refactor(shipping-notice): 重构货代发货通知状态管理,移除废弃的process_status字段
统一货代发货通知的业务阶段为四个标准阶段:接收解析、订单复核、发货准备、上传完成 设置 ui_state 为前端唯一状态数据源,不再依赖 process_status 驱动业务流程 删除 shipping_notices 表的废弃 process_status 列及对应复合索引,新增数据库迁移脚本 替换全栈代码中所有对 process_status 的引用为生命周期、上传状态等领域字段 更新相关文档、测试用例与前端展示逻辑适配新的状态管理规则
This commit is contained in:
1 parent
6684e7181a
commit
5ef8329bd8
178 files changed
+5091
-1734
No files matched your search
@@ -2,8 +2,8 @@
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.vue
|
||||
* 用途:渲染统一 Gate 恢复卡片与 STP 履约待办说明(表单/弹窗入口)。
|
||||
* 依赖:ProcessGateRecoveryCard、shipping.api、shipping-tasks.api、ManualUploadEvidenceDialog。
|
||||
* 逻辑:gateCanHandle 控制 Gate 卡写按钮;actionsExecutable 控制 invokeActionByCode / 对话框写;
|
||||
* hidePrimaryActions=true 时不渲染 action_buttons(订单处理工作台写入口仅 Footer);
|
||||
* 逻辑:gateCanHandle 控制 Gate 卡写按钮;actionsExecutable 控制统一 action.code 写操作;
|
||||
* hidePrimaryActions=true 时隐藏本卡按钮(订单处理工作台写入口仅 Footer);
|
||||
* 系统 Worker / technical_auto_only 不计入人工阻断,避免「待处理事项」冒充系统等待。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
@@ -35,7 +35,6 @@ 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 { gateSummaryIndicatesManualUpload } from '@/features/chat/shipping/shippingProcessingFulfillment';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
detail: ShippingTaskDetail;
|
||||
@@ -45,7 +44,7 @@ const props = withDefaults(defineProps<{
|
||||
gateCanHandle?: boolean;
|
||||
/** Footer/Resolver 委托的 invokeActionByCode 是否可执行写。 */
|
||||
actionsExecutable?: boolean;
|
||||
/** 为 true 时隐藏全部 action_buttons(订单处理工作台写入口仅 Footer)。 */
|
||||
/** 为 true 时隐藏本卡全部后端 actions(订单处理工作台写入口仅 Footer)。 */
|
||||
hidePrimaryActions?: boolean;
|
||||
/** 订单处理工作台将 Gate 卡提升到右侧展示时隐藏此处重复卡。 */
|
||||
hideGateCard?: boolean;
|
||||
@@ -92,16 +91,9 @@ const processGateSummary = computed((): ShippingProcessGateUserSummary | null =>
|
||||
|| (summary.value.process_gate as ShippingProcessGateUserSummary | null | undefined)
|
||||
|| null,
|
||||
);
|
||||
const actionButtons = computed(() => props.detail.ui_state?.action_buttons || []);
|
||||
const checkpointKind = computed(() => String(props.detail.ui_state?.checkpoint_kind || ''));
|
||||
/** 统一 Gate 投影中的主要恢复动作;用于去重旧 action_buttons。 */
|
||||
const processGateNextAction = computed(() =>
|
||||
String(
|
||||
processGateSummary.value?.next_action_code
|
||||
|| processGateSummary.value?.current_blocking_gate?.next_action_code
|
||||
|| '',
|
||||
).trim(),
|
||||
);
|
||||
const unifiedActions = computed(() => props.detail.ui_state?.actions || { primary: null, secondary: [] });
|
||||
const backendPrimaryAction = computed(() => unifiedActions.value.primary || null);
|
||||
const backendSecondaryActions = computed(() => unifiedActions.value.secondary || []);
|
||||
/** 有 Gate 阻断时优先展示统一投影文案。 */
|
||||
const displayTodoTitle = computed(() =>
|
||||
processGateSummary.value?.current_blocking_gate?.label
|
||||
@@ -115,31 +107,6 @@ const displayTodoMessage = computed(() =>
|
||||
|| t('workspace.shippingNotice.todo.noActionMessage'),
|
||||
);
|
||||
|
||||
/**
|
||||
* 是否展示「待人工上传登记」提示。
|
||||
* 核心逻辑:优先 process_gate / current_blocking_gate 的 next_action_code 与
|
||||
* available_actions;RPA 上传中不展示;禁止用 workflow_item.lifecycle 作主判据。
|
||||
*/
|
||||
const showWaitingManualUploadNote = computed(() => {
|
||||
const process = String(props.detail.process_status || '').trim();
|
||||
if (process === 'uploading') return false;
|
||||
const gateNextAction = String(
|
||||
processGateSummary.value?.current_blocking_gate?.next_action_code
|
||||
|| processGateSummary.value?.next_action_code
|
||||
|| processGateNextAction.value
|
||||
|| '',
|
||||
).trim();
|
||||
const allowedActions = [
|
||||
...(summary.value.allowed_actions || []),
|
||||
...(actionButtons.value.map((item) => item.id)),
|
||||
];
|
||||
return gateSummaryIndicatesManualUpload({
|
||||
nextActionCode: gateNextAction,
|
||||
checkpointKind: checkpointKind.value,
|
||||
availableActions: allowedActions,
|
||||
});
|
||||
});
|
||||
|
||||
/** 当前导出工件 id,供人工上传登记对话框绑定。 */
|
||||
const currentExportArtifactId = computed(() => {
|
||||
const artifacts = props.detail.export_artifacts;
|
||||
@@ -147,41 +114,6 @@ const currentExportArtifactId = computed(() => {
|
||||
const id = Number(artifacts[0]?.id);
|
||||
return Number.isFinite(id) ? id : null;
|
||||
});
|
||||
/** auto_continue 仅保留刷新;正常 STP 由后台自动推进。 */
|
||||
const AUTO_CONTINUE_ACTIONS = new Set(['refresh']);
|
||||
/** wait_manual_upload 仅允许下载/导出/人工上传确认。 */
|
||||
const WAIT_MANUAL_UPLOAD_ACTIONS = new Set(['download_excel', 'export', 'mark_manual_uploaded', 'refresh']);
|
||||
/** must_human 保留例外处理动作,禁止 Chat 侧履约写路径。 */
|
||||
const MUST_HUMAN_ACTIONS = new Set([
|
||||
'confirm',
|
||||
'reject',
|
||||
'reparse',
|
||||
'replace_notice_file',
|
||||
'rematch',
|
||||
'retry_rpa',
|
||||
'confirm_inventory_source',
|
||||
'retry_resolve_inventory_source',
|
||||
'confirm_customer',
|
||||
'freeze_order',
|
||||
'upload_inventory_file',
|
||||
'match_inventory',
|
||||
'refresh',
|
||||
]);
|
||||
/**
|
||||
* 按 STP checkpoint_kind 过滤工作台动作,避免 auto_continue 误点写操作。
|
||||
*/
|
||||
function isActionAllowedForCheckpoint(actionId: string, kind: string): boolean {
|
||||
if (!kind || kind === 'complete') return actionId === 'refresh';
|
||||
if (kind === 'auto_continue') return AUTO_CONTINUE_ACTIONS.has(actionId);
|
||||
if (kind === 'wait_manual_upload') return WAIT_MANUAL_UPLOAD_ACTIONS.has(actionId);
|
||||
if (kind === 'must_human') return MUST_HUMAN_ACTIONS.has(actionId);
|
||||
return true;
|
||||
}
|
||||
const allowedIds = computed(() => {
|
||||
const fromSummary = summary.value.allowed_actions;
|
||||
if (Array.isArray(fromSummary) && fromSummary.length) return new Set(fromSummary.map(String));
|
||||
return new Set(actionButtons.value.map((item) => item.id));
|
||||
});
|
||||
const hasBlockingGate = computed(() => {
|
||||
const gate = processGateSummary.value;
|
||||
if (!gate?.current_blocking_gate) return false;
|
||||
@@ -205,40 +137,7 @@ const isSystemAutoWait = computed(() => {
|
||||
return !hasBlockingGate.value;
|
||||
});
|
||||
|
||||
const UNIFIED_OWNED_ACTION_IDS = new Set([
|
||||
'retry',
|
||||
'refresh',
|
||||
'download_excel',
|
||||
'export',
|
||||
'open_manual_upload',
|
||||
'mark_manual_uploaded',
|
||||
'regenerate_excel',
|
||||
'view_result',
|
||||
'open_order_review',
|
||||
'open_order_processing',
|
||||
]);
|
||||
|
||||
const visibleActions = computed(() => {
|
||||
// [STEP] 订单处理工作台:写操作仅 Footer;不渲染 Notice action_buttons(D1)。
|
||||
if (props.hidePrimaryActions) return [];
|
||||
// [STEP] Gate 阻断或系统自动等待时均由统一 Gate 投影拥有动作;
|
||||
// 禁止历史 action_buttons(如 edit_formal_task)穿透到当前阶段。
|
||||
if (hasBlockingGate.value || isSystemAutoWait.value) return [];
|
||||
return actionButtons.value.filter((action) => {
|
||||
const id = String(action.id || '');
|
||||
if (id === 'regenerate_manual_upload_todo') return false;
|
||||
if (UNIFIED_OWNED_ACTION_IDS.has(id)) {
|
||||
return false;
|
||||
}
|
||||
if (!allowedIds.value.has(id) || !isActionAllowedForCheckpoint(id, checkpointKind.value)) {
|
||||
return false;
|
||||
}
|
||||
if (processGateNextAction.value && id === processGateNextAction.value) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
// 统一 actions 已是唯一按钮来源;旧 action_buttons 不再参与渲染。
|
||||
/** Gate 卡写权限;订单处理工作台传入 false 保持只读。 */
|
||||
const resolvedGateCanHandle = computed(() => (
|
||||
props.gateCanHandle !== undefined ? Boolean(props.gateCanHandle) : Boolean(props.canHandle)
|
||||
@@ -508,6 +407,17 @@ async function runAction(action: ShippingChatAction) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 将后端统一动作适配到现有专用弹窗/提交执行器;业务判断仍完全由后端提供。 */
|
||||
async function runUnifiedAction(action: NonNullable<typeof backendPrimaryAction.value>) {
|
||||
if (!action.enabled) return;
|
||||
await runAction({
|
||||
id: action.code,
|
||||
label: action.label || action.code,
|
||||
message: action.disabled_reason || '',
|
||||
variant: action.kind === 'terminate' ? 'danger' : action.kind === 'view' ? 'secondary' : 'primary',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 供订单处理工作台统一 ActionBar 委托履约动作(库存源/匹配/上传登记等)。
|
||||
*
|
||||
@@ -516,13 +426,11 @@ async function runAction(action: ShippingChatAction) {
|
||||
async function invokeActionByCode(actionId: string) {
|
||||
const id = String(actionId || '').trim();
|
||||
if (!id) return;
|
||||
const fromButtons = actionButtons.value.find((item) => String(item.id || '') === id);
|
||||
await runAction(fromButtons || {
|
||||
id,
|
||||
label: id,
|
||||
message: '',
|
||||
variant: 'primary',
|
||||
});
|
||||
const projected = [backendPrimaryAction.value, ...backendSecondaryActions.value]
|
||||
.find((item) => item && item.code === id);
|
||||
if (projected) {
|
||||
await runUnifiedAction(projected);
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
@@ -564,30 +472,33 @@ defineExpose({
|
||||
<div v-if="!resolvedActionsExecutable" class="mt-3 text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnly') }}
|
||||
</div>
|
||||
<div v-else-if="visibleActions.length" class="mt-3 flex flex-wrap gap-2">
|
||||
<div v-else-if="backendPrimaryAction || backendSecondaryActions.length" class="mt-3 flex flex-wrap gap-2">
|
||||
<button
|
||||
v-for="action in visibleActions"
|
||||
:key="action.id"
|
||||
v-if="backendPrimaryAction"
|
||||
:key="backendPrimaryAction.code"
|
||||
type="button"
|
||||
class="rounded-xl px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-50"
|
||||
:class="action.variant === 'danger'
|
||||
:class="backendPrimaryAction.kind === 'terminate'
|
||||
? 'bg-rose-600 text-white hover:bg-rose-700'
|
||||
: action.variant === 'secondary'
|
||||
: backendPrimaryAction.kind === 'view'
|
||||
? 'border border-default bg-surface text-secondary hover:bg-surface-soft'
|
||||
: 'bg-brand-600 text-white hover:bg-brand-700'"
|
||||
:disabled="busyId === action.id"
|
||||
@click="runAction(action)"
|
||||
:disabled="!backendPrimaryAction.enabled || busyId === backendPrimaryAction.code"
|
||||
@click="runUnifiedAction(backendPrimaryAction)"
|
||||
>
|
||||
{{ action.label }}
|
||||
{{ backendPrimaryAction.label || backendPrimaryAction.code }}
|
||||
</button>
|
||||
<button
|
||||
v-for="action in backendSecondaryActions"
|
||||
:key="action.code"
|
||||
type="button"
|
||||
class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft disabled:opacity-50"
|
||||
:disabled="!action.enabled || busyId === action.code"
|
||||
@click="runUnifiedAction(action)"
|
||||
>
|
||||
{{ action.label || action.code }}
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
v-if="showWaitingManualUploadNote"
|
||||
class="mt-3 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800"
|
||||
data-testid="manual-upload-end-note"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.todo.waitingManualUploadNote') }}
|
||||
</p>
|
||||
<ManualUploadEvidenceDialog
|
||||
v-model:open="manualUploadOpen"
|
||||
:task-no="detail.task_no"
|
||||
|
||||
Reference in new issue
Block a user