feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置 新增收料报表管理的前端页面、路由和侧边栏入口 新增后端收料报表配置接口、数据库模型和RPA脚本 优化发货通知流程的重试策略,将shipping相关job默认不自动重试 移除废弃的库存源确认相关逻辑,更新流程门禁规则 重构订单模板的值适配器模块,新增坐标OCR值适配器 清理前端shipping菜单和action的废弃选项 更新相关文档和测试用例,调整.gitignore忽略规则
This commit is contained in:
1 parent
260465b72d
commit
1b6483a4ea
466 files changed
+32115
-33796
No files matched your search
@@ -10,32 +10,28 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import ShippingCustomerConfirmDialog from '@/features/chat/components/ShippingCustomerConfirmDialog.vue';
|
||||
import type {
|
||||
ShippingChatAction,
|
||||
ShippingCustomerOption,
|
||||
ShippingInventorySourceCandidate,
|
||||
ShippingTaskDetail,
|
||||
ShippingUnifiedAction,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import {
|
||||
confirmWorkspaceShippingCustomer,
|
||||
confirmWorkspaceShippingInventorySource,
|
||||
freezeWorkspaceShippingOrder,
|
||||
listWorkspaceShippingCustomerOptions,
|
||||
retryWorkspaceShippingUpload,
|
||||
submitWorkspaceShippingDecision,
|
||||
type ShippingFulfillmentOwnershipContext,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import { refreshShippingTodoBadge } from '@/features/workspace/composables/useShippingTodoBadge';
|
||||
import InventorySourceSelectDialog from './InventorySourceSelectDialog.vue';
|
||||
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import { postWorkspaceProcessGateAction } from '@/features/shipping-process-gates/api/process-gates.api';
|
||||
import type { ShippingProcessGateUserSummary } from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
getWorkspaceProcessExecution,
|
||||
postWorkspaceProcessGateAction,
|
||||
} from '@/features/shipping-process-gates/api/process-gates.api';
|
||||
import type {
|
||||
ShippingProcessGateActionResponse,
|
||||
ShippingProcessGateUserSummary,
|
||||
} from '@/features/shipping-process-gates/types/process-gate.types';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
detail: ShippingTaskDetail;
|
||||
@@ -43,14 +39,12 @@ const props = withDefaults(defineProps<{
|
||||
canHandle?: boolean;
|
||||
/** Gate 卡是否允许写(订单处理工作台恒为 false)。 */
|
||||
gateCanHandle?: boolean;
|
||||
/** Footer/Resolver 委托的 invokeActionByCode 是否可执行写。 */
|
||||
/** 当前可见面板是否允许执行后端已授权动作。 */
|
||||
actionsExecutable?: boolean;
|
||||
/** 为 true 时隐藏本卡全部后端 actions(订单处理工作台写入口仅 Footer)。 */
|
||||
hidePrimaryActions?: boolean;
|
||||
/** 订单处理工作台将 Gate 卡提升到右侧展示时隐藏此处重复卡。 */
|
||||
hideGateCard?: boolean;
|
||||
/** 仅作为工作台动作执行器/弹窗宿主,不渲染第二套卡片或按钮。 */
|
||||
headless?: boolean;
|
||||
/** 工作台权威正式 Notice 号;与 detail.task_no 不一致时禁止履约写。 */
|
||||
expectedNoticeTaskNo?: string | null;
|
||||
/** 工作台权威 OT 号,随履约 API 校验归属。 */
|
||||
@@ -65,7 +59,6 @@ const props = withDefaults(defineProps<{
|
||||
actionsExecutable: undefined,
|
||||
hidePrimaryActions: false,
|
||||
hideGateCard: false,
|
||||
headless: false,
|
||||
expectedNoticeTaskNo: null,
|
||||
expectedOrderTaskNo: null,
|
||||
expectedReviewCaseNo: null,
|
||||
@@ -83,11 +76,6 @@ const manualUploadOpen = ref(false);
|
||||
const customerDialogOpen = ref(false);
|
||||
const customerOptions = ref<ShippingCustomerOption[]>([]);
|
||||
const customerLoading = ref(false);
|
||||
const freezeDialogOpen = ref(false);
|
||||
const pendingFreezeVersion = ref<number | null>(null);
|
||||
const inventorySourceDialogOpen = ref(false);
|
||||
const inventorySourceCandidates = ref<ShippingInventorySourceCandidate[]>([]);
|
||||
const inventorySourceInitialCode = ref('');
|
||||
|
||||
const summary = computed(() => props.detail.ui_state?.summary || {});
|
||||
const processGateSummary = computed((): ShippingProcessGateUserSummary | null =>
|
||||
@@ -175,70 +163,6 @@ async function afterSuccess() {
|
||||
await refreshShippingTodoBadge(true);
|
||||
emit('refreshed');
|
||||
}
|
||||
/**
|
||||
* 从任务上下文解析唯一库存源编码;多候选或无候选时返回空字符串。
|
||||
*/
|
||||
function resolveSingleInventorySourceCode(action: ShippingChatAction): string {
|
||||
const fromAction = String(action.source_code || '').trim().toUpperCase();
|
||||
if (fromAction) return fromAction;
|
||||
const resolution = props.detail.inventory_source_resolution;
|
||||
const candidates = resolution && typeof resolution === 'object'
|
||||
? (resolution as { candidates?: unknown }).candidates
|
||||
: null;
|
||||
if (Array.isArray(candidates) && candidates.length === 1) {
|
||||
const only = candidates[0];
|
||||
if (only && typeof only === 'object') {
|
||||
return String((only as { source_code?: unknown }).source_code || '').trim().toUpperCase();
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* 打开库存源选择对话框;若已能唯一解析则直接提交。
|
||||
*/
|
||||
async function runConfirmInventorySource(action: ShippingChatAction) {
|
||||
const directCode = resolveSingleInventorySourceCode(action);
|
||||
if (directCode) {
|
||||
busyId.value = 'confirm_inventory_source';
|
||||
try {
|
||||
await confirmWorkspaceShippingInventorySource(props.detail.task_no, directCode);
|
||||
await afterSuccess();
|
||||
} catch (e: unknown) {
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
} finally {
|
||||
busyId.value = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
const resolution = props.detail.inventory_source_resolution;
|
||||
const raw = resolution && typeof resolution === 'object'
|
||||
? (resolution as { candidates?: unknown }).candidates
|
||||
: null;
|
||||
inventorySourceCandidates.value = Array.isArray(raw)
|
||||
? raw.filter((item): item is ShippingInventorySourceCandidate =>
|
||||
Boolean(item && typeof item === 'object' && (item as ShippingInventorySourceCandidate).source_code))
|
||||
: [];
|
||||
inventorySourceInitialCode.value = String(action.source_code || '').trim().toUpperCase();
|
||||
inventorySourceDialogOpen.value = true;
|
||||
}
|
||||
/**
|
||||
* 对话框确认库存源后提交后端。
|
||||
*/
|
||||
async function onInventorySourceConfirm(sourceCode: string) {
|
||||
if (!sourceCode.trim()) {
|
||||
msg.warning(t('workspace.shippingNotice.actions.inventorySourcePrompt'));
|
||||
return;
|
||||
}
|
||||
busyId.value = 'confirm_inventory_source';
|
||||
try {
|
||||
await confirmWorkspaceShippingInventorySource(props.detail.task_no, sourceCode.trim().toUpperCase());
|
||||
await afterSuccess();
|
||||
} catch (e: unknown) {
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
} finally {
|
||||
busyId.value = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 打开客户确认对话框并加载启用标准客户。
|
||||
*/
|
||||
@@ -285,49 +209,6 @@ async function onCustomerConfirm(customerId: number) {
|
||||
busyId.value = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 校验版本并打开冻结确认对话框。
|
||||
*/
|
||||
function openFreezeDialog() {
|
||||
const version = Number(props.detail.order_data_version);
|
||||
if (!Number.isInteger(version) || version < 1) {
|
||||
msg.warning(t('workspace.shippingNotice.actions.freezeFailed'));
|
||||
return;
|
||||
}
|
||||
pendingFreezeVersion.value = version;
|
||||
freezeDialogOpen.value = true;
|
||||
}
|
||||
/**
|
||||
* 确认冻结后提交后端。
|
||||
*/
|
||||
async function onFreezeConfirm() {
|
||||
const version = pendingFreezeVersion.value;
|
||||
if (version == null) return;
|
||||
busyId.value = 'freeze_order';
|
||||
try {
|
||||
await freezeWorkspaceShippingOrder(props.detail.task_no, version);
|
||||
await afterSuccess();
|
||||
} catch (e: unknown) {
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
} finally {
|
||||
busyId.value = null;
|
||||
pendingFreezeVersion.value = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 组装履约 API 归属上下文(仅非空字段)。
|
||||
*/
|
||||
function ownershipContext(): ShippingFulfillmentOwnershipContext | undefined {
|
||||
const ctx: ShippingFulfillmentOwnershipContext = {};
|
||||
const ot = String(props.expectedOrderTaskNo || '').trim();
|
||||
const caseNo = String(props.expectedReviewCaseNo || '').trim();
|
||||
const run = String(props.expectedRunNo || '').trim();
|
||||
if (ot) ctx.expectedOrderTaskNo = ot;
|
||||
if (caseNo) ctx.expectedReviewCaseNo = caseNo;
|
||||
if (run) ctx.expectedRunNo = run;
|
||||
return (ctx.expectedOrderTaskNo || ctx.expectedReviewCaseNo || ctx.expectedRunNo) ? ctx : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* 履约写前校验正式任务号与工作台权威上下文一致。
|
||||
*
|
||||
@@ -344,7 +225,43 @@ async function assertFulfillmentOwnership(): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 将兼容按钮收口为服务端正式 Gate Action;缺少 Projection 身份时只刷新。 */
|
||||
const ASYNC_ATTEMPT_POLL_INTERVAL_MS = 800;
|
||||
const ASYNC_ATTEMPT_POLL_LIMIT = 25;
|
||||
const ASYNC_ATTEMPT_TERMINAL_STATUSES = new Set(['succeeded', 'failed', 'cancelled', 'superseded']);
|
||||
|
||||
/**
|
||||
* 等待后端已受理的异步 Gate Attempt 收口,避免仅刷新一次而仍读取到 Worker 执行前的投影。
|
||||
*
|
||||
* @param response - Gate Action API 的原始响应;仅由 dispatch/attempt 判定是否轮询。
|
||||
*/
|
||||
async function waitForAsyncGateAttempt(response: ShippingProcessGateActionResponse): Promise<void> {
|
||||
if (response.dispatch !== 'async_job' || !Number.isInteger(Number(response.attempt?.id))) return;
|
||||
const executionNo = String(response.execution_no || '').trim();
|
||||
const submittedGateCode = String(response.gate_code || '').trim();
|
||||
const attemptId = Number(response.attempt.id);
|
||||
if (!executionNo || !submittedGateCode || attemptId < 1) return;
|
||||
for (let index = 0; index < ASYNC_ATTEMPT_POLL_LIMIT; index += 1) {
|
||||
const latest = await getWorkspaceProcessExecution(executionNo);
|
||||
const latestAttempt = latest.current_blocking_gate?.latest_attempt;
|
||||
const latestAttemptId = Number(latestAttempt?.id || 0);
|
||||
const latestAttemptStatus = String(latestAttempt?.status || '').trim().toLowerCase();
|
||||
if (
|
||||
(latestAttemptId === attemptId || latestAttemptId === 0)
|
||||
&& ASYNC_ATTEMPT_TERMINAL_STATUSES.has(latestAttemptStatus)
|
||||
) return;
|
||||
const currentGateCode = String(latest.current_blocking_gate?.gate_code || '').trim();
|
||||
const executionStatus = String(latest.status || '').trim().toLowerCase();
|
||||
if (
|
||||
currentGateCode
|
||||
&& currentGateCode !== submittedGateCode
|
||||
&& !['pending', 'queued', 'running'].includes(executionStatus)
|
||||
) return;
|
||||
if (!latest.current_blocking_gate && ['completed', 'cancelled'].includes(executionStatus)) return;
|
||||
await new Promise((resolve) => window.setTimeout(resolve, ASYNC_ATTEMPT_POLL_INTERVAL_MS));
|
||||
}
|
||||
}
|
||||
|
||||
/** 将后端下发的 Gate Action 原样提交;缺少 Projection 身份时只刷新。 */
|
||||
async function requestProjectedGateAction(actionCode: string): Promise<boolean> {
|
||||
const executionNo = String(processGateSummary.value?.execution_no || '').trim();
|
||||
const gate = processGateSummary.value?.current_blocking_gate;
|
||||
@@ -354,119 +271,63 @@ async function requestProjectedGateAction(actionCode: string): Promise<boolean>
|
||||
emit('refreshed');
|
||||
return false;
|
||||
}
|
||||
await postWorkspaceProcessGateAction(executionNo, gateCode, {
|
||||
const response = await postWorkspaceProcessGateAction(executionNo, gateCode, {
|
||||
action_code: actionCode,
|
||||
expected_gate_version: version,
|
||||
idempotency_key: `task-todo:${executionNo}:${gateCode}:${version}:${actionCode}:${crypto.randomUUID()}`,
|
||||
});
|
||||
try {
|
||||
await waitForAsyncGateAttempt(response);
|
||||
} catch {
|
||||
// 受理结果已由 POST 确认;轮询仅用于缩小异步投影窗口,读取短暂失败仍刷新父级事实。
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行后端允许的动作;人工上传/客户/库存源/冻结走对话框,其余走对应工作台 API。
|
||||
*/
|
||||
async function runAction(action: ShippingChatAction) {
|
||||
if (!resolvedActionsExecutable.value || busyId.value) return;
|
||||
const id = String(action.id || '');
|
||||
if (id === 'mark_manual_uploaded') {
|
||||
/** 将后端统一动作适配到既有宿主能力;业务判断、展示和授权仍完全由后端提供。 */
|
||||
async function runUnifiedAction(action: ShippingUnifiedAction) {
|
||||
if (!resolvedActionsExecutable.value || !action.enabled || busyId.value) return;
|
||||
const dispatch = String(action.dispatch || 'mutation').trim();
|
||||
const uiHandler = String(action.ui_handler || '').trim();
|
||||
if (dispatch === 'dialog' && uiHandler === 'manual_upload_evidence') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
manualUploadOpen.value = true;
|
||||
return;
|
||||
}
|
||||
if (id === 'refresh') {
|
||||
emit('refreshed');
|
||||
if (dispatch === 'view' && uiHandler === 'excel_download') {
|
||||
busyId.value = action.code;
|
||||
try {
|
||||
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
|
||||
await afterSuccess();
|
||||
} catch (e: unknown) {
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
} finally {
|
||||
busyId.value = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (id === 'confirm_customer') {
|
||||
if (dispatch === 'navigation' && uiHandler === 'customer_resolution') {
|
||||
await openCustomerDialog();
|
||||
return;
|
||||
}
|
||||
if (id === 'confirm_inventory_source') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
await runConfirmInventorySource(action);
|
||||
return;
|
||||
}
|
||||
if (id === 'freeze_order') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
openFreezeDialog();
|
||||
return;
|
||||
}
|
||||
busyId.value = id;
|
||||
if (dispatch !== 'mutation' && dispatch !== 'refresh') return;
|
||||
// 生命周期区域按后端 target_surface 展示后,再将同一份后端 action.code 原样
|
||||
// 提交 Gate;前端不再维护库存、Excel 或 RPA 的动作别名与 API 分派。
|
||||
busyId.value = action.code;
|
||||
try {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
const ownership = ownershipContext();
|
||||
if (id === 'download_excel' || id === 'export') {
|
||||
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'generate_excel') {
|
||||
await requestProjectedGateAction('regenerate_excel_artifact');
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
// [AUTHORITY] Gate 投影使用 retry_inventory_matching;保留旧码仅用于过渡数据。
|
||||
// 三者均必须走同一个带 execution/gate/version 的 Gate Action API,不能退回
|
||||
// 旧 submitWorkspaceShippingDecision,否则会绕过当前 Gate 的乐观锁与授权校验。
|
||||
if (id === 'match_inventory' || id === 'rematch' || id === 'retry_inventory_matching') {
|
||||
await requestProjectedGateAction('retry_inventory_matching');
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'retry_upload') {
|
||||
await retryWorkspaceShippingUpload(props.detail.task_no, ownership);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
await submitWorkspaceShippingDecision(props.detail.task_no, id);
|
||||
await requestProjectedGateAction(action.code);
|
||||
await afterSuccess();
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof BusinessError && e.code === 'SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH') {
|
||||
msg.warning(t('errors.codes.SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH'));
|
||||
emit('refreshed');
|
||||
return;
|
||||
}
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
} finally {
|
||||
busyId.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 将后端统一动作适配到现有专用弹窗/提交执行器;业务判断仍完全由后端提供。 */
|
||||
async function runUnifiedAction(action: ShippingUnifiedAction) {
|
||||
if (!action.enabled) return;
|
||||
await runAction({
|
||||
id: action.code,
|
||||
// 此入口也供 Footer 按 action code 委托执行;该动作不一定会渲染为卡片按钮,
|
||||
// 因此展示 label 缺失时使用协议 code 作为仅供执行器的占位,而非拒绝正式 Gate 动作。
|
||||
label: String(action.label || action.code),
|
||||
message: action.disabled_reason || '',
|
||||
variant: action.kind === 'terminate' ? 'danger' : action.kind === 'view' ? 'secondary' : 'primary',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 供订单处理工作台统一 ActionBar 委托履约动作(库存源/匹配/上传登记等)。
|
||||
*
|
||||
* @param actionId - ui_state / Gate 动作码
|
||||
*/
|
||||
async function invokeActionByCode(actionId: string) {
|
||||
const id = String(actionId || '').trim();
|
||||
if (!id) return;
|
||||
const projected = [rawBackendPrimaryAction.value, ...rawBackendSecondaryActions.value]
|
||||
.find((item) => item && item.code === id);
|
||||
if (projected) {
|
||||
await runUnifiedAction(projected);
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
invokeActionByCode,
|
||||
openCustomerDialog,
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div v-if="!headless" class="space-y-3">
|
||||
<div class="space-y-3">
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="!hideGateCard"
|
||||
:summary="processGateSummary"
|
||||
@@ -478,7 +339,7 @@ defineExpose({
|
||||
@refreshed="afterSuccess"
|
||||
@refresh-needed="afterSuccess"
|
||||
@confirm-customer="() => void openCustomerDialog()"
|
||||
@manual-upload="() => void invokeActionByCode('mark_manual_uploaded')"
|
||||
@manual-upload="manualUploadOpen = true"
|
||||
/>
|
||||
<section
|
||||
v-if="!hasBlockingGate && !isSystemAutoWait"
|
||||
@@ -541,21 +402,6 @@ defineExpose({
|
||||
@search="searchCustomers"
|
||||
@confirm="onCustomerConfirm"
|
||||
/>
|
||||
<InventorySourceSelectDialog
|
||||
v-model:open="inventorySourceDialogOpen"
|
||||
:candidates="inventorySourceCandidates"
|
||||
:initial-code="inventorySourceInitialCode"
|
||||
@confirm="onInventorySourceConfirm"
|
||||
/>
|
||||
<DeleteConfirmDialog
|
||||
v-model="freezeDialogOpen"
|
||||
confirm-tone="primary"
|
||||
:title="$t('workspace.shippingNotice.actions.freezeOrder')"
|
||||
:message="$t('workspace.shippingNotice.actions.freezeConfirm')"
|
||||
:confirm-text="$t('workspace.shippingNotice.actions.freezeOrder')"
|
||||
:confirm-loading="busyId === 'freeze_order'"
|
||||
@confirm="onFreezeConfirm"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user