fix(报价单): 后台/系统触发传递时补最小 ctx,避免 branch_required 静默失败

This commit is contained in:
Ubuntu
2026-10-18 20:48:57 +08:00
parent f587b22047
commit 83274ddf5d
+16 -1
View File
@@ -47,11 +47,26 @@ export async function requestDeliveryReviewForSheet(input: {
const branchCode =
input.branchCode || getEffectiveBranchCode(input.ctx || null, input.operatingBranchCode || null);
if (!branchCode) return { ok: false, code: 'branch_required', message: '请选择当前操作分公司' };
// 后台/系统触发没有请求上下文 ⇒ 造一个只带分公司的最小 ctx(非超管 ⇒ getEffectiveBranchCode 直接用 ctx.branchCode)
const ctx: TenantContext =
input.ctx ??
({
userId: '',
roles: [],
permissions: ['customer_manage'],
branchCode,
supplierCode: null,
purchaserCode: null,
isSuperAdmin: false,
isBranchAdmin: false,
isInternalStaff: false,
isSupplierAccount: false,
} as TenantContext);
try {
const res = await submitPriceProposal({
quoteSheetCode: input.quoteSheetCode,
note: null,
ctx: input.ctx ?? null,
ctx,
operatingBranchCode: input.operatingBranchCode ?? branchCode,
requestedBy: input.requestedBy ?? null,
});