feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口

完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
hugo committed 2026-08-11 14:04:39 +08:00
1 parent 8e0bbf7a81
commit c94d173f92
181 files changed
+12947 -1724

No files matched your search

@@ -60,6 +60,7 @@ export function useShippingProcessingWorkItem(
let timer: ReturnType<typeof window.setTimeout> | null = null;
let generation = 0;
let stopped = false;
let refreshInFlight: { no: string; promise: Promise<void> } | null = null;
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
const monotonic = Boolean(options.monotonicProgressVersion);
@@ -87,6 +88,10 @@ export function useShippingProcessingWorkItem(
*/
async function refresh(): Promise<void> {
const no = String(toValue(workItemNo) || '').trim();
if (refreshInFlight?.no === no) {
await refreshInFlight.promise;
return;
}
const enabled = options.enabled == null ? true : Boolean(toValue(options.enabled));
if (!enabled || !no) {
projection.value = null;
@@ -96,7 +101,8 @@ export function useShippingProcessingWorkItem(
}
const gen = generation;
loading.value = true;
try {
const request = (async () => {
try {
const raw = await getWorkspaceShippingProcessingWorkItem(workItemType, no);
if (stopped || gen !== generation) return;
const normalized = normalizeShippingProcessingProjection(raw);
@@ -112,7 +118,7 @@ export function useShippingProcessingWorkItem(
void refresh();
}, pollMs);
}
} catch (err) {
} catch (err) {
if (stopped || gen !== generation) return;
// 404 / 业务不存在:清空投影但不抛到页面主流程。
if (err instanceof BusinessError && (err.status === 404 || err.code?.includes('NOT_FOUND'))) {
@@ -128,8 +134,15 @@ export function useShippingProcessingWorkItem(
void refresh();
}, pollMs);
}
} finally {
} finally {
if (gen === generation) loading.value = false;
}
})();
refreshInFlight = { no, promise: request };
try {
await request;
} finally {
if (refreshInFlight?.promise === request) refreshInFlight = null;
}
}
@@ -147,6 +160,9 @@ export function useShippingProcessingWorkItem(
error.value = null;
return;
}
// OT/PDF 切换时先清空旧投影,避免新请求完成前继续展示第一份 PDF 的状态。
projection.value = null;
error.value = null;
void refresh();
},
{ immediate: true },