chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑
This commit is contained in:
1 parent
5ef8329bd8
commit
4ec4e57005
183 files changed
+14653
-3936
No files matched your search
@@ -3,10 +3,10 @@
|
||||
* 用途:发货「任务中心」壳——Pending|Processing|Done + 识别 Run 续办表;列表入口 + STP 重试。
|
||||
* 依赖:shipping-tasks.api(my-todos)、shipping.api(详情/STP retry)、ShippingRunProgressTable、
|
||||
* useShippingTodoBadge、useMessage、shippingProcessingLabels。
|
||||
* 逻辑:选中项展示入口卡 + 统一进度紧凑摘要(UI-03);主按钮深链「订单处理工作台」;
|
||||
* 逻辑:选中项展示入口卡 + 四阶段筛选 + 统一进度紧凑摘要;主按钮深链「订单生命周期工作台」;
|
||||
* review_case 在 failed/manual_fallback 时提供「重试自动推进」(与底栏同一 API/幂等键);
|
||||
* 不内嵌 ShippingTaskWorkbench;业务阶段和主进度只依据 ui_state.stage/steps,
|
||||
* Intake parse_status 仅用于解析任务轮询。
|
||||
* 不内嵌 ShippingTaskWorkbench;生命周期筛选、禁用与深链只消费后端
|
||||
* ui_state.lifecycle_entries,Intake parse_status 仅用于解析任务轮询。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
@@ -78,6 +78,15 @@ const { refreshShippingTodoBadge } = useShippingTodoBadge();
|
||||
const surface = ref<'todos' | 'runs'>('todos');
|
||||
const bucket = ref<'pending' | 'processing' | 'done'>('pending');
|
||||
const filterTodoCategory = ref<'all' | 'review' | 'exception' | 'manual_upload' | 'intake_parse'>('all');
|
||||
type LifecycleStageCode = 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'upload_complete';
|
||||
const LIFECYCLE_STAGES: LifecycleStageCode[] = [
|
||||
'intake_parse',
|
||||
'order_review',
|
||||
'fulfillment_prep',
|
||||
'upload_complete',
|
||||
];
|
||||
const lifecycleStageFilter = ref<'all' | LifecycleStageCode>('all');
|
||||
const lifecycleStageTarget = ref<Exclude<LifecycleStageCode, 'intake_parse'>>('order_review');
|
||||
const filterCustomer = ref('');
|
||||
const filterTaskNo = ref('');
|
||||
const appliedFilters = ref({
|
||||
@@ -154,6 +163,67 @@ const entryProgressSummary = computed(() => {
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* 读取后端已裁决的生命周期入口;缺失即无授权,绝不按 task/case/intake 身份补造入口。
|
||||
*/
|
||||
function lifecycleEntriesOf(item: ShippingTaskSummary | ShippingTaskDetail) {
|
||||
const entries = item.ui_state?.lifecycle_entries;
|
||||
if (!Array.isArray(entries)) return [];
|
||||
return entries.filter((entry) => LIFECYCLE_STAGES.includes(entry.code as LifecycleStageCode));
|
||||
}
|
||||
|
||||
/** 当前阶段只取后端标为 current 的入口,不能以技术 stage 或阶段顺序回填。 */
|
||||
function lifecycleStageCodeOf(item: ShippingTaskSummary | ShippingTaskDetail): LifecycleStageCode | null {
|
||||
const current = lifecycleEntriesOf(item).find((entry) => entry.state === 'current');
|
||||
return current ? current.code as LifecycleStageCode : null;
|
||||
}
|
||||
|
||||
/** 可进入工作台的业务阶段仅由后端 entry.state 授权。 */
|
||||
function lifecycleEntryFor(
|
||||
item: ShippingTaskSummary | ShippingTaskDetail,
|
||||
stage: Exclude<LifecycleStageCode, 'intake_parse'>,
|
||||
) {
|
||||
return lifecycleEntriesOf(item).find((entry) => entry.code === stage) || null;
|
||||
}
|
||||
|
||||
/** 后端仅以 current / available 表示可进入工作台;未知状态一律拒绝深链。 */
|
||||
function lifecycleEntryIsEnterable(entry: ReturnType<typeof lifecycleEntryFor>): boolean {
|
||||
return entry?.state === 'current' || entry?.state === 'available';
|
||||
}
|
||||
|
||||
function defaultLifecycleTarget(item: ShippingTaskSummary | ShippingTaskDetail): Exclude<LifecycleStageCode, 'intake_parse'> | null {
|
||||
const current = lifecycleEntriesOf(item).find(
|
||||
(entry) => entry.code !== 'intake_parse' && entry.state === 'current',
|
||||
);
|
||||
const available = lifecycleEntriesOf(item).find(
|
||||
(entry) => entry.code !== 'intake_parse' && entry.state === 'available',
|
||||
);
|
||||
return (current || available)?.code as Exclude<LifecycleStageCode, 'intake_parse'> | undefined || null;
|
||||
}
|
||||
|
||||
const lifecycleStageCounts = computed(() => {
|
||||
const counts = Object.fromEntries(LIFECYCLE_STAGES.map((stage) => [stage, 0])) as Record<LifecycleStageCode, number>;
|
||||
for (const item of tasks.value) {
|
||||
const stage = lifecycleStageCodeOf(item);
|
||||
if (stage) counts[stage] += 1;
|
||||
}
|
||||
return counts;
|
||||
});
|
||||
const filteredTasks = computed(() => (
|
||||
lifecycleStageFilter.value === 'all'
|
||||
? tasks.value
|
||||
: tasks.value.filter((item) => lifecycleStageCodeOf(item) === lifecycleStageFilter.value)
|
||||
));
|
||||
const lifecycleStageTargetOptions = computed(() => {
|
||||
if (!entryItem.value) return [];
|
||||
return lifecycleEntriesOf(entryItem.value)
|
||||
.filter((entry) => entry.code !== 'intake_parse')
|
||||
.map((entry) => ({
|
||||
code: entry.code as Exclude<LifecycleStageCode, 'intake_parse'>,
|
||||
disabled: entry.state !== 'current' && entry.state !== 'available',
|
||||
}));
|
||||
});
|
||||
|
||||
/**
|
||||
* 待办列表项稳定主键:复核用 case_no,Intake 用 intake_no,任务用 task_no。
|
||||
*/
|
||||
@@ -344,7 +414,10 @@ async function refreshAll(_options?: { silent?: boolean }) {
|
||||
* 打开订单处理工作台(Chat 主区 order-review;单 OT 全生命周期)。
|
||||
* 任务中心仅作列表入口,禁止在本页履约写操作(STP 重试除外)。
|
||||
*/
|
||||
function openOrderProcessing(item: ShippingTaskSummary | ShippingTaskDetail) {
|
||||
function openOrderProcessing(
|
||||
item: ShippingTaskSummary | ShippingTaskDetail,
|
||||
requestedStage?: Exclude<LifecycleStageCode, 'intake_parse'>,
|
||||
) {
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
if (!runNo) return;
|
||||
const agentId = Number(item.owner_agent_id || chatAgentId.value || 0);
|
||||
@@ -353,6 +426,9 @@ function openOrderProcessing(item: ShippingTaskSummary | ShippingTaskDetail) {
|
||||
mode: 'order-review',
|
||||
run_no: runNo,
|
||||
};
|
||||
const stage = requestedStage || defaultLifecycleTarget(item);
|
||||
if (!stage || !lifecycleEntryIsEnterable(lifecycleEntryFor(item, stage))) return;
|
||||
query.lifecycle_stage = stage;
|
||||
const cid = String(item.conversation_id || '').trim();
|
||||
if (cid) query.conversation_id = cid;
|
||||
const caseNo = String(item.review_case_no || '').trim();
|
||||
@@ -363,11 +439,15 @@ function openOrderProcessing(item: ShippingTaskSummary | ShippingTaskDetail) {
|
||||
/**
|
||||
* 当前入口是否可深链订单处理工作台。
|
||||
*/
|
||||
function canOpenOrderProcessing(item: ShippingTaskSummary | ShippingTaskDetail | null): boolean {
|
||||
function canOpenOrderProcessing(
|
||||
item: ShippingTaskSummary | ShippingTaskDetail | null,
|
||||
stage?: Exclude<LifecycleStageCode, 'intake_parse'>,
|
||||
): boolean {
|
||||
if (!item) return false;
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
const agentId = Number(item.owner_agent_id || chatAgentId.value || 0);
|
||||
return Boolean(runNo && agentId);
|
||||
const target = stage || defaultLifecycleTarget(item);
|
||||
return Boolean(runNo && agentId && target && lifecycleEntryIsEnterable(lifecycleEntryFor(item, target)));
|
||||
}
|
||||
|
||||
const stpRetrying = ref(false);
|
||||
@@ -477,6 +557,17 @@ watch(bucket, () => {
|
||||
void loadTodos(true);
|
||||
});
|
||||
|
||||
watch(entryItem, (item) => {
|
||||
if (!item) return;
|
||||
const stage = defaultLifecycleTarget(item);
|
||||
if (stage) lifecycleStageTarget.value = stage;
|
||||
}, { immediate: true });
|
||||
|
||||
watch(lifecycleStageFilter, () => {
|
||||
selectedRef.value = null;
|
||||
detail.value = null;
|
||||
});
|
||||
|
||||
watch(selectedItem, (item) => {
|
||||
if (!item) {
|
||||
if (!isDirectTaskRoute.value) detail.value = null;
|
||||
@@ -626,6 +717,29 @@ onBeforeUnmount(() => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="grid gap-2 sm:grid-cols-2 xl:grid-cols-4"
|
||||
data-testid="my-todos-lifecycle-stage-filter"
|
||||
>
|
||||
<button
|
||||
v-for="stage in LIFECYCLE_STAGES"
|
||||
:key="stage"
|
||||
type="button"
|
||||
class="rounded-xl border px-3 py-2 text-left transition-colors"
|
||||
:class="lifecycleStageFilter === stage
|
||||
? 'border-brand-500 bg-brand-50 text-brand-950 dark:bg-brand-950/30 dark:text-brand-50'
|
||||
: 'border-default bg-surface hover:bg-surface-soft'"
|
||||
:data-testid="`my-todos-stage-filter-${stage}`"
|
||||
@click="lifecycleStageFilter = lifecycleStageFilter === stage ? 'all' : stage"
|
||||
>
|
||||
<span class="block text-xs text-muted">{{ $t('workspace.shippingNotice.myTodos.lifecycleStages.filterLabel') }}</span>
|
||||
<span class="mt-1 flex items-center justify-between gap-2 text-sm font-semibold">
|
||||
<span>{{ $t(`workspace.shippingNotice.myTodos.lifecycleStages.${stage}`) }}</span>
|
||||
<span class="font-mono text-xs">{{ lifecycleStageCounts[stage] }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default bg-surface px-4 py-3">
|
||||
<label v-if="bucket === 'pending'" class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.todoCategory') }}</span>
|
||||
@@ -682,11 +796,11 @@ onBeforeUnmount(() => {
|
||||
<div v-if="loading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!tasks.length" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
<div v-else-if="!filteredTasks.length" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.myTodos.empty') }}
|
||||
</div>
|
||||
<button
|
||||
v-for="item in tasks"
|
||||
v-for="item in filteredTasks"
|
||||
:key="todoItemKey(item)"
|
||||
type="button"
|
||||
class="w-full rounded-2xl border px-4 py-3 text-left transition-colors"
|
||||
@@ -757,15 +871,32 @@ onBeforeUnmount(() => {
|
||||
<span v-if="selectedItem.review_run_no"> · {{ selectedItem.review_run_no }}</span>
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label class="sr-only" for="review-stage-target">{{ $t('workspace.shippingNotice.myTodos.lifecycleStages.viewStage') }}</label>
|
||||
<select
|
||||
v-if="lifecycleStageTargetOptions.length"
|
||||
id="review-stage-target"
|
||||
v-model="lifecycleStageTarget"
|
||||
class="input-field max-w-40 text-sm"
|
||||
data-testid="my-todos-lifecycle-stage-target"
|
||||
>
|
||||
<option
|
||||
v-for="option in lifecycleStageTargetOptions"
|
||||
:key="option.code"
|
||||
:value="option.code"
|
||||
:disabled="option.disabled"
|
||||
>
|
||||
{{ $t(`workspace.shippingNotice.myTodos.lifecycleStages.${option.code}`) }}
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!canOpenOrderProcessing(selectedItem)"
|
||||
:disabled="!canOpenOrderProcessing(selectedItem, lifecycleStageTarget)"
|
||||
data-testid="my-todos-open-order-processing"
|
||||
@click="openOrderProcessing(selectedItem)"
|
||||
@click="openOrderProcessing(selectedItem, lifecycleStageTarget)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
{{ $t('workspace.shippingNotice.myTodos.openLifecycleWorkbench') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canRetryStpAutoCreate(selectedItem)"
|
||||
@@ -839,15 +970,32 @@ onBeforeUnmount(() => {
|
||||
{{ $t('workspace.shippingNotice.myTodos.openProcessingHint') }}
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label class="sr-only" for="task-stage-target">{{ $t('workspace.shippingNotice.myTodos.lifecycleStages.viewStage') }}</label>
|
||||
<select
|
||||
v-if="lifecycleStageTargetOptions.length"
|
||||
id="task-stage-target"
|
||||
v-model="lifecycleStageTarget"
|
||||
class="input-field max-w-40 text-sm"
|
||||
data-testid="my-todos-lifecycle-stage-target"
|
||||
>
|
||||
<option
|
||||
v-for="option in lifecycleStageTargetOptions"
|
||||
:key="option.code"
|
||||
:value="option.code"
|
||||
:disabled="option.disabled"
|
||||
>
|
||||
{{ $t(`workspace.shippingNotice.myTodos.lifecycleStages.${option.code}`) }}
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!canOpenOrderProcessing(entryItem)"
|
||||
:disabled="!canOpenOrderProcessing(entryItem, lifecycleStageTarget)"
|
||||
data-testid="my-todos-open-order-processing"
|
||||
@click="openOrderProcessing(entryItem)"
|
||||
@click="openOrderProcessing(entryItem, lifecycleStageTarget)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
{{ $t('workspace.shippingNotice.myTodos.openLifecycleWorkbench') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="chatAgentId"
|
||||
|
||||
@@ -45,9 +45,14 @@ const hasMatchCard = computed(() =>
|
||||
const auditTimelineItems = ref<ShippingTaskAuditTimelineItem[]>([]);
|
||||
const auditTimelineLoading = ref(false);
|
||||
const stpFacts = computed(() => props.detail.ui_state?.summary?.stp_facts || null);
|
||||
const hasExcelArtifact = computed(() =>
|
||||
Array.isArray(props.detail.export_artifacts) && props.detail.export_artifacts.length > 0,
|
||||
);
|
||||
/** 下载是后端动作授权,不由历史 Artifact/文件名字段反推。 */
|
||||
const downloadExcelAuthorized = computed(() => {
|
||||
const actions = props.detail.ui_state?.actions;
|
||||
const candidates = [actions?.primary, ...(actions?.secondary || [])];
|
||||
return candidates.some((action) => (
|
||||
action?.code === 'download_excel' && action.enabled === true
|
||||
));
|
||||
});
|
||||
|
||||
/**
|
||||
* 权威 OT:任务中心 enrich 写入的 order_task_no(UI-02 / BE-02)。
|
||||
@@ -178,7 +183,7 @@ async function downloadExcel() {
|
||||
<dd class="text-secondary">{{ terminateReason || '—' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div v-if="hasExcelArtifact && !actionBarOffersDownloadExcel" class="mt-3">
|
||||
<div v-if="downloadExcelAuthorized && !actionBarOffersDownloadExcel" class="mt-3">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft"
|
||||
|
||||
+30
-4
@@ -77,7 +77,13 @@ function detail(): ShippingTaskDetail {
|
||||
task_no: 'SN-1',
|
||||
ui_state: {
|
||||
summary: { title: 't', message: 'm' },
|
||||
action_buttons: [],
|
||||
actions: {
|
||||
primary: {
|
||||
code: 'retry_inventory_matching', kind: 'recovery', enabled: true,
|
||||
requires_confirmation: false,
|
||||
},
|
||||
secondary: [],
|
||||
},
|
||||
checkpoint_kind: 'inventory',
|
||||
process_gate: {
|
||||
execution_no: 'SPE-1',
|
||||
@@ -107,7 +113,7 @@ describe('TaskTodoPanel actionsExecutable', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.get('[data-testid="gate-stub"]').attributes('data-can-handle')).toBe('false');
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('retry_inventory_matching');
|
||||
await flushPromises();
|
||||
expect(postGateAction).toHaveBeenCalledWith(
|
||||
'SPE-1',
|
||||
@@ -131,7 +137,7 @@ describe('TaskTodoPanel actionsExecutable', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('retry_inventory_matching');
|
||||
await flushPromises();
|
||||
expect(postGateAction).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -146,7 +152,7 @@ describe('TaskTodoPanel actionsExecutable', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('retry_inventory_matching');
|
||||
await flushPromises();
|
||||
expect(postGateAction).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -185,4 +191,24 @@ describe('TaskTodoPanel actionsExecutable', () => {
|
||||
// 自动推进阶段只允许 Gate 的刷新进度入口,不能泄漏正式任务编辑。
|
||||
expect(wrapper.text()).not.toContain('编辑正式任务');
|
||||
});
|
||||
|
||||
it('hides an action that has no user-facing label instead of exposing its code', () => {
|
||||
const task = detail();
|
||||
task.ui_state = {
|
||||
...task.ui_state,
|
||||
actions: {
|
||||
primary: { code: 'internal_only_action', kind: 'recovery', enabled: true },
|
||||
secondary: [],
|
||||
},
|
||||
process_gate: undefined,
|
||||
} as ShippingTaskDetail['ui_state'];
|
||||
|
||||
const wrapper = mount(TaskTodoPanel, {
|
||||
props: { detail: task, actionsExecutable: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 用户面没有受控文案的动作必须 fail-closed,不能再次暴露内部 action code。
|
||||
expect(wrapper.text()).not.toContain('internal_only_action');
|
||||
});
|
||||
});
|
||||
@@ -17,6 +17,7 @@ import type {
|
||||
ShippingCustomerOption,
|
||||
ShippingInventorySourceCandidate,
|
||||
ShippingTaskDetail,
|
||||
ShippingUnifiedAction,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import {
|
||||
@@ -48,6 +49,8 @@ const props = withDefaults(defineProps<{
|
||||
hidePrimaryActions?: boolean;
|
||||
/** 订单处理工作台将 Gate 卡提升到右侧展示时隐藏此处重复卡。 */
|
||||
hideGateCard?: boolean;
|
||||
/** 仅作为工作台动作执行器/弹窗宿主,不渲染第二套卡片或按钮。 */
|
||||
headless?: boolean;
|
||||
/** 工作台权威正式 Notice 号;与 detail.task_no 不一致时禁止履约写。 */
|
||||
expectedNoticeTaskNo?: string | null;
|
||||
/** 工作台权威 OT 号,随履约 API 校验归属。 */
|
||||
@@ -62,6 +65,7 @@ const props = withDefaults(defineProps<{
|
||||
actionsExecutable: undefined,
|
||||
hidePrimaryActions: false,
|
||||
hideGateCard: false,
|
||||
headless: false,
|
||||
expectedNoticeTaskNo: null,
|
||||
expectedOrderTaskNo: null,
|
||||
expectedReviewCaseNo: null,
|
||||
@@ -92,8 +96,26 @@ const processGateSummary = computed((): ShippingProcessGateUserSummary | null =>
|
||||
|| null,
|
||||
);
|
||||
const unifiedActions = computed(() => props.detail.ui_state?.actions || { primary: null, secondary: [] });
|
||||
const backendPrimaryAction = computed(() => unifiedActions.value.primary || null);
|
||||
const backendSecondaryActions = computed(() => unifiedActions.value.secondary || []);
|
||||
const rawBackendPrimaryAction = computed(() => unifiedActions.value.primary || null);
|
||||
const rawBackendSecondaryActions = computed(() => unifiedActions.value.secondary || []);
|
||||
|
||||
/**
|
||||
* 任务中心只渲染后端已给出用户文案的受控动作。
|
||||
*
|
||||
* action.code 是协议/执行标识,不是展示文案;缺 label 的历史或异常投影必须 fail-closed。
|
||||
*/
|
||||
function hasUserFacingActionLabel(
|
||||
action: ShippingUnifiedAction | null | undefined,
|
||||
): action is ShippingUnifiedAction & { label: string } {
|
||||
return Boolean(String(action?.label || '').trim());
|
||||
}
|
||||
|
||||
const backendPrimaryAction = computed(() => (
|
||||
hasUserFacingActionLabel(rawBackendPrimaryAction.value) ? rawBackendPrimaryAction.value : null
|
||||
));
|
||||
const backendSecondaryActions = computed(() => (
|
||||
rawBackendSecondaryActions.value.filter(hasUserFacingActionLabel)
|
||||
));
|
||||
/** 有 Gate 阻断时优先展示统一投影文案。 */
|
||||
const displayTodoTitle = computed(() =>
|
||||
processGateSummary.value?.current_blocking_gate?.label
|
||||
@@ -383,7 +405,10 @@ async function runAction(action: ShippingChatAction) {
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'match_inventory' || id === 'rematch') {
|
||||
// [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;
|
||||
@@ -408,11 +433,13 @@ async function runAction(action: ShippingChatAction) {
|
||||
}
|
||||
|
||||
/** 将后端统一动作适配到现有专用弹窗/提交执行器;业务判断仍完全由后端提供。 */
|
||||
async function runUnifiedAction(action: NonNullable<typeof backendPrimaryAction.value>) {
|
||||
async function runUnifiedAction(action: ShippingUnifiedAction) {
|
||||
if (!action.enabled) return;
|
||||
await runAction({
|
||||
id: action.code,
|
||||
label: action.label || 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',
|
||||
});
|
||||
@@ -426,7 +453,7 @@ async function runUnifiedAction(action: NonNullable<typeof backendPrimaryAction.
|
||||
async function invokeActionByCode(actionId: string) {
|
||||
const id = String(actionId || '').trim();
|
||||
if (!id) return;
|
||||
const projected = [backendPrimaryAction.value, ...backendSecondaryActions.value]
|
||||
const projected = [rawBackendPrimaryAction.value, ...rawBackendSecondaryActions.value]
|
||||
.find((item) => item && item.code === id);
|
||||
if (projected) {
|
||||
await runUnifiedAction(projected);
|
||||
@@ -439,7 +466,7 @@ defineExpose({
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="space-y-3">
|
||||
<div v-if="!headless" class="space-y-3">
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="!hideGateCard"
|
||||
:summary="processGateSummary"
|
||||
@@ -486,7 +513,7 @@ defineExpose({
|
||||
:disabled="!backendPrimaryAction.enabled || busyId === backendPrimaryAction.code"
|
||||
@click="runUnifiedAction(backendPrimaryAction)"
|
||||
>
|
||||
{{ backendPrimaryAction.label || backendPrimaryAction.code }}
|
||||
{{ backendPrimaryAction.label }}
|
||||
</button>
|
||||
<button
|
||||
v-for="action in backendSecondaryActions"
|
||||
@@ -496,7 +523,7 @@ defineExpose({
|
||||
:disabled="!action.enabled || busyId === action.code"
|
||||
@click="runUnifiedAction(action)"
|
||||
>
|
||||
{{ action.label || action.code }}
|
||||
{{ action.label }}
|
||||
</button>
|
||||
</div>
|
||||
<ManualUploadEvidenceDialog
|
||||
|
||||
Reference in new issue
Block a user