feat(shipping-notice): 实现滚动履约功能,优化发货通知流程与代码清理
清理废弃的ShippingCase相关代码与依赖,统一使用ShippingNotice直接关联客户数据。调整库存网关依赖规则,支持仅对库存满足或已人工放行的订单行生成发货Excel,实现滚动履约逻辑。
This commit is contained in:
1 parent
7cfd5d167e
commit
1e5aedb9ed
235 files changed
+11394
-9613
No files matched your search
@@ -145,6 +145,15 @@ onBeforeUnmount(() => {
|
||||
<component v-if="!collapsed" :is="shippingExpanded ? ChevronDown : ChevronRight" class="h-4 w-4" />
|
||||
</button>
|
||||
<div v-if="!collapsed && shippingExpanded" class="mt-1 space-y-1 pl-5">
|
||||
<RouterLink
|
||||
v-if="isAdmin"
|
||||
:to="WORKSPACE_PATHS.shippingNoticeCustomers"
|
||||
class="ws-nav-btn py-2.5 text-[13px]"
|
||||
:class="{ 'ws-nav-btn--active': isActive(['workspace-shipping-customers']) }"
|
||||
>
|
||||
<ContactRound class="h-4 w-4" />
|
||||
<span>{{ $t('workspace.nav.shippingCustomers') }}</span>
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
:to="WORKSPACE_PATHS.shippingNoticeMyTasks"
|
||||
class="ws-nav-btn py-2.5 text-[13px]"
|
||||
@@ -159,15 +168,6 @@ onBeforeUnmount(() => {
|
||||
{{ pendingBadge > 99 ? '99+' : pendingBadge }}
|
||||
</span>
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
v-if="isAdmin"
|
||||
:to="WORKSPACE_PATHS.shippingNoticeCustomers"
|
||||
class="ws-nav-btn py-2.5 text-[13px]"
|
||||
:class="{ 'ws-nav-btn--active': isActive(['workspace-shipping-customers']) }"
|
||||
>
|
||||
<ContactRound class="h-4 w-4" />
|
||||
<span>{{ $t('workspace.nav.shippingCustomers') }}</span>
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
<RouterLink
|
||||
|
||||
+10
-24
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ManualUploadEvidenceDialog.spec.ts
|
||||
* 用途:锁定人工上传登记弹窗无障碍与必填校验契约。
|
||||
* 依赖:vitest、@vue/test-utils、vue-i18n、file-assets / shipping-tasks API mock。
|
||||
* 逻辑:打开时具备 dialog 角色;Escape 关闭;缺少回执号不得提交;关闭后恢复先前焦点。
|
||||
* 用途:锁定人工上传确认弹窗无障碍与无凭据提交契约。
|
||||
* 依赖:vitest、@vue/test-utils、vue-i18n、shipping-tasks API mock。
|
||||
* 逻辑:打开时具备 dialog 角色;Escape 关闭;无需截图/PDF或回执即可确认;关闭后恢复先前焦点。
|
||||
*/
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
@@ -10,10 +10,6 @@ import { createI18n } from 'vue-i18n';
|
||||
import { nextTick } from 'vue';
|
||||
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
|
||||
|
||||
vi.mock('@/shared/api/file-assets.api', () => ({
|
||||
uploadFileAsset: vi.fn(async () => ({ asset_no: 'FA-TEST-1' })),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
|
||||
markWorkspaceShippingManualUploaded: vi.fn(async () => ({})),
|
||||
}));
|
||||
@@ -25,11 +21,7 @@ const messages = {
|
||||
actions: { failed: '失败' },
|
||||
manualUpload: {
|
||||
title: '登记人工上传',
|
||||
hint: '请上传凭据并填写回执号',
|
||||
evidenceLabel: '证据文件',
|
||||
freightRefLabel: '货代回执号',
|
||||
evidenceRequired: '请先选择证据文件',
|
||||
freightRefRequired: '请填写货代回执号',
|
||||
hint: '请确认 Excel 已上传至货代平台',
|
||||
cancel: '取消',
|
||||
submit: '确认已上传',
|
||||
submitting: '提交中…',
|
||||
@@ -47,7 +39,7 @@ function mountDialog(open = true) {
|
||||
return mount(ManualUploadEvidenceDialog, {
|
||||
props: {
|
||||
open,
|
||||
taskNo: 'SN-DIALOG-1',
|
||||
businessNo: 'WVC26082301',
|
||||
artifactId: 9,
|
||||
},
|
||||
attachTo: document.body,
|
||||
@@ -97,21 +89,15 @@ describe('ManualUploadEvidenceDialog', () => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('requires freight receipt before submit when evidence is selected', async () => {
|
||||
it('submits with business_no without file evidence or freight receipt', async () => {
|
||||
const wrapper = mountDialog(true);
|
||||
await nextTick();
|
||||
const fileInput = wrapper.get('input[type="file"]');
|
||||
const file = new File(['evidence'], 'shot.png', { type: 'image/png' });
|
||||
Object.defineProperty(fileInput.element, 'files', {
|
||||
value: [file],
|
||||
configurable: true,
|
||||
});
|
||||
await fileInput.trigger('change');
|
||||
await nextTick();
|
||||
|
||||
const submit = wrapper.findAll('button').find((btn) => btn.text().includes('确认已上传'));
|
||||
expect(submit).toBeTruthy();
|
||||
expect(submit!.attributes('disabled')).toBeDefined();
|
||||
expect(submit!.attributes('disabled')).toBeUndefined();
|
||||
await submit!.trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.emitted('success')).toHaveLength(1);
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
+8
-55
@@ -1,19 +1,18 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ManualUploadEvidenceDialog.vue
|
||||
* 用途:人工上传凭据对话框;截图/PDF 证据与货代回执号均必填。
|
||||
* 依赖:uploadFileAsset、workspace shipping-tasks.api、Vue watch/nextTick。
|
||||
* 逻辑:由 TaskTodoPanel 在 mark_manual_uploaded 动作时打开;禁止触发 RPA 上传;
|
||||
* 用途:人工确认货代已上传当前发货通知 Excel 的对话框。
|
||||
* 依赖:workspace shipping-tasks.api、Vue watch/nextTick。
|
||||
* 逻辑:由 TaskTodoPanel 在 mark_manual_uploaded 动作时打开;不采集截图/PDF或回执号;
|
||||
* 对齐复核弹层无障碍:role=dialog、aria-modal、焦点陷阱、Escape、关闭后焦点恢复。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { uploadFileAsset } from '@/shared/api/file-assets.api';
|
||||
import { markWorkspaceShippingManualUploaded } from '@/features/workspace/api/shipping-tasks.api';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
taskNo: string;
|
||||
businessNo: string;
|
||||
artifactId?: number | null;
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
@@ -26,8 +25,6 @@ const emit = defineEmits<{
|
||||
const { t } = useI18n();
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
const evidenceFile = ref<File | null>(null);
|
||||
const freightRefNo = ref('');
|
||||
const panelRef = ref<HTMLElement | null>(null);
|
||||
let previouslyFocused: HTMLElement | null = null;
|
||||
|
||||
@@ -54,8 +51,6 @@ function focusableNodes(): HTMLElement[] {
|
||||
*/
|
||||
function close() {
|
||||
if (busy.value) return;
|
||||
evidenceFile.value = null;
|
||||
freightRefNo.value = '';
|
||||
error.value = '';
|
||||
emit('update:open', false);
|
||||
}
|
||||
@@ -126,36 +121,15 @@ onBeforeUnmount(() => {
|
||||
});
|
||||
|
||||
/**
|
||||
* 选择证据文件(截图或 PDF)。
|
||||
*/
|
||||
function onFileChange(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
evidenceFile.value = input.files?.[0] || null;
|
||||
error.value = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传证据资产并登记人工上传完成。
|
||||
* 核心逻辑:证据文件与回执号均必填,与后端 record_manual_upload 契约一致。
|
||||
* 登记人工上传完成。
|
||||
* 核心逻辑:仅提交 business_no 与可选 Artifact,服务端负责唯一 Excel 和状态门禁。
|
||||
*/
|
||||
async function submit() {
|
||||
if (props.disabled || busy.value) return;
|
||||
if (!evidenceFile.value) {
|
||||
error.value = t('workspace.shippingNotice.manualUpload.evidenceRequired');
|
||||
return;
|
||||
}
|
||||
const receipt = freightRefNo.value.trim();
|
||||
if (!receipt) {
|
||||
error.value = t('workspace.shippingNotice.manualUpload.freightRefRequired');
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const asset = await uploadFileAsset(evidenceFile.value);
|
||||
await markWorkspaceShippingManualUploaded(props.taskNo, {
|
||||
evidence_asset_no: asset.asset_no,
|
||||
freight_ref_no: receipt,
|
||||
await markWorkspaceShippingManualUploaded(props.businessNo, {
|
||||
...(props.artifactId ? { artifact_id: props.artifactId } : {}),
|
||||
});
|
||||
emit('success');
|
||||
@@ -193,27 +167,6 @@ async function submit() {
|
||||
{{ $t('workspace.shippingNotice.manualUpload.hint') }}
|
||||
</p>
|
||||
|
||||
<label class="mt-4 block text-xs font-medium text-muted">
|
||||
{{ $t('workspace.shippingNotice.manualUpload.evidenceLabel') }}
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*,application/pdf"
|
||||
class="mt-1 block w-full text-sm"
|
||||
:disabled="busy || disabled"
|
||||
@change="onFileChange"
|
||||
>
|
||||
</label>
|
||||
|
||||
<label class="mt-3 block text-xs font-medium text-muted">
|
||||
{{ $t('workspace.shippingNotice.manualUpload.freightRefLabel') }}
|
||||
<input
|
||||
v-model="freightRefNo"
|
||||
type="text"
|
||||
class="mt-1 w-full rounded-xl border border-default bg-surface px-3 py-2 text-sm"
|
||||
:disabled="busy || disabled"
|
||||
>
|
||||
</label>
|
||||
|
||||
<p v-if="error" class="mt-3 text-sm text-rose-600" role="alert">{{ error }}</p>
|
||||
|
||||
<div class="mt-5 flex justify-end gap-2">
|
||||
@@ -228,7 +181,7 @@ async function submit() {
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="busy || disabled || !evidenceFile || !freightRefNo.trim()"
|
||||
:disabled="busy || disabled"
|
||||
@click="submit"
|
||||
>
|
||||
{{ busy ? $t('workspace.shippingNotice.manualUpload.submitting') : $t('workspace.shippingNotice.manualUpload.submit') }}
|
||||
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ShippingTaskCenterPage.notice-batch.spec.ts
|
||||
* 用途:验收任务中心只按发货通知单 business_no 展示与执行货代批量操作。
|
||||
* 依赖:ShippingTaskCenterPage、货代 API、我的待办 API、Vue Test Utils。
|
||||
* 逻辑:正式 Notice 可选择并传 business_nos;Review/Intake 不能进入选择集;列表行只显示服务端投影的通知明细。
|
||||
*/
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { createMemoryHistory, createRouter } from 'vue-router';
|
||||
import ShippingTaskCenterPage from './ShippingTaskCenterPage.vue';
|
||||
|
||||
const batchConfirm = vi.fn(async () => ({ results: [{ status: 'confirmed' }] }));
|
||||
const batchRpa = vi.fn(async () => ({ results: [{ status: 'accepted' }] }));
|
||||
const downloadArchive = vi.fn(async () => undefined);
|
||||
const listTodos = vi.fn(async () => ({ items: [], page: 1, page_size: 20, total: 0 }));
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
SHIPPING_NOTICE_AGENT_CODE: 'shipping_notice',
|
||||
listShippingChatAgents: vi.fn(async () => []),
|
||||
getWorkspaceShippingTask: vi.fn(),
|
||||
retryWorkspaceShippingOrderStpAutoCreate: vi.fn(),
|
||||
batchConfirmWorkspaceShippingNoticesUploaded: (...args: unknown[]) => batchConfirm(...args),
|
||||
batchStartWorkspaceShippingNoticeRpaUpload: (...args: unknown[]) => batchRpa(...args),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
|
||||
listWorkspaceShippingMyTodos: (...args: unknown[]) => listTodos(...args),
|
||||
countWorkspaceShippingMyTodos: vi.fn(async () => ({ pending: 0, processing: 0, done: 0, total_pending_badge: 0 })),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/composables/useShippingTodoBadge', () => ({
|
||||
useShippingTodoBadge: () => ({ refreshShippingTodoBadge: vi.fn(async () => undefined) }),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/shipping/shippingDownload', () => ({
|
||||
downloadWorkspaceShippingNoticeExportArchive: (...args: unknown[]) => downloadArchive(...args),
|
||||
}));
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
workspace: {
|
||||
shippingNotice: {
|
||||
title: '批次进度中心',
|
||||
refresh: '刷新',
|
||||
loading: '加载中',
|
||||
selectCase: '请选择任务',
|
||||
myTodos: {
|
||||
title: '批次进度中心',
|
||||
subtitle: '按文件查看进度',
|
||||
lifecycleStages: {
|
||||
filterLabel: '阶段',
|
||||
intake_parse: '接收解析',
|
||||
order_review: '订单复核',
|
||||
fulfillment_prep: '通知准备',
|
||||
freight_upload: '货代上传',
|
||||
upload_complete: '通知完成',
|
||||
},
|
||||
buckets: { pending: '待处理', processing: '处理中', done: '已完成' },
|
||||
filters: {
|
||||
todoCategory: '待办类型', all: '全部', review: '待复核', exception: '异常',
|
||||
manualUpload: '人工上传', intakeParse: '接收解析', customer: '客户',
|
||||
customerPlaceholder: '客户名称或简称', taskNo: '任务编号', taskNoPlaceholder: 'SN 编号',
|
||||
apply: '应用筛选', reset: '重置',
|
||||
},
|
||||
empty: '当前桶内暂无待办',
|
||||
openProcessingHint: '请处理',
|
||||
openProcessingUnavailable: '暂不可用',
|
||||
openReview: '订单复核',
|
||||
openLifecycleWorkbench: '进入工作台',
|
||||
openConversation: '打开对话',
|
||||
intakeParseBadge: '材料解析',
|
||||
progressSummary: '当前阶段:{stage}',
|
||||
progressBlocker: '当前阻断:{reason}',
|
||||
viewStage: '查看阶段',
|
||||
},
|
||||
openChat: '打开对话',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const routes = [{
|
||||
path: '/',
|
||||
name: 'workspace-shipping-my-tasks',
|
||||
component: ShippingTaskCenterPage,
|
||||
}];
|
||||
|
||||
function notice(businessNo: string, poNumber: string, partNumber: string) {
|
||||
return {
|
||||
id: Number(businessNo.slice(-2)), task_no: `SN-${businessNo}`, business_no: businessNo,
|
||||
item_kind: 'task', todo_ref: `SN-${businessNo}`, source_type: 'post_ot_fulfillment_wave',
|
||||
po_number: poNumber, customer_name: 'Customer', upload_status: 'pending',
|
||||
notice_line_summary: [{ line_no: '10', part_number: partNumber, shipment_qty: '4', available_qty: '9' }],
|
||||
artifact_summary: { export_file_name: `${businessNo}.xlsx` },
|
||||
};
|
||||
}
|
||||
|
||||
async function mountPage() {
|
||||
const router = createRouter({ history: createMemoryHistory(), routes });
|
||||
await router.push('/');
|
||||
await router.isReady();
|
||||
return mount(ShippingTaskCenterPage, {
|
||||
global: {
|
||||
plugins: [i18n, router],
|
||||
stubs: {
|
||||
RouterLink: true,
|
||||
ShippingRunProgressTable: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
describe('ShippingTaskCenterPage notice batch operations', () => {
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('only makes formal Notices selectable and displays each Notice projection', async () => {
|
||||
listTodos.mockResolvedValueOnce({
|
||||
items: [
|
||||
notice('WYC26082301', 'PO-100', 'PART-A'),
|
||||
notice('WYC26082302', 'PO-100', 'PART-B'),
|
||||
{ id: 30, task_no: 'OT-30', item_kind: 'review_case', todo_ref: 'SNRC-30', review_case_no: 'SNRC-30', source_type: 'review' },
|
||||
{ id: 31, task_no: '', item_kind: 'order_intake', todo_ref: 'SNI-31', intake_no: 'SNI-31', source_type: 'intake' },
|
||||
], page: 1, page_size: 20, total: 4,
|
||||
});
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.get('[aria-label="WYC26082301"]').exists()).toBe(true);
|
||||
expect(wrapper.get('[aria-label="WYC26082302"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[aria-label="SNRC-30"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).toContain('PO-100');
|
||||
expect(wrapper.text()).toContain('PART-A');
|
||||
expect(wrapper.text()).toContain('PART-B');
|
||||
expect(wrapper.text()).toContain('WYC26082301.xlsx');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('sends selected business_nos to download, manual confirmation and RPA independently', async () => {
|
||||
listTodos.mockResolvedValue({
|
||||
items: [notice('WYC26082301', 'PO-100', 'PART-A'), notice('WYC26082302', 'PO-100', 'PART-B')],
|
||||
page: 1, page_size: 20, total: 2,
|
||||
});
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
await wrapper.get('[aria-label="WYC26082301"]').setValue(true);
|
||||
await wrapper.get('[aria-label="WYC26082302"]').setValue(true);
|
||||
|
||||
const toolbar = wrapper.get('[data-testid="shipping-notice-batch-toolbar"]');
|
||||
const buttons = toolbar.findAll('button');
|
||||
await buttons[0].trigger('click');
|
||||
expect(downloadArchive).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
|
||||
await buttons[1].trigger('click');
|
||||
await flushPromises();
|
||||
expect(batchConfirm).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
|
||||
await buttons[2].trigger('click');
|
||||
await flushPromises();
|
||||
expect(batchRpa).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('keeps all five lifecycle stage filters on one wide-screen row', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
const track = wrapper.get('[data-testid="my-todos-lifecycle-stage-filter"]');
|
||||
expect(track.classes()).toContain('xl:grid-cols-5');
|
||||
expect(track.findAll('button')).toHaveLength(5);
|
||||
expect(track.text()).toContain('货代上传');
|
||||
expect(track.text()).not.toContain('workspace.shippingNotice.myTodos.lifecycleStages.freight_upload');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('counts a pending review item from its backend stage even without an enterable lifecycle entry', async () => {
|
||||
listTodos.mockResolvedValueOnce({
|
||||
items: [{
|
||||
item_kind: 'review_case',
|
||||
task_no: '',
|
||||
review_run_no: 'RUN-1',
|
||||
review_case_no: 'CASE-1',
|
||||
ui_state: {
|
||||
stage: { code: 'order_review', label: '订单复核', index: 2, total: 5 },
|
||||
lifecycle_entries: [],
|
||||
},
|
||||
}],
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
total: 1,
|
||||
});
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.get('[data-testid="my-todos-stage-filter-order_review"]').text()).toContain('1');
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
@@ -11,12 +11,14 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { ExternalLink, RefreshCw } from 'lucide-vue-next';
|
||||
import { CheckSquare, Download, ExternalLink, RefreshCw, Upload } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
getWorkspaceShippingTask,
|
||||
listShippingChatAgents,
|
||||
retryWorkspaceShippingOrderStpAutoCreate,
|
||||
batchConfirmWorkspaceShippingNoticesUploaded,
|
||||
batchStartWorkspaceShippingNoticeRpaUpload,
|
||||
SHIPPING_NOTICE_AGENT_CODE,
|
||||
type ShippingTaskDetail,
|
||||
type ShippingTaskSummary,
|
||||
@@ -38,6 +40,7 @@ import {
|
||||
isShippingTodoListItemInProgress,
|
||||
} from './shippingTaskCenterPolling';
|
||||
import ShippingRunProgressTable from './ShippingRunProgressTable.vue';
|
||||
import { downloadWorkspaceShippingNoticeExportArchive } from '@/features/chat/shipping/shippingDownload';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
@@ -98,6 +101,9 @@ const appliedFilters = ref({
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const tasks = ref<ShippingTaskSummary[]>([]);
|
||||
/** 货代批量选择只容纳有 business_no 的正式发货通知,Review/Intake 永不进入集合。 */
|
||||
const selectedBusinessNos = ref<string[]>([]);
|
||||
const batchActionBusy = ref<'download' | 'confirm' | 'rpa' | null>(null);
|
||||
const selectedRef = ref<string | null>(null);
|
||||
/** 仅直链摘要,供入口卡展示;禁止内嵌履约工作台。 */
|
||||
const detail = ref<ShippingTaskDetail | null>(null);
|
||||
@@ -176,7 +182,13 @@ function lifecycleEntriesOf(item: ShippingTaskSummary | ShippingTaskDetail) {
|
||||
/** 当前阶段只取后端标为 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;
|
||||
if (current) return current.code as LifecycleStageCode;
|
||||
// [AUTHORITY] 待人工处理的 Review Case 可能没有可进入工作台的 lifecycle entry,
|
||||
// 但后端仍会下发 ui_state.stage 作为当前业务阶段;统计与筛选必须保留该阶段。
|
||||
const stage = String(item.ui_state?.stage?.code || '').trim();
|
||||
return LIFECYCLE_STAGES.includes(stage as LifecycleStageCode)
|
||||
? stage as LifecycleStageCode
|
||||
: null;
|
||||
}
|
||||
|
||||
/** 可进入工作台的业务阶段仅由后端 entry.state 授权。 */
|
||||
@@ -192,6 +204,35 @@ function lifecycleEntryIsEnterable(entry: ReturnType<typeof lifecycleEntryFor>):
|
||||
return entry?.state === 'current' || entry?.state === 'available';
|
||||
}
|
||||
|
||||
/** 接收解析入口只消费后端独立授权,不从阶段名称推导可写权限。 */
|
||||
function canOpenIntakeParse(item: ShippingTaskSummary | ShippingTaskDetail | null): 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
|
||||
&& item.ui_state?.intake_parse_authorized === true,
|
||||
);
|
||||
}
|
||||
|
||||
/** 打开对话中的接收解析工作面,复用批次进度中心的同一深链契约。 */
|
||||
function openIntakeParse(item: ShippingTaskSummary | ShippingTaskDetail) {
|
||||
if (!canOpenIntakeParse(item)) return;
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
const agentId = Number(item.owner_agent_id || chatAgentId.value || 0);
|
||||
const query: Record<string, string> = {
|
||||
mode: 'order-review',
|
||||
run_no: runNo,
|
||||
lifecycle_stage: 'intake_parse',
|
||||
};
|
||||
const cid = String(item.conversation_id || '').trim();
|
||||
if (cid) query.conversation_id = cid;
|
||||
const caseNo = String(item.review_case_no || '').trim();
|
||||
if (caseNo) query.case_no = caseNo;
|
||||
void router.push({ path: `/chat/${agentId}`, query });
|
||||
}
|
||||
|
||||
function defaultLifecycleTarget(item: ShippingTaskSummary | ShippingTaskDetail): Exclude<LifecycleStageCode, 'intake_parse'> | null {
|
||||
const current = lifecycleEntriesOf(item).find(
|
||||
(entry) => entry.code !== 'intake_parse' && entry.state === 'current',
|
||||
@@ -215,6 +256,12 @@ const filteredTasks = computed(() => (
|
||||
? tasks.value
|
||||
: tasks.value.filter((item) => lifecycleStageCodeOf(item) === lifecycleStageFilter.value)
|
||||
));
|
||||
const noticeRows = computed(() => filteredTasks.value.filter((item) => Boolean(String(item.business_no || '').trim())));
|
||||
const selectedBusinessNoSet = computed(() => new Set(selectedBusinessNos.value));
|
||||
const selectedNoticeCount = computed(() => selectedBusinessNos.value.length);
|
||||
const allVisibleNoticesSelected = computed(() => (
|
||||
noticeRows.value.length > 0 && noticeRows.value.every((item) => selectedBusinessNoSet.value.has(String(item.business_no)))
|
||||
));
|
||||
const lifecycleStageTargetOptions = computed(() => {
|
||||
if (!entryItem.value) return [];
|
||||
return lifecycleEntriesOf(entryItem.value)
|
||||
@@ -248,7 +295,53 @@ function todoDisplayNo(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'order_intake' || item.intake_no) {
|
||||
return String(item.intake_no || item.todo_ref || '—');
|
||||
}
|
||||
return String(item.task_no || item.todo_ref || '—');
|
||||
return String(item.business_no || item.task_no || item.todo_ref || '—');
|
||||
}
|
||||
|
||||
/** 切换一张正式发货通知的批量选择,始终按 business_no 去重。 */
|
||||
function toggleNoticeSelection(item: ShippingTaskSummary): void {
|
||||
const businessNo = String(item.business_no || '').trim();
|
||||
if (!businessNo) return;
|
||||
selectedBusinessNos.value = selectedBusinessNoSet.value.has(businessNo)
|
||||
? selectedBusinessNos.value.filter((value) => value !== businessNo)
|
||||
: [...selectedBusinessNos.value, businessNo];
|
||||
}
|
||||
|
||||
/** 对当前筛选页的正式通知全选/取消;Review 与 Intake 保持不可选。 */
|
||||
function toggleAllVisibleNotices(): void {
|
||||
const visible = noticeRows.value.map((item) => String(item.business_no || '').trim()).filter(Boolean);
|
||||
selectedBusinessNos.value = allVisibleNoticesSelected.value
|
||||
? selectedBusinessNos.value.filter((value) => !visible.includes(value))
|
||||
: Array.from(new Set([...selectedBusinessNos.value, ...visible]));
|
||||
}
|
||||
|
||||
/** 批量请求后只提示汇总,逐单状态由服务端结果决定,避免前端自行推断。 */
|
||||
function summarizeBatchResults(results: Array<Record<string, unknown>>, action: string): void {
|
||||
const accepted = results.filter((item) => ['accepted', 'confirmed'].includes(String(item.status || ''))).length;
|
||||
const blocked = results.length - accepted;
|
||||
if (blocked) msg.warning(t('workspace.shippingNotice.batch.partialResult', { action, accepted, blocked }));
|
||||
else msg.success(t('workspace.shippingNotice.batch.success', { action, count: accepted }));
|
||||
}
|
||||
|
||||
async function runNoticeBatchAction(action: 'download' | 'confirm' | 'rpa'): Promise<void> {
|
||||
if (!selectedBusinessNos.value.length || batchActionBusy.value) return;
|
||||
batchActionBusy.value = action;
|
||||
try {
|
||||
if (action === 'download') {
|
||||
await downloadWorkspaceShippingNoticeExportArchive(selectedBusinessNos.value);
|
||||
msg.success(t('workspace.shippingNotice.batch.downloadStarted'));
|
||||
return;
|
||||
}
|
||||
const result = action === 'confirm'
|
||||
? await batchConfirmWorkspaceShippingNoticesUploaded(selectedBusinessNos.value)
|
||||
: await batchStartWorkspaceShippingNoticeRpaUpload(selectedBusinessNos.value);
|
||||
summarizeBatchResults(result.results || [], t(`workspace.shippingNotice.batch.${action}`));
|
||||
await refreshAll();
|
||||
} catch (error) {
|
||||
msg.error(error instanceof Error ? error.message : t('workspace.shippingNotice.actions.failed'));
|
||||
} finally {
|
||||
batchActionBusy.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,6 +465,8 @@ async function loadTodos(resetPage = false) {
|
||||
task_no: appliedFilters.value.task_no || undefined,
|
||||
});
|
||||
tasks.value = result.items || [];
|
||||
const visibleBusinessNos = new Set(tasks.value.map((item) => String(item.business_no || '').trim()).filter(Boolean));
|
||||
selectedBusinessNos.value = selectedBusinessNos.value.filter((value) => visibleBusinessNos.has(value));
|
||||
totalTasks.value = Number(result.total || 0);
|
||||
if (preferredTaskNo.value && !selectedRef.value) {
|
||||
const hit = tasks.value.find(
|
||||
@@ -670,6 +765,17 @@ onBeforeUnmount(() => {
|
||||
</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="canOpenIntakeParse(detail)"
|
||||
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"
|
||||
data-testid="my-todos-open-intake-parse"
|
||||
@click="openIntakeParse(detail)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openIntakeParse') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
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(detail)"
|
||||
@@ -690,7 +796,7 @@ onBeforeUnmount(() => {
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
v-if="!canOpenOrderProcessing(detail)"
|
||||
v-if="!canOpenOrderProcessing(detail) && !canOpenIntakeParse(detail)"
|
||||
class="text-xs text-amber-700 dark:text-amber-300"
|
||||
data-testid="my-todos-open-processing-unavailable"
|
||||
>
|
||||
@@ -717,7 +823,7 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="grid gap-2 sm:grid-cols-2 xl:grid-cols-4"
|
||||
class="grid gap-2 sm:grid-cols-2 xl:grid-cols-5"
|
||||
data-testid="my-todos-lifecycle-stage-filter"
|
||||
>
|
||||
<button
|
||||
@@ -792,6 +898,51 @@ onBeforeUnmount(() => {
|
||||
|
||||
<div class="grid gap-5 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,2.15fr)]">
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-if="noticeRows.length"
|
||||
class="flex flex-wrap items-center gap-2 rounded-2xl border border-default bg-surface px-3 py-2"
|
||||
data-testid="shipping-notice-batch-toolbar"
|
||||
>
|
||||
<label class="inline-flex items-center gap-2 text-xs text-secondary">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allVisibleNoticesSelected"
|
||||
:aria-label="$t('workspace.shippingNotice.batch.selectAll')"
|
||||
@change="toggleAllVisibleNotices"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.batch.selectAll') }}
|
||||
</label>
|
||||
<span class="text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.batch.selected', { count: selectedNoticeCount }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-default px-2 py-1 text-xs disabled:opacity-50"
|
||||
:disabled="!selectedNoticeCount || Boolean(batchActionBusy)"
|
||||
@click="runNoticeBatchAction('download')"
|
||||
>
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.download') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-default px-2 py-1 text-xs disabled:opacity-50"
|
||||
:disabled="!selectedNoticeCount || Boolean(batchActionBusy)"
|
||||
@click="runNoticeBatchAction('confirm')"
|
||||
>
|
||||
<CheckSquare class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.confirm') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-default px-2 py-1 text-xs disabled:opacity-50"
|
||||
:disabled="!selectedNoticeCount || Boolean(batchActionBusy)"
|
||||
@click="runNoticeBatchAction('rpa')"
|
||||
>
|
||||
<Upload class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.rpa') }}
|
||||
</button>
|
||||
</div>
|
||||
<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>
|
||||
@@ -807,7 +958,17 @@ onBeforeUnmount(() => {
|
||||
@click="selectTodo(item)"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<span class="font-mono text-sm font-semibold text-primary">{{ todoDisplayNo(item) }}</span>
|
||||
<span class="inline-flex min-w-0 items-center gap-2">
|
||||
<input
|
||||
v-if="item.business_no"
|
||||
type="checkbox"
|
||||
:checked="selectedBusinessNoSet.has(String(item.business_no))"
|
||||
:aria-label="String(item.business_no)"
|
||||
@click.stop
|
||||
@change="toggleNoticeSelection(item)"
|
||||
>
|
||||
<span class="font-mono text-sm font-semibold text-primary">{{ todoDisplayNo(item) }}</span>
|
||||
</span>
|
||||
<span
|
||||
v-if="item.todo_category === 'review' || item.item_kind === 'review_case'"
|
||||
class="rounded-full bg-amber-50 px-2 py-0.5 text-[10px] text-amber-700"
|
||||
@@ -833,6 +994,20 @@ onBeforeUnmount(() => {
|
||||
<div class="mt-1 truncate text-xs text-muted">
|
||||
{{ item.customer_name || item.source_file_name || item.review_run_no || '—' }}
|
||||
</div>
|
||||
<template v-if="item.business_no">
|
||||
<div class="mt-2 flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted">
|
||||
<span>PO: {{ item.po_number || '—' }}</span>
|
||||
<span>{{ $t('workspace.shippingNotice.batch.lines') }}: {{ item.notice_line_summary?.length || 0 }}</span>
|
||||
<span>{{ $t('workspace.shippingNotice.batch.parts') }}: {{ item.notice_line_summary?.map((line) => line.part_number).filter(Boolean).join(' / ') || '—' }}</span>
|
||||
</div>
|
||||
<div class="mt-1 text-[11px] text-muted">
|
||||
{{ $t('workspace.shippingNotice.batch.quantities') }}:
|
||||
{{ item.notice_line_summary?.map((line) => `${line.shipment_qty || '—'} / ${line.available_qty || '—'}`).join(' · ') || '—' }}
|
||||
</div>
|
||||
<div class="mt-1 text-[11px] text-muted">
|
||||
Excel: {{ item.artifact_summary?.export_file_name || '—' }} · {{ $t('workspace.shippingNotice.batch.uploadStatus') }}: {{ item.upload_status || '—' }}
|
||||
</div>
|
||||
</template>
|
||||
</button>
|
||||
<div v-if="totalPages > 1" class="flex items-center justify-between gap-2 pt-2 text-xs text-muted">
|
||||
<button
|
||||
@@ -888,6 +1063,17 @@ onBeforeUnmount(() => {
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
v-if="canOpenIntakeParse(selectedItem)"
|
||||
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"
|
||||
data-testid="my-todos-open-intake-parse"
|
||||
@click="openIntakeParse(selectedItem)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openIntakeParse') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
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, lifecycleStageTarget)"
|
||||
@@ -987,6 +1173,17 @@ onBeforeUnmount(() => {
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
v-if="canOpenIntakeParse(entryItem)"
|
||||
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"
|
||||
data-testid="my-todos-open-intake-parse"
|
||||
@click="openIntakeParse(entryItem)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openIntakeParse') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
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, lifecycleStageTarget)"
|
||||
@@ -1007,7 +1204,7 @@ onBeforeUnmount(() => {
|
||||
</button>
|
||||
</div>
|
||||
<p
|
||||
v-if="!canOpenOrderProcessing(entryItem)"
|
||||
v-if="!canOpenOrderProcessing(entryItem) && !canOpenIntakeParse(entryItem)"
|
||||
class="text-xs text-amber-700 dark:text-amber-300"
|
||||
data-testid="my-todos-open-processing-unavailable"
|
||||
>
|
||||
|
||||
@@ -22,7 +22,7 @@ import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import TaskTodoPanel from './TaskTodoPanel.vue';
|
||||
import StpProgressFactsPanel from './StpProgressFactsPanel.vue';
|
||||
import TaskProgressTimeline from './TaskProgressTimeline.vue';
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import { downloadWorkspaceShippingNoticeExcelFile } from '@/features/chat/shipping/shippingDownload';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -149,7 +149,9 @@ watch(
|
||||
*/
|
||||
async function downloadExcel() {
|
||||
try {
|
||||
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
|
||||
const businessNo = String(props.detail.business_no || '').trim();
|
||||
if (!businessNo) throw new Error(t('workspace.shippingNotice.actions.failed'));
|
||||
await downloadWorkspaceShippingNoticeExcelFile(businessNo);
|
||||
emit('refreshed');
|
||||
} catch (e: unknown) {
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
@@ -214,8 +216,6 @@ async function downloadExcel() {
|
||||
<dd>{{ detail.ship_to || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.freightRef') }}</dt>
|
||||
<dd>{{ detail.freight_ref_no || '—' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
confirmWorkspaceShippingCustomer,
|
||||
listWorkspaceShippingCustomerOptions,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import { downloadWorkspaceShippingNoticeExcelFile } from '@/features/chat/shipping/shippingDownload';
|
||||
import { refreshShippingTodoBadge } from '@/features/workspace/composables/useShippingTodoBadge';
|
||||
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
@@ -289,7 +289,7 @@ 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 (dispatch === 'dialog' && uiHandler === 'manual_upload_confirmation') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
manualUploadOpen.value = true;
|
||||
return;
|
||||
@@ -297,7 +297,9 @@ async function runUnifiedAction(action: ShippingUnifiedAction) {
|
||||
if (dispatch === 'view' && uiHandler === 'excel_download') {
|
||||
busyId.value = action.code;
|
||||
try {
|
||||
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
|
||||
const businessNo = String(props.detail.business_no || '').trim();
|
||||
if (!businessNo) throw new Error(t('workspace.shippingNotice.actions.failed'));
|
||||
await downloadWorkspaceShippingNoticeExcelFile(businessNo);
|
||||
await afterSuccess();
|
||||
} catch (e: unknown) {
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
@@ -389,9 +391,9 @@ async function runUnifiedAction(action: ShippingUnifiedAction) {
|
||||
</div>
|
||||
<ManualUploadEvidenceDialog
|
||||
v-model:open="manualUploadOpen"
|
||||
:task-no="detail.task_no"
|
||||
:business-no="detail.business_no || ''"
|
||||
:artifact-id="currentExportArtifactId"
|
||||
:disabled="!resolvedActionsExecutable"
|
||||
:disabled="!resolvedActionsExecutable || !detail.business_no"
|
||||
@success="afterSuccess"
|
||||
/>
|
||||
<ShippingCustomerConfirmDialog
|
||||
|
||||
+18
-49
@@ -1,60 +1,29 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/shippingTaskCenterPolling.spec.ts
|
||||
* 用途:验收任务中心 Intake / Review / OT 轮询边界(UI-01 / UI-02)。
|
||||
* 依赖:isShippingTodoListItemInProgress、ShippingTaskSummary。
|
||||
* 逻辑:parsing Intake 轮询;parse_failed 停止;Intake→OT 后按投影状态决定。
|
||||
* 用途:锁定任务中心自动轮询的边界,避免人工待处理任务被误判为持续处理中。
|
||||
* 依赖:isShippingTodoListItemInProgress。
|
||||
* 逻辑:只有后端明确的进行中状态继续轮询;复核草稿、失败和完成任务停止轮询。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingTaskSummary } from '@/features/chat/api/shipping.api';
|
||||
import { isShippingTodoListItemInProgress } from './shippingTaskCenterPolling';
|
||||
|
||||
function intakeItem(status: string): ShippingTaskSummary {
|
||||
return {
|
||||
item_kind: 'order_intake',
|
||||
todo_ref: 'SNI-1',
|
||||
intake_no: 'SNI-1',
|
||||
intake_parse_status: status,
|
||||
todo_category: 'intake_parse',
|
||||
} as ShippingTaskSummary;
|
||||
}
|
||||
|
||||
describe('isShippingTodoListItemInProgress', () => {
|
||||
it('polls created/queued/parsing intake items', () => {
|
||||
// 关键断言:解析中 Intake 必须持续轮询,避免任务中心卡在旧状态。
|
||||
expect(isShippingTodoListItemInProgress(intakeItem('created'))).toBe(true);
|
||||
expect(isShippingTodoListItemInProgress(intakeItem('queued'))).toBe(true);
|
||||
expect(isShippingTodoListItemInProgress(intakeItem('parsing'))).toBe(true);
|
||||
it('does not poll a review case that is waiting for human editing', () => {
|
||||
expect(isShippingTodoListItemInProgress({
|
||||
item_kind: 'review_case',
|
||||
status: 'waiting_human',
|
||||
task_no: '',
|
||||
review_run_no: 'RUN-1',
|
||||
} as never)).toBe(false);
|
||||
});
|
||||
|
||||
it('stops polling parse_failed intake items', () => {
|
||||
expect(isShippingTodoListItemInProgress(intakeItem('parse_failed'))).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps polling open review cases', () => {
|
||||
expect(
|
||||
isShippingTodoListItemInProgress({
|
||||
item_kind: 'review_case',
|
||||
review_case_no: 'SNRC-1',
|
||||
review_run_no: 'SNER-1',
|
||||
} as ShippingTaskSummary),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('after intake becomes OT, uses shipping_processing_status', () => {
|
||||
// Intake 消失后由 OT 卡承接:waiting_review 继续轮询,completed 停止。
|
||||
expect(
|
||||
isShippingTodoListItemInProgress({
|
||||
item_kind: 'task',
|
||||
task_no: 'OT-1',
|
||||
shipping_processing_status: 'waiting_review',
|
||||
} as ShippingTaskSummary),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isShippingTodoListItemInProgress({
|
||||
item_kind: 'task',
|
||||
task_no: 'OT-1',
|
||||
shipping_processing_status: 'completed',
|
||||
} as ShippingTaskSummary),
|
||||
).toBe(false);
|
||||
it('continues polling a review case with an explicit processing status', () => {
|
||||
expect(isShippingTodoListItemInProgress({
|
||||
item_kind: 'review_case',
|
||||
status: 'processing',
|
||||
shipping_processing_status: 'processing',
|
||||
task_no: '',
|
||||
review_run_no: 'RUN-1',
|
||||
} as never)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -43,7 +43,12 @@ export const INTAKE_POLLING_PARSE_STATUSES = new Set([
|
||||
*/
|
||||
export function isShippingTodoListItemInProgress(item: ShippingTaskSummary): boolean {
|
||||
if (item.item_kind === 'review_case' || (item.review_run_no && !item.task_no)) {
|
||||
return true;
|
||||
const unified = String(item.shipping_processing_status || '').trim().toLowerCase();
|
||||
if (unified) {
|
||||
if (TERMINAL_PROCESSING_STATUSES.has(unified)) return false;
|
||||
return IN_PROGRESS_PROCESSING_STATUSES.has(unified);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (item.item_kind === 'order_intake') {
|
||||
const intakeStatus = String(
|
||||
|
||||
Reference in new issue
Block a user