feat(shipping-notice): 实现滚动履约功能,优化发货通知流程与代码清理
清理废弃的ShippingCase相关代码与依赖,统一使用ShippingNotice直接关联客户数据。调整库存网关依赖规则,支持仅对库存满足或已人工放行的订单行生成发货Excel,实现滚动履约逻辑。
This commit is contained in:
1 parent
7cfd5d167e
commit
1e5aedb9ed
235 files changed
+11394
-9613
No files matched your search
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
import {
|
||||
downloadWorkspaceShippingExportArchive as requestShippingExportArchive,
|
||||
workspaceShippingNoticeExportUrl,
|
||||
workspaceShippingExportUrl,
|
||||
workspaceShippingInventoryFileUrl,
|
||||
workspaceShippingLineInventoryFileUrl,
|
||||
@@ -16,6 +17,14 @@ export async function downloadWorkspaceShippingExcelFile(taskId: string): Promis
|
||||
await downloadWorkspaceShippingFile(workspaceShippingExportUrl(taskId), `${taskId}.xlsx`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按发货通知单号下载其唯一正式 Excel。
|
||||
* 新货代操作只能传 business_no;task_no 下载函数仅保留给尚未迁移的非货代工作流。
|
||||
*/
|
||||
export async function downloadWorkspaceShippingNoticeExcelFile(businessNo: string): Promise<void> {
|
||||
await downloadWorkspaceShippingFile(workspaceShippingNoticeExportUrl(businessNo), `${businessNo}.xlsx`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载当前任务活动关联的库存快照。
|
||||
* 核心逻辑:浏览器只发起受控 URL;后端复核任务归属、active link 与物理文件,不按库存源猜测文件。
|
||||
@@ -64,3 +73,25 @@ async function downloadWorkspaceShippingFile(url: string, fallbackName: string):
|
||||
export const downloadWorkspaceShippingExportArchive = (payload: {
|
||||
task_nos?: string[];
|
||||
}) => requestShippingExportArchive(payload);
|
||||
|
||||
/** 按多个 business_no 下载各自唯一 Excel 的 ZIP。 */
|
||||
export async function downloadWorkspaceShippingNoticeExportArchive(businessNos: string[]): Promise<void> {
|
||||
const response = await fetch('/api/workspace/shipping-notices/batch/export', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify({ business_nos: businessNos }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
const body = await response.json().catch(() => ({}));
|
||||
throw new Error((body as { error?: string; message?: string }).error || response.statusText);
|
||||
}
|
||||
const blob = await response.blob();
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = objectUrl;
|
||||
anchor.download = 'shipping_notices.zip';
|
||||
document.body.appendChild(anchor);
|
||||
anchor.click();
|
||||
document.body.removeChild(anchor);
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
}
|
||||
@@ -33,7 +33,7 @@ export type ShippingProcessingWorkItemTypeArg = 'order_intake' | 'order_task';
|
||||
*
|
||||
* @param workItemType - order_intake | order_task
|
||||
* @param workItemNo - Intake 编号或 OT 编号(MaybeRef)
|
||||
* @param options.enabled - 是否启用;options.pollMs - 轮询间隔;
|
||||
* @param options.enabled - 是否启用;options.pollMs - 轮询间隔;options.continuousPolling - 是否由本 composable 持续轮询;
|
||||
* options.monotonicProgressVersion - 仅工作台:旧 progress_version 不覆盖本地
|
||||
* @returns projection / loading / error / refresh / stop
|
||||
*/
|
||||
@@ -43,6 +43,8 @@ export function useShippingProcessingWorkItem(
|
||||
options: {
|
||||
enabled?: MaybeRefOrGetter<boolean>;
|
||||
pollMs?: number;
|
||||
/** false 时仅由调用方显式 refresh;用于已有页面级协调轮询的工作台。 */
|
||||
continuousPolling?: boolean;
|
||||
/** 仅订单处理工作台开启;任务中心保持默认 false。 */
|
||||
monotonicProgressVersion?: boolean;
|
||||
} = {},
|
||||
@@ -61,6 +63,7 @@ export function useShippingProcessingWorkItem(
|
||||
let stopped = false;
|
||||
let refreshInFlight: { no: string; promise: Promise<void> } | null = null;
|
||||
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
||||
const continuousPolling = options.continuousPolling !== false;
|
||||
const monotonic = Boolean(options.monotonicProgressVersion);
|
||||
|
||||
/**
|
||||
@@ -112,7 +115,7 @@ export function useShippingProcessingWorkItem(
|
||||
error.value = null;
|
||||
clearTimer();
|
||||
const next = projection.value;
|
||||
if (next && !TERMINAL_STATUSES.has(next.status) && !stopped) {
|
||||
if (continuousPolling && next && !TERMINAL_STATUSES.has(next.status) && !stopped) {
|
||||
timer = window.setTimeout(() => {
|
||||
void refresh();
|
||||
}, pollMs);
|
||||
@@ -128,7 +131,7 @@ export function useShippingProcessingWorkItem(
|
||||
}
|
||||
error.value = err instanceof BusinessError ? err.message : 'network_recoverable';
|
||||
clearTimer();
|
||||
if (!stopped) {
|
||||
if (continuousPolling && !stopped) {
|
||||
timer = window.setTimeout(() => {
|
||||
void refresh();
|
||||
}, pollMs);
|
||||
|
||||
Reference in new issue
Block a user