| | |
| | | specificationModel: row.specificationModel || "", |
| | | pendingInvoiceTotal: Number(row.pendingInvoiceTotal || 0), |
| | | taxRate: row.taxRate ?? "", |
| | | receiptPaymentAmount: "", |
| | | // 默认本次回款金额 = 待回款金额 |
| | | receiptPaymentAmount: Number(row.pendingInvoiceTotal || 0), |
| | | receiptPaymentType: "", |
| | | registrant: userStore.nickName, |
| | | receiptPaymentDate: "", |
| | |
| | | |
| | | // 保存回款记录 |
| | | const saveReceiptPayment = (row) => { |
| | | // 子表回款金额合计校验:所有回款记录金额之和不能大于父数据合同金额 |
| | | // 这里父数据“合同金额”按:已回款金额( invoiceTotal ) + 待回款金额( pendingInvoiceTotal ) 计算 |
| | | const findParentRowByChildId = (childId) => { |
| | | return tableData.value.find((p) => |
| | | Array.isArray(p.children) && p.children.some((c) => c.id === childId) |
| | | ); |
| | | }; |
| | | const parentRow = findParentRowByChildId(row.id); |
| | | if (parentRow) { |
| | | const contractAmount = |
| | | Number(parentRow.invoiceTotal || 0) + Number(parentRow.pendingInvoiceTotal || 0); |
| | | const sumReceipt = (parentRow.children || []).reduce((sum, item) => { |
| | | const val = Number(item?.receiptPaymentAmount ?? 0); |
| | | return sum + (Number.isFinite(val) ? val : 0); |
| | | }, 0); |
| | | if (sumReceipt > contractAmount) { |
| | | proxy.$modal.msgError( |
| | | `回款金额合计(${sumReceipt.toFixed(2)})不能大于合同金额(${contractAmount.toFixed(2)})` |
| | | ); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | let updateData = { |
| | | id: row.id, |
| | | receiptPaymentType: row.receiptPaymentType, |