feat(shipping-notice): 增强发货通知与订单抽取功能,支持多进程处理与紧急停止
- 移除不再使用的 SHIPPING_NOTICE_LAYOUT_PARSER_REVISION 配置 - 在环境配置中新增 SHIPPING_NOTICE_WORKER_CONCURRENCY 和 SHIPPING_NOTICE_JOB_RUNNING_TIMEOUT_SECONDS - 实现发货通知 worker 进程,支持并发处理订单抽取任务 - 引入紧急停止功能,允许管理员在运行中控制订单解析状态 - 更新相关 API,支持读取与设置紧急停止状态 - 增强文档与代码注释,反映新的业务逻辑与功能要求
This commit is contained in:
1 parent
d0fe084999
commit
b352c281d5
149 files changed
+12550
-1874
No files matched your search
@@ -17,6 +17,7 @@ import type {
|
||||
OrderProfileSampleIntake,
|
||||
OrderProfileSamplePreview,
|
||||
OrderProfilePreviewPages,
|
||||
OrderProfileRegionDiagnosticsResponse,
|
||||
OrderProfileBoundSample,
|
||||
OrderProfilePageTextCandidates,
|
||||
OrderProfileBlindTestInput,
|
||||
@@ -229,13 +230,14 @@ export const suggestOrderProfileOrderFields = (
|
||||
},
|
||||
);
|
||||
|
||||
/** 按当前未保存的工作台定义重读订单单头字段值,供刷新后的复核面板恢复证据。 */
|
||||
/** 按当前未保存的工作台定义重读订单单头字段值;传入多页时由后端统一处理跨页冲突。 */
|
||||
export const previewOrderProfileOrderFieldValues = (
|
||||
documentId: number, schemaVersionId: number, pageNo: number, definition: ShippingOrderDocumentProfile['definition'],
|
||||
pageNos?: number[],
|
||||
) => requestJson<OrderFieldValuePreviewResponse>(
|
||||
'/api/admin/shipping-notice/order-document-profile-samples/order-field-values-preview', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ document_id: documentId, schema_version_id: schemaVersionId, page_no: pageNo, definition }),
|
||||
body: JSON.stringify({ document_id: documentId, schema_version_id: schemaVersionId, page_no: pageNo, page_nos: pageNos, definition }),
|
||||
...jsonAuth(),
|
||||
},
|
||||
);
|
||||
@@ -370,6 +372,13 @@ export const authorizeOrderProfileFrozenSamplePreviewPages = (profileId: number,
|
||||
{ method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 读取冻结样本当前页模板已登记区域的识别值,禁止客户端提交任意坐标。 */
|
||||
export const getOrderProfileFrozenSampleRegionDiagnostics = (profileId: number, sampleBindingId: number, pageNo: number) =>
|
||||
requestJson<OrderProfileRegionDiagnosticsResponse>(
|
||||
`/api/admin/shipping-notice/order-document-profiles/${profileId}/samples/${sampleBindingId}/region-diagnostics/${pageNo}`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
/** 列出当前 Profile 已绑定的标注/训练样本,用于恢复工作台上下文。 */
|
||||
export const listOrderProfileBoundSamples = (profileId: number) =>
|
||||
requestJson<OrderProfileBoundSample[]>(
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
:schemas-resolved="schemasResolved"
|
||||
@update:model-value="updateIdentity"
|
||||
/>
|
||||
<OrderProfileSampleStep v-else-if="step === 2" v-model="documentId" :samples="samples" @uploaded="refreshSamples" />
|
||||
<OrderProfileSampleStep v-else-if="step === 2" v-model="documentId" :samples="samples" @uploaded="refreshSamples(false)" @refresh="refreshSamples()" />
|
||||
<OrderProfileModelStartStep v-else v-model="tableId" :tables="tables" />
|
||||
</main>
|
||||
|
||||
|
||||
+88
-32
@@ -48,6 +48,7 @@ import type {
|
||||
OrderProfileRelativeRegion,
|
||||
OrderProfileBoundSample,
|
||||
OrderFieldLayoutSuggestion,
|
||||
OrderProfileRowReconstructionMode,
|
||||
ShippingOrderDocumentProfile,
|
||||
} from "@/features/admin/types/shipping-order-document-profile.types";
|
||||
import type {
|
||||
@@ -61,9 +62,7 @@ import {
|
||||
toOrderProfileAnchorId,
|
||||
buildOrderProfileRecognitionResults,
|
||||
groupUniqueOrderProfileLineFields,
|
||||
isOrderProfileAnchorRelativeCandidate,
|
||||
normalizeOrderProfileRelativeRegion,
|
||||
toOrderProfileAnchorRelativeRegion,
|
||||
} from "./orderProfileForm.utils";
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -157,6 +156,11 @@ const form = reactive({
|
||||
changeNote: "",
|
||||
});
|
||||
const regions = ref<OrderProfileCanvasRegion[]>([]);
|
||||
/** 每个明细表区的重建策略与页范围独立保存,避免画布重开/保存时回退为默认固定子行。 */
|
||||
const tableRegionSettings = reactive<Record<number, {
|
||||
rowReconstructionMode: OrderProfileRowReconstructionMode;
|
||||
pageScope: 'first_page' | 'all_pages' | 'continuation_pages' | 'exact_page';
|
||||
}>>({});
|
||||
/** 文档匹配锚点独立于字段坐标;必须以固定标签和固定值关系区分模板。 */
|
||||
const documentMatch = reactive({
|
||||
requiredAnchors: [] as OrderProfileDocumentMatchAnchor[],
|
||||
@@ -206,6 +210,22 @@ const headerFields = computed<ShippingOrderFieldConfig[]>(
|
||||
const pageRegions = computed(() =>
|
||||
regions.value.filter((item) => item.pageNo === pageNo.value),
|
||||
);
|
||||
const activePageHasLines = computed(() => pageRegions.value.some((item) => item.kind === 'line'));
|
||||
const activeTableRegionSetting = computed(() => tableRegionSettings[pageNo.value] || {
|
||||
rowReconstructionMode: 'fixed_subrows' as const,
|
||||
pageScope: 'exact_page' as const,
|
||||
});
|
||||
const ensureTableRegionSetting = (targetPageNo: number) => {
|
||||
tableRegionSettings[targetPageNo] ||= {
|
||||
rowReconstructionMode: 'fixed_subrows',
|
||||
pageScope: 'exact_page',
|
||||
};
|
||||
return tableRegionSettings[targetPageNo];
|
||||
};
|
||||
const updateActiveTableRegionSetting = () => {
|
||||
checkpoint();
|
||||
schedulePreview();
|
||||
};
|
||||
const selectedRegion = computed(
|
||||
() => pageRegions.value.find((item) => item.id === selectedId.value) || null,
|
||||
);
|
||||
@@ -213,7 +233,6 @@ const selectedRegion = computed(
|
||||
const selectedRegionSampleValue = computed(() => {
|
||||
const region = selectedRegion.value;
|
||||
if (!region || region.kind !== 'order_field') return null;
|
||||
if (region.suggestedValue) return region.suggestedValue;
|
||||
if (!region.fieldCode) return null;
|
||||
return orderFieldValuePreviews.value.find((item) => item.field_code === region.fieldCode)?.value || null;
|
||||
});
|
||||
@@ -762,6 +781,7 @@ const definition = () => {
|
||||
)]
|
||||
.sort((left, right) => left - right)
|
||||
.map((regionPageNo) => {
|
||||
const regionSettings = ensureTableRegionSetting(regionPageNo);
|
||||
const pageItems = normalizedRegions.filter(
|
||||
(item) => item.pageNo === regionPageNo,
|
||||
);
|
||||
@@ -834,10 +854,11 @@ const definition = () => {
|
||||
);
|
||||
return {
|
||||
region_id: `main_lines_page_${regionPageNo}`,
|
||||
page_scope: "exact_page" as const,
|
||||
page_no: regionPageNo,
|
||||
page_scope: regionSettings.pageScope,
|
||||
page_no: regionSettings.pageScope === 'exact_page' ? regionPageNo : null,
|
||||
region: tableRegion,
|
||||
line_start_field_code: resolveLineStartFieldCode(mainLineFieldCodes),
|
||||
row_reconstruction_mode: regionSettings.rowReconstructionMode,
|
||||
header_layouts: headerLayouts,
|
||||
line_layouts: lineRegions.map((line, index) => {
|
||||
const fieldRegions = fieldRegionsFor(line.id);
|
||||
@@ -894,11 +915,6 @@ const definition = () => {
|
||||
(candidate.id === item.parentId || candidate.orderFieldId === item.orderFieldId),
|
||||
);
|
||||
const anchorId = toOrderProfileAnchorId(anchor);
|
||||
const isAnchorRelative = Boolean(anchor && anchorId && ["right_of_anchor", "below_anchor"].includes(item.valueMode || "")
|
||||
&& isOrderProfileAnchorRelativeCandidate(item.region, anchor.region));
|
||||
const relativeValueRegion = isAnchorRelative && anchor
|
||||
? toOrderProfileAnchorRelativeRegion(item.region, anchor.region)
|
||||
: null;
|
||||
return {
|
||||
layout_id: item.orderFieldId || item.id,
|
||||
field_id: "",
|
||||
@@ -915,13 +931,12 @@ const definition = () => {
|
||||
aliases: [],
|
||||
match_mode: "exact" as const,
|
||||
region: anchor.region,
|
||||
position_locked: !isAnchorRelative,
|
||||
position_locked: true,
|
||||
minimum_evidence_level: "coordinate" as const,
|
||||
}
|
||||
: null,
|
||||
// 画布框是读取边界;锚点只用于定位字段,不能再参与值框二次投影。
|
||||
value_region: relativeValueRegion,
|
||||
absolute_value_region: anchor && anchorId && !relativeValueRegion ? item.region : null,
|
||||
absolute_value_region: anchor && anchorId ? item.region : null,
|
||||
fallback_value_region: anchor && anchorId ? null : item.region,
|
||||
value_mode: item.valueMode || "single_line",
|
||||
stop_anchors:
|
||||
@@ -952,11 +967,6 @@ const definition = () => {
|
||||
candidate.kind === "order_anchor" &&
|
||||
(candidate.id === item.parentId || candidate.orderFieldId === layoutId),
|
||||
);
|
||||
const isAnchorRelative = Boolean(anchor && ["right_of_anchor", "below_anchor"].includes(item.valueMode || "")
|
||||
&& isOrderProfileAnchorRelativeCandidate(item.region, anchor.region));
|
||||
const relativeValueRegion = isAnchorRelative && anchor
|
||||
? toOrderProfileAnchorRelativeRegion(item.region, anchor.region)
|
||||
: null;
|
||||
return {
|
||||
layout_id: layoutId,
|
||||
label: item.label,
|
||||
@@ -969,12 +979,11 @@ const definition = () => {
|
||||
aliases: [],
|
||||
match_mode: "exact" as const,
|
||||
region: anchor.region,
|
||||
position_locked: !isAnchorRelative,
|
||||
position_locked: true,
|
||||
minimum_evidence_level: "coordinate" as const,
|
||||
}
|
||||
: null,
|
||||
value_region: relativeValueRegion,
|
||||
absolute_value_region: anchor && !relativeValueRegion ? item.region : null,
|
||||
absolute_value_region: anchor ? item.region : null,
|
||||
fallback_value_region: anchor ? null : item.region,
|
||||
value_mode: item.valueMode || "single_line",
|
||||
stop_anchors:
|
||||
@@ -1517,6 +1526,14 @@ const mergeEquivalentOrderAnchors = (items: OrderProfileCanvasRegion[]) => {
|
||||
|
||||
/** 从 v2 定义恢复区域,供草稿重开后继续在画布上编辑。 */
|
||||
const restoreRegions = (profile: ShippingOrderDocumentProfile) => {
|
||||
for (const key of Object.keys(tableRegionSettings)) delete tableRegionSettings[Number(key)];
|
||||
for (const table of profile.definition.table_regions) {
|
||||
const regionPageNo = restoreOrderProfileRegionPageNo(table);
|
||||
tableRegionSettings[regionPageNo] = {
|
||||
rowReconstructionMode: table.row_reconstruction_mode || 'fixed_subrows',
|
||||
pageScope: table.page_scope,
|
||||
};
|
||||
}
|
||||
const restored: OrderProfileCanvasRegion[] = [
|
||||
...(profile.definition.document_match.required_anchors || []).flatMap<OrderProfileCanvasRegion>((anchor) => {
|
||||
if (!anchor.label_region || !anchor.value_region || !anchor.page_no) return [];
|
||||
@@ -1530,7 +1547,7 @@ const restoreRegions = (profile: ShippingOrderDocumentProfile) => {
|
||||
}),
|
||||
...(profile.definition.draft_unbound_order_field_layouts || []).flatMap<OrderProfileCanvasRegion>((item) => {
|
||||
const pageNo = item.page_scope === "exact_page" ? item.page_no || 1 : 1;
|
||||
if (!item.anchor?.region || (!item.value_region && !item.absolute_value_region)) {
|
||||
if (!item.anchor?.region || !item.absolute_value_region) {
|
||||
return [{
|
||||
id: `unbound-${item.layout_id}`,
|
||||
kind: "order_field" as const,
|
||||
@@ -1553,13 +1570,11 @@ const restoreRegions = (profile: ShippingOrderDocumentProfile) => {
|
||||
kind: "order_field" as const,
|
||||
label: item.label,
|
||||
region: {
|
||||
x0: item.absolute_value_region?.x0 ?? anchor.x0 + item.value_region!.x0 * (anchor.x1 - anchor.x0),
|
||||
y0: item.absolute_value_region?.y0 ?? anchor.y0 + item.value_region!.y0 * (anchor.y1 - anchor.y0),
|
||||
x1: item.absolute_value_region?.x1 ?? anchor.x0 + item.value_region!.x1 * (anchor.x1 - anchor.x0),
|
||||
y1: item.absolute_value_region?.y1 ?? anchor.y0 + item.value_region!.y1 * (anchor.y1 - anchor.y0),
|
||||
...item.absolute_value_region,
|
||||
},
|
||||
fieldCode: null,
|
||||
orderFieldId: item.layout_id,
|
||||
valueMode: item.value_mode,
|
||||
pageNo,
|
||||
}];
|
||||
}),
|
||||
@@ -1572,7 +1587,7 @@ const restoreRegions = (profile: ShippingOrderDocumentProfile) => {
|
||||
pageNo: item.page_scope === "exact_page" ? item.page_no || 1 : 1,
|
||||
})),
|
||||
...(profile.definition.order_field_layouts || []).flatMap((item) => {
|
||||
if (!item.anchor?.region || (!item.value_region && !item.absolute_value_region)) return [];
|
||||
if (!item.anchor?.region || !item.absolute_value_region) return [];
|
||||
const anchor = item.anchor.region;
|
||||
return [{
|
||||
id: item.anchor.anchor_id,
|
||||
@@ -1586,10 +1601,7 @@ const restoreRegions = (profile: ShippingOrderDocumentProfile) => {
|
||||
kind: "order_field" as const,
|
||||
label: schemaFieldLabel(item.field_code),
|
||||
region: {
|
||||
x0: item.absolute_value_region?.x0 ?? anchor.x0 + item.value_region!.x0 * (anchor.x1 - anchor.x0),
|
||||
y0: item.absolute_value_region?.y0 ?? anchor.y0 + item.value_region!.y0 * (anchor.y1 - anchor.y0),
|
||||
x1: item.absolute_value_region?.x1 ?? anchor.x0 + item.value_region!.x1 * (anchor.x1 - anchor.x0),
|
||||
y1: item.absolute_value_region?.y1 ?? anchor.y0 + item.value_region!.y1 * (anchor.y1 - anchor.y0),
|
||||
...item.absolute_value_region,
|
||||
},
|
||||
fieldCode: item.field_code,
|
||||
orderFieldId: item.layout_id,
|
||||
@@ -2076,6 +2088,36 @@ onBeforeUnmount(() => {
|
||||
<p v-if="!documentMatch.requiredAnchors.length" class="document-match-editor__warning">{{ t('admin.shippingOrderProfiles.workbench.documentMatchAnchorEmpty') }}</p>
|
||||
<p v-if="documentAnchorNotice" class="document-match-editor__warning">{{ documentAnchorNotice }}</p>
|
||||
</section>
|
||||
<section v-if="activePageHasLines" class="table-region-editor">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.workbench.tableRegionSettings') }}</strong>
|
||||
<label>{{ t('admin.shippingOrderProfiles.workbench.rowReconstructionMode') }}
|
||||
<select
|
||||
:value="activeTableRegionSetting.rowReconstructionMode"
|
||||
class="select-field"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFormEdit"
|
||||
@change="(event) => { ensureTableRegionSetting(pageNo).rowReconstructionMode = (event.target as HTMLSelectElement).value as OrderProfileRowReconstructionMode; updateActiveTableRegionSetting(); }"
|
||||
>
|
||||
<option value="fixed_subrows">{{ t('admin.shippingOrderProfiles.workbench.rowReconstructionModes.fixedSubrows') }}</option>
|
||||
<option value="adaptive_record_columns">{{ t('admin.shippingOrderProfiles.workbench.rowReconstructionModes.adaptiveRecordColumns') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<p>{{ t(`admin.shippingOrderProfiles.workbench.rowReconstructionHints.${activeTableRegionSetting.rowReconstructionMode}`) }}</p>
|
||||
<label>{{ t('admin.shippingOrderProfiles.workbench.tableRegionPageScope') }}
|
||||
<select
|
||||
:value="activeTableRegionSetting.pageScope"
|
||||
class="select-field"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFormEdit"
|
||||
@change="(event) => { ensureTableRegionSetting(pageNo).pageScope = (event.target as HTMLSelectElement).value as typeof activeTableRegionSetting.pageScope; updateActiveTableRegionSetting(); }"
|
||||
>
|
||||
<option value="exact_page">{{ t('admin.shippingOrderProfiles.workbench.tableRegionPageScopes.exactPage') }}</option>
|
||||
<option value="first_page">{{ t('admin.shippingOrderProfiles.workbench.tableRegionPageScopes.firstPage') }}</option>
|
||||
<option value="all_pages">{{ t('admin.shippingOrderProfiles.workbench.tableRegionPageScopes.allPages') }}</option>
|
||||
<option value="continuation_pages">{{ t('admin.shippingOrderProfiles.workbench.tableRegionPageScopes.continuationPages') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
</section>
|
||||
<section v-if="selectedRegion" class="editor">
|
||||
<div class="selected-region-meta">
|
||||
<span>{{ t('admin.shippingOrderProfiles.workbench.selectedRegion') }}</span>
|
||||
@@ -2508,6 +2550,18 @@ onBeforeUnmount(() => {
|
||||
padding: 0.85rem;
|
||||
background: #f8fafc;
|
||||
}
|
||||
.table-region-editor {
|
||||
display: grid;
|
||||
gap: 0.55rem;
|
||||
margin-bottom: 0.8rem;
|
||||
padding: 0.75rem;
|
||||
border: 1px solid #dbe5f0;
|
||||
border-radius: 0.5rem;
|
||||
background: #f8fafc;
|
||||
}
|
||||
.table-region-editor > strong { font-size: 0.84rem; }
|
||||
.table-region-editor > label { display: grid; gap: 0.3rem; font-size: 0.78rem; color: #475569; }
|
||||
.table-region-editor > p { margin: 0; font-size: 0.72rem; color: #64748b; }
|
||||
.document-match-editor__heading { display: flex; gap: 0.5rem; align-items: start; }
|
||||
.document-match-editor__heading strong { font-size: 0.84rem; }
|
||||
.document-match-editor__heading p { margin: 0.3rem 0 0; font-size: 0.72rem; color: #64748b; }
|
||||
@@ -2651,6 +2705,8 @@ onBeforeUnmount(() => {
|
||||
.editor-title { min-width: 0; }
|
||||
.editor-workbench .desk { max-width: none; min-height: calc(100vh - 7rem); border-inline: 0; box-shadow: none; }
|
||||
.editor-desk { grid-template-columns: minmax(0, 1fr) 20rem; }
|
||||
.editor-desk > main { min-height: 0; }
|
||||
.editor-workbench .config { max-height: calc(100vh - 5rem); overflow-y: auto; }
|
||||
.editor-bottom-drawer { max-width: none; border-top: 1px solid #334155; background: #f8fafc; }
|
||||
.suggestion-decision { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; border-top: 1px solid #7dd3fc; background: #ecfeff; padding: .65rem .9rem; color: #155e75; }
|
||||
.suggestion-decision span { border-radius: 999px; background: #bae6fd; padding: .15rem .4rem; font-size: .72rem; }.suggestion-decision button,.suggestion-decision .select-field { border: 1px solid #0891b2; border-radius: .35rem; background: #fff; padding: .35rem .55rem; color: #0e7490; font-size: .75rem; }
|
||||
@@ -3090,7 +3146,7 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.editor-desk { grid-template-columns: 1fr; min-height: auto; }
|
||||
.editor-workbench .config { border-left: 0; border-top: 1px solid #cbd5e1; }
|
||||
.editor-workbench .config { max-height: none; overflow-y: visible; border-left: 0; border-top: 1px solid #cbd5e1; }
|
||||
.editor-bottom-drawer__content { grid-template-columns: 1fr; }
|
||||
}
|
||||
.order-field-list {
|
||||
|
||||
+13
-6
@@ -104,15 +104,20 @@ async function loadContext(): Promise<void> {
|
||||
/** Schema 显示名称服务于业务核对;稳定编码仅作为辅助追溯信息保留。 */
|
||||
function fieldName(fieldCode: string): string { return fieldNames.value.get(fieldCode) || fieldCode; }
|
||||
|
||||
/** 使用本次草稿定义重读表头和明细;结果只来自实时接口,不回退历史建议文本。 */
|
||||
/** 使用本次草稿定义重读全部已绑定表头页和明细;结果只来自实时接口,不回退历史建议文本。 */
|
||||
async function loadReadResults(): Promise<void> {
|
||||
if (!profile.value || !sample.value?.table_id) return;
|
||||
resultLoading.value = true;
|
||||
resultFailed.value = false;
|
||||
try {
|
||||
const pageNo = sample.value.table_identity_snapshot?.page_no || 1;
|
||||
const pageNos = Array.from(new Set((profile.value.definition.order_field_layouts || []).map((item) => (
|
||||
item.page_scope === 'exact_page' ? (item.page_no || 1) : 1
|
||||
)))).sort((left, right) => left - right);
|
||||
const pageNo = pageNos[0] || sample.value.table_identity_snapshot?.page_no || 1;
|
||||
const [headers, lines] = await Promise.all([
|
||||
previewOrderProfileOrderFieldValues(sample.value.document_id, profile.value.schema_version_id, pageNo, profile.value.definition),
|
||||
previewOrderProfileOrderFieldValues(
|
||||
sample.value.document_id, profile.value.schema_version_id, pageNo, profile.value.definition, pageNos,
|
||||
),
|
||||
previewOrderProfileRegion(profileId, sample.value.document_id, sample.value.table_id, profile.value.definition),
|
||||
]);
|
||||
headerValues.value = headers.fields;
|
||||
@@ -168,8 +173,9 @@ function backToEditor(): void {
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([loadRuns(), loadContext()]);
|
||||
await loadReadResults();
|
||||
if (canStartBlindTest.value) {
|
||||
await Promise.all([loadBlindTestSuite(), loadReadResults()]);
|
||||
await loadBlindTestSuite();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -212,13 +218,13 @@ onMounted(async () => {
|
||||
<div class="gate-actions"><strong :class="`status ${blindTestSuite?.status || 'pending'}`">{{ t(`admin.shippingOrderProfiles.blindTest.status.${blindTestSuite?.status || 'missing'}`) }}</strong><button type="button" class="btn-secondary" @click="goToBlindTest">{{ t('admin.shippingOrderProfiles.blindTest.title') }}</button></div>
|
||||
</section>
|
||||
|
||||
<section v-if="canStartBlindTest" class="results" :aria-label="t('admin.orderProfileValidation.resultsTitle')">
|
||||
<section v-if="profile && sample" class="results" :aria-label="t('admin.orderProfileValidation.resultsTitle')">
|
||||
<div class="results-heading"><div><h2>{{ t('admin.orderProfileValidation.resultsTitle') }}</h2><p>{{ t('admin.orderProfileValidation.resultsHint') }}</p></div><button type="button" class="btn-secondary btn-sm" :disabled="resultLoading" @click="loadReadResults">{{ t('admin.orderProfileValidation.refreshResults') }}</button></div>
|
||||
<p v-if="resultLoading">{{ t('admin.orderProfileValidation.resultsLoading') }}</p>
|
||||
<p v-else-if="resultFailed" class="result-error">{{ t('admin.orderProfileValidation.resultsFailed') }}</p>
|
||||
<template v-else>
|
||||
<h3>{{ t('admin.orderProfileValidation.headerResults') }}</h3>
|
||||
<dl v-if="headerValues.length" class="header-results"><div v-for="field in headerValues" :key="field.field_id"><dt>{{ fieldName(field.field_code) }}</dt><dd class="field-code">{{ field.field_code }}</dd><dd>{{ field.value || t('admin.orderProfileValidation.noValue') }}</dd></div></dl>
|
||||
<dl v-if="headerValues.length" class="header-results"><div v-for="field in headerValues" :key="`${field.field_id}:${field.page_no || 0}`" :class="`field-${field.status}`"><dt>{{ fieldName(field.field_code) }}</dt><dd class="field-code">{{ field.field_code }} · P{{ field.page_no || '-' }}</dd><dd>{{ field.value || t('admin.orderProfileValidation.noValue') }}</dd><dd v-if="field.issues.length" class="field-issues">{{ field.issues.join(', ') }}</dd></div></dl>
|
||||
<p v-else>{{ t('admin.orderProfileValidation.noHeaderResults') }}</p>
|
||||
<h3>{{ t('admin.orderProfileValidation.lineResults') }}</h3>
|
||||
<div v-if="linePreview?.rows?.length" class="line-results"><table><thead><tr><th v-for="field in linePreview.rows[0]" :key="field"><span>{{ fieldName(field) }}</span><small>{{ field }}</small></th><th>{{ t('admin.orderProfileValidation.rowStatus') }}</th></tr></thead><tbody><tr v-for="(row, index) in linePreview.rows.slice(1)" :key="index" :class="linePreview.row_roles[index + 1] === 'deleted' ? 'deleted-row' : ''"><td v-for="(value, cellIndex) in row" :key="cellIndex">{{ value || t('admin.orderProfileValidation.noValue') }}</td><td>{{ linePreview.row_roles[index + 1] === 'deleted' ? t('admin.orderProfileValidation.deleted') : t('admin.orderProfileValidation.read') }}</td></tr></tbody></table></div>
|
||||
@@ -241,5 +247,6 @@ button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.current-draft-validation { display: grid; gap: 16px; margin-top: 20px; padding: 16px; }.current-draft-validation > header { align-items: center; }.current-draft-validation > header > div { min-width: 0; }.current-draft-validation > header button { flex: 0 0 auto; }.checks { display: grid; gap: 10px; }.checks article { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-radius: 8px; padding: 15px 16px; }.status { min-width: 72px; text-align: right; font-size: 13px; font-weight: 600; }.passed { color: #15803d; }.failed, .stale { color: #b91c1c; }.pending, .running { color: #64748b; }
|
||||
.blind-test-gate { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 16px; }.blind-test-gate h2 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }.gate-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }.gate-actions .approved { color: #15803d; }.gate-actions .draft, .gate-actions .missing { color: #b45309; }
|
||||
.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 { border-color: #fed7aa; background: #fff7ed; }.header-results .field-issues { color: #b45309; font-size: 11px; }
|
||||
@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>
|
||||
+120
-6
@@ -2,10 +2,11 @@
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileVersionDetailPage.vue
|
||||
用途:订单模板版本中心详情页,支持刷新恢复与分享。
|
||||
依赖:版本详情 composable、配置概览组件、版本中心 API。
|
||||
逻辑:当前已接入配置概览、只读样本画布、服务端语义 diff、审计时间线与实际使用;后续仅剩盲测隔离与发布治理收口。
|
||||
逻辑:当前已接入配置概览、只读样本画布、服务端语义 diff、审计时间线与实际使用;
|
||||
Schema 迁移弹窗按模态语义提供初始焦点、Tab 陷阱、Escape 关闭与焦点恢复。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
@@ -35,6 +36,19 @@ const migrating = ref(false);
|
||||
const migrationOpen = ref(false);
|
||||
const publishedSchema = ref<ShippingOrderSchemaVersion | null>(null);
|
||||
const migrationResolutions = ref<Record<string, { action: "unbind" } | { replacement_field_id: string }>>({});
|
||||
const migrationPanelRef = ref<HTMLElement | null>(null);
|
||||
const migrationCancelRef = ref<HTMLButtonElement | null>(null);
|
||||
let previouslyFocused: HTMLElement | null = null;
|
||||
|
||||
const FOCUSABLE_SELECTOR = [
|
||||
"a[href]",
|
||||
"button:not([disabled])",
|
||||
"textarea:not([disabled])",
|
||||
"input:not([disabled])",
|
||||
"select:not([disabled])",
|
||||
'[tabindex]:not([tabindex="-1"])',
|
||||
].join(",");
|
||||
|
||||
const {
|
||||
activeTab,
|
||||
detail,
|
||||
@@ -62,6 +76,53 @@ const loadPublishedSchema = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 收集迁移弹窗内可聚焦控件。 */
|
||||
function migrationFocusableNodes(): HTMLElement[] {
|
||||
if (!migrationPanelRef.value) return [];
|
||||
return Array.from(migrationPanelRef.value.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR))
|
||||
.filter((node) => !node.hasAttribute("disabled") && node.getAttribute("aria-hidden") !== "true");
|
||||
}
|
||||
|
||||
/** 关闭 Schema 迁移弹窗。 */
|
||||
function closeSchemaMigration(): void {
|
||||
if (migrating.value) return;
|
||||
migrationOpen.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape 关闭;Tab 在弹窗内循环,阻止焦点逃逸到背景页。
|
||||
*/
|
||||
function onMigrationKeydown(event: KeyboardEvent): void {
|
||||
if (!migrationOpen.value) return;
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
closeSchemaMigration();
|
||||
return;
|
||||
}
|
||||
if (event.key !== "Tab") return;
|
||||
const nodes = migrationFocusableNodes();
|
||||
const first = nodes[0];
|
||||
const last = nodes[nodes.length - 1];
|
||||
if (!first || !last) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
const active = document.activeElement as HTMLElement | null;
|
||||
const inside = Boolean(active && migrationPanelRef.value?.contains(active));
|
||||
if (event.shiftKey) {
|
||||
if (!inside || active === first) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!inside || active === last) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
}
|
||||
|
||||
const openSchemaMigration = () => {
|
||||
migrationResolutions.value = Object.fromEntries(
|
||||
breakingChanges.value.map((change) => [change.field_id, { action: "unbind" }]),
|
||||
@@ -125,6 +186,35 @@ const migrateSchema = async () => {
|
||||
|
||||
onMounted(() => { void loadPublishedSchema(); });
|
||||
|
||||
watch(
|
||||
() => migrationOpen.value,
|
||||
async (open, wasOpen) => {
|
||||
if (typeof document === "undefined") return;
|
||||
if (open && !wasOpen) {
|
||||
previouslyFocused = document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: null;
|
||||
document.addEventListener("keydown", onMigrationKeydown, true);
|
||||
await nextTick();
|
||||
(migrationCancelRef.value || migrationFocusableNodes()[0])?.focus();
|
||||
return;
|
||||
}
|
||||
if (!open && wasOpen) {
|
||||
document.removeEventListener("keydown", onMigrationKeydown, true);
|
||||
const restoreTarget = previouslyFocused;
|
||||
previouslyFocused = null;
|
||||
await nextTick();
|
||||
restoreTarget?.focus?.();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (typeof document !== "undefined") {
|
||||
document.removeEventListener("keydown", onMigrationKeydown, true);
|
||||
}
|
||||
});
|
||||
|
||||
watch([detail, publishedSchema, () => route.query.migrate], () => {
|
||||
if (route.query.migrate !== "1" || !canMigrateSchema.value || migrationOpen.value) return;
|
||||
openSchemaMigration();
|
||||
@@ -312,8 +402,21 @@ const createNewVersion = async () => {
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="migrationOpen" class="migration-backdrop" role="presentation" @click.self="migrationOpen = false">
|
||||
<section class="migration-dialog" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderProfiles.schemaMigration.title')">
|
||||
<div
|
||||
v-if="migrationOpen"
|
||||
class="migration-backdrop"
|
||||
role="presentation"
|
||||
data-testid="order-profile-schema-migration-backdrop"
|
||||
@click.self="closeSchemaMigration"
|
||||
>
|
||||
<section
|
||||
ref="migrationPanelRef"
|
||||
class="migration-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="t('admin.shippingOrderProfiles.schemaMigration.title')"
|
||||
data-testid="order-profile-schema-migration-dialog"
|
||||
>
|
||||
<h2>{{ t("admin.shippingOrderProfiles.schemaMigration.title") }}</h2>
|
||||
<p>{{ t("admin.shippingOrderProfiles.schemaMigration.description", { from: detail?.schema_version, to: publishedSchema?.version }) }}</p>
|
||||
<p class="migration-note">{{ t("admin.shippingOrderProfiles.schemaMigration.revalidation") }}</p>
|
||||
@@ -337,8 +440,19 @@ const createNewVersion = async () => {
|
||||
</div>
|
||||
<p v-else class="migration-note">{{ t("admin.shippingOrderProfiles.schemaMigration.noBreakingChanges") }}</p>
|
||||
<footer>
|
||||
<button type="button" class="btn-secondary" :disabled="migrating" @click="migrationOpen = false">{{ t("admin.shippingOrderProfiles.schemaMigration.cancel") }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="migrating" @click="migrateSchema">{{ migrating ? t("admin.shippingOrderProfiles.saving") : t("admin.shippingOrderProfiles.schemaMigration.confirm") }}</button>
|
||||
<button
|
||||
ref="migrationCancelRef"
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
:disabled="migrating"
|
||||
data-testid="order-profile-schema-migration-cancel"
|
||||
@click="closeSchemaMigration"
|
||||
>
|
||||
{{ t("admin.shippingOrderProfiles.schemaMigration.cancel") }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary" :disabled="migrating" @click="migrateSchema">
|
||||
{{ migrating ? t("admin.shippingOrderProfiles.saving") : t("admin.shippingOrderProfiles.schemaMigration.confirm") }}
|
||||
</button>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
+15
-5
@@ -2,7 +2,8 @@
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileDocumentCanvas.vue
|
||||
用途:展示受控 PDF 单页预览,并以相对坐标框支持选择、拖动和缩放区域。
|
||||
依赖:浏览器 fetch、认证请求头、OrderProfileCanvasRegion。
|
||||
逻辑:父级签发单页令牌并提供分页动作;mode=readonly 时只允许查看/缩放/切页,不允许写入任何标注改动。
|
||||
逻辑:父级签发单页令牌并提供分页动作;mode=readonly 时只允许查看/缩放/切页,不允许写入任何标注改动;
|
||||
画布区域 aria-label 走四语言 i18n,供辅助技术正确读出只读/标注模式。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
@@ -171,8 +172,11 @@ const endCreation = () => {
|
||||
};
|
||||
|
||||
const selected = computed(() => new Set([props.selectedRegionId]));
|
||||
/** 订单字段标签只使用父级本次坐标读取结果,模板定义仍只保存字段与坐标。 */
|
||||
/** 在画布徽标展示字段身份和实际识别值;编辑态订单字段继续使用工作台即时读取状态。 */
|
||||
const displayRegionLabel = (region: OrderProfileCanvasRegion): string => {
|
||||
if (readonlyMode.value && !['line', 'exclusion'].includes(region.kind)) {
|
||||
return `${region.label} · ${region.recognizedValue || t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable')}`;
|
||||
}
|
||||
if (region.kind !== 'order_field') return region.label;
|
||||
const state = props.orderFieldValueState || 'idle';
|
||||
const value = region.fieldCode ? props.orderFieldValues?.[region.fieldCode] : null;
|
||||
@@ -202,7 +206,12 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="canvas-shell" :aria-label="readonlyMode ? 'Document readonly canvas' : 'Document annotation canvas'">
|
||||
<section
|
||||
class="canvas-shell"
|
||||
:aria-label="readonlyMode
|
||||
? t('admin.shippingOrderProfiles.workbench.readonlyCanvasAriaLabel')
|
||||
: t('admin.shippingOrderProfiles.workbench.annotationCanvasAriaLabel')"
|
||||
>
|
||||
<header v-if="imageUrl" class="canvas-toolbar">
|
||||
<div class="toolbar-actions">
|
||||
<template v-if="!readonlyMode">
|
||||
@@ -277,7 +286,7 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.canvas-shell { min-height: 36rem; background: #101827; padding: 0 1rem 1rem; overflow: hidden; }
|
||||
.canvas-shell { display: flex; height: calc(100vh - 5rem); min-height: 48rem; flex-direction: column; background: #101827; padding: 0 1rem 1rem; overflow: hidden; }
|
||||
.canvas-toolbar { position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem; margin: 0 -1rem 1rem; padding: .55rem 1rem; border-bottom: 1px solid #26354b; background: rgb(15 23 42 / .98); color: #cbd5e1; font-size: .75rem; }
|
||||
.canvas-toolbar > div { display: flex; align-items: center; gap: .35rem; }
|
||||
.canvas-toolbar button { display: inline-flex; min-width: 2rem; height: 2rem; align-items: center; justify-content: center; gap: .35rem; border: 1px solid #475569; border-radius: .35rem; background: #1e293b; padding: .3rem .5rem; color: #e2e8f0; font-size: .72rem; }
|
||||
@@ -300,7 +309,7 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
.canvas-toolbar output { min-width: 3.4rem; color: #f8fafc; text-align: center; }
|
||||
.zoom-control .fit-action { padding-inline: .65rem; }
|
||||
.canvas-state { display: grid; min-height: 32rem; place-items: center; color: #94a3b8; font-size: .875rem; }
|
||||
.canvas-work-area { display: flex; max-height: 43rem; gap: .6rem; }
|
||||
.canvas-work-area { display: flex; min-height: 0; flex: 1; gap: .6rem; }
|
||||
.canvas-work-area.readonly { gap: 0; }
|
||||
.canvas-viewport { position: relative; min-width: 0; flex: 1; overflow: auto; }
|
||||
.canvas-viewport.panning { cursor: grab; }
|
||||
@@ -355,6 +364,7 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
.region.selected:not(.region-line) { z-index: 4; }
|
||||
.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; }
|
||||
.page-control { grid-column: 1 / -1; grid-row: 2; }
|
||||
.zoom-control { justify-self: end; }
|
||||
|
||||
+101
-2
@@ -8,10 +8,14 @@
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { authorizeOrderProfileFrozenSamplePreviewPages } from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import {
|
||||
authorizeOrderProfileFrozenSamplePreviewPages,
|
||||
getOrderProfileFrozenSampleRegionDiagnostics,
|
||||
} from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import type {
|
||||
OrderProfileBoundSample,
|
||||
OrderProfilePreviewPages,
|
||||
OrderProfileRegionDiagnostic,
|
||||
ShippingOrderDocumentProfile,
|
||||
} from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import OrderProfileDocumentCanvas from './OrderProfileDocumentCanvas.vue';
|
||||
@@ -28,6 +32,8 @@ const errorMessage = ref('');
|
||||
const selectedSampleId = ref<number | null>(null);
|
||||
const selectedRegionId = ref<string | null>(null);
|
||||
const previewPages = ref<OrderProfilePreviewPages | null>(null);
|
||||
const regionDiagnostics = ref(new Map<string, OrderProfileRegionDiagnostic>());
|
||||
const diagnosticsLoading = ref(false);
|
||||
const pageNo = ref(1);
|
||||
|
||||
const readonlySamples = computed(() =>
|
||||
@@ -36,7 +42,15 @@ const readonlySamples = computed(() =>
|
||||
const selectedSample = computed<OrderProfileBoundSample | null>(() =>
|
||||
readonlySamples.value.find((sample) => sample.id === selectedSampleId.value) || null,
|
||||
);
|
||||
const readonlyRegions = computed(() => buildOrderProfileReadonlyRegions(props.detail));
|
||||
const readonlyRegions = computed(() => buildOrderProfileReadonlyRegions(props.detail).map((region) => {
|
||||
const diagnostic = regionDiagnostics.value.get(region.id);
|
||||
return diagnostic ? {
|
||||
...region,
|
||||
recognizedValue: diagnostic.recognized_value,
|
||||
configuredValue: diagnostic.configured_value,
|
||||
matchesConfigured: diagnostic.matches_configured,
|
||||
} : region;
|
||||
}));
|
||||
const pageRegions = computed(() => readonlyRegions.value.filter((region) => region.pageNo === pageNo.value));
|
||||
const selectedRegion = computed(() => pageRegions.value.find((region) => region.id === selectedRegionId.value) || null);
|
||||
const currentGrant = computed(() =>
|
||||
@@ -48,6 +62,9 @@ const previewPagePath = computed(() => (
|
||||
: null
|
||||
));
|
||||
const immutable = computed(() => props.detail.status !== 'draft');
|
||||
const selectedDiagnostic = computed(() => (
|
||||
selectedRegion.value ? regionDiagnostics.value.get(selectedRegion.value.id) || null : null
|
||||
));
|
||||
|
||||
const sampleLabel = (sample: OrderProfileBoundSample) => {
|
||||
const tableLabel = sample.table_identity_snapshot?.table_id || sample.table_id || '-';
|
||||
@@ -57,6 +74,7 @@ const sampleLabel = (sample: OrderProfileBoundSample) => {
|
||||
const loadPreview = async (sampleId: number | null) => {
|
||||
if (!sampleId || !immutable.value) {
|
||||
previewPages.value = null;
|
||||
regionDiagnostics.value = new Map();
|
||||
errorMessage.value = '';
|
||||
return;
|
||||
}
|
||||
@@ -78,6 +96,27 @@ const loadPreview = async (sampleId: number | null) => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 读取当前冻结样本页的受控区域识别值,并按 region ID 合并到只读画布。 */
|
||||
const loadRegionDiagnostics = async (): Promise<void> => {
|
||||
const sampleId = selectedSampleId.value;
|
||||
if (!sampleId || !immutable.value) {
|
||||
regionDiagnostics.value = new Map();
|
||||
return;
|
||||
}
|
||||
diagnosticsLoading.value = true;
|
||||
try {
|
||||
const payload = await getOrderProfileFrozenSampleRegionDiagnostics(props.detail.id, sampleId, pageNo.value);
|
||||
regionDiagnostics.value = new Map(payload.items.map((item) => [item.region_id, item]));
|
||||
} catch (error) {
|
||||
regionDiagnostics.value = new Map();
|
||||
errorMessage.value = error instanceof BusinessError
|
||||
? error.message
|
||||
: t('admin.shippingOrderProfiles.versionCenter.regionDiagnosticsLoadFailed');
|
||||
} finally {
|
||||
diagnosticsLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.detail.id,
|
||||
() => {
|
||||
@@ -90,6 +129,10 @@ watch(
|
||||
watch(selectedSampleId, (value) => {
|
||||
void loadPreview(value);
|
||||
}, { immediate: true });
|
||||
|
||||
watch([selectedSampleId, pageNo], () => {
|
||||
void loadRegionDiagnostics();
|
||||
}, { immediate: true });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -134,6 +177,7 @@ watch(selectedSampleId, (value) => {
|
||||
<OrderProfileFrozenEvidencePanel :sample="selectedSample" />
|
||||
<section class="panel">
|
||||
<h3>{{ t('admin.shippingOrderProfiles.versionCenter.regionSummaryTitle') }}</h3>
|
||||
<p v-if="diagnosticsLoading" class="diagnostic-state">{{ t('admin.shippingOrderProfiles.versionCenter.regionDiagnosticsLoading') }}</p>
|
||||
<p v-if="!selectedRegion" class="empty">{{ t('admin.shippingOrderProfiles.versionCenter.selectRegionHint') }}</p>
|
||||
<dl v-else class="grid">
|
||||
<div>
|
||||
@@ -152,6 +196,22 @@ watch(selectedSampleId, (value) => {
|
||||
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.regionPageTitle') }}</dt>
|
||||
<dd>{{ selectedRegion.pageNo }}</dd>
|
||||
</div>
|
||||
<div class="wide-row">
|
||||
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.recognizedValueTitle') }}</dt>
|
||||
<dd class="diagnostic-value">{{ selectedDiagnostic?.recognized_value || t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable') }}</dd>
|
||||
</div>
|
||||
<div v-if="selectedDiagnostic?.configured_value != null" class="wide-row">
|
||||
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.configuredValueTitle') }}</dt>
|
||||
<dd class="diagnostic-value">{{ selectedDiagnostic.configured_value }}</dd>
|
||||
</div>
|
||||
<div v-if="selectedDiagnostic?.matches_configured != null" class="wide-row">
|
||||
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.matchResultTitle') }}</dt>
|
||||
<dd :class="selectedDiagnostic.matches_configured ? 'match-ok' : 'match-failed'">
|
||||
{{ selectedDiagnostic.matches_configured
|
||||
? t('admin.shippingOrderProfiles.versionCenter.matchResultMatched')
|
||||
: t('admin.shippingOrderProfiles.versionCenter.matchResultMismatched') }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</section>
|
||||
</div>
|
||||
@@ -225,6 +285,45 @@ watch(selectedSampleId, (value) => {
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.wide-row {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.diagnostic-state {
|
||||
margin: 0.75rem 0 0;
|
||||
color: #0369a1;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.diagnostic-value {
|
||||
border-left: 3px solid #0ea5e9;
|
||||
background: #f0f9ff;
|
||||
padding: 0.65rem 0.75rem;
|
||||
color: #0f172a;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
line-height: 1.55;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.match-ok,
|
||||
.match-failed {
|
||||
display: inline-flex;
|
||||
width: fit-content;
|
||||
border-radius: 999px;
|
||||
padding: 0.3rem 0.65rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.match-ok {
|
||||
background: #dcfce7;
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
.match-failed {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.warning-text {
|
||||
margin: 0;
|
||||
color: #b45309;
|
||||
|
||||
+28
-12
@@ -5,7 +5,7 @@
|
||||
逻辑:上传后轮询同一 Intake;只有 ready 样本进入父级选择值,避免要求管理员重复选择刚上传的文件。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { CheckCircle2, Clock3, UploadCloud } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
@@ -15,11 +15,12 @@ import { createOrderProfileSample, getOrderProfileSampleStatus } from '@/feature
|
||||
|
||||
type Sample = { document_id: number; filename?: string | null; table_count: number; intake_no: string };
|
||||
const props = defineProps<{ samples: Sample[]; modelValue: number }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: number]; uploaded: []; }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: number]; uploaded: [intakeNo: string]; refresh: []; }>();
|
||||
const { t } = useI18n();
|
||||
const message = useMessage();
|
||||
const uploading = ref(false);
|
||||
const pendingIntake = ref<{ intakeNo: string; filename: string; state: 'parsing' | 'failed'; errorCode?: string | null } | null>(null);
|
||||
type PendingState = 'uploading' | 'queued' | 'parsing' | 'syncing' | 'failed';
|
||||
const pendingIntake = ref<{ intakeNo?: string; filename: string; state: PendingState; errorCode?: string | null } | null>(null);
|
||||
let pollingTimer: number | null = null;
|
||||
const selectedSample = computed(() => props.samples.find((item) => item.document_id === props.modelValue) || null);
|
||||
|
||||
@@ -39,19 +40,26 @@ function selectUploadedSample(intakeNo: string): boolean {
|
||||
const sample = props.samples.find((item) => item.intake_no === intakeNo);
|
||||
if (!sample) return false;
|
||||
emit('update:modelValue', sample.document_id);
|
||||
stopPolling();
|
||||
pendingIntake.value = null;
|
||||
return true;
|
||||
}
|
||||
/** 父级完成样本列表请求后立即选中同一 Intake,避免固定延时与接口响应竞态。 */
|
||||
watch(() => props.samples, () => {
|
||||
const intakeNo = pendingIntake.value?.intakeNo;
|
||||
if (intakeNo && pendingIntake.value?.state === 'syncing' && selectUploadedSample(intakeNo)) {
|
||||
message.success(t('admin.shippingOrderProfiles.wizard.sampleReady'));
|
||||
}
|
||||
}, { deep: false });
|
||||
/** 查询异步解析状态,完成后请求父级刷新列表并自动选中当前上传的样本。 */
|
||||
async function pollIntake(intakeNo: string): Promise<void> {
|
||||
try {
|
||||
const result = await getOrderProfileSampleStatus(intakeNo);
|
||||
if (result.parse_status === 'parsed' && result.document_count > 0) {
|
||||
emit('uploaded');
|
||||
window.setTimeout(() => {
|
||||
if (selectUploadedSample(intakeNo)) message.success(t('admin.shippingOrderProfiles.wizard.sampleReady'));
|
||||
else pollingTimer = window.setTimeout(() => void pollIntake(intakeNo), 800);
|
||||
}, 350);
|
||||
pendingIntake.value = { intakeNo, filename: pendingIntake.value?.filename || '', state: 'syncing' };
|
||||
emit('uploaded', intakeNo);
|
||||
// 列表可能比状态接口晚一个轮询周期可见,保持轮询直到父级刷新后精确选中。
|
||||
pollingTimer = window.setTimeout(() => void pollIntake(intakeNo), 1000);
|
||||
return;
|
||||
}
|
||||
if (['failed', 'error'].includes(result.parse_status)) {
|
||||
@@ -60,6 +68,7 @@ async function pollIntake(intakeNo: string): Promise<void> {
|
||||
};
|
||||
return;
|
||||
}
|
||||
if (pendingIntake.value) pendingIntake.value.state = result.document_count ? 'parsing' : 'queued';
|
||||
pollingTimer = window.setTimeout(() => void pollIntake(intakeNo), 1500);
|
||||
} catch {
|
||||
pollingTimer = window.setTimeout(() => void pollIntake(intakeNo), 2000);
|
||||
@@ -74,12 +83,14 @@ async function upload(event: Event): Promise<void> {
|
||||
if (!/\.(pdf|eml)$/i.test(file.name)) { message.error(t('admin.shippingOrderProfiles.sampleFileTypeInvalid')); return; }
|
||||
stopPolling();
|
||||
uploading.value = true;
|
||||
pendingIntake.value = { filename: file.name, state: 'uploading' };
|
||||
try {
|
||||
const asset = await uploadFileAsset(file);
|
||||
const intake = await createOrderProfileSample(asset.asset_no);
|
||||
pendingIntake.value = { intakeNo: intake.intake_no, filename: file.name, state: 'parsing' };
|
||||
pendingIntake.value = { intakeNo: intake.intake_no, filename: file.name, state: 'queued' };
|
||||
void pollIntake(intake.intake_no);
|
||||
} catch (error) {
|
||||
pendingIntake.value = null;
|
||||
message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.wizard.uploadFailed'));
|
||||
} finally { uploading.value = false; }
|
||||
}
|
||||
@@ -95,8 +106,13 @@ onBeforeUnmount(stopPolling);
|
||||
</section>
|
||||
|
||||
<div v-if="pendingIntake" class="parse-status" :class="{ failed: pendingIntake.state === 'failed' }">
|
||||
<Clock3 v-if="pendingIntake.state === 'parsing'" :size="19" /><span v-else>!</span>
|
||||
<div><strong>{{ pendingIntake.filename }}</strong><p>{{ pendingIntake.state === 'parsing' ? t('admin.shippingOrderProfiles.wizard.sampleParsing') : sampleFailureMessage(pendingIntake.errorCode) }}</p></div>
|
||||
<Clock3 v-if="pendingIntake.state !== 'failed'" :size="19" /><span v-else>!</span>
|
||||
<div>
|
||||
<strong>{{ pendingIntake.filename }}</strong>
|
||||
<p v-if="pendingIntake.state === 'failed'">{{ sampleFailureMessage(pendingIntake.errorCode) }}</p>
|
||||
<p v-else>{{ t(`admin.shippingOrderProfiles.wizard.sampleStatus.${pendingIntake.state}`) }}</p>
|
||||
<button v-if="pendingIntake.state !== 'uploading' && pendingIntake.state !== 'failed'" type="button" class="refresh-status" @click="emit('refresh')">{{ t('admin.shippingOrderProfiles.wizard.refreshSamples') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedSample" class="selected-sample"><CheckCircle2 :size="20" /><div><strong>{{ t('admin.shippingOrderProfiles.wizard.sampleSelected') }}</strong><span>{{ selectedSample.filename || selectedSample.intake_no }} · {{ selectedSample.table_count }} {{ t('admin.shippingOrderProfiles.tablesUnit') }}</span></div></div>
|
||||
@@ -109,5 +125,5 @@ onBeforeUnmount(stopPolling);
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--bg-surface-soft); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--status-info-fg); background: var(--status-info-bg); }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: var(--text-primary); font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .84rem; }.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: #1677d2; font-weight: 700; cursor: pointer; }.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--status-info-fg); background: var(--status-info-bg); }.parse-status strong,.selected-sample strong { display: block; color: var(--text-primary); }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--text-muted); font-size: .83rem; }.parse-status.failed { color: var(--status-error-fg); border-color: var(--status-error-border); background: var(--status-error-bg); }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--status-error-fg); font-weight: 800; }.selected-sample { color: var(--status-success-fg); border-color: var(--status-success-border); background: var(--status-success-bg); }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: var(--text-secondary); font-size: .88rem; font-weight: 700; }.field .select-field { min-height: 44px; font: inherit; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
|
||||
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--bg-surface-soft); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--status-info-fg); background: var(--status-info-bg); }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: var(--text-primary); font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .84rem; }.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: #1677d2; font-weight: 700; cursor: pointer; }.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--status-info-fg); background: var(--status-info-bg); }.parse-status strong,.selected-sample strong { display: block; color: var(--text-primary); }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--text-muted); font-size: .83rem; }.refresh-status { margin-top: 6px; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; text-decoration: underline; }.parse-status.failed { color: var(--status-error-fg); border-color: var(--status-error-border); background: var(--status-error-bg); }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--status-error-fg); font-weight: 800; }.selected-sample { color: var(--status-success-fg); border-color: var(--status-success-border); background: var(--status-success-bg); }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: var(--text-secondary); font-size: .88rem; font-weight: 700; }.field .select-field { min-height: 44px; font: inherit; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
|
||||
</style>
|
||||
-22
@@ -15,9 +15,7 @@ import {
|
||||
shouldShowStandardOrderProfilePreview,
|
||||
toOrderProfileAnchorId,
|
||||
buildOrderProfileRecognitionResults,
|
||||
isOrderProfileAnchorRelativeCandidate,
|
||||
normalizeOrderProfileRelativeRegion,
|
||||
toOrderProfileAnchorRelativeRegion,
|
||||
groupUniqueOrderProfileLineFields,
|
||||
} from './orderProfileForm.utils';
|
||||
|
||||
@@ -226,24 +224,4 @@ describe('order profile form rules', () => {
|
||||
expect(normalizeOrderProfileRelativeRegion({ x0: 1.1, y0: .2, x1: 1.2, y1: .3 })).toBeNull();
|
||||
});
|
||||
|
||||
it('serializes a right-of-anchor value box as a movable anchor-relative region', () => {
|
||||
expect(toOrderProfileAnchorRelativeRegion(
|
||||
{ x0: .42, y0: .80, x1: .50, y1: .82 },
|
||||
{ x0: .30, y0: .80, x1: .41, y1: .82 },
|
||||
)).toEqual({ x0: expect.closeTo(1.090909), y0: 0, x1: expect.closeTo(1.818181), y1: 1 });
|
||||
});
|
||||
|
||||
it('keeps a remote legacy value box absolute instead of creating invalid relative offsets', () => {
|
||||
expect(isOrderProfileAnchorRelativeCandidate(
|
||||
{ x0: .33, y0: .58, x1: .72, y1: .60 },
|
||||
{ x0: .02, y0: .10, x1: .15, y1: .12 },
|
||||
)).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps a same-row auto suggestion absolute when its tiny label makes the relative span exceed the contract', () => {
|
||||
expect(isOrderProfileAnchorRelativeCandidate(
|
||||
{ x0: .30, y0: .40, x1: .95, y1: .42 },
|
||||
{ x0: .20, y0: .40, x1: .21, y1: .42 },
|
||||
)).toBe(false);
|
||||
});
|
||||
});
|
||||
-37
@@ -68,43 +68,6 @@ export const normalizeOrderProfileRelativeRegion = (
|
||||
return x0 < x1 && y0 < y1 ? { x0, y0, x1, y1 } : null;
|
||||
};
|
||||
|
||||
/** 将页面值框换算为锚点尺寸的相对偏移,供标签右侧字段随标签移动读取。 */
|
||||
export const toOrderProfileAnchorRelativeRegion = (
|
||||
valueRegion: OrderProfileRelativeRegion,
|
||||
anchorRegion: OrderProfileRelativeRegion,
|
||||
): OrderProfileRelativeRegion | null => {
|
||||
const width = anchorRegion.x1 - anchorRegion.x0;
|
||||
const height = anchorRegion.y1 - anchorRegion.y0;
|
||||
if (width <= 0 || height <= 0) return null;
|
||||
const relative = {
|
||||
x0: (valueRegion.x0 - anchorRegion.x0) / width,
|
||||
y0: (valueRegion.y0 - anchorRegion.y0) / height,
|
||||
x1: (valueRegion.x1 - anchorRegion.x0) / width,
|
||||
y1: (valueRegion.y1 - anchorRegion.y0) / height,
|
||||
};
|
||||
return Number.isFinite(relative.x0) && Number.isFinite(relative.y0)
|
||||
&& Number.isFinite(relative.x1) && Number.isFinite(relative.y1)
|
||||
&& relative.x0 < relative.x1 && relative.y0 < relative.y1 ? relative : null;
|
||||
};
|
||||
|
||||
/** 判断标签和值框是否是同一视觉行,只有这种画布关系可安全改为随标签移动。 */
|
||||
export const isOrderProfileAnchorRelativeCandidate = (
|
||||
valueRegion: OrderProfileRelativeRegion,
|
||||
anchorRegion: OrderProfileRelativeRegion,
|
||||
): boolean => {
|
||||
const anchorHeight = anchorRegion.y1 - anchorRegion.y0;
|
||||
const valueHeight = valueRegion.y1 - valueRegion.y0;
|
||||
if (anchorHeight <= 0 || valueHeight <= 0) return false;
|
||||
const tolerance = Math.max(anchorHeight, valueHeight) * 2;
|
||||
if (!(valueRegion.y0 <= anchorRegion.y1 + tolerance
|
||||
&& anchorRegion.y0 <= valueRegion.y1 + tolerance)) return false;
|
||||
const relative = toOrderProfileAnchorRelativeRegion(valueRegion, anchorRegion);
|
||||
// Backend intentionally bounds offsets to prevent a tiny auto-detected label
|
||||
// from producing an unbounded template rule. Fall back to the page box here.
|
||||
return relative !== null && [relative.x0, relative.y0, relative.x1, relative.y1]
|
||||
.every((value) => value >= -12 && value <= 12);
|
||||
};
|
||||
|
||||
/**
|
||||
* 判断是否显示普通表格预览;可直接创建 Profile 的表格不受上一张表多物理行状态影响。
|
||||
* @param profileCreationAllowed - 当前表格是否可直接创建 Profile
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-order-document-profiles/orderProfileReadonlyCanvas.utils.spec.ts
|
||||
* 用途:验证版本只读画布完整恢复模板定义中的诊断区域。
|
||||
* 依赖:Vitest、orderProfileReadonlyCanvas.utils。
|
||||
* 逻辑:已发布版本的必需锚点必须同时显示标签框和值框,且区域 ID 与冻结诊断接口一致。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingOrderDocumentProfile } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import { buildOrderProfileReadonlyRegions } from './orderProfileReadonlyCanvas.utils';
|
||||
|
||||
describe('buildOrderProfileReadonlyRegions', () => {
|
||||
it('restores required anchor label and value regions on the published canvas', () => {
|
||||
const profile = {
|
||||
definition: {
|
||||
document_match: {
|
||||
required_anchors: [{
|
||||
anchor_id: 'plant_address',
|
||||
label: 'PLANT ADDR:',
|
||||
value: 'No. 88',
|
||||
value_position: 'right',
|
||||
page_no: 1,
|
||||
label_region: { x0: .1, y0: .1, x1: .2, y1: .15 },
|
||||
value_region: { x0: .2, y0: .1, x1: .5, y1: .2 },
|
||||
minimum_evidence_level: 'coordinate',
|
||||
}],
|
||||
optional_anchors: [],
|
||||
},
|
||||
table_regions: [],
|
||||
order_field_layouts: [],
|
||||
draft_unbound_order_field_layouts: [],
|
||||
},
|
||||
} as unknown as ShippingOrderDocumentProfile;
|
||||
|
||||
const regions = buildOrderProfileReadonlyRegions(profile);
|
||||
|
||||
// 关键断言:版本画布与后端诊断接口使用同一 region ID,标签和值均不可丢失。
|
||||
expect(regions).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({ id: 'plant_address_label', kind: 'document_anchor_label', configuredValue: 'PLANT ADDR:' }),
|
||||
expect.objectContaining({ id: 'plant_address_value', kind: 'document_anchor_value', configuredValue: 'No. 88' }),
|
||||
]));
|
||||
});
|
||||
});
|
||||
+24
-18
@@ -61,9 +61,29 @@ export const buildOrderProfileReadonlyRegions = (
|
||||
profile: ShippingOrderDocumentProfile,
|
||||
): OrderProfileCanvasRegion[] => {
|
||||
const restored: OrderProfileCanvasRegion[] = [
|
||||
...(profile.definition.document_match.required_anchors || []).flatMap<OrderProfileCanvasRegion>((anchor) => {
|
||||
if (!anchor.label_region || !anchor.value_region || !anchor.page_no) return [];
|
||||
return [{
|
||||
id: `${anchor.anchor_id}_label`,
|
||||
kind: 'document_anchor_label',
|
||||
label: anchor.label,
|
||||
configuredValue: anchor.label,
|
||||
region: anchor.label_region,
|
||||
parentId: anchor.anchor_id,
|
||||
pageNo: anchor.page_no,
|
||||
}, {
|
||||
id: `${anchor.anchor_id}_value`,
|
||||
kind: 'document_anchor_value',
|
||||
label: anchor.value,
|
||||
configuredValue: anchor.value,
|
||||
region: anchor.value_region,
|
||||
parentId: anchor.anchor_id,
|
||||
pageNo: anchor.page_no,
|
||||
}];
|
||||
}),
|
||||
...(profile.definition.draft_unbound_order_field_layouts || []).flatMap<OrderProfileCanvasRegion>((item) => {
|
||||
const pageNo = pageNoOf(item.page_scope, item.page_no);
|
||||
if (!item.anchor?.region || !item.value_region) {
|
||||
if (!item.anchor?.region || !item.absolute_value_region) {
|
||||
return [{
|
||||
id: `unbound-${item.layout_id}`,
|
||||
kind: 'order_field',
|
||||
@@ -74,8 +94,6 @@ export const buildOrderProfileReadonlyRegions = (
|
||||
}];
|
||||
}
|
||||
const anchor = item.anchor.region;
|
||||
const width = anchor.x1 - anchor.x0;
|
||||
const height = anchor.y1 - anchor.y0;
|
||||
return [{
|
||||
id: `unbound-${item.anchor.anchor_id}`,
|
||||
kind: 'order_anchor',
|
||||
@@ -87,12 +105,7 @@ export const buildOrderProfileReadonlyRegions = (
|
||||
id: `unbound-${item.layout_id}`,
|
||||
kind: 'order_field',
|
||||
label: item.label,
|
||||
region: {
|
||||
x0: anchor.x0 + item.value_region.x0 * width,
|
||||
y0: anchor.y0 + item.value_region.y0 * height,
|
||||
x1: anchor.x0 + item.value_region.x1 * width,
|
||||
y1: anchor.y0 + item.value_region.y1 * height,
|
||||
},
|
||||
region: item.absolute_value_region,
|
||||
fieldCode: null,
|
||||
orderFieldId: item.layout_id,
|
||||
pageNo,
|
||||
@@ -107,10 +120,8 @@ export const buildOrderProfileReadonlyRegions = (
|
||||
pageNo: pageNoOf(item.page_scope, item.page_no),
|
||||
})),
|
||||
...(profile.definition.order_field_layouts || []).flatMap((item) => {
|
||||
if (!item.anchor?.region || !item.value_region) return [];
|
||||
if (!item.anchor?.region || !item.absolute_value_region) return [];
|
||||
const anchor = item.anchor.region;
|
||||
const width = anchor.x1 - anchor.x0;
|
||||
const height = anchor.y1 - anchor.y0;
|
||||
return [{
|
||||
id: item.anchor.anchor_id,
|
||||
kind: 'order_anchor' as const,
|
||||
@@ -122,12 +133,7 @@ export const buildOrderProfileReadonlyRegions = (
|
||||
id: item.layout_id,
|
||||
kind: 'order_field' as const,
|
||||
label: item.field_code,
|
||||
region: {
|
||||
x0: anchor.x0 + item.value_region.x0 * width,
|
||||
y0: anchor.y0 + item.value_region.y0 * height,
|
||||
x1: anchor.x0 + item.value_region.x1 * width,
|
||||
y1: anchor.y0 + item.value_region.y1 * height,
|
||||
},
|
||||
region: item.absolute_value_region,
|
||||
fieldCode: item.field_code,
|
||||
orderFieldId: item.layout_id,
|
||||
valueMode: item.value_mode,
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
export type OrderProfileExtractorKey = 'direct' | 'temp_internal_parts' | 'quantity_uom' | 'amount_currency' | 'price_currency';
|
||||
export type OrderProfileEvidenceLevel = 'coordinate' | 'ocr_coordinate';
|
||||
export type OrderProfileAllowedSource = 'pdf_coordinate' | 'ocr_coordinate';
|
||||
export type OrderProfileRowReconstructionMode = 'fixed_subrows' | 'adaptive_record_columns';
|
||||
export type OrderProfileChangeSource = 'wizard_created' | 'manual_save' | 'autosave' | 'restore' | 'sample_changed';
|
||||
export type OrderProfileLeaseState = 'active' | 'expired' | 'released' | 'taken_over';
|
||||
export type OrderProfileValidationRunType = 'instant_check' | 'current_sample' | 'blind_test' | 'scenario_coverage' | 'schema_compatibility';
|
||||
@@ -25,7 +26,6 @@ export type OrderProfileGovernanceErrorCode =
|
||||
| 'SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_CONSUMED';
|
||||
|
||||
export interface OrderProfileRelativeRegion { x0: number; y0: number; x1: number; y1: number; }
|
||||
export interface OrderProfileAnchorRelativeRegion { x0: number; y0: number; x1: number; y1: number; }
|
||||
export interface OrderProfileDocumentMatchAnchor { anchor_id: string; label: string; value: string; value_position: 'right' | 'below'; page_no?: number | null; label_region?: OrderProfileRelativeRegion | null; value_region?: OrderProfileRelativeRegion | null; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileAnchorRule { anchor_id: string; text: string; aliases?: string[]; match_mode: 'exact' | 'contains'; region?: OrderProfileRelativeRegion | null; position_locked?: boolean; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileFieldRegion { field_id: string; field_code: string; scope: 'header' | 'line'; region: OrderProfileRelativeRegion; extractor_key: OrderProfileExtractorKey; allowed_sources: OrderProfileAllowedSource[]; minimum_evidence_level: OrderProfileEvidenceLevel; target_fields?: Array<{ field_id: string; field_code: string; scope: 'header' | 'line' }>; }
|
||||
@@ -33,7 +33,7 @@ export interface OrderProfileOrderFieldLayout { layout_id: string; field_id: str
|
||||
export interface OrderProfileDraftUnboundOrderFieldLayout { layout_id: string; label: string; page_scope: 'first_page' | 'all_pages' | 'exact_page'; page_no?: number | null; anchor?: OrderProfileAnchorRule | null; value_region?: OrderProfileAnchorRelativeRegion | null; absolute_value_region?: OrderProfileRelativeRegion | null; fallback_value_region?: OrderProfileRelativeRegion | null; value_mode: 'single_line' | 'multi_line' | 'right_of_anchor' | 'below_anchor'; stop_anchors: OrderProfileAnchorRule[]; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileHeaderLayout { layout_id: string; region: OrderProfileRelativeRegion; field_regions: OrderProfileFieldRegion[]; }
|
||||
export interface OrderProfileLineLayout { layout_id: string; row_offset: number; role: 'main' | 'continuation'; region: OrderProfileRelativeRegion; field_regions: OrderProfileFieldRegion[]; new_line_anchor?: OrderProfileAnchorRule | null; continuation_conditions: OrderProfileAnchorRule[]; required_fields: string[]; allowed_empty_fields: string[]; }
|
||||
export interface OrderProfileTableRegion { region_id: string; page_scope: 'first_page' | 'all_pages' | 'continuation_pages' | 'exact_page'; page_no?: number | null; region: OrderProfileRelativeRegion; /** 逻辑明细起行锚点;默认 customer_po_line_no;line_no 为可识别内部项次亦可绑定。 */ line_start_field_code?: string; header_layouts: OrderProfileHeaderLayout[]; line_layouts: OrderProfileLineLayout[]; continuation_rule: { allow_cross_page: boolean; required_anchor_ids: string[] }; termination_rules: Array<{ rule_id: string; anchor: OrderProfileAnchorRule }>; exclusion_regions: OrderProfileRelativeRegion[]; draft_unbound_field_regions?: Array<{ region_id: string; parent_layout_id: string; label: string; region: OrderProfileRelativeRegion }>; }
|
||||
export interface OrderProfileTableRegion { region_id: string; page_scope: 'first_page' | 'all_pages' | 'continuation_pages' | 'exact_page'; page_no?: number | null; region: OrderProfileRelativeRegion; /** 逻辑明细起行锚点;默认 customer_po_line_no;line_no 为可识别内部项次亦可绑定。 */ line_start_field_code?: string; /** 默认固定子行;仅显式启用时允许在同一逻辑明细内跨视觉行按列重建。 */ row_reconstruction_mode?: OrderProfileRowReconstructionMode; header_layouts: OrderProfileHeaderLayout[]; line_layouts: OrderProfileLineLayout[]; continuation_rule: { allow_cross_page: boolean; required_anchor_ids: string[] }; termination_rules: Array<{ rule_id: string; anchor: OrderProfileAnchorRule }>; exclusion_regions: OrderProfileRelativeRegion[]; draft_unbound_field_regions?: Array<{ region_id: string; parent_layout_id: string; label: string; region: OrderProfileRelativeRegion }>; }
|
||||
export interface OrderProfileDocumentMatch { document_type: 'purchase_order'; page_pattern: 'one_or_more'; required_anchors: OrderProfileDocumentMatchAnchor[]; optional_anchors: OrderProfileDocumentMatchAnchor[]; minimum_score: number; minimum_margin: number; }
|
||||
|
||||
/** 阶段 3 重构前仅用于让旧工作台编译;不能作为 v2 API 请求或持久化定义。 */
|
||||
@@ -369,6 +369,15 @@ export interface OrderProfileBoundSample {
|
||||
evidence_frozen_at?: string | null;
|
||||
}
|
||||
export interface OrderProfilePreviewPages { sample_binding_id?: number; document_id: number; page_count: number; pages: OrderProfilePreviewPageGrant[]; expires_in_seconds: number; }
|
||||
export interface OrderProfileRegionDiagnostic {
|
||||
region_id: string;
|
||||
kind: OrderProfileCanvasRegion['kind'];
|
||||
label: string;
|
||||
recognized_value: string;
|
||||
configured_value?: string | null;
|
||||
matches_configured?: boolean | null;
|
||||
}
|
||||
export interface OrderProfileRegionDiagnosticsResponse { sample_binding_id: number; page_no: number; items: OrderProfileRegionDiagnostic[]; }
|
||||
export interface OrderProfilePageTextCandidates { document_id: number; page_no: number; tables: Array<{ table_id: string; row_count: number; column_count: number; rows: string[][] }>; status: 'needs_review'; }
|
||||
/** 发布门禁的脱敏盲测摘要;真值只在管理员添加样本时提交。 */
|
||||
export interface OrderProfileTestSuite {
|
||||
@@ -424,6 +433,12 @@ export interface OrderProfileCanvasRegion {
|
||||
valueMode?: 'single_line' | 'multi_line' | 'right_of_anchor' | 'below_anchor';
|
||||
/** 自动标记时从同一值框读取的待复核文本,仅用于工作台即时展示。 */
|
||||
suggestedValue?: string | null;
|
||||
/** 版本只读画布从冻结样本读取的实际识别值,仅用于诊断展示。 */
|
||||
recognizedValue?: string | null;
|
||||
/** 必需锚点保存的固定值,用于与冻结样本实际识别值对照。 */
|
||||
configuredValue?: string | null;
|
||||
/** 必需锚点固定值是否命中;普通字段没有配置值时为 null。 */
|
||||
matchesConfigured?: boolean | null;
|
||||
/** 自动建议实际使用的坐标证据来源,保存时映射到最小证据等级。 */
|
||||
evidenceSource?: 'pdf_coordinate' | 'ocr_coordinate';
|
||||
stopAnchorText?: string | null;
|
||||
@@ -553,9 +568,12 @@ export interface OrderFieldValuePreview {
|
||||
value: string | null;
|
||||
status: 'confirmed' | 'needs_review' | 'unavailable';
|
||||
page_no: number | null;
|
||||
issues: string[];
|
||||
}
|
||||
|
||||
export interface OrderFieldValuePreviewResponse {
|
||||
page_no: number;
|
||||
page_nos?: number[];
|
||||
fields: OrderFieldValuePreview[];
|
||||
}
|
||||
export interface OrderProfileAnchorRelativeRegion { x0: number; y0: number; x1: number; y1: number; }
|
||||
@@ -33,6 +33,10 @@ import type {
|
||||
ShippingOrderReviewDraftWrite,
|
||||
ShippingOrderReviewEvidence,
|
||||
ShippingOrderReviewInventoryCandidatesWrite,
|
||||
ShippingOrderReviewLlmAdjudicationPayload,
|
||||
ShippingOrderReviewLlmSuggestion,
|
||||
ShippingOrderReviewLlmSuggestionRequest,
|
||||
ShippingOrderReviewLlmSuggestionResponse,
|
||||
ShippingOrderReviewReparseResponse,
|
||||
ShippingOrderReviewRun,
|
||||
ShippingWorkflow,
|
||||
@@ -364,6 +368,33 @@ export const getWorkspaceShippingOrderReviewEvidence = (caseNo: string) =>
|
||||
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/evidence`,
|
||||
);
|
||||
|
||||
/** 列出 Case 下 LLM 证据建议记录。 */
|
||||
export const listWorkspaceShippingOrderReviewLlmSuggestions = (caseNo: string) =>
|
||||
requestJson<{ case_no: string; llm_review_enabled: boolean; items: ShippingOrderReviewLlmSuggestion[] }>(
|
||||
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/llm-suggestions`,
|
||||
);
|
||||
|
||||
/** 为指定字段请求 Dify 最小证据建议。 */
|
||||
export const requestWorkspaceShippingOrderReviewLlmSuggestion = (
|
||||
caseNo: string,
|
||||
body: ShippingOrderReviewLlmSuggestionRequest & { expected_draft_version?: number },
|
||||
) =>
|
||||
requestJson<ShippingOrderReviewLlmSuggestionResponse>(
|
||||
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/llm-suggestions`,
|
||||
jsonPost(body),
|
||||
);
|
||||
|
||||
/** 人工裁决 LLM 建议。 */
|
||||
export const adjudicateWorkspaceShippingOrderReviewLlmSuggestion = (
|
||||
caseNo: string,
|
||||
suggestionNo: string,
|
||||
body: ShippingOrderReviewLlmAdjudicationPayload,
|
||||
) =>
|
||||
requestJson<ShippingOrderReviewLlmSuggestionResponse>(
|
||||
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/llm-suggestions/${encodeURIComponent(suggestionNo)}/adjudicate`,
|
||||
jsonPost(body),
|
||||
);
|
||||
|
||||
/** 以认证请求取得 PDF Blob,避免 iframe 无法携带 JWT 而退化为公开预览 URL。 */
|
||||
export async function getWorkspaceShippingOrderReviewPreview(caseNo: string): Promise<Blob> {
|
||||
const response = await fetch(
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewLlmEvidenceComparison.vue
|
||||
用途:三列对比当前草稿、AI 建议与原文证据。
|
||||
依赖:vue-i18n、ShippingOrderReviewEvidence / LlmSuggestion 类型。
|
||||
逻辑:嵌入 ReviewLlmSuggestionDialog;逐字失败码与后端 value_not_in_evidence 对齐;只读展示。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderReviewEvidence, ShippingOrderReviewLlmSuggestion } from '../../types/shipping.api.types';
|
||||
|
||||
/** 三列对比入参;建议/证据可空,标签缺省为空串。 */
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
draftValue?: unknown;
|
||||
suggestion?: ShippingOrderReviewLlmSuggestion | null;
|
||||
evidence?: ShippingOrderReviewEvidence | null;
|
||||
fieldLabel?: string;
|
||||
}>(),
|
||||
{
|
||||
fieldLabel: '',
|
||||
},
|
||||
);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const suggestedValue = computed(() => props.suggestion?.suggested_value ?? '-');
|
||||
const draftDisplay = computed(() => {
|
||||
const value = props.draftValue;
|
||||
if (value === null || value === undefined || value === '') return '-';
|
||||
return String(value);
|
||||
});
|
||||
const evidenceQuote = computed(() => props.evidence?.quote || '-');
|
||||
const evidenceLocation = computed(() => {
|
||||
const page = props.evidence?.page_no;
|
||||
const cell = props.evidence?.cell_id;
|
||||
if (page && cell) return t('chat.shippingOrderReview.llmSuggestion.evidenceAtCell', { page, cell });
|
||||
if (page) return t('chat.shippingOrderReview.evidenceAt', { page });
|
||||
return t('chat.shippingOrderReview.llmSuggestion.noEvidenceCoords');
|
||||
});
|
||||
/** 与后端 rejection_reason 对齐;含历史别名 suggested_value_not_in_evidence。 */
|
||||
const VERBATIM_FAIL_CODES = new Set([
|
||||
'value_not_in_evidence',
|
||||
'suggested_value_not_in_evidence',
|
||||
'empty_suggestion',
|
||||
'field_id_mismatch',
|
||||
]);
|
||||
const verbatimOk = computed(() => {
|
||||
if (String(props.suggestion?.status || '') === 'validation_failed') return false;
|
||||
const issues = props.suggestion?.validation_issues || [];
|
||||
return !issues.some((item) => VERBATIM_FAIL_CODES.has(String(item.code || '')));
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid gap-3 md:grid-cols-3" data-testid="review-llm-evidence-comparison">
|
||||
<div class="rounded-lg border border-slate-200 bg-slate-50 p-3">
|
||||
<p class="text-xs font-medium uppercase tracking-wide text-slate-500">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.currentDraft') }}
|
||||
</p>
|
||||
<p class="mt-2 text-sm font-semibold text-slate-900">{{ props.fieldLabel }}</p>
|
||||
<p class="mt-1 text-sm text-slate-700">{{ draftDisplay }}</p>
|
||||
</div>
|
||||
<div class="rounded-lg border border-indigo-200 bg-indigo-50/60 p-3">
|
||||
<p class="text-xs font-medium uppercase tracking-wide text-indigo-600">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.aiSuggestion') }}
|
||||
</p>
|
||||
<p class="mt-2 text-sm font-semibold text-slate-900">{{ suggestedValue }}</p>
|
||||
<p class="mt-1 text-xs" :class="verbatimOk ? 'text-emerald-700' : 'text-amber-700'">
|
||||
{{
|
||||
verbatimOk
|
||||
? t('chat.shippingOrderReview.llmSuggestion.verbatimOk')
|
||||
: t('chat.shippingOrderReview.llmSuggestion.verbatimFailed')
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-lg border border-slate-200 bg-white p-3">
|
||||
<p class="text-xs font-medium uppercase tracking-wide text-slate-500">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.sourceEvidence') }}
|
||||
</p>
|
||||
<p class="mt-2 text-sm text-slate-800">{{ evidenceQuote }}</p>
|
||||
<p class="mt-1 text-xs text-slate-500">{{ evidenceLocation }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,233 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewLlmSuggestionDialog.vue
|
||||
用途:复核工作台内 AI 建议对比与裁决对话框。
|
||||
依赖:vue-i18n、ReviewLlmEvidenceComparison、ShippingOrderReview* 类型。
|
||||
逻辑:接受可备注;修改/拒绝必须填写原因;validation_failed 仅允许拒绝;
|
||||
含 dialog 语义、Escape、焦点陷阱与恢复。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type {
|
||||
ShippingOrderReviewEvidence,
|
||||
ShippingOrderReviewLlmSuggestion,
|
||||
} from '../../types/shipping.api.types';
|
||||
import ReviewLlmEvidenceComparison from './ReviewLlmEvidenceComparison.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
suggestion?: ShippingOrderReviewLlmSuggestion | null;
|
||||
evidence?: ShippingOrderReviewEvidence | null;
|
||||
draftValue?: unknown;
|
||||
/** Schema 字段展示名;缺省回退 field_id。 */
|
||||
fieldLabel?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
decide: [payload: { decision: 'accept' | 'modify' | 'reject'; reason: string; value?: unknown }];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const decision = ref<'accept' | 'modify' | 'reject'>('accept');
|
||||
const reason = ref('');
|
||||
const modifiedValue = ref('');
|
||||
const panelRef = ref<HTMLElement | null>(null);
|
||||
const previousFocus = ref<HTMLElement | null>(null);
|
||||
|
||||
/** 逐字验证失败时仅允许拒绝,禁止 accept/modify。 */
|
||||
const rejectOnly = computed(() => String(props.suggestion?.status || '') === 'validation_failed');
|
||||
|
||||
const displayFieldLabel = computed(() =>
|
||||
String(props.fieldLabel || props.suggestion?.field_id || '').trim(),
|
||||
);
|
||||
|
||||
const evidenceLevelText = computed(() => {
|
||||
const code = String(props.suggestion?.evidence_level || 'L1_field').trim() || 'L1_field';
|
||||
const key = `chat.shippingOrderReview.llmSuggestion.evidenceLevel.${code}`;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.llmSuggestion.scope', { level: code });
|
||||
});
|
||||
|
||||
const canSubmit = computed(() => {
|
||||
if (decision.value === 'accept') return !rejectOnly.value;
|
||||
return Boolean(reason.value.trim());
|
||||
});
|
||||
|
||||
/**
|
||||
* 提交裁决;修改/拒绝无原因时按钮禁用。
|
||||
*/
|
||||
function submit() {
|
||||
if (!canSubmit.value) return;
|
||||
emit('decide', {
|
||||
decision: decision.value,
|
||||
reason: reason.value.trim(),
|
||||
value: decision.value === 'modify' ? modifiedValue.value : undefined,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭弹窗并通知父级。
|
||||
*/
|
||||
function close() {
|
||||
emit('close');
|
||||
}
|
||||
|
||||
/**
|
||||
* 收集面板内可聚焦控件,供焦点陷阱使用。
|
||||
*/
|
||||
function focusableElements(): HTMLElement[] {
|
||||
const root = panelRef.value;
|
||||
if (!root) return [];
|
||||
return Array.from(
|
||||
root.querySelectorAll<HTMLElement>(
|
||||
'button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',
|
||||
),
|
||||
).filter((el) => !el.hasAttribute('disabled') && el.tabIndex !== -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开时聚焦首个可交互控件;关闭时恢复触发焦点。
|
||||
*/
|
||||
async function restoreOrCaptureFocus(open: boolean) {
|
||||
if (typeof document === 'undefined') return;
|
||||
if (open) {
|
||||
previousFocus.value = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
await nextTick();
|
||||
const first = focusableElements()[0];
|
||||
first?.focus();
|
||||
return;
|
||||
}
|
||||
previousFocus.value?.focus?.();
|
||||
previousFocus.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape 关闭;Tab 在对话框内循环,防止焦点落到遮罩后的复核页。
|
||||
*/
|
||||
function onKeydown(event: KeyboardEvent) {
|
||||
if (!props.open) return;
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'Tab') return;
|
||||
const nodes = focusableElements();
|
||||
const first = nodes[0];
|
||||
const last = nodes[nodes.length - 1];
|
||||
// [STEP] noUncheckedIndexedAccess:空数组或越界时 first/last 为 undefined,禁止直接 .focus()。
|
||||
if (!first || !last) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
const active = document.activeElement as HTMLElement | null;
|
||||
if (event.shiftKey && active === first) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
} else if (!event.shiftKey && active === last) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
(open) => {
|
||||
if (open) {
|
||||
decision.value = rejectOnly.value ? 'reject' : 'accept';
|
||||
reason.value = '';
|
||||
modifiedValue.value = String(props.suggestion?.suggested_value ?? '');
|
||||
}
|
||||
void restoreOrCaptureFocus(open);
|
||||
if (typeof document === 'undefined') return;
|
||||
if (open) document.addEventListener('keydown', onKeydown);
|
||||
else document.removeEventListener('keydown', onKeydown);
|
||||
},
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (typeof document !== 'undefined') document.removeEventListener('keydown', onKeydown);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="t('chat.shippingOrderReview.llmSuggestion.dialogTitle')"
|
||||
data-testid="review-llm-suggestion-dialog"
|
||||
@click.self="close"
|
||||
>
|
||||
<div
|
||||
ref="panelRef"
|
||||
class="max-h-[80vh] w-full max-w-3xl overflow-auto rounded-lg bg-white p-4 shadow-lg dark:bg-slate-900"
|
||||
data-testid="review-llm-suggestion-panel"
|
||||
>
|
||||
<h3 class="text-base font-semibold">{{ t('chat.shippingOrderReview.llmSuggestion.dialogTitle') }}</h3>
|
||||
<p class="mt-1 text-xs text-slate-500">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.dialogHint') }}
|
||||
· {{ evidenceLevelText }}
|
||||
</p>
|
||||
|
||||
<div class="mt-4">
|
||||
<ReviewLlmEvidenceComparison
|
||||
:draft-value="draftValue"
|
||||
:suggestion="suggestion"
|
||||
:evidence="evidence"
|
||||
:field-label="displayFieldLabel"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-wrap gap-4 text-sm">
|
||||
<label v-if="!rejectOnly" class="inline-flex items-center gap-1">
|
||||
<input v-model="decision" type="radio" value="accept" />
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.decisions.accept') }}
|
||||
</label>
|
||||
<label v-if="!rejectOnly" class="inline-flex items-center gap-1">
|
||||
<input v-model="decision" type="radio" value="modify" />
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.decisions.modify') }}
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-1">
|
||||
<input v-model="decision" type="radio" value="reject" />
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.decisions.reject') }}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<input
|
||||
v-if="decision === 'modify'"
|
||||
v-model="modifiedValue"
|
||||
class="mt-2 w-full rounded border p-2 text-sm dark:border-slate-700 dark:bg-slate-950"
|
||||
:placeholder="t('chat.shippingOrderReview.llmSuggestion.modifiedValue')"
|
||||
/>
|
||||
<textarea
|
||||
v-model="reason"
|
||||
class="mt-2 w-full rounded border p-2 text-sm dark:border-slate-700 dark:bg-slate-950"
|
||||
rows="2"
|
||||
:placeholder="
|
||||
decision === 'accept'
|
||||
? t('chat.shippingOrderReview.llmSuggestion.noteOptional')
|
||||
: t('chat.shippingOrderReview.llmSuggestion.reasonRequired')
|
||||
"
|
||||
/>
|
||||
|
||||
<div class="mt-3 flex justify-end gap-2">
|
||||
<button type="button" class="rounded border px-3 py-1 text-sm" @click="close">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border px-3 py-1 text-sm disabled:opacity-50"
|
||||
:disabled="!canSubmit"
|
||||
data-testid="review-llm-submit-decision"
|
||||
@click="submit"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.submit') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewLlmSuggestionPanel.spec.ts
|
||||
* 用途:锁定 LLM 建议面板的草稿对比与裁决弹窗契约。
|
||||
* 依赖:vitest、@vue/test-utils、vue-i18n。
|
||||
* 逻辑:按建议字段解析 header 草稿值;弹窗含 dialog 语义;修改/拒绝无原因不可提交。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import ReviewLlmSuggestionPanel from './ReviewLlmSuggestionPanel.vue';
|
||||
import type {
|
||||
ShippingOrderReviewCase,
|
||||
ShippingOrderReviewLlmSuggestion,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const messages = {
|
||||
en: {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
llmSuggestion: {
|
||||
panelTitle: 'AI suggestion',
|
||||
panelHint: 'Minimal evidence only',
|
||||
request: 'Request',
|
||||
requesting: 'Requesting',
|
||||
review: 'Review',
|
||||
empty: 'No suggestions',
|
||||
scope: 'Scope {level}',
|
||||
dialogTitle: 'AI suggestion dialog',
|
||||
dialogHint: 'Compare draft and evidence',
|
||||
currentDraft: 'Current draft',
|
||||
aiSuggestion: 'AI suggestion',
|
||||
sourceEvidence: 'Evidence',
|
||||
verbatimOk: 'OK',
|
||||
verbatimFailed: 'Failed',
|
||||
evidenceAtCell: 'page {page} {cell}',
|
||||
noEvidenceCoords: 'no coords',
|
||||
cancel: 'Cancel',
|
||||
submit: 'Submit',
|
||||
modifiedValue: 'Modified',
|
||||
noteOptional: 'Note',
|
||||
reasonRequired: 'Reason required',
|
||||
status: { idle: 'Idle', pending: 'Pending', validated: 'Validated' },
|
||||
decisions: { accept: 'Accept', modify: 'Modify', reject: 'Reject' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 构造最小 Case + 建议夹具。
|
||||
*/
|
||||
function fixtures() {
|
||||
const suggestion: ShippingOrderReviewLlmSuggestion = {
|
||||
suggestion_no: 'RSG-TEST001',
|
||||
field_id: 'fld-po',
|
||||
scope: 'header',
|
||||
evidence_level: 'L1_field',
|
||||
status: 'validated',
|
||||
suggested_value: 'PO-NEW',
|
||||
validation_issues: [],
|
||||
};
|
||||
const activeCase = {
|
||||
case_no: 'SRC-1',
|
||||
draft: {
|
||||
draft_version: 3,
|
||||
header_values: {
|
||||
values: { 'fld-po': { value: 'PO-OLD', source: 'manual' } },
|
||||
machine_fields: [{ field_id: 'fld-po', value: 'PO-MACHINE' }],
|
||||
},
|
||||
lines: [],
|
||||
},
|
||||
} as unknown as ShippingOrderReviewCase;
|
||||
return { suggestion, activeCase };
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂载建议面板。
|
||||
*/
|
||||
function mountPanel(overrides?: {
|
||||
suggestions?: ShippingOrderReviewLlmSuggestion[];
|
||||
editable?: boolean;
|
||||
focusedFieldId?: string;
|
||||
}) {
|
||||
const { suggestion, activeCase } = fixtures();
|
||||
const i18n = createI18n({ legacy: false, locale: 'en', messages });
|
||||
return mount(ReviewLlmSuggestionPanel, {
|
||||
props: {
|
||||
activeCase,
|
||||
evidence: [{ evidence_id: 'e1', field_id: 'fld-po', quote: 'PO-NEW', page_no: 1, source: 'layout' }],
|
||||
editable: overrides?.editable ?? true,
|
||||
saving: false,
|
||||
suggestions: overrides?.suggestions ?? [suggestion],
|
||||
suggestionLoading: false,
|
||||
focusedFieldId: overrides?.focusedFieldId ?? 'fld-po',
|
||||
focusedLineKey: null,
|
||||
draftValue: null,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
attachTo: document.body,
|
||||
});
|
||||
}
|
||||
|
||||
describe('ReviewLlmSuggestionPanel', () => {
|
||||
it('opens dialog with current draft value for three-way compare', async () => {
|
||||
const wrapper = mountPanel();
|
||||
await wrapper.get('ul button').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
const dialog = document.querySelector('[data-testid="review-llm-suggestion-dialog"]');
|
||||
expect(dialog).not.toBeNull();
|
||||
expect(dialog?.getAttribute('role')).toBe('dialog');
|
||||
expect(dialog?.getAttribute('aria-modal')).toBe('true');
|
||||
expect(document.body.textContent).toContain('PO-OLD');
|
||||
expect(document.body.textContent).toContain('PO-NEW');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('blocks submit for reject without reason and closes on Escape', async () => {
|
||||
const wrapper = mountPanel();
|
||||
await wrapper.get('ul button').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
const radios = Array.from(document.querySelectorAll<HTMLInputElement>('input[type="radio"]'));
|
||||
const reject = radios.find((el) => el.value === 'reject');
|
||||
expect(reject).toBeTruthy();
|
||||
reject!.checked = true;
|
||||
reject!.dispatchEvent(new Event('change'));
|
||||
await flushPromises();
|
||||
|
||||
const submit = document.querySelector<HTMLButtonElement>('[data-testid="review-llm-submit-decision"]');
|
||||
expect(submit?.disabled).toBe(true);
|
||||
|
||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
|
||||
await flushPromises();
|
||||
expect(document.querySelector('[data-testid="review-llm-suggestion-dialog"]')).toBeNull();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('keeps validation_failed suggestions out of accept list and reject-only in dialog', async () => {
|
||||
const failed: ShippingOrderReviewLlmSuggestion = {
|
||||
suggestion_no: 'RSG-FAIL',
|
||||
field_id: 'fld-po',
|
||||
scope: 'header',
|
||||
evidence_level: 'L1_field',
|
||||
status: 'validation_failed',
|
||||
suggested_value: 'PO-BAD',
|
||||
validation_issues: [{ code: 'value_not_in_evidence', severity: 'blocking' }],
|
||||
};
|
||||
const wrapper = mountPanel({ suggestions: [failed] });
|
||||
expect(wrapper.find('ul:not([data-testid="review-llm-failed-list"])').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-llm-failed-list"]').exists()).toBe(true);
|
||||
|
||||
await wrapper.get('[data-testid="review-llm-open-failed"]').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
const radios = Array.from(document.querySelectorAll<HTMLInputElement>('input[type="radio"]'));
|
||||
expect(radios.map((el) => el.value)).toEqual(['reject']);
|
||||
expect(document.body.textContent).toContain('Failed');
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,251 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewLlmSuggestionPanel.vue
|
||||
用途:复核工作台内嵌 AI 建议入口、列表与裁决触发(非顶级导航)。
|
||||
依赖:vue-i18n、ReviewLlmSuggestionDialog、ShippingOrderReview* 类型。
|
||||
逻辑:请求/裁决由父级 composable 执行;仅 validated 可接受;validation_failed 单独列表仅可拒绝;
|
||||
证据按 field_id + line_key/line_index 绑定;打开弹窗时按建议字段解析当前草稿值。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type {
|
||||
ShippingOrderReviewCase,
|
||||
ShippingOrderReviewEvidence,
|
||||
ShippingOrderReviewLlmAdjudicationPayload,
|
||||
ShippingOrderReviewLlmSuggestion,
|
||||
} from '../../types/shipping.api.types';
|
||||
import ReviewLlmSuggestionDialog from './ReviewLlmSuggestionDialog.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
activeCase?: ShippingOrderReviewCase | null;
|
||||
evidence?: ShippingOrderReviewEvidence[] | null;
|
||||
editable?: boolean;
|
||||
saving?: boolean;
|
||||
suggestions?: ShippingOrderReviewLlmSuggestion[];
|
||||
suggestionLoading?: boolean;
|
||||
focusedFieldId?: string | null;
|
||||
focusedLineKey?: string | null;
|
||||
/** 父级传入的聚焦字段草稿;弹窗优先用建议字段自身解析值。 */
|
||||
draftValue?: unknown;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
requestSuggestion: [];
|
||||
adjudicate: [payload: {
|
||||
suggestion: ShippingOrderReviewLlmSuggestion;
|
||||
body: ShippingOrderReviewLlmAdjudicationPayload;
|
||||
}];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const dialogOpen = ref(false);
|
||||
const selected = ref<ShippingOrderReviewLlmSuggestion | null>(null);
|
||||
|
||||
/** 仅已通过逐字校验的建议可进入 accept/modify 待裁决列表。 */
|
||||
const pendingSuggestions = computed(() =>
|
||||
(props.suggestions || []).filter((item) => String(item.status || '') === 'validated' && !item.decision),
|
||||
);
|
||||
|
||||
/** 验证失败建议仅可查看/拒绝,不进入可接受列表。 */
|
||||
const failedSuggestions = computed(() =>
|
||||
(props.suggestions || []).filter((item) => String(item.status || '') === 'validation_failed' && !item.decision),
|
||||
);
|
||||
|
||||
const statusLabel = computed(() => {
|
||||
if (props.suggestionLoading) return t('chat.shippingOrderReview.llmSuggestion.status.pending');
|
||||
const latest = (props.suggestions || [])[0];
|
||||
const code = String(latest?.status || latest?.decision || 'idle');
|
||||
const key = `chat.shippingOrderReview.llmSuggestion.status.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
});
|
||||
|
||||
const canRequest = computed(() =>
|
||||
Boolean(props.editable && props.activeCase && props.focusedFieldId && !props.suggestionLoading && !props.saving),
|
||||
);
|
||||
|
||||
/**
|
||||
* 证据须同时匹配 field_id 与明细行(machine-N → line_index)。
|
||||
*/
|
||||
function evidenceMatchesFieldLine(
|
||||
item: ShippingOrderReviewEvidence,
|
||||
fieldId: string,
|
||||
lineKey: string | null | undefined,
|
||||
): boolean {
|
||||
if (String(item.field_id || '') !== fieldId) return false;
|
||||
const key = String(lineKey || '').trim();
|
||||
if (!key) {
|
||||
return item.line_index == null || item.line_index === undefined;
|
||||
}
|
||||
const matched = /^machine-(\d+)$/i.exec(key);
|
||||
if (matched) {
|
||||
const idx = Number(matched[1]) - 1;
|
||||
return Number(item.line_index) === idx;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const selectedEvidence = computed(() => {
|
||||
const items = props.evidence || [];
|
||||
const fieldId = String(selected.value?.field_id || props.focusedFieldId || '');
|
||||
const lineKey = selected.value?.line_key ?? props.focusedLineKey;
|
||||
return items.find((item) => evidenceMatchesFieldLine(item, fieldId, lineKey)) || null;
|
||||
});
|
||||
|
||||
/**
|
||||
* 从草稿容器读取字段当前值(人工值优先,否则机器投影)。
|
||||
*/
|
||||
function readContainerDraftValue(container: Record<string, unknown> | null | undefined, fieldId: string): unknown {
|
||||
if (!container || !fieldId) return null;
|
||||
const values = container.values as Record<string, { value?: unknown }> | undefined;
|
||||
if (values?.[fieldId] && 'value' in values[fieldId]) return values[fieldId].value ?? null;
|
||||
const machine = Array.isArray(container.machine_fields)
|
||||
? (container.machine_fields as Array<Record<string, unknown>>)
|
||||
: [];
|
||||
const hit = machine.find((item) => String(item.field_id || '') === fieldId);
|
||||
return hit?.value ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按建议(或聚焦字段)解析当前草稿值,供三方对比。
|
||||
*/
|
||||
const dialogDraftValue = computed(() => {
|
||||
const fieldId = String(selected.value?.field_id || props.focusedFieldId || '');
|
||||
const lineKey = selected.value?.line_key ?? props.focusedLineKey;
|
||||
const draft = props.activeCase?.draft;
|
||||
if (!draft || !fieldId) return props.draftValue ?? null;
|
||||
if (lineKey) {
|
||||
const lines = Array.isArray(draft.lines) ? draft.lines : [];
|
||||
const line = lines.find((item) => String((item as { line_key?: string }).line_key || '') === String(lineKey));
|
||||
return readContainerDraftValue(line as Record<string, unknown> | undefined, fieldId);
|
||||
}
|
||||
return readContainerDraftValue(draft.header_values as Record<string, unknown> | undefined, fieldId);
|
||||
});
|
||||
|
||||
/**
|
||||
* 打开指定建议的对比裁决对话框。
|
||||
*/
|
||||
function openSuggestion(item: ShippingOrderReviewLlmSuggestion) {
|
||||
selected.value = item;
|
||||
dialogOpen.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将建议字段解析为 Schema 展示名;缺失时回退 field_id。
|
||||
*/
|
||||
function suggestionFieldLabel(item: ShippingOrderReviewLlmSuggestion): string {
|
||||
const fieldId = String(item.field_id || '').trim();
|
||||
const fields = props.activeCase?.schema?.fields || [];
|
||||
const hit = fields.find((field) => String(field.field_id || '') === fieldId);
|
||||
const name = String(hit?.display_name || hit?.field_code || '').trim();
|
||||
if (name && item.line_key) {
|
||||
return `${name} · ${item.line_key}`;
|
||||
}
|
||||
return name || fieldId || '—';
|
||||
}
|
||||
|
||||
/**
|
||||
* 将证据等级转为业务文案,避免直接展示 L1_field。
|
||||
*/
|
||||
function evidenceLevelLabel(level?: string | null): string {
|
||||
const code = String(level || 'L1_field').trim() || 'L1_field';
|
||||
const key = `chat.shippingOrderReview.llmSuggestion.evidenceLevel.${code}`;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.llmSuggestion.scope', { level: code });
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对话框裁决转发给父级。
|
||||
*/
|
||||
function onDecide(payload: { decision: 'accept' | 'modify' | 'reject'; reason: string; value?: unknown }) {
|
||||
if (!selected.value) return;
|
||||
emit('adjudicate', {
|
||||
suggestion: selected.value,
|
||||
body: {
|
||||
decision: payload.decision,
|
||||
reason: payload.reason || undefined,
|
||||
value: payload.value,
|
||||
expected_draft_version: props.activeCase?.draft?.draft_version,
|
||||
},
|
||||
});
|
||||
dialogOpen.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="rounded-xl border border-slate-200 bg-white p-3 text-sm shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<div>
|
||||
<div class="font-semibold">{{ t('chat.shippingOrderReview.llmSuggestion.panelTitle') }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.panelHint') }}
|
||||
· {{ evidenceLevelLabel(selected?.evidence_level || 'L1_field') }}
|
||||
· {{ statusLabel }}
|
||||
<span v-if="suggestions?.length">· {{ suggestions.length }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border px-2 py-1 text-xs disabled:opacity-50"
|
||||
:disabled="!canRequest"
|
||||
data-testid="review-llm-request"
|
||||
@click="emit('requestSuggestion')"
|
||||
>
|
||||
{{
|
||||
suggestionLoading
|
||||
? t('chat.shippingOrderReview.llmSuggestion.requesting')
|
||||
: t('chat.shippingOrderReview.llmSuggestion.request')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p v-if="!pendingSuggestions.length && !failedSuggestions.length" class="mt-3 text-xs text-slate-500">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.empty') }}
|
||||
</p>
|
||||
<ul v-if="pendingSuggestions.length" class="mt-3 space-y-2">
|
||||
<li
|
||||
v-for="item in pendingSuggestions"
|
||||
:key="item.suggestion_no"
|
||||
class="flex items-center justify-between gap-2 rounded border border-slate-200 px-2 py-1.5 dark:border-slate-700"
|
||||
>
|
||||
<div class="min-w-0 truncate text-xs">
|
||||
<span class="font-medium">{{ suggestionFieldLabel(item) }}</span>
|
||||
<span class="ml-2 opacity-70">{{ item.suggested_value ?? '—' }}</span>
|
||||
</div>
|
||||
<button type="button" class="shrink-0 rounded border px-2 py-0.5 text-xs" @click="openSuggestion(item)">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.review') }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
<ul v-if="failedSuggestions.length" class="mt-3 space-y-2" data-testid="review-llm-failed-list">
|
||||
<li
|
||||
v-for="item in failedSuggestions"
|
||||
:key="item.suggestion_no"
|
||||
class="flex items-center justify-between gap-2 rounded border border-amber-200 bg-amber-50/50 px-2 py-1.5 dark:border-amber-900 dark:bg-amber-950/30"
|
||||
>
|
||||
<div class="min-w-0 truncate text-xs">
|
||||
<span class="font-medium">{{ suggestionFieldLabel(item) }}</span>
|
||||
<span class="ml-2 text-amber-700 dark:text-amber-300">
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.verbatimFailed') }}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded border px-2 py-0.5 text-xs"
|
||||
data-testid="review-llm-open-failed"
|
||||
@click="openSuggestion(item)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.llmSuggestion.review') }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ReviewLlmSuggestionDialog
|
||||
:open="dialogOpen"
|
||||
:suggestion="selected"
|
||||
:evidence="selectedEvidence"
|
||||
:draft-value="dialogDraftValue"
|
||||
:field-label="selected ? suggestionFieldLabel(selected) : ''"
|
||||
@close="dialogOpen = false"
|
||||
@decide="onDecide"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
+97
-37
@@ -3,7 +3,8 @@
|
||||
* features/chat/components/shipping/ShippingOrderDocumentResultItem.vue
|
||||
* 用途:渲染单个 PDF 的订单抽取结果摘要,供详情抽屉按文档逐项展示。
|
||||
* 依赖:订单抽取文档 DTO、vue-i18n。
|
||||
* 逻辑:只显示用户可理解的业务字段;reason_code 优先 i18n,缺失时对 SHIPPING_NOTICE.* 回退通用提示;人工复核由上层统一跳转。
|
||||
* 逻辑:默认只展示状态/PO/行数/阻断原因;审计与补充信息收入详情折叠;
|
||||
* 「查看证据」与「人工复核」分别携带 focus+documentId;未知原因码回退通用文案并展开技术码。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -15,9 +16,20 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
enterManualReview: [];
|
||||
enterManualReview: [payload?: { focus?: 'evidence' | 'draft'; documentId?: number }];
|
||||
}>();
|
||||
|
||||
/**
|
||||
* 向父级发出进入复核事件,并带上当前文档与入口焦点。
|
||||
* @param focus - evidence=查看证据;draft=人工复核草稿
|
||||
*/
|
||||
function emitEnterReview(focus: 'evidence' | 'draft') {
|
||||
emit('enterManualReview', {
|
||||
focus,
|
||||
documentId: Number(props.document.document_id || 0) || undefined,
|
||||
});
|
||||
}
|
||||
|
||||
const { t, te, locale } = useI18n();
|
||||
|
||||
const statusTone = computed(() => {
|
||||
@@ -60,6 +72,13 @@ const reasonLabel = computed(() => {
|
||||
if (code.startsWith('SHIPPING_NOTICE.')) {
|
||||
return t('chat.shippingOrderExtractionTechnicalFailureUserHint');
|
||||
}
|
||||
return t('chat.shippingOrderExtractionReasonUnknown');
|
||||
});
|
||||
const reasonTechnicalCode = computed(() => {
|
||||
const code = String(props.document.reason_code || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `chat.shippingOrderExtractionReason.${code}`;
|
||||
if (te(key) || code.startsWith('SHIPPING_NOTICE.')) return '';
|
||||
return code;
|
||||
});
|
||||
const emailSupplementLabel = computed(() => {
|
||||
@@ -87,6 +106,18 @@ const retryStatusLabel = computed(() => {
|
||||
const key = `chat.shippingOrderExtractionRetryStatus.${status}`;
|
||||
return status && te(key) ? t(key) : '';
|
||||
});
|
||||
const routeTypeLabel = computed(() => {
|
||||
const code = String(props.document.route_type || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `chat.shippingOrderExtractionRouteType.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
});
|
||||
const freezeSourceLabel = computed(() => {
|
||||
const code = String(props.document.freeze_source || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `chat.shippingOrderExtractionFreezeSource.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
});
|
||||
const budgetCostLabel = computed(() => {
|
||||
if (!props.document.budget_cost) return '';
|
||||
return t('chat.shippingOrderExtractionBudgetCost', {
|
||||
@@ -105,6 +136,27 @@ const canEnterManualReview = computed(() => (
|
||||
props.document.available_actions.some((action) => action === 'review_candidate' || action === 'manual_review')
|
||||
));
|
||||
const canViewEvidence = computed(() => props.document.available_actions.includes('view_evidence'));
|
||||
|
||||
const hasAuditDetails = computed(() => Boolean(
|
||||
props.document.selection_batch
|
||||
|| props.document.group_key
|
||||
|| props.document.profile
|
||||
|| routeTypeLabel.value
|
||||
|| freezeSourceLabel.value
|
||||
|| (props.document.email_supplement?.status && props.document.email_supplement.status !== 'none')
|
||||
|| emailSupplementRelations.value.length
|
||||
|| (props.document.email_supplement?.conflict_count || 0) > 0
|
||||
|| retryStatusLabel.value
|
||||
|| budgetCostLabel.value
|
||||
|| (
|
||||
props.document.email_supplement?.reservation_id_status
|
||||
&& props.document.email_supplement.reservation_id_status !== 'none'
|
||||
)
|
||||
|| (
|
||||
props.document.email_supplement?.source_type_status
|
||||
&& props.document.email_supplement.source_type_status !== 'none'
|
||||
),
|
||||
));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -125,50 +177,23 @@ const canViewEvidence = computed(() => props.document.available_actions.includes
|
||||
<div v-if="['pending', 'routing', 'matching_profile', 'extracting', 'merging_supplement'].includes(document.status) || document.activity_event_code" class="mt-1 text-xs font-medium opacity-85">
|
||||
{{ statusActivityLabel }}
|
||||
</div>
|
||||
<!-- 核心业务结果:状态时间 + PO + 行数 -->
|
||||
<div class="mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs opacity-85">
|
||||
<span v-if="activityTimeLabel">{{ activityTimeLabel }}</span>
|
||||
<span v-if="document.selection_batch">
|
||||
{{ t('chat.shippingOrderExtractionSelectionBatch', { batch: document.selection_batch }) }}
|
||||
</span>
|
||||
<span v-if="document.group_key">
|
||||
{{ t('chat.shippingOrderExtractionGroupKey', { key: document.group_key }) }}
|
||||
</span>
|
||||
<span v-if="document.po_number">
|
||||
{{ t('chat.shippingOrderExtractionPoNumber', { value: document.po_number }) }}
|
||||
</span>
|
||||
<span v-if="document.line_count > 0">
|
||||
{{ t('chat.shippingOrderExtractionLineCount', { count: document.line_count }) }}
|
||||
</span>
|
||||
<span v-if="document.profile">
|
||||
{{ t('chat.shippingOrderExtractionProfileSummary', {
|
||||
name: document.profile.name || document.profile.code,
|
||||
version: document.profile.version,
|
||||
}) }}
|
||||
</span>
|
||||
<span>
|
||||
{{ emailSupplementLabel }}
|
||||
</span>
|
||||
<span>
|
||||
{{ t('chat.shippingOrderExtractionEmailSupplementField.reservation') }}{{ reservationStatusLabel }}
|
||||
</span>
|
||||
<span>
|
||||
{{ t('chat.shippingOrderExtractionEmailSupplementField.sourceType') }}{{ sourceTypeStatusLabel }}
|
||||
</span>
|
||||
<span v-for="relation in emailSupplementRelations" :key="relation">
|
||||
{{ relation }}
|
||||
</span>
|
||||
<span v-if="document.email_supplement.conflict_count > 0">
|
||||
{{ t('chat.shippingOrderExtractionEmailSupplementConflictCount', { count: document.email_supplement.conflict_count }) }}
|
||||
</span>
|
||||
<span v-if="retryStatusLabel">
|
||||
{{ retryStatusLabel }}
|
||||
</span>
|
||||
<span v-if="budgetCostLabel">
|
||||
{{ budgetCostLabel }}
|
||||
</span>
|
||||
</div>
|
||||
<!-- 异常信息 -->
|
||||
<div v-if="reasonLabel" class="mt-2 text-xs font-medium opacity-90">
|
||||
{{ reasonLabel }}
|
||||
<details v-if="reasonTechnicalCode" class="mt-1 font-normal opacity-80">
|
||||
<summary class="cursor-pointer">{{ t('chat.shippingOrderExtractionReasonTechDetails') }}</summary>
|
||||
<code class="mt-1 block break-all text-[11px]">{{ reasonTechnicalCode }}</code>
|
||||
</details>
|
||||
</div>
|
||||
<ul v-if="reviewDetails.length" class="mt-2 space-y-1 text-xs font-medium opacity-90">
|
||||
<li v-for="detail in reviewDetails" :key="`${detail.line_number}-${detail.field_code || 'general'}`">
|
||||
@@ -181,12 +206,47 @@ const canViewEvidence = computed(() => props.document.available_actions.includes
|
||||
<div v-if="document.status === 'failed'" class="mt-1 text-xs font-medium opacity-90">
|
||||
{{ t('chat.shippingOrderExtractionTechnicalFailureUserHint') }}
|
||||
</div>
|
||||
<!-- 审计/补充详情:默认折叠,降低首屏密度 -->
|
||||
<details v-if="hasAuditDetails" class="mt-2 text-xs opacity-85">
|
||||
<summary class="cursor-pointer select-none font-medium">
|
||||
{{ t('chat.shippingOrderExtractionMoreDetails') }}
|
||||
</summary>
|
||||
<div class="mt-2 flex flex-wrap gap-x-4 gap-y-1">
|
||||
<span v-if="document.selection_batch">
|
||||
{{ t('chat.shippingOrderExtractionSelectionBatch', { batch: document.selection_batch }) }}
|
||||
</span>
|
||||
<span v-if="document.group_key">
|
||||
{{ t('chat.shippingOrderExtractionGroupKey', { key: document.group_key }) }}
|
||||
</span>
|
||||
<span v-if="document.profile">
|
||||
{{ t('chat.shippingOrderExtractionProfileSummary', {
|
||||
name: document.profile.name || document.profile.code,
|
||||
version: document.profile.version,
|
||||
}) }}
|
||||
</span>
|
||||
<span v-if="routeTypeLabel">{{ routeTypeLabel }}</span>
|
||||
<span v-if="freezeSourceLabel">{{ freezeSourceLabel }}</span>
|
||||
<span>{{ emailSupplementLabel }}</span>
|
||||
<span>
|
||||
{{ t('chat.shippingOrderExtractionEmailSupplementField.reservation') }}{{ reservationStatusLabel }}
|
||||
</span>
|
||||
<span>
|
||||
{{ t('chat.shippingOrderExtractionEmailSupplementField.sourceType') }}{{ sourceTypeStatusLabel }}
|
||||
</span>
|
||||
<span v-for="relation in emailSupplementRelations" :key="relation">{{ relation }}</span>
|
||||
<span v-if="document.email_supplement.conflict_count > 0">
|
||||
{{ t('chat.shippingOrderExtractionEmailSupplementConflictCount', { count: document.email_supplement.conflict_count }) }}
|
||||
</span>
|
||||
<span v-if="retryStatusLabel">{{ retryStatusLabel }}</span>
|
||||
<span v-if="budgetCostLabel">{{ budgetCostLabel }}</span>
|
||||
</div>
|
||||
</details>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="canViewEvidence"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
@click="emit('enterManualReview')"
|
||||
@click="emitEnterReview('evidence')"
|
||||
>
|
||||
<FileText class="h-3.5 w-3.5" />
|
||||
{{ t('chat.shippingOrderExtractionAction.view_evidence') }}
|
||||
@@ -195,7 +255,7 @@ const canViewEvidence = computed(() => props.document.available_actions.includes
|
||||
v-if="canEnterManualReview"
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
@click="emit('enterManualReview')"
|
||||
@click="emitEnterReview('draft')"
|
||||
>
|
||||
{{ t(`chat.shippingOrderExtractionAction.${document.available_actions.includes('review_candidate') ? 'review_candidate' : 'manual_review'}`) }}
|
||||
</button>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingOrderExtractionCard.vue
|
||||
* 用途:聊天主区批次进度卡——摘要计数、Run 级处理事项、当前文件阶段、健康提醒与动作。
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、orderExtractionProgressDisplay、Workflow 计数投影、vue-router、vue-i18n。
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、
|
||||
* orderExtractionProgressDisplay、Workflow 计数投影、vue-router、vue-i18n。
|
||||
* 逻辑:有 Workflow 投影时优先展示统一 counts;否则回退 handling_items / primary_notice;
|
||||
* 右侧 ShippingWorkflowTimeline 承接逐 PDF 明细;禁止发明百分比与 ETA。
|
||||
* 「查看处理详情」挂载详情抽屉;抽屉内证据/复核入口携带 focus+document_id 打开复核页;
|
||||
* 文档与时间线加载失败支持独立就地重试;右侧 ShippingWorkflowTimeline 承接逐 PDF 明细。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref } from 'vue';
|
||||
@@ -14,7 +16,15 @@ import type {
|
||||
ShippingOrderExtractionHandlingItemState,
|
||||
ShippingOrderExtractionState,
|
||||
} from '../../types/chat.types';
|
||||
import type { ShippingWorkflowItemCounts } from '../../types/shipping.api.types';
|
||||
import type {
|
||||
ShippingOrderExtractionDocumentResult,
|
||||
ShippingOrderExtractionProgressEvent,
|
||||
ShippingWorkflowItemCounts,
|
||||
} from '../../types/shipping.api.types';
|
||||
import {
|
||||
listWorkspaceShippingOrderExtractionDocuments,
|
||||
listWorkspaceShippingOrderExtractionProgressEvents,
|
||||
} from '../../api/shipping.api';
|
||||
import {
|
||||
formatOrderExtractionElapsed,
|
||||
resolveOrderExtractionUserStageKey,
|
||||
@@ -25,6 +35,7 @@ import {
|
||||
type ShippingHandlingRefTarget,
|
||||
} from '../../shipping/orderExtractionHandlingRefs';
|
||||
import { SHIPPING_WORKFLOW_KEY } from '../../shipping/useShippingNoticeWorkflow';
|
||||
import ShippingOrderExtractionDetailsDrawer from './ShippingOrderExtractionDetailsDrawer.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
state: ShippingOrderExtractionState;
|
||||
@@ -49,6 +60,14 @@ const confirmCancelOpen = ref(false);
|
||||
const cancelReason = ref('');
|
||||
const injectedWorkflow = inject(SHIPPING_WORKFLOW_KEY, null);
|
||||
|
||||
const detailsOpen = ref(false);
|
||||
const detailsLoading = ref(false);
|
||||
const detailsLoadFailed = ref(false);
|
||||
const detailsDocuments = ref<ShippingOrderExtractionDocumentResult[]>([]);
|
||||
const progressLoading = ref(false);
|
||||
const progressLoadFailed = ref(false);
|
||||
const progressEvents = ref<ShippingOrderExtractionProgressEvent[]>([]);
|
||||
|
||||
/**
|
||||
* 统一计数:优先 props.workflowSummary,其次 inject 的 Workflow.counts,最后回退 Run summary。
|
||||
*/
|
||||
@@ -230,22 +249,50 @@ function handlingTitle(item: ShippingOrderExtractionHandlingItemState): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析原因码文案;未知码回退为原文。
|
||||
* 解析原因码是否已有本地化文案。
|
||||
* @param code - 原因码
|
||||
*/
|
||||
function hasReasonLabel(code: string): boolean {
|
||||
const normalized = String(code || '').trim();
|
||||
if (!normalized) return false;
|
||||
return te(`chat.shippingOrderExtractionReason.${normalized}`)
|
||||
|| te(`chat.shippingOrderExtractionHandling.reason.${normalized}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析原因码文案;未知码回退通用提示(原始码放入技术详情)。
|
||||
* @param code - 原因码
|
||||
*/
|
||||
function reasonLabel(code: string): string {
|
||||
const key = `chat.shippingOrderExtractionReason.${code}`;
|
||||
const normalized = String(code || '').trim();
|
||||
if (!normalized) return '';
|
||||
const key = `chat.shippingOrderExtractionReason.${normalized}`;
|
||||
if (te(key)) return t(key);
|
||||
const freezeKey = `chat.shippingOrderExtractionHandling.reason.${code}`;
|
||||
return te(freezeKey) ? t(freezeKey) : code;
|
||||
const freezeKey = `chat.shippingOrderExtractionHandling.reason.${normalized}`;
|
||||
return te(freezeKey) ? t(freezeKey) : t('chat.shippingOrderExtractionReasonUnknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* 收集事项中无本地化文案的原因码,供可展开技术详情展示。
|
||||
* @param item - 处理事项
|
||||
*/
|
||||
function unknownReasonCodes(item: ShippingOrderExtractionHandlingItemState): string[] {
|
||||
return (item.reasonCodes || [])
|
||||
.map((code) => String(code || '').trim())
|
||||
.filter((code) => code && !hasReasonLabel(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开订单复核工作台(Chat order-review 模式)。
|
||||
* @param options.documentId - 可选,定位到具体 PDF(由右侧 case 映射承接时仍打开 Run 复核)
|
||||
* @param options.documentId - 可选,定位到具体 PDF
|
||||
* @param options.candidateNo - 可选,写入 query 供复核页筛选
|
||||
* @param options.focus - evidence=证据区;draft=草稿复核(默认)
|
||||
*/
|
||||
async function openOrderReview(options?: { documentId?: number; candidateNo?: string }) {
|
||||
async function openOrderReview(options?: {
|
||||
documentId?: number;
|
||||
candidateNo?: string;
|
||||
focus?: 'evidence' | 'draft';
|
||||
}) {
|
||||
const runNo = String(props.runNo || '').trim();
|
||||
if (!runNo) return;
|
||||
const query: Record<string, string> = {
|
||||
@@ -259,6 +306,10 @@ async function openOrderReview(options?: { documentId?: number; candidateNo?: st
|
||||
if (candidateNo) query.candidate = candidateNo;
|
||||
const documentId = Number(options?.documentId || 0);
|
||||
if (documentId > 0) query.document_id = String(documentId);
|
||||
const focus = options?.focus === 'evidence' || options?.focus === 'draft'
|
||||
? options.focus
|
||||
: 'draft';
|
||||
query.focus = focus;
|
||||
await router.push({
|
||||
name: 'Chat',
|
||||
params: { agentId: String(route.params.agentId || '') },
|
||||
@@ -266,6 +317,89 @@ async function openOrderReview(options?: { documentId?: number; candidateNo?: st
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅重载详情抽屉的文档结果列表。
|
||||
*/
|
||||
async function loadDetailsDocuments() {
|
||||
const runNo = String(props.runNo || '').trim();
|
||||
if (!runNo) {
|
||||
detailsDocuments.value = [];
|
||||
detailsLoadFailed.value = true;
|
||||
return;
|
||||
}
|
||||
detailsLoading.value = true;
|
||||
detailsLoadFailed.value = false;
|
||||
try {
|
||||
const docsRes = await listWorkspaceShippingOrderExtractionDocuments(runNo).catch(() => null);
|
||||
if (docsRes) {
|
||||
detailsDocuments.value = Array.isArray(docsRes.items) ? docsRes.items : [];
|
||||
} else {
|
||||
detailsDocuments.value = [];
|
||||
detailsLoadFailed.value = true;
|
||||
}
|
||||
} finally {
|
||||
detailsLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅重载详情抽屉的进度时间线。
|
||||
*/
|
||||
async function loadDetailsProgress() {
|
||||
const runNo = String(props.runNo || '').trim();
|
||||
if (!runNo) {
|
||||
progressEvents.value = [];
|
||||
progressLoadFailed.value = true;
|
||||
return;
|
||||
}
|
||||
progressLoading.value = true;
|
||||
progressLoadFailed.value = false;
|
||||
try {
|
||||
const eventsRes = await listWorkspaceShippingOrderExtractionProgressEvents(runNo).catch(() => null);
|
||||
if (eventsRes) {
|
||||
progressEvents.value = Array.isArray(eventsRes.items) ? eventsRes.items : [];
|
||||
} else {
|
||||
progressEvents.value = [];
|
||||
progressLoadFailed.value = true;
|
||||
}
|
||||
} finally {
|
||||
progressLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 并行加载详情抽屉所需的文档列表与进度事件。
|
||||
*/
|
||||
async function loadDetailsDrawerData() {
|
||||
await Promise.all([loadDetailsDocuments(), loadDetailsProgress()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开 Run 级处理详情抽屉(文档结果 + 进度时间线)。
|
||||
*/
|
||||
async function openDetailsDrawer() {
|
||||
detailsOpen.value = true;
|
||||
await loadDetailsDrawerData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭详情抽屉。
|
||||
*/
|
||||
function closeDetailsDrawer() {
|
||||
detailsOpen.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从详情抽屉进入复核/证据页。
|
||||
*/
|
||||
async function enterReviewFromDetails(payload?: { focus?: 'evidence' | 'draft'; documentId?: number }) {
|
||||
await openOrderReview({
|
||||
documentId: payload?.documentId,
|
||||
focus: payload?.focus === 'evidence' ? 'evidence' : 'draft',
|
||||
});
|
||||
closeDetailsDrawer();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开任务工作台,定位自动冻结受阻等任务号。
|
||||
*/
|
||||
@@ -290,6 +424,7 @@ async function openAffectedRef(target: ShippingHandlingRefTarget) {
|
||||
await openOrderReview({
|
||||
documentId: target.documentId,
|
||||
candidateNo: target.candidateNo,
|
||||
focus: 'draft',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -316,12 +451,12 @@ async function handleHandlingAction(item: ShippingOrderExtractionHandlingItemSta
|
||||
await openAffectedRef(first.target);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
action === 'enter_manual_review'
|
||||
|| action === 'review_candidate'
|
||||
|| action === 'view_details'
|
||||
) {
|
||||
await openOrderReview();
|
||||
if (action === 'view_details') {
|
||||
await openDetailsDrawer();
|
||||
return;
|
||||
}
|
||||
if (action === 'enter_manual_review' || action === 'review_candidate') {
|
||||
await openOrderReview({ focus: 'draft' });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,6 +569,18 @@ function openCancelConfirm() {
|
||||
<div v-if="item.reasonCodes.length" class="mt-1 opacity-80">
|
||||
{{ t('chat.shippingOrderExtractionHandling.reasonPrefix') }}
|
||||
{{ item.reasonCodes.slice(0, 4).map(reasonLabel).join(';') }}
|
||||
<details
|
||||
v-if="unknownReasonCodes(item).length"
|
||||
class="mt-1"
|
||||
data-testid="shipping-order-extraction-reason-tech"
|
||||
>
|
||||
<summary class="cursor-pointer opacity-90">
|
||||
{{ t('chat.shippingOrderExtractionReasonTechDetails') }}
|
||||
</summary>
|
||||
<code class="mt-1 block break-all text-[11px]">
|
||||
{{ unknownReasonCodes(item).join(', ') }}
|
||||
</code>
|
||||
</details>
|
||||
</div>
|
||||
<div
|
||||
v-if="affectedRows(item).length"
|
||||
@@ -511,6 +658,15 @@ function openCancelConfirm() {
|
||||
</div>
|
||||
|
||||
<div v-else class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="String(props.runNo || '').trim()"
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
data-testid="shipping-order-extraction-view-details"
|
||||
@click="openDetailsDrawer"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionAction.view_details') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="showRefresh"
|
||||
type="button"
|
||||
@@ -545,5 +701,20 @@ function openCancelConfirm() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ShippingOrderExtractionDetailsDrawer
|
||||
:open="detailsOpen"
|
||||
:state="state"
|
||||
:documents="detailsDocuments"
|
||||
:progress-events="progressEvents"
|
||||
:loading="detailsLoading"
|
||||
:load-failed="detailsLoadFailed"
|
||||
:progress-loading="progressLoading"
|
||||
:progress-load-failed="progressLoadFailed"
|
||||
@close="closeDetailsDrawer"
|
||||
@enter-manual-review="enterReviewFromDetails"
|
||||
@retry-documents="loadDetailsDocuments"
|
||||
@retry-progress="loadDetailsProgress"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
+148
-27
@@ -3,9 +3,11 @@
|
||||
* features/chat/components/shipping/ShippingOrderExtractionDetailsDrawer.vue
|
||||
* 用途:以抽屉形式展示一次订单抽取 Run 的按 PDF 归并详情和事实时间线。
|
||||
* 依赖:订单抽取状态卡、文档结果项、订单抽取 progress-events DTO、vue-i18n。
|
||||
* 逻辑:聊天摘要卡只显示概览;需要查看逐文档结果和每轮事件原因时由本抽屉承接新的 Run 级事实时间线。
|
||||
* 逻辑:聊天摘要卡只显示概览;需要查看逐文档结果和每轮事件原因时由本抽屉承接;
|
||||
* 以模态对话框语义呈现(初始焦点、Tab 陷阱、Escape/关闭后焦点恢复);
|
||||
* 文档与时间线加载失败分别提供就地重试。
|
||||
*/
|
||||
import { onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { X } from 'lucide-vue-next';
|
||||
import type { ShippingOrderExtractionState } from '../../types/chat.types';
|
||||
@@ -29,20 +31,33 @@ const props = defineProps<{
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
enterManualReview: [];
|
||||
enterManualReview: [payload?: { focus?: 'evidence' | 'draft'; documentId?: number }];
|
||||
retryDocuments: [];
|
||||
retryProgress: [];
|
||||
}>();
|
||||
|
||||
const { t, te, locale } = useI18n();
|
||||
let removeKeydownListener: (() => void) | null = null;
|
||||
const panelRef = ref<HTMLElement | null>(null);
|
||||
const closeButtonRef = ref<HTMLButtonElement | null>(null);
|
||||
let previouslyFocused: HTMLElement | null = null;
|
||||
const timelineOpen = ref(false);
|
||||
|
||||
const FOCUSABLE_SELECTOR = [
|
||||
'a[href]',
|
||||
'button:not([disabled])',
|
||||
'textarea:not([disabled])',
|
||||
'input:not([disabled])',
|
||||
'select:not([disabled])',
|
||||
'[tabindex]:not([tabindex="-1"])',
|
||||
].join(',');
|
||||
|
||||
const translateReasonCodes = (codes: string[] | undefined): string[] => (
|
||||
(codes || [])
|
||||
.map((code) => {
|
||||
const normalized = String(code || '').trim();
|
||||
if (!normalized) return '';
|
||||
const key = `chat.shippingOrderExtractionReason.${normalized}`;
|
||||
return te(key) ? t(key) : normalized;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderExtractionReasonUnknown');
|
||||
})
|
||||
.filter(Boolean)
|
||||
);
|
||||
@@ -88,22 +103,79 @@ const eventContextLabel = (event: ShippingOrderExtractionProgressEvent): string
|
||||
const eventCategoryKey = (event: ShippingOrderExtractionProgressEvent): string =>
|
||||
`chat.shippingOrderExtractionTimelineTag.${classifyOrderExtractionTimelineEvent(event)}`;
|
||||
|
||||
/** 收集抽屉内可聚焦控件。 */
|
||||
function focusableNodes(): HTMLElement[] {
|
||||
if (!panelRef.value) return [];
|
||||
return Array.from(panelRef.value.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR))
|
||||
.filter((node) => !node.hasAttribute('disabled') && node.getAttribute('aria-hidden') !== 'true');
|
||||
}
|
||||
|
||||
/** 关闭抽屉。 */
|
||||
function handleClose(): void {
|
||||
emit('close');
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape 关闭;Tab 在抽屉内循环,阻止焦点逃逸到背景页。
|
||||
*/
|
||||
function onKeydown(event: KeyboardEvent): void {
|
||||
if (!props.open) return;
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
handleClose();
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'Tab') return;
|
||||
const nodes = focusableNodes();
|
||||
const first = nodes[0];
|
||||
const last = nodes[nodes.length - 1];
|
||||
if (!first || !last) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
const active = document.activeElement as HTMLElement | null;
|
||||
const inside = Boolean(active && panelRef.value?.contains(active));
|
||||
if (event.shiftKey) {
|
||||
if (!inside || active === first) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!inside || active === last) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
(open) => {
|
||||
removeKeydownListener?.();
|
||||
removeKeydownListener = null;
|
||||
if (!open) return;
|
||||
const handleKeydown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') emit('close');
|
||||
};
|
||||
window.addEventListener('keydown', handleKeydown);
|
||||
removeKeydownListener = () => window.removeEventListener('keydown', handleKeydown);
|
||||
async (open, wasOpen) => {
|
||||
if (typeof document === 'undefined') return;
|
||||
if (open && !wasOpen) {
|
||||
previouslyFocused = document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: null;
|
||||
document.addEventListener('keydown', onKeydown, true);
|
||||
await nextTick();
|
||||
(closeButtonRef.value || focusableNodes()[0])?.focus();
|
||||
return;
|
||||
}
|
||||
if (!open && wasOpen) {
|
||||
document.removeEventListener('keydown', onKeydown, true);
|
||||
const restoreTarget = previouslyFocused;
|
||||
previouslyFocused = null;
|
||||
await nextTick();
|
||||
restoreTarget?.focus?.();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
removeKeydownListener?.();
|
||||
if (typeof document !== 'undefined') {
|
||||
document.removeEventListener('keydown', onKeydown, true);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -112,9 +184,11 @@ onBeforeUnmount(() => {
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex justify-end bg-slate-950/40"
|
||||
@click.self="emit('close')"
|
||||
data-testid="shipping-order-extraction-details-drawer"
|
||||
@click.self="handleClose"
|
||||
>
|
||||
<aside
|
||||
ref="panelRef"
|
||||
class="flex h-full w-full max-w-[560px] flex-col bg-white shadow-2xl dark:bg-slate-900"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
@@ -145,10 +219,12 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
ref="closeButtonRef"
|
||||
type="button"
|
||||
class="rounded-md p-1 text-slate-500 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-slate-800 dark:hover:text-slate-100"
|
||||
:aria-label="t('chat.shippingOrderExtractionCloseDetails')"
|
||||
@click="emit('close')"
|
||||
data-testid="shipping-order-extraction-details-close"
|
||||
@click="handleClose"
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
</button>
|
||||
@@ -158,8 +234,20 @@ onBeforeUnmount(() => {
|
||||
<div v-if="loading" class="rounded-lg border border-dashed border-slate-300 px-3 py-4 text-sm text-slate-600 dark:border-slate-700 dark:text-slate-300">
|
||||
{{ t('chat.shippingOrderExtractionDocumentsLoading') }}
|
||||
</div>
|
||||
<div v-else-if="loadFailed" class="rounded-lg border border-amber-300 bg-amber-50 px-3 py-4 text-sm text-amber-900 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-100">
|
||||
{{ t('chat.shippingOrderExtractionDocumentsUnavailable') }}
|
||||
<div
|
||||
v-else-if="loadFailed"
|
||||
class="rounded-lg border border-amber-300 bg-amber-50 px-3 py-4 text-sm text-amber-900 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-100"
|
||||
data-testid="shipping-order-extraction-documents-failed"
|
||||
>
|
||||
<p>{{ t('chat.shippingOrderExtractionDocumentsUnavailable') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-2 rounded-md border border-current/30 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
data-testid="shipping-order-extraction-documents-retry"
|
||||
@click="emit('retryDocuments')"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionDetailsRetry') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="documents.length === 0" class="rounded-lg border border-dashed border-slate-300 px-3 py-4 text-sm text-slate-600 dark:border-slate-700 dark:text-slate-300">
|
||||
{{ t('chat.shippingOrderExtractionNoDocuments') }}
|
||||
@@ -168,14 +256,38 @@ onBeforeUnmount(() => {
|
||||
v-for="document in documents"
|
||||
:key="document.unit_id"
|
||||
:document="document"
|
||||
@enter-manual-review="emit('enterManualReview')"
|
||||
@enter-manual-review="(payload) => emit('enterManualReview', payload)"
|
||||
/>
|
||||
<details :open="timelineOpen" class="rounded-lg border border-slate-200 bg-white px-3 py-3 dark:border-slate-700 dark:bg-slate-950/40" @toggle="timelineOpen = ($event.currentTarget as HTMLDetailsElement).open">
|
||||
<summary class="cursor-pointer text-xs font-semibold text-slate-900 dark:text-slate-100">{{ t('chat.shippingOrderExtractionTimelineTitle') }}</summary>
|
||||
<div v-if="state.selectionPlan?.totalAttachmentCount || state.unitSummary?.technicalFailureReasonCodes?.length" class="mt-3 rounded-lg bg-slate-50 px-3 py-3 text-xs text-slate-700 dark:bg-slate-900/60 dark:text-slate-200">
|
||||
<div v-if="state.selectionPlan?.totalAttachmentCount">{{ t('chat.shippingOrderExtractionPlanSummary', { total: state.selectionPlan.totalAttachmentCount, groups: state.selectionPlan.groupCount || 0, attachments: state.selectionPlan.maxInitialAttachments || 0, concurrency: state.selectionPlan.maxInitialConcurrency || 0 }) }}</div>
|
||||
<div v-if="state.unitSummary?.reviewRequiredReasonCodes?.length" class="mt-1">{{ t('chat.shippingOrderExtractionReviewReasonCodes', { codes: translateReasonCodes(state.unitSummary.reviewRequiredReasonCodes).join(' / ') }) }}</div>
|
||||
<div v-if="state.unitSummary?.technicalFailureReasonCodes?.length" class="mt-1">{{ t('chat.shippingOrderExtractionTechnicalFailureCodes', { codes: state.unitSummary.technicalFailureReasonCodes.join(', ') }) }}</div>
|
||||
<details
|
||||
:open="timelineOpen"
|
||||
class="rounded-lg border border-slate-200 bg-white px-3 py-3 dark:border-slate-700 dark:bg-slate-950/40"
|
||||
@toggle="timelineOpen = ($event.currentTarget as HTMLDetailsElement).open"
|
||||
>
|
||||
<summary class="cursor-pointer text-xs font-semibold text-slate-900 dark:text-slate-100">
|
||||
{{ t('chat.shippingOrderExtractionTimelineTitle') }}
|
||||
</summary>
|
||||
<div
|
||||
v-if="state.selectionPlan?.totalAttachmentCount || state.unitSummary?.technicalFailureReasonCodes?.length"
|
||||
class="mt-3 rounded-lg bg-slate-50 px-3 py-3 text-xs text-slate-700 dark:bg-slate-900/60 dark:text-slate-200"
|
||||
>
|
||||
<div v-if="state.selectionPlan?.totalAttachmentCount">
|
||||
{{ t('chat.shippingOrderExtractionPlanSummary', {
|
||||
total: state.selectionPlan.totalAttachmentCount,
|
||||
groups: state.selectionPlan.groupCount || 0,
|
||||
attachments: state.selectionPlan.maxInitialAttachments || 0,
|
||||
concurrency: state.selectionPlan.maxInitialConcurrency || 0,
|
||||
}) }}
|
||||
</div>
|
||||
<div v-if="state.unitSummary?.reviewRequiredReasonCodes?.length" class="mt-1">
|
||||
{{ t('chat.shippingOrderExtractionReviewReasonCodes', {
|
||||
codes: translateReasonCodes(state.unitSummary.reviewRequiredReasonCodes).join(' / '),
|
||||
}) }}
|
||||
</div>
|
||||
<div v-if="state.unitSummary?.technicalFailureReasonCodes?.length" class="mt-1">
|
||||
{{ t('chat.shippingOrderExtractionTechnicalFailureCodes', {
|
||||
codes: state.unitSummary.technicalFailureReasonCodes.join(', '),
|
||||
}) }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="progressLoading"
|
||||
@@ -186,8 +298,17 @@ onBeforeUnmount(() => {
|
||||
<div
|
||||
v-else-if="progressLoadFailed"
|
||||
class="mt-2 text-sm text-amber-700 dark:text-amber-200"
|
||||
data-testid="shipping-order-extraction-timeline-failed"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionTimelineUnavailable') }}
|
||||
<p>{{ t('chat.shippingOrderExtractionTimelineUnavailable') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-2 rounded-md border border-current/30 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
data-testid="shipping-order-extraction-timeline-retry"
|
||||
@click="emit('retryProgress')"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionDetailsRetry') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="progressEvents.length === 0"
|
||||
|
||||
+24
-1
@@ -75,7 +75,12 @@ describe('ShippingWorkflowItemDetailDrawer', () => {
|
||||
const wrapper = mount(ShippingWorkflowItemDetailDrawer, {
|
||||
props: {
|
||||
open: true,
|
||||
item: buildItem({ lifecycle_status: 'failed', current_document_filename: 'fail.pdf' }),
|
||||
item: buildItem({
|
||||
lifecycle_status: 'failed',
|
||||
current_document_filename: 'fail.pdf',
|
||||
available_actions: ['cancel', 'reparse'],
|
||||
reparse_kind: 'failed_run_retry',
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
attachTo: document.body,
|
||||
@@ -90,6 +95,24 @@ describe('ShippingWorkflowItemDetailDrawer', () => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('hides reparse for pending_review without case contract', async () => {
|
||||
const wrapper = mount(ShippingWorkflowItemDetailDrawer, {
|
||||
props: {
|
||||
open: true,
|
||||
item: buildItem({
|
||||
lifecycle_status: 'pending_review',
|
||||
current_case_no: null,
|
||||
available_actions: ['cancel'],
|
||||
reparse_kind: null,
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
attachTo: document.body,
|
||||
});
|
||||
expect(drawerRoot()?.querySelector('[data-testid="shipping-workflow-item-drawer-reparse"]')).toBeNull();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('hides cancel for closed items and emits close', async () => {
|
||||
const wrapper = mount(ShippingWorkflowItemDetailDrawer, {
|
||||
props: {
|
||||
|
||||
+16
-5
@@ -3,8 +3,8 @@
|
||||
* 用途:单个 WorkflowItem(PDF)详情抽屉——文件名、阶段、事件时间线、取消/重识别入口。
|
||||
* 依赖:vue-i18n、ShippingWorkflowItem / Event 类型、lucide-vue-next。
|
||||
* 逻辑:由 ShippingWorkflowTimeline 打开;展示 filename / current_stage / events;
|
||||
* 取消与重识别仅 emit,由父级用应用内原因弹窗收集;禁止发明百分比与 ETA。
|
||||
* 以模态对话框语义呈现:初始焦点、Tab 陷阱、Escape/关闭后焦点恢复。
|
||||
* 取消与重识别以后端 available_actions 为准,仅 emit 由父级收集原因;
|
||||
* 禁止发明百分比与 ETA。以模态对话框语义呈现:初始焦点、Tab 陷阱、Escape/关闭后焦点恢复。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
@@ -45,13 +45,24 @@ const events = computed((): ShippingWorkflowEvent[] => (
|
||||
));
|
||||
|
||||
const canCancel = computed(() => {
|
||||
const actions = props.item?.available_actions;
|
||||
if (Array.isArray(actions)) return actions.includes('cancel');
|
||||
const status = String(props.item?.lifecycle_status || '').trim();
|
||||
return Boolean(props.item) && !['closed', 'cancelled'].includes(status);
|
||||
});
|
||||
|
||||
const canReparse = computed(() => {
|
||||
const status = String(props.item?.lifecycle_status || '').trim();
|
||||
return Boolean(props.item) && ['failed', 'reparse_failed', 'pending_review'].includes(status);
|
||||
const actions = props.item?.available_actions;
|
||||
if (Array.isArray(actions)) return actions.includes('reparse');
|
||||
// 无契约时 fail-closed,禁止仅凭 pending_review 展示。
|
||||
return false;
|
||||
});
|
||||
|
||||
const reparseActionLabel = computed(() => {
|
||||
if (props.item?.reparse_kind === 'failed_run_retry') {
|
||||
return t('chat.shippingWorkflow.actions.retryFailedRun');
|
||||
}
|
||||
return t('chat.shippingWorkflow.actions.reparse');
|
||||
});
|
||||
|
||||
const filename = computed(() => {
|
||||
@@ -293,7 +304,7 @@ onBeforeUnmount(() => {
|
||||
data-testid="shipping-workflow-item-drawer-reparse"
|
||||
@click="emit('reparse', item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.reparse') }}
|
||||
{{ reparseActionLabel }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canCancel"
|
||||
|
||||
@@ -211,7 +211,13 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
|
||||
it('shows reparse action for failed items', async () => {
|
||||
const controller = buildController([
|
||||
buildItem({ item_no: 'SWI-FAIL', lifecycle_status: 'failed', current_document_filename: 'bad.pdf' }),
|
||||
buildItem({
|
||||
item_no: 'SWI-FAIL',
|
||||
lifecycle_status: 'failed',
|
||||
current_document_filename: 'bad.pdf',
|
||||
available_actions: ['cancel', 'reparse'],
|
||||
reparse_kind: 'failed_run_retry',
|
||||
}),
|
||||
]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
@@ -219,5 +225,24 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-action-reparse"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('重试失败识别');
|
||||
});
|
||||
|
||||
it('hides reparse for pending_review without available_actions.reparse', async () => {
|
||||
const controller = buildController([
|
||||
buildItem({
|
||||
item_no: 'SWI-PR',
|
||||
lifecycle_status: 'pending_review',
|
||||
current_case_no: null,
|
||||
available_actions: ['cancel'],
|
||||
reparse_kind: null,
|
||||
}),
|
||||
]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-action-reparse"]').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -111,7 +111,6 @@ const ACTIONABLE_FILTER_STATUSES = new Set([
|
||||
'queued',
|
||||
'manual_upload_pending',
|
||||
]);
|
||||
const REPARSE_STATUSES = new Set(['failed', 'reparse_failed', 'pending_review']);
|
||||
|
||||
/**
|
||||
* 将 Item 归入展示分组。
|
||||
@@ -128,17 +127,32 @@ function resolveGroup(item: ShippingWorkflowItem): ItemGroupKey {
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否允许取消(非 closed/cancelled)。
|
||||
* 是否允许取消:优先后端 available_actions,否则回退非终态。
|
||||
*/
|
||||
function canCancel(item: ShippingWorkflowItem): boolean {
|
||||
const actions = item.available_actions;
|
||||
if (Array.isArray(actions)) return actions.includes('cancel');
|
||||
return !COMPLETED_STATUSES.has(String(item.lifecycle_status || '').trim());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否允许重试/重新识别。
|
||||
* 是否允许重试/重新识别:必须以后端 available_actions 为准。
|
||||
*/
|
||||
function canReparse(item: ShippingWorkflowItem): boolean {
|
||||
return REPARSE_STATUSES.has(String(item.lifecycle_status || '').trim());
|
||||
const actions = item.available_actions;
|
||||
if (Array.isArray(actions)) return actions.includes('reparse');
|
||||
// 无契约时 fail-closed:禁止仅凭 pending_review 展示(会稳定触发 CASE_REQUIRED)。
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重识别按钮文案:区分 Case 新版本与失败 Run 重试。
|
||||
*/
|
||||
function reparseActionLabel(item: ShippingWorkflowItem): string {
|
||||
if (item.reparse_kind === 'failed_run_retry') {
|
||||
return t('chat.shippingWorkflow.actions.retryFailedRun');
|
||||
}
|
||||
return t('chat.shippingWorkflow.actions.reparse');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -299,6 +313,9 @@ async function onReasonConfirm(payload: { reason: string; comment?: string }) {
|
||||
detailItem.value = null;
|
||||
}
|
||||
} catch (err) {
|
||||
// 失败时关闭原因确认框,避免与错误提示双遮罩。
|
||||
reasonDialogOpen.value = false;
|
||||
reasonDialogItem.value = null;
|
||||
const message = err instanceof BusinessError ? err.message : t('errors.generic');
|
||||
msg.error(message);
|
||||
} finally {
|
||||
@@ -528,7 +545,7 @@ watch(
|
||||
data-testid="shipping-workflow-action-reparse"
|
||||
@click="openReparseDialog(item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.reparse') }}
|
||||
{{ reparseActionLabel(item) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canCancel(item)"
|
||||
|
||||
@@ -31,12 +31,17 @@ import {
|
||||
putWorkspaceShippingOrderReviewInventoryCandidates,
|
||||
reparseWorkspaceShippingOrderReviewDocument,
|
||||
validateWorkspaceShippingOrderReviewDraft,
|
||||
listWorkspaceShippingOrderReviewLlmSuggestions,
|
||||
requestWorkspaceShippingOrderReviewLlmSuggestion,
|
||||
adjudicateWorkspaceShippingOrderReviewLlmSuggestion,
|
||||
} from '../api/shipping.api';
|
||||
import type {
|
||||
ShippingOrderReviewBuildEligibility,
|
||||
ShippingOrderReviewBuildEligibilityLineProjection,
|
||||
ShippingOrderReviewCase,
|
||||
ShippingOrderReviewEvidence,
|
||||
ShippingOrderReviewLlmAdjudicationPayload,
|
||||
ShippingOrderReviewLlmSuggestion,
|
||||
ShippingOrderReviewRun,
|
||||
ShippingWorkflowItem,
|
||||
ShippingWorkflowItemVersion,
|
||||
@@ -189,6 +194,10 @@ export function useShippingOrderReview() {
|
||||
const draftConflict = ref<DraftVersionConflict | null>(null);
|
||||
const versionsLoading = ref(false);
|
||||
const evidence = ref<ShippingOrderReviewEvidence[]>([]);
|
||||
const llmSuggestions = ref<ShippingOrderReviewLlmSuggestion[]>([]);
|
||||
const suggestionLoading = ref(false);
|
||||
const focusedFieldId = ref<string | null>(null);
|
||||
const focusedLineKey = ref<string | null>(null);
|
||||
const previewUrl = ref('');
|
||||
/** 确认后是否展示并轮询 Workflow 自动进度。 */
|
||||
const showWorkflowProgress = ref(false);
|
||||
@@ -402,6 +411,7 @@ export function useShippingOrderReview() {
|
||||
const caseNo = preferredCaseNo || run.items[0]?.case_no;
|
||||
activeCase.value = caseNo ? await getWorkspaceShippingOrderReviewCase(caseNo) : null;
|
||||
evidence.value = caseNo ? (await getWorkspaceShippingOrderReviewEvidence(caseNo)).items : [];
|
||||
llmSuggestions.value = activeCase.value?.llm_suggestions ?? [];
|
||||
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
|
||||
previewUrl.value = '';
|
||||
if (caseNo) {
|
||||
@@ -430,6 +440,7 @@ export function useShippingOrderReview() {
|
||||
]);
|
||||
activeCase.value = detail;
|
||||
evidence.value = result.items;
|
||||
llmSuggestions.value = detail.llm_suggestions ?? [];
|
||||
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
|
||||
previewUrl.value = '';
|
||||
try {
|
||||
@@ -672,6 +683,59 @@ export function useShippingOrderReview() {
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* 设置当前聚焦字段,供 LLM 建议面板请求范围。
|
||||
*/
|
||||
const focusSuggestionField = (fieldId: string, lineKey?: string | null) => {
|
||||
focusedFieldId.value = fieldId;
|
||||
focusedLineKey.value = lineKey ?? null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 请求当前聚焦字段的 Dify 最小证据建议。
|
||||
*/
|
||||
const requestSuggestion = async (issueCode?: string | null) => {
|
||||
if (!activeCase.value || !focusedFieldId.value) return null;
|
||||
suggestionLoading.value = true;
|
||||
try {
|
||||
const response = await requestWorkspaceShippingOrderReviewLlmSuggestion(activeCase.value.case_no, {
|
||||
field_id: focusedFieldId.value,
|
||||
line_key: focusedLineKey.value,
|
||||
issue_code: issueCode ?? undefined,
|
||||
expected_draft_version: activeCase.value.draft?.draft_version,
|
||||
});
|
||||
activeCase.value = response.case;
|
||||
llmSuggestions.value = response.case.llm_suggestions ?? llmSuggestions.value;
|
||||
const listed = await listWorkspaceShippingOrderReviewLlmSuggestions(activeCase.value.case_no);
|
||||
llmSuggestions.value = listed.items;
|
||||
return response;
|
||||
} finally {
|
||||
suggestionLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 人工裁决 LLM 建议。
|
||||
*/
|
||||
const decideSuggestion = async (
|
||||
suggestionNo: string,
|
||||
body: ShippingOrderReviewLlmAdjudicationPayload,
|
||||
) => {
|
||||
if (!activeCase.value) return null;
|
||||
return save(async () => {
|
||||
const response = await adjudicateWorkspaceShippingOrderReviewLlmSuggestion(
|
||||
activeCase.value!.case_no,
|
||||
suggestionNo,
|
||||
{
|
||||
...body,
|
||||
expected_draft_version: body.expected_draft_version ?? activeCase.value!.draft?.draft_version,
|
||||
},
|
||||
);
|
||||
llmSuggestions.value = response.case.llm_suggestions ?? llmSuggestions.value;
|
||||
return response.case;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 跳转至工作项当前版本对应的 Run/Case。
|
||||
* @returns 目标 run_no 与 case_no;无法解析时返回 null。
|
||||
@@ -714,6 +778,10 @@ export function useShippingOrderReview() {
|
||||
isReadOnly,
|
||||
editable,
|
||||
evidence,
|
||||
llmSuggestions,
|
||||
suggestionLoading,
|
||||
focusedFieldId,
|
||||
focusedLineKey,
|
||||
previewUrl,
|
||||
showWorkflowProgress,
|
||||
workflowProgressPolling,
|
||||
@@ -745,5 +813,8 @@ export function useShippingOrderReview() {
|
||||
reparseDocument,
|
||||
uploadReplacement,
|
||||
startReplacementRun,
|
||||
focusSuggestionField,
|
||||
requestSuggestion,
|
||||
decideSuggestion,
|
||||
};
|
||||
}
|
||||
@@ -187,6 +187,43 @@ describe('useChatShippingSendHandler', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('submits ready intakes from separate upload selections in one run', async () => {
|
||||
const attachments = ref([
|
||||
{
|
||||
id: 'notice-first', kind: 'shipping_notice' as const, type: 'document' as const,
|
||||
uploadStatus: 'uploaded' as const, parseStatus: 'parsed' as const,
|
||||
orderExtractionStatus: 'not_started' as const, uploadProgress: 100,
|
||||
originalFilename: 'first.eml', fileSize: 100, intakeNo: 'SNI-FIRST', uploadBatchId: 'batch-first',
|
||||
},
|
||||
{
|
||||
id: 'notice-second', kind: 'shipping_notice' as const, type: 'document' as const,
|
||||
uploadStatus: 'uploaded' as const, parseStatus: 'parsed' as const,
|
||||
orderExtractionStatus: 'not_started' as const, uploadProgress: 100,
|
||||
originalFilename: 'second.eml', fileSize: 120, intakeNo: 'SNI-SECOND', uploadBatchId: 'batch-second',
|
||||
},
|
||||
]);
|
||||
const startOrderExtractionRun = vi.fn(async () => true);
|
||||
const ctx = createContext({
|
||||
attachments,
|
||||
getParsedIntakeNos: () => ['SNI-FIRST', 'SNI-SECOND'],
|
||||
startOrderExtractionRun,
|
||||
});
|
||||
const { tryHandleShippingAttachmentAutoFlow } = createShippingSendHandlers(ctx);
|
||||
|
||||
const consumed = await tryHandleShippingAttachmentAutoFlow(undefined, '', '');
|
||||
|
||||
expect(consumed).toBe(true);
|
||||
expect(startOrderExtractionRun).toHaveBeenCalledWith(
|
||||
'chat.shippingOrderExtractionDefaultUserMessage',
|
||||
['SNI-FIRST', 'SNI-SECOND'],
|
||||
[
|
||||
{ name: 'first.eml', size: 100, extension: 'eml', type: 'document', source: 'shipping_notice' },
|
||||
{ name: 'second.eml', size: 120, extension: 'eml', type: 'document', source: 'shipping_notice' },
|
||||
],
|
||||
);
|
||||
expect(attachments.value).toEqual([]);
|
||||
});
|
||||
|
||||
it('keeps attachments in the input when starting the run fails', async () => {
|
||||
const attachment = {
|
||||
id: 'notice-start-failed',
|
||||
|
||||
@@ -226,10 +226,6 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
.map((item) => String(item.uploadBatchId || '').trim())
|
||||
.filter(Boolean),
|
||||
);
|
||||
if (batchIds.size > 1) {
|
||||
ctx.msg.warning('当前发送批次不一致,请重新上传需要一起识别的文件');
|
||||
return true;
|
||||
}
|
||||
const userAttachments = createChatMessageAttachmentSnapshots(
|
||||
noticeItems.filter((item) =>
|
||||
item.intakeNo
|
||||
@@ -241,7 +237,8 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
ctx.shippingAutoFlowRequested.value = false;
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
try {
|
||||
const uploadBatchId = [...batchIds][0];
|
||||
// 多次文件选择可以共同进入一个 Run;仅单一上传批次时携带该幂等提示。
|
||||
const uploadBatchId = batchIds.size === 1 ? [...batchIds][0] : undefined;
|
||||
const started = uploadBatchId
|
||||
? await ctx.startOrderExtractionRun?.(query, intakeNos, userAttachments, uploadBatchId)
|
||||
: await ctx.startOrderExtractionRun?.(query, intakeNos, userAttachments);
|
||||
|
||||
@@ -1,18 +1,132 @@
|
||||
/**
|
||||
* features/chat/shipping/useShippingNoticeIntakes.spec.ts
|
||||
* 用途:验证订单抽取阶段的轮询与本地即时状态合并规则。
|
||||
* 依赖:Vitest、useShippingNoticeIntakes 纯函数导出。
|
||||
* 逻辑:确保 parsed 不会提前停止 extracting 轮询,且服务端 not_started 不覆盖刚点击发送的本地状态。
|
||||
* 用途:验证发货通知批量入队、订单抽取轮询与本地即时状态合并规则。
|
||||
* 依赖:Vitest、Vue ref、useShippingNoticeIntakes、文件资产与 Intake API mock。
|
||||
* 逻辑:确保同批附件一次进入输入区并并发预处理;parsed 不提前停止 extracting 轮询,服务端 not_started 不覆盖本地状态。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { ref } from 'vue';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import type { PendingAttachment } from '../types/shipping.types';
|
||||
|
||||
const apiMocks = vi.hoisted(() => ({
|
||||
uploadFileAsset: vi.fn(),
|
||||
createShippingNoticeIntake: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/api/file-assets.api', () => ({
|
||||
uploadFileAsset: apiMocks.uploadFileAsset,
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
cancelShippingNoticeIntake: vi.fn(),
|
||||
createShippingNoticeIntake: apiMocks.createShippingNoticeIntake,
|
||||
getShippingNoticeIntakeStatuses: vi.fn(),
|
||||
listActiveShippingNoticeIntakes: vi.fn(),
|
||||
promoteShippingNoticeCandidate: vi.fn(),
|
||||
rejectShippingNoticeCandidate: vi.fn(),
|
||||
resolveShippingNoticeCandidateDuplicate: vi.fn(),
|
||||
resolveShippingNoticeDuplicate: vi.fn(),
|
||||
retryShippingNoticeIntake: vi.fn(),
|
||||
updateShippingNoticeCandidate: vi.fn(),
|
||||
}));
|
||||
|
||||
import {
|
||||
isOrderExtractionEligibleIntake,
|
||||
resolveShippingOrderExtractionStatus,
|
||||
shouldRestoreShippingNoticeIntake,
|
||||
shouldPollShippingNoticeIntake,
|
||||
useShippingNoticeIntakes,
|
||||
} from './useShippingNoticeIntakes';
|
||||
|
||||
/** 创建可手动完成的 Promise,用于断言多个附件上传是否在同一轮启动。 */
|
||||
function createDeferred<T>() {
|
||||
let resolve!: (value: T) => void;
|
||||
const promise = new Promise<T>((done) => {
|
||||
resolve = done;
|
||||
});
|
||||
return { promise, resolve };
|
||||
}
|
||||
|
||||
describe('shipping notice order extraction state', () => {
|
||||
it('adds the whole selected batch before starting concurrent preprocessing', async () => {
|
||||
const firstUpload = createDeferred<{ asset_no: string }>();
|
||||
const secondUpload = createDeferred<{ asset_no: string }>();
|
||||
apiMocks.uploadFileAsset
|
||||
.mockReset()
|
||||
.mockReturnValueOnce(firstUpload.promise)
|
||||
.mockReturnValueOnce(secondUpload.promise);
|
||||
apiMocks.createShippingNoticeIntake
|
||||
.mockReset()
|
||||
.mockImplementation(async (assetNo: string, _conversationId: string | null, uploadBatchId: string) => ({
|
||||
intake_no: `SNI-${assetNo}`,
|
||||
upload_batch_id: uploadBatchId,
|
||||
parse_status: 'parsed',
|
||||
candidates: [],
|
||||
}));
|
||||
const attachments = ref<PendingAttachment[]>([]);
|
||||
const intakes = useShippingNoticeIntakes({
|
||||
attachments,
|
||||
conversationId: ref(null),
|
||||
msg: { warning: vi.fn() },
|
||||
t: (key) => key,
|
||||
});
|
||||
const files = [
|
||||
new File(['first'], 'first.eml', { type: 'message/rfc822' }),
|
||||
new File(['second'], 'second.eml', { type: 'message/rfc822' }),
|
||||
];
|
||||
|
||||
const enqueuePromise = intakes.enqueueNoticeFiles(files);
|
||||
|
||||
expect(attachments.value).toHaveLength(2);
|
||||
expect(new Set(attachments.value.map((item) => item.kind === 'shipping_notice' ? item.uploadBatchId : undefined)).size).toBe(1);
|
||||
expect(apiMocks.uploadFileAsset).toHaveBeenCalledTimes(2);
|
||||
|
||||
firstUpload.resolve({ asset_no: 'ASSET-1' });
|
||||
secondUpload.resolve({ asset_no: 'ASSET-2' });
|
||||
await enqueuePromise;
|
||||
|
||||
expect(apiMocks.createShippingNoticeIntake).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('submits all ready attachments even when users selected them in separate batches', async () => {
|
||||
apiMocks.uploadFileAsset
|
||||
.mockReset()
|
||||
.mockResolvedValueOnce({ asset_no: 'ASSET-1' })
|
||||
.mockResolvedValueOnce({ asset_no: 'ASSET-2' });
|
||||
apiMocks.createShippingNoticeIntake
|
||||
.mockReset()
|
||||
.mockImplementation(async (assetNo: string, _conversationId: string | null, uploadBatchId: string) => ({
|
||||
intake_no: `SNI-${assetNo}`,
|
||||
upload_batch_id: uploadBatchId,
|
||||
parse_status: 'parsed',
|
||||
parse_summary: {
|
||||
preview_status: 'ready_for_extraction',
|
||||
ready_for_extraction: true,
|
||||
attachment_directory_complete: true,
|
||||
},
|
||||
order_extraction_status: 'not_started',
|
||||
candidates: [],
|
||||
}));
|
||||
const attachments = ref<PendingAttachment[]>([]);
|
||||
const intakes = useShippingNoticeIntakes({
|
||||
attachments,
|
||||
conversationId: ref(null),
|
||||
msg: { warning: vi.fn() },
|
||||
t: (key) => key,
|
||||
});
|
||||
|
||||
await intakes.enqueueNoticeFiles([
|
||||
new File(['first'], 'first.eml', { type: 'message/rfc822' }),
|
||||
]);
|
||||
await intakes.enqueueNoticeFiles([
|
||||
new File(['second'], 'second.eml', { type: 'message/rfc822' }),
|
||||
]);
|
||||
|
||||
// 两次选择具有不同 uploadBatchId,但同在当前输入框时必须进入同一个订单抽取 Run。
|
||||
expect(new Set(attachments.value.map((item) => item.kind === 'shipping_notice' ? item.uploadBatchId : undefined)).size).toBe(2);
|
||||
expect(intakes.getParsedIntakeNos()).toEqual(['SNI-ASSET-1', 'SNI-ASSET-2']);
|
||||
});
|
||||
|
||||
it('does not resubmit consumed intakes for a new order extraction turn', () => {
|
||||
expect(isOrderExtractionEligibleIntake({
|
||||
intakeNo: 'SNI-CONSUMED',
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
* features/chat/shipping/useShippingNoticeIntakes.ts
|
||||
* 用途:发货通知选择即上传、创建 intake 与批量状态轮询编排。
|
||||
* 依赖:file-assets.api、shipping.api、shipping.types、shippingNoticeAttachmentIntegrity、后端布局状态汇总。
|
||||
* 逻辑:useChatShipping / useChatAttachments 在货代 Agent 下委托本 composable 管理预解析附件;
|
||||
* 逻辑:useChatShipping / useChatAttachments 在货代 Agent 下委托本 composable 原子加入附件并并发预解析;
|
||||
* 点击发送时汇集输入框内全部合格附件,不以某次文件选择生成的 uploadBatchId 截断;
|
||||
* 完整性判定委托 shippingNoticeAttachmentIntegrity(与后端契约对齐);会话刷新仅恢复未提交的处理中或解析失败附件。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, ref, type Ref } from 'vue';
|
||||
@@ -247,8 +248,6 @@ export interface UseShippingNoticeIntakesOptions {
|
||||
export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOptions) {
|
||||
const pollTimer = ref<ReturnType<typeof setTimeout> | null>(null);
|
||||
const pollRound = ref(0);
|
||||
// 新文件选择显式推进当前批次;恢复历史卡片不能覆盖它。
|
||||
const currentUploadBatchId = ref<string | null>(null);
|
||||
|
||||
const noticeAttachments = computed(() =>
|
||||
options.attachments.value.filter(
|
||||
@@ -256,12 +255,8 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
),
|
||||
);
|
||||
|
||||
const currentBatchAttachments = computed(() => {
|
||||
const batchId = currentUploadBatchId.value;
|
||||
return batchId
|
||||
? noticeAttachments.value.filter((item) => item.uploadBatchId === batchId)
|
||||
: noticeAttachments.value;
|
||||
});
|
||||
// 输入框就是本次提交边界;多次选择加入的附件必须一起校验和发送。
|
||||
const currentBatchAttachments = noticeAttachments;
|
||||
|
||||
const hasBlockingUploadOrParse = computed(() =>
|
||||
currentBatchAttachments.value.some((item) =>
|
||||
@@ -422,16 +417,19 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 将同一次选择的发货通知作为一个批次加入输入区,并并发完成资产上传与 Intake 创建。
|
||||
* 核心逻辑:先原子追加全部附件,确保 UI 立即展示完整批次;再并发预处理,单文件失败由 processSingleFile 独立记录。
|
||||
* @param files - 用户同一次选择的本地附件;所有文件共享同一个 uploadBatchId
|
||||
* @returns 全部附件的预处理任务结束后完成;单文件失败不会拒绝整个批次
|
||||
*/
|
||||
const enqueueNoticeFiles = async (files: File[]) => {
|
||||
// 同一次选择共享一个持久化批次;后续发送只会自动取这个最新批次。
|
||||
// 同一次选择共享批次 ID,用于上传幂等和状态关联;发送范围由当前输入框决定。
|
||||
const uploadBatchId = globalThis.crypto?.randomUUID?.()
|
||||
|| `${Date.now()}-${Math.random().toString(36).slice(2, 12)}`;
|
||||
currentUploadBatchId.value = uploadBatchId;
|
||||
for (const file of files) {
|
||||
const attachment = createPendingAttachment(file, uploadBatchId);
|
||||
options.attachments.value = [...options.attachments.value, attachment];
|
||||
await processSingleFile(attachment);
|
||||
}
|
||||
const batchAttachments = files.map((file) => createPendingAttachment(file, uploadBatchId));
|
||||
options.attachments.value = [...options.attachments.value, ...batchAttachments];
|
||||
await Promise.all(batchAttachments.map((attachment) => processSingleFile(attachment)));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -468,12 +466,15 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
};
|
||||
|
||||
const getParsedIntakeNos = () => {
|
||||
const eligible = noticeAttachments.value.filter(isOrderExtractionEligibleIntake);
|
||||
const currentBatchId = currentUploadBatchId.value
|
||||
|| [...noticeAttachments.value].reverse().find((item) => item.uploadBatchId)?.uploadBatchId;
|
||||
return eligible
|
||||
.filter((item) => item.uploadBatchId === currentBatchId)
|
||||
.map((item) => String(item.intakeNo));
|
||||
const seen = new Set<string>();
|
||||
return noticeAttachments.value
|
||||
.filter(isOrderExtractionEligibleIntake)
|
||||
.map((item) => String(item.intakeNo || '').trim().toUpperCase())
|
||||
.filter((intakeNo) => {
|
||||
if (!intakeNo || seen.has(intakeNo)) return false;
|
||||
seen.add(intakeNo);
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
||||
/** 点击发送后立即展示订单识别阶段,并启动 Intake 状态轮询。 */
|
||||
|
||||
@@ -803,6 +803,11 @@ export interface ShippingOrderExtractionDocumentResult {
|
||||
po_number?: string | null;
|
||||
line_count: number;
|
||||
profile?: ShippingOrderExtractionProfileSummary | null;
|
||||
/** 对外路由:profile_deterministic / generic_deterministic / llm_assisted_review / manual_review / rejected */
|
||||
route_type?: string | null;
|
||||
match_status?: string | null;
|
||||
/** 冻结来源:异型模板 / 通用规则 / 人工确认 */
|
||||
freeze_source?: string | null;
|
||||
email_supplement: ShippingOrderExtractionEmailSupplementResult;
|
||||
reason_code?: string | null;
|
||||
review_details?: Array<{ line_number: number; field_code?: string | null; reason_code: string }>;
|
||||
@@ -1016,7 +1021,8 @@ export type ShippingOrderReviewValueSource =
|
||||
| 'manual'
|
||||
| 'manual_override'
|
||||
| 'derived'
|
||||
| 'skipped';
|
||||
| 'skipped'
|
||||
| 'llm_suggested';
|
||||
|
||||
export interface ShippingOrderReviewDraftFieldMeta {
|
||||
value_source?: ShippingOrderReviewValueSource;
|
||||
@@ -1107,6 +1113,7 @@ export interface ShippingOrderReviewCase {
|
||||
build_eligibility?: ShippingOrderReviewBuildEligibility;
|
||||
} | null;
|
||||
available_actions: string[];
|
||||
llm_suggestions?: ShippingOrderReviewLlmSuggestion[];
|
||||
}
|
||||
|
||||
export interface ShippingOrderReviewConfirmResponse {
|
||||
@@ -1154,6 +1161,45 @@ export interface ShippingOrderReviewEvidence {
|
||||
source: string;
|
||||
}
|
||||
|
||||
/** Dify 最小证据建议 DTO;与后端 serialize_suggestion 对齐。 */
|
||||
export interface ShippingOrderReviewLlmSuggestion {
|
||||
suggestion_no: string;
|
||||
field_id: string;
|
||||
line_key?: string | null;
|
||||
scope: string;
|
||||
evidence_level: string;
|
||||
status: string;
|
||||
suggested_value?: unknown;
|
||||
validation_issues?: Array<{ code?: string; severity?: string }>;
|
||||
decision?: string | null;
|
||||
decision_reason?: string | null;
|
||||
decision_note?: string | null;
|
||||
draft_version_at_request?: number | null;
|
||||
created_at?: string | null;
|
||||
adjudicated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingOrderReviewLlmSuggestionRequest {
|
||||
field_id: string;
|
||||
line_key?: string | null;
|
||||
evidence_level?: string;
|
||||
issue_code?: string | null;
|
||||
allow_full_pdf?: boolean;
|
||||
}
|
||||
|
||||
export interface ShippingOrderReviewLlmAdjudicationPayload {
|
||||
decision: 'accept' | 'modify' | 'reject';
|
||||
expected_draft_version?: number;
|
||||
value?: unknown;
|
||||
reason?: string;
|
||||
note?: string;
|
||||
}
|
||||
|
||||
export interface ShippingOrderReviewLlmSuggestionResponse {
|
||||
suggestion: ShippingOrderReviewLlmSuggestion;
|
||||
case: ShippingOrderReviewCase;
|
||||
}
|
||||
|
||||
export interface ShippingNoticeDocumentResponse {
|
||||
id: number;
|
||||
document_type: string;
|
||||
@@ -1305,6 +1351,13 @@ export interface ShippingWorkflowItem {
|
||||
closed_at?: string | null;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
/**
|
||||
* 后端权威可用动作(cancel / reparse / enter_manual_review)。
|
||||
* 前端不得仅凭 lifecycle_status 自行推导重识别资格。
|
||||
*/
|
||||
available_actions?: string[];
|
||||
/** case_version=新建识别版本;failed_run_retry=原失败 Run 重试。 */
|
||||
reparse_kind?: 'case_version' | 'failed_run_retry' | string | null;
|
||||
/** 详情接口 include_events=true 时附带。 */
|
||||
events?: ShippingWorkflowEvent[];
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<!--
|
||||
用途:提供按 PDF 独立处理的建单前订单人工复核工作台(阶段 3:工作项版本中心)。
|
||||
features/chat/views/ShippingOrderReviewView.vue
|
||||
用途:提供按 PDF 独立处理的建单前订单人工复核工作台(版本中心 + AI 最小证据建议)。
|
||||
依赖:路由参数、复核 composable、ReviewDocumentPreview、ReviewVersionHistoryPanel、ReviewActionConfirmDialog、
|
||||
ReviewLineNoOverrideDialog、ReviewBuildEligibilityPanel、ReviewInventoryCandidatesPanel、
|
||||
ReviewWorkflowProgressPanel。
|
||||
ReviewWorkflowProgressPanel、ReviewLlmSuggestionPanel。
|
||||
逻辑:左 PDF 预览 + 中部订单编辑 + 右侧独立建单资格/库存候选门禁区(sticky);
|
||||
build_eligibility 驱动建单门禁与零候选时已启用库存源选择;破坏性操作二次确认;
|
||||
确认后挂载自动进度面板并轮询 Workflow Item;内部项次 line_no 编辑须经覆盖原因弹窗。
|
||||
底部操作窄屏纵向堆叠(异常操作在上、保存/确认建单在下且确认最后);
|
||||
初始加载失败提供就地重试(再次调用 load);
|
||||
确认后挂载自动进度面板并轮询 Workflow Item;内部项次 line_no 编辑须经覆盖原因弹窗;
|
||||
AI 建议请求/裁决走 useShippingOrderReview.requestSuggestion / decideSuggestion。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
@@ -26,6 +30,7 @@ import ReviewLineNoOverrideDialog, {
|
||||
type LineNoOverridePayload,
|
||||
} from '../components/shipping-review/ReviewLineNoOverrideDialog.vue';
|
||||
import ReviewVersionHistoryPanel from '../components/shipping-review/ReviewVersionHistoryPanel.vue';
|
||||
import ReviewLlmSuggestionPanel from '../components/shipping-review/ReviewLlmSuggestionPanel.vue';
|
||||
import ReviewWorkflowProgressPanel from '../components/shipping-review/ReviewWorkflowProgressPanel.vue';
|
||||
import { REVIEW_BUILD_ELIGIBILITY_BLOCKED, useShippingOrderReview } from '../shipping-review/useShippingOrderReview';
|
||||
import type {
|
||||
@@ -57,6 +62,10 @@ const {
|
||||
saveFailed,
|
||||
versionsLoading,
|
||||
evidence,
|
||||
llmSuggestions,
|
||||
suggestionLoading,
|
||||
focusedFieldId,
|
||||
focusedLineKey,
|
||||
previewUrl,
|
||||
load,
|
||||
selectCase,
|
||||
@@ -77,6 +86,9 @@ const {
|
||||
markQualityIssue,
|
||||
reparseDocument,
|
||||
uploadReplacement,
|
||||
focusSuggestionField,
|
||||
requestSuggestion,
|
||||
decideSuggestion,
|
||||
editable,
|
||||
showWorkflowProgress,
|
||||
workflowProgressPolling,
|
||||
@@ -87,8 +99,23 @@ const runNo = computed(() => String(route.query.run_no || route.params.runNo ||
|
||||
const agentId = computed(() => String(route.params.agentId || ''));
|
||||
const conversationId = computed(() => String(page.conversationId || route.query.conversation_id || ''));
|
||||
const itemNoFromQuery = computed(() => String(route.query.item_no || ''));
|
||||
|
||||
const reviewFocus = computed(() => String(route.query.focus || '').trim());
|
||||
const focusedEvidenceRef = ref<{ fieldId: string; lineIndex?: number } | null>(null);
|
||||
|
||||
watch(
|
||||
() => [evidence.value, reviewFocus.value] as const,
|
||||
([items, focus]) => {
|
||||
if (focus !== 'evidence' || !items?.length) return;
|
||||
const first = items.find((item) => item.bbox) || items[0];
|
||||
if (!first) return;
|
||||
focusedEvidenceRef.value = {
|
||||
fieldId: String(first.field_id || '').trim(),
|
||||
lineIndex: first.line_index == null ? undefined : Number(first.line_index),
|
||||
};
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* 当前用于 PDF 证据高亮的条目:明细同时按字段与行号匹配,避免多行同字段定位错位。
|
||||
*/
|
||||
@@ -115,6 +142,8 @@ const findFieldEvidence = (fieldId: string, lineIndex?: number) => (evidence.val
|
||||
const hasFieldEvidence = (fieldId: string, lineIndex?: number) => Boolean(findFieldEvidence(fieldId, lineIndex));
|
||||
/** 聚焦字段证据:有 bbox 时高亮,否则仅切至证据所在页。 */
|
||||
const focusFieldEvidence = (fieldId: string, lineIndex?: number) => {
|
||||
const lineKey = lineIndex != null ? activeCase.value?.draft?.lines?.[lineIndex]?.line_key : undefined;
|
||||
focusSuggestionField(String(fieldId || '').trim(), typeof lineKey === 'string' ? lineKey : null);
|
||||
focusedEvidenceRef.value = findFieldEvidence(fieldId, lineIndex)
|
||||
? { fieldId: String(fieldId || '').trim(), lineIndex }
|
||||
: null;
|
||||
@@ -143,6 +172,24 @@ const draftValue = (container: Record<string, unknown>, fieldId: string) => {
|
||||
return machineValueByIdFor(machine, fieldId);
|
||||
};
|
||||
|
||||
/**
|
||||
* 当前聚焦字段的草稿值,供 LLM 建议面板做三方对比。
|
||||
*/
|
||||
const focusedLlmDraftValue = computed(() => {
|
||||
const fieldId = String(focusedFieldId.value || '');
|
||||
if (!fieldId || !activeCase.value?.draft) return null;
|
||||
const lineKey = focusedLineKey.value;
|
||||
if (lineKey) {
|
||||
const line = (activeCase.value.draft.lines || []).find(
|
||||
(item) => String((item as { line_key?: string }).line_key || '') === String(lineKey),
|
||||
);
|
||||
if (!line) return null;
|
||||
return draftValue(line as Record<string, unknown>, fieldId);
|
||||
}
|
||||
const header = activeCase.value.draft.header_values as Record<string, unknown> | undefined;
|
||||
return header ? draftValue(header, fieldId) : null;
|
||||
});
|
||||
|
||||
/**
|
||||
* 读取投影字段元数据(值来源 / 锁定 / 覆盖原因)。
|
||||
* @param container - 表头或明细草稿容器
|
||||
@@ -543,6 +590,18 @@ const back = () => router.replace({
|
||||
),
|
||||
});
|
||||
|
||||
/**
|
||||
* 就地重试加载复核 Run/Case(不依赖整页刷新)。
|
||||
*/
|
||||
function retryLoad() {
|
||||
const nextRun = runNo.value;
|
||||
if (!nextRun) return;
|
||||
void load(nextRun, String(route.query.case || route.query.case_no || '') || undefined, {
|
||||
conversationId: conversationId.value || undefined,
|
||||
itemNo: itemNoFromQuery.value || undefined,
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
[runNo, () => String(route.query.case || route.query.case_no || ''), conversationId, itemNoFromQuery],
|
||||
([nextRun, nextCase, nextConversationId, nextItemNo]) => {
|
||||
@@ -718,8 +777,21 @@ watch(
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="p-8 text-sm text-slate-600 dark:text-slate-300">{{ t('chat.shippingOrderReview.loading') }}</div>
|
||||
<div v-else-if="loadFailed" class="m-4 rounded-lg border border-rose-300 bg-rose-50 p-4 text-sm text-rose-900 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-100">
|
||||
{{ t('chat.shippingOrderReview.unavailable') }}
|
||||
<div
|
||||
v-else-if="loadFailed"
|
||||
class="m-4 rounded-lg border border-rose-300 bg-rose-50 p-4 text-sm text-rose-900 dark:border-rose-800 dark:bg-rose-950/30 dark:text-rose-100"
|
||||
data-testid="shipping-order-review-load-failed"
|
||||
>
|
||||
<p>{{ t('chat.shippingOrderReview.unavailable') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-1 rounded border border-current/30 px-3 py-1.5 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
data-testid="shipping-order-review-retry-load"
|
||||
@click="retryLoad"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ t('chat.shippingOrderReview.retryLoad') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1 overflow-y-auto">
|
||||
<section class="p-4 lg:p-5">
|
||||
@@ -794,6 +866,20 @@ watch(
|
||||
<div v-for="issue in activeCase.draft.issues" :key="`${issue.code}-${issue.severity}`" class="mt-1">{{ issue.code }}</div>
|
||||
</div>
|
||||
|
||||
<ReviewLlmSuggestionPanel
|
||||
:active-case="activeCase"
|
||||
:evidence="evidence"
|
||||
:editable="editable"
|
||||
:saving="saving"
|
||||
:suggestions="llmSuggestions"
|
||||
:suggestion-loading="suggestionLoading"
|
||||
:focused-field-id="focusedFieldId"
|
||||
:focused-line-key="focusedLineKey"
|
||||
:draft-value="focusedLlmDraftValue"
|
||||
@request-suggestion="requestSuggestion()"
|
||||
@adjudicate="({ suggestion, body }) => decideSuggestion(suggestion.suggestion_no, body)"
|
||||
/>
|
||||
|
||||
<section class="rounded-xl border border-slate-200 bg-white p-4 shadow-sm dark:border-slate-800 dark:bg-slate-900">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
@@ -983,35 +1069,68 @@ watch(
|
||||
|
||||
<footer
|
||||
v-if="activeCase?.draft && !isReadOnly"
|
||||
class="flex shrink-0 flex-wrap items-center justify-end gap-2 border-t border-slate-200 bg-white p-3 dark:border-slate-800 dark:bg-slate-900"
|
||||
class="flex shrink-0 flex-col gap-3 border-t border-slate-200 bg-white p-3 sm:flex-row sm:items-center sm:justify-between dark:border-slate-800 dark:bg-slate-900"
|
||||
data-testid="review-footer-actions"
|
||||
>
|
||||
<button v-if="activeCase?.available_actions.includes('mark_non_order')" type="button" :disabled="saving" class="rounded border px-3 py-2 text-sm disabled:opacity-50" @click="openActionDialog('non_order')">
|
||||
{{ t('chat.shippingOrderReview.markNonOrder') }}
|
||||
</button>
|
||||
<button v-if="activeCase?.available_actions.includes('mark_quality_issue')" type="button" :disabled="saving" class="rounded border px-3 py-2 text-sm disabled:opacity-50" @click="openActionDialog('quality_issue')">
|
||||
{{ t('chat.shippingOrderReview.markQualityIssue') }}
|
||||
</button>
|
||||
<button v-if="activeCase?.available_actions.includes('reparse')" type="button" :disabled="saving" class="inline-flex items-center gap-1 rounded border px-3 py-2 text-sm disabled:opacity-50" @click="openActionDialog('reparse')">
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.reparse') }}
|
||||
</button>
|
||||
<label v-if="activeCase?.available_actions.includes('mark_quality_issue')" class="cursor-pointer rounded border px-3 py-2 text-sm">
|
||||
<input class="sr-only" type="file" accept="application/pdf,.pdf" :disabled="saving" @change="selectReplacement">
|
||||
{{ t('chat.shippingOrderReview.uploadReplacement') }}
|
||||
</label>
|
||||
<button v-if="activeCase?.available_actions.includes('validate')" type="button" :disabled="saving" class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50" @click="reportSave(() => validate())">
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveNow') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('confirm')"
|
||||
type="button"
|
||||
:disabled="saving || !canConfirmBuild"
|
||||
class="rounded bg-emerald-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
data-testid="review-confirm-create"
|
||||
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
|
||||
@click="openActionDialog('confirm')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.confirmCreate') }}
|
||||
</button>
|
||||
<!-- 窄屏:异常操作在上;主操作(含确认建单)固定在下且确认按钮为组内最后一项 -->
|
||||
<div class="order-1 flex flex-wrap items-center gap-2 sm:order-1">
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('mark_non_order')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="rounded border border-rose-200 px-3 py-2 text-sm text-rose-700 hover:bg-rose-50 disabled:opacity-50 dark:border-rose-900 dark:text-rose-300 dark:hover:bg-rose-950/40"
|
||||
@click="openActionDialog('non_order')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.markNonOrder') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('mark_quality_issue')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="rounded border border-amber-200 px-3 py-2 text-sm text-amber-800 hover:bg-amber-50 disabled:opacity-50 dark:border-amber-900 dark:text-amber-200 dark:hover:bg-amber-950/40"
|
||||
@click="openActionDialog('quality_issue')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.markQualityIssue') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('reparse')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center gap-1 rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
@click="openActionDialog('reparse')"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.reparse') }}
|
||||
</button>
|
||||
<label
|
||||
v-if="activeCase?.available_actions.includes('mark_quality_issue')"
|
||||
class="cursor-pointer rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
>
|
||||
<input class="sr-only" type="file" accept="application/pdf,.pdf" :disabled="saving" @change="selectReplacement">
|
||||
{{ t('chat.shippingOrderReview.uploadReplacement') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="order-2 flex flex-wrap items-center justify-end gap-2 sm:order-2">
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('validate')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
@click="reportSave(() => validate())"
|
||||
>
|
||||
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveNow') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="activeCase?.available_actions.includes('confirm')"
|
||||
type="button"
|
||||
:disabled="saving || !canConfirmBuild"
|
||||
class="rounded bg-emerald-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
data-testid="review-confirm-create"
|
||||
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
|
||||
@click="openActionDialog('confirm')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.confirmCreate') }}
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<ReviewActionConfirmDialog
|
||||
|
||||
@@ -2852,6 +2852,13 @@
|
||||
"uploadNewSampleHint": "The system parses it automatically and selects it when ready.",
|
||||
"uploading": "Uploading",
|
||||
"sampleParsing": "Parsing now. This file will be selected automatically when ready.",
|
||||
"sampleStatus": {
|
||||
"uploading": "Uploading the file. Keep this page open.",
|
||||
"queued": "The file is uploaded and waiting for the parsing job to start.",
|
||||
"parsing": "Parsing the document and layout. It will be added to the list and selected automatically.",
|
||||
"syncing": "Parsing is complete. Synchronizing the sample list and selecting it automatically."
|
||||
},
|
||||
"refreshSamples": "Refresh sample list now",
|
||||
"sampleParseFailed": "Parsing failed. Upload again or choose an existing sample.",
|
||||
"sampleLayoutCoordinatesMissing": "Template layout parsing failed: table-cell coordinates are missing. Use another sample or check MinerU output.",
|
||||
"sampleLayoutSnapshotTooLarge": "Template layout parsing failed: the snapshot exceeds the size limit. Use a shorter or simpler sample.",
|
||||
@@ -3162,6 +3169,13 @@
|
||||
"regionKindTitle": "Region kind",
|
||||
"regionFieldCodeTitle": "Field code",
|
||||
"regionPageTitle": "Page",
|
||||
"recognizedValueTitle": "Recognized value",
|
||||
"configuredValueTitle": "Configured value",
|
||||
"matchResultTitle": "Match result",
|
||||
"matchResultMatched": "Matched",
|
||||
"matchResultMismatched": "Mismatch",
|
||||
"regionDiagnosticsLoading": "Reading frozen recognized values...",
|
||||
"regionDiagnosticsLoadFailed": "Failed to load frozen recognized values",
|
||||
"sampleSummaryTitle": "Sample summary",
|
||||
"annotationCount": "Annotation samples",
|
||||
"trainingCount": "Training samples",
|
||||
@@ -3352,6 +3366,8 @@
|
||||
"openCanvas": "Create draft and open canvas",
|
||||
"loadingPage": "Loading page...",
|
||||
"canvasZoom": "Page zoom",
|
||||
"readonlyCanvasAriaLabel": "Document readonly canvas",
|
||||
"annotationCanvasAriaLabel": "Document annotation canvas",
|
||||
"zoomOut": "Zoom out",
|
||||
"zoomIn": "Zoom in",
|
||||
"fitPage": "Fit page",
|
||||
@@ -3407,6 +3423,23 @@
|
||||
"review": "Review",
|
||||
"noIssues": "No blocking configuration issue.",
|
||||
"currentConfiguration": "Current configuration",
|
||||
"tableRegionSettings": "Line table settings",
|
||||
"rowReconstructionMode": "Line reconstruction mode",
|
||||
"rowReconstructionModes": {
|
||||
"fixedSubrows": "Fixed subrows (default)",
|
||||
"adaptiveRecordColumns": "Adaptive column reconstruction"
|
||||
},
|
||||
"rowReconstructionHints": {
|
||||
"fixed_subrows": "Use when every detail record has a fixed number of physical rows.",
|
||||
"adaptive_record_columns": "Use when columns stay stable but fields may appear on different physical rows; complete an independent blind test first."
|
||||
},
|
||||
"tableRegionPageScope": "Page scope",
|
||||
"tableRegionPageScopes": {
|
||||
"exactPage": "Current page only",
|
||||
"firstPage": "First page only",
|
||||
"allPages": "All pages",
|
||||
"continuationPages": "Continuation pages only"
|
||||
},
|
||||
"undo": "Undo",
|
||||
"redo": "Redo",
|
||||
"header": "Header",
|
||||
|
||||
@@ -295,6 +295,7 @@
|
||||
"finished": "Finished {time}"
|
||||
},
|
||||
"shippingOrderExtractionUnknownDocument": "Unnamed PDF",
|
||||
"shippingOrderExtractionMoreDetails": "Audit and supplement details",
|
||||
"shippingOrderExtractionUnread": "{count} order identification result(s) need review",
|
||||
"shippingOrderExtractionActivity": {
|
||||
"plan_created": "The extraction plan is ready and the first wave is being prepared.",
|
||||
@@ -389,6 +390,18 @@
|
||||
"unknown": "Line-item field"
|
||||
},
|
||||
"shippingOrderExtractionProfileSummary": "Template: {name} V{version}",
|
||||
"shippingOrderExtractionRouteType": {
|
||||
"profile_deterministic": "Specialized template parse",
|
||||
"generic_deterministic": "Generic rule-based parse",
|
||||
"llm_assisted_review": "AI-assisted review",
|
||||
"manual_review": "Manual review",
|
||||
"rejected": "Rejected"
|
||||
},
|
||||
"shippingOrderExtractionFreezeSource": {
|
||||
"profile_deterministic": "Auto-freeze source: template",
|
||||
"generic_deterministic": "Auto-freeze source: generic rules",
|
||||
"manual_confirmation": "Freeze source: manual confirmation"
|
||||
},
|
||||
"shippingOrderExtractionPlanSummary": "This run planned {groups} order group(s) from {total} attachment(s). The first wave may process up to {attachments} attachment(s) with concurrency {concurrency}.",
|
||||
"shippingOrderExtractionPlanSelected": "{count} attachment(s) selected",
|
||||
"shippingOrderExtractionPlanPendingExpansion": "{count} attachment(s) queued for later waves",
|
||||
@@ -406,6 +419,9 @@
|
||||
"shippingOrderExtractionTechnicalFailureCode": "The system could not complete processing",
|
||||
"shippingOrderExtractionTechnicalFailureCodes": "Some attachments could not be completed",
|
||||
"shippingOrderExtractionTechnicalFailureUserHint": "The system could not complete processing. Please try again later.",
|
||||
"shippingOrderExtractionReasonUnknown": "There is a processing reason that needs attention",
|
||||
"shippingOrderExtractionReasonTechDetails": "Technical details",
|
||||
"shippingOrderExtractionDetailsRetry": "Retry loading",
|
||||
"shippingOrderExtractionRetryStatus": {
|
||||
"not_started": "not started",
|
||||
"running": "processing",
|
||||
@@ -1402,6 +1418,7 @@
|
||||
"readOnly": "Read-only preview",
|
||||
"loading": "Loading review results...",
|
||||
"unavailable": "Review results are unavailable. Please try again later.",
|
||||
"retryLoad": "Retry loading",
|
||||
"documentNavigation": "PDF navigation",
|
||||
"documents": "PDF documents",
|
||||
"unnamedDocument": "Unnamed PDF",
|
||||
@@ -1441,7 +1458,54 @@
|
||||
"manual": "Manual edit",
|
||||
"manual_override": "Manual override",
|
||||
"derived": "Derived",
|
||||
"skipped": "Derivation skipped"
|
||||
"skipped": "Derivation skipped",
|
||||
"llm_suggested": "AI suggested (pending)"
|
||||
},
|
||||
"llmSuggestion": {
|
||||
"title": "AI-assisted suggestion",
|
||||
"panelTitle": "AI-assisted suggestion",
|
||||
"panelHint": "Only minimal frozen evidence is sent; orders are never auto-frozen.",
|
||||
"request": "Request AI suggestion",
|
||||
"requesting": "Requesting…",
|
||||
"compare": "Compare suggestion",
|
||||
"scope": "Evidence scope: {level}",
|
||||
"evidenceLevel": {
|
||||
"L1_field": "Field text",
|
||||
"L2_table": "Containing table",
|
||||
"L3_page": "Containing page",
|
||||
"L4_pdf": "Full PDF (authorized)"
|
||||
},
|
||||
"review": "Review",
|
||||
"empty": "No AI suggestions yet. Select a field, then request.",
|
||||
"dialogTitle": "AI-assisted suggestion",
|
||||
"dialogHint": "Suggested values must appear verbatim in document evidence.",
|
||||
"currentDraft": "Current draft",
|
||||
"aiSuggestion": "AI suggestion",
|
||||
"sourceEvidence": "Source evidence",
|
||||
"verbatimOk": "Verbatim match OK",
|
||||
"verbatimFailed": "No verbatim match in evidence",
|
||||
"evidenceAtCell": "PDF page {page} · {cell}",
|
||||
"noEvidenceCoords": "No reliable coordinates; quote only",
|
||||
"status": {
|
||||
"idle": "Idle",
|
||||
"pending": "Pending",
|
||||
"validated": "Validated",
|
||||
"accepted": "Accepted",
|
||||
"modified": "Modified",
|
||||
"rejected": "Rejected",
|
||||
"failed": "Unavailable"
|
||||
},
|
||||
"decisions": {
|
||||
"accept": "Accept",
|
||||
"modify": "Modify & accept",
|
||||
"reject": "Reject"
|
||||
},
|
||||
"modifiedValue": "Modified value",
|
||||
"reason": "Reason",
|
||||
"reasonRequired": "Reason is required for modify or reject",
|
||||
"noteOptional": "Note (optional)",
|
||||
"cancel": "Cancel",
|
||||
"submit": "Submit decision"
|
||||
},
|
||||
"lineNoOverrideDialog": {
|
||||
"title": "Override internal line no.",
|
||||
@@ -1740,7 +1804,8 @@
|
||||
"refresh": "Refresh",
|
||||
"viewProgress": "View progress",
|
||||
"cancelFile": "Cancel this file",
|
||||
"reparse": "Retry / re-identify"
|
||||
"reparse": "Re-identify",
|
||||
"retryFailedRun": "Retry failed run"
|
||||
},
|
||||
"reasonDialog": {
|
||||
"cancelTitle": "Cancel this file",
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
"AGENT.ADMIN_SCOPE_INVALID": "The application management tab parameter is invalid.",
|
||||
"AGENT.INTERNAL_EXECUTOR_USER_ACCESS_FORBIDDEN": "Internal executors cannot be displayed, assigned, or accessed through user-facing APIs.",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_NOT_RETRYABLE": "Only failed order identification runs can be retried.",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_REASON_REQUIRED": "A reason is required to re-identify. Please provide one and try again.",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_NOT_ALLOWED": "Re-identify is not allowed in the current status. Open manual review, or retry only after the run has failed.",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_CASE_REQUIRED": "This file has no review case yet, so a new identification version cannot be created. Finish extraction to enter review, or retry only after the run has failed.",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_SOURCE_INVALID": "The linked extraction run is unavailable. Refresh and try again, or contact an administrator.",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_SNAPSHOT_OBSOLETE": "This run uses an obsolete input contract and cannot be retried. Send the email and attachments again to start a new run.",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_CONVERSATION_ACTIVE": "An order identification run is already processing in this conversation. Please wait for it to finish.",
|
||||
"SHIPPING_NOTICE.CANCEL_FORBIDDEN": "You are not allowed to cancel this order identification run.",
|
||||
|
||||
@@ -2720,6 +2720,13 @@
|
||||
"uploadNewSampleHint": "ระบบจะแยกข้อมูลอัตโนมัติและเลือกไฟล์นี้เมื่อพร้อม",
|
||||
"uploading": "กำลังอัปโหลด",
|
||||
"sampleParsing": "กำลังแยกข้อมูล และจะเลือกไฟล์นี้อัตโนมัติเมื่อพร้อม",
|
||||
"sampleStatus": {
|
||||
"uploading": "กำลังอัปโหลดไฟล์ โปรดอย่าปิดหน้านี้",
|
||||
"queued": "อัปโหลดไฟล์แล้ว และกำลังรอให้งานแยกข้อมูลเริ่มทำงาน",
|
||||
"parsing": "กำลังแยกข้อมูลเอกสารและเลย์เอาต์ เมื่อเสร็จแล้วจะเพิ่มในรายการและเลือกให้อัตโนมัติ",
|
||||
"syncing": "แยกข้อมูลเสร็จแล้ว กำลังซิงโครไนซ์รายการตัวอย่างและเลือกให้อัตโนมัติ"
|
||||
},
|
||||
"refreshSamples": "รีเฟรชรายการตัวอย่างทันที",
|
||||
"sampleParseFailed": "แยกข้อมูลไม่สำเร็จ โปรดอัปโหลดใหม่หรือเลือกตัวอย่างเดิม",
|
||||
"sampleLayoutCoordinatesMissing": "การแยกเลย์เอาต์เทมเพลตล้มเหลว: ไม่มีพิกัดเซลล์ตาราง โปรดใช้ตัวอย่างอื่นหรือตรวจสอบผลลัพธ์ MinerU",
|
||||
"sampleLayoutSnapshotTooLarge": "การแยกเลย์เอาต์เทมเพลตล้มเหลว: snapshot มีขนาดเกินขีดจำกัด โปรดใช้ตัวอย่างที่สั้นหรือเรียบง่ายกว่า",
|
||||
@@ -3030,6 +3037,13 @@
|
||||
"regionKindTitle": "ประเภทพื้นที่",
|
||||
"regionFieldCodeTitle": "รหัสฟิลด์",
|
||||
"regionPageTitle": "หน้า",
|
||||
"recognizedValueTitle": "ค่าที่อ่านได้จริง",
|
||||
"configuredValueTitle": "ค่าที่ตั้งค่าในเทมเพลต",
|
||||
"matchResultTitle": "ผลการจับคู่",
|
||||
"matchResultMatched": "จับคู่สำเร็จ",
|
||||
"matchResultMismatched": "ไม่ตรงกัน",
|
||||
"regionDiagnosticsLoading": "กำลังอ่านค่าที่รู้จำจากหลักฐานที่แช่แข็ง...",
|
||||
"regionDiagnosticsLoadFailed": "โหลดค่าที่รู้จำจากหลักฐานที่แช่แข็งไม่สำเร็จ",
|
||||
"sampleSummaryTitle": "สรุปตัวอย่าง",
|
||||
"annotationCount": "ตัวอย่างการทำเครื่องหมาย",
|
||||
"trainingCount": "ตัวอย่างการฝึก",
|
||||
@@ -3220,6 +3234,8 @@
|
||||
"openCanvas": "สร้างฉบับร่างและเปิดผืนงาน",
|
||||
"loadingPage": "กำลังโหลดหน้า...",
|
||||
"canvasZoom": "การซูมหน้า",
|
||||
"readonlyCanvasAriaLabel": "ผืนงานเอกสารแบบอ่านอย่างเดียว",
|
||||
"annotationCanvasAriaLabel": "ผืนงานทำเครื่องหมายเอกสาร",
|
||||
"zoomOut": "ย่อ",
|
||||
"zoomIn": "ขยาย",
|
||||
"fitPage": "พอดีหน้า",
|
||||
@@ -3275,6 +3291,23 @@
|
||||
"review": "ตรวจทาน",
|
||||
"noIssues": "ไม่มีปัญหาการตั้งค่าที่ขัดขวาง",
|
||||
"currentConfiguration": "การตั้งค่าปัจจุบัน",
|
||||
"tableRegionSettings": "การตั้งค่าตารางรายละเอียด",
|
||||
"rowReconstructionMode": "โหมดสร้างแถวรายละเอียดใหม่",
|
||||
"rowReconstructionModes": {
|
||||
"fixedSubrows": "แถวย่อยคงที่ (ค่าเริ่มต้น)",
|
||||
"adaptiveRecordColumns": "สร้างใหม่ตามคอลัมน์แบบปรับตัว"
|
||||
},
|
||||
"rowReconstructionHints": {
|
||||
"fixed_subrows": "ใช้เมื่อแต่ละรายการมีจำนวนแถวจริงคงที่",
|
||||
"adaptive_record_columns": "ใช้เมื่อคอลัมน์คงที่แต่ฟิลด์อาจอยู่คนละแถวจริง ควรทำ blind test อิสระก่อน"
|
||||
},
|
||||
"tableRegionPageScope": "ขอบเขตหน้า",
|
||||
"tableRegionPageScopes": {
|
||||
"exactPage": "เฉพาะหน้าปัจจุบัน",
|
||||
"firstPage": "เฉพาะหน้าแรก",
|
||||
"allPages": "ทุกหน้า",
|
||||
"continuationPages": "เฉพาะหน้าต่อเนื่อง"
|
||||
},
|
||||
"undo": "เลิกทำ",
|
||||
"redo": "ทำซ้ำ",
|
||||
"header": "หัวตาราง",
|
||||
|
||||
@@ -295,6 +295,7 @@
|
||||
"finished": "เสร็จเมื่อ {time}"
|
||||
},
|
||||
"shippingOrderExtractionUnknownDocument": "PDF ไม่มีชื่อ",
|
||||
"shippingOrderExtractionMoreDetails": "ดูรายละเอียดการตรวจสอบและข้อมูลเสริม",
|
||||
"shippingOrderExtractionUnread": "มีผลการระบุคำสั่งซื้อ {count} รายการรอตรวจสอบ",
|
||||
"shippingOrderExtractionActivity": {
|
||||
"plan_created": "สร้างแผนการระบุแล้ว กำลังเตรียมไฟล์แนบรอบแรก",
|
||||
@@ -389,6 +390,18 @@
|
||||
"unknown": "ฟิลด์รายการ"
|
||||
},
|
||||
"shippingOrderExtractionProfileSummary": "เทมเพลต: {name} V{version}",
|
||||
"shippingOrderExtractionRouteType": {
|
||||
"profile_deterministic": "แยกวิเคราะห์ด้วยเทมเพลตพิเศษ",
|
||||
"generic_deterministic": "แยกวิเคราะห์ด้วยกฎทั่วไป",
|
||||
"llm_assisted_review": "ตรวจทานด้วย AI",
|
||||
"manual_review": "ตรวจทานด้วยตนเอง",
|
||||
"rejected": "ปฏิเสธแล้ว"
|
||||
},
|
||||
"shippingOrderExtractionFreezeSource": {
|
||||
"profile_deterministic": "แหล่งตรึงอัตโนมัติ: เทมเพลต",
|
||||
"generic_deterministic": "แหล่งตรึงอัตโนมัติ: กฎทั่วไป",
|
||||
"manual_confirmation": "แหล่งตรึง: ยืนยันด้วยตนเอง"
|
||||
},
|
||||
"shippingOrderExtractionPlanSummary": "รอบนี้วางแผน {groups} กลุ่มคำสั่งซื้อจากไฟล์แนบ {total} ไฟล์ โดยรอบแรกจะประมวลผลได้สูงสุด {attachments} ไฟล์ พร้อมกัน {concurrency} ไฟล์",
|
||||
"shippingOrderExtractionPlanSelected": "เลือกแล้ว {count} ไฟล์",
|
||||
"shippingOrderExtractionPlanPendingExpansion": "รอขยายรอบถัดไป {count} ไฟล์",
|
||||
@@ -406,6 +419,9 @@
|
||||
"shippingOrderExtractionTechnicalFailureCode": "ระบบไม่สามารถดำเนินการให้เสร็จสิ้นได้",
|
||||
"shippingOrderExtractionTechnicalFailureCodes": "ไฟล์แนบบางรายการดำเนินการไม่สำเร็จ",
|
||||
"shippingOrderExtractionTechnicalFailureUserHint": "ระบบไม่สามารถดำเนินการให้เสร็จสิ้นได้ โปรดลองอีกครั้งภายหลัง",
|
||||
"shippingOrderExtractionReasonUnknown": "มีสาเหตุการประมวลผลที่ต้องตรวจสอบ",
|
||||
"shippingOrderExtractionReasonTechDetails": "รายละเอียดทางเทคนิค",
|
||||
"shippingOrderExtractionDetailsRetry": "ลองโหลดอีกครั้ง",
|
||||
"shippingOrderExtractionRetryStatus": {
|
||||
"not_started": "ยังไม่เริ่ม",
|
||||
"running": "กำลังประมวลผล",
|
||||
@@ -1402,6 +1418,7 @@
|
||||
"readOnly": "ดูอย่างเดียว",
|
||||
"loading": "กำลังโหลดผลการตรวจทาน...",
|
||||
"unavailable": "ยังโหลดผลการตรวจทานไม่ได้ โปรดลองอีกครั้งภายหลัง",
|
||||
"retryLoad": "ลองโหลดอีกครั้ง",
|
||||
"documentNavigation": "รายการ PDF",
|
||||
"documents": "ไฟล์ PDF",
|
||||
"unnamedDocument": "PDF ไม่มีชื่อ",
|
||||
@@ -1441,7 +1458,54 @@
|
||||
"manual": "แก้ไขโดยผู้ใช้",
|
||||
"manual_override": "เขียนทับโดยผู้ใช้",
|
||||
"derived": "อนุมานจากกฎ",
|
||||
"skipped": "ข้ามการอนุมาน"
|
||||
"skipped": "ข้ามการอนุมาน",
|
||||
"llm_suggested": "AI แนะนำ (รอยืนยัน)"
|
||||
},
|
||||
"llmSuggestion": {
|
||||
"title": "คำแนะนำจาก AI",
|
||||
"panelTitle": "คำแนะนำจาก AI",
|
||||
"panelHint": "ส่งเฉพาะหลักฐานขั้นต่ำที่แช่แข็งแล้ว ไม่มีการแช่แข็งคำสั่งซื้ออัตโนมัติ",
|
||||
"request": "ขอคำแนะนำ AI",
|
||||
"requesting": "กำลังขอ…",
|
||||
"compare": "เปรียบเทียบคำแนะนำ",
|
||||
"scope": "ขอบเขตหลักฐาน: {level}",
|
||||
"evidenceLevel": {
|
||||
"L1_field": "ข้อความฟิลด์",
|
||||
"L2_table": "ตารางที่เกี่ยวข้อง",
|
||||
"L3_page": "หน้าที่เกี่ยวข้อง",
|
||||
"L4_pdf": "PDF ทั้งฉบับ (ต้องได้รับอนุญาต)"
|
||||
},
|
||||
"review": "พิจารณา",
|
||||
"empty": "ยังไม่มีคำแนะนำ AI เลือกฟิลด์แล้วกดขอ",
|
||||
"dialogTitle": "คำแนะนำจาก AI",
|
||||
"dialogHint": "ค่าที่แนะนำต้องปรากฏตรงตามหลักฐานในเอกสาร",
|
||||
"currentDraft": "แบบร่างปัจจุบัน",
|
||||
"aiSuggestion": "คำแนะนำ AI",
|
||||
"sourceEvidence": "หลักฐานต้นฉบับ",
|
||||
"verbatimOk": "ตรงตามหลักฐาน",
|
||||
"verbatimFailed": "ไม่พบค่าตรงตามหลักฐาน",
|
||||
"evidenceAtCell": "PDF หน้า {page} · {cell}",
|
||||
"noEvidenceCoords": "ไม่มีพิกัดที่เชื่อถือได้ แสดงเฉพาะข้อความอ้างอิง",
|
||||
"status": {
|
||||
"idle": "ยังไม่ขอ",
|
||||
"pending": "กำลังขอ",
|
||||
"validated": "ตรวจแล้ว",
|
||||
"accepted": "ยอมรับแล้ว",
|
||||
"modified": "แก้ไขแล้ว",
|
||||
"rejected": "ปฏิเสธแล้ว",
|
||||
"failed": "ใช้ไม่ได้"
|
||||
},
|
||||
"decisions": {
|
||||
"accept": "ยอมรับ",
|
||||
"modify": "แก้ไขแล้วยอมรับ",
|
||||
"reject": "ปฏิเสธ"
|
||||
},
|
||||
"modifiedValue": "ค่าที่แก้ไข",
|
||||
"reason": "เหตุผล",
|
||||
"reasonRequired": "ต้องระบุเหตุผลเมื่อแก้ไขหรือปฏิเสธ",
|
||||
"noteOptional": "หมายเหตุ (ไม่บังคับ)",
|
||||
"cancel": "ยกเลิก",
|
||||
"submit": "ส่งการตัดสินใจ"
|
||||
},
|
||||
"lineNoOverrideDialog": {
|
||||
"title": "เขียนทับเลขรายการภายใน",
|
||||
@@ -1740,7 +1804,8 @@
|
||||
"refresh": "รีเฟรช",
|
||||
"viewProgress": "ดูความคืบหน้า",
|
||||
"cancelFile": "ยกเลิกไฟล์นี้",
|
||||
"reparse": "ลองใหม่ / ระบุใหม่"
|
||||
"reparse": "ระบุใหม่",
|
||||
"retryFailedRun": "ลองรันที่ล้มเหลวอีกครั้ง"
|
||||
},
|
||||
"reasonDialog": {
|
||||
"cancelTitle": "ยกเลิกไฟล์นี้",
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
"AGENT.ADMIN_SCOPE_INVALID": "พารามิเตอร์แท็บการจัดการแอปพลิเคชันไม่ถูกต้อง",
|
||||
"AGENT.INTERNAL_EXECUTOR_USER_ACCESS_FORBIDDEN": "ไม่สามารถแสดง มอบสิทธิ์ หรือเข้าถึงตัวดำเนินการภายในผ่าน API สำหรับผู้ใช้ได้",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_NOT_RETRYABLE": "ลองระบุใหม่ได้เฉพาะงานระบุคำสั่งซื้อที่ล้มเหลวเท่านั้น",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_REASON_REQUIRED": "ต้องระบุเหตุผลในการระบุใหม่ กรุณาเติมแล้วลองอีกครั้ง",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_NOT_ALLOWED": "สถานะปัจจุบันไม่อนุญาตให้ระบุใหม่ กรุณาเข้าสู่การตรวจทานด้วยตนเอง หรือรอให้การระบุล้มเหลวก่อนแล้วค่อยลองใหม่",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_CASE_REQUIRED": "ไฟล์นี้ยังไม่มีเคสตรวจทาน จึงสร้างเวอร์ชันระบุใหม่ไม่ได้ กรุณาให้การระบุเสร็จแล้วเข้าสู่การตรวจทาน หรือลองใหม่ได้เฉพาะเมื่อรันล้มเหลว",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_SOURCE_INVALID": "งานระบุที่เชื่อมโยงใช้งานไม่ได้ กรุณารีเฟรชแล้วลองใหม่ หรือติดต่อผู้ดูแล",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_SNAPSHOT_OBSOLETE": "งานนี้ใช้สัญญาข้อมูลนำเข้าเวอร์ชันเก่าและไม่สามารถลองใหม่ได้ โปรดส่งอีเมลและไฟล์แนบอีกครั้งเพื่อเริ่มงานใหม่",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_CONVERSATION_ACTIVE": "มีงานระบุคำสั่งซื้อกำลังดำเนินการอยู่ในบทสนทนานี้ โปรดรอให้เสร็จสิ้นก่อน",
|
||||
"SHIPPING_NOTICE.CANCEL_FORBIDDEN": "คุณไม่มีสิทธิ์ยกเลิกงานระบุคำสั่งซื้อนี้",
|
||||
|
||||
@@ -2959,6 +2959,13 @@
|
||||
"uploadNewSampleHint": "上传后系统会自动解析;完成后自动选中该文件。",
|
||||
"uploading": "正在上传",
|
||||
"sampleParsing": "正在解析,完成后会自动选中。",
|
||||
"sampleStatus": {
|
||||
"uploading": "文件正在上传,请勿关闭当前页面。",
|
||||
"queued": "文件已上传,正在等待解析任务启动。",
|
||||
"parsing": "正在解析文档与版面,完成后会自动加入下方列表并选中。",
|
||||
"syncing": "解析已完成,正在同步样本列表并自动选中。"
|
||||
},
|
||||
"refreshSamples": "立即刷新样本列表",
|
||||
"sampleParseFailed": "解析失败,请重新上传或选择已有样本。",
|
||||
"sampleLayoutCoordinatesMissing": "模板布局解析失败:未取得表格单元格坐标,请更换样本或检查 MinerU 输出。",
|
||||
"sampleLayoutSnapshotTooLarge": "模板布局解析失败:解析快照超出大小限制,请使用页数更少或内容更精简的样本。",
|
||||
@@ -3268,6 +3275,13 @@
|
||||
"regionKindTitle": "区域类型",
|
||||
"regionFieldCodeTitle": "字段编码",
|
||||
"regionPageTitle": "所属页",
|
||||
"recognizedValueTitle": "实际识别值",
|
||||
"configuredValueTitle": "模板配置值",
|
||||
"matchResultTitle": "匹配结果",
|
||||
"matchResultMatched": "匹配成功",
|
||||
"matchResultMismatched": "不匹配",
|
||||
"regionDiagnosticsLoading": "正在读取冻结识别值...",
|
||||
"regionDiagnosticsLoadFailed": "冻结识别值加载失败",
|
||||
"sampleSummaryTitle": "样本摘要",
|
||||
"annotationCount": "标注样本",
|
||||
"trainingCount": "训练样本",
|
||||
@@ -3458,6 +3472,8 @@
|
||||
"openCanvas": "创建草稿并打开画布",
|
||||
"loadingPage": "正在加载页面…",
|
||||
"canvasZoom": "页面缩放",
|
||||
"readonlyCanvasAriaLabel": "文档只读画布",
|
||||
"annotationCanvasAriaLabel": "文档标注画布",
|
||||
"zoomOut": "缩小",
|
||||
"zoomIn": "放大",
|
||||
"fitPage": "适合页面",
|
||||
@@ -3513,6 +3529,23 @@
|
||||
"review": "复核",
|
||||
"noIssues": "没有阻断配置问题。",
|
||||
"currentConfiguration": "当前配置",
|
||||
"tableRegionSettings": "明细表区设置",
|
||||
"rowReconstructionMode": "明细行重建方式",
|
||||
"rowReconstructionModes": {
|
||||
"fixedSubrows": "固定子行(默认)",
|
||||
"adaptiveRecordColumns": "自适应列重建"
|
||||
},
|
||||
"rowReconstructionHints": {
|
||||
"fixed_subrows": "适用于每条明细的物理行数量固定的版式。",
|
||||
"adaptive_record_columns": "适用于列位置稳定、字段可能分散在不同物理行的版式;请先完成独立盲测。"
|
||||
},
|
||||
"tableRegionPageScope": "适用页范围",
|
||||
"tableRegionPageScopes": {
|
||||
"exactPage": "仅当前页",
|
||||
"firstPage": "仅第一页",
|
||||
"allPages": "所有页面",
|
||||
"continuationPages": "仅续页"
|
||||
},
|
||||
"undo": "撤销",
|
||||
"redo": "重做",
|
||||
"header": "表头",
|
||||
|
||||
@@ -329,6 +329,7 @@
|
||||
"finished": "完成于 {time}"
|
||||
},
|
||||
"shippingOrderExtractionUnknownDocument": "未命名 PDF",
|
||||
"shippingOrderExtractionMoreDetails": "查看审计与补充信息",
|
||||
"shippingOrderExtractionUnread": "有 {count} 条订单识别结果待查看",
|
||||
"shippingOrderExtractionActivity": {
|
||||
"plan_created": "识别计划已创建,正在准备首轮附件。",
|
||||
@@ -423,6 +424,18 @@
|
||||
"unknown": "明细字段"
|
||||
},
|
||||
"shippingOrderExtractionProfileSummary": "模板:{name} V{version}",
|
||||
"shippingOrderExtractionRouteType": {
|
||||
"profile_deterministic": "异型模板确定性解析",
|
||||
"generic_deterministic": "通用规则确定性解析",
|
||||
"llm_assisted_review": "AI 辅助复核",
|
||||
"manual_review": "人工复核",
|
||||
"rejected": "已拒识"
|
||||
},
|
||||
"shippingOrderExtractionFreezeSource": {
|
||||
"profile_deterministic": "自动冻结来源:异型模板",
|
||||
"generic_deterministic": "自动冻结来源:通用规则",
|
||||
"manual_confirmation": "冻结来源:人工确认"
|
||||
},
|
||||
"shippingOrderExtractionPlanSummary": "本轮从 {total} 个附件中规划 {groups} 个订单组,首轮最多识别 {attachments} 个附件,并发 {concurrency} 个。",
|
||||
"shippingOrderExtractionPlanSelected": "已选 {count} 个附件",
|
||||
"shippingOrderExtractionPlanPendingExpansion": "待扩展 {count} 个附件",
|
||||
@@ -440,6 +453,9 @@
|
||||
"shippingOrderExtractionTechnicalFailureCode": "系统暂未完成处理",
|
||||
"shippingOrderExtractionTechnicalFailureCodes": "部分附件暂未完成处理",
|
||||
"shippingOrderExtractionTechnicalFailureUserHint": "系统暂未完成处理,您可以稍后重试。",
|
||||
"shippingOrderExtractionReasonUnknown": "存在需关注的处理原因",
|
||||
"shippingOrderExtractionReasonTechDetails": "技术详情",
|
||||
"shippingOrderExtractionDetailsRetry": "重试加载",
|
||||
"shippingOrderExtractionRetryStatus": {
|
||||
"not_started": "尚未开始",
|
||||
"running": "处理中",
|
||||
@@ -1436,6 +1452,7 @@
|
||||
"readOnly": "只读预览",
|
||||
"loading": "正在加载复核结果...",
|
||||
"unavailable": "暂时无法加载复核结果,请稍后重试。",
|
||||
"retryLoad": "重新加载",
|
||||
"documentNavigation": "PDF 导航",
|
||||
"documents": "PDF 文件",
|
||||
"unnamedDocument": "未命名 PDF",
|
||||
@@ -1475,7 +1492,54 @@
|
||||
"manual": "人工修改",
|
||||
"manual_override": "人工覆盖",
|
||||
"derived": "规则派生",
|
||||
"skipped": "派生跳过"
|
||||
"skipped": "派生跳过",
|
||||
"llm_suggested": "AI 建议(待确认)"
|
||||
},
|
||||
"llmSuggestion": {
|
||||
"title": "AI 辅助建议",
|
||||
"panelTitle": "AI 辅助建议",
|
||||
"panelHint": "仅发送最小冻结证据;不会自动冻结订单。",
|
||||
"request": "请求 AI 建议",
|
||||
"requesting": "请求中…",
|
||||
"compare": "对比建议",
|
||||
"scope": "证据范围:{level}",
|
||||
"evidenceLevel": {
|
||||
"L1_field": "字段原文",
|
||||
"L2_table": "所在表格",
|
||||
"L3_page": "所在页面",
|
||||
"L4_pdf": "整份 PDF(需授权)"
|
||||
},
|
||||
"review": "裁决",
|
||||
"empty": "尚无 AI 建议。选择字段后点击请求。",
|
||||
"dialogTitle": "AI 辅助建议",
|
||||
"dialogHint": "建议值须逐字存在于文档证据;接受前不会自动建单。",
|
||||
"currentDraft": "当前草稿",
|
||||
"aiSuggestion": "AI 建议",
|
||||
"sourceEvidence": "原文证据",
|
||||
"verbatimOk": "逐字验证通过",
|
||||
"verbatimFailed": "未在证据中找到逐字匹配",
|
||||
"evidenceAtCell": "PDF 第 {page} 页 · {cell}",
|
||||
"noEvidenceCoords": "无可靠坐标,仅显示引文",
|
||||
"status": {
|
||||
"idle": "未请求",
|
||||
"pending": "请求中",
|
||||
"validated": "已验证",
|
||||
"accepted": "已接受",
|
||||
"modified": "已修改",
|
||||
"rejected": "已拒绝",
|
||||
"failed": "不可用"
|
||||
},
|
||||
"decisions": {
|
||||
"accept": "接受",
|
||||
"modify": "修改后接受",
|
||||
"reject": "拒绝"
|
||||
},
|
||||
"modifiedValue": "修改后的值",
|
||||
"reason": "原因",
|
||||
"reasonRequired": "修改或拒绝时必须填写原因",
|
||||
"noteOptional": "备注(可选)",
|
||||
"cancel": "取消",
|
||||
"submit": "提交裁决"
|
||||
},
|
||||
"lineNoOverrideDialog": {
|
||||
"title": "覆盖内部项次",
|
||||
@@ -1740,7 +1804,8 @@
|
||||
"refresh": "刷新",
|
||||
"viewProgress": "查看进度",
|
||||
"cancelFile": "取消此文件",
|
||||
"reparse": "重试/重新识别"
|
||||
"reparse": "重新识别",
|
||||
"retryFailedRun": "重试失败识别"
|
||||
},
|
||||
"reasonDialog": {
|
||||
"cancelTitle": "取消此文件",
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
"AGENT.ADMIN_SCOPE_INVALID": "应用管理页签参数无效。",
|
||||
"AGENT.INTERNAL_EXECUTOR_USER_ACCESS_FORBIDDEN": "内部执行器不能展示、授权或通过普通用户接口访问。",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_NOT_RETRYABLE": "只有识别失败的订单任务可以重新识别。",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_REASON_REQUIRED": "重新识别必须填写原因,请补充后重试。",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_NOT_ALLOWED": "当前状态不允许重新识别。请先进入人工复核,或等待识别失败后再重试。",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_CASE_REQUIRED": "当前文件尚无复核单,不能新建识别版本。请先完成识别进入人工复核,或仅在识别失败后重试原任务。",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_SOURCE_INVALID": "关联的识别任务不可用,无法重新识别。请刷新后重试或联系管理员。",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_SNAPSHOT_OBSOLETE": "该识别任务使用旧版输入契约,无法重试。请重新发送邮件及附件发起新识别。",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_CONVERSATION_ACTIVE": "当前对话已有订单识别任务正在处理,请等待完成后再继续。",
|
||||
"SHIPPING_NOTICE.CANCEL_FORBIDDEN": "无权取消该订单识别任务。",
|
||||
|
||||
@@ -2720,6 +2720,13 @@
|
||||
"uploadNewSampleHint": "系統會自動解析,完成後自動選取該檔案。",
|
||||
"uploading": "正在上傳",
|
||||
"sampleParsing": "正在解析,完成後會自動選取。",
|
||||
"sampleStatus": {
|
||||
"uploading": "檔案正在上傳,請勿關閉目前頁面。",
|
||||
"queued": "檔案已上傳,正在等待解析工作啟動。",
|
||||
"parsing": "正在解析文件與版面,完成後會自動加入下方清單並選取。",
|
||||
"syncing": "解析已完成,正在同步樣本清單並自動選取。"
|
||||
},
|
||||
"refreshSamples": "立即重新整理樣本清單",
|
||||
"sampleParseFailed": "解析失敗,請重新上傳或選擇既有樣本。",
|
||||
"sampleLayoutCoordinatesMissing": "模板版面解析失敗:未取得表格儲存格座標,請更換樣本或檢查 MinerU 輸出。",
|
||||
"sampleLayoutSnapshotTooLarge": "模板版面解析失敗:解析快照超出大小限制,請使用頁數較少或內容較精簡的樣本。",
|
||||
@@ -3030,6 +3037,13 @@
|
||||
"regionKindTitle": "區域類型",
|
||||
"regionFieldCodeTitle": "欄位編碼",
|
||||
"regionPageTitle": "所屬頁",
|
||||
"recognizedValueTitle": "實際識別值",
|
||||
"configuredValueTitle": "範本設定值",
|
||||
"matchResultTitle": "比對結果",
|
||||
"matchResultMatched": "比對成功",
|
||||
"matchResultMismatched": "不相符",
|
||||
"regionDiagnosticsLoading": "正在讀取凍結識別值...",
|
||||
"regionDiagnosticsLoadFailed": "凍結識別值載入失敗",
|
||||
"sampleSummaryTitle": "樣本摘要",
|
||||
"annotationCount": "標註樣本",
|
||||
"trainingCount": "訓練樣本",
|
||||
@@ -3220,6 +3234,8 @@
|
||||
"openCanvas": "建立草稿並開啟畫布",
|
||||
"loadingPage": "正在載入頁面…",
|
||||
"canvasZoom": "頁面縮放",
|
||||
"readonlyCanvasAriaLabel": "文件唯讀畫布",
|
||||
"annotationCanvasAriaLabel": "文件標註畫布",
|
||||
"zoomOut": "縮小",
|
||||
"zoomIn": "放大",
|
||||
"fitPage": "適合頁面",
|
||||
@@ -3275,6 +3291,23 @@
|
||||
"review": "複核",
|
||||
"noIssues": "沒有阻斷設定問題。",
|
||||
"currentConfiguration": "目前設定",
|
||||
"tableRegionSettings": "明細表區設定",
|
||||
"rowReconstructionMode": "明細行重建方式",
|
||||
"rowReconstructionModes": {
|
||||
"fixedSubrows": "固定子行(預設)",
|
||||
"adaptiveRecordColumns": "自適應欄位重建"
|
||||
},
|
||||
"rowReconstructionHints": {
|
||||
"fixed_subrows": "適用於每筆明細的實體行數固定的版型。",
|
||||
"adaptive_record_columns": "適用於欄位位置固定、欄位可能分散在不同實體行的版型;請先完成獨立盲測。"
|
||||
},
|
||||
"tableRegionPageScope": "適用頁範圍",
|
||||
"tableRegionPageScopes": {
|
||||
"exactPage": "僅目前頁面",
|
||||
"firstPage": "僅第一頁",
|
||||
"allPages": "所有頁面",
|
||||
"continuationPages": "僅續頁"
|
||||
},
|
||||
"undo": "復原",
|
||||
"redo": "重做",
|
||||
"header": "表頭",
|
||||
|
||||
@@ -295,6 +295,7 @@
|
||||
"finished": "完成於 {time}"
|
||||
},
|
||||
"shippingOrderExtractionUnknownDocument": "未命名 PDF",
|
||||
"shippingOrderExtractionMoreDetails": "查看稽核與補充資訊",
|
||||
"shippingOrderExtractionUnread": "有 {count} 項訂單識別結果待查看",
|
||||
"shippingOrderExtractionActivity": {
|
||||
"plan_created": "識別計劃已建立,正在準備首輪附件。",
|
||||
@@ -389,6 +390,18 @@
|
||||
"unknown": "明細欄位"
|
||||
},
|
||||
"shippingOrderExtractionProfileSummary": "模板:{name} V{version}",
|
||||
"shippingOrderExtractionRouteType": {
|
||||
"profile_deterministic": "異型模板確定性解析",
|
||||
"generic_deterministic": "通用規則確定性解析",
|
||||
"llm_assisted_review": "AI 輔助複核",
|
||||
"manual_review": "人工複核",
|
||||
"rejected": "已拒識"
|
||||
},
|
||||
"shippingOrderExtractionFreezeSource": {
|
||||
"profile_deterministic": "自動凍結來源:異型模板",
|
||||
"generic_deterministic": "自動凍結來源:通用規則",
|
||||
"manual_confirmation": "凍結來源:人工確認"
|
||||
},
|
||||
"shippingOrderExtractionPlanSummary": "本輪從 {total} 個附件中規劃 {groups} 個訂單組,首輪最多識別 {attachments} 個附件,並發 {concurrency} 個。",
|
||||
"shippingOrderExtractionPlanSelected": "已選 {count} 個附件",
|
||||
"shippingOrderExtractionPlanPendingExpansion": "待擴展 {count} 個附件",
|
||||
@@ -406,6 +419,9 @@
|
||||
"shippingOrderExtractionTechnicalFailureCode": "系統暫時無法完成處理",
|
||||
"shippingOrderExtractionTechnicalFailureCodes": "部分附件暫時無法完成處理",
|
||||
"shippingOrderExtractionTechnicalFailureUserHint": "系統暫時無法完成處理,請稍後再試。",
|
||||
"shippingOrderExtractionReasonUnknown": "存在需關注的處理原因",
|
||||
"shippingOrderExtractionReasonTechDetails": "技術詳情",
|
||||
"shippingOrderExtractionDetailsRetry": "重試載入",
|
||||
"shippingOrderExtractionRetryStatus": {
|
||||
"not_started": "尚未開始",
|
||||
"running": "處理中",
|
||||
@@ -1402,6 +1418,7 @@
|
||||
"readOnly": "唯讀預覽",
|
||||
"loading": "正在載入覆核結果...",
|
||||
"unavailable": "暫時無法載入覆核結果,請稍後再試。",
|
||||
"retryLoad": "重新載入",
|
||||
"documentNavigation": "PDF 導覽",
|
||||
"documents": "PDF 檔案",
|
||||
"unnamedDocument": "未命名 PDF",
|
||||
@@ -1441,7 +1458,54 @@
|
||||
"manual": "人工修改",
|
||||
"manual_override": "人工覆蓋",
|
||||
"derived": "規則派生",
|
||||
"skipped": "派生跳過"
|
||||
"skipped": "派生跳過",
|
||||
"llm_suggested": "AI 建議(待確認)"
|
||||
},
|
||||
"llmSuggestion": {
|
||||
"title": "AI 輔助建議",
|
||||
"panelTitle": "AI 輔助建議",
|
||||
"panelHint": "僅發送最小凍結證據;不會自動凍結訂單。",
|
||||
"request": "請求 AI 建議",
|
||||
"requesting": "請求中…",
|
||||
"compare": "對比建議",
|
||||
"scope": "證據範圍:{level}",
|
||||
"evidenceLevel": {
|
||||
"L1_field": "欄位原文",
|
||||
"L2_table": "所在表格",
|
||||
"L3_page": "所在頁面",
|
||||
"L4_pdf": "整份 PDF(需授權)"
|
||||
},
|
||||
"review": "裁決",
|
||||
"empty": "尚無 AI 建議。選擇欄位後點擊請求。",
|
||||
"dialogTitle": "AI 輔助建議",
|
||||
"dialogHint": "建議值須逐字存在於文件證據;接受前不會自動建單。",
|
||||
"currentDraft": "當前草稿",
|
||||
"aiSuggestion": "AI 建議",
|
||||
"sourceEvidence": "原文證據",
|
||||
"verbatimOk": "逐字驗證通過",
|
||||
"verbatimFailed": "未在證據中找到逐字匹配",
|
||||
"evidenceAtCell": "PDF 第 {page} 頁 · {cell}",
|
||||
"noEvidenceCoords": "無可靠座標,僅顯示引文",
|
||||
"status": {
|
||||
"idle": "未請求",
|
||||
"pending": "請求中",
|
||||
"validated": "已驗證",
|
||||
"accepted": "已接受",
|
||||
"modified": "已修改",
|
||||
"rejected": "已拒絕",
|
||||
"failed": "不可用"
|
||||
},
|
||||
"decisions": {
|
||||
"accept": "接受",
|
||||
"modify": "修改後接受",
|
||||
"reject": "拒絕"
|
||||
},
|
||||
"modifiedValue": "修改後的值",
|
||||
"reason": "原因",
|
||||
"reasonRequired": "修改或拒絕時必須填寫原因",
|
||||
"noteOptional": "備註(可選)",
|
||||
"cancel": "取消",
|
||||
"submit": "提交裁決"
|
||||
},
|
||||
"lineNoOverrideDialog": {
|
||||
"title": "覆蓋內部項次",
|
||||
@@ -1740,7 +1804,8 @@
|
||||
"refresh": "重新整理",
|
||||
"viewProgress": "查看進度",
|
||||
"cancelFile": "取消此檔案",
|
||||
"reparse": "重試/重新識別"
|
||||
"reparse": "重新識別",
|
||||
"retryFailedRun": "重試失敗識別"
|
||||
},
|
||||
"reasonDialog": {
|
||||
"cancelTitle": "取消此檔案",
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
"AGENT.ADMIN_SCOPE_INVALID": "應用管理頁籤參數無效。",
|
||||
"AGENT.INTERNAL_EXECUTOR_USER_ACCESS_FORBIDDEN": "內部執行器不能顯示、授權或透過一般使用者介面存取。",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_NOT_RETRYABLE": "只有識別失敗的訂單任務可以重新識別。",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_REASON_REQUIRED": "重新識別必須填寫原因,請補充後重試。",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_NOT_ALLOWED": "目前狀態不允許重新識別。請先進入人工覆核,或等待識別失敗後再重試。",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_CASE_REQUIRED": "目前檔案尚無覆核單,不能建立新識別版本。請先完成識別進入人工覆核,或僅在識別失敗後重試原任務。",
|
||||
"SHIPPING_NOTICE.WORKFLOW_ITEM_REPARSE_SOURCE_INVALID": "關聯的識別任務不可用,無法重新識別。請重新整理後重試或聯絡管理員。",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_RUN_SNAPSHOT_OBSOLETE": "此識別任務使用舊版輸入契約,無法重試。請重新傳送郵件及附件以開始新的識別。",
|
||||
"SHIPPING_NOTICE.ORDER_EXTRACTION_CONVERSATION_ACTIVE": "目前對話已有訂單識別任務正在處理,請等待完成後再繼續。",
|
||||
"SHIPPING_NOTICE.CANCEL_FORBIDDEN": "無權取消該訂單識別任務。",
|
||||
|
||||
@@ -50,8 +50,6 @@ export class BusinessError extends Error {
|
||||
* @returns 当前语言的用户可见错误信息
|
||||
*/
|
||||
export function resolveLocalizedErrorMessage(code?: string, fallbackMessage?: string): string {
|
||||
const normalizedCode = code ? code.replace(/\./g, '_') : '';
|
||||
const key = normalizedCode ? `errors.codes.${normalizedCode}` : '';
|
||||
const fallback = String(fallbackMessage || '').trim();
|
||||
const isGenericFallback = (msg: string) => {
|
||||
const v = msg.trim().toLowerCase();
|
||||
@@ -61,21 +59,44 @@ export function resolveLocalizedErrorMessage(code?: string, fallbackMessage?: st
|
||||
if (v.startsWith('http ')) return true;
|
||||
return false;
|
||||
};
|
||||
if (key && i18n.global.te(key)) {
|
||||
const localized = String(i18n.global.t(key));
|
||||
if (normalizedCode === 'VALIDATION_INVALID_PARAM' && fallback && !isGenericFallback(fallback) && fallback !== localized) {
|
||||
return `${localized} ${fallback}`;
|
||||
|
||||
/**
|
||||
* 在 errors.codes 中查找文案:优先字面量键(含点号),再尝试下划线键与路径解析。
|
||||
*/
|
||||
const lookupCodeMessage = (rawCode: string): string | null => {
|
||||
const bag = i18n.global.tm('errors.codes') as Record<string, unknown> | string | null;
|
||||
if (bag && typeof bag === 'object' && !Array.isArray(bag)) {
|
||||
const direct = bag[rawCode];
|
||||
if (typeof direct === 'string' && direct.trim()) return direct;
|
||||
const underscoredLeaf = rawCode.replace(/\./g, '_');
|
||||
const viaUnderscore = bag[underscoredLeaf];
|
||||
if (typeof viaUnderscore === 'string' && viaUnderscore.trim()) return viaUnderscore;
|
||||
}
|
||||
if (
|
||||
normalizedCode === 'AUTH_FORBIDDEN'
|
||||
&& fallback
|
||||
&& !isGenericFallback(fallback)
|
||||
&& fallback.toLowerCase() !== 'forbidden'
|
||||
&& fallback !== localized
|
||||
) {
|
||||
return fallback;
|
||||
const underscoredPath = `errors.codes.${rawCode.replace(/\./g, '_')}`;
|
||||
if (i18n.global.te(underscoredPath)) return String(i18n.global.t(underscoredPath));
|
||||
const dottedPath = `errors.codes.${rawCode}`;
|
||||
if (i18n.global.te(dottedPath)) return String(i18n.global.t(dottedPath));
|
||||
return null;
|
||||
};
|
||||
|
||||
if (code) {
|
||||
const localized = lookupCodeMessage(code);
|
||||
if (localized) {
|
||||
const normalizedCode = code.replace(/\./g, '_');
|
||||
if (normalizedCode === 'VALIDATION_INVALID_PARAM' && fallback && !isGenericFallback(fallback) && fallback !== localized) {
|
||||
return `${localized} ${fallback}`;
|
||||
}
|
||||
if (
|
||||
normalizedCode === 'AUTH_FORBIDDEN'
|
||||
&& fallback
|
||||
&& !isGenericFallback(fallback)
|
||||
&& fallback.toLowerCase() !== 'forbidden'
|
||||
&& fallback !== localized
|
||||
) {
|
||||
return fallback;
|
||||
}
|
||||
return localized;
|
||||
}
|
||||
return localized;
|
||||
}
|
||||
if (fallback) return fallback;
|
||||
if (i18n.global.te('errors.generic')) {
|
||||
|
||||
Reference in new issue
Block a user