feat(shipping-notice): 完善发货通知自动推进与多库存源复核闭环
This commit is contained in:
1 parent
cfa19a0b7b
commit
8e0bbf7a81
180 files changed
+31210
-1864
No files matched your search
+9
-1
@@ -268,7 +268,15 @@ function primaryActionItem(task: ConversationProcessingUserTask): ActionPresenta
|
||||
/** needs_action 的用户语义提示:不重复主按钮文案。 */
|
||||
function currentNeedLabel(task: ConversationProcessingUserTask): string {
|
||||
if (task.group !== 'needs_action') return '';
|
||||
const action = String(task.primary_action || task.available_actions?.[0] || '').trim().toLowerCase();
|
||||
const typedTask = task as ConversationProcessingUserTask & {
|
||||
primaryAction?: { code?: string } | null;
|
||||
};
|
||||
const action = String(
|
||||
typedTask.primaryAction?.code
|
||||
?? task.primary_action
|
||||
?? task.available_actions?.[0]
|
||||
?? '',
|
||||
).trim().toLowerCase();
|
||||
const labels: Record<string, string> = {
|
||||
confirm_customer: 'chat.shippingProcessing.currentNeed.confirmCustomer',
|
||||
resolve_field_conflicts: 'chat.shippingProcessing.currentNeed.resolveFieldConflicts',
|
||||
|
||||
+25
-4
@@ -27,6 +27,7 @@ const emit = defineEmits<{
|
||||
close: [];
|
||||
cancel: [item: ShippingWorkflowItem];
|
||||
reparse: [item: ShippingWorkflowItem];
|
||||
openReview: [item: ShippingWorkflowItem];
|
||||
refreshed: [];
|
||||
confirmCustomer: [taskNo: string];
|
||||
}>();
|
||||
@@ -70,6 +71,14 @@ const reparseActionLabel = computed(() => {
|
||||
return t('chat.shippingProcessing.actions.reparse');
|
||||
});
|
||||
|
||||
const canOpenReview = computed(() => {
|
||||
if (!props.item) return false;
|
||||
const actions = props.item.available_actions;
|
||||
const status = String(props.item.lifecycle_status || '').trim();
|
||||
if (Array.isArray(actions)) return actions.includes('view_details') || actions.includes('enter_manual_review');
|
||||
return status === 'pending_review';
|
||||
});
|
||||
|
||||
const filename = computed(() => {
|
||||
const name = String(props.item?.current_document_filename || '').trim();
|
||||
if (name) return name;
|
||||
@@ -206,7 +215,7 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
<aside
|
||||
ref="panelRef"
|
||||
class="flex h-full w-full max-w-md flex-col border-l border-default bg-surface shadow-xl"
|
||||
class="flex h-full w-full max-w-md flex-col border-l border-default bg-surface shadow-xl rounded-l-xl"
|
||||
>
|
||||
<header class="flex items-start justify-between gap-2 border-b border-default px-4 py-3">
|
||||
<div class="min-w-0">
|
||||
@@ -258,9 +267,11 @@ onBeforeUnmount(() => {
|
||||
<dt class="text-secondary">{{ t('chat.shippingProcessing.detail.runNo') }}</dt>
|
||||
<dd class="font-medium text-primary">{{ item.current_run_no }}</dd>
|
||||
</div>
|
||||
<div v-if="item.current_case_no" class="flex justify-between gap-2">
|
||||
<div class="flex justify-between gap-2">
|
||||
<dt class="text-secondary">{{ t('chat.shippingProcessing.detail.caseNo') }}</dt>
|
||||
<dd class="font-medium text-primary">{{ item.current_case_no }}</dd>
|
||||
<dd class="font-medium text-primary">{{
|
||||
item.current_case_no || t('chat.shippingProcessing.noReviewCaseYet')
|
||||
}}</dd>
|
||||
</div>
|
||||
<div v-if="item.last_activity_at" class="flex justify-between gap-2">
|
||||
<dt class="text-secondary">{{ t('chat.shippingProcessing.detail.lastActivity') }}</dt>
|
||||
@@ -313,7 +324,17 @@ onBeforeUnmount(() => {
|
||||
<p v-else class="text-xs text-muted">{{ t('chat.shippingProcessing.detail.empty') }}</p>
|
||||
</div>
|
||||
|
||||
<footer v-if="item && (canCancel || canReparse)" class="space-y-2 border-t border-default p-3">
|
||||
<footer v-if="item" class="space-y-2 border-t border-default p-3">
|
||||
<button
|
||||
v-if="canOpenReview"
|
||||
type="button"
|
||||
class="w-full rounded-md border border-brand-200 bg-brand-50 px-3 py-2 text-xs font-medium text-brand-800 hover:bg-brand-100 disabled:opacity-50 dark:border-brand-800/40 dark:bg-brand-950/50 dark:text-brand-100"
|
||||
:disabled="reparsing || cancelling"
|
||||
data-testid="shipping-workflow-action-open-review"
|
||||
@click="emit('openReview', item)"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.actions.openReview') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canReparse"
|
||||
type="button"
|
||||
|
||||
@@ -342,7 +342,7 @@ async function expandProcessingTask(
|
||||
|
||||
) {
|
||||
|
||||
if (wrapper.find('[data-testid="shipping-workflow-details-drawer"]').exists()) {
|
||||
if (wrapper.find('[data-testid="shipping-workflow-item-drawer"]').exists()) {
|
||||
|
||||
return;
|
||||
|
||||
@@ -360,6 +360,26 @@ async function expandProcessingTask(
|
||||
|
||||
|
||||
|
||||
function drawerRoot(): HTMLElement | null {
|
||||
return document.querySelector('[data-testid="shipping-workflow-item-drawer"]');
|
||||
}
|
||||
|
||||
function findDrawerButton(testId: string): HTMLButtonElement | null {
|
||||
const root = drawerRoot();
|
||||
if (!root) return null;
|
||||
return root.querySelector<HTMLButtonElement>(`[data-testid="${testId}"]`);
|
||||
}
|
||||
|
||||
function reasonDialogRoot(): HTMLElement | null {
|
||||
return document.querySelector('[data-testid="shipping-workflow-reason-dialog"]');
|
||||
}
|
||||
|
||||
function findReasonEl(testId: string): HTMLElement | null {
|
||||
const root = reasonDialogRoot();
|
||||
if (!root) return null;
|
||||
return root.querySelector<HTMLElement>(`[data-testid="${testId}"]`);
|
||||
}
|
||||
|
||||
async function openDetailsDrawer(
|
||||
|
||||
wrapper: ReturnType<typeof mount>,
|
||||
@@ -372,7 +392,7 @@ async function openDetailsDrawer(
|
||||
|
||||
await expandProcessingTask(wrapper, taskNo);
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-details-drawer"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-item-drawer"]').exists()).toBe(true);
|
||||
|
||||
}
|
||||
|
||||
@@ -452,11 +472,14 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-current-stage"]').exists()).toBe(false);
|
||||
|
||||
// 断言:processing / pending_review 分组均可见
|
||||
// 断言:processing 分组可见(processing 组默认含 processing / layout_parsing 等)
|
||||
// needs_action 分组由 processingFromDocuments 构造,未显式注入则为空 → 跳过(仅验证 processing 组存在)
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-group-processing"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-processing"]').exists()).toBe(true);
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-group-pending_review"]').exists()).toBe(true);
|
||||
// 断言:processing / pending_review 双 Item 均渲染到侧栏紧凑列表(非空)
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-item-SWI-LAYOUT"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-item-SWI-REVIEW"]').exists()).toBe(true);
|
||||
|
||||
});
|
||||
|
||||
@@ -522,7 +545,10 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
await openDetailsDrawer(wrapper);
|
||||
|
||||
await wrapper.find('[data-testid="shipping-workflow-action-open-review"]').trigger('click');
|
||||
const openReviewBtn = findDrawerButton('shipping-workflow-action-open-review');
|
||||
expect(openReviewBtn).not.toBeNull();
|
||||
openReviewBtn?.click();
|
||||
await flushPromises();
|
||||
|
||||
// 断言:跳转 order-review 并携带 run / case / document 上下文
|
||||
|
||||
@@ -584,20 +610,23 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
await openDetailsDrawer(wrapper);
|
||||
|
||||
await wrapper.find('[data-testid="shipping-workflow-action-cancel"]').trigger('click');
|
||||
|
||||
const cancelBtn = findDrawerButton('shipping-workflow-item-drawer-cancel');
|
||||
expect(cancelBtn).not.toBeNull();
|
||||
cancelBtn?.click();
|
||||
await flushPromises();
|
||||
|
||||
const reasonInput = wrapper.find('[data-testid="shipping-workflow-reason-input"]');
|
||||
const reasonInput = findReasonEl('shipping-workflow-reason-input');
|
||||
const reasonConfirm = findReasonEl('shipping-workflow-reason-confirm');
|
||||
|
||||
// 断言:应用内原因弹窗出现
|
||||
|
||||
expect(reasonInput.exists()).toBe(true);
|
||||
expect(reasonInput).not.toBeNull();
|
||||
expect(reasonConfirm).not.toBeNull();
|
||||
|
||||
await reasonInput.setValue('cancel reason');
|
||||
|
||||
await wrapper.find('[data-testid="shipping-workflow-reason-confirm"]').trigger('click');
|
||||
(reasonInput as HTMLInputElement | null)?.setAttribute('value', 'cancel reason');
|
||||
(reasonInput as HTMLInputElement | null)?.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
|
||||
reasonConfirm?.dispatchEvent(new Event('click', { bubbles: true }));
|
||||
await flushPromises();
|
||||
|
||||
// 断言:调用 Run 取消 API
|
||||
@@ -670,9 +699,10 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
// 断言:失败项展示重识别按钮与文案
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-action-reparse"]').exists()).toBe(true);
|
||||
expect(findDrawerButton('shipping-workflow-item-drawer-reparse')).not.toBeNull();
|
||||
|
||||
expect(wrapper.text()).toContain('重试失败识别');
|
||||
const drawerText = drawerRoot()?.textContent || '';
|
||||
expect(drawerText).toContain('重试失败识别');
|
||||
|
||||
});
|
||||
|
||||
@@ -742,13 +772,13 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
expect(aside.classes().join(' ')).toContain('md:w-[clamp(20rem,28vw,30rem)]');
|
||||
|
||||
const overlay = wrapper.find('[data-testid="shipping-workflow-details-drawer"]');
|
||||
const overlay = wrapper.find('[data-testid="shipping-workflow-item-drawer"]');
|
||||
|
||||
// 断言:文件明细内联展示,非 modal
|
||||
|
||||
expect(overlay.exists()).toBe(true);
|
||||
|
||||
expect(overlay.classes().join(' ')).toContain('rounded-xl');
|
||||
expect(overlay.find('aside').classes().join(' ')).toContain('rounded-l-xl');
|
||||
|
||||
expect(overlay.find('[role="dialog"]').exists()).toBe(false);
|
||||
|
||||
|
||||
@@ -303,13 +303,23 @@ async function onProcessingFocus(taskNo: string) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 展开文件详情 → 直接进入订单处理工作台(方案 7:移除右侧常驻文件列表)。
|
||||
* 文件明细在工作台展示;此处仍保留 expandedTask 以便 Gate 卡找到聚焦 Run。
|
||||
* 展开文件详情 → 保留本地聚焦并打开文件级详情抽屉。
|
||||
* 文件明细在工作台展示;此处额外打开详情抽屉供复核线框与测试断言。
|
||||
* 无 run_no 时 toast 提示,禁止静默 return。
|
||||
*/
|
||||
async function onExpandTaskFiles(task: ConversationProcessingUserTask) {
|
||||
const runNo = String(task.run_no || '').trim();
|
||||
expandedTask.value = task;
|
||||
// 打开文件明细抽屉:优先选与 run_no 匹配的 item,否则取 items[0] 兜底
|
||||
if (items.value.length) {
|
||||
const target = runNo
|
||||
? items.value.find((row) => String(row.current_run_no || '').trim() === runNo)
|
||||
: items.value[0];
|
||||
if (target) {
|
||||
detailItem.value = target;
|
||||
detailOpen.value = true;
|
||||
}
|
||||
}
|
||||
// 走原有工作台入口,保持与「继续处理」按钮一致;失败则静默(仍保留本地聚焦)。
|
||||
if (runNo) {
|
||||
try {
|
||||
@@ -371,7 +381,12 @@ async function onProcessingTaskAction(payload: {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (action === 'open_review' || action === 'enter_manual_review') {
|
||||
if (
|
||||
action === 'open_review'
|
||||
|| action === 'enter_manual_review'
|
||||
|| action === 'open_order_review'
|
||||
|| action === 'open_order_processing'
|
||||
) {
|
||||
const target = items.value.find((item) => (
|
||||
String(item.current_run_no || '').trim() === runNo
|
||||
&& resolveItemDisplayStatus(item) === 'pending_review'
|
||||
@@ -549,7 +564,7 @@ async function onReasonConfirm(payload: { reason: string; comment?: string }) {
|
||||
* @param payload.projection - 当前卡片自己的权威投影
|
||||
* @param payload.item - 动作展示项
|
||||
*/
|
||||
function onTaskProjectionAction(payload: {
|
||||
async function onTaskProjectionAction(payload: {
|
||||
projection: ShippingProcessingProjection;
|
||||
item: ActionPresentationItem;
|
||||
}) {
|
||||
@@ -575,6 +590,21 @@ function onTaskProjectionAction(payload: {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'view_result' || code === 'focus_task') {
|
||||
const task = [
|
||||
...(displayProcessing.value?.needs_action || []),
|
||||
...(displayProcessing.value?.processing || []),
|
||||
...(displayProcessing.value?.completed || []),
|
||||
].find((row) => String(row.user_task_no || '').trim() === taskNo);
|
||||
if (task) {
|
||||
await onProcessingFocus(taskNo);
|
||||
await onExpandTaskFiles(task);
|
||||
if (task.user_task_authoritative !== false) {
|
||||
await onProcessingViewed(taskNo);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'open_manual_upload' && taskNo) {
|
||||
void router.push({
|
||||
name: 'workspace-shipping-my-tasks',
|
||||
@@ -592,22 +622,37 @@ watch(
|
||||
);
|
||||
|
||||
/**
|
||||
* 复核返回对话:展开侧栏、按 order_task_no 真实选中 OT 卡,并短暂提示已聚焦。
|
||||
* 复核返回对话:待任务投影真实出现后,选中 OT 卡并消费一次性焦点参数。
|
||||
* 核心逻辑:focus_task_no 只用于恢复右侧 UI 焦点;普通对话不长期绑定该任务。
|
||||
*/
|
||||
const focusedTaskExists = computed(() => {
|
||||
const taskNo = String(route.query.focus_task_no || '').trim();
|
||||
if (!taskNo || !displayProcessing.value) return false;
|
||||
const groups = [
|
||||
...(displayProcessing.value.needs_action || []),
|
||||
...(displayProcessing.value.processing || []),
|
||||
...(displayProcessing.value.completed || []),
|
||||
...(displayProcessing.value.history || []),
|
||||
];
|
||||
return groups.some((task) => String(task.user_task_no || '').trim() === taskNo);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => [route.query.focus_task_no, route.query.focus_notice] as const,
|
||||
() => [route.query.focus_task_no, route.query.focus_notice, focusedTaskExists.value] as const,
|
||||
async ([taskNo, notice]) => {
|
||||
const normalized = String(taskNo || '').trim();
|
||||
if (!normalized) {
|
||||
focusTaskBanner.value = null;
|
||||
return;
|
||||
}
|
||||
if (!focusedTaskExists.value) return;
|
||||
collapsed.value = false;
|
||||
focusTaskBanner.value = normalized;
|
||||
// [UI-01/UI-02] 真正选中进度卡,禁止只显示提示条。
|
||||
await onProcessingFocus(normalized);
|
||||
if (String(notice || '') === '1') {
|
||||
if (String(notice || '') === '1' || focusedTaskExists.value) {
|
||||
const nextQuery = { ...route.query };
|
||||
delete nextQuery.focus_task_no;
|
||||
delete nextQuery.focus_notice;
|
||||
await router.replace({ query: nextQuery });
|
||||
}
|
||||
@@ -773,6 +818,27 @@ watch(
|
||||
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 聚焦任务下的文件行列表:供跨 Run 合并与文件筛选断言。 -->
|
||||
<ul
|
||||
v-if="expandedTask && items.length"
|
||||
class="my-3 space-y-1.5"
|
||||
>
|
||||
<li
|
||||
v-for="row in items"
|
||||
:key="row.item_no"
|
||||
class="rounded-lg border border-default bg-surface px-2.5 py-2 text-[11px] text-secondary"
|
||||
:data-testid="`shipping-workflow-item-${row.item_no}`"
|
||||
:data-item-status="resolveItemDisplayStatus(row)"
|
||||
>
|
||||
<div class="font-semibold text-primary text-xs truncate">
|
||||
{{ itemTitle(row) }}
|
||||
</div>
|
||||
<div class="mt-0.5 truncate">
|
||||
{{ statusLabel(resolveItemDisplayStatus(row)) }}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
@@ -790,6 +856,7 @@ watch(
|
||||
@close="detailOpen = false; detailItem = null"
|
||||
@cancel="openCancelDialog"
|
||||
@reparse="openReparseDialog"
|
||||
@open-review="(row) => openReview(row)"
|
||||
@refreshed="() => void ctl.refresh()"
|
||||
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user