fix(consignment): 内部库存匹配仅允许待分配和待抢单

This commit is contained in:
2026-11-13 16:34:44 +08:00
parent d8793db593
commit 40fa9e2725
9 changed files with 163 additions and 41 deletions
@@ -61,6 +61,9 @@ export default function ConsignmentWorkOrderMatchModal({
queryKey: ['admin-consignment-match-candidates', workOrderId],
queryFn: () => fetchAdminConsignmentMatchCandidates(Number(workOrderId)),
enabled: open && Boolean(workOrderId),
// 409 等业务拒绝对话框要直接把原因展示出来,不能重试后再被误判成“没有库存”。
retry: false,
refetchOnWindowFocus: false,
})
const data = candidatesQuery.data?.data
const options = useMemo(() => data?.options || [], [data?.options])
@@ -222,10 +225,25 @@ export default function ConsignmentWorkOrderMatchModal({
}
>
{candidatesQuery.isLoading ? <Card loading /> : null}
{!candidatesQuery.isLoading && options.length === 0 ? (
{candidatesQuery.isError ? (
<Alert
type="error"
showIcon
message="读取可匹配寄卖库存失败"
description={
candidatesQuery.error instanceof Error ? candidatesQuery.error.message : '请稍后重试'
}
action={
<Button size="small" onClick={() => void candidatesQuery.refetch()}>
重试
</Button>
}
/>
) : null}
{!candidatesQuery.isLoading && !candidatesQuery.isError && options.length === 0 ? (
<Empty description="没有同配置的在库寄卖库存" />
) : null}
{options.length > 0 ? (
{!candidatesQuery.isError && options.length > 0 ? (
<Space direction="vertical" size={12} style={{ width: '100%' }}>
{data?.matchingMode === 'off' ? (
<Alert
@@ -239,7 +257,7 @@ export default function ConsignmentWorkOrderMatchModal({
type={remainingNeeded <= 0 ? 'warning' : 'info'}
showIcon
message={infoMessage}
description="系统候选按寄卖配置打分;非精确/冲突库存必须人工勾选并填写原因。拼单必须一次拼满,失败不会占用任何库存。"
description="待分配工单也可直接人工匹配;候选仍按寄卖配置打分,非精确/冲突库存必须人工勾选并填写原因。拼单必须一次拼满,失败不会占用任何库存。"
/>
<Space wrap size={8}>
<Tag color="blue">
@@ -163,7 +163,6 @@ const ADMIN_NOTE_QUICK_TAGS = ['已通知加好友'] as const
const FILTERABLE_WORK_ORDER_STATUSES = [
'pending_material',
'unassigned',
'internal_matching',
'open',
'in_progress',
'pending_acceptance',
@@ -2071,19 +2070,13 @@ export default function WorkOrdersPanel() {
寄卖匹配只保留新引擎入口:旧的 /fulfill 手动匹配不支持数量拆分,
还会绕过 profile/重新匹配排除,已从 UI 收敛掉。
*/}
{canFulfillConsignment &&
['internal_matching', 'unassigned', 'open'].includes(String(row.status || '')) ? (
{canFulfillConsignment && ['unassigned', 'open'].includes(String(row.status || '')) ? (
<Button
type={String(row.status || '') === 'internal_matching' ? 'primary' : 'default'}
icon={<ThunderboltOutlined />}
onClick={() => setConsignmentMatchOrder(row)}
title={
String(row.status || '') === 'internal_matching'
? '手动选择寄卖库存并立即匹配;拼单必须一次拼满'
: '按寄卖配置精确匹配库存;拼单工单可选多条库存一起拼'
}
title="按寄卖配置匹配同配置库存;拼单工单可选多条库存一起拼"
>
{String(row.status || '') === 'internal_matching' ? '手动匹配寄卖' : '内部库存匹配'}
内部库存匹配
</Button>
) : null}
{canCustomerRefund &&
@@ -74,11 +74,11 @@ export function filterManualMatchOptions<T>(
/**
* 哪些订单状态可以手动指定现货。
*
* 与后端 `fulfillWorkOrderWithConsignment` 的前置校验保持一致(允许 unassigned /
* pending_material / open):入口先按同一口径收敛,避免"按钮点了才报错"。
* 与后端新引擎的前置校验保持一致:只允许待分配(unassigned)和待抢单(open)。
* 待补资料必须先补资料/发布到待抢单;历史内部匹配中已由迁移统一转为待抢单。
*/
export function isManuallyMatchableOrderStatus(status: string): boolean {
return status === 'unassigned' || status === 'pending_material' || status === 'open'
return status === 'unassigned' || status === 'open'
}
/**