|
|
@@ -802,8 +802,11 @@
|
|
|
//合同回调
|
|
|
async changeContract(data) {
|
|
|
console.log('changeOrder~~~', data);
|
|
|
- const tempIds = data.map((item) => item.id);
|
|
|
- const tempNames = data.map((item) => item.contractNo);
|
|
|
+ // 子组件在单选/多选路径下 emit 的形态不一致,归一化为数组
|
|
|
+ const list = Array.isArray(data) ? data : data ? [data] : [];
|
|
|
+ if (!list.length) return;
|
|
|
+ const tempIds = list.map((item) => item.id);
|
|
|
+ const tempNames = list.map((item) => item.contractNo);
|
|
|
this.getPlanData(tempIds, tempNames);
|
|
|
// const res = await getDetail(data.id);
|
|
|
// this.$set(this.form, 'sourceId', data.id);
|
|
|
@@ -897,8 +900,11 @@
|
|
|
//订单回调
|
|
|
async changeOrder(data) {
|
|
|
console.log('changeOrder~~~', data);
|
|
|
- const tempIds = data.map((item) => item.id);
|
|
|
- const tempNames = data.map((item) => item.orderNo);
|
|
|
+ // 子组件在单选/多选路径下 emit 的形态不一致,归一化为数组
|
|
|
+ const list = Array.isArray(data) ? data : data ? [data] : [];
|
|
|
+ if (!list.length) return;
|
|
|
+ const tempIds = list.map((item) => item.id);
|
|
|
+ const tempNames = list.map((item) => item.orderNo);
|
|
|
this.getPlanData(tempIds, tempNames);
|
|
|
// this.$set(this.form, 'sourceId', data.id);
|
|
|
// this.$set(this.form, 'sourceCode', data.orderNo);
|
|
|
@@ -1182,9 +1188,23 @@
|
|
|
|
|
|
invoiceAmountChange(item, sum) {
|
|
|
console.log('item~~~', item, sum);
|
|
|
- const sameKeyItems = this.form.relatedList.filter((d) => d.sourceCode === item.key)
|
|
|
+ const sameKeyItems = this.form.relatedList.filter((d) => d.sourceCode === item.key);
|
|
|
console.log('sameKeyItems~~~', sameKeyItems);
|
|
|
-
|
|
|
+
|
|
|
+ // 从关联物品清单中取该订单的"未开票金额"和"本次开票金额"(per-detail 字段)
|
|
|
+ const tableInfoRef = this.$refs.tableInfoRef;
|
|
|
+ let unInvoiceAmount = 0;
|
|
|
+ let invoiceAmount = 0;
|
|
|
+ if (tableInfoRef && tableInfoRef.tableForm && tableInfoRef.tableForm.detailList) {
|
|
|
+ const matchedDetail = tableInfoRef.tableForm.detailList.find(
|
|
|
+ (d) => d.key === item.key
|
|
|
+ );
|
|
|
+ if (matchedDetail) {
|
|
|
+ unInvoiceAmount = parseFloat(matchedDetail.unInvoiceAmount) || 0;
|
|
|
+ invoiceAmount = parseFloat(matchedDetail.invoiceAmount) || 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let remainingTotal = sum;
|
|
|
const lastIndex = sameKeyItems.length - 1;
|
|
|
|
|
|
@@ -1202,6 +1222,13 @@
|
|
|
remainingTotal -= allocateAmount;
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ // 来源清单的未开票金额 = 关联物品清单的未开票金额 - 本次开票金额
|
|
|
+ const remainingUnInvoice = (unInvoiceAmount - invoiceAmount).toFixed(2);
|
|
|
+ sameKeyItems.forEach((paymentItem) => {
|
|
|
+ this.$set(paymentItem, 'unInvoiceAmount', remainingUnInvoice);
|
|
|
+ });
|
|
|
+
|
|
|
this.updateInvoiceAmount();
|
|
|
console.log('分配完成后的 sameKeyItems:', sameKeyItems);
|
|
|
},
|