fix(编辑报价单): 本单客户查询为空时回退使用请求客户,避免 500「请至少选择一个客户」(线上未部署的补发)
This commit is contained in:
@@ -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,把脏事务留给连接池)
|
||||
|
||||
Reference in New Issue
Block a user