feat(shipping-notice): 增强订单文档 Profile 管理功能,新增复核与草稿管理

- 添加订单复核相关模型及 API,支持复核案例的创建、更新和确认
- 实现复核草稿的管理功能,允许用户对复核内容进行编辑和保存
- 引入复核事件审计,确保复核过程的可追溯性
- 更新数据库模型以支持复核和草稿的关系管理
- 完善相关服务逻辑,确保复核与草稿的状态管理和数据一致性
- 增强文档模板的管理能力,支持更复杂的业务场景
This commit is contained in:
hugo committed 2026-07-29 09:50:25 +08:00
1 parent 61ac6403c4
commit b7307fc573
147 files changed
+15108 -1522

No files matched your search

@@ -55,6 +55,16 @@ const ShippingOrderExtractionRunsPage = () =>
import("@/features/admin/modules/shipping-order-extraction-runs/ShippingOrderExtractionRunsPage.vue");
const ShippingOrderDocumentProfilesPage = () =>
import("@/features/admin/modules/shipping-order-document-profiles/ShippingOrderDocumentProfilesPage.vue");
const OrderProfileVersionDetailPage = () =>
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfileVersionDetailPage.vue");
const OrderProfileCreateWizardPage = () =>
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfileCreateWizardPage.vue");
const OrderProfileEditorRoutePage = () =>
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfileEditorRoutePage.vue");
const OrderProfileValidationPage = () =>
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfileValidationPage.vue");
const OrderProfilePublishCheckPage = () =>
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfilePublishCheckPage.vue");
export const adminRoutes: RouteRecordRaw[] = [
{
@@ -177,6 +187,42 @@ export const adminRoutes: RouteRecordRaw[] = [
component: ShippingOrderDocumentProfilesPage,
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "订单文档模板" },
},
// 阶段 0 先固定 URL 身份;对应专属页面将在各自实施阶段替换,当前不切换旧工作台流量。
{
path: "shipping-order-document-profiles/new",
name: "AdminShippingOrderDocumentProfileCreate",
component: OrderProfileCreateWizardPage,
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "创建订单文档模板" },
},
{
path: "shipping-order-document-profiles/:profileCode/drafts/:profileId/edit",
name: "AdminShippingOrderDocumentProfileEdit",
component: OrderProfileEditorRoutePage,
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "编辑订单文档模板" },
},
{
path: "shipping-order-document-profiles/:profileCode/drafts/:profileId/validate",
name: "AdminShippingOrderDocumentProfileValidate",
component: OrderProfileValidationPage,
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "验证订单文档模板" },
},
{
path: "shipping-order-document-profiles/:profileCode/drafts/:profileId/publish-check",
name: "AdminShippingOrderDocumentProfilePublishCheck",
component: OrderProfilePublishCheckPage,
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "订单文档模板发布检查" },
},
{
path: "shipping-order-document-profiles/:profileCode/versions/:version",
name: "AdminShippingOrderDocumentProfileVersionDetail",
component: OrderProfileVersionDetailPage,
meta: {
requiresAdmin: true,
adminModule: "shipping_inventory",
adminSubModule: 'order_document_profiles',
title: "模板版本详情",
},
},
{
path: "announcements",
@@ -10,4 +10,17 @@ export const chatRoutes: RouteRecordRaw[] = [
name: 'Chat',
component: () => import('@/features/chat/views/ChatView.vue'),
},
{
path: '/chat/:agentId/shipping-order-review/:runNo',
name: 'ShippingOrderReviewLegacy',
redirect: (to) => ({
name: 'Chat',
params: { agentId: to.params.agentId },
query: {
...to.query,
mode: 'order-review',
run_no: String(to.params.runNo || ''),
},
}),
},
];
@@ -8,8 +8,6 @@
import { requestJson } from '@/shared/api/client';
import { getAuthHeaders } from '@/shared/utils/auth';
import type {
CreateOrderProfileFromSampleInput,
LegacyCreateOrderProfileFromSampleInput,
OrderProfileSampleDocument,
CoordinateReconstructionPreview,
CoordinateReconstructionSuggestion,
@@ -24,6 +22,13 @@ import type {
OrderProfileBlindTestInput,
OrderProfileBlindTestAvailableSample,
OrderProfileBlindTestCandidate,
OrderProfileAuditEventPage,
OrderProfileUsagePage,
OrderProfileVersionDiff,
OrderProfileVersionFamilySummary,
OrderProfileVersionSummary,
OrderProfileDraftRevision,
OrderProfileEditLease,
OrderProfileTestSuite,
ShippingOrderDocumentProfile,
} from '../types/shipping-order-document-profile.types';
@@ -35,6 +40,131 @@ const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getA
export const listOrderDocumentProfiles = () =>
requestJson<ShippingOrderDocumentProfile[]>('/api/admin/shipping-notice/order-document-profiles', auth());
/** 列出模板族摘要,供版本中心和默认选版使用。 */
export const listOrderDocumentProfileFamilies = () =>
requestJson<OrderProfileVersionFamilySummary[]>('/api/admin/shipping-notice/order-document-profile-families', auth());
/** 列出单个模板族的全部版本摘要。 */
export const listOrderDocumentProfileFamilyVersions = (profileCode: string) =>
requestJson<OrderProfileVersionSummary[]>(
`/api/admin/shipping-notice/order-document-profile-families/${encodeURIComponent(profileCode)}/versions`,
auth(),
);
/** 通过模板编码与版本号读取安全详情;版本不存在时由服务端返回明确 404。 */
export const getOrderDocumentProfileByFamilyVersion = (profileCode: string, version: number) =>
requestJson<ShippingOrderDocumentProfile>(
`/api/admin/shipping-notice/order-document-profile-families/${encodeURIComponent(profileCode)}/versions/${version}`,
auth(),
);
/** 读取单个模板版本的结构化详情,不包含 PDF、正文或盲测真值。 */
export const getOrderDocumentProfileDetail = (profileId: number) =>
requestJson<ShippingOrderDocumentProfile>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}`,
auth(),
);
/** 以乐观锁、Revision 和当前标签租约保存草稿的完整 v2 定义。 */
export const saveOrderDocumentProfileDraft = (profileId: number, payload: {
profile_code: string; display_name: string; schema_version_id: number;
definition: ShippingOrderDocumentProfile['definition']; change_note?: string;
expected_lock_version: number; browser_session_id: string; lease_token: string; operation_id: string;
}) => requestJson<ShippingOrderDocumentProfile>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}`,
{ method: 'PUT', body: JSON.stringify(payload), ...jsonAuth() },
);
/** 获取草稿单写者租约;令牌只应保存在当前浏览器标签的内存中。 */
export const acquireOrderDocumentProfileEditLease = (
profileId: number,
input: { browser_session_id: string; operation_id: string; confirm_takeover?: boolean },
) => requestJson<OrderProfileEditLease & { lease_token: string }>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/edit-lease`,
{ method: 'POST', body: JSON.stringify(input), ...jsonAuth() },
);
/** 续租当前标签的编辑许可,服务端会拒绝过期、冲突或错误令牌。 */
export const renewOrderDocumentProfileEditLease = (
profileId: number,
input: { browser_session_id: string; lease_token: string; operation_id: string },
) => requestJson<OrderProfileEditLease & { lease_token: string }>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/edit-lease/renew`,
{ method: 'POST', body: JSON.stringify(input), ...jsonAuth() },
);
/** 释放当前标签租约,不保存或展示其他会话的租约信息。 */
export const releaseOrderDocumentProfileEditLease = (
profileId: number,
input: { browser_session_id: string; lease_token: string; operation_id: string },
) => requestJson<void>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/edit-lease/release`,
{ method: 'POST', body: JSON.stringify(input), ...jsonAuth() },
);
/** 读取草稿不可变 Revision 元数据,完整定义仅能通过受控恢复使用。 */
export const listOrderDocumentProfileDraftRevisions = (profileId: number) =>
requestJson<OrderProfileDraftRevision[]>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/draft-revisions`, auth(),
);
/** 恢复旧 Revision 时由服务端另存为新 Revision,历史不会被覆盖。 */
export const restoreOrderDocumentProfileDraftRevision = (
profileId: number,
revisionNo: number,
input: { browser_session_id: string; lease_token: string; expected_lock_version: number; operation_id: string },
) => requestJson<ShippingOrderDocumentProfile>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/draft-revisions/${revisionNo}/restore`,
{ method: 'POST', body: JSON.stringify(input), ...jsonAuth() },
);
/** 读取同模板版本的服务端语义 diff;未指定 against_profile_id 时默认对比上一版本。 */
export const getOrderDocumentProfileDiff = (profileId: number, againstProfileId?: number | null) =>
requestJson<OrderProfileVersionDiff>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/diff${againstProfileId ? `?against_profile_id=${againstProfileId}` : ''}`,
auth(),
);
/** 读取模板版本治理时间线,支持 request_id、事件类型、操作者与日期过滤。 */
export const listOrderDocumentProfileAuditEvents = (
profileId: number,
params?: {
eventType?: string;
actor?: string;
requestIdFilter?: string;
createdFrom?: string;
createdTo?: string;
beforeId?: number | null;
limit?: number;
},
) => {
const query = new URLSearchParams();
if (params?.eventType) query.set('event_type', params.eventType);
if (params?.actor) query.set('actor', params.actor);
if (params?.requestIdFilter) query.set('request_id_filter', params.requestIdFilter);
if (params?.createdFrom) query.set('created_from', params.createdFrom);
if (params?.createdTo) query.set('created_to', params.createdTo);
if (params?.beforeId) query.set('before_id', String(params.beforeId));
if (params?.limit) query.set('limit', String(params.limit));
const suffix = query.toString();
return requestJson<OrderProfileAuditEventPage>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/audit-events${suffix ? `?${suffix}` : ''}`,
auth(),
);
};
/** 读取模板版本的实际使用记录,只返回每个 Unit 最新的 RouteDecision。 */
export const listOrderDocumentProfileUsages = (profileId: number, params?: { beforeId?: number | null; limit?: number }) => {
const query = new URLSearchParams();
if (params?.beforeId) query.set('before_id', String(params.beforeId));
if (params?.limit) query.set('limit', String(params.limit));
const suffix = query.toString();
return requestJson<OrderProfileUsagePage>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/usages${suffix ? `?${suffix}` : ''}`,
auth(),
);
};
/** 列出已具备 ready MinerU 表格的样本文档。 */
export const listOrderProfileSamples = () =>
requestJson<OrderProfileSampleDocument[]>('/api/admin/shipping-notice/order-document-profile-samples', auth());
@@ -118,28 +248,81 @@ export const generateOrderProfileOcrCoordinateEvidence = (documentId: number, ta
},
);
/** 由真实样本和结构化列选择创建 Profile 草稿。 */
export const createOrderProfileFromSample = (payload: CreateOrderProfileFromSampleInput | LegacyCreateOrderProfileFromSampleInput) =>
requestJson<ShippingOrderDocumentProfile>('/api/admin/shipping-notice/order-document-profiles/from-sample', {
method: 'POST', body: JSON.stringify(payload), ...jsonAuth(),
});
/** 用新样本和乐观锁更新已存在草稿。 */
export const updateOrderProfileFromSample = (
profileId: number, payload: (CreateOrderProfileFromSampleInput | LegacyCreateOrderProfileFromSampleInput) & { expected_lock_version: number },
) => requestJson<ShippingOrderDocumentProfile>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/from-sample`, {
method: 'PUT', body: JSON.stringify(payload), ...jsonAuth(),
},
/** 三步向导的唯一落库动作:原子创建草稿、主样本、Revision 和编辑租约。 */
export const completeOrderDocumentProfileWizard = (payload: {
profile_code: string;
display_name: string;
schema_version_id: number;
document_id: number;
main_table_id: string;
browser_session_id: string;
operation_id: string;
}) => requestJson<ShippingOrderDocumentProfile & {
edit_lease: { lease_token: string; browser_session_id: string; expires_at: string };
}>(
'/api/admin/shipping-notice/order-document-profiles/wizard-complete',
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
);
/** 发布草稿并退役同编码旧版本。 */
export const publishOrderDocumentProfile = (profileId: number, expectedLockVersion: number) =>
requestJson<ShippingOrderDocumentProfile>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/publish`,
{ method: 'POST', body: JSON.stringify({ expected_lock_version: expectedLockVersion }), ...jsonAuth() },
/** 冻结建议决定;接受后的实际区域修改仍由当前草稿保存接口统一写入 Revision。 */
export const decideOrderDocumentProfileSuggestion = (profileId: number, payload: {
suggestion_id: string;
suggestion_checksum: string;
suggestion_summary: Record<string, unknown>;
decision: 'accepted' | 'accepted_adjusted' | 'rejected';
adjustment_summary?: Record<string, unknown>;
browser_session_id: string;
lease_token: string;
operation_id: string;
}) => requestJson<{ suggestion_id: string; decision: string; revision_no: number }>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/suggestion-decisions`,
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
);
/** 读取不可变验证运行摘要;服务端会将与当前草稿不一致的历史运行标记为 stale。 */
export const listOrderProfileValidationRuns = (profileId: number) =>
requestJson<import('@/features/admin/types/shipping-order-document-profile.types').OrderProfileValidationRun[]>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/validation-runs`, auth(),
);
/** 运行当前草稿的即时结构检查,必须携带编辑租约,禁止绕过单写者保护。 */
export const runOrderProfileInstantCheck = (profileId: number, payload: {
browser_session_id: string; lease_token: string; operation_id: string;
}) => requestJson<import('@/features/admin/types/shipping-order-document-profile.types').OrderProfileValidationRun>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/validation-runs/instant-check`,
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
);
/** 在绑定 annotation/training 样本上试运行;接口不会接受或回显盲测真值。 */
export const runOrderProfileCurrentSample = (profileId: number, payload: {
sample_binding_id?: number; browser_session_id: string; lease_token: string; operation_id: string;
}) => requestJson<import('@/features/admin/types/shipping-order-document-profile.types').OrderProfileValidationRun>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/validation-runs/current-sample`,
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
);
/** 创建不可变发布检查报告;必须指定与当前草稿 checksum 一致的通过验证运行。 */
export const createOrderProfilePublishCheck = (profileId: number, payload: {
validation_run_id: number; browser_session_id: string; lease_token: string; operation_id: string;
}) => requestJson<import('@/features/admin/types/shipping-order-document-profile.types').OrderProfilePublishCheckReport>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/publish-checks`,
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
);
/** 读取已冻结报告;草稿若改变,服务端会将报告持久化标记为 invalidated。 */
export const getOrderProfilePublishCheck = (profileId: number, reportNo: string) =>
requestJson<import('@/features/admin/types/shipping-order-document-profile.types').OrderProfilePublishCheckReport>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/publish-checks/${encodeURIComponent(reportNo)}`, auth(),
);
/** 对报告的每条警告逐项确认后,原子消费报告并发布草稿。 */
export const confirmOrderProfilePublishCheck = (profileId: number, reportNo: string, payload: {
confirmed_warning_keys: string[]; browser_session_id: string; lease_token: string; operation_id: string;
}) => requestJson<ShippingOrderDocumentProfile>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/publish-checks/${encodeURIComponent(reportNo)}/confirm`,
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
);
/** 从不可变版本复制下一草稿。 */
export const cloneOrderDocumentProfile = (profileId: number) =>
requestJson<ShippingOrderDocumentProfile>(
@@ -181,6 +364,13 @@ export const authorizeOrderProfilePreviewPages = (profileId: number, documentId:
},
);
/** 为冻结样本绑定申请只读详情页逐页预览授权,禁止回退到当前 document layout。 */
export const authorizeOrderProfileFrozenSamplePreviewPages = (profileId: number, sampleBindingId: number) =>
requestJson<OrderProfilePreviewPages>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/samples/${sampleBindingId}/preview-pages`,
{ method: 'POST', ...jsonAuth() },
);
/** 列出当前 Profile 已绑定的标注/训练样本,用于恢复工作台上下文。 */
export const listOrderProfileBoundSamples = (profileId: number) =>
requestJson<OrderProfileBoundSample[]>(
@@ -3,6 +3,7 @@ import { ref, onMounted, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { Plus, Trash2, Edit2, Play, FileText, Image as ImageIcon } from 'lucide-vue-next';
import { listAdminAgents, listAdminAgentGuides, createAdminAgentGuide, updateAdminAgentGuide, deleteAdminAgentGuide, uploadAdminAgentGuideFile } from '@/features/admin/api/admin.api';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
const { t } = useI18n();
@@ -28,6 +29,8 @@ const form = ref({
const isUploading = ref(false);
const uploadError = ref('');
const deleteDialogOpen = ref(false);
const pendingDeleteGuideId = ref<number | null>(null);
const fetchAgents = async () => {
try {
@@ -143,13 +146,20 @@ const submitForm = async () => {
}
};
const deleteGuide = async (id: number) => {
if (!confirm('确定要删除该指南吗?删除后不可恢复。')) return;
const deleteGuide = (id: number) => {
pendingDeleteGuideId.value = id;
deleteDialogOpen.value = true;
};
const confirmDeleteGuide = async () => {
const id = pendingDeleteGuideId.value;
if (!id) return;
try {
await deleteAdminAgentGuide(id);
await fetchGuides();
} catch (error) {
console.error('Failed to delete guide:', error);
} finally {
pendingDeleteGuideId.value = null;
}
};
@@ -348,5 +358,6 @@ const getIcon = (type: string) => {
</div>
</div>
</div>
<DeleteConfirmDialog v-model="deleteDialogOpen" title="删除指南" message="确定要删除该指南吗?删除后不可恢复。" confirm-tone="danger" @confirm="confirmDeleteGuide" />
</div>
</template>
@@ -0,0 +1,39 @@
<!--
features/admin/modules/shipping-order-document-profiles/OrderProfileCreateWizardPage.vue
用途:订单模板三步创建向导。
依赖:Schema/样本/表格 API、三个步骤组件、Router。
逻辑:身份、样本、主表格均在浏览器内暂存;仅第三步完成调用原子 wizard-complete 接口。
-->
<script setup lang="ts">
import { computed, onMounted, reactive, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import { getShippingOrderSchemaState } from '@/features/admin/api/shipping-order-schema.api';
import { completeOrderDocumentProfileWizard, getOrderProfileSampleTables, listOrderProfileSamples } from '@/features/admin/api/shipping-order-document-profile.api';
import type { ShippingOrderSchemaVersion } from '@/features/admin/types/shipping-order-schema.types';
import OrderProfileIdentityStep from './components/OrderProfileIdentityStep.vue';
import OrderProfileSampleStep from './components/OrderProfileSampleStep.vue';
import OrderProfileModelStartStep from './components/OrderProfileModelStartStep.vue';
const { t } = useI18n(); const router = useRouter(); const message = useMessage();
const step = ref(1); const saving = ref(false); const schemas = ref<ShippingOrderSchemaVersion[]>([]);
const samples = ref<Array<{ document_id:number; intake_no:string; filename?:string|null; table_count:number }>>([]);
const tables = ref<Array<{ table_id:string; page_no:number; row_count:number; column_count:number; rows:string[][] }>>([]);
const identity = reactive({ displayName:'', profileCode:'', schemaId:0 }); const documentId = ref(0); const tableId = ref('');
const browserSessionId = crypto.randomUUID();
const canNext = computed(() => step.value === 1 ? Boolean(identity.displayName.trim() && identity.profileCode.trim() && identity.schemaId) : step.value === 2 ? Boolean(documentId.value) : Boolean(tableId.value));
/** 加载可用 Schema 与已解析样本;失败不创建或缓存任何 Profile。 */
async function loadContext(): Promise<void> { try { const [state, nextSamples] = await Promise.all([getShippingOrderSchemaState(), listOrderProfileSamples()]); schemas.value = state.versions || []; samples.value = nextSamples; } catch (error) { message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.wizard.loadFailed')); } }
/** 刷新上传后的样本库;样本解析未完成时只会留在样本库,不能产出半成品模板。 */
async function refreshSamples(): Promise<void> { try { samples.value = await listOrderProfileSamples(); } catch { message.error(t('admin.shippingOrderProfiles.wizard.loadFailed')); } }
watch(documentId, async (id) => { tableId.value=''; tables.value=[]; if (!id) return; try { const preview = await getOrderProfileSampleTables(id); tables.value = preview.tables; } catch (error) { message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.wizard.tableLoadFailed')); } });
/** 前进仅校验本地步骤状态;最后一步才拥有正式落库权限。 */
function next(): void { if (!canNext.value) { message.error(t('admin.shippingOrderProfiles.wizard.incomplete')); return; } if (step.value < 3) step.value += 1; }
/** 单事务完成后进入草稿编辑路由;创建草稿和创建并进入标注共享同一审计动作。 */
async function finish(enterEditor: boolean): Promise<void> { if (!canNext.value) return; saving.value=true; try { const profile = await completeOrderDocumentProfileWizard({ profile_code:identity.profileCode, display_name:identity.displayName, schema_version_id:identity.schemaId, document_id:documentId.value, main_table_id:tableId.value, browser_session_id:browserSessionId, operation_id:crypto.randomUUID() }); message.success(t('admin.shippingOrderProfiles.created')); if (enterEditor) router.push({ name:'AdminShippingOrderDocumentProfileEdit', params:{ profileCode:profile.profile_code, profileId:profile.id }, query:{ editorSessionId:browserSessionId } }); else router.push({ name:'AdminShippingOrderDocumentProfiles' }); } catch (error) { message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.wizard.createFailed')); } finally { saving.value=false; } }
onMounted(loadContext);
</script>
<template><section class="wizard"><header><button type="button" @click="router.push({ name:'AdminShippingOrderDocumentProfiles' })">{{ t('admin.cancel') }}</button><h1>{{ t('admin.shippingOrderProfiles.wizard.title') }}</h1><p>{{ t('admin.shippingOrderProfiles.wizard.steps', { step }) }}</p></header><OrderProfileIdentityStep v-if="step===1" v-model="identity" :schemas="schemas"/><OrderProfileSampleStep v-else-if="step===2" v-model="documentId" :samples="samples" @uploaded="refreshSamples"/><OrderProfileModelStartStep v-else v-model="tableId" :tables="tables"/><footer><button v-if="step>1" type="button" @click="step-=1">{{ t('admin.shippingOrderProfiles.wizard.previous') }}</button><span/><button v-if="step<3" class="primary" type="button" :disabled="!canNext" @click="next">{{ t('admin.shippingOrderProfiles.wizard.next') }}</button><template v-else><button type="button" :disabled="saving||!canNext" @click="finish(false)">{{ t('admin.shippingOrderProfiles.wizard.createDraft') }}</button><button class="primary" type="button" :disabled="saving||!canNext" @click="finish(true)">{{ t('admin.shippingOrderProfiles.wizard.createAndEdit') }}</button></template></footer></section></template>
<style scoped>.wizard{display:grid;gap:1.5rem;max-width:58rem;margin:0 auto;padding:1.5rem}.wizard header{display:grid;gap:.5rem}.wizard h1,.wizard p{margin:0}.wizard p{color:#64748b}.wizard footer{display:flex;gap:.75rem;align-items:center}.wizard footer span{flex:1}.wizard button{padding:.55rem .8rem;border:1px solid #cbd5e1;border-radius:.4rem;background:#fff}.wizard .primary{background:#2563eb;color:#fff;border-color:#2563eb}.wizard button:disabled{opacity:.5;cursor:not-allowed}</style>
@@ -0,0 +1,26 @@
<!--
features/admin/modules/shipping-order-document-profiles/OrderProfileEditorRoutePage.vue
用途:承接草稿编辑深链并挂载独立编辑页。
依赖:Vue Router、OrderProfileEditorPage。
逻辑:将路径草稿身份传递给独立编辑页;query 仅传递标签会话,不得改变目标草稿。
-->
<script setup lang="ts">
import { ref } from 'vue';
import OrderProfileEditorPage from './OrderProfileEditorPage.vue';
const ready = ref(false);
/**
* 路由参数由编辑页直接读取;本页只在挂载前准备渲染,避免旧 query 身份适配。
* @returns 设置完成后显示编辑页。
*/
function prepareEditor(): void {
ready.value = true;
}
prepareEditor();
</script>
<template>
<OrderProfileEditorPage v-if="ready" />
</template>
@@ -0,0 +1,83 @@
<!--
features/admin/modules/shipping-order-document-profiles/OrderProfileLibraryPage.vue
用途:按 profile_code 聚合展示订单文档模板族,是创建和继续编辑的唯一首页。
依赖:Profile family API、Vue Router、Vue I18n。
逻辑:列表只选择下一步路由;草稿进入编辑页,已发布版本创建新草稿,历史版本进入只读版本中心。
-->
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import { cloneOrderDocumentProfile, listOrderDocumentProfileFamilies } from '@/features/admin/api/shipping-order-document-profile.api';
import type { OrderProfileVersionFamilySummary } from '@/features/admin/types/shipping-order-document-profile.types';
const { t } = useI18n();
const router = useRouter();
const message = useMessage();
const loading = ref(false);
const query = ref('');
const families = ref<OrderProfileVersionFamilySummary[]>([]);
const filteredFamilies = computed(() => {
const keyword = query.value.trim().toLowerCase();
if (!keyword) return families.value;
return families.value.filter((item) => `${item.profile_code} ${item.display_name}`.toLowerCase().includes(keyword));
});
/** 加载模板族摘要;列表只显示聚合结果,不能将每个版本扁平为独立模板。 */
async function loadFamilies(): Promise<void> {
loading.value = true;
try {
families.value = await listOrderDocumentProfileFamilies();
} catch (error) {
message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.library.loadFailed'));
} finally {
loading.value = false;
}
}
/** 打开当前草稿编辑路由;草稿不存在时由其它操作创建,不在列表页隐式创建。 */
function continueEditing(item: OrderProfileVersionFamilySummary): void {
if (!item.draft_profile_id) return;
router.push({ name: 'AdminShippingOrderDocumentProfileEdit', params: { profileCode: item.profile_code, profileId: item.draft_profile_id } });
}
/** 从已发布版本建立同族下一草稿,然后进入后续编辑路由。 */
async function createNewVersion(item: OrderProfileVersionFamilySummary): Promise<void> {
if (!item.published_profile_id) return;
try {
const draft = await cloneOrderDocumentProfile(item.published_profile_id);
router.push({ name: 'AdminShippingOrderDocumentProfileEdit', params: { profileCode: draft.profile_code, profileId: draft.id } });
} catch (error) {
message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.library.createFailed'));
}
}
/** 进入不可变历史详情,不允许在此页面把版本伪装成新草稿。 */
function viewVersion(item: OrderProfileVersionFamilySummary): void {
router.push({ name: 'AdminShippingOrderDocumentProfileVersionDetail', params: { profileCode: item.profile_code, version: item.default_version } });
}
onMounted(loadFamilies);
</script>
<template>
<section class="profile-library">
<header class="profile-library__header">
<div><h1>{{ t('admin.shippingOrderProfiles.library.title') }}</h1><p>{{ t('admin.shippingOrderProfiles.library.subtitle') }}</p></div>
<button class="primary" type="button" @click="router.push({ name: 'AdminShippingOrderDocumentProfileCreate' })">{{ t('admin.shippingOrderProfiles.library.create') }}</button>
</header>
<input v-model="query" class="profile-library__search" :placeholder="t('admin.shippingOrderProfiles.library.search')" type="search">
<p v-if="loading">{{ t('admin.shippingOrderProfiles.library.loading') }}</p>
<p v-else-if="!filteredFamilies.length">{{ t('admin.shippingOrderProfiles.library.empty') }}</p>
<table v-else><thead><tr><th>{{ t('admin.shippingOrderProfiles.name') }}</th><th>{{ t('admin.shippingOrderProfiles.code') }}</th><th>{{ t('admin.shippingOrderProfiles.library.status') }}</th><th>{{ t('admin.shippingOrderProfiles.library.actions') }}</th></tr></thead>
<tbody><tr v-for="item in filteredFamilies" :key="item.profile_code"><td>{{ item.display_name }}</td><td><code>{{ item.profile_code }}</code></td><td>{{ item.draft_profile_id ? t('admin.shippingOrderProfiles.library.draft') : item.published_profile_id ? t('admin.shippingOrderProfiles.library.published', { version: item.published_version }) : t('admin.shippingOrderProfiles.library.retired') }}</td><td class="profile-library__actions"><button v-if="item.draft_profile_id" type="button" @click="continueEditing(item)">{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}</button><button v-else-if="item.published_profile_id" type="button" @click="createNewVersion(item)">{{ t('admin.shippingOrderProfiles.newVersion') }}</button><button type="button" @click="viewVersion(item)">{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}</button></td></tr></tbody>
</table>
</section>
</template>
<style scoped>
.profile-library { display:grid; gap:1rem; padding:1.5rem; } .profile-library__header { display:flex; justify-content:space-between; gap:1rem; align-items:start; } h1,p { margin:0; } p { color:#64748b; margin-top:.35rem; } .primary { background:#2563eb; color:#fff; border:0; border-radius:.45rem; padding:.6rem .9rem; } .profile-library__search { max-width:28rem; padding:.6rem; border:1px solid #cbd5e1; border-radius:.4rem; } table { border-collapse:collapse; width:100%; background:#fff; } th,td { padding:.75rem; border-bottom:1px solid #e2e8f0; text-align:left; } .profile-library__actions { display:flex; gap:.5rem; flex-wrap:wrap; } button { cursor:pointer; } @media (max-width:700px) { .profile-library__header { flex-direction:column; } table { font-size:.8rem; } }
</style>
@@ -0,0 +1,39 @@
<!--
features/admin/modules/shipping-order-document-profiles/OrderProfilePublishCheckPage.vue
用途:生成、审阅和消费订单模板的不可变发布检查报告。
依赖:发布检查 API、验证运行 API、Vue Router 和统一消息提示。
逻辑:用户选择当前通过验证运行生成报告;阻断项不可确认,警告逐项确认后才可原子发布。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import {
acquireOrderDocumentProfileEditLease, confirmOrderProfilePublishCheck, createOrderProfilePublishCheck,
listOrderProfileValidationRuns,
} from '@/features/admin/api/shipping-order-document-profile.api';
import type { OrderProfilePublishCheckReport, OrderProfileValidationRun } from '@/features/admin/types/shipping-order-document-profile.types';
const route = useRoute(); const router = useRouter(); const message = useMessage();
const { t } = useI18n();
const profileId = Number(route.params.profileId);
const runs = ref<OrderProfileValidationRun[]>([]); const report = ref<OrderProfilePublishCheckReport | null>(null);
const selectedRunId = ref<number | null>(null); const confirmed = ref<string[]>([]); const busy = ref(false);
const sessionId = String(route.query.editorSessionId || '').trim() || crypto.randomUUID(); const leaseToken = ref('');
/** 显示统一业务错误,避免发布页暴露服务端实现细节。 */
function fail(error: unknown): void { message.error(error instanceof BusinessError ? error.code : t('admin.orderProfilePublishCheck.failed')); }
/** 获取租约后才允许创建或消费报告,避免发布页绕过草稿写保护。 */
async function ensureLease(): Promise<boolean> { if (leaseToken.value) return true; try { leaseToken.value = (await acquireOrderDocumentProfileEditLease(profileId, { browser_session_id: sessionId, operation_id: crypto.randomUUID() })).lease_token; return true; } catch (error) { fail(error); return false; } }
/** 加载仅当前草稿仍有效的通过验证运行,历史 stale 运行不可用于发布。 */
async function loadRuns(): Promise<void> { try { runs.value = await listOrderProfileValidationRuns(profileId); selectedRunId.value = runs.value.find(item => item.status === 'passed')?.id || null; } catch (error) { fail(error); } }
/** 创建并冻结新报告;一次 operation 重试会在服务端返回同一报告。 */
async function createReport(): Promise<void> { if (!selectedRunId.value || !(await ensureLease())) return; busy.value = true; try { report.value = await createOrderProfilePublishCheck(profileId, { validation_run_id: selectedRunId.value, browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() }); confirmed.value = []; } catch (error) { fail(error); } finally { busy.value = false; } }
/** 逐项确认所有警告并消费报告,成功后跳转既有只读版本详情页。 */
async function publish(): Promise<void> { if (!report.value || !(await ensureLease())) return; busy.value = true; try { const published = await confirmOrderProfilePublishCheck(profileId, report.value.report_no || '', { confirmed_warning_keys: confirmed.value, browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() }); await router.replace({ name: 'AdminShippingOrderDocumentProfileVersionDetail', params: { profileCode: published.profile_code, version: String(published.version) } }); } catch (error) { fail(error); } finally { busy.value = false; } }
onMounted(loadRuns);
</script>
<template><section class="page"><header><div><p>{{ t('admin.orderProfilePublishCheck.eyebrow') }}</p><h1>{{ t('admin.orderProfilePublishCheck.title') }}</h1><small>{{ t('admin.orderProfilePublishCheck.description') }}</small></div><button type="button" @click="router.back()">{{ t('admin.orderProfilePublishCheck.back') }}</button></header><section v-if="!report" class="card"><h2>{{ t('admin.orderProfilePublishCheck.selectRun') }}</h2><label v-for="run in runs.filter(item => item.status === 'passed')" :key="run.id"><input v-model="selectedRunId" type="radio" :value="run.id">#{{ run.id }} · {{ run.run_type }} · {{ run.created_at }}</label><p v-if="!runs.some(item => item.status === 'passed')">{{ t('admin.orderProfilePublishCheck.noRun') }}</p><button :disabled="busy || !selectedRunId" type="button" @click="createReport">{{ t('admin.orderProfilePublishCheck.create') }}</button></section><section v-else class="card"><h2>{{ t('admin.orderProfilePublishCheck.report', { reportNo: report.report_no }) }}</h2><p>{{ t('admin.orderProfilePublishCheck.status', { status: report.status, revision: report.revision_no }) }}</p><h3>{{ t('admin.orderProfilePublishCheck.blocking') }}</h3><p v-if="!report.blocking_items.length">{{ t('admin.orderProfilePublishCheck.noBlocking') }}</p><ul><li v-for="item in report.blocking_items" :key="String(item.key)">{{ item.message }}</li></ul><h3>{{ t('admin.orderProfilePublishCheck.warnings') }}</h3><label v-for="item in report.warning_items" :key="String(item.key)"><input v-model="confirmed" type="checkbox" :value="String(item.key)">{{ item.message }}</label><button :disabled="busy || report.status !== 'valid' || report.blocking_items.length > 0 || confirmed.length !== report.warning_items.length" type="button" @click="publish">{{ t('admin.orderProfilePublishCheck.confirm') }}</button></section></section></template>
<style scoped>.page{max-width:900px;margin:auto;padding:28px}.page header{display:flex;justify-content:space-between;gap:16px}.page header p{color:#2563eb;font-weight:700;margin:0}.page h1{margin:4px 0}.card{margin-top:24px;padding:20px;border:1px solid #cbd5e1;border-radius:8px}.card label{display:block;margin:10px 0}.card button,header button{margin-top:14px;padding:8px 13px;border:0;border-radius:5px;background:#2563eb;color:white}header button{background:#64748b}</style>
@@ -0,0 +1,127 @@
<!--
features/admin/modules/shipping-order-document-profiles/OrderProfileValidationPage.vue
用途:展示草稿不可变验证运行,并发起即时检查和当前样本试运行。
依赖:Profile API、Vue Router、统一消息提示。
逻辑:从稳定路由获取草稿身份;所有写操作透传编辑器会话租约,页面仅展示安全摘要与运行编号。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import {
acquireOrderDocumentProfileEditLease,
listOrderProfileValidationRuns,
runOrderProfileCurrentSample,
runOrderProfileInstantCheck,
} from '@/features/admin/api/shipping-order-document-profile.api';
import type { OrderProfileValidationRun } from '@/features/admin/types/shipping-order-document-profile.types';
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const message = useMessage();
const profileId = Number(route.params.profileId);
const runs = ref<OrderProfileValidationRun[]>([]);
const loading = ref(false);
const executing = ref(false);
const leaseToken = ref('');
const sessionId = String(route.query.editorSessionId || '').trim() || crypto.randomUUID();
/** 将后端业务错误转换为统一提示,避免验证页泄露服务端内部细节。 */
function report(error: unknown): void {
const code = error instanceof BusinessError ? error.code : '';
message.error(code ? t(`errors.${code}`, code) : t('admin.orderProfileValidation.failed'));
}
/** 读取运行历史;后端自行计算 stale,因此客户端不根据本地草稿猜测有效性。 */
async function loadRuns(): Promise<void> {
loading.value = true;
try {
runs.value = await listOrderProfileValidationRuns(profileId);
} catch (error) {
report(error);
} finally {
loading.value = false;
}
}
/** 为本页获取单写者租约;冲突时明确提示并保留只读历史查询。 */
async function ensureLease(): Promise<boolean> {
if (leaseToken.value) return true;
try {
const lease = await acquireOrderDocumentProfileEditLease(profileId, {
browser_session_id: sessionId, operation_id: crypto.randomUUID(),
});
leaseToken.value = lease.lease_token;
return true;
} catch (error) {
report(error);
return false;
}
}
/** 运行指定验证类型,完成后重新加载服务端冻结的运行摘要。 */
async function execute(kind: 'instant' | 'sample'): Promise<void> {
if (!(await ensureLease())) return;
executing.value = true;
try {
const payload = { browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() };
if (kind === 'instant') await runOrderProfileInstantCheck(profileId, payload);
else await runOrderProfileCurrentSample(profileId, payload);
await loadRuns();
message.success(t('admin.orderProfileValidation.completed'));
} catch (error) {
report(error);
} finally {
executing.value = false;
}
}
/** 返回同一草稿的编辑路由,保留标签会话身份以复用仍有效的租约。 */
function backToEditor(): void {
router.push({ name: 'AdminShippingOrderDocumentProfileEdit', params: route.params, query: { editorSessionId: sessionId } });
}
onMounted(loadRuns);
</script>
<template>
<section class="validation-page">
<header>
<div>
<p class="eyebrow">{{ t('admin.orderProfileValidation.eyebrow') }}</p>
<h1>{{ t('admin.orderProfileValidation.title') }}</h1>
<p>{{ t('admin.orderProfileValidation.description') }}</p>
</div>
<button class="secondary" type="button" @click="backToEditor">{{ t('admin.orderProfileValidation.backToEditor') }}</button>
</header>
<div class="actions">
<button type="button" :disabled="executing" @click="execute('instant')">{{ t('admin.orderProfileValidation.instantCheck') }}</button>
<button type="button" :disabled="executing" @click="execute('sample')">{{ t('admin.orderProfileValidation.currentSample') }}</button>
</div>
<p v-if="loading">{{ t('admin.orderProfileValidation.loading') }}</p>
<table v-else>
<thead><tr><th>{{ t('admin.orderProfileValidation.run') }}</th><th>{{ t('admin.orderProfileValidation.type') }}</th><th>{{ t('admin.orderProfileValidation.status') }}</th><th>{{ t('admin.orderProfileValidation.summary') }}</th><th>{{ t('admin.orderProfileValidation.time') }}</th></tr></thead>
<tbody>
<tr v-for="run in runs" :key="run.id">
<td>#{{ run.id }}</td><td>{{ run.run_type }}</td><td><span :class="`status ${run.status}`">{{ run.status }}</span></td>
<td>{{ JSON.stringify((run as OrderProfileValidationRun & { summary?: Record<string, unknown> }).summary || {}) }}</td><td>{{ run.created_at }}</td>
</tr>
<tr v-if="!runs.length"><td colspan="5">{{ t('admin.orderProfileValidation.empty') }}</td></tr>
</tbody>
</table>
</section>
</template>
<style scoped>
.validation-page { max-width: 1180px; margin: 0 auto; padding: 28px; color: #1e293b; }
header { display: flex; justify-content: space-between; gap: 24px; align-items: start; }
h1 { margin: 4px 0; font-size: 24px; } .eyebrow { margin: 0; color: #2563eb; font-size: 12px; font-weight: 700; }
header p:not(.eyebrow) { color: #64748b; margin: 0; }.actions { display: flex; gap: 12px; margin: 24px 0; }
button { border: 0; border-radius: 6px; background: #2563eb; color: #fff; padding: 9px 14px; cursor: pointer; } button.secondary { background: #e2e8f0; color: #334155; } button:disabled { opacity: .6; cursor: wait; }
table { width: 100%; border-collapse: collapse; background: #fff; } th, td { padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top; } td:nth-child(4) { max-width: 420px; overflow-wrap: anywhere; color: #475569; }
.status { text-transform: uppercase; font-size: 12px; font-weight: 700; }.passed { color: #15803d; }.failed, .stale { color: #b91c1c; }
@media (max-width: 767px) { .validation-page { padding: 16px; } header { display: block; } header button { margin-top: 16px; } table { font-size: 12px; } }
</style>
@@ -0,0 +1,338 @@
<!--
features/admin/modules/shipping-order-document-profiles/OrderProfileVersionDetailPage.vue
用途:订单模板版本中心详情页,支持刷新恢复与分享。
依赖:版本详情 composable、配置概览组件、版本中心 API。
逻辑:当前已接入配置概览、只读样本画布、服务端语义 diff、审计时间线与实际使用;后续仅剩盲测隔离与发布治理收口。
-->
<script setup lang="ts">
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import { BusinessError } from "@/shared/api/client";
import { useMessage } from "@/shared/composables/useMessage";
import { cloneOrderDocumentProfile } from "@/features/admin/api/shipping-order-document-profile.api";
import OrderProfileReadOnlyCanvas from "./components/OrderProfileReadOnlyCanvas.vue";
import OrderProfileAuditTimeline from "./components/OrderProfileAuditTimeline.vue";
import OrderProfileVersionDiff from "./components/OrderProfileVersionDiff.vue";
import OrderProfileVersionOverview from "./components/OrderProfileVersionOverview.vue";
import OrderProfileUsageTable from "./components/OrderProfileUsageTable.vue";
import {
useOrderProfileVersionDetail,
type OrderProfileVersionDetailTab,
} from "./composables/useOrderProfileVersionDetail";
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const message = useMessage();
const cloning = ref(false);
const {
activeTab,
detail,
errorMessage,
loading,
profileCode,
tabOptions,
versions,
} = useOrderProfileVersionDetail();
const pageTitle = computed(() => {
if (!detail.value) {
return `${profileCode.value} · v${route.params.version || ""}`;
}
const statusKey =
detail.value.status === "draft"
? "currentDraft"
: detail.value.status === "published"
? "currentPublished"
: "retired";
return `${detail.value.profile_code} · v${detail.value.version} · ${t(
`admin.shippingOrderProfiles.versionCenter.status.${statusKey}`,
)}`;
});
const openTab = (tab: OrderProfileVersionDetailTab) => {
void router.replace({
query: {
...route.query,
tab,
},
});
};
const openVersion = (profileCodeParam: string, versionParam: number) => {
void router.push({
name: "AdminShippingOrderDocumentProfileVersionDetail",
params: {
profileCode: profileCodeParam,
version: String(versionParam),
},
query: {
tab: activeTab.value,
},
});
};
const goBackToWorkbench = () => {
void router.push({
name: "AdminShippingOrderDocumentProfiles",
query: {
profileCode: profileCode.value || undefined,
},
});
};
const continueEditing = () => {
if (!detail.value) return;
void router.push({
name: "AdminShippingOrderDocumentProfiles",
query: {
profileCode: detail.value.profile_code,
profileId: String(detail.value.id),
},
});
};
const createNewVersion = async () => {
if (!detail.value || cloning.value) return;
cloning.value = true;
try {
const draft = await cloneOrderDocumentProfile(detail.value.id);
message.success(t("admin.shippingOrderProfiles.cloned"));
void router.push({
name: "AdminShippingOrderDocumentProfiles",
query: {
profileCode: draft.profile_code,
profileId: String(draft.id),
},
});
} catch (error) {
message.error(
error instanceof BusinessError ? error.message : t("admin.shippingOrderProfiles.loadFailed"),
);
} finally {
cloning.value = false;
}
};
</script>
<template>
<section class="version-detail-page">
<header class="page-header">
<button type="button" class="ghost-button" @click="goBackToWorkbench">
{{ t("admin.shippingOrderProfiles.versionCenter.backToWorkbench") }}
</button>
<div class="header-main">
<div>
<p class="eyebrow">{{ t("admin.shippingOrderProfiles.versionCenter.eyebrow") }}</p>
<h1>{{ pageTitle }}</h1>
</div>
<div class="header-actions" v-if="detail">
<button
v-if="detail.status === 'draft'"
type="button"
class="primary-button"
@click="continueEditing"
>
{{ t("admin.shippingOrderProfiles.versionCenter.continueEditing") }}
</button>
<button
v-else
type="button"
class="primary-button"
:disabled="cloning"
@click="createNewVersion"
>
{{
cloning
? t("admin.shippingOrderProfiles.saving")
: t("admin.shippingOrderProfiles.newVersion")
}}
</button>
</div>
</div>
</header>
<div v-if="loading" class="state-card">
{{ t("admin.shippingOrderProfiles.versionCenter.loading") }}
</div>
<div v-else-if="errorMessage" class="state-card error-card">
{{ errorMessage }}
</div>
<template v-else-if="detail">
<nav class="tab-nav" :aria-label="t('admin.shippingOrderProfiles.versionCenter.tabsLabel')">
<button
v-for="tab in tabOptions"
:key="tab.key"
type="button"
class="tab-button"
:class="{ active: activeTab === tab.key }"
@click="openTab(tab.key)"
>
<span>{{ t(`admin.shippingOrderProfiles.versionCenter.tabs.${tab.key}`) }}</span>
<small v-if="tab.count !== undefined && tab.count !== null">{{ tab.count }}</small>
</button>
</nav>
<div class="content-layout">
<aside class="version-rail">
<header>
<h2>{{ t("admin.shippingOrderProfiles.versionCenter.familyVersions") }}</h2>
<p>{{ detail.profile_code }}</p>
</header>
<button
v-for="item in versions"
:key="item.id"
type="button"
class="version-item"
:class="{ active: item.id === detail.id }"
@click="openVersion(item.profile_code, item.version)"
>
<strong>v{{ item.version }}</strong>
<span>{{ t(`admin.shippingOrderProfiles.versionCenter.status.${item.status === 'draft' ? 'currentDraft' : item.status === 'published' ? 'currentPublished' : 'retired'}`) }}</span>
</button>
</aside>
<div class="detail-panel">
<OrderProfileVersionOverview v-if="activeTab === 'overview'" :detail="detail" />
<OrderProfileReadOnlyCanvas v-else-if="activeTab === 'canvas'" :detail="detail" />
<OrderProfileVersionDiff v-else-if="activeTab === 'diff'" :detail="detail" :versions="versions" />
<OrderProfileAuditTimeline v-else-if="activeTab === 'audit'" :detail="detail" />
<OrderProfileUsageTable v-else-if="activeTab === 'usage'" :detail="detail" />
<section v-else class="state-card">
{{ t("admin.shippingOrderProfiles.loadFailed") }}
</section>
</div>
</div>
</template>
</section>
</template>
<style scoped>
.version-detail-page {
display: grid;
gap: 1rem;
}
.page-header,
.state-card,
.version-rail,
.detail-panel {
border: 1px solid #e2e8f0;
border-radius: 1rem;
background: #fff;
padding: 1rem;
}
.page-header {
display: grid;
gap: 0.9rem;
}
.header-main {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.eyebrow {
margin: 0 0 0.35rem;
color: #64748b;
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.06em;
}
.page-header h1,
.version-rail h2 {
margin: 0;
color: #0f172a;
}
.ghost-button,
.primary-button,
.tab-button,
.version-item {
border: 1px solid #cbd5e1;
border-radius: 0.7rem;
background: #fff;
cursor: pointer;
font-size: 0.875rem;
}
.ghost-button,
.primary-button {
padding: 0.5rem 0.85rem;
}
.primary-button {
background: #0f172a;
border-color: #0f172a;
color: #fff;
}
.tab-nav {
display: flex;
flex-wrap: wrap;
gap: 0.6rem;
}
.tab-button {
display: inline-flex;
align-items: center;
gap: 0.45rem;
padding: 0.55rem 0.85rem;
}
.tab-button.active {
border-color: #2563eb;
background: #eff6ff;
color: #1d4ed8;
}
.content-layout {
display: grid;
gap: 1rem;
grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
}
.version-rail {
display: grid;
align-content: start;
gap: 0.75rem;
}
.version-rail header p {
margin: 0.35rem 0 0;
color: #64748b;
}
.version-item {
display: grid;
gap: 0.2rem;
justify-items: start;
padding: 0.75rem;
}
.version-item.active {
border-color: #2563eb;
background: #eff6ff;
}
.version-item span {
color: #64748b;
font-size: 0.75rem;
}
.error-card {
color: #b91c1c;
}
@media (max-width: 960px) {
.header-main,
.content-layout {
grid-template-columns: 1fr;
}
}
</style>
@@ -1,13 +1,13 @@
<!--
features/admin/modules/shipping-order-document-profiles/ShippingOrderDocumentProfilesPage.vue
用途:订单坐标 Profile 管理路由入口。
依赖:OrderProfileWorkbench。
逻辑:页面编排保持极薄;受控页面预览、区域标注、版本抽屉和草稿保护全部由工作台组件协作完成。
依赖:OrderProfileLibraryPage。
逻辑:列表页只承担模板族管理与路由分发;旧工作台不再作为首页创建入口。
-->
<script setup lang="ts">
import OrderProfileWorkbench from './OrderProfileWorkbench.vue';
import OrderProfileLibraryPage from './OrderProfileLibraryPage.vue';
</script>
<template>
<OrderProfileWorkbench />
<OrderProfileLibraryPage />
</template>
@@ -0,0 +1,317 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileAuditTimeline.vue
用途:展示订单模板版本中心的治理审计时间线。
依赖:版本中心审计 API、版本详情 DTO、Vue I18n。
逻辑:使用 before_id 游标分页避免新增事件导致翻页重复;只展示安全 detail 摘要,不展示 PDF、正文或盲测真值。
-->
<script setup lang="ts">
import { computed, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { BusinessError } from "@/shared/api/client";
import { listOrderDocumentProfileAuditEvents } from "@/features/admin/api/shipping-order-document-profile.api";
import type {
OrderProfileAuditEventPage,
ShippingOrderDocumentProfile,
} from "@/features/admin/types/shipping-order-document-profile.types";
const props = defineProps<{ detail: ShippingOrderDocumentProfile }>();
const { t } = useI18n();
const loading = ref(false);
const errorMessage = ref("");
const page = ref<OrderProfileAuditEventPage | null>(null);
const cursorStack = ref<Array<number | null>>([]);
const activeBeforeId = ref<number | null>(null);
const filters = reactive({
eventType: "",
actor: "",
requestIdFilter: "",
createdFrom: "",
createdTo: "",
});
const formatTime = (value?: string | null) => value ? new Date(value).toLocaleString() : "-";
const formatJson = (value: unknown) => {
try {
return JSON.stringify(value ?? {}, null, 2);
} catch {
return String(value ?? "");
}
};
const hasPrevious = computed(() => cursorStack.value.length > 0);
const hasNext = computed(() => Boolean(page.value?.page.has_more && page.value?.page.next_before_id));
const load = async () => {
loading.value = true;
errorMessage.value = "";
try {
page.value = await listOrderDocumentProfileAuditEvents(props.detail.id, {
eventType: filters.eventType.trim() || undefined,
actor: filters.actor.trim() || undefined,
requestIdFilter: filters.requestIdFilter.trim() || undefined,
createdFrom: filters.createdFrom || undefined,
createdTo: filters.createdTo || undefined,
beforeId: activeBeforeId.value,
limit: 20,
});
} catch (error) {
page.value = null;
errorMessage.value = error instanceof BusinessError
? error.message
: t("admin.shippingOrderProfiles.versionCenter.audit.loadFailed");
} finally {
loading.value = false;
}
};
const applyFilters = async () => {
activeBeforeId.value = null;
cursorStack.value = [];
await load();
};
const resetFilters = async () => {
filters.eventType = "";
filters.actor = "";
filters.requestIdFilter = "";
filters.createdFrom = "";
filters.createdTo = "";
await applyFilters();
};
const loadNext = async () => {
if (!page.value?.page.next_before_id) return;
cursorStack.value.push(activeBeforeId.value);
activeBeforeId.value = page.value.page.next_before_id;
await load();
};
const loadPrevious = async () => {
if (!cursorStack.value.length) return;
activeBeforeId.value = cursorStack.value.pop() ?? null;
await load();
};
watch(
() => props.detail.id,
() => {
activeBeforeId.value = null;
cursorStack.value = [];
void load();
},
{ immediate: true },
);
</script>
<template>
<section class="timeline-panel">
<div class="toolbar">
<div>
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.audit.title") }}</h3>
<p>{{ t("admin.shippingOrderProfiles.versionCenter.audit.subtitle") }}</p>
</div>
<div class="toolbar-actions">
<button type="button" class="ghost-button" :disabled="loading" @click="resetFilters">
{{ t("admin.shippingOrderProfiles.versionCenter.audit.reset") }}
</button>
<button type="button" class="primary-button" :disabled="loading" @click="applyFilters">
{{ t("admin.shippingOrderProfiles.versionCenter.audit.apply") }}
</button>
</div>
</div>
<div class="filters">
<label>
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.eventType") }}</span>
<input v-model="filters.eventType" type="text" />
</label>
<label>
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.actor") }}</span>
<input v-model="filters.actor" type="text" />
</label>
<label>
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.requestId") }}</span>
<input v-model="filters.requestIdFilter" type="text" />
</label>
<label>
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.createdFrom") }}</span>
<input v-model="filters.createdFrom" type="date" />
</label>
<label>
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.createdTo") }}</span>
<input v-model="filters.createdTo" type="date" />
</label>
</div>
<div v-if="loading" class="state-card">
{{ t("admin.shippingOrderProfiles.versionCenter.audit.loading") }}
</div>
<div v-else-if="errorMessage" class="state-card error-card">
{{ errorMessage }}
</div>
<div v-else-if="!page?.items.length" class="state-card">
{{ t("admin.shippingOrderProfiles.versionCenter.audit.empty") }}
</div>
<div v-else class="timeline-list">
<article
v-for="item in page.items"
:key="item.id"
class="timeline-item"
>
<header>
<div>
<p class="timeline-type">{{ item.event_type }}</p>
<h4>{{ item.actor.display_name }}</h4>
</div>
<div class="meta">
<span>{{ formatTime(item.created_at) }}</span>
<code v-if="item.request_id">{{ item.request_id }}</code>
</div>
</header>
<pre>{{ formatJson(item.detail) }}</pre>
</article>
</div>
<div class="pager">
<button type="button" class="ghost-button" :disabled="loading || !hasPrevious" @click="loadPrevious">
{{ t("admin.shippingOrderProfiles.versionCenter.audit.previous") }}
</button>
<button type="button" class="ghost-button" :disabled="loading || !hasNext" @click="loadNext">
{{ t("admin.shippingOrderProfiles.versionCenter.audit.next") }}
</button>
</div>
</section>
</template>
<style scoped>
.timeline-panel,
.toolbar,
.filters,
.timeline-item,
.state-card {
border: 1px solid #e2e8f0;
border-radius: 1rem;
background: #fff;
}
.timeline-panel {
display: grid;
gap: 0.9rem;
}
.toolbar,
.filters,
.state-card,
.timeline-item {
padding: 0.95rem 1rem;
}
.toolbar {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.toolbar h3,
.timeline-item h4 {
margin: 0;
color: #0f172a;
}
.toolbar p,
.timeline-type {
margin: 0.25rem 0 0;
color: #64748b;
font-size: 0.75rem;
}
.toolbar-actions,
.pager {
display: flex;
gap: 0.6rem;
}
.filters {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 0.75rem;
}
.filters label {
display: grid;
gap: 0.3rem;
color: #475569;
font-size: 0.75rem;
}
.filters input,
.ghost-button,
.primary-button {
border: 1px solid #cbd5e1;
border-radius: 0.75rem;
background: #fff;
padding: 0.5rem 0.75rem;
font-size: 0.875rem;
}
.primary-button {
background: #0f172a;
border-color: #0f172a;
color: #fff;
}
.timeline-list {
display: grid;
gap: 0.8rem;
}
.timeline-item header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.meta {
display: grid;
justify-items: end;
gap: 0.25rem;
color: #64748b;
font-size: 0.75rem;
}
.timeline-item pre {
margin: 0.85rem 0 0;
border-radius: 0.75rem;
background: #0f172a;
padding: 0.8rem;
color: #e2e8f0;
font-size: 0.72rem;
line-height: 1.45;
overflow: auto;
white-space: pre-wrap;
}
.error-card {
color: #b91c1c;
}
@media (max-width: 1100px) {
.filters {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 720px) {
.toolbar,
.timeline-item header {
display: grid;
}
.filters {
grid-template-columns: 1fr;
}
}
</style>
@@ -2,7 +2,7 @@
features/admin/modules/shipping-order-document-profiles/components/OrderProfileDocumentCanvas.vue
用途:展示受控 PDF 单页预览,并以相对坐标框支持选择、拖动和缩放区域。
依赖:浏览器 fetch、认证请求头、OrderProfileCanvasRegion。
逻辑:父工作台签发单页令牌并提供分页/保存动作;本组件下载短时 PNG,以三段式工具栏和窄工具轨承载标注交互。
逻辑:父级签发单页令牌并提供分页动作;mode=readonly 时只允许查看/缩放/切页,不允许写入任何标注改动。
-->
<script setup lang="ts">
import { computed, onBeforeUnmount, ref, watch } from 'vue';
@@ -14,6 +14,8 @@ import type { OrderProfileCanvasRegion, OrderProfilePreviewPageGrant } from '@/f
const props = defineProps<{
profileId: number | null;
grant?: OrderProfilePreviewPageGrant | null;
mode?: 'edit' | 'readonly';
previewPagePath?: string | null;
regions: OrderProfileCanvasRegion[];
selectedRegionId?: string | null;
creationKind?: OrderProfileCanvasRegion['kind'] | null;
@@ -30,6 +32,7 @@ const props = defineProps<{
saving?: boolean;
}>();
const { t } = useI18n();
const readonlyMode = computed(() => props.mode === 'readonly');
const emit = defineEmits<{
select: [regionId: string];
start: [regionId: string];
@@ -68,8 +71,10 @@ const loadPage = async () => {
URL.revokeObjectURL(imageUrl.value);
imageUrl.value = '';
try {
const previewPath = props.previewPagePath
|| `/api/admin/shipping-notice/order-document-profiles/${props.profileId}/preview-pages`;
const response = await fetch(
`/api/admin/shipping-notice/order-document-profiles/${props.profileId}/preview-pages/${props.grant.page_no}?preview_token=${encodeURIComponent(props.grant.preview_token)}`,
`${previewPath}/${props.grant.page_no}?preview_token=${encodeURIComponent(props.grant.preview_token)}`,
{ headers: getAuthHeaders(), cache: 'no-store' },
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
@@ -79,9 +84,9 @@ const loadPage = async () => {
}
};
/** 将指针移动映射为相对坐标;八向手柄独立调整边或角,放大后仍以相对坐标精确落位。 */
/** 将指针移动映射为相对坐标;readonly 模式只保留选中,不允许几何变化。 */
const move = (event: PointerEvent) => {
if (!activeDrag || !canvas.value) return;
if (!activeDrag || !canvas.value || readonlyMode.value) return;
const bounds = canvas.value.getBoundingClientRect();
const dx = (event.clientX - activeDrag.startX) / bounds.width;
const dy = (event.clientY - activeDrag.startY) / bounds.height;
@@ -104,10 +109,11 @@ const move = (event: PointerEvent) => {
emit('change', activeDrag.id, { x0, y0, x1: x0 + width, y1: y0 + height });
};
/** 为单次鼠标手势建立一个撤销边界,避免每个像素移动污染历史。 */
/** 为单次鼠标手势建立一个撤销边界;readonly 模式仅允许选中区域。 */
const beginDrag = (event: PointerEvent, region: OrderProfileCanvasRegion, mode: DragMode) => {
event.preventDefault();
emit('select', region.id);
if (readonlyMode.value) return;
emit('start', region.id);
activeDrag = { id: region.id, mode, startX: event.clientX, startY: event.clientY, region: { ...region.region } };
window.addEventListener('pointermove', move);
@@ -122,7 +128,7 @@ const endMove = () => {
};
/** 未处于绘制模式时以左键拖动画布视口,避免依赖横纵滚动条定位放大页面。 */
const beginPan = (event: PointerEvent) => {
if (props.creationKind || !viewport.value || event.button !== 0) return;
if ((props.creationKind && !readonlyMode.value) || !viewport.value || event.button !== 0) return;
event.preventDefault();
activePan = { startX: event.clientX, startY: event.clientY, scrollLeft: viewport.value.scrollLeft, scrollTop: viewport.value.scrollTop };
window.addEventListener('pointermove', pan);
@@ -136,7 +142,7 @@ const pan = (event: PointerEvent) => {
const endPan = () => { activePan = null; window.removeEventListener('pointermove', pan); };
/** 在启用绘制模式时,把指针位置转换为受约束的相对区域并交由父级创建。 */
const beginCreation = (event: PointerEvent) => {
if (!props.creationKind || !canvas.value) { beginPan(event); return; }
if (readonlyMode.value || !props.creationKind || !canvas.value) { beginPan(event); return; }
const bounds = canvas.value.getBoundingClientRect();
const x = Math.max(0, Math.min(1, (event.clientX - bounds.left) / bounds.width));
const y = Math.max(0, Math.min(1, (event.clientY - bounds.top) / bounds.height));
@@ -180,49 +186,163 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
</script>
<template>
<section class="canvas-shell" aria-label="Document annotation canvas">
<section class="canvas-shell" :aria-label="readonlyMode ? 'Document readonly canvas' : 'Document annotation canvas'">
<header v-if="imageUrl" class="canvas-toolbar">
<div class="toolbar-actions"><button type="button" :disabled="undoDisabled" :title="t('admin.shippingOrderProfiles.workbench.undo')" @click="emit('undo')"><RotateCcw /></button><button type="button" :disabled="redoDisabled" :title="t('admin.shippingOrderProfiles.workbench.redo')" @click="emit('redo')"><Redo2 /></button><span class="toolbar-divider" aria-hidden="true" /><button type="button" :disabled="duplicateDisabled" :title="t('admin.shippingOrderProfiles.workbench.duplicateRegionShortcut')" @click="emit('duplicate')"><Copy /></button><button type="button" class="delete-action" :disabled="deleteDisabled" :title="t('admin.shippingOrderProfiles.workbench.deleteRegionShortcut')" @click="emit('delete')"><Trash2 /></button><span class="toolbar-divider" aria-hidden="true" /><button type="button" class="save-action" :disabled="saveDisabled || saving" :title="t('admin.save')" @click="emit('save')"><Save /><span>{{ saving ? t('admin.shippingOrderProfiles.saving') : t('admin.save') }}</span></button></div>
<div class="page-control"><button type="button" :disabled="pageNo <= 1" :title="t('admin.shippingOrderExtractionRuns.previous')" @click="emit('page', pageNo - 1)"><ArrowLeft /></button><label><input v-model.number="pageInput" type="number" min="1" :max="pageCount" :aria-label="t('admin.shippingOrderProfiles.workbench.pageNavigation')" @change="goToPage" @keydown.enter.prevent="goToPage" /><span>/ {{ pageCount }}</span></label><button type="button" :disabled="pageNo >= pageCount" :title="t('admin.shippingOrderExtractionRuns.next')" @click="emit('page', pageNo + 1)"><ArrowRight /></button></div>
<div class="zoom-control"><button type="button" :disabled="zoom <= .5" :title="t('admin.shippingOrderProfiles.workbench.zoomOut')" @click="adjustZoom(-.25)"><Minus /></button><output>{{ zoomPercent }}%</output><button type="button" :disabled="zoom >= 4" :title="t('admin.shippingOrderProfiles.workbench.zoomIn')" @click="adjustZoom(.25)"><Plus /></button><button type="button" class="fit-action" @click="resetZoom">{{ t('admin.shippingOrderProfiles.workbench.fitPage') }}</button></div>
<div class="toolbar-actions">
<template v-if="!readonlyMode">
<button type="button" :disabled="undoDisabled" :title="t('admin.shippingOrderProfiles.workbench.undo')" @click="emit('undo')"><RotateCcw /></button>
<button type="button" :disabled="redoDisabled" :title="t('admin.shippingOrderProfiles.workbench.redo')" @click="emit('redo')"><Redo2 /></button>
<span class="toolbar-divider" aria-hidden="true" />
<button type="button" :disabled="duplicateDisabled" :title="t('admin.shippingOrderProfiles.workbench.duplicateRegionShortcut')" @click="emit('duplicate')"><Copy /></button>
<button type="button" class="delete-action" :disabled="deleteDisabled" :title="t('admin.shippingOrderProfiles.workbench.deleteRegionShortcut')" @click="emit('delete')"><Trash2 /></button>
<span class="toolbar-divider" aria-hidden="true" />
<button type="button" class="save-action" :disabled="saveDisabled || saving" :title="t('admin.save')" @click="emit('save')"><Save /><span>{{ saving ? t('admin.shippingOrderProfiles.saving') : t('admin.save') }}</span></button>
</template>
<span v-else class="readonly-badge">{{ t('admin.shippingOrderProfiles.versionCenter.readonlyCanvasBadge') }}</span>
</div>
<div class="page-control">
<button type="button" :disabled="pageNo <= 1" :title="t('admin.shippingOrderExtractionRuns.previous')" @click="emit('page', pageNo - 1)"><ArrowLeft /></button>
<label><input v-model.number="pageInput" type="number" min="1" :max="pageCount" :aria-label="t('admin.shippingOrderProfiles.workbench.pageNavigation')" @change="goToPage" @keydown.enter.prevent="goToPage" /><span>/ {{ pageCount }}</span></label>
<button type="button" :disabled="pageNo >= pageCount" :title="t('admin.shippingOrderExtractionRuns.next')" @click="emit('page', pageNo + 1)"><ArrowRight /></button>
</div>
<div class="zoom-control">
<button type="button" :disabled="zoom <= .5" :title="t('admin.shippingOrderProfiles.workbench.zoomOut')" @click="adjustZoom(-.25)"><Minus /></button>
<output>{{ zoomPercent }}%</output>
<button type="button" :disabled="zoom >= 4" :title="t('admin.shippingOrderProfiles.workbench.zoomIn')" @click="adjustZoom(.25)"><Plus /></button>
<button type="button" class="fit-action" @click="resetZoom">{{ t('admin.shippingOrderProfiles.workbench.fitPage') }}</button>
</div>
</header>
<div v-if="loading" class="canvas-state">{{ t('admin.shippingOrderProfiles.workbench.loadingPage') }}</div>
<div v-else-if="!imageUrl" class="canvas-state">{{ t('admin.shippingOrderProfiles.workbench.selectBoundPdf') }}</div>
<div v-else class="canvas-work-area"><aside class="annotation-tools" :class="{ collapsed: !toolsOpen }"><button type="button" class="tools-toggle" :aria-expanded="toolsOpen" :aria-label="toolsOpen ? t('admin.shippingOrderProfiles.workbench.hideAnnotationTools') : t('admin.shippingOrderProfiles.workbench.showAnnotationTools')" @click="toolsOpen = !toolsOpen"><BoxSelect /><span v-if="toolsOpen">{{ t('admin.shippingOrderProfiles.workbench.annotationTools') }}</span></button><template v-if="toolsOpen"><button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawOrderAnchor')" :class="{ active: creationKind === 'order_anchor' }" @click="emit('draw', 'order_anchor')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.orderAnchorTool') }}</span></button><button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawOrderField')" :class="{ active: creationKind === 'order_field' }" @click="emit('draw', 'order_field')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.orderField') }}</span></button><button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawHeader')" :class="{ active: creationKind === 'header_field' }" @click="emit('draw', 'header_field')"><TableProperties /><span>{{ t('admin.shippingOrderProfiles.workbench.headerTool') }}</span></button><button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawLine')" :class="{ active: creationKind === 'line' }" @click="emit('draw', 'line')"><ScanLine /><span>{{ t('admin.shippingOrderProfiles.workbench.lineTool') }}</span></button><button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawField')" :class="{ active: creationKind === 'field' }" @click="emit('draw', 'field')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.fieldTool') }}</span></button><button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawExclusion')" :class="{ active: creationKind === 'exclusion' }" @click="emit('draw', 'exclusion')"><Eraser /><span>{{ t('admin.shippingOrderProfiles.workbench.exclusionTool') }}</span></button><button type="button" class="suggest" :disabled="autoSuggestDisabled || suggesting" @click="emit('suggest')"><Sparkles /><span>{{ suggesting ? t('admin.shippingOrderProfiles.workbench.autoSuggestRunning') : t('admin.shippingOrderProfiles.workbench.autoSuggest') }}</span></button><p v-if="suggestionProgress" class="suggestion-progress" :class="{ failed: !suggesting }">{{ suggestionProgress }}</p></template></aside><div ref="viewport" class="canvas-viewport" :class="{ panning: !creationKind }" @wheel.prevent="handleWheel"><div ref="canvas" class="canvas-stage" :class="{ drawing: creationKind }" :style="{ '--canvas-zoom': zoom }" @pointerdown="beginCreation">
<img :src="imageUrl" alt="Controlled document page preview" draggable="false" />
<div
v-for="region in regions"
:key="region.id"
role="button"
tabindex="0"
class="region"
:class="[`region-${region.kind}`, { selected: selected.has(region.id) }]"
:style="{ left: `${region.region.x0 * 100}%`, top: `${region.region.y0 * 100}%`, width: `${(region.region.x1 - region.region.x0) * 100}%`, height: `${(region.region.y1 - region.region.y0) * 100}%` }"
@pointerdown.stop="beginDrag($event, region, 'move')"
@keydown.enter="emit('select', region.id)"
@keydown.space.prevent="emit('select', region.id)"
><span class="region-label" @pointerdown.stop="beginDrag($event, region, 'move')">{{ region.label }}</span><template v-if="region.kind === 'line'"><span v-for="edge in ['n', 'e', 's', 'w']" :key="edge" class="line-hit-edge" :class="`line-hit-${edge}`" @pointerdown.stop="beginDrag($event, region, 'move')" /></template><button v-for="handle in ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'] as ResizeHandle[]" :key="handle" type="button" class="resize-handle" :class="`handle-${handle}`" :aria-label="t('admin.shippingOrderProfiles.workbench.resizeHandle', { direction: handle })" @pointerdown.stop="beginDrag($event, region, handle)" /></div>
<div v-if="creationRegion" class="creation-region" :style="{ left: `${creationRegion.x0 * 100}%`, top: `${creationRegion.y0 * 100}%`, width: `${(creationRegion.x1 - creationRegion.x0) * 100}%`, height: `${(creationRegion.y1 - creationRegion.y0) * 100}%` }" />
</div></div></div>
<div v-else class="canvas-work-area" :class="{ readonly: readonlyMode }">
<aside v-if="!readonlyMode" class="annotation-tools" :class="{ collapsed: !toolsOpen }">
<button type="button" class="tools-toggle" :aria-expanded="toolsOpen" :aria-label="toolsOpen ? t('admin.shippingOrderProfiles.workbench.hideAnnotationTools') : t('admin.shippingOrderProfiles.workbench.showAnnotationTools')" @click="toolsOpen = !toolsOpen"><BoxSelect /><span v-if="toolsOpen">{{ t('admin.shippingOrderProfiles.workbench.annotationTools') }}</span></button>
<template v-if="toolsOpen">
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawOrderAnchor')" :class="{ active: creationKind === 'order_anchor' }" @click="emit('draw', 'order_anchor')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.orderAnchorTool') }}</span></button>
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawOrderField')" :class="{ active: creationKind === 'order_field' }" @click="emit('draw', 'order_field')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.orderField') }}</span></button>
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawHeader')" :class="{ active: creationKind === 'header_field' }" @click="emit('draw', 'header_field')"><TableProperties /><span>{{ t('admin.shippingOrderProfiles.workbench.headerTool') }}</span></button>
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawLine')" :class="{ active: creationKind === 'line' }" @click="emit('draw', 'line')"><ScanLine /><span>{{ t('admin.shippingOrderProfiles.workbench.lineTool') }}</span></button>
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawField')" :class="{ active: creationKind === 'field' }" @click="emit('draw', 'field')"><BoxSelect /><span>{{ t('admin.shippingOrderProfiles.workbench.fieldTool') }}</span></button>
<button type="button" :title="t('admin.shippingOrderProfiles.workbench.drawExclusion')" :class="{ active: creationKind === 'exclusion' }" @click="emit('draw', 'exclusion')"><Eraser /><span>{{ t('admin.shippingOrderProfiles.workbench.exclusionTool') }}</span></button>
<button type="button" class="suggest" :disabled="autoSuggestDisabled || suggesting" @click="emit('suggest')"><Sparkles /><span>{{ suggesting ? t('admin.shippingOrderProfiles.workbench.autoSuggestRunning') : t('admin.shippingOrderProfiles.workbench.autoSuggest') }}</span></button>
<p v-if="suggestionProgress" class="suggestion-progress" :class="{ failed: !suggesting }">{{ suggestionProgress }}</p>
</template>
</aside>
<div ref="viewport" class="canvas-viewport" :class="{ panning: !creationKind || readonlyMode }" @wheel.prevent="handleWheel">
<div ref="canvas" class="canvas-stage" :class="{ drawing: creationKind && !readonlyMode }" :style="{ '--canvas-zoom': zoom }" @pointerdown="beginCreation">
<img :src="imageUrl" alt="Controlled document page preview" draggable="false" />
<div
v-for="region in regions"
:key="region.id"
role="button"
tabindex="0"
class="region"
:class="[`region-${region.kind}`, { selected: selected.has(region.id) }]"
:style="{ left: `${region.region.x0 * 100}%`, top: `${region.region.y0 * 100}%`, width: `${(region.region.x1 - region.region.x0) * 100}%`, height: `${(region.region.y1 - region.region.y0) * 100}%` }"
@pointerdown.stop="beginDrag($event, region, 'move')"
@keydown.enter="emit('select', region.id)"
@keydown.space.prevent="emit('select', region.id)"
>
<span class="region-label" @pointerdown.stop="beginDrag($event, region, 'move')">{{ region.label }}</span>
<template v-if="region.kind === 'line' && !readonlyMode">
<span v-for="edge in ['n', 'e', 's', 'w']" :key="edge" class="line-hit-edge" :class="`line-hit-${edge}`" @pointerdown.stop="beginDrag($event, region, 'move')" />
</template>
<button v-if="!readonlyMode" v-for="handle in ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw'] as ResizeHandle[]" :key="handle" type="button" class="resize-handle" :class="`handle-${handle}`" :aria-label="t('admin.shippingOrderProfiles.workbench.resizeHandle', { direction: handle })" @pointerdown.stop="beginDrag($event, region, handle)" />
</div>
<div v-if="creationRegion" class="creation-region" :style="{ left: `${creationRegion.x0 * 100}%`, top: `${creationRegion.y0 * 100}%`, width: `${(creationRegion.x1 - creationRegion.x0) * 100}%`, height: `${(creationRegion.y1 - creationRegion.y0) * 100}%` }" />
</div>
</div>
</div>
</section>
</template>
<style scoped>
.canvas-shell { min-height: 36rem; 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; }.canvas-toolbar button:hover { border-color: #60a5fa; background: #26364f; }.canvas-toolbar button:disabled { cursor: not-allowed; opacity: .4; }.canvas-toolbar svg,.annotation-tools svg { width: .95rem; height: .95rem; }.toolbar-actions { justify-self: start; }.toolbar-divider { width: 1px; height: 1.25rem; margin: 0 .15rem; background: #475569; }.toolbar-actions .delete-action:not(:disabled) { color: #fecaca; }.toolbar-actions .delete-action:not(:disabled):hover { border-color: #f87171; background: #7f1d1d; color: #fff; }.toolbar-actions .save-action { border-color: #0284c7; background: #0284c7; padding-inline: .65rem; }.page-control { justify-self: center; }.page-control label { display: flex; height: 2rem; align-items: center; gap: .3rem; border: 1px solid #475569; border-radius: .35rem; background: #0f172a; padding: 0 .45rem; color: #94a3b8; }.page-control input { width: 3rem; border: 0; background: transparent; color: #f8fafc; font: 700 .76rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; outline: 0; }.zoom-control { justify-self: end; }.canvas-toolbar output { min-width: 3.4rem; color: #f8fafc; text-align: center; }.zoom-control .fit-action { padding-inline: .65rem; }
.canvas-shell { min-height: 36rem; 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; }
.canvas-toolbar button:hover { border-color: #60a5fa; background: #26364f; }
.canvas-toolbar button:disabled { cursor: not-allowed; opacity: .4; }
.canvas-toolbar svg, .annotation-tools svg { width: .95rem; height: .95rem; }
.toolbar-actions { justify-self: start; }
.toolbar-divider { width: 1px; height: 1.25rem; margin: 0 .15rem; background: #475569; }
.toolbar-actions .delete-action:not(:disabled) { color: #fecaca; }
.toolbar-actions .delete-action:not(:disabled):hover { border-color: #f87171; background: #7f1d1d; color: #fff; }
.toolbar-actions .save-action { border-color: #0284c7; background: #0284c7; padding-inline: .65rem; }
.readonly-badge { display: inline-flex; align-items: center; min-height: 2rem; border: 1px solid #475569; border-radius: .35rem; background: #0f172a; padding: 0 .65rem; color: #cbd5e1; }
.page-control { justify-self: center; }
.page-control label { display: flex; height: 2rem; align-items: center; gap: .3rem; border: 1px solid #475569; border-radius: .35rem; background: #0f172a; padding: 0 .45rem; color: #94a3b8; }
.page-control input { width: 3rem; border: 0; background: transparent; color: #f8fafc; font: 700 .76rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; outline: 0; }
.zoom-control { justify-self: end; }
.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-viewport { position: relative; min-width: 0; flex: 1; overflow: auto; }.canvas-viewport.panning { cursor: grab; }.canvas-viewport.panning:active { cursor: grabbing; }.canvas-stage { position: relative; margin: auto; width: calc(100% * var(--canvas-zoom)); min-width: 42rem; box-shadow: 0 16px 40px rgba(0,0,0,.35); }.canvas-stage img { display: block; width: 100%; user-select: none; }.canvas-stage.drawing { cursor: crosshair; }.creation-region { position: absolute; z-index: 5; box-sizing: border-box; border: 2px dashed #34d399; background: rgb(16 185 129 / .18); pointer-events: none; }
.annotation-tools { display: grid; align-content: start; gap: .3rem; flex: 0 0 7rem; padding: .35rem; border: 1px solid rgb(71 85 105 / .9); border-radius: .5rem; background: rgb(15 23 42 / .94); box-shadow: 0 8px 24px rgb(15 23 42 / .3); }.annotation-tools.collapsed { flex-basis: 2.45rem; padding: .3rem; }.annotation-tools button { display: flex; min-height: 2rem; align-items: center; gap: .4rem; border: 1px solid transparent; border-radius: .35rem; background: #1e293b; padding: .35rem .45rem; color: #e2e8f0; font-size: .7rem; text-align: left; white-space: nowrap; }.annotation-tools button:hover,.annotation-tools button.active { border-color: #38bdf8; background: #0c4a6e; color: #f0f9ff; }.annotation-tools .tools-toggle { justify-content: center; }.annotation-tools.collapsed .tools-toggle { padding-inline: 0; }.annotation-tools .suggest { border-color: #0ea5e9; background: #0284c7; font-weight: 700; }.annotation-tools button:disabled { cursor: not-allowed; opacity: .45; }.suggestion-progress { margin: .1rem; color: #bae6fd; font-size: .66rem; line-height: 1.35; }.suggestion-progress.failed { color: #fca5a5; }
.region { position: absolute; box-sizing: border-box; z-index: 2; border: 2px solid #38bdf8; background: rgb(14 165 233 / .10); color: #e0f2fe; cursor: move; text-align: left; touch-action: none; }.region:focus-visible { outline: 3px solid white; outline-offset: 2px; }
.canvas-work-area { display: flex; max-height: 43rem; gap: .6rem; }
.canvas-work-area.readonly { gap: 0; }
.canvas-viewport { position: relative; min-width: 0; flex: 1; overflow: auto; }
.canvas-viewport.panning { cursor: grab; }
.canvas-viewport.panning:active { cursor: grabbing; }
.canvas-stage { position: relative; margin: auto; width: calc(100% * var(--canvas-zoom)); min-width: 42rem; box-shadow: 0 16px 40px rgba(0,0,0,.35); }
.canvas-stage img { display: block; width: 100%; user-select: none; }
.canvas-stage.drawing { cursor: crosshair; }
.creation-region { position: absolute; z-index: 5; box-sizing: border-box; border: 2px dashed #34d399; background: rgb(16 185 129 / .18); pointer-events: none; }
.annotation-tools { display: grid; align-content: start; gap: .3rem; flex: 0 0 7rem; padding: .35rem; border: 1px solid rgb(71 85 105 / .9); border-radius: .5rem; background: rgb(15 23 42 / .94); box-shadow: 0 8px 24px rgb(15 23 42 / .3); }
.annotation-tools.collapsed { flex-basis: 2.45rem; padding: .3rem; }
.annotation-tools button { display: flex; min-height: 2rem; align-items: center; gap: .4rem; border: 1px solid transparent; border-radius: .35rem; background: #1e293b; padding: .35rem .45rem; color: #e2e8f0; font-size: .7rem; text-align: left; white-space: nowrap; }
.annotation-tools button:hover, .annotation-tools button.active { border-color: #38bdf8; background: #0c4a6e; color: #f0f9ff; }
.annotation-tools .tools-toggle { justify-content: center; }
.annotation-tools.collapsed .tools-toggle { padding-inline: 0; }
.annotation-tools .suggest { border-color: #0ea5e9; background: #0284c7; font-weight: 700; }
.annotation-tools button:disabled { cursor: not-allowed; opacity: .45; }
.suggestion-progress { margin: .1rem; color: #bae6fd; font-size: .66rem; line-height: 1.35; }
.suggestion-progress.failed { color: #fca5a5; }
.region { position: absolute; box-sizing: border-box; z-index: 2; border: 2px solid #38bdf8; background: rgb(14 165 233 / .10); color: #e0f2fe; cursor: move; text-align: left; touch-action: none; }
.region:focus-visible { outline: 3px solid white; outline-offset: 2px; }
.region-label { position: absolute; top: -1.65rem; left: -2px; max-width: min(18rem, 100%); overflow: hidden; border: 1px solid rgb(255 255 255 / .7); border-radius: .25rem .25rem 0 0; background: #0369a1; padding: .2rem .45rem; color: white; font: 700 .7rem/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.resize-handle { position: absolute; z-index: 3; width: 10px; height: 10px; border: 2px solid white; border-radius: 2px; background: #0ea5e9; box-shadow: 0 1px 2px rgb(15 23 42 / .55); padding: 0; touch-action: none; }.handle-n,.handle-s { left: 50%; margin-left: -5px; cursor: ns-resize; }.handle-e,.handle-w { top: 50%; margin-top: -5px; cursor: ew-resize; }.handle-nw,.handle-se { cursor: nwse-resize; }.handle-ne,.handle-sw { cursor: nesw-resize; }.handle-n,.handle-nw,.handle-ne { top: -6px; }.handle-s,.handle-sw,.handle-se { bottom: -6px; }.handle-e,.handle-ne,.handle-se { right: -6px; }.handle-w,.handle-nw,.handle-sw { left: -6px; }
.region-header_field { z-index: 2; border: 1.5px solid #f59e0b; background: rgb(245 158 11 / .08); }.region-header_field .region-label,.region-header_field .resize-handle { background: #b45309; }
.region-order_field { z-index: 2; border: 1.5px solid #22c55e; background: rgb(34 197 94 / .08); }.region-order_field .region-label,.region-order_field .resize-handle { background: #15803d; }
.region-order_anchor { z-index: 2; border: 1.5px solid #a855f7; background: rgb(168 85 247 / .08); }.region-order_anchor .region-label,.region-order_anchor .resize-handle { background: #7e22ce; }
.region-line { z-index: 0; border-color: #a78bfa; background: rgb(167 139 250 / .1); pointer-events: none; }.region-line .region-label,.region-line .line-hit-edge,.region-line.selected .resize-handle { pointer-events: auto; }.region-line .region-label,.region-line .resize-handle { background: #6d28d9; }
.line-hit-edge { position: absolute; z-index: 2; display: block; }.line-hit-n,.line-hit-s { right: -6px; left: -6px; height: 12px; cursor: move; }.line-hit-e,.line-hit-w { top: 6px; bottom: 6px; width: 12px; cursor: move; }.line-hit-n { top: -6px; }.line-hit-e { right: -6px; }.line-hit-s { bottom: -6px; }.line-hit-w { left: -6px; }
.region-exclusion { z-index: 3; border-style: dashed; border-color: #f87171; background: rgb(248 113 113 / .1); }.region-exclusion .region-label,.region-exclusion .resize-handle { background: #b91c1c; }
.region:not(.selected) .resize-handle { display: none; }.region.selected { outline: 3px solid white; outline-offset: 2px; }.region.selected:not(.region-line) { z-index: 4; }
.resize-handle { position: absolute; z-index: 3; width: 10px; height: 10px; border: 2px solid white; border-radius: 2px; background: #0ea5e9; box-shadow: 0 1px 2px rgb(15 23 42 / .55); padding: 0; touch-action: none; }
.handle-n, .handle-s { left: 50%; margin-left: -5px; cursor: ns-resize; }
.handle-e, .handle-w { top: 50%; margin-top: -5px; cursor: ew-resize; }
.handle-nw, .handle-se { cursor: nwse-resize; }
.handle-ne, .handle-sw { cursor: nesw-resize; }
.handle-n, .handle-nw, .handle-ne { top: -6px; }
.handle-s, .handle-sw, .handle-se { bottom: -6px; }
.handle-e, .handle-ne, .handle-se { right: -6px; }
.handle-w, .handle-nw, .handle-sw { left: -6px; }
.region-header_field { z-index: 2; border: 1.5px solid #f59e0b; background: rgb(245 158 11 / .08); }
.region-header_field .region-label, .region-header_field .resize-handle { background: #b45309; }
.region-order_field { z-index: 2; border: 1.5px solid #22c55e; background: rgb(34 197 94 / .08); }
.region-order_field .region-label, .region-order_field .resize-handle { background: #15803d; }
.region-order_anchor { z-index: 2; border: 1.5px solid #a855f7; background: rgb(168 85 247 / .08); }
.region-order_anchor .region-label, .region-order_anchor .resize-handle { background: #7e22ce; }
.region-line { z-index: 0; border-color: #a78bfa; background: rgb(167 139 250 / .1); pointer-events: none; }
.region-line .region-label, .region-line .line-hit-edge, .region-line.selected .resize-handle { pointer-events: auto; }
.region-line .region-label, .region-line .resize-handle { background: #6d28d9; }
.line-hit-edge { position: absolute; z-index: 2; display: block; }
.line-hit-n, .line-hit-s { right: -6px; left: -6px; height: 12px; cursor: move; }
.line-hit-e, .line-hit-w { top: 6px; bottom: 6px; width: 12px; cursor: move; }
.line-hit-n { top: -6px; }
.line-hit-e { right: -6px; }
.line-hit-s { bottom: -6px; }
.line-hit-w { left: -6px; }
.region-exclusion { z-index: 3; border-style: dashed; border-color: #f87171; background: rgb(248 113 113 / .1); }
.region-exclusion .region-label, .region-exclusion .resize-handle { background: #b91c1c; }
.region:not(.selected) .resize-handle { display: none; }
.region.selected { outline: 3px solid white; outline-offset: 2px; }
.region.selected:not(.region-line) { z-index: 4; }
.canvas-stage.drawing .region { pointer-events: none; }
@media (max-width: 900px) { .canvas-toolbar { grid-template-columns: 1fr auto; }.page-control { grid-column: 1 / -1; grid-row: 2; }.zoom-control { justify-self: end; }.canvas-stage { min-width: 32rem; }.canvas-viewport { max-height: 32rem; } } @media (max-width: 640px) { .canvas-shell { min-height: 24rem; padding-inline: .5rem; }.canvas-toolbar { margin-inline: -.5rem; padding-inline: .5rem; }.toolbar-actions .save-action span,.fit-action { display: none; }.annotation-tools { flex-basis: 2.45rem; }.annotation-tools button span,.suggestion-progress { display: none; } }
@media (max-width: 900px) {
.canvas-toolbar { grid-template-columns: 1fr auto; }
.page-control { grid-column: 1 / -1; grid-row: 2; }
.zoom-control { justify-self: end; }
.canvas-stage { min-width: 32rem; }
.canvas-viewport { max-height: 32rem; }
}
@media (max-width: 640px) {
.canvas-shell { min-height: 24rem; padding-inline: .5rem; }
.canvas-toolbar { margin-inline: -.5rem; padding-inline: .5rem; }
.toolbar-actions .save-action span, .fit-action { display: none; }
.annotation-tools { flex-basis: 2.45rem; }
.annotation-tools button span, .suggestion-progress { display: none; }
}
.tools-toggle span { display: none; }
</style>
@@ -0,0 +1,117 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileFrozenEvidencePanel.vue
用途:展示当前只读样本绑定的冻结证据信息。
依赖:版本详情样本 DTO、i18n。
逻辑:只渲染冻结身份与快照摘要,不泄露正文、对象存储地址或盲测真值。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { OrderProfileBoundSample } from '@/features/admin/types/shipping-order-document-profile.types';
const props = defineProps<{
sample: OrderProfileBoundSample | null;
}>();
const { t } = useI18n();
const frozenStatus = computed(() => (
props.sample?.frozen_evidence_ready
? t('admin.shippingOrderProfiles.versionCenter.frozenEvidence.ready')
: t('admin.shippingOrderProfiles.versionCenter.frozenEvidence.missing')
));
</script>
<template>
<aside class="panel">
<h3>{{ t('admin.shippingOrderProfiles.versionCenter.frozenEvidencePanelTitle') }}</h3>
<p v-if="!sample" class="empty">{{ t('admin.shippingOrderProfiles.versionCenter.selectSampleHint') }}</p>
<dl v-else class="grid">
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.statusLabel') }}</dt>
<dd>{{ frozenStatus }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.sampleFile') }}</dt>
<dd>{{ sample.source_filename_snapshot || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.layoutVersionId') }}</dt>
<dd>{{ sample.layout_version_id || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.evidenceFrozenAt') }}</dt>
<dd>{{ sample.evidence_frozen_at || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.pageCountPlain') }}</dt>
<dd>{{ sample.page_count_snapshot || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.parserIdentity') }}</dt>
<dd>{{ sample.parser_name || sample.parser_key || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.parserVersionTitle') }}</dt>
<dd>{{ sample.parser_version || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.frozenTableId') }}</dt>
<dd>{{ sample.table_identity_snapshot?.table_id || sample.table_id || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.frozenPageNo') }}</dt>
<dd>{{ sample.table_identity_snapshot?.page_no || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.frozenRowCount') }}</dt>
<dd>{{ sample.table_identity_snapshot?.row_count || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.layoutChecksumTitle') }}</dt>
<dd><code>{{ sample.layout_payload_checksum || '-' }}</code></dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.contentHashTitle') }}</dt>
<dd><code>{{ sample.source_content_hash || '-' }}</code></dd>
</div>
</dl>
</aside>
</template>
<style scoped>
.panel {
border: 1px solid #e2e8f0;
border-radius: 1rem;
background: #fff;
padding: 1rem;
}
.panel h3 {
margin: 0;
color: #0f172a;
}
.empty {
margin: 0.85rem 0 0;
color: #64748b;
}
.grid {
display: grid;
gap: 0.85rem;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
margin: 0.9rem 0 0;
}
.grid dt {
color: #64748b;
font-size: 0.75rem;
}
.grid dd {
margin: 0.3rem 0 0;
color: #0f172a;
word-break: break-word;
}
</style>
@@ -0,0 +1,19 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileIdentityStep.vue
用途:收集创建向导第一步的模板身份与 Schema。
依赖:Schema DTO、Vue I18n。
逻辑:仅双向绑定浏览器状态,不调用创建 API,profile_code 在完成后由服务端永久冻结。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderSchemaVersion } from '@/features/admin/types/shipping-order-schema.types';
const props = defineProps<{ modelValue: { displayName: string; profileCode: string; schemaId: number }; schemas: ShippingOrderSchemaVersion[] }>();
const emit = defineEmits<{ 'update:modelValue': [value: { displayName: string; profileCode: string; schemaId: number }] }>();
const { t } = useI18n();
const publishedSchemas = computed(() => props.schemas.filter((item) => item.status === 'published'));
/** 更新单个身份字段但不触发创建;向导刷新前没有正式 Profile。 */
function update(key: 'displayName' | 'profileCode' | 'schemaId', value: string | number): void { emit('update:modelValue', { ...props.modelValue, [key]: value }); }
</script>
<template><div class="wizard-step"><label>{{ t('admin.shippingOrderProfiles.name') }}<input :value="modelValue.displayName" @input="update('displayName', ($event.target as HTMLInputElement).value)"></label><label>{{ t('admin.shippingOrderProfiles.code') }}<input :value="modelValue.profileCode" @input="update('profileCode', ($event.target as HTMLInputElement).value.toUpperCase())"></label><small>{{ t('admin.shippingOrderProfiles.wizard.codeHint') }}</small><label>{{ t('admin.shippingOrderProfiles.schema') }}<select :value="modelValue.schemaId" @change="update('schemaId', Number(($event.target as HTMLSelectElement).value))"><option :value="0">{{ t('admin.shippingOrderProfiles.wizard.selectSchema') }}</option><option v-for="schema in publishedSchemas" :key="schema.id" :value="schema.id">v{{ schema.version }}</option></select></label></div></template>
<style scoped>.wizard-step{display:grid;gap:1rem;max-width:36rem}.wizard-step label{display:grid;gap:.35rem;font-weight:600}.wizard-step input,.wizard-step select{padding:.6rem;border:1px solid #cbd5e1;border-radius:.4rem}small{color:#64748b}</style>
@@ -0,0 +1,14 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileModelStartStep.vue
用途:确认样本文档中作为建模起点的主表格。
依赖:样本表格预览 DTO、Vue I18n。
逻辑:只让用户选定服务端已发现的 table_id;缺少有效表格时禁止完成向导。
-->
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const props = defineProps<{ tables: Array<{ table_id: string; page_no: number; row_count: number; column_count: number; rows: string[][] }>; modelValue: string }>();
const emit = defineEmits<{ 'update:modelValue': [value: string] }>();
const { t } = useI18n();
</script>
<template><div class="wizard-step"><label>{{ t('admin.shippingOrderProfiles.table') }}<select :value="modelValue" @change="emit('update:modelValue', ($event.target as HTMLSelectElement).value)"><option value="">{{ t('admin.shippingOrderProfiles.selectTable') }}</option><option v-for="table in tables" :key="table.table_id" :value="table.table_id">{{ t('admin.shippingOrderProfiles.wizard.tableOption', { page: table.page_no, rows: table.row_count, columns: table.column_count }) }}</option></select></label><p v-if="!tables.length">{{ t('admin.shippingOrderProfiles.wizard.noTable') }}</p><table v-else-if="modelValue"><tbody><tr v-for="row in tables.find((item) => item.table_id === modelValue)?.rows.slice(0, 4) || []" :key="row.join('|')"><td v-for="cell in row" :key="cell">{{ cell }}</td></tr></tbody></table></div></template>
<style scoped>.wizard-step{display:grid;gap:1rem}.wizard-step label{display:grid;gap:.35rem;font-weight:600}.wizard-step select{padding:.6rem;border:1px solid #cbd5e1;border-radius:.4rem}table{border-collapse:collapse}td{padding:.35rem;border:1px solid #e2e8f0}p{color:#b45309}</style>
@@ -0,0 +1,249 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileReadOnlyCanvas.vue
用途:在版本详情页展示基于冻结样本绑定的只读画布。
依赖:冻结样本预览 API、OrderProfileDocumentCanvas、冻结证据面板。
逻辑:只允许 annotation/training 样本进入普通画布;blind_test 继续留在摘要层,不进入样本选择器。
-->
<script setup lang="ts">
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 type {
OrderProfileBoundSample,
OrderProfilePreviewPages,
ShippingOrderDocumentProfile,
} from '@/features/admin/types/shipping-order-document-profile.types';
import OrderProfileDocumentCanvas from './OrderProfileDocumentCanvas.vue';
import OrderProfileFrozenEvidencePanel from './OrderProfileFrozenEvidencePanel.vue';
import { buildOrderProfileReadonlyRegions } from '../orderProfileReadonlyCanvas.utils';
const props = defineProps<{
detail: ShippingOrderDocumentProfile;
}>();
const { t } = useI18n();
const loading = ref(false);
const errorMessage = ref('');
const selectedSampleId = ref<number | null>(null);
const selectedRegionId = ref<string | null>(null);
const previewPages = ref<OrderProfilePreviewPages | null>(null);
const pageNo = ref(1);
const readonlySamples = computed(() =>
(props.detail.sample_summary?.samples || []).filter((sample) => sample.sample_role !== 'blind_test'),
);
const selectedSample = computed<OrderProfileBoundSample | null>(() =>
readonlySamples.value.find((sample) => sample.id === selectedSampleId.value) || null,
);
const readonlyRegions = computed(() => buildOrderProfileReadonlyRegions(props.detail));
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(() =>
previewPages.value?.pages.find((item) => item.page_no === pageNo.value) || null,
);
const previewPagePath = computed(() => (
props.detail.id && selectedSample.value
? `/api/admin/shipping-notice/order-document-profiles/${props.detail.id}/samples/${selectedSample.value.id}/preview-pages`
: null
));
const immutable = computed(() => props.detail.status !== 'draft');
const sampleLabel = (sample: OrderProfileBoundSample) => {
const tableLabel = sample.table_identity_snapshot?.table_id || sample.table_id || '-';
return `${sample.source_filename_snapshot || `#${sample.id}`} · ${tableLabel}`;
};
const loadPreview = async (sampleId: number | null) => {
if (!sampleId || !immutable.value) {
previewPages.value = null;
errorMessage.value = '';
return;
}
loading.value = true;
errorMessage.value = '';
selectedRegionId.value = null;
try {
const payload = await authorizeOrderProfileFrozenSamplePreviewPages(props.detail.id, sampleId);
previewPages.value = payload;
const preferredPage = selectedSample.value?.table_identity_snapshot?.page_no || 1;
pageNo.value = Math.max(1, Math.min(payload.page_count || 1, preferredPage));
} catch (error) {
previewPages.value = null;
errorMessage.value = error instanceof BusinessError
? error.message
: t('admin.shippingOrderProfiles.versionCenter.canvasLoadFailed');
} finally {
loading.value = false;
}
};
watch(
() => props.detail.id,
() => {
const firstReady = readonlySamples.value.find((sample) => sample.frozen_evidence_ready) || readonlySamples.value[0] || null;
selectedSampleId.value = firstReady?.id || null;
},
{ immediate: true },
);
watch(selectedSampleId, (value) => {
void loadPreview(value);
}, { immediate: true });
</script>
<template>
<section class="readonly-layout">
<div v-if="!immutable" class="state-card">
{{ t('admin.shippingOrderProfiles.versionCenter.draftCanvasHint') }}
</div>
<div v-else-if="!readonlySamples.length" class="state-card">
{{ t('admin.shippingOrderProfiles.versionCenter.noReadableSamples') }}
</div>
<template v-else>
<div class="toolbar">
<label class="field">
<span>{{ t('admin.shippingOrderProfiles.versionCenter.readonlySample') }}</span>
<select v-model.number="selectedSampleId">
<option v-for="sample in readonlySamples" :key="sample.id" :value="sample.id">
{{ sampleLabel(sample) }}
</option>
</select>
</label>
<p v-if="selectedSample && !selectedSample.frozen_evidence_ready" class="warning-text">
{{ t('admin.shippingOrderProfiles.versionCenter.sampleFrozenEvidenceMissing') }}
</p>
</div>
<div v-if="errorMessage" class="state-card error-card">{{ errorMessage }}</div>
<div v-else-if="loading" class="state-card">{{ t('admin.shippingOrderProfiles.versionCenter.loadingCanvas') }}</div>
<div v-else-if="selectedSample && currentGrant" class="canvas-grid">
<OrderProfileDocumentCanvas
:profile-id="detail.id"
:grant="currentGrant"
:mode="'readonly'"
:preview-page-path="previewPagePath"
:regions="pageRegions"
:selected-region-id="selectedRegionId"
:page-no="pageNo"
:page-count="previewPages?.page_count || 1"
@select="selectedRegionId = $event"
@page="pageNo = $event"
/>
<div class="side-panel">
<OrderProfileFrozenEvidencePanel :sample="selectedSample" />
<section class="panel">
<h3>{{ t('admin.shippingOrderProfiles.versionCenter.regionSummaryTitle') }}</h3>
<p v-if="!selectedRegion" class="empty">{{ t('admin.shippingOrderProfiles.versionCenter.selectRegionHint') }}</p>
<dl v-else class="grid">
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.regionLabelTitle') }}</dt>
<dd>{{ selectedRegion.label }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.regionKindTitle') }}</dt>
<dd>{{ selectedRegion.kind }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.regionFieldCodeTitle') }}</dt>
<dd>{{ selectedRegion.fieldCode || '-' }}</dd>
</div>
<div>
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.regionPageTitle') }}</dt>
<dd>{{ selectedRegion.pageNo }}</dd>
</div>
</dl>
</section>
</div>
</div>
</template>
</section>
</template>
<style scoped>
.readonly-layout {
display: grid;
gap: 1rem;
}
.toolbar,
.state-card,
.panel {
border: 1px solid #e2e8f0;
border-radius: 1rem;
background: #fff;
padding: 1rem;
}
.toolbar {
display: grid;
gap: 0.75rem;
}
.field {
display: grid;
gap: 0.35rem;
}
.field span {
color: #475569;
font-size: 0.8rem;
}
.field select {
border: 1px solid #cbd5e1;
border-radius: 0.7rem;
min-height: 2.5rem;
padding: 0 0.75rem;
}
.canvas-grid {
display: grid;
gap: 1rem;
grid-template-columns: minmax(0, 1fr) 320px;
}
.side-panel {
display: grid;
gap: 1rem;
align-content: start;
}
.grid {
display: grid;
gap: 0.75rem;
grid-template-columns: repeat(2, minmax(0, 1fr));
margin: 0.85rem 0 0;
}
.grid dt {
color: #64748b;
font-size: 0.75rem;
}
.grid dd {
margin: 0.25rem 0 0;
color: #0f172a;
word-break: break-word;
}
.warning-text {
margin: 0;
color: #b45309;
}
.error-card {
color: #b91c1c;
}
.empty {
margin: 0.75rem 0 0;
color: #64748b;
}
@media (max-width: 1180px) {
.canvas-grid {
grid-template-columns: 1fr;
}
}
</style>
@@ -0,0 +1,21 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileSampleStep.vue
用途:选择或上传模板样本,并显示其异步解析状态。
依赖:模板样本 API、文件资产上传 API、Vue I18n。
逻辑:上传只创建样本库 Intake;此步骤不创建 Profile,解析完成后才允许选择样本文档。
-->
<script setup lang="ts">
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import { uploadFileAsset } from '@/shared/api/file-assets.api';
import { createOrderProfileSample } from '@/features/admin/api/shipping-order-document-profile.api';
const props = defineProps<{ samples: Array<{ document_id: number; filename?: string | null; table_count: number; intake_no: string }>; modelValue: number }>();
const emit = defineEmits<{ 'update:modelValue': [value: number]; uploaded: [] }>();
const { t } = useI18n(); const message = useMessage(); const uploading = ref(false);
/** 上传文件后仅投递样本解析;父级轮询并刷新可选样本列表。 */
async function upload(event: Event): Promise<void> { const file = (event.target as HTMLInputElement).files?.[0]; if (!file) return; if (!/\.(pdf|eml)$/i.test(file.name)) { message.error(t('admin.shippingOrderProfiles.sampleFileTypeInvalid')); return; } uploading.value = true; try { const asset = await uploadFileAsset(file); await createOrderProfileSample(asset.asset_no); emit('uploaded'); } catch (error) { message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.wizard.uploadFailed')); } finally { uploading.value = false; } }
</script>
<template><div class="wizard-step"><label>{{ t('admin.shippingOrderProfiles.uploadSample') }}<input type="file" accept=".pdf,.eml,application/pdf,message/rfc822" :disabled="uploading" @change="upload"></label><p>{{ t('admin.shippingOrderProfiles.wizard.sampleHint') }}</p><label>{{ t('admin.shippingOrderProfiles.selectSample') }}<select :value="modelValue" @change="emit('update:modelValue', Number(($event.target as HTMLSelectElement).value))"><option :value="0">{{ t('admin.shippingOrderProfiles.selectSample') }}</option><option v-for="sample in samples" :key="sample.document_id" :value="sample.document_id">{{ sample.filename || sample.intake_no }} · {{ sample.table_count }} {{ t('admin.shippingOrderProfiles.tablesUnit') }}</option></select></label></div></template>
<style scoped>.wizard-step{display:grid;gap:1rem;max-width:36rem}.wizard-step label{display:grid;gap:.35rem;font-weight:600}.wizard-step select{padding:.6rem;border:1px solid #cbd5e1;border-radius:.4rem}p{margin:0;color:#64748b}</style>
@@ -0,0 +1,273 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileUsageTable.vue
用途:展示订单模板版本的实际使用记录,并提供进入只读 Run 审计的入口。
依赖:版本中心 usage API、Vue Router。
逻辑:只读取每个 Unit 最新 RouteDecision 的安全投影;点击行跳转到管理员 Run 诊断页,不在当前页改动任何业务状态。
-->
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BusinessError } from "@/shared/api/client";
import { listOrderDocumentProfileUsages } from "@/features/admin/api/shipping-order-document-profile.api";
import type {
OrderProfileUsagePage,
OrderProfileUsageRow,
ShippingOrderDocumentProfile,
} from "@/features/admin/types/shipping-order-document-profile.types";
const props = defineProps<{ detail: ShippingOrderDocumentProfile }>();
const { t } = useI18n();
const router = useRouter();
const loading = ref(false);
const errorMessage = ref("");
const page = ref<OrderProfileUsagePage | null>(null);
const cursorStack = ref<Array<number | null>>([]);
const activeBeforeId = ref<number | null>(null);
const hasPrevious = computed(() => cursorStack.value.length > 0);
const hasNext = computed(() => Boolean(page.value?.page.has_more && page.value?.page.next_before_id));
const formatTime = (value?: string | null) => value ? new Date(value).toLocaleString() : "-";
const translateUsageValue = (scope: "runStatuses" | "matchStatuses" | "executionStatuses" | "identityModes", value: string) =>
t(`admin.shippingOrderProfiles.versionCenter.usage.${scope}.${value}`, value);
const load = async () => {
loading.value = true;
errorMessage.value = "";
try {
page.value = await listOrderDocumentProfileUsages(props.detail.id, {
beforeId: activeBeforeId.value,
limit: 20,
});
} catch (error) {
page.value = null;
errorMessage.value = error instanceof BusinessError
? error.message
: t("admin.shippingOrderProfiles.versionCenter.usage.loadFailed");
} finally {
loading.value = false;
}
};
const loadNext = async () => {
if (!page.value?.page.next_before_id) return;
cursorStack.value.push(activeBeforeId.value);
activeBeforeId.value = page.value.page.next_before_id;
await load();
};
const loadPrevious = async () => {
if (!cursorStack.value.length) return;
activeBeforeId.value = cursorStack.value.pop() ?? null;
await load();
};
const openDiagnostic = (item: OrderProfileUsageRow) => {
void router.push({
name: item.diagnostic_entry.route_name,
query: {
runNo: item.diagnostic_entry.run_no,
},
});
};
watch(
() => props.detail.id,
() => {
activeBeforeId.value = null;
cursorStack.value = [];
void load();
},
{ immediate: true },
);
</script>
<template>
<section class="usage-panel">
<div class="toolbar">
<div>
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.usage.title") }}</h3>
<p>{{ t("admin.shippingOrderProfiles.versionCenter.usage.subtitle") }}</p>
</div>
<button type="button" class="ghost-button" :disabled="loading" @click="load">
{{ t("admin.shippingOrderProfiles.versionCenter.usage.refresh") }}
</button>
</div>
<div v-if="loading" class="state-card">
{{ t("admin.shippingOrderProfiles.versionCenter.usage.loading") }}
</div>
<div v-else-if="errorMessage" class="state-card error-card">
{{ errorMessage }}
</div>
<div v-else-if="!page?.items.length" class="state-card">
{{ t("admin.shippingOrderProfiles.versionCenter.usage.empty") }}
</div>
<div v-else class="table-wrapper">
<table>
<thead>
<tr>
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.runNo") }}</th>
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.document") }}</th>
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.matchStatus") }}</th>
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.executionStatus") }}</th>
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.identityMode") }}</th>
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.autoCreateApproved") }}</th>
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.createdAt") }}</th>
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.reasonCodes") }}</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="item in page.items" :key="item.route_decision_id">
<td>
<div class="cell-title">{{ item.run_no }}</div>
<small>{{ translateUsageValue("runStatuses", item.run_status) }}</small>
</td>
<td>
<div class="cell-title">{{ item.document_label }}</div>
<small>#{{ item.unit_position + 1 }}</small>
</td>
<td>{{ translateUsageValue("matchStatuses", item.match_status) }}</td>
<td>{{ translateUsageValue("executionStatuses", item.execution_status) }}</td>
<td>{{ translateUsageValue("identityModes", item.identity_match_mode) }}</td>
<td>
{{
item.auto_create_approved == null
? "-"
: t(item.auto_create_approved
? "admin.shippingOrderProfiles.versionCenter.usage.yes"
: "admin.shippingOrderProfiles.versionCenter.usage.no")
}}
</td>
<td>{{ formatTime(item.created_at) }}</td>
<td>
<span v-if="item.reason_codes.length">{{ item.reason_codes.join(", ") }}</span>
<span v-else>-</span>
</td>
<td>
<button type="button" class="link-button" @click="openDiagnostic(item)">
{{ t("admin.shippingOrderProfiles.versionCenter.usage.openDiagnostic") }}
</button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="pager">
<button type="button" class="ghost-button" :disabled="loading || !hasPrevious" @click="loadPrevious">
{{ t("admin.shippingOrderProfiles.versionCenter.usage.previous") }}
</button>
<button type="button" class="ghost-button" :disabled="loading || !hasNext" @click="loadNext">
{{ t("admin.shippingOrderProfiles.versionCenter.usage.next") }}
</button>
</div>
</section>
</template>
<style scoped>
.usage-panel,
.toolbar,
.table-wrapper,
.state-card {
border: 1px solid #e2e8f0;
border-radius: 1rem;
background: #fff;
}
.usage-panel {
display: grid;
gap: 0.9rem;
}
.toolbar,
.state-card,
.table-wrapper {
padding: 0.95rem 1rem;
}
.toolbar,
.pager {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 0.8rem;
}
.toolbar h3 {
margin: 0;
color: #0f172a;
}
.toolbar p {
margin: 0.25rem 0 0;
color: #64748b;
font-size: 0.75rem;
}
.ghost-button,
.link-button {
border: 1px solid #cbd5e1;
border-radius: 0.75rem;
background: #fff;
padding: 0.5rem 0.75rem;
font-size: 0.875rem;
}
.link-button {
color: #2563eb;
}
.table-wrapper {
overflow-x: auto;
}
table {
width: 100%;
min-width: 980px;
border-collapse: collapse;
font-size: 0.84rem;
}
thead {
background: #f8fafc;
color: #64748b;
font-size: 0.75rem;
}
th,
td {
padding: 0.75rem;
border-bottom: 1px solid #e2e8f0;
text-align: left;
vertical-align: top;
}
tbody tr:last-child td {
border-bottom: 0;
}
.cell-title {
color: #0f172a;
font-weight: 600;
}
td small {
color: #64748b;
}
.error-card {
color: #b91c1c;
}
@media (max-width: 720px) {
.toolbar,
.pager {
display: grid;
}
}
</style>
@@ -0,0 +1,436 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileVersionDiff.vue
用途:展示订单模板版本中心的服务端语义 diff。
依赖:版本中心 diff API、路由 query、版本摘要列表。
逻辑:始终由服务端计算差异;前端只负责选择对比版本、呈现 summary 和折叠原始 JSON 快照。
-->
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import { BusinessError } from "@/shared/api/client";
import { getOrderDocumentProfileDiff } from "@/features/admin/api/shipping-order-document-profile.api";
import type {
OrderProfileVersionDiff,
OrderProfileVersionDiffChange,
OrderProfileVersionDiffItem,
OrderProfileVersionSummary,
ShippingOrderDocumentProfile,
} from "@/features/admin/types/shipping-order-document-profile.types";
const props = defineProps<{
detail: ShippingOrderDocumentProfile;
versions: OrderProfileVersionSummary[];
}>();
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const loading = ref(false);
const errorMessage = ref("");
const diff = ref<OrderProfileVersionDiff | null>(null);
const explicitAgainstProfileId = computed<number | null>(() => {
const raw = Number(route.query.againstProfileId || 0);
return Number.isFinite(raw) && raw > 0 ? raw : null;
});
const comparableVersions = computed(() =>
props.versions.filter((item) => item.id !== props.detail.id),
);
const changedItems = computed(() =>
(diff.value?.items || []).filter((item) => item.change_type !== "unchanged"),
);
const selectedAgainstProfileId = computed<number | null>(() =>
explicitAgainstProfileId.value ?? diff.value?.compare_profile?.id ?? null,
);
const comparisonTargetLabel = computed(() => {
const target = comparableVersions.value.find((item) => item.id === selectedAgainstProfileId.value)
|| diff.value?.compare_profile
|| null;
if (!target) {
return t("admin.shippingOrderProfiles.versionCenter.diff.initialVersion");
}
return `v${target.version} · ${t(`admin.shippingOrderProfiles.versionCenter.status.${target.status === "draft" ? "currentDraft" : target.status === "published" ? "currentPublished" : "retired"}`)}`;
});
const entityTypeLabel = (item: OrderProfileVersionDiffItem) =>
t(`admin.shippingOrderProfiles.versionCenter.diff.entityType.${item.entity_type}`);
const changeTypeLabel = (value: OrderProfileVersionDiffItem["change_type"]) =>
t(`admin.shippingOrderProfiles.versionCenter.diff.changeType.${value}`);
const changeLabel = (change: OrderProfileVersionDiffChange) => change.key;
const valueText = (value: unknown) => {
if (value === null || value === undefined || value === "") {
return t("admin.shippingOrderProfiles.versionCenter.diff.empty");
}
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
return String(value);
}
try {
return JSON.stringify(value, null, 2);
} catch {
return String(value);
}
};
const syncAgainstProfileId = (againstProfileId: number | null) => {
const query = { ...route.query };
if (againstProfileId) {
query.againstProfileId = String(againstProfileId);
} else {
delete query.againstProfileId;
}
void router.replace({ query });
};
const handleAgainstChange = (event: Event) => {
const value = Number((event.target as HTMLSelectElement).value || 0);
syncAgainstProfileId(Number.isFinite(value) && value > 0 ? value : null);
};
const load = async () => {
loading.value = true;
errorMessage.value = "";
try {
diff.value = await getOrderDocumentProfileDiff(props.detail.id, explicitAgainstProfileId.value);
} catch (error) {
diff.value = null;
errorMessage.value =
error instanceof BusinessError
? error.message
: t("admin.shippingOrderProfiles.versionCenter.diff.loadFailed");
} finally {
loading.value = false;
}
};
watch(
() => [props.detail.id, explicitAgainstProfileId.value],
() => {
void load();
},
{ immediate: true },
);
</script>
<template>
<section class="diff-panel">
<div class="toolbar">
<div>
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.diff.title") }}</h3>
<p>{{ t("admin.shippingOrderProfiles.versionCenter.diff.subtitle") }}</p>
</div>
<label class="compare-select">
<span>{{ t("admin.shippingOrderProfiles.versionCenter.diff.compareTarget") }}</span>
<select
:value="explicitAgainstProfileId || ''"
@change="handleAgainstChange"
>
<option value="">{{ t("admin.shippingOrderProfiles.versionCenter.diff.defaultPrevious") }}</option>
<option
v-for="item in comparableVersions"
:key="item.id"
:value="item.id"
>
v{{ item.version }} · {{ t(`admin.shippingOrderProfiles.versionCenter.status.${item.status === "draft" ? "currentDraft" : item.status === "published" ? "currentPublished" : "retired"}`) }}
</option>
</select>
</label>
</div>
<div v-if="loading" class="state-card">
{{ t("admin.shippingOrderProfiles.versionCenter.diff.loading") }}
</div>
<div v-else-if="errorMessage" class="state-card error-card">
{{ errorMessage }}
</div>
<template v-else-if="diff">
<div class="summary-bar">
<span class="summary-target">{{ t("admin.shippingOrderProfiles.versionCenter.diff.comparedWith", { target: comparisonTargetLabel }) }}</span>
<span class="summary-pill added">{{ t("admin.shippingOrderProfiles.versionCenter.diff.summary.added", { count: diff.summary.added }) }}</span>
<span class="summary-pill removed">{{ t("admin.shippingOrderProfiles.versionCenter.diff.summary.removed", { count: diff.summary.removed }) }}</span>
<span class="summary-pill modified">{{ t("admin.shippingOrderProfiles.versionCenter.diff.summary.modified", { count: diff.summary.modified }) }}</span>
<span class="summary-pill unchanged">{{ t("admin.shippingOrderProfiles.versionCenter.diff.summary.unchanged", { count: diff.summary.unchanged }) }}</span>
</div>
<div v-if="!changedItems.length" class="state-card">
{{ t("admin.shippingOrderProfiles.versionCenter.diff.noChanges") }}
</div>
<article
v-for="item in changedItems"
:key="`${item.entity_type}:${item.entity_id}:${item.parent_id || ''}`"
class="diff-item"
:class="item.change_type"
>
<header>
<div>
<p>{{ entityTypeLabel(item) }}</p>
<h4>{{ item.label }}</h4>
</div>
<span class="change-type">{{ changeTypeLabel(item.change_type) }}</span>
</header>
<dl v-if="item.changes.length" class="change-list">
<div
v-for="change in item.changes"
:key="change.key"
>
<dt><code>{{ changeLabel(change) }}</code></dt>
<dd>
<template v-if="change.kind === 'set'">
<div class="change-pair"><del>{{ valueText(change.before) }}</del><ins>{{ valueText(change.after) }}</ins></div>
<small v-if="change.added?.length">{{ t("admin.shippingOrderProfiles.versionCenter.diff.addedValues", { values: change.added.join(', ') }) }}</small>
<small v-if="change.removed?.length">{{ t("admin.shippingOrderProfiles.versionCenter.diff.removedValues", { values: change.removed.join(', ') }) }}</small>
<small v-if="change.order_changed">{{ t("admin.shippingOrderProfiles.versionCenter.diff.orderChanged") }}</small>
</template>
<template v-else>
<div class="change-pair"><del>{{ valueText(change.before) }}</del><ins>{{ valueText(change.after) }}</ins></div>
</template>
</dd>
</div>
</dl>
<details class="raw-json">
<summary>{{ t("admin.shippingOrderProfiles.versionCenter.diff.rawJson") }}</summary>
<div class="raw-json-grid">
<section>
<h5>{{ t("admin.shippingOrderProfiles.versionCenter.diff.beforeSnapshot") }}</h5>
<pre>{{ valueText(item.before_snapshot) }}</pre>
</section>
<section>
<h5>{{ t("admin.shippingOrderProfiles.versionCenter.diff.afterSnapshot") }}</h5>
<pre>{{ valueText(item.after_snapshot) }}</pre>
</section>
</div>
</details>
</article>
</template>
</section>
</template>
<style scoped>
.diff-panel,
.toolbar,
.summary-bar,
.diff-item,
.state-card {
border: 1px solid #e2e8f0;
border-radius: 1rem;
background: #fff;
}
.diff-panel {
display: grid;
gap: 0.9rem;
}
.toolbar,
.summary-bar,
.state-card,
.diff-item {
padding: 0.95rem 1rem;
}
.toolbar {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.toolbar h3,
.diff-item h4,
.raw-json h5 {
margin: 0;
color: #0f172a;
}
.toolbar p,
.diff-item header p {
margin: 0 0 0.3rem;
color: #64748b;
font-size: 0.75rem;
}
.compare-select {
display: grid;
gap: 0.35rem;
color: #475569;
font-size: 0.75rem;
}
.compare-select select {
min-width: 220px;
border: 1px solid #cbd5e1;
border-radius: 0.75rem;
background: #fff;
padding: 0.5rem 0.75rem;
color: #0f172a;
font-size: 0.875rem;
}
.summary-bar {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
}
.summary-target {
margin-right: 0.5rem;
color: #334155;
font-size: 0.875rem;
}
.summary-pill,
.change-type {
border-radius: 999px;
padding: 0.2rem 0.55rem;
font-size: 0.75rem;
}
.summary-pill.added,
.diff-item.added .change-type {
background: #dcfce7;
color: #166534;
}
.summary-pill.removed,
.diff-item.removed .change-type {
background: #fee2e2;
color: #b91c1c;
}
.summary-pill.modified,
.diff-item.modified .change-type {
background: #dbeafe;
color: #1d4ed8;
}
.summary-pill.unchanged,
.diff-item.unchanged .change-type {
background: #e2e8f0;
color: #475569;
}
.diff-item {
border-left-width: 4px;
}
.diff-item.added { border-left-color: #22c55e; }
.diff-item.removed { border-left-color: #ef4444; }
.diff-item.modified { border-left-color: #3b82f6; }
.diff-item header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.change-list {
display: grid;
gap: 0.8rem;
margin: 0.95rem 0 0;
}
.change-list div {
display: grid;
grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
gap: 0.75rem;
}
.change-list dt {
color: #475569;
font-size: 0.75rem;
}
.change-list dd {
display: grid;
gap: 0.3rem;
margin: 0;
color: #334155;
font-size: 0.82rem;
overflow-wrap: anywhere;
}
.change-pair {
display: grid;
gap: 0.25rem;
}
del {
color: #b91c1c;
text-decoration: line-through;
}
ins {
color: #15803d;
text-decoration: none;
}
.change-list small {
color: #64748b;
}
.raw-json {
margin-top: 0.9rem;
border-top: 1px solid #e2e8f0;
padding-top: 0.9rem;
}
.raw-json summary {
cursor: pointer;
color: #334155;
font-size: 0.8rem;
font-weight: 600;
}
.raw-json-grid {
display: grid;
gap: 0.85rem;
margin-top: 0.75rem;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.raw-json pre {
margin: 0.45rem 0 0;
border-radius: 0.75rem;
background: #0f172a;
padding: 0.75rem;
color: #e2e8f0;
font-size: 0.72rem;
line-height: 1.45;
overflow: auto;
white-space: pre-wrap;
}
.error-card {
color: #b91c1c;
}
@media (max-width: 900px) {
.toolbar,
.diff-item header,
.change-list div,
.raw-json-grid {
grid-template-columns: 1fr;
}
.toolbar,
.diff-item header {
display: grid;
}
.compare-select select {
min-width: 0;
}
}
</style>
@@ -1,36 +0,0 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileVersionDrawer.vue
用途:将模板历史收进可开合抽屉,避免版本列表占据标注工作面。
依赖:ShippingOrderDocumentProfile DTO。
逻辑:父页面负责版本动作和盲测流程;抽屉只发出用户意图。
-->
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import type { ShippingOrderDocumentProfile } from '@/features/admin/types/shipping-order-document-profile.types';
defineProps<{ open: boolean; profiles: ShippingOrderDocumentProfile[] }>();
const { t } = useI18n();
defineEmits<{ close: []; edit: [profile: ShippingOrderDocumentProfile]; publish: [profile: ShippingOrderDocumentProfile]; clone: [profile: ShippingOrderDocumentProfile]; migrate: [profile: ShippingOrderDocumentProfile]; retire: [profile: ShippingOrderDocumentProfile]; remove: [profile: ShippingOrderDocumentProfile]; test: [profile: ShippingOrderDocumentProfile] }>();
</script>
<template>
<aside v-if="open" class="drawer" :aria-label="t('admin.shippingOrderProfiles.versions')">
<header><strong>{{ t('admin.shippingOrderProfiles.versions') }}</strong><button type="button" @click="$emit('close')">{{ t('common.close') }}</button></header>
<article v-for="profile in profiles" :key="profile.id">
<div><b>{{ profile.display_name }} · v{{ profile.version }}</b><small>{{ profile.profile_code }} · {{ profile.status }}</small><small v-if="profile.auto_freeze_qualification">{{ t(`admin.shippingOrderProfiles.autoFreezeQualification.${profile.auto_freeze_qualification.status}`) }}</small><small v-if="profile.migration_status === 'needs_revalidation'" class="migration-status">{{ t('admin.shippingOrderProfiles.migrationNeedsReview') }}</small></div>
<div class="actions">
<button v-if="profile.status === 'draft'" type="button" @click="$emit('edit', profile)">{{ t('common.edit') }}</button>
<button v-if="profile.status === 'draft'" type="button" @click="$emit('test', profile)">{{ t('admin.shippingOrderProfiles.blindTest.title') }}</button>
<button v-if="profile.status === 'draft'" type="button" @click="$emit('publish', profile)">{{ t('admin.shippingOrderProfiles.publish') }}</button>
<button v-if="profile.status === 'draft'" type="button" @click="$emit('remove', profile)">{{ t('common.delete') }}</button>
<button v-if="profile.status !== 'draft'" type="button" @click="$emit('clone', profile)">{{ t('admin.shippingOrderProfiles.newVersion') }}</button>
<button v-if="profile.status === 'published' && profile.schema_compatibility?.status === 'breaking'" type="button" @click="$emit('migrate', profile)">{{ t('admin.shippingOrderProfiles.migrateSchema') }}</button>
<button v-if="profile.status === 'published'" type="button" @click="$emit('retire', profile)">{{ t('admin.shippingOrderProfiles.retire') }}</button>
</div>
</article>
</aside>
</template>
<style scoped>
.drawer { position: fixed; inset: 0 0 0 auto; z-index: 30; width: min(28rem, 92vw); overflow: auto; border-left: 1px solid #cbd5e1; background: white; box-shadow: -16px 0 36px rgb(15 23 42 / .16); }.drawer header { position: sticky; top: 0; display: flex; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 1rem; }.drawer article { display: grid; gap: .75rem; border-bottom: 1px solid #e2e8f0; padding: 1rem; }.drawer b,.drawer small { display: block; }.drawer small { margin-top: .25rem; color: #64748b; }.actions { display: flex; flex-wrap: wrap; gap: .4rem; }.actions button,.drawer header button { border: 1px solid #cbd5e1; border-radius: .4rem; background: white; padding: .35rem .55rem; font-size: .75rem; }.actions button:hover { background: #f1f5f9; }
.drawer small.migration-status { color: #b45309; }
</style>
@@ -0,0 +1,272 @@
<!--
features/admin/modules/shipping-order-document-profiles/components/OrderProfileVersionOverview.vue
用途:展示模板版本详情的配置概览页签。
依赖:订单模板详情 DTO、i18n。
逻辑:仅渲染结构化摘要与冻结证据状态,不请求 PDF、Layout payload 或盲测真值。
-->
<script setup lang="ts">
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import type { ShippingOrderDocumentProfile } from "@/features/admin/types/shipping-order-document-profile.types";
const props = defineProps<{
detail: ShippingOrderDocumentProfile;
}>();
const { t } = useI18n();
const statusLabel = computed(() => {
if (props.detail.status === "draft") {
return t("admin.shippingOrderProfiles.versionCenter.status.currentDraft");
}
if (props.detail.status === "published") {
return t("admin.shippingOrderProfiles.versionCenter.status.currentPublished");
}
return t("admin.shippingOrderProfiles.versionCenter.status.retired");
});
const frozenEvidenceLabel = computed(() => {
const status = props.detail.frozen_evidence?.status || "pending";
return t(`admin.shippingOrderProfiles.versionCenter.frozenEvidence.${status}`);
});
const testStatusLabel = computed(() => {
const status = props.detail.test_summary?.status || "missing";
return t(`admin.shippingOrderProfiles.versionCenter.testStatus.${status}`);
});
</script>
<template>
<section class="overview">
<div class="hero-card">
<div class="hero-row">
<div>
<p class="eyebrow">{{ detail.profile_code }}</p>
<h2>v{{ detail.version }} · {{ statusLabel }}</h2>
</div>
<div class="hero-meta">
<span class="meta-chip">
{{ t("admin.shippingOrderProfiles.versionCenter.schemaVersion") }}
{{ detail.schema_summary?.version ?? "-" }}
</span>
<span class="meta-chip">
{{ t("admin.shippingOrderProfiles.versionCenter.sampleCount", { count: detail.sample_summary?.sample_count || 0 }) }}
</span>
</div>
</div>
<p class="hero-subtitle">{{ detail.display_name }}</p>
<p v-if="detail.change_note" class="change-note">{{ detail.change_note }}</p>
<dl class="hero-grid">
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.checksum") }}</dt>
<dd><code>{{ detail.checksum || "-" }}</code></dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.schemaChecksum") }}</dt>
<dd><code>{{ detail.schema_summary?.checksum || "-" }}</code></dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.publishedAt") }}</dt>
<dd>{{ detail.published_at || "-" }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.retiredAt") }}</dt>
<dd>{{ detail.retired_at || "-" }}</dd>
</div>
</dl>
</div>
<div class="summary-grid">
<article class="summary-card">
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.definitionStats") }}</h3>
<dl>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.tableRegions") }}</dt>
<dd>{{ detail.definition_stats?.table_region_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.headerLayouts") }}</dt>
<dd>{{ detail.definition_stats?.header_layout_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.lineLayouts") }}</dt>
<dd>{{ detail.definition_stats?.line_layout_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.orderFieldLayouts") }}</dt>
<dd>{{ detail.definition_stats?.order_field_layout_count || 0 }}</dd>
</div>
</dl>
</article>
<article class="summary-card">
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.frozenEvidenceTitle") }}</h3>
<dl>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.statusLabel") }}</dt>
<dd>{{ frozenEvidenceLabel }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.sampleCountPlain") }}</dt>
<dd>{{ detail.frozen_evidence?.sample_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.frozenSampleCount") }}</dt>
<dd>{{ detail.frozen_evidence?.frozen_sample_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.auditReady") }}</dt>
<dd>{{ detail.frozen_evidence?.audit_ready ? t("common.yes") : t("common.no") }}</dd>
</div>
</dl>
</article>
<article class="summary-card">
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.sampleSummaryTitle") }}</h3>
<dl>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.annotationCount") }}</dt>
<dd>{{ detail.sample_summary?.annotation_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.trainingCount") }}</dt>
<dd>{{ detail.sample_summary?.training_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.blindTestCount") }}</dt>
<dd>{{ detail.sample_summary?.blind_test_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.firstSample") }}</dt>
<dd>{{ detail.sample_summary?.samples?.[0]?.source_filename_snapshot || "-" }}</dd>
</div>
</dl>
</article>
<article class="summary-card">
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.testSummaryTitle") }}</h3>
<dl>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.statusLabel") }}</dt>
<dd>{{ testStatusLabel }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.sampleCountPlain") }}</dt>
<dd>{{ detail.test_summary?.sample_count || 0 }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.approvedAt") }}</dt>
<dd>{{ detail.test_summary?.approved_at || "-" }}</dd>
</div>
<div>
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.latestRun") }}</dt>
<dd>{{ detail.test_summary?.latest_run?.status || "-" }}</dd>
</div>
</dl>
</article>
</div>
<article class="summary-card source-card">
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.sourceVersionTitle") }}</h3>
<p v-if="detail.source_version">
{{ detail.source_version.profile_code }} · v{{ detail.source_version.version }} ·
{{ detail.source_version.status }}
</p>
<p v-else>{{ t("admin.shippingOrderProfiles.versionCenter.noSourceVersion") }}</p>
</article>
</section>
</template>
<style scoped>
.overview {
display: grid;
gap: 1rem;
}
.hero-card,
.summary-card {
border: 1px solid #e2e8f0;
border-radius: 0.9rem;
background: #fff;
padding: 1rem;
}
.hero-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.eyebrow {
margin: 0 0 0.35rem;
color: #64748b;
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.06em;
}
.hero-card h2,
.summary-card h3 {
margin: 0;
color: #0f172a;
}
.hero-subtitle,
.change-note {
margin: 0.65rem 0 0;
color: #475569;
}
.change-note {
border-left: 3px solid #cbd5e1;
padding-left: 0.75rem;
}
.hero-meta {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: 0.5rem;
}
.meta-chip {
border-radius: 999px;
background: #eff6ff;
color: #1d4ed8;
padding: 0.35rem 0.65rem;
font-size: 0.75rem;
}
.hero-grid,
.summary-card dl {
display: grid;
gap: 0.75rem;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
margin: 1rem 0 0;
}
.hero-grid dt,
.summary-card dt {
color: #64748b;
font-size: 0.75rem;
}
.hero-grid dd,
.summary-card dd {
margin: 0.25rem 0 0;
color: #0f172a;
word-break: break-word;
}
.summary-grid {
display: grid;
gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.source-card p {
margin: 0.75rem 0 0;
color: #334155;
}
</style>
@@ -0,0 +1,108 @@
/**
* features/admin/modules/shipping-order-document-profiles/composables/useOrderProfileVersionDetail.ts
* 用途:按独立详情路由加载模板版本详情与同族版本导航数据。
* 依赖:vue-router、订单模板版本中心 API。
* 逻辑:只读取结构化详情与版本摘要,不触发 PDF 预览、画布或盲测真值请求。
*/
import { computed, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { BusinessError } from "@/shared/api/client";
import {
getOrderDocumentProfileByFamilyVersion,
listOrderDocumentProfileFamilyVersions,
} from "@/features/admin/api/shipping-order-document-profile.api";
import type {
OrderProfileVersionSummary,
ShippingOrderDocumentProfile,
} from "@/features/admin/types/shipping-order-document-profile.types";
export type OrderProfileVersionDetailTab =
| "overview"
| "canvas"
| "diff"
| "audit"
| "usage";
export interface OrderProfileVersionDetailTabOption {
key: OrderProfileVersionDetailTab;
count?: number | null;
}
const VALID_TABS: OrderProfileVersionDetailTab[] = [
"overview",
"canvas",
"diff",
"audit",
"usage",
];
/**
* 按路由参数读取版本详情,只暴露阶段 3 需要的只读状态。
*/
export const useOrderProfileVersionDetail = () => {
const route = useRoute();
const loading = ref(false);
const detail = ref<ShippingOrderDocumentProfile | null>(null);
const versions = ref<OrderProfileVersionSummary[]>([]);
const errorMessage = ref("");
const profileCode = computed(() =>
String(route.params.profileCode || "").trim(),
);
const version = computed(() => Number(route.params.version || 0));
const activeTab = computed<OrderProfileVersionDetailTab>(() => {
const raw = String(route.query.tab || "overview").trim();
return VALID_TABS.includes(raw as OrderProfileVersionDetailTab)
? (raw as OrderProfileVersionDetailTab)
: "overview";
});
const tabOptions = computed<OrderProfileVersionDetailTabOption[]>(() => [
{ key: "overview" },
{ key: "canvas", count: detail.value?.sample_summary?.sample_count || 0 },
{ key: "diff" },
{ key: "audit" },
{ key: "usage" },
]);
const load = async () => {
if (!profileCode.value || !Number.isFinite(version.value) || version.value <= 0) {
detail.value = null;
versions.value = [];
errorMessage.value = "";
return;
}
loading.value = true;
errorMessage.value = "";
try {
const [detailPayload, versionsPayload] = await Promise.all([
getOrderDocumentProfileByFamilyVersion(profileCode.value, version.value),
listOrderDocumentProfileFamilyVersions(profileCode.value),
]);
detail.value = detailPayload;
versions.value = versionsPayload;
} catch (error) {
detail.value = null;
versions.value = [];
errorMessage.value =
error instanceof BusinessError ? error.message : "Failed to load";
} finally {
loading.value = false;
}
};
watch([profileCode, version], () => {
void load();
}, { immediate: true });
return {
activeTab,
detail,
errorMessage,
loading,
profileCode,
tabOptions,
version,
versions,
};
};
@@ -0,0 +1,191 @@
/**
* features/admin/modules/shipping-order-document-profiles/orderProfileReadonlyCanvas.utils.ts
* 用途:把模板定义恢复成版本详情只读画布可渲染的区域集合。
* 依赖:订单模板类型、restoreOrderProfileRegionPageNo。
* 逻辑:版本详情只读展示几何和绑定身份,不写回表单或草稿状态。
*/
import type {
OrderProfileCanvasRegion,
ShippingOrderDocumentProfile,
} from '@/features/admin/types/shipping-order-document-profile.types';
import { restoreOrderProfileRegionPageNo } from './orderProfileForm.utils';
const mergeEquivalentOrderAnchors = (items: OrderProfileCanvasRegion[]) => {
const canonicalByKey = new Map<string, string>();
const anchorIds = new Map<string, string>();
const retained: OrderProfileCanvasRegion[] = [];
const anchorKey = (item: OrderProfileCanvasRegion) => [
item.pageNo,
item.label.trim().toLocaleLowerCase(),
item.region.x0,
item.region.y0,
item.region.x1,
item.region.y1,
].join('|');
for (const item of items) {
if (item.kind !== 'order_anchor') {
retained.push(item);
continue;
}
const canonicalId = canonicalByKey.get(anchorKey(item));
if (canonicalId) {
anchorIds.set(item.id, canonicalId);
if (item.orderFieldId) anchorIds.set(`layout:${item.orderFieldId}`, canonicalId);
continue;
}
canonicalByKey.set(anchorKey(item), item.id);
anchorIds.set(item.id, item.id);
if (item.orderFieldId) anchorIds.set(`layout:${item.orderFieldId}`, item.id);
retained.push(item);
}
return retained.map((item) => item.kind === 'order_field'
? {
...item,
parentId: item.parentId
? anchorIds.get(item.parentId) || item.parentId
: item.orderFieldId
? anchorIds.get(`layout:${item.orderFieldId}`) || null
: null,
}
: item);
};
const pageNoOf = (pageScope: 'first_page' | 'all_pages' | 'exact_page', pageNo?: number | null) =>
pageScope === 'exact_page' ? (pageNo || 1) : 1;
/**
* 从版本详情定义恢复只读画布区域;标签统一优先使用 field_code,避免引入可编辑态依赖。
*/
export const buildOrderProfileReadonlyRegions = (
profile: ShippingOrderDocumentProfile,
): OrderProfileCanvasRegion[] => {
const restored: OrderProfileCanvasRegion[] = [
...(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) {
return [{
id: `unbound-${item.layout_id}`,
kind: 'order_field',
label: item.label,
region: item.fallback_value_region || { x0: .1, y0: .1, x1: .2, y1: .15 },
fieldCode: null,
pageNo,
}];
}
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',
label: item.anchor.text,
region: anchor,
orderFieldId: item.layout_id,
pageNo,
}, {
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,
},
fieldCode: null,
orderFieldId: item.layout_id,
pageNo,
}];
}),
...(profile.definition.order_field_layouts || []).filter((item) => !item.anchor).map((item) => ({
id: item.layout_id,
kind: 'order_field' as const,
label: item.field_code,
region: item.fallback_value_region || { x0: .1, y0: .1, x1: .2, y1: .15 },
fieldCode: item.field_code,
pageNo: pageNoOf(item.page_scope, item.page_no),
})),
...(profile.definition.order_field_layouts || []).flatMap((item) => {
if (!item.anchor?.region || !item.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,
label: item.anchor.text,
region: anchor,
orderFieldId: item.layout_id,
pageNo: pageNoOf(item.page_scope, item.page_no),
}, {
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,
},
fieldCode: item.field_code,
orderFieldId: item.layout_id,
valueMode: item.value_mode,
stopAnchorText: item.stop_anchors[0]?.text || null,
pageNo: pageNoOf(item.page_scope, item.page_no),
}];
}),
...profile.definition.table_regions.flatMap((table) => {
const regionPageNo = restoreOrderProfileRegionPageNo(table);
const headerLayoutIds = new Set(table.header_layouts.map((item) => item.layout_id));
return [
...table.header_layouts.flatMap((header) =>
header.field_regions.map((item, index) => ({
id: `${header.layout_id}-field-${index}`,
kind: 'header_field' as const,
label: item.field_code,
fieldCode: item.field_code,
region: item.region,
parentId: header.layout_id,
pageNo: regionPageNo,
})),
),
...table.line_layouts.map((item) => ({
id: item.layout_id,
kind: 'line' as const,
label: item.layout_id,
region: item.region,
pageNo: regionPageNo,
})),
...table.line_layouts.flatMap((line) =>
line.field_regions.map((item, index) => ({
id: `${line.layout_id}-field-${index}`,
kind: 'field' as const,
label: item.field_code,
region: item.region,
fieldCode: item.field_code,
parentId: line.layout_id,
pageNo: regionPageNo,
})),
),
...(table.draft_unbound_field_regions || []).map((item) => ({
id: item.region_id,
kind: headerLayoutIds.has(item.parent_layout_id) ? ('header_field' as const) : ('field' as const),
label: item.label,
region: item.region,
fieldCode: null,
parentId: item.parent_layout_id,
pageNo: regionPageNo,
})),
...table.exclusion_regions.map((region, index) => ({
id: `exclusion-${regionPageNo}-${index}`,
kind: 'exclusion' as const,
label: `exclusion ${index + 1}`,
region,
pageNo: regionPageNo,
})),
];
}),
];
return mergeEquivalentOrderAnchors(restored);
};
@@ -5,8 +5,9 @@
逻辑:列表按状态筛选并按需加载单条详情;页面不提供重试、取消或任何业务数据修改入口。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import {
getShippingOrderExtractionDiagnosticRun,
listShippingOrderExtractionDiagnosticRuns,
@@ -15,6 +16,8 @@ import {
} from '@/features/admin/api/admin.api';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const loading = ref(false);
const detailLoading = ref(false);
const page = ref(1);
@@ -51,6 +54,9 @@ const openDetail = async (runNo: string) => {
error.value = '';
try {
detail.value = await getShippingOrderExtractionDiagnosticRun(runNo);
if (route.query.runNo !== runNo) {
void router.replace({ query: { ...route.query, runNo } });
}
} catch {
error.value = t('admin.shippingOrderExtractionRuns.detailFailed');
} finally {
@@ -58,12 +64,37 @@ const openDetail = async (runNo: string) => {
}
};
const closeDetail = () => {
detail.value = null;
if (route.query.runNo) {
const nextQuery = { ...route.query };
delete nextQuery.runNo;
void router.replace({ query: nextQuery });
}
};
const applyStatus = async () => {
page.value = 1;
await load();
};
onMounted(() => { void load(); });
onMounted(() => {
void load();
const runNo = String(route.query.runNo || '').trim();
if (runNo) void openDetail(runNo);
});
watch(
() => String(route.query.runNo || '').trim(),
(runNo) => {
if (!runNo) {
detail.value = null;
return;
}
if (detail.value?.run.run_no === runNo || detailLoading.value) return;
void openDetail(runNo);
},
);
</script>
<template>
@@ -106,9 +137,9 @@ onMounted(() => { void load(); });
</div>
<div class="flex items-center justify-end gap-3 text-sm"><button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page <= 1 || loading" @click="page -= 1; load()">{{ t('admin.shippingOrderExtractionRuns.previous') }}</button><span>{{ page }}</span><button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">{{ t('admin.shippingOrderExtractionRuns.next') }}</button></div>
<div v-if="detail || detailLoading" class="fixed inset-0 z-50 flex justify-end bg-black/30" @click.self="detail = null">
<div v-if="detail || detailLoading" class="fixed inset-0 z-50 flex justify-end bg-black/30" @click.self="closeDetail">
<aside class="h-full w-full max-w-2xl overflow-y-auto bg-surface p-6 shadow-2xl">
<div class="flex items-center justify-between"><h2 class="text-lg font-bold">{{ t('admin.shippingOrderExtractionRuns.detailTitle') }}</h2><button type="button" class="text-secondary" @click="detail = null">{{ t('admin.close') }}</button></div>
<div class="flex items-center justify-between"><h2 class="text-lg font-bold">{{ t('admin.shippingOrderExtractionRuns.detailTitle') }}</h2><button type="button" class="text-secondary" @click="closeDetail">{{ t('admin.close') }}</button></div>
<p v-if="detailLoading" class="mt-6 text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</p>
<template v-else-if="detail"><dl class="mt-5 grid grid-cols-2 gap-3 text-sm"><dt>{{ t('admin.shippingOrderExtractionRuns.runNo') }}</dt><dd class="font-mono text-xs">{{ detail.run.run_no }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.currentEvent') }}</dt><dd class="font-mono text-xs">{{ detail.run.current_event_code || '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.candidateMaterializedAt') }}</dt><dd>{{ formatTime(detail.run.candidate_materialized_at) }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.errorCode') }}</dt><dd>{{ detail.run.error_code || '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.totalDuration') }}</dt><dd>{{ formatDuration(detail.run.durations_ms.total) }}</dd></dl>
<section class="mt-6 rounded-lg border border-default p-4 text-sm">
@@ -66,4 +66,17 @@ describe('shipping configuration navigation contract', () => {
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'order_document_profiles' }),
]);
});
it('routes a newly created draft to the dedicated editor deep link', () => {
// 关键断言:创建向导完成后不能回落到模板库,必须有草稿身份明确的编辑入口。
const editorRoute = adminRoutes[0].children?.find(
(route) => route.name === 'AdminShippingOrderDocumentProfileEdit',
);
expect(editorRoute?.path).toBe('shipping-order-document-profiles/:profileCode/drafts/:profileId/edit');
expect(editorRoute?.meta).toEqual(expect.objectContaining({
requiresAdmin: true,
adminModule: 'shipping_inventory',
adminSubModule: 'order_document_profiles',
}));
});
});
@@ -8,6 +8,21 @@
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 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';
export type OrderProfileValidationRunStatus = 'pending' | 'running' | 'passed' | 'failed' | 'stale';
export type OrderProfilePublishCheckStatus = 'valid' | 'invalidated' | 'consumed' | 'expired';
/** 阶段 0 冻结的 Profile 治理错误码;后端在相应阶段实现时必须使用这些稳定身份。 */
export type OrderProfileGovernanceErrorCode =
| 'SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_REQUIRED'
| 'SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_CONFLICT'
| 'SHIPPING.ORDER_DOCUMENT_PROFILE_LOCK_VERSION_CONFLICT'
| 'SHIPPING.ORDER_DOCUMENT_PROFILE_REVISION_NOT_FOUND'
| 'SHIPPING.ORDER_DOCUMENT_PROFILE_VALIDATION_STALE'
| 'SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_INVALID'
| '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; }
@@ -72,12 +87,283 @@ export interface ShippingOrderDocumentProfile {
requires_customer_confirmation?: boolean;
scope_updated_at?: string | null;
};
frozen_evidence?: {
status: 'pending' | 'ready' | 'missing';
sample_count: number;
frozen_sample_count: number;
audit_ready: boolean;
};
schema_summary?: {
id: number;
version?: number | null;
checksum?: string | null;
};
definition_stats?: {
table_region_count: number;
header_layout_count: number;
line_layout_count: number;
order_field_layout_count: number;
draft_unbound_order_field_layout_count: number;
};
sample_summary?: {
annotation_count: number;
training_count: number;
blind_test_count: number;
sample_count: number;
samples: OrderProfileBoundSample[];
};
test_summary?: {
status: 'missing' | 'draft' | 'approved' | 'superseded';
sample_count: number;
approved_at?: string | null;
latest_run?: {
status: 'passed' | 'failed';
sample_count: number;
passed_sample_count: number;
failure_codes: string[];
} | null;
};
source_version?: {
id: number;
profile_code: string;
version: number;
status: 'draft' | 'published' | 'retired';
checksum?: string | null;
} | null;
}
/** 不可变草稿快照;修改 Profile 时只追加新修订,禁止覆盖历史定义。 */
export interface OrderProfileDraftRevision {
revision_no: number;
profile_id: number;
base_lock_version: number;
result_lock_version: number;
definition_checksum: string;
change_source: OrderProfileChangeSource;
actor_id: number | null;
browser_session_id: string;
operation_id: string;
change_summary: Record<string, unknown>;
created_at: string;
}
/** 当前浏览器标签持有的单写者租约;令牌仅用于写请求,不能记录或展示。 */
export interface OrderProfileEditLease {
profile_id: number;
state: OrderProfileLeaseState;
actor_id: number | null;
browser_session_id: string;
expires_at: string;
last_renewed_at: string | null;
lock_version: number;
}
/** 绑定精确草稿 checksum 的不可变验证运行摘要。 */
export interface OrderProfileValidationRun {
id: number;
profile_id: number;
revision_no: number;
definition_checksum: string;
run_type: OrderProfileValidationRunType;
status: OrderProfileValidationRunStatus;
stored_status?: Exclude<OrderProfileValidationRunStatus, 'stale'>;
summary?: Record<string, unknown>;
operation_id: string;
created_at: string;
completed_at: string | null;
}
/** 发布检查冻结草稿、验证运行与锁版本;只能被一次原子发布消费。 */
export interface OrderProfilePublishCheckReport {
id: number;
report_no: string;
profile_id: number;
revision_no: number;
definition_checksum: string;
lock_version: number;
validation_run_id: number | null;
semantic_diff?: Record<string, unknown>;
status: OrderProfilePublishCheckStatus;
blocking_items: Array<Record<string, unknown>>;
warning_items: Array<Record<string, unknown>>;
operation_id: string;
created_at: string;
consumed_at: string | null;
}
export interface OrderProfileVersionFamilySummary {
profile_code: string;
display_name: string;
draft_profile_id?: number | null;
draft_version?: number | null;
published_profile_id?: number | null;
published_version?: number | null;
latest_profile_id: number;
latest_version: number;
default_profile_id: number;
default_version: number;
version_count: number;
updated_at: string;
}
export interface OrderProfileVersionSummary {
id: number;
profile_code: string;
display_name: string;
version: number;
status: 'draft' | 'published' | 'retired';
schema_version_id: number;
schema_version?: number | null;
schema_checksum?: string | null;
checksum?: string | null;
change_note?: string | null;
source_profile_id?: number | null;
published_at?: string | null;
retired_at?: string | null;
template_mode?: string;
training_sample_count?: number;
match_strategy_summary?: Record<string, number | null>;
migration_status?: 'normal' | 'needs_revalidation' | 'blocked';
auto_freeze_qualification?: ShippingOrderDocumentProfile['auto_freeze_qualification'];
frozen_evidence?: ShippingOrderDocumentProfile['frozen_evidence'];
definition_stats?: ShippingOrderDocumentProfile['definition_stats'];
updated_at: string;
}
export interface OrderProfileVersionDiffChange {
key: string;
kind: 'value' | 'set' | 'region' | 'json';
before: unknown;
after: unknown;
added?: string[];
removed?: string[];
order_changed?: boolean;
tolerance?: number;
}
export interface OrderProfileVersionDiffItem {
entity_type:
| 'profile_meta'
| 'document_match'
| 'table_region'
| 'header_layout'
| 'header_field_region'
| 'line_layout'
| 'line_field_region'
| 'termination_rule'
| 'exclusion_region'
| 'order_field_layout'
| 'sample_binding';
entity_id: string;
parent_id?: string | null;
label: string;
change_type: 'added' | 'removed' | 'modified' | 'unchanged';
changes: OrderProfileVersionDiffChange[];
before_snapshot?: Record<string, unknown> | null;
after_snapshot?: Record<string, unknown> | null;
}
export interface OrderProfileVersionDiff {
base_profile: Pick<OrderProfileVersionSummary, 'id' | 'profile_code' | 'display_name' | 'version' | 'status' | 'schema_version_id' | 'schema_version' | 'schema_checksum' | 'checksum'>;
compare_profile?: Pick<OrderProfileVersionSummary, 'id' | 'profile_code' | 'display_name' | 'version' | 'status' | 'schema_version_id' | 'schema_version' | 'schema_checksum' | 'checksum'> | null;
comparison_mode: 'explicit' | 'previous' | 'initial';
summary: {
added: number;
removed: number;
modified: number;
unchanged: number;
};
items: OrderProfileVersionDiffItem[];
}
export interface OrderProfileAuditEvent {
id: number;
event_type: string;
request_id?: string | null;
document_id?: number | null;
actor: {
id?: number | null;
username?: string | null;
display_name: string;
};
detail: Record<string, unknown>;
created_at?: string | null;
}
export interface OrderProfileAuditEventPage {
profile: Pick<OrderProfileVersionSummary, 'id' | 'profile_code' | 'version' | 'status'>;
filters: {
event_type?: string | null;
actor?: string | null;
request_id?: string | null;
created_from?: string | null;
created_to?: string | null;
};
items: OrderProfileAuditEvent[];
page: {
limit: number;
before_id?: number | null;
next_before_id?: number | null;
has_more: boolean;
};
}
export interface OrderProfileUsageRow {
route_decision_id: number;
identity_match_mode: 'direct_profile_id' | 'snapshot_identity_match';
run_no: string;
run_status: string;
unit_id: number;
unit_position: number;
document_id: number;
document_label: string;
match_status: string;
execution_status: string;
auto_create_approved?: boolean | null;
selected_profile_code?: string | null;
selected_profile_version?: number | null;
selected_profile_checksum?: string | null;
reason_codes: string[];
created_at?: string | null;
diagnostic_entry: {
route_name: 'AdminShippingOrderExtractionRuns';
run_no: string;
};
}
export interface OrderProfileUsagePage {
profile: Pick<OrderProfileVersionSummary, 'id' | 'profile_code' | 'version' | 'status' | 'checksum'>;
items: OrderProfileUsageRow[];
page: {
limit: number;
before_id?: number | null;
next_before_id?: number | null;
has_more: boolean;
};
}
/** 受控预览授权只对单页生效,令牌不得持久化或复用。 */
export interface OrderProfilePreviewPageGrant { page_no: number; preview_token: string; }
export interface OrderProfileBoundSample { id: number; document_id: number; table_id?: string | null; sample_role: 'annotation' | 'training'; created_at: string; }
export interface OrderProfilePreviewPages { document_id: number; page_count: number; pages: OrderProfilePreviewPageGrant[]; expires_in_seconds: number; }
export interface OrderProfileBoundSample {
id: number;
document_id: number;
table_id?: string | null;
sample_role: 'annotation' | 'training' | 'blind_test';
created_at: string;
frozen_evidence_ready?: boolean;
layout_version_id?: number | null;
source_content_hash?: string | null;
layout_payload_checksum?: string | null;
layout_contract_version?: string | null;
parser_key?: string | null;
parser_name?: string | null;
parser_version?: string | null;
source_filename_snapshot?: string | null;
page_count_snapshot?: number | null;
table_identity_snapshot?: { table_id?: string | null; page_no?: number | null; row_count?: number | null } | null;
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 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 {
@@ -182,21 +468,6 @@ export interface CreateOrderProfileFromSampleInput {
change_note?: string;
}
/** 阶段 3 替换前的旧工作台本地表单形状;服务端会拒绝其提交。 */
export interface LegacyCreateOrderProfileFromSampleInput {
profile_code: string;
display_name: string;
schema_version_id: number;
document_id: number;
table_id: string;
header_row_index: number;
data_start_row_index: number;
row_structure: 'preserved' | 'unsupported_row_structure';
column_rules: OrderProfileColumnRule[];
drop_zero_qty: boolean;
coordinate_reconstruction?: CoordinateReconstructionSettings | null;
change_note?: string;
}
export interface CoordinateReconstructionSettings {
method: 'native_pdf_coordinates.v1' | 'ocr_pdf_coordinates.v1';
column_boundaries: number[];
+127 -1
View File
@@ -27,6 +27,11 @@ import type {
ShippingOrderExtractionRun,
ShippingOrderExtractionProgressEvent,
ShippingOrderExtractionRunCreateResponse,
ShippingOrderReviewCase,
ShippingOrderReviewDraftWrite,
ShippingOrderReviewEvidence,
ShippingOrderReviewReparseResponse,
ShippingOrderReviewRun,
ShippingTaskUiState,
} from '../types/shipping.api.types';
@@ -200,6 +205,127 @@ export const listWorkspaceShippingOrderExtractionDocuments = (runNo: string) =>
`/api/workspace/shipping-notice/order-extraction-runs/${encodeURIComponent(runNo)}/documents`,
);
/** 获取 Run 下每份 PDF 的建单前复核摘要,服务端负责 owner 隔离。 */
export const getWorkspaceShippingOrderReviewRun = (runNo: string) =>
requestJson<ShippingOrderReviewRun>(
`/api/workspace/shipping-notice/order-extraction-runs/${encodeURIComponent(runNo)}/review`,
);
/** 获取一份 PDF 的冻结 Schema 与只读机器/草稿投影。 */
export const getWorkspaceShippingOrderReviewCase = (caseNo: string) =>
requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}`,
);
/** 保存一个复核订单头字段;后端以 expected_draft_version 拒绝过期窗口覆盖。 */
export const patchWorkspaceShippingOrderReviewHeaderField = (
caseNo: string, fieldId: string, payload: ShippingOrderReviewDraftWrite,
) => requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/draft/header-fields/${encodeURIComponent(fieldId)}`,
{ method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) },
);
/** 保存一个复核订单行字段;line_key 仅接受当前 Case DTO 返回的稳定标识。 */
export const patchWorkspaceShippingOrderReviewLineField = (
caseNo: string, lineKey: string, fieldId: string, payload: ShippingOrderReviewDraftWrite,
) => requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/draft/lines/${encodeURIComponent(lineKey)}/fields/${encodeURIComponent(fieldId)}`,
{ method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) },
);
export const addWorkspaceShippingOrderReviewLine = (caseNo: string, expectedDraftVersion: number) =>
requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/draft/lines`,
{ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ expected_draft_version: expectedDraftVersion }) },
);
export const copyWorkspaceShippingOrderReviewLine = (caseNo: string, lineKey: string, expectedDraftVersion: number) =>
requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/draft/lines/${encodeURIComponent(lineKey)}/copy`,
{ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ expected_draft_version: expectedDraftVersion }) },
);
export const deleteWorkspaceShippingOrderReviewLine = (caseNo: string, lineKey: string, expectedDraftVersion: number) =>
requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/draft/lines/${encodeURIComponent(lineKey)}`,
{ method: 'DELETE', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ expected_draft_version: expectedDraftVersion }) },
);
export const validateWorkspaceShippingOrderReviewDraft = (caseNo: string, expectedDraftVersion: number) =>
requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/draft/validate`,
{ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ expected_draft_version: expectedDraftVersion }) },
);
/** 确认当前 PDF 的已校验草稿;服务端以版本和幂等键确保只创建一张 Task。 */
export const confirmWorkspaceShippingOrderReviewCase = (
caseNo: string,
payload: { expected_draft_version: number; idempotency_key: string; warning_acknowledgements?: Array<{ code: string; comment?: string }> },
) => requestJson<import('../types/shipping.api.types').ShippingOrderReviewConfirmResponse>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/confirm`,
{ method: 'POST', headers: { 'Content-Type': 'application/json', 'Idempotency-Key': payload.idempotency_key }, body: JSON.stringify(payload) },
);
/** 启用无机器订单 PDF 的唯一人工草稿;不创建第二个订单对象。 */
export const createWorkspaceShippingOrderReviewManualDraft = (caseNo: string, comment?: string) =>
requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/manual-draft`,
jsonPost({ comment }),
);
/** 将当前 PDF 独立处置为非订单,服务端不会影响同一 Run 的其他 PDF。 */
export const markWorkspaceShippingOrderReviewNonOrder = (caseNo: string, reason: string, comment?: string) =>
requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/disposition/non-order`,
jsonPost({ reason, comment }),
);
/** 标记质量异常但保留原始 PDF、机器结果和草稿,供补件或重识别。 */
export const markWorkspaceShippingOrderReviewQualityIssue = (caseNo: string, reason: string, comment?: string) =>
requestJson<ShippingOrderReviewCase>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/disposition/quality-issue`,
jsonPost({ reason, comment }),
);
/** 仅创建当前 Case PDF 的后继识别 Run,重复点击幂等复用同一个处理中 Run。 */
export const reparseWorkspaceShippingOrderReviewDocument = (caseNo: string, reason: string, comment?: string) =>
requestJson<ShippingOrderReviewReparseResponse>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/reparse`,
jsonPost({ reason, comment }),
);
/** 绑定已上传的替代 PDF;预解析成功后再单独创建替代识别 Run。 */
export const createWorkspaceShippingOrderReviewReplacementIntake = (caseNo: string, assetNo: string) =>
requestJson<ShippingNoticeIntakeResponse>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/replacement-intakes`,
jsonPost({ asset_no: assetNo }),
);
/** 替代 Intake 解析成唯一 PDF 后创建新的单文档 Run。 */
export const createWorkspaceShippingOrderReviewReplacementRun = (caseNo: string, intakeNo: string) =>
requestJson<ShippingOrderReviewReparseResponse>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/replacement-runs`,
jsonPost({ intake_no: intakeNo }),
);
/** 获取复核字段的安全证据摘要;PDF 二进制继续由受控同源预览接口提供。 */
export const getWorkspaceShippingOrderReviewEvidence = (caseNo: string) =>
requestJson<{ case_no: string; items: ShippingOrderReviewEvidence[] }>(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/evidence`,
);
/** 以认证请求取得 PDF Blob,避免 iframe 无法携带 JWT 而退化为公开预览 URL。 */
export async function getWorkspaceShippingOrderReviewPreview(caseNo: string): Promise<Blob> {
const response = await fetch(
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/document-preview`,
{ headers: getAuthHeaders() },
);
if (!response.ok) {
throw new BusinessError({ message: 'Review PDF preview failed', code: 'SHIPPING.REVIEW_PREVIEW_NOT_FOUND', status: response.status });
}
return response.blob();
}
/** 用户展开状态卡时获取脱敏进度时间线;不返回节点或Workflow诊断数据。 */
export const listWorkspaceShippingOrderExtractionProgressEvents = (runNo: string) =>
requestJson<{ items: ShippingOrderExtractionProgressEvent[] }>(
@@ -762,7 +888,7 @@ export const refreshShippingNoticeDuplicate = (intakeNo: string) =>
export const updateShippingNoticeCandidate = (
candidateNo: string,
patch: { selected?: boolean; business_summary?: Record<string, unknown> },
patch: { selected: boolean },
) => requestJson<import('../types/shipping.api.types').ShippingNoticeCandidateResponse>(
`/api/workspace/shipping-notice/candidates/${encodeURIComponent(candidateNo)}`,
{
@@ -5,7 +5,7 @@
* 逻辑:附件卡片位于文本框上方;订单审核结果随对应聊天消息展示,输入区只保留附件处理状态。
*/
<script setup lang="ts">
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import type { Ref } from 'vue';
import {
@@ -82,7 +82,6 @@ const emit = defineEmits<{
'retry-shipping-notice-attachment': [id: string];
'resolve-shipping-notice-duplicate': [id: string];
'select-shipping-candidate': [candidateNo: string, selected: boolean];
'update-shipping-candidate': [candidateNo: string, businessSummary: Record<string, unknown>, done: (success: boolean) => void];
'resolve-shipping-candidate-duplicate': [candidateNo: string, action: import('../types/shipping.types').ShippingDuplicateAction, targetTaskNo: string | undefined, reason: string | undefined, done: (success: boolean) => void];
'local-files-selected': [event: Event];
'add-remote-url': [url: string];
@@ -104,6 +103,16 @@ const showAttachmentUrlPanel = ref(false);
const showKbDropdown = ref(false);
const attachmentUrlInput = ref('');
/** 当前发货通知是否仍在上传或预解析,决定输入框下方的操作提示。 */
const hasShippingNoticeInProgress = computed(() => props.attachments.some(
(attachment) => attachment.kind === 'shipping_notice'
&& (
attachment.uploadStatus === 'waiting'
|| attachment.uploadStatus === 'uploading'
|| ['waiting', 'queued', 'parsing'].includes(attachment.parseStatus)
),
));
/**
* 汇总 EML 附件解析进度,供输入栏徽标展示。
* 核心逻辑:阶段 1 仅展示快览结果;优先说明发现了多少附件,技术失败/目录不完整再退化为问题提示。
@@ -464,14 +473,7 @@ watch(
v-if="isShippingNoticeAgent && attachments.length > 0"
class="flex flex-wrap items-center gap-2 px-3 pb-1 text-xs text-muted"
>
<button
type="button"
class="rounded-full border border-default bg-surface-soft px-3 py-1 font-medium text-secondary transition-colors hover:bg-surface-soft/70"
@click="emit('use-shipping-suggested-prompt')"
>
{{ shippingSuggestedPrompt || '推荐问题' }}
</button>
<span>{{ t('chat.shippingNoticeConfirmBatchHint') }}</span>
<span>{{ hasShippingNoticeInProgress ? t('chat.shippingNoticeWaitingForParse') : t('chat.shippingNoticeConfirmBatchHint') }}</span>
</div>
<div class="mt-1.5 flex items-center justify-between px-1.5 pb-0.5">
@@ -6,6 +6,7 @@
*/
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { Maximize2, Minimize2, Loader2 } from 'lucide-vue-next';
import ChatShell from '@/shared/layouts/ChatShell.vue';
import ChatSidebar from '@/features/chat/components/ChatSidebar.vue';
@@ -18,6 +19,7 @@ import ShippingBatchWorkspaceDrawer from '@/features/chat/components/ShippingBat
import TrainingWorkspacePanel from '@/features/chat/components/TrainingWorkspacePanel.vue';
import LedgerConfigPanel from '@/features/maintenance/components/LedgerConfigPanel.vue';
import MaintenanceRecordManagerPanel from '@/features/maintenance/components/MaintenanceRecordManagerPanel.vue';
import ShippingOrderReviewView from '@/features/chat/views/ShippingOrderReviewView.vue';
import { useChatPageContext } from '@/features/chat/composables/chat.context';
import { matchesTrainingAgent } from '@/features/chat/training/trainingWorkspace.utils';
import { agentHasIntentUiProfile } from '@/shared/utils/agent-registry.utils';
@@ -36,6 +38,8 @@ type MaintenanceRecordPanelCommand = {
};
const page = useChatPageContext();
const route = useRoute();
const isOrderReviewMode = computed(() => route.query.mode === 'order-review' && typeof route.query.run_no === 'string' && route.query.run_no.length > 0);
const isTrainingAgentPage = computed(() => matchesTrainingAgent(page.currentAgent));
const isMaintenanceAgentPage = computed(() => agentHasIntentUiProfile(page.currentAgent, 'maintenance'));
const embeddedIframeSrc = computed(() => {
@@ -195,7 +199,8 @@ watch(() => page.currentAgentId, () => {
</div>
<template v-else>
<div class="flex min-h-0 min-w-0 flex-1">
<ShippingOrderReviewView v-if="isOrderReviewMode" />
<div v-else class="flex min-h-0 min-w-0 flex-1">
<div class="flex min-h-0 min-w-0 flex-1 flex-col">
<TrainingWorkspacePanel
:current-agent="page.currentAgent"
@@ -291,7 +296,6 @@ watch(() => page.currentAgentId, () => {
@retry-shipping-notice-attachment="page.retryShippingNoticeAttachment"
@resolve-shipping-notice-duplicate="page.openShippingDuplicateDialog"
@select-shipping-candidate="page.setShippingCandidateSelected"
@update-shipping-candidate="page.updateShippingCandidateSummary"
@resolve-shipping-candidate-duplicate="page.resolveShippingCandidateDuplicate"
@local-files-selected="page.handleLocalFilesSelected"
@add-remote-url="page.addRemoteUrlAttachment"
@@ -1,344 +0,0 @@
<!--
features/chat/components/ShippingNoticeCandidateReview.vue
用途:展示一封 EML 下的订单候选,并提供选择、结构化修订与重复决策入口。
依赖:shipping.types、Vue I18n。
逻辑:组件维护 PO 与订单行编辑草稿,持久化操作通过事件交给 useShippingNoticeIntakes。
-->
<script setup lang="ts">
import { computed, reactive, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingDuplicateAction, ShippingNoticePendingAttachment } from '../types/shipping.types';
interface EditableCandidateLine {
source: Record<string, unknown>;
part_number: string;
customer_part_number: string;
aws_part_number: string;
qty: string;
reservation_id: string;
inventory_source_hint: string;
uom: string;
}
const props = defineProps<{
attachment: ShippingNoticePendingAttachment;
canForceCreate: boolean;
}>();
const emit = defineEmits<{
update: [candidateNo: string, businessSummary: Record<string, unknown>, done: (success: boolean) => void];
resolveDuplicate: [candidateNo: string, action: ShippingDuplicateAction, targetTaskNo: string | undefined, reason: string | undefined, done: (success: boolean) => void];
promote: [candidateNo: string, done: (success: boolean) => void];
reject: [candidateNo: string, done: (success: boolean) => void];
}>();
const { t } = useI18n();
const editingCandidateNo = ref('');
const editError = ref('');
const editPoNumber = ref('');
const editLines = reactive<EditableCandidateLine[]>([]);
const forceReasonCandidateNo = ref('');
const forceReason = ref('');
const submittingCandidateNo = ref('');
const candidates = computed(() => props.attachment.candidates || []);
watch(() => props.attachment.candidates, () => {
if (editingCandidateNo.value && !candidates.value.some((item) => item.candidateNo === editingCandidateNo.value)) {
editingCandidateNo.value = '';
}
});
/**
* 将 Candidate 摘要投影为可编辑的 PO 与订单行。
* 核心逻辑:保留原始扩展字段,并显式映射三类料号、数量、Reservation ID、库存源线索与单位。
* @param candidateNo - 待编辑的 Candidate 编号
* @returns 无返回值;Candidate 不存在时保持当前编辑状态
*/
function startEdit(candidateNo: string): void {
const candidate = candidates.value.find((item) => item.candidateNo === candidateNo);
if (!candidate) return;
const sourceLines = Array.isArray(candidate.businessSummary.lines)
? candidate.businessSummary.lines.filter((item): item is Record<string, unknown> => !!item && typeof item === 'object')
: [];
editingCandidateNo.value = candidateNo;
editPoNumber.value = String(candidate.businessSummary.po_number || candidate.poNumber || '');
editLines.splice(0, editLines.length, ...sourceLines.map((line) => ({
source: { ...line },
part_number: String(line.part_number || ''),
customer_part_number: String(line.customer_part_number || ''),
aws_part_number: String(line.aws_part_number || ''),
qty: String(line.qty ?? ''),
reservation_id: String(line.reservation_id || ''),
inventory_source_hint: String(line.inventory_source_hint || ''),
uom: String(line.uom || 'EA'),
})));
if (!editLines.length) addLine();
editError.value = '';
}
/**
* 新增一条待修订订单行。
* 核心逻辑:创建带三类料号和可选库存源线索的空白草稿。
* @returns 无返回值
*/
function addLine(): void {
editLines.push({
source: {},
part_number: '',
customer_part_number: '',
aws_part_number: '',
qty: '',
reservation_id: '',
inventory_source_hint: '',
uom: 'EA',
});
}
/**
* 校验并提交 Candidate 修订。
* 核心逻辑:保留原始扩展字段,并按 v2 契约提交三类料号与唯一库存源线索。
* @returns 无返回值;校验失败时写入本地错误提示
*/
function saveEdit(): void {
const candidate = candidates.value.find((item) => item.candidateNo === editingCandidateNo.value);
if (!candidate || !editLines.length) return;
const normalizedLines = editLines.map((line) => {
const source = { ...line.source };
return {
...source,
part_number: line.part_number.trim(),
customer_part_number: line.customer_part_number.trim() || undefined,
aws_part_number: line.aws_part_number.trim() || undefined,
qty: Number(line.qty),
reservation_id: line.reservation_id.trim() || undefined,
inventory_source_hint: line.inventory_source_hint.trim() || undefined,
uom: line.uom.trim() || 'EA',
};
});
if (normalizedLines.some((line) => !line.part_number || !Number.isFinite(line.qty) || line.qty <= 0)) {
editError.value = t('chat.shippingCandidateInvalidLine');
return;
}
submittingCandidateNo.value = candidate.candidateNo;
emit('update', candidate.candidateNo, {
...candidate.businessSummary,
po_number: editPoNumber.value.trim() || null,
lines: normalizedLines,
}, (success) => {
submittingCandidateNo.value = '';
if (success) {
editingCandidateNo.value = '';
editError.value = '';
}
});
}
/**
* 非编辑态展示 Candidate 订单行摘要。
* @param candidate - 当前 Candidate
*/
function readonlyLines(candidate: typeof candidates.value[number]): Array<Record<string, unknown>> {
const lines = candidate.businessSummary?.lines;
return Array.isArray(lines)
? lines.filter((item): item is Record<string, unknown> => !!item && typeof item === 'object')
: [];
}
/** 将未知值格式化为表格占位文本。 */
function displayCell(value: unknown): string {
const text = String(value ?? '').trim();
return text || '—';
}
/** 将客户匹配状态转换为面向业务用户的文案。 */
function customerMatchStatus(status: string): string {
return t(`chat.shippingCustomerMatch.status.${status}`);
}
/** 对当前首个重复目标应用决策;强制新建时要求填写原因。 */
function resolveDuplicate(candidateNo: string, action: ShippingDuplicateAction): void {
const candidate = candidates.value.find((item) => item.candidateNo === candidateNo);
const target = candidate?.duplicate?.matches?.[0]?.taskNo;
if (action === 'force_create') {
forceReasonCandidateNo.value = candidateNo;
forceReason.value = '';
return;
}
submittingCandidateNo.value = candidateNo;
emit('resolveDuplicate', candidateNo, action, target, undefined, () => {
submittingCandidateNo.value = '';
});
}
/** 提交内联强制新建原因,避免浏览器 prompt 丢失上下文或不可访问。 */
function submitForceCreate(candidateNo: string): void {
const candidate = candidates.value.find((item) => item.candidateNo === candidateNo);
const reason = forceReason.value.trim();
if (!candidate || !reason) return;
submittingCandidateNo.value = candidateNo;
emit(
'resolveDuplicate',
candidateNo,
'force_create',
candidate.duplicate?.matches?.[0]?.taskNo,
reason,
(success) => {
submittingCandidateNo.value = '';
if (success) forceReasonCandidateNo.value = '';
},
);
}
/** 发起后端决定的人工采纳或驳回;UI 不自行推导履约资格。 */
function decideCandidate(candidateNo: string, action: 'promote' | 'reject'): void {
submittingCandidateNo.value = candidateNo;
const done = () => { submittingCandidateNo.value = ''; };
if (action === 'promote') emit('promote', candidateNo, done);
else emit('reject', candidateNo, done);
}
</script>
<template>
<div v-if="candidates.length" class="w-full space-y-2 rounded-xl border border-default bg-surface px-3 py-2">
<div class="flex items-center justify-between text-xs">
<span class="font-semibold text-primary">{{ t('chat.shippingCandidateTitle') }}</span>
<span class="text-muted">{{ t('chat.shippingCandidateCount', { count: candidates.length }) }}</span>
</div>
<div v-for="candidate in candidates" :key="candidate.candidateNo" class="rounded-lg border border-default bg-surface-soft p-2 text-xs">
<div class="flex flex-wrap items-center gap-2">
<span class="font-mono text-primary">{{ candidate.candidateNo }}</span>
<span class="font-medium text-secondary">PO {{ candidate.poNumber || '-' }}</span>
<span v-if="candidate.documentFilename" class="max-w-40 truncate text-muted">{{ candidate.documentFilename }}</span>
<span :class="candidate.candidateStatus === 'accepted' ? 'text-emerald-700' : 'text-amber-700'">
{{ candidate.candidateStatus === 'accepted' ? (candidate.acceptanceMode === 'automatic' ? t('chat.shippingCandidateAutoAccepted') : t('chat.shippingCandidateAccepted')) : (candidate.candidateStatus === 'rejected' ? t('chat.shippingCandidateRejected') : t('chat.shippingCandidateNeedsReview')) }}
</span>
<button v-if="candidate.actionButtons.includes('edit')" type="button" class="ml-auto text-brand-700 hover:underline" @click="startEdit(candidate.candidateNo)">
{{ t('chat.shippingCandidateEdit') }}
</button>
</div>
<div v-if="candidate.conflicts.length" class="mt-1 text-amber-700">
{{ t('chat.shippingCandidateConflictCount', { count: candidate.conflicts.length }) }}
</div>
<div
v-if="candidate.customerMatches?.length"
class="mt-2 overflow-x-auto rounded-lg border border-default bg-surface"
>
<div class="border-b border-default bg-surface-soft px-2 py-1.5 font-semibold text-primary">
{{ t('chat.shippingCustomerMatch.title') }}
</div>
<table class="min-w-full text-[11px]">
<thead class="text-left text-muted">
<tr>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.role') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.rawName') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.standardName') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.shortCode') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.site') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.statusLabel') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="match in candidate.customerMatches" :key="match.role" class="border-t border-default/60">
<td class="px-2 py-1 font-medium">{{ t(`chat.shippingCustomerMatch.roles.${match.role}`) }}</td>
<td class="px-2 py-1">{{ displayCell(match.raw_name) }}</td>
<td class="px-2 py-1">{{ displayCell(match.standard_name) }}</td>
<td class="px-2 py-1 font-mono">{{ displayCell(match.short_code) }}</td>
<td class="px-2 py-1">{{ displayCell(match.candidates?.find((item) => item.site_id === match.site_id)?.site_name) }}</td>
<td class="px-2 py-1">{{ customerMatchStatus(match.status) }}</td>
</tr>
</tbody>
</table>
</div>
<div
v-if="editingCandidateNo !== candidate.candidateNo && readonlyLines(candidate).length"
class="mt-2 overflow-x-auto rounded-lg border border-default bg-surface"
>
<table class="min-w-full text-[11px]">
<thead class="bg-surface-soft text-left text-muted">
<tr>
<th class="px-2 py-1">{{ t('chat.shippingNoticeUi.partNumber') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingNoticeUi.customerPartNumber') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingNoticeUi.awsPartNumber') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCandidateQty') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingCandidateReservation') }}</th>
<th class="px-2 py-1">{{ t('chat.shippingNoticeUi.inventorySourceHint') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="(line, index) in readonlyLines(candidate)"
:key="`${candidate.candidateNo}-line-${index}`"
class="border-t border-default/60"
>
<td class="px-2 py-1 font-mono">{{ displayCell(line.part_number) }}</td>
<td class="px-2 py-1 font-mono">{{ displayCell(line.customer_part_number) }}</td>
<td class="px-2 py-1 font-mono">{{ displayCell(line.aws_part_number) }}</td>
<td class="px-2 py-1">{{ displayCell(line.qty) }}</td>
<td class="px-2 py-1 font-mono">{{ displayCell(line.reservation_id) }}</td>
<td class="px-2 py-1">{{ displayCell(line.inventory_source_hint) }}</td>
</tr>
</tbody>
</table>
</div>
<div v-if="(candidate.missingFields || []).length" class="mt-1 text-amber-700">
{{ t('chat.shippingCandidateMissingFields', { fields: (candidate.missingFields || []).join(', ') }) }}
</div>
<div v-if="candidate.duplicate?.blocking && !candidate.duplicateResolution" class="mt-2 flex flex-wrap items-center gap-2 text-amber-700">
<span>{{ t('chat.shippingCandidateDuplicate', { task: candidate.duplicate.matches[0]?.taskNo || '-' }) }}</span>
<button
v-if="candidate.duplicate.allowedActions.includes('open_existing')"
type="button"
class="rounded border border-default bg-surface px-2 py-0.5"
@click="resolveDuplicate(candidate.candidateNo, 'open_existing')"
>{{ t('chat.shippingNoticeDuplicateOpenExisting') }}</button>
<button
v-if="candidate.duplicate.allowedActions.includes('create_revision')"
type="button"
class="rounded border border-default bg-surface px-2 py-0.5"
@click="resolveDuplicate(candidate.candidateNo, 'create_revision')"
>{{ t('chat.shippingNoticeDuplicateCreateRevision') }}</button>
<button
v-if="canForceCreate && candidate.duplicate.allowedActions.includes('force_create')"
type="button"
class="rounded border border-amber-300 bg-surface px-2 py-0.5"
@click="resolveDuplicate(candidate.candidateNo, 'force_create')"
>{{ t('chat.shippingNoticeDuplicateForceCreate') }}</button>
</div>
<div v-if="forceReasonCandidateNo === candidate.candidateNo" class="mt-2 flex gap-2">
<input v-model="forceReason" :placeholder="t('chat.shippingCandidateForceReasonPrompt')" class="min-w-0 flex-1 rounded border border-default bg-surface px-2 py-1" />
<button type="button" class="rounded bg-amber-600 px-2 py-1 text-white disabled:opacity-50" :disabled="!forceReason.trim() || submittingCandidateNo === candidate.candidateNo" @click="submitForceCreate(candidate.candidateNo)">{{ t('chat.shippingNoticeDuplicateConfirm') }}</button>
<button type="button" class="text-muted" @click="forceReasonCandidateNo = ''">{{ t('common.cancel') }}</button>
</div>
<div v-else-if="candidate.duplicateResolution" class="mt-1 text-muted">
{{ t('chat.shippingCandidateDuplicateResolved', { action: candidate.duplicateResolution.action }) }}
</div>
<div v-if="candidate.actionButtons.includes('promote') || candidate.actionButtons.includes('reject')" class="mt-2 flex gap-2">
<button v-if="candidate.actionButtons.includes('promote')" type="button" class="rounded bg-brand-600 px-2 py-1 text-white disabled:opacity-50" :disabled="submittingCandidateNo === candidate.candidateNo" @click="decideCandidate(candidate.candidateNo, 'promote')">{{ t('chat.shippingCandidatePromote') }}</button>
<button v-if="candidate.actionButtons.includes('reject')" type="button" class="rounded border border-default px-2 py-1 text-secondary disabled:opacity-50" :disabled="submittingCandidateNo === candidate.candidateNo" @click="decideCandidate(candidate.candidateNo, 'reject')">{{ t('chat.shippingCandidateReject') }}</button>
</div>
<div v-if="editingCandidateNo === candidate.candidateNo" class="mt-2 space-y-2">
<label class="block">
<span class="text-muted">{{ t('chat.shippingCandidatePoNumber') }}</span>
<input v-model="editPoNumber" class="mt-1 w-full rounded border border-default bg-surface px-2 py-1 text-primary" />
</label>
<div v-for="(line, index) in editLines" :key="index" class="grid grid-cols-2 gap-2 rounded border border-default bg-surface p-2 md:grid-cols-4">
<input v-model="line.part_number" :placeholder="t('chat.shippingNoticeUi.partNumber')" class="rounded border border-default px-2 py-1" />
<input v-model="line.customer_part_number" :placeholder="t('chat.shippingNoticeUi.customerPartNumber')" class="rounded border border-default px-2 py-1" />
<input v-model="line.aws_part_number" :placeholder="t('chat.shippingNoticeUi.awsPartNumber')" class="rounded border border-default px-2 py-1" />
<input v-model="line.qty" type="number" min="0.0001" step="any" :placeholder="t('chat.shippingCandidateQty')" class="rounded border border-default px-2 py-1" />
<input v-model="line.reservation_id" :placeholder="t('chat.shippingCandidateReservation')" class="rounded border border-default px-2 py-1" />
<input v-model="line.inventory_source_hint" :placeholder="t('chat.shippingNoticeUi.inventorySourceHint')" class="rounded border border-default px-2 py-1" />
<div class="flex gap-1">
<input v-model="line.uom" :placeholder="t('chat.shippingCandidateUom')" class="min-w-0 flex-1 rounded border border-default px-2 py-1" />
<button v-if="editLines.length > 1" type="button" class="text-red-600" @click="editLines.splice(index, 1)">×</button>
</div>
</div>
<button type="button" class="text-brand-700 hover:underline" @click="addLine">{{ t('chat.shippingCandidateAddLine') }}</button>
<div v-if="editError" class="text-red-600">{{ editError }}</div>
<div class="flex justify-end gap-2">
<button type="button" class="rounded px-2 py-1 text-secondary" @click="editingCandidateNo = ''">{{ t('common.cancel') }}</button>
<button type="button" class="rounded bg-brand-600 px-2 py-1 text-white disabled:opacity-50" :disabled="submittingCandidateNo === candidate.candidateNo" @click="saveEdit">{{ t('chat.shippingCandidateSave') }}</button>
</div>
</div>
</div>
</div>
</template>
@@ -23,7 +23,6 @@ import ChatMessageAttachmentList from './ChatMessageAttachmentList.vue';
import MaintenanceDeviceResultCard from './MaintenanceDeviceResultCard.vue';
import ShippingMatchResultCard from './ShippingMatchResultCard.vue';
import ShippingParseReviewMessage, { type ShippingParseReviewHandlers } from './ShippingParseReviewMessage.vue';
import ShippingNoticeCandidateReview from '../ShippingNoticeCandidateReview.vue';
import type { ShippingMessageHandlers } from './shippingMessageHandlers';
import TrainingExamQuestionMessage, { type TrainingHandlers } from './TrainingExamQuestionMessage.vue';
import TrainingVideoMessage from './TrainingVideoMessage.vue';
@@ -32,8 +31,6 @@ import TrainingResultCard from './TrainingResultCard.vue';
import ShippingOrderExtractionCard from '../shipping/ShippingOrderExtractionCard.vue';
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../../types/chat.types';
import type { ShippingMatchResultPayload } from '../../types/shipping.types';
import type { ShippingNoticePendingAttachment } from '../../types/shipping.types';
import type { ShippingOrderExtractionReviewAttachment } from '../../types/chat.types';
import type { MaintenanceDevice } from '@/features/maintenance/types/ledger.types';
import type { MaintenanceRecord } from '@/features/maintenance/types/record.types';
@@ -137,60 +134,12 @@ const showShippingActionsPanel = computed(() =>
);
const shippingOrderExtractionState = computed(() => message.shipping_order_extraction_state);
const retryingOrderExtraction = ref(false);
const reviewAttachmentsSection = ref<HTMLElement | null>(null);
const shippingOrderExtractionRunNo = computed(() => {
const payload = message.payload && typeof message.payload === 'object'
? message.payload as Record<string, unknown>
: {};
return String(payload.order_extraction_run_no || '').trim();
});
const shippingOrderExtractionReviewAttachments = computed<ShippingNoticePendingAttachment[]>(() => {
const payload = message.payload && typeof message.payload === 'object' ? message.payload as Record<string, unknown> : {};
const reviews = Array.isArray(payload.shipping_order_extraction_review)
? payload.shipping_order_extraction_review as ShippingOrderExtractionReviewAttachment[]
: [];
return reviews
.filter((item) => item && Array.isArray(item.candidates) && item.candidates.length)
.map((item) => ({
id: `shipping-order-extraction-review-${item.intakeNo}`,
kind: 'shipping_notice' as const,
type: 'document' as const,
intakeNo: item.intakeNo,
uploadStatus: 'uploaded' as const,
parseStatus: 'parsed' as const,
uploadProgress: 100,
originalFilename: item.originalFilename,
fileSize: 0,
candidates: item.candidates,
}));
});
const updateOrderExtractionCandidate = async (
candidateNo: string,
businessSummary: Record<string, unknown>,
done: (success: boolean) => void,
) => {
await shippingHandlers.updateCandidate(candidateNo, businessSummary, done);
};
const promoteOrderExtractionCandidate = async (candidateNo: string, done: (success: boolean) => void) => {
await shippingHandlers.promoteCandidate(candidateNo, done);
};
const rejectOrderExtractionCandidate = async (candidateNo: string, done: (success: boolean) => void) => {
await shippingHandlers.rejectCandidate(candidateNo, done);
};
const resolveOrderExtractionCandidateDuplicate = async (
candidateNo: string,
action: import('../../types/shipping.types').ShippingDuplicateAction,
targetTaskNo: string | undefined,
reason: string | undefined,
done: (success: boolean) => void,
) => {
await shippingHandlers.resolveCandidateDuplicate(candidateNo, action, targetTaskNo, reason, done);
};
/** 失败卡片复用原 Run 重试;按钮本地防重,成功后状态卡由 Run 轮询原位更新。 */
const retryShippingOrderExtraction = async () => {
if (!shippingOrderExtractionRunNo.value || retryingOrderExtraction.value) return;
@@ -201,11 +150,6 @@ const retryShippingOrderExtraction = async () => {
retryingOrderExtraction.value = false;
}
};
const enterOrderExtractionManualReview = async () => {
if (!shippingOrderExtractionReviewAttachments.value.length) return;
await nextTick();
reviewAttachmentsSection.value?.scrollIntoView({ behavior: 'smooth', block: 'start' });
};
const isLastMessage = computed(() => index === messageCount - 1 || (message.role === 'assistant' && isLatestAssistantMessage));
const isCopied = computed(() => copiedIndex === index);
const renderedMarkdown = computed(() => (
@@ -732,26 +676,8 @@ function handleInlineDownload(file: InlineDownloadFile): void {
v-if="shippingOrderExtractionState"
:state="shippingOrderExtractionState"
:run-no="shippingOrderExtractionRunNo"
:has-review-attachments="shippingOrderExtractionReviewAttachments.length > 0"
@retry="retryShippingOrderExtraction"
@enter-manual-review="enterOrderExtractionManualReview"
/>
<div
v-if="shippingOrderExtractionReviewAttachments.length"
ref="reviewAttachmentsSection"
class="mb-3 space-y-2"
>
<ShippingNoticeCandidateReview
v-for="attachment in shippingOrderExtractionReviewAttachments"
:key="attachment.intakeNo"
:attachment="attachment"
:can-force-create="false"
@update="updateOrderExtractionCandidate"
@resolve-duplicate="resolveOrderExtractionCandidateDuplicate"
@promote="promoteOrderExtractionCandidate"
@reject="rejectOrderExtractionCandidate"
/>
</div>
<LeaveMessageBlock
v-if="isLeaveMessage"
:message="message"
@@ -17,7 +17,6 @@ export interface ShippingMessageHandlers {
removeLine: (msg: ChatMessage, lineIndex: number) => Promise<boolean>;
retryOrderExtractionRun: (runNo: string) => Promise<boolean>;
reparseOrderExtractionRun: (runNo: string, reason: 'rule_updated' | 'field_mapping_error' | 'document_quality' | 'other') => Promise<boolean>;
updateCandidate: (candidateNo: string, businessSummary: Record<string, unknown>, done: (success: boolean) => void) => Promise<void>;
resolveCandidateDuplicate: (candidateNo: string, action: import('../../types/shipping.types').ShippingDuplicateAction, targetTaskNo: string | undefined, reason: string | undefined, done: (success: boolean) => void) => Promise<void>;
promoteCandidate: (candidateNo: string, done: (success: boolean) => void) => Promise<void>;
rejectCandidate: (candidateNo: string, done: (success: boolean) => void) => Promise<void>;
@@ -0,0 +1,73 @@
<!--
用途:渲染受控 PDF Blob,并仅为服务端验证的 bbox 绘制证据高亮。
依赖:pdfjs-dist、Review Evidence DTO。
逻辑:预览失败独立显示,不影响同页草稿编辑;缺少可靠 bbox 时只保留页码定位。
-->
<script setup lang="ts">
import { nextTick, ref, watch } from 'vue';
import * as pdfjs from 'pdfjs-dist';
import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
import type { ShippingOrderReviewEvidence } from '../../types/shipping.api.types';
pdfjs.GlobalWorkerOptions.workerSrc = workerUrl;
const props = defineProps<{
src: string;
evidence?: ShippingOrderReviewEvidence | null;
title: string;
loadingText: string;
unavailableText: string;
}>();
const canvas = ref<HTMLCanvasElement | null>(null);
const loading = ref(false);
const failed = ref(false);
/** 将当前页渲染到 canvas;高亮以 PDF viewport 为基准,绝不猜测不可靠坐标。 */
const render = async () => {
if (!props.src) return;
loading.value = true;
failed.value = false;
try {
const document = await pdfjs.getDocument(props.src).promise;
const pageNo = Math.min(Math.max(props.evidence?.page_no || 1, 1), document.numPages);
const page = await document.getPage(pageNo);
const viewport = page.getViewport({ scale: 1.4 });
await nextTick();
if (!canvas.value) return;
canvas.value.width = Math.ceil(viewport.width);
canvas.value.height = Math.ceil(viewport.height);
const context = canvas.value.getContext('2d');
if (!context) return;
await page.render({ canvas: canvas.value, canvasContext: context, viewport }).promise;
const bbox = props.evidence?.bbox;
if (bbox) {
context.save();
context.fillStyle = 'rgba(250, 204, 21, 0.35)';
context.strokeStyle = 'rgba(202, 138, 4, 0.95)';
context.lineWidth = 2;
const x = bbox.x0 * viewport.width;
const y = bbox.y0 * viewport.height;
const width = (bbox.x1 - bbox.x0) * viewport.width;
const height = (bbox.y1 - bbox.y0) * viewport.height;
context.fillRect(x, y, width, height);
context.strokeRect(x, y, width, height);
context.restore();
}
} catch {
failed.value = true;
} finally {
loading.value = false;
}
};
watch(() => [props.src, props.evidence?.evidence_id], () => { void render(); }, { immediate: true });
</script>
<template>
<div class="relative flex min-h-[360px] items-center justify-center overflow-auto bg-slate-100 p-3 dark:bg-slate-950">
<!-- Keep the canvas mounted while PDF.js is loading; otherwise nextTick cannot obtain a render target. -->
<canvas ref="canvas" :aria-label="title" class="max-w-full bg-white shadow" :class="{ invisible: loading || failed }" />
<span v-if="loading" class="absolute text-sm text-slate-500">{{ loadingText }}</span>
<span v-else-if="failed" class="absolute text-sm text-rose-600">{{ unavailableText }}</span>
</div>
</template>
@@ -3,7 +3,7 @@
* features/chat/components/shipping/ShippingOrderDocumentResultItem.vue
* 用途:渲染单个 PDF 的订单抽取结果摘要,供详情抽屉按文档逐项展示。
* 依赖:订单抽取文档 DTO、vue-i18n。
* 逻辑:只显示用户可理解的业务字段;人工复核入口复用现有候选审核区,不直接暴露内部证据细节。
* 逻辑:只显示用户可理解的业务字段;人工复核由上层统一跳转独立工作台。
*/
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
@@ -12,14 +12,13 @@ import type { ShippingOrderExtractionDocumentResult } from '../../types/shipping
const props = defineProps<{
document: ShippingOrderExtractionDocumentResult;
hasReviewAttachments?: boolean;
}>();
const emit = defineEmits<{
enterManualReview: [];
}>();
const { t, te } = useI18n();
const { t, te, locale } = useI18n();
const statusTone = computed(() => {
switch (props.document.status) {
@@ -36,6 +35,23 @@ const statusTone = computed(() => {
});
const statusLabel = computed(() => t(`chat.shippingOrderExtractionDocumentStatus.${props.document.status}`));
const statusActivityLabel = computed(() => {
const key = `chat.shippingOrderExtractionActivity.${props.document.activity_event_code || props.document.status}`;
return te(key) ? t(key) : statusLabel.value;
});
const formatTime = (value: string | null | undefined): string => {
const date = new Date(String(value || ''));
if (Number.isNaN(date.getTime())) return '';
return new Intl.DateTimeFormat(String(locale.value || 'zh-CN'), {
hour: '2-digit', minute: '2-digit', hour12: false,
}).format(date);
};
const activityTimeLabel = computed(() => {
if (props.document.finished_at) return t('chat.shippingOrderExtractionDocumentTiming.finished', { time: formatTime(props.document.finished_at) });
if (props.document.last_activity_at) return t('chat.shippingOrderExtractionDocumentTiming.updated', { time: formatTime(props.document.last_activity_at) });
if (props.document.started_at) return t('chat.shippingOrderExtractionDocumentTiming.started', { time: formatTime(props.document.started_at) });
return '';
});
const reasonLabel = computed(() => (
props.document.reason_code
? t(`chat.shippingOrderExtractionReason.${props.document.reason_code}`)
@@ -81,13 +97,9 @@ const reviewFieldLabel = (fieldCode: string | null | undefined): string => {
};
const canEnterManualReview = computed(() => (
props.hasReviewAttachments
&& props.document.available_actions.some((action) => action === 'review_candidate' || action === 'manual_review')
));
const canViewEvidence = computed(() => (
props.hasReviewAttachments
&& props.document.available_actions.includes('view_evidence')
props.document.available_actions.some((action) => action === 'review_candidate' || action === 'manual_review')
));
const canViewEvidence = computed(() => props.document.available_actions.includes('view_evidence'));
</script>
<template>
@@ -105,7 +117,11 @@ const canViewEvidence = computed(() => (
<div class="truncate text-sm font-semibold">{{ document.file_name || t('chat.shippingOrderExtractionUnknownDocument') }}</div>
<span class="rounded-full bg-black/10 px-2 py-0.5 text-[11px] dark:bg-white/10">{{ statusLabel }}</span>
</div>
<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>
<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>
@@ -8,6 +8,7 @@ import { nextTick } from 'vue';
import { mount } from '@vue/test-utils';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { createI18n } from 'vue-i18n';
import { createMemoryHistory, createRouter } from 'vue-router';
import chatZhCn from '@/locales/zh-CN/chat.json';
import ShippingOrderDocumentResultItem from './ShippingOrderDocumentResultItem.vue';
import ShippingOrderExtractionCard from './ShippingOrderExtractionCard.vue';
@@ -43,6 +44,14 @@ const flushUi = async () => {
await nextTick();
};
const makeRouter = () => createRouter({
history: createMemoryHistory(),
routes: [
{ path: '/chat/:agentId', name: 'Chat', component: { template: '<div />' } },
{ path: '/chat/:agentId/order-review/:runNo', name: 'ShippingOrderReview', component: { template: '<div />' } },
],
});
const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): ShippingOrderExtractionState => ({
status: 'processing',
summary: {
@@ -116,7 +125,7 @@ describe('ShippingOrderExtractionCard', () => {
document.body.innerHTML = '';
});
it('loads documents once when opening details from server actions', async () => {
it('refreshes documents whenever the details drawer is opened', async () => {
api.listDocuments.mockResolvedValue({ items: [buildDocument()] });
api.listProgressEvents.mockResolvedValue({ items: [buildProgressEvent()] });
const wrapper = mount(ShippingOrderExtractionCard, {
@@ -189,21 +198,24 @@ describe('ShippingOrderExtractionCard', () => {
await detailButton!.trigger('click');
await flushUi();
expect(api.listDocuments).toHaveBeenCalledTimes(1);
expect(api.listProgressEvents).toHaveBeenCalledTimes(1);
expect(api.listDocuments).toHaveBeenCalledTimes(2);
expect(api.listProgressEvents).toHaveBeenCalledTimes(2);
});
it('emits manual review directly when attachments are already available', async () => {
it('routes manual review directly to the dedicated workspace', async () => {
const router = makeRouter();
await router.push({ name: 'Chat', params: { agentId: 'agent-1' } });
await router.isReady();
const pushSpy = vi.spyOn(router, 'push');
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
state: buildState({
availableActions: ['enter_manual_review'],
}),
runNo: 'SNER-002',
hasReviewAttachments: true,
},
global: {
plugins: [i18n],
plugins: [i18n, router],
stubs: {
teleport: true,
},
@@ -215,10 +227,37 @@ describe('ShippingOrderExtractionCard', () => {
await reviewButton!.trigger('click');
expect(wrapper.emitted('enterManualReview')).toHaveLength(1);
await vi.waitFor(() => expect(pushSpy).toHaveBeenCalled());
expect(pushSpy).toHaveBeenCalledWith({
name: 'Chat',
params: { agentId: 'agent-1' },
query: { mode: 'order-review', run_no: 'SNER-002' },
});
expect(api.listDocuments).not.toHaveBeenCalled();
});
it('preserves the originating conversation when entering manual review', async () => {
const router = makeRouter();
await router.push({ name: 'Chat', params: { agentId: 'agent-1' }, query: { conversation_id: 'conv-123' } });
await router.isReady();
const pushSpy = vi.spyOn(router, 'push');
const wrapper = mount(ShippingOrderExtractionCard, {
props: { state: buildState({ availableActions: ['enter_manual_review'] }), runNo: 'SNER-003' },
global: { plugins: [i18n, router], stubs: { teleport: true } },
});
const reviewButton = wrapper.findAll('button').find((item) => item.text().includes('进入人工复核'));
expect(reviewButton).toBeTruthy();
await reviewButton!.trigger('click');
await vi.waitFor(() => expect(pushSpy).toHaveBeenCalled());
expect(pushSpy).toHaveBeenCalledWith({
name: 'Chat',
params: { agentId: 'agent-1' },
query: { conversation_id: 'conv-123', mode: 'order-review', run_no: 'SNER-003' },
});
});
it('emits retry for failed attachments without mutating state locally', async () => {
const wrapper = mount(ShippingOrderExtractionCard, {
props: {
@@ -305,7 +344,6 @@ describe('ShippingOrderExtractionDetailsDrawer', () => {
loadFailed: false,
progressLoading: false,
progressLoadFailed: false,
hasReviewAttachments: true,
},
global: {
plugins: [i18n],
@@ -369,7 +407,6 @@ describe('ShippingOrderDocumentResultItem', () => {
},
available_actions: ['view_evidence', 'manual_review'],
}),
hasReviewAttachments: true,
},
global: {
plugins: [i18n],
@@ -5,7 +5,8 @@
* 依赖:订单抽取 Run 状态卡 DTO、documents API、详情抽屉。
* 逻辑:卡片只显示 Run 汇总、当前活动和下一步动作;逐 PDF 结果与 Run 事实时间线延迟到抽屉内按需加载。
*/
import { computed, ref, watch } from 'vue';
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { CircleCheck, CircleX, LoaderCircle, TriangleAlert } from 'lucide-vue-next';
import {
@@ -22,7 +23,6 @@ import ShippingOrderExtractionDetailsDrawer from './ShippingOrderExtractionDetai
const props = defineProps<{
state: ShippingOrderExtractionState;
runNo?: string;
hasReviewAttachments?: boolean;
}>();
const emit = defineEmits<{
@@ -31,6 +31,8 @@ const emit = defineEmits<{
}>();
const { t, te } = useI18n();
const route = useRoute();
const router = useRouter();
const detailsOpen = ref(false);
const documents = ref<ShippingOrderExtractionDocumentResult[]>([]);
@@ -41,6 +43,17 @@ const documentsLoadedForRun = ref('');
const loadingProgressEvents = ref(false);
const progressEventsLoadFailed = ref(false);
const progressEventsLoadedForRun = ref('');
let detailsRefreshTimer: ReturnType<typeof setInterval> | null = null;
const detailsFreshnessKey = computed(() => JSON.stringify({
runNo: props.runNo || '',
status: props.state.status,
phase: props.state.currentActivity?.eventCode || '',
total: props.state.summary.totalDocuments,
completed: props.state.summary.completedDocuments,
reviewRequired: props.state.summary.reviewRequiredDocuments,
failed: props.state.summary.failedDocuments,
}));
watch(
() => props.runNo,
@@ -152,11 +165,16 @@ const currentActivityContextSummary = computed(() => {
return parts.join(' · ');
});
const openDetails = async () => {
/**
* 刷新抽屉中的 Run 详情。
*
* 文档列表可能在布局 Job 完成后才落库;抽屉绝不能缓存首次打开时的空结果,
* 否则聊天卡已显示新状态而详情仍停留在旧的“暂无结果”。
*/
const refreshDetails = async () => {
if (!props.runNo) return;
detailsOpen.value = true;
const tasks: Promise<void>[] = [];
if (documentsLoadedForRun.value !== props.runNo && !loadingDocuments.value) {
if (!loadingDocuments.value) {
loadingDocuments.value = true;
documentsLoadFailed.value = false;
tasks.push(
@@ -173,7 +191,7 @@ const openDetails = async () => {
}),
);
}
if (progressEventsLoadedForRun.value !== props.runNo && !loadingProgressEvents.value) {
if (!loadingProgressEvents.value) {
loadingProgressEvents.value = true;
progressEventsLoadFailed.value = false;
tasks.push(
@@ -195,17 +213,55 @@ const openDetails = async () => {
}
};
const openDetails = async () => {
if (!props.runNo) return;
detailsOpen.value = true;
await refreshDetails();
};
/** 详情打开期间独立刷新,避免长任务只在聊天卡状态变更时才显示新阶段。 */
const stopDetailsRefresh = () => {
if (detailsRefreshTimer) clearInterval(detailsRefreshTimer);
detailsRefreshTimer = null;
};
watch(detailsOpen, (open) => {
stopDetailsRefresh();
if (!open || !props.runNo || !['queued', 'processing'].includes(props.state.status)) return;
detailsRefreshTimer = setInterval(() => void refreshDetails(), 2000);
});
watch(() => props.state.status, (status) => {
if (!['queued', 'processing'].includes(status)) stopDetailsRefresh();
});
onBeforeUnmount(stopDetailsRefresh);
watch(detailsFreshnessKey, () => {
if (detailsOpen.value) void refreshDetails();
});
/** 新建单前复核统一进入独立工作台,不能再落入聊天内旧 Candidate 编辑区。 */
const openReviewWorkspace = async () => {
if (!props.runNo) return;
await router.push({
name: 'Chat',
params: { agentId: String(route.params.agentId || '') },
query: {
...route.query,
mode: 'order-review',
run_no: props.runNo,
},
});
};
const handleActionClick = async (action: string) => {
switch (action) {
case 'view_details':
await openDetails();
return;
case 'enter_manual_review':
if (props.hasReviewAttachments) {
emit('enterManualReview');
} else {
await openDetails();
}
await openReviewWorkspace();
return;
case 'retry_failed_attachments':
emit('retry');
@@ -235,7 +291,6 @@ const handleActionClick = async (action: string) => {
<div class="mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs opacity-90">
<span>{{ t('chat.shippingOrderExtractionSummary.total', { count: state.summary.totalDocuments }) }}</span>
<span>{{ t('chat.shippingOrderExtractionSummary.completedProgress', { value: completedLabel }) }}</span>
<span>{{ t('chat.shippingOrderExtractionSummary.candidates', { count: state.summary.candidateCount }) }}</span>
<span>{{ t('chat.shippingOrderExtractionSummary.reviewRequired', { count: state.summary.reviewRequiredDocuments }) }}</span>
<span v-if="state.summary.failedDocuments > 0">
{{ t('chat.shippingOrderExtractionSummary.failed', { count: state.summary.failedDocuments }) }}
@@ -294,9 +349,8 @@ const handleActionClick = async (action: string) => {
:load-failed="documentsLoadFailed"
:progress-loading="loadingProgressEvents"
:progress-load-failed="progressEventsLoadFailed"
:has-review-attachments="hasReviewAttachments"
@close="detailsOpen = false"
@enter-manual-review="emit('enterManualReview')"
@enter-manual-review="openReviewWorkspace"
/>
</div>
</template>
@@ -5,7 +5,7 @@
* 依赖:订单抽取状态卡、文档结果项、订单抽取 progress-events DTO、vue-i18n。
* 逻辑:聊天摘要卡只显示概览;需要查看逐文档结果和每轮事件原因时由本抽屉承接新的 Run 级事实时间线。
*/
import { onBeforeUnmount, watch } from 'vue';
import { onBeforeUnmount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { X } from 'lucide-vue-next';
import type { ShippingOrderExtractionState } from '../../types/chat.types';
@@ -25,7 +25,6 @@ const props = defineProps<{
loadFailed: boolean;
progressLoading: boolean;
progressLoadFailed: boolean;
hasReviewAttachments?: boolean;
}>();
const emit = defineEmits<{
@@ -35,6 +34,7 @@ const emit = defineEmits<{
const { t, te, locale } = useI18n();
let removeKeydownListener: (() => void) | null = null;
const timelineOpen = ref(false);
const translateReasonCodes = (codes: string[] | undefined): string[] => (
(codes || [])
@@ -155,37 +155,27 @@ onBeforeUnmount(() => {
</header>
<div class="flex-1 space-y-3 overflow-y-auto px-4 py-4">
<div
v-if="state.selectionPlan?.totalAttachmentCount || state.unitSummary?.technicalFailureReasonCodes?.length"
class="rounded-lg border border-slate-200 bg-slate-50 px-3 py-3 text-xs text-slate-700 dark:border-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?.expansionTriggerReasonCodes?.length" class="mt-1">
{{ t('chat.shippingOrderExtractionExpansionTriggerCodes', {
codes: translateReasonCodes(state.unitSummary.expansionTriggerReasonCodes).join(' / '),
}) }}
</div>
<div v-if="state.unitSummary?.technicalFailureReasonCodes?.length" class="mt-1">
{{ t('chat.shippingOrderExtractionTechnicalFailureCodes', {
codes: state.unitSummary.technicalFailureReasonCodes.join(', '),
}) }}
</div>
<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 class="rounded-lg border border-slate-200 bg-white px-3 py-3 dark:border-slate-700 dark:bg-slate-950/40">
<div class="text-xs font-semibold text-slate-900 dark:text-slate-100">
{{ t('chat.shippingOrderExtractionTimelineTitle') }}
<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>
<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') }}
</div>
<ShippingOrderDocumentResultItem
v-for="document in documents"
:key="document.unit_id"
:document="document"
@enter-manual-review="emit('enterManualReview')"
/>
<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"
@@ -227,23 +217,7 @@ onBeforeUnmount(() => {
</div>
</li>
</ol>
</div>
<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>
<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') }}
</div>
<ShippingOrderDocumentResultItem
v-for="document in documents"
:key="document.unit_id"
:document="document"
:has-review-attachments="hasReviewAttachments"
@enter-manual-review="emit('enterManualReview')"
/>
</details>
</div>
</aside>
</div>
@@ -551,7 +551,6 @@ export function useChatPage() {
},
retryShippingNoticeAttachment: shipping.retryShippingNoticeAttachment,
setShippingCandidateSelected: shipping.setShippingCandidateSelected,
updateShippingCandidateSummary: shipping.updateShippingCandidateSummary,
resolveShippingCandidateDuplicate: shipping.resolveShippingCandidateDuplicate,
showShippingDuplicateDialog: shipping.showShippingDuplicateDialog,
shippingDuplicateAttachment: shipping.shippingDuplicateAttachment,
@@ -1007,24 +1007,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
}
};
/** 保存 Candidate 结构化修订,并保留服务端校验错误。 */
const updateShippingCandidateSummary = async (
candidateNo: string,
businessSummary: Record<string, unknown>,
done?: (success: boolean) => void,
) => {
try {
await shippingIntakes.updateCandidateSummary(candidateNo, businessSummary);
const candidate = shippingIntakes.noticeAttachments.value.flatMap((item) => item.candidates || []).find((item) => item.candidateNo === candidateNo);
if (candidate) await shippingOrderExtractionRuns.updateCandidateReviewSnapshot(candidate);
msg.success(t('chat.shippingCandidateUpdateDone'));
done?.(true);
} catch (error: unknown) {
msg.warning(error instanceof Error ? error.message : t('chat.shippingCandidateUpdateFailed'));
done?.(false);
}
};
/** 保存 Candidate 重复决策,并统一展示权限或目标漂移错误。 */
const resolveShippingCandidateDuplicate = async (
candidateNo: string,
@@ -1121,6 +1103,12 @@ export function useChatShipping(options: UseChatShippingOptions) {
t,
});
// 快览完成后补充可见的用户请求;用户已输入备注时绝不覆盖。
watch([isShippingNoticeAgent, shippingIntakes.allParsedReady], ([isShippingAgent, allParsedReady]) => {
if (!isShippingAgent || !allParsedReady || input.value.trim()) return;
input.value = t('chat.shippingOrderExtractionDefaultUserMessage');
});
const { handleShippingMenuAction, handleShippingActionClick } = createShippingMenuHandlers({
isThinking,
currentAgentId,
@@ -1510,7 +1498,6 @@ export function useChatShipping(options: UseChatShippingOptions) {
reparseOrderExtractionRun: shippingOrderExtractionRuns.reparseRun,
shippingNoticeAllReadyForConfirmation: shippingIntakes.allReadyForConfirmation,
setShippingCandidateSelected,
updateShippingCandidateSummary,
resolveShippingCandidateDuplicate,
promoteShippingCandidate,
rejectShippingCandidate,
@@ -37,7 +37,6 @@ type ShippingHandlerSource = Pick<
| 'removeShippingParseReviewLine'
| 'retryOrderExtractionRun'
| 'reparseOrderExtractionRun'
| 'updateShippingCandidateSummary'
| 'resolveShippingCandidateDuplicate'
| 'promoteShippingCandidate'
| 'rejectShippingCandidate'
@@ -76,7 +75,6 @@ export function createShippingMessageHandlers(shipping: ShippingHandlerSource):
removeLine: shipping.removeShippingParseReviewLine,
retryOrderExtractionRun: shipping.retryOrderExtractionRun,
reparseOrderExtractionRun: shipping.reparseOrderExtractionRun,
updateCandidate: shipping.updateShippingCandidateSummary,
resolveCandidateDuplicate: shipping.resolveShippingCandidateDuplicate,
promoteCandidate: shipping.promoteShippingCandidate,
rejectCandidate: shipping.rejectShippingCandidate,
@@ -27,4 +27,24 @@ describe('createChatPageLocalMessageApi', () => {
expect(conversationId.value).toBe('conv-local');
expect(message.chat_log_id).toBe(42);
});
it('persists user attachment snapshots so history restores the submitted files', async () => {
const conversationId = ref<string | null>('conv-attachments');
api.saveLocalChatMessage.mockResolvedValue({ chat_log_id: 43 });
const helpers = createChatPageLocalMessageApi({ conversationId, currentAgentId: computed(() => 7) });
const message: ChatMessage = {
role: 'user', type: 'text', content: '',
attachments: [{ name: 'orders.eml', size: 128, extension: 'eml', type: 'document', source: 'shipping_notice' }],
payload: { formId: 'shipping-order-extraction-user:SNER-ATTACHMENTS' },
};
await helpers.saveLocalMessageToBackend(message);
expect(api.saveLocalChatMessage).toHaveBeenCalledWith(expect.objectContaining({
payload: {
formId: 'shipping-order-extraction-user:SNER-ATTACHMENTS',
user_attachments: message.attachments,
},
}));
});
});
@@ -35,7 +35,15 @@ export function createChatPageLocalMessageApi(ctx: ChatPageLocalMessageContext)
role: localMsg.role,
type: localMsg.type,
content: localMsg.content,
payload: localMsg.payload,
// 专用业务发送路径也必须持久化附件展示快照;否则会话同步会用不含附件的历史记录替换当前气泡。
payload: {
...(localMsg.payload && typeof localMsg.payload === 'object'
? localMsg.payload as Record<string, unknown>
: {}),
...(localMsg.role === 'user' && localMsg.attachments?.length
? { user_attachments: localMsg.attachments }
: {}),
},
query: userQuery,
agent_id: ctx.currentAgentId.value,
});
@@ -154,7 +154,9 @@ export function createChatPageSendApi(ctx: ChatPageSendContext) {
onAssistantMessageFinished: ctx.onAssistantMessageFinished,
},
);
if (!sent.accepted) {
// Keep the legacy boolean result compatible while callers migrate to ChatMessageSendResult.
const accepted = (sent as unknown) === true || Boolean(sent.accepted);
if (!accepted) {
if (shouldClearInput) ctx.input.value = content;
return;
}
@@ -0,0 +1,170 @@
/**
* features/chat/shipping-review/useShippingOrderReview.ts
* 用途:加载建单前复核 Run 和当前 PDF Case 的只读数据。
* 依赖:shipping API、Vue 响应式状态。
* 逻辑:路由刷新后以 runNo 重建列表,再按 case_no 加载详情;阶段 2 不写入草稿。
*/
import { ref } from 'vue';
import {
addWorkspaceShippingOrderReviewLine,
createWorkspaceShippingOrderReviewManualDraft,
createWorkspaceShippingOrderReviewReplacementIntake,
createWorkspaceShippingOrderReviewReplacementRun,
copyWorkspaceShippingOrderReviewLine,
confirmWorkspaceShippingOrderReviewCase,
deleteWorkspaceShippingOrderReviewLine,
getWorkspaceShippingOrderReviewCase,
getWorkspaceShippingOrderReviewEvidence,
getWorkspaceShippingOrderReviewPreview,
getShippingNoticeIntake,
getWorkspaceShippingOrderReviewRun,
patchWorkspaceShippingOrderReviewHeaderField,
patchWorkspaceShippingOrderReviewLineField,
markWorkspaceShippingOrderReviewNonOrder,
markWorkspaceShippingOrderReviewQualityIssue,
reparseWorkspaceShippingOrderReviewDocument,
validateWorkspaceShippingOrderReviewDraft,
} from '../api/shipping.api';
import type { ShippingOrderReviewCase, ShippingOrderReviewEvidence, ShippingOrderReviewRun } from '../types/shipping.api.types';
import { uploadFileAsset } from '@/shared/api/file-assets.api';
export function useShippingOrderReview() {
const reviewRun = ref<ShippingOrderReviewRun | null>(null);
const activeCase = ref<ShippingOrderReviewCase | null>(null);
const loading = ref(false);
const loadFailed = ref(false);
const saving = ref(false);
const saveFailed = ref(false);
const evidence = ref<ShippingOrderReviewEvidence[]>([]);
const previewUrl = ref('');
/** 加载 Run 汇总后优先恢复 URL 指定 Case,否则打开首个 PDF。 */
const load = async (runNo: string, preferredCaseNo?: string) => {
loading.value = true;
loadFailed.value = false;
try {
const run = await getWorkspaceShippingOrderReviewRun(runNo);
reviewRun.value = run;
const caseNo = preferredCaseNo || run.items[0]?.case_no;
activeCase.value = caseNo ? await getWorkspaceShippingOrderReviewCase(caseNo) : null;
evidence.value = caseNo ? (await getWorkspaceShippingOrderReviewEvidence(caseNo)).items : [];
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
previewUrl.value = '';
if (caseNo) {
try { previewUrl.value = URL.createObjectURL(await getWorkspaceShippingOrderReviewPreview(caseNo)); } catch { /* PDF failure must not block the draft. */ }
}
} catch {
loadFailed.value = true;
reviewRun.value = null;
activeCase.value = null;
} finally {
loading.value = false;
}
};
/** 切换 PDF 时仅换详情,列表保持已加载结果,避免重复请求。 */
const selectCase = async (caseNo: string) => {
const [detail, result] = await Promise.all([
getWorkspaceShippingOrderReviewCase(caseNo),
getWorkspaceShippingOrderReviewEvidence(caseNo),
]);
activeCase.value = detail;
evidence.value = result.items;
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
previewUrl.value = '';
try { previewUrl.value = URL.createObjectURL(await getWorkspaceShippingOrderReviewPreview(caseNo)); } catch { /* Preview remains independently recoverable. */ }
};
/** 串行保存当前 Case,成功后使用服务端 DTO 替换本地草稿,避免旧响应回写。 */
const save = async (action: () => Promise<ShippingOrderReviewCase>) => {
saving.value = true;
saveFailed.value = false;
try {
activeCase.value = await action();
if (reviewRun.value && activeCase.value) {
const item = reviewRun.value.items.find((row) => row.case_no === activeCase.value?.case_no);
if (item) {
item.status = activeCase.value.status;
item.draft_version = activeCase.value.draft?.draft_version;
item.issue_count = activeCase.value.draft?.issues.length || 0;
}
}
} catch (error) {
saveFailed.value = true;
throw error;
} finally {
saving.value = false;
}
};
const version = () => activeCase.value?.draft?.draft_version || 0;
const patchHeader = (fieldId: string, value: unknown, restoreMachine = false) => {
if (!activeCase.value) return Promise.resolve();
return save(() => patchWorkspaceShippingOrderReviewHeaderField(activeCase.value!.case_no, fieldId, {
expected_draft_version: version(), value, restore_machine: restoreMachine,
}));
};
const patchLine = (lineKey: string, fieldId: string, value: unknown, restoreMachine = false) => {
if (!activeCase.value) return Promise.resolve();
return save(() => patchWorkspaceShippingOrderReviewLineField(activeCase.value!.case_no, lineKey, fieldId, {
expected_draft_version: version(), value, restore_machine: restoreMachine,
}));
};
const addLine = () => activeCase.value && save(() => addWorkspaceShippingOrderReviewLine(activeCase.value!.case_no, version()));
const copyLine = (lineKey: string) => activeCase.value && save(() => copyWorkspaceShippingOrderReviewLine(activeCase.value!.case_no, lineKey, version()));
const deleteLine = (lineKey: string) => activeCase.value && save(() => deleteWorkspaceShippingOrderReviewLine(activeCase.value!.case_no, lineKey, version()));
const validate = () => activeCase.value && save(() => validateWorkspaceShippingOrderReviewDraft(activeCase.value!.case_no, version()));
/** 确认动作不复用自动保存:服务端返回 Task 与只读 Case,而不是仅草稿 DTO。 */
const confirm = async () => {
if (!activeCase.value) return null;
saving.value = true;
saveFailed.value = false;
try {
const response = await confirmWorkspaceShippingOrderReviewCase(activeCase.value.case_no, {
expected_draft_version: version(),
idempotency_key: crypto.randomUUID(),
});
activeCase.value = response.case;
if (reviewRun.value) reviewRun.value = await getWorkspaceShippingOrderReviewRun(reviewRun.value.run_no);
return response;
} catch (error) {
saveFailed.value = true;
throw error;
} finally {
saving.value = false;
}
};
const createManualDraft = () => activeCase.value && save(() => createWorkspaceShippingOrderReviewManualDraft(activeCase.value!.case_no));
const markNonOrder = (reason: string) => activeCase.value && save(() => markWorkspaceShippingOrderReviewNonOrder(activeCase.value!.case_no, reason));
const markQualityIssue = (reason: string) => activeCase.value && save(() => markWorkspaceShippingOrderReviewQualityIssue(activeCase.value!.case_no, reason));
const reparseDocument = async (reason: string) => {
if (!activeCase.value) return null;
const response = await reparseWorkspaceShippingOrderReviewDocument(activeCase.value.case_no, reason);
activeCase.value = await getWorkspaceShippingOrderReviewCase(activeCase.value.case_no);
if (reviewRun.value) reviewRun.value = await getWorkspaceShippingOrderReviewRun(reviewRun.value.run_no);
return response;
};
/** 上传替代 PDF 后等待既有 Intake 预解析;只有获得唯一 Document 才创建替代 Run。 */
const uploadReplacement = async (file: File) => {
if (!activeCase.value) return null;
const asset = await uploadFileAsset(file);
const intake = await createWorkspaceShippingOrderReviewReplacementIntake(activeCase.value.case_no, asset.asset_no);
for (let attempt = 0; attempt < 60; attempt += 1) {
const current = await getShippingNoticeIntake(intake.intake_no);
if (current.parse_status === 'parsed') return startReplacementRun(current.intake_no);
if (['parse_failed', 'cancelled', 'expired'].includes(current.parse_status)) {
throw new Error('Replacement PDF parsing failed');
}
await new Promise<void>((resolve) => window.setTimeout(resolve, 1000));
}
throw new Error('Replacement PDF parsing is still pending');
};
const startReplacementRun = async (intakeNo: string) => {
if (!activeCase.value) return null;
const response = await createWorkspaceShippingOrderReviewReplacementRun(activeCase.value.case_no, intakeNo);
activeCase.value = await getWorkspaceShippingOrderReviewCase(activeCase.value.case_no);
if (reviewRun.value) reviewRun.value = await getWorkspaceShippingOrderReviewRun(reviewRun.value.run_no);
return response;
};
return { reviewRun, activeCase, evidence, previewUrl, loading, loadFailed, saving, saveFailed, load, selectCase, patchHeader, patchLine, addLine, copyLine, deleteLine, validate, confirm, createManualDraft, markNonOrder, markQualityIssue, reparseDocument, uploadReplacement, startReplacementRun };
}
@@ -8,10 +8,14 @@ import { computeNoticeFilesContentFingerprint } from './shippingNoticeBatchIdemp
describe('shippingNoticeBatchIdempotency', () => {
it('treats duplicate files as one content set', async () => {
const content = 'same-notice-content';
const single = new File([content], 'a.txt', { type: 'text/plain' });
const createFile = (name: string) => ({
name,
arrayBuffer: async () => new TextEncoder().encode(content),
}) as File;
const single = createFile('a.txt');
const duplicatePair = [
new File([content], 'a.txt', { type: 'text/plain' }),
new File([content], 'b.txt', { type: 'text/plain' }),
createFile('a.txt'),
createFile('b.txt'),
];
const singleFp = await computeNoticeFilesContentFingerprint([single]);
@@ -1,6 +1,6 @@
/**
* features/chat/shipping/useChatShippingSendHandler.spec.ts
* 用途:验证阶段 2 发送语义,只冻结当前输入框这批 Intake,并允许空备注启动识别。
* 用途:验证阶段 2 发送语义,只冻结当前输入框这批 Intake,并为仅附件发送补充用户可见的默认请求。
*/
import { computed, ref } from 'vue';
import { beforeEach, describe, expect, it, vi } from 'vitest';
@@ -149,7 +149,7 @@ describe('useChatShippingSendHandler', () => {
expect(attachments.value).toEqual([laterNotice, otherAttachment]);
});
it('allows an empty note when the user only authorizes attachment analysis', async () => {
it('adds a visible default request when the user only sends attachments', async () => {
const startOrderExtractionRun = vi.fn(async () => true);
const ctx = createContext({
attachments: ref([{
@@ -174,7 +174,7 @@ describe('useChatShippingSendHandler', () => {
expect(consumed).toBe(true);
expect(startOrderExtractionRun).toHaveBeenCalledWith(
'',
'chat.shippingOrderExtractionDefaultUserMessage',
['SNI-EMPTY-NOTE'],
[{
name: 'orders.eml',
@@ -236,8 +236,8 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
&& submittedIntakes.has(item.intakeNo.trim().toUpperCase()),
),
);
// 阶段 2:发送是“授权开始识别”,备注允许为空,不能再偷偷注入默认提示词。
const query = trimmed;
// 阶段 2:空备注补充用户可见的默认请求,便于会话记录与审计;不改变 Worker 的确定性识别流程。
const query = trimmed || ctx.t('chat.shippingOrderExtractionDefaultUserMessage');
ctx.shippingAutoFlowRequested.value = false;
if (typeof textOrEvent !== 'string') ctx.input.value = '';
try {
@@ -68,7 +68,7 @@ describe('shipping notice order extraction state', () => {
expect(resolveShippingOrderExtractionStatus(undefined, 'not_started')).toBe('not_started');
});
it('restores in-progress, retryable, and pending-candidate attachments into the input area', () => {
it('restores only in-progress and retryable attachments into the input area', () => {
expect(shouldRestoreShippingNoticeIntake('queued')).toBe(true);
expect(shouldRestoreShippingNoticeIntake('parsing')).toBe(true);
expect(shouldRestoreShippingNoticeIntake('parse_failed')).toBe(true);
@@ -78,15 +78,15 @@ describe('shipping notice order extraction state', () => {
attachment_directory_complete: true,
})).toBe(true);
expect(shouldRestoreShippingNoticeIntake('parsed', 'failed', 0)).toBe(true);
expect(shouldRestoreShippingNoticeIntake('parsed', 'partially_completed', 2)).toBe(true);
expect(shouldRestoreShippingNoticeIntake('parsed', 'not_started', 0, {
preview_status: 'directory_incomplete',
ready_for_extraction: false,
attachment_directory_complete: false,
})).toBe(false);
// 已完成且没有待审核 Candidate 的文件仅保留在用户消息气泡中。
// 已发送的终态文件(包括待人工复核)仅保留在用户消息气泡和结果卡中。
expect(shouldRestoreShippingNoticeIntake('parsed', 'completed')).toBe(false);
expect(shouldRestoreShippingNoticeIntake('parsed', 'partially_completed', 2)).toBe(false);
expect(shouldRestoreShippingNoticeIntake('parsed', 'partially_completed', 0)).toBe(false);
expect(shouldRestoreShippingNoticeIntake('parsed', 'completed', 2)).toBe(false);
expect(shouldRestoreShippingNoticeIntake('consumed')).toBe(false);
@@ -41,16 +41,16 @@ const ACTIVE_ORDER_EXTRACTION = new Set(['extracting']);
* 判断服务端 Intake 是否应恢复到输入栏。
* AI 触发时机:无;页面刷新或重新打开会话时调用。
* 上传快览与发送授权已拆分:未发送但已快览成功的附件,刷新后也必须恢复到输入栏;
* 已进入订单抽取终态的附件仅保留在消息气泡中,避免把旧批次误带回当前输入框。
* 已进入订单抽取终态(包括待人工复核)的附件仅保留在消息气泡和结果卡中,
* 避免把已发送的旧批次误带回当前输入框。
* @param parseStatus - 服务端返回的预解析状态。
* @param orderExtractionStatus - 服务端返回的订单抽取状态。
* @param candidateCount - 当前仍可审核的订单 Candidate 数量。
* @returns 是否恢复为待发送附件卡片
*/
export function shouldRestoreShippingNoticeIntake(
parseStatus: string | null | undefined,
orderExtractionStatus?: string | null,
candidateCount = 0,
_candidateCount = 0,
parseSummary?: ShippingNoticePendingAttachment['parseSummary'],
): boolean {
const status = String(parseStatus || '').trim().toLowerCase();
@@ -62,8 +62,7 @@ export function shouldRestoreShippingNoticeIntake(
&& (!extractionStatus || extractionStatus === 'not_started')
&& !isShippingNoticeAttachmentParseIncomplete(parseSummary)
)
|| extractionStatus === 'failed'
|| (extractionStatus === 'partially_completed' && candidateCount > 0);
|| extractionStatus === 'failed';
}
/** 判断 Intake 是否仍需轮询上传预处理或订单抽取状态。 */
@@ -582,19 +581,6 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
}
};
/** 保存 Candidate 人工修订后的订单摘要。 */
const updateCandidateSummary = async (candidateNo: string, businessSummary: Record<string, unknown>) => {
const remote = await updateShippingNoticeCandidate(candidateNo, { business_summary: businessSummary });
for (const attachment of noticeAttachments.value) {
if (!(attachment.candidates || []).some((item) => item.candidateNo === candidateNo)) continue;
patchAttachment(attachment.id, {
candidates: (attachment.candidates || []).map((item) =>
item.candidateNo === candidateNo ? mapServerCandidate(remote) : item,
),
});
}
};
/** 人工采纳已复核的 Dify Candidate;后端决定是否已满足履约门禁。 */
const promoteCandidate = async (candidateNo: string) => {
const remote = await promoteShippingNoticeCandidate(candidateNo);
@@ -667,7 +653,6 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
resolveDuplicateAttachment,
resolveCandidateDuplicate,
setCandidateSelected,
updateCandidateSummary,
promoteCandidate,
rejectCandidate,
getParsedIntakeNos,
@@ -692,6 +692,10 @@ export interface ShippingOrderExtractionDocumentResult {
reason_code?: string | null;
review_details?: Array<{ line_number: number; field_code?: string | null; reason_code: string }>;
available_actions: string[];
activity_event_code?: string | null;
started_at?: string | null;
last_activity_at?: string | null;
finished_at?: string | null;
}
export interface ShippingOrderExtractionRun {
@@ -783,6 +787,82 @@ export interface ShippingOrderExtractionDocumentsResponse {
items: ShippingOrderExtractionDocumentResult[];
}
/** 建单前订单复核的冻结 Schema 字段;阶段 2 只读展示,编辑能力由后续阶段扩展。 */
export interface ShippingOrderReviewSchemaField {
field_id: string;
field_code: string;
display_name: string;
scope: string;
value_type: string;
required: boolean;
options: unknown[];
}
export interface ShippingOrderReviewCaseSummary {
case_no: string;
document_id: number;
file_name?: string | null;
status: string;
draft_version?: number | null;
issue_count: number;
available_actions: string[];
}
export interface ShippingOrderReviewRun {
run_no: string;
summary: Record<string, number>;
items: ShippingOrderReviewCaseSummary[];
}
export interface ShippingOrderReviewCase {
case_no: string;
run_no: string;
document: { id: number; file_name?: string | null };
status: string;
disposition?: string | null;
confirmed_task_id?: number | null;
candidate?: { candidate_no: string; validation_status: string; po_number?: string | null } | null;
schema: { schema_version_id: number; fields: ShippingOrderReviewSchemaField[] };
draft?: {
draft_version: number;
header_values: Record<string, unknown>;
lines: Array<Record<string, unknown>>;
issues: Array<{ code?: string; severity?: string }>;
validation: Record<string, unknown>;
} | null;
available_actions: string[];
}
export interface ShippingOrderReviewConfirmResponse {
task_no?: string | null;
idempotent_replay: boolean;
case: ShippingOrderReviewCase;
}
export interface ShippingOrderReviewReparseResponse {
run: ShippingOrderExtractionRun;
reused: boolean;
}
export interface ShippingOrderReviewDraftWrite {
expected_draft_version: number;
value?: unknown;
restore_machine?: boolean;
}
export interface ShippingOrderReviewEvidence {
evidence_id: string;
field_id: string;
line_index?: number | null;
machine_value?: unknown;
quote?: string | null;
page_no?: number | null;
table_id?: string | null;
cell_id?: string | null;
bbox?: { x0: number; y0: number; x1: number; y1: number } | null;
source: string;
}
export interface ShippingNoticeDocumentResponse {
id: number;
document_type: string;
@@ -0,0 +1,156 @@
<!--
用途:提供按 PDF 独立处理的建单前订单人工复核工作台。
依赖:路由参数、复核 composable、冻结 Schema DTO、受控 PDF 预览组件。
逻辑:复用聊天壳的历史侧栏;中心维护订单单头和表格化单身,右侧固定 PDF/证据检查器;处置、重识别及确认建单均只消费当前 Case Draft。
-->
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { ArrowLeft, Copy, FileText, MapPin, Plus, RefreshCw, Save, Trash2, TriangleAlert, Undo2 } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import { useIsMobile } from '@/shared/composables/useIsMobile';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import { useChatPageContext } from '@/features/chat/composables/chat.context';
import { useShippingOrderReview } from '../shipping-review/useShippingOrderReview';
import ReviewDocumentPreview from '../components/shipping-review/ReviewDocumentPreview.vue';
const route = useRoute();
const router = useRouter();
const page = useChatPageContext();
const { t } = useI18n();
const { reviewRun, activeCase, evidence, previewUrl, loading, loadFailed, saving, saveFailed, load, selectCase, patchHeader, patchLine, addLine, copyLine, deleteLine, validate, confirm, createManualDraft, markNonOrder, markQualityIssue, reparseDocument, uploadReplacement } = useShippingOrderReview();
const msg = useMessage();
const { isMobile } = useIsMobile();
/** 新模式从 query 读取 run_no;保留旧路径参数以兼容已收藏的复核链接。 */
const runNo = computed(() => String(route.query.run_no || route.params.runNo || ''));
const agentId = computed(() => String(route.params.agentId || ''));
const headerSchemaFields = computed(() => (activeCase.value?.schema.fields || []).filter((field) => field.scope === 'header'));
const lineSchemaFields = computed(() => (activeCase.value?.schema.fields || []).filter((field) => field.scope === 'line'));
const headerHasMachineValue = (fieldId: string) => machineValueByIdFor(
Array.isArray(activeCase.value?.draft?.header_values.machine_fields)
? activeCase.value?.draft?.header_values.machine_fields as Array<Record<string, unknown>> : [],
fieldId,
) !== '';
const primaryHeaderFields = computed(() => headerSchemaFields.value.filter((field) => field.required || headerHasMachineValue(field.field_id)));
const optionalEmptyHeaderFields = computed(() => headerSchemaFields.value.filter((field) => !field.required && !headerHasMachineValue(field.field_id)));
const lineHasValue = (fieldId: string) => (activeCase.value?.draft?.lines || []).some((line) => draftValue(line, fieldId) !== '');
const primaryLineFields = computed(() => lineSchemaFields.value.filter((field) => field.required || lineHasValue(field.field_id)));
const optionalEmptyLineFields = computed(() => lineSchemaFields.value.filter((field) => !field.required && !lineHasValue(field.field_id)));
const machineValue = (field: Record<string, unknown>) => {
const observations = Array.isArray(field.observations) ? field.observations as Array<Record<string, unknown>> : [];
return String(observations[0]?.value || t('chat.shippingOrderReview.emptyValue'));
};
const draftValue = (container: Record<string, unknown>, fieldId: string) => {
const values = container.values as Record<string, { value?: unknown }> | undefined;
if (values?.[fieldId] && 'value' in values[fieldId]) return String(values[fieldId].value ?? '');
const machine = Array.isArray(container.machine_fields) ? container.machine_fields as Array<Record<string, unknown>> : [];
return machineValueByIdFor(machine, fieldId);
};
const machineValueByIdFor = (fields: Array<Record<string, unknown>>, fieldId: string) => {
const field = fields.find((item) => String(item.field_id || '') === fieldId);
return field ? machineValue(field) : '';
};
const editable = computed(() => activeCase.value?.available_actions.includes('edit_draft') || false);
const selectedEvidenceId = ref('');
const contextOpen = ref(false);
const confirmDialogOpen = ref(false);
const selectedEvidence = computed(() => evidence.value.find((item) => item.evidence_id === selectedEvidenceId.value) || null);
// PDF.js uses evidence.page_no to select the page; retain the original Blob URL while switching evidence.
const previewSrc = computed(() => previewUrl.value);
const selectEvidence = (fieldId: string, lineIndex?: number) => {
const item = evidence.value.find((entry) => entry.field_id === fieldId && entry.line_index === lineIndex);
selectedEvidenceId.value = item?.evidence_id || '';
};
const reportSave = async (action: () => Promise<unknown> | null) => {
try { await action(); }
catch (error) {
const message = error instanceof BusinessError ? error.message : t('errors.generic');
msg.error(message);
}
};
const reportDisposition = async (action: () => Promise<unknown> | null) => {
try { await action(); }
catch (error) {
const message = error instanceof BusinessError ? error.message : t('errors.generic');
msg.error(message);
}
};
const confirmCase = () => {
confirmDialogOpen.value = true;
};
const confirmCaseSubmit = async () => {
await reportDisposition(() => confirm());
};
const selectReplacement = (event: Event) => {
const file = (event.target as HTMLInputElement).files?.[0];
if (file) void reportDisposition(() => uploadReplacement(file));
(event.target as HTMLInputElement).value = '';
};
const select = async (caseNo: string) => {
await selectCase(caseNo);
// Preserve review mode and the originating conversation while switching PDFs.
await router.replace({ query: { ...route.query, case: caseNo } });
};
/** 在同一 ChatView 内退出复核模式,保留原会话实例及其滚动位置。 */
const back = () => router.replace({
name: 'Chat',
params: { agentId: agentId.value },
query: Object.fromEntries(Object.entries(route.query).filter(([key]) => key !== 'mode' && key !== 'run_no')),
});
watch(
[runNo, () => String(route.query.case || '')],
([nextRun, nextCase]) => { if (nextRun) void load(nextRun, nextCase || undefined); },
{ immediate: true },
);
</script>
<template>
<main class="flex min-h-0 flex-1 flex-col bg-slate-50 text-slate-900 dark:bg-slate-950 dark:text-slate-100">
<header class="flex shrink-0 items-center gap-3 border-b border-slate-200 bg-white px-4 py-3 dark:border-slate-800 dark:bg-slate-900">
<button type="button" class="rounded-md p-1 hover:bg-slate-100 dark:hover:bg-slate-800" :aria-label="t('chat.shippingOrderReview.back')" @click="back"><ArrowLeft class="h-5 w-5" /></button>
<div class="min-w-0"><h1 class="text-base font-semibold">{{ t('chat.shippingOrderReview.title') }}</h1><p class="truncate text-xs text-slate-500 dark:text-slate-400">{{ t('chat.shippingOrderReview.run', { runNo }) }}</p></div>
<button type="button" class="ml-auto rounded border border-slate-200 px-2.5 py-1.5 text-xs hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800" @click="contextOpen = !contextOpen">{{ contextOpen ? '收起对话上下文' : '对话上下文' }}</button>
<span class="shrink-0 rounded-full bg-sky-100 px-2.5 py-1 text-xs text-sky-800 dark:bg-sky-950 dark:text-sky-100">{{ saving ? t('chat.shippingOrderReview.saving') : saveFailed ? t('chat.shippingOrderReview.saveFailed') : t('chat.shippingOrderReview.saved') }}</span>
</header>
<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>
<div v-else class="grid min-h-0 flex-1 grid-cols-1 xl:grid-cols-[minmax(0,1fr)_minmax(340px,420px)]">
<section class="min-h-0 overflow-y-auto p-4 lg:p-5">
<div v-if="activeCase?.draft?.issues?.length" class="mb-4 rounded-lg border border-amber-300 bg-amber-50 p-3 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-100"><div class="font-semibold">{{ t('chat.shippingOrderReview.issues') }}</div><div v-for="issue in activeCase.draft.issues" :key="`${issue.code}-${issue.severity}`" class="mt-1">{{ issue.code }}</div></div>
<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><h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.orderFields') }}</h2><p class="mt-1 text-xs text-slate-500">{{ t('chat.shippingOrderReview.schemaVersion', { version: activeCase?.schema.schema_version_id || '-' }) }}</p></div></div>
<div v-if="primaryHeaderFields.length" class="mt-4 grid gap-3 md:grid-cols-2 2xl:grid-cols-3">
<div v-for="field in primaryHeaderFields" :key="field.field_id" class="min-w-0">
<label class="flex items-center justify-between gap-2 text-xs font-medium text-slate-600 dark:text-slate-300"><span class="truncate">{{ field.display_name }}<span v-if="field.required"> *</span></span><button type="button" class="shrink-0 text-slate-500 hover:text-sky-600" :aria-label="t('chat.shippingOrderReview.viewEvidence')" @click="selectEvidence(field.field_id)"><MapPin class="h-3.5 w-3.5" /></button></label>
<input :value="draftValue(activeCase?.draft?.header_values || {}, field.field_id)" :disabled="!editable || saving" class="mt-1 w-full rounded-md border border-slate-300 bg-white px-2.5 py-2 text-sm dark:border-slate-600 dark:bg-slate-950" @change="reportSave(() => patchHeader(field.field_id, ($event.target as HTMLInputElement).value))">
<div class="mt-1 flex items-center justify-between gap-2 text-[11px] text-slate-500"><span>{{ (activeCase?.draft?.header_values as Record<string, unknown>)?.values && Object.prototype.hasOwnProperty.call((activeCase?.draft?.header_values as Record<string, unknown>).values as object, field.field_id) ? t('chat.shippingOrderReview.manualSource') : t('chat.shippingOrderReview.machineSource') }}</span><button v-if="editable" type="button" class="hover:text-sky-600" @click="reportSave(() => patchHeader(field.field_id, null, true))"><Undo2 class="mr-1 inline h-3 w-3" />{{ t('chat.shippingOrderReview.restoreMachine') }}</button></div>
</div>
</div>
<div v-else class="mt-4 rounded-lg border border-dashed border-slate-300 p-3 text-sm text-slate-500 dark:border-slate-700"><p>{{ t('chat.shippingOrderReview.noMachineOrder') }}</p><div v-if="activeCase?.available_actions.includes('create_draft')" class="mt-3 flex flex-wrap gap-2"><button type="button" class="rounded border px-2 py-1 text-xs" :disabled="saving" @click="reportDisposition(() => createManualDraft())">{{ t('chat.shippingOrderReview.createManualDraft') }}</button><button type="button" class="rounded border px-2 py-1 text-xs" :disabled="saving" @click="reportDisposition(() => markNonOrder('non_order'))">{{ t('chat.shippingOrderReview.markNonOrder') }}</button></div></div>
<details v-if="optionalEmptyHeaderFields.length" class="mt-4 rounded-lg border border-slate-200 p-3 text-sm dark:border-slate-700"><summary class="cursor-pointer font-medium">{{ t('chat.shippingOrderReview.moreFields', { count: optionalEmptyHeaderFields.length }) }}</summary><div class="mt-3 grid gap-2 sm:grid-cols-2"><div v-for="field in optionalEmptyHeaderFields" :key="field.field_id" class="text-xs"><div class="text-slate-500">{{ field.display_name }}</div><div>{{ t('chat.shippingOrderReview.emptyValue') }}</div></div></div></details>
</section>
<section class="mt-4 rounded-xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900">
<div class="flex items-center justify-between gap-3 border-b border-slate-200 px-4 py-3 dark:border-slate-800"><div><h3 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.lines') }}</h3><p class="mt-1 text-xs text-slate-500">{{ (activeCase?.draft?.lines || []).length }} {{ t('chat.shippingOrderReview.lines') }}</p></div><button v-if="!isMobile" type="button" :disabled="!editable || saving" class="inline-flex items-center gap-1 rounded border px-2 py-1 text-xs disabled:opacity-50" @click="reportSave(() => addLine())"><Plus class="h-3.5 w-3.5" />{{ t('chat.shippingOrderReview.addLine') }}</button></div>
<div v-if="activeCase?.draft?.lines?.length" class="overflow-x-auto"><table class="min-w-full border-collapse text-left text-xs"><thead class="bg-slate-50 text-slate-500 dark:bg-slate-950/40 dark:text-slate-400"><tr><th class="sticky left-0 z-10 min-w-14 border-b border-slate-200 bg-slate-50 px-3 py-2 font-medium dark:border-slate-800 dark:bg-slate-950">#</th><th v-for="field in primaryLineFields" :key="field.field_id" class="min-w-40 border-b border-slate-200 px-3 py-2 font-medium dark:border-slate-800">{{ field.display_name }}<span v-if="field.required"> *</span></th><th v-if="!isMobile" class="sticky right-0 z-10 border-b border-slate-200 bg-slate-50 px-3 py-2 dark:border-slate-800 dark:bg-slate-950"><span class="sr-only">{{ t('chat.shippingOrderReview.line', { index: '' }) }}</span></th></tr></thead><tbody><tr v-for="(line, index) in activeCase?.draft?.lines || []" :key="String(line.line_key || index)" class="border-b border-slate-100 last:border-0 dark:border-slate-800"><td class="sticky left-0 z-10 bg-white px-3 py-2 font-medium dark:bg-slate-900">{{ index + 1 }}</td><td v-for="field in primaryLineFields" :key="field.field_id" class="min-w-40 px-3 py-2 align-top"><div class="flex min-w-0 items-center gap-1"><input :value="draftValue(line, field.field_id)" :disabled="!editable || saving" class="min-w-0 flex-1 rounded border border-slate-300 bg-white px-2 py-1.5 dark:border-slate-600 dark:bg-slate-950" @change="reportSave(() => patchLine(String(line.line_key), field.field_id, ($event.target as HTMLInputElement).value))"><button type="button" class="shrink-0 text-slate-500 hover:text-sky-600" :aria-label="t('chat.shippingOrderReview.viewEvidence')" @click="selectEvidence(field.field_id, index)"><MapPin class="h-3.5 w-3.5" /></button></div></td><td v-if="!isMobile" class="sticky right-0 z-10 whitespace-nowrap bg-white px-2 py-2 dark:bg-slate-900"><button type="button" :disabled="!editable || saving" class="rounded p-1 hover:bg-slate-100 disabled:opacity-50 dark:hover:bg-slate-800" :aria-label="t('chat.shippingOrderReview.copyLine')" @click="reportSave(() => copyLine(String(line.line_key)))"><Copy class="h-3.5 w-3.5" /></button><button type="button" :disabled="!editable || saving" class="rounded p-1 hover:bg-slate-100 disabled:opacity-50 dark:hover:bg-slate-800" :aria-label="t('chat.shippingOrderReview.deleteLine')" @click="reportSave(() => deleteLine(String(line.line_key)))"><Trash2 class="h-3.5 w-3.5" /></button></td></tr></tbody></table></div>
<div v-else class="p-4 text-sm text-slate-500">{{ t('chat.shippingOrderReview.noLines') }}</div>
<details v-if="optionalEmptyLineFields.length" class="border-t border-slate-200 px-4 py-3 text-xs dark:border-slate-800"><summary class="cursor-pointer text-slate-500">{{ t('chat.shippingOrderReview.moreFields', { count: optionalEmptyLineFields.length }) }}</summary><p class="mt-2 text-slate-500">{{ optionalEmptyLineFields.map((field) => field.display_name).join(' · ') }}</p></details>
</section>
</section>
<aside class="flex min-h-0 flex-col border-t border-slate-200 bg-white xl:border-l xl:border-t-0 dark:border-slate-800 dark:bg-slate-900">
<nav class="shrink-0 border-b border-slate-200 p-3 dark:border-slate-800" :aria-label="t('chat.shippingOrderReview.documentNavigation')"><div class="mb-2 text-xs font-semibold text-slate-500">{{ t('chat.shippingOrderReview.documents') }}</div><div class="flex gap-2 overflow-x-auto xl:flex-col xl:overflow-y-auto"><button v-for="item in reviewRun?.items || []" :key="item.case_no" type="button" class="min-w-52 rounded-lg border p-2.5 text-left text-sm xl:min-w-0" :class="activeCase?.case_no === item.case_no ? 'border-sky-500 bg-sky-50 dark:bg-sky-950/30' : 'border-slate-200 hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800'" @click="select(item.case_no)"><div class="truncate font-medium">{{ item.file_name || t('chat.shippingOrderReview.unnamedDocument') }}</div><div class="mt-1 flex items-center gap-1 text-xs text-slate-500"><TriangleAlert v-if="item.issue_count" class="h-3.5 w-3.5 text-amber-500" />{{ t('chat.shippingOrderReview.caseStatus', { status: item.status, count: item.issue_count }) }}</div></button></div></nav>
<div v-if="contextOpen" class="min-h-0 flex-1 overflow-y-auto p-4"><h2 class="text-sm font-semibold">对话上下文</h2><p class="mt-1 text-xs text-slate-500">当前会话中最近的订单抽取消息与附件。</p><div class="mt-4 space-y-3"><article v-for="(message, index) in page.messages.slice(-6)" :key="`${message.local_id || index}`" class="rounded-lg border border-slate-200 p-3 text-sm dark:border-slate-700"><div class="mb-1 text-xs font-medium text-slate-500">{{ message.role === 'user' ? '用户' : 'AI' }}</div><p class="whitespace-pre-wrap break-words">{{ message.content }}</p><div v-if="message.attachments?.length" class="mt-2 text-xs text-slate-500">{{ message.attachments.map((item) => item.name || '附件').join(' · ') }}</div></article><p v-if="page.messages.length === 0" class="text-sm text-slate-500">暂无可显示的对话上下文。</p></div></div>
<div v-else class="flex min-h-0 flex-1 flex-col p-3"><div class="mb-2 flex items-center gap-2 text-sm font-semibold"><FileText class="h-4 w-4" />{{ activeCase?.document.file_name || t('chat.shippingOrderReview.unnamedDocument') }}</div><div class="min-h-[320px] flex-1 overflow-hidden rounded-xl border border-slate-300 bg-slate-50 dark:border-slate-700 dark:bg-slate-950"><ReviewDocumentPreview v-if="previewSrc" :src="previewSrc" :evidence="selectedEvidence" :title="t('chat.shippingOrderReview.previewTitle')" :loading-text="t('chat.shippingOrderReview.previewLoading')" :unavailable-text="t('chat.shippingOrderReview.previewUnavailable')" /></div><div v-if="selectedEvidence" class="mt-3 rounded-lg border border-sky-200 bg-sky-50 p-3 text-xs text-sky-950 dark:border-sky-900 dark:bg-sky-950/30 dark:text-sky-100"><div class="flex items-center gap-1 font-semibold"><MapPin class="h-3.5 w-3.5" />{{ t('chat.shippingOrderReview.evidenceAt', { page: selectedEvidence.page_no || '-' }) }}</div><p v-if="selectedEvidence.quote" class="mt-1 break-words">{{ selectedEvidence.quote }}</p><p v-if="!selectedEvidence.bbox" class="mt-1">{{ t('chat.shippingOrderReview.evidenceNoHighlight') }}</p></div><p v-else class="mt-3 text-xs text-slate-500">{{ t('chat.shippingOrderReview.evidenceSummary') }}</p></div>
</aside>
</div>
<footer v-if="activeCase?.draft" 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"><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="reportDisposition(() => markNonOrder('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="reportDisposition(() => markQualityIssue('other'))">{{ 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="reportDisposition(() => reparseDocument('document_quality'))"><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" class="rounded bg-emerald-600 px-3 py-2 text-sm text-white disabled:opacity-50" @click="confirmCase">{{ t('chat.shippingOrderReview.confirmCreate') }}</button></footer>
<DeleteConfirmDialog v-model="confirmDialogOpen" :title="t('chat.shippingOrderReview.confirmCreate')" :message="t('chat.shippingOrderReview.confirmPrompt')" :confirm-text="t('chat.shippingOrderReview.confirmCreate')" confirm-tone="primary" :confirm-loading="saving" @confirm="confirmCaseSubmit" />
</main>
</template>
@@ -9,6 +9,7 @@ import { onMounted, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { Edit, FileSpreadsheet, Fingerprint, GitMerge, History, Plus, Search, Trash2, UserX } from 'lucide-vue-next';
import CustomerDeleteDialog from './components/CustomerDeleteDialog.vue';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import CustomerMergeDialog from './components/CustomerMergeDialog.vue';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import CustomerFormModal from './components/CustomerFormModal.vue';
@@ -92,5 +93,18 @@ onMounted(() => { void Promise.all([admin.loadCustomers(), admin.loadShadowRepor
<CustomerDeleteDialog :visible="admin.showDeleteDialog.value" :customer="admin.deleteCustomer.value" :impact="admin.deleteImpact.value" :is-saving="admin.isSaving.value" @close="admin.closeDeleteCustomer" @confirm="admin.confirmDeleteCustomer" />
<CustomerLifecyclePanel :visible="admin.showLifecyclePanel.value" :customer="admin.lifecycleCustomer.value" :timeline="admin.lifecycleTimeline.value" @close="admin.closeLifecycleTimeline" />
<CustomerMergeDialog :visible="admin.showMergeDialog.value" :source="admin.mergeCustomer.value" :impact="admin.mergeImpact.value" :customers="admin.importTargetCustomers.value" :is-saving="admin.isSaving.value" @close="admin.closeMergeCustomer" @preview="admin.previewMergeCustomer" @confirm="admin.confirmMergeCustomer" />
<DeleteConfirmDialog
:model-value="admin.pendingReasonAction.value !== null"
:title="admin.pendingReasonAction.value?.kind === 'deactivate' ? t('admin.shippingCustomers.deactivate') : t('admin.shippingCustomers.identifiers.title')"
:message="admin.pendingReasonAction.value?.kind === 'deactivate' ? t('admin.shippingCustomers.confirmDeactivate', { name: admin.pendingReasonAction.value.customer.standard_name }) : t('admin.shippingCustomers.prompts.identifierChangeReason')"
:reason-label="admin.pendingReasonAction.value?.kind === 'deactivate' ? t('admin.shippingCustomers.prompts.deactivateReason') : t('admin.shippingCustomers.prompts.identifierChangeReason')"
:reason-placeholder="admin.pendingReasonAction.value?.kind === 'deactivate' ? t('admin.shippingCustomers.prompts.deactivateReason') : t('admin.shippingCustomers.prompts.identifierChangeReason')"
reason-required
confirm-tone="primary"
:confirm-loading="admin.isSaving.value"
@update:model-value="(visible) => { if (!visible) admin.cancelReasonAction(); }"
@cancel="admin.cancelReasonAction"
@confirm="admin.confirmReasonAction"
/>
</section>
</template>
@@ -82,6 +82,7 @@ export function useShippingCustomersAdmin() {
const showDeleteDialog = ref(false);
const showLifecyclePanel = ref(false);
const showMergeDialog = ref(false);
const pendingReasonAction = ref<{ kind: 'deactivate'; customer: ShippingCustomerRow } | { kind: 'update_evidence'; evidenceId: number; payload: Record<string, unknown> } | null>(null);
/** 分页加载全部客户选项,供导入冲突和影子真值标签共用。 */
const loadAllCustomerOptions = async (): Promise<void> => {
@@ -176,17 +177,9 @@ export function useShippingCustomersAdmin() {
}
};
/** 停用客户并保留历史业务引用。 */
const deactivateCustomer = async (customer: ShippingCustomerRow): Promise<void> => {
if (!window.confirm(t('admin.shippingCustomers.confirmDeactivate', { name: customer.standard_name }))) return;
const reason = window.prompt(t('admin.shippingCustomers.prompts.deactivateReason'))?.trim();
if (!reason) return;
try {
await deactivateShippingCustomer(customer.id, reason);
await loadCustomers();
} catch (error) {
showError(error, 'admin.shippingCustomers.msg.saveFailed');
}
/** 打开停用确认;审计原因由平台公共确认组件收集。 */
const deactivateCustomer = (customer: ShippingCustomerRow): void => {
pendingReasonAction.value = { kind: 'deactivate', customer };
};
/** 打开客户治理时间线;读取失败时不显示过期的其他客户审计。 */
@@ -349,18 +342,32 @@ export function useShippingCustomersAdmin() {
}
};
/** 更新证据审核状态或自动匹配授权,并刷新详情。 */
const updateIdentityEvidence = async (evidenceId: number, payload: Record<string, unknown>): Promise<void> => {
/** 打开证据变更确认;审计原因由平台公共确认组件收集。 */
const updateIdentityEvidence = (evidenceId: number, payload: Record<string, unknown>): void => {
if (!selectedCustomer.value) return;
pendingReasonAction.value = { kind: 'update_evidence', evidenceId, payload };
};
/** 确认后提交需要审计原因的治理动作。 */
const confirmReasonAction = async (reason: string): Promise<void> => {
const action = pendingReasonAction.value;
if (!action || !reason.trim()) return;
isSaving.value = true;
try {
const reason = window.prompt(t('admin.shippingCustomers.prompts.identifierChangeReason'))?.trim();
if (!reason) return;
await updateShippingIdentityEvidence(evidenceId, { ...payload, reason });
selectedCustomer.value = await getShippingCustomer(selectedCustomer.value.id);
if (action.kind === 'deactivate') {
await deactivateShippingCustomer(action.customer.id, reason.trim());
await loadCustomers();
} else {
await updateShippingIdentityEvidence(action.evidenceId, { ...action.payload, reason: reason.trim() });
if (selectedCustomer.value) selectedCustomer.value = await getShippingCustomer(selectedCustomer.value.id);
}
} catch (error) {
showError(error, 'admin.shippingCustomers.msg.saveFailed');
} finally {
isSaving.value = false;
pendingReasonAction.value = null;
}
};
const cancelReasonAction = (): void => { pendingReasonAction.value = null; };
/** 新增外部系统客户编码,并重新读取客户详情。 */
const addExternalRef = async (payload: { source_system: string; customer_code: string }): Promise<void> => {
@@ -501,9 +508,9 @@ export function useShippingCustomersAdmin() {
customers, importTargetCustomers, selectedCustomer, publishedEvidenceDefinitions, customerForm, importBatch, shadowReport, deleteCustomer, deleteImpact, lifecycleCustomer, lifecycleTimeline, mergeCustomer, mergeImpact,
searchQuery, statusFilter, page, pageSize, total, pages,
isLoading, isSaving, isImporting, isShadowLoading,
showCustomerModal, showIdentifiersPanel, showImportDialog, showDeleteDialog, showLifecyclePanel, showMergeDialog,
showCustomerModal, showIdentifiersPanel, showImportDialog, showDeleteDialog, showLifecyclePanel, showMergeDialog, pendingReasonAction,
loadCustomers, searchCustomers, openCreateCustomer, openEditCustomer, closeCustomerModal,
saveCustomer, deactivateCustomer, openLifecycleTimeline, closeLifecycleTimeline, openDeleteCustomer, closeDeleteCustomer, confirmDeleteCustomer, openMergeCustomer, previewMergeCustomer, closeMergeCustomer, confirmMergeCustomer, openIdentifiers, addIdentityEvidence, updateIdentityEvidence, addExternalRef, addSite,
saveCustomer, deactivateCustomer, confirmReasonAction, cancelReasonAction, openLifecycleTimeline, closeLifecycleTimeline, openDeleteCustomer, closeDeleteCustomer, confirmDeleteCustomer, openMergeCustomer, previewMergeCustomer, closeMergeCustomer, confirmMergeCustomer, openIdentifiers, addIdentityEvidence, updateIdentityEvidence, addExternalRef, addSite,
openImport, uploadImport, decideImportRow, publishImport, downloadTemplate, downloadReconciliation,
loadShadowReport, labelShadowResolution,
};
@@ -144,6 +144,19 @@ const detailIssues = computed(() => (
.filter(Boolean)
: []
));
const detailTodoTitle = computed(() => (
sanitizeShippingRuntimeStatusText(String(detail.value?.ui_state?.summary?.title || '').trim())
|| t('workspace.shippingNotice.todo.noActionTitle')
));
const detailTodoMessage = computed(() => (
sanitizeShippingRuntimeStatusText(String(detail.value?.ui_state?.summary?.message || '').trim())
|| detailIssues.value[0]
|| t('workspace.shippingNotice.todo.noActionMessage')
));
const detailTodoActionLabel = computed(() => (
String(detail.value?.ui_state?.action_buttons?.[0]?.label || '').trim()
));
const detailHasTodo = computed(() => !!detailTodoActionLabel.value);
const inventorySnapshotLabel = (triggerType?: string | null) => {
const key = String(triggerType || 'on_demand');
@@ -319,8 +332,8 @@ onMounted(async () => {
</button>
</div>
<div class="grid gap-5 lg:grid-cols-5">
<div class="lg:col-span-2 space-y-2">
<div class="grid gap-5 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,2.15fr)]">
<div class="space-y-2">
<div v-if="loading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.loading') }}
</div>
@@ -345,6 +358,12 @@ onMounted(async () => {
</span>
</div>
<div class="mt-1 truncate text-sm text-secondary">{{ item.customer_name || '—' }}</div>
<div
v-if="item.ui_state?.summary?.title"
class="mt-1 truncate text-xs font-medium text-brand-700"
>
{{ sanitizeShippingRuntimeStatusText(item.ui_state.summary.title) }}
</div>
<div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-muted">
<span>{{ formatLocalDateTime(item.created_at) }}</span>
<span v-if="item.batch_index && item.batch_total" class="rounded-full bg-sky-50 px-2 py-0.5 font-medium text-sky-700">
@@ -380,7 +399,7 @@ onMounted(async () => {
</div>
</div>
<div class="lg:col-span-3 rounded-2xl border border-default bg-surface/50 p-5">
<div class="rounded-2xl border border-default bg-surface/50 p-5">
<div v-if="!selectedTaskNo" class="py-16 text-center text-sm text-muted">
{{ $t('workspace.shippingNotice.selectCase') }}
</div>
@@ -414,7 +433,33 @@ onMounted(async () => {
</div>
</div>
<ShippingWorkflowStepper :steps="detailWorkflowSteps" />
<section class="rounded-2xl border border-brand-200 bg-brand-50/50 p-4">
<div class="flex flex-wrap items-start justify-between gap-4">
<div class="min-w-0">
<div class="text-xs font-semibold uppercase tracking-wide text-brand-700">
{{ $t('workspace.shippingNotice.todo.label') }}
</div>
<h3 class="mt-1 text-base font-semibold text-primary">{{ detailTodoTitle }}</h3>
<p class="mt-1 text-sm text-secondary">{{ detailTodoMessage }}</p>
</div>
<button
v-if="chatAgentId && detailHasTodo"
type="button"
class="inline-flex shrink-0 items-center gap-1 rounded-xl bg-brand-600 px-3 py-2 text-sm font-medium text-white hover:bg-brand-700"
@click="openInChat(detail.task_no, detail.conversation_id, detail.batch_no)"
>
<ExternalLink class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.todo.handleInChat', { action: detailTodoActionLabel }) }}
</button>
</div>
</section>
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
<div class="mb-3 text-xs font-semibold uppercase tracking-wide text-muted">
{{ $t('workspace.shippingNotice.todo.workflow') }}
</div>
<ShippingWorkflowStepper :steps="detailWorkflowSteps" />
</section>
<div
v-if="detailStepProgress"
@@ -451,7 +496,9 @@ onMounted(async () => {
</div>
</div>
<dl class="grid gap-3 sm:grid-cols-2 text-sm">
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
<h3 class="mb-3 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.todo.orderOverview') }}</h3>
<dl class="grid gap-3 sm:grid-cols-2 text-sm">
<div>
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.status') }}</dt>
<dd :title="detail.process_status">{{ statusBadge(detail).label }}</dd>
@@ -462,7 +509,8 @@ onMounted(async () => {
</div>
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.shipTo') }}</dt><dd>{{ detail.ship_to || '—' }}</dd></div>
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.freightRef') }}</dt><dd>{{ detail.freight_ref_no || '—' }}</dd></div>
</dl>
</dl>
</section>
<div
v-if="hasInventorySourceFields"
+226 -1
View File
@@ -2534,8 +2534,30 @@
"enterOneField": "Please enter at least one field to update",
"batchDeleteResult": "Deleted {count} users."
},
"orderProfileValidation": {
"eyebrow": "DRAFT VALIDATION",
"title": "Validate Order Document Profile",
"description": "Run summaries exclude PDFs, object-storage addresses, and blind-test ground truth. Historical runs become stale after a draft change.",
"backToEditor": "Back to editor",
"instantCheck": "Run instant check",
"currentSample": "Run current sample",
"loading": "Loading validation runs...",
"run": "Run",
"type": "Type",
"status": "Status",
"summary": "Safe summary",
"time": "Created",
"empty": "No validation runs yet.",
"completed": "Validation run completed.",
"failed": "Validation run failed."
},
"orderProfilePublishCheck": {
"eyebrow": "PUBLISH GATE", "title": "Confirm Order Document Profile Publication", "description": "The report freezes the draft version and becomes invalid when the draft changes.", "back": "Back", "selectRun": "Select a passing validation run", "noRun": "The current draft has no passing validation run for publication.", "create": "Create publish-check report", "report": "Report {reportNo}", "status": "Status: {status} · Revision {revision}", "blocking": "Blocking items", "noBlocking": "No blocking items.", "warnings": "Warnings (confirm each item)", "confirm": "Confirm publication", "failed": "Publish check failed."
},
"shippingOrderProfiles": {
"title": "Order Document Profiles",
"library": { "title": "Order document templates", "subtitle": "Manage template families, drafts, published versions, and historical views.", "create": "Create template", "search": "Search templates", "status": "Current status", "actions": "Actions", "draft": "Draft", "published": "Published v{version}", "retired": "Retired", "loading": "Loading templates...", "empty": "No templates found.", "loadFailed": "Failed to load templates.", "createFailed": "Failed to create the new version draft." },
"wizard": { "title": "Create order document template", "steps": "Step {step} of 3", "codeHint": "This code is permanent after creation and is used for routing, version grouping, and audit.", "selectSchema": "Select a published schema", "previous": "Back", "next": "Next", "createDraft": "Create draft", "createAndEdit": "Create and start annotation", "incomplete": "Complete the required fields before continuing.", "loadFailed": "Failed to load wizard options.", "uploadFailed": "Failed to upload the template sample.", "sampleHint": "Uploading or selecting a sample does not create a template.", "tableLoadFailed": "Failed to load sample tables.", "tableOption": "Page {page} · {rows} rows · {columns} columns", "noTable": "This sample has no available table. Choose another parsed sample.", "createFailed": "The template draft could not be created. No partial template was kept." },
"subtitle": "Configure exact column mappings from MinerU table samples without editing JSON or fingerprints.",
"structureBlocked": "This table has a structural error and cannot create a profile. Wait for coordinate-evidence reconstruction and review it; do not repair the raw grid with field mappings.",
"reconstructionRequired": "This header contains line data. Confirm column boundaries and rebuild the table first; the result requires manual review.",
@@ -2638,6 +2660,209 @@
"compositePart": "Composite customer/internal part",
"previewEmpty": "Select a sample document and table to preview",
"versions": "Profile versions",
"versionCenter": {
"eyebrow": "Version Center",
"backToWorkbench": "Back to Workbench",
"continueEditing": "Continue editing",
"viewVersion": "View version",
"familyVersions": "Version navigation",
"loading": "Loading version detail...",
"tabsLabel": "Profile version detail tabs",
"tabs": {
"overview": "Overview",
"canvas": "Sample canvas",
"diff": "Version diff",
"audit": "Audit log",
"usage": "Usage"
},
"tabPlaceholders": {
"canvas": "The sample canvas arrives in phase 4 and will remain strictly read-only from frozen evidence.",
"diff": "Version diff arrives in phase 5 with a stable server-side semantic diff.",
"audit": "Audit log arrives in phase 6. This phase keeps only the detail route and overview.",
"usage": "Usage arrives in phase 6. This phase keeps only the detail route and overview."
},
"diff": {
"title": "Semantic version diff",
"subtitle": "Only compares structured rule changes inside the same profile family. No document body, object storage address, or blind-test truth is exposed.",
"compareTarget": "Compare against",
"defaultPrevious": "Previous version by default",
"initialVersion": "Initial version (compared with an empty baseline)",
"comparedWith": "Comparing with: {target}",
"loading": "Loading version diff...",
"loadFailed": "Failed to load the version diff",
"noChanges": "There is no semantic change to show between these versions.",
"rawJson": "View raw JSON snapshots",
"beforeSnapshot": "Baseline snapshot",
"afterSnapshot": "Current snapshot",
"empty": "Empty",
"orderChanged": "Order only changed",
"addedValues": "Added: {values}",
"removedValues": "Removed: {values}",
"summary": {
"added": "Added {count}",
"removed": "Removed {count}",
"modified": "Modified {count}",
"unchanged": "Unchanged {count}"
},
"changeType": {
"added": "Added",
"removed": "Removed",
"modified": "Modified",
"unchanged": "Unchanged"
},
"entityType": {
"profile_meta": "Profile governance",
"document_match": "Document match",
"table_region": "Table region",
"header_layout": "Header layout",
"header_field_region": "Header field region",
"line_layout": "Line layout",
"line_field_region": "Line field region",
"termination_rule": "Termination rule",
"exclusion_region": "Exclusion region",
"order_field_layout": "Order field layout",
"sample_binding": "Sample evidence"
}
},
"audit": {
"title": "Audit timeline",
"subtitle": "Replay governance actions for this version by request id, event type, actor, and date range.",
"eventType": "Event type",
"actor": "Actor",
"requestId": "Request ID",
"createdFrom": "Created from",
"createdTo": "Created to",
"apply": "Apply",
"reset": "Reset",
"loading": "Loading audit events...",
"loadFailed": "Failed to load audit events",
"empty": "No audit event matches the current filters.",
"previous": "Previous",
"next": "Next"
},
"usage": {
"title": "Actual usage",
"subtitle": "Only the latest routing fact of each document unit is shown, with a link to the read-only run audit.",
"refresh": "Refresh",
"loading": "Loading actual usage...",
"loadFailed": "Failed to load actual usage",
"empty": "This version has no actual usage yet.",
"openDiagnostic": "Open run audit",
"previous": "Previous",
"next": "Next",
"yes": "Yes",
"no": "No",
"columns": {
"runNo": "Run no",
"document": "Document",
"matchStatus": "Match status",
"executionStatus": "Execution status",
"identityMode": "Match mode",
"autoCreateApproved": "Auto completed",
"createdAt": "Time",
"reasonCodes": "Failure/degrade reasons"
},
"runStatuses": {
"queued": "Queued",
"processing": "Processing",
"completed": "Completed",
"partially_completed": "Partially completed",
"review_required": "Review required",
"failed": "Failed",
"cancelled": "Cancelled"
},
"matchStatuses": {
"unique_match": "Unique match",
"no_match": "No match",
"ambiguous": "Ambiguous",
"layout_drift": "Layout drift",
"evidence_insufficient": "Insufficient evidence"
},
"executionStatuses": {
"pending": "Pending",
"routing": "Routing",
"matching_profile": "Matching profile",
"extracting": "Extracting",
"merging_supplement": "Merging supplement",
"candidate_ready": "Candidate ready",
"review_required": "Review required",
"failed": "Failed",
"cancelled": "Cancelled"
},
"identityModes": {
"direct_profile_id": "Direct foreign-key match",
"snapshot_identity_match": "Frozen snapshot match"
}
},
"status": {
"currentDraft": "Current draft",
"currentPublished": "Current published",
"retired": "Retired"
},
"schemaVersion": "Schema v",
"sampleCount": "Samples {count}",
"checksum": "Profile checksum",
"schemaChecksum": "Schema checksum",
"publishedAt": "Published at",
"retiredAt": "Retired at",
"definitionStats": "Definition scale",
"tableRegions": "Table regions",
"headerLayouts": "Header layouts",
"lineLayouts": "Line layouts",
"orderFieldLayouts": "Order field layouts",
"frozenEvidenceTitle": "Frozen evidence",
"statusLabel": "Status",
"sampleCountPlain": "Sample count",
"frozenSampleCount": "Frozen samples",
"auditReady": "Audit ready",
"readonlyCanvasBadge": "Read-only canvas",
"loadingCanvas": "Loading read-only canvas...",
"canvasLoadFailed": "Failed to load the read-only canvas",
"draftCanvasHint": "Draft versions should continue in the workbench. The detail-page canvas is reserved for frozen-evidence review.",
"noReadableSamples": "This version has no annotation/training sample available for the ordinary read-only canvas.",
"readonlySample": "Read-only sample",
"sampleFrozenEvidenceMissing": "This sample does not have complete frozen evidence. The system will not fall back to the current document or latest layout.",
"frozenEvidencePanelTitle": "Frozen evidence panel",
"selectSampleHint": "Select a frozen sample to inspect its evidence.",
"sampleFile": "Sample file",
"layoutVersionId": "Layout version ID",
"evidenceFrozenAt": "Frozen at",
"pageCountPlain": "Page count",
"parserIdentity": "Parser identity",
"parserVersionTitle": "Parser version",
"frozenTableId": "Frozen table ID",
"frozenPageNo": "Frozen page",
"frozenRowCount": "Frozen rows",
"layoutChecksumTitle": "Layout checksum",
"contentHashTitle": "Content hash",
"regionSummaryTitle": "Region summary",
"selectRegionHint": "Click a region on the canvas to inspect its binding summary.",
"regionLabelTitle": "Region label",
"regionKindTitle": "Region kind",
"regionFieldCodeTitle": "Field code",
"regionPageTitle": "Page",
"sampleSummaryTitle": "Sample summary",
"annotationCount": "Annotation samples",
"trainingCount": "Training samples",
"blindTestCount": "Blind-test samples",
"firstSample": "First sample",
"testSummaryTitle": "Test summary",
"approvedAt": "Approved at",
"latestRun": "Latest run",
"sourceVersionTitle": "Source version",
"noSourceVersion": "This version was not cloned from a historical version.",
"frozenEvidence": {
"pending": "Pending",
"ready": "Ready",
"missing": "Missing"
},
"testStatus": {
"missing": "Missing",
"draft": "Draft",
"approved": "Approved",
"superseded": "Superseded"
}
},
"currentVersion": "Current",
"publishedAt": "Published: {time}",
"publish": "Publish",
@@ -2697,7 +2922,7 @@
},
"workbench": {
"boundHistoricalSchema": "bound historical version",
"intro": "Drag evidence regions on a controlled document page; saved definitions contain no HTML or storage URL.",
"intro": "Drag evidence regions on a controlled document page; saved definitions contain no HTML or storage URL.", "structure": "Structure", "saveStatus": { "saved": "Saved", "saving": "Saving", "failed": "Save failed; local edits are retained", "readonly": "Read-only: edit lease expired" }, "exportLocalDraft": "Export local draft", "recoverLease": "Reacquire lease", "takeOverLease": "Take over lease", "suggestionReadyForDecision": "Suggestion is ready for a decision", "acceptSuggestion": "Accept", "acceptAdjustedSuggestion": "Accept with adjustments", "rejectSuggestion": "Reject", "suggestionAdjustmentField": "Choose replacement field",
"openCanvas": "Create draft and open canvas",
"loadingPage": "Loading page...",
"canvasZoom": "Page zoom",
+11
View File
@@ -130,6 +130,7 @@
"shippingCandidateReviewRequired": "A selected order candidate still needs review. Correct its conflicting fields first.",
"shippingCandidateSelectRequired": "Select at least one order candidate before creating tasks.",
"shippingOrderExtractionDefaultPrompt": "Fully parse the shipping orders in the uploaded email and attachments, then create eligible tasks automatically.",
"shippingOrderExtractionDefaultUserMessage": "Please identify and extract the order information from the attached files.",
"shippingOrderExtractionCardTitle": {
"queued": "Order parsing is queued",
"processing": "Order parsing is in progress",
@@ -168,10 +169,17 @@
"shippingOrderExtractionDocumentsLoading": "Loading PDF processing results...",
"shippingOrderExtractionDocumentsUnavailable": "PDF processing results are temporarily unavailable. Please try again later.",
"shippingOrderExtractionNoDocuments": "No PDF results are available yet.",
"shippingOrderExtractionDocumentTiming": {
"started": "Started {time}",
"updated": "Updated {time}",
"finished": "Finished {time}"
},
"shippingOrderExtractionUnknownDocument": "Unnamed PDF",
"shippingOrderExtractionUnread": "{count} order identification result(s) need review",
"shippingOrderExtractionActivity": {
"plan_created": "The extraction plan is ready and the first wave is being prepared.",
"layout_parsing_started": "Parsing the order attachment layout. Recognition will start automatically when it finishes.",
"layout_parsing_completed": "Attachment parsing is complete. Starting order recognition.",
"initial_wave_started": "The system has started analyzing the first wave of attachments.",
"expansion_wave_started": "The system has started analyzing the next wave of candidate attachments.",
"document_queued": "The attachment has been accepted and is waiting for a worker.",
@@ -1080,5 +1088,8 @@
{ "id": "q19", "type": "boolean", "prompt": "External documents do not need to be controlled or managed by the organization.", "answer": "false", "explanation": "External documents also need controlled management." },
{ "id": "q20", "type": "boolean", "prompt": "Product-related requirements should include legal and regulatory requirements as well as customer requirements.", "answer": "true", "explanation": "Product requirements must cover both regulations and customer requirements." }
]
},
"shippingOrderReview": {
"title": "Order review", "run": "Run {runNo}", "back": "Back to chat", "readOnly": "Read-only preview", "loading": "Loading review results...", "unavailable": "Review results are unavailable. Please try again later.", "documentNavigation": "PDF navigation", "documents": "PDF documents", "unnamedDocument": "Unnamed PDF", "caseStatus": "{status} · {count} issue(s)", "previewTitle": "PDF preview", "previewLoading": "Loading PDF preview...", "previewUnavailable": "PDF preview is unavailable. Draft editing is unaffected.", "evidenceSummary": "Select a field's location icon to inspect its evidence.", "evidenceAt": "PDF page {page}", "evidenceNoHighlight": "This evidence has no reliable coordinates. Only its page and quote are shown; no highlight is fabricated.", "viewEvidence": "View evidence", "orderFields": "Order fields", "schemaVersion": "Frozen schema #{version}", "issues": "Open issues", "machineSource": "Source: machine extraction", "manualSource": "Source: manual edit", "restoreMachine": "Restore machine value", "saved": "Saved", "saving": "Saving", "saveFailed": "Save failed", "saveNow": "Save and validate", "addLine": "Add line", "copyLine": "Copy line", "deleteLine": "Delete line", "noMachineOrder": "No reliable order was identified.", "lines": "Order lines", "line": "Line {index}", "noLines": "No order lines were identified.", "moreFields": "More order information ({count})", "emptyValue": "Not provided", "unknownField": "Order field", "createManualDraft": "Create manual order draft", "markNonOrder": "Mark as non-order", "markQualityIssue": "File quality issue", "reparse": "Reparse this PDF", "uploadReplacement": "Upload replacement PDF", "confirmCreate": "Confirm and create task", "confirmPrompt": "This freezes the current draft and creates one independent task. Editing will no longer be available. Continue?"
}
}
+2 -1
View File
@@ -31,5 +31,6 @@
"unsorted": "Click to sort",
"asc": "Ascending, click for descending",
"desc": "Descending, click for ascending"
}
},
"required": "This field is required"
}
+36 -1
View File
@@ -41,6 +41,13 @@
"SHIPPING_ORDER_DOCUMENT_PROFILE_IMMUTABLE": "A published order document parsing profile cannot be modified.",
"SHIPPING_ORDER_DOCUMENT_PROFILE_LOCK_VERSION_REQUIRED": "The profile lock version is missing. Refresh and try again.",
"SHIPPING_ORDER_DOCUMENT_PROFILE_VERSION_CONFLICT": "Another administrator changed the profile. Refresh and try again.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_REQUIRED": "An active editing lease is required. Refresh or take over the draft first.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_CONFLICT": "This draft is currently being edited in another browser session.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LOCK_VERSION_CONFLICT": "The draft changed on the server. Refresh and resolve the conflict before saving.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_REVISION_NOT_FOUND": "The requested draft revision was not found.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_VALIDATION_STALE": "This validation run no longer matches the current draft.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_INVALID": "The publish check is no longer valid. Run the checks again.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_CONSUMED": "This publish check has already been used.",
"SHIPPING_ORDER_DOCUMENT_PROFILE_DRAFT_EXISTS": "This order document parsing profile already has a draft.",
"SHIPPING_ORDER_DOCUMENT_PROFILE_PUBLISH_INVALID": "The current order document parsing profile cannot be published.",
"SHIPPING_ORDER_DOCUMENT_PROFILE_PUBLISH_GATE_TRAINING": "Bind at least one training sample before publishing.",
@@ -343,6 +350,34 @@
"SHIPPING_CUSTOMER_IMPORT_PUBLISH_CONFLICT": "A data conflict occurred while publishing the import.",
"SHIPPING.ORDER_SCHEMA_PROFILE_IMPACT_CONFIRM_REQUIRED": "This order field version affects existing document profiles. Confirm the impact before publishing.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_INVALID": "The order document profile field migration is invalid.",
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_REQUIRED": "Resolve every affected field before creating the migration draft."
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_REQUIRED": "Resolve every affected field before creating the migration draft.",
"SHIPPING_REVIEW_CASE_NOT_FOUND": "The order review case was not found or is not accessible.",
"SHIPPING_REVIEW_CASE_NOT_EDITABLE": "This order review is finished and can no longer be edited.",
"SHIPPING_REVIEW_DRAFT_VERSION_REQUIRED": "A valid draft version is required.",
"SHIPPING_REVIEW_DRAFT_VERSION_MISMATCH": "The draft was updated in another window. Refresh and try again.",
"SHIPPING_REVIEW_FIELD_INVALID": "The review field is not in this order's frozen schema.",
"SHIPPING_REVIEW_LINE_NOT_FOUND": "The order line was not found or was deleted.",
"SHIPPING_REVIEW_DOCUMENT_NOT_FOUND": "The review PDF does not exist or is not accessible.",
"SHIPPING_REVIEW_MANUAL_DRAFT_ALREADY_HAS_CANDIDATE": "This PDF already has a machine order and cannot create a manual order.",
"SHIPPING_REVIEW_DRAFT_NOT_FOUND": "The order draft does not exist.",
"SHIPPING_REVIEW_DISPOSITION_NOT_ALLOWED": "This PDF is already finalized and its disposition cannot be changed.",
"SHIPPING_REVIEW_NON_ORDER_REASON_INVALID": "The non-order reason is invalid.",
"SHIPPING_REVIEW_QUALITY_REASON_INVALID": "The file quality issue reason is invalid.",
"SHIPPING_REVIEW_REPARSE_NOT_ALLOWED": "This PDF cannot be reparsed.",
"SHIPPING_REVIEW_REPARSE_REASON_INVALID": "The reparse reason is invalid.",
"SHIPPING_REVIEW_REPARSE_SOURCE_INVALID": "The source for reparsing this PDF is unavailable.",
"SHIPPING_REVIEW_REPARSE_PENDING": "This PDF is already being reparsed.",
"SHIPPING_REVIEW_REPLACEMENT_NOT_ALLOWED": "A replacement file cannot be used for this PDF now.",
"SHIPPING_REVIEW_REPLACEMENT_FILE_INVALID": "The replacement file must be a PDF.",
"SHIPPING_REVIEW_REPLACEMENT_NOT_FOUND": "The replacement intake does not exist or is not accessible.",
"SHIPPING_REVIEW_REPLACEMENT_PENDING": "The replacement PDF is still parsing. Try again later.",
"SHIPPING_REVIEW_REPLACEMENT_DOCUMENT_INVALID": "The replacement file must contain exactly one PDF.",
"SHIPPING_REVIEW_WARNING_ACK_INVALID": "The warning acknowledgements are invalid.",
"SHIPPING_REVIEW_CONFIRM_NOT_ALLOWED": "This order review cannot be confirmed now.",
"SHIPPING_REVIEW_DUPLICATE_RESOLUTION_REQUIRED": "This order may be a duplicate. Resolve it through the duplicate workflow first.",
"SHIPPING_REVIEW_IDEMPOTENCY_KEY_REQUIRED": "The confirmation request is missing an idempotency key. Please try again.",
"SHIPPING_REVIEW_IDEMPOTENCY_KEY_CONFLICT": "The confirmation request conflicts with an existing request. Refresh and try again.",
"SHIPPING_REVIEW_CONFIRM_VALIDATION_FAILED": "The draft has not passed complete validation and cannot be confirmed.",
"SHIPPING_REVIEW_CONFIRM_DOCUMENT_INVALID": "The review PDF is unavailable and cannot be confirmed."
}
}
+8
View File
@@ -168,6 +168,14 @@
"selectCase": "Select a task to view details",
"loadFailed": "Failed to load task",
"openChat": "Continue in Chat",
"todo": {
"label": "Current task",
"noActionTitle": "No action needed now",
"noActionMessage": "The system is processing the next step. Check the workflow and activity log.",
"handleInChat": "{action} in Chat",
"workflow": "Workflow",
"orderOverview": "Order overview"
},
"download": "Download Excel",
"downloadBatch": "Download batch ZIP",
"selectAllVisible": "Select current results",
+226 -1
View File
@@ -2402,8 +2402,30 @@
"enterOneField": "กรุณากรอกข้อมูลอย่างน้อยหนึ่งช่องเพื่ออัปเดต",
"batchDeleteResult": "ลบผู้ใช้ {count} คนแล้ว"
},
"orderProfileValidation": {
"eyebrow": "การตรวจสอบฉบับร่าง",
"title": "ตรวจสอบโปรไฟล์เอกสารคำสั่งซื้อ",
"description": "สรุปผลไม่รวม PDF ที่อยู่ object storage หรือข้อมูลจริงของ blind test และผลเก่าจะล้าสมัยเมื่อร่างเปลี่ยนแปลง",
"backToEditor": "กลับไปยังตัวแก้ไข",
"instantCheck": "เรียกใช้การตรวจสอบทันที",
"currentSample": "ทดสอบตัวอย่างปัจจุบัน",
"loading": "กำลังโหลดผลการตรวจสอบ...",
"run": "หมายเลขการรัน",
"type": "ประเภท",
"status": "สถานะ",
"summary": "สรุปที่ปลอดภัย",
"time": "เวลาสร้าง",
"empty": "ยังไม่มีผลการตรวจสอบ",
"completed": "ตรวจสอบเสร็จแล้ว",
"failed": "ตรวจสอบล้มเหลว"
},
"orderProfilePublishCheck": {
"eyebrow": "ด่านเผยแพร่", "title": "ยืนยันการเผยแพร่โปรไฟล์เอกสารคำสั่งซื้อ", "description": "รายงานจะตรึงรุ่นฉบับร่างและจะใช้งานไม่ได้เมื่อฉบับร่างเปลี่ยน", "back": "กลับ", "selectRun": "เลือกผลตรวจสอบที่ผ่าน", "noRun": "ฉบับร่างปัจจุบันไม่มีผลตรวจสอบที่ผ่านสำหรับการเผยแพร่", "create": "สร้างรายงานตรวจสอบการเผยแพร่", "report": "รายงาน {reportNo}", "status": "สถานะ: {status} · Revision {revision}", "blocking": "รายการที่ขัดขวาง", "noBlocking": "ไม่มีรายการที่ขัดขวาง", "warnings": "คำเตือน (ยืนยันแต่ละรายการ)", "confirm": "ยืนยันการเผยแพร่", "failed": "ตรวจสอบการเผยแพร่ล้มเหลว"
},
"shippingOrderProfiles": {
"title": "โปรไฟล์เอกสารคำสั่งซื้อ",
"library": { "title": "เทมเพลตเอกสารคำสั่งซื้อ", "subtitle": "จัดการกลุ่มเทมเพลต ฉบับร่าง เวอร์ชันที่เผยแพร่ และประวัติ", "create": "สร้างเทมเพลต", "search": "ค้นหาเทมเพลต", "status": "สถานะปัจจุบัน", "actions": "การดำเนินการ", "draft": "ฉบับร่าง", "published": "เผยแพร่ v{version}", "retired": "เลิกใช้แล้ว", "loading": "กำลังโหลดเทมเพลต...", "empty": "ไม่พบเทมเพลต", "loadFailed": "โหลดเทมเพลตไม่สำเร็จ", "createFailed": "สร้างฉบับร่างเวอร์ชันใหม่ไม่สำเร็จ" },
"wizard": { "title": "สร้างเทมเพลตเอกสารคำสั่งซื้อ", "steps": "ขั้นตอน {step} จาก 3", "codeHint": "รหัสแก้ไขไม่ได้หลังสร้าง ใช้สำหรับ routing การรวมเวอร์ชัน และการตรวจสอบ", "selectSchema": "เลือก Schema ที่เผยแพร่", "previous": "ย้อนกลับ", "next": "ถัดไป", "createDraft": "สร้างฉบับร่าง", "createAndEdit": "สร้างและเริ่มทำคำอธิบายประกอบ", "incomplete": "กรอกข้อมูลที่จำเป็นก่อนดำเนินการ", "loadFailed": "โหลดตัวเลือกตัวช่วยสร้างไม่สำเร็จ", "uploadFailed": "อัปโหลดตัวอย่างเทมเพลตไม่สำเร็จ", "sampleHint": "การอัปโหลดหรือเลือกตัวอย่างจะไม่สร้างเทมเพลต", "tableLoadFailed": "โหลดตารางตัวอย่างไม่สำเร็จ", "tableOption": "หน้า {page} · {rows} แถว · {columns} คอลัมน์", "noTable": "ตัวอย่างนี้ไม่มีตารางที่ใช้ได้ เลือกตัวอย่างที่แยกข้อมูลแล้วอื่น", "createFailed": "ไม่สามารถสร้างฉบับร่างเทมเพลตได้ และไม่มีข้อมูลค้างอยู่" },
"subtitle": "ตั้งค่าการแมปคอลัมน์จากตัวอย่างตาราง MinerU โดยไม่ต้องแก้ไข JSON หรือลายนิ้วมือโครงสร้าง",
"structureBlocked": "ตารางนี้มีข้อผิดพลาดด้านโครงสร้างและไม่สามารถสร้างโปรไฟล์ได้ โปรดรอการสร้างใหม่จากหลักฐานพิกัดแล้วตรวจทาน ห้ามแก้กริดต้นฉบับด้วยการแมปฟิลด์",
"reconstructionRequired": "หัวตารางนี้มีข้อมูลรายการ ต้องยืนยันขอบเขตคอลัมน์และสร้างตารางใหม่ก่อน โดยต้องตรวจทานผลลัพธ์ด้วยคน",
@@ -2506,6 +2528,209 @@
"compositePart": "รหัสลูกค้า/ภายในแบบผสม",
"previewEmpty": "เลือกเอกสารและตารางตัวอย่างเพื่อดูตัวอย่าง",
"versions": "เวอร์ชันโปรไฟล์",
"versionCenter": {
"eyebrow": "ศูนย์เวอร์ชันเทมเพลต",
"backToWorkbench": "กลับไปยังเวิร์กเบนช์เทมเพลต",
"continueEditing": "แก้ไขต่อ",
"viewVersion": "ดูเวอร์ชัน",
"familyVersions": "การนำทางเวอร์ชัน",
"loading": "กำลังโหลดรายละเอียดเวอร์ชัน...",
"tabsLabel": "แท็บรายละเอียดเวอร์ชันเทมเพลต",
"tabs": {
"overview": "ภาพรวมการตั้งค่า",
"canvas": "ผืนงานตัวอย่าง",
"diff": "ความต่างของเวอร์ชัน",
"audit": "บันทึกการตรวจสอบ",
"usage": "การใช้งานจริง"
},
"tabPlaceholders": {
"canvas": "ผืนงานตัวอย่างจะเชื่อมต่อในระยะที่ 4 และจะแสดงแบบอ่านอย่างเดียวจากหลักฐานที่ถูกแช่แข็ง",
"diff": "ความต่างของเวอร์ชันจะเชื่อมต่อในระยะที่ 5 โดยใช้ semantic diff ฝั่งเซิร์ฟเวอร์ที่เสถียร",
"audit": "บันทึกการตรวจสอบจะเชื่อมต่อในระยะที่ 6 ระยะนี้คงไว้เฉพาะเส้นทางรายละเอียดและภาพรวม",
"usage": "การใช้งานจริงจะเชื่อมต่อในระยะที่ 6 ระยะนี้คงไว้เฉพาะเส้นทางรายละเอียดและภาพรวม"
},
"diff": {
"title": "ความต่างเชิงความหมายของเวอร์ชัน",
"subtitle": "เปรียบเทียบเฉพาะการเปลี่ยนแปลงกฎเชิงโครงสร้างภายในตระกูลเทมเพลตเดียวกัน โดยไม่เปิดเผยเนื้อหาเอกสาร ที่อยู่จัดเก็บ หรือค่าจริงของ blind test",
"compareTarget": "เวอร์ชันที่ใช้เปรียบเทียบ",
"defaultPrevious": "ใช้เวอร์ชันก่อนหน้าเป็นค่าเริ่มต้น",
"initialVersion": "เวอร์ชันแรก (เทียบกับ baseline ว่าง)",
"comparedWith": "กำลังเทียบกับ: {target}",
"loading": "กำลังโหลดความต่างของเวอร์ชัน...",
"loadFailed": "โหลดความต่างของเวอร์ชันไม่สำเร็จ",
"noChanges": "ไม่มีการเปลี่ยนแปลงเชิงความหมายที่จะแสดงระหว่างสองเวอร์ชันนี้",
"rawJson": "ดู snapshot JSON ดิบ",
"beforeSnapshot": "snapshot ฝั่ง baseline",
"afterSnapshot": "snapshot ปัจจุบัน",
"empty": "ว่าง",
"orderChanged": "เปลี่ยนเฉพาะลำดับ",
"addedValues": "เพิ่ม: {values}",
"removedValues": "ลบ: {values}",
"summary": {
"added": "เพิ่ม {count}",
"removed": "ลบ {count}",
"modified": "แก้ไข {count}",
"unchanged": "ไม่เปลี่ยน {count}"
},
"changeType": {
"added": "เพิ่ม",
"removed": "ลบ",
"modified": "แก้ไข",
"unchanged": "ไม่เปลี่ยน"
},
"entityType": {
"profile_meta": "การกำกับดูแลเทมเพลต",
"document_match": "การจับคู่เอกสาร",
"table_region": "พื้นที่ตาราง",
"header_layout": "เลย์เอาต์หัวตาราง",
"header_field_region": "พื้นที่ฟิลด์หัวตาราง",
"line_layout": "เลย์เอาต์รายการ",
"line_field_region": "พื้นที่ฟิลด์รายการ",
"termination_rule": "กฎสิ้นสุด",
"exclusion_region": "พื้นที่ยกเว้น",
"order_field_layout": "เลย์เอาต์ฟิลด์คำสั่งซื้อ",
"sample_binding": "หลักฐานตัวอย่าง"
}
},
"audit": {
"title": "ไทม์ไลน์การตรวจสอบ",
"subtitle": "ย้อนดูการดำเนินการกำกับดูแลของเวอร์ชันนี้ด้วย request id ประเภทเหตุการณ์ ผู้ปฏิบัติ และช่วงวันที่",
"eventType": "ประเภทเหตุการณ์",
"actor": "ผู้ปฏิบัติ",
"requestId": "Request ID",
"createdFrom": "วันที่เริ่มต้น",
"createdTo": "วันที่สิ้นสุด",
"apply": "กรอง",
"reset": "รีเซ็ต",
"loading": "กำลังโหลดบันทึกการตรวจสอบ...",
"loadFailed": "โหลดบันทึกการตรวจสอบไม่สำเร็จ",
"empty": "ไม่มีบันทึกการตรวจสอบภายใต้เงื่อนไขที่เลือก",
"previous": "ก่อนหน้า",
"next": "ถัดไป"
},
"usage": {
"title": "การใช้งานจริง",
"subtitle": "แสดงเฉพาะข้อเท็จจริงการ route ล่าสุดของแต่ละหน่วยเอกสาร และสามารถเปิด run audit แบบอ่านอย่างเดียวได้",
"refresh": "รีเฟรช",
"loading": "กำลังโหลดการใช้งานจริง...",
"loadFailed": "โหลดการใช้งานจริงไม่สำเร็จ",
"empty": "เวอร์ชันนี้ยังไม่มีการใช้งานจริง",
"openDiagnostic": "เปิด run audit",
"previous": "ก่อนหน้า",
"next": "ถัดไป",
"yes": "ใช่",
"no": "ไม่ใช่",
"columns": {
"runNo": "รหัส Run",
"document": "เอกสาร",
"matchStatus": "สถานะการจับคู่",
"executionStatus": "สถานะการทำงาน",
"identityMode": "วิธีการจับคู่",
"autoCreateApproved": "เสร็จอัตโนมัติ",
"createdAt": "เวลา",
"reasonCodes": "เหตุผลความล้มเหลว/ลดระดับ"
},
"runStatuses": {
"queued": "อยู่ในคิว",
"processing": "กำลังประมวลผล",
"completed": "เสร็จสิ้น",
"partially_completed": "เสร็จบางส่วน",
"review_required": "ต้องตรวจทาน",
"failed": "ล้มเหลว",
"cancelled": "ยกเลิกแล้ว"
},
"matchStatuses": {
"unique_match": "จับคู่ได้หนึ่งเดียว",
"no_match": "ไม่พบการจับคู่",
"ambiguous": "กำกวม",
"layout_drift": "เลย์เอาต์เปลี่ยน",
"evidence_insufficient": "หลักฐานไม่พอ"
},
"executionStatuses": {
"pending": "รอดำเนินการ",
"routing": "กำลัง route",
"matching_profile": "กำลังจับคู่เทมเพลต",
"extracting": "กำลังสกัดข้อมูล",
"merging_supplement": "กำลังรวมข้อมูลเสริม",
"candidate_ready": "ตัวเลือกพร้อมแล้ว",
"review_required": "ต้องตรวจทาน",
"failed": "ล้มเหลว",
"cancelled": "ยกเลิกแล้ว"
},
"identityModes": {
"direct_profile_id": "จับคู่ด้วย foreign key โดยตรง",
"snapshot_identity_match": "จับคู่ด้วย frozen snapshot"
}
},
"status": {
"currentDraft": "ฉบับร่างปัจจุบัน",
"currentPublished": "เวอร์ชันที่ใช้งานอยู่",
"retired": "เลิกใช้งานแล้ว"
},
"schemaVersion": "Schema v",
"sampleCount": "ตัวอย่าง {count}",
"checksum": "เช็กซัมโปรไฟล์",
"schemaChecksum": "เช็กซัม Schema",
"publishedAt": "เวลาเผยแพร่",
"retiredAt": "เวลาเลิกใช้งาน",
"definitionStats": "ขนาดการตั้งค่า",
"tableRegions": "พื้นที่ตาราง",
"headerLayouts": "เลย์เอาต์หัวตาราง",
"lineLayouts": "เลย์เอาต์แถวรายการ",
"orderFieldLayouts": "เลย์เอาต์ฟิลด์คำสั่งซื้อ",
"frozenEvidenceTitle": "หลักฐานที่แช่แข็ง",
"statusLabel": "สถานะ",
"sampleCountPlain": "จำนวนตัวอย่าง",
"frozenSampleCount": "ตัวอย่างที่แช่แข็งแล้ว",
"auditReady": "พร้อมตรวจสอบ",
"readonlyCanvasBadge": "ผืนงานอ่านอย่างเดียว",
"loadingCanvas": "กำลังโหลดผืนงานอ่านอย่างเดียว...",
"canvasLoadFailed": "โหลดผืนงานอ่านอย่างเดียวไม่สำเร็จ",
"draftCanvasHint": "เวอร์ชันฉบับร่างควรกลับไปแก้ไขใน workbench ต่อ ส่วนผืนงานในหน้ารายละเอียดใช้สำหรับตรวจทานหลักฐานที่ถูกแช่แข็งเท่านั้น",
"noReadableSamples": "เวอร์ชันนี้ไม่มีตัวอย่าง annotation/training สำหรับผืนงานอ่านอย่างเดียวทั่วไป",
"readonlySample": "ตัวอย่างอ่านอย่างเดียว",
"sampleFrozenEvidenceMissing": "ตัวอย่างนี้ไม่มีหลักฐานที่ถูกแช่แข็งครบถ้วน ระบบจะไม่ถอยกลับไปใช้เอกสารปัจจุบันหรือ layout ล่าสุด",
"frozenEvidencePanelTitle": "แผงหลักฐานที่แช่แข็ง",
"selectSampleHint": "เลือกตัวอย่างที่ถูกแช่แข็งเพื่อดูหลักฐาน",
"sampleFile": "ไฟล์ตัวอย่าง",
"layoutVersionId": "รหัสเวอร์ชันเลย์เอาต์",
"evidenceFrozenAt": "เวลาที่แช่แข็ง",
"pageCountPlain": "จำนวนหน้า",
"parserIdentity": "ตัวตน parser",
"parserVersionTitle": "เวอร์ชัน parser",
"frozenTableId": "รหัสตารางที่แช่แข็ง",
"frozenPageNo": "หน้าที่แช่แข็ง",
"frozenRowCount": "จำนวนแถวที่แช่แข็ง",
"layoutChecksumTitle": "เช็กซัมเลย์เอาต์",
"contentHashTitle": "แฮชไฟล์",
"regionSummaryTitle": "สรุปพื้นที่",
"selectRegionHint": "คลิกพื้นที่บนผืนงานเพื่อดูสรุปการผูกข้อมูล",
"regionLabelTitle": "ป้ายชื่อพื้นที่",
"regionKindTitle": "ประเภทพื้นที่",
"regionFieldCodeTitle": "รหัสฟิลด์",
"regionPageTitle": "หน้า",
"sampleSummaryTitle": "สรุปตัวอย่าง",
"annotationCount": "ตัวอย่างการทำเครื่องหมาย",
"trainingCount": "ตัวอย่างการฝึก",
"blindTestCount": "ตัวอย่างทดสอบแบบปิดบัง",
"firstSample": "ตัวอย่างแรก",
"testSummaryTitle": "สรุปการทดสอบ",
"approvedAt": "เวลาอนุมัติ",
"latestRun": "การรันล่าสุด",
"sourceVersionTitle": "เวอร์ชันต้นทาง",
"noSourceVersion": "เวอร์ชันนี้ไม่ได้คัดลอกจากเวอร์ชันประวัติ",
"frozenEvidence": {
"pending": "รอดำเนินการ",
"ready": "พร้อมแล้ว",
"missing": "ขาดหาย"
},
"testStatus": {
"missing": "ยังไม่มี",
"draft": "ฉบับร่าง",
"approved": "อนุมัติแล้ว",
"superseded": "หมดอายุแล้ว"
}
},
"currentVersion": "ใช้งานอยู่",
"publishedAt": "เผยแพร่: {time}",
"publish": "เผยแพร่",
@@ -2565,7 +2790,7 @@
},
"workbench": {
"boundHistoricalSchema": "เวอร์ชันประวัติที่ผูกไว้",
"intro": "ลากพื้นที่หลักฐานบนหน้าเอกสารที่ควบคุมไว้ คำนิยามที่บันทึกไม่มี HTML หรือ URL ที่เก็บข้อมูล",
"intro": "ลากพื้นที่หลักฐานบนหน้าเอกสารที่ควบคุมไว้ คำนิยามที่บันทึกไม่มี HTML หรือ URL ที่เก็บข้อมูล", "structure": "โครงสร้าง", "saveStatus": { "saved": "บันทึกแล้ว", "saving": "กำลังบันทึก", "failed": "บันทึกล้มเหลว แต่การแก้ไขในเครื่องยังคงอยู่", "readonly": "อ่านอย่างเดียว: สัญญาเช่าแก้ไขหมดอายุ" }, "exportLocalDraft": "ส่งออกฉบับร่างในเครื่อง", "recoverLease": "รับสัญญาเช่าใหม่", "takeOverLease": "ยืนยันรับช่วงสัญญาเช่า", "suggestionReadyForDecision": "ข้อเสนอแนะพร้อมให้ตัดสินใจ", "acceptSuggestion": "ยอมรับ", "acceptAdjustedSuggestion": "ยอมรับหลังปรับ", "rejectSuggestion": "ปฏิเสธ", "suggestionAdjustmentField": "เลือกฟิลด์ทดแทน",
"openCanvas": "สร้างฉบับร่างและเปิดผืนงาน",
"loadingPage": "กำลังโหลดหน้า...",
"canvasZoom": "การซูมหน้า",
+11
View File
@@ -130,6 +130,7 @@
"shippingCandidateReviewRequired": "รายการคำสั่งซื้อที่เลือกยังต้องตรวจสอบ โปรดแก้ไขข้อมูลที่ขัดแย้งก่อน",
"shippingCandidateSelectRequired": "โปรดเลือกรายการคำสั่งซื้ออย่างน้อยหนึ่งรายการก่อนสร้างงาน",
"shippingOrderExtractionDefaultPrompt": "โปรดแยกวิเคราะห์คำสั่งซื้อจัดส่งจากอีเมลและไฟล์แนบที่อัปโหลดให้ครบถ้วน แล้วสร้างงานที่ผ่านเกณฑ์โดยอัตโนมัติ",
"shippingOrderExtractionDefaultUserMessage": "โปรดระบุและดึงข้อมูลคำสั่งซื้อจากไฟล์แนบ",
"shippingOrderExtractionCardTitle": {
"queued": "คำสั่งแยกวิเคราะห์คำสั่งซื้ออยู่ในคิว",
"processing": "กำลังแยกวิเคราะห์คำสั่งซื้อ",
@@ -168,10 +169,17 @@
"shippingOrderExtractionDocumentsLoading": "กำลังโหลดผลลัพธ์การประมวลผล PDF...",
"shippingOrderExtractionDocumentsUnavailable": "ยังไม่สามารถโหลดผลลัพธ์การประมวลผล PDF ได้ โปรดลองอีกครั้งภายหลัง",
"shippingOrderExtractionNoDocuments": "ยังไม่มีผลลัพธ์ PDF",
"shippingOrderExtractionDocumentTiming": {
"started": "เริ่มเมื่อ {time}",
"updated": "อัปเดตเมื่อ {time}",
"finished": "เสร็จเมื่อ {time}"
},
"shippingOrderExtractionUnknownDocument": "PDF ไม่มีชื่อ",
"shippingOrderExtractionUnread": "มีผลการระบุคำสั่งซื้อ {count} รายการรอตรวจสอบ",
"shippingOrderExtractionActivity": {
"plan_created": "สร้างแผนการระบุแล้ว กำลังเตรียมไฟล์แนบรอบแรก",
"layout_parsing_started": "กำลังแยกโครงร่างไฟล์แนบคำสั่งซื้อ ระบบจะเริ่มจดจำโดยอัตโนมัติเมื่อเสร็จสิ้น",
"layout_parsing_completed": "แยกไฟล์แนบเสร็จแล้ว กำลังเริ่มจดจำคำสั่งซื้อ",
"initial_wave_started": "ระบบเริ่มวิเคราะห์ไฟล์แนบรอบแรกแล้ว",
"expansion_wave_started": "ระบบเริ่มวิเคราะห์ไฟล์แนบผู้สมัครรอบถัดไปแล้ว",
"document_queued": "ระบบรับไฟล์แนบแล้วและกำลังรอ Worker",
@@ -1080,5 +1088,8 @@
{ "id": "q19", "type": "boolean", "prompt": "เอกสารจากภายนอกไม่จำเป็นต้องถูกควบคุมหรือจัดการโดยองค์กร", "answer": "false", "explanation": "เอกสารจากภายนอกก็ต้องมีการควบคุมเช่นกัน" },
{ "id": "q20", "type": "boolean", "prompt": "ข้อกำหนดที่เกี่ยวข้องกับผลิตภัณฑ์ควรรวมถึงข้อกำหนดตามกฎหมายและข้อกำหนดของลูกค้า", "answer": "true", "explanation": "ข้อกำหนดของผลิตภัณฑ์ต้องครอบคลุมทั้งกฎหมายและความต้องการของลูกค้า" }
]
},
"shippingOrderReview": {
"title": "ตรวจทานคำสั่งซื้อ", "run": "รอบการระบุ {runNo}", "back": "กลับไปยังแชต", "readOnly": "ดูอย่างเดียว", "loading": "กำลังโหลดผลการตรวจทาน...", "unavailable": "ยังโหลดผลการตรวจทานไม่ได้ โปรดลองอีกครั้งภายหลัง", "documentNavigation": "รายการ PDF", "documents": "ไฟล์ PDF", "unnamedDocument": "PDF ไม่มีชื่อ", "caseStatus": "{status} · ปัญหา {count} รายการ", "previewTitle": "ตัวอย่าง PDF", "previewLoading": "กำลังโหลดตัวอย่าง PDF...", "previewUnavailable": "ตัวอย่าง PDF ใช้งานไม่ได้ แต่การแก้ไขร่างไม่ได้รับผลกระทบ", "evidenceSummary": "เลือกไอคอนตำแหน่งข้างฟิลด์เพื่อดูหลักฐาน", "evidenceAt": "PDF หน้า {page}", "evidenceNoHighlight": "หลักฐานนี้ไม่มีพิกัดที่เชื่อถือได้ จะแสดงเฉพาะหน้าและข้อความอ้างอิงโดยไม่สร้างการไฮไลต์เทียม", "viewEvidence": "ดูหลักฐาน", "orderFields": "ฟิลด์คำสั่งซื้อ", "schemaVersion": "Schema ที่ตรึงไว้ #{version}", "issues": "ปัญหาที่ยังเปิดอยู่", "machineSource": "แหล่งที่มา: การระบุของระบบ", "manualSource": "แหล่งที่มา: แก้ไขโดยผู้ใช้", "restoreMachine": "คืนค่าเครื่อง", "saved": "บันทึกแล้ว", "saving": "กำลังบันทึก", "saveFailed": "บันทึกไม่สำเร็จ", "saveNow": "บันทึกและตรวจสอบ", "addLine": "เพิ่มรายการ", "copyLine": "คัดลอกรายการ", "deleteLine": "ลบรายการ", "noMachineOrder": "ไม่พบคำสั่งซื้อที่เชื่อถือได้", "lines": "รายการคำสั่งซื้อ", "line": "บรรทัด {index}", "noLines": "ไม่พบรายการคำสั่งซื้อ", "moreFields": "ข้อมูลคำสั่งซื้อเพิ่มเติม ({count})", "emptyValue": "ไม่มีข้อมูล", "unknownField": "ฟิลด์คำสั่งซื้อ", "createManualDraft": "สร้างร่างคำสั่งซื้อด้วยตนเอง", "markNonOrder": "ทำเครื่องหมายว่าไม่ใช่คำสั่งซื้อ", "markQualityIssue": "ปัญหาคุณภาพไฟล์", "reparse": "ระบุ PDF นี้ใหม่", "uploadReplacement": "อัปโหลด PDF ทดแทน", "confirmCreate": "ยืนยันและสร้างงาน", "confirmPrompt": "การยืนยันจะตรึงฉบับร่างปัจจุบันและสร้างงานแยกหนึ่งงาน และจะไม่สามารถแก้ไขต่อได้ ต้องการดำเนินการต่อหรือไม่?"
}
}
+2 -1
View File
@@ -31,5 +31,6 @@
"unsorted": "คลิกเพื่อเรียงลำดับ",
"asc": "เรียงจากน้อยไปมาก คลิกเพื่อสลับ",
"desc": "เรียงจากมากไปน้อย คลิกเพื่อสลับ"
}
},
"required": "กรุณากรอกข้อมูลที่จำเป็น"
}
+36 -1
View File
@@ -41,6 +41,13 @@
"SHIPPING_ORDER_DOCUMENT_PROFILE_IMMUTABLE": "ไม่สามารถแก้ไขโปรไฟล์เอกสารคำสั่งซื้อที่เผยแพร่แล้ว",
"SHIPPING_ORDER_DOCUMENT_PROFILE_LOCK_VERSION_REQUIRED": "ไม่มีเวอร์ชันล็อกของโปรไฟล์ โปรดรีเฟรชแล้วลองใหม่",
"SHIPPING_ORDER_DOCUMENT_PROFILE_VERSION_CONFLICT": "ผู้ดูแลระบบรายอื่นแก้ไขโปรไฟล์แล้ว โปรดรีเฟรชแล้วลองใหม่",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_REQUIRED": "ต้องมีสัญญาเช่าการแก้ไขที่ยังใช้งานอยู่ โปรดรีเฟรชหรือเข้ารับช่วงฉบับร่างก่อน",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_CONFLICT": "ฉบับร่างนี้กำลังถูกแก้ไขในเซสชันเบราว์เซอร์อื่น",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LOCK_VERSION_CONFLICT": "ฉบับร่างบนเซิร์ฟเวอร์เปลี่ยนแล้ว โปรดรีเฟรชและแก้ไขข้อขัดแย้งก่อนบันทึก",
"SHIPPING.ORDER_DOCUMENT_PROFILE_REVISION_NOT_FOUND": "ไม่พบการแก้ไขฉบับร่างที่ร้องขอ",
"SHIPPING.ORDER_DOCUMENT_PROFILE_VALIDATION_STALE": "การตรวจสอบนี้ไม่ตรงกับฉบับร่างปัจจุบันแล้ว",
"SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_INVALID": "การตรวจสอบก่อนเผยแพร่ไม่ใช้ได้แล้ว โปรดตรวจสอบใหม่",
"SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_CONSUMED": "การตรวจสอบก่อนเผยแพร่นี้ถูกใช้ไปแล้ว",
"SHIPPING_ORDER_DOCUMENT_PROFILE_DRAFT_EXISTS": "โปรไฟล์เอกสารคำสั่งซื้อนี้มีฉบับร่างอยู่แล้ว",
"SHIPPING_ORDER_DOCUMENT_PROFILE_PUBLISH_INVALID": "ไม่สามารถเผยแพร่โปรไฟล์เอกสารคำสั่งซื้อปัจจุบัน",
"SHIPPING_ORDER_DOCUMENT_PROFILE_PUBLISH_GATE_TRAINING": "ต้องผูกตัวอย่างการฝึกอย่างน้อยหนึ่งรายการก่อนเผยแพร่",
@@ -343,6 +350,34 @@
"SHIPPING_CUSTOMER_IMPORT_PUBLISH_CONFLICT": "เกิดข้อขัดแย้งของข้อมูลระหว่างเผยแพร่",
"SHIPPING.ORDER_SCHEMA_PROFILE_IMPACT_CONFIRM_REQUIRED": "เวอร์ชันฟิลด์คำสั่งซื้อนี้มีผลต่อโปรไฟล์เอกสารที่มีอยู่ โปรดยืนยันผลกระทบก่อนเผยแพร่",
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_INVALID": "การกำหนดการย้ายฟิลด์ของโปรไฟล์เอกสารคำสั่งซื้อไม่ถูกต้อง",
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_REQUIRED": "โปรดจัดการฟิลด์ที่ได้รับผลกระทบทั้งหมดก่อนสร้างฉบับร่างการย้าย"
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_REQUIRED": "โปรดจัดการฟิลด์ที่ได้รับผลกระทบทั้งหมดก่อนสร้างฉบับร่างการย้าย",
"SHIPPING_REVIEW_CASE_NOT_FOUND": "ไม่พบรายการตรวจทานคำสั่งซื้อหรือไม่มีสิทธิ์เข้าถึง",
"SHIPPING_REVIEW_CASE_NOT_EDITABLE": "การตรวจทานคำสั่งซื้อนี้สิ้นสุดแล้วและแก้ไขไม่ได้",
"SHIPPING_REVIEW_DRAFT_VERSION_REQUIRED": "ต้องระบุเวอร์ชันร่างที่ถูกต้อง",
"SHIPPING_REVIEW_DRAFT_VERSION_MISMATCH": "ร่างถูกแก้ไขจากหน้าต่างอื่น โปรดรีเฟรชแล้วลองใหม่",
"SHIPPING_REVIEW_FIELD_INVALID": "ฟิลด์ตรวจทานไม่อยู่ใน Schema ที่ตรึงไว้ของคำสั่งซื้อนี้",
"SHIPPING_REVIEW_LINE_NOT_FOUND": "ไม่พบรายการคำสั่งซื้อหรือรายการถูกลบแล้ว",
"SHIPPING_REVIEW_DOCUMENT_NOT_FOUND": "ไม่พบ PDF สำหรับตรวจทานหรือไม่มีสิทธิ์เข้าถึง",
"SHIPPING_REVIEW_MANUAL_DRAFT_ALREADY_HAS_CANDIDATE": "PDF นี้มีคำสั่งซื้อจากระบบแล้ว จึงสร้างคำสั่งซื้อด้วยตนเองไม่ได้",
"SHIPPING_REVIEW_DRAFT_NOT_FOUND": "ไม่พบร่างคำสั่งซื้อ",
"SHIPPING_REVIEW_DISPOSITION_NOT_ALLOWED": "PDF นี้จัดการเสร็จแล้วและเปลี่ยนผลการจัดการไม่ได้",
"SHIPPING_REVIEW_NON_ORDER_REASON_INVALID": "เหตุผลที่ไม่ใช่คำสั่งซื้อไม่ถูกต้อง",
"SHIPPING_REVIEW_QUALITY_REASON_INVALID": "เหตุผลปัญหาคุณภาพไฟล์ไม่ถูกต้อง",
"SHIPPING_REVIEW_REPARSE_NOT_ALLOWED": "ไม่อนุญาตให้ระบุ PDF นี้ใหม่",
"SHIPPING_REVIEW_REPARSE_REASON_INVALID": "เหตุผลการระบุใหม่ไม่ถูกต้อง",
"SHIPPING_REVIEW_REPARSE_SOURCE_INVALID": "แหล่งข้อมูลสำหรับระบุ PDF นี้ใหม่ใช้งานไม่ได้",
"SHIPPING_REVIEW_REPARSE_PENDING": "PDF นี้กำลังระบุใหม่อยู่",
"SHIPPING_REVIEW_REPLACEMENT_NOT_ALLOWED": "ไม่สามารถใช้ไฟล์ทดแทนกับ PDF นี้ในขณะนี้",
"SHIPPING_REVIEW_REPLACEMENT_FILE_INVALID": "ไฟล์ทดแทนต้องเป็น PDF",
"SHIPPING_REVIEW_REPLACEMENT_NOT_FOUND": "ไม่พบรายการรับไฟล์ทดแทนหรือไม่มีสิทธิ์เข้าถึง",
"SHIPPING_REVIEW_REPLACEMENT_PENDING": "PDF ทดแทนกำลังแยกวิเคราะห์ โปรดลองอีกครั้งภายหลัง",
"SHIPPING_REVIEW_REPLACEMENT_DOCUMENT_INVALID": "ไฟล์ทดแทนต้องมี PDF เพียงหนึ่งไฟล์",
"SHIPPING_REVIEW_WARNING_ACK_INVALID": "ข้อมูลการยืนยันคำเตือนไม่ถูกต้อง",
"SHIPPING_REVIEW_CONFIRM_NOT_ALLOWED": "ไม่สามารถยืนยันการตรวจทานคำสั่งซื้อนี้ได้ในขณะนี้",
"SHIPPING_REVIEW_DUPLICATE_RESOLUTION_REQUIRED": "คำสั่งซื้อนี้อาจซ้ำกัน โปรดจัดการผ่านขั้นตอนคำสั่งซื้อซ้ำก่อน",
"SHIPPING_REVIEW_IDEMPOTENCY_KEY_REQUIRED": "คำขอยืนยันไม่มีคีย์ idempotency โปรดลองอีกครั้ง",
"SHIPPING_REVIEW_IDEMPOTENCY_KEY_CONFLICT": "คำขอยืนยันขัดแย้งกับคำขอเดิม โปรดรีเฟรชแล้วลองอีกครั้ง",
"SHIPPING_REVIEW_CONFIRM_VALIDATION_FAILED": "ฉบับร่างยังไม่ผ่านการตรวจสอบครบถ้วน จึงยืนยันไม่ได้",
"SHIPPING_REVIEW_CONFIRM_DOCUMENT_INVALID": "PDF สำหรับตรวจทานไม่พร้อมใช้งาน จึงยืนยันไม่ได้"
}
}
+8
View File
@@ -109,6 +109,14 @@
"selectCase": "เลือกงานทางซ้ายเพื่อดูรายละเอียด",
"loadFailed": "โหลดไม่สำเร็จ",
"openChat": "ดำเนินการต่อใน Chat",
"todo": {
"label": "งานที่ต้องทำตอนนี้",
"noActionTitle": "ยังไม่ต้องดำเนินการด้วยตนเอง",
"noActionMessage": "ระบบกำลังประมวลผลขั้นตอนถัดไป โปรดดูขั้นตอนการทำงานและบันทึกกิจกรรม",
"handleInChat": "{action} ใน Chat",
"workflow": "ขั้นตอนการทำงาน",
"orderOverview": "ภาพรวมคำสั่งซื้อ"
},
"download": "ดาวน์โหลด Excel",
"downloadBatch": "ดาวน์โหลด ZIP ของชุดงาน",
"selectAllVisible": "เลือกผลลัพธ์ปัจจุบันทั้งหมด",
+226 -1
View File
@@ -2512,8 +2512,30 @@
"enterOneField": "请至少输入一个要更新的字段",
"batchDeleteResult": "已删除 {count} 位用户。"
},
"orderProfileValidation": {
"eyebrow": "草稿验证",
"title": "验证订单文档模板",
"description": "运行摘要不包含 PDF、对象存储地址或盲测真值;草稿变更后历史运行将标记为过期。",
"backToEditor": "返回编辑器",
"instantCheck": "运行即时检查",
"currentSample": "试运行当前样本",
"loading": "正在加载验证运行...",
"run": "运行编号",
"type": "类型",
"status": "状态",
"summary": "安全摘要",
"time": "创建时间",
"empty": "尚无验证运行。",
"completed": "验证运行已完成。",
"failed": "验证运行失败。"
},
"orderProfilePublishCheck": {
"eyebrow": "发布门禁", "title": "确认发布订单文档模板", "description": "报告冻结草稿版本;草稿改变后报告自动失效。", "back": "返回", "selectRun": "选择通过的验证运行", "noRun": "当前草稿没有可用于发布的通过验证运行。", "create": "生成发布检查报告", "report": "报告 {reportNo}", "status": "状态:{status} · Revision {revision}", "blocking": "阻断项", "noBlocking": "无阻断项。", "warnings": "警告(必须逐项确认)", "confirm": "确认发布", "failed": "发布检查失败。"
},
"shippingOrderProfiles": {
"title": "订单文档模板",
"library": { "title": "订单文档模板", "subtitle": "管理模板族、草稿、已发布版本和历史查看。", "create": "创建模板", "search": "搜索模板", "status": "当前状态", "actions": "操作", "draft": "草稿", "published": "已发布 v{version}", "retired": "已退役", "loading": "正在加载模板...", "empty": "暂无模板。", "loadFailed": "加载模板失败。", "createFailed": "创建新版本草稿失败。" },
"wizard": { "title": "创建订单文档模板", "steps": "第 {step} 步,共 3 步", "codeHint": "创建后编码不可修改,用于路由、版本聚合和审计。", "selectSchema": "选择已发布 Schema", "previous": "上一步", "next": "下一步", "createDraft": "创建草稿", "createAndEdit": "创建并进入标注", "incomplete": "请先完成必填信息。", "loadFailed": "加载向导选项失败。", "uploadFailed": "上传模板样本失败。", "sampleHint": "上传或选择样本不会创建模板。", "tableLoadFailed": "加载样本表格失败。", "tableOption": "第 {page} 页 · {rows} 行 · {columns} 列", "noTable": "该样本没有可用表格,请选择其他已解析样本。", "createFailed": "模板草稿创建失败,未保留半成品。" },
"subtitle": "从 MinerU 表格样本可视化配置精确列映射;无需编辑 JSON 或结构指纹。",
"structureBlocked": "该表格结构异常,不能创建模板。请等待坐标证据重建后再复核,勿通过字段映射修复原始网格。",
"reconstructionRequired": "此表头混入明细,需先确认列边界并重建表格;重建结果必须人工审核。",
@@ -2616,6 +2638,209 @@
"compositePart": "复合客户/内部料号",
"previewEmpty": "请选择样本文档和表格查看预览",
"versions": "模板版本",
"versionCenter": {
"eyebrow": "模板版本中心",
"backToWorkbench": "返回模板工作台",
"continueEditing": "继续编辑",
"viewVersion": "查看版本",
"familyVersions": "版本导航",
"loading": "正在加载版本详情...",
"tabsLabel": "模板版本详情页签",
"tabs": {
"overview": "配置概览",
"canvas": "样本画布",
"diff": "版本差异",
"audit": "审计记录",
"usage": "实际使用"
},
"tabPlaceholders": {
"canvas": "样本画布会在阶段 4 接入,并严格基于冻结证据只读展示。",
"diff": "版本差异会在阶段 5 接入,由服务端提供稳定语义 diff。",
"audit": "审计记录会在阶段 6 接入,当前阶段只保留详情路由与概览。",
"usage": "实际使用会在阶段 6 接入,当前阶段只保留详情路由与概览。"
},
"diff": {
"title": "版本语义差异",
"subtitle": "仅比较同一模板族的结构化规则变化;不展示正文、对象存储地址或盲测真值。",
"compareTarget": "对比版本",
"defaultPrevious": "默认上一版本",
"initialVersion": "首个版本(与空基线比较)",
"comparedWith": "当前对比:{target}",
"loading": "正在加载版本差异...",
"loadFailed": "版本差异加载失败",
"noChanges": "当前版本与对比版本没有可展示的语义变化。",
"rawJson": "查看原始 JSON 快照",
"beforeSnapshot": "基线快照",
"afterSnapshot": "当前快照",
"empty": "空",
"orderChanged": "仅顺序变化",
"addedValues": "新增:{values}",
"removedValues": "移除:{values}",
"summary": {
"added": "新增 {count}",
"removed": "移除 {count}",
"modified": "修改 {count}",
"unchanged": "未变 {count}"
},
"changeType": {
"added": "新增",
"removed": "移除",
"modified": "修改",
"unchanged": "未变"
},
"entityType": {
"profile_meta": "模板治理",
"document_match": "文档匹配",
"table_region": "表格区域",
"header_layout": "表头布局",
"header_field_region": "表头字段区域",
"line_layout": "明细布局",
"line_field_region": "明细字段区域",
"termination_rule": "终止规则",
"exclusion_region": "排除区域",
"order_field_layout": "订单字段布局",
"sample_binding": "样本证据"
}
},
"audit": {
"title": "审计记录",
"subtitle": "按 request_id、事件类型、操作者和日期范围回放当前版本的治理操作。",
"eventType": "事件类型",
"actor": "操作者",
"requestId": "请求 ID",
"createdFrom": "开始日期",
"createdTo": "结束日期",
"apply": "筛选",
"reset": "重置",
"loading": "正在加载审计记录...",
"loadFailed": "审计记录加载失败",
"empty": "当前筛选条件下没有审计记录。",
"previous": "上一页",
"next": "下一页"
},
"usage": {
"title": "实际使用",
"subtitle": "只统计每个文档单元最新的模板分流事实,并可进入只读 Run 审计。",
"refresh": "刷新",
"loading": "正在加载实际使用...",
"loadFailed": "实际使用加载失败",
"empty": "当前版本还没有实际使用记录。",
"openDiagnostic": "查看运行审计",
"previous": "上一页",
"next": "下一页",
"yes": "是",
"no": "否",
"columns": {
"runNo": "Run 编号",
"document": "文档",
"matchStatus": "匹配状态",
"executionStatus": "执行状态",
"identityMode": "命中方式",
"autoCreateApproved": "自动完成",
"createdAt": "时间",
"reasonCodes": "失败/降级原因"
},
"runStatuses": {
"queued": "排队中",
"processing": "处理中",
"completed": "已完成",
"partially_completed": "部分完成",
"review_required": "待人工复核",
"failed": "失败",
"cancelled": "已取消"
},
"matchStatuses": {
"unique_match": "唯一命中",
"no_match": "未命中",
"ambiguous": "命中歧义",
"layout_drift": "版面漂移",
"evidence_insufficient": "证据不足"
},
"executionStatuses": {
"pending": "待处理",
"routing": "分流中",
"matching_profile": "匹配模板中",
"extracting": "提取中",
"merging_supplement": "补充合并中",
"candidate_ready": "候选已就绪",
"review_required": "待人工复核",
"failed": "失败",
"cancelled": "已取消"
},
"identityModes": {
"direct_profile_id": "直接外键命中",
"snapshot_identity_match": "冻结快照命中"
}
},
"status": {
"currentDraft": "当前草稿",
"currentPublished": "当前生效",
"retired": "已退役"
},
"schemaVersion": "Schema v",
"sampleCount": "样本 {count}",
"checksum": "模板校验和",
"schemaChecksum": "Schema 校验和",
"publishedAt": "发布时间",
"retiredAt": "退役时间",
"definitionStats": "配置规模",
"tableRegions": "表格区域",
"headerLayouts": "表头布局",
"lineLayouts": "明细行布局",
"orderFieldLayouts": "订单字段布局",
"frozenEvidenceTitle": "冻结证据",
"statusLabel": "状态",
"sampleCountPlain": "样本数",
"frozenSampleCount": "已冻结样本",
"auditReady": "可审计",
"readonlyCanvasBadge": "只读画布",
"loadingCanvas": "正在加载只读画布...",
"canvasLoadFailed": "只读画布加载失败",
"draftCanvasHint": "草稿版本请回到模板工作台继续编辑;版本详情页的样本画布仅用于冻结证据只读复核。",
"noReadableSamples": "当前版本没有可进入普通只读画布的 annotation/training 样本。",
"readonlySample": "只读样本",
"sampleFrozenEvidenceMissing": "该样本缺少完整冻结证据,系统不会降级读取当前文档或最新 layout。",
"frozenEvidencePanelTitle": "冻结证据面板",
"selectSampleHint": "请选择一个冻结样本查看证据。",
"sampleFile": "样本文件",
"layoutVersionId": "布局版本 ID",
"evidenceFrozenAt": "冻结时间",
"pageCountPlain": "页数",
"parserIdentity": "解析器身份",
"parserVersionTitle": "解析器版本",
"frozenTableId": "冻结表格 ID",
"frozenPageNo": "冻结页码",
"frozenRowCount": "冻结行数",
"layoutChecksumTitle": "布局校验和",
"contentHashTitle": "文件哈希",
"regionSummaryTitle": "区域摘要",
"selectRegionHint": "点击画布上的区域查看绑定摘要。",
"regionLabelTitle": "区域标签",
"regionKindTitle": "区域类型",
"regionFieldCodeTitle": "字段编码",
"regionPageTitle": "所属页",
"sampleSummaryTitle": "样本摘要",
"annotationCount": "标注样本",
"trainingCount": "训练样本",
"blindTestCount": "盲测样本",
"firstSample": "首个样本",
"testSummaryTitle": "测试摘要",
"approvedAt": "批准时间",
"latestRun": "最近运行",
"sourceVersionTitle": "来源版本",
"noSourceVersion": "该版本不是从历史版本复制而来。",
"frozenEvidence": {
"pending": "待补齐",
"ready": "已冻结",
"missing": "缺失"
},
"testStatus": {
"missing": "未建立",
"draft": "草稿",
"approved": "已批准",
"superseded": "已失效"
}
},
"currentVersion": "当前生效",
"publishedAt": "发布时间:{time}",
"publish": "发布",
@@ -2675,7 +2900,7 @@
},
"workbench": {
"boundHistoricalSchema": "已绑定历史版本",
"intro": "在受控文档页面拖拽证据区域;保存定义不含 HTML 或存储地址。",
"intro": "在受控文档页面拖拽证据区域;保存定义不含 HTML 或存储地址。", "structure": "结构", "saveStatus": { "saved": "已保存", "saving": "正在保存", "failed": "保存失败,将保留本地修改", "readonly": "只读:编辑租约已失效" }, "exportLocalDraft": "导出本地草稿", "recoverLease": "重新获取租约", "takeOverLease": "确认接管租约", "suggestionReadyForDecision": "建议已生成,请确认决定", "acceptSuggestion": "接受", "acceptAdjustedSuggestion": "调整后接受", "rejectSuggestion": "拒绝", "suggestionAdjustmentField": "选择替代字段",
"openCanvas": "创建草稿并打开画布",
"loadingPage": "正在加载页面…",
"canvasZoom": "页面缩放",
+11
View File
@@ -130,6 +130,7 @@
"shippingCandidateReviewRequired": "仍有已选订单候选需要审核,请先修订冲突字段。",
"shippingCandidateSelectRequired": "请至少选择一个订单候选后再确认建单。",
"shippingOrderExtractionDefaultPrompt": "请完整解析已上传邮件及附件中的发货订单,并按规则自动建单。",
"shippingOrderExtractionDefaultUserMessage": "请识别并提取附件中的订单信息。",
"shippingOrderExtractionCardTitle": {
"queued": "订单解析排队中",
"processing": "订单解析处理中",
@@ -168,10 +169,17 @@
"shippingOrderExtractionDocumentsLoading": "正在加载 PDF 处理结果...",
"shippingOrderExtractionDocumentsUnavailable": "暂时无法加载 PDF 处理结果,请稍后再试。",
"shippingOrderExtractionNoDocuments": "暂未返回 PDF 结果。",
"shippingOrderExtractionDocumentTiming": {
"started": "开始于 {time}",
"updated": "更新于 {time}",
"finished": "完成于 {time}"
},
"shippingOrderExtractionUnknownDocument": "未命名 PDF",
"shippingOrderExtractionUnread": "有 {count} 条订单识别结果待查看",
"shippingOrderExtractionActivity": {
"plan_created": "识别计划已创建,正在准备首轮附件。",
"layout_parsing_started": "正在解析订单附件版面,完成后将自动开始识别。",
"layout_parsing_completed": "附件解析完成,正在开始订单识别。",
"initial_wave_started": "系统已开始分析首轮附件。",
"expansion_wave_started": "系统已开始分析下一轮候选附件。",
"document_queued": "后台已接收附件,等待 Worker 处理。",
@@ -1158,5 +1166,8 @@
"explanation": "产品要求必须同时覆盖法规和客户要求,这是质量体系基础。"
}
]
},
"shippingOrderReview": {
"title": "订单人工复核", "run": "识别批次 {runNo}", "back": "返回对话", "readOnly": "只读预览", "loading": "正在加载复核结果...", "unavailable": "暂时无法加载复核结果,请稍后重试。", "documentNavigation": "PDF 导航", "documents": "PDF 文件", "unnamedDocument": "未命名 PDF", "caseStatus": "{status} · {count} 个问题", "previewTitle": "PDF 预览", "previewLoading": "正在加载 PDF 预览...", "previewUnavailable": "PDF 预览不可用,草稿编辑不受影响。", "evidenceSummary": "选择字段旁的定位图标可查看证据。", "evidenceAt": "PDF 第 {page} 页", "evidenceNoHighlight": "该证据没有可靠坐标,仅提供页码与引文,不显示虚假高亮。", "viewEvidence": "查看证据", "orderFields": "订单字段", "schemaVersion": "冻结 Schema #{version}", "issues": "待处理问题", "machineSource": "来源:机器识别", "manualSource": "来源:人工修改", "restoreMachine": "恢复机器值", "saved": "已保存", "saving": "保存中", "saveFailed": "保存失败", "saveNow": "立即保存并校验", "addLine": "新增行", "copyLine": "复制行", "deleteLine": "删除行", "noMachineOrder": "未识别到可信订单。", "lines": "订单明细", "line": "第 {index} 行", "noLines": "未识别到订单明细。", "moreFields": "更多订单信息({count})", "emptyValue": "未提供", "unknownField": "订单字段", "createManualDraft": "手工创建订单草稿", "markNonOrder": "标记为非订单", "markQualityIssue": "文件质量异常", "reparse": "重新识别此 PDF", "uploadReplacement": "上传替代 PDF", "confirmCreate": "确认并创建任务", "confirmPrompt": "确认后将冻结当前草稿并创建独立任务,且不能继续编辑。是否继续?"
}
}
+2 -1
View File
@@ -31,5 +31,6 @@
"unsorted": "点击排序",
"asc": "升序,点击切换为降序",
"desc": "降序,点击切换为升序"
}
},
"required": "请填写必填项"
}
+36 -1
View File
@@ -41,6 +41,13 @@
"SHIPPING_ORDER_DOCUMENT_PROFILE_IMMUTABLE": "已发布的订单文档解析模板不可修改。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_LOCK_VERSION_REQUIRED": "订单文档解析模板缺少版本锁,请刷新后重试。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_VERSION_CONFLICT": "订单文档解析模板已被其他管理员修改,请刷新后重试。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_REQUIRED": "需要有效的编辑租约,请先刷新或接管草稿。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_CONFLICT": "该草稿正在由另一个浏览器会话编辑。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LOCK_VERSION_CONFLICT": "服务端草稿已变更,请刷新并解决冲突后再保存。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_REVISION_NOT_FOUND": "未找到请求的草稿修订版本。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_VALIDATION_STALE": "该验证运行已不匹配当前草稿。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_INVALID": "发布检查已失效,请重新执行检查。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_CONSUMED": "该发布检查已被使用。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_DRAFT_EXISTS": "该订单文档解析模板已有草稿版本。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_PUBLISH_INVALID": "当前订单文档解析模板不能发布。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_PUBLISH_GATE_TRAINING": "发布前必须至少绑定一个训练样本。",
@@ -343,6 +350,34 @@
"SHIPPING_CUSTOMER_IMPORT_PUBLISH_CONFLICT": "发布导入批次时发生数据冲突。",
"SHIPPING.ORDER_SCHEMA_PROFILE_IMPACT_CONFIRM_REQUIRED": "订单字段版本会影响现有文档模板,请确认影响后再发布。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_INVALID": "订单文档模板字段迁移配置无效。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_REQUIRED": "请处理全部受影响字段后再创建迁移草稿。"
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_REQUIRED": "请处理全部受影响字段后再创建迁移草稿。",
"SHIPPING_REVIEW_CASE_NOT_FOUND": "订单复核对象不存在或无权访问。",
"SHIPPING_REVIEW_CASE_NOT_EDITABLE": "该订单复核已结束,不能再编辑。",
"SHIPPING_REVIEW_DRAFT_VERSION_REQUIRED": "缺少有效的草稿版本号。",
"SHIPPING_REVIEW_DRAFT_VERSION_MISMATCH": "草稿已被其他窗口更新,请刷新后重试。",
"SHIPPING_REVIEW_FIELD_INVALID": "复核字段不属于该订单的冻结模板。",
"SHIPPING_REVIEW_LINE_NOT_FOUND": "订单明细行不存在或已被删除。",
"SHIPPING_REVIEW_DOCUMENT_NOT_FOUND": "复核 PDF 不存在或无权访问。",
"SHIPPING_REVIEW_MANUAL_DRAFT_ALREADY_HAS_CANDIDATE": "该 PDF 已有机器订单,不能再创建手工订单。",
"SHIPPING_REVIEW_DRAFT_NOT_FOUND": "订单草稿不存在。",
"SHIPPING_REVIEW_DISPOSITION_NOT_ALLOWED": "该 PDF 已完成处理,不能再变更处置。",
"SHIPPING_REVIEW_NON_ORDER_REASON_INVALID": "非订单原因无效。",
"SHIPPING_REVIEW_QUALITY_REASON_INVALID": "文件质量异常原因无效。",
"SHIPPING_REVIEW_REPARSE_NOT_ALLOWED": "该 PDF 不允许重新识别。",
"SHIPPING_REVIEW_REPARSE_REASON_INVALID": "重新识别原因无效。",
"SHIPPING_REVIEW_REPARSE_SOURCE_INVALID": "当前 PDF 的重新识别来源不可用。",
"SHIPPING_REVIEW_REPARSE_PENDING": "该 PDF 正在重新识别。",
"SHIPPING_REVIEW_REPLACEMENT_NOT_ALLOWED": "该 PDF 当前不能上传或使用替代文件。",
"SHIPPING_REVIEW_REPLACEMENT_FILE_INVALID": "替代文件必须是 PDF。",
"SHIPPING_REVIEW_REPLACEMENT_NOT_FOUND": "替代文件接入记录不存在或无权访问。",
"SHIPPING_REVIEW_REPLACEMENT_PENDING": "替代 PDF 仍在解析,请稍后重试。",
"SHIPPING_REVIEW_REPLACEMENT_DOCUMENT_INVALID": "替代文件必须且只能包含一份 PDF。",
"SHIPPING_REVIEW_WARNING_ACK_INVALID": "警告确认内容无效。",
"SHIPPING_REVIEW_CONFIRM_NOT_ALLOWED": "该订单复核当前不能确认建单。",
"SHIPPING_REVIEW_DUPLICATE_RESOLUTION_REQUIRED": "订单存在重复风险,请先按重复订单流程处理。",
"SHIPPING_REVIEW_IDEMPOTENCY_KEY_REQUIRED": "确认建单缺少幂等键,请重试。",
"SHIPPING_REVIEW_IDEMPOTENCY_KEY_CONFLICT": "确认请求冲突,请刷新后重试。",
"SHIPPING_REVIEW_CONFIRM_VALIDATION_FAILED": "草稿尚未通过完整校验,不能确认建单。",
"SHIPPING_REVIEW_CONFIRM_DOCUMENT_INVALID": "复核 PDF 已不可用,不能确认建单。"
}
}
@@ -169,6 +169,14 @@
"selectCase": "选择左侧任务查看详情",
"loadFailed": "加载失败",
"openChat": "在 Chat 中继续",
"todo": {
"label": "当前待办",
"noActionTitle": "当前无需人工操作",
"noActionMessage": "系统正在处理后续步骤,请查看流程和处理记录。",
"handleInChat": "在 Chat 中{action}",
"workflow": "处理流程",
"orderOverview": "订单概览"
},
"download": "下载 Excel",
"downloadBatch": "下载本批次 ZIP",
"selectAllVisible": "全选当前结果",
+226 -1
View File
@@ -2402,8 +2402,30 @@
"enterOneField": "請至少輸入一個要更新的字段",
"batchDeleteResult": "已刪除 {count} 位用戶。"
},
"orderProfileValidation": {
"eyebrow": "草稿驗證",
"title": "驗證訂單文件範本",
"description": "執行摘要不包含 PDF、物件儲存位址或盲測真值;草稿變更後歷史執行將標示為過期。",
"backToEditor": "返回編輯器",
"instantCheck": "執行即時檢查",
"currentSample": "試執行目前樣本",
"loading": "正在載入驗證執行...",
"run": "執行編號",
"type": "類型",
"status": "狀態",
"summary": "安全摘要",
"time": "建立時間",
"empty": "尚無驗證執行。",
"completed": "驗證執行已完成。",
"failed": "驗證執行失敗。"
},
"orderProfilePublishCheck": {
"eyebrow": "發布閘門", "title": "確認發布訂單文件範本", "description": "報告會凍結草稿版本;草稿變更後報告自動失效。", "back": "返回", "selectRun": "選擇通過的驗證執行", "noRun": "目前草稿沒有可供發布的通過驗證執行。", "create": "建立發布檢查報告", "report": "報告 {reportNo}", "status": "狀態:{status} · Revision {revision}", "blocking": "阻斷項", "noBlocking": "無阻斷項。", "warnings": "警告(必須逐項確認)", "confirm": "確認發布", "failed": "發布檢查失敗。"
},
"shippingOrderProfiles": {
"title": "訂單文件範本",
"library": { "title": "訂單文件範本", "subtitle": "管理範本族、草稿、已發布版本與歷史檢視。", "create": "建立範本", "search": "搜尋範本", "status": "目前狀態", "actions": "操作", "draft": "草稿", "published": "已發布 v{version}", "retired": "已退役", "loading": "正在載入範本...", "empty": "沒有範本。", "loadFailed": "載入範本失敗。", "createFailed": "建立新版本草稿失敗。" },
"wizard": { "title": "建立訂單文件範本", "steps": "第 {step} 步,共 3 步", "codeHint": "建立後編碼不可修改,用於路由、版本彙整與稽核。", "selectSchema": "選擇已發布 Schema", "previous": "上一步", "next": "下一步", "createDraft": "建立草稿", "createAndEdit": "建立並進入標註", "incomplete": "請先完成必填資訊。", "loadFailed": "載入精靈選項失敗。", "uploadFailed": "上傳範本樣本失敗。", "sampleHint": "上傳或選擇樣本不會建立範本。", "tableLoadFailed": "載入樣本表格失敗。", "tableOption": "第 {page} 頁 · {rows} 列 · {columns} 欄", "noTable": "此樣本沒有可用表格,請選擇其他已解析樣本。", "createFailed": "範本草稿建立失敗,未保留半成品。" },
"subtitle": "從 MinerU 表格樣本視覺化設定精確欄位對應;無需編輯 JSON 或結構指紋。",
"structureBlocked": "此表格結構異常,不能建立範本。請等待座標證據重建後再複核,勿以欄位對應修復原始網格。",
"reconstructionRequired": "此表頭混入明細,需先確認欄位邊界並重建表格;重建結果必須人工複核。",
@@ -2506,6 +2528,209 @@
"compositePart": "複合客戶/內部料號",
"previewEmpty": "請選擇樣本文件和表格查看預覽",
"versions": "範本版本",
"versionCenter": {
"eyebrow": "範本版本中心",
"backToWorkbench": "返回範本工作台",
"continueEditing": "繼續編輯",
"viewVersion": "查看版本",
"familyVersions": "版本導覽",
"loading": "正在載入版本詳情...",
"tabsLabel": "範本版本詳情頁籤",
"tabs": {
"overview": "設定概覽",
"canvas": "樣本畫布",
"diff": "版本差異",
"audit": "審計記錄",
"usage": "實際使用"
},
"tabPlaceholders": {
"canvas": "樣本畫布將於階段 4 接入,並嚴格依凍結證據做唯讀展示。",
"diff": "版本差異將於階段 5 接入,由服務端提供穩定語義 diff。",
"audit": "審計記錄將於階段 6 接入,當前階段只保留詳情路由與概覽。",
"usage": "實際使用將於階段 6 接入,當前階段只保留詳情路由與概覽。"
},
"diff": {
"title": "版本語義差異",
"subtitle": "只比較同一範本族內的結構化規則變化;不展示正文、物件儲存位址或盲測真值。",
"compareTarget": "對比版本",
"defaultPrevious": "預設上一版本",
"initialVersion": "首個版本(與空白基線比較)",
"comparedWith": "目前對比:{target}",
"loading": "正在載入版本差異...",
"loadFailed": "版本差異載入失敗",
"noChanges": "目前版本與對比版本沒有可展示的語義變化。",
"rawJson": "查看原始 JSON 快照",
"beforeSnapshot": "基線快照",
"afterSnapshot": "目前快照",
"empty": "空",
"orderChanged": "僅順序變化",
"addedValues": "新增:{values}",
"removedValues": "移除:{values}",
"summary": {
"added": "新增 {count}",
"removed": "移除 {count}",
"modified": "修改 {count}",
"unchanged": "未變 {count}"
},
"changeType": {
"added": "新增",
"removed": "移除",
"modified": "修改",
"unchanged": "未變"
},
"entityType": {
"profile_meta": "範本治理",
"document_match": "文件匹配",
"table_region": "表格區域",
"header_layout": "表頭版面",
"header_field_region": "表頭欄位區域",
"line_layout": "明細版面",
"line_field_region": "明細欄位區域",
"termination_rule": "終止規則",
"exclusion_region": "排除區域",
"order_field_layout": "訂單欄位版面",
"sample_binding": "樣本證據"
}
},
"audit": {
"title": "審計記錄",
"subtitle": "依 request_id、事件類型、操作者與日期範圍回放目前版本的治理操作。",
"eventType": "事件類型",
"actor": "操作者",
"requestId": "請求 ID",
"createdFrom": "開始日期",
"createdTo": "結束日期",
"apply": "篩選",
"reset": "重置",
"loading": "正在載入審計記錄...",
"loadFailed": "審計記錄載入失敗",
"empty": "目前篩選條件下沒有審計記錄。",
"previous": "上一頁",
"next": "下一頁"
},
"usage": {
"title": "實際使用",
"subtitle": "只統計每個文件單元最新的模板分流事實,並可進入唯讀 Run 審計。",
"refresh": "重新整理",
"loading": "正在載入實際使用...",
"loadFailed": "實際使用載入失敗",
"empty": "目前版本尚無實際使用紀錄。",
"openDiagnostic": "查看執行審計",
"previous": "上一頁",
"next": "下一頁",
"yes": "是",
"no": "否",
"columns": {
"runNo": "Run 編號",
"document": "文件",
"matchStatus": "匹配狀態",
"executionStatus": "執行狀態",
"identityMode": "命中方式",
"autoCreateApproved": "自動完成",
"createdAt": "時間",
"reasonCodes": "失敗/降級原因"
},
"runStatuses": {
"queued": "排隊中",
"processing": "處理中",
"completed": "已完成",
"partially_completed": "部分完成",
"review_required": "待人工複核",
"failed": "失敗",
"cancelled": "已取消"
},
"matchStatuses": {
"unique_match": "唯一命中",
"no_match": "未命中",
"ambiguous": "命中歧義",
"layout_drift": "版面漂移",
"evidence_insufficient": "證據不足"
},
"executionStatuses": {
"pending": "待處理",
"routing": "分流中",
"matching_profile": "匹配模板中",
"extracting": "提取中",
"merging_supplement": "補充合併中",
"candidate_ready": "候選已就緒",
"review_required": "待人工複核",
"failed": "失敗",
"cancelled": "已取消"
},
"identityModes": {
"direct_profile_id": "直接外鍵命中",
"snapshot_identity_match": "凍結快照命中"
}
},
"status": {
"currentDraft": "當前草稿",
"currentPublished": "當前生效",
"retired": "已退役"
},
"schemaVersion": "Schema v",
"sampleCount": "樣本 {count}",
"checksum": "範本校驗和",
"schemaChecksum": "Schema 校驗和",
"publishedAt": "發布時間",
"retiredAt": "退役時間",
"definitionStats": "設定規模",
"tableRegions": "表格區域",
"headerLayouts": "表頭版面",
"lineLayouts": "明細行版面",
"orderFieldLayouts": "訂單欄位版面",
"frozenEvidenceTitle": "凍結證據",
"statusLabel": "狀態",
"sampleCountPlain": "樣本數",
"frozenSampleCount": "已凍結樣本",
"auditReady": "可審計",
"readonlyCanvasBadge": "唯讀畫布",
"loadingCanvas": "正在載入唯讀畫布...",
"canvasLoadFailed": "唯讀畫布載入失敗",
"draftCanvasHint": "草稿版本請回到範本工作台繼續編輯;版本詳情頁的樣本畫布僅用於凍結證據唯讀複核。",
"noReadableSamples": "當前版本沒有可進入普通唯讀畫布的 annotation/training 樣本。",
"readonlySample": "唯讀樣本",
"sampleFrozenEvidenceMissing": "此樣本缺少完整凍結證據,系統不會降級讀取當前文件或最新 layout。",
"frozenEvidencePanelTitle": "凍結證據面板",
"selectSampleHint": "請選擇一個凍結樣本查看證據。",
"sampleFile": "樣本文件",
"layoutVersionId": "版面版本 ID",
"evidenceFrozenAt": "凍結時間",
"pageCountPlain": "頁數",
"parserIdentity": "解析器身份",
"parserVersionTitle": "解析器版本",
"frozenTableId": "凍結表格 ID",
"frozenPageNo": "凍結頁碼",
"frozenRowCount": "凍結列數",
"layoutChecksumTitle": "版面校驗和",
"contentHashTitle": "文件雜湊",
"regionSummaryTitle": "區域摘要",
"selectRegionHint": "點擊畫布上的區域查看綁定摘要。",
"regionLabelTitle": "區域標籤",
"regionKindTitle": "區域類型",
"regionFieldCodeTitle": "欄位編碼",
"regionPageTitle": "所屬頁",
"sampleSummaryTitle": "樣本摘要",
"annotationCount": "標註樣本",
"trainingCount": "訓練樣本",
"blindTestCount": "盲測樣本",
"firstSample": "首個樣本",
"testSummaryTitle": "測試摘要",
"approvedAt": "批准時間",
"latestRun": "最近執行",
"sourceVersionTitle": "來源版本",
"noSourceVersion": "此版本不是從歷史版本複製而來。",
"frozenEvidence": {
"pending": "待補齊",
"ready": "已凍結",
"missing": "缺失"
},
"testStatus": {
"missing": "未建立",
"draft": "草稿",
"approved": "已批准",
"superseded": "已失效"
}
},
"currentVersion": "目前生效",
"publishedAt": "發布時間:{time}",
"publish": "發布",
@@ -2565,7 +2790,7 @@
},
"workbench": {
"boundHistoricalSchema": "已綁定歷史版本",
"intro": "在受控文件頁面拖曳證據區域;儲存定義不含 HTML 或儲存位址。",
"intro": "在受控文件頁面拖曳證據區域;儲存定義不含 HTML 或儲存位址。", "structure": "結構", "saveStatus": { "saved": "已儲存", "saving": "正在儲存", "failed": "儲存失敗,將保留本機修改", "readonly": "唯讀:編輯租約已失效" }, "exportLocalDraft": "匯出本機草稿", "recoverLease": "重新取得租約", "takeOverLease": "確認接管租約", "suggestionReadyForDecision": "建議已產生,請確認決定", "acceptSuggestion": "接受", "acceptAdjustedSuggestion": "調整後接受", "rejectSuggestion": "拒絕", "suggestionAdjustmentField": "選擇替代欄位",
"openCanvas": "建立草稿並開啟畫布",
"loadingPage": "正在載入頁面…",
"canvasZoom": "頁面縮放",
+11
View File
@@ -130,6 +130,7 @@
"shippingCandidateReviewRequired": "仍有已選訂單候選需要審核,請先修訂衝突欄位。",
"shippingCandidateSelectRequired": "請至少選擇一個訂單候選後再確認建單。",
"shippingOrderExtractionDefaultPrompt": "請完整解析已上傳郵件及附件中的發貨訂單,並依規則自動建單。",
"shippingOrderExtractionDefaultUserMessage": "請識別並擷取附件中的訂單資訊。",
"shippingOrderExtractionCardTitle": {
"queued": "訂單解析排隊中",
"processing": "訂單解析處理中",
@@ -168,10 +169,17 @@
"shippingOrderExtractionDocumentsLoading": "正在載入 PDF 處理結果...",
"shippingOrderExtractionDocumentsUnavailable": "暫時無法載入 PDF 處理結果,請稍後再試。",
"shippingOrderExtractionNoDocuments": "暫未返回 PDF 結果。",
"shippingOrderExtractionDocumentTiming": {
"started": "開始於 {time}",
"updated": "更新於 {time}",
"finished": "完成於 {time}"
},
"shippingOrderExtractionUnknownDocument": "未命名 PDF",
"shippingOrderExtractionUnread": "有 {count} 項訂單識別結果待查看",
"shippingOrderExtractionActivity": {
"plan_created": "識別計劃已建立,正在準備首輪附件。",
"layout_parsing_started": "正在解析訂單附件版面,完成後將自動開始識別。",
"layout_parsing_completed": "附件解析完成,正在開始訂單識別。",
"initial_wave_started": "系統已開始分析首輪附件。",
"expansion_wave_started": "系統已開始分析下一輪候選附件。",
"document_queued": "後台已接收附件,等待 Worker 處理。",
@@ -1080,5 +1088,8 @@
{ "id": "q19", "type": "boolean", "prompt": "對於外來文件,組織不需對其進行控制與管理。", "answer": "false", "explanation": "外來文件同樣需要受控管理,確保版本與使用正確。" },
{ "id": "q20", "type": "boolean", "prompt": "與產品有關的要求應包括有關法律法規規定的要求及顧客的要求等。", "answer": "true", "explanation": "產品要求必須同時覆蓋法規和客戶要求,這是品質體系基礎。" }
]
},
"shippingOrderReview": {
"title": "訂單人工覆核", "run": "識別批次 {runNo}", "back": "返回對話", "readOnly": "唯讀預覽", "loading": "正在載入覆核結果...", "unavailable": "暫時無法載入覆核結果,請稍後再試。", "documentNavigation": "PDF 導覽", "documents": "PDF 檔案", "unnamedDocument": "未命名 PDF", "caseStatus": "{status} · {count} 個問題", "previewTitle": "PDF 預覽", "previewLoading": "正在載入 PDF 預覽...", "previewUnavailable": "PDF 預覽不可用,草稿編輯不受影響。", "evidenceSummary": "選擇欄位旁的定位圖示即可查看證據。", "evidenceAt": "PDF 第 {page} 頁", "evidenceNoHighlight": "此證據沒有可靠座標,僅提供頁碼與引文,不顯示虛假高亮。", "viewEvidence": "查看證據", "orderFields": "訂單欄位", "schemaVersion": "凍結 Schema #{version}", "issues": "待處理問題", "machineSource": "來源:機器識別", "manualSource": "來源:人工修改", "restoreMachine": "恢復機器值", "saved": "已儲存", "saving": "儲存中", "saveFailed": "儲存失敗", "saveNow": "立即儲存並驗證", "addLine": "新增行", "copyLine": "複製行", "deleteLine": "刪除行", "noMachineOrder": "未識別到可信訂單。", "lines": "訂單明細", "line": "第 {index} 行", "noLines": "未識別到訂單明細。", "moreFields": "更多訂單資訊({count})", "emptyValue": "未提供", "unknownField": "訂單欄位", "createManualDraft": "手動建立訂單草稿", "markNonOrder": "標記為非訂單", "markQualityIssue": "檔案品質異常", "reparse": "重新識別此 PDF", "uploadReplacement": "上傳替代 PDF", "confirmCreate": "確認並建立任務", "confirmPrompt": "確認後將凍結目前草稿並建立獨立任務,且無法繼續編輯。是否繼續?"
}
}
+2 -1
View File
@@ -31,5 +31,6 @@
"unsorted": "點擊排序",
"asc": "升序,點擊切換為降序",
"desc": "降序,點擊切換為升序"
}
},
"required": "請填寫必填欄位"
}
+36 -1
View File
@@ -41,6 +41,13 @@
"SHIPPING_ORDER_DOCUMENT_PROFILE_IMMUTABLE": "已發布的訂單文件解析範本不可修改。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_LOCK_VERSION_REQUIRED": "訂單文件解析範本缺少版本鎖,請重新整理後再試。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_VERSION_CONFLICT": "訂單文件解析範本已被其他管理員修改,請重新整理後再試。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_REQUIRED": "需要有效的編輯租約,請先重新整理或接管草稿。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LEASE_CONFLICT": "此草稿正在由另一個瀏覽器工作階段編輯。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_LOCK_VERSION_CONFLICT": "伺服器草稿已變更,請重新整理並解決衝突後再儲存。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_REVISION_NOT_FOUND": "找不到要求的草稿修訂版本。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_VALIDATION_STALE": "此驗證執行已不符合目前草稿。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_INVALID": "發布檢查已失效,請重新執行檢查。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_PUBLISH_CHECK_CONSUMED": "此發布檢查已被使用。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_DRAFT_EXISTS": "此訂單文件解析範本已有草稿版本。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_PUBLISH_INVALID": "目前訂單文件解析範本不能發布。",
"SHIPPING_ORDER_DOCUMENT_PROFILE_PUBLISH_GATE_TRAINING": "發布前必須至少綁定一個訓練樣本。",
@@ -343,6 +350,34 @@
"SHIPPING_CUSTOMER_IMPORT_PUBLISH_CONFLICT": "發佈匯入批次時發生資料衝突。",
"SHIPPING.ORDER_SCHEMA_PROFILE_IMPACT_CONFIRM_REQUIRED": "訂單欄位版本會影響現有文件範本,請確認影響後再發布。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_INVALID": "訂單文件範本欄位遷移設定無效。",
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_REQUIRED": "請處理全部受影響欄位後再建立遷移草稿。"
"SHIPPING.ORDER_DOCUMENT_PROFILE_MIGRATION_REQUIRED": "請處理全部受影響欄位後再建立遷移草稿。",
"SHIPPING_REVIEW_CASE_NOT_FOUND": "訂單覆核物件不存在或無權存取。",
"SHIPPING_REVIEW_CASE_NOT_EDITABLE": "此訂單覆核已結束,不能再編輯。",
"SHIPPING_REVIEW_DRAFT_VERSION_REQUIRED": "缺少有效的草稿版本號。",
"SHIPPING_REVIEW_DRAFT_VERSION_MISMATCH": "草稿已被其他視窗更新,請重新整理後再試。",
"SHIPPING_REVIEW_FIELD_INVALID": "覆核欄位不屬於此訂單的凍結範本。",
"SHIPPING_REVIEW_LINE_NOT_FOUND": "訂單明細行不存在或已被刪除。",
"SHIPPING_REVIEW_DOCUMENT_NOT_FOUND": "覆核 PDF 不存在或無權存取。",
"SHIPPING_REVIEW_MANUAL_DRAFT_ALREADY_HAS_CANDIDATE": "此 PDF 已有機器訂單,不能再建立手動訂單。",
"SHIPPING_REVIEW_DRAFT_NOT_FOUND": "訂單草稿不存在。",
"SHIPPING_REVIEW_DISPOSITION_NOT_ALLOWED": "此 PDF 已完成處理,不能再變更處置。",
"SHIPPING_REVIEW_NON_ORDER_REASON_INVALID": "非訂單原因無效。",
"SHIPPING_REVIEW_QUALITY_REASON_INVALID": "檔案品質異常原因無效。",
"SHIPPING_REVIEW_REPARSE_NOT_ALLOWED": "此 PDF 不允許重新識別。",
"SHIPPING_REVIEW_REPARSE_REASON_INVALID": "重新識別原因無效。",
"SHIPPING_REVIEW_REPARSE_SOURCE_INVALID": "目前 PDF 的重新識別來源不可用。",
"SHIPPING_REVIEW_REPARSE_PENDING": "此 PDF 正在重新識別。",
"SHIPPING_REVIEW_REPLACEMENT_NOT_ALLOWED": "此 PDF 目前不能上傳或使用替代檔案。",
"SHIPPING_REVIEW_REPLACEMENT_FILE_INVALID": "替代檔案必須是 PDF。",
"SHIPPING_REVIEW_REPLACEMENT_NOT_FOUND": "替代檔案接入記錄不存在或無權存取。",
"SHIPPING_REVIEW_REPLACEMENT_PENDING": "替代 PDF 仍在解析,請稍後再試。",
"SHIPPING_REVIEW_REPLACEMENT_DOCUMENT_INVALID": "替代檔案必須且只能包含一份 PDF。",
"SHIPPING_REVIEW_WARNING_ACK_INVALID": "警告確認內容無效。",
"SHIPPING_REVIEW_CONFIRM_NOT_ALLOWED": "此訂單覆核目前不能確認建單。",
"SHIPPING_REVIEW_DUPLICATE_RESOLUTION_REQUIRED": "訂單存在重複風險,請先依重複訂單流程處理。",
"SHIPPING_REVIEW_IDEMPOTENCY_KEY_REQUIRED": "確認建單缺少冪等鍵,請重試。",
"SHIPPING_REVIEW_IDEMPOTENCY_KEY_CONFLICT": "確認請求衝突,請重新整理後再試。",
"SHIPPING_REVIEW_CONFIRM_VALIDATION_FAILED": "草稿尚未通過完整驗證,不能確認建單。",
"SHIPPING_REVIEW_CONFIRM_DOCUMENT_INVALID": "覆核 PDF 已不可用,不能確認建單。"
}
}
@@ -169,6 +169,14 @@
"selectCase": "選擇左側任務查看詳情",
"loadFailed": "載入失敗",
"openChat": "在 Chat 中繼續",
"todo": {
"label": "目前待辦",
"noActionTitle": "目前無需人工操作",
"noActionMessage": "系統正在處理後續步驟,請查看流程和處理記錄。",
"handleInChat": "在 Chat 中{action}",
"workflow": "處理流程",
"orderOverview": "訂單概覽"
},
"download": "下載 Excel",
"downloadBatch": "下載本批次 ZIP",
"selectAllVisible": "全選目前結果",
@@ -6,7 +6,7 @@
* 逻辑:KbWorkspaceOverlays、ChatViewOverlays、各管理端页面以 v-model 控制显隐。
*/
import { computed, onBeforeUnmount, watch } from 'vue';
import { computed, onBeforeUnmount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
interface Props {
@@ -18,6 +18,10 @@ interface Props {
confirmLoading?: boolean;
/** danger 用于删除;primary 用于写入等非破坏性确认 */
confirmTone?: 'danger' | 'primary';
/** 可选审计原因;开启 required 后确认前必须填写。 */
reasonLabel?: string;
reasonPlaceholder?: string;
reasonRequired?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
@@ -27,15 +31,20 @@ const props = withDefaults(defineProps<Props>(), {
cancelText: '',
confirmLoading: false,
confirmTone: 'danger',
reasonLabel: '',
reasonPlaceholder: '',
reasonRequired: false,
});
const emit = defineEmits<{
(e: 'update:modelValue', value: boolean): void;
(e: 'confirm'): void;
(e: 'confirm', reason: string): void;
(e: 'cancel'): void;
}>();
const { t } = useI18n();
const reason = ref('');
const reasonMissing = ref(false);
const resolvedTitle = computed(() => props.title || t('common.deleteDialog.defaultTitle'));
const resolvedMessage = computed(() => props.message || t('common.deleteDialog.defaultMessage'));
@@ -60,7 +69,12 @@ const handleCancel = () => {
* 核心逻辑:先 emit confirm 供父级执行删除,再 closeDialog,与取消行为一致,避免仅依赖父级 v-model 时弹窗残留。
*/
const handleConfirm = () => {
emit('confirm');
const resolvedReason = reason.value.trim();
if (props.reasonRequired && !resolvedReason) {
reasonMissing.value = true;
return;
}
emit('confirm', resolvedReason);
closeDialog();
};
@@ -74,6 +88,8 @@ watch(
() => props.modelValue,
(visible) => {
if (visible) {
reason.value = '';
reasonMissing.value = false;
document.addEventListener('keydown', handleEscKey);
return;
}
@@ -108,6 +124,12 @@ onBeforeUnmount(() => {
</div>
</div>
<label v-if="reasonLabel" class="mt-5 block space-y-1.5">
<span class="label-field">{{ reasonLabel }}<span v-if="reasonRequired" class="text-red-500"> *</span></span>
<textarea v-model="reason" rows="3" class="input-field w-full resize-y" :placeholder="reasonPlaceholder" @input="reasonMissing = false" />
<span v-if="reasonMissing" class="text-xs text-red-600">{{ t('common.required') }}</span>
</label>
<div class="mt-6 flex justify-end gap-2">
<button type="button" class="btn-secondary btn-sm" @click="handleCancel">
{{ resolvedCancelText }}