From ffc2942d2b32d4a672d4df168bb11f07f418beff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B3=89=E4=BD=B3?= <1107186916@qq.com> Date: Thu, 5 Nov 2026 13:25:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=98=E6=AC=BE=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=8D=95=E5=8F=B7=E8=AF=AF=E8=B7=B3=E9=A2=84?= =?UTF-8?q?=E4=BB=98=E7=BB=93=E7=AE=97=E5=8D=95=E8=BF=87=E6=BB=A4-1?= =?UTF-8?q?=E5=8D=A0=E4=BD=8Did?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/payment-application-form.vue | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/src/views/payment/payment-application-form.vue b/src/views/payment/payment-application-form.vue index 0a01f1c..f93c25f 100644 --- a/src/views/payment/payment-application-form.vue +++ b/src/views/payment/payment-application-form.vue @@ -1296,9 +1296,11 @@ export default { this.form = { ...emptyForm(), ...data, + // 后端可能返回 -1 占位预付 id,统一归一为 null,防止点击结算单号误跳预付 + preSettlementId: this.isValidReferenceId(data.preSettlementId) ? data.preSettlementId : null, preSettlementIds: data.preSettlementIds?.length ? data.preSettlementIds - : data.preSettlementId + : this.isValidReferenceId(data.preSettlementId) ? [data.preSettlementId] : [], attachments: this.parse(data.attachmentsJson), @@ -1344,9 +1346,13 @@ export default { this.form = { ...emptyForm(), ...data, + // 后端可能返回 -1 占位预付 id,统一归一为 null,防止点击结算单号误跳预付 + preSettlementId: this.isValidReferenceId(data.preSettlementId) + ? data.preSettlementId + : null, preSettlementIds: data.preSettlementIds?.length ? data.preSettlementIds - : data.preSettlementId + : this.isValidReferenceId(data.preSettlementId) ? [data.preSettlementId] : [], attachments: this.parse(data.attachmentsJson), @@ -1587,17 +1593,22 @@ export default { }); }, clearFormalReferenceWhenPreOnly() { + // 纯预付引用才收敛为预付;-1 占位 id 不得充当预付关联 const progressAdvance = this.form.paymentType === 'progress_advance'; const onlyPre = progressAdvance || (this.referenceRows.length > 0 && this.referenceRows.every(item => item.referenceType === 'pre')); if (!onlyPre) return; - if (!this.form.preSettlementId) { + if (!this.isValidReferenceId(this.form.preSettlementId)) { const preId = - this.referenceRows.find(item => item.referenceType === 'pre')?.id || - (progressAdvance ? this.form.settlementId : null); - if (preId) { + this.referenceRows.find( + item => item.referenceType === 'pre' && this.isValidReferenceId(item.id) + )?.id || + (progressAdvance && this.isValidReferenceId(this.form.settlementId) + ? this.form.settlementId + : null); + if (this.isValidReferenceId(preId)) { this.form.preSettlementId = preId; this.form.preSettlementIds = [preId]; } @@ -1608,13 +1619,16 @@ export default { }, restoreReferenceRows(data, fallbackRow) { const relations = Array.isArray(data?.settlements) ? data.settlements : []; + // 行级预付/正式类型以过滤占位 id 后的关联为准,决定点击结算单号的跳转目标 const rows = relations .map(item => { - const isPre = Boolean(item.preSettlementId || item.preSettlementNo); + // 后端用 -1 占位空 id,必须先过滤再判预付,否则正式结算行会被误标为预付 + const preId = this.isValidReferenceId(item.preSettlementId) ? item.preSettlementId : null; + const isPre = Boolean(preId || item.preSettlementNo); const settlementNo = item.preSettlementNo || item.formalSettlementNo || ''; if (!settlementNo) return null; return { - id: isPre ? item.preSettlementId || item.formalSettlementId : item.formalSettlementId, + id: isPre ? preId || item.formalSettlementId : item.formalSettlementId, settlementNo, referenceType: isPre ? 'pre' : 'formal', settlementAmount: Number(Number(item.settlementAmount || 0).toFixed(2)), @@ -1642,9 +1656,10 @@ export default { }, createReferenceRow(row) { const settlementAmount = Number(row.settlementAmount || 0); + // 后端以 -1 占位空预付 id,必须先校验否则正式结算行会被误判为预付 const isPre = Boolean( row.preSettlementNo || - row.preSettlementId || + this.isValidReferenceId(row.preSettlementId) || row.referenceType === 'pre' || row.paymentType === 'progress_advance' ); @@ -2770,23 +2785,26 @@ export default { }, async openSettlementDetail(row = {}) { const settlementNo = String(row.settlementNo || '').trim(); + // 行上 referenceType 优先;发票行等只带单号的,按单号回查引用行;都缺省才回落表单级推断 + const matchedReference = this.referenceRows.find( + item => String(item.settlementNo || '').trim() === settlementNo + ); + const referenceType = row.referenceType || matchedReference?.referenceType; const isPre = - row.referenceType === 'pre' || - this.form.paymentType === 'progress_advance' || - Boolean(this.form.preSettlementId || this.form.preSettlementNo); + referenceType === 'pre' || + (!referenceType && + (this.form.paymentType === 'progress_advance' || + Boolean( + this.isValidReferenceId(this.form.preSettlementId) || this.form.preSettlementNo + ))); let id = row.id || row.preSettlementId || row.settlementId || + matchedReference?.id || (isPre ? this.form.preSettlementId || this.form.preSettlementIds?.[0] : this.form.settlementId || this.form.settlementIds?.[0]); - if (!id && settlementNo) { - const matched = this.referenceRows.find( - item => String(item.settlementNo || '').trim() === settlementNo - ); - id = matched?.id; - } if (!id && settlementNo) { try { const listApi = isPre ? preApi.getList : formalApi.getList;