|
@@ -94,8 +94,10 @@
|
|
|
return {
|
|
return {
|
|
|
businessId: '',
|
|
businessId: '',
|
|
|
fullscreen: false,
|
|
fullscreen: false,
|
|
|
|
|
+ saveLoading: false,
|
|
|
datasource: [],
|
|
datasource: [],
|
|
|
recorpayList: [],
|
|
recorpayList: [],
|
|
|
|
|
+ statPayable: null,
|
|
|
// 应付信息初始明细(查询/编辑回填),由 payablesInfo 本地维护,提交时取回
|
|
// 应付信息初始明细(查询/编辑回填),由 payablesInfo 本地维护,提交时取回
|
|
|
payablesList: [],
|
|
payablesList: [],
|
|
|
dataForm: {
|
|
dataForm: {
|
|
@@ -156,17 +158,26 @@
|
|
|
async getInfo(row) {
|
|
async getInfo(row) {
|
|
|
let data = await accountstatementInfoAPI(row.id);
|
|
let data = await accountstatementInfoAPI(row.id);
|
|
|
// this.recorpayList = data.recorpayList || [];
|
|
// this.recorpayList = data.recorpayList || [];
|
|
|
- data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100;
|
|
|
|
|
- data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100;
|
|
|
|
|
- data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementedAmount * 100), 0) / 100;
|
|
|
|
|
- data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
|
|
|
|
|
- this.datasource = data.orderList || [];
|
|
|
|
|
- // 编辑详情回填应付信息(兼容 payablesList / statPayable 两种字段)
|
|
|
|
|
|
|
+ // data.orderTotalAmount = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.orderAmount * 100), 0) / 100;
|
|
|
|
|
+ // data.amountTotalPrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementAmount * 100), 0) / 100;
|
|
|
|
|
+ // data.amountCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.statementedAmount * 100), 0) / 100;
|
|
|
|
|
+ // data.amountUnCompletePrice = data.orderList.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100;
|
|
|
|
|
+ // this.datasource = data.orderList || [];
|
|
|
|
|
+ // // 编辑详情回填应付信息(兼容 payablesList / statPayable 两种字段)
|
|
|
|
|
+
|
|
|
|
|
+ // this.dataForm = data;
|
|
|
|
|
+
|
|
|
|
|
+ this.datasource = data.productList || [];
|
|
|
|
|
+
|
|
|
this.payablesList =
|
|
this.payablesList =
|
|
|
- data.payablesList ||
|
|
|
|
|
(data.statPayable && data.statPayable.statPayableDetailList) ||
|
|
(data.statPayable && data.statPayable.statPayableDetailList) ||
|
|
|
[];
|
|
[];
|
|
|
- this.dataForm = data;
|
|
|
|
|
|
|
+ // 保存查询到的完整 statPayable 对象,作为提交入参
|
|
|
|
|
+ this.statPayable = data.statPayable || null;
|
|
|
|
|
+ this.dataForm = {
|
|
|
|
|
+ ...this.dataForm,
|
|
|
|
|
+ ...data,
|
|
|
|
|
+ };
|
|
|
switch (this.dataForm.dateType) {
|
|
switch (this.dataForm.dateType) {
|
|
|
case 1:
|
|
case 1:
|
|
|
this.$set(this.dataForm,'year',this.dataForm.dateValue)
|
|
this.$set(this.dataForm,'year',this.dataForm.dateValue)
|
|
@@ -210,9 +221,10 @@
|
|
|
// this.recorpayList = data.recorpayList || [];
|
|
// this.recorpayList = data.recorpayList || [];
|
|
|
this.datasource = data.productList || [];
|
|
this.datasource = data.productList || [];
|
|
|
// 查询接口暂未返回预付信息时,先置空(由 payablesInfo 本地维护)
|
|
// 查询接口暂未返回预付信息时,先置空(由 payablesInfo 本地维护)
|
|
|
- this.payablesList = data.payablesList ||
|
|
|
|
|
|
|
+ this.payablesList =
|
|
|
(data.statPayable && data.statPayable.statPayableDetailList) ||
|
|
(data.statPayable && data.statPayable.statPayableDetailList) ||
|
|
|
[];
|
|
[];
|
|
|
|
|
+ this.statPayable = data.statPayable || null;
|
|
|
this.dataForm = {
|
|
this.dataForm = {
|
|
|
...this.dataForm,
|
|
...this.dataForm,
|
|
|
...data
|
|
...data
|
|
@@ -226,42 +238,59 @@
|
|
|
// amountCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementedAmount * 100), 0) / 100,
|
|
// amountCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.statementedAmount * 100), 0) / 100,
|
|
|
// amountUnCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100
|
|
// amountUnCompletePrice: data.reduce((pre, cur) => pre + Math.round(+cur.unStatementAmount * 100), 0) / 100
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
// if (!this.datasource.length) this.$message.warning('暂无订单信息');
|
|
// if (!this.datasource.length) this.$message.warning('暂无订单信息');
|
|
|
},
|
|
},
|
|
|
//保存
|
|
//保存
|
|
|
async save(is) {
|
|
async save(is) {
|
|
|
- if (!this.datasource.length && !this.recorpayList.length && !this.payablesList.length)
|
|
|
|
|
- return this.$message.warning('暂无对账信息');
|
|
|
|
|
|
|
+ if (!this.datasource.length)
|
|
|
|
|
+ return this.$message.warning('暂无对账信息');
|
|
|
|
|
|
|
|
- let api =
|
|
|
|
|
- this.dialogType == 'add'
|
|
|
|
|
- ? createAccountStatementAPI
|
|
|
|
|
- : accountstatementUpdateAPI;
|
|
|
|
|
- // 提交时一次性取回应付信息(本地明细 + 汇总)
|
|
|
|
|
- const payablesData = this.$refs.payablesInfoRef
|
|
|
|
|
- ? this.$refs.payablesInfoRef.getSubmitData()
|
|
|
|
|
- : { payablesList: [], statementAdvanceTotalPrice: 0, receivedTotalPrice: 0 };
|
|
|
|
|
- let params = {
|
|
|
|
|
- ...this.dataForm,
|
|
|
|
|
- orderList: this.datasource,
|
|
|
|
|
- recorpayList: this.recorpayList,
|
|
|
|
|
- payablesList: payablesData.payablesList,
|
|
|
|
|
- totalAdvanceConfirmAmount: payablesData.statementAdvanceTotalPrice,
|
|
|
|
|
- totalPayableAmount: payablesData.receivedTotalPrice
|
|
|
|
|
- };
|
|
|
|
|
- let data = await api(params);
|
|
|
|
|
- if (is == 'sub') {
|
|
|
|
|
- await this.submit(data);
|
|
|
|
|
- return;
|
|
|
|
|
- // await submitAccountStatementApproveAPI(
|
|
|
|
|
- // {
|
|
|
|
|
- // businessId: data,
|
|
|
|
|
- // type: this.dataForm.type
|
|
|
|
|
- // }
|
|
|
|
|
- // )
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 校验明细表与应付信息表单
|
|
|
|
|
+ await this.$refs.accountDetailTableRef.getValidForm();
|
|
|
|
|
+ await this.$refs.payablesInfoRef.validate();
|
|
|
|
|
+
|
|
|
|
|
+ let api =
|
|
|
|
|
+ this.dialogType == 'add'
|
|
|
|
|
+ ? createAccountStatementAPI
|
|
|
|
|
+ : accountstatementUpdateAPI;
|
|
|
|
|
+ // 提交时一次性取回应付信息(本地明细 + 汇总),不再实时回写
|
|
|
|
|
+ const payablesData = this.$refs.payablesInfoRef.getSubmitData();
|
|
|
|
|
+ // statPayable 为完整数据容器,保存时以它为基准组装应付明细与汇总
|
|
|
|
|
+ const statPayable = {
|
|
|
|
|
+ statPayableDetailList: payablesData.payablesList,
|
|
|
|
|
+ statementAdvanceTotalPrice:
|
|
|
|
|
+ payablesData.statementAdvanceTotalPrice,
|
|
|
|
|
+ receivedTotalPrice: payablesData.receivedTotalPrice
|
|
|
|
|
+ };
|
|
|
|
|
+ this.statPayable = statPayable;
|
|
|
|
|
+
|
|
|
|
|
+ const statementAdvanceTotalPrice =
|
|
|
|
|
+ payablesData.statementAdvanceTotalPrice;
|
|
|
|
|
+ const receivedTotalPrice = payablesData.receivedTotalPrice;
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ ...this.dataForm,
|
|
|
|
|
+ statementAdvanceTotalPrice,
|
|
|
|
|
+ receivedTotalPrice,
|
|
|
|
|
+ totalAdvanceConfirmAmount: statementAdvanceTotalPrice,
|
|
|
|
|
+ totalPayableAmount: receivedTotalPrice,
|
|
|
|
|
+ productList: this.datasource,
|
|
|
|
|
+ statPayable
|
|
|
|
|
+ };
|
|
|
|
|
+ this.saveLoading = true;
|
|
|
|
|
+ let data = await api(params);
|
|
|
|
|
+ if (is == 'sub') {
|
|
|
|
|
+ await this.submit(data);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.$message.success('操作成功');
|
|
|
|
|
+ this.reload();
|
|
|
|
|
+ this.saveLoading = false;
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('保存失败:', error);
|
|
|
|
|
+ this.saveLoading = false;
|
|
|
}
|
|
}
|
|
|
- this.$message.success('操作成功');
|
|
|
|
|
- this.reload();
|
|
|
|
|
},
|
|
},
|
|
|
async submit(res) {
|
|
async submit(res) {
|
|
|
let data = await accountstatementInfoAPI(this.businessId || res);
|
|
let data = await accountstatementInfoAPI(this.businessId || res);
|