|
|
@@ -409,7 +409,7 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- convertToArrayFormat(data) {
|
|
|
+ convertToArrayFormat(data, type) {
|
|
|
const result = [];
|
|
|
Object.keys(data.productMap).forEach(key => {
|
|
|
console.log('key!!!', key);
|
|
|
@@ -425,31 +425,35 @@
|
|
|
amountTotalPrice: amountTotalPrice,
|
|
|
defaultAmountTotalPrice: defaultAmountTotalPrice,
|
|
|
...detail,
|
|
|
- invoiceAmount: '',
|
|
|
+ invoiceAmount: detail.invoiceAmount || 0,
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ if(type == 'setValue') {
|
|
|
+ // Allocate defaultAmountTotalPrice to invoiceAmount for each key group
|
|
|
+ const uniqueKeys = [...new Set(result.map(item => item.key))];
|
|
|
+ uniqueKeys.forEach(key => {
|
|
|
+ const sameKeyItems = result.filter(item => item.key === key);
|
|
|
+ if (sameKeyItems.length > 0) {
|
|
|
+ const defaultAmountTotalPrice = parseFloat(sameKeyItems[0].defaultAmountTotalPrice) || 0;
|
|
|
+ let remainingTotal = defaultAmountTotalPrice;
|
|
|
+
|
|
|
+ sameKeyItems.forEach(item => {
|
|
|
+ if (remainingTotal <= 0) {
|
|
|
+ item.invoiceAmount = 0;
|
|
|
+ } else {
|
|
|
+ const unInvoiceAmount = parseFloat(item.unInvoiceAmount) || 0;
|
|
|
+ const allocateAmount = Math.min(remainingTotal, unInvoiceAmount);
|
|
|
+ item.invoiceAmount = allocateAmount.toFixed(2);
|
|
|
+ remainingTotal -= allocateAmount;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
- // Allocate defaultAmountTotalPrice to invoiceAmount for each key group
|
|
|
- const uniqueKeys = [...new Set(result.map(item => item.key))];
|
|
|
- uniqueKeys.forEach(key => {
|
|
|
- const sameKeyItems = result.filter(item => item.key === key);
|
|
|
- if (sameKeyItems.length > 0) {
|
|
|
- const defaultAmountTotalPrice = parseFloat(sameKeyItems[0].defaultAmountTotalPrice) || 0;
|
|
|
- let remainingTotal = defaultAmountTotalPrice;
|
|
|
-
|
|
|
- sameKeyItems.forEach(item => {
|
|
|
- if (remainingTotal <= 0) {
|
|
|
- item.invoiceAmount = 0;
|
|
|
- } else {
|
|
|
- const unInvoiceAmount = parseFloat(item.unInvoiceAmount) || 0;
|
|
|
- const allocateAmount = Math.min(remainingTotal, unInvoiceAmount);
|
|
|
- item.invoiceAmount = allocateAmount.toFixed(2);
|
|
|
- remainingTotal -= allocateAmount;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
|
|
|
return result;
|
|
|
},
|
|
|
@@ -532,7 +536,7 @@
|
|
|
putValue(data) {
|
|
|
let tempData = JSON.parse(JSON.stringify(data));
|
|
|
console.log('tableInfoNew putValue', tempData);
|
|
|
- tempData.detailList = this.convertToArrayFormat(tempData);
|
|
|
+ tempData.detailList = this.convertToArrayFormat(tempData, 'putValue');
|
|
|
console.log('data.detailList', data.detailList);
|
|
|
this.tableForm = tempData;
|
|
|
console.log('tableInfoNew putValue~~~', this.tableForm);
|