feat(shipping-notice): 完善订单解析、模板管理与库存 RPA 流程
- 优化订单文档解析、补充合并与坐标重建 - 完善订单模板校验、发布及前端管理界面 - 改进库存 RPA 下载回退与工作流处理 - 补充后端、前端及 RPA 自动化测试 - 更新 Shipping Notice 技术文档与四语言文案
This commit is contained in:
1 parent
c4a27324c8
commit
8f2f568f92
46 files changed
+1745
-265
No files matched your search
@@ -589,7 +589,15 @@ export const readOrderProfilePreviewPageRegionText = (
|
||||
signal?: AbortSignal,
|
||||
purpose?: 'reservation_id_region',
|
||||
renderedImageBase64?: string | null,
|
||||
) => requestJson<{ document_id: number; page_no: number; text: string; source: string | null; status: 'needs_review'; reservation_candidates?: Array<{ value: string; line_no: number | null; scope: 'header' | 'line'; raw_text: string; status: string }> }>(
|
||||
) => requestJson<{
|
||||
document_id: number;
|
||||
page_no: number;
|
||||
text: string;
|
||||
source: string | null;
|
||||
status: 'needs_review';
|
||||
reservation_candidates?: Array<{ value: string; line_no: number | null; scope: 'header' | 'line'; raw_text: string; status: string }>;
|
||||
reservation_region_reason?: string | null;
|
||||
}>(
|
||||
`/api/admin/shipping-notice/order-document-profiles/${profileId}/preview-pages/${pageNo}/region-text`, {
|
||||
method: 'POST', body: JSON.stringify({ document_id: documentId, region, ...(purpose ? { purpose } : {}), ...(renderedImageBase64 ? { rendered_image_base64: renderedImageBase64 } : {}) }), signal, ...jsonAuth(),
|
||||
},
|
||||
|
||||
+8
@@ -442,6 +442,14 @@ onBeforeUnmount(() => {
|
||||
<section v-if="candidate" class="card candidate-card">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.reviewHint') }}</h2>
|
||||
<p v-if="!candidate.confirmable" class="training-required">{{ t('admin.shippingOrderProfiles.blindTest.diagnosticOnly') }}</p>
|
||||
<p
|
||||
v-if="candidate.reservation_region_status === 'needs_review'"
|
||||
class="training-required"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.blindTest.reservationRegionNeedsReview', {
|
||||
reasons: (candidate.reservation_region_review_reasons || []).join(', ') || candidate.reservation_region_status,
|
||||
}) }}
|
||||
</p>
|
||||
<p v-if="!candidate.rows.length">{{ t('admin.shippingOrderProfiles.blindTest.candidateRowsEmpty') }}</p>
|
||||
<article v-for="(row, index) in candidate.rows" :key="index" class="review-item">
|
||||
<template v-if="rowReviews[index]">
|
||||
|
||||
+21
-6
@@ -5,7 +5,8 @@
|
||||
XfaDatasetTree、XfaCollectionSelector、XfaSplitRulePanel、shippingOrderField.utils。
|
||||
逻辑:PDF 与 XFA 共用同一 desk DOM(main + aside.config + OrderProfileDocumentCanvas);
|
||||
XFA 仅在属性区插入读取方式/数据源/拆分/样本显示增量;OCR 建议进入普通建议区;
|
||||
未绑定订单字段框通过横幅 + 画布高亮强制展示,避免空白底图漏看导致发布失败。
|
||||
未绑定订单字段框通过横幅 + 画布高亮强制展示,避免空白底图漏看导致发布失败;
|
||||
选中已有标注时退出绘制模式,避免 drawing 态吞掉缩放导致标签高度无法调整。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
@@ -467,6 +468,7 @@ const reservationIdCandidates = ref<Array<{
|
||||
raw_text: string;
|
||||
status: string;
|
||||
}>>([]);
|
||||
const reservationIdRegionReason = ref<string | null>(null);
|
||||
const reservationIdCandidateState = ref<'idle' | 'loading' | 'ready' | 'failed'>('idle');
|
||||
/**
|
||||
* 共同画布的字段选项只决定视觉定位;coordinate 末端值源仍必须由 Schema 显式授权
|
||||
@@ -556,7 +558,11 @@ const ensureTableRegionSetting = (targetPageNo: number) => {
|
||||
/** coordinate 末端取值 adapter 投影的画布动作。 */
|
||||
const coordinateCanvasActions = computed<OrderProfileCanvasActions>(() => ({
|
||||
create: (region) => createDrawnRegion(region),
|
||||
select: (id) => { selectedId.value = id; },
|
||||
select: (id) => {
|
||||
// 选中已有框时退出绘制,否则 .drawing 会吞掉缩放手柄事件,表现为高度无法调整。
|
||||
creationKind.value = null;
|
||||
selectedId.value = id;
|
||||
},
|
||||
dragStart: (id) => beginRegionGesture(id),
|
||||
dragEnd: () => endRegionGesture(),
|
||||
change: (id, region) => updateRegion(id, region),
|
||||
@@ -1038,18 +1044,22 @@ const updateReservationIdRegion = (region: OrderProfileRelativeRegion): void =>
|
||||
};
|
||||
const clearReservationIdRegion = (): void => {
|
||||
reservationIdRegion.value = null;
|
||||
reservationIdCandidates.value = [];
|
||||
reservationIdRegionReason.value = null;
|
||||
reservationIdCandidateState.value = 'idle';
|
||||
reservationIdRegionDirty.value = true;
|
||||
markLocalChange();
|
||||
scheduleAutosave();
|
||||
};
|
||||
/**
|
||||
* 读取当前圈选区域的 Reservation 候选。
|
||||
* 核心逻辑:编辑器预览调用与正式解析相同的后端固定解析器,前端不自行推断行归属。
|
||||
* 读取当前专区启用后的 Reservation 候选(与正式解析相同的 Vendor Comments 锚点)。
|
||||
* 核心逻辑:编辑器预览调用后端锚点扫描;矩形仅作启用标记,前端不自行推断行归属。
|
||||
*/
|
||||
const refreshReservationIdCandidates = async (): Promise<void> => {
|
||||
const configured = reservationIdRegion.value;
|
||||
if (!active.value || !form.documentId || !configured) {
|
||||
reservationIdCandidates.value = [];
|
||||
reservationIdRegionReason.value = null;
|
||||
reservationIdCandidateState.value = 'idle';
|
||||
return;
|
||||
}
|
||||
@@ -1064,9 +1074,11 @@ const refreshReservationIdCandidates = async (): Promise<void> => {
|
||||
'reservation_id_region',
|
||||
);
|
||||
reservationIdCandidates.value = result.reservation_candidates || [];
|
||||
reservationIdRegionReason.value = result.reservation_region_reason || null;
|
||||
reservationIdCandidateState.value = 'ready';
|
||||
} catch {
|
||||
reservationIdCandidates.value = [];
|
||||
reservationIdRegionReason.value = null;
|
||||
reservationIdCandidateState.value = 'failed';
|
||||
}
|
||||
};
|
||||
@@ -3360,11 +3372,14 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
清除区域
|
||||
</button>
|
||||
<small v-if="reservationIdRegion">已标记第 {{ reservationIdRegion.page_no }} 页区域;解析结果由预览/复核统一返回。</small>
|
||||
<small v-if="reservationIdRegion">已标记第 {{ reservationIdRegion.page_no }} 页区域;正式取值按 Vendor Comments→Terms 锚点,与验证/盲测/正式解析一致。</small>
|
||||
<p v-if="reservationIdCandidateState === 'loading'" class="reservation-region-config__status">正在识别 Reservation ID…</p>
|
||||
<p v-else-if="reservationIdCandidateState === 'failed'" class="reservation-region-config__status">区域预览失败;保存后可在盲测/复核中再次确认。</p>
|
||||
<template v-else-if="reservationIdCandidateState === 'ready'">
|
||||
<p v-if="!reservationIdCandidates.length" class="reservation-region-config__status">未识别到 Reservation ID,请检查圈选范围。</p>
|
||||
<p v-if="reservationIdRegionReason" class="reservation-region-config__status reservation-region-config__review">
|
||||
专区锚点异常:{{ reservationIdRegionReason }}
|
||||
</p>
|
||||
<p v-else-if="!reservationIdCandidates.length" class="reservation-region-config__status">未识别到 Reservation ID,请检查 Vendor Comments / Terms 锚点。</p>
|
||||
<ul v-else class="reservation-region-config__candidates">
|
||||
<li v-for="candidate in reservationIdCandidates" :key="`${candidate.value}:${candidate.line_no}:${candidate.raw_text}`">
|
||||
<code>{{ candidate.value }}</code>
|
||||
|
||||
+19
-15
@@ -261,20 +261,23 @@ onMounted(loadFamilies);
|
||||
</small>
|
||||
</td>
|
||||
<td class="profile-library__actions">
|
||||
<button v-if="item.draft_profile_id" class="btn-ghost btn-sm" type="button" @click="continueEditing(item)">{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}</button>
|
||||
<button v-if="item.draft_profile_id" class="btn-danger btn-sm" type="button" @click="requestDeleteDraft(item)">{{ t('admin.delete') }}</button>
|
||||
<button v-else-if="item.published_profile_id && !schemaMigrationRequired(item)" class="btn-secondary btn-sm" type="button" @click="createNewVersion(item)">{{ t('admin.shippingOrderProfiles.newVersion') }}</button>
|
||||
<button v-if="!item.draft_profile_id && item.published_profile_id && schemaMigrationRequired(item)" class="btn-secondary btn-sm" type="button" @click="openSchemaMigration(item)">{{ t('admin.shippingOrderProfiles.schemaMigration.listAction') }}</button>
|
||||
<button class="btn-ghost btn-sm" type="button" @click="viewVersion(item)">{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}</button>
|
||||
<button
|
||||
v-if="item.unified_binding_status === 'needs_migration' || item.unified_needs_migration"
|
||||
class="btn-ghost btn-sm"
|
||||
type="button"
|
||||
data-testid="order-profile-unified-migration-open"
|
||||
@click="openUnifiedMigration(item)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.unifiedMigration.open') }}
|
||||
</button>
|
||||
<!-- flex 必须放在 td 内层,避免破坏 table-cell 盒模型导致行分隔线错位 -->
|
||||
<div class="profile-library__actions-inner">
|
||||
<button v-if="item.draft_profile_id" class="btn-ghost btn-sm" type="button" @click="continueEditing(item)">{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}</button>
|
||||
<button v-if="item.draft_profile_id" class="btn-danger btn-sm" type="button" @click="requestDeleteDraft(item)">{{ t('admin.delete') }}</button>
|
||||
<button v-else-if="item.published_profile_id && !schemaMigrationRequired(item)" class="btn-secondary btn-sm" type="button" @click="createNewVersion(item)">{{ t('admin.shippingOrderProfiles.newVersion') }}</button>
|
||||
<button v-if="!item.draft_profile_id && item.published_profile_id && schemaMigrationRequired(item)" class="btn-secondary btn-sm" type="button" @click="openSchemaMigration(item)">{{ t('admin.shippingOrderProfiles.schemaMigration.listAction') }}</button>
|
||||
<button class="btn-ghost btn-sm" type="button" @click="viewVersion(item)">{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}</button>
|
||||
<button
|
||||
v-if="item.unified_binding_status === 'needs_migration' || item.unified_needs_migration"
|
||||
class="btn-ghost btn-sm"
|
||||
type="button"
|
||||
data-testid="order-profile-unified-migration-open"
|
||||
@click="openUnifiedMigration(item)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.unifiedMigration.open') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -326,7 +329,8 @@ onMounted(loadFamilies);
|
||||
.status-badge.published { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
|
||||
.schema-status { display: block; margin-top: 5px; color: #64748b; font-size: 11px; white-space: nowrap; }.schema-status.warning { color: #b45309; }
|
||||
.actions-heading { min-width: 190px; }
|
||||
.profile-library__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
|
||||
.profile-library__actions { vertical-align: middle; }
|
||||
.profile-library__actions-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.page-header { flex-direction: column; }
|
||||
|
||||
+22
@@ -55,10 +55,19 @@ const validationEvidence = computed<OrderProfileValidationEvidence | null>(() =>
|
||||
cross_checks: value.cross_checks && typeof value.cross_checks === 'object' && !Array.isArray(value.cross_checks)
|
||||
? value.cross_checks as Record<string, unknown>
|
||||
: {},
|
||||
reservation_region_status: typeof value.reservation_region_status === 'string'
|
||||
? value.reservation_region_status
|
||||
: undefined,
|
||||
reservation_region_review_reasons: Array.isArray(value.reservation_region_review_reasons)
|
||||
? value.reservation_region_review_reasons.map((item) => String(item))
|
||||
: undefined,
|
||||
};
|
||||
});
|
||||
const evidenceHeaderFields = computed(() => validationEvidence.value?.header_fields || []);
|
||||
const evidenceLines = computed(() => validationEvidence.value?.lines || []);
|
||||
const reservationRegionReviewReasons = computed(
|
||||
() => validationEvidence.value?.reservation_region_review_reasons || [],
|
||||
);
|
||||
const ADAPTER_CROSS_CHECK_KEYS = [
|
||||
'mirror_status',
|
||||
'acroform_status',
|
||||
@@ -330,6 +339,16 @@ onMounted(async () => {
|
||||
</dl>
|
||||
<p v-else>{{ t('admin.orderProfileValidation.noHeaderResults') }}</p>
|
||||
|
||||
<section
|
||||
v-if="validationEvidence?.reservation_region_status === 'needs_review' || reservationRegionReviewReasons.length"
|
||||
class="reservation-region-review"
|
||||
>
|
||||
<h3>{{ t('admin.orderProfileValidation.reservationRegionTitle') }}</h3>
|
||||
<p>{{ t('admin.orderProfileValidation.reservationRegionNeedsReview', {
|
||||
reasons: reservationRegionReviewReasons.join(', ') || validationEvidence?.reservation_region_status || '-',
|
||||
}) }}</p>
|
||||
</section>
|
||||
|
||||
<h3>{{ t('admin.orderProfileValidation.lineResults') }}</h3>
|
||||
<div v-if="evidenceLines.length" class="line-results">
|
||||
<article v-for="line in evidenceLines" :key="String(line.row_index)" class="xfa-line-card">
|
||||
@@ -371,6 +390,9 @@ button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.results { margin-top: 20px; padding: 16px; }.results-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }.results h2, .results h3 { margin: 0; color: #1e293b; }.results h2 { font-size: 15px; }.results h3 { margin-top: 20px; font-size: 14px; }.results-heading p { margin: 5px 0 0; color: #64748b; font-size: 13px; line-height: 1.5; }.header-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0 0; }.header-results div { border: 1px solid #e5ebf1; border-radius: 6px; background: #fbfdff; padding: 10px; }.header-results dt { color: #475569; font-size: 13px; font-weight: 600; }.header-results dd { margin: 4px 0 0; overflow-wrap: anywhere; }.header-results .field-code, .line-results th small { color: #94a3b8; font-size: 11px; font-weight: 400; }.line-results { margin-top: 12px; overflow-x: auto; border: 1px solid #e5ebf1; border-radius: 6px; }.line-results table { width: 100%; min-width: 560px; border-collapse: collapse; }.line-results th, .line-results td { padding: 10px 12px; border-bottom: 1px solid #e5ebf1; text-align: left; vertical-align: top; overflow-wrap: anywhere; }.line-results tbody tr:last-child td { border-bottom: 0; }.line-results th { background: #f8fafc; color: #64748b; font-size: 12px; font-weight: 600; }.line-results th span, .line-results th small { display: block; }.deleted-row { color: #94a3b8; text-decoration: line-through; }.result-error { color: #b91c1c; }
|
||||
.header-results .field-needs_review, .header-results .field-unavailable, .header-results .field-failed, .header-results .field-missing { border-color: #fed7aa; background: #fff7ed; }.header-results .field-issues { color: #b45309; font-size: 11px; }
|
||||
.header-results .field-passed { border-color: #bbf7d0; background: #f0fdf4; }
|
||||
.reservation-region-review { margin-top: 16px; padding: 12px; border: 1px solid #fed7aa; border-radius: 8px; background: #fff7ed; }
|
||||
.reservation-region-review h3 { margin: 0; color: #9a3412; font-size: 14px; }
|
||||
.reservation-region-review p { margin: 6px 0 0; color: #b45309; font-size: 13px; }
|
||||
.xfa-line-card { margin-top: 12px; padding: 12px; border: 1px solid #e5ebf1; border-radius: 8px; background: #fbfdff; }.xfa-line-card h4 { margin: 0 0 8px; font-size: 13px; color: #475569; }
|
||||
@media (max-width: 767px) { .validation-page { padding: 16px; } header, .validation-state, .current-draft-validation > header, .checks article, .blind-test-gate, .results-heading { display: grid; }.validation-state button, .current-draft-validation > header button, .blind-test-gate button, .results-heading button { width: 100%; } }
|
||||
</style>
|
||||
+106
@@ -142,6 +142,112 @@ describe('OrderProfileDocumentCanvas PDF preview', () => {
|
||||
expect(region.attributes('aria-label')).toContain('待绑定');
|
||||
});
|
||||
|
||||
it('ignores wheel zoom while a vertical resize drag is active', async () => {
|
||||
const shortAnchor = {
|
||||
id: 'order_field_1_1_anchor',
|
||||
kind: 'order_anchor' as const,
|
||||
label: 'Number',
|
||||
pageNo: 1,
|
||||
region: { x0: .78, y0: .12, x1: .84, y1: .158 },
|
||||
};
|
||||
const wrapper = mount(OrderProfileDocumentCanvas, {
|
||||
props: {
|
||||
profileId: 8,
|
||||
grant: { page_no: 1, preview_token: 'page-token' },
|
||||
previewPagePath: '/api/admin/shipping-notice/order-document-profiles/8/preview-pages',
|
||||
regions: [shortAnchor],
|
||||
selectedRegionId: shortAnchor.id,
|
||||
pageNo: 1,
|
||||
pageCount: 1,
|
||||
},
|
||||
global: {
|
||||
plugins: [createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
admin: { shippingOrderProfiles: { workbench: { pagePreviewAlt: 'page', resizeHandle: '{direction}' } } },
|
||||
},
|
||||
},
|
||||
})],
|
||||
},
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const stage = wrapper.find('.canvas-stage').element as HTMLElement;
|
||||
Object.defineProperty(stage, 'getBoundingClientRect', {
|
||||
value: () => ({ left: 0, top: 0, width: 1000, height: 1000, right: 1000, bottom: 1000, x: 0, y: 0, toJSON: () => ({}) }),
|
||||
});
|
||||
|
||||
const southEdge = wrapper.find('.resize-edge-s');
|
||||
southEdge.element.dispatchEvent(new PointerEvent('pointerdown', {
|
||||
bubbles: true, cancelable: true, clientX: 810, clientY: 158, pointerId: 1,
|
||||
}));
|
||||
// 拖高过程中触控板滚轮不得改缩放,否则纵向手势表现为“高度拉不动”。
|
||||
const beforeZoom = wrapper.find('.zoom-control output').text();
|
||||
await wrapper.find('.canvas-viewport').trigger('wheel', { deltaY: -120 });
|
||||
expect(wrapper.find('.zoom-control output').text()).toBe(beforeZoom);
|
||||
|
||||
window.dispatchEvent(new PointerEvent('pointermove', { clientX: 810, clientY: 240 }));
|
||||
window.dispatchEvent(new PointerEvent('pointerup', { clientX: 810, clientY: 240 }));
|
||||
await flushPromises();
|
||||
|
||||
const change = wrapper.emitted('change')?.at(-1);
|
||||
expect((change?.[1] as { y1: number }).y1).toBeGreaterThan(shortAnchor.region.y1);
|
||||
expect(wrapper.find('.region').attributes('style')).toContain('bottom:');
|
||||
});
|
||||
|
||||
it('allows shrinking label height below the legacy 0.01 floor', async () => {
|
||||
const tallAnchor = {
|
||||
id: 'order_field_1_2_anchor',
|
||||
kind: 'order_anchor' as const,
|
||||
label: 'Number',
|
||||
pageNo: 1,
|
||||
region: { x0: .70, y0: .035, x1: .85, y1: .055 },
|
||||
};
|
||||
const wrapper = mount(OrderProfileDocumentCanvas, {
|
||||
props: {
|
||||
profileId: 8,
|
||||
grant: { page_no: 1, preview_token: 'page-token' },
|
||||
previewPagePath: '/api/admin/shipping-notice/order-document-profiles/8/preview-pages',
|
||||
regions: [tallAnchor],
|
||||
selectedRegionId: tallAnchor.id,
|
||||
pageNo: 1,
|
||||
pageCount: 1,
|
||||
},
|
||||
global: {
|
||||
plugins: [createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
admin: { shippingOrderProfiles: { workbench: { pagePreviewAlt: 'page', resizeHandle: '{direction}' } } },
|
||||
},
|
||||
},
|
||||
})],
|
||||
},
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const stage = wrapper.find('.canvas-stage').element as HTMLElement;
|
||||
Object.defineProperty(stage, 'getBoundingClientRect', {
|
||||
value: () => ({ left: 0, top: 0, width: 1000, height: 1000, right: 1000, bottom: 1000, x: 0, y: 0, toJSON: () => ({}) }),
|
||||
});
|
||||
|
||||
// 从下边向上拖,目标高度约 0.006(低于旧下限 0.01,高于新下限 0.002)。
|
||||
wrapper.find('.resize-edge-s').element.dispatchEvent(new PointerEvent('pointerdown', {
|
||||
bubbles: true, cancelable: true, clientX: 775, clientY: 55, pointerId: 1,
|
||||
}));
|
||||
window.dispatchEvent(new PointerEvent('pointermove', { clientX: 775, clientY: 41 }));
|
||||
window.dispatchEvent(new PointerEvent('pointerup', { clientX: 775, clientY: 41 }));
|
||||
await flushPromises();
|
||||
|
||||
const next = wrapper.emitted('change')?.at(-1)?.[1] as { y0: number; y1: number };
|
||||
// 关键断言:单行标签可缩到 <0.01;旧硬编码 .01 会把 y1 卡在 y0+0.01。
|
||||
expect(next.y1 - next.y0).toBeLessThan(0.01);
|
||||
expect(next.y1 - next.y0).toBeGreaterThanOrEqual(0.002);
|
||||
});
|
||||
|
||||
it('captures the selected XFA appearance from the unscaled PDF.js canvas', async () => {
|
||||
const drawImage = vi.fn();
|
||||
const toDataURL = vi.fn(() => 'data:image/png;base64,canvas-crop');
|
||||
|
||||
+91
-19
@@ -5,6 +5,9 @@
|
||||
逻辑:父级签发单页令牌并提供分页动作;mode=readonly 时只允许查看/缩放/切页,不允许写入任何标注改动;
|
||||
PNG 预览 token 为一次性消费,组件内按页缓存 blob,翻页回访不再重新拉 token;
|
||||
未绑定订单字段框强制高亮(region--unbound),并暴露 scrollRegionIntoView 供横幅定位删除;
|
||||
选中框用 top/right/bottom/left 定位(避免 height% 在内容撑高容器上失效);
|
||||
拖拽/缩放进行中忽略滚轮缩放,避免触控板纵向手势把高度调整抢走;
|
||||
绘制模式下仍允许操作当前选中框;整边 resize 热区便于矮标签拉高;
|
||||
画布区域 aria-label 走四语言 i18n;可选 emptyHint/loadError 区分 XFA page_unavailable 与 PDF 缺样本空态。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -245,20 +248,39 @@ const onRetryClick = () => {
|
||||
emit('retry');
|
||||
};
|
||||
|
||||
/**
|
||||
* 画布框最小边长(相对页坐标)。
|
||||
* 旧值 0.01(页高 1%)对单行标签过粗,例如 Number 框会被卡在高度差 ≥0.01;
|
||||
* 0.002 仍保证正面积,又能贴紧字形。
|
||||
*/
|
||||
const MIN_REGION_SPAN = 0.002;
|
||||
|
||||
/**
|
||||
* 判断缩放手柄是否包含指定轴向。
|
||||
* 核心逻辑:用显式枚举替代 `includes('n')`,避免手柄命名变更时误匹配。
|
||||
*/
|
||||
const resizeAffects = (handle: ResizeHandle, axis: 'n' | 'e' | 's' | 'w'): boolean => {
|
||||
if (axis === 'n') return handle === 'n' || handle === 'ne' || handle === 'nw';
|
||||
if (axis === 's') return handle === 's' || handle === 'se' || handle === 'sw';
|
||||
if (axis === 'e') return handle === 'e' || handle === 'ne' || handle === 'se';
|
||||
return handle === 'w' || handle === 'nw' || handle === 'sw';
|
||||
};
|
||||
|
||||
/** 将指针移动映射为相对坐标;readonly 模式只保留选中,不允许几何变化。 */
|
||||
const move = (event: PointerEvent) => {
|
||||
if (!activeDrag || !canvas.value || readonlyMode.value) return;
|
||||
const bounds = canvas.value.getBoundingClientRect();
|
||||
if (bounds.width < 1 || bounds.height < 1) return;
|
||||
const dx = (event.clientX - activeDrag.startX) / bounds.width;
|
||||
const dy = (event.clientY - activeDrag.startY) / bounds.height;
|
||||
if (activeDrag.mode !== 'move') {
|
||||
const handle = activeDrag.mode;
|
||||
const prior = activeDrag.region;
|
||||
const next = {
|
||||
x0: handle.includes('w') ? Math.max(0, Math.min(prior.x1 - .01, prior.x0 + dx)) : prior.x0,
|
||||
y0: handle.includes('n') ? Math.max(0, Math.min(prior.y1 - .01, prior.y0 + dy)) : prior.y0,
|
||||
x1: handle.includes('e') ? Math.max(prior.x0 + .01, Math.min(1, prior.x1 + dx)) : prior.x1,
|
||||
y1: handle.includes('s') ? Math.max(prior.y0 + .01, Math.min(1, prior.y1 + dy)) : prior.y1,
|
||||
x0: resizeAffects(handle, 'w') ? Math.max(0, Math.min(prior.x1 - MIN_REGION_SPAN, prior.x0 + dx)) : prior.x0,
|
||||
y0: resizeAffects(handle, 'n') ? Math.max(0, Math.min(prior.y1 - MIN_REGION_SPAN, prior.y0 + dy)) : prior.y0,
|
||||
x1: resizeAffects(handle, 'e') ? Math.max(prior.x0 + MIN_REGION_SPAN, Math.min(1, prior.x1 + dx)) : prior.x1,
|
||||
y1: resizeAffects(handle, 's') ? Math.max(prior.y0 + MIN_REGION_SPAN, Math.min(1, prior.y1 + dy)) : prior.y1,
|
||||
};
|
||||
emit('change', activeDrag.id, next);
|
||||
return;
|
||||
@@ -279,6 +301,7 @@ const beginDrag = (event: PointerEvent, region: OrderProfileCanvasRegion, mode:
|
||||
activeDrag = { id: region.id, mode, startX: event.clientX, startY: event.clientY, region: { ...region.region } };
|
||||
window.addEventListener('pointermove', move);
|
||||
window.addEventListener('pointerup', endMove, { once: true });
|
||||
window.addEventListener('pointercancel', endMove, { once: true });
|
||||
};
|
||||
|
||||
/** 结束一次区域移动并停止全局事件监听。 */
|
||||
@@ -286,6 +309,7 @@ const endMove = () => {
|
||||
activeDrag = null;
|
||||
emit('end');
|
||||
window.removeEventListener('pointermove', move);
|
||||
window.removeEventListener('pointercancel', endMove);
|
||||
};
|
||||
/** 未处于绘制模式时以左键拖动画布视口,避免依赖横纵滚动条定位放大页面。 */
|
||||
const beginPan = (event: PointerEvent) => {
|
||||
@@ -321,7 +345,7 @@ const updateCreation = (event: PointerEvent) => {
|
||||
};
|
||||
const endCreation = () => {
|
||||
const region = creationRegion.value;
|
||||
if (region && region.x1 - region.x0 >= .01 && region.y1 - region.y0 >= .01) emit('create', region);
|
||||
if (region && region.x1 - region.x0 >= MIN_REGION_SPAN && region.y1 - region.y0 >= MIN_REGION_SPAN) emit('create', region);
|
||||
creationStart = null;
|
||||
creationRegion.value = null;
|
||||
window.removeEventListener('pointermove', updateCreation);
|
||||
@@ -357,8 +381,11 @@ const displayRegionLabel = (region: OrderProfileCanvasRegion): string => {
|
||||
const adjustZoom = (delta: number) => { zoom.value = Math.max(.5, Math.min(4, Math.round((zoom.value + delta) * 100) / 100)); };
|
||||
/** 恢复适合工作台宽度的默认倍率,便于快速定位整页。 */
|
||||
const resetZoom = () => { zoom.value = 1; };
|
||||
/** 在画布上滚动时缩放页面,避免管理员来回点击工具栏中断标注。 */
|
||||
const handleWheel = (event: WheelEvent) => { adjustZoom(event.deltaY < 0 ? .1 : -.1); };
|
||||
/** 在画布上滚动时缩放页面;拖拽/绘制进行中忽略,避免触控板纵向手势抢走高度调整。 */
|
||||
const handleWheel = (event: WheelEvent) => {
|
||||
if (activeDrag || activePan || creationStart) return;
|
||||
adjustZoom(event.deltaY < 0 ? .1 : -.1);
|
||||
};
|
||||
/** 校验页码输入并请求父工作台切页;超出范围时吸附到最近有效页。 */
|
||||
const goToPage = () => {
|
||||
const nextPage = Math.max(1, Math.min(props.pageCount || 1, Math.round(Number(pageInput.value) || props.pageNo)));
|
||||
@@ -511,7 +538,12 @@ onBeforeUnmount(() => {
|
||||
},
|
||||
region.visualBindingStatus ? `region-visual--${region.visualBindingStatus}` : '',
|
||||
]"
|
||||
:style="{ left: `${region.region.x0 * 100}%`, top: `${region.region.y0 * 100}%`, width: `${(region.region.x1 - region.region.x0) * 100}%`, height: `${(region.region.y1 - region.region.y0) * 100}%` }"
|
||||
:style="{
|
||||
left: `${region.region.x0 * 100}%`,
|
||||
top: `${region.region.y0 * 100}%`,
|
||||
right: `${(1 - region.region.x1) * 100}%`,
|
||||
bottom: `${(1 - region.region.y1) * 100}%`,
|
||||
}"
|
||||
:aria-label="displayRegionLabel(region)"
|
||||
@pointerdown.stop="beginDrag($event, region, 'move')"
|
||||
@keydown.enter="emit('select', region.id)"
|
||||
@@ -521,9 +553,39 @@ onBeforeUnmount(() => {
|
||||
<template v-if="region.kind === 'line' && !readonlyMode && !region.isPreview">
|
||||
<span v-for="edge in ['n', 'e', 's', 'w']" :key="edge" class="line-hit-edge" :class="`line-hit-${edge}`" @pointerdown.stop="beginDrag($event, region, 'move')" />
|
||||
</template>
|
||||
<button v-if="!readonlyMode && !region.isPreview" v-for="handle in ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'] as ResizeHandle[]" :key="handle" type="button" class="resize-handle" :class="`handle-${handle}`" :aria-label="t('admin.shippingOrderProfiles.workbench.resizeHandle', { direction: handle })" @pointerdown.stop="beginDrag($event, region, handle)" />
|
||||
<!-- 整边缩放热区:矮标签框拖上下边时不再落入整体 move。角点手柄叠在热区之上。 -->
|
||||
<template v-if="!readonlyMode && !region.isPreview && selected.has(region.id)">
|
||||
<span
|
||||
v-for="edge in ['n', 'e', 's', 'w'] as ResizeHandle[]"
|
||||
:key="`edge-${edge}`"
|
||||
class="resize-edge"
|
||||
:class="`resize-edge-${edge}`"
|
||||
:aria-hidden="true"
|
||||
@pointerdown.stop="beginDrag($event, region, edge)"
|
||||
/>
|
||||
</template>
|
||||
<span
|
||||
v-if="!readonlyMode && !region.isPreview"
|
||||
v-for="handle in ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'] as ResizeHandle[]"
|
||||
:key="handle"
|
||||
role="button"
|
||||
tabindex="-1"
|
||||
class="resize-handle"
|
||||
:class="`handle-${handle}`"
|
||||
:aria-label="t('admin.shippingOrderProfiles.workbench.resizeHandle', { direction: handle })"
|
||||
@pointerdown.stop="beginDrag($event, region, handle)"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="creationRegion" class="creation-region" :style="{ left: `${creationRegion.x0 * 100}%`, top: `${creationRegion.y0 * 100}%`, width: `${(creationRegion.x1 - creationRegion.x0) * 100}%`, height: `${(creationRegion.y1 - creationRegion.y0) * 100}%` }" />
|
||||
<div
|
||||
v-if="creationRegion"
|
||||
class="creation-region"
|
||||
:style="{
|
||||
left: `${creationRegion.x0 * 100}%`,
|
||||
top: `${creationRegion.y0 * 100}%`,
|
||||
right: `${(1 - creationRegion.x1) * 100}%`,
|
||||
bottom: `${(1 - creationRegion.y1) * 100}%`,
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -578,6 +640,9 @@ onBeforeUnmount(() => {
|
||||
.canvas-stage img { display: block; width: 100%; user-select: none; }
|
||||
.canvas-stage canvas.pdf-page { display: block; background: white; pointer-events: none; user-select: none; }
|
||||
.canvas-stage.drawing { cursor: crosshair; }
|
||||
.canvas-stage.drawing .region { pointer-events: none; }
|
||||
/* 绘制模式下仍可缩放/移动当前选中框,避免点了标签工具后高度完全拉不动。 */
|
||||
.canvas-stage.drawing .region.selected { pointer-events: auto; }
|
||||
.creation-region { position: absolute; z-index: 5; box-sizing: border-box; border: 2px dashed #34d399; background: rgb(16 185 129 / .18); pointer-events: none; }
|
||||
.annotation-tools { display: grid; align-content: start; gap: .3rem; flex: 0 0 2.65rem; padding: .3rem; border: 1px solid rgb(71 85 105 / .9); border-radius: .5rem; background: rgb(15 23 42 / .94); box-shadow: 0 8px 24px rgb(15 23 42 / .3); }
|
||||
.annotation-tools button { display: grid; min-height: 2rem; place-items: center; border: 1px solid transparent; border-radius: .35rem; background: #1e293b; padding: .35rem; color: #e2e8f0; }
|
||||
@@ -589,16 +654,24 @@ onBeforeUnmount(() => {
|
||||
.suggestion-preview-badge { color: #fbbf24; font-size: .68rem; }
|
||||
.region { position: absolute; box-sizing: border-box; z-index: 2; border: 2px solid #38bdf8; background: rgb(14 165 233 / .10); color: #e0f2fe; cursor: move; text-align: left; touch-action: none; }
|
||||
.region:focus-visible { outline: 3px solid white; outline-offset: 2px; }
|
||||
.region-label { position: absolute; top: -1.65rem; left: -2px; max-width: min(18rem, 100%); overflow: hidden; border: 1px solid rgb(255 255 255 / .7); border-radius: .25rem .25rem 0 0; background: #0369a1; padding: .2rem .45rem; color: white; font: 700 .7rem/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.resize-handle { position: absolute; z-index: 3; width: 10px; height: 10px; border: 2px solid white; border-radius: 2px; background: #0ea5e9; box-shadow: 0 1px 2px rgb(15 23 42 / .55); padding: 0; touch-action: none; }
|
||||
.handle-n, .handle-s { left: 50%; margin-left: -5px; cursor: ns-resize; }
|
||||
.handle-e, .handle-w { top: 50%; margin-top: -5px; cursor: ew-resize; }
|
||||
.region-label { position: absolute; z-index: 2; top: -1.65rem; left: -2px; max-width: min(18rem, 100%); overflow: hidden; border: 1px solid rgb(255 255 255 / .7); border-radius: .25rem .25rem 0 0; background: #0369a1; padding: .2rem .45rem; color: white; font: 700 .7rem/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
|
||||
/* 整边热区略伸出框外,左右缩进避开角点,保证矮框上下边可拉高。 */
|
||||
.resize-edge { position: absolute; z-index: 4; touch-action: none; }
|
||||
.resize-edge-n, .resize-edge-s { left: 8px; right: 8px; height: 14px; cursor: ns-resize; }
|
||||
.resize-edge-e, .resize-edge-w { top: 8px; bottom: 8px; width: 14px; cursor: ew-resize; }
|
||||
.resize-edge-n { top: -7px; }
|
||||
.resize-edge-s { bottom: -7px; }
|
||||
.resize-edge-e { right: -7px; }
|
||||
.resize-edge-w { left: -7px; }
|
||||
.resize-handle { position: absolute; z-index: 5; box-sizing: border-box; width: 12px; height: 12px; border: 2px solid white; border-radius: 2px; background: #0ea5e9; box-shadow: 0 1px 2px rgb(15 23 42 / .55); padding: 0; touch-action: none; cursor: pointer; }
|
||||
.handle-n, .handle-s { left: 50%; margin-left: -6px; cursor: ns-resize; }
|
||||
.handle-e, .handle-w { top: 50%; margin-top: -6px; cursor: ew-resize; }
|
||||
.handle-nw, .handle-se { cursor: nwse-resize; }
|
||||
.handle-ne, .handle-sw { cursor: nesw-resize; }
|
||||
.handle-n, .handle-nw, .handle-ne { top: -6px; }
|
||||
.handle-s, .handle-sw, .handle-se { bottom: -6px; }
|
||||
.handle-e, .handle-ne, .handle-se { right: -6px; }
|
||||
.handle-w, .handle-nw, .handle-sw { left: -6px; }
|
||||
.handle-n, .handle-nw, .handle-ne { top: -7px; }
|
||||
.handle-s, .handle-sw, .handle-se { bottom: -7px; }
|
||||
.handle-e, .handle-ne, .handle-se { right: -7px; }
|
||||
.handle-w, .handle-nw, .handle-sw { left: -7px; }
|
||||
.region-header_field { z-index: 2; border: 1.5px solid #f59e0b; background: rgb(245 158 11 / .08); }
|
||||
.region-header_field .region-label, .region-header_field .resize-handle { background: #b45309; }
|
||||
.region-order_field { z-index: 2; border: 1.5px solid #22c55e; background: rgb(34 197 94 / .08); }
|
||||
@@ -652,7 +725,6 @@ onBeforeUnmount(() => {
|
||||
.region.selected:not(.region-line) { z-index: 4; }
|
||||
.region-preview { z-index: 5; border-style: dashed; border-width: 2px; border-color: #fbbf24; background: rgb(245 158 11 / .18); color: #fef3c7; cursor: default; pointer-events: auto; }
|
||||
.region-preview .region-label { background: #a16207; }
|
||||
.canvas-stage.drawing .region { pointer-events: none; }
|
||||
@media (max-width: 900px) {
|
||||
.canvas-shell { height: auto; min-height: 36rem; }
|
||||
.canvas-toolbar { grid-template-columns: 1fr auto; }
|
||||
|
||||
+7
-1
@@ -763,7 +763,13 @@ export const selectCurrentDatasetsValidationEvidence = (
|
||||
lines: value.lines,
|
||||
cross_checks: value.cross_checks && typeof value.cross_checks === 'object' && !Array.isArray(value.cross_checks)
|
||||
? value.cross_checks : {},
|
||||
} as OrderProfileValidationEvidence;
|
||||
...(typeof value.reservation_region_status === 'string'
|
||||
? { reservation_region_status: value.reservation_region_status }
|
||||
: {}),
|
||||
...(Array.isArray(value.reservation_region_review_reasons)
|
||||
? { reservation_region_review_reasons: value.reservation_region_review_reasons.map((item) => String(item)) }
|
||||
: {}),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -577,6 +577,9 @@ export interface OrderProfileValidationEvidence {
|
||||
header_fields: OrderProfileValidationEvidenceField[];
|
||||
lines: OrderProfileValidationEvidenceLine[];
|
||||
cross_checks: Record<string, unknown>;
|
||||
/** Vendor Comments 专区与正式解析共用;仅 needs_review 时出现。 */
|
||||
reservation_region_status?: string;
|
||||
reservation_region_review_reasons?: string[];
|
||||
}
|
||||
|
||||
/** 绑定精确草稿 checksum 的不可变验证运行摘要。 */
|
||||
@@ -936,6 +939,8 @@ export interface OrderProfileBlindTestCandidate {
|
||||
layout_version_id: number | null; layout_payload_checksum: string | null;
|
||||
layout_parser_key: string | null; layout_parser_version: string | null;
|
||||
order_fields: Array<{ field_id: string; field_code: string; scope: 'header'; value: unknown; status: 'confirmed' | 'needs_review' | 'unavailable'; page_no: number | null; issues: string[] }>;
|
||||
reservation_region_status?: string;
|
||||
reservation_region_review_reasons?: string[];
|
||||
}
|
||||
|
||||
/** 工作台的本地几何状态;保存前转为 v2 相对区域定义。 */
|
||||
|
||||
@@ -1068,29 +1068,54 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
build_eligibility: { can_build: true, status: 'ready', line_projections: [] },
|
||||
},
|
||||
});
|
||||
api.getCase.mockResolvedValue(readyCase);
|
||||
const confirmedCase = {
|
||||
...readyCase,
|
||||
status: 'confirmed',
|
||||
confirmed_task_no: 'OT-1',
|
||||
order_task_no: 'OT-1',
|
||||
has_formal_ot: true,
|
||||
};
|
||||
api.getCase.mockResolvedValue(confirmedCase);
|
||||
api.getRun.mockResolvedValue({
|
||||
run_no: 'RUN-1', summary: {},
|
||||
items: [{ case_no: 'CASE-1', document_id: 1, status: 'ready', available_actions: ['confirm'] }],
|
||||
});
|
||||
api.getQueue.mockResolvedValue({
|
||||
summary: { total: 1, needs_action: 1, processing: 0, completed: 0 },
|
||||
items: [{
|
||||
case_no: 'CASE-1', document_id: 1, source_run_no: 'RUN-1', status: 'confirmed',
|
||||
lifecycle_stage: 'fulfillment_prep',
|
||||
lifecycle_entries: [{ code: 'fulfillment_prep', state: 'current' }],
|
||||
}],
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
api.getPreview.mockResolvedValue({ preview_url: '' });
|
||||
api.getProcessingWorkItem.mockResolvedValue({
|
||||
work_item_no: 'OT-1', status: 'blocked', user_status: 'waiting_human',
|
||||
workItemNo: 'OT-1',
|
||||
status: 'waiting_human',
|
||||
userStatus: 'waiting_human',
|
||||
stage: 'inventory_matching',
|
||||
currentGate: { gateCode: 'inventory_matching', status: 'blocked_manual' },
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [{ code: 'fulfillment_prep', state: 'current' }],
|
||||
},
|
||||
});
|
||||
api.confirmCase.mockResolvedValue({
|
||||
task_no: 'SN-1', order_task_no: 'OT-1', shipping_notice_no: 'SN-1', idempotent_replay: false,
|
||||
case: { ...readyCase, status: 'confirmed', order_task_no: 'OT-1' }, auto_progress_started: true,
|
||||
case: confirmedCase, auto_progress_started: true,
|
||||
});
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'WFI-1' });
|
||||
const queueCallsBeforeConfirm = api.getQueue.mock.calls.length;
|
||||
await review.confirm();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
|
||||
await Promise.resolve();
|
||||
// 中断(waiting_human,即“等待人工处理”)视为线性终态:结果不会自行变化,必须停止轮询。
|
||||
// 中断(waiting_human)停轮询前须刷新 Case/Queue,否则自动跳阶段拿不到 lifecycle。
|
||||
expect(api.getQueue.mock.calls.length).toBeGreaterThan(queueCallsBeforeConfirm);
|
||||
expect(review.workflowProgressPolling.value).toBe(false);
|
||||
|
||||
review.stopWorkflowProgressPolling();
|
||||
|
||||
@@ -621,9 +621,12 @@ export function useShippingOrderReview(options: {
|
||||
};
|
||||
|
||||
/**
|
||||
* 轮询正式 OT / Extraction Run 的处理投影,驱动工作流进度与阶段条。
|
||||
*
|
||||
* OT ShippingProcessing Extraction Run
|
||||
* WorkflowItem OT Run
|
||||
* 核心逻辑:有权威 OT 时刷 shipping processing;投影进入 waiting_human/failed 等
|
||||
* 终态前先 await refreshActiveAutomationLifecycle,保证五阶段条能跟随跳转后再停轮询。
|
||||
*
|
||||
* @param itemNo - 可选工作流/OT 编号覆盖
|
||||
*/
|
||||
const startWorkflowProgressPolling = (itemNo?: string | null) => {
|
||||
stopWorkflowProgressPolling();
|
||||
@@ -658,12 +661,8 @@ export function useShippingOrderReview(options: {
|
||||
lastUnifiedStatus = unifiedStatus;
|
||||
options.onWorkflowRefresh?.();
|
||||
}
|
||||
if (UNIFIED_TERMINAL.has(unifiedStatus)) {
|
||||
stopWorkflowProgressPolling();
|
||||
return;
|
||||
}
|
||||
// 顶部五阶段取 Case/Queue 的 lifecycle_entries。仅当 OT 投影的阶段/门禁发生变化
|
||||
// 时刷新一次,避免每 2.5 秒重复读取队列;不等待该读取,保证终态轮询及时停止。
|
||||
// 时刷新一次,避免每 2.5 秒重复读取队列。
|
||||
const lifecycleFingerprint = [
|
||||
unifiedStatus,
|
||||
String(shippingProcessingProjection.value?.stage || ''),
|
||||
@@ -672,7 +671,13 @@ export function useShippingOrderReview(options: {
|
||||
].join('|');
|
||||
if (lifecycleFingerprint !== lastLifecycleFingerprint) {
|
||||
lastLifecycleFingerprint = lifecycleFingerprint;
|
||||
void refreshActiveAutomationLifecycle();
|
||||
// [STEP] waiting_human/failed 也会停轮询,但停前必须落地一次阶段投影,
|
||||
// 否则提交订单后秒级阻断时五阶段条卡在订单复核、自动跳转永不触发。
|
||||
await refreshActiveAutomationLifecycle();
|
||||
}
|
||||
if (UNIFIED_TERMINAL.has(unifiedStatus)) {
|
||||
stopWorkflowProgressPolling();
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1999,6 +1999,47 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('follows the backend stage advance when the route has no lifecycle_stage deep link', async () => {
|
||||
// 无 lifecycle_stage = 尚未钉工作面,应跟随系统 current,不能因空深链永久停在订单复核。
|
||||
const originalQueue = reviewQueue.value;
|
||||
try {
|
||||
reviewQueue.value = {
|
||||
...reviewQueue.value,
|
||||
items: [{
|
||||
...reviewQueue.value.items[0],
|
||||
lifecycle_stage: 'order_review',
|
||||
lifecycle_entries: [
|
||||
{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'fulfillment_prep', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
|
||||
],
|
||||
}],
|
||||
};
|
||||
const wrapper = await mountView({});
|
||||
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
|
||||
.toBeUndefined();
|
||||
|
||||
reviewQueue.value = {
|
||||
...reviewQueue.value,
|
||||
items: [{
|
||||
...reviewQueue.value.items[0],
|
||||
lifecycle_stage: 'fulfillment_prep',
|
||||
lifecycle_entries: [
|
||||
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
|
||||
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
|
||||
],
|
||||
}],
|
||||
};
|
||||
await nextTick();
|
||||
await flushPromises();
|
||||
|
||||
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
|
||||
.toBe('fulfillment_prep');
|
||||
expect(messageMocks.success).toHaveBeenCalledWith('已自动推进到通知准备');
|
||||
} finally {
|
||||
reviewQueue.value = originalQueue;
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps a manually revisited earlier lifecycle stage when the backend advances', async () => {
|
||||
const originalQueue = reviewQueue.value;
|
||||
try {
|
||||
|
||||
@@ -4451,8 +4451,10 @@ watch(
|
||||
) return;
|
||||
// 只响应后端 current 阶段的真实推进:用户点击已完成阶段只会改路由,
|
||||
// 绝不能触发自动跳转而被带回当前阶段。
|
||||
// 无 lifecycle_stage 深链 = 尚未钉工作面,视为仍跟随系统(与「仍停在旧 current」同权)。
|
||||
const requested = String(route.query.lifecycle_stage || '').trim();
|
||||
if (requested !== previousStage) return;
|
||||
const followingSystem = !requested || requested === previousStage;
|
||||
if (!followingSystem) return;
|
||||
if (lifecycleStagePinnedByUserForCase.value === String(activeCase.value?.case_no || '').trim()) return;
|
||||
const previousIndex = LIFECYCLE_STAGE_CODES.indexOf(previousStage);
|
||||
const currentIndex = LIFECYCLE_STAGE_CODES.indexOf(currentStage);
|
||||
|
||||
Reference in new issue
Block a user