feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估
- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。 - 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。 - 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。 - 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。 - 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
1 parent
cef3d5b26a
commit
3a9fbac2fc
226 files changed
+25010
-2098
No files matched your search
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* features/admin/api/shipping-audit.api.ts
|
||||
* 用途:货代统一审计查询/详情/关联链/哈希校验/导出 HTTP 客户端。
|
||||
* 依赖:shared/api/client、getAuthHeaders。
|
||||
* 依赖:shared/api/client(requestJson / requestBlob)、getAuthHeaders。
|
||||
* 逻辑:由 ShippingAuditCenterPage / ShippingAuditEventDetailDrawer 调用;
|
||||
* 导出走 blob 下载;敏感详情由后端按 audit_sensitive_read 裁剪。
|
||||
* 导出走 requestBlob;失败为 BusinessError;敏感详情由后端按 audit_sensitive_read 裁剪。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { requestBlob, requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
|
||||
export type ShippingAuditEventSummary = {
|
||||
@@ -56,11 +56,20 @@ export type ShippingAuditEventDetail = ShippingAuditEventSummary & {
|
||||
|
||||
export type ShippingAuditFilters = {
|
||||
event_type?: string;
|
||||
/**
|
||||
* 事件分组:review_workbench / chat_workbench / process_gate /
|
||||
* candidate_qualification / workflow_node。
|
||||
*/
|
||||
event_type_group?: string;
|
||||
actor_type?: string;
|
||||
/** 操作者用户 ID;与后端 audit_query_service.actor_id 对齐 */
|
||||
actor_id?: string;
|
||||
run_no?: string;
|
||||
task_no?: string;
|
||||
/** Candidate 编号;匹配 aggregate_id */
|
||||
candidate_no?: string;
|
||||
/** Process Gate / 节点码;匹配 aggregate_id 后缀 */
|
||||
gate_code?: string;
|
||||
document_id?: string;
|
||||
operation_id?: string;
|
||||
request_id?: string;
|
||||
@@ -69,6 +78,8 @@ export type ShippingAuditFilters = {
|
||||
workflow_item_id?: string;
|
||||
review_case_no?: string;
|
||||
owner_user_id?: string;
|
||||
/** 稳定业务原因码;与后端 audit_query_service.reason_code 对齐 */
|
||||
reason_code?: string;
|
||||
result?: string;
|
||||
created_from?: string;
|
||||
created_to?: string;
|
||||
@@ -154,12 +165,13 @@ export function verifyShippingAuditHashChain(body: {
|
||||
|
||||
/**
|
||||
* 受控导出审计 CSV/JSON,并触发浏览器下载。
|
||||
* 核心逻辑:经 requestBlob 统一鉴权与 BusinessError;成功后触发本地下载。
|
||||
*/
|
||||
export async function exportShippingAuditEvents(
|
||||
filters: ShippingAuditFilters = {},
|
||||
format: 'csv' | 'json' = 'csv',
|
||||
): Promise<void> {
|
||||
const response = await fetch('/api/admin/shipping-notice/audit-events/export', {
|
||||
const { blob, filename } = await requestBlob('/api/admin/shipping-notice/audit-events/export', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...getAuthHeaders(),
|
||||
@@ -167,15 +179,10 @@ export async function exportShippingAuditEvents(
|
||||
},
|
||||
body: JSON.stringify({ ...filters, format, limit: 2000 }),
|
||||
});
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
const blob = await response.blob();
|
||||
const disposition = response.headers.get('Content-Disposition') || '';
|
||||
const filename = disposition.match(/filename="?([^";]+)"?/i)?.[1]
|
||||
|| `shipping-audit.${format}`;
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = objectUrl;
|
||||
anchor.download = filename;
|
||||
anchor.download = filename || `shipping-audit.${format}`;
|
||||
anchor.click();
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
}
|
||||
@@ -296,7 +296,7 @@ export const runOrderProfileInstantCheck = (profileId: number, payload: {
|
||||
|
||||
/** 在绑定 annotation/training 样本上试运行;接口不会接受或回显盲测真值。 */
|
||||
export const runOrderProfileCurrentSample = (profileId: number, payload: {
|
||||
sample_binding_id?: number; browser_session_id: string; lease_token: string; operation_id: string;
|
||||
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() },
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-audit/ShippingAuditCenterPage.vue
|
||||
用途:管理员货代统一审计中心——按 Workflow/Item/Run/PDF/Case/Task 筛选、详情 Diff、关联链、哈希校验、受控导出。
|
||||
依赖:shipping-audit.api、ShippingAuditEventDetailDrawer、Vue I18n。
|
||||
逻辑:列表不含快照全文;详情抽屉按权限脱敏;导出/校验写服务端访问审计。
|
||||
用途:管理员货代统一审计中心——按 Conversation/Run/Candidate/Task/Gate/节点分组筛选、详情 Diff、关联链、哈希校验、受控导出。
|
||||
依赖:shipping-audit.api、shippingAuditDisplay、ShippingAuditEventDetailDrawer、Vue I18n、BusinessError、useMessage。
|
||||
逻辑:列表不含快照全文;详情抽屉按权限脱敏;导出/校验写服务端访问审计;
|
||||
事件分组含复核/对话/Process Gate/资格/节点;支持 candidate_no / gate_code;
|
||||
窄屏用卡片列表;桌面表无横滚,Case/Task 在业务关联列,WF/Item/Run 芯片可复制。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
exportShippingAuditEvents,
|
||||
getShippingAuditEvent,
|
||||
@@ -19,12 +23,15 @@ import {
|
||||
type ShippingAuditHashVerifyResult,
|
||||
} from '@/features/admin/api/shipping-audit.api';
|
||||
import ShippingAuditEventDetailDrawer from './ShippingAuditEventDetailDrawer.vue';
|
||||
import { shippingAuditBusinessLabel } from './shippingAuditDisplay';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const exporting = ref(false);
|
||||
const verifying = ref(false);
|
||||
const moreOpen = ref(false);
|
||||
const error = ref('');
|
||||
const page = ref(1);
|
||||
const pageSize = 25;
|
||||
@@ -35,6 +42,7 @@ const chainHint = ref('');
|
||||
const verifyResult = ref<ShippingAuditHashVerifyResult | null>(null);
|
||||
const filters = ref<ShippingAuditFilters>({
|
||||
event_type: '',
|
||||
event_type_group: '',
|
||||
actor_type: '',
|
||||
actor_id: '',
|
||||
workflow_id: '',
|
||||
@@ -43,10 +51,13 @@ const filters = ref<ShippingAuditFilters>({
|
||||
document_id: '',
|
||||
review_case_no: '',
|
||||
task_no: '',
|
||||
candidate_no: '',
|
||||
gate_code: '',
|
||||
conversation_id: '',
|
||||
owner_user_id: '',
|
||||
operation_id: '',
|
||||
request_id: '',
|
||||
reason_code: '',
|
||||
result: '',
|
||||
created_from: '',
|
||||
created_to: '',
|
||||
@@ -77,6 +88,62 @@ function buildFilterPayload(): ShippingAuditFilters {
|
||||
|
||||
const formatTime = (value?: string | null) => (value ? new Date(value).toLocaleString() : '—');
|
||||
|
||||
/**
|
||||
* 列表主区业务关联:仅 Case/Task,与 WF/Item/Run 技术编号严格分离。
|
||||
*/
|
||||
function primaryBusinessRefs(row: ShippingAuditEventSummary): string {
|
||||
const parts = [
|
||||
row.review_case_no ? `Case ${row.review_case_no}` : '',
|
||||
row.task_no ? `Task ${row.task_no}` : '',
|
||||
].filter(Boolean);
|
||||
return parts.length ? parts.join(' · ') : '—';
|
||||
}
|
||||
|
||||
/**
|
||||
* 行级技术编号芯片(WF/Item/Run),供桌面业务关联列与窄屏卡片复用。
|
||||
*/
|
||||
function techRefChips(row: ShippingAuditEventSummary): Array<{ label: string; value: string }> {
|
||||
return [
|
||||
{ label: 'WF', value: row.workflow_id },
|
||||
{ label: 'Item', value: row.workflow_item_id },
|
||||
{ label: 'Run', value: row.run_no },
|
||||
].filter((entry): entry is { label: string; value: string } => Boolean(entry.value));
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务化标签:与详情抽屉共用 shippingAuditDisplay,保证口径一致。
|
||||
*/
|
||||
function businessLabel(kind: 'eventTypes' | 'actions' | 'reasonCodes' | 'actorTypes' | 'results', code?: string | null): string {
|
||||
return shippingAuditBusinessLabel({ t, te }, kind, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制技术编号;失败时静默忽略。
|
||||
*/
|
||||
async function copyTechId(value?: string | null) {
|
||||
const text = String(value || '').trim();
|
||||
if (!text || !navigator?.clipboard?.writeText) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
msg.success(t('admin.shippingAudit.copied'));
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一捕获 API 错误为页面提示 + useMessage。
|
||||
*/
|
||||
function reportError(err: unknown, fallbackKey: string) {
|
||||
if (err instanceof BusinessError) {
|
||||
error.value = err.message;
|
||||
msg.error(err.message);
|
||||
return;
|
||||
}
|
||||
error.value = t(fallbackKey);
|
||||
msg.error(t(fallbackKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载审计列表;服务端已做管理员鉴权与访问留痕。
|
||||
*/
|
||||
@@ -87,8 +154,8 @@ async function load() {
|
||||
const response = await listShippingAuditEvents(page.value, pageSize, buildFilterPayload());
|
||||
rows.value = response.items;
|
||||
total.value = response.total;
|
||||
} catch {
|
||||
error.value = t('admin.shippingAudit.loadFailed');
|
||||
} catch (err) {
|
||||
reportError(err, 'admin.shippingAudit.loadFailed');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -110,8 +177,8 @@ async function openDetail(eventId: number) {
|
||||
error.value = '';
|
||||
try {
|
||||
detail.value = await getShippingAuditEvent(eventId);
|
||||
} catch {
|
||||
error.value = t('admin.shippingAudit.detailFailed');
|
||||
} catch (err) {
|
||||
reportError(err, 'admin.shippingAudit.detailFailed');
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
@@ -123,6 +190,7 @@ async function openDetail(eventId: number) {
|
||||
async function loadAssociationChain() {
|
||||
error.value = '';
|
||||
chainHint.value = '';
|
||||
moreOpen.value = false;
|
||||
try {
|
||||
const payload = buildFilterPayload();
|
||||
const hasSeed = Boolean(
|
||||
@@ -141,8 +209,8 @@ async function loadAssociationChain() {
|
||||
rows.value = chain.items.slice().reverse();
|
||||
total.value = chain.total;
|
||||
page.value = 1;
|
||||
} catch {
|
||||
error.value = t('admin.shippingAudit.chainFailed');
|
||||
} catch (err) {
|
||||
reportError(err, 'admin.shippingAudit.chainFailed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +221,7 @@ async function runHashVerify() {
|
||||
verifying.value = true;
|
||||
error.value = '';
|
||||
verifyResult.value = null;
|
||||
moreOpen.value = false;
|
||||
try {
|
||||
const payload = buildFilterPayload();
|
||||
verifyResult.value = await verifyShippingAuditHashChain({
|
||||
@@ -160,8 +229,8 @@ async function runHashVerify() {
|
||||
workflow_item_id: payload.workflow_item_id || undefined,
|
||||
sample_limit: 200,
|
||||
});
|
||||
} catch {
|
||||
error.value = t('admin.shippingAudit.verifyFailed');
|
||||
} catch (err) {
|
||||
reportError(err, 'admin.shippingAudit.verifyFailed');
|
||||
} finally {
|
||||
verifying.value = false;
|
||||
}
|
||||
@@ -175,13 +244,16 @@ async function exportCsv() {
|
||||
error.value = '';
|
||||
try {
|
||||
await exportShippingAuditEvents(buildFilterPayload(), 'csv');
|
||||
} catch {
|
||||
error.value = t('admin.shippingAudit.exportFailed');
|
||||
msg.success(t('admin.shippingAudit.exportDone'));
|
||||
} catch (err) {
|
||||
reportError(err, 'admin.shippingAudit.exportFailed');
|
||||
} finally {
|
||||
exporting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const pageLabel = computed(() => String(page.value));
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
});
|
||||
@@ -189,24 +261,40 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<section class="space-y-5 p-5 md:p-7" data-testid="shipping-audit-center">
|
||||
<header class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<header class="flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-start sm:justify-between">
|
||||
<div class="min-w-0">
|
||||
<h1 class="section-title">{{ t('admin.shippingAudit.title') }}</h1>
|
||||
<p class="section-desc mt-1 max-w-3xl">{{ t('admin.shippingAudit.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="verifying" @click="runHashVerify">
|
||||
{{ verifying ? t('admin.shippingAudit.verifying') : t('admin.shippingAudit.verifyChain') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="loadAssociationChain">
|
||||
{{ t('admin.shippingAudit.loadChain') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="exporting" @click="exportCsv">
|
||||
{{ exporting ? t('admin.shippingAudit.exporting') : t('admin.shippingAudit.export') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="loading" @click="load">
|
||||
<!-- [STEP] 窄屏主操作:刷新/导出;校验与关联链收入“更多”。 -->
|
||||
<div class="flex w-full flex-wrap items-center gap-2 sm:w-auto sm:justify-end">
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="loading" data-testid="shipping-audit-refresh" @click="load">
|
||||
{{ t('admin.shippingAudit.refresh') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="exporting" data-testid="shipping-audit-export" @click="exportCsv">
|
||||
{{ exporting ? t('admin.shippingAudit.exporting') : t('admin.shippingAudit.export') }}
|
||||
</button>
|
||||
<div class="relative">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary btn-sm md:hidden"
|
||||
data-testid="shipping-audit-more"
|
||||
@click="moreOpen = !moreOpen"
|
||||
>
|
||||
{{ t('admin.shippingAudit.moreActions') }}
|
||||
</button>
|
||||
<div
|
||||
class="absolute right-0 z-10 mt-1 w-44 rounded-lg border border-default bg-surface p-1 shadow-md md:static md:mt-0 md:flex md:w-auto md:items-center md:gap-2 md:border-0 md:bg-transparent md:p-0 md:shadow-none"
|
||||
:class="moreOpen ? 'block' : 'hidden md:flex'"
|
||||
>
|
||||
<button type="button" class="btn-secondary btn-sm w-full justify-start md:w-auto" :disabled="verifying" @click="runHashVerify">
|
||||
{{ verifying ? t('admin.shippingAudit.verifying') : t('admin.shippingAudit.verifyChain') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary btn-sm w-full justify-start md:w-auto" @click="loadAssociationChain">
|
||||
{{ t('admin.shippingAudit.loadChain') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -235,24 +323,62 @@ onMounted(() => {
|
||||
<span>{{ t('admin.shippingAudit.filters.taskNo') }}</span>
|
||||
<input v-model="filters.task_no" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.candidateNo') }}</span>
|
||||
<input
|
||||
v-model="filters.candidate_no"
|
||||
class="input-field text-sm"
|
||||
data-testid="shipping-audit-filter-candidate-no"
|
||||
@keyup.enter="applyFilters"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.gateCode') }}</span>
|
||||
<input
|
||||
v-model="filters.gate_code"
|
||||
class="input-field text-sm"
|
||||
data-testid="shipping-audit-filter-gate-code"
|
||||
@keyup.enter="applyFilters"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.actorType') }}</span>
|
||||
<select v-model="filters.actor_type" class="select-field text-sm" @change="applyFilters">
|
||||
<option value="">{{ t('admin.shippingAudit.filters.all') }}</option>
|
||||
<option value="user">user</option>
|
||||
<option value="admin">admin</option>
|
||||
<option value="system">system</option>
|
||||
<option value="rpa">rpa</option>
|
||||
<option value="user">{{ t('admin.shippingAudit.labels.actorTypes.user') }}</option>
|
||||
<option value="admin">{{ t('admin.shippingAudit.labels.actorTypes.admin') }}</option>
|
||||
<option value="system">{{ t('admin.shippingAudit.labels.actorTypes.system') }}</option>
|
||||
<option value="rpa">{{ t('admin.shippingAudit.labels.actorTypes.rpa') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.actorId') }}</span>
|
||||
<input v-model="filters.actor_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.eventTypeGroup') }}</span>
|
||||
<select
|
||||
v-model="filters.event_type_group"
|
||||
class="select-field text-sm"
|
||||
data-testid="shipping-audit-filter-event-type-group"
|
||||
@change="applyFilters"
|
||||
>
|
||||
<option value="">{{ t('admin.shippingAudit.filters.all') }}</option>
|
||||
<option value="review_workbench">{{ t('admin.shippingAudit.filters.eventTypeGroupReviewWorkbench') }}</option>
|
||||
<option value="chat_workbench">{{ t('admin.shippingAudit.filters.eventTypeGroupChatWorkbench') }}</option>
|
||||
<option value="process_gate">{{ t('admin.shippingAudit.filters.eventTypeGroupProcessGate') }}</option>
|
||||
<option value="candidate_qualification">{{ t('admin.shippingAudit.filters.eventTypeGroupQualification') }}</option>
|
||||
<option value="workflow_node">{{ t('admin.shippingAudit.filters.eventTypeGroupWorkflowNode') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.eventType') }}</span>
|
||||
<input v-model="filters.event_type" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.reasonCode') }}</span>
|
||||
<input v-model="filters.reason_code" class="input-field text-sm" data-testid="shipping-audit-filter-reason-code" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.result') }}</span>
|
||||
<input v-model="filters.result" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
@@ -288,43 +414,114 @@ onMounted(() => {
|
||||
</p>
|
||||
<p v-if="error" class="rounded-lg border border-rose-200 bg-rose-50 p-3 text-sm text-rose-700">{{ error }}</p>
|
||||
|
||||
<div class="overflow-x-auto rounded-xl border border-default bg-surface">
|
||||
<table class="min-w-[1360px] w-full text-left text-sm">
|
||||
<!-- 窄屏卡片列表:避免 1360px 表强制横向滚动才能点到 Diff -->
|
||||
<div class="space-y-3 lg:hidden" data-testid="shipping-audit-card-list">
|
||||
<p v-if="loading" class="rounded-xl border border-default bg-surface px-3 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.shippingAudit.loading') }}
|
||||
</p>
|
||||
<p v-else-if="!rows.length" class="rounded-xl border border-default bg-surface px-3 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.shippingAudit.empty') }}
|
||||
</p>
|
||||
<article
|
||||
v-for="row in rows"
|
||||
:key="row.id"
|
||||
class="rounded-xl border border-default bg-surface p-3"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<div class="text-sm font-medium text-secondary">{{ businessLabel('eventTypes', row.event_type) }}</div>
|
||||
<div class="mt-0.5 text-xs text-muted">{{ businessLabel('actions', row.action) }}</div>
|
||||
</div>
|
||||
<button type="button" class="shrink-0 text-sm text-brand-600 hover:underline" @click="openDetail(row.id)">
|
||||
{{ t('admin.shippingAudit.diff') }}
|
||||
</button>
|
||||
</div>
|
||||
<dl class="mt-2 grid gap-1 text-xs text-secondary">
|
||||
<div><dt class="inline text-muted">{{ t('admin.shippingAudit.columns.time') }}:</dt><dd class="inline">{{ formatTime(row.created_at) }}</dd></div>
|
||||
<div><dt class="inline text-muted">{{ t('admin.shippingAudit.columns.actor') }}:</dt><dd class="inline">{{ businessLabel('actorTypes', row.actor_type) }}</dd></div>
|
||||
<div><dt class="inline text-muted">{{ t('admin.shippingAudit.columns.reasonCode') }}:</dt><dd class="inline font-medium">{{ businessLabel('reasonCodes', row.reason_code) }}</dd></div>
|
||||
<div><dt class="inline text-muted">{{ t('admin.shippingAudit.columns.result') }}:</dt><dd class="inline">{{ businessLabel('results', row.result) }}</dd></div>
|
||||
<div v-if="primaryBusinessRefs(row) !== '—'">
|
||||
<dt class="inline text-muted">{{ t('admin.shippingAudit.columns.businessRefs') }}:</dt>
|
||||
<dd class="inline">{{ primaryBusinessRefs(row) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div
|
||||
v-if="techRefChips(row).length"
|
||||
class="mt-2 flex flex-wrap items-center gap-1.5"
|
||||
data-testid="shipping-audit-tech-ref-chips"
|
||||
>
|
||||
<span class="text-[10px] text-muted">{{ t('admin.shippingAudit.techRefs') }}</span>
|
||||
<button
|
||||
v-for="item in techRefChips(row)"
|
||||
:key="`${row.id}-m-tech-${item.label}`"
|
||||
type="button"
|
||||
class="rounded border border-default px-2 py-1 font-mono text-[11px] text-muted"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- 桌面表:table-fixed + 无横滚;技术编号行内次要芯片,无需额外展开 -->
|
||||
<div class="hidden overflow-x-hidden rounded-xl border border-default bg-surface lg:block" data-testid="shipping-audit-desktop-table">
|
||||
<table class="w-full table-fixed text-left text-sm">
|
||||
<thead class="border-b border-default bg-surface-soft text-xs text-muted">
|
||||
<tr>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.time') }}</th>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.event') }}</th>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.actor') }}</th>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.workflow') }}</th>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.workflowItem') }}</th>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.reviewCase') }}</th>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.run') }}</th>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.task') }}</th>
|
||||
<th class="px-3 py-2">{{ t('admin.shippingAudit.columns.result') }}</th>
|
||||
<th class="px-3 py-2"></th>
|
||||
<th class="w-[16%] px-3 py-2">{{ t('admin.shippingAudit.columns.time') }}</th>
|
||||
<th class="w-[20%] px-3 py-2">{{ t('admin.shippingAudit.columns.event') }}</th>
|
||||
<th class="w-[10%] px-3 py-2">{{ t('admin.shippingAudit.columns.actor') }}</th>
|
||||
<th class="w-[18%] px-3 py-2">{{ t('admin.shippingAudit.columns.reasonCode') }}</th>
|
||||
<th class="w-[10%] px-3 py-2">{{ t('admin.shippingAudit.columns.result') }}</th>
|
||||
<th class="w-[16%] px-3 py-2">{{ t('admin.shippingAudit.columns.businessRefs') }}</th>
|
||||
<th class="w-[10%] px-3 py-2"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="loading">
|
||||
<td colspan="10" class="px-3 py-8 text-center text-muted">{{ t('admin.shippingAudit.loading') }}</td>
|
||||
<td colspan="7" class="px-3 py-8 text-center text-muted">{{ t('admin.shippingAudit.loading') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="!rows.length">
|
||||
<td colspan="10" class="px-3 py-8 text-center text-muted">{{ t('admin.shippingAudit.empty') }}</td>
|
||||
<td colspan="7" class="px-3 py-8 text-center text-muted">{{ t('admin.shippingAudit.empty') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in rows" :key="row.id" class="border-b border-default last:border-0">
|
||||
<td class="px-3 py-2 text-xs">{{ formatTime(row.created_at) }}</td>
|
||||
<td class="px-3 py-2">
|
||||
<div class="font-medium">{{ row.event_type }}</div>
|
||||
<div class="text-[11px] text-muted">{{ row.action || '—' }}</div>
|
||||
<tr
|
||||
v-for="row in rows"
|
||||
:key="row.id"
|
||||
class="border-b border-default last:border-0"
|
||||
>
|
||||
<td class="px-3 py-2 align-top text-xs">{{ formatTime(row.created_at) }}</td>
|
||||
<td class="px-3 py-2 align-top">
|
||||
<div class="font-medium break-words">{{ businessLabel('eventTypes', row.event_type) }}</div>
|
||||
<div class="text-[11px] text-muted break-words">{{ businessLabel('actions', row.action) }}</div>
|
||||
</td>
|
||||
<td class="px-3 py-2 text-xs">{{ row.actor_type }}<span v-if="row.actor_id"> / {{ row.actor_id }}</span></td>
|
||||
<td class="px-3 py-2 font-mono text-xs">{{ row.workflow_id || '—' }}</td>
|
||||
<td class="px-3 py-2 font-mono text-xs">{{ row.workflow_item_id || '—' }}</td>
|
||||
<td class="px-3 py-2 font-mono text-xs">{{ row.review_case_no || '—' }}</td>
|
||||
<td class="px-3 py-2 font-mono text-xs">{{ row.run_no || '—' }}</td>
|
||||
<td class="px-3 py-2 font-mono text-xs">{{ row.task_no || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ row.result || '—' }}</td>
|
||||
<td class="px-3 py-2">
|
||||
<td class="px-3 py-2 align-top text-xs">{{ businessLabel('actorTypes', row.actor_type) }}</td>
|
||||
<td class="px-3 py-2 align-top text-xs break-words font-medium text-secondary">
|
||||
{{ businessLabel('reasonCodes', row.reason_code) }}
|
||||
</td>
|
||||
<td class="px-3 py-2 align-top">{{ businessLabel('results', row.result) }}</td>
|
||||
<td class="px-3 py-2 align-top text-[11px] text-secondary break-words">
|
||||
<div>{{ primaryBusinessRefs(row) }}</div>
|
||||
<div
|
||||
v-if="techRefChips(row).length"
|
||||
class="mt-1 flex flex-wrap gap-1"
|
||||
data-testid="shipping-audit-tech-ref-chips"
|
||||
>
|
||||
<button
|
||||
v-for="item in techRefChips(row)"
|
||||
:key="`${row.id}-tech-${item.label}`"
|
||||
type="button"
|
||||
class="rounded border border-default bg-surface-soft px-1 py-0.5 font-mono text-[10px] text-muted"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-2 align-top">
|
||||
<button type="button" class="text-brand-600 hover:underline" @click="openDetail(row.id)">
|
||||
{{ t('admin.shippingAudit.diff') }}
|
||||
</button>
|
||||
@@ -337,7 +534,7 @@ onMounted(() => {
|
||||
<div class="flex items-center justify-end gap-3 text-sm">
|
||||
<span class="text-xs text-muted">{{ t('admin.shippingAudit.total', { count: total }) }}</span>
|
||||
<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.shippingAudit.previous') }}</button>
|
||||
<span>{{ page }}</span>
|
||||
<span>{{ pageLabel }}</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.shippingAudit.next') }}</button>
|
||||
</div>
|
||||
|
||||
|
||||
+66
-6
@@ -1,15 +1,23 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-audit/ShippingAuditEventDetailDrawer.spec.ts
|
||||
* 用途:锁定审计详情抽屉脱敏提示与 Diff 渲染契约。
|
||||
* 用途:锁定审计详情抽屉脱敏、业务化标签与 Diff 渲染契约。
|
||||
* 依赖:Vitest、@vue/test-utils、ShippingAuditEventDetailDrawer。
|
||||
* 逻辑:敏感脱敏文案可见;Diff 行按 key 渲染;无 Diff 显示空态。
|
||||
* 逻辑:敏感脱敏文案可见;事件/操作者/结果用业务标签;技术编号不直接平铺主区;Diff 行按 key 渲染。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import ShippingAuditEventDetailDrawer from './ShippingAuditEventDetailDrawer.vue';
|
||||
import type { ShippingAuditEventDetail } from '@/features/admin/api/shipping-audit.api';
|
||||
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => ({
|
||||
success: vi.fn(),
|
||||
warning: vi.fn(),
|
||||
error: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
const messages = {
|
||||
'zh-CN': {
|
||||
admin: {
|
||||
@@ -24,12 +32,41 @@ const messages = {
|
||||
noDiff: '无可展示的白名单差异',
|
||||
eventHash: '事件哈希',
|
||||
previousEventHash: '前序哈希',
|
||||
columns: { event: '事件', actor: '操作者', run: 'Run', task: 'Task', result: '结果' },
|
||||
copied: '已复制编号',
|
||||
copyId: '复制编号',
|
||||
techRefsHint: '技术编号默认折叠展示,点击即可复制。',
|
||||
hashSection: '哈希摘要(排障用)',
|
||||
columns: {
|
||||
event: '事件',
|
||||
actor: '操作者',
|
||||
run: 'Run',
|
||||
task: 'Task',
|
||||
result: '结果',
|
||||
reasonCode: '原因',
|
||||
refs: '关联编号',
|
||||
},
|
||||
filters: {
|
||||
workflowId: 'Workflow',
|
||||
workflowItemId: 'Workflow Item',
|
||||
documentId: 'PDF/文档',
|
||||
reviewCaseNo: 'Case',
|
||||
operationId: 'operation_id',
|
||||
requestId: 'request_id',
|
||||
},
|
||||
labels: {
|
||||
eventTypes: {
|
||||
fallback: '审计事件',
|
||||
order_review_confirmed: '订单复核已确认',
|
||||
status_changed: '状态已变更',
|
||||
},
|
||||
actions: { fallback: '业务操作' },
|
||||
reasonCodes: { fallback: '业务原因' },
|
||||
actorTypes: {
|
||||
user: '业务用户',
|
||||
system: '系统',
|
||||
unknown: '未知操作者',
|
||||
},
|
||||
results: { success: '成功', ok: '成功' },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -60,11 +97,35 @@ describe('ShippingAuditEventDetailDrawer', () => {
|
||||
diff: [],
|
||||
};
|
||||
const wrapper = mountDrawer(detail);
|
||||
// 关键断言:无敏感读权限时展示脱敏提示。
|
||||
expect(wrapper.find('[data-testid="shipping-audit-sensitive-redacted"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('敏感快照已按权限脱敏');
|
||||
});
|
||||
|
||||
it('uses business labels and does not flatten raw event_type in primary meta', () => {
|
||||
const detail: ShippingAuditEventDetail = {
|
||||
id: 3,
|
||||
event_type: 'order_review_confirmed',
|
||||
action: 'unknown_action_xyz',
|
||||
aggregate_type: 'shipping_order_review_case',
|
||||
aggregate_id: 'SRC-3',
|
||||
actor_type: 'user',
|
||||
actor_id: 'u-9',
|
||||
result: 'success',
|
||||
run_no: 'SNER-9',
|
||||
request_id: 'req-9',
|
||||
has_snapshots: false,
|
||||
sensitive_redacted: false,
|
||||
diff: [],
|
||||
};
|
||||
const wrapper = mountDrawer(detail);
|
||||
const text = wrapper.text();
|
||||
expect(wrapper.get('[data-testid="shipping-audit-detail-event"]').text()).toContain('订单复核已确认');
|
||||
expect(wrapper.get('[data-testid="shipping-audit-detail-actor"]').text()).toContain('业务用户');
|
||||
expect(wrapper.get('[data-testid="shipping-audit-detail-result"]').text()).toContain('成功');
|
||||
expect(text).not.toContain('order_review_confirmed');
|
||||
expect(wrapper.find('[data-testid="shipping-audit-detail-tech-refs"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('renders whitelist diff rows', () => {
|
||||
const detail: ShippingAuditEventDetail = {
|
||||
id: 2,
|
||||
@@ -77,7 +138,6 @@ describe('ShippingAuditEventDetailDrawer', () => {
|
||||
diff: [{ key: 'status', change: 'changed', before: 'queued', after: 'processing' }],
|
||||
};
|
||||
const wrapper = mountDrawer(detail);
|
||||
// 关键断言:Diff 仅展示白名单键变化。
|
||||
expect(wrapper.find('[data-testid="shipping-audit-diff-rows"]').text()).toContain('status');
|
||||
expect(wrapper.text()).toContain('queued');
|
||||
expect(wrapper.text()).toContain('processing');
|
||||
|
||||
+119
-31
@@ -1,13 +1,16 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-audit/ShippingAuditEventDetailDrawer.vue
|
||||
用途:审计事件详情抽屉——元数据、敏感脱敏提示、白名单 Diff、哈希摘要。
|
||||
依赖:shipping-audit.api 类型、Vue I18n。
|
||||
逻辑:由 ShippingAuditCenterPage 传入 detail;关闭时 emit close;不自行拉接口。
|
||||
用途:审计事件详情抽屉——业务化元数据、敏感脱敏提示、白名单 Diff、哈希摘要。
|
||||
依赖:shipping-audit.api 类型、shippingAuditDisplay、Vue I18n、useMessage。
|
||||
逻辑:由 ShippingAuditCenterPage 传入 detail;事件/动作/结果与列表同源业务标签;
|
||||
技术编号以复制芯片展示;关闭时 emit close;不自行拉接口。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { ShippingAuditEventDetail } from '@/features/admin/api/shipping-audit.api';
|
||||
import { shippingAuditBusinessLabel } from './shippingAuditDisplay';
|
||||
|
||||
const props = defineProps<{
|
||||
detail: ShippingAuditEventDetail | null;
|
||||
@@ -18,10 +21,52 @@ const emit = defineEmits<{
|
||||
close: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const open = computed(() => Boolean(props.detail || props.loading));
|
||||
|
||||
/**
|
||||
* 与列表页一致的业务化标签。
|
||||
*/
|
||||
function label(kind: 'eventTypes' | 'actions' | 'reasonCodes' | 'actorTypes' | 'results', code?: string | null): string {
|
||||
return shippingAuditBusinessLabel({ t, te }, kind, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制技术编号。
|
||||
*/
|
||||
async function copyTechId(value?: string | null) {
|
||||
const text = String(value || '').trim();
|
||||
if (!text || !navigator?.clipboard?.writeText) return;
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
msg.success(t('admin.shippingAudit.copied'));
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情中仅展示有值的关联编号芯片。
|
||||
*/
|
||||
const techRefs = computed(() => {
|
||||
const d = props.detail;
|
||||
if (!d) return [] as Array<{ label: string; value: string }>;
|
||||
return [
|
||||
{ label: t('admin.shippingAudit.filters.workflowId'), value: d.workflow_id },
|
||||
{ label: t('admin.shippingAudit.filters.workflowItemId'), value: d.workflow_item_id },
|
||||
{ label: t('admin.shippingAudit.columns.run'), value: d.run_no },
|
||||
{ label: t('admin.shippingAudit.filters.documentId'), value: d.document_id },
|
||||
{ label: t('admin.shippingAudit.filters.reviewCaseNo'), value: d.review_case_no },
|
||||
{ label: t('admin.shippingAudit.columns.task'), value: d.task_no },
|
||||
{ label: t('admin.shippingAudit.filters.operationId'), value: d.operation_id },
|
||||
{ label: t('admin.shippingAudit.filters.requestId'), value: d.request_id },
|
||||
]
|
||||
.map((item) => ({ label: item.label, value: String(item.value || '').trim() }))
|
||||
.filter((item) => Boolean(item.value));
|
||||
});
|
||||
|
||||
/**
|
||||
* 关闭抽屉。
|
||||
*/
|
||||
@@ -51,34 +96,77 @@ function onClose() {
|
||||
>
|
||||
{{ t('admin.shippingAudit.sensitiveRedacted') }}
|
||||
</p>
|
||||
<dl class="mt-5 grid grid-cols-2 gap-3 text-sm">
|
||||
<dt>{{ t('admin.shippingAudit.columns.event') }}</dt>
|
||||
<dd>{{ detail.event_type }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.columns.actor') }}</dt>
|
||||
<dd>{{ detail.actor_type }} / {{ detail.actor_id || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.filters.workflowId') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.workflow_id || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.filters.workflowItemId') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.workflow_item_id || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.columns.run') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.run_no || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.filters.documentId') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.document_id || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.filters.reviewCaseNo') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.review_case_no || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.columns.task') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.task_no || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.columns.result') }}</dt>
|
||||
<dd>{{ detail.result || '—' }}</dd>
|
||||
<dt>operation_id</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.operation_id || '—' }}</dd>
|
||||
<dt>request_id</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.request_id || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.eventHash') }}</dt>
|
||||
<dd class="font-mono text-[10px] break-all">{{ detail.event_hash || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.previousEventHash') }}</dt>
|
||||
<dd class="font-mono text-[10px] break-all">{{ detail.previous_event_hash || '—' }}</dd>
|
||||
<dl class="mt-5 grid grid-cols-1 gap-3 text-sm sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.event') }}</dt>
|
||||
<dd class="mt-0.5 font-medium" data-testid="shipping-audit-detail-event">
|
||||
{{ label('eventTypes', detail.event_type) }}
|
||||
</dd>
|
||||
<dd class="text-xs text-muted">{{ label('actions', detail.action) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.actor') }}</dt>
|
||||
<dd class="mt-0.5" data-testid="shipping-audit-detail-actor">
|
||||
{{ label('actorTypes', detail.actor_type) }}
|
||||
<span v-if="detail.actor_id" class="text-muted"> · {{ t('admin.shippingAudit.copyId') }}</span>
|
||||
</dd>
|
||||
<button
|
||||
v-if="detail.actor_id"
|
||||
type="button"
|
||||
class="mt-1 rounded border border-default px-2 py-0.5 font-mono text-[11px] text-muted"
|
||||
:title="String(detail.actor_id)"
|
||||
@click="copyTechId(detail.actor_id)"
|
||||
>
|
||||
{{ detail.actor_id }}
|
||||
</button>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.reasonCode') }}</dt>
|
||||
<dd class="mt-0.5">{{ label('reasonCodes', detail.reason_code) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.result') }}</dt>
|
||||
<dd class="mt-0.5" data-testid="shipping-audit-detail-result">
|
||||
{{ label('results', detail.result) }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<section class="mt-5" data-testid="shipping-audit-detail-tech-refs">
|
||||
<h3 class="text-sm font-semibold">{{ t('admin.shippingAudit.columns.refs') }}</h3>
|
||||
<p class="mt-1 text-[11px] text-muted">{{ t('admin.shippingAudit.techRefsHint') }}</p>
|
||||
<div v-if="techRefs.length" class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
v-for="item in techRefs"
|
||||
:key="`${item.label}-${item.value}`"
|
||||
type="button"
|
||||
class="rounded border border-default px-2 py-1 text-[11px] text-secondary"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
<span class="text-muted">{{ item.label }}</span>
|
||||
· {{ t('admin.shippingAudit.copyId') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-else class="mt-2 text-xs text-muted">—</p>
|
||||
</section>
|
||||
|
||||
<details class="mt-5 rounded-lg border border-default p-3 text-xs">
|
||||
<summary class="cursor-pointer font-medium text-secondary">
|
||||
{{ t('admin.shippingAudit.hashSection') }}
|
||||
</summary>
|
||||
<dl class="mt-3 space-y-2">
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.eventHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]">{{ detail.event_hash || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.previousEventHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]">{{ detail.previous_event_hash || '—' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</details>
|
||||
|
||||
<h3 class="mt-6 font-semibold">{{ t('admin.shippingAudit.diff') }}</h3>
|
||||
<div v-if="detail.diff?.length" class="mt-2 space-y-2" data-testid="shipping-audit-diff-rows">
|
||||
<div
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-audit/shippingAuditDisplay.ts
|
||||
* 用途:审计中心列表与详情共用的业务化标签解析。
|
||||
* 依赖:vue-i18n Translator(te/t)。
|
||||
* 逻辑:ShippingAuditCenterPage / ShippingAuditEventDetailDrawer 调用;
|
||||
* 未知码回退通用业务文案,避免主界面直接堆叠内部事件码。
|
||||
*/
|
||||
|
||||
export type ShippingAuditLabelKind =
|
||||
| 'eventTypes'
|
||||
| 'actions'
|
||||
| 'reasonCodes'
|
||||
| 'actorTypes'
|
||||
| 'results';
|
||||
|
||||
export type ShippingAuditTranslate = {
|
||||
t: (key: string) => string;
|
||||
te: (key: string) => boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* 将审计事件/动作/原因/操作者/结果码转为业务化文案。
|
||||
* @param i18n - vue-i18n te/t
|
||||
* @param kind - 标签分类
|
||||
* @param code - 原始稳定码
|
||||
* @returns 业务文案;空码返回 —
|
||||
*/
|
||||
export function shippingAuditBusinessLabel(
|
||||
i18n: ShippingAuditTranslate,
|
||||
kind: ShippingAuditLabelKind,
|
||||
code?: string | null,
|
||||
): string {
|
||||
const raw = String(code || '').trim();
|
||||
if (!raw) return '—';
|
||||
const key = `admin.shippingAudit.labels.${kind}.${raw}`;
|
||||
if (i18n.te(key)) return i18n.t(key);
|
||||
if (kind === 'actorTypes') return i18n.t('admin.shippingAudit.labels.actorTypes.unknown');
|
||||
if (kind === 'results') return raw;
|
||||
return i18n.t(`admin.shippingAudit.labels.${kind}.fallback`);
|
||||
}
|
||||
+27
-2
@@ -1024,6 +1024,8 @@ const save = async (automatic = false) => {
|
||||
display_name: form.displayName,
|
||||
schema_version_id: form.schemaId,
|
||||
definition: definition(),
|
||||
sample_document_id: form.documentId,
|
||||
sample_table_id: form.tableId,
|
||||
change_note: form.changeNote,
|
||||
};
|
||||
if (!existingProfile) throw new Error('A draft must be created by the wizard before editing.');
|
||||
@@ -1751,9 +1753,16 @@ const edit = async (profile: ShippingOrderDocumentProfile) => {
|
||||
}
|
||||
try {
|
||||
boundSamples.value = await listOrderProfileBoundSamples(profile.id);
|
||||
form.documentId =
|
||||
boundSamples.value.find((item) => item.sample_role === "annotation")?.document_id || 0;
|
||||
const annotationSample = boundSamples.value.find((item) => item.sample_role === "annotation") || null;
|
||||
form.documentId = annotationSample?.document_id || 0;
|
||||
await loadSampleTables();
|
||||
// Restore the exact bound physical table instead of defaulting to the
|
||||
// first parsed table; otherwise detail recognition may target the wrong
|
||||
// page after returning from validation.
|
||||
if (annotationSample?.table_id && sampleTables.value.some((item) => item.table_id === annotationSample.table_id)) {
|
||||
form.tableId = annotationSample.table_id;
|
||||
pageNo.value = sampleTables.value.find((item) => item.table_id === annotationSample.table_id)?.page_no || pageNo.value;
|
||||
}
|
||||
await loadPages();
|
||||
} catch (error) {
|
||||
fail(error);
|
||||
@@ -1762,10 +1771,26 @@ const edit = async (profile: ShippingOrderDocumentProfile) => {
|
||||
// Page preview grants are independent from coordinate extraction. A grant
|
||||
// failure must not leave the right-hand recognition panel at "waiting".
|
||||
await refreshOrderFieldSuggestionValues();
|
||||
// Restoring a draft suppresses the table watcher; explicitly re-read the
|
||||
// current table so detail rows are visible immediately after returning.
|
||||
schedulePreview();
|
||||
}
|
||||
};
|
||||
/** 跳转到独立验证页;页面仍需当前标签持有租约,不能绕过草稿单写者保护。 */
|
||||
const validateProfile = async (profile: ShippingOrderDocumentProfile) => {
|
||||
// Flush pending autosave/local edits before validation; otherwise the
|
||||
// validation page may validate the previous immutable draft revision.
|
||||
if (autosaveTimer) {
|
||||
window.clearTimeout(autosaveTimer);
|
||||
autosaveTimer = null;
|
||||
}
|
||||
if (saving.value) {
|
||||
for (let attempt = 0; attempt < 100 && saving.value; attempt += 1) {
|
||||
await new Promise<void>((resolve) => window.setTimeout(resolve, 50));
|
||||
}
|
||||
}
|
||||
if (dirty.value) await save();
|
||||
if (dirty.value || saving.value || saveState.value === 'failed' || saveState.value === 'readonly') return;
|
||||
await router.push({
|
||||
name: "AdminShippingOrderDocumentProfileValidate",
|
||||
params: { profileCode: profile.profile_code, profileId: String(profile.id) },
|
||||
|
||||
+8
-1
@@ -143,12 +143,19 @@ async function ensureLease(): Promise<boolean> {
|
||||
/** 依次执行配置结构和当前样本试读;任一步失败均不允许进入发布检查。 */
|
||||
async function validateCurrentDraft(): Promise<void> {
|
||||
if (!(await ensureLease())) return;
|
||||
if (!sample.value?.id) {
|
||||
message.error(t('admin.orderProfileValidation.noTrainingSample'));
|
||||
return;
|
||||
}
|
||||
executing.value = true;
|
||||
try {
|
||||
const payload = () => ({ browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() });
|
||||
await runOrderProfileInstantCheck(profileId, payload());
|
||||
await runOrderProfileCurrentSample(profileId, payload());
|
||||
await runOrderProfileCurrentSample(profileId, { ...payload(), sample_binding_id: sample.value.id });
|
||||
await loadRuns();
|
||||
// Refresh the draft/sample context after validation so the result preview
|
||||
// uses the same binding and definition that the server just validated.
|
||||
await loadContext();
|
||||
await loadBlindTestSuite();
|
||||
await loadReadResults();
|
||||
message.success(t('admin.orderProfileValidation.completed'));
|
||||
|
||||
@@ -516,6 +516,7 @@ export interface CoordinateReconstructionPreview {
|
||||
table_id: string;
|
||||
row_count: number;
|
||||
column_count: number;
|
||||
field_codes: string[];
|
||||
rows: string[][];
|
||||
row_roles: Array<'header' | 'data' | 'deleted'>;
|
||||
source_row_indices: number[][];
|
||||
|
||||
Reference in new issue
Block a user