|
@@ -13,6 +13,7 @@
|
|
|
:select="true"
|
|
|
:usePage="false"
|
|
|
@handleSelect="toSelect"
|
|
|
+ rowkey="_id"
|
|
|
>
|
|
|
<template #options="{item}">
|
|
|
<template v-if="item.model == 'client'">
|
|
@@ -26,6 +27,15 @@
|
|
|
</data-table>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
+
|
|
|
+ <el-dialog title="是否结算" :visible.sync="dialog" :destroy-on-close="true" @close="toClose">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24">若要结算,可以填写该结算单的标题及备注,以便以后查看可以快速找到结算单</el-col>
|
|
|
+ <el-col :span="24">
|
|
|
+ <data-form v-model="form" :fields="efields" @save="toJs"></data-form>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -43,6 +53,7 @@ export default {
|
|
|
components: {},
|
|
|
data: function() {
|
|
|
return {
|
|
|
+ dialog: false,
|
|
|
fields: [
|
|
|
{ label: '供应商', model: 'client', notable: true, filter: 'select' },
|
|
|
{ label: '第三方车号', model: 'car_no', notable: true, filter: true },
|
|
@@ -50,17 +61,30 @@ export default {
|
|
|
{ label: '发货时间', model: 'send_time' },
|
|
|
{ label: '订单号', model: 'order_nos' },
|
|
|
{ label: '线路', model: 'route' },
|
|
|
- { label: '货物', model: 'goods', format: i => i.map(g => g.name).join(';') },
|
|
|
- { label: '运费(不含税)', model: 't_sq_ys' },
|
|
|
+ {
|
|
|
+ label: '货物',
|
|
|
+ model: 'goods',
|
|
|
+ format: i => {
|
|
|
+ if (i) return i.map(g => g.name).join(';');
|
|
|
+ },
|
|
|
+ },
|
|
|
+ { label: '费用类型', model: 'cost_item' },
|
|
|
+ { label: '金额(不含税)', model: 'sq_ys' },
|
|
|
{ label: '税率', model: 'taxes' },
|
|
|
- { label: '运费税后', model: 't_sh_ys' },
|
|
|
+ { label: '税后金额', model: 'sh_ys' },
|
|
|
],
|
|
|
list: [],
|
|
|
total: 0,
|
|
|
//选择的数据列表
|
|
|
selected: [],
|
|
|
clientList: [],
|
|
|
- client: undefined, //选择的客户
|
|
|
+ searchData: {},
|
|
|
+
|
|
|
+ form: {},
|
|
|
+ efields: [
|
|
|
+ { label: '标题', model: 'title' },
|
|
|
+ { label: '备注', model: 'remark', type: 'textarea', options: { autosize: { maxRows: 5, minRows: 3 } } },
|
|
|
+ ],
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -70,33 +94,68 @@ export default {
|
|
|
...transport(['supplierCalculate', 'supplierExport', 'js']),
|
|
|
...client({ getClientList: 'query' }),
|
|
|
async search(data) {
|
|
|
- const { client } = data;
|
|
|
- this.$set(this, `client`, client);
|
|
|
+ this.$set(this, 'searchData', data);
|
|
|
const res = await this.supplierCalculate(data);
|
|
|
+ console.log(res);
|
|
|
if (this.$checkRes(res)) this.$set(this, `list`, res.data);
|
|
|
},
|
|
|
//选中的数据
|
|
|
toSelect(data) {
|
|
|
+ console.log(data);
|
|
|
this.selected = data;
|
|
|
},
|
|
|
//导出
|
|
|
async toExport() {
|
|
|
- const ids = this.selected.map(i => i._id);
|
|
|
- const res = await this.supplierExport({ ids });
|
|
|
- if (this.$checkRes(res)) window.open(res);
|
|
|
- this.$confirm('是否结算选择的订单?', '结算提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- }).then(async () => {
|
|
|
- const jsRes = await this.js({ ids, client: this.client, owner: this.user.id });
|
|
|
- if (this.$checkRes(jsRes, '结算成功', '结算失败')) {
|
|
|
- this.$refs.table.selectReset();
|
|
|
- this.list = [];
|
|
|
- this.selected = [];
|
|
|
- }
|
|
|
- });
|
|
|
+ // 需要将运费支出与其他支出分到2个字段
|
|
|
+ // ids仍然是运输表的
|
|
|
+ const ids = _.compact(
|
|
|
+ this.selected.map(i => {
|
|
|
+ if (i.supplier) return i._id;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ // 订单支出部分,根据运输方字段是否存在来区分
|
|
|
+ const outOrderIds = _.compact(
|
|
|
+ this.selected.map(i => {
|
|
|
+ if (!i.supplier) return i.order_id;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ // 将客户id/车号也传过去,这里只能有一个,因为查询时限制其只能有一个
|
|
|
+ const obj = _.pickBy(this.searchData, (value, key) => (key === 'client' || key === 'car_no') && value);
|
|
|
+ const res = await this.supplierExport({ ids, outOrderIds, ...obj });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ window.open(res);
|
|
|
+ this.dialog = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ async toJs() {
|
|
|
+ let dup = _.cloneDeep(this.form);
|
|
|
+ dup.ids = _.compact(
|
|
|
+ this.selected.map(i => {
|
|
|
+ if (i.supplier) return i._id;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ dup.outOrderIds = _.compact(
|
|
|
+ this.selected.map(i => {
|
|
|
+ if (!i.supplier) return i.order_id;
|
|
|
+ })
|
|
|
+ );
|
|
|
+ dup.owner = this.user.id;
|
|
|
+ dup = { ...dup, ..._.pickBy(this.searchData, (value, key) => (key === 'client' || key === 'car_no') && value) };
|
|
|
+ const jsRes = await this.js(dup);
|
|
|
+ if (this.$checkRes(jsRes, '结算成功', '结算失败')) {
|
|
|
+ this.toClose();
|
|
|
+ this.$refs.table.selectReset();
|
|
|
+ this.list = [];
|
|
|
+ this.selected = [];
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ toClose() {
|
|
|
+ this.dialog = false;
|
|
|
+ this.form = {};
|
|
|
},
|
|
|
+
|
|
|
async getOtherList() {
|
|
|
const cRes = await this.getClientList({ type: '供应商' });
|
|
|
if (this.$checkRes(cRes)) this.$set(this, `clientList`, cRes.data);
|