From 6f4c656bef3ce2b727848895e288a5fb000cba86 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 19 Oct 2026 18:54:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=BC=96=E8=BE=91=E6=8A=A5=E4=BB=B7?= =?UTF-8?q?=E5=8D=95):=20=E6=9C=AC=E5=8D=95=E5=AE=A2=E6=88=B7=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=B8=BA=E7=A9=BA=E6=97=B6=E5=9B=9E=E9=80=80=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E8=AF=B7=E6=B1=82=E5=AE=A2=E6=88=B7=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=20500=E3=80=8C=E8=AF=B7=E8=87=B3=E5=B0=91=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E4=B8=80=E4=B8=AA=E5=AE=A2=E6=88=B7=E3=80=8D=EF=BC=88?= =?UTF-8?q?=E7=BA=BF=E4=B8=8A=E6=9C=AA=E9=83=A8=E7=BD=B2=E7=9A=84=E8=A1=A5?= =?UTF-8?q?=E5=8F=91=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/services/quoteSheetService.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/src/services/quoteSheetService.ts b/server/src/services/quoteSheetService.ts index 731bec5..67082f1 100644 --- a/server/src/services/quoteSheetService.ts +++ b/server/src/services/quoteSheetService.ts @@ -190,7 +190,20 @@ export async function resolveEditCustomerSplit(input: { `SELECT customer_code FROM customer_quote_sheet_customers WHERE quote_sheet_code = $1`, [code] ); - const ownCustomerCodes = current.rows.map((r) => String(r.customer_code)); + let ownCustomerCodes = current.rows.map((r) => String(r.customer_code)); + /** + * 兜底(生产事故 2026-10-19):若因分公司上下文没命中而查不到本单客户, + * **绝不能把空列表传给编辑服务**(会 500「请至少选择一个客户」)。 + * 此时以请求里带的客户为准(前端本来就把当前单据的客户一起提交)。 + */ + if (!ownCustomerCodes.length && requested.length) { + console.warn('[quote-edit] 本单客户查询为空,回退使用请求客户', { + quoteSheetCode: code, + branchCode, + requested, + }); + ownCustomerCodes = [...requested]; + } const ownSet = new Set(ownCustomerCodes); const extra = requested.filter((c) => !ownSet.has(c)); // 单出口:先算结果,再 COMMIT,最后 return(早退会跳过 COMMIT,把脏事务留给连接池)