fix(shipping-notice,admin-schedule,frontend): 修复发货通知与后台排程的业务bug并优化各模块功能
1. 后端发货通知模块:
清空重试任务旧状态避免残留,新增RPA进度回调接口
优化库存匹配性能,修复人工确认校验逻辑与登录弹窗遮挡问题
新增排程worker启动脚本,清理冗余环境配置与缓存查询开销
2. 前端后台排程模块:
新增任务key归一化工具兼容历史格式,修复参数表单隐藏问题
添加加载错误处理,更新多语言文案替换裸JSON占位符
This commit is contained in:
1 parent
1e5aedb9ed
commit
06c18b3c7c
81 files changed
+3301
-424
No files matched your search
@@ -2632,16 +2632,27 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
summary: {}, steps: [],
|
||||
},
|
||||
} as any);
|
||||
// 完成面改版后按「已上传通知聚合」消费同一份 freight groups;仅 uploaded 通知进入完成面。
|
||||
vi.mocked(taskApi.getWorkspaceShippingFreightNoticeGroups).mockResolvedValue({
|
||||
po_number: 'PO-100',
|
||||
items: [
|
||||
{ business_no: 'WYC26082401', po_number: 'PO-100', upload_status: 'uploaded', export_file_name: 'WYC26082401.xlsx', lines: [
|
||||
{ line_no: '00010', part_number: 'PART-A', reservation_id: 'RSV-A', qty: '2' },
|
||||
] },
|
||||
{ business_no: 'WYC26082402', po_number: 'PO-100', upload_status: 'pending', export_file_name: 'WYC26082402.xlsx', lines: [] },
|
||||
],
|
||||
} as any);
|
||||
|
||||
const wrapper = await mountView({ lifecycle_stage: 'upload_complete' });
|
||||
await flushPromises();
|
||||
|
||||
const evidence = wrapper.get('[data-testid="review-lifecycle-upload-complete"]');
|
||||
expect(evidence.text()).toContain('succeeded');
|
||||
expect(evidence.text()).not.toContain('LATEST-FAILED');
|
||||
// 只展示已上传通知(uploaded),未上传(pending)不进入完成面。
|
||||
expect(evidence.text()).toContain('WYC26082401');
|
||||
expect(evidence.text()).not.toContain('WYC26082402');
|
||||
// 人工确认不再展示或依赖货代回执号,即使历史投影仍带有 freight_ref_no。
|
||||
expect(evidence.text()).not.toContain('LEGACY-REF-MUST-NOT-BE-SHOWN');
|
||||
expect(evidence.text()).not.toContain('failed');
|
||||
expect(evidence.text()).not.toContain('LATEST-FAILED');
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
|
||||
});
|
||||
@@ -2894,7 +2905,8 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
expect(wrapper.find('[data-testid="review-confirm-outcome"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="retry-auto-progress-after-confirm"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-RECOVER-1');
|
||||
// 发货通知单号与订单明细行绑定,不在任务级整单显示;当前任务卡不展示单条通知单号。
|
||||
expect(wrapper.find('[data-testid="review-current-processing-ot"]').exists()).toBe(false);
|
||||
}, 15000);
|
||||
|
||||
it('does not submit an action before the formal OT Gate projection arrives (UI-01)', async () => {
|
||||
@@ -3168,7 +3180,8 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-CONFIRM-PROGRESS-FAIL');
|
||||
// 发货通知单号随订单明细绑定,不在任务级整单展示;当前任务卡不含单条通知单号。
|
||||
expect(wrapper.find('[data-testid="review-current-processing-ot"]').exists()).toBe(false);
|
||||
}, 15000);
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { Bot, Check, Crosshair, Download, MoreHorizontal, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
|
||||
import { Bot, Check, ChevronDown, Crosshair, Download, MoreHorizontal, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
@@ -2107,14 +2107,39 @@ const freightNoticeGroups = ref<ShippingFreightNoticeGroup[]>([]);
|
||||
const freightNoticeGroupsLoading = ref(false);
|
||||
const freightNoticeGroupsReason = ref<string | null>(null);
|
||||
const freightNoticeGroupsLoadFailed = ref(false);
|
||||
/** 右栏业务主身份必须是 business_no;技术 OT 仅用于内部追踪。 */
|
||||
const currentShippingBusinessNo = computed(() => (
|
||||
String(formalTaskDetail.value?.business_no || '').trim()
|
||||
|| String(shippingProcessingProjection.value?.shippingNoticeNo || '').trim()
|
||||
|| null
|
||||
));
|
||||
const selectedFreightBusinessNos = ref<string[]>([]);
|
||||
const freightBatchBusy = ref<'download' | 'confirm' | 'rpa' | 'regenerate' | null>(null);
|
||||
/**
|
||||
* 通知完成面的只读聚合:同 PO 中已有上传成功证据(upload_status=uploaded)的发货通知。
|
||||
* 核心逻辑:与货代上传面消费同一份 freightNoticeGroups,仅按终态过滤;未上传的
|
||||
* 通知仍留在货代上传面处理,完成面不出现混淆态。
|
||||
*/
|
||||
const uploadedFreightNoticeGroups = computed(() =>
|
||||
freightNoticeGroups.value.filter((item) =>
|
||||
String(item.upload_status || '').trim().toLowerCase() === 'uploaded',
|
||||
),
|
||||
);
|
||||
/** 批次留底下载:把已完成通知全部打包为 ZIP(复用后端 /shipping-notices/batch/export)。 */
|
||||
const uploadingBatchArchive = ref(false);
|
||||
async function downloadCompletedBatchArchive() {
|
||||
const businessNos = uploadedFreightNoticeGroups.value
|
||||
.map((item) => String(item.business_no || '').trim())
|
||||
.filter(Boolean);
|
||||
if (!businessNos.length || uploadingBatchArchive.value) return;
|
||||
uploadingBatchArchive.value = true;
|
||||
try {
|
||||
await downloadWorkspaceShippingNoticeExportArchive(businessNos);
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
} finally {
|
||||
uploadingBatchArchive.value = false;
|
||||
}
|
||||
}
|
||||
/** 通知完成面的展开明细:同一时刻只展开一张通知(与货代上传面交互一致)。 */
|
||||
const expandedCompletedNoticeNo = ref<string | null>(null);
|
||||
function toggleCompletedNoticeLine(businessNo: string) {
|
||||
expandedCompletedNoticeNo.value = expandedCompletedNoticeNo.value === businessNo ? null : businessNo;
|
||||
}
|
||||
const formalTaskDetailLoading = ref(false);
|
||||
const formalTaskDetailLoadFailed = ref(false);
|
||||
/**
|
||||
@@ -2407,6 +2432,11 @@ async function runFreightBatchAction(action: 'download' | 'confirm' | 'rpa') {
|
||||
} else {
|
||||
await batchStartWorkspaceShippingNoticeRpaUpload(selectedFreightBusinessNos.value);
|
||||
}
|
||||
// 确认/RPA 后重拉同 PO 通知聚合,使通知完成面能立即呈现最新 uploaded 状态。
|
||||
if (action === 'confirm' || action === 'rpa') {
|
||||
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
|
||||
if (taskNo) await loadFreightNoticeGroups(taskNo);
|
||||
}
|
||||
await Promise.all([loadFormalTaskDetail(), refreshShippingProcessing()]);
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
@@ -2438,6 +2468,9 @@ async function runFreightNoticeAction(
|
||||
await submitFormalGateAction('regenerate_excel_artifact');
|
||||
return;
|
||||
}
|
||||
// 确认/RPA 后重拉同 PO 通知聚合,使通知完成面能立即呈现最新 uploaded 状态。
|
||||
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
|
||||
if (taskNo) await loadFreightNoticeGroups(taskNo);
|
||||
await Promise.all([loadFormalTaskDetail(), refreshShippingProcessing()]);
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
@@ -2461,13 +2494,14 @@ function canRunFreightNoticeAction(group: ShippingFreightNoticeGroup, actionCode
|
||||
}
|
||||
|
||||
watch(
|
||||
[confirmedNoticeTaskNo, workbenchMode, hasCreatedShippingTask, isLifecycleFreightUpload],
|
||||
([taskNo, mode, created, isFreightUpload]) => {
|
||||
[confirmedNoticeTaskNo, workbenchMode, hasCreatedShippingTask, isLifecycleFreightUpload, isLifecycleUploadComplete],
|
||||
([taskNo, mode, created, isFreightUpload, isUploadComplete]) => {
|
||||
const completed = String(displayCase.value?.current_stage?.code || '').trim().toLowerCase() === 'completed'
|
||||
|| String(displayCase.value?.user_status || '').trim().toLowerCase() === 'completed';
|
||||
// Notice 聚合只服务货代上传工作面;通知准备/文件切换不能为此扫描同 PO 全部 Notice。
|
||||
if (taskNo && created && isFreightUpload) void loadFreightNoticeGroups(taskNo);
|
||||
if (!isFreightUpload) {
|
||||
// Notice 聚合服务货代上传与通知完成两个工作面;通知准备/文件切换不扫描同 PO 全部 Notice。
|
||||
const needsNoticeGroups = isFreightUpload || isUploadComplete;
|
||||
if (taskNo && created && needsNoticeGroups) void loadFreightNoticeGroups(taskNo);
|
||||
if (!needsNoticeGroups) {
|
||||
freightNoticeGroups.value = [];
|
||||
selectedFreightBusinessNos.value = [];
|
||||
}
|
||||
@@ -2603,6 +2637,37 @@ function preparationLineCustomerPoLine(line: { line_key?: string | null; custome
|
||||
return draftValueText || String(line.customer_po_line_no || '').trim() || '—';
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知行项次展示:按后端 line_no_source 区分渲染。
|
||||
* 核心逻辑:field=冻结字段真实值(普通展示);customer_po_line_no=客户 PO 行号(普通展示,
|
||||
* 附带来源提示);sequence=系统行序(弱化样式 + 来源提示);缺失直接显示 —。
|
||||
* 禁止前端按 position/序号自行推导业务项次。
|
||||
*/
|
||||
function freightLineNoDisplay(line: { line_no?: string | number | null; line_no_source?: string | null }): {
|
||||
text: string;
|
||||
muted: boolean;
|
||||
title: string;
|
||||
} {
|
||||
const value = line.line_no ?? null;
|
||||
if (value === null || value === '') return { text: '—', muted: false, title: '' };
|
||||
const source = String(line.line_no_source || '').trim();
|
||||
if (source === 'sequence') {
|
||||
return {
|
||||
text: String(value),
|
||||
muted: true,
|
||||
title: t('chat.shippingOrderReview.lifecycle.freightUpload.lineNoSourceSequence'),
|
||||
};
|
||||
}
|
||||
if (source === 'customer_po_line_no') {
|
||||
return {
|
||||
text: String(value),
|
||||
muted: false,
|
||||
title: t('chat.shippingOrderReview.lifecycle.freightUpload.lineNoSourceCustomerPo'),
|
||||
};
|
||||
}
|
||||
return { text: String(value), muted: false, title: '' };
|
||||
}
|
||||
|
||||
async function confirmPreparationWave() {
|
||||
const caseNo = String(activeCase.value?.case_no || '').trim();
|
||||
const draftVersion = activeCase.value?.draft?.draft_version;
|
||||
@@ -4068,7 +4133,7 @@ watch(
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
<table class="min-w-full text-left text-xs"><thead class="border-b border-default bg-surface-muted/30"><tr><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.lineNo') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th></tr></thead><tbody><tr v-for="line in group.lines" :key="`${group.business_no}-${line.line_no}-${line.part_number}`" class="border-b border-default last:border-0" data-testid="review-freight-upload-line"><td class="px-3 py-2">{{ line.line_no || '—' }}</td><td class="px-3 py-2">{{ line.part_number || '—' }}</td><td class="px-3 py-2">{{ line.reservation_id || '—' }}</td><td class="px-3 py-2">{{ line.shipment_qty || '—' }}</td></tr></tbody></table>
|
||||
<table class="min-w-full text-left text-xs"><thead class="border-b border-default bg-surface-muted/30"><tr><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.lineNo') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th></tr></thead><tbody><tr v-for="line in group.lines" :key="`${group.business_no}-${line.line_no}-${line.part_number}`" class="border-b border-default last:border-0" data-testid="review-freight-upload-line"><td class="px-3 py-2"><span :class="freightLineNoDisplay(line).muted ? 'text-muted' : ''" :title="freightLineNoDisplay(line).title">{{ freightLineNoDisplay(line).text }}</span></td><td class="px-3 py-2">{{ line.part_number || '—' }}</td><td class="px-3 py-2">{{ line.reservation_id || '—' }}</td><td class="px-3 py-2">{{ line.shipment_qty || '—' }}</td></tr></tbody></table>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="mt-3 rounded-lg border border-default bg-surface-muted/50 p-3 text-xs text-secondary">{{ freightNoticeGroupsReason === 'po_missing' ? t('chat.shippingOrderReview.lifecycle.freightUpload.poMissing') : t('chat.shippingOrderReview.lifecycle.freightUpload.empty') }}</p>
|
||||
@@ -4081,9 +4146,88 @@ watch(
|
||||
>
|
||||
<h2 class="text-sm font-semibold text-primary">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.title') }}</h2>
|
||||
<p class="mt-1 text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.subtitle') }}</p>
|
||||
<div class="mt-3 rounded-lg border border-emerald-200 bg-surface/70 p-3 text-xs text-secondary dark:border-emerald-900">
|
||||
<p v-if="formalTaskDetail.ui_state?.stage_context?.upload?.succeeded_attempt" class="mt-1">{{ t('chat.shippingOrderReview.lifecycle.upload.attempt', { status: formalTaskDetail.ui_state.stage_context.upload.succeeded_attempt.status || '-', mode: formalTaskDetail.ui_state.stage_context.upload.succeeded_attempt.mode || '-' }) }}</p>
|
||||
|
||||
<!-- 聚合头:本批已上传数量 + 留底下载(ZIP 打包全部已完成通知) -->
|
||||
<div class="mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border border-emerald-200 bg-surface px-3 py-2 text-xs dark:border-emerald-900" data-testid="review-upload-complete-toolbar">
|
||||
<span class="font-medium text-emerald-900 dark:text-emerald-100">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.batchCount', { count: uploadedFreightNoticeGroups.length }) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-emerald-300 px-2 py-1 font-medium text-emerald-700 hover:bg-emerald-50 disabled:opacity-50 dark:border-emerald-700 dark:text-emerald-200 dark:hover:bg-emerald-950/40"
|
||||
:disabled="!uploadedFreightNoticeGroups.length || uploadingBatchArchive"
|
||||
data-testid="review-upload-complete-batch-download"
|
||||
@click="void downloadCompletedBatchArchive()"
|
||||
>
|
||||
{{ uploadingBatchArchive
|
||||
? t('chat.shippingOrderReview.lifecycle.uploadComplete.batchDownloading')
|
||||
: t('chat.shippingOrderReview.lifecycle.uploadComplete.batchDownload') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="uploadedFreightNoticeGroups.length" class="mt-3 space-y-3" data-testid="review-upload-complete-groups">
|
||||
<div
|
||||
v-for="group in uploadedFreightNoticeGroups"
|
||||
:key="group.business_no"
|
||||
class="rounded-lg border border-emerald-200 bg-surface/70 dark:border-emerald-900"
|
||||
data-testid="review-upload-complete-notice"
|
||||
>
|
||||
<!-- 单据行:identity + 状态 + 单张下载 + 展开明细 -->
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 border-b border-emerald-200/70 px-3 py-2 text-xs dark:border-emerald-900/70">
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1">
|
||||
<span class="font-semibold text-primary">{{ group.business_no }}</span>
|
||||
<span class="inline-flex items-center gap-1 font-medium text-emerald-700 dark:text-emerald-300">
|
||||
<Check class="h-3.5 w-3.5" aria-hidden="true" />
|
||||
{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.uploaded') }}
|
||||
</span>
|
||||
<span class="text-secondary">{{ group.po_number ? `PO: ${group.po_number}` : '' }}</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-emerald-300 px-2 py-1 font-medium text-emerald-700 hover:bg-emerald-50 dark:border-emerald-700 dark:text-emerald-200 dark:hover:bg-emerald-950/40"
|
||||
data-testid="review-upload-complete-download"
|
||||
@click="void downloadFreightNotice(group.business_no)"
|
||||
>{{ t('chat.shippingOrderReview.lifecycle.freightUpload.download') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface disabled:opacity-50"
|
||||
:aria-expanded="expandedCompletedNoticeNo === group.business_no"
|
||||
:aria-label="expandedCompletedNoticeNo === group.business_no
|
||||
? t('chat.shippingOrderReview.lifecycle.uploadComplete.collapse')
|
||||
: t('chat.shippingOrderReview.lifecycle.uploadComplete.expand')"
|
||||
data-testid="review-upload-complete-toggle-lines"
|
||||
@click="toggleCompletedNoticeLine(group.business_no)"
|
||||
>
|
||||
{{ expandedCompletedNoticeNo === group.business_no
|
||||
? t('chat.shippingOrderReview.lifecycle.uploadComplete.collapse')
|
||||
: t('chat.shippingOrderReview.lifecycle.uploadComplete.expand') }}
|
||||
<ChevronDown class="h-3.5 w-3.5 transition-transform" :class="{ 'rotate-180': expandedCompletedNoticeNo === group.business_no }" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="expandedCompletedNoticeNo === group.business_no" class="space-y-2 px-3 pb-3 pt-2 text-xs" data-testid="review-upload-complete-lines">
|
||||
<p v-if="group.export_file_name" class="text-secondary">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.exportFile', { file: group.export_file_name }) }}</p>
|
||||
<table class="min-w-full text-left">
|
||||
<thead class="border-b border-default bg-surface-muted/30">
|
||||
<tr>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.lineNo') }}</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="line in group.lines" :key="`${group.business_no}-${line.line_no}-${line.part_number}`" class="border-b border-default last:border-0" data-testid="review-upload-complete-line">
|
||||
<td class="px-3 py-2"><span :class="freightLineNoDisplay(line).muted ? 'text-muted' : ''" :title="freightLineNoDisplay(line).title">{{ freightLineNoDisplay(line).text }}</span></td>
|
||||
<td class="px-3 py-2">{{ line.part_number || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ line.reservation_id || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ line.shipment_qty ?? '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="mt-3 rounded-lg border border-emerald-200 bg-surface/70 p-3 text-xs text-secondary dark:border-emerald-900">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.empty') }}</p>
|
||||
</section>
|
||||
|
||||
<ReviewIntakeParsePanel
|
||||
@@ -4514,8 +4658,6 @@ watch(
|
||||
:task-no="displayCase?.confirmed_task_no || displayCase?.post_confirm_auto_progress?.task_no"
|
||||
:confirmed-task-id="displayCase?.confirmed_task_id"
|
||||
:show-admin-diagnosis="showAdminTaskMissingDiagnosis"
|
||||
:has-formal-ot="shippingProcessingProjection?.hasFormalOt ?? hasFormalOt"
|
||||
:shipping-notice-no="currentShippingBusinessNo"
|
||||
:user-status="currentTaskUserStatus"
|
||||
:retryable="visibleCurrentTaskRetryable"
|
||||
:blocking-reason="currentTaskBlockingReason"
|
||||
|
||||
Reference in new issue
Block a user