feat(shipping-notice): 新增货代客户管理功能,支持客户导入、识别证据管理与客户确认

This commit is contained in:
hugo committed 2026-07-16 08:16:19 +08:00
1 parent b595e157e9
commit 4fbaed2b4c
176 files changed
+14011 -994

No files matched your search

@@ -32,6 +32,23 @@ export { isShippingNoticeAttachmentParseIncomplete } from './shippingNoticeAttac
const TERMINAL_PARSE = new Set(['parsed', 'failed', 'parse_failed', 'consumed', 'cancelled', 'expired']);
const ACTIVE_PARSE = new Set(['waiting', 'queued', 'parsing', 'created']);
const ACTIVE_ORDER_EXTRACTION = new Set(['extracting']);
/** 判断 Intake 是否仍需轮询上传预处理或订单抽取状态。 */
export function shouldPollShippingNoticeIntake(
item: Pick<ShippingNoticePendingAttachment, 'parseStatus' | 'orderExtractionStatus'>,
): boolean {
return !TERMINAL_PARSE.has(item.parseStatus)
|| ACTIVE_ORDER_EXTRACTION.has(String(item.orderExtractionStatus || '').trim().toLowerCase());
}
/** 保留刚点击发送的本地 extracting,直到服务端进入真实抽取状态或返回终态。 */
export function resolveShippingOrderExtractionStatus(localStatus?: string, remoteStatus?: string | null): string | undefined {
const local = String(localStatus || '').trim().toLowerCase();
const remote = String(remoteStatus || '').trim().toLowerCase();
if (local === 'extracting' && (!remote || remote === 'not_started')) return 'extracting';
return remote || undefined;
}
function mapServerParseStatus(status: string): ShippingNoticePendingAttachment['parseStatus'] {
const normalized = String(status || '').trim().toLowerCase();
@@ -160,7 +177,8 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|| item.uploadStatus === 'waiting'
|| ACTIVE_PARSE.has(item.parseStatus)
|| item.parseStatus === 'queued'
|| item.parseStatus === 'parsing',
|| item.parseStatus === 'parsing'
|| ACTIVE_ORDER_EXTRACTION.has(String(item.orderExtractionStatus || '').trim().toLowerCase()),
),
);
@@ -223,7 +241,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
if (!intakeNos.length) return;
if (intakeNos.every((no) => {
const item = noticeAttachments.value.find((entry) => entry.intakeNo === no);
return item != null && TERMINAL_PARSE.has(item.parseStatus);
return item != null && !shouldPollShippingNoticeIntake(item);
})) {
return;
}
@@ -255,7 +273,10 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
if (!local) continue;
patchAttachment(local.id, {
parseStatus: mapServerParseStatus(remote.parse_status),
orderExtractionStatus: remote.order_extraction_status || undefined,
orderExtractionStatus: resolveShippingOrderExtractionStatus(
local.orderExtractionStatus,
remote.order_extraction_status,
),
orderExtractionVersion: remote.order_extraction_version || undefined,
parseSummary: (remote.parse_summary || undefined) as ShippingNoticeParseSummary | undefined,
errorCode: remote.order_extraction_error_code || remote.error_code || undefined,
@@ -357,6 +378,32 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
)
.map((item) => String(item.intakeNo));
/** 点击发送后立即展示订单识别阶段,并启动 Intake 状态轮询。 */
const markOrderExtractionStarted = (intakeNos: string[]) => {
const selected = new Set(intakeNos.map((item) => String(item || '').trim().toUpperCase()).filter(Boolean));
for (const attachment of noticeAttachments.value) {
if (!attachment.intakeNo || !selected.has(attachment.intakeNo.toUpperCase())) continue;
patchAttachment(attachment.id, {
orderExtractionStatus: 'extracting',
errorCode: undefined,
errorMessage: undefined,
});
}
schedulePoll();
};
/** 聊天请求未成功发起时撤销本地即时状态;服务端真实状态由下一次刷新覆盖。 */
const rollbackOrderExtractionStarted = (intakeNos: string[]) => {
const selected = new Set(intakeNos.map((item) => String(item || '').trim().toUpperCase()).filter(Boolean));
for (const attachment of noticeAttachments.value) {
if (!attachment.intakeNo || !selected.has(attachment.intakeNo.toUpperCase())) continue;
if (attachment.orderExtractionStatus === 'extracting') {
patchAttachment(attachment.id, { orderExtractionStatus: 'not_started' });
}
}
schedulePoll();
};
const clearConsumedAttachments = () => {
options.attachments.value = options.attachments.value.filter(
(item) => item.kind !== 'shipping_notice' || item.parseStatus !== 'consumed',
@@ -391,7 +438,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
}));
const nonNotice = options.attachments.value.filter((item) => item.kind !== 'shipping_notice');
options.attachments.value = [...nonNotice, ...restored];
if (restored.some((item) => item.parseStatus === 'queued' || item.parseStatus === 'parsing')) {
if (restored.some((item) => shouldPollShippingNoticeIntake(item))) {
schedulePoll();
}
};
@@ -486,6 +533,8 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
setCandidateSelected,
updateCandidateSummary,
getParsedIntakeNos,
markOrderExtractionStarted,
rollbackOrderExtractionStarted,
getSelectedCandidateNos,
refreshStatuses,
clearConsumedAttachments,