|
@@ -351,8 +351,9 @@
|
|
|
methods: {
|
|
methods: {
|
|
|
convertToArrayFormat(data) {
|
|
convertToArrayFormat(data) {
|
|
|
return Object.keys(data.productMap).map(key => {
|
|
return Object.keys(data.productMap).map(key => {
|
|
|
- console.log('key', key);
|
|
|
|
|
|
|
+ console.log('key!!!', key);
|
|
|
const paymentItem = data.receiptPayments?.filter(item => item?.relatedOrderNo == key)|| [];
|
|
const paymentItem = data.receiptPayments?.filter(item => item?.relatedOrderNo == key)|| [];
|
|
|
|
|
+ console.log('paymentItem', paymentItem);
|
|
|
return {
|
|
return {
|
|
|
key: key,
|
|
key: key,
|
|
|
amountTotalPrice: paymentItem.length ? paymentItem.reduce((acc, cur) => acc + cur.invoiceAmount, 0) : 0,
|
|
amountTotalPrice: paymentItem.length ? paymentItem.reduce((acc, cur) => acc + cur.invoiceAmount, 0) : 0,
|
|
@@ -374,8 +375,8 @@
|
|
|
sum += Number(r.invoiceAmount);
|
|
sum += Number(r.invoiceAmount);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- if(val && +val > +this.tableForm.detailList[idx].details[index].discountAmount) {
|
|
|
|
|
- this.$message.error('物品开票金额不能大于折让合计');
|
|
|
|
|
|
|
+ if(val && +val > +this.tableForm.detailList[idx].details[index].unInvoiceAmount) {
|
|
|
|
|
+ this.$message.error('物品开票金额不能大于未开票金额');
|
|
|
this.$set(this.tableForm.detailList[idx].details[index], 'invoiceAmount', '');
|
|
this.$set(this.tableForm.detailList[idx].details[index], 'invoiceAmount', '');
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -449,9 +450,12 @@
|
|
|
this.setSelectData(row);
|
|
this.setSelectData(row);
|
|
|
},
|
|
},
|
|
|
putValue(data) {
|
|
putValue(data) {
|
|
|
- console.log('tableInfoNew putValue', data);
|
|
|
|
|
- data.detailList = this.convertToArrayFormat(data);
|
|
|
|
|
- this.tableForm = data;
|
|
|
|
|
|
|
+ let tempData = JSON.parse(JSON.stringify(data));
|
|
|
|
|
+ console.log('tableInfoNew putValue', tempData);
|
|
|
|
|
+ tempData.detailList = this.convertToArrayFormat(tempData);
|
|
|
|
|
+ console.log('data.detailList', data.detailList);
|
|
|
|
|
+ this.tableForm = tempData;
|
|
|
|
|
+ console.log('tableInfoNew putValue~~~', this.tableForm);
|
|
|
},
|
|
},
|
|
|
setValue(data) {
|
|
setValue(data) {
|
|
|
let tempData = JSON.parse(JSON.stringify(data));
|
|
let tempData = JSON.parse(JSON.stringify(data));
|
|
@@ -485,7 +489,7 @@
|
|
|
// this.$refs.table.reload();
|
|
// this.$refs.table.reload();
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
|
- * 分配开票金额到明细项(根据discountAmount限制)
|
|
|
|
|
|
|
+ * 分配开票金额到明细项(根据未开票金额unInvoiceAmount限制)
|
|
|
* @param {Array|Object} data - 明细列表或单个明细对象
|
|
* @param {Array|Object} data - 明细列表或单个明细对象
|
|
|
* @returns {Array|Object} 处理后的数据
|
|
* @returns {Array|Object} 处理后的数据
|
|
|
*/
|
|
*/
|
|
@@ -503,15 +507,15 @@
|
|
|
// 剩余金额为0,分配0
|
|
// 剩余金额为0,分配0
|
|
|
detail.invoiceAmount = 0;
|
|
detail.invoiceAmount = 0;
|
|
|
} else {
|
|
} else {
|
|
|
- // 获取当前明细的discountAmount
|
|
|
|
|
- const discountAmount = Number(detail.discountAmount) || 0;
|
|
|
|
|
|
|
+ // 获取当前明细的unInvoiceAmount
|
|
|
|
|
+ const unInvoiceAmount = Number(detail.unInvoiceAmount) || 0;
|
|
|
|
|
|
|
|
- if (remainingTotal > discountAmount) {
|
|
|
|
|
- // 剩余金额大于discountAmount,分配discountAmount
|
|
|
|
|
- detail.invoiceAmount = discountAmount;
|
|
|
|
|
- remainingTotal -= discountAmount;
|
|
|
|
|
|
|
+ if (remainingTotal > unInvoiceAmount) {
|
|
|
|
|
+ // 剩余金额大于unInvoiceAmount,分配unInvoiceAmount
|
|
|
|
|
+ detail.invoiceAmount = unInvoiceAmount;
|
|
|
|
|
+ remainingTotal -= unInvoiceAmount;
|
|
|
} else {
|
|
} else {
|
|
|
- // 剩余金额小于等于discountAmount,分配剩余金额
|
|
|
|
|
|
|
+ // 剩余金额小于等于unInvoiceAmount,分配剩余金额
|
|
|
detail.invoiceAmount = remainingTotal;
|
|
detail.invoiceAmount = remainingTotal;
|
|
|
remainingTotal = 0;
|
|
remainingTotal = 0;
|
|
|
}
|
|
}
|
|
@@ -531,15 +535,15 @@
|
|
|
// 剩余金额为0,分配0
|
|
// 剩余金额为0,分配0
|
|
|
detail.invoiceAmount = 0;
|
|
detail.invoiceAmount = 0;
|
|
|
} else {
|
|
} else {
|
|
|
- // 获取当前明细的discountAmount
|
|
|
|
|
- const discountAmount = Number(detail.discountAmount) || 0;
|
|
|
|
|
|
|
+ // 获取当前明细的unInvoiceAmount
|
|
|
|
|
+ const unInvoiceAmount = Number(detail.unInvoiceAmount) || 0;
|
|
|
|
|
|
|
|
- if (remainingTotal > discountAmount) {
|
|
|
|
|
- // 剩余金额大于discountAmount,分配discountAmount
|
|
|
|
|
- detail.invoiceAmount = discountAmount;
|
|
|
|
|
- remainingTotal -= discountAmount;
|
|
|
|
|
|
|
+ if (remainingTotal > unInvoiceAmount) {
|
|
|
|
|
+ // 剩余金额大于unInvoiceAmount,分配unInvoiceAmount
|
|
|
|
|
+ detail.invoiceAmount = unInvoiceAmount;
|
|
|
|
|
+ remainingTotal -= unInvoiceAmount;
|
|
|
} else {
|
|
} else {
|
|
|
- // 剩余金额小于等于discountAmount,分配剩余金额
|
|
|
|
|
|
|
+ // 剩余金额小于等于unInvoiceAmount,分配剩余金额
|
|
|
detail.invoiceAmount = remainingTotal;
|
|
detail.invoiceAmount = remainingTotal;
|
|
|
remainingTotal = 0;
|
|
remainingTotal = 0;
|
|
|
}
|
|
}
|
|
@@ -556,7 +560,7 @@
|
|
|
// let detail = this.tableForm.detailList[index];
|
|
// let detail = this.tableForm.detailList[index];
|
|
|
// console.log('tableInfoNew setPrice', row, data, index);
|
|
// console.log('tableInfoNew setPrice', row, data, index);
|
|
|
const paymentItem = data.filter(item => item?.relatedOrderNo == row.relatedOrderNo);
|
|
const paymentItem = data.filter(item => item?.relatedOrderNo == row.relatedOrderNo);
|
|
|
- // console.log('tableInfoNew paymentItem', paymentItem);
|
|
|
|
|
|
|
+ console.log('tableInfoNew~~~', this.tableForm.detailList[index]);
|
|
|
this.tableForm.detailList[index].amountTotalPrice = paymentItem.length ? paymentItem.reduce((acc, cur) => acc + +cur.invoiceAmount, 0) : 0;
|
|
this.tableForm.detailList[index].amountTotalPrice = paymentItem.length ? paymentItem.reduce((acc, cur) => acc + +cur.invoiceAmount, 0) : 0;
|
|
|
this.tableForm.detailList[index].defaultAmountTotalPrice = paymentItem.length ? paymentItem.reduce((acc, cur) => acc + +cur.invoiceAmount, 0) : 0;
|
|
this.tableForm.detailList[index].defaultAmountTotalPrice = paymentItem.length ? paymentItem.reduce((acc, cur) => acc + +cur.invoiceAmount, 0) : 0;
|
|
|
// console.log('tableInfoNew tableForm', this.tableForm.detailList);
|
|
// console.log('tableInfoNew tableForm', this.tableForm.detailList);
|