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"
|
||||
|
||||
Reference in new issue
Block a user