Merge branch 'dev' into common-problems-fuzzy-query
This commit is contained in:
commit
d3204f1db8
790 files changed
+71443
-26080
No files matched your search
+33
-9
@@ -7,7 +7,12 @@
|
||||
* 书签/刷新冷启动遇到 401 时只回登录页;本页已确认会话后中途失效才弹窗。
|
||||
*/
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { watch, onMounted, onBeforeUnmount } from 'vue';
|
||||
import { computed, watch, onMounted, onBeforeUnmount } from 'vue';
|
||||
import { ElConfigProvider } from 'element-plus';
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
||||
import zhTw from 'element-plus/es/locale/lang/zh-tw';
|
||||
import en from 'element-plus/es/locale/lang/en';
|
||||
import th from 'element-plus/es/locale/lang/th';
|
||||
import { useTheme } from '@/shared/composables/useTheme';
|
||||
import LevelMessageDialog from '@/shared/components/LevelMessageDialog.vue';
|
||||
import { useGlobalMessageDialog } from '@/shared/composables/useGlobalMessageDialog';
|
||||
@@ -18,6 +23,23 @@ import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store';
|
||||
|
||||
const router = useRouter();
|
||||
const { locale, t } = useI18n();
|
||||
|
||||
/**
|
||||
* Element Plus 组件内置文案(下拉占位/日期面板/分页等)跟随应用语言:
|
||||
* EP 有独立 locale 体系,默认英文,必须在根部经 el-config-provider 注入当前语言包。
|
||||
*/
|
||||
const elementPlusLocale = computed(() => {
|
||||
switch (locale.value) {
|
||||
case 'zh-TW':
|
||||
return zhTw;
|
||||
case 'en':
|
||||
return en;
|
||||
case 'th':
|
||||
return th;
|
||||
default:
|
||||
return zhCn;
|
||||
}
|
||||
});
|
||||
const { themePreference, initTheme, setThemePreference } = useTheme();
|
||||
const {
|
||||
messageDialogVisible,
|
||||
@@ -136,12 +158,14 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<router-view />
|
||||
<LevelMessageDialog
|
||||
v-model="messageDialogVisible"
|
||||
:level="messageDialogLevel"
|
||||
:title="messageDialogTitle"
|
||||
:message="messageDialogContent"
|
||||
@close="closeMessageDialog"
|
||||
/>
|
||||
<el-config-provider :locale="elementPlusLocale">
|
||||
<router-view />
|
||||
<LevelMessageDialog
|
||||
v-model="messageDialogVisible"
|
||||
:level="messageDialogLevel"
|
||||
:title="messageDialogTitle"
|
||||
:message="messageDialogContent"
|
||||
@close="closeMessageDialog"
|
||||
/>
|
||||
</el-config-provider>
|
||||
</template>
|
||||
@@ -46,8 +46,8 @@ const LinkedServicesPage = () =>
|
||||
|
||||
const ReportsPage = () =>
|
||||
import("@/features/admin/modules/reports/ReportsPage.vue");
|
||||
const ShippingInventoryPage = () =>
|
||||
import("@/features/admin/modules/shipping-inventory/ShippingInventoryPage.vue");
|
||||
const FreightRpaPage = () =>
|
||||
import("@/features/admin/modules/freight-rpa/FreightRpaPage.vue");
|
||||
const ShippingFieldAssetsPage = () =>
|
||||
import("@/features/admin/modules/shipping-field-assets/ShippingFieldAssetsPage.vue");
|
||||
const ShippingOrderSchemaPage = () =>
|
||||
@@ -82,6 +82,9 @@ const TrainingConfigPage = () =>
|
||||
const IntegrationConnectorPage = () =>
|
||||
import("@/features/admin/modules/integration-connector/IntegrationConnectorPage.vue");
|
||||
|
||||
const TransferTypesPage = () =>
|
||||
import("@/features/admin/modules/transfer-types/TransferTypesPage.vue");
|
||||
|
||||
export const adminRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: "/admin",
|
||||
@@ -171,82 +174,82 @@ export const adminRoutes: RouteRecordRaw[] = [
|
||||
|
||||
{
|
||||
path: "shipping-notice",
|
||||
name: "AdminShippingInventory",
|
||||
component: ShippingInventoryPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'inventory', title: "货代管理" },
|
||||
name: "AdminFreightRpa",
|
||||
component: FreightRpaPage,
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'inventory', title: "货代管理" },
|
||||
},
|
||||
{
|
||||
path: "shipping-field-assets",
|
||||
name: "AdminShippingFieldAssets",
|
||||
component: ShippingFieldAssetsPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'field_assets', title: "字段资产库" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'field_assets', title: "字段资产库" },
|
||||
},
|
||||
{
|
||||
path: "shipping-order-schema",
|
||||
name: "AdminShippingOrderSchema",
|
||||
component: ShippingOrderSchemaPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_schema', title: "订单 Schema" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'order_schema', title: "订单 Schema" },
|
||||
},
|
||||
{
|
||||
path: "shipping-identity-rules",
|
||||
name: "AdminShippingIdentityRules",
|
||||
component: ShippingIdentityRulesPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'identity_rules', title: "客户识别规则" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'identity_rules', title: "客户识别规则" },
|
||||
},
|
||||
{
|
||||
path: "shipping-order-extraction-runs",
|
||||
name: "AdminShippingOrderExtractionRuns",
|
||||
component: ShippingOrderExtractionRunsPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_extraction_runs', title: "识别任务" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'order_extraction_runs', title: "识别任务" },
|
||||
},
|
||||
{
|
||||
path: "shipping-audit",
|
||||
name: "AdminShippingAudit",
|
||||
component: ShippingAuditCenterPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'shipping_audit', title: "运行与审计" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'shipping_audit', title: "运行与审计" },
|
||||
},
|
||||
{
|
||||
path: "shipping-process-gates",
|
||||
name: "AdminShippingProcessGates",
|
||||
component: ShippingProcessGateDiagnosticsPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'process_gates', title: "门禁诊断" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'process_gates', title: "门禁诊断" },
|
||||
},
|
||||
{
|
||||
path: "shipping-order-document-profiles",
|
||||
name: "AdminShippingOrderDocumentProfiles",
|
||||
component: ShippingOrderDocumentProfilesPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "订单文档模板" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", 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: "创建订单文档模板" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", 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: "编辑订单文档模板" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", 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: "验证订单文档模板" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'order_document_profiles', title: "验证订单文档模板" },
|
||||
},
|
||||
{
|
||||
path: "shipping-order-document-profiles/:profileCode/drafts/:profileId/blind-test",
|
||||
name: "AdminShippingOrderDocumentProfileBlindTest",
|
||||
component: OrderProfileBlindTestPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "订单文档模板盲测" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", 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: "订单文档模板发布检查" },
|
||||
meta: { requiresAdmin: true, adminModule: "freight_rpa", adminSubModule: 'order_document_profiles', title: "订单文档模板发布检查" },
|
||||
},
|
||||
{
|
||||
path: "shipping-order-document-profiles/:profileCode/versions/:version",
|
||||
@@ -254,7 +257,7 @@ export const adminRoutes: RouteRecordRaw[] = [
|
||||
component: OrderProfileVersionDetailPage,
|
||||
meta: {
|
||||
requiresAdmin: true,
|
||||
adminModule: "shipping_inventory",
|
||||
adminModule: "freight_rpa",
|
||||
adminSubModule: 'order_document_profiles',
|
||||
title: "模板版本详情",
|
||||
},
|
||||
@@ -341,6 +344,16 @@ export const adminRoutes: RouteRecordRaw[] = [
|
||||
title: "admin.nav.integrationConnector",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "transfer-types",
|
||||
name: "AdminTransferTypes",
|
||||
component: TransferTypesPage,
|
||||
meta: {
|
||||
requiresAdmin: true,
|
||||
adminModule: "transfer_types",
|
||||
title: "admin.nav.transferTypes",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "reports/:table?",
|
||||
name: "AdminReports",
|
||||
|
||||
@@ -62,12 +62,6 @@ export const workspaceRoutes: RouteRecordRaw[] = [
|
||||
component: () => import('@/features/workspace/pages/ScheduleRunsPage.vue'),
|
||||
meta: { title: 'workspace.nav.scheduleRuns' },
|
||||
},
|
||||
{
|
||||
path: 'receipt-reports',
|
||||
name: 'workspace-receipt-reports',
|
||||
component: () => import('@/features/workspace/pages/ReceiptReportFilesPage.vue'),
|
||||
meta: { title: 'workspace.nav.receiptReports' },
|
||||
},
|
||||
{
|
||||
path: 'shipping-notice',
|
||||
redirect: '/workspace/shipping-notice/my-tasks',
|
||||
|
||||
@@ -70,10 +70,11 @@ export const config = {
|
||||
schedules: true, // 定时任务
|
||||
wecom: true, // 企业微信
|
||||
linked_services: true, // 关联服务(侧栏跳转入口)
|
||||
shipping_inventory: true, // 货代配置
|
||||
freight_rpa: true, // 货代配置
|
||||
procurement_contract: true, // 采购合同审查(模板库 + 历史)
|
||||
training_config: true,
|
||||
integration_connector: true, // 集成连接器配置
|
||||
transfer_types: true, // 在途调拨类型配置(ADR 0002)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getA
|
||||
|
||||
|
||||
|
||||
export type ShippingInventoryReadinessCheck = {
|
||||
export type ShippingOnhandReadinessCheck = {
|
||||
code: string;
|
||||
status: 'passed' | 'pending' | 'failed' | 'stale' | 'empty';
|
||||
blocking: boolean;
|
||||
@@ -49,15 +49,15 @@ export type ShippingInventoryReadinessCheck = {
|
||||
evidence: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export type ShippingInventoryReadiness = {
|
||||
export type ShippingOnhandReadiness = {
|
||||
ready: boolean;
|
||||
checks: ShippingInventoryReadinessCheck[];
|
||||
checks: ShippingOnhandReadinessCheck[];
|
||||
missing_requirements: string[];
|
||||
};
|
||||
|
||||
export type ShippingInventoryConfigurationTest = {
|
||||
export type ShippingOnhandConfigurationTest = {
|
||||
run_no: string;
|
||||
inventory_source_id: number;
|
||||
source_id: number;
|
||||
source_config_version: number;
|
||||
rpa_profile_config_version: number;
|
||||
status: 'awaiting_rpa' | 'processing' | 'completed' | 'completed_empty' | 'failed';
|
||||
@@ -76,7 +76,7 @@ export type ShippingInventoryConfigurationTest = {
|
||||
};
|
||||
};
|
||||
|
||||
export type ShippingInventoryValidationBatch = {
|
||||
export type ShippingOnhandValidationBatch = {
|
||||
id: number;
|
||||
batch_no: string;
|
||||
status: 'queued' | 'running' | 'completed' | 'partial_failed' | 'failed';
|
||||
@@ -85,7 +85,7 @@ export type ShippingInventoryValidationBatch = {
|
||||
empty_count: number;
|
||||
failed_count: number;
|
||||
stale_count: number;
|
||||
runs: ShippingInventoryConfigurationTest[];
|
||||
runs: ShippingOnhandConfigurationTest[];
|
||||
};
|
||||
|
||||
export type ShippingOrderExtractionDiagnosticAutoFreezePolicy = {
|
||||
@@ -171,8 +171,8 @@ export const getShippingOrderExtractionHealth = (windowHours = 24) => {
|
||||
};
|
||||
|
||||
/** 下载管理员可访问的库存快照,并保留服务端指定的原始文件名。 */
|
||||
export const downloadShippingInventorySnapshot = async (snapshotId: number, fallbackName: string): Promise<void> => {
|
||||
const response = await fetch(`/api/admin/shipping-notice/snapshots/${snapshotId}/download`, { headers: getAuthHeaders() });
|
||||
export const downloadShippingOnhandSnapshot = async (snapshotId: number, fallbackName: string): Promise<void> => {
|
||||
const response = await fetch(`/api/admin/freight-rpa/onhand/snapshots/${snapshotId}/download`, { headers: getAuthHeaders() });
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
const blob = await response.blob();
|
||||
const disposition = response.headers.get('Content-Disposition') || '';
|
||||
@@ -186,18 +186,18 @@ export const downloadShippingInventorySnapshot = async (snapshotId: number, fall
|
||||
};
|
||||
|
||||
/** 货代库存配置统一接口;敏感凭据仅能写入,服务端不会回显。 */
|
||||
export const getShippingInventoryConfig = async () => Promise.all([
|
||||
requestJson<unknown[]>('/api/admin/shipping-notice/rpa-profiles', auth()),
|
||||
requestJson<unknown[]>('/api/admin/shipping-notice/sources', auth()),
|
||||
requestJson<unknown[]>('/api/admin/shipping-notice/routing-rules', auth()),
|
||||
requestJson<unknown[]>('/api/admin/shipping-notice/external-mappings', auth()),
|
||||
requestJson<unknown[]>('/api/admin/shipping-notice/snapshots', auth()),
|
||||
requestJson<unknown[]>('/api/admin/shipping-notice/export-records', auth()),
|
||||
requestJson<unknown[]>('/api/admin/shipping-notice/parsing-profiles', auth()),
|
||||
export const getShippingOnhandConfig = async () => Promise.all([
|
||||
requestJson<unknown[]>('/api/admin/freight-rpa/rpa-profiles', auth()),
|
||||
requestJson<unknown[]>('/api/admin/freight-rpa/sources', auth()),
|
||||
requestJson<unknown[]>('/api/admin/freight-rpa/onhand/routing-rules', auth()),
|
||||
requestJson<unknown[]>('/api/admin/freight-rpa/onhand/external-mappings', auth()),
|
||||
requestJson<unknown[]>('/api/admin/freight-rpa/onhand/snapshots', auth()),
|
||||
requestJson<unknown[]>('/api/admin/freight-rpa/onhand/export-records', auth()),
|
||||
requestJson<unknown[]>('/api/admin/freight-rpa/onhand/parsing-profiles', auth()),
|
||||
requestJson<unknown[]>('/api/admin/shipping-notice/excel-templates', auth()),
|
||||
]);
|
||||
|
||||
export type ShippingInventoryField = {
|
||||
export type ShippingOnhandField = {
|
||||
id: number;
|
||||
display_name: string;
|
||||
description: string;
|
||||
@@ -208,20 +208,20 @@ export type ShippingInventoryField = {
|
||||
};
|
||||
|
||||
/** 管理可供不同库存文件解析方案复用的统一库存业务字段。 */
|
||||
export const getShippingInventoryFields = () => requestJson<ShippingInventoryField[]>(
|
||||
'/api/admin/shipping-notice/inventory-fields?include_retired=true', auth(),
|
||||
export const getShippingOnhandFields = () => requestJson<ShippingOnhandField[]>(
|
||||
'/api/admin/freight-rpa/onhand/fields?include_retired=true', auth(),
|
||||
);
|
||||
export const createShippingInventoryField = (payload: Omit<ShippingInventoryField, 'id' | 'status'>) => requestJson<ShippingInventoryField>(
|
||||
'/api/admin/shipping-notice/inventory-fields', { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
export const createShippingOnhandField = (payload: Omit<ShippingOnhandField, 'id' | 'status'>) => requestJson<ShippingOnhandField>(
|
||||
'/api/admin/freight-rpa/onhand/fields', { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
export const updateShippingInventoryField = (id: number, payload: Omit<ShippingInventoryField, 'id' | 'status'>) => requestJson<ShippingInventoryField>(
|
||||
`/api/admin/shipping-notice/inventory-fields/${id}`, { method: 'PUT', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
export const updateShippingOnhandField = (id: number, payload: Omit<ShippingOnhandField, 'id' | 'status'>) => requestJson<ShippingOnhandField>(
|
||||
`/api/admin/freight-rpa/onhand/fields/${id}`, { method: 'PUT', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
export const retireShippingInventoryField = (id: number) => requestJson<ShippingInventoryField>(
|
||||
`/api/admin/shipping-notice/inventory-fields/${id}/retire`, { method: 'POST', ...jsonAuth() },
|
||||
export const retireShippingOnhandField = (id: number) => requestJson<ShippingOnhandField>(
|
||||
`/api/admin/freight-rpa/onhand/fields/${id}/retire`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
export const deleteShippingInventoryField = (id: number) => requestJson<void>(
|
||||
`/api/admin/shipping-notice/inventory-fields/${id}`, { method: 'DELETE', ...auth() },
|
||||
export const deleteShippingOnhandField = (id: number) => requestJson<void>(
|
||||
`/api/admin/freight-rpa/onhand/fields/${id}`, { method: 'DELETE', ...auth() },
|
||||
);
|
||||
|
||||
/** 上传或更新版本化发货 Excel 模板;文件仅在创建草稿时提交。 */
|
||||
@@ -251,15 +251,15 @@ export const deleteShippingExcelTemplate = (id: number) => requestJson<void>(
|
||||
);
|
||||
|
||||
/** 读取库存路由可选的已发布订单字段。 */
|
||||
export const getShippingInventoryRoutingFields = () => requestJson<{
|
||||
export const getShippingOnhandRoutingFields = () => requestJson<{
|
||||
order_fields: Array<{ field_id: string; field_code: string; display_name: string; description?: string; scope: 'header' | 'line' }>;
|
||||
order_schema_published: boolean;
|
||||
}>('/api/admin/shipping-notice/routing-fields', auth());
|
||||
}>('/api/admin/freight-rpa/onhand/routing-fields', auth());
|
||||
|
||||
export type ShippingInventoryConfigurationCatalog = {
|
||||
export type ShippingOnhandConfigurationCatalog = {
|
||||
order_fields: Array<{ field_id: string; field_code: string; display_name: string; description?: string; scope: 'header' | 'line' }>;
|
||||
order_schema_published: boolean;
|
||||
inventory_fields: ShippingInventoryField[];
|
||||
inventory_fields: ShippingOnhandField[];
|
||||
template_system_facts: string[];
|
||||
template_source_kinds: Array<'order_field' | 'inventory_field' | 'system_fact' | 'constant'>;
|
||||
template_row_modes: Array<'header' | 'line'>;
|
||||
@@ -267,167 +267,175 @@ export type ShippingInventoryConfigurationCatalog = {
|
||||
};
|
||||
|
||||
/** 读取 Profile 与模板结构化编辑器使用的后端权威白名单。 */
|
||||
export const getShippingInventoryConfigurationCatalog = () =>
|
||||
requestJson<ShippingInventoryConfigurationCatalog>(
|
||||
'/api/admin/shipping-notice/configuration-catalog', auth(),
|
||||
export const getShippingOnhandConfigurationCatalog = () =>
|
||||
requestJson<ShippingOnhandConfigurationCatalog>(
|
||||
'/api/admin/freight-rpa/onhand/configuration-catalog', auth(),
|
||||
);
|
||||
|
||||
/** 保存和发布可复用库存解析 Profile。 */
|
||||
export const saveShippingInventoryParsingProfile = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/parsing-profiles${id ? `/${id}` : ''}`,
|
||||
export const saveShippingOnhandParsingProfile = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/parsing-profiles${id ? `/${id}` : ''}`,
|
||||
{ method: id ? 'PUT' : 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
export const publishShippingInventoryParsingProfile = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/parsing-profiles/${id}/publish`, { method: 'POST', ...jsonAuth() },
|
||||
export const publishShippingOnhandParsingProfile = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/parsing-profiles/${id}/publish`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
export const retireShippingInventoryParsingProfile = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/parsing-profiles/${id}/retire`, { method: 'POST', ...jsonAuth() },
|
||||
export const retireShippingOnhandParsingProfile = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/parsing-profiles/${id}/retire`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
export const deleteShippingInventoryParsingProfile = (id: number) => requestJson<void>(
|
||||
`/api/admin/shipping-notice/parsing-profiles/${id}`, { method: 'DELETE', ...auth() },
|
||||
export const deleteShippingOnhandParsingProfile = (id: number) => requestJson<void>(
|
||||
`/api/admin/freight-rpa/onhand/parsing-profiles/${id}`, { method: 'DELETE', ...auth() },
|
||||
);
|
||||
|
||||
/** 上传库存样本,由后端分析工作表、表头、栏位样例和字段建议。 */
|
||||
export const createShippingInventoryStructureAnalysis = (file: File) => {
|
||||
export const createShippingOnhandStructureAnalysis = (file: File) => {
|
||||
const form = new FormData();
|
||||
form.set('file', file);
|
||||
return requestJson<unknown>('/api/admin/shipping-notice/inventory-structure-analyses', {
|
||||
return requestJson<unknown>('/api/admin/freight-rpa/onhand/structure-analyses', {
|
||||
method: 'POST', body: form, ...auth(),
|
||||
});
|
||||
};
|
||||
/** 读取标准异动字段目录(只读领域契约,供收料异动解析规则映射表单)。 */
|
||||
/** 读取标准异动字段目录(只读领域契约,供入站/出站报表规则映射表单)。 */
|
||||
export const fetchMovementFields = () => requestJson<Array<{ code: string; value_type: string; required: boolean; is_identity: boolean }>>(
|
||||
'/api/admin/shipping-notice/movement-fields', auth(),
|
||||
'/api/admin/freight-rpa/movement-fields', auth(),
|
||||
);
|
||||
/** 用已分析的真实栏位创建库存文件解析方案草稿。 */
|
||||
export const createShippingInventoryParsingDraftFromAnalysis = (id: number, payload: Record<string, unknown>) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/inventory-structure-analyses/${id}/create-profile-draft`,
|
||||
export const createShippingOnhandParsingDraftFromAnalysis = (id: number, payload: Record<string, unknown>) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/structure-analyses/${id}/create-profile-draft`,
|
||||
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 样本替换先读取后端结构差异;管理员确认前不会改动草稿的审计证据。 */
|
||||
export const previewShippingInventorySampleReplacement = (profileId: number, analysisId: number, payload: Record<string, unknown> = {}) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/parsing-profiles/${profileId}/sample-replacement-preview/${analysisId}`,
|
||||
export const previewShippingOnhandSampleReplacement = (profileId: number, analysisId: number, payload: Record<string, unknown> = {}) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/parsing-profiles/${profileId}/sample-replacement-preview/${analysisId}`,
|
||||
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 确认复用后端推荐的已发布解析方案;库存站点绑定仍由后续测试流程确认。 */
|
||||
export const adoptShippingInventoryParsingProfile = (analysisId: number, profileId: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/inventory-structure-analyses/${analysisId}/adopt-profile`,
|
||||
export const adoptShippingOnhandParsingProfile = (analysisId: number, profileId: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/structure-analyses/${analysisId}/adopt-profile`,
|
||||
{ method: 'POST', body: JSON.stringify({ profile_id: profileId }), ...jsonAuth() },
|
||||
);
|
||||
/** 列出已确认、可由管理员沉淀为库存文件解析方案草稿的对话临时库存会话。 */
|
||||
export const listShippingTemporaryInventorySessions = () => requestJson<unknown>(
|
||||
'/api/admin/shipping-notice/temporary-inventory-sessions', auth(),
|
||||
/** 列出已确认、可由管理员沉淀为库存文件解析方案草稿的对话临时库存会话。路径留在 /api/admin/shipping-notice/temporary-onhand-sessions。 */
|
||||
export const listShippingTemporaryOnhandSessions = () => requestJson<unknown>(
|
||||
'/api/admin/shipping-notice/temporary-onhand-sessions', auth(),
|
||||
);
|
||||
/** 使用临时会话锁定的结构和映射创建草稿;前端提交的字段映射不会被接受。 */
|
||||
/** 使用临时会话锁定的结构和映射创建草稿;前端提交的字段映射不会被接受。路径为 /api/admin/shipping-notice/temporary-onhand-sessions/<sessionNo>/create-profile-draft。 */
|
||||
export const createShippingParsingDraftFromTemporarySession = (sessionNo: string, payload: Record<string, unknown>) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/temporary-inventory-sessions/${encodeURIComponent(sessionNo)}/create-profile-draft`,
|
||||
`/api/admin/shipping-notice/temporary-onhand-sessions/${encodeURIComponent(sessionNo)}/create-profile-draft`,
|
||||
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 保存 RPA Profile;password 未传或为空时由服务端保留旧密文。 */
|
||||
export const saveShippingRpaProfile = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/rpa-profiles${id ? `/${id}` : ''}`,
|
||||
`/api/admin/freight-rpa/rpa-profiles${id ? `/${id}` : ''}`,
|
||||
{ method: id ? 'PUT' : 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
export const deleteShippingRpaProfile = (id: number) => requestJson<void>(
|
||||
`/api/admin/shipping-notice/rpa-profiles/${id}`, { method: 'DELETE', ...auth() },
|
||||
`/api/admin/freight-rpa/rpa-profiles/${id}`, { method: 'DELETE', ...auth() },
|
||||
);
|
||||
|
||||
/** 保存 Inventory Source,服务端校验其 Driver 与 Profile 一致。 */
|
||||
export const saveShippingInventorySource = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/sources${id ? `/${id}` : ''}`,
|
||||
export const saveShippingOnhandSource = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/sources${id ? `/${id}` : ''}`,
|
||||
{ method: id ? 'PUT' : 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 读取/保存站点独立收料配置;严禁通过库存站点保存接口夹带这些字段。 */
|
||||
export const getShippingReceiptReportConfig = (sourceId: number) => requestJson<Record<string, unknown> | null>(
|
||||
`/api/admin/shipping-notice/sources/${sourceId}/receipt-report-config`, auth(),
|
||||
/** 读取/保存站点独立入站报表配置(/freight-rpa/sources/<id>/inbound-report-config);严禁通过库存站点保存接口夹带这些字段。 */
|
||||
export const getInboundReportConfig = (sourceId: number) => requestJson<Record<string, unknown> | null>(
|
||||
`/api/admin/freight-rpa/sources/${sourceId}/inbound-report-config`, auth(),
|
||||
);
|
||||
export const saveShippingReceiptReportConfig = (sourceId: number, payload: Record<string, unknown>) => requestJson<Record<string, unknown>>(
|
||||
`/api/admin/shipping-notice/sources/${sourceId}/receipt-report-config`,
|
||||
export const saveInboundReportConfig = (sourceId: number, payload: Record<string, unknown>) => requestJson<Record<string, unknown>>(
|
||||
`/api/admin/freight-rpa/sources/${sourceId}/inbound-report-config`,
|
||||
{ method: 'PUT', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 读取/保存站点独立出站报表配置;载荷键与入站相同,严禁夹带来源站点字段。 */
|
||||
export const getOutboundReportConfig = (sourceId: number) => requestJson<Record<string, unknown> | null>(
|
||||
`/api/admin/freight-rpa/sources/${sourceId}/outbound-report-config`, auth(),
|
||||
);
|
||||
export const saveOutboundReportConfig = (sourceId: number, payload: Record<string, unknown>) => requestJson<Record<string, unknown>>(
|
||||
`/api/admin/freight-rpa/sources/${sourceId}/outbound-report-config`,
|
||||
{ method: 'PUT', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 直接绑定停用库存站点到已发布解析方案;服务端自动写入操作审计。 */
|
||||
export const bindShippingInventorySourceParsingProfile = (id: number, payload: { parsing_profile_id: number }) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/sources/${id}/bind-parsing-profile`, { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
export const bindShippingOnhandSourceParsingProfile = (id: number, payload: { parsing_profile_id: number }) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/sources/${id}/bind-parsing-profile`, { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 原子批量绑定已发布解析方案;任一站点不合格时整批拒绝,避免部分更新。 */
|
||||
export const bulkBindShippingInventorySourceParsingProfile = (payload: { source_ids: number[]; parsing_profile_id: number }) => requestJson<unknown[]>(
|
||||
'/api/admin/shipping-notice/sources/bulk-bind-parsing-profile', { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
export const bulkBindShippingOnhandSourceParsingProfile = (payload: { source_ids: number[]; parsing_profile_id: number }) => requestJson<unknown[]>(
|
||||
'/api/admin/freight-rpa/sources/bulk-bind-parsing-profile', { method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
/** 读取站点解析方案绑定的可追溯审计记录。 */
|
||||
export const getShippingInventorySourceParsingBindingAudits = (id: number) => requestJson<unknown[]>(
|
||||
`/api/admin/shipping-notice/sources/${id}/parsing-binding-audits`, auth(),
|
||||
export const getShippingOnhandSourceParsingBindingAudits = (id: number) => requestJson<unknown[]>(
|
||||
`/api/admin/freight-rpa/sources/${id}/parsing-binding-audits`, auth(),
|
||||
);
|
||||
export const deleteShippingInventorySource = (id: number) => requestJson<void>(
|
||||
`/api/admin/shipping-notice/sources/${id}`, { method: 'DELETE', ...auth() },
|
||||
export const deleteShippingOnhandSource = (id: number) => requestJson<void>(
|
||||
`/api/admin/freight-rpa/sources/${id}`, { method: 'DELETE', ...auth() },
|
||||
);
|
||||
/** 仅在站点完成测试和必需绑定后启用正式库存运行。 */
|
||||
export const activateShippingInventorySource = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/sources/${id}/activate`, { method: 'POST', ...jsonAuth() },
|
||||
export const activateShippingOnhandSource = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/sources/${id}/activate`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
/** 停用库存站点但保留其既有配置和审计记录。 */
|
||||
export const deactivateShippingInventorySource = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/sources/${id}/deactivate`, { method: 'POST', ...jsonAuth() },
|
||||
export const deactivateShippingOnhandSource = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/sources/${id}/deactivate`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
/** 对停用库存站点发起异步 RPA 测试导出,测试文件不会进入生产库存池。 */
|
||||
export const startShippingInventoryConfigurationTest = (id: number) => requestJson<ShippingInventoryConfigurationTest>(
|
||||
`/api/admin/shipping-notice/sources/${id}/test-export`, { method: 'POST', ...jsonAuth() },
|
||||
export const startShippingOnhandConfigurationTest = (id: number) => requestJson<ShippingOnhandConfigurationTest>(
|
||||
`/api/admin/freight-rpa/sources/${id}/test-export`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
/** 查询库存站点测试导出与结构识别的后端真实状态。 */
|
||||
export const getShippingInventoryConfigurationTest = (id: number, runNo: string) => requestJson<ShippingInventoryConfigurationTest>(
|
||||
`/api/admin/shipping-notice/sources/${id}/test-export/${encodeURIComponent(runNo)}`, auth(),
|
||||
export const getShippingOnhandConfigurationTest = (id: number, runNo: string) => requestJson<ShippingOnhandConfigurationTest>(
|
||||
`/api/admin/freight-rpa/sources/${id}/test-export/${encodeURIComponent(runNo)}`, auth(),
|
||||
);
|
||||
/** 读取当前站点配置对应的最近测试,使刷新页面或重开抽屉时可恢复服务端真实状态。 */
|
||||
export const getLatestShippingInventoryConfigurationTest = (id: number) => requestJson<ShippingInventoryConfigurationTest | null>(
|
||||
`/api/admin/shipping-notice/sources/${id}/test-export/latest`, auth(),
|
||||
export const getLatestShippingOnhandConfigurationTest = (id: number) => requestJson<ShippingOnhandConfigurationTest | null>(
|
||||
`/api/admin/freight-rpa/sources/${id}/test-export/latest`, auth(),
|
||||
);
|
||||
/** 管理员确认测试结果使用的已发布解析方案,才更新停用库存站点绑定。 */
|
||||
export const confirmShippingInventoryConfigurationTestProfile = (id: number, runNo: string, profileId: number) => requestJson<any>(
|
||||
`/api/admin/shipping-notice/sources/${id}/test-export/${encodeURIComponent(runNo)}/confirm-profile`,
|
||||
export const confirmShippingOnhandConfigurationTestProfile = (id: number, runNo: string, profileId: number) => requestJson<any>(
|
||||
`/api/admin/freight-rpa/sources/${id}/test-export/${encodeURIComponent(runNo)}/confirm-profile`,
|
||||
{ method: 'POST', body: JSON.stringify({ profile_id: profileId }), ...jsonAuth() },
|
||||
);
|
||||
/** 对已绑定发布解析方案的多个停用站点发起受控批量测试。 */
|
||||
export const startShippingInventoryValidationBatch = (sourceIds: number[]) => requestJson<ShippingInventoryValidationBatch>(
|
||||
'/api/admin/shipping-notice/source-validation-batches', { method: 'POST', body: JSON.stringify({ source_ids: sourceIds }), ...jsonAuth() },
|
||||
export const startShippingOnhandValidationBatch = (sourceIds: number[]) => requestJson<ShippingOnhandValidationBatch>(
|
||||
'/api/admin/freight-rpa/onhand/validation-batches', { method: 'POST', body: JSON.stringify({ source_ids: sourceIds }), ...jsonAuth() },
|
||||
);
|
||||
/** 读取批量测试进度和逐站点独立结果。 */
|
||||
export const getShippingInventoryValidationBatch = (batchId: number) => requestJson<ShippingInventoryValidationBatch>(
|
||||
`/api/admin/shipping-notice/source-validation-batches/${batchId}`, auth(),
|
||||
export const getShippingOnhandValidationBatch = (batchId: number) => requestJson<ShippingOnhandValidationBatch>(
|
||||
`/api/admin/freight-rpa/onhand/validation-batches/${batchId}`, auth(),
|
||||
);
|
||||
/** 恢复最近尚未结束的批量测试,供刷新页面后继续展示进度。 */
|
||||
export const getLatestActiveShippingInventoryValidationBatch = () => requestJson<ShippingInventoryValidationBatch | null>(
|
||||
'/api/admin/shipping-notice/source-validation-batches/latest-active', auth(),
|
||||
export const getLatestActiveShippingOnhandValidationBatch = () => requestJson<ShippingOnhandValidationBatch | null>(
|
||||
'/api/admin/freight-rpa/onhand/validation-batches/latest-active', auth(),
|
||||
);
|
||||
/** 仅重试批次内失败或已过期的站点。 */
|
||||
export const retryFailedShippingInventoryValidationBatch = (batchId: number) => requestJson<ShippingInventoryValidationBatch>(
|
||||
`/api/admin/shipping-notice/source-validation-batches/${batchId}/retry-failed`, { method: 'POST', ...jsonAuth() },
|
||||
export const retryFailedShippingOnhandValidationBatch = (batchId: number) => requestJson<ShippingOnhandValidationBatch>(
|
||||
`/api/admin/freight-rpa/onhand/validation-batches/${batchId}/retry-failed`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 保存路由规则草稿;规则发布需调用独立接口以生成审计快照。 */
|
||||
export const saveShippingInventoryRule = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/routing-rules${id ? `/${id}` : ''}`,
|
||||
export const saveShippingOnhandRule = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/routing-rules${id ? `/${id}` : ''}`,
|
||||
{ method: id ? 'PUT' : 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 发布草稿规则,服务端会保存不可变定义快照。 */
|
||||
export const publishShippingInventoryRule = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/routing-rules/${id}/publish`,
|
||||
export const publishShippingOnhandRule = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/routing-rules/${id}/publish`,
|
||||
{ method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
export const retireShippingInventoryRule = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/routing-rules/${id}/retire`, { method: 'POST', ...jsonAuth() },
|
||||
export const retireShippingOnhandRule = (id: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/routing-rules/${id}/retire`, { method: 'POST', ...jsonAuth() },
|
||||
);
|
||||
export const deleteShippingInventoryRule = (id: number) => requestJson<void>(
|
||||
`/api/admin/shipping-notice/routing-rules/${id}`, { method: 'DELETE', ...auth() },
|
||||
export const deleteShippingOnhandRule = (id: number) => requestJson<void>(
|
||||
`/api/admin/freight-rpa/onhand/routing-rules/${id}`, { method: 'DELETE', ...auth() },
|
||||
);
|
||||
|
||||
/** 保存精确或 Source 默认外部系统映射。 */
|
||||
export const saveShippingInventoryExternalMapping = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/shipping-notice/external-mappings${id ? `/${id}` : ''}`,
|
||||
export const saveShippingOnhandExternalMapping = (payload: Record<string, unknown>, id?: number) => requestJson<unknown>(
|
||||
`/api/admin/freight-rpa/onhand/external-mappings${id ? `/${id}` : ''}`,
|
||||
{ method: id ? 'PUT' : 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
export const deleteShippingInventoryExternalMapping = (id: number) => requestJson<void>(
|
||||
`/api/admin/shipping-notice/external-mappings/${id}`, { method: 'DELETE', ...auth() },
|
||||
export const deleteShippingOnhandExternalMapping = (id: number) => requestJson<void>(
|
||||
`/api/admin/freight-rpa/onhand/external-mappings/${id}`, { method: 'DELETE', ...auth() },
|
||||
);
|
||||
export const listAdminTrainingConfigs = () =>
|
||||
requestJson<TrainingConfig[]>('/api/admin/training-configs', auth());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/api/schedule.api.ts
|
||||
* 管理后台定时任务 HTTP API:任务 CRUD、配置、测试执行、运行记录。
|
||||
* 管理后台定时任务 HTTP API:任务 CRUD、配置、测试执行、运行记录、库存/入站/出站 raw-zip。
|
||||
*/
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
@@ -159,8 +159,11 @@ export const adminRunExcelUrl = (runId: number) => `/api/admin/schedule-runs/${r
|
||||
export const adminRunInventoryRawZipUrl = (runId: number) =>
|
||||
`/api/admin/schedule-runs/${runId}/inventory-raw-zip`;
|
||||
|
||||
export const adminRunReceiptRawZipUrl = (runId: number) =>
|
||||
`/api/admin/schedule-runs/${runId}/receipt-raw-zip`;
|
||||
export const adminRunInboundRawZipUrl = (runId: number) =>
|
||||
`/api/admin/schedule-runs/${runId}/inbound-raw-zip`;
|
||||
|
||||
export const adminRunOutboundRawZipUrl = (runId: number) =>
|
||||
`/api/admin/schedule-runs/${runId}/outbound-raw-zip`;
|
||||
|
||||
export interface RpaWorkerHeartbeatWorker {
|
||||
worker_id?: string;
|
||||
@@ -181,7 +184,7 @@ export interface RpaWorkerHeartbeatWorker {
|
||||
}
|
||||
|
||||
export interface RpaWorkerHeartbeatSummary {
|
||||
scope?: 'inventory' | 'receipt' | string;
|
||||
scope?: 'onhand' | 'inbound' | 'outbound' | string;
|
||||
ready: boolean;
|
||||
message: string;
|
||||
detail_message?: string;
|
||||
@@ -195,7 +198,7 @@ export interface RpaWorkerHeartbeatSummary {
|
||||
workers: RpaWorkerHeartbeatWorker[];
|
||||
}
|
||||
|
||||
export const getAdminRpaWorkersStatus = (scope: 'inventory' | 'receipt' = 'inventory') =>
|
||||
export const getAdminRpaWorkersStatus = (scope: 'onhand' | 'inbound' | 'outbound' = 'onhand') =>
|
||||
getJson<RpaWorkerHeartbeatSummary>(`/api/admin/rpa-workers/status?scope=${encodeURIComponent(scope)}`);
|
||||
|
||||
export type { DifyExecutionSnapshot, ScheduleRun, ScheduleTask, StepLog, TestScheduleRunResult, TestScheduleSqlResult };
|
||||
@@ -11,7 +11,7 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
LayoutDashboard, UserCog, Building, Bot, FileText,
|
||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, BarChart2, AppWindow,
|
||||
ScrollText, ExternalLink, PackageSearch, GraduationCap, Cable,
|
||||
ScrollText, ExternalLink, PackageSearch, GraduationCap, Cable, ArrowLeftRight,
|
||||
} from 'lucide-vue-next';
|
||||
import type { Component } from 'vue';
|
||||
import { config } from '@/config';
|
||||
@@ -44,16 +44,18 @@ const iconMap: Record<AdminModuleId, Component> = {
|
||||
procurement_contract: ScrollText,
|
||||
training_config: GraduationCap,
|
||||
integration_connector: Cable,
|
||||
transfer_types: ArrowLeftRight,
|
||||
reports: BarChart2,
|
||||
shipping_inventory: PackageSearch,
|
||||
freight_rpa: PackageSearch,
|
||||
};
|
||||
|
||||
const visibleModules = computed(() =>
|
||||
ADMIN_MODULE_METAS.filter((item) => config.admin.modules[item.configKey] !== false),
|
||||
);
|
||||
|
||||
// 调拨类型(transfer_types)已移入货代管理子菜单(路由规则之下),不再作为顶级入口渲染
|
||||
const standardModules = computed(() =>
|
||||
visibleModules.value.filter((item) => item.id !== 'wecom' && item.id !== 'shipping_inventory'),
|
||||
visibleModules.value.filter((item) => item.id !== 'wecom' && item.id !== 'freight_rpa' && item.id !== 'transfer_types'),
|
||||
);
|
||||
|
||||
const isModuleActive = (moduleId: AdminModuleId): boolean =>
|
||||
@@ -61,11 +63,19 @@ const isModuleActive = (moduleId: AdminModuleId): boolean =>
|
||||
|
||||
const isReportsActive = computed(() => route.meta.adminModule === 'reports');
|
||||
const isWecomActive = computed(() => route.meta.adminModule === 'wecom');
|
||||
const isShippingActive = computed(() => route.meta.adminModule === 'shipping_inventory');
|
||||
// 货代管理激活态涵盖调拨类型:进入该子页时父菜单高亮并自动展开
|
||||
const isShippingActive = computed(() => (
|
||||
route.meta.adminModule === 'freight_rpa' || route.meta.adminModule === 'transfer_types'
|
||||
));
|
||||
|
||||
const shippingGroups = computed(() => [...new Set(SHIPPING_CONFIG_SUB_MODULE_METAS.map((item) => item.groupKey))]);
|
||||
const shippingExpanded = ref<Record<string, boolean>>({});
|
||||
|
||||
// 子菜单项可见性:调拨类型沿用自身的模块 config 开关,其余跟随货代管理父开关
|
||||
const visibleShippingSubMetas = computed(() =>
|
||||
SHIPPING_CONFIG_SUB_MODULE_METAS.filter((item) => item.id !== 'transfer_types' || config.admin.modules.transfer_types !== false),
|
||||
);
|
||||
|
||||
const isShippingSubActive = (sub: (typeof SHIPPING_CONFIG_SUB_MODULE_METAS)[number]): boolean => {
|
||||
if (route.name !== sub.routeName) return false;
|
||||
if (!sub.query) return true;
|
||||
@@ -200,7 +210,7 @@ watch(
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="config.admin.modules.shipping_inventory !== false" class="flex flex-col flex-shrink-0">
|
||||
<div v-if="config.admin.modules.freight_rpa !== false" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="admin-nav-btn group justify-between"
|
||||
@@ -223,7 +233,7 @@ watch(
|
||||
</button>
|
||||
<div v-if="shippingExpanded[groupKey]" class="pl-3 space-y-1">
|
||||
<button
|
||||
v-for="sub in SHIPPING_CONFIG_SUB_MODULE_METAS.filter((item) => item.groupKey === groupKey)"
|
||||
v-for="sub in visibleShippingSubMetas.filter((item) => item.groupKey === groupKey)"
|
||||
:key="sub.id"
|
||||
type="button"
|
||||
class="admin-nav-subitem text-left"
|
||||
|
||||
@@ -16,14 +16,15 @@ export interface AdminModuleMeta {
|
||||
export interface ShippingConfigSubModuleMeta {
|
||||
id: ShippingConfigSubModuleId;
|
||||
routeName:
|
||||
| 'AdminShippingInventory'
|
||||
| 'AdminFreightRpa'
|
||||
| 'AdminShippingFieldAssets'
|
||||
| 'AdminShippingOrderSchema'
|
||||
| 'AdminShippingIdentityRules'
|
||||
| 'AdminShippingOrderExtractionRuns'
|
||||
| 'AdminShippingAudit'
|
||||
| 'AdminShippingProcessGates'
|
||||
| 'AdminShippingOrderDocumentProfiles';
|
||||
| 'AdminShippingOrderDocumentProfiles'
|
||||
| 'AdminTransferTypes';
|
||||
path:
|
||||
| 'shipping-notice'
|
||||
| 'shipping-field-assets'
|
||||
@@ -32,15 +33,16 @@ export interface ShippingConfigSubModuleMeta {
|
||||
| 'shipping-order-extraction-runs'
|
||||
| 'shipping-audit'
|
||||
| 'shipping-process-gates'
|
||||
| 'shipping-order-document-profiles';
|
||||
| 'shipping-order-document-profiles'
|
||||
| 'transfer-types';
|
||||
labelKey: string;
|
||||
groupKey: 'admin.nav.shippingOrderRecognition' | 'admin.nav.shippingInventoryManagement' | 'admin.nav.shippingRunAudit';
|
||||
groupKey: 'admin.nav.shippingOrderRecognition' | 'admin.nav.freightRpaManagement' | 'admin.nav.shippingRunAudit';
|
||||
query?: { section: 'parsing' | 'profiles' | 'sources' | 'mappings' | 'rules' | 'templates' | 'snapshots' | 'exports' };
|
||||
}
|
||||
|
||||
/** 已独立拆分的模块(全部 admin 模块均已拆分) */
|
||||
export const STANDALONE_ADMIN_MODULES = new Set<AdminModuleId>([
|
||||
'dashboard', 'agents', 'users', 'departments', 'announcements', 'questions', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'shipping_inventory', 'procurement_contract', 'reports', 'training_config', 'integration_connector'
|
||||
'dashboard', 'agents', 'users', 'departments', 'announcements', 'questions', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'freight_rpa', 'procurement_contract', 'reports', 'training_config', 'integration_connector', 'transfer_types'
|
||||
]);
|
||||
|
||||
export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
@@ -50,7 +52,7 @@ export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'agents', routeName: 'AdminAgents', path: 'agents', labelKey: 'admin.nav.agents', configKey: 'agents' },
|
||||
{ id: 'knowledge_base', routeName: 'AdminKnowledgeBase', path: 'knowledge-base', labelKey: 'admin.nav.knowledgeBase', configKey: 'knowledge_base' },
|
||||
{ id: 'schedules', routeName: 'AdminSchedules', path: 'schedules', labelKey: 'admin.nav.schedules', configKey: 'schedules' },
|
||||
{ id: 'shipping_inventory', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.nav.shippingConfig', configKey: 'shipping_inventory' },
|
||||
{ id: 'freight_rpa', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.nav.shippingConfig', configKey: 'freight_rpa' },
|
||||
{ id: 'announcements', routeName: 'AdminAnnouncements', path: 'announcements', labelKey: 'admin.nav.announcements', configKey: 'announcements' },
|
||||
{ id: 'questions', routeName: 'AdminQuestions', path: 'questions', labelKey: 'admin.nav.questions', configKey: 'questions' },
|
||||
{ id: 'wecom', routeName: 'AdminWecom', path: 'wecom', labelKey: 'admin.nav.wecom', configKey: 'wecom' },
|
||||
@@ -60,6 +62,7 @@ export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'procurement_contract', routeName: 'AdminProcurementContract', path: 'procurement-contract', labelKey: 'admin.nav.procurementContract', configKey: 'procurement_contract' },
|
||||
{ id: 'training_config', routeName: 'AdminTrainingConfig', path: 'training-config', labelKey: 'admin.nav.trainingConfig', configKey: 'training_config' },
|
||||
{ id: 'integration_connector', routeName: 'AdminIntegrationConnector', path: 'integration-connector', labelKey: 'admin.nav.integrationConnector', configKey: 'integration_connector' },
|
||||
{ id: 'transfer_types', routeName: 'AdminTransferTypes', path: 'transfer-types', labelKey: 'admin.nav.transferTypes', configKey: 'transfer_types' },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -76,16 +79,18 @@ export const SHIPPING_CONFIG_SUB_MODULE_METAS: ShippingConfigSubModuleMeta[] = [
|
||||
{ id: 'order_document_profiles', routeName: 'AdminShippingOrderDocumentProfiles', path: 'shipping-order-document-profiles', labelKey: 'admin.nav.shippingOrderDocumentProfiles', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'identity_rules', routeName: 'AdminShippingIdentityRules', path: 'shipping-identity-rules', labelKey: 'admin.nav.shippingIdentityRules', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'order_extraction_runs', routeName: 'AdminShippingOrderExtractionRuns', path: 'shipping-order-extraction-runs', labelKey: 'admin.nav.shippingOrderExtractionRuns', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'inventory_fields', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.parsingProfiles', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'parsing' } },
|
||||
{ id: 'connections', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.connections', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'profiles' } },
|
||||
{ id: 'inventory_sites', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.sources', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'sources' } },
|
||||
{ id: 'warehouse_mappings', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.externalMappings', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'mappings' } },
|
||||
{ id: 'routing_rules', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.rules', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'rules' } },
|
||||
{ id: 'shipping_templates', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.excelTemplates', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'templates' } },
|
||||
{ id: 'inventory_fields', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.parsingProfiles', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'parsing' } },
|
||||
{ id: 'connections', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.connections', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'profiles' } },
|
||||
{ id: 'inventory_sites', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.sources', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'sources' } },
|
||||
{ id: 'warehouse_mappings', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.externalMappings', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'mappings' } },
|
||||
{ id: 'routing_rules', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.rules', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'rules' } },
|
||||
// 调拨类型(原顶级入口「在途调拨类型」移入货代管理,挂在路由规则之下;路由独立注册于 AdminTransferTypes)
|
||||
{ id: 'transfer_types', routeName: 'AdminTransferTypes', path: 'transfer-types', labelKey: 'admin.nav.transferTypes', groupKey: 'admin.nav.freightRpaManagement' },
|
||||
{ id: 'shipping_templates', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.excelTemplates', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'templates' } },
|
||||
{ id: 'shipping_audit', routeName: 'AdminShippingAudit', path: 'shipping-audit', labelKey: 'admin.nav.shippingAudit', groupKey: 'admin.nav.shippingRunAudit' },
|
||||
{ id: 'process_gates', routeName: 'AdminShippingProcessGates', path: 'shipping-process-gates', labelKey: 'admin.nav.shippingProcessGates', groupKey: 'admin.nav.shippingRunAudit' },
|
||||
{ id: 'inventory_snapshots', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.snapshots', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'snapshots' } },
|
||||
{ id: 'export_records', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.exports', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'exports' } },
|
||||
{ id: 'inventory_snapshots', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.snapshots', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'snapshots' } },
|
||||
{ id: 'export_records', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.exports', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'exports' } },
|
||||
];
|
||||
|
||||
export const ADMIN_REPORT_TABLES: AdminReportTableId[] = [
|
||||
@@ -97,7 +102,10 @@ export const ADMIN_REPORT_TABLES: AdminReportTableId[] = [
|
||||
'issue_analysis',
|
||||
];
|
||||
|
||||
export const LEGACY_MODULE_QUERY_TO_PATH: Record<string, string> = {};
|
||||
/** 旧 /admin?module=shipping_inventory 落到货代 RPA 页 /admin/shipping-notice,不再拼出死路径。 */
|
||||
export const LEGACY_MODULE_QUERY_TO_PATH: Record<string, string> = {
|
||||
shipping_inventory: 'shipping-notice',
|
||||
};
|
||||
|
||||
export const adminModulePath = (moduleId: AdminModuleId | string): string => {
|
||||
if (moduleId === 'reports') return '/admin/reports';
|
||||
|
||||
@@ -10,3 +10,4 @@ export { adminModulePath, ADMIN_MODULE_METAS } from './constants/modules';
|
||||
export type { AdminModuleId } from './types/admin.types';
|
||||
export * from './api/admin.api';
|
||||
export * from './api/schedule.api';
|
||||
export * from './modules/transfer-types/transferTypes.api';
|
||||
File diff suppressed because it is too large.
Load diff
+13
-13
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/receiptReportConfigForm.spec.ts
|
||||
* 用途:覆盖收料报表表单的独立载荷边界。
|
||||
* 依赖:receiptReportConfigForm、vitest。
|
||||
* 逻辑:防止收料配置保存时把库存站点路径、库存查询条件或启停状态误发到库存接口;
|
||||
* 收料无独立启停字段,载荷不得包含 enabled。
|
||||
* features/admin/modules/freight-rpa/inboundReportConfigForm.spec.ts
|
||||
* 用途:覆盖入站报表表单的独立载荷边界。
|
||||
* 依赖:inboundReportConfigForm、vitest。
|
||||
* 逻辑:防止入站配置保存时把来源站点路径、库存查询条件或启停状态误发到库存接口;
|
||||
* 入站无独立启停字段,载荷不得包含 enabled。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildReceiptReportConfigPayload } from './receiptReportConfigForm';
|
||||
import { buildInboundReportConfigPayload } from './inboundReportConfigForm';
|
||||
|
||||
describe('receiptReportConfigForm', () => {
|
||||
it('builds a receipt-only payload without inventory source fields', () => {
|
||||
// 关键断言:收料路径与条件必须走独立 API,不能夹带库存 RPA 配置或启停字段。
|
||||
const payload = buildReceiptReportConfigPayload({
|
||||
describe('inboundReportConfigForm', () => {
|
||||
it('builds an inbound-only payload without inventory source fields', () => {
|
||||
// 关键断言:入站路径与条件必须走独立 API,不能夹带来源站点 RPA 配置或启停字段。
|
||||
const payload = buildInboundReportConfigPayload({
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt Detail' },
|
||||
query_parameters_json: [
|
||||
{ name: 'Warehouse', mode: 'multi_text', values: ['AWSDU', 'AWSDU-02'], required: false, select_all: false },
|
||||
@@ -23,7 +23,7 @@ describe('receiptReportConfigForm', () => {
|
||||
enabled: true,
|
||||
warehouse_ids_json: ['SHOULD-NOT-LEAK'],
|
||||
inventory_report_path_json: { report_name: 'On Hand' },
|
||||
} as Parameters<typeof buildReceiptReportConfigPayload>[0] & Record<string, unknown>);
|
||||
} as Parameters<typeof buildInboundReportConfigPayload>[0] & Record<string, unknown>);
|
||||
|
||||
expect(payload).toEqual({
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt Detail' },
|
||||
@@ -42,14 +42,14 @@ describe('receiptReportConfigForm', () => {
|
||||
|
||||
it('carries movement profile binding and normalizes absent id to explicit unbind', () => {
|
||||
// 关键断言:异动解析绑定随配置提交;未绑定时必须显式提交 null(解绑),不能省略键。
|
||||
const bound = buildReceiptReportConfigPayload({
|
||||
const bound = buildInboundReportConfigPayload({
|
||||
report_path_json: { report_name: 'Inbound Details' },
|
||||
query_parameters_json: [],
|
||||
parsing_profile_id: 7,
|
||||
});
|
||||
expect(bound.parsing_profile_id).toBe(7);
|
||||
|
||||
const unbound = buildReceiptReportConfigPayload({
|
||||
const unbound = buildInboundReportConfigPayload({
|
||||
report_path_json: { report_name: 'Inbound Details' },
|
||||
query_parameters_json: [],
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/inboundReportConfigForm.ts
|
||||
* 用途:构建独立入站报表配置的受限保存载荷。
|
||||
* 依赖:无外部依赖。
|
||||
* 逻辑:页面仅将入站路径与查询条件提交到 /api/admin/freight-rpa/sources/<id>/inbound-report-config,与库存同构(查询条件可选,空=页面默认),
|
||||
* 隔离来源站点字段;入站无独立启停字段,是否运行统一由来源站点 enabled 决定。
|
||||
*/
|
||||
|
||||
export type InboundReportConfigInput = {
|
||||
report_path_json: Record<string, unknown>;
|
||||
query_parameters_json: Array<Record<string, unknown>>;
|
||||
/** 入站异动解析规则绑定;0/undefined 视为未绑定并归一为 null(显式解绑)。 */
|
||||
parsing_profile_id?: number | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 构造独立入站配置保存载荷。
|
||||
* 核心逻辑:白名单复制可配置业务字段,不允许调用方把库存源、Profile 或启停字段带入入站 API;
|
||||
* 异动解析绑定随配置一并提交(null=解绑)。
|
||||
* @param input - 抽屉中的入站配置表单状态。
|
||||
* @returns 仅包含入站配置 API 支持字段的深拷贝载荷。
|
||||
*/
|
||||
export function buildInboundReportConfigPayload(input: InboundReportConfigInput): InboundReportConfigInput {
|
||||
return {
|
||||
report_path_json: { ...(input.report_path_json || {}) },
|
||||
query_parameters_json: (input.query_parameters_json || []).map((item) => ({ ...item })),
|
||||
parsing_profile_id: input.parsing_profile_id ? Number(input.parsing_profile_id) : null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/movementFieldLabels.spec.ts
|
||||
* 用途:锁定库存解析管理页「标准异动字段」标签映射与后端 MOVEMENT_FIELDS 契约一致。
|
||||
* 依赖:vitest、四语言 locales 下各 admin.json。
|
||||
* 逻辑:页面用 `movementFields.${item.code}` 动态取标签,code 集合由后端目录接口
|
||||
* (movement_contract.MOVEMENT_FIELDS)在运行期下发,静态 i18n 工具查不出缺键——
|
||||
* 后端扩字段而语言包未同步时,界面会把原始 key(如 admin.freightRpa.
|
||||
* movementFields.order_type)直接渲染给用户(2026-10-15 实测回归)。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import zhCN from '@/locales/zh-CN/admin.json';
|
||||
import zhTW from '@/locales/zh-TW/admin.json';
|
||||
import en from '@/locales/en/admin.json';
|
||||
import th from '@/locales/th/admin.json';
|
||||
|
||||
// 后端权威契约:backend/app/services/in_transit_transfer/movement_contract.py MOVEMENT_FIELDS。
|
||||
// ⚠️ 后端追加/删除异动字段时,必须同步此列表与四语言包 movementFields(i18n 四语言红线)。
|
||||
const BACKEND_MOVEMENT_FIELD_CODES = [
|
||||
'doc_no', 'line_no', 'in_out_flag', 'material_code', 'material_name',
|
||||
'warehouse_code', 'storage_code', 'lot_no', 'quantity', 'movement_date', 'unit',
|
||||
'line_seq', 'specification', 'order_type', 'odm_id', 'odm_name', 'carton_id', 'pallet_id',
|
||||
'external_doc_no', 'external_line_no',
|
||||
] as const;
|
||||
|
||||
const LABEL_MAPS: Record<string, Record<string, string>> = {
|
||||
'zh-CN': (zhCN as Record<string, any>).freightRpa.movementFields,
|
||||
'zh-TW': (zhTW as Record<string, any>).freightRpa.movementFields,
|
||||
en: (en as Record<string, any>).freightRpa.movementFields,
|
||||
th: (th as Record<string, any>).freightRpa.movementFields,
|
||||
};
|
||||
|
||||
describe('movementFieldLabels', () => {
|
||||
it('四语言 movementFields 与后端 MOVEMENT_FIELDS 契约逐键对齐', () => {
|
||||
for (const [locale, labels] of Object.entries(LABEL_MAPS)) {
|
||||
const codes = Object.keys(labels);
|
||||
// 关键断言:不缺键(缺键=界面渲染原始 key)、不多键(多键=契约外死键误导维护者)。
|
||||
expect(codes.sort(), `${locale} 缺键/多键`).toEqual([...BACKEND_MOVEMENT_FIELD_CODES].sort());
|
||||
// 关键断言:每个标签都是非空真实文案,防止键在但值为空。
|
||||
for (const code of codes) expect(labels[code].trim().length, `${locale}.${code}`).toBeGreaterThan(0);
|
||||
}
|
||||
});
|
||||
|
||||
it('四语言之间标签键集互相同步(防单语言先行漂移)', () => {
|
||||
const keySets = Object.values(LABEL_MAPS).map((labels) => Object.keys(labels).sort());
|
||||
// 关键断言:任一语言补键时必须四语言同时补齐。
|
||||
for (const keySet of keySets.slice(1)) expect(keySet).toEqual(keySets[0]);
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/movementParsingProfileForm.spec.ts
|
||||
* features/admin/modules/freight-rpa/movementParsingProfileForm.spec.ts
|
||||
* 用途:覆盖收料异动解析规则映射的组装边界。
|
||||
* 依赖:movementParsingProfileForm、vitest。
|
||||
* 逻辑:标准异动字段是只读领域契约——映射键必须是契约 code,必填字段缺失要阻断保存。
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/movementParsingProfileForm.ts
|
||||
* 用途:组装收料异动解析规则(purpose='movement')的标准字段映射载荷。
|
||||
* features/admin/modules/freight-rpa/movementParsingProfileForm.ts
|
||||
* 用途:组装入站/出站解析规则(purpose='inbound'|'outbound')的标准异动字段映射载荷。
|
||||
* 依赖:无外部依赖。
|
||||
* 逻辑:标准异动字段目录由后端 /admin/shipping-notice/movement-fields 只读下发,
|
||||
* 逻辑:标准异动字段目录由后端 /admin/freight-rpa/movement-fields 只读下发,
|
||||
* 本模块只做裁剪与校验——映射键是契约 code,必填字段缺失阻断保存;
|
||||
* 不提供任何自定义字段的入口(业务领域字段不允许用户自定义)。
|
||||
*/
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/outboundReportConfigForm.spec.ts
|
||||
* 用途:覆盖出站报表表单的独立载荷边界。
|
||||
* 依赖:outboundReportConfigForm、vitest。
|
||||
* 逻辑:防止出站配置保存时把来源站点路径、库存查询条件或启停状态误发到库存接口;
|
||||
* 出站无独立启停字段,载荷不得包含 enabled。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildOutboundReportConfigPayload } from './outboundReportConfigForm';
|
||||
|
||||
describe('outboundReportConfigForm', () => {
|
||||
it('builds an outbound-only payload without inventory source fields', () => {
|
||||
// 关键断言:出站路径与条件必须走独立 API,不能夹带来源站点 RPA 配置或启停字段。
|
||||
const payload = buildOutboundReportConfigPayload({
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Outbound', report_name: 'Outbound Detail' },
|
||||
query_parameters_json: [
|
||||
{ name: 'Warehouse', mode: 'multi_text', values: ['AWSDU', 'AWSDU-02'], required: false, select_all: false },
|
||||
{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false },
|
||||
],
|
||||
source_code: 'INVENTORY-SHOULD-NOT-LEAK',
|
||||
snapshot_ttl_seconds: 86400,
|
||||
enabled: true,
|
||||
warehouse_ids_json: ['SHOULD-NOT-LEAK'],
|
||||
inventory_report_path_json: { report_name: 'On Hand' },
|
||||
} as Parameters<typeof buildOutboundReportConfigPayload>[0] & Record<string, unknown>);
|
||||
|
||||
expect(payload).toEqual({
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Outbound', report_name: 'Outbound Detail' },
|
||||
query_parameters_json: [
|
||||
{ name: 'Warehouse', mode: 'multi_text', values: ['AWSDU', 'AWSDU-02'], required: false, select_all: false },
|
||||
{ name: 'Owner', mode: 'single', values: ['AWS'], required: false, select_all: false },
|
||||
],
|
||||
parsing_profile_id: null,
|
||||
});
|
||||
expect(payload).not.toHaveProperty('source_code');
|
||||
expect(payload).not.toHaveProperty('snapshot_ttl_seconds');
|
||||
expect(payload).not.toHaveProperty('enabled');
|
||||
expect(payload).not.toHaveProperty('warehouse_ids_json');
|
||||
});
|
||||
|
||||
it('carries movement profile binding and normalizes absent id to explicit unbind', () => {
|
||||
// 关键断言:异动解析绑定随配置提交;未绑定时必须显式提交 null(解绑),不能省略键。
|
||||
const bound = buildOutboundReportConfigPayload({
|
||||
report_path_json: { report_name: 'Outbound Details' },
|
||||
query_parameters_json: [],
|
||||
parsing_profile_id: 9,
|
||||
});
|
||||
expect(bound.parsing_profile_id).toBe(9);
|
||||
|
||||
const unbound = buildOutboundReportConfigPayload({
|
||||
report_path_json: { report_name: 'Outbound Details' },
|
||||
query_parameters_json: [],
|
||||
});
|
||||
expect(unbound.parsing_profile_id).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/outboundReportConfigForm.ts
|
||||
* 用途:构建独立出站报表配置的受限保存载荷。
|
||||
* 依赖:无外部依赖。
|
||||
* 逻辑:页面仅将出站路径与查询条件提交到 /api/admin/freight-rpa/sources/<id>/outbound-report-config,与入站同构(查询条件可选,空=页面默认),
|
||||
* 隔离来源站点字段;出站无独立启停字段,是否运行统一由来源站点 enabled 决定。
|
||||
*/
|
||||
|
||||
export type OutboundReportConfigInput = {
|
||||
report_path_json: Record<string, unknown>;
|
||||
query_parameters_json: Array<Record<string, unknown>>;
|
||||
/** 出站异动解析规则绑定;0/undefined 视为未绑定并归一为 null(显式解绑)。 */
|
||||
parsing_profile_id?: number | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 构造独立出站配置保存载荷。
|
||||
* 核心逻辑:白名单复制可配置业务字段,不允许调用方把库存源、Profile 或启停字段带入出站 API;
|
||||
* 异动解析绑定随配置一并提交(null=解绑)。
|
||||
* @param input - 抽屉中的出站配置表单状态。
|
||||
* @returns 仅包含出站配置 API 支持字段的深拷贝载荷。
|
||||
*/
|
||||
export function buildOutboundReportConfigPayload(input: OutboundReportConfigInput): OutboundReportConfigInput {
|
||||
return {
|
||||
report_path_json: { ...(input.report_path_json || {}) },
|
||||
query_parameters_json: (input.query_parameters_json || []).map((item) => ({ ...item })),
|
||||
parsing_profile_id: input.parsing_profile_id ? Number(input.parsing_profile_id) : null,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/parsingProfileListGroups.spec.ts
|
||||
* 用途:覆盖报表规则列表「按用途分组 → 组内按编号排序」的纯函数契约。
|
||||
* 依赖:parsingProfileListGroups、vitest。
|
||||
* 逻辑:分组顺序与编号序是列表扫读的稳定契约,变更必须显式同步。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { groupParsingProfilesByPurpose, sortParsingProfiles } from './parsingProfileListGroups';
|
||||
|
||||
describe('parsingProfileListGroups', () => {
|
||||
it('sorts by purpose order then profile_code then version desc', () => {
|
||||
// 关键断言:库存→入站→出站;同组内编号升序;同编号高版本在前。
|
||||
const sorted = sortParsingProfiles([
|
||||
{ id: 1, purpose: 'outbound', profile_code: 'Z_OUT', version: 1 },
|
||||
{ id: 2, purpose: 'onhand', profile_code: 'B_ON', version: 1 },
|
||||
{ id: 3, purpose: 'inbound', profile_code: 'A_IN', version: 1 },
|
||||
{ id: 4, purpose: 'onhand', profile_code: 'A_ON', version: 1 },
|
||||
{ id: 5, purpose: 'onhand', profile_code: 'A_ON', version: 2 },
|
||||
]);
|
||||
expect(sorted.map((row) => `${row.purpose}:${row.profile_code}:V${row.version}`)).toEqual([
|
||||
'onhand:A_ON:V2',
|
||||
'onhand:A_ON:V1',
|
||||
'onhand:B_ON:V1',
|
||||
'inbound:A_IN:V1',
|
||||
'outbound:Z_OUT:V1',
|
||||
]);
|
||||
});
|
||||
|
||||
it('groups by purpose in fixed order and omits empty groups', () => {
|
||||
// 关键断言:空用途不渲染分组壳;组内已按编号排好。
|
||||
const groups = groupParsingProfilesByPurpose([
|
||||
{ id: 1, purpose: 'outbound', profile_code: 'B_OUT', version: 1 },
|
||||
{ id: 2, purpose: 'outbound', profile_code: 'A_OUT', version: 1 },
|
||||
{ id: 3, purpose: 'onhand', profile_code: 'M_ON', version: 1 },
|
||||
]);
|
||||
expect(groups.map((group) => group.purpose)).toEqual(['onhand', 'outbound']);
|
||||
expect(groups[0].items.map((row) => row.profile_code)).toEqual(['M_ON']);
|
||||
expect(groups[1].items.map((row) => row.profile_code)).toEqual(['A_OUT', 'B_OUT']);
|
||||
});
|
||||
|
||||
it('treats unknown purpose as last bucket after outbound', () => {
|
||||
const groups = groupParsingProfilesByPurpose([
|
||||
{ id: 1, purpose: 'legacy', profile_code: 'X', version: 1 },
|
||||
{ id: 2, purpose: 'inbound', profile_code: 'I', version: 1 },
|
||||
]);
|
||||
expect(groups.map((group) => group.purpose)).toEqual(['inbound', 'legacy']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/parsingProfileListGroups.ts
|
||||
* 用途:报表规则列表排序与按用途分组(库存 → 入站 → 出站)。
|
||||
* 依赖:无;纯函数,供 FreightRpaPage 列表渲染使用。
|
||||
* 逻辑:先按固定用途序,再按 profile_code 升序,同编号取 version 降序;空组不产出。
|
||||
*/
|
||||
|
||||
/** 规则用途:与后端 freight_rpa_parsing_profiles.purpose 对齐。 */
|
||||
export type ParsingProfilePurpose = 'onhand' | 'inbound' | 'outbound' | string;
|
||||
|
||||
/** 列表分组最小字段;其它卡片字段原样透传。 */
|
||||
export type ParsingProfileListItem = {
|
||||
purpose?: ParsingProfilePurpose | null;
|
||||
profile_code?: string | null;
|
||||
version?: number | null;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
export type ParsingProfileListGroup<T extends ParsingProfileListItem = ParsingProfileListItem> = {
|
||||
purpose: string;
|
||||
items: T[];
|
||||
};
|
||||
|
||||
/** 固定分组顺序:与业务绑定对象(库存站 / 入站配置 / 出站配置)一致。 */
|
||||
export const PARSING_PURPOSE_ORDER = ['onhand', 'inbound', 'outbound'] as const;
|
||||
|
||||
/**
|
||||
* 用途在固定序中的排序权重;未知用途排在已知用途之后。
|
||||
* @param purpose - 规则用途
|
||||
* @returns 越小越靠前
|
||||
*/
|
||||
function purposeRank(purpose: string): number {
|
||||
const index = (PARSING_PURPOSE_ORDER as readonly string[]).indexOf(purpose);
|
||||
return index >= 0 ? index : PARSING_PURPOSE_ORDER.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较两条解析规则的列表序。
|
||||
* 核心逻辑:用途序 → 编号升序(忽略大小写)→ 版本降序。
|
||||
* @param left - 左侧规则
|
||||
* @param right - 右侧规则
|
||||
* @returns 负/零/正,供 Array.sort 使用
|
||||
*/
|
||||
export function compareParsingProfiles(
|
||||
left: ParsingProfileListItem,
|
||||
right: ParsingProfileListItem,
|
||||
): number {
|
||||
const leftPurpose = String(left.purpose || '').trim().toLowerCase();
|
||||
const rightPurpose = String(right.purpose || '').trim().toLowerCase();
|
||||
const byPurpose = purposeRank(leftPurpose) - purposeRank(rightPurpose);
|
||||
if (byPurpose !== 0) return byPurpose;
|
||||
|
||||
const leftCode = String(left.profile_code || '').trim();
|
||||
const rightCode = String(right.profile_code || '').trim();
|
||||
const byCode = leftCode.localeCompare(rightCode, undefined, { sensitivity: 'base' });
|
||||
if (byCode !== 0) return byCode;
|
||||
|
||||
return Number(right.version || 0) - Number(left.version || 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按列表契约排序解析规则(扁平结果,供查找 / 空态计数复用)。
|
||||
* @param items - 原始规则列表
|
||||
* @returns 新数组,不修改入参
|
||||
*/
|
||||
export function sortParsingProfiles<T extends ParsingProfileListItem>(items: readonly T[]): T[] {
|
||||
return [...items].sort(compareParsingProfiles);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按用途分组;组顺序固定,空组省略,组内已排序。
|
||||
* @param items - 原始规则列表
|
||||
* @returns 非空分组列表
|
||||
*/
|
||||
export function groupParsingProfilesByPurpose<T extends ParsingProfileListItem>(
|
||||
items: readonly T[],
|
||||
): ParsingProfileListGroup<T>[] {
|
||||
const sorted = sortParsingProfiles(items);
|
||||
const buckets = new Map<string, T[]>();
|
||||
|
||||
for (const item of sorted) {
|
||||
const purpose = String(item.purpose || '').trim().toLowerCase() || 'unknown';
|
||||
const bucket = buckets.get(purpose);
|
||||
if (bucket) bucket.push(item);
|
||||
else buckets.set(purpose, [item]);
|
||||
}
|
||||
|
||||
const orderedPurposes = [
|
||||
...PARSING_PURPOSE_ORDER.filter((purpose) => buckets.has(purpose)),
|
||||
...[...buckets.keys()].filter(
|
||||
(purpose) => !(PARSING_PURPOSE_ORDER as readonly string[]).includes(purpose),
|
||||
),
|
||||
];
|
||||
|
||||
return orderedPurposes.map((purpose) => ({
|
||||
purpose,
|
||||
items: buckets.get(purpose) || [],
|
||||
}));
|
||||
}
|
||||
+7
-7
@@ -1,20 +1,20 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/shippingInventoryReadiness.spec.ts
|
||||
* features/admin/modules/freight-rpa/shippingOnhandReadiness.spec.ts
|
||||
* 用途:覆盖库存站点上线检查与测试恢复的纯状态映射。
|
||||
* 依赖:shippingInventoryReadiness、vitest。
|
||||
* 依赖:shippingOnhandReadiness、vitest。
|
||||
* 逻辑:防止页面把已完成项目显示为待办,或持续轮询服务端已结束的测试任务。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingInventoryReadinessCheck } from '@/features/admin/api/admin.api';
|
||||
import { isConfigurationTestRunning, needsReadinessAction, readinessMarkerKind } from './shippingInventoryReadiness';
|
||||
import { normaliseInventoryReportPath } from './shippingInventorySourceForm';
|
||||
import type { ShippingOnhandReadinessCheck } from '@/features/admin/api/admin.api';
|
||||
import { isConfigurationTestRunning, needsReadinessAction, readinessMarkerKind } from './shippingOnhandReadiness';
|
||||
import { normaliseInventoryReportPath } from './shippingOnhandSourceForm';
|
||||
|
||||
const check = (status: ShippingInventoryReadinessCheck['status'], blocking: boolean): ShippingInventoryReadinessCheck => ({
|
||||
const check = (status: ShippingOnhandReadinessCheck['status'], blocking: boolean): ShippingOnhandReadinessCheck => ({
|
||||
code: 'configuration_test', status, blocking, action: 'run_configuration_test', evidence: {},
|
||||
});
|
||||
|
||||
describe('shippingInventoryReadiness', () => {
|
||||
describe('shippingOnhandReadiness', () => {
|
||||
it('keeps stale checks actionable and visually distinct from ordinary pending work', () => {
|
||||
// 关键断言:配置已变更的测试不能被渲染成普通待办,管理员必须重新测试。
|
||||
expect(readinessMarkerKind('stale')).toBe('attention');
|
||||
+7
-7
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/shippingInventoryReadiness.ts
|
||||
* features/admin/modules/freight-rpa/shippingOnhandReadiness.ts
|
||||
* 用途:归一库存站点上线检查与配置测试的前端展示状态。
|
||||
* 依赖:admin.api 中的 Inventory Readiness/Test 类型。
|
||||
* 逻辑:ShippingInventoryPage 调用本文件决定测试轮询、步骤标记和推荐动作;后端仍是门禁真相源。
|
||||
* 依赖:admin.api 的 ShippingOnhandReadinessCheck / ShippingOnhandConfigurationTest。
|
||||
* 逻辑:FreightRpaPage 调用本文件决定测试轮询、步骤标记和推荐动作;后端仍是门禁真相源。
|
||||
*/
|
||||
|
||||
import type { ShippingInventoryConfigurationTest, ShippingInventoryReadinessCheck } from '@/features/admin/api/admin.api';
|
||||
import type { ShippingOnhandConfigurationTest, ShippingOnhandReadinessCheck } from '@/features/admin/api/admin.api';
|
||||
|
||||
export type ReadinessMarker = 'complete' | 'attention' | 'pending';
|
||||
|
||||
@@ -15,7 +15,7 @@ export type ReadinessMarker = 'complete' | 'attention' | 'pending';
|
||||
* @param status - 后端 `checks[]` 返回的稳定状态。
|
||||
* @returns 供页面选择图形和颜色的有限标记,不参与启用门禁计算。
|
||||
*/
|
||||
export function readinessMarkerKind(status: ShippingInventoryReadinessCheck['status']): ReadinessMarker {
|
||||
export function readinessMarkerKind(status: ShippingOnhandReadinessCheck['status']): ReadinessMarker {
|
||||
if (status === 'passed') return 'complete';
|
||||
if (status === 'failed' || status === 'stale') return 'attention';
|
||||
return 'pending';
|
||||
@@ -27,7 +27,7 @@ export function readinessMarkerKind(status: ShippingInventoryReadinessCheck['sta
|
||||
* @param check - 后端权威检查项。
|
||||
* @returns 为 true 时页面可展示对应的单一下一步动作。
|
||||
*/
|
||||
export function needsReadinessAction(check: ShippingInventoryReadinessCheck): boolean {
|
||||
export function needsReadinessAction(check: ShippingOnhandReadinessCheck): boolean {
|
||||
return check.status !== 'passed' && check.blocking;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,6 @@ export function needsReadinessAction(check: ShippingInventoryReadinessCheck): bo
|
||||
* @param test - 当前恢复或新发起的测试运行。
|
||||
* @returns 是否继续轮询。
|
||||
*/
|
||||
export function isConfigurationTestRunning(test: ShippingInventoryConfigurationTest | null): boolean {
|
||||
export function isConfigurationTestRunning(test: ShippingOnhandConfigurationTest | null): boolean {
|
||||
return Boolean(test && ['awaiting_rpa', 'processing'].includes(test.status));
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/shippingInventorySourceForm.ts
|
||||
* features/admin/modules/freight-rpa/shippingOnhandSourceForm.ts
|
||||
* 用途:规范化库存站点表单中仅适用于 DBS 的报表路径字段。
|
||||
* 依赖:无外部依赖,仅处理库存站点表单的连接器类型和 JSON 路径。
|
||||
* 逻辑:ShippingInventoryPage 在回填、保存和脏状态比较时调用,避免非 DBS 站点携带 DBS 默认路径。
|
||||
* 逻辑:FreightRpaPage 在回填、保存和脏状态比较时调用,避免非 DBS 站点携带 DBS 默认路径。
|
||||
*/
|
||||
|
||||
export type InventoryReportPath = Record<string, unknown>;
|
||||
+13
-6
@@ -194,19 +194,26 @@ describe('IntegrationCallLogsPanel', () => {
|
||||
});
|
||||
const wrapper = mountPanel();
|
||||
await flushPromises();
|
||||
const options = wrapper.find('[data-testid="call-filter-status"]').findAll('option')
|
||||
.map((o) => o.element.value).filter((v) => v !== '');
|
||||
// 筛选下拉已迁移 el-select:原生 <option> 由 ElOption 组件承载(下拉本体 teleport 到 body),
|
||||
// value 从组件 prop 读取(等价旧的原生 option value 枚举);「—」占位项 value 为空串需剔除
|
||||
const options = wrapper.getComponent('[data-testid="call-filter-status"]')
|
||||
.findAllComponents({ name: 'ElOption' })
|
||||
.map((o) => String(o.props('value')))
|
||||
.filter((v) => v !== '');
|
||||
expect(options).toEqual([
|
||||
'success', 'duplicate_success', 'duplicate_unverified',
|
||||
'business_failed', 'technical_failed', 'timeout', 'result_unknown',
|
||||
]);
|
||||
// 状态徽章已迁移 el-tag(success/danger type 配色替代旧 Tailwind bg-*-100 类);
|
||||
// call-row 落在首列单元格内,状态徽章在同行其他列,故改按 el-table 行定位
|
||||
const tableRows = wrapper.findAll('.el-table__row');
|
||||
// [断言意图] 成功族判定:duplicate_success(幂等重放命中,业务已成功)徽章走绿色成功侧
|
||||
const dupOkRow = wrapper.findAll('[data-testid="call-row"]')[0];
|
||||
const dupOkRow = tableRows[0];
|
||||
expect(dupOkRow.text()).toContain('duplicate_success');
|
||||
expect(dupOkRow.find('span.bg-green-100').exists()).toBe(true);
|
||||
expect(dupOkRow.find('.el-tag--success').exists()).toBe(true);
|
||||
// [断言意图] duplicate_unverified(回执未核实)保守归非成功态,徽章保持红色 ✗
|
||||
const dupUnknownRow = wrapper.findAll('[data-testid="call-row"]')[1];
|
||||
const dupUnknownRow = tableRows[1];
|
||||
expect(dupUnknownRow.text()).toContain('duplicate_unverified');
|
||||
expect(dupUnknownRow.find('span.bg-red-100').exists()).toBe(true);
|
||||
expect(dupUnknownRow.find('.el-tag--danger').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
+11
@@ -7,6 +7,17 @@
|
||||
* 列表按类型标签/非密账号/来源本地化与布尔启停开关渲染。
|
||||
*/
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
// el-table 在 jsdom 依赖 ResizeObserver 计算列布局,缺失时行不渲染单元格
|
||||
class ResizeObserverStub {
|
||||
observe(): void {}
|
||||
|
||||
unobserve(): void {}
|
||||
|
||||
disconnect(): void {}
|
||||
}
|
||||
(globalThis as Record<string, unknown>).ResizeObserver
|
||||
= (globalThis as Record<string, unknown>).ResizeObserver || ResizeObserverStub;
|
||||
import { defineComponent, h, ref } from 'vue';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createMemoryHistory, createRouter } from 'vue-router';
|
||||
|
||||
+7
-10
@@ -115,6 +115,13 @@ function envLabel(value: string) {
|
||||
: value;
|
||||
}
|
||||
|
||||
/** 环境徽章配色:生产绿 / 测试橙 / 其余中性(el-tag type 映射)。 */
|
||||
function envTagType(value: string): 'success' | 'warning' | 'info' {
|
||||
if (value === 'prod') return 'success';
|
||||
if (value === 'test') return 'warning';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
/** 状态本地化标签;未知值兜底原样显示。 */
|
||||
function statusLabel(value: string) {
|
||||
return t(`admin.integrationConnector.statusLabels.${value}`, value);
|
||||
@@ -159,16 +166,6 @@ function statusTagType(value: string): 'success' | 'warning' | 'info' {
|
||||
return 'info';
|
||||
}
|
||||
|
||||
/**
|
||||
* 环境标签颜色。生产为成功,测试为警告。
|
||||
* @param value - 环境码
|
||||
*/
|
||||
function envTagType(value: string): 'success' | 'warning' | 'info' {
|
||||
if (value === 'prod') return 'success';
|
||||
if (value === 'test') return 'warning';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
/** 行内测试结果(无结果返回 null,供模板 v-if 使用)。 */
|
||||
function testResultOf(code: string) {
|
||||
return testResults.value[code] ?? null;
|
||||
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* features/admin/modules/integration-connector/__tests__/IntegrationConnectorPage.spec.ts
|
||||
* 用途:集成连接器页 EP 迁移后的冒烟契约——el-tabs 页签、el-table 列表渲染
|
||||
* (类型/环境 el-tag、行内 el-switch 启停开关)、编辑抽屉(el-drawer +
|
||||
* el-form 控件族)与新增提交路径调用 create API。
|
||||
* 依赖:@vue/test-utils、vitest、@/i18n、integration-connector.api(mock)。
|
||||
* 逻辑:mock 模块 API 返回一条 REST 客户端 + 一条凭据引用 + 一条能力(形状与
|
||||
* types/integration-connector.types.ts 对齐);页面走真实 composable,
|
||||
* 断言 EP 组件结构与关键交互路径(列表 → 打开编辑抽屉 → 新建并保存调用 create),
|
||||
* 不锁样式细节。
|
||||
*/
|
||||
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import IntegrationConnectorPage from '../IntegrationConnectorPage.vue';
|
||||
|
||||
// el-table 布局依赖 ResizeObserver,jsdom 缺失需补齐桩实现
|
||||
class ResizeObserverStub {
|
||||
observe(): void {}
|
||||
|
||||
unobserve(): void {}
|
||||
|
||||
disconnect(): void {}
|
||||
}
|
||||
(globalThis as Record<string, unknown>).ResizeObserver
|
||||
= (globalThis as Record<string, unknown>).ResizeObserver || ResizeObserverStub;
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
listIntegrationCapabilities: vi.fn(),
|
||||
callIntegrationCapability: vi.fn(),
|
||||
listIntegrationClientInstances: vi.fn(),
|
||||
createIntegrationClientInstance: vi.fn(),
|
||||
updateIntegrationClientInstance: vi.fn(),
|
||||
deleteIntegrationClientInstance: vi.fn(),
|
||||
testIntegrationClientConnection: vi.fn(),
|
||||
listIntegrationInterfaceDefinitions: vi.fn(),
|
||||
createIntegrationInterfaceDefinition: vi.fn(),
|
||||
updateIntegrationInterfaceDefinition: vi.fn(),
|
||||
changeIntegrationInterfaceLifecycle: vi.fn(),
|
||||
listIntegrationBindings: vi.fn(),
|
||||
createIntegrationBinding: vi.fn(),
|
||||
updateIntegrationBinding: vi.fn(),
|
||||
changeIntegrationBindingLifecycle: vi.fn(),
|
||||
listIntegrationCredentialReferences: vi.fn(),
|
||||
listIntegrationCredentialTypes: vi.fn(),
|
||||
createIntegrationCredentialReference: vi.fn(),
|
||||
updateIntegrationCredentialReference: vi.fn(),
|
||||
listIntegrationCalls: vi.fn(),
|
||||
getIntegrationCall: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../api/integration-connector.api', () => api);
|
||||
|
||||
enableAutoUnmount(afterEach);
|
||||
|
||||
// EP 重型页面(表格+页签+抽屉+调用日志面板)在全量并行渲染时较慢,放宽本文件超时,
|
||||
// 避免三文件同跑时「打开编辑抽屉」等重挂载用例撞 5s 默认超时
|
||||
vi.setConfig({ testTimeout: 20000 });
|
||||
|
||||
// ---- 测试夹具:形状与 types/integration-connector.types.ts 序列化契约对齐 ----
|
||||
const clientRow = {
|
||||
id: 1,
|
||||
code: 'erp-prod',
|
||||
name: '生产 ERP',
|
||||
connector_type: 'rest',
|
||||
environment: 'prod',
|
||||
endpoint: 'https://erp.example.com/api',
|
||||
timeout_seconds: 60,
|
||||
db_kind: null,
|
||||
config_json: {},
|
||||
credential_ref_code: null,
|
||||
enabled: true,
|
||||
};
|
||||
const credentialRow = {
|
||||
id: 1,
|
||||
code: 'tiptop-erp',
|
||||
secret_ref: 'db:tiptop-erp',
|
||||
secret_provider: 'db',
|
||||
credential_type: 'password',
|
||||
secret_fields: { username: 'tiptop' },
|
||||
has_secret: true,
|
||||
version: 1,
|
||||
status: 'active',
|
||||
updated_at: null,
|
||||
last_verified_at: null,
|
||||
};
|
||||
const capabilityRow = {
|
||||
name: 'in_transit_transfer.query_inventory',
|
||||
write: false,
|
||||
idempotency: 'invoice',
|
||||
input_schema: {},
|
||||
output_schema: {},
|
||||
};
|
||||
|
||||
const mountPage = async () => {
|
||||
const wrapper = mount(IntegrationConnectorPage, { global: { plugins: [i18n] } });
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
describe('IntegrationConnectorPage EP 迁移冒烟', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.listIntegrationClientInstances.mockResolvedValue([clientRow]);
|
||||
api.listIntegrationInterfaceDefinitions.mockResolvedValue([]);
|
||||
api.listIntegrationBindings.mockResolvedValue([]);
|
||||
api.listIntegrationCredentialReferences.mockResolvedValue([credentialRow]);
|
||||
api.listIntegrationCredentialTypes.mockResolvedValue([
|
||||
{
|
||||
type: 'password',
|
||||
fields: [
|
||||
{ key: 'username', secret: false, required: true },
|
||||
{ key: 'password', secret: true, required: true },
|
||||
],
|
||||
},
|
||||
]);
|
||||
api.listIntegrationCapabilities.mockResolvedValue([capabilityRow]);
|
||||
api.listIntegrationCalls.mockResolvedValue({ total: 0, page: 1, page_size: 20, items: [] });
|
||||
});
|
||||
|
||||
it('列表渲染:el-tabs 页签 + el-table 行 + 类型/环境标签 + 行内启停开关', async () => {
|
||||
const wrapper = await mountPage();
|
||||
// 关键断言:页签为 el-tabs;默认 client tab 的 el-table 渲染一行客户端
|
||||
expect(wrapper.find('.el-tabs').exists()).toBe(true);
|
||||
const table = wrapper.find('.connector-page .el-table');
|
||||
expect(table.exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('生产 ERP');
|
||||
expect(wrapper.text()).toContain('erp-prod');
|
||||
// 类型(info plain)与环境(prod=success)以 el-tag 呈现
|
||||
const tags = wrapper.findAll('.el-table .el-tag');
|
||||
expect(tags.length).toBeGreaterThanOrEqual(2);
|
||||
expect(wrapper.text()).toContain('生产');
|
||||
// 启停开关为 el-switch(data-testid 原位保留),启用态 aria-checked=true
|
||||
const toggle = wrapper.find('[data-testid="client-toggle"]');
|
||||
expect(toggle.exists()).toBe(true);
|
||||
expect(toggle.find('[role="switch"]').attributes('aria-checked')).toBe('true');
|
||||
});
|
||||
|
||||
it('打开编辑抽屉:el-drawer dialog 语义 + el-form(label-position=top) EP 控件族', async () => {
|
||||
const wrapper = await mountPage();
|
||||
// 操作列「编辑」为图标链接按钮(title=admin.edit),点击后 openEditModal 回填表单
|
||||
await wrapper.find('button[title="编辑"]').trigger('click');
|
||||
await flushPromises();
|
||||
const drawer = wrapper.find('[data-testid="connector-form-drawer"]');
|
||||
// 关键断言:抽屉为 el-drawer(open 态 + role=dialog),表单为 el-form label-position=top
|
||||
expect(drawer.exists()).toBe(true);
|
||||
expect(drawer.classes()).toContain('el-drawer');
|
||||
expect(drawer.classes()).toContain('open');
|
||||
expect(drawer.attributes('role')).toBe('dialog');
|
||||
const form = wrapper.find('.el-drawer .el-form');
|
||||
expect(form.exists()).toBe(true);
|
||||
expect(form.classes()).toContain('el-form--label-top');
|
||||
// 表单控件为 EP 组件:编码回显且编辑态锁定(el-input disabled)、连接地址 el-input 有值
|
||||
const code = wrapper.find('[data-testid="client-code"]');
|
||||
expect((code.element as HTMLInputElement).value).toBe('erp-prod');
|
||||
expect((code.element as HTMLInputElement).disabled).toBe(true);
|
||||
const endpoint = wrapper.find('[data-testid="client-endpoint"]');
|
||||
expect((endpoint.element as HTMLInputElement).value).toBe('https://erp.example.com/api');
|
||||
// 连接器类型/环境/凭据引用均为 el-select;启用开关置于底部操作条
|
||||
expect(wrapper.findAll('.el-drawer .el-select').length).toBeGreaterThanOrEqual(3);
|
||||
expect(wrapper.find('[data-testid="client-enabled-switch"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('打开新增后提交:保存按钮走 createIntegrationClientInstance(mock resolve)', async () => {
|
||||
const wrapper = await mountPage();
|
||||
api.createIntegrationClientInstance.mockResolvedValue({ ...clientRow, id: 2, code: 'erp-x' });
|
||||
// 顶部「新增」为 el-button type=primary
|
||||
await wrapper.find('.page-header .el-button--primary').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="connector-form-drawer"].open').exists()).toBe(true);
|
||||
// 填名称(编码留空 → 按名称自动建议 erp-x),点抽屉底部「保存更改」
|
||||
await wrapper.find('[data-testid="client-name"]').setValue('ERP X');
|
||||
const footer = wrapper.find('.el-drawer__footer');
|
||||
expect(footer.exists()).toBe(true);
|
||||
await footer.find('.el-button--primary').trigger('click');
|
||||
await flushPromises();
|
||||
// 关键断言:提交路径调用 create API,payload 为 composable 组装的客户端实例字段
|
||||
expect(api.createIntegrationClientInstance).toHaveBeenCalledTimes(1);
|
||||
const payload = api.createIntegrationClientInstance.mock.calls[0][0];
|
||||
expect(payload.name).toBe('ERP X');
|
||||
expect(payload.code).toBe('erp-x');
|
||||
expect(payload.connector_type).toBe('rest');
|
||||
expect(payload.environment).toBe('prod');
|
||||
expect(payload.enabled).toBe(true);
|
||||
});
|
||||
});
|
||||
+632
-269
@@ -1,22 +1,41 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/components/IntegrationCallLogsPanel.vue
|
||||
用途:集成调用日志面板——筛选条 + 分页列表 + 行点击详情抽屉(能力无关通用口径)。
|
||||
依赖:../api/integration-connector.api(listIntegrationCalls / getIntegrationCall)、
|
||||
../utils/integration-call-replay(buildCurl / buildSqlReplay)、
|
||||
useMessage、copyTextToClipboard、formatLocalDateTime、useI18n。
|
||||
依赖:element-plus(表格/筛选控件/日期选择/抽屉/空态/v-loading,沿用管理端 element-trial 主题)、
|
||||
../api/integration-connector.api(listIntegrationCalls / getIntegrationCall)、
|
||||
../utils/integration-call-replay(buildCurl / buildSqlReplay)、
|
||||
useMessage、copyTextToClipboard、formatLocalDateTime、useI18n。
|
||||
逻辑:筛选(接口编码/客户端编码/连接类型/状态/operation_id/trace_id/业务单号/
|
||||
参数关键字/执行时间起止)回车或点「查询」生效(查询回第一页),「重置」清空;
|
||||
列表按 id 倒序分页,行点击拉取全量详情开右侧抽屉;抽屉含步骤时间线
|
||||
(同 operation_id 各步、当前步高亮)、线级请求与业务参数双栏、原始报文与
|
||||
归一化 JSON 双栏;复制按钮组按连接类型分流:soap/rest=复制 body / 复制 curl,
|
||||
列表按 id 倒序分页,行点击拉取全量详情开右侧抽屉(el-drawer 原生承接 Esc 关闭);
|
||||
抽屉含步骤时间线(同 operation_id 各步、当前步高亮)、线级请求与业务参数双栏、
|
||||
原始报文与归一化 JSON 双栏;复制按钮组按连接类型分流:soap/rest=复制 body / 复制 curl,
|
||||
database=复制 SQL(绑定已内联、写入类自动包事务并红字警示),
|
||||
另有复制原始报文 / 复制 JSON / 复制 operation_id / 复制 trace_id;
|
||||
wire_json 为 NULL(历史存量行)时如实显示「无线级详情(历史记录)」,不回填。
|
||||
视觉层已迁移 Element Plus(element-trial 主题),布局间距由 AdminLayout 壳层持有。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ChevronLeft, ChevronRight, X } from 'lucide-vue-next';
|
||||
import {
|
||||
ElButton,
|
||||
ElDatePicker,
|
||||
ElDrawer,
|
||||
ElEmpty,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
vLoading,
|
||||
} from 'element-plus';
|
||||
import { ArrowLeft, ArrowRight, CircleCheck, CircleClose, Close } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { copyTextToClipboard } from '@/shared/utils/clipboard';
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
@@ -143,11 +162,6 @@ function closeDetail() {
|
||||
detail.value = null;
|
||||
}
|
||||
|
||||
/** 抽屉打开时 Esc 关闭(与表单抽屉行为一致)。 */
|
||||
function onEscKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape' && detail.value) closeDetail();
|
||||
}
|
||||
|
||||
/** 复制文本到剪贴板(带降级方案),成功后弹「已复制」提示。 */
|
||||
async function copy(text: string) {
|
||||
const ok = await copyTextToClipboard(text);
|
||||
@@ -162,16 +176,6 @@ function isSuccess(status: string): boolean {
|
||||
return status === 'success' || status === 'duplicate_success';
|
||||
}
|
||||
|
||||
/** 状态徽标配色:成功绿 / 其余红。 */
|
||||
function statusBadgeClass(status: string): string {
|
||||
return isSuccess(status) ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700';
|
||||
}
|
||||
|
||||
/** 状态图标:✓ 成功 / ✗ 失败。 */
|
||||
function statusIcon(status: string): string {
|
||||
return isSuccess(status) ? '✓' : '✗';
|
||||
}
|
||||
|
||||
/** 单号列文本:优先业务单号 business_ref,未透传时回退 operation_id 前 8 位。 */
|
||||
function refTextOf(row: IntegrationCallLogRow): string {
|
||||
return row.business_ref || row.operation_id.slice(0, 8);
|
||||
@@ -205,289 +209,648 @@ function prettyJson(value: unknown): string {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', onEscKey);
|
||||
void load();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('keydown', onEscKey);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<!-- 筛选条:全部可选,回车 / 点查询生效 -->
|
||||
<div class="rounded-xl border border-default bg-surface p-4 space-y-3">
|
||||
<div class="grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5" @keyup.enter="query">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterInterface') }}</label>
|
||||
<input v-model="filters.interface_code" type="text" class="input-field text-sm font-mono" data-testid="call-filter-interface" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterClient') }}</label>
|
||||
<input v-model="filters.client_code" type="text" class="input-field text-sm font-mono" data-testid="call-filter-client" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterConnector') }}</label>
|
||||
<select v-model="filters.connector_type" class="input-field text-sm" data-testid="call-filter-connector">
|
||||
<option value="">—</option>
|
||||
<option v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :value="opt.value">{{ t(opt.labelKey) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterStatus') }}</label>
|
||||
<select v-model="filters.status" class="input-field text-sm font-mono" data-testid="call-filter-status">
|
||||
<option value="">—</option>
|
||||
<option v-for="s in CALL_STATUS_OPTIONS" :key="s" :value="s">{{ s }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterOperationId') }}</label>
|
||||
<input v-model="filters.operation_id" type="text" class="input-field text-sm font-mono" data-testid="call-filter-operation-id" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterTraceId') }}</label>
|
||||
<input v-model="filters.trace_id" type="text" class="input-field text-sm font-mono" data-testid="call-filter-trace-id" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterBusinessRef') }}</label>
|
||||
<input v-model="filters.business_ref" type="text" class="input-field text-sm font-mono" data-testid="call-filter-business-ref" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterKeyword') }}</label>
|
||||
<input v-model="filters.keyword" type="text" class="input-field text-sm" data-testid="call-filter-keyword" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.dateFrom') }}</label>
|
||||
<input v-model="filters.date_from" type="date" class="input-field text-sm" data-testid="call-filter-date-from" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.dateTo') }}</label>
|
||||
<input v-model="filters.date_to" type="date" class="input-field text-sm" data-testid="call-filter-date-to" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button type="button" class="btn-primary" data-testid="call-filter-query" @click="query">
|
||||
{{ t('admin.integrationConnector.callLogs.query') }}
|
||||
</button>
|
||||
<button type="button" class="btn-ghost" data-testid="call-filter-reset" @click="resetFilters">
|
||||
{{ t('admin.integrationConnector.callLogs.reset') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="call-logs-panel">
|
||||
<!-- 筛选条:一行化(flex wrap),全部可选,回车 / 点查询生效 -->
|
||||
<div class="filter-bar" @keyup.enter="query">
|
||||
<el-input
|
||||
v-model="filters.interface_code"
|
||||
class="filter-field mono-filter"
|
||||
:placeholder="t('admin.integrationConnector.callLogs.filterInterface')"
|
||||
clearable
|
||||
data-testid="call-filter-interface"
|
||||
/>
|
||||
<el-input
|
||||
v-model="filters.client_code"
|
||||
class="filter-field mono-filter"
|
||||
:placeholder="t('admin.integrationConnector.callLogs.filterClient')"
|
||||
clearable
|
||||
data-testid="call-filter-client"
|
||||
/>
|
||||
<el-select v-model="filters.connector_type" class="filter-field" data-testid="call-filter-connector">
|
||||
<el-option :label="t('common.filter.all')" value="" />
|
||||
<el-option v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :value="opt.value" :label="t(opt.labelKey)" />
|
||||
</el-select>
|
||||
<el-select v-model="filters.status" class="filter-field mono-filter" data-testid="call-filter-status">
|
||||
<el-option :label="t('common.filter.all')" value="" />
|
||||
<el-option v-for="s in CALL_STATUS_OPTIONS" :key="s" :value="s" :label="s" />
|
||||
</el-select>
|
||||
<el-input
|
||||
v-model="filters.operation_id"
|
||||
class="filter-field mono-filter"
|
||||
:placeholder="t('admin.integrationConnector.callLogs.filterOperationId')"
|
||||
clearable
|
||||
data-testid="call-filter-operation-id"
|
||||
/>
|
||||
<el-input
|
||||
v-model="filters.trace_id"
|
||||
class="filter-field mono-filter"
|
||||
:placeholder="t('admin.integrationConnector.callLogs.filterTraceId')"
|
||||
clearable
|
||||
data-testid="call-filter-trace-id"
|
||||
/>
|
||||
<el-input
|
||||
v-model="filters.business_ref"
|
||||
class="filter-field mono-filter"
|
||||
:placeholder="t('admin.integrationConnector.callLogs.filterBusinessRef')"
|
||||
clearable
|
||||
data-testid="call-filter-business-ref"
|
||||
/>
|
||||
<el-input
|
||||
v-model="filters.keyword"
|
||||
class="filter-field"
|
||||
:placeholder="t('admin.integrationConnector.callLogs.filterKeyword')"
|
||||
clearable
|
||||
data-testid="call-filter-keyword"
|
||||
/>
|
||||
<el-date-picker
|
||||
v-model="filters.date_from"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
:placeholder="t('admin.integrationConnector.callLogs.dateFrom')"
|
||||
class="filter-field"
|
||||
data-testid="call-filter-date-from"
|
||||
/>
|
||||
<el-date-picker
|
||||
v-model="filters.date_to"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
:placeholder="t('admin.integrationConnector.callLogs.dateTo')"
|
||||
class="filter-field"
|
||||
data-testid="call-filter-date-to"
|
||||
/>
|
||||
<el-button type="primary" data-testid="call-filter-query" @click="query">
|
||||
{{ t('admin.integrationConnector.callLogs.query') }}
|
||||
</el-button>
|
||||
<el-button data-testid="call-filter-reset" @click="resetFilters">
|
||||
{{ t('admin.integrationConnector.callLogs.reset') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 调用记录列表(id 倒序;行点击开详情抽屉) -->
|
||||
<div class="admin-table-wrap" :class="loading ? 'opacity-60 pointer-events-none' : ''">
|
||||
<div class="px-4 py-3 flex items-center justify-between">
|
||||
<h4 class="text-sm font-bold text-primary">{{ t('admin.integrationConnector.callLogs.title') }}</h4>
|
||||
<span class="text-xs text-muted font-mono">({{ total }})</span>
|
||||
<div class="logs-card">
|
||||
<div class="logs-head">
|
||||
<h4 class="logs-title">{{ t('admin.integrationConnector.callLogs.title') }}</h4>
|
||||
<span class="logs-total mono">({{ total }})</span>
|
||||
</div>
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs w-16">#</th>
|
||||
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colTime') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colCapability') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colInterface') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colRef') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs w-20">{{ t('admin.integrationConnector.callLogs.colStep') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs w-44">{{ t('admin.integrationConnector.callLogs.colStatus') }}</th>
|
||||
<th class="px-4 py-3 text-right text-xs w-24">{{ t('admin.integrationConnector.callLogs.colElapsed') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="items.length === 0">
|
||||
<td colspan="8" class="px-6 admin-table-empty">{{ t('admin.integrationConnector.empty') }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-for="row in items"
|
||||
:key="row.id"
|
||||
data-testid="call-row"
|
||||
class="cursor-pointer hover:bg-surface-soft transition-colors"
|
||||
@click="openDetail(row)"
|
||||
>
|
||||
<td class="px-4 py-3 text-xs text-muted font-mono">{{ row.id }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary font-mono whitespace-nowrap">{{ formatLocalDateTime(row.created_at) }}</td>
|
||||
<td class="px-4 py-3 text-xs font-mono text-secondary max-w-[220px]"><span class="block truncate" :title="row.capability">{{ row.capability }}</span></td>
|
||||
<td class="px-4 py-3 text-xs font-mono text-secondary max-w-[200px]"><span class="block truncate" :title="row.interface_code || ''">{{ row.interface_code || '—' }}</span></td>
|
||||
<td class="px-4 py-3 text-xs font-mono text-secondary" :title="row.business_ref || row.operation_id">{{ refTextOf(row) }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary font-mono">{{ stepText(row) }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium font-mono" :class="statusBadgeClass(row.status)">
|
||||
{{ statusIcon(row.status) }} {{ row.status }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary font-mono text-right whitespace-nowrap">{{ row.elapsed_ms }}ms</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="flex items-center justify-end gap-3 px-4 py-3 text-xs text-secondary">
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
<el-table v-loading="loading" :data="items" row-key="id" class="logs-table" @row-click="openDetail">
|
||||
<template #empty>
|
||||
<el-empty :description="t('admin.integrationConnector.empty')" :image-size="60" />
|
||||
</template>
|
||||
<el-table-column label="#" width="80">
|
||||
<template #default="{ row }">
|
||||
<span class="cell-mono" data-testid="call-row">{{ row.id }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.integrationConnector.callLogs.colTime')" width="170">
|
||||
<template #default="{ row }">
|
||||
<span class="cell-mono nowrap">{{ formatLocalDateTime(row.created_at) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.integrationConnector.callLogs.colCapability')" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<span class="cell-ellipsis mono" :title="row.capability">{{ row.capability }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.integrationConnector.callLogs.colInterface')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="cell-ellipsis mono" :title="row.interface_code || ''">{{ row.interface_code || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.integrationConnector.callLogs.colRef')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="cell-mono" :title="row.business_ref || row.operation_id">{{ refTextOf(row as IntegrationCallLogRow) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.integrationConnector.callLogs.colStep')" width="90">
|
||||
<template #default="{ row }">
|
||||
<span class="cell-mono">{{ stepText(row as IntegrationCallLogRow) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.integrationConnector.callLogs.colStatus')" width="190">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="isSuccess(row.status) ? 'success' : 'danger'" size="small" class="status-tag">
|
||||
<el-icon class="status-icon">
|
||||
<CircleCheck v-if="isSuccess(row.status)" />
|
||||
<CircleClose v-else />
|
||||
</el-icon>
|
||||
<span class="mono">{{ row.status }}</span>
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.integrationConnector.callLogs.colElapsed')" width="110" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="cell-mono nowrap">{{ row.elapsed_ms }}ms</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="pager">
|
||||
<el-button
|
||||
:icon="ArrowLeft"
|
||||
:title="t('admin.integrationConnector.callLogs.prevPage')"
|
||||
data-testid="call-prev-page"
|
||||
:disabled="page <= 1 || loading"
|
||||
@click="goPrev"
|
||||
>
|
||||
<ChevronLeft class="w-4 h-4" />
|
||||
</button>
|
||||
<span class="font-mono">{{ page }} / {{ totalPages }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
/>
|
||||
<span class="pager-text mono">{{ page }} / {{ totalPages }}</span>
|
||||
<el-button
|
||||
:icon="ArrowRight"
|
||||
:title="t('admin.integrationConnector.callLogs.nextPage')"
|
||||
data-testid="call-next-page"
|
||||
:disabled="page >= totalPages || loading"
|
||||
@click="goNext"
|
||||
>
|
||||
<ChevronRight class="w-4 h-4" />
|
||||
</button>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 详情抽屉:右侧滑出(步骤时间线 + 线级/归一化双栏 + 复现命令复制) -->
|
||||
<div
|
||||
v-if="detail"
|
||||
class="fixed inset-0 z-50 flex justify-end bg-overlay animate-fade-in"
|
||||
<!-- 详情抽屉:右侧滑出(步骤时间线 + 线级/归一化双栏 + 复现命令复制;Esc 关闭由 el-drawer 原生承接) -->
|
||||
<el-drawer
|
||||
:model-value="detail !== null"
|
||||
size="920px"
|
||||
resizable
|
||||
destroy-on-close
|
||||
:show-close="false"
|
||||
class="call-detail-drawer"
|
||||
data-testid="call-detail-drawer"
|
||||
@click.self="closeDetail"
|
||||
@close="closeDetail"
|
||||
>
|
||||
<aside role="dialog" aria-modal="true" :aria-label="t('admin.integrationConnector.callLogs.detailTitle')" class="h-full w-full max-w-4xl flex flex-col bg-surface shadow-2xl outline-none">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-6 pb-4 border-b border-default shrink-0 space-y-2">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<h3 class="section-title">{{ t('admin.integrationConnector.callLogs.detailTitle') }} #{{ detail.call.id }}</h3>
|
||||
<button type="button" class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary" :aria-label="t('admin.cancel')" data-testid="call-detail-close" @click="closeDetail">
|
||||
<X class="w-4 h-4" />
|
||||
</button>
|
||||
<template #header>
|
||||
<div v-if="detail" class="detail-header">
|
||||
<div class="detail-title-row">
|
||||
<h3 class="detail-title">{{ t('admin.integrationConnector.callLogs.detailTitle') }} #{{ detail.call.id }}</h3>
|
||||
<el-button
|
||||
link
|
||||
:icon="Close"
|
||||
:aria-label="t('admin.cancel')"
|
||||
data-testid="call-detail-close"
|
||||
@click="closeDetail"
|
||||
/>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-x-6 gap-y-1 text-xs text-secondary">
|
||||
<span><span class="text-muted">{{ t('admin.integrationConnector.callLogs.colCapability') }}: </span><span class="font-mono">{{ detail.call.capability }}</span></span>
|
||||
<span>
|
||||
<span class="text-muted">{{ t('admin.integrationConnector.callLogs.colStatus') }}: </span>
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium font-mono" :class="statusBadgeClass(detail.call.status)">
|
||||
{{ statusIcon(detail.call.status) }} {{ detail.call.status }}
|
||||
</span>
|
||||
<div class="detail-meta">
|
||||
<span class="meta-item">
|
||||
<span class="meta-key">{{ t('admin.integrationConnector.callLogs.colCapability') }}: </span>
|
||||
<span class="mono">{{ detail.call.capability }}</span>
|
||||
</span>
|
||||
<span><span class="text-muted">{{ t('admin.integrationConnector.callLogs.colElapsed') }}: </span><span class="font-mono">{{ detail.call.elapsed_ms }}ms</span></span>
|
||||
<span v-if="detail.call.business_ref">
|
||||
<span class="text-muted">{{ t('admin.integrationConnector.callLogs.filterBusinessRef') }}: </span><span class="font-mono">{{ detail.call.business_ref }}</span>
|
||||
<span class="meta-item">
|
||||
<span class="meta-key">{{ t('admin.integrationConnector.callLogs.colStatus') }}: </span>
|
||||
<el-tag :type="isSuccess(detail.call.status) ? 'success' : 'danger'" size="small" class="status-tag">
|
||||
<el-icon class="status-icon">
|
||||
<CircleCheck v-if="isSuccess(detail.call.status)" />
|
||||
<CircleClose v-else />
|
||||
</el-icon>
|
||||
<span class="mono">{{ detail.call.status }}</span>
|
||||
</el-tag>
|
||||
</span>
|
||||
<span class="meta-item">
|
||||
<span class="meta-key">{{ t('admin.integrationConnector.callLogs.colElapsed') }}: </span>
|
||||
<span class="mono">{{ detail.call.elapsed_ms }}ms</span>
|
||||
</span>
|
||||
<span v-if="detail.call.business_ref" class="meta-item">
|
||||
<span class="meta-key">{{ t('admin.integrationConnector.callLogs.filterBusinessRef') }}: </span>
|
||||
<span class="mono">{{ detail.call.business_ref }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-x-6 gap-y-1 text-xs">
|
||||
<span class="flex items-center gap-1.5 min-w-0">
|
||||
<span class="text-muted font-mono shrink-0">operation:</span>
|
||||
<span class="font-mono text-secondary truncate max-w-[240px]" :title="detail.call.operation_id">{{ detail.call.operation_id }}</span>
|
||||
<button type="button" class="px-1.5 py-0.5 rounded-md text-xs font-medium text-brand-600 hover:bg-brand-50 shrink-0" data-testid="call-copy-operation-id" @click="copy(detail.call.operation_id)">
|
||||
<div class="detail-meta">
|
||||
<span class="meta-item min-w-0">
|
||||
<span class="meta-key mono">operation:</span>
|
||||
<span class="mono ellipsis" :title="detail.call.operation_id">{{ detail.call.operation_id }}</span>
|
||||
<el-button link type="primary" size="small" data-testid="call-copy-operation-id" @click="copy(detail.call.operation_id)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyOperationId') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</span>
|
||||
<span class="flex items-center gap-1.5 min-w-0">
|
||||
<span class="text-muted font-mono shrink-0">trace:</span>
|
||||
<span class="font-mono text-secondary truncate max-w-[240px]" :title="detail.call.trace_id">{{ detail.call.trace_id }}</span>
|
||||
<button type="button" class="px-1.5 py-0.5 rounded-md text-xs font-medium text-brand-600 hover:bg-brand-50 shrink-0" data-testid="call-copy-trace-id" @click="copy(detail.call.trace_id)">
|
||||
<span class="meta-item min-w-0">
|
||||
<span class="meta-key mono">trace:</span>
|
||||
<span class="mono ellipsis" :title="detail.call.trace_id">{{ detail.call.trace_id }}</span>
|
||||
<el-button link type="primary" size="small" data-testid="call-copy-trace-id" @click="copy(detail.call.trace_id)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyTraceId') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto flex-1">
|
||||
<!-- 步骤时间线:同一次能力调用的 N 步(当前步高亮) -->
|
||||
<section class="space-y-2">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.timeline') }}</h4>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<template v-for="(entry, idx) in detail.timeline" :key="entry.id">
|
||||
<div class="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs" :class="isCurrentStep(entry) ? 'bg-brand-50 ring-1 ring-brand-300' : 'bg-surface-soft'">
|
||||
<span class="inline-block w-2 h-2 rounded-full shrink-0" :class="isSuccess(entry.status) ? 'bg-green-500' : 'bg-red-500'" />
|
||||
<span class="font-mono text-muted">{{ stepLabel(entry, idx) }}</span>
|
||||
<span class="text-secondary font-medium font-mono">{{ entry.interface_code || '—' }}</span>
|
||||
<span class="font-mono" :class="isSuccess(entry.status) ? 'text-green-600' : 'text-red-600'">{{ statusIcon(entry.status) }} {{ entry.status }}</span>
|
||||
<span class="text-muted font-mono">{{ entry.elapsed_ms }}ms</span>
|
||||
</div>
|
||||
<span v-if="idx < detail.timeline.length - 1" class="text-muted" aria-hidden="true">──</span>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
<div v-if="detail" class="detail-body">
|
||||
<!-- 步骤时间线:同一次能力调用的 N 步(当前步高亮) -->
|
||||
<section class="detail-section">
|
||||
<h4 class="section-label">{{ t('admin.integrationConnector.callLogs.timeline') }}</h4>
|
||||
<div class="timeline">
|
||||
<template v-for="(entry, idx) in detail.timeline" :key="entry.id">
|
||||
<div class="timeline-step" :class="{ current: isCurrentStep(entry) }">
|
||||
<span class="timeline-dot" :class="isSuccess(entry.status) ? 'dot-ok' : 'dot-fail'" />
|
||||
<span class="cell-mono">{{ stepLabel(entry, idx) }}</span>
|
||||
<span class="step-interface mono">{{ entry.interface_code || '—' }}</span>
|
||||
<span class="mono" :class="isSuccess(entry.status) ? 'text-ok' : 'text-fail'">
|
||||
{{ entry.status }}
|
||||
</span>
|
||||
<span class="cell-mono">{{ entry.elapsed_ms }}ms</span>
|
||||
</div>
|
||||
<span v-if="idx < detail.timeline.length - 1" class="timeline-sep" aria-hidden="true">──</span>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 请求:线级请求(wire)+ 业务参数(归一化)双栏 -->
|
||||
<section class="space-y-2">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.request') }}</h4>
|
||||
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
|
||||
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
|
||||
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.wire') }}</h5>
|
||||
<template v-if="wire">
|
||||
<!-- soap/rest:method/url/SOAPAction/headers + 完整请求 body XML -->
|
||||
<template v-if="wire.kind !== 'database'">
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all">{{ wireMetaText }}</pre>
|
||||
<div class="text-xs text-muted font-mono">── request_body ──</div>
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ wire.request_body }}</pre>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-body" @click="copy(wire.request_body || '')">
|
||||
{{ t('admin.integrationConnector.callLogs.copyBody') }}
|
||||
</button>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-curl" @click="copy(curlCommand)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyCurl') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- database:pre/bulk/post 三段最终 SQL + 绑定首行 + 行数;写入类红字警示 -->
|
||||
<template v-else>
|
||||
<div v-for="(s, idx) in wire.statements || []" :key="idx" class="space-y-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium bg-surface-soft text-secondary font-mono">{{ s.phase }}</span>
|
||||
<span v-if="statementRowCount(s)" class="text-xs text-muted font-mono">rows: {{ statementRowCount(s) }}</span>
|
||||
</div>
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all">{{ s.sql }}</pre>
|
||||
<pre v-if="s.binds && Object.keys(s.binds).length > 0" class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-muted whitespace-pre-wrap break-all">{{ prettyJson(s.binds) }}</pre>
|
||||
</div>
|
||||
<div v-if="wire.rowcount !== undefined" class="text-xs text-muted font-mono">rowcount: {{ wire.rowcount }}</div>
|
||||
<p v-if="hasWriteStatement" class="text-xs font-medium text-red-600" data-testid="call-sql-write-warning">
|
||||
{{ t('admin.integrationConnector.callLogs.sqlWriteWarning') }}
|
||||
</p>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-sql" @click="copy(sqlReplayText)">
|
||||
{{ t('admin.integrationConnector.callLogs.copySql') }}
|
||||
</button>
|
||||
</template>
|
||||
<!-- 请求:线级请求(wire)+ 业务参数(归一化)双栏 -->
|
||||
<section class="detail-section">
|
||||
<h4 class="section-label">{{ t('admin.integrationConnector.callLogs.request') }}</h4>
|
||||
<div class="dual-grid">
|
||||
<div class="pane">
|
||||
<h5 class="pane-title">{{ t('admin.integrationConnector.callLogs.wire') }}</h5>
|
||||
<template v-if="wire">
|
||||
<!-- soap/rest:method/url/SOAPAction/headers + 完整请求 body XML -->
|
||||
<template v-if="wire.kind !== 'database'">
|
||||
<pre class="pre-block">{{ wireMetaText }}</pre>
|
||||
<div class="pre-caption mono">── request_body ──</div>
|
||||
<pre class="pre-block pre-scroll">{{ wire.request_body }}</pre>
|
||||
<div class="copy-row">
|
||||
<el-button size="small" data-testid="call-copy-body" @click="copy(wire.request_body || '')">
|
||||
{{ t('admin.integrationConnector.callLogs.copyBody') }}
|
||||
</el-button>
|
||||
<el-button size="small" data-testid="call-copy-curl" @click="copy(curlCommand)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyCurl') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 历史存量行 / 未捕获场景:wire_json 为 NULL,如实展示不回填 -->
|
||||
<p v-else class="text-xs text-muted" data-testid="call-no-wire">
|
||||
{{ t('admin.integrationConnector.callLogs.noWire') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
|
||||
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.normalized') }}</h5>
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ prettyJson(detail.call.request_summary_json) }}</pre>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-request-json" @click="copy(prettyJson(detail.call.request_summary_json))">
|
||||
{{ t('admin.integrationConnector.callLogs.copyJson') }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- database:pre/bulk/post 三段最终 SQL + 绑定首行 + 行数;写入类红字警示 -->
|
||||
<template v-else>
|
||||
<div v-for="(s, idx) in wire.statements || []" :key="idx" class="sql-block">
|
||||
<div class="sql-head">
|
||||
<el-tag type="info" effect="plain" size="small" class="mono">{{ s.phase }}</el-tag>
|
||||
<span v-if="statementRowCount(s)" class="cell-mono">rows: {{ statementRowCount(s) }}</span>
|
||||
</div>
|
||||
<pre class="pre-block">{{ s.sql }}</pre>
|
||||
<pre v-if="s.binds && Object.keys(s.binds).length > 0" class="pre-block pre-muted">{{ prettyJson(s.binds) }}</pre>
|
||||
</div>
|
||||
<div v-if="wire.rowcount !== undefined" class="cell-mono">rowcount: {{ wire.rowcount }}</div>
|
||||
<p v-if="hasWriteStatement" class="write-warning" data-testid="call-sql-write-warning">
|
||||
{{ t('admin.integrationConnector.callLogs.sqlWriteWarning') }}
|
||||
</p>
|
||||
<el-button size="small" data-testid="call-copy-sql" @click="copy(sqlReplayText)">
|
||||
{{ t('admin.integrationConnector.callLogs.copySql') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</template>
|
||||
<!-- 历史存量行 / 未捕获场景:wire_json 为 NULL,如实展示不回填 -->
|
||||
<p v-else class="cell-muted" data-testid="call-no-wire">
|
||||
{{ t('admin.integrationConnector.callLogs.noWire') }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
<div class="pane">
|
||||
<h5 class="pane-title">{{ t('admin.integrationConnector.callLogs.normalized') }}</h5>
|
||||
<pre class="pre-block pre-scroll">{{ prettyJson(detail.call.request_summary_json) }}</pre>
|
||||
<el-button size="small" data-testid="call-copy-request-json" @click="copy(prettyJson(detail.call.request_summary_json))">
|
||||
{{ t('admin.integrationConnector.callLogs.copyJson') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 响应:原始报文 + 归一化 JSON 双栏 -->
|
||||
<section class="space-y-2">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.response') }}</h4>
|
||||
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
|
||||
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
|
||||
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.rawPayload') }}</h5>
|
||||
<pre v-if="wire" class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ rawResponseText }}</pre>
|
||||
<p v-else class="text-xs text-muted" data-testid="call-no-wire-response">{{ t('admin.integrationConnector.callLogs.noWire') }}</p>
|
||||
<button v-if="wire" type="button" class="btn-ghost text-xs" data-testid="call-copy-raw" @click="copy(rawResponseText)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyRaw') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
|
||||
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.normalizedJson') }}</h5>
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ prettyJson(detail.call.response_summary_json) }}</pre>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-response-json" @click="copy(prettyJson(detail.call.response_summary_json))">
|
||||
{{ t('admin.integrationConnector.callLogs.copyJson') }}
|
||||
</button>
|
||||
</div>
|
||||
<!-- 响应:原始报文 + 归一化 JSON 双栏 -->
|
||||
<section class="detail-section">
|
||||
<h4 class="section-label">{{ t('admin.integrationConnector.callLogs.response') }}</h4>
|
||||
<div class="dual-grid">
|
||||
<div class="pane">
|
||||
<h5 class="pane-title">{{ t('admin.integrationConnector.callLogs.rawPayload') }}</h5>
|
||||
<pre v-if="wire" class="pre-block pre-scroll">{{ rawResponseText }}</pre>
|
||||
<p v-else class="cell-muted" data-testid="call-no-wire-response">{{ t('admin.integrationConnector.callLogs.noWire') }}</p>
|
||||
<el-button v-if="wire" size="small" data-testid="call-copy-raw" @click="copy(rawResponseText)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyRaw') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="pane">
|
||||
<h5 class="pane-title">{{ t('admin.integrationConnector.callLogs.normalizedJson') }}</h5>
|
||||
<pre class="pre-block pre-scroll">{{ prettyJson(detail.call.response_summary_json) }}</pre>
|
||||
<el-button size="small" data-testid="call-copy-response-json" @click="copy(prettyJson(detail.call.response_summary_json))">
|
||||
{{ t('admin.integrationConnector.callLogs.copyJson') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.call-logs-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
/* 筛选条一行化:flex wrap + 固定宽度控件,回车/查询触发 */
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 10px;
|
||||
background: var(--el-bg-color);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.filter-field {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
/* 等宽栈无中文字形:中文 placeholder 需回退正文字体,避免宋体衬线观感(输入的编码仍为等宽) */
|
||||
.mono-filter :deep(.el-input__inner)::placeholder {
|
||||
font-family: var(--el-font-family);
|
||||
}
|
||||
.mono-filter :deep(.el-input__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
}
|
||||
|
||||
/* 列表卡片 */
|
||||
.logs-card {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 10px;
|
||||
background: var(--el-bg-color);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.logs-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.logs-title {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.logs-total {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.logs-table :deep(.el-table__row) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
}
|
||||
|
||||
.cell-mono {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.cell-muted {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cell-ellipsis {
|
||||
display: block;
|
||||
max-width: 220px;
|
||||
overflow: hidden;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 状态徽章:成功/失败 + 图标 + 原始状态值(等宽) */
|
||||
.status-tag {
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
}
|
||||
|
||||
.status-tag .status-icon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
/* 分页条 */
|
||||
.pager {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.pager-text {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 详情抽屉头部:标题 + 元信息 + 复制入口 */
|
||||
.detail-header {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.detail-title-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.detail-title {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detail-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px 24px;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.meta-key {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.ellipsis {
|
||||
max-width: 240px;
|
||||
overflow: hidden;
|
||||
color: var(--el-text-color-regular);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 详情正文:分区标题 + 双栏面板 */
|
||||
.detail-body {
|
||||
display: grid;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.detail-section {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.section-label {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.dual-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.dual-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
.pane {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 10px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.pane-title {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.copy-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.pre-block {
|
||||
margin: 0;
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-regular);
|
||||
padding: 10px;
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.pre-scroll {
|
||||
max-height: 288px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.pre-muted {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.pre-caption {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.sql-block {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.sql-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.write-warning {
|
||||
margin: 0;
|
||||
color: var(--el-color-danger);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* 步骤时间线:chip 链 + 当前步高亮 */
|
||||
.timeline {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.timeline-step {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-light);
|
||||
padding: 6px 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.timeline-step.current {
|
||||
border: 1px solid var(--el-color-primary-light-5);
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
|
||||
.timeline-dot {
|
||||
display: inline-block;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
flex: none;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.dot-ok {
|
||||
background: var(--el-color-success);
|
||||
}
|
||||
|
||||
.dot-fail {
|
||||
background: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.step-interface {
|
||||
color: var(--el-text-color-regular);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.text-ok {
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.text-fail {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.timeline-sep {
|
||||
color: var(--el-text-color-placeholder);
|
||||
}
|
||||
</style>
|
||||
+100
-28
@@ -1,11 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/components/IntegrationCapabilityCallModal.vue
|
||||
用途:手动调用一个已注册能力(输入 params / context JSON),展示调用结果与 trace。
|
||||
依赖:showCallModal、callParamsText、callContextText、callResult、callBusy。
|
||||
逻辑:由 IntegrationConnectorPage 打开;emit close/run。
|
||||
依赖:element-plus(dialog 弹窗/只读 textarea/按钮,沿用管理端 element-trial 主题)、
|
||||
showCallModal、callParamsText、callContextText、callResult、callBusy。
|
||||
逻辑:由 IntegrationConnectorPage 打开;emit close/run。原自绘弹窗不点遮罩关闭、
|
||||
无 Esc 关闭、无右上角关闭钮,el-dialog 以 close-on-click-modal/close-on-press-escape/
|
||||
show-close 三关对齐该语义;关闭唯一入口是 footer 的取消与运行链路。
|
||||
视觉层已迁移 Element Plus(element-trial 主题),布局间距由 AdminLayout 壳层持有。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElInput } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { IntegrationCallResultRow } from '../types/integration-connector.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -26,34 +34,98 @@ const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-2xl max-h-[92vh] scale-100">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
||||
<h3 class="section-title">{{ t('admin.integrationConnector.callModal.title', { capability }) }}</h3>
|
||||
<p class="section-desc mt-1">{{ t('admin.integrationConnector.callModal.hint') }}</p>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
:title="t('admin.integrationConnector.callModal.title', { capability })"
|
||||
width="640px"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
:show-close="false"
|
||||
class="capability-call-dialog"
|
||||
@close="emit('close')"
|
||||
>
|
||||
<div class="call-modal-body">
|
||||
<div class="readonly-field">
|
||||
<label class="readonly-label">{{ t('admin.integrationConnector.callModal.params') }}</label>
|
||||
<el-input
|
||||
:model-value="props.paramsText"
|
||||
type="textarea"
|
||||
:rows="6"
|
||||
spellcheck="false"
|
||||
readonly
|
||||
class="readonly-mono"
|
||||
/>
|
||||
<p class="readonly-hint">{{ t('admin.integrationConnector.callModal.paramsHint') }}</p>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-4 overflow-y-auto">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callModal.params') }}</label>
|
||||
<textarea :value="props.paramsText" rows="6" class="input-field text-sm font-mono" spellcheck="false" readonly />
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.callModal.paramsHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callModal.context') }}</label>
|
||||
<textarea :value="props.contextText" rows="4" class="input-field text-sm font-mono" spellcheck="false" readonly />
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.callModal.contextHint') }}</p>
|
||||
</div>
|
||||
<div v-if="result" class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callModal.result') }}</label>
|
||||
<pre class="rounded-lg bg-surface-soft p-3 text-xs font-mono text-secondary whitespace-pre-wrap break-all">{{ JSON.stringify(result, null, 2) }}</pre>
|
||||
</div>
|
||||
<div class="readonly-field">
|
||||
<label class="readonly-label">{{ t('admin.integrationConnector.callModal.context') }}</label>
|
||||
<el-input
|
||||
:model-value="props.contextText"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
spellcheck="false"
|
||||
readonly
|
||||
class="readonly-mono"
|
||||
/>
|
||||
<p class="readonly-hint">{{ t('admin.integrationConnector.callModal.contextHint') }}</p>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary disabled:opacity-70" :disabled="busy" @click="emit('run')">
|
||||
{{ busy ? t('admin.integrationConnector.callModal.running') : t('admin.integrationConnector.callModal.run') }}
|
||||
</button>
|
||||
<div v-if="result" class="readonly-field">
|
||||
<label class="readonly-label">{{ t('admin.integrationConnector.callModal.result') }}</label>
|
||||
<pre class="result-pre">{{ JSON.stringify(result, null, 2) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="emit('close')">{{ t('admin.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="busy" :disabled="busy" @click="emit('run')">
|
||||
{{ busy ? t('admin.integrationConnector.callModal.running') : t('admin.integrationConnector.callModal.run') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.call-modal-body {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.readonly-field {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.readonly-label {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.readonly-hint {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 只读 JSON 展示保留等宽字体 */
|
||||
.readonly-mono :deep(.el-textarea__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.result-pre {
|
||||
margin: 0;
|
||||
max-height: 240px;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-regular);
|
||||
padding: 12px;
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
+172
-121
@@ -4,12 +4,16 @@
|
||||
* SOAP 显示 WSDL,database 显示 db_kind 专属下拉与数据库连接串 label;
|
||||
* 绑定表单的有序步骤编辑器(添加/删除/上移下移/每步独立参数映射);
|
||||
* 以及抽屉化后的 JSON 编辑字段(格式化/失焦校验)、脏检查关闭确认与 Esc 关闭行为。
|
||||
* 依赖:@vue/test-utils、vitest、i18n。
|
||||
* 依赖:@vue/test-utils、vitest、element-plus(ElMessageBox mock)、i18n。
|
||||
* 逻辑:切换 connector_type 断言字段可见性;对 JsonTextareaField 断言格式化改写
|
||||
* 与非法 JSON 提示;mock window.confirm 断言脏表单关闭拦截与放行。
|
||||
* 与非法 JSON 提示;spy ElMessageBox.confirm 断言脏表单关闭拦截与放行。
|
||||
* 组件已迁移 Element Plus:el-drawer 正文懒渲染(挂载后统一 flushPromises)、
|
||||
* el-select/el-switch 等 DIV 根控件按 EP 组件结构交互(见下方辅助函数)。
|
||||
*/
|
||||
import { mount, enableAutoUnmount } from '@vue/test-utils';
|
||||
import { enableAutoUnmount, flushPromises, mount, type VueWrapper } from '@vue/test-utils';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { nextTick } from 'vue';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import i18n from '@/i18n';
|
||||
import IntegrationConnectorFormDrawer from './IntegrationConnectorFormDrawer.vue';
|
||||
import JsonTextareaField from './JsonTextareaField.vue';
|
||||
@@ -25,8 +29,8 @@ import {
|
||||
|
||||
enableAutoUnmount(afterEach);
|
||||
|
||||
function mountDrawer(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
return mount(IntegrationConnectorFormDrawer, {
|
||||
async function mountDrawer(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
const wrapper = mount(IntegrationConnectorFormDrawer, {
|
||||
props: {
|
||||
visible: true,
|
||||
activeEntity: 'client',
|
||||
@@ -49,19 +53,57 @@ function mountDrawer(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
// el-drawer 正文懒渲染(rendered 标记在 mounted 后置位),冲刷微任务队列等待表单挂载
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/** DIV 根控件(el-select 等)的 v-model 赋值:DOMWrapper.setValue 对 DIV 会抛错,
|
||||
* 必须走组件 update:modelValue;EP 下拉用户选择除 update:modelValue 外还会 emit change,
|
||||
* 表单 @change 联动(类型切换清 db_kind、接口选客户端联动类型/编码)依赖它,一并补发。 */
|
||||
async function setControl(wrapper: VueWrapper, testId: string, value: unknown) {
|
||||
const control = wrapper.getComponent(`[data-testid="${testId}"]`);
|
||||
control.setValue(value);
|
||||
control.vm.$emit('change', value);
|
||||
await nextTick();
|
||||
}
|
||||
|
||||
/** el-select 选项断言:原生 <option> 已由 ElOption 组件承载(下拉本体 teleport 到 body),
|
||||
* 文案从组件 label prop 读取。 */
|
||||
function optionLabelsOf(wrapper: VueWrapper, testId: string): string[] {
|
||||
return wrapper.getComponent(`[data-testid="${testId}"]`)
|
||||
.findAllComponents({ name: 'ElOption' })
|
||||
.map((option) => String(option.props('label')));
|
||||
}
|
||||
|
||||
/** el-select 禁用只读断言:根为 DIV 无 disabled 属性,EP 以 .el-select__wrapper 的
|
||||
* is-disabled class 表达禁用态。 */
|
||||
function isSelectDisabled(wrapper: VueWrapper, testId: string): boolean {
|
||||
return wrapper.getComponent(`[data-testid="${testId}"]`)
|
||||
.find('.el-select__wrapper')
|
||||
.classes()
|
||||
.includes('is-disabled');
|
||||
}
|
||||
|
||||
/** 模拟点击遮罩关闭:EP overlay 用 useSameTarget 过滤「从面板内部发起」的点击,
|
||||
* 需在 overlay 上按 mousedown → mouseup → click 三连触发才判定为遮罩点击。 */
|
||||
async function clickMask(wrapper: VueWrapper) {
|
||||
const overlay = wrapper.find('.el-overlay');
|
||||
await overlay.trigger('mousedown');
|
||||
await overlay.trigger('mouseup');
|
||||
await overlay.trigger('click');
|
||||
}
|
||||
|
||||
describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
it('REST 默认显示接口地址与超时字段', () => {
|
||||
const wrapper = mountDrawer();
|
||||
it('REST 默认显示接口地址与超时字段', async () => {
|
||||
const wrapper = await mountDrawer();
|
||||
expect(wrapper.find('[data-testid="client-endpoint"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="client-timeout"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('切换到 SOAP 后连接地址 label 变为 WSDL,超时仍显示;同一 endpoint 字段', async () => {
|
||||
const wrapper = mountDrawer();
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('soap');
|
||||
await wrapper.vm.$nextTick();
|
||||
const wrapper = await mountDrawer();
|
||||
await setControl(wrapper, 'client-connector-type', 'soap');
|
||||
// 连接地址仍是同一 client-endpoint 字段,仅 label 变 WSDL
|
||||
expect(wrapper.find('[data-testid="client-endpoint"]').exists()).toBe(true);
|
||||
// 超时在 SOAP 下也显示
|
||||
@@ -70,8 +112,8 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
expect(labels.some((t) => t.includes('WSDL'))).toBe(true);
|
||||
});
|
||||
|
||||
it('接口定义 REST 显示 HTTP 方法与请求路径', () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'interface' });
|
||||
it('接口定义 REST 显示 HTTP 方法与请求路径', async () => {
|
||||
const wrapper = await mountDrawer({ activeEntity: 'interface' });
|
||||
const labels = wrapper.findAll('label').map((l) => l.text());
|
||||
expect(labels.some((t) => t.includes('HTTP 方法'))).toBe(true);
|
||||
expect(labels.some((t) => t.includes('请求路径'))).toBe(true);
|
||||
@@ -80,26 +122,27 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
it('接口定义:选客户端实例后编码自动建议为「客户端编码-名称slug」,连接器类型为同款禁用下拉随客户端联动', async () => {
|
||||
const interfaceForm = createEmptyInterfaceDefinitionForm();
|
||||
interfaceForm.name = '鼎捷TOPGP库存查询GetItemStockList';
|
||||
const wrapper = mountDrawer({
|
||||
const wrapper = await mountDrawer({
|
||||
activeEntity: 'interface',
|
||||
interfaceForm,
|
||||
clientOptions: [{ code: '1001', name: '鼎捷TOPGP', connector_type: 'soap' }],
|
||||
});
|
||||
await wrapper.find('[data-testid="interface-client"]').setValue('1001');
|
||||
await setControl(wrapper, 'interface-client', '1001');
|
||||
// 编码留空 → 按客户端编码 + 名称 slug 自动建议
|
||||
expect(interfaceForm.code).toBe('1001-topgp-getitemstocklist');
|
||||
// 连接器类型与客户端实例同款下拉控件,仅禁用只读:随所选客户端联动展示
|
||||
const typeSelect = wrapper.find('[data-testid="interface-connector-type"]');
|
||||
const typeSelect = wrapper.getComponent('[data-testid="interface-connector-type"]');
|
||||
expect(typeSelect.text()).toContain('SOAP');
|
||||
expect(typeSelect.attributes('disabled')).toBeDefined();
|
||||
// 只渲染当前类型单项,不提供其他选项(不可改选)
|
||||
expect(typeSelect.findAll('option').length).toBe(1);
|
||||
// el-select 根为 DIV 无 disabled 属性,禁用态改以 .el-select__wrapper 的 is-disabled class 断言
|
||||
expect(isSelectDisabled(wrapper, 'interface-connector-type')).toBe(true);
|
||||
// 原生 option 标签已由 ElOption 组件承载,等价断言「只渲染当前类型单项,不提供其他选项(不可改选)」
|
||||
expect(typeSelect.findAllComponents({ name: 'ElOption' }).length).toBe(1);
|
||||
});
|
||||
|
||||
it('接口定义:状态在底部操作条以状态胶囊只读展示(悬停承载说明),无启用勾选', () => {
|
||||
it('接口定义:状态在底部操作条以状态胶囊只读展示(悬停承载说明),无启用勾选', async () => {
|
||||
const interfaceForm = createEmptyInterfaceDefinitionForm();
|
||||
interfaceForm.status = 'published';
|
||||
const wrapper = mountDrawer({ activeEntity: 'interface', interfaceForm });
|
||||
const wrapper = await mountDrawer({ activeEntity: 'interface', interfaceForm });
|
||||
// 操作条只放安静的状态指示器:彩点胶囊,不放表单控件与多行文案;长说明走悬停 title
|
||||
const chip = wrapper.find('[data-testid="lifecycle-status-chip"]');
|
||||
expect(chip.exists()).toBe(true);
|
||||
@@ -109,8 +152,8 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
expect(wrapper.findAll('input[type="checkbox"]').length).toBe(0);
|
||||
});
|
||||
|
||||
it('绑定:无来源实例编码字段,状态在底部操作条以禁用下拉只读展示', () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'binding' });
|
||||
it('绑定:无来源实例编码字段,状态在底部操作条以禁用下拉只读展示', async () => {
|
||||
const wrapper = await mountDrawer({ activeEntity: 'binding' });
|
||||
const labels = wrapper.findAll('label').map((l) => l.text());
|
||||
// 来源快捷列已删除:路由条件统一走高级配置 JSON
|
||||
expect(labels.some((t) => t.includes('来源实例编码'))).toBe(false);
|
||||
@@ -122,7 +165,7 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
|
||||
it('绑定:添加步骤并选接口后,只读提示该步接口归属的客户端实例', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountDrawer({
|
||||
const wrapper = await mountDrawer({
|
||||
activeEntity: 'binding',
|
||||
bindingForm,
|
||||
clientOptions: [
|
||||
@@ -135,21 +178,25 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
expect(wrapper.find('[data-testid="binding-client"]').exists()).toBe(false);
|
||||
// 添加一步并选择接口定义 → 只读提示其归属客户端实例
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('1001-iface');
|
||||
await setControl(wrapper, 'binding-step-interface-0', '1001-iface');
|
||||
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('1001');
|
||||
});
|
||||
|
||||
it('绑定能力下拉选项本地化:有翻译显示「中文名(注册名)」,无翻译兜底注册名', () => {
|
||||
const wrapper = mountDrawer({
|
||||
it('绑定能力下拉选项本地化:有翻译显示「中文名(注册名)」,无翻译兜底注册名', async () => {
|
||||
const wrapper = await mountDrawer({
|
||||
activeEntity: 'binding',
|
||||
capabilityOptions: [
|
||||
{ name: 'in_transit_transfer.query_inventory' },
|
||||
{ name: 'unknown.capability' },
|
||||
],
|
||||
});
|
||||
// 能力下拉是绑定表单首个 select;选项不再出现原始注册名裸文案
|
||||
const capabilitySelect = wrapper.find('select');
|
||||
expect(capabilitySelect.findAll('option').map((o) => o.text())).toEqual([
|
||||
// 能力下拉是绑定表单首个 el-select;原生 <option> 已由 ElOption 组件承载,
|
||||
// 文案从 label prop 读取(等价旧的原生 option 文本枚举)
|
||||
const capabilitySelect = wrapper.findComponent({ name: 'ElSelect' });
|
||||
expect(capabilitySelect.exists()).toBe(true);
|
||||
const labels = capabilitySelect.findAllComponents({ name: 'ElOption' })
|
||||
.map((o) => String(o.props('label')));
|
||||
expect(labels).toEqual([
|
||||
'在途库存查询(in_transit_transfer.query_inventory)',
|
||||
'unknown.capability',
|
||||
]);
|
||||
@@ -158,16 +205,16 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
|
||||
describe('IntegrationConnectorFormDrawer database connector type', () => {
|
||||
it('类型下拉含「数据库直连」;选中后显示 db_kind 四选一下拉、数据库连接串 label,超时照显', async () => {
|
||||
const wrapper = mountDrawer();
|
||||
const typeOptions = wrapper.find('[data-testid="client-connector-type"]').findAll('option');
|
||||
expect(typeOptions.map((o) => o.text())).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
|
||||
const wrapper = await mountDrawer();
|
||||
// el-select 选项由 ElOption 组件承载,label 从组件 prop 读取(等价旧的原生 option 文本枚举)
|
||||
expect(optionLabelsOf(wrapper, 'client-connector-type')).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
|
||||
// 非 database 类型不渲染 db_kind 下拉
|
||||
expect(wrapper.find('[data-testid="client-db-kind"]').exists()).toBe(false);
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
|
||||
const dbKind = wrapper.find('[data-testid="client-db-kind"]');
|
||||
await setControl(wrapper, 'client-connector-type', 'database');
|
||||
const dbKind = wrapper.getComponent('[data-testid="client-db-kind"]');
|
||||
expect(dbKind.exists()).toBe(true);
|
||||
// db_kind 专属下拉四选一(含未选占位项),label 即库名
|
||||
expect(dbKind.findAll('option').map((o) => o.text())).toEqual(['—', 'MySQL', 'Oracle', 'SQL Server', 'PostgreSQL']);
|
||||
// db_kind 专属下拉四选一(含未选占位项),label 即库名;同上按 ElOption 组件 label 断言
|
||||
expect(optionLabelsOf(wrapper, 'client-db-kind')).toEqual(['—', 'MySQL', 'Oracle', 'SQL Server', 'PostgreSQL']);
|
||||
// endpoint label 切换为数据库连接串语义;超时字段照常显示
|
||||
const labels = wrapper.findAll('label').map((l) => l.text());
|
||||
expect(labels.some((t) => t.includes('数据库连接串'))).toBe(true);
|
||||
@@ -176,12 +223,12 @@ describe('IntegrationConnectorFormDrawer database connector type', () => {
|
||||
|
||||
it('database 类型不显示 HTTP 方法/请求路径(接口表单随客户端联动 database 类型)', async () => {
|
||||
const interfaceForm = createEmptyInterfaceDefinitionForm();
|
||||
const wrapper = mountDrawer({
|
||||
const wrapper = await mountDrawer({
|
||||
activeEntity: 'interface',
|
||||
interfaceForm,
|
||||
clientOptions: [{ code: 'erp-db', name: 'ERP Oracle', connector_type: 'database' }],
|
||||
});
|
||||
await wrapper.find('[data-testid="interface-client"]').setValue('erp-db');
|
||||
await setControl(wrapper, 'interface-client', 'erp-db');
|
||||
// 接口类型随客户端联动为 database
|
||||
expect(interfaceForm.connector_type).toBe('database');
|
||||
const labels = wrapper.findAll('label').map((l) => l.text());
|
||||
@@ -193,18 +240,18 @@ describe('IntegrationConnectorFormDrawer database connector type', () => {
|
||||
|
||||
it('切回非 database 类型后 db_kind 下拉隐藏且残留值清空', async () => {
|
||||
const clientForm = createEmptyClientInstanceForm();
|
||||
const wrapper = mountDrawer({ clientForm });
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
|
||||
await wrapper.find('[data-testid="client-db-kind"]').setValue('oracle');
|
||||
const wrapper = await mountDrawer({ clientForm });
|
||||
await setControl(wrapper, 'client-connector-type', 'database');
|
||||
await setControl(wrapper, 'client-db-kind', 'oracle');
|
||||
expect(clientForm.db_kind).toBe('oracle');
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('rest');
|
||||
await setControl(wrapper, 'client-connector-type', 'rest');
|
||||
expect(wrapper.find('[data-testid="client-db-kind"]').exists()).toBe(false);
|
||||
expect(clientForm.db_kind).toBe('');
|
||||
});
|
||||
|
||||
it('database 类型高级配置提示列出生效键 oracle_lib_dir', async () => {
|
||||
const wrapper = mountDrawer();
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
|
||||
const wrapper = await mountDrawer();
|
||||
await setControl(wrapper, 'client-connector-type', 'database');
|
||||
expect(wrapper.text()).toContain('"oracle_lib_dir"');
|
||||
});
|
||||
});
|
||||
@@ -227,15 +274,15 @@ describe('IntegrationConnectorFormDrawer binding steps editor', () => {
|
||||
|
||||
it('接口从单选改为有序多选:添加两步,每步独立接口下拉与归属客户端只读提示', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountBinding({ bindingForm });
|
||||
const wrapper = await mountBinding({ bindingForm });
|
||||
// 空态无步骤行
|
||||
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(0);
|
||||
// 添加两步
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
expect(bindingForm.steps).toHaveLength(2);
|
||||
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('IF-STAGE');
|
||||
await wrapper.find('[data-testid="binding-step-interface-1"]').setValue('IF-SUBMIT');
|
||||
await setControl(wrapper, 'binding-step-interface-0', 'IF-STAGE');
|
||||
await setControl(wrapper, 'binding-step-interface-1', 'IF-SUBMIT');
|
||||
// 每步显示归属客户端只读提示(跨客户端步骤:database + soap)
|
||||
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('erp-db');
|
||||
expect(wrapper.find('[data-testid="binding-step-client-1"]').text()).toContain('tiptop-ws');
|
||||
@@ -243,11 +290,11 @@ describe('IntegrationConnectorFormDrawer binding steps editor', () => {
|
||||
|
||||
it('上移/下移重排步骤顺序;首步无上移、末步无下移(禁用)', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountBinding({ bindingForm });
|
||||
const wrapper = await mountBinding({ bindingForm });
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('IF-STAGE');
|
||||
await wrapper.find('[data-testid="binding-step-interface-1"]').setValue('IF-SUBMIT');
|
||||
await setControl(wrapper, 'binding-step-interface-0', 'IF-STAGE');
|
||||
await setControl(wrapper, 'binding-step-interface-1', 'IF-SUBMIT');
|
||||
expect(wrapper.find('[data-testid="binding-step-up-0"]').attributes('disabled')).toBeDefined();
|
||||
expect(wrapper.find('[data-testid="binding-step-down-1"]').attributes('disabled')).toBeDefined();
|
||||
// 下移首步 → 顺序翻转
|
||||
@@ -262,13 +309,12 @@ describe('IntegrationConnectorFormDrawer binding steps editor', () => {
|
||||
|
||||
it('删除步骤移除对应行;每步参数映射独立编辑写回对应步骤', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountBinding({ bindingForm });
|
||||
const wrapper = await mountBinding({ bindingForm });
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
// 每步独立的 param_mapping JSON 编辑(沿用 JsonTextareaField 交互)
|
||||
const stepRows = wrapper.findAll('[data-testid="binding-step-row"]');
|
||||
await stepRows[0].findComponent(JsonTextareaField).find('[data-testid="json-textarea"]')
|
||||
.setValue('{"erp_org":{"expr":"external_org"}}');
|
||||
await stepRows[0].find('[data-testid="json-textarea"]').setValue('{"erp_org":{"expr":"external_org"}}');
|
||||
expect(bindingForm.steps[0].param_mapping_json).toBe('{"erp_org":{"expr":"external_org"}}');
|
||||
expect(bindingForm.steps[1].param_mapping_json).toBe('');
|
||||
// 删除首步 → 只剩原第二步
|
||||
@@ -277,7 +323,7 @@ describe('IntegrationConnectorFormDrawer binding steps editor', () => {
|
||||
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(1);
|
||||
});
|
||||
|
||||
it('既有单接口绑定编辑回归:steps_json 单步行回显为一步且接口预选', () => {
|
||||
it('既有单接口绑定编辑回归:steps_json 单步行回显为一步且接口预选', async () => {
|
||||
const bindingForm = bindingRowToForm({
|
||||
id: 5, capability: 'in_transit_transfer.create_transfer', context_selector_json: {},
|
||||
steps_json: [{ interface_code: 'IF-STAGE', param_mapping_json: { erp_org: { expr: 'external_org' } } }],
|
||||
@@ -286,15 +332,16 @@ describe('IntegrationConnectorFormDrawer binding steps editor', () => {
|
||||
mapping_version: 1, priority: 0, environment: 'prod',
|
||||
effective_from: null, effective_to: null, status: 'draft',
|
||||
} as IntegrationBindingRow);
|
||||
const wrapper = mountBinding({ bindingForm });
|
||||
const wrapper = await mountBinding({ bindingForm });
|
||||
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(1);
|
||||
expect((wrapper.find('[data-testid="binding-step-interface-0"]').element as HTMLSelectElement).value).toBe('IF-STAGE');
|
||||
// el-select 不再是原生 select:预选值改以 EP 选中项文本断言(选项 label 为「名称(编码)」,含编码)
|
||||
expect(wrapper.getComponent('[data-testid="binding-step-interface-0"]').text()).toContain('IF-STAGE');
|
||||
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('erp-db');
|
||||
});
|
||||
});
|
||||
|
||||
describe('IntegrationConnectorFormDrawer JSON fields', () => {
|
||||
function findJsonField(wrapper: ReturnType<typeof mountDrawer>, labelPart: string) {
|
||||
function findJsonField(wrapper: VueWrapper, labelPart: string) {
|
||||
const field = wrapper
|
||||
.findAllComponents(JsonTextareaField)
|
||||
.find((w) => String(w.props('label')).includes(labelPart));
|
||||
@@ -302,8 +349,8 @@ describe('IntegrationConnectorFormDrawer JSON fields', () => {
|
||||
return field!;
|
||||
}
|
||||
|
||||
it('接口定义 4 个 JSON 字段纵向全宽堆叠渲染', () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'interface' });
|
||||
it('接口定义 4 个 JSON 字段纵向全宽堆叠渲染', async () => {
|
||||
const wrapper = await mountDrawer({ activeEntity: 'interface' });
|
||||
const labels = wrapper.findAllComponents(JsonTextareaField).map((w) => String(w.props('label')));
|
||||
expect(labels.some((t) => t.includes('请求模板'))).toBe(true);
|
||||
expect(labels.some((t) => t.includes('入参 Schema'))).toBe(true);
|
||||
@@ -313,7 +360,7 @@ describe('IntegrationConnectorFormDrawer JSON fields', () => {
|
||||
|
||||
it('格式化按钮将合法 JSON pretty-print 写回表单 state', async () => {
|
||||
const interfaceForm: InterfaceDefinitionFormState = createEmptyInterfaceDefinitionForm();
|
||||
const wrapper = mountDrawer({ activeEntity: 'interface', interfaceForm });
|
||||
const wrapper = await mountDrawer({ activeEntity: 'interface', interfaceForm });
|
||||
const field = findJsonField(wrapper, '请求模板');
|
||||
await field!.find('[data-testid="json-textarea"]').setValue('{"method":"POST","params":["erp_org"]}');
|
||||
await field!.find('[data-testid="json-format-button"]').trigger('click');
|
||||
@@ -323,7 +370,7 @@ describe('IntegrationConnectorFormDrawer JSON fields', () => {
|
||||
|
||||
it('非法 JSON 失焦后显示红字提示,格式化不改写内容', async () => {
|
||||
const interfaceForm: InterfaceDefinitionFormState = createEmptyInterfaceDefinitionForm();
|
||||
const wrapper = mountDrawer({ activeEntity: 'interface', interfaceForm });
|
||||
const wrapper = await mountDrawer({ activeEntity: 'interface', interfaceForm });
|
||||
const field = findJsonField(wrapper, '请求模板');
|
||||
const textarea = field!.find('[data-testid="json-textarea"]');
|
||||
await textarea.setValue('{ invalid');
|
||||
@@ -337,10 +384,10 @@ describe('IntegrationConnectorFormDrawer JSON fields', () => {
|
||||
expect(interfaceForm.request_spec_json).toBe('{ invalid');
|
||||
});
|
||||
|
||||
it('客户端实例与绑定实体的 JSON 字段同样启用格式化能力', () => {
|
||||
const clientWrapper = mountDrawer({ activeEntity: 'client' });
|
||||
it('客户端实例与绑定实体的 JSON 字段同样启用格式化能力', async () => {
|
||||
const clientWrapper = await mountDrawer({ activeEntity: 'client' });
|
||||
expect(findJsonField(clientWrapper, '连接配置').find('[data-testid="json-format-button"]').exists()).toBe(true);
|
||||
const bindingWrapper = mountDrawer({ activeEntity: 'binding' });
|
||||
const bindingWrapper = await mountDrawer({ activeEntity: 'binding' });
|
||||
expect(findJsonField(bindingWrapper, '高级路由条件').find('[data-testid="json-format-button"]').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -350,8 +397,8 @@ describe('IntegrationConnectorFormDrawer close guard', () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('抽屉带 dialog 语义且打开时渲染标题', () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'client' });
|
||||
it('抽屉带 dialog 语义且打开时渲染标题', async () => {
|
||||
const wrapper = await mountDrawer({ activeEntity: 'client' });
|
||||
const dialog = wrapper.find('[role="dialog"]');
|
||||
expect(dialog.exists()).toBe(true);
|
||||
expect(dialog.attributes('aria-modal')).toBe('true');
|
||||
@@ -359,47 +406,54 @@ describe('IntegrationConnectorFormDrawer close guard', () => {
|
||||
});
|
||||
|
||||
it('干净表单点击遮罩直接关闭,不弹确认', async () => {
|
||||
const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(false);
|
||||
const wrapper = mountDrawer();
|
||||
await wrapper.find('[data-testid="connector-form-drawer"]').trigger('click');
|
||||
// 脏检查确认已由 window.confirm 迁移为 ElMessageBox.confirm;默认拒绝=取消语义,干净表单不应触达
|
||||
const confirmSpy = vi.spyOn(ElMessageBox, 'confirm').mockRejectedValue('cancelled');
|
||||
const wrapper = await mountDrawer();
|
||||
await clickMask(wrapper);
|
||||
await flushPromises();
|
||||
expect(wrapper.emitted('close')).toHaveLength(1);
|
||||
expect(confirmSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('脏表单关闭先确认:拒绝则留在抽屉,允许才 emit close', async () => {
|
||||
const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(false);
|
||||
const wrapper = mountDrawer();
|
||||
// ElMessageBox.confirm 的 resolve=确认放弃、reject=取消保留(等价旧 window.confirm 布尔返回)
|
||||
const confirmSpy = vi.spyOn(ElMessageBox, 'confirm').mockRejectedValue('cancelled');
|
||||
const wrapper = await mountDrawer();
|
||||
await wrapper.find('[data-testid="client-endpoint"]').setValue('https://erp.example.com');
|
||||
await wrapper.find('[data-testid="connector-form-drawer"]').trigger('click');
|
||||
await clickMask(wrapper);
|
||||
await flushPromises();
|
||||
// 用户拒绝关闭 → 不 emit
|
||||
expect(confirmSpy).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.emitted('close')).toBeUndefined();
|
||||
|
||||
confirmSpy.mockReturnValue(true);
|
||||
await wrapper.find('[data-testid="connector-form-drawer"]').trigger('click');
|
||||
confirmSpy.mockResolvedValue('confirm');
|
||||
await clickMask(wrapper);
|
||||
await flushPromises();
|
||||
// 用户确认放弃 → 放行关闭
|
||||
expect(wrapper.emitted('close')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('Esc 关闭走同一确认入口(脏表单拒绝时不关闭)', async () => {
|
||||
const confirmSpy = vi.spyOn(window, 'confirm').mockReturnValue(false);
|
||||
const wrapper = mountDrawer();
|
||||
const confirmSpy = vi.spyOn(ElMessageBox, 'confirm').mockRejectedValue('cancelled');
|
||||
const wrapper = await mountDrawer();
|
||||
await wrapper.find('[data-testid="client-endpoint"]').setValue('https://erp.example.com');
|
||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
|
||||
await flushPromises();
|
||||
expect(confirmSpy).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.emitted('close')).toBeUndefined();
|
||||
|
||||
// 干净表单 Esc 直接关闭
|
||||
const cleanWrapper = mountDrawer();
|
||||
const cleanWrapper = await mountDrawer();
|
||||
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
|
||||
await flushPromises();
|
||||
expect(cleanWrapper.emitted('close')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('IntegrationConnectorFormDrawer credential modes', () => {
|
||||
it('db 模式按类型动态渲染字段(secret 字段为密码框),不显示 Secret 引用键', () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'credential' });
|
||||
it('db 模式按类型动态渲染字段(secret 字段为密码框),不显示 Secret 引用键', async () => {
|
||||
const wrapper = await mountDrawer({ activeEntity: 'credential' });
|
||||
const username = wrapper.find('[data-testid="credential-field-username"]');
|
||||
const password = wrapper.find('[data-testid="credential-field-password"]');
|
||||
expect(username.exists()).toBe(true);
|
||||
@@ -412,25 +466,25 @@ describe('IntegrationConnectorFormDrawer credential modes', () => {
|
||||
expect(wrapper.text()).toContain('{credential_password}');
|
||||
});
|
||||
|
||||
it('编辑态密文字段显示留空保持原值提示', () => {
|
||||
it('编辑态密文字段显示留空保持原值提示', async () => {
|
||||
const form = { ...createEmptyCredentialReferenceForm(), id: 7, fields: { username: 'erp_user' } };
|
||||
const wrapper = mountDrawer({ activeEntity: 'credential', credentialForm: form });
|
||||
const wrapper = await mountDrawer({ activeEntity: 'credential', credentialForm: form });
|
||||
const password = wrapper.find('[data-testid="credential-field-password"]');
|
||||
expect(password.attributes('placeholder')).toContain('留空');
|
||||
expect((wrapper.find('[data-testid="credential-field-username"]').element as HTMLInputElement).value).toBe('erp_user');
|
||||
});
|
||||
|
||||
it('切换凭据类型到 token 后按新类型渲染字段', async () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'credential' });
|
||||
await wrapper.find('[data-testid="credential-type"]').setValue('token');
|
||||
const wrapper = await mountDrawer({ activeEntity: 'credential' });
|
||||
await setControl(wrapper, 'credential-type', 'token');
|
||||
expect(wrapper.find('[data-testid="credential-field-token"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="credential-field-username"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).toContain('{credential_token}');
|
||||
});
|
||||
|
||||
it('切到 env 模式只显示 Secret 引用键,隐藏类型字段', async () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'credential' });
|
||||
await wrapper.find('[data-testid="credential-provider"]').setValue('env');
|
||||
const wrapper = await mountDrawer({ activeEntity: 'credential' });
|
||||
await setControl(wrapper, 'credential-provider', 'env');
|
||||
expect(wrapper.find('[data-testid="credential-secret-ref"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="credential-field-username"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="credential-field-password"]').exists()).toBe(false);
|
||||
@@ -438,14 +492,13 @@ describe('IntegrationConnectorFormDrawer credential modes', () => {
|
||||
});
|
||||
|
||||
describe('IntegrationConnectorFormDrawer credential identity freeze', () => {
|
||||
it('新建态:类型/来源下拉选项本地化渲染(与列表徽章一致),状态不进表单,无只读信息区', () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'credential' });
|
||||
const typeOptions = wrapper.find('[data-testid="credential-type"]').findAll('option');
|
||||
expect(typeOptions.map((o) => o.text())).toEqual(['账密', '令牌']);
|
||||
const providerOptions = wrapper.find('[data-testid="credential-provider"]').findAll('option');
|
||||
expect(providerOptions.map((o) => o.text())).toEqual(['界面维护(加密保存)', '环境变量']);
|
||||
// 状态由列表生命周期按钮流转,凭据表单只有来源/类型两个下拉
|
||||
expect(wrapper.findAll('select').length).toBe(2);
|
||||
it('新建态:类型/来源下拉选项本地化渲染(与列表徽章一致),状态不进表单,无只读信息区', async () => {
|
||||
const wrapper = await mountDrawer({ activeEntity: 'credential' });
|
||||
// 下拉选项由 ElOption 组件承载,本地化文案从 label prop 读取(等价旧的原生 option 文本枚举)
|
||||
expect(optionLabelsOf(wrapper, 'credential-type')).toEqual(['账密', '令牌']);
|
||||
expect(optionLabelsOf(wrapper, 'credential-provider')).toEqual(['界面维护(加密保存)', '环境变量']);
|
||||
// 状态由列表生命周期按钮流转,凭据表单只有来源/类型两个下拉(原生 select 计数等价改为 ElSelect 组件计数)
|
||||
expect(wrapper.findAllComponents({ name: 'ElSelect' }).length).toBe(2);
|
||||
// 新建态没有只读信息区
|
||||
expect(wrapper.find('[data-testid="credential-meta"]').exists()).toBe(false);
|
||||
// 正文分组:基本信息 + 凭据值
|
||||
@@ -453,32 +506,31 @@ describe('IntegrationConnectorFormDrawer credential identity freeze', () => {
|
||||
expect(wrapper.text()).toContain('凭据值');
|
||||
});
|
||||
|
||||
it('编辑态:编码/类型/来源以同款禁用表单控件只读展示(不用徽章形态),启用开关在底部操作条', () => {
|
||||
it('编辑态:编码/类型/来源以同款禁用表单控件只读展示(不用徽章形态),启用开关在底部操作条', async () => {
|
||||
const form = { ...createEmptyCredentialReferenceForm(), id: 7, code: 'tiptop-erp', credential_type: 'password', secret_provider: 'db', status: 'active' };
|
||||
const wrapper = mountDrawer({ activeEntity: 'credential', credentialForm: form });
|
||||
const wrapper = await mountDrawer({ activeEntity: 'credential', credentialForm: form });
|
||||
// 与新建态同款正常控件、禁用只读:编码输入框 + 来源/类型下拉(本地化文案,不出现裸枚举)
|
||||
const codeInput = wrapper.find('[data-testid="credential-code"]');
|
||||
expect((codeInput.element as HTMLInputElement).disabled).toBe(true);
|
||||
expect((codeInput.element as HTMLInputElement).value).toBe('tiptop-erp');
|
||||
const providerSelect = wrapper.find('[data-testid="credential-provider"]');
|
||||
expect(providerSelect.attributes('disabled')).toBeDefined();
|
||||
expect(providerSelect.text()).toContain('界面维护(加密保存)');
|
||||
const typeSelect = wrapper.find('[data-testid="credential-type"]');
|
||||
expect(typeSelect.attributes('disabled')).toBeDefined();
|
||||
expect(typeSelect.text()).toContain('账密');
|
||||
expect(isSelectDisabled(wrapper, 'credential-provider')).toBe(true);
|
||||
expect(wrapper.find('[data-testid="credential-provider"]').text()).toContain('界面维护(加密保存)');
|
||||
expect(isSelectDisabled(wrapper, 'credential-type')).toBe(true);
|
||||
expect(wrapper.find('[data-testid="credential-type"]').text()).toContain('账密');
|
||||
// 状态 = 底部操作条启用开关(随保存生效),悬停 title 说明停用断流后果
|
||||
const row = wrapper.find('[data-testid="credential-enabled-row"]');
|
||||
expect(row.exists()).toBe(true);
|
||||
expect(row.text()).toContain('随保存操作生效');
|
||||
// el-switch 将 role="switch"/aria-checked 渲染在内部 input 上(aria-checked 由内部 role=switch 元素承载)
|
||||
const switchBtn = wrapper.find('[data-testid="credential-enabled-switch"]');
|
||||
expect(switchBtn.attributes('aria-checked')).toBe('true');
|
||||
expect(switchBtn.find('[role="switch"]').attributes('aria-checked')).toBe('true');
|
||||
expect(switchBtn.attributes('title')).toContain('立即失败');
|
||||
// 变更路径一句话提示
|
||||
expect(wrapper.text()).toContain('以上信息创建后不可更改');
|
||||
});
|
||||
|
||||
it('凭据值段占位符逐个以代码徽章展示', () => {
|
||||
const wrapper = mountDrawer({ activeEntity: 'credential' });
|
||||
it('凭据值段占位符逐个以代码徽章展示', async () => {
|
||||
const wrapper = await mountDrawer({ activeEntity: 'credential' });
|
||||
const chips = wrapper.findAll('[data-testid="credential-placeholder-chip"]');
|
||||
expect(chips.map((c) => c.text())).toEqual(['{credential_username}', '{credential_password}']);
|
||||
});
|
||||
@@ -487,7 +539,7 @@ describe('IntegrationConnectorFormDrawer credential identity freeze', () => {
|
||||
describe('IntegrationConnectorFormDrawer client form redesign', () => {
|
||||
it('名称失焦且编码为空时自动建议 kebab-case 编码;已填编码不被覆盖', async () => {
|
||||
const clientForm = createEmptyClientInstanceForm();
|
||||
const wrapper = mountDrawer({ clientForm });
|
||||
const wrapper = await mountDrawer({ clientForm });
|
||||
await wrapper.find('[data-testid="client-name"]').setValue('ERP X');
|
||||
await wrapper.find('[data-testid="client-name"]').trigger('blur');
|
||||
expect(clientForm.code).toBe('erp-x');
|
||||
@@ -499,51 +551,50 @@ describe('IntegrationConnectorFormDrawer client form redesign', () => {
|
||||
|
||||
it('编辑态编码锁定不可改,类型/环境下拉本地化渲染', async () => {
|
||||
const clientForm = { ...createEmptyClientInstanceForm(), id: 3, code: 'erp-x' };
|
||||
const wrapper = mountDrawer({ clientForm });
|
||||
const wrapper = await mountDrawer({ clientForm });
|
||||
const code = wrapper.find('[data-testid="client-code"]');
|
||||
expect((code.element as HTMLInputElement).disabled).toBe(true);
|
||||
const typeOptions = wrapper.find('[data-testid="client-connector-type"]').findAll('option');
|
||||
expect(typeOptions.map((o) => o.text())).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
|
||||
const envOptions = wrapper.find('[data-testid="client-environment"]').findAll('option');
|
||||
expect(envOptions.map((o) => o.text())).toEqual(['开发', '测试', '生产']);
|
||||
// 下拉选项由 ElOption 组件承载,本地化文案从 label prop 读取(等价旧的原生 option 文本枚举)
|
||||
expect(optionLabelsOf(wrapper, 'client-connector-type')).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
|
||||
expect(optionLabelsOf(wrapper, 'client-environment')).toEqual(['开发', '测试', '生产']);
|
||||
});
|
||||
|
||||
it('凭据引用为下拉选择(含「无(匿名访问)」空项),高级配置按类型给出生效键提示', async () => {
|
||||
const wrapper = mountDrawer({
|
||||
const wrapper = await mountDrawer({
|
||||
credentialOptions: [{ code: 'tiptop-erp' }, { code: 'wms-token' }],
|
||||
});
|
||||
const credOptions = wrapper.find('[data-testid="client-credential-ref"]').findAll('option');
|
||||
expect(credOptions.map((o) => o.text())).toEqual(['无(匿名访问)', 'tiptop-erp', 'wms-token']);
|
||||
// 下拉选项由 ElOption 组件承载,label 从组件 prop 读取(等价旧的原生 option 文本枚举)
|
||||
expect(optionLabelsOf(wrapper, 'client-credential-ref')).toEqual(['无(匿名访问)', 'tiptop-erp', 'wms-token']);
|
||||
// REST:高级配置提示列出生效键 headers
|
||||
expect(wrapper.text()).toContain('"headers"');
|
||||
// 切到 SOAP:提示变为「暂无额外生效键」语义
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('soap');
|
||||
await setControl(wrapper, 'client-connector-type', 'soap');
|
||||
expect(wrapper.text()).toContain('暂无额外生效的配置键');
|
||||
});
|
||||
|
||||
it('启用开关置于底部操作条左侧:小字注明随保存生效,点击翻转 state,非客户端实体不渲染', async () => {
|
||||
const clientForm = createEmptyClientInstanceForm();
|
||||
const wrapper = mountDrawer({ clientForm });
|
||||
const wrapper = await mountDrawer({ clientForm });
|
||||
const row = wrapper.find('[data-testid="client-enabled-row"]');
|
||||
// 启用不再是表单体里的孤行复选框,而是底部操作条左侧的 role="switch" 开关
|
||||
//(EP el-switch 自带隐藏 checkbox input,旧「无复选框」计数已锁死旧实现,等价改断言开关结构)
|
||||
expect(row.exists()).toBe(true);
|
||||
expect(wrapper.findAll('input[type="checkbox"]').length).toBe(0);
|
||||
const switchBtn = wrapper.find('[data-testid="client-enabled-switch"]');
|
||||
expect(switchBtn.attributes('role')).toBe('switch');
|
||||
expect(switchBtn.find('[role="switch"]').exists()).toBe(true);
|
||||
// 小字「随保存操作生效」与列表行内开关的即时生效区分;悬停 title 携带停用后果
|
||||
expect(row.text()).toContain('随保存操作生效');
|
||||
expect(switchBtn.attributes('title')).toContain('连接测试不受影响');
|
||||
// 默认启用;点击翻转表单 state,aria 状态同步
|
||||
// 默认启用;点击翻转表单 state,aria 状态同步(aria-checked 在内部 role=switch 元素上)
|
||||
expect(clientForm.enabled).toBe(true);
|
||||
await switchBtn.trigger('click');
|
||||
expect(clientForm.enabled).toBe(false);
|
||||
expect(switchBtn.attributes('aria-checked')).toBe('false');
|
||||
expect(switchBtn.find('[role="switch"]').attributes('aria-checked')).toBe('false');
|
||||
// 凭据实体渲染自己的启用开关(同一底部形态),客户端开关行不出现
|
||||
const credWrapper = mountDrawer({ activeEntity: 'credential' });
|
||||
const credWrapper = await mountDrawer({ activeEntity: 'credential' });
|
||||
expect(credWrapper.find('[data-testid="client-enabled-row"]').exists()).toBe(false);
|
||||
expect(credWrapper.find('[data-testid="credential-enabled-row"]').exists()).toBe(true);
|
||||
// 接口/绑定不渲染启用开关,改为底部状态只读下拉
|
||||
const ifaceWrapper = mountDrawer({ activeEntity: 'interface' });
|
||||
const ifaceWrapper = await mountDrawer({ activeEntity: 'interface' });
|
||||
expect(ifaceWrapper.find('[data-testid="client-enabled-row"]').exists()).toBe(false);
|
||||
expect(ifaceWrapper.find('[data-testid="lifecycle-status-row"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
+493
-292
@@ -1,9 +1,10 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/components/IntegrationConnectorFormDrawer.vue
|
||||
用途:集成连接器四实体(客户端实例/接口定义/绑定/凭据引用)创建与编辑抽屉。
|
||||
依赖:activeEntity 对应的表单 state、useI18n、JsonTextareaField。
|
||||
逻辑:由 IntegrationConnectorPage 打开;按 activeEntity 渲染对应字段,客户端实例
|
||||
表单按「基本信息 → 连接配置 → 高级」分组,启用开关置于底部操作条左侧(随保存生效,悬停显示停用后果);
|
||||
依赖:element-plus(drawer 抽屉/form 表单控件族/ElMessageBox,沿用管理端 element-trial 主题)、
|
||||
activeEntity 对应的表单 state、useI18n、JsonTextareaField。
|
||||
逻辑:由 IntegrationConnectorPage 打开(props/emit 契约不变);按 activeEntity 渲染对应字段,
|
||||
客户端实例表单按「基本信息 → 连接配置 → 高级」分组,启用开关置于底部操作条左侧(随保存生效,悬停显示停用后果);
|
||||
客户端编码留空时按名称自动建议、
|
||||
接口编码留空时按「客户端实例编码-名称」自动建议(均可手改,已填不覆盖,编辑态编码锁定);
|
||||
客户端实例的连接器类型/环境/凭据引用均为下拉(选项来自模块常量与凭据列表,未知值兜底);
|
||||
@@ -18,11 +19,30 @@
|
||||
展示编码/类型/来源/状态(label+值行,与接口定义只读字段同款式),新建态下拉选项
|
||||
文案本地化与列表一致;高级配置帮助文案按连接器类型的生效键动态切换。
|
||||
JSON 配置字段统一走 JsonTextareaField;提交 emit save。右侧抽屉承载(表单长、JSON 面积大),
|
||||
带未保存离开确认(脏检查)、Esc 关闭与 dialog aria 语义。
|
||||
带未保存离开确认(脏检查经 ElMessageBox)、Esc/遮罩/× 关闭与 dialog aria 语义由 el-drawer 原生提供。
|
||||
视觉层已迁移 Element Plus(element-trial 主题),布局间距由 AdminLayout 壳层持有。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElDatePicker,
|
||||
ElDrawer,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElMessageBox,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSwitch,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import { ArrowDown, ArrowUp, CircleClose, Plus } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import JsonTextareaField from './JsonTextareaField.vue';
|
||||
import {
|
||||
CONNECTOR_CONFIG_KEYS,
|
||||
@@ -65,7 +85,6 @@ const emit = defineEmits<{
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const panelRef = ref<HTMLElement | null>(null);
|
||||
/** 打开时刻的表单快照,用于脏检查(表单均为扁平原始值,stringify 比对可靠)。 */
|
||||
const initialSnapshot = ref('');
|
||||
|
||||
@@ -232,12 +251,6 @@ const lifecycleStatus = computed(() =>
|
||||
props.activeEntity === 'interface' ? props.interfaceForm.status : props.bindingForm.status,
|
||||
);
|
||||
|
||||
/** 状态胶囊配色:已发布绿 / 其余中性(与列表状态徽章同规则;未知值兜底中性)。 */
|
||||
const lifecycleChipClass = computed(() => {
|
||||
if (lifecycleStatus.value === 'published') return 'bg-emerald-50 text-emerald-700';
|
||||
return 'bg-surface-soft text-secondary';
|
||||
});
|
||||
|
||||
/** 凭据类型本地化标签;未注册类型兜底原样显示(不写死类型集合)。 */
|
||||
function credentialTypeLabel(value: string) {
|
||||
return t(`admin.integrationConnector.credentialTypeLabels.${value}`, value);
|
||||
@@ -248,6 +261,39 @@ function credentialProviderLabel(value: string) {
|
||||
return t(`admin.integrationConnector.statusLabels.${value}`, value);
|
||||
}
|
||||
|
||||
// ---- 控件视图适配层(仅做「EP 控件值类型 ↔ 表单 state 类型」换算,不改提交契约) ----
|
||||
|
||||
/** 超时(秒):表单 state 恒为 string(composable 以 trim() 判空),el-input-number 产出 number。 */
|
||||
const timeoutSecondsModel = computed<number | undefined>({
|
||||
get: () => {
|
||||
const raw = props.clientForm.timeout_seconds;
|
||||
if (!raw.trim()) return undefined;
|
||||
const num = Number(raw);
|
||||
return Number.isFinite(num) ? num : undefined;
|
||||
},
|
||||
set: (value) => {
|
||||
props.clientForm.timeout_seconds = value === undefined || value === null ? '' : String(value);
|
||||
},
|
||||
});
|
||||
|
||||
/** 映射版本:清空时回退 1(与提交层 Number(form.mapping_version || 1) 兜底一致)。 */
|
||||
function setMappingVersion(value: number | undefined) {
|
||||
props.bindingForm.mapping_version = value ?? 1;
|
||||
}
|
||||
|
||||
/** 优先级:清空时回退 0(与提交层 Number(form.priority || 0) 兜底一致)。 */
|
||||
function setPriority(value: number | undefined) {
|
||||
props.bindingForm.priority = value ?? 0;
|
||||
}
|
||||
|
||||
/** 生效开始/结束:value-format 下控件产出 string|null,表单 state 恒为 string(空串=未设置)。 */
|
||||
function setEffectiveFrom(value: unknown) {
|
||||
props.bindingForm.effective_from = typeof value === 'string' ? value : '';
|
||||
}
|
||||
function setEffectiveTo(value: unknown) {
|
||||
props.bindingForm.effective_to = typeof value === 'string' ? value : '';
|
||||
}
|
||||
|
||||
const activeForm = computed(() => {
|
||||
if (props.activeEntity === 'client') return props.clientForm;
|
||||
if (props.activeEntity === 'interface') return props.interfaceForm;
|
||||
@@ -258,118 +304,112 @@ const activeForm = computed(() => {
|
||||
/** 表单相对打开时是否有变更;有变更时关闭需用户确认,防误触丢数据。 */
|
||||
const isDirty = computed(() => JSON.stringify(activeForm.value) !== initialSnapshot.value);
|
||||
|
||||
/** 统一关闭入口:脏表单先弹确认,取消则留在抽屉。 */
|
||||
function requestClose() {
|
||||
if (isDirty.value && !window.confirm(t('admin.integrationConnector.msg.unsavedConfirm'))) return;
|
||||
/**
|
||||
* 统一关闭入口:脏表单先经 ElMessageBox 确认(window.confirm 迁移),取消则留在抽屉。
|
||||
* 供 el-drawer before-close(Esc/遮罩/×)与底部「取消」按钮共用;保存成功路径不经此函数。
|
||||
*/
|
||||
async function requestClose() {
|
||||
if (!isDirty.value) {
|
||||
emit('close');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.integrationConnector.msg.unsavedConfirm'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
emit('close');
|
||||
}
|
||||
|
||||
/** Esc 关闭走同一确认入口。 */
|
||||
function onKeydown(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') requestClose();
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
initialSnapshot.value = JSON.stringify(activeForm.value);
|
||||
document.addEventListener('keydown', onKeydown);
|
||||
void nextTick(() => panelRef.value?.focus());
|
||||
} else {
|
||||
document.removeEventListener('keydown', onKeydown);
|
||||
}
|
||||
if (visible) initialSnapshot.value = JSON.stringify(activeForm.value);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="visible"
|
||||
class="fixed inset-0 z-50 flex justify-end bg-overlay"
|
||||
<el-drawer
|
||||
:model-value="visible"
|
||||
:title="entityTitle"
|
||||
size="720px"
|
||||
resizable
|
||||
destroy-on-close
|
||||
class="connector-form-drawer"
|
||||
data-testid="connector-form-drawer"
|
||||
@click.self="requestClose"
|
||||
:before-close="requestClose"
|
||||
>
|
||||
<aside
|
||||
ref="panelRef"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="entityTitle"
|
||||
class="h-full w-full max-w-4xl flex flex-col bg-surface shadow-2xl outline-none"
|
||||
>
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-default shrink-0">
|
||||
<h3 class="section-title">{{ entityTitle }}</h3>
|
||||
<p class="section-desc mt-1">{{ entityHint }}</p>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto flex-1">
|
||||
<div class="drawer-body">
|
||||
<p class="drawer-hint">{{ entityHint }}</p>
|
||||
<el-form label-position="top" @submit.prevent>
|
||||
<!-- 客户端实例:基本信息 → 连接配置 → 高级 三段式 -->
|
||||
<template v-if="activeEntity === 'client'">
|
||||
<div class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.sections.basic') }}</h4>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.name') }}</label>
|
||||
<input v-model="clientForm.name" type="text" class="input-field text-sm" data-testid="client-name" @blur="onClientNameBlur" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.code') }}</label>
|
||||
<input v-model="clientForm.code" type="text" class="input-field text-sm font-mono" :disabled="Boolean(clientForm.id)" data-testid="client-code" />
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.codeHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.connectorType') }}</label>
|
||||
<select v-model="clientForm.connector_type" class="input-field text-sm" data-testid="client-connector-type" @change="onConnectorTypeChange">
|
||||
<option v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :value="opt.value">{{ t(opt.labelKey) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="clientForm.connector_type === 'database'" class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.dbKind') }}</label>
|
||||
<div class="form-section">
|
||||
<h4 class="section-title">{{ t('admin.integrationConnector.sections.basic') }}</h4>
|
||||
<div class="form-grid">
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.name')">
|
||||
<el-input v-model="clientForm.name" data-testid="client-name" @blur="onClientNameBlur" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.code')">
|
||||
<el-input v-model="clientForm.code" class="mono-input" :disabled="Boolean(clientForm.id)" data-testid="client-code" />
|
||||
<p class="field-hint">{{ t('admin.integrationConnector.fields.codeHint') }}</p>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.connectorType')">
|
||||
<el-select v-model="clientForm.connector_type" data-testid="client-connector-type" @change="onConnectorTypeChange">
|
||||
<el-option v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :value="opt.value" :label="t(opt.labelKey)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-if="clientForm.connector_type === 'database'"
|
||||
:label="t('admin.integrationConnector.fields.dbKind')"
|
||||
>
|
||||
<!-- db_kind 专属四选一(D16):仅 database 类型显示;未选提交由 composable 校验拦截 -->
|
||||
<select v-model="clientForm.db_kind" class="input-field text-sm" data-testid="client-db-kind">
|
||||
<option value="">—</option>
|
||||
<option v-for="kind in DB_KIND_OPTIONS" :key="kind" :value="kind">{{ t(`admin.integrationConnector.connectorDbKind.${kind}`) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.environment') }}</label>
|
||||
<select v-model="clientForm.environment" class="input-field text-sm" data-testid="client-environment">
|
||||
<option v-for="env in ENVIRONMENT_OPTIONS" :key="env" :value="env">{{ t(`admin.integrationConnector.envLabels.${env}`) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<el-select v-model="clientForm.db_kind" data-testid="client-db-kind">
|
||||
<el-option label="—" value="" />
|
||||
<el-option v-for="kind in DB_KIND_OPTIONS" :key="kind" :value="kind" :label="t(`admin.integrationConnector.connectorDbKind.${kind}`)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.environment')">
|
||||
<el-select v-model="clientForm.environment" data-testid="client-environment">
|
||||
<el-option v-for="env in ENVIRONMENT_OPTIONS" :key="env" :value="env" :label="t(`admin.integrationConnector.envLabels.${env}`)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.sections.connection') }}</h4>
|
||||
<div class="form-section">
|
||||
<h4 class="section-title">{{ t('admin.integrationConnector.sections.connection') }}</h4>
|
||||
<!-- 连接地址:endpoint 合一字段;label 按连接器类型显示(REST=接口地址,SOAP=WSDL 地址,database=数据库连接串) -->
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t(endpointLabelKey) }}</label>
|
||||
<input v-model="clientForm.endpoint" type="text" class="input-field text-sm" :placeholder="t(endpointPlaceholderKey)" data-testid="client-endpoint" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.timeout') }}</label>
|
||||
<input v-model="clientForm.timeout_seconds" type="number" class="input-field text-sm" min="0" data-testid="client-timeout" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.credentialRef') }}</label>
|
||||
<select v-model="clientForm.credential_ref_code" class="input-field text-sm" data-testid="client-credential-ref">
|
||||
<option value="">{{ t('admin.integrationConnector.fields.credentialNone') }}</option>
|
||||
<option v-for="opt in credentialOptions || []" :key="opt.code" :value="opt.code">{{ opt.code }}</option>
|
||||
</select>
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.credentialRefHint') }}</p>
|
||||
</div>
|
||||
<el-form-item :label="t(endpointLabelKey)">
|
||||
<el-input v-model="clientForm.endpoint" :placeholder="t(endpointPlaceholderKey)" data-testid="client-endpoint" />
|
||||
</el-form-item>
|
||||
<div class="form-grid">
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.timeout')">
|
||||
<el-input-number v-model="timeoutSecondsModel" :min="0" class="full-control" data-testid="client-timeout" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.credentialRef')">
|
||||
<el-select v-model="clientForm.credential_ref_code" data-testid="client-credential-ref">
|
||||
<el-option :label="t('admin.integrationConnector.fields.credentialNone')" value="" />
|
||||
<el-option v-for="opt in credentialOptions || []" :key="opt.code" :value="opt.code" :label="opt.code" />
|
||||
</el-select>
|
||||
<p class="field-hint">{{ t('admin.integrationConnector.fields.credentialRefHint') }}</p>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<details class="rounded-lg border border-slate-200 px-3 py-2">
|
||||
<summary class="cursor-pointer text-xs font-bold text-secondary">{{ t('admin.integrationConnector.sections.advanced') }}</summary>
|
||||
<div class="mt-2 space-y-2">
|
||||
<p class="text-xs text-muted">{{ clientConfigHint }}</p>
|
||||
<details class="advanced-block">
|
||||
<summary class="advanced-summary">{{ t('admin.integrationConnector.sections.advanced') }}</summary>
|
||||
<div class="advanced-body">
|
||||
<p class="field-hint">{{ clientConfigHint }}</p>
|
||||
<JsonTextareaField
|
||||
v-model="clientForm.config_json"
|
||||
:label="t('admin.integrationConnector.fields.configJson')"
|
||||
@@ -379,147 +419,149 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
|
||||
</details>
|
||||
</template>
|
||||
|
||||
<!-- 接口定义:编码自动建议 + 类型随客户端联动(只读徽章)+ 接口契约 JSON 常显 + 状态只读徽章 -->
|
||||
<!-- 接口定义:编码自动建议 + 类型随客户端联动(只读下拉)+ 接口契约 JSON 常显 + 状态只读徽章 -->
|
||||
<template v-else-if="activeEntity === 'interface'">
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.name') }}</label>
|
||||
<input v-model="interfaceForm.name" type="text" class="input-field text-sm" data-testid="interface-name" @blur="onInterfaceNameBlur" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.code') }}</label>
|
||||
<input v-model="interfaceForm.code" type="text" class="input-field text-sm font-mono" :disabled="Boolean(interfaceForm.id)" data-testid="interface-code" />
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.codeHintInterface') }}</p>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.clientInstance') }}</label>
|
||||
<select v-model="interfaceForm.client_instance_code" class="input-field text-sm" data-testid="interface-client" @change="onInterfaceClientChange">
|
||||
<option v-for="opt in clientOptions" :key="opt.code" :value="opt.code">{{ optionLabel(opt.name, opt.code) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.connectorType') }}</label>
|
||||
<div class="form-grid">
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.name')">
|
||||
<el-input v-model="interfaceForm.name" data-testid="interface-name" @blur="onInterfaceNameBlur" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.code')">
|
||||
<el-input v-model="interfaceForm.code" class="mono-input" :disabled="Boolean(interfaceForm.id)" data-testid="interface-code" />
|
||||
<p class="field-hint">{{ t('admin.integrationConnector.fields.codeHintInterface') }}</p>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.clientInstance')">
|
||||
<el-select v-model="interfaceForm.client_instance_code" data-testid="interface-client" @change="onInterfaceClientChange">
|
||||
<el-option v-for="opt in clientOptions" :key="opt.code" :value="opt.code" :label="optionLabel(opt.name, opt.code)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.connectorType')">
|
||||
<!-- 与客户端实例同款下拉控件、仅禁用只读:类型随客户端实例自动确定(后端以其为单一事实源推导),不可单独修改 -->
|
||||
<select
|
||||
:value="interfaceForm.connector_type"
|
||||
class="input-field text-sm disabled:opacity-70"
|
||||
disabled
|
||||
data-testid="interface-connector-type"
|
||||
>
|
||||
<option :value="interfaceForm.connector_type">{{ connectorTypeLabel(interfaceForm.connector_type) }}</option>
|
||||
</select>
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.connectorTypeHint') }}</p>
|
||||
</div>
|
||||
<el-select :model-value="interfaceForm.connector_type" disabled data-testid="interface-connector-type">
|
||||
<el-option :value="interfaceForm.connector_type" :label="connectorTypeLabel(interfaceForm.connector_type)" />
|
||||
</el-select>
|
||||
<p class="field-hint">{{ t('admin.integrationConnector.fields.connectorTypeHint') }}</p>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-if="interfaceForm.connector_type === 'rest'" class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.httpMethod') }}</label>
|
||||
<select v-model="interfaceForm.http_method" class="input-field text-sm">
|
||||
<option value="">—</option>
|
||||
<option value="GET">GET</option>
|
||||
<option value="POST">POST</option>
|
||||
<option value="PUT">PUT</option>
|
||||
<option value="DELETE">DELETE</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.requestPath') }}</label>
|
||||
<input v-model="interfaceForm.request_path" type="text" class="input-field text-sm font-mono" :placeholder="t('admin.integrationConnector.placeholders.requestPath')" />
|
||||
</div>
|
||||
<div v-if="interfaceForm.connector_type === 'rest'" class="form-grid">
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.httpMethod')">
|
||||
<el-select v-model="interfaceForm.http_method">
|
||||
<el-option label="—" value="" />
|
||||
<el-option label="GET" value="GET" />
|
||||
<el-option label="POST" value="POST" />
|
||||
<el-option label="PUT" value="PUT" />
|
||||
<el-option label="DELETE" value="DELETE" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.requestPath')">
|
||||
<el-input v-model="interfaceForm.request_path" class="mono-input" :placeholder="t('admin.integrationConnector.placeholders.requestPath')" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
<!-- 接口契约(请求模板/入参 Schema/回传映射/出参 Schema)即接口定义本体:常显纵向全宽,不再折叠 -->
|
||||
<div class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.sections.contract') }}</h4>
|
||||
<div class="form-section">
|
||||
<h4 class="section-title">{{ t('admin.integrationConnector.sections.contract') }}</h4>
|
||||
<JsonTextareaField v-model="interfaceForm.request_spec_json" :label="t('admin.integrationConnector.fields.requestSpec')" />
|
||||
<JsonTextareaField v-model="interfaceForm.input_schema_json" :label="t('admin.integrationConnector.fields.inputSchema')" />
|
||||
<JsonTextareaField v-model="interfaceForm.response_mapping_json" :label="t('admin.integrationConnector.fields.responseMapping')" />
|
||||
<JsonTextareaField v-model="interfaceForm.output_schema_json" :label="t('admin.integrationConnector.fields.outputSchema')" />
|
||||
</div>
|
||||
<!-- 状态不进表单正文:以底部操作条只读下拉展示(转移只经列表生命周期按钮) -->
|
||||
<!-- 状态不进表单正文:以底部操作条只读状态徽章展示(转移只经列表生命周期按钮) -->
|
||||
</template>
|
||||
|
||||
<!-- 绑定:接口为有序步骤编辑器(client 由各步接口归属自带);状态为只读徽章(发布/退役走列表生命周期按钮) -->
|
||||
<template v-else-if="activeEntity === 'binding'">
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.capability') }}</label>
|
||||
<select v-model="bindingForm.capability" class="input-field text-sm">
|
||||
<option v-for="cap in capabilityOptions" :key="cap.name" :value="cap.name">{{ capabilityOptionLabel(cap.name) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.environment') }}</label>
|
||||
<select v-model="bindingForm.environment" class="input-field text-sm">
|
||||
<option v-for="env in ENVIRONMENT_OPTIONS" :key="env" :value="env">{{ t(`admin.integrationConnector.envLabels.${env}`) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.mappingVersion') }}</label>
|
||||
<input v-model.number="bindingForm.mapping_version" type="number" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.priority') }}</label>
|
||||
<input v-model.number="bindingForm.priority" type="number" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.effectiveFrom') }}</label>
|
||||
<input v-model="bindingForm.effective_from" type="datetime-local" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.effectiveTo') }}</label>
|
||||
<input v-model="bindingForm.effective_to" type="datetime-local" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.capability')">
|
||||
<el-select v-model="bindingForm.capability">
|
||||
<el-option v-for="cap in capabilityOptions" :key="cap.name" :value="cap.name" :label="capabilityOptionLabel(cap.name)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.environment')">
|
||||
<el-select v-model="bindingForm.environment">
|
||||
<el-option v-for="env in ENVIRONMENT_OPTIONS" :key="env" :value="env" :label="t(`admin.integrationConnector.envLabels.${env}`)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.mappingVersion')">
|
||||
<el-input-number
|
||||
:model-value="bindingForm.mapping_version"
|
||||
class="full-control"
|
||||
@update:model-value="setMappingVersion"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.priority')">
|
||||
<el-input-number
|
||||
:model-value="bindingForm.priority"
|
||||
class="full-control"
|
||||
@update:model-value="setPriority"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.effectiveFrom')">
|
||||
<el-date-picker
|
||||
:model-value="bindingForm.effective_from || undefined"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD[T]HH:mm"
|
||||
:placeholder="t('admin.integrationConnector.fields.effectiveFrom')"
|
||||
class="full-control"
|
||||
@update:model-value="setEffectiveFrom"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.effectiveTo')">
|
||||
<el-date-picker
|
||||
:model-value="bindingForm.effective_to || undefined"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD[T]HH:mm"
|
||||
:placeholder="t('admin.integrationConnector.fields.effectiveTo')"
|
||||
class="full-control"
|
||||
@update:model-value="setEffectiveTo"
|
||||
/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<!-- 有序步骤编辑器:提交时以 steps_json([{interface_code, param_mapping_json}])发送,
|
||||
调用期按数组顺序执行;client 由各步接口归属自带 → 每步只读提示,不再单独维护 -->
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.bindingSteps.label') }}</h4>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="binding-add-step" @click="addBindingStep">
|
||||
+ {{ t('admin.integrationConnector.bindingSteps.add') }}
|
||||
</button>
|
||||
<div class="form-section">
|
||||
<div class="steps-head">
|
||||
<h4 class="section-title">{{ t('admin.integrationConnector.bindingSteps.label') }}</h4>
|
||||
<el-button :icon="Plus" size="small" data-testid="binding-add-step" @click="addBindingStep">
|
||||
{{ t('admin.integrationConnector.bindingSteps.add') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.bindingSteps.hint') }}</p>
|
||||
<p class="field-hint">{{ t('admin.integrationConnector.bindingSteps.hint') }}</p>
|
||||
<div
|
||||
v-for="(step, index) in bindingForm.steps"
|
||||
:key="index"
|
||||
class="space-y-2 rounded-lg border border-slate-200 px-3 py-2.5"
|
||||
class="step-row"
|
||||
data-testid="binding-step-row"
|
||||
>
|
||||
<div class="flex items-end gap-2">
|
||||
<span class="pb-2 text-xs font-bold text-muted">{{ index + 1 }}</span>
|
||||
<div class="flex-1 space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.bindingSteps.interface') }}</label>
|
||||
<select v-model="step.interface_code" class="input-field text-sm" :data-testid="`binding-step-interface-${index}`">
|
||||
<option value="">—</option>
|
||||
<option v-for="opt in interfaceOptions" :key="opt.code" :value="opt.code">{{ optionLabel(opt.name, opt.code) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost text-xs"
|
||||
<div class="step-line">
|
||||
<span class="step-index">{{ index + 1 }}</span>
|
||||
<el-form-item class="step-interface" :label="t('admin.integrationConnector.bindingSteps.interface')">
|
||||
<el-select v-model="step.interface_code" :data-testid="`binding-step-interface-${index}`">
|
||||
<el-option label="—" value="" />
|
||||
<el-option v-for="opt in interfaceOptions" :key="opt.code" :value="opt.code" :label="optionLabel(opt.name, opt.code)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-button
|
||||
:icon="ArrowUp"
|
||||
:disabled="index === 0"
|
||||
:title="t('admin.integrationConnector.bindingSteps.moveUp')"
|
||||
:data-testid="`binding-step-up-${index}`"
|
||||
@click="moveBindingStep(index, -1)"
|
||||
>↑</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost text-xs"
|
||||
/>
|
||||
<el-button
|
||||
:icon="ArrowDown"
|
||||
:disabled="index === bindingForm.steps.length - 1"
|
||||
:title="t('admin.integrationConnector.bindingSteps.moveDown')"
|
||||
:data-testid="`binding-step-down-${index}`"
|
||||
@click="moveBindingStep(index, 1)"
|
||||
>↓</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost text-xs"
|
||||
/>
|
||||
<el-button
|
||||
type="danger"
|
||||
:icon="CircleClose"
|
||||
:title="t('admin.integrationConnector.bindingSteps.remove')"
|
||||
:data-testid="`binding-step-remove-${index}`"
|
||||
@click="removeBindingStep(index)"
|
||||
>✕</button>
|
||||
/>
|
||||
</div>
|
||||
<p v-if="bindingStepClientHint(index)" class="text-xs text-muted" :data-testid="`binding-step-client-${index}`">
|
||||
<p v-if="bindingStepClientHint(index)" class="field-hint" :data-testid="`binding-step-client-${index}`">
|
||||
{{ bindingStepClientHint(index) }}
|
||||
</p>
|
||||
<JsonTextareaField
|
||||
@@ -528,141 +570,300 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<details class="rounded-lg border border-slate-200 px-3 py-2">
|
||||
<summary class="cursor-pointer text-xs font-bold text-secondary">{{ t('admin.integrationConnector.advancedConfig') }}</summary>
|
||||
<div class="mt-2 space-y-2">
|
||||
<details class="advanced-block">
|
||||
<summary class="advanced-summary">{{ t('admin.integrationConnector.advancedConfig') }}</summary>
|
||||
<div class="advanced-body">
|
||||
<JsonTextareaField v-model="bindingForm.context_selector_json" :label="t('admin.integrationConnector.fields.contextSelector')" />
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.contextSelectorHint') }}</p>
|
||||
<p class="field-hint">{{ t('admin.integrationConnector.fields.contextSelectorHint') }}</p>
|
||||
</div>
|
||||
</details>
|
||||
<!-- 状态不进表单正文:以底部操作条只读下拉展示(转移只经列表生命周期按钮) -->
|
||||
<!-- 状态不进表单正文:以底部操作条只读状态徽章展示(转移只经列表生命周期按钮) -->
|
||||
</template>
|
||||
|
||||
<!-- 凭据引用:基本信息统一为正常表单控件(编辑态禁用只读,不用徽章形态);状态经底部启用开关随保存生效 -->
|
||||
<template v-else>
|
||||
<div class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.sections.basic') }}</h4>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.code') }}</label>
|
||||
<input v-model="credentialForm.code" type="text" class="input-field text-sm font-mono disabled:opacity-70" :disabled="isCredentialEdit" data-testid="credential-code" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.secretProvider') }}</label>
|
||||
<div class="form-section">
|
||||
<h4 class="section-title">{{ t('admin.integrationConnector.sections.basic') }}</h4>
|
||||
<div class="form-grid">
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.code')">
|
||||
<el-input v-model="credentialForm.code" class="mono-input" :disabled="isCredentialEdit" data-testid="credential-code" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.secretProvider')">
|
||||
<!-- 编辑态禁用:db↔env 切换会让存量密文变孤儿数据或调用期晚失败,变更须新建引用 -->
|
||||
<select v-model="credentialForm.secret_provider" class="input-field text-sm disabled:opacity-70" :disabled="isCredentialEdit" data-testid="credential-provider">
|
||||
<option value="db">{{ credentialProviderLabel('db') }}</option>
|
||||
<option value="env">{{ credentialProviderLabel('env') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.credentialType') }}</label>
|
||||
<el-select v-model="credentialForm.secret_provider" :disabled="isCredentialEdit" data-testid="credential-provider">
|
||||
<el-option value="db" :label="credentialProviderLabel('db')" />
|
||||
<el-option value="env" :label="credentialProviderLabel('env')" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.integrationConnector.fields.credentialType')">
|
||||
<!-- 编辑态禁用:类型决定密文字段结构,中途改类型会使存量密文失效,变更须新建引用 -->
|
||||
<select
|
||||
<el-select
|
||||
v-model="credentialForm.credential_type"
|
||||
class="input-field text-sm disabled:opacity-70"
|
||||
:disabled="isCredentialEdit || credentialForm.secret_provider !== 'db'"
|
||||
data-testid="credential-type"
|
||||
>
|
||||
<option v-for="spec in credentialTypeOptions" :key="spec.type" :value="spec.type">{{ credentialTypeLabel(spec.type) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<el-option v-for="spec in credentialTypeOptions" :key="spec.type" :value="spec.type" :label="credentialTypeLabel(spec.type)" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<p v-if="isCredentialEdit" class="text-xs text-muted">{{ t('admin.integrationConnector.formHints.credentialImmutable') }}</p>
|
||||
<p v-if="isCredentialEdit" class="field-hint">{{ t('admin.integrationConnector.formHints.credentialImmutable') }}</p>
|
||||
</div>
|
||||
<!-- 凭据值段:db 按类型动态渲染(secret 字段加密落库不回显,编辑留空 = 保持旧值);env 只登记配置键名 -->
|
||||
<div class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.sections.credentialValues') }}</h4>
|
||||
<div class="form-section">
|
||||
<h4 class="section-title">{{ t('admin.integrationConnector.sections.credentialValues') }}</h4>
|
||||
<template v-if="credentialForm.secret_provider === 'db'">
|
||||
<div v-if="credentialTypeSpec" class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div v-for="field in credentialTypeSpec.fields" :key="field.key" class="space-y-1.5">
|
||||
<label class="label-field">
|
||||
{{ credentialFieldLabel(field.key) }}
|
||||
<span v-if="!field.secret" class="text-xs text-muted">({{ t('admin.integrationConnector.fields.visibleField') }})</span>
|
||||
</label>
|
||||
<input
|
||||
<div v-if="credentialTypeSpec" class="form-grid">
|
||||
<el-form-item v-for="field in credentialTypeSpec.fields" :key="field.key" :label="credentialFieldLabel(field.key)">
|
||||
<el-input
|
||||
v-model="credentialForm.fields[field.key]"
|
||||
:type="field.secret ? 'password' : 'text'"
|
||||
class="input-field text-sm"
|
||||
:autocomplete="field.secret ? 'new-password' : 'off'"
|
||||
:placeholder="field.secret && credentialForm.id ? t('admin.integrationConnector.placeholders.passwordKeep') : ''"
|
||||
:data-testid="`credential-field-${field.key}`"
|
||||
/>
|
||||
</div>
|
||||
<span v-if="!field.secret" class="field-hint">({{ t('admin.integrationConnector.fields.visibleField') }})</span>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<!-- 模板占位符以代码徽章逐个展示,供接口模板作者复制 -->
|
||||
<div v-if="credentialPlaceholderKeys.length" class="flex flex-wrap items-center gap-2 text-xs text-muted">
|
||||
<span>{{ t('admin.integrationConnector.msg.credentialPlaceholdersHint') }}</span>
|
||||
<div v-if="credentialPlaceholderKeys.length" class="placeholder-row">
|
||||
<span class="field-hint">{{ t('admin.integrationConnector.msg.credentialPlaceholdersHint') }}</span>
|
||||
<code
|
||||
v-for="key in credentialPlaceholderKeys"
|
||||
:key="key"
|
||||
class="rounded bg-surface-soft px-1.5 py-0.5 font-mono text-[11px] text-secondary"
|
||||
class="placeholder-chip"
|
||||
data-testid="credential-placeholder-chip"
|
||||
>{{ key }}</code>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.secretRef') }}</label>
|
||||
<input v-model="credentialForm.secret_ref" type="text" class="input-field text-sm" data-testid="credential-secret-ref" />
|
||||
</div>
|
||||
<el-form-item v-else :label="t('admin.integrationConnector.fields.secretRef')">
|
||||
<el-input v-model="credentialForm.secret_ref" data-testid="credential-secret-ref" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="drawer-footer">
|
||||
<!-- 启用开关置于操作条左侧(仅客户端实体):内容区滚动时始终可见;
|
||||
小字「随保存操作生效」与列表行内开关的即时生效区分,悬停 title 显示停用的调用期后果 -->
|
||||
<div v-if="activeEntity === 'client'" class="mr-auto flex items-center gap-2.5" data-testid="client-enabled-row">
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
:aria-checked="clientForm.enabled"
|
||||
<div v-if="activeEntity === 'client'" class="footer-left" data-testid="client-enabled-row">
|
||||
<el-switch
|
||||
v-model="clientForm.enabled"
|
||||
:title="t('admin.integrationConnector.fields.enabledHint')"
|
||||
class="relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors"
|
||||
:class="clientForm.enabled ? 'bg-brand-600' : 'bg-slate-300'"
|
||||
data-testid="client-enabled-switch"
|
||||
@click="clientForm.enabled = !clientForm.enabled"
|
||||
>
|
||||
<span class="inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform" :class="clientForm.enabled ? 'translate-x-4' : 'translate-x-0.5'" />
|
||||
</button>
|
||||
<span class="whitespace-nowrap text-sm font-medium text-secondary">{{ t('admin.integrationConnector.fields.enabled') }}</span>
|
||||
<span class="whitespace-nowrap text-xs text-muted">{{ t('admin.integrationConnector.fields.enabledFooterHint') }}</span>
|
||||
/>
|
||||
<span class="footer-label">{{ t('admin.integrationConnector.fields.enabled') }}</span>
|
||||
<span class="footer-hint">{{ t('admin.integrationConnector.fields.enabledFooterHint') }}</span>
|
||||
</div>
|
||||
<!-- 凭据启用开关:同一底部形态;翻转 active↔retired,随「保存更改」提交(停用即断流,title 说明后果) -->
|
||||
<div v-else-if="activeEntity === 'credential'" class="mr-auto flex items-center gap-2.5" data-testid="credential-enabled-row">
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
:aria-checked="credentialEnabled"
|
||||
<div v-else-if="activeEntity === 'credential'" class="footer-left" data-testid="credential-enabled-row">
|
||||
<el-switch
|
||||
:model-value="credentialEnabled"
|
||||
:title="t('admin.integrationConnector.fields.credentialEnabledHint')"
|
||||
class="relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors"
|
||||
:class="credentialEnabled ? 'bg-brand-600' : 'bg-slate-300'"
|
||||
data-testid="credential-enabled-switch"
|
||||
@click="toggleCredentialEnabled"
|
||||
>
|
||||
<span class="inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform" :class="credentialEnabled ? 'translate-x-4' : 'translate-x-0.5'" />
|
||||
</button>
|
||||
<span class="whitespace-nowrap text-sm font-medium text-secondary">{{ t('admin.integrationConnector.fields.enabled') }}</span>
|
||||
<span class="whitespace-nowrap text-xs text-muted">{{ t('admin.integrationConnector.fields.enabledFooterHint') }}</span>
|
||||
@change="toggleCredentialEnabled"
|
||||
/>
|
||||
<span class="footer-label">{{ t('admin.integrationConnector.fields.enabled') }}</span>
|
||||
<span class="footer-hint">{{ t('admin.integrationConnector.fields.enabledFooterHint') }}</span>
|
||||
</div>
|
||||
<!-- 接口/绑定生命周期状态:安静的状态指示器(彩点胶囊 + 悬停承载长说明)——
|
||||
<!-- 接口/绑定生命周期状态:安静的状态指示器(状态徽章 + 悬停承载长说明)——
|
||||
操作条不放表单控件与多行文案,转移入口在列表行内按钮 -->
|
||||
<div v-else-if="activeEntity === 'interface' || activeEntity === 'binding'" class="mr-auto flex items-center gap-2" data-testid="lifecycle-status-row">
|
||||
<span class="whitespace-nowrap text-xs text-muted">{{ t('admin.integrationConnector.fields.status') }}</span>
|
||||
<span
|
||||
class="inline-flex items-center gap-1.5 whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-medium"
|
||||
:class="lifecycleChipClass"
|
||||
<div v-else-if="activeEntity === 'interface' || activeEntity === 'binding'" class="footer-left" data-testid="lifecycle-status-row">
|
||||
<span class="footer-hint">{{ t('admin.integrationConnector.fields.status') }}</span>
|
||||
<el-tag
|
||||
:type="lifecycleStatus === 'published' ? 'success' : 'info'"
|
||||
size="small"
|
||||
class="lifecycle-chip"
|
||||
:title="t('admin.integrationConnector.fields.statusHint')"
|
||||
data-testid="lifecycle-status-chip"
|
||||
>
|
||||
<span class="h-1.5 w-1.5 rounded-full bg-current" />
|
||||
<span class="chip-dot" />
|
||||
{{ statusLabel(lifecycleStatus) }}
|
||||
</span>
|
||||
</el-tag>
|
||||
</div>
|
||||
<button type="button" class="btn-ghost" @click="requestClose">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary disabled:opacity-70" :disabled="isSaving" @click="emit('save')">
|
||||
<span class="footer-spacer" />
|
||||
<el-button :disabled="isSaving" @click="requestClose">{{ t('admin.cancel') }}</el-button>
|
||||
<el-button type="primary" :loading="isSaving" :disabled="isSaving" @click="emit('save')">
|
||||
{{ isSaving ? t('admin.save') + '...' : t('admin.save') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.drawer-body {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.drawer-hint {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* 分区标题:与在途调拨类型页同款(上分隔线 + 加粗小标题) */
|
||||
.section-title {
|
||||
margin: 8px 0 12px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
padding-top: 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.form-section {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0 16px;
|
||||
}
|
||||
|
||||
/* EP 控件在表单网格内占满整格 */
|
||||
.form-grid :deep(.el-select),
|
||||
.form-grid :deep(.el-input-number),
|
||||
.form-grid :deep(.el-date-editor),
|
||||
.el-form-item :deep(.el-select) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.full-control {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mono-input :deep(.el-input__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
margin: 2px 0 0;
|
||||
width: 100%;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* 高级配置折叠块:原生 details 语义保留,视觉走 EP 中性 token */
|
||||
.advanced-block {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
.advanced-summary {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.advanced-body {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* 有序步骤编辑器 */
|
||||
.steps-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.steps-head .section-title {
|
||||
border-top: none;
|
||||
margin: 0;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.step-row {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.step-line {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.step-index {
|
||||
padding-top: 30px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.step-interface {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.placeholder-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.placeholder-chip {
|
||||
border-radius: 5px;
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-regular);
|
||||
padding: 2px 6px;
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* 抽屉底部操作区:左侧业务开关/状态徽章 + 右侧取消/保存 */
|
||||
.drawer-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.footer-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.footer-label {
|
||||
white-space: nowrap;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.footer-hint {
|
||||
white-space: nowrap;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.footer-spacer {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.lifecycle-chip .chip-dot {
|
||||
display: inline-block;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
+54
-14
@@ -2,14 +2,19 @@
|
||||
features/admin/modules/integration-connector/components/JsonTextareaField.vue
|
||||
用途:JSON 配置字段统一编辑器——全宽等宽 textarea + 格式化按钮 + 失焦即时校验,
|
||||
供本模块四实体表单(请求模板/Schema/映射/连接配置/上下文选择器)复用。
|
||||
依赖:useI18n。
|
||||
依赖:element-plus(textarea 输入与链接按钮,沿用管理端 element-trial 主题)、useI18n。
|
||||
逻辑:v-model 承载 JSON 文本(由父级表单 state 持有);失焦时校验,非法显示红字
|
||||
提示;「格式化」仅在合法 JSON 时 pretty-print 改写,非法时只提示不改写内容。
|
||||
空值视为合法(与保存链路 parseJsonField 的「空串返回 {}」一致)。
|
||||
视觉层已迁移 Element Plus(element-trial 主题),布局间距由 AdminLayout 壳层持有。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElInput } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
|
||||
const props = defineProps<{
|
||||
/** 字段标签,同时用于错误提示中的字段名。 */
|
||||
@@ -52,31 +57,66 @@ function format() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-1.5">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<label class="label-field">{{ label }}</label>
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs font-medium text-brand-600 hover:text-brand-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
<div class="json-field">
|
||||
<div class="json-field-head">
|
||||
<label class="json-field-label">{{ label }}</label>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="!modelValue.trim()"
|
||||
data-testid="json-format-button"
|
||||
@click="format"
|
||||
>
|
||||
{{ t('admin.integrationConnector.formatJson') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
<textarea
|
||||
:value="modelValue"
|
||||
rows="12"
|
||||
class="input-field text-sm font-mono leading-5"
|
||||
<el-input
|
||||
:model-value="modelValue"
|
||||
type="textarea"
|
||||
:rows="12"
|
||||
spellcheck="false"
|
||||
:placeholder="placeholder"
|
||||
class="json-field-textarea"
|
||||
data-testid="json-textarea"
|
||||
@input="emit('update:modelValue', ($event.target as HTMLTextAreaElement).value)"
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
@blur="onBlur"
|
||||
/>
|
||||
<p v-if="touched && !isValid" class="text-xs text-red-600" data-testid="json-error">
|
||||
<p v-if="touched && !isValid" class="json-field-error" data-testid="json-error">
|
||||
{{ t('admin.integrationConnector.invalidJsonHint') }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.json-field {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.json-field-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.json-field-label {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* 等宽字体保留:JSON 契约字段的阅读与编辑都依赖等宽对齐 */
|
||||
.json-field-textarea :deep(.el-textarea__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.json-field-error {
|
||||
margin: 0;
|
||||
color: var(--el-color-danger);
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,23 +1,34 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/SchedulesPage.vue
|
||||
* 定时任务管理独立页面壳层。路由:/admin/schedules
|
||||
* 依赖:useSchedulesAdmin、schedules.context、子 panel/overlays 组件。
|
||||
* 逻辑:reactive + provide admin 上下文;onMounted 加载列表。
|
||||
* 用途:定时任务管理独立页面壳层。路由:/admin/schedules
|
||||
* 依赖:useSchedulesAdmin、schedules.context、Element Plus、子 panel/overlays。
|
||||
* 逻辑:reactive + provide admin;ElConfigProvider 包裹 admin-table-section;概览/工作台切换。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted, provide, reactive } from 'vue';
|
||||
import { ElConfigProvider } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { useSchedulesAdmin } from './composables/useSchedulesAdmin';
|
||||
import { SCHEDULES_ADMIN_KEY, SCHEDULE_CREATE_MODAL_OPEN_KEY, type SchedulesAdminContextProvided } from './composables/schedules.context';
|
||||
import {
|
||||
SCHEDULES_ADMIN_KEY,
|
||||
SCHEDULE_CREATE_MODAL_OPEN_KEY,
|
||||
type SchedulesAdminContextProvided,
|
||||
} from './composables/schedules.context';
|
||||
import SchedulePageHeader from './components/SchedulePageHeader.vue';
|
||||
import ScheduleOverviewPanel from './components/ScheduleOverviewPanel.vue';
|
||||
import ScheduleWorkbenchPanel from './components/ScheduleWorkbenchPanel.vue';
|
||||
import SchedulesPageOverlays from './components/SchedulesPageOverlays.vue';
|
||||
|
||||
const { elementLocale } = useElementProvider();
|
||||
const adminApi = useSchedulesAdmin();
|
||||
const admin = reactive(adminApi) as SchedulesAdminContextProvided;
|
||||
provide(SCHEDULES_ADMIN_KEY, admin);
|
||||
/** 弹窗 v-if 须绑定原始 ref,避免 reactive 属性赋值破坏 ref 链接 */
|
||||
provide(SCHEDULE_CREATE_MODAL_OPEN_KEY, adminApi.showScheduleCreateModal);
|
||||
|
||||
onMounted(async () => {
|
||||
await admin.loadAll();
|
||||
await admin.applyFromRouteQuery();
|
||||
@@ -25,10 +36,12 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="section-gap animate-fade-in-up">
|
||||
<SchedulePageHeader />
|
||||
<ScheduleOverviewPanel v-if="admin.scheduleViewMode === 'overview'" />
|
||||
<ScheduleWorkbenchPanel v-else />
|
||||
</section>
|
||||
<SchedulesPageOverlays />
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<SchedulePageHeader />
|
||||
<ScheduleOverviewPanel v-if="admin.scheduleViewMode === 'overview'" />
|
||||
<ScheduleWorkbenchPanel v-else />
|
||||
</section>
|
||||
<SchedulesPageOverlays />
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
+12
-12
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/DynamicTaskParamsForm.spec.ts
|
||||
* 用途:复现「货代库存 RPA」平台任务参数表单的渲染。
|
||||
* 背景:排程编辑弹窗选择 shipping-inventory-rpa 后,库存源多选字段不呈现,且弹窗按钮疑似失效。
|
||||
* 断言:给定带 source_codes(multi_select/options_source=shipping_inventory_sources) 的定义,
|
||||
* 背景:排程编辑弹窗选择 freight-rpa-onhand 后,库存源多选字段不呈现,且弹窗按钮疑似失效。
|
||||
* 断言:给定带 source_codes(multi_select/options_source=freight_rpa_sources) 的定义,
|
||||
* 挂载后应渲染「库存源」标签及动态选项,而不是抛错或渲染为空。
|
||||
*/
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
@@ -19,26 +19,26 @@ vi.mock('@/features/admin/api/schedule.api', () => ({
|
||||
),
|
||||
}));
|
||||
|
||||
const shippingInventoryRpaDefinition = {
|
||||
task_type: 'shipping-inventory-rpa',
|
||||
const shippingOnhandRpaDefinition = {
|
||||
task_type: 'freight-rpa-onhand',
|
||||
label: '货代库存 RPA',
|
||||
label_key: 'admin.schedule.form.platformJobShippingInventory',
|
||||
label_key: 'admin.schedule.form.platformJobFreightRpaOnhand',
|
||||
description: '按计划从配置的库存源抓取库存数据,由 freight_rpa_worker 异步导出。',
|
||||
description_key: 'admin.schedule.form.shippingInventoryJobHint',
|
||||
description_key: 'admin.schedule.form.freightRpaOnhandJobHint',
|
||||
category: 'shipping',
|
||||
params_schema: [
|
||||
{
|
||||
key: 'source_codes',
|
||||
type: 'multi_select',
|
||||
label: '库存源',
|
||||
label_key: 'admin.schedule.form.shippingInventorySources',
|
||||
label_key: 'admin.schedule.form.freightRpaSources',
|
||||
required: false,
|
||||
default: [],
|
||||
options_source: 'shipping_inventory_sources',
|
||||
options_source: 'freight_rpa_sources',
|
||||
placeholder: '留空则导出全部启用库存源',
|
||||
placeholder_key: 'admin.schedule.form.shippingInventorySourcesPlaceholder',
|
||||
placeholder_key: 'admin.schedule.form.freightRpaSourcesPlaceholder',
|
||||
help: '选择需要执行的库存源;选项来自库存源配置,留空则全部执行。',
|
||||
help_key: 'admin.schedule.form.shippingInventorySourcesHelp',
|
||||
help_key: 'admin.schedule.form.freightRpaSourcesHelp',
|
||||
},
|
||||
],
|
||||
defaults: { source_codes: [] },
|
||||
@@ -57,7 +57,7 @@ function mountForm() {
|
||||
});
|
||||
return mount(DynamicTaskParamsForm, {
|
||||
props: {
|
||||
definition: shippingInventoryRpaDefinition as any,
|
||||
definition: shippingOnhandRpaDefinition as any,
|
||||
modelValue: { source_codes: [] },
|
||||
valid: true,
|
||||
},
|
||||
@@ -65,7 +65,7 @@ function mountForm() {
|
||||
});
|
||||
}
|
||||
|
||||
describe('DynamicTaskParamsForm (shipping-inventory-rpa)', () => {
|
||||
describe('DynamicTaskParamsForm (freight-rpa-onhand)', () => {
|
||||
beforeEach(() => vi.clearAllMocks());
|
||||
|
||||
it('renders the 库存源 label and the two dynamic options', async () => {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* features/admin/modules/schedules/components/DynamicTaskParamsForm.vue
|
||||
* 用途:平台任务参数通用表单——按注册表 params_schema 渲染控件并输出统一 job_params。
|
||||
* 依赖:schedule.api(PlatformTaskDefinition/listAdminPlatformTaskOptions)、vue-i18n。
|
||||
* 逻辑:ScheduleCreateEditModal 传入选中任务的 definition;本组件只认识控件 type 与
|
||||
* 逻辑:ScheduleCreateEditDrawer 传入选中任务的 definition;本组件只认识控件 type 与
|
||||
* options_source,不认识具体任务(红框参数区完全由 schema 决定);
|
||||
* 高级配置折叠 JSON 与 schema type=json 字段均本地校验,非法时 emit valid=false 阻止保存;
|
||||
* modelValue 异步回填时同步 _advanced / json 文本(用户已编辑时不覆盖)。
|
||||
|
||||
+472
@@ -0,0 +1,472 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleCreateEditDrawer.vue
|
||||
* 用途:排程新增/编辑右侧抽屉(Element Plus ElDrawer + ElForm)。
|
||||
* 依赖:schedules.context、ScheduleCronDesigner、DynamicTaskParamsForm、Element Plus。
|
||||
* 逻辑:替换原居中 Modal;平台 Job 与动态参数区行为不变;ElDrawer resizable 支持左缘拖拽调宽。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowDown, ArrowUp, Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElCollapse,
|
||||
ElCollapseItem,
|
||||
ElDivider,
|
||||
ElDrawer,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
} from 'element-plus';
|
||||
import { useScheduleCreateModalOpen, useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
import DynamicTaskParamsForm from './DynamicTaskParamsForm.vue';
|
||||
import ScheduleCronDesigner from './ScheduleCronDesigner.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
const showCreateModal = useScheduleCreateModalOpen();
|
||||
|
||||
const drawerTitle = computed(() => (
|
||||
admin.scheduleEditingId ? t('admin.schedule.form.editTitle') : t('admin.schedule.form.createTitle')
|
||||
));
|
||||
|
||||
const submitDisabled = computed(() => (
|
||||
admin.scheduleCreateSaving
|
||||
|| !admin.scheduleCreateForm.name
|
||||
|| !admin.scheduleCreateForm.owner_user_id
|
||||
|| !admin.cronDesigner.isValid
|
||||
));
|
||||
|
||||
/**
|
||||
* 用户下拉展示名。
|
||||
* @param user - 用户行
|
||||
*/
|
||||
function userLabel(user: { real_name?: string | null; username: string; employee_id?: string | null }): string {
|
||||
const name = user.real_name || user.username;
|
||||
return user.employee_id ? `${name}(${user.employee_id})` : name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭抽屉(提交中忽略,由 ElDrawer 的 close-on 控制)。
|
||||
*/
|
||||
function handleClose(): void {
|
||||
if (!admin.scheduleCreateSaving) admin.closeScheduleCreateModal();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElDrawer
|
||||
:model-value="showCreateModal"
|
||||
size="min(720px, 96vw)"
|
||||
direction="rtl"
|
||||
resizable
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="!admin.scheduleCreateSaving"
|
||||
:close-on-press-escape="!admin.scheduleCreateSaving"
|
||||
:show-close="!admin.scheduleCreateSaving"
|
||||
class="schedule-create-drawer"
|
||||
@close="handleClose"
|
||||
>
|
||||
<template #header>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ drawerTitle }}</h3>
|
||||
</template>
|
||||
|
||||
<ElForm label-position="top" class="schedule-create-form" @submit.prevent>
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.name')" required>
|
||||
<ElInput
|
||||
v-model="admin.scheduleCreateForm.name"
|
||||
:placeholder="t('admin.schedule.form.namePlaceholder')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.owner')" required>
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.owner_user_id"
|
||||
filterable
|
||||
class="w-full"
|
||||
:disabled="admin.users.length === 0"
|
||||
:placeholder="admin.users.length === 0 ? t('admin.schedule.form.noUsers') : t('admin.schedule.form.selectOwner')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="u in admin.users"
|
||||
:key="u.id"
|
||||
:label="userLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
|
||||
<ElDivider content-position="left">{{ t('admin.schedule.form.dataSourceConfig') }}</ElDivider>
|
||||
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.scheduleType')">
|
||||
<ElSelect v-model="admin.scheduleCreateForm.schedule_type" class="w-full">
|
||||
<ElOption :label="t('admin.schedule.form.scheduleTypeDataPipeline')" value="data_pipeline" />
|
||||
<ElOption :label="t('admin.schedule.form.scheduleTypePlatformJob')" value="platform_job" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'"
|
||||
:label="t('admin.schedule.form.dataSourceType')"
|
||||
>
|
||||
<ElSelect v-model="admin.scheduleCreateForm.data_source_type" class="w-full">
|
||||
<ElOption :label="t('admin.schedule.form.databaseDirect')" value="database" />
|
||||
<ElOption :label="t('admin.schedule.form.externalApi')" value="external_api" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
v-else
|
||||
:label="t('admin.schedule.form.platformJob')"
|
||||
>
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.platform_api_path"
|
||||
class="w-full"
|
||||
:placeholder="t('admin.schedule.form.selectPlatformJob')"
|
||||
@change="admin.handlePlatformJobChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="job in admin.platformJobs"
|
||||
:key="job.key"
|
||||
:label="job.label_key ? t(job.label_key) : (job.label || job.key)"
|
||||
:value="job.key"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
|
||||
<ElSpace v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'" wrap class="mb-3">
|
||||
<ElButton
|
||||
:disabled="admin.scheduleTestLoading || !admin.scheduleEditingId"
|
||||
:loading="admin.scheduleTestLoading"
|
||||
@click="admin.handleTestScheduleSql"
|
||||
>
|
||||
{{ admin.scheduleTestLoading ? t('admin.schedule.form.querying') : t('admin.schedule.form.testQuery') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
:icon="admin.scheduleConfigCollapsed ? ArrowDown : ArrowUp"
|
||||
@click="admin.scheduleConfigCollapsed = !admin.scheduleConfigCollapsed"
|
||||
>
|
||||
{{ admin.scheduleConfigCollapsed ? t('admin.schedule.form.expandConfig') : t('admin.schedule.form.collapseConfig') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
|
||||
<div
|
||||
v-show="admin.scheduleCreateForm.schedule_type === 'data_pipeline' && !admin.scheduleConfigCollapsed"
|
||||
class="space-y-3"
|
||||
>
|
||||
<template v-if="admin.scheduleCreateForm.data_source_type === 'database'">
|
||||
<ElCollapse model-value="ds">
|
||||
<ElCollapseItem :title="t('admin.schedule.form.dataSourceSection')" name="ds">
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.dsDbType')">
|
||||
<ElSelect v-model="admin.scheduleSqlEditForm.ds_db_type" class="w-full">
|
||||
<ElOption label="SQL Server" value="sqlserver" />
|
||||
<ElOption label="PostgreSQL" value="postgresql" />
|
||||
<ElOption label="MySQL" value="mysql" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsHost')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_host" :placeholder="t('admin.schedule.form.dsHostPlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsPort')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_port" placeholder="1433" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsDatabase')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_database" :placeholder="t('admin.schedule.form.dsDatabasePlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsUsername')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_username" placeholder="sa" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsPassword')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_password" type="password" show-password :placeholder="t('admin.schedule.form.dsPasswordPlaceholder')" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div v-if="admin.scheduleSqlEditForm.ds_db_type === 'sqlserver'" class="grid grid-cols-1 gap-2 sm:grid-cols-3">
|
||||
<ElFormItem :label="t('admin.schedule.form.dsDriver')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.ds_driver" placeholder="SQL Server" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsEncrypt')">
|
||||
<ElSelect v-model="admin.scheduleSqlEditForm.ds_encrypt" class="w-full" clearable>
|
||||
<ElOption :label="t('admin.schedule.form.defaultNo')" value="" />
|
||||
<ElOption label="yes" value="yes" />
|
||||
<ElOption label="no" value="no" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.dsTrustCert')">
|
||||
<ElSelect v-model="admin.scheduleSqlEditForm.ds_trust_cert" class="w-full" clearable>
|
||||
<ElOption :label="t('admin.schedule.form.defaultYes')" value="" />
|
||||
<ElOption label="yes" value="yes" />
|
||||
<ElOption label="no" value="no" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<p class="text-xs text-muted">{{ t('admin.schedule.form.envVarHint', { token: t('admin.schedule.form.envVarToken') }) }}</p>
|
||||
</ElCollapseItem>
|
||||
</ElCollapse>
|
||||
|
||||
<ElFormItem :label="t('admin.schedule.form.baseFetchSql')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.base_fetch_sql" type="textarea" :rows="6" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.fetchWhereConditions')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.fetch_where_conditions" type="textarea" :rows="3" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.fetchOrderBy')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.fetch_order_by" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.detailSql')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.detail_sql" type="textarea" :rows="4" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.writebackSql')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.writeback_sql" type="textarea" :rows="2" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.rowIdKey')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.row_id_key" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.logPrefix')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.log_prefix" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<ElFormItem :label="t('admin.schedule.form.aliasOrder')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.alias_order_str" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.detailAliasOrder')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.detail_alias_order_str" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.headerLabels')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.header_labels_str" type="textarea" :rows="3" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
</template>
|
||||
|
||||
<template v-if="admin.scheduleCreateForm.data_source_type === 'external_api'">
|
||||
<ElFormItem :label="t('admin.schedule.form.apiUrl')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.api_url" placeholder="https://api.example.com/endpoint" />
|
||||
</ElFormItem>
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.apiMethod')">
|
||||
<ElSelect v-model="admin.scheduleSqlEditForm.api_method" class="w-full">
|
||||
<ElOption label="POST" value="POST" />
|
||||
<ElOption label="GET" value="GET" />
|
||||
<ElOption label="PUT" value="PUT" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.apiTimeoutSeconds')">
|
||||
<ElInputNumber :model-value="120" disabled class="w-full" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<ElFormItem :label="t('admin.schedule.form.apiHeaders')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.api_headers_str" type="textarea" :rows="2" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.apiBodyTemplate')">
|
||||
<ElInput v-model="admin.scheduleSqlEditForm.api_body_template" type="textarea" :rows="3" class="font-mono text-xs" />
|
||||
</ElFormItem>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'platform_job'" class="mt-2">
|
||||
<DynamicTaskParamsForm
|
||||
v-if="admin.selectedPlatformTaskDefinition"
|
||||
:definition="admin.selectedPlatformTaskDefinition"
|
||||
:model-value="admin.scheduleCreateForm.job_params"
|
||||
:valid="admin.platformJobParamsValid"
|
||||
@update:model-value="admin.scheduleCreateForm.job_params = $event"
|
||||
@update:valid="admin.platformJobParamsValid = $event"
|
||||
/>
|
||||
<div
|
||||
v-else-if="admin.platformTaskDefinitionsLoading || admin.platformTaskDefinitionsError"
|
||||
class="space-y-2 rounded-lg border border-default px-4 py-3 text-sm text-muted"
|
||||
>
|
||||
<p>
|
||||
{{ admin.platformTaskDefinitionsLoading
|
||||
? t('admin.schedule.form.dynamicParamsLoading')
|
||||
: t('admin.schedule.form.dynamicParamsLoadFailed') }}
|
||||
</p>
|
||||
<ElButton
|
||||
v-if="admin.platformTaskDefinitionsError && !admin.platformTaskDefinitionsLoading"
|
||||
size="small"
|
||||
@click="admin.loadPlatformTaskDefinitions"
|
||||
>
|
||||
{{ t('admin.schedule.form.dynamicParamsRetry') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleTestResult" class="mt-3 rounded-lg border border-emerald-200 bg-emerald-50/40 p-3">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h4 class="text-sm font-bold text-emerald-900">{{ t('admin.schedule.testRun.queryResult') }}</h4>
|
||||
<ElButton link type="primary" @click="admin.scheduleTestResult = null">✕</ElButton>
|
||||
</div>
|
||||
<p class="mb-2 text-xs text-emerald-600">
|
||||
{{ t('admin.schedule.testRun.resultSummary', { total: admin.scheduleTestResult.total, showing: admin.scheduleTestResult.showing }) }}
|
||||
</p>
|
||||
<div class="mb-2 overflow-x-auto rounded border border-emerald-200 bg-surface">
|
||||
<table class="w-full text-xs">
|
||||
<thead class="bg-emerald-50">
|
||||
<tr>
|
||||
<th
|
||||
v-for="col in admin.scheduleTestResult.columns"
|
||||
:key="col"
|
||||
class="whitespace-nowrap px-3 py-2 text-left font-semibold text-emerald-800"
|
||||
>{{ col }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(row, ri) in admin.scheduleTestResult.rows"
|
||||
:key="ri"
|
||||
class="border-t border-emerald-100"
|
||||
>
|
||||
<td
|
||||
v-for="col in admin.scheduleTestResult.columns"
|
||||
:key="col"
|
||||
class="whitespace-nowrap px-3 py-1.5 text-secondary"
|
||||
>{{ row[col] }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<details>
|
||||
<summary class="cursor-pointer text-xs font-semibold text-emerald-700">{{ t('admin.schedule.testRun.viewGeneratedSql') }}</summary>
|
||||
<pre class="admin-pre-block admin-pre-block--sql">{{ admin.scheduleTestResult.sql }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<template v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'">
|
||||
<ElDivider />
|
||||
<div class="grid grid-cols-1 gap-2 sm:grid-cols-2">
|
||||
<ElFormItem :label="t('admin.schedule.form.agentLabel')">
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.dify_agent_id"
|
||||
class="w-full"
|
||||
clearable
|
||||
:disabled="admin.agents.length === 0"
|
||||
:placeholder="admin.agents.length === 0 ? t('admin.schedule.form.noAgents') : t('admin.schedule.form.agentDisabled')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="a in admin.agents"
|
||||
:key="a.id"
|
||||
:label="`${a.name}${t('admin.schedule.form.agentOptionId', { id: a.dify_app_id?.slice(0, 8) || a.id })}`"
|
||||
:value="a.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.waitSeconds')">
|
||||
<ElInputNumber v-model="admin.scheduleCreateForm.wait_seconds" :min="0" class="w-full" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
|
||||
<ElFormItem>
|
||||
<ElCheckbox v-model="admin.scheduleCreateForm.kb_sync_enabled">
|
||||
{{ t('admin.schedule.form.kbSyncEnabled') }}
|
||||
</ElCheckbox>
|
||||
<p class="mt-1 text-xs text-muted">{{ t('admin.schedule.form.kbSyncHint') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem
|
||||
v-if="admin.scheduleCreateForm.kb_sync_enabled"
|
||||
:label="t('admin.schedule.form.kbGroup')"
|
||||
>
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.kb_group_id"
|
||||
class="w-full"
|
||||
:disabled="admin.kbGroups.length === 0"
|
||||
:placeholder="admin.kbGroups.length === 0 ? t('admin.schedule.form.noKbGroups') : t('admin.schedule.form.selectKbGroup')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="group in admin.kbGroups"
|
||||
:key="group.id"
|
||||
:label="group.name"
|
||||
:value="group.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem
|
||||
v-if="admin.scheduleCreateForm.dify_agent_id"
|
||||
:label="t('admin.schedule.form.difySystemPrompt')"
|
||||
>
|
||||
<p class="mb-2 text-xs text-muted">{{ t('admin.schedule.form.difySystemPromptHint') }}</p>
|
||||
<ElInput
|
||||
v-model="admin.scheduleSqlEditForm.dify_system_prompt"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
class="font-mono text-sm"
|
||||
:placeholder="t('admin.schedule.form.difySystemPromptPlaceholder')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</template>
|
||||
|
||||
<ElDivider content-position="left">{{ t('admin.schedule.form.cronTitle') }}</ElDivider>
|
||||
<p class="mb-3 text-xs text-muted">{{ t('admin.schedule.form.cronHint') }}</p>
|
||||
<ScheduleCronDesigner
|
||||
:designer="admin.cronDesigner"
|
||||
:format-date-time="admin.formatDateTime"
|
||||
/>
|
||||
|
||||
<ElFormItem class="mt-4">
|
||||
<ElCheckbox v-model="admin.scheduleCreateForm.notify_enabled">
|
||||
{{ t('admin.schedule.form.notifyEnabled') }}
|
||||
</ElCheckbox>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="admin.scheduleCreateForm.notify_enabled" :label="t('admin.schedule.form.selectNotifyUsers')">
|
||||
<ElSelect
|
||||
v-model="admin.scheduleCreateForm.notify_user_ids_json"
|
||||
multiple
|
||||
filterable
|
||||
class="w-full"
|
||||
:placeholder="t('admin.schedule.form.selectNotifyUsers')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="u in admin.users"
|
||||
:key="u.id"
|
||||
:label="userLabel(u)"
|
||||
:value="u.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem>
|
||||
<ElCheckbox v-model="admin.scheduleCreateForm.enabled">
|
||||
{{ t('admin.schedule.form.enableOnCreate') }}
|
||||
</ElCheckbox>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
|
||||
<template #footer>
|
||||
<div class="flex justify-end gap-3">
|
||||
<ElButton :disabled="admin.scheduleCreateSaving" @click="admin.closeScheduleCreateModal">
|
||||
{{ t('admin.schedule.form.cancel') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:icon="Plus"
|
||||
:loading="admin.scheduleCreateSaving"
|
||||
:disabled="submitDisabled"
|
||||
@click="admin.createSchedule"
|
||||
>
|
||||
{{ admin.scheduleCreateSaving
|
||||
? t('admin.schedule.form.saving')
|
||||
: (admin.scheduleEditingId
|
||||
? t('admin.schedule.form.saveChanges')
|
||||
: t('admin.schedule.form.createSchedule')) }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-create-form :deep(.el-form-item) {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.schedule-create-form :deep(.el-divider) {
|
||||
margin: 12px 0 16px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,500 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleCreateEditModal.vue
|
||||
* 用途:定时任务创建/编辑弹窗。
|
||||
* 依赖:schedules.context、ScheduleCronDesigner、DynamicTaskParamsForm。
|
||||
* 逻辑:平台 Job 下拉展示由 registry 返回的 label_key 经 $t() 渲染;平台任务参数区由
|
||||
* DynamicTaskParamsForm 按 params_schema 通用渲染,本组件不再按任务硬编码 v-if。
|
||||
*/
|
||||
import { ChevronDown, ChevronUp, Plus } from 'lucide-vue-next';
|
||||
import { useScheduleCreateModalOpen, useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
import DynamicTaskParamsForm from './DynamicTaskParamsForm.vue';
|
||||
import ScheduleCronDesigner from './ScheduleCronDesigner.vue';
|
||||
|
||||
const admin = useSchedulesAdminContext();
|
||||
const showCreateModal = useScheduleCreateModalOpen();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="showCreateModal" class="admin-modal-overlay items-center">
|
||||
<div class="admin-modal-panel max-h-[92vh] max-w-3xl min-h-0">
|
||||
<div class="flex shrink-0 items-center justify-between border-b border-subtle px-8 py-6">
|
||||
<h3 class="text-2xl font-bold tracking-tight text-primary">{{ admin.scheduleEditingId ? $t('admin.schedule.form.editTitle') : $t('admin.schedule.form.createTitle') }}</h3>
|
||||
<button
|
||||
class="rounded-full p-2 text-muted transition hover-surface-soft hover:text-secondary"
|
||||
@click="admin.closeScheduleCreateModal"
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 space-y-5 overflow-y-auto px-8 py-6">
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.name') }}</label>
|
||||
<input v-model="admin.scheduleCreateForm.name" class="input-field !text-sm !leading-5" :placeholder="$t('admin.schedule.form.namePlaceholder')" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.owner') }}</label>
|
||||
<div class="relative">
|
||||
<input
|
||||
v-model="admin.scheduleOwnerQuery"
|
||||
type="text"
|
||||
class="input-field !text-sm !leading-5"
|
||||
:placeholder="admin.users.length === 0 ? $t('admin.schedule.form.noUsers') : $t('admin.schedule.form.selectOwner')"
|
||||
:disabled="admin.users.length === 0"
|
||||
@focus="admin.scheduleOwnerDropdownOpen = true"
|
||||
@input="admin.handleScheduleOwnerInput"
|
||||
@blur="admin.scheduleCloseOwnerDropdown"
|
||||
/>
|
||||
<div
|
||||
v-if="admin.scheduleOwnerDropdownOpen && admin.users.length > 0"
|
||||
class="admin-dropdown max-h-60 w-full overflow-y-auto"
|
||||
>
|
||||
<button
|
||||
v-for="u in admin.filteredOwnerUsers"
|
||||
:key="u.id"
|
||||
type="button"
|
||||
class="flex w-full items-center gap-3 px-3 py-2 text-left text-sm transition hover:bg-surface-soft"
|
||||
:class="admin.scheduleCreateForm.owner_user_id === u.id ? 'bg-blue-50/50' : ''"
|
||||
@mousedown.prevent="admin.selectScheduleOwner(u.id)"
|
||||
>
|
||||
<span class="text-secondary">{{ u.real_name || u.username }}{{ u.employee_id ? '(' + u.employee_id + ')' : '' }}</span>
|
||||
</button>
|
||||
<div v-if="admin.filteredOwnerUsers.length === 0" class="px-3 py-2 text-sm text-muted">
|
||||
{{ $t('admin.wecom.noData') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- SQL Config Panel -->
|
||||
<div class="rounded-2xl border border-default bg-surface-soft/40 p-4">
|
||||
<div class="mb-3 space-y-3">
|
||||
<h4 class="text-base font-bold text-primary">{{ $t('admin.schedule.form.dataSourceConfig') }}</h4>
|
||||
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-1.5 block text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('admin.schedule.form.scheduleType') }}
|
||||
</label>
|
||||
<select
|
||||
v-model="admin.scheduleCreateForm.schedule_type"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
>
|
||||
<option value="data_pipeline">{{ $t('admin.schedule.form.scheduleTypeDataPipeline') }}</option>
|
||||
<option value="platform_job">{{ $t('admin.schedule.form.scheduleTypePlatformJob') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'">
|
||||
<label class="mb-1.5 block text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('admin.schedule.form.dataSourceType') }}
|
||||
</label>
|
||||
<select
|
||||
v-model="admin.scheduleCreateForm.data_source_type"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
>
|
||||
<option value="database">{{ $t('admin.schedule.form.databaseDirect') }}</option>
|
||||
<option value="external_api">{{ $t('admin.schedule.form.externalApi') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-else>
|
||||
<label class="mb-1.5 block text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('admin.schedule.form.platformJob') }}
|
||||
</label>
|
||||
<select
|
||||
v-model="admin.scheduleCreateForm.platform_api_path"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
@change="admin.handlePlatformJobChange"
|
||||
>
|
||||
<option :value="null">{{ $t('admin.schedule.form.selectPlatformJob') }}</option>
|
||||
<option v-for="job in admin.platformJobs" :key="job.key" :value="job.key">
|
||||
{{ job.label_key ? $t(job.label_key) : job.label || job.key }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'"
|
||||
class="flex flex-wrap items-center gap-2 sm:shrink-0"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary btn-sm inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="admin.scheduleTestLoading || !admin.scheduleEditingId"
|
||||
@click="admin.handleTestScheduleSql"
|
||||
>
|
||||
{{ admin.scheduleTestLoading ? $t('admin.schedule.form.querying') : $t('admin.schedule.form.testQuery') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary btn-sm inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap"
|
||||
@click="admin.scheduleConfigCollapsed = !admin.scheduleConfigCollapsed"
|
||||
>
|
||||
<ChevronDown v-if="admin.scheduleConfigCollapsed" class="h-3.5 w-3.5 shrink-0" />
|
||||
<ChevronUp v-else class="h-3.5 w-3.5 shrink-0" />
|
||||
{{ admin.scheduleConfigCollapsed ? $t('admin.schedule.form.expandConfig') : $t('admin.schedule.form.collapseConfig') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-show="admin.scheduleCreateForm.schedule_type === 'data_pipeline' && !admin.scheduleConfigCollapsed"
|
||||
class="space-y-3"
|
||||
>
|
||||
<template v-if="admin.scheduleCreateForm.data_source_type === 'database'">
|
||||
<!-- 数据源配置 -->
|
||||
<details class="rounded-xl border border-default bg-surface" open>
|
||||
<summary class="cursor-pointer px-4 py-2.5 text-sm font-semibold text-secondary hover:bg-surface-soft rounded-xl">{{ $t('admin.schedule.form.dataSourceSection') }}</summary>
|
||||
<div class="space-y-3 px-4 pb-4 pt-2">
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsDbType') }}</label>
|
||||
<select v-model="admin.scheduleSqlEditForm.ds_db_type" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200">
|
||||
<option value="sqlserver">SQL Server</option>
|
||||
<option value="postgresql">PostgreSQL</option>
|
||||
<option value="mysql">MySQL</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsHost') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_host" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" :placeholder="$t('admin.schedule.form.dsHostPlaceholder')" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-4 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsPort') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_port" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" placeholder="1433" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsDatabase') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_database" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" :placeholder="$t('admin.schedule.form.dsDatabasePlaceholder')" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsUsername') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_username" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" placeholder="sa" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsPassword') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_password" type="password" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" :placeholder="$t('admin.schedule.form.dsPasswordPlaceholder')" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="admin.scheduleSqlEditForm.ds_db_type === 'sqlserver'" class="grid grid-cols-3 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsDriver') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.ds_driver" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" placeholder="SQL Server" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsEncrypt') }}</label>
|
||||
<select v-model="admin.scheduleSqlEditForm.ds_encrypt" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200">
|
||||
<option value="">{{ $t('admin.schedule.form.defaultNo') }}</option>
|
||||
<option value="yes">yes</option>
|
||||
<option value="no">no</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.dsTrustCert') }}</label>
|
||||
<select v-model="admin.scheduleSqlEditForm.ds_trust_cert" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200">
|
||||
<option value="">{{ $t('admin.schedule.form.defaultYes') }}</option>
|
||||
<option value="yes">yes</option>
|
||||
<option value="no">no</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-xs text-muted">{{ $t('admin.schedule.form.envVarHint', { token: $t('admin.schedule.form.envVarToken') }) }}</p>
|
||||
</div>
|
||||
</details>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.baseFetchSql') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.base_fetch_sql"
|
||||
class="w-full min-h-[160px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.fetchWhereConditions') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.fetch_where_conditions"
|
||||
class="w-full min-h-[80px] rounded-xl border border-amber-200 bg-amber-50/30 p-3 text-xs leading-relaxed text-secondary font-mono focus:border-amber-300 focus:outline-none focus:ring-1 focus:ring-amber-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.fetchOrderBy') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.fetch_order_by" class="w-full input-field px-3 py-2 text-xs font-mono text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.detailSql') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.detail_sql"
|
||||
class="w-full min-h-[120px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.writebackSql') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.writeback_sql"
|
||||
class="w-full min-h-[48px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.rowIdKey') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.row_id_key" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.logPrefix') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.log_prefix" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="hidden">
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.aliasOrder') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.alias_order_str" class="w-full input-field px-3 py-2 text-xs font-mono text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.detailAliasOrder') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.detail_alias_order_str" class="w-full input-field px-3 py-2 text-xs font-mono text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.headerLabels') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.header_labels_str"
|
||||
class="w-full min-h-[100px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 外部API模式 -->
|
||||
<template v-if="admin.scheduleCreateForm.data_source_type === 'external_api'">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiUrl') }}</label>
|
||||
<input v-model="admin.scheduleSqlEditForm.api_url" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" placeholder="https://api.example.com/endpoint" />
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiMethod') }}</label>
|
||||
<select v-model="admin.scheduleSqlEditForm.api_method" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200">
|
||||
<option value="POST">POST</option>
|
||||
<option value="GET">GET</option>
|
||||
<option value="PUT">PUT</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiTimeoutSeconds') }}</label>
|
||||
<input type="number" :value="120" class="w-full input-field px-3 py-2 text-sm text-secondary focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200" disabled />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiHeaders') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.api_headers_str"
|
||||
class="w-full min-h-[60px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.apiBodyTemplate') }}</label>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.api_body_template"
|
||||
class="w-full min-h-[80px] input-field p-3 text-xs leading-relaxed text-secondary font-mono focus:border-blue-300 focus:outline-none focus:ring-1 focus:ring-blue-200 resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 平台任务参数区:完全由注册表 params_schema 决定,无任务级 v-if。
|
||||
外层仅按 schedule_type 判定(同步、必然为真),不依赖异步 definitions;
|
||||
定义解析完成前显示加载提示,完成后立即渲染 DynamicTaskParamsForm(含库存源)。 -->
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'platform_job'" class="mt-3">
|
||||
<DynamicTaskParamsForm
|
||||
v-if="admin.selectedPlatformTaskDefinition"
|
||||
:definition="admin.selectedPlatformTaskDefinition"
|
||||
:model-value="admin.scheduleCreateForm.job_params"
|
||||
:valid="admin.platformJobParamsValid"
|
||||
@update:model-value="admin.scheduleCreateForm.job_params = $event"
|
||||
@update:valid="admin.platformJobParamsValid = $event"
|
||||
/>
|
||||
<div v-else-if="admin.platformTaskDefinitionsLoading || admin.platformTaskDefinitionsError" class="space-y-2 rounded-xl border border-blue-200 bg-blue-50/40 px-4 py-3 text-sm text-muted">
|
||||
<p>{{ admin.platformTaskDefinitionsLoading
|
||||
? $t('admin.schedule.form.dynamicParamsLoading')
|
||||
: $t('admin.schedule.form.dynamicParamsLoadFailed') }}</p>
|
||||
<button
|
||||
v-if="admin.platformTaskDefinitionsError && !admin.platformTaskDefinitionsLoading"
|
||||
type="button"
|
||||
class="btn-secondary btn-sm"
|
||||
@click="admin.loadPlatformTaskDefinitions"
|
||||
>
|
||||
{{ $t('admin.schedule.form.dynamicParamsRetry') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleTestResult" class="mt-4 rounded-2xl border border-emerald-200 bg-emerald-50/40 p-4">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h4 class="text-sm font-bold text-emerald-900">{{ $t('admin.schedule.testRun.queryResult') }}</h4>
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-xs text-emerald-600">{{ $t('admin.schedule.testRun.resultSummary', { total: admin.scheduleTestResult.total, showing: admin.scheduleTestResult.showing }) }}</span>
|
||||
<button class="rounded-full p-1 text-emerald-400 transition hover:bg-emerald-100 hover:text-emerald-600" @click="admin.scheduleTestResult = null">✕</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-2 overflow-x-auto rounded-xl border border-emerald-200 bg-surface">
|
||||
<table class="w-full text-xs">
|
||||
<thead class="bg-emerald-50">
|
||||
<tr>
|
||||
<th v-for="col in admin.scheduleTestResult.columns" :key="col" class="whitespace-nowrap px-3 py-2 text-left font-semibold text-emerald-800">{{ col }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(row, ri) in admin.scheduleTestResult.rows" :key="ri" class="border-t border-emerald-100">
|
||||
<td v-for="col in admin.scheduleTestResult.columns" :key="col" class="whitespace-nowrap px-3 py-1.5 text-secondary">{{ row[col] }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<details class="mt-2">
|
||||
<summary class="cursor-pointer text-xs font-semibold text-emerald-700 hover:text-emerald-900">{{ $t('admin.schedule.testRun.viewGeneratedSql') }}</summary>
|
||||
<pre class="admin-pre-block admin-pre-block--sql">{{ admin.scheduleTestResult.sql }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'" class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.agentLabel') }}</label>
|
||||
<div class="relative">
|
||||
<select v-model="admin.scheduleCreateForm.dify_agent_id" class="input-field appearance-none pr-10 !text-sm !leading-5" :disabled="admin.agents.length === 0">
|
||||
<option :value="null">{{ admin.agents.length === 0 ? $t('admin.schedule.form.noAgents') : $t('admin.schedule.form.agentDisabled') }}</option>
|
||||
<option v-for="a in admin.agents" :key="a.id" :value="a.id">{{ a.name }}{{ $t('admin.schedule.form.agentOptionId', { id: a.dify_app_id?.slice(0, 8) || a.id }) }}</option>
|
||||
</select>
|
||||
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
|
||||
<svg class="h-4 w-4 text-muted" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z" clip-rule="evenodd"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.waitSeconds') }}</label>
|
||||
<input v-model.number="admin.scheduleCreateForm.wait_seconds" type="number" min="0" class="input-field !text-sm !leading-5" placeholder="300" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleCreateForm.schedule_type === 'data_pipeline'" class="rounded-2xl border border-emerald-200 bg-emerald-50/40 p-4">
|
||||
<label class="flex items-center gap-2 text-sm font-semibold text-secondary">
|
||||
<input v-model="admin.scheduleCreateForm.kb_sync_enabled" type="checkbox" class="h-4 w-4 rounded border-default text-emerald-600 focus:ring-emerald-300" />
|
||||
{{ $t('admin.schedule.form.kbSyncEnabled') }}
|
||||
</label>
|
||||
<p class="mt-1 text-xs text-muted">{{ $t('admin.schedule.form.kbSyncHint') }}</p>
|
||||
<div v-if="admin.scheduleCreateForm.kb_sync_enabled" class="mt-3">
|
||||
<label class="mb-2 block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.kbGroup') }}</label>
|
||||
<select v-model="admin.scheduleCreateForm.kb_group_id" class="input-field !text-sm !leading-5" :disabled="admin.kbGroups.length === 0">
|
||||
<option :value="null">{{ admin.kbGroups.length === 0 ? $t('admin.schedule.form.noKbGroups') : $t('admin.schedule.form.selectKbGroup') }}</option>
|
||||
<option v-for="group in admin.kbGroups" :key="group.id" :value="group.id">{{ group.name }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.scheduleCreateForm.dify_agent_id" class="rounded-2xl border border-indigo-200 bg-indigo-50/40 p-4">
|
||||
<div class="mb-2">
|
||||
<label class="block text-sm font-medium text-secondary">{{ $t('admin.schedule.form.difySystemPrompt') }}</label>
|
||||
<p class="mt-1 text-xs text-muted">{{ $t('admin.schedule.form.difySystemPromptHint') }}</p>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="admin.scheduleSqlEditForm.dify_system_prompt"
|
||||
class="input-field min-h-[140px] p-3 text-sm font-mono resize-y border-indigo-200"
|
||||
:placeholder="$t('admin.schedule.form.difySystemPromptPlaceholder')"
|
||||
></textarea>
|
||||
</div>
|
||||
|
||||
<ScheduleCronDesigner
|
||||
:designer="admin.cronDesigner"
|
||||
:format-date-time="admin.formatDateTime"
|
||||
/>
|
||||
|
||||
<div class="input-field px-3 py-2.5">
|
||||
<div class="flex flex-col gap-2 md:flex-row md:items-center">
|
||||
<label class="inline-flex shrink-0 items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="admin.scheduleCreateForm.notify_enabled" type="checkbox" class="h-4 w-4 rounded text-blue-600" />
|
||||
{{ $t('admin.schedule.form.notifyEnabled') }}
|
||||
</label>
|
||||
<div v-if="admin.scheduleCreateForm.notify_enabled" class="relative flex-1">
|
||||
<div
|
||||
class="min-h-[38px] input-field px-3 py-2 text-sm flex flex-wrap gap-1.5 items-center focus-within:border-blue-300 focus-within:ring-1 focus-within:ring-blue-200"
|
||||
>
|
||||
<span
|
||||
v-for="uid in admin.scheduleCreateForm.notify_user_ids_json"
|
||||
:key="uid"
|
||||
class="inline-flex items-center gap-1 rounded-lg bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-700"
|
||||
>
|
||||
{{ admin.getUserName(uid) }}
|
||||
<button
|
||||
type="button"
|
||||
class="ml-0.5 text-blue-400 hover:text-blue-600"
|
||||
@click.stop="admin.removeNotifyUser(uid)"
|
||||
>✕</button>
|
||||
</span>
|
||||
<input
|
||||
v-model="admin.scheduleNotifyUserQuery"
|
||||
type="text"
|
||||
class="min-w-[120px] flex-1 border-0 bg-transparent p-0 text-sm text-secondary outline-none focus:ring-0"
|
||||
:placeholder="$t('admin.schedule.form.selectNotifyUsers')"
|
||||
@focus="admin.scheduleNotifyDropdownOpen = true"
|
||||
@input="admin.scheduleNotifyDropdownOpen = true"
|
||||
@blur="admin.scheduleCloseNotifyDropdown"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.scheduleNotifyDropdownOpen"
|
||||
class="admin-dropdown max-h-60 w-full overflow-y-auto"
|
||||
>
|
||||
<button
|
||||
v-for="u in admin.filteredNotifyUsers"
|
||||
:key="u.id"
|
||||
type="button"
|
||||
class="flex w-full cursor-pointer items-center gap-2 px-3 py-2 text-left text-sm transition hover:bg-surface-soft"
|
||||
:class="admin.scheduleCreateForm.notify_user_ids_json.includes(u.id) ? 'bg-blue-50/50' : ''"
|
||||
@mousedown.prevent="admin.toggleNotifyUser(u.id)"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="pointer-events-none h-3.5 w-3.5 rounded text-blue-600"
|
||||
:checked="admin.scheduleCreateForm.notify_user_ids_json.includes(u.id)"
|
||||
tabindex="-1"
|
||||
readonly
|
||||
/>
|
||||
<span class="text-secondary">{{ u.real_name || u.username }}{{ u.employee_id ? '(' + u.employee_id + ')' : '' }}</span>
|
||||
</button>
|
||||
<div v-if="admin.filteredNotifyUsers.length === 0" class="px-3 py-2 text-sm text-muted">
|
||||
{{ $t('admin.wecom.noData') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-default bg-surface-soft/40 px-4 py-3">
|
||||
<label class="inline-flex cursor-pointer items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="admin.scheduleCreateForm.enabled" type="checkbox" class="admin-checkbox" />
|
||||
{{ $t('admin.schedule.form.enableOnCreate') }}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-modal-footer admin-modal-footer--muted relative z-10 pointer-events-auto justify-end gap-3 px-8 py-5">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
@click="admin.closeScheduleCreateModal"
|
||||
>
|
||||
{{ $t('admin.schedule.form.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary inline-flex items-center gap-2 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="admin.scheduleCreateSaving || !admin.scheduleCreateForm.name || !admin.scheduleCreateForm.owner_user_id || !admin.cronDesigner.isValid"
|
||||
@click="admin.createSchedule"
|
||||
>
|
||||
<Plus class="h-4 w-4 shrink-0" />
|
||||
{{ admin.scheduleCreateSaving ? $t('admin.schedule.form.saving') : (admin.scheduleEditingId ? $t('admin.schedule.form.saveChanges') : $t('admin.schedule.form.createSchedule')) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
+329
-132
@@ -1,153 +1,350 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleOverviewPanel.vue
|
||||
* 定时任务概览模式:统计卡片与任务卡片网格。
|
||||
* 依赖:schedules.context、lucide-vue-next。
|
||||
* 逻辑:inject admin;展示 schedules 列表与快捷操作。
|
||||
* 用途:排程管理概览——紧凑统计条 + 筛选 + ElTable + 前端分页 + 批量启停。
|
||||
* 依赖:schedules.context、Element Plus、ScheduleTask。
|
||||
* 逻辑:全量 schedules 前端过滤/排序/分页;行点击进工作台;操作列 stop 冒泡。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { Edit3, FlaskConical, Plus, Power, PowerOff, Rocket, Settings2, Trash2 } from 'lucide-vue-next';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Search } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import type { ScheduleTask } from '@/shared/types/schedule.types';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
|
||||
type StatusFilter = 'all' | 'enabled' | 'disabled';
|
||||
type TypeFilter = 'all' | 'data_pipeline' | 'platform_job';
|
||||
type SortKey = 'name' | 'last_run_at' | 'next_run_at' | '';
|
||||
|
||||
const searchKeyword = ref('');
|
||||
const statusFilter = ref<StatusFilter>('all');
|
||||
const typeFilter = ref<TypeFilter>('all');
|
||||
const sortKey = ref<SortKey>('name');
|
||||
const sortDir = ref<'asc' | 'desc'>('asc');
|
||||
const currentPage = ref(1);
|
||||
const pageSize = ref(20);
|
||||
const pageSizeOptions = [10, 20, 50, 100];
|
||||
const selectedRows = ref<ScheduleTask[]>([]);
|
||||
const bulkBusy = ref(false);
|
||||
|
||||
/**
|
||||
* 按关键词/状态/类型过滤后的排程列表,再按当前排序键排序。
|
||||
*/
|
||||
const filteredSchedules = computed(() => {
|
||||
const keyword = searchKeyword.value.trim().toLowerCase();
|
||||
const matched = admin.schedules.filter((item) => {
|
||||
const haystack = `${item.name} ${item.schedule_no} ${item.cron_expr} ${item.owner_username || ''}`.toLowerCase();
|
||||
const matchesKeyword = !keyword || haystack.includes(keyword);
|
||||
const matchesStatus = statusFilter.value === 'all'
|
||||
|| (statusFilter.value === 'enabled' && item.enabled)
|
||||
|| (statusFilter.value === 'disabled' && !item.enabled);
|
||||
const matchesType = typeFilter.value === 'all' || item.schedule_type === typeFilter.value;
|
||||
return matchesKeyword && matchesStatus && matchesType;
|
||||
});
|
||||
|
||||
if (!sortKey.value) return matched;
|
||||
return [...matched].sort((a, b) => {
|
||||
let result = 0;
|
||||
if (sortKey.value === 'name') {
|
||||
result = a.name.localeCompare(b.name, undefined, { numeric: true });
|
||||
} else if (sortKey.value === 'last_run_at') {
|
||||
result = (Date.parse(a.last_run_at || '') || 0) - (Date.parse(b.last_run_at || '') || 0);
|
||||
} else {
|
||||
result = (Date.parse(a.next_run_at || '') || 0) - (Date.parse(b.next_run_at || '') || 0);
|
||||
}
|
||||
return sortDir.value === 'asc' ? result : -result;
|
||||
});
|
||||
});
|
||||
|
||||
const pagedSchedules = computed(() => {
|
||||
const start = (currentPage.value - 1) * pageSize.value;
|
||||
return filteredSchedules.value.slice(start, start + pageSize.value);
|
||||
});
|
||||
|
||||
const tableEmptyText = computed(() => (
|
||||
admin.schedules.length === 0 ? t('admin.schedule.emptyList') : t('admin.schedule.filters.emptyResult')
|
||||
));
|
||||
|
||||
watch([searchKeyword, statusFilter, typeFilter], () => {
|
||||
currentPage.value = 1;
|
||||
});
|
||||
|
||||
/**
|
||||
* 同步表格勾选行,供批量启停使用。
|
||||
* @param rows - 当前选中的排程行
|
||||
*/
|
||||
function onSelectionChange(rows: ScheduleTask[]): void {
|
||||
selectedRows.value = rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 表头自定义排序写回本地 sortKey/sortDir。
|
||||
* @param payload - Element sort-change 载荷
|
||||
*/
|
||||
function onSortChange(payload: { prop: string | null; order: string | null }): void {
|
||||
const prop = payload.prop;
|
||||
if (prop === 'name' || prop === 'last_run_at' || prop === 'next_run_at') {
|
||||
sortKey.value = payload.order ? prop : '';
|
||||
sortDir.value = payload.order === 'ascending' ? 'asc' : 'desc';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 行点击进入工作台(操作列需 stop 冒泡)。
|
||||
* @param row - 被点击的排程
|
||||
*/
|
||||
function onRowClick(row: ScheduleTask): void {
|
||||
void admin.openScheduleRunSubmenu(row.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量将选中排程设为启用或停用。
|
||||
* @param enabled - true 启用,false 停用
|
||||
*/
|
||||
async function bulkSetEnabled(enabled: boolean): Promise<void> {
|
||||
if (selectedRows.value.length === 0 || bulkBusy.value) return;
|
||||
bulkBusy.value = true;
|
||||
try {
|
||||
for (const row of selectedRows.value) {
|
||||
if (row.enabled !== enabled) {
|
||||
await admin.setScheduleEnabled(row.id, enabled);
|
||||
}
|
||||
}
|
||||
selectedRows.value = [];
|
||||
} finally {
|
||||
bulkBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="admin-panel-lg p-6 shadow-sm">
|
||||
<div class="mb-5 grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4">
|
||||
<div class="admin-stat-tile px-4 py-3">
|
||||
<div class="text-xl font-bold text-primary">{{ admin.schedules.length }}</div>
|
||||
<div class="text-sm text-muted">{{ $t('admin.schedule.stats.total') }}</div>
|
||||
<div>
|
||||
<div class="schedule-stats-bar">
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.schedules.length }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.stats.total') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3">
|
||||
<div class="text-xl font-bold text-primary">{{ admin.scheduleEnabledCount }}</div>
|
||||
<div class="text-sm text-muted">{{ $t('admin.schedule.stats.enabled') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.scheduleEnabledCount }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.stats.enabled') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3">
|
||||
<div class="text-xl font-bold text-primary">{{ admin.scheduleDisabledCount }}</div>
|
||||
<div class="text-sm text-muted">{{ $t('admin.schedule.stats.disabled') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.scheduleDisabledCount }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.stats.disabled') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3">
|
||||
<div class="text-xl font-bold text-primary">{{ admin.scheduleRunningCount }}</div>
|
||||
<div class="text-sm text-muted">{{ $t('admin.schedule.stats.running') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.scheduleRunningCount }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.stats.running') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-panel p-4">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h4 class="text-lg font-bold text-primary">{{ $t('admin.schedule.sectionOverview') }}</h4>
|
||||
<span class="text-xs text-muted">{{ $t('admin.schedule.switchByCard') }}</span>
|
||||
</div>
|
||||
<div v-if="admin.scheduleLoading" class="py-8 text-center text-sm text-muted">{{ $t('admin.schedule.loading') }}</div>
|
||||
<div v-else class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3 auto-rows-fr">
|
||||
<div class="admin-panel p-4 transition-colors hover:border-brand-300 h-full min-h-[260px] flex flex-col">
|
||||
<div class="mb-3 flex items-center gap-2">
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-xl bg-brand-50 text-brand-600">
|
||||
<Settings2 class="h-4 w-4" />
|
||||
</div>
|
||||
<div class="font-semibold text-primary">{{ $t('admin.schedule.addTitle') }}</div>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{{ $t('admin.schedule.addHint') }}
|
||||
</div>
|
||||
<div class="mt-auto pt-3">
|
||||
<button
|
||||
@click="admin.openScheduleCreateModal"
|
||||
class="inline-flex w-full items-center justify-center gap-2 rounded-xl bg-brand-600 px-3 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
>
|
||||
<Plus class="h-4 w-4" />
|
||||
{{ $t('admin.schedule.addButton') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="s in admin.schedules"
|
||||
:key="s.id"
|
||||
class="flex h-full min-h-[260px] flex-col admin-panel p-4 transition hover:border-blue-200 hover:bg-surface-soft"
|
||||
>
|
||||
<div
|
||||
class="w-full shrink-0 cursor-pointer rounded-lg text-left outline-none focus-visible:ring-2 focus-visible:ring-brand-400"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="admin.openScheduleRunSubmenu(s.id)"
|
||||
@keydown.enter.prevent="admin.openScheduleRunSubmenu(s.id)"
|
||||
@keydown.space.prevent="admin.openScheduleRunSubmenu(s.id)"
|
||||
>
|
||||
<div class="min-h-[96px]">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-base font-semibold text-primary">{{ s.name }}</div>
|
||||
<div class="mt-0.5 truncate text-xs text-muted" :title="s.schedule_no">{{ s.schedule_no }}</div>
|
||||
</div>
|
||||
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="s.enabled ? 'bg-emerald-100 text-emerald-700' : 'bg-surface-strong text-secondary'">
|
||||
{{ s.enabled ? $t('admin.schedule.enabled') : $t('admin.schedule.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 text-sm text-muted">Cron:{{ s.cron_expr }}</div>
|
||||
<div class="mt-1 text-sm text-muted">{{ $t('admin.schedule.owner') }}:{{ s.owner_username || s.owner_user_id }}</div>
|
||||
</div>
|
||||
<div class="schedule-filters">
|
||||
<ElInput
|
||||
v-model="searchKeyword"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
class="schedule-filter-search"
|
||||
:placeholder="t('admin.schedule.filters.searchPlaceholder')"
|
||||
/>
|
||||
<ElSelect v-model="statusFilter" class="schedule-filter-select" :placeholder="t('admin.schedule.filters.statusAll')">
|
||||
<ElOption :label="t('admin.schedule.filters.statusAll')" value="all" />
|
||||
<ElOption :label="t('admin.schedule.enabled')" value="enabled" />
|
||||
<ElOption :label="t('admin.schedule.disabled')" value="disabled" />
|
||||
</ElSelect>
|
||||
<ElSelect v-model="typeFilter" class="schedule-filter-select" :placeholder="t('admin.schedule.filters.typeAll')">
|
||||
<ElOption :label="t('admin.schedule.filters.typeAll')" value="all" />
|
||||
<ElOption :label="t('admin.schedule.form.scheduleTypeDataPipeline')" value="data_pipeline" />
|
||||
<ElOption :label="t('admin.schedule.form.scheduleTypePlatformJob')" value="platform_job" />
|
||||
</ElSelect>
|
||||
<ElSpace v-if="selectedRows.length > 0" wrap>
|
||||
<ElButton :loading="bulkBusy" @click="() => void bulkSetEnabled(true)">
|
||||
{{ t('admin.schedule.bulk.enable') }} ({{ selectedRows.length }})
|
||||
</ElButton>
|
||||
<ElButton :loading="bulkBusy" @click="() => void bulkSetEnabled(false)">
|
||||
{{ t('admin.schedule.bulk.disable') }} ({{ selectedRows.length }})
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</div>
|
||||
|
||||
<ElTable
|
||||
v-loading="admin.scheduleLoading"
|
||||
class="hx-admin-table"
|
||||
:data="pagedSchedules"
|
||||
row-key="id"
|
||||
:default-sort="{ prop: 'name', order: 'ascending' }"
|
||||
:empty-text="tableEmptyText"
|
||||
highlight-current-row
|
||||
@selection-change="onSelectionChange"
|
||||
@sort-change="onSortChange"
|
||||
@row-click="onRowClick"
|
||||
>
|
||||
<ElTableColumn type="selection" width="48" reserve-selection />
|
||||
<ElTableColumn prop="name" :label="t('admin.schedule.table.name')" min-width="160" sortable="custom">
|
||||
<template #default="{ row }">
|
||||
<div class="truncate font-medium text-primary" :title="(row as ScheduleTask).name">
|
||||
{{ (row as ScheduleTask).name }}
|
||||
</div>
|
||||
<div class="relative z-10 mt-auto shrink-0 pt-3" @click.stop>
|
||||
<div class="mb-1 text-sm text-muted">
|
||||
{{ $t('admin.schedule.lastRun') }}:{{ admin.formatDateTime(s.last_run_at) }}
|
||||
</div>
|
||||
<div class="mb-3 text-sm text-muted">
|
||||
{{ $t('admin.schedule.nextRun') }}:{{ admin.formatDateTime(s.next_run_at) }}
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-2 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
@click="admin.openScheduleEditModal(s)"
|
||||
>
|
||||
<Edit3 class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.edit') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!s.enabled"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-emerald-200 px-3 py-2 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50"
|
||||
@click.stop="admin.setScheduleEnabled(s.id, true)"
|
||||
>
|
||||
<Power class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.start') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-amber-200 px-3 py-2 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-50"
|
||||
@click.stop="admin.setScheduleEnabled(s.id, false)"
|
||||
>
|
||||
<PowerOff class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.pause') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-blue-200 px-3 py-2 text-xs font-medium text-blue-700 transition-colors hover:bg-blue-50"
|
||||
@click.stop="admin.runScheduleNow(s.id)"
|
||||
>
|
||||
<Rocket class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.run') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="s.schedule_type === 'data_pipeline' && s.data_source_type === 'database'"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-violet-200 px-3 py-2 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
|
||||
@click.stop="admin.openTestRunDialog(s)"
|
||||
>
|
||||
<FlaskConical class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.test') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-rose-200 px-3 py-2 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50"
|
||||
@click.stop="admin.deleteSchedule(s)"
|
||||
>
|
||||
<Trash2 class="h-3.5 w-3.5" />
|
||||
{{ $t('admin.schedule.actions.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="schedule_no" :label="t('admin.schedule.scheduleNo')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<span class="truncate text-muted" :title="(row as ScheduleTask).schedule_no">
|
||||
{{ (row as ScheduleTask).schedule_no }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.schedule.table.status')" width="100">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="(row as ScheduleTask).enabled ? 'success' : 'info'" effect="light" size="small">
|
||||
{{ (row as ScheduleTask).enabled ? t('admin.schedule.enabled') : t('admin.schedule.disabled') }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="cron_expr" :label="t('admin.schedule.table.cron')" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<code class="schedule-cron">{{ (row as ScheduleTask).cron_expr }}</code>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.schedule.owner')" min-width="100">
|
||||
<template #default="{ row }">
|
||||
{{ (row as ScheduleTask).owner_username || (row as ScheduleTask).owner_user_id }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="last_run_at" :label="t('admin.schedule.lastRun')" min-width="160" sortable="custom">
|
||||
<template #default="{ row }">{{ admin.formatDateTime((row as ScheduleTask).last_run_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="next_run_at" :label="t('admin.schedule.nextRun')" min-width="160" sortable="custom">
|
||||
<template #default="{ row }">{{ admin.formatDateTime((row as ScheduleTask).next_run_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.schedule.table.actions')" width="280" align="right" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<div class="schedule-row-actions" @click.stop>
|
||||
<ElButton link type="primary" @click="admin.openScheduleEditModal(row as ScheduleTask)">
|
||||
{{ t('admin.schedule.actions.edit') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!(row as ScheduleTask).enabled"
|
||||
link
|
||||
type="success"
|
||||
@click="() => void admin.setScheduleEnabled((row as ScheduleTask).id, true)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.start') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-else
|
||||
link
|
||||
type="warning"
|
||||
@click="() => void admin.setScheduleEnabled((row as ScheduleTask).id, false)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.pause') }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="() => void admin.runScheduleNow((row as ScheduleTask).id)">
|
||||
{{ t('admin.schedule.actions.run') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="(row as ScheduleTask).schedule_type === 'data_pipeline' && (row as ScheduleTask).data_source_type === 'database'"
|
||||
link
|
||||
type="primary"
|
||||
@click="admin.openTestRunDialog(row as ScheduleTask)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.test') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="() => void admin.deleteSchedule(row as ScheduleTask)">
|
||||
{{ t('admin.schedule.actions.delete') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="admin.schedules.length === 0" class="rounded-xl border border-dashed border-default px-4 py-6 text-center text-sm text-muted">
|
||||
{{ $t('admin.schedule.emptyList') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div v-if="filteredSchedules.length > 0" class="hx-admin-pager">
|
||||
<ElPagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:total="filteredSchedules.length"
|
||||
:page-sizes="pageSizeOptions"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-stats-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px 32px;
|
||||
padding: 12px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.schedule-stat {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.schedule-stat__value {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.schedule-stat__label {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.schedule-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.schedule-filter-search {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
.schedule-filter-select {
|
||||
width: 10rem;
|
||||
}
|
||||
|
||||
.schedule-cron {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.schedule-row-actions {
|
||||
display: inline-flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.schedule-row-actions :deep(.el-button) {
|
||||
margin-left: 0;
|
||||
padding: 0 6px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,46 +1,57 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/SchedulePageHeader.vue
|
||||
* 定时任务页顶栏:返回、标题、刷新。
|
||||
* 依赖:schedules.context、lucide-vue-next。
|
||||
* 逻辑:inject admin 上下文;概览/工作台模式切换标题与返回按钮。
|
||||
* 用途:排程管理页表头(KB 式 admin-table-header)。
|
||||
* 依赖:schedules.context、Element Plus、@element-plus/icons-vue。
|
||||
* 逻辑:概览显示刷新/新增;工作台显示返回/刷新;由 SchedulesPage 包在 admin-table-section 内。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ArrowLeft, RefreshCw, Settings2 } from 'lucide-vue-next';
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, Plus, Refresh } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElSpace } from 'element-plus';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
|
||||
const isWorkbench = computed(() => admin.scheduleViewMode === 'workbench');
|
||||
const title = computed(() => (
|
||||
isWorkbench.value ? t('admin.schedule.workbenchTitle') : t('admin.schedule.overviewTitle')
|
||||
));
|
||||
const subtitle = computed(() => (
|
||||
isWorkbench.value ? t('admin.schedule.workbenchSubtitle') : t('admin.schedule.overviewSubtitle')
|
||||
));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="admin-panel-lg px-7 py-6 shadow-sm">
|
||||
<div class="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
|
||||
<div class="flex items-start gap-4">
|
||||
<button
|
||||
v-if="admin.scheduleViewMode === 'workbench'"
|
||||
class="inline-flex h-14 w-14 items-center justify-center admin-panel text-muted transition hover:bg-surface-soft hover:text-secondary"
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-start gap-3">
|
||||
<ElButton
|
||||
v-if="isWorkbench"
|
||||
:icon="ArrowLeft"
|
||||
circle
|
||||
:aria-label="t('admin.schedule.backToOverview')"
|
||||
@click="admin.backToScheduleOverview"
|
||||
>
|
||||
<ArrowLeft class="h-7 w-7" />
|
||||
</button>
|
||||
<div class="flex h-14 w-14 items-center justify-center rounded-2xl bg-blue-50 text-blue-600">
|
||||
<Settings2 class="h-7 w-7" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold tracking-tight text-primary">
|
||||
{{ admin.scheduleViewMode === 'overview' ? $t('admin.schedule.overviewTitle') : $t('admin.schedule.workbenchTitle') }}
|
||||
</h2>
|
||||
<p class="mt-1.5 text-sm text-muted">
|
||||
{{ admin.scheduleViewMode === 'overview' ? $t('admin.schedule.overviewSubtitle') : $t('admin.schedule.workbenchSubtitle') }}
|
||||
</p>
|
||||
/>
|
||||
<div class="min-w-0">
|
||||
<h2 class="section-title">{{ title }}</h2>
|
||||
<p class="section-desc mt-1">{{ subtitle }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
class="inline-flex items-center gap-2 admin-panel px-5 py-2.5 text-sm font-semibold text-secondary transition hover:bg-surface-soft"
|
||||
@click="() => void admin.loadSchedules()"
|
||||
>
|
||||
<RefreshCw class="h-5 w-5" />
|
||||
{{ $t('admin.schedule.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
<ElSpace wrap>
|
||||
<ElButton :icon="Refresh" @click="() => void admin.loadSchedules()">
|
||||
{{ t('admin.schedule.refresh') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!isWorkbench"
|
||||
type="primary"
|
||||
:icon="Plus"
|
||||
@click="admin.openScheduleCreateModal"
|
||||
>
|
||||
{{ t('admin.schedule.addButton') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</div>
|
||||
</template>
|
||||
+22
-9
@@ -1,26 +1,39 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleWorkbenchPanel.spec.ts
|
||||
* 用途:断言执行记录页不默认展示原始库存/收料下载;仅企微深链 raw_zip=1 时突出下载入口。
|
||||
* 用途:断言执行记录页不默认展示原始库存/收料下载;仅企微深链 raw_zip=1 时突出下载入口;
|
||||
* 方案 C 无左侧排程列表,使用 ElSelect 切换任务。
|
||||
*/
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('ScheduleWorkbenchPanel run table actions', () => {
|
||||
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
|
||||
const content = readFileSync(panelPath, 'utf8');
|
||||
|
||||
it('does not render raw inventory zip download in the run table column', () => {
|
||||
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
|
||||
const content = readFileSync(panelPath, 'utf8');
|
||||
expect(content).not.toMatch(/downloadScheduleInventoryRawZip\(r\.id\)/);
|
||||
expect(content).not.toMatch(/downloadScheduleReceiptRawZip\(r\.id\)/);
|
||||
expect(content).not.toMatch(/downloadScheduleInboundRawZip\(r\.id\)/);
|
||||
expect(content).not.toMatch(/downloadScheduleOutboundRawZip\(r\.id\)/);
|
||||
});
|
||||
|
||||
it('only shows raw inventory/receipt download when wecom deep link prompt is active', () => {
|
||||
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
|
||||
const content = readFileSync(panelPath, 'utf8');
|
||||
it('only shows raw inventory/inbound/outbound download when wecom deep link prompt is active', () => {
|
||||
expect(content).toMatch(/wecomRawZipPromptRunId/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.inventory_raw_zip_available"/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.receipt_raw_zip_available"/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.inbound_raw_zip_available"/);
|
||||
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.outbound_raw_zip_available"/);
|
||||
expect(content).toMatch(/admin\.wecomRawZipPromptRunId === admin\.expandedScheduleRun\.id/);
|
||||
expect(content).toMatch(/downloadScheduleReceiptRawZip/);
|
||||
expect(content).toMatch(/downloadScheduleInboundRawZip/);
|
||||
expect(content).toMatch(/downloadScheduleOutboundRawZip/);
|
||||
});
|
||||
|
||||
it('uses scheme C full-width layout without left schedule card list', () => {
|
||||
// 无左侧卡片式排程列表(旧 workbench-* 卡片循环)
|
||||
expect(content).not.toMatch(/workbench-\$\{s\.id\}/);
|
||||
expect(content).not.toMatch(/lg:grid-cols-\[320px/);
|
||||
// 顶栏 ElSelect 切换任务
|
||||
expect(content).toMatch(/ElSelect/);
|
||||
expect(content).toMatch(/selectedIdModel/);
|
||||
expect(content).toMatch(/admin\.schedule\.currentTask/);
|
||||
});
|
||||
});
|
||||
+534
-399
@@ -1,425 +1,560 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleWorkbenchPanel.vue
|
||||
* 定时任务工作台模式:侧边任务列表与运行记录表格。
|
||||
* 依赖:schedules.context、lucide-vue-next。
|
||||
* 逻辑:inject admin;筛选/查询运行记录、展开日志详情。
|
||||
* 用途:排程工作台方案 C——无左栏;顶栏 ElSelect 切换任务;全宽执行记录。
|
||||
* 依赖:schedules.context、Element Plus、lucide-vue-next(展开区图标)。
|
||||
* 逻辑:选中任务上下文条 + 紧凑指标 + 筛选 + 运行表;保留企微 raw zip 深链提示。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ChevronDown, ChevronUp, Download, Edit3, Eye, FlaskConical, Power, PowerOff, Rocket, Trash2,
|
||||
ChevronDown, ChevronUp, Download, Eye,
|
||||
} from 'lucide-vue-next';
|
||||
import {
|
||||
ElButton,
|
||||
ElDatePicker,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
|
||||
const selectedIdModel = computed({
|
||||
get: () => admin.selectedScheduleId,
|
||||
set: (id: number | null) => {
|
||||
if (id != null) void admin.viewScheduleRuns(id);
|
||||
},
|
||||
});
|
||||
|
||||
const skippedMetricLabel = computed(() => {
|
||||
if (admin.isInboundRpaSchedule) return t('admin.schedule.totalSkippedReceipt');
|
||||
if (admin.isOutboundRpaSchedule) return t('admin.schedule.totalSkippedOutbound');
|
||||
if (admin.isInventoryRpaSchedule) return t('admin.schedule.totalSkippedInventory');
|
||||
return t('admin.schedule.totalSkipped');
|
||||
});
|
||||
|
||||
/**
|
||||
* 顶栏切换排程时的 option 展示文案。
|
||||
* @param name - 排程名称
|
||||
* @param scheduleNo - 排程编号
|
||||
*/
|
||||
function scheduleOptionLabel(name: string, scheduleNo: string): string {
|
||||
return `${name} · ${scheduleNo}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="grid grid-cols-2 gap-3 admin-panel-lg p-4 shadow-sm md:grid-cols-4 xl:grid-cols-8">
|
||||
<div class="col-span-2 admin-stat-tile px-4 py-3 xl:col-span-3">
|
||||
<div class="truncate text-base font-semibold text-primary">{{ admin.selectedSchedule?.name || $t('admin.schedule.noSelection') }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.selectedHint', { time: admin.selectedScheduleLatestRunAt }) }}</div>
|
||||
<div class="schedule-workbench">
|
||||
<div class="schedule-workbench__context">
|
||||
<div class="schedule-workbench__switcher">
|
||||
<span class="schedule-workbench__label">{{ t('admin.schedule.currentTask') }}</span>
|
||||
<ElSelect
|
||||
v-model="selectedIdModel"
|
||||
filterable
|
||||
class="schedule-workbench__select"
|
||||
:placeholder="t('admin.schedule.noSelection')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="s in admin.schedules"
|
||||
:key="s.id"
|
||||
:label="scheduleOptionLabel(s.name, s.schedule_no)"
|
||||
:value="s.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
<template v-if="admin.selectedSchedule">
|
||||
<ElTag
|
||||
:type="admin.selectedSchedule.enabled ? 'success' : 'info'"
|
||||
effect="light"
|
||||
size="small"
|
||||
>
|
||||
{{ admin.selectedSchedule.enabled ? t('admin.schedule.enabled') : t('admin.schedule.disabled') }}
|
||||
</ElTag>
|
||||
<code class="schedule-cron">{{ admin.selectedSchedule.cron_expr }}</code>
|
||||
<div
|
||||
v-if="admin.showsRpaWorkerStatus"
|
||||
class="schedule-workbench__worker"
|
||||
>
|
||||
<span class="text-muted">{{ t('admin.schedule.rpaWorker.title') }}</span>
|
||||
<ElTag
|
||||
v-if="admin.rpaWorkerStatusLoading"
|
||||
size="small"
|
||||
type="info"
|
||||
effect="plain"
|
||||
>
|
||||
{{ t('admin.schedule.rpaWorker.loading') }}
|
||||
</ElTag>
|
||||
<ElTag
|
||||
v-else
|
||||
size="small"
|
||||
:type="admin.rpaWorkerStatus?.ready ? 'success' : 'danger'"
|
||||
effect="light"
|
||||
>
|
||||
{{ admin.rpaWorkerStatus?.ready ? t('admin.schedule.rpaWorker.online') : t('admin.schedule.rpaWorker.offline') }}
|
||||
</ElTag>
|
||||
<span class="text-muted text-xs">
|
||||
{{ t('admin.schedule.rpaWorker.lastHeartbeat', { time: admin.rpaWorkerLastHeartbeatAt }) }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-primary">{{ admin.selectedScheduleRuns.length }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.runBatches') }}</div>
|
||||
|
||||
<ElSpace v-if="admin.selectedSchedule" wrap>
|
||||
<ElButton @click="admin.openScheduleEditModal(admin.selectedSchedule)">
|
||||
{{ t('admin.schedule.actions.edit') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!admin.selectedSchedule.enabled"
|
||||
type="success"
|
||||
plain
|
||||
@click="() => void admin.setScheduleEnabled(admin.selectedSchedule!.id, true)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.start') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-else
|
||||
type="warning"
|
||||
plain
|
||||
@click="() => void admin.setScheduleEnabled(admin.selectedSchedule!.id, false)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.pause') }}
|
||||
</ElButton>
|
||||
<ElButton type="primary" plain @click="() => void admin.runScheduleNow(admin.selectedSchedule!.id)">
|
||||
{{ t('admin.schedule.actions.run') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="admin.selectedSchedule.schedule_type === 'data_pipeline' && admin.selectedSchedule.data_source_type === 'database'"
|
||||
@click="admin.openTestRunDialog(admin.selectedSchedule)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.test') }}
|
||||
</ElButton>
|
||||
<ElButton type="danger" plain @click="() => void admin.deleteSchedule(admin.selectedSchedule!)">
|
||||
{{ t('admin.schedule.actions.delete') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</div>
|
||||
|
||||
<div class="schedule-stats-bar">
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.selectedScheduleRuns.length }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.runBatches') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-primary">{{ admin.selectedScheduleRunMetrics.total }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.totalProcessed') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value">{{ admin.selectedScheduleRunMetrics.total }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.totalProcessed') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-emerald-700">{{ admin.selectedScheduleRunMetrics.success }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.totalSuccess') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value text-emerald-700">{{ admin.selectedScheduleRunMetrics.success }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.totalSuccess') }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-amber-600">{{ admin.selectedScheduleRunMetrics.skipped }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{
|
||||
admin.isReceiptRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedReceipt')
|
||||
: admin.isInventoryRpaSchedule
|
||||
? $t('admin.schedule.totalSkippedInventory')
|
||||
: $t('admin.schedule.totalSkipped')
|
||||
}}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value text-amber-600">{{ admin.selectedScheduleRunMetrics.skipped }}</span>
|
||||
<span class="schedule-stat__label">{{ skippedMetricLabel }}</span>
|
||||
</div>
|
||||
<div class="admin-stat-tile px-4 py-3 text-center">
|
||||
<div class="text-base font-semibold text-rose-600">{{ admin.selectedScheduleRunMetrics.failed }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.totalFailed') }}</div>
|
||||
<div class="schedule-stat">
|
||||
<span class="schedule-stat__value text-rose-600">{{ admin.selectedScheduleRunMetrics.failed }}</span>
|
||||
<span class="schedule-stat__label">{{ t('admin.schedule.totalFailed') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-panel-lg p-6 shadow-sm">
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-[320px_minmax(0,1fr)]">
|
||||
<div class="admin-panel-lg p-6 shadow-sm">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<h4 class="text-lg font-semibold text-primary">{{ $t('admin.schedule.listTitle') }}</h4>
|
||||
<span class="text-xs text-muted">{{ $t('admin.schedule.switchByCard') }}</span>
|
||||
</div>
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-for="s in admin.schedules"
|
||||
:key="`workbench-${s.id}`"
|
||||
class="w-full cursor-pointer rounded-2xl border px-4 py-4 text-left transition-all"
|
||||
:class="admin.selectedScheduleId === s.id ? 'border-blue-300 bg-blue-50/60' : 'border-default bg-surface hover:border-blue-200 hover:bg-surface-soft'"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@click="admin.viewScheduleRuns(s.id)"
|
||||
@keydown.enter.prevent="admin.viewScheduleRuns(s.id)"
|
||||
@keydown.space.prevent="admin.viewScheduleRuns(s.id)"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<div class="truncate font-semibold text-primary">{{ s.name }}</div>
|
||||
<div class="mt-0.5 text-xs text-muted">{{ s.schedule_no }}</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-default p-1.5 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
:title="$t('admin.schedule.actions.edit')"
|
||||
@click.stop="admin.openScheduleEditModal(s)"
|
||||
>
|
||||
<Edit3 class="h-3 w-3" />
|
||||
</button>
|
||||
<button
|
||||
v-if="!s.enabled"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-emerald-200 p-1.5 text-xs font-medium text-emerald-700 transition-colors hover:bg-emerald-50"
|
||||
:title="$t('admin.schedule.actions.start')"
|
||||
@click.stop="admin.setScheduleEnabled(s.id, true)"
|
||||
>
|
||||
<Power class="h-3 w-3" />
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="inline-flex items-center justify-center rounded-xl border border-amber-200 p-1.5 text-xs font-medium text-amber-700 transition-colors hover:bg-amber-50"
|
||||
:title="$t('admin.schedule.actions.pause')"
|
||||
@click.stop="admin.setScheduleEnabled(s.id, false)"
|
||||
>
|
||||
<PowerOff class="h-3 w-3" />
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center justify-center rounded-xl border border-blue-200 p-1.5 text-xs font-medium text-blue-700 transition-colors hover:bg-blue-50"
|
||||
:title="$t('admin.schedule.actions.run')"
|
||||
@click.stop="admin.runScheduleNow(s.id)"
|
||||
>
|
||||
<Rocket class="h-3 w-3" />
|
||||
</button>
|
||||
<button
|
||||
v-if="s.schedule_type === 'data_pipeline' && s.data_source_type === 'database'"
|
||||
class="inline-flex items-center justify-center rounded-xl border border-violet-200 p-1.5 text-xs font-medium text-violet-700 transition-colors hover:bg-violet-50"
|
||||
:title="$t('admin.schedule.actions.test')"
|
||||
@click.stop="admin.openTestRunDialog(s)"
|
||||
>
|
||||
<FlaskConical class="h-3 w-3" />
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center justify-center rounded-xl border border-rose-200 p-1.5 text-xs font-medium text-rose-600 transition-colors hover:bg-rose-50"
|
||||
:title="$t('admin.schedule.actions.delete')"
|
||||
@click.stop="admin.deleteSchedule(s)"
|
||||
>
|
||||
<Trash2 class="h-3 w-3" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="s.enabled ? 'bg-emerald-100 text-emerald-700' : 'bg-surface-strong text-secondary'">
|
||||
{{ s.enabled ? $t('admin.schedule.enabled') : $t('admin.schedule.disabled') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.selectedSchedule" class="schedule-workbench__runs">
|
||||
<div class="schedule-workbench__runs-head">
|
||||
<div>
|
||||
<div v-if="admin.selectedSchedule" class="admin-panel p-4">
|
||||
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-primary">{{ $t('admin.schedule.recordsTitle', { name: admin.selectedSchedule.name }) }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">{{ $t('admin.schedule.recordsSubtitle') }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.showsRpaWorkerStatus"
|
||||
class="inline-flex items-center gap-2 rounded-lg border border-default px-3 py-2 text-xs"
|
||||
>
|
||||
<span class="text-muted">{{ $t('admin.schedule.rpaWorker.title') }}</span>
|
||||
<span
|
||||
v-if="admin.rpaWorkerStatusLoading"
|
||||
class="rounded-full bg-surface-soft px-2 py-0.5 text-secondary"
|
||||
>
|
||||
{{ $t('admin.schedule.rpaWorker.loading') }}
|
||||
</span>
|
||||
<span
|
||||
v-else
|
||||
class="rounded-full px-2 py-0.5 font-medium"
|
||||
:class="admin.rpaWorkerStatus?.ready ? 'bg-emerald-100 text-emerald-700' : 'bg-rose-100 text-rose-700'"
|
||||
>
|
||||
{{ admin.rpaWorkerStatus?.ready ? $t('admin.schedule.rpaWorker.online') : $t('admin.schedule.rpaWorker.offline') }}
|
||||
</span>
|
||||
<span class="text-muted">
|
||||
{{ $t('admin.schedule.rpaWorker.lastHeartbeat', { time: admin.rpaWorkerLastHeartbeatAt }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="!admin.rpaWorkerStatusLoading && admin.rpaWorkerStatus && !admin.rpaWorkerStatus.ready && admin.rpaWorkerStatus.detail_message"
|
||||
class="max-w-[360px] truncate text-amber-700"
|
||||
:title="admin.rpaWorkerStatus.detail_message"
|
||||
>
|
||||
{{ admin.rpaWorkerStatus.detail_message }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2 text-xs">
|
||||
<label class="text-muted">{{ $t('admin.schedule.filterStart') }}</label>
|
||||
<input type="datetime-local" step="1" v-model="admin.scheduleRunStartedAfter" class="!min-w-0 !w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-default" />
|
||||
<label class="text-muted">{{ $t('admin.schedule.filterEnd') }}</label>
|
||||
<input type="datetime-local" step="1" v-model="admin.scheduleRunStartedBefore" class="!min-w-0 !w-[170px] !py-1 !px-2 !text-xs rounded-lg border border-default" />
|
||||
<select v-model="admin.scheduleRunStatusFilter" class="!min-w-0 !w-[90px] !py-1 !px-2 !text-xs rounded-lg border border-default">
|
||||
<option v-for="opt in admin.scheduleRunStatusOptions" :key="opt.value" :value="opt.value">
|
||||
{{ opt.label }}
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
class="inline-flex items-center rounded-lg bg-brand-600 px-2.5 py-1 text-xs font-medium text-white hover:bg-brand-700"
|
||||
@click="admin.viewScheduleRuns(admin.selectedSchedule.id)"
|
||||
>
|
||||
{{ $t('admin.schedule.query') }}
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex items-center rounded-lg border border-default px-2.5 py-1 text-xs font-medium text-secondary hover:bg-surface-soft"
|
||||
@click="admin.resetScheduleRunFilters(); admin.viewScheduleRuns(admin.selectedSchedule.id)"
|
||||
>
|
||||
{{ $t('admin.schedule.reset') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="admin-table-wrap max-h-[calc(100vh-20rem)] rounded-xl border border-subtle scrollbar-thin">
|
||||
<table
|
||||
class="admin-table table-fixed text-xs"
|
||||
:style="{ minWidth: `${admin.scheduleRunColumnDefs.reduce((sum, col) => sum + col.width, 0)}px` }"
|
||||
>
|
||||
<colgroup>
|
||||
<col
|
||||
v-for="col in admin.scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
:style="{
|
||||
width: `${col.width}px`,
|
||||
minWidth: `${col.width}px`,
|
||||
maxWidth: `${col.width}px`,
|
||||
}"
|
||||
/>
|
||||
</colgroup>
|
||||
<thead class="sticky top-0 z-10 admin-table-sticky-head">
|
||||
<tr class="text-muted">
|
||||
<th
|
||||
v-for="(col, colIndex) in admin.scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
class="group relative max-w-0 overflow-hidden admin-table-sticky-head px-4 py-3 text-xs font-semibold uppercase select-none"
|
||||
>
|
||||
<span class="block truncate pr-2" :title="col.label">{{ col.label }}</span>
|
||||
<span
|
||||
class="absolute inset-y-0 -right-1 z-10 w-2 cursor-col-resize"
|
||||
@mousedown.prevent="admin.startScheduleColResize(colIndex, $event)"
|
||||
:title="$t('admin.schedule.resizeColumn', { label: col.label })"
|
||||
></span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="admin.scheduleRunsLoading">
|
||||
<td colspan="11" class="px-4 py-8 text-center text-sm text-muted">{{ $t('admin.schedule.queryingRuns') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="admin.filteredScheduleRuns.length === 0">
|
||||
<td colspan="11" class="px-4 py-8 text-center text-sm text-muted">{{ $t('admin.schedule.noRunRecords') }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-else
|
||||
v-for="r in admin.filteredScheduleRuns"
|
||||
:key="r.id"
|
||||
class="text-secondary transition"
|
||||
>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="r.run_no">{{ r.run_no }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.formatDateTime(r.started_at)">{{ admin.formatDateTime(r.started_at) }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.formatDateTime(r.finished_at)">{{ admin.formatDateTime(r.finished_at) }}</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 items-center gap-1 overflow-hidden">
|
||||
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="admin.getScheduleRunStatusBadge(r.status).cls">
|
||||
{{ admin.getScheduleRunStatusBadge(r.status).label }}
|
||||
</span>
|
||||
<span v-if="r.error_message" class="min-w-0 truncate text-xs text-muted" :title="r.error_message">...</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.total_count }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.success_count }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.skipped_count ?? 0 }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.getScheduleRunFailedCountTitle(r)">
|
||||
<span>{{ r.failed_count }}</span>
|
||||
<span
|
||||
v-if="admin.isScheduleRunExcelExportFailed(r)"
|
||||
class="ml-1 text-xs font-medium text-amber-600"
|
||||
>+Excel</span>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<span v-if="r.wecom_notified" class="inline-flex max-w-full shrink-0 items-center gap-1 truncate text-xs text-emerald-600" :title="$t('admin.schedule.notified')">
|
||||
<svg class="h-3.5 w-3.5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg>
|
||||
{{ $t('admin.schedule.notified') }}
|
||||
</span>
|
||||
<span v-else-if="r.wecom_notify_error" class="block truncate text-xs text-amber-500" :title="r.wecom_notify_error">{{ $t('admin.schedule.notifyError') }}</span>
|
||||
<span v-else class="text-xs text-muted">-</span>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-1 overflow-hidden">
|
||||
<a
|
||||
v-if="r.total_count > 0"
|
||||
href="#"
|
||||
@click.prevent="admin.downloadScheduleExcel(r.id)"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-lg border border-default px-2 py-1 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
>
|
||||
<Download class="h-3 w-3 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadDetail') }}
|
||||
</a>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 items-center overflow-hidden">
|
||||
<button
|
||||
v-if="(r.step_logs && r.step_logs.length > 0) || r.dify_execution_snapshot || r.kb_sync_status"
|
||||
@click="admin.expandedScheduleRunId = admin.expandedScheduleRunId === r.id ? null : r.id"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-lg border border-blue-200 px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50"
|
||||
>
|
||||
<Eye class="h-3 w-3 shrink-0" />
|
||||
{{ $t('admin.schedule.log') }}
|
||||
<ChevronDown v-if="admin.expandedScheduleRunId !== r.id" class="h-3 w-3 shrink-0" />
|
||||
<ChevronUp v-else class="h-3 w-3 shrink-0" />
|
||||
</button>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-if="admin.expandedScheduleRun"
|
||||
:key="'expanded-' + admin.expandedScheduleRunId"
|
||||
>
|
||||
<td colspan="11" class="w-full max-w-none px-4 py-3 bg-surface-soft/60">
|
||||
<div class="min-w-0 w-full max-w-full space-y-3">
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.inventory_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawInventoryZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleInventoryRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadInventoryRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.receipt_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawReceiptZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleReceiptRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ $t('admin.schedule.downloadReceiptRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.expandedScheduleRun.kb_sync_status"
|
||||
class="rounded-xl border border-emerald-200 bg-emerald-50/50 p-3 text-xs text-secondary"
|
||||
>
|
||||
<div class="font-bold text-emerald-800">{{ $t('admin.schedule.kbSync.title') }}</div>
|
||||
<div class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.kbSync.status') }}:</span>
|
||||
{{ admin.expandedScheduleRun.kb_sync_status }}
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.kb_document_id" class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.kbSync.document') }}:</span>
|
||||
{{ admin.expandedScheduleRun.kb_document_id }}
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.kb_sync_error" class="mt-1 text-rose-600">
|
||||
{{ admin.expandedScheduleRun.kb_sync_error }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.expandedScheduleRun.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-1">
|
||||
<h5 class="min-w-0 text-xs font-bold uppercase text-indigo-800">{{ $t('admin.schedule.difySnapshot.title') }}</h5>
|
||||
<time
|
||||
class="shrink-0 whitespace-nowrap text-[10px] text-indigo-600/80"
|
||||
:title="admin.expandedScheduleRun.dify_execution_snapshot.captured_at || '-'"
|
||||
>
|
||||
{{ admin.formatDateTime(admin.expandedScheduleRun.dify_execution_snapshot.captured_at) }}
|
||||
</time>
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-secondary">
|
||||
<div class="break-words">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.difySnapshot.agent') }}:</span>
|
||||
{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
<span class="text-muted">{{ $t('admin.schedule.difySnapshot.agentId', { id: admin.expandedScheduleRun.dify_execution_snapshot.dify_agent_id ?? '-' }) }}</span>
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_app_id">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.difySnapshot.difyAppId') }}:</span>
|
||||
{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_app_id }}
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-muted">{{ $t('admin.schedule.difySnapshot.systemPrompt') }}:</span>
|
||||
<pre
|
||||
v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[240px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-surface p-3 font-mono text-[11px] leading-relaxed text-primary"
|
||||
>{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-muted">{{ $t('admin.schedule.difySnapshot.notConfiguredUseDefault') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-muted">{{ $t('admin.schedule.difySnapshot.notEnabledRun') }}</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 mb-2">
|
||||
<h5 class="text-xs font-bold text-secondary uppercase">{{ $t('admin.schedule.runLogs') }}</h5>
|
||||
<span class="text-xs text-muted">{{ $t('admin.schedule.stepsCount', { count: admin.expandedScheduleRun.step_logs?.length || 0 }) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(log, li) in admin.expandedScheduleRun.step_logs || []"
|
||||
:key="li"
|
||||
class="rounded-xl border p-3"
|
||||
:class="log.status === 'failed' ? 'border-rose-200 bg-rose-50/40' : 'border-default bg-surface'"
|
||||
>
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-bold"
|
||||
:class="(admin.stepStatusMap[log.status] || admin.stepStatusMap.success || { cls: 'bg-surface-soft text-secondary' }).cls">
|
||||
{{ (admin.stepStatusMap[log.status] || { label: log.status }).label }}
|
||||
</span>
|
||||
<span class="text-xs font-semibold text-secondary">{{ admin.stepLabelMap[log.step] || log.step }}</span>
|
||||
<span v-if="log.row_id" class="text-[10px] text-muted">row_id={{ log.row_id }}</span>
|
||||
<span v-if="log.duration_ms != null" class="text-[10px] text-muted">{{ log.duration_ms }}ms</span>
|
||||
</div>
|
||||
<details v-if="log.detail" class="mt-1">
|
||||
<summary class="cursor-pointer text-[10px] font-semibold text-muted hover:text-secondary">{{ $t('admin.schedule.viewDetail') }}</summary>
|
||||
<pre class="admin-pre-block">{{ JSON.stringify(log.detail, null, 2) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="rounded-2xl border border-dashed border-default bg-surface px-4 py-10 text-center text-sm text-muted">
|
||||
{{ $t('admin.schedule.noSelectionHint') }}
|
||||
</div>
|
||||
<h3 class="text-base font-semibold text-primary">
|
||||
{{ t('admin.schedule.recordsTitle', { name: admin.selectedSchedule.name }) }}
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-muted">{{ t('admin.schedule.recordsSubtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="schedule-filters">
|
||||
<ElDatePicker
|
||||
v-model="admin.scheduleRunStartedAfter"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
:placeholder="t('admin.schedule.filterStart')"
|
||||
class="schedule-filter-date"
|
||||
/>
|
||||
<ElDatePicker
|
||||
v-model="admin.scheduleRunStartedBefore"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm:ss"
|
||||
:placeholder="t('admin.schedule.filterEnd')"
|
||||
class="schedule-filter-date"
|
||||
/>
|
||||
<ElSelect
|
||||
v-model="admin.scheduleRunStatusFilter"
|
||||
class="schedule-filter-status"
|
||||
:placeholder="t('admin.schedule.columns.status')"
|
||||
>
|
||||
<ElOption
|
||||
v-for="opt in admin.scheduleRunStatusOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElButton type="primary" @click="admin.viewScheduleRuns(admin.selectedSchedule.id)">
|
||||
{{ t('admin.schedule.query') }}
|
||||
</ElButton>
|
||||
<ElButton @click="admin.resetScheduleRunFilters(); admin.viewScheduleRuns(admin.selectedSchedule.id)">
|
||||
{{ t('admin.schedule.reset') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap max-h-[calc(100vh-22rem)] scrollbar-thin">
|
||||
<table
|
||||
class="admin-table table-fixed text-xs"
|
||||
:style="{ minWidth: `${admin.scheduleRunColumnDefs.reduce((sum, col) => sum + col.width, 0)}px` }"
|
||||
>
|
||||
<colgroup>
|
||||
<col
|
||||
v-for="col in admin.scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
:style="{
|
||||
width: `${col.width}px`,
|
||||
minWidth: `${col.width}px`,
|
||||
maxWidth: `${col.width}px`,
|
||||
}"
|
||||
/>
|
||||
</colgroup>
|
||||
<thead class="sticky top-0 z-10 admin-table-sticky-head">
|
||||
<tr class="text-muted">
|
||||
<th
|
||||
v-for="(col, colIndex) in admin.scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
class="group relative max-w-0 overflow-hidden admin-table-sticky-head px-4 py-3 text-xs font-semibold uppercase select-none"
|
||||
>
|
||||
<span class="block truncate pr-2" :title="col.label">{{ col.label }}</span>
|
||||
<span
|
||||
class="absolute inset-y-0 -right-1 z-10 w-2 cursor-col-resize"
|
||||
@mousedown.prevent="admin.startScheduleColResize(colIndex, $event)"
|
||||
:title="t('admin.schedule.resizeColumn', { label: col.label })"
|
||||
></span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="admin.scheduleRunsLoading">
|
||||
<td colspan="11" class="px-4 py-8 text-center text-sm text-muted">{{ t('admin.schedule.queryingRuns') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="admin.filteredScheduleRuns.length === 0">
|
||||
<td colspan="11" class="px-4 py-8 text-center text-sm text-muted">{{ t('admin.schedule.noRunRecords') }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-else
|
||||
v-for="r in admin.filteredScheduleRuns"
|
||||
:key="r.id"
|
||||
class="text-secondary transition"
|
||||
>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="r.run_no">{{ r.run_no }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.formatDateTime(r.started_at)">{{ admin.formatDateTime(r.started_at) }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.formatDateTime(r.finished_at)">{{ admin.formatDateTime(r.finished_at) }}</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 items-center gap-1 overflow-hidden">
|
||||
<span
|
||||
class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="admin.getScheduleRunStatusBadge(r.status).cls"
|
||||
>
|
||||
{{ admin.getScheduleRunStatusBadge(r.status).label }}
|
||||
</span>
|
||||
<span v-if="r.error_message" class="min-w-0 truncate text-xs text-muted" :title="r.error_message">...</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.total_count }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.success_count }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5">{{ r.skipped_count ?? 0 }}</td>
|
||||
<td class="max-w-0 truncate px-4 py-2.5" :title="admin.getScheduleRunFailedCountTitle(r)">
|
||||
<span>{{ r.failed_count }}</span>
|
||||
<span
|
||||
v-if="admin.isScheduleRunExcelExportFailed(r)"
|
||||
class="ml-1 text-xs font-medium text-amber-600"
|
||||
>+Excel</span>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<span
|
||||
v-if="r.wecom_notified"
|
||||
class="inline-flex max-w-full shrink-0 items-center gap-1 truncate text-xs text-emerald-600"
|
||||
:title="t('admin.schedule.notified')"
|
||||
>
|
||||
{{ t('admin.schedule.notified') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="r.wecom_notify_error"
|
||||
class="block truncate text-xs text-amber-500"
|
||||
:title="r.wecom_notify_error"
|
||||
>{{ t('admin.schedule.notifyError') }}</span>
|
||||
<span v-else class="text-xs text-muted">-</span>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-1 overflow-hidden">
|
||||
<a
|
||||
v-if="r.total_count > 0"
|
||||
href="#"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-lg border border-default px-2 py-1 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
|
||||
@click.prevent="admin.downloadScheduleExcel(r.id)"
|
||||
>
|
||||
<Download class="h-3 w-3 shrink-0" />
|
||||
{{ t('admin.schedule.downloadDetail') }}
|
||||
</a>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="max-w-0 overflow-hidden px-4 py-2.5">
|
||||
<div class="flex min-w-0 items-center overflow-hidden">
|
||||
<button
|
||||
v-if="(r.step_logs && r.step_logs.length > 0) || r.dify_execution_snapshot || r.kb_sync_status"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-lg border border-blue-200 px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50"
|
||||
@click="admin.expandedScheduleRunId = admin.expandedScheduleRunId === r.id ? null : r.id"
|
||||
>
|
||||
<Eye class="h-3 w-3 shrink-0" />
|
||||
{{ t('admin.schedule.log') }}
|
||||
<ChevronDown v-if="admin.expandedScheduleRunId !== r.id" class="h-3 w-3 shrink-0" />
|
||||
<ChevronUp v-else class="h-3 w-3 shrink-0" />
|
||||
</button>
|
||||
<span v-else class="text-muted">-</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-if="admin.expandedScheduleRun"
|
||||
:key="'expanded-' + admin.expandedScheduleRunId"
|
||||
>
|
||||
<td colspan="11" class="w-full max-w-none px-4 py-3 bg-surface-soft/60">
|
||||
<div class="min-w-0 w-full max-w-full space-y-3">
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.inventory_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ t('admin.schedule.rawInventoryZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleInventoryRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ t('admin.schedule.downloadInventoryRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.inbound_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ t('admin.schedule.rawInboundZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleInboundRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ t('admin.schedule.downloadInboundRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.outbound_raw_zip_available"
|
||||
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
|
||||
>
|
||||
<p class="text-sm font-medium text-blue-900">{{ t('admin.schedule.rawOutboundZipWecomHint') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
|
||||
@click="admin.downloadScheduleOutboundRawZip(admin.expandedScheduleRun.id)"
|
||||
>
|
||||
<Download class="h-4 w-4 shrink-0" />
|
||||
{{ t('admin.schedule.downloadOutboundRawZipPackage') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.expandedScheduleRun.kb_sync_status"
|
||||
class="rounded-xl border border-emerald-200 bg-emerald-50/50 p-3 text-xs text-secondary"
|
||||
>
|
||||
<div class="font-bold text-emerald-800">{{ t('admin.schedule.kbSync.title') }}</div>
|
||||
<div class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ t('admin.schedule.kbSync.status') }}:</span>
|
||||
{{ admin.expandedScheduleRun.kb_sync_status }}
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.kb_document_id" class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ t('admin.schedule.kbSync.document') }}:</span>
|
||||
{{ admin.expandedScheduleRun.kb_document_id }}
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.kb_sync_error" class="mt-1 text-rose-600">
|
||||
{{ admin.expandedScheduleRun.kb_sync_error }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="admin.expandedScheduleRun.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-1">
|
||||
<h5 class="min-w-0 text-xs font-bold uppercase text-indigo-800">{{ t('admin.schedule.difySnapshot.title') }}</h5>
|
||||
<time
|
||||
class="shrink-0 whitespace-nowrap text-[10px] text-indigo-600/80"
|
||||
:title="admin.expandedScheduleRun.dify_execution_snapshot.captured_at || '-'"
|
||||
>
|
||||
{{ admin.formatDateTime(admin.expandedScheduleRun.dify_execution_snapshot.captured_at) }}
|
||||
</time>
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-secondary">
|
||||
<div class="break-words">
|
||||
<span class="font-semibold text-muted">{{ t('admin.schedule.difySnapshot.agent') }}:</span>
|
||||
{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
<span class="text-muted">{{ t('admin.schedule.difySnapshot.agentId', { id: admin.expandedScheduleRun.dify_execution_snapshot.dify_agent_id ?? '-' }) }}</span>
|
||||
</div>
|
||||
<div v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_app_id">
|
||||
<span class="font-semibold text-muted">{{ t('admin.schedule.difySnapshot.difyAppId') }}:</span>
|
||||
{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_app_id }}
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-muted">{{ t('admin.schedule.difySnapshot.systemPrompt') }}:</span>
|
||||
<pre
|
||||
v-if="admin.expandedScheduleRun.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[240px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-surface p-3 font-mono text-[11px] leading-relaxed text-primary"
|
||||
>{{ admin.expandedScheduleRun.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-muted">{{ t('admin.schedule.difySnapshot.notConfiguredUseDefault') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-muted">{{ t('admin.schedule.difySnapshot.notEnabledRun') }}</div>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2">
|
||||
<h5 class="text-xs font-bold uppercase text-secondary">{{ t('admin.schedule.runLogs') }}</h5>
|
||||
<span class="text-xs text-muted">{{ t('admin.schedule.stepsCount', { count: admin.expandedScheduleRun.step_logs?.length || 0 }) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(log, li) in admin.expandedScheduleRun.step_logs || []"
|
||||
:key="li"
|
||||
class="rounded-xl border p-3"
|
||||
:class="log.status === 'failed' ? 'border-rose-200 bg-rose-50/40' : 'border-default bg-surface'"
|
||||
>
|
||||
<div class="mb-1 flex items-center gap-2">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-bold"
|
||||
:class="(admin.stepStatusMap[log.status] || admin.stepStatusMap.success || { cls: 'bg-surface-soft text-secondary' }).cls"
|
||||
>
|
||||
{{ (admin.stepStatusMap[log.status] || { label: log.status }).label }}
|
||||
</span>
|
||||
<span class="text-xs font-semibold text-secondary">{{ admin.stepLabelMap[log.step] || log.step }}</span>
|
||||
<span v-if="log.row_id" class="text-[10px] text-muted">row_id={{ log.row_id }}</span>
|
||||
<span v-if="log.duration_ms != null" class="text-[10px] text-muted">{{ log.duration_ms }}ms</span>
|
||||
</div>
|
||||
<details v-if="log.detail" class="mt-1">
|
||||
<summary class="cursor-pointer text-[10px] font-semibold text-muted hover:text-secondary">{{ t('admin.schedule.viewDetail') }}</summary>
|
||||
<pre class="admin-pre-block">{{ JSON.stringify(log.detail, null, 2) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="px-8 py-16 text-center text-sm text-muted"
|
||||
>
|
||||
{{ t('admin.schedule.noSelectionHint') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-workbench__context {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px 16px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.schedule-workbench__switcher {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.schedule-workbench__label {
|
||||
font-size: 0.875rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.schedule-workbench__select {
|
||||
width: min(100%, 28rem);
|
||||
}
|
||||
|
||||
.schedule-workbench__worker {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px 8px;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.schedule-stats-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px 32px;
|
||||
padding: 12px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.schedule-stat {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.schedule-stat__value {
|
||||
font-size: 1.125rem;
|
||||
font-weight: 700;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.schedule-stat__label {
|
||||
font-size: 0.8125rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.schedule-workbench__runs-head {
|
||||
padding: 16px 32px 0;
|
||||
}
|
||||
|
||||
.schedule-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 12px 32px 16px;
|
||||
}
|
||||
|
||||
.schedule-filter-date {
|
||||
width: 11.5rem;
|
||||
}
|
||||
|
||||
.schedule-filter-status {
|
||||
width: 8rem;
|
||||
}
|
||||
|
||||
.schedule-cron {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.admin-table-wrap {
|
||||
margin: 0 32px 24px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/schedules/components/SchedulesPageOverlays.vue
|
||||
* 定时任务页弹窗层:试运行、创建/编辑、删除确认。
|
||||
* 用途:定时任务页弹层——试运行、创建/编辑抽屉、删除确认。
|
||||
* 依赖:DeleteConfirmDialog、ScheduleCreateEditDrawer、ScheduleTestRunDialog、schedules.context。
|
||||
* 逻辑:由 SchedulesPage 挂载;创建/编辑已改为右侧 ElDrawer。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
import ScheduleCreateEditModal from './ScheduleCreateEditModal.vue';
|
||||
import ScheduleCreateEditDrawer from './ScheduleCreateEditDrawer.vue';
|
||||
import ScheduleTestRunDialog from './ScheduleTestRunDialog.vue';
|
||||
|
||||
const admin = useSchedulesAdminContext();
|
||||
@@ -13,7 +15,7 @@ const admin = useSchedulesAdminContext();
|
||||
|
||||
<template>
|
||||
<ScheduleTestRunDialog />
|
||||
<ScheduleCreateEditModal />
|
||||
<ScheduleCreateEditDrawer />
|
||||
<DeleteConfirmDialog
|
||||
v-model="admin.showDeleteConfirmDialog"
|
||||
:title="admin.deleteConfirmTitle"
|
||||
|
||||
+13
-8
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminDeepLink.ts
|
||||
* 用途:解析企微深链 query,定位排程执行记录并在登录后自动下载原始库存/收料包。
|
||||
* 用途:解析企微深链 query,定位排程执行记录并在登录后自动下载原始库存/入站/出站包。
|
||||
* 依赖:vue-router、schedule-admin.state、useScheduleAdminRuns。
|
||||
* 逻辑:SchedulesPage onMounted 在 loadAll 后调用;消费 task_id/run_id/raw_zip/download,自动下载失败时保留手动入口。
|
||||
*/
|
||||
@@ -16,14 +16,14 @@ function parsePositiveInt(raw: unknown): number | null {
|
||||
|
||||
/**
|
||||
* 根据路由 query 打开工作台执行记录;raw_zip=1 时展开 run 并保留手动下载按钮。
|
||||
* 核心逻辑:download=inventory_raw_zip / receipt_raw_zip 时登录后自动下载一次;
|
||||
* 核心逻辑:download=inventory_raw_zip / inbound_raw_zip / outbound_raw_zip 时登录后自动下载一次;
|
||||
* 若企微内置浏览器拦截,用户仍可点醒目按钮重试。
|
||||
*/
|
||||
export function useScheduleAdminDeepLink(
|
||||
state: ScheduleAdminState,
|
||||
runs: Pick<
|
||||
ScheduleAdminRuns,
|
||||
'viewScheduleRuns' | 'downloadScheduleInventoryRawZip' | 'downloadScheduleReceiptRawZip'
|
||||
'viewScheduleRuns' | 'downloadScheduleInventoryRawZip' | 'downloadScheduleInboundRawZip' | 'downloadScheduleOutboundRawZip'
|
||||
>,
|
||||
) {
|
||||
const route = useRoute();
|
||||
@@ -38,8 +38,10 @@ export function useScheduleAdminDeepLink(
|
||||
const downloadKind = String(route.query.download || '');
|
||||
const shouldAutoDownloadInventory =
|
||||
rawZipPrompt && downloadKind === 'inventory_raw_zip';
|
||||
const shouldAutoDownloadReceipt =
|
||||
rawZipPrompt && downloadKind === 'receipt_raw_zip';
|
||||
const shouldAutoDownloadInbound =
|
||||
rawZipPrompt && downloadKind === 'inbound_raw_zip';
|
||||
const shouldAutoDownloadOutbound =
|
||||
rawZipPrompt && downloadKind === 'outbound_raw_zip';
|
||||
|
||||
state.scheduleViewMode.value = 'workbench';
|
||||
state.selectedScheduleId.value = taskId;
|
||||
@@ -53,10 +55,13 @@ export function useScheduleAdminDeepLink(
|
||||
if (target?.inventory_raw_zip_available && shouldAutoDownloadInventory) {
|
||||
state.wecomRawZipPromptRunId.value = runId;
|
||||
await runs.downloadScheduleInventoryRawZip(runId);
|
||||
} else if (target?.receipt_raw_zip_available && shouldAutoDownloadReceipt) {
|
||||
} else if (target?.inbound_raw_zip_available && shouldAutoDownloadInbound) {
|
||||
state.wecomRawZipPromptRunId.value = runId;
|
||||
await runs.downloadScheduleReceiptRawZip(runId);
|
||||
} else if (target?.inventory_raw_zip_available || target?.receipt_raw_zip_available) {
|
||||
await runs.downloadScheduleInboundRawZip(runId);
|
||||
} else if (target?.outbound_raw_zip_available && shouldAutoDownloadOutbound) {
|
||||
state.wecomRawZipPromptRunId.value = runId;
|
||||
await runs.downloadScheduleOutboundRawZip(runId);
|
||||
} else if (target?.inventory_raw_zip_available || target?.inbound_raw_zip_available || target?.outbound_raw_zip_available) {
|
||||
// 深链仅 raw_zip=1 无 download 时仍展示手动入口。
|
||||
state.wecomRawZipPromptRunId.value = runId;
|
||||
}
|
||||
|
||||
+1
-1
@@ -146,7 +146,7 @@ export function useScheduleAdminForm(
|
||||
// 历史货代 RPA 任务兼容:job_params 为空时把旧 api_body_template JSON 迁移进 schema 表单
|
||||
if (
|
||||
scheduleCreateForm.value.schedule_type === 'platform_job'
|
||||
&& scheduleCreateForm.value.platform_api_path === 'shipping-inventory-rpa'
|
||||
&& scheduleCreateForm.value.platform_api_path === 'freight-rpa-onhand'
|
||||
&& !(scheduleCreateForm.value.job_params && Object.values(scheduleCreateForm.value.job_params).some((v) => Array.isArray(v) ? v.length : v))
|
||||
&& (cfg.external_api?.body_template || '').trim()
|
||||
) {
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminRuns.spec.ts
|
||||
* 用途:锁定出站排程 job key、Worker scope 与 raw-zip 下载接线,避免回退到仅 inbound。
|
||||
* 依赖:useScheduleAdminRuns 源文件、vitest。
|
||||
* 逻辑:窄测读源码契约,不启动 Vue 运行时。
|
||||
*/
|
||||
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('useScheduleAdminRuns outbound schedule wiring', () => {
|
||||
const source = readFileSync(resolve(__dirname, 'useScheduleAdminRuns.ts'), 'utf8');
|
||||
|
||||
it('recognizes freight-rpa-outbound and polls worker scope outbound', () => {
|
||||
// 关键断言:出站排程必须独立于 inbound,徽标 scope 为 outbound。
|
||||
expect(source).toContain("selectedScheduleJobKey.value === 'freight-rpa-outbound'");
|
||||
expect(source).toContain("computed<'onhand' | 'inbound' | 'outbound'>");
|
||||
expect(source).toContain("if (isOutboundRpaSchedule.value) return 'outbound'");
|
||||
expect(source).toContain('isInventoryRpaSchedule.value || isInboundRpaSchedule.value || isOutboundRpaSchedule.value');
|
||||
});
|
||||
|
||||
it('exposes outbound raw-zip download mirroring inbound', () => {
|
||||
expect(source).toContain('downloadScheduleOutboundRawZip');
|
||||
expect(source).toContain('adminRunOutboundRawZipUrl');
|
||||
expect(source).toContain('admin.schedule.msg.downloadOutboundRawZipFailed');
|
||||
});
|
||||
});
|
||||
+58
-26
@@ -2,13 +2,13 @@
|
||||
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminRuns.ts
|
||||
* 执行批次列表:筛选、列宽、展开详情、Excel 下载、指标派生与 RPA Worker 心跳轮询。
|
||||
* 轮询策略(历史查询与监控职责分离):执行记录列表是纯历史查询,仅切任务/查询/重置时按需加载;
|
||||
* RPA Worker 在线状态是监控信号,仅在库存/收料排程工作台模式下每 RPA_WORKER_STATUS_POLL_MS 静默轮询一次,
|
||||
* RPA Worker 在线状态是监控信号,仅在库存/入站/出站排程工作台模式下每 RPA_WORKER_STATUS_POLL_MS 静默轮询一次,
|
||||
* 后台标签页暂停、请求未返回时跳过(防堆叠),使「在线/离线」徽标及时反映心跳。
|
||||
* 收料/库存排程的跳过列与统计砖分别显示「无收料/跳过」「无库存/跳过」。
|
||||
* 入站/出站/库存排程的跳过列与统计砖分别显示「无入站/跳过」「无出站/跳过」「无库存/跳过」。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, watch, type Ref } from 'vue';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
import { listAdminScheduleRuns, adminRunInventoryRawZipUrl, adminRunReceiptRawZipUrl, getAdminRpaWorkersStatus } from '@/features/admin/api/schedule.api';
|
||||
import { listAdminScheduleRuns, adminRunInventoryRawZipUrl, adminRunInboundRawZipUrl, adminRunOutboundRawZipUrl, getAdminRpaWorkersStatus } from '@/features/admin/api/schedule.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { formatDateTime } from '../../utils/schedule-format.utils';
|
||||
@@ -50,22 +50,28 @@ export function useScheduleAdminRuns(
|
||||
);
|
||||
|
||||
const isInventoryRpaSchedule = computed(
|
||||
() => selectedScheduleJobKey.value === 'shipping-inventory-rpa',
|
||||
() => selectedScheduleJobKey.value === 'freight-rpa-onhand',
|
||||
);
|
||||
|
||||
const isReceiptRpaSchedule = computed(
|
||||
() => selectedScheduleJobKey.value === 'freight-receipt-rpa',
|
||||
const isInboundRpaSchedule = computed(
|
||||
() => selectedScheduleJobKey.value === 'freight-rpa-inbound',
|
||||
);
|
||||
|
||||
const isOutboundRpaSchedule = computed(
|
||||
() => selectedScheduleJobKey.value === 'freight-rpa-outbound',
|
||||
);
|
||||
|
||||
/**
|
||||
* 同步执行记录列表表头文案;收料/库存排程的「跳过」列分别显示无收料/无库存。
|
||||
* 同步执行记录列表表头文案;入站/出站/库存排程的「跳过」列分别显示无入站/无出站/无库存。
|
||||
*/
|
||||
const syncScheduleRunColumnLabels = () => {
|
||||
const skippedKey = isReceiptRpaSchedule.value
|
||||
const skippedKey = isInboundRpaSchedule.value
|
||||
? 'skippedCountReceipt'
|
||||
: isInventoryRpaSchedule.value
|
||||
? 'skippedCountInventory'
|
||||
: 'skippedCount';
|
||||
: isOutboundRpaSchedule.value
|
||||
? 'skippedCountOutbound'
|
||||
: isInventoryRpaSchedule.value
|
||||
? 'skippedCountInventory'
|
||||
: 'skippedCount';
|
||||
const keyToI18n: Record<string, string> = {
|
||||
run_no: 'runNo',
|
||||
started_at: 'startedAt',
|
||||
@@ -85,7 +91,7 @@ export function useScheduleAdminRuns(
|
||||
});
|
||||
};
|
||||
watch(
|
||||
[locale, isReceiptRpaSchedule, isInventoryRpaSchedule],
|
||||
[locale, isInboundRpaSchedule, isOutboundRpaSchedule, isInventoryRpaSchedule],
|
||||
syncScheduleRunColumnLabels,
|
||||
{ immediate: true },
|
||||
);
|
||||
@@ -178,14 +184,17 @@ export function useScheduleAdminRuns(
|
||||
return raw ? formatDateTime(raw) : '-';
|
||||
});
|
||||
|
||||
/** 库存或收料排程工作台均展示 RPA Worker 心跳徽标。 */
|
||||
/** 在手 / 入站 / 出站排程工作台均展示 RPA Worker 心跳徽标。 */
|
||||
const showsRpaWorkerStatus = computed(
|
||||
() => isInventoryRpaSchedule.value || isReceiptRpaSchedule.value,
|
||||
() => isInventoryRpaSchedule.value || isInboundRpaSchedule.value || isOutboundRpaSchedule.value,
|
||||
);
|
||||
|
||||
const rpaWorkerStatusScope = computed<'inventory' | 'receipt'>(() =>
|
||||
(isReceiptRpaSchedule.value ? 'receipt' : 'inventory'),
|
||||
);
|
||||
// scope 取值与后端 /rpa-workers/status 约定一致(onhand|inbound|outbound)。
|
||||
const rpaWorkerStatusScope = computed<'onhand' | 'inbound' | 'outbound'>(() => {
|
||||
if (isOutboundRpaSchedule.value) return 'outbound';
|
||||
if (isInboundRpaSchedule.value) return 'inbound';
|
||||
return 'onhand';
|
||||
});
|
||||
|
||||
const rpaWorkerLastHeartbeatAt = computed(() => {
|
||||
const workers = rpaWorkerStatus.value?.workers || [];
|
||||
@@ -216,12 +225,12 @@ export function useScheduleAdminRuns(
|
||||
}
|
||||
};
|
||||
|
||||
// ── RPA Worker 心跳轮询(监控信号,库存/收料排程) ───────────────────────
|
||||
// ── RPA Worker 心跳轮询(监控信号,库存/入站/出站排程) ───────────────────────
|
||||
// 心跳由 Worker 每约 20s 上报一次(服务端 TTL 默认 90s),UI 每 10s 刷新即足够;
|
||||
// 2s 固定轮询只有少量时间点在变化,属于对无变化数据的过度请求。
|
||||
const RPA_WORKER_STATUS_POLL_MS = 10_000;
|
||||
|
||||
/** 是否需要前台轮询心跳:工作台模式且当前排程为库存或收料类 */
|
||||
/** 是否需要前台轮询心跳:工作台模式且当前排程为库存、入站或出站类 */
|
||||
const shouldPollRpaWorkerStatus = computed(
|
||||
() => scheduleViewMode.value === 'workbench' && showsRpaWorkerStatus.value && !!selectedScheduleId.value,
|
||||
);
|
||||
@@ -333,12 +342,12 @@ export function useScheduleAdminRuns(
|
||||
};
|
||||
|
||||
/**
|
||||
* 下载收料原始 ZIP;API 与文件名口径对齐库存 raw zip。
|
||||
* 下载入站原始 ZIP;API 与文件名口径对齐库存 raw zip。
|
||||
*/
|
||||
const downloadScheduleReceiptRawZip = async (runId: number) => {
|
||||
const res = await fetch(adminRunReceiptRawZipUrl(runId), { headers: getAuthHeaders() });
|
||||
const downloadScheduleInboundRawZip = async (runId: number) => {
|
||||
const res = await fetch(adminRunInboundRawZipUrl(runId), { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
msg.error(t('admin.schedule.msg.downloadReceiptRawZipFailed'));
|
||||
msg.error(t('admin.schedule.msg.downloadInboundRawZipFailed'));
|
||||
return;
|
||||
}
|
||||
const blob = await res.blob();
|
||||
@@ -346,7 +355,28 @@ export function useScheduleAdminRuns(
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
const disposition = res.headers.get('content-disposition');
|
||||
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || '收料RPA-收料.zip';
|
||||
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || '入站RPA-入站.zip';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
|
||||
/**
|
||||
* 下载出站原始 ZIP;API 与文件名口径对齐入站 raw zip。
|
||||
*/
|
||||
const downloadScheduleOutboundRawZip = async (runId: number) => {
|
||||
const res = await fetch(adminRunOutboundRawZipUrl(runId), { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
msg.error(t('admin.schedule.msg.downloadOutboundRawZipFailed'));
|
||||
return;
|
||||
}
|
||||
const blob = await res.blob();
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
const disposition = res.headers.get('content-disposition');
|
||||
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || '出站RPA-出站.zip';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
@@ -367,7 +397,8 @@ export function useScheduleAdminRuns(
|
||||
selectedScheduleRunMetrics,
|
||||
selectedScheduleLatestRunAt,
|
||||
isInventoryRpaSchedule,
|
||||
isReceiptRpaSchedule,
|
||||
isInboundRpaSchedule,
|
||||
isOutboundRpaSchedule,
|
||||
showsRpaWorkerStatus,
|
||||
rpaWorkerLastHeartbeatAt,
|
||||
refreshRpaWorkerStatus,
|
||||
@@ -375,7 +406,8 @@ export function useScheduleAdminRuns(
|
||||
viewScheduleRuns,
|
||||
downloadScheduleExcel,
|
||||
downloadScheduleInventoryRawZip,
|
||||
downloadScheduleReceiptRawZip,
|
||||
downloadScheduleInboundRawZip,
|
||||
downloadScheduleOutboundRawZip,
|
||||
startScheduleColResize,
|
||||
formatDateTime,
|
||||
isScheduleRunExcelExportFailed,
|
||||
|
||||
@@ -16,7 +16,7 @@ export type ScheduleDataSourceType = 'database' | 'external_api';
|
||||
|
||||
/** 平台内置 Job key(与后端 registry 一致,仅作类型提示) */
|
||||
export type PlatformJobKey =
|
||||
| 'shipping-inventory-rpa'
|
||||
| 'freight-rpa-onhand'
|
||||
| 'faq-aggregate-hot'
|
||||
| 'fixed-assets-snapshot';
|
||||
|
||||
|
||||
@@ -8,19 +8,19 @@ import { normalizePlatformJobKey } from './schedule-job-key.utils';
|
||||
|
||||
describe('normalizePlatformJobKey', () => {
|
||||
it('保留规范化连字符 key', () => {
|
||||
expect(normalizePlatformJobKey('shipping-inventory-rpa')).toBe('shipping-inventory-rpa');
|
||||
expect(normalizePlatformJobKey('freight-rpa-onhand')).toBe('freight-rpa-onhand');
|
||||
});
|
||||
|
||||
it('下划线转连字符(历史小写别名)', () => {
|
||||
expect(normalizePlatformJobKey('shipping_inventory_rpa')).toBe('shipping-inventory-rpa');
|
||||
expect(normalizePlatformJobKey('freight_rpa_onhand')).toBe('freight-rpa-onhand');
|
||||
});
|
||||
|
||||
it('大小写不敏感', () => {
|
||||
expect(normalizePlatformJobKey('Shipping-Inventory-RPA')).toBe('shipping-inventory-rpa');
|
||||
expect(normalizePlatformJobKey('Freight-Rpa-Onhand')).toBe('freight-rpa-onhand');
|
||||
});
|
||||
|
||||
it('取完整内部路径最后一段', () => {
|
||||
expect(normalizePlatformJobKey('/api/internal/jobs/shipping-inventory-rpa')).toBe('shipping-inventory-rpa');
|
||||
expect(normalizePlatformJobKey('/api/internal/jobs/freight-rpa-onhand')).toBe('freight-rpa-onhand');
|
||||
});
|
||||
|
||||
it('去 query / hash / 首尾斜杠', () => {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* 逻辑:小写 → 去 query/hash → 去首尾斜杠 → 取路径最后一段 → 下划线转连字符。
|
||||
* 用途:openScheduleEditModal 读入 platform_api_path 时归一化,使「平台任务」下拉回显与
|
||||
* selectedPlatformTaskDefinition 的 task_type 精确匹配不受历史非规范存储值影响。
|
||||
* 后端在保存时已归一化,历史数据仍可能存下划线(shipping_inventory_rpa)、完整内部路径
|
||||
* (/api/internal/jobs/shipping-inventory-rpa)或大小写差异;前端此前用严格 === 字符串比较,
|
||||
* 后端在保存时已归一化,历史数据仍可能存下划线(freight_rpa_onhand)、完整内部路径
|
||||
* (/api/internal/jobs/freight-rpa-onhand)或大小写差异;前端此前用严格 === 字符串比较,
|
||||
* 一旦不匹配即静默隐藏参数表单(含库存源),本工具修复该匹配漏洞。
|
||||
*/
|
||||
export function normalizePlatformJobKey(value: string | null | undefined): string {
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-audit/ShippingAuditCenterPage.vue
|
||||
用途:管理员货代统一审计中心——按 Conversation/Run/Candidate/Task/Gate/节点分组筛选、详情 Diff、关联链、哈希校验、受控导出。
|
||||
依赖:shipping-audit.api、shippingAuditDisplay、ShippingAuditEventDetailDrawer、Vue I18n、BusinessError、useMessage。
|
||||
依赖:element-plus(工具栏/筛选面板/提示横幅/时间线/分页,沿用管理端 element-trial 主题)、
|
||||
@element-plus/icons-vue、shipping-audit.api、shippingAuditDisplay、
|
||||
ShippingAuditEventDetailDrawer(el-drawer 版)、BusinessError、useMessage、Vue I18n。
|
||||
逻辑:列表不含快照全文;详情抽屉按权限脱敏;导出/校验写服务端访问审计;
|
||||
事件分组含复核/对话/Process Gate/资格/节点;支持 candidate_no / gate_code;
|
||||
窄屏用卡片列表;桌面表无横滚,Case/Task 在业务关联列,WF/Item/Run 芯片可复制。
|
||||
EP 迁移:按钮/筛选控件/横幅/空态/加载迁移为 el-button / el-input / el-select / el-date-picker /
|
||||
el-alert / el-empty / el-skeleton,审计事件列表迁移为 el-timeline(窄屏/桌面双容器保留
|
||||
原响应式断点与全部 data-testid 契约);业务脚本(筛选/关联链/哈希校验/导出)零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElDatePicker,
|
||||
ElEmpty,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSkeleton,
|
||||
ElTimeline,
|
||||
ElTimelineItem,
|
||||
} from 'element-plus';
|
||||
import { Refresh, Search } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
@@ -264,304 +284,347 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="space-y-5 p-5 md:p-7" data-testid="shipping-audit-center">
|
||||
<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>
|
||||
<section class="shipping-audit-page" data-testid="shipping-audit-center">
|
||||
<header class="page-header">
|
||||
<div class="page-heading-copy">
|
||||
<h1>{{ t('admin.shippingAudit.title') }}</h1>
|
||||
<!-- 段落行宽限制(原 max-w-3xl)保留,页面根限宽/内边距由壳层持有 -->
|
||||
<p class="page-desc">{{ t('admin.shippingAudit.subtitle') }}</p>
|
||||
</div>
|
||||
<!-- [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">
|
||||
<div class="page-actions">
|
||||
<el-button
|
||||
size="small"
|
||||
:icon="Refresh"
|
||||
:loading="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">
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
:loading="exporting"
|
||||
: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"
|
||||
</el-button>
|
||||
<div class="more-wrap">
|
||||
<el-button
|
||||
size="small"
|
||||
class="more-toggle"
|
||||
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">
|
||||
</el-button>
|
||||
<div class="more-panel" :class="{ 'more-panel--open': moreOpen }">
|
||||
<el-button size="small" :loading="verifying" :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">
|
||||
</el-button>
|
||||
<el-button size="small" @click="loadAssociationChain">
|
||||
{{ t('admin.shippingAudit.loadChain') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="grid gap-3 rounded-xl border border-default bg-surface p-3 md:grid-cols-3 lg:grid-cols-4">
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<div class="filters-panel">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.workflowId') }}</span>
|
||||
<input v-model="filters.workflow_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.workflow_id" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.workflowItemId') }}</span>
|
||||
<input v-model="filters.workflow_item_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.workflow_item_id" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.runNo') }}</span>
|
||||
<input v-model="filters.run_no" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.run_no" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.documentId') }}</span>
|
||||
<input v-model="filters.document_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.document_id" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.reviewCaseNo') }}</span>
|
||||
<input v-model="filters.review_case_no" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.review_case_no" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.taskNo') }}</span>
|
||||
<input v-model="filters.task_no" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.task_no" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.candidateNo') }}</span>
|
||||
<input
|
||||
<el-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">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.gateCode') }}</span>
|
||||
<input
|
||||
<el-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">
|
||||
<label class="filter-field">
|
||||
<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">{{ 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>
|
||||
<el-select v-model="filters.actor_type" @change="applyFilters">
|
||||
<el-option :label="t('admin.shippingAudit.filters.all')" value="" />
|
||||
<el-option :label="t('admin.shippingAudit.labels.actorTypes.user')" value="user" />
|
||||
<el-option :label="t('admin.shippingAudit.labels.actorTypes.admin')" value="admin" />
|
||||
<el-option :label="t('admin.shippingAudit.labels.actorTypes.system')" value="system" />
|
||||
<el-option :label="t('admin.shippingAudit.labels.actorTypes.rpa')" value="rpa" />
|
||||
</el-select>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.actorId') }}</span>
|
||||
<input v-model="filters.actor_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.actor_id" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.eventTypeGroup') }}</span>
|
||||
<select
|
||||
<el-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="formal_task_edit">{{ t('admin.shippingAudit.filters.eventTypeGroupFormalTaskEdit') }}</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>
|
||||
<option value="xfa_visual">{{ t('admin.shippingAudit.filters.eventTypeGroupXfaVisual') }}</option>
|
||||
<option value="xfa_split">{{ t('admin.shippingAudit.filters.eventTypeGroupXfaSplit') }}</option>
|
||||
<option value="xfa_unified">{{ t('admin.shippingAudit.filters.eventTypeGroupXfaUnified') }}</option>
|
||||
</select>
|
||||
<el-option :label="t('admin.shippingAudit.filters.all')" value="" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupReviewWorkbench')" value="review_workbench" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupFormalTaskEdit')" value="formal_task_edit" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupChatWorkbench')" value="chat_workbench" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupProcessGate')" value="process_gate" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupQualification')" value="candidate_qualification" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupWorkflowNode')" value="workflow_node" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupXfaVisual')" value="xfa_visual" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupXfaSplit')" value="xfa_split" />
|
||||
<el-option :label="t('admin.shippingAudit.filters.eventTypeGroupXfaUnified')" value="xfa_unified" />
|
||||
</el-select>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.profileId') }}</span>
|
||||
<input
|
||||
<el-input
|
||||
v-model="filters.profile_id"
|
||||
class="input-field text-sm"
|
||||
data-testid="shipping-audit-filter-profile-id"
|
||||
@keyup.enter="applyFilters"
|
||||
>
|
||||
/>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.bindingId') }}</span>
|
||||
<input
|
||||
<el-input
|
||||
v-model="filters.binding_id"
|
||||
class="input-field text-sm"
|
||||
data-testid="shipping-audit-filter-binding-id"
|
||||
@keyup.enter="applyFilters"
|
||||
>
|
||||
/>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.eventType') }}</span>
|
||||
<input v-model="filters.event_type" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.event_type" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<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">
|
||||
<el-input
|
||||
v-model="filters.reason_code"
|
||||
data-testid="shipping-audit-filter-reason-code"
|
||||
@keyup.enter="applyFilters"
|
||||
/>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.result') }}</span>
|
||||
<input v-model="filters.result" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
<el-input v-model="filters.result" @keyup.enter="applyFilters" />
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.createdFrom') }}</span>
|
||||
<input v-model="filters.created_from" type="datetime-local" class="input-field text-sm" @change="applyFilters">
|
||||
<!-- value-format 保持字符串契约,normalizeDateTimeFilter 逻辑不变 -->
|
||||
<el-date-picker
|
||||
v-model="filters.created_from"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm"
|
||||
@change="applyFilters"
|
||||
/>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<label class="filter-field">
|
||||
<span>{{ t('admin.shippingAudit.filters.createdTo') }}</span>
|
||||
<input v-model="filters.created_to" type="datetime-local" class="input-field text-sm" @change="applyFilters">
|
||||
<el-date-picker
|
||||
v-model="filters.created_to"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm"
|
||||
@change="applyFilters"
|
||||
/>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary md:col-span-2 lg:col-span-1">
|
||||
<label class="filter-field filter-field--wide">
|
||||
<span>{{ t('admin.shippingAudit.filters.q') }}</span>
|
||||
<div class="flex gap-2">
|
||||
<input v-model="filters.q" class="input-field text-sm flex-1" @keyup.enter="applyFilters">
|
||||
<button type="button" class="btn-secondary btn-sm" @click="applyFilters">{{ t('admin.shippingAudit.apply') }}</button>
|
||||
<div class="filter-q-row">
|
||||
<el-input
|
||||
v-model="filters.q"
|
||||
:prefix-icon="Search"
|
||||
clearable
|
||||
@keyup.enter="applyFilters"
|
||||
@clear="applyFilters"
|
||||
/>
|
||||
<el-button size="small" @click="applyFilters">{{ t('admin.shippingAudit.apply') }}</el-button>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<p v-if="chainHint" class="rounded-lg border border-default bg-surface-soft px-3 py-2 text-xs text-secondary">{{ chainHint }}</p>
|
||||
<p
|
||||
<el-alert v-if="chainHint" type="info" :closable="false" :title="chainHint" />
|
||||
<el-alert
|
||||
v-if="verifyResult"
|
||||
class="rounded-lg border border-default bg-surface-soft px-3 py-2 text-xs text-secondary"
|
||||
data-testid="shipping-audit-verify-result"
|
||||
>
|
||||
{{ t('admin.shippingAudit.verifySummary', {
|
||||
type="info"
|
||||
:closable="false"
|
||||
:title="t('admin.shippingAudit.verifySummary', {
|
||||
ok: verifyResult.ok ? t('admin.shippingAudit.verifyOk') : t('admin.shippingAudit.verifyFailedShort'),
|
||||
checked: verifyResult.checked_chains,
|
||||
failed: verifyResult.failed_chains,
|
||||
}) }}
|
||||
</p>
|
||||
<p v-if="error" class="rounded-lg border border-rose-200 bg-rose-50 p-3 text-sm text-rose-700">{{ error }}</p>
|
||||
})"
|
||||
data-testid="shipping-audit-verify-result"
|
||||
/>
|
||||
<el-alert v-if="error" type="error" :closable="false" :title="error" />
|
||||
|
||||
<!-- 窄屏卡片列表:避免 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"
|
||||
<div class="audit-panel audit-panel--mobile" data-testid="shipping-audit-card-list">
|
||||
<el-skeleton v-if="loading" :rows="5" animated />
|
||||
<el-empty
|
||||
v-else-if="!rows.length"
|
||||
:description="t('admin.shippingAudit.empty')"
|
||||
:image-size="60"
|
||||
/>
|
||||
<el-timeline v-else class="audit-timeline">
|
||||
<el-timeline-item
|
||||
v-for="row in rows"
|
||||
:key="row.id"
|
||||
:timestamp="formatTime(row.created_at)"
|
||||
placement="top"
|
||||
>
|
||||
<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="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="7" class="px-3 py-8 text-center text-muted">{{ t('admin.shippingAudit.loading') }}</td>
|
||||
</tr>
|
||||
<tr v-else-if="!rows.length">
|
||||
<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 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 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 class="audit-event">
|
||||
<div class="audit-event-head">
|
||||
<div class="audit-event-name">
|
||||
<strong>{{ businessLabel('eventTypes', row.event_type) }}</strong>
|
||||
<span class="audit-event-action">{{ businessLabel('actions', row.action) }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-2 align-top">
|
||||
<button type="button" class="text-brand-600 hover:underline" @click="openDetail(row.id)">
|
||||
<el-button link type="primary" @click="openDetail(row.id)">
|
||||
{{ t('admin.shippingAudit.diff') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<dl class="audit-event-meta">
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingAudit.columns.actor') }}:</dt>
|
||||
<dd>{{ businessLabel('actorTypes', row.actor_type) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingAudit.columns.reasonCode') }}:</dt>
|
||||
<dd class="audit-event-reason">{{ businessLabel('reasonCodes', row.reason_code) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingAudit.columns.result') }}:</dt>
|
||||
<dd>{{ businessLabel('results', row.result) }}</dd>
|
||||
</div>
|
||||
<div v-if="primaryBusinessRefs(row) !== '—'">
|
||||
<dt>{{ t('admin.shippingAudit.columns.businessRefs') }}:</dt>
|
||||
<dd>{{ primaryBusinessRefs(row) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div
|
||||
v-if="techRefChips(row).length"
|
||||
class="tech-chips"
|
||||
data-testid="shipping-audit-tech-ref-chips"
|
||||
>
|
||||
<span class="tech-chips-label">{{ t('admin.shippingAudit.techRefs') }}</span>
|
||||
<button
|
||||
v-for="item in techRefChips(row)"
|
||||
:key="`${row.id}-m-tech-${item.label}`"
|
||||
type="button"
|
||||
class="tech-chip"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</div>
|
||||
|
||||
<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>{{ 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 class="audit-panel audit-panel--desktop" data-testid="shipping-audit-desktop-table">
|
||||
<el-skeleton v-if="loading" :rows="5" animated />
|
||||
<el-empty
|
||||
v-else-if="!rows.length"
|
||||
:description="t('admin.shippingAudit.empty')"
|
||||
:image-size="60"
|
||||
/>
|
||||
<el-timeline v-else class="audit-timeline">
|
||||
<el-timeline-item
|
||||
v-for="row in rows"
|
||||
:key="row.id"
|
||||
:timestamp="formatTime(row.created_at)"
|
||||
placement="top"
|
||||
>
|
||||
<div class="audit-event">
|
||||
<div class="audit-event-head">
|
||||
<div class="audit-event-name">
|
||||
<strong>{{ businessLabel('eventTypes', row.event_type) }}</strong>
|
||||
<span class="audit-event-action">{{ businessLabel('actions', row.action) }}</span>
|
||||
</div>
|
||||
<el-button link type="primary" @click="openDetail(row.id)">
|
||||
{{ t('admin.shippingAudit.diff') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<dl class="audit-event-meta">
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingAudit.columns.actor') }}:</dt>
|
||||
<dd>{{ businessLabel('actorTypes', row.actor_type) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingAudit.columns.reasonCode') }}:</dt>
|
||||
<dd class="audit-event-reason">{{ businessLabel('reasonCodes', row.reason_code) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingAudit.columns.result') }}:</dt>
|
||||
<dd>{{ businessLabel('results', row.result) }}</dd>
|
||||
</div>
|
||||
<div v-if="primaryBusinessRefs(row) !== '—'">
|
||||
<dt>{{ t('admin.shippingAudit.columns.businessRefs') }}:</dt>
|
||||
<dd>{{ primaryBusinessRefs(row) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div
|
||||
v-if="techRefChips(row).length"
|
||||
class="tech-chips"
|
||||
data-testid="shipping-audit-tech-ref-chips"
|
||||
>
|
||||
<span class="tech-chips-label">{{ t('admin.shippingAudit.techRefs') }}</span>
|
||||
<button
|
||||
v-for="item in techRefChips(row)"
|
||||
:key="`${row.id}-tech-${item.label}`"
|
||||
type="button"
|
||||
class="tech-chip"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</div>
|
||||
|
||||
<div class="pagination-row">
|
||||
<span class="pagination-total">{{ t('admin.shippingAudit.total', { count: total }) }}</span>
|
||||
<el-button size="small" :disabled="page <= 1 || loading" @click="page -= 1; load()">
|
||||
{{ t('admin.shippingAudit.previous') }}
|
||||
</el-button>
|
||||
<span class="pagination-page">{{ pageLabel }}</span>
|
||||
<el-button size="small" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">
|
||||
{{ t('admin.shippingAudit.next') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<ShippingAuditEventDetailDrawer
|
||||
@@ -571,3 +634,283 @@ onMounted(() => {
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 全宽布局:水平内边距由 AdminLayout 壳层统一持有,页面只保留内部块间距 */
|
||||
.shipping-audit-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.page-heading-copy {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.page-desc {
|
||||
margin: 4px 0 0;
|
||||
max-width: 48rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* 页头操作区:相邻 el-button 间距统一交给 flex gap */
|
||||
.page-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.page-actions .el-button + .el-button,
|
||||
.more-panel .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
/* “更多”操作区:窄屏为下拉面板,md+ 常驻内联(与原 md:hidden / md:static 语义一致) */
|
||||
.more-wrap {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.more-panel {
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
top: calc(100% + 4px);
|
||||
right: 0;
|
||||
display: none;
|
||||
min-width: 176px;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 4px;
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 10px;
|
||||
background: var(--el-bg-color);
|
||||
padding: 4px;
|
||||
box-shadow: var(--el-box-shadow-light);
|
||||
}
|
||||
|
||||
.more-panel.more-panel--open {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.more-panel .el-button {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.more-toggle {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.more-panel,
|
||||
.more-panel.more-panel--open {
|
||||
position: static;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.more-panel .el-button {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* 筛选面板:md 3 列 / lg 4 列(原 md:grid-cols-3 lg:grid-cols-4) */
|
||||
.filters-panel {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.filter-field {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.filter-field :deep(.el-select),
|
||||
.filter-field :deep(.el-date-editor.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.filter-q-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.filter-q-row :deep(.el-input) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.filter-q-row .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.filters-panel {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.filter-field--wide {
|
||||
grid-column: span 2;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.filters-panel {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.filter-field--wide {
|
||||
grid-column: auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* 窄屏/桌面双列表容器:结构与 data-testid 契约保持,仅按 lg 断点切换可见性 */
|
||||
.audit-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.audit-panel--desktop {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.audit-panel--mobile {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.audit-panel--desktop {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.audit-timeline {
|
||||
padding: 4px 0 0 4px;
|
||||
}
|
||||
|
||||
.audit-event-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.audit-event-name {
|
||||
display: grid;
|
||||
min-width: 0;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.audit-event-name strong {
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.audit-event-action {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.audit-event-meta {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
margin: 8px 0 0;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.audit-event-meta dt {
|
||||
display: inline;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.audit-event-meta dd {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.audit-event-reason {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.tech-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.tech-chips-label {
|
||||
color: var(--el-text-color-placeholder);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.tech-chip {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 6px;
|
||||
background: var(--el-fill-color-lighter);
|
||||
padding: 2px 8px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tech-chip:hover {
|
||||
border-color: var(--el-color-primary-light-5);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.pagination-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.pagination-total {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.pagination-page {
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
+326
-138
@@ -1,14 +1,30 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-audit/ShippingAuditEventDetailDrawer.vue
|
||||
用途:审计事件详情抽屉——业务化元数据、敏感脱敏提示、白名单 Diff、XFA 快照引用、哈希摘要。
|
||||
依赖:shipping-audit.api 类型、shippingAuditDisplay、Vue I18n、useMessage。
|
||||
依赖:element-plus(el-drawer / el-alert / el-descriptions / el-collapse / el-skeleton,
|
||||
沿用管理端 element-trial 主题)、shipping-audit.api 类型、shippingAuditDisplay、
|
||||
useMessage、Vue I18n。
|
||||
逻辑:由 ShippingAuditCenterPage 传入 detail;事件/动作/结果与列表同源业务标签;
|
||||
展示 before/after checksum 与 XFA snapshot_ref;技术编号以复制芯片展示;
|
||||
若快照/metadata 含视觉绑定前后摘要则单独渲染;关闭时 emit close;不自行拉接口。
|
||||
若快照/metadata 含视觉绑定前后摘要则单独渲染;对外契约(props: detail/loading、
|
||||
emit: close)不变,开合仍由父级 detail/loading 派生,关闭统一走 emit close;
|
||||
迁移为 el-drawer(size 640px / resizable / destroy-on-close);不自行拉接口。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElAlert,
|
||||
ElCollapse,
|
||||
ElCollapseItem,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElDrawer,
|
||||
ElSkeleton,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { ShippingAuditEventDetail } from '@/features/admin/api/shipping-audit.api';
|
||||
import { shippingAuditBusinessLabel } from './shippingAuditDisplay';
|
||||
@@ -96,7 +112,7 @@ const visualBindingDiff = computed(() => {
|
||||
});
|
||||
|
||||
/**
|
||||
* 关闭抽屉。
|
||||
* 关闭抽屉(el-drawer 关闭意图统一回传父级,保持 emit close 契约)。
|
||||
*/
|
||||
function onClose() {
|
||||
emit('close');
|
||||
@@ -104,165 +120,337 @@ function onClose() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex justify-end bg-overlay"
|
||||
<el-drawer
|
||||
:model-value="open"
|
||||
size="640px"
|
||||
resizable
|
||||
destroy-on-close
|
||||
class="audit-detail-drawer"
|
||||
data-testid="shipping-audit-detail-drawer"
|
||||
@click.self="onClose"
|
||||
@update:model-value="onClose"
|
||||
>
|
||||
<aside class="h-full w-full max-w-xl overflow-y-auto bg-surface p-6 shadow-2xl">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-lg font-bold">{{ t('admin.shippingAudit.detailTitle') }}</h2>
|
||||
<button type="button" class="text-secondary" @click="onClose">{{ t('admin.close') }}</button>
|
||||
</div>
|
||||
<p v-if="loading" class="mt-6 text-muted">{{ t('admin.shippingAudit.loading') }}</p>
|
||||
<template v-else-if="detail">
|
||||
<p
|
||||
v-if="detail.sensitive_redacted"
|
||||
class="mt-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800"
|
||||
data-testid="shipping-audit-sensitive-redacted"
|
||||
>
|
||||
{{ t('admin.shippingAudit.sensitiveRedacted') }}
|
||||
</p>
|
||||
<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>
|
||||
<template #header>
|
||||
<h2 class="drawer-title">{{ t('admin.shippingAudit.detailTitle') }}</h2>
|
||||
</template>
|
||||
<el-skeleton v-if="loading" :rows="6" animated />
|
||||
<div v-else-if="detail" class="drawer-content">
|
||||
<el-alert
|
||||
v-if="detail.sensitive_redacted"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
:title="t('admin.shippingAudit.sensitiveRedacted')"
|
||||
data-testid="shipping-audit-sensitive-redacted"
|
||||
/>
|
||||
<el-descriptions :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingAudit.columns.event')">
|
||||
<div class="detail-primary" data-testid="shipping-audit-detail-event">
|
||||
{{ label('eventTypes', detail.event_type) }}
|
||||
</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 class="detail-sub">{{ label('actions', detail.action) }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingAudit.columns.actor')">
|
||||
<div data-testid="shipping-audit-detail-actor">
|
||||
{{ label('actorTypes', detail.actor_type) }}
|
||||
<span v-if="detail.actor_id" class="detail-sub"> · {{ t('admin.shippingAudit.copyId') }}</span>
|
||||
</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>
|
||||
<button
|
||||
v-if="detail.actor_id"
|
||||
type="button"
|
||||
class="copy-chip copy-chip--mono"
|
||||
:title="String(detail.actor_id)"
|
||||
@click="copyTechId(detail.actor_id)"
|
||||
>
|
||||
{{ detail.actor_id }}
|
||||
</button>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingAudit.columns.reasonCode')">
|
||||
{{ label('reasonCodes', detail.reason_code) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingAudit.columns.result')">
|
||||
<span data-testid="shipping-audit-detail-result">{{ label('results', detail.result) }}</span>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<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>
|
||||
<section class="detail-section" data-testid="shipping-audit-detail-tech-refs">
|
||||
<h3>{{ t('admin.shippingAudit.columns.refs') }}</h3>
|
||||
<p class="detail-hint">{{ t('admin.shippingAudit.techRefsHint') }}</p>
|
||||
<div v-if="techRefs.length" class="chip-row">
|
||||
<button
|
||||
v-for="item in techRefs"
|
||||
:key="`${item.label}-${item.value}`"
|
||||
type="button"
|
||||
class="copy-chip"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
<span class="copy-chip-label">{{ item.label }}</span>
|
||||
· {{ t('admin.shippingAudit.copyId') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-else class="detail-hint">—</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">
|
||||
<!-- 原生 details 迁移为 el-collapse -->
|
||||
<el-collapse class="hash-collapse">
|
||||
<el-collapse-item :title="t('admin.shippingAudit.hashSection')" name="hash">
|
||||
<dl class="hash-list">
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.eventHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]">{{ detail.event_hash || '—' }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.eventHash') }}</dt>
|
||||
<dd>{{ 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>
|
||||
<dt>{{ t('admin.shippingAudit.previousEventHash') }}</dt>
|
||||
<dd>{{ detail.previous_event_hash || '—' }}</dd>
|
||||
</div>
|
||||
<div v-if="detail.before_hash">
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.beforeHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]" data-testid="shipping-audit-before-hash">{{ detail.before_hash }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.beforeHash') }}</dt>
|
||||
<dd data-testid="shipping-audit-before-hash">{{ detail.before_hash }}</dd>
|
||||
</div>
|
||||
<div v-if="detail.after_hash">
|
||||
<dt class="text-muted">{{ t('admin.shippingAudit.afterHash') }}</dt>
|
||||
<dd class="break-all font-mono text-[10px]" data-testid="shipping-audit-after-hash">{{ detail.after_hash }}</dd>
|
||||
<dt>{{ t('admin.shippingAudit.afterHash') }}</dt>
|
||||
<dd data-testid="shipping-audit-after-hash">{{ detail.after_hash }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</details>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
|
||||
<section
|
||||
v-if="visualBindingDiff"
|
||||
class="mt-5"
|
||||
data-testid="shipping-audit-visual-binding-diff"
|
||||
>
|
||||
<h3 class="text-sm font-semibold">{{ t('admin.shippingAudit.visualBindingDiff') }}</h3>
|
||||
<p class="mt-1 text-[11px] text-muted">{{ t('admin.shippingAudit.visualBindingDiffHint') }}</p>
|
||||
<div class="mt-2 space-y-2 rounded-lg border border-default p-3 text-xs">
|
||||
<div>
|
||||
<div class="font-medium text-muted">{{ t('admin.shippingAudit.before') }}</div>
|
||||
<pre class="mt-1 whitespace-pre-wrap break-all">{{ visualBindingDiff.before == null ? '—' : JSON.stringify(visualBindingDiff.before, null, 2) }}</pre>
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-medium text-muted">{{ t('admin.shippingAudit.after') }}</div>
|
||||
<pre class="mt-1 whitespace-pre-wrap break-all">{{ visualBindingDiff.after == null ? '—' : JSON.stringify(visualBindingDiff.after, null, 2) }}</pre>
|
||||
</div>
|
||||
<section
|
||||
v-if="visualBindingDiff"
|
||||
class="detail-section"
|
||||
data-testid="shipping-audit-visual-binding-diff"
|
||||
>
|
||||
<h3>{{ t('admin.shippingAudit.visualBindingDiff') }}</h3>
|
||||
<p class="detail-hint">{{ t('admin.shippingAudit.visualBindingDiffHint') }}</p>
|
||||
<div class="panel-box">
|
||||
<div>
|
||||
<div class="detail-label">{{ t('admin.shippingAudit.before') }}</div>
|
||||
<pre class="code-block">{{ visualBindingDiff.before == null ? '—' : JSON.stringify(visualBindingDiff.before, null, 2) }}</pre>
|
||||
</div>
|
||||
</section>
|
||||
<div>
|
||||
<div class="detail-label">{{ t('admin.shippingAudit.after') }}</div>
|
||||
<pre class="code-block">{{ visualBindingDiff.after == null ? '—' : JSON.stringify(visualBindingDiff.after, null, 2) }}</pre>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="detail.xfa_snapshot_refs?.length"
|
||||
class="mt-5"
|
||||
data-testid="shipping-audit-xfa-snapshots"
|
||||
>
|
||||
<h3 class="text-sm font-semibold">{{ t('admin.shippingAudit.xfaSnapshots') }}</h3>
|
||||
<p class="mt-1 text-[11px] text-muted">{{ t('admin.shippingAudit.xfaSnapshotsHint') }}</p>
|
||||
<ul class="mt-2 space-y-2">
|
||||
<li
|
||||
v-for="ref in detail.xfa_snapshot_refs"
|
||||
:key="ref.snapshot_ref"
|
||||
class="rounded-lg border border-default px-3 py-2 text-xs"
|
||||
<section
|
||||
v-if="detail.xfa_snapshot_refs?.length"
|
||||
class="detail-section"
|
||||
data-testid="shipping-audit-xfa-snapshots"
|
||||
>
|
||||
<h3>{{ t('admin.shippingAudit.xfaSnapshots') }}</h3>
|
||||
<p class="detail-hint">{{ t('admin.shippingAudit.xfaSnapshotsHint') }}</p>
|
||||
<ul class="ref-list">
|
||||
<li
|
||||
v-for="ref in detail.xfa_snapshot_refs"
|
||||
:key="ref.snapshot_ref"
|
||||
class="panel-box"
|
||||
>
|
||||
<div class="detail-primary">{{ ref.purpose }}</div>
|
||||
<button
|
||||
type="button"
|
||||
class="copy-chip copy-chip--mono"
|
||||
:title="ref.snapshot_ref"
|
||||
data-testid="shipping-audit-xfa-snapshot-ref"
|
||||
@click="copyTechId(ref.snapshot_ref)"
|
||||
>
|
||||
<div class="font-medium">{{ ref.purpose }}</div>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-1 rounded border border-default px-2 py-0.5 font-mono text-[11px] text-muted"
|
||||
:title="ref.snapshot_ref"
|
||||
data-testid="shipping-audit-xfa-snapshot-ref"
|
||||
@click="copyTechId(ref.snapshot_ref)"
|
||||
>
|
||||
{{ t('admin.shippingAudit.copyId') }} · {{ ref.snapshot_ref.slice(0, 12) }}…
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
{{ t('admin.shippingAudit.copyId') }} · {{ ref.snapshot_ref.slice(0, 12) }}…
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<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 class="detail-section">
|
||||
<h3>{{ t('admin.shippingAudit.diff') }}</h3>
|
||||
<div v-if="detail.diff?.length" class="diff-rows" data-testid="shipping-audit-diff-rows">
|
||||
<div
|
||||
v-for="row in detail.diff"
|
||||
:key="row.key"
|
||||
class="rounded-lg border border-default p-3 text-xs"
|
||||
class="panel-box diff-row"
|
||||
>
|
||||
<div class="font-medium">{{ row.key }} · {{ row.change }}</div>
|
||||
<div class="mt-1 text-muted">{{ t('admin.shippingAudit.before') }}: {{ row.before == null ? '—' : JSON.stringify(row.before) }}</div>
|
||||
<div class="text-muted">{{ t('admin.shippingAudit.after') }}: {{ row.after == null ? '—' : JSON.stringify(row.after) }}</div>
|
||||
<div class="detail-primary">{{ row.key }} · {{ row.change }}</div>
|
||||
<div class="detail-hint">{{ t('admin.shippingAudit.before') }}: {{ row.before == null ? '—' : JSON.stringify(row.before) }}</div>
|
||||
<div class="detail-hint">{{ t('admin.shippingAudit.after') }}: {{ row.after == null ? '—' : JSON.stringify(row.after) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="mt-2 text-sm text-muted">{{ t('admin.shippingAudit.noDiff') }}</p>
|
||||
</template>
|
||||
</aside>
|
||||
</div>
|
||||
<p v-else class="detail-hint">{{ t('admin.shippingAudit.noDiff') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.drawer-title {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 17px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.drawer-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.detail-section {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.detail-section h3 {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detail-hint {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.detail-primary {
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.detail-sub {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.detail-label {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.chip-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
/* 复制芯片:技术编号点击复制,保留 title 提示 */
|
||||
.copy-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
max-width: 100%;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 6px;
|
||||
background: var(--el-bg-color);
|
||||
padding: 3px 8px;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.copy-chip:hover {
|
||||
border-color: var(--el-color-primary-light-5);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.copy-chip-label {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.copy-chip--mono {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/* 哈希摘要折叠区:原生 details 迁移 el-collapse */
|
||||
.hash-collapse {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
padding: 0 12px;
|
||||
}
|
||||
|
||||
.hash-collapse :deep(.el-collapse-item__header) {
|
||||
height: 36px;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.hash-collapse :deep(.el-collapse-item__wrap) {
|
||||
border-bottom: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.hash-collapse :deep(.el-collapse-item__content) {
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
.hash-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.hash-list dt {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.hash-list dd {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-regular);
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.panel-box {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.code-block {
|
||||
margin: 6px 0 0;
|
||||
max-height: 12rem;
|
||||
overflow: auto;
|
||||
border-radius: 6px;
|
||||
background: var(--el-fill-color-light);
|
||||
padding: 8px;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.ref-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.ref-list .panel-box {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
justify-items: start;
|
||||
}
|
||||
|
||||
.diff-rows {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.diff-row {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
</style>
|
||||
+640
-286
File diff suppressed because it is too large.
Load diff
+140
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-field-assets/__tests__/ShippingFieldAssetsPage.spec.ts
|
||||
* 用途:字段资产库 EP 迁移后的冒烟契约——工具栏一行化控件、主从工作台渲染、
|
||||
* 详情(descriptions/tag/alert)、新建与弃用对话框、审计时间线。
|
||||
* 依赖:@vue/test-utils、vitest、@/i18n、shipping-field-assets.api(mock)。
|
||||
* 逻辑:mock API 返回一条系统标准 + 一条扩展字段;断言 EP 组件结构与关键交互路径,
|
||||
* 不锁样式细节。
|
||||
*/
|
||||
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import ShippingFieldAssetsPage from '../ShippingFieldAssetsPage.vue';
|
||||
|
||||
const apiMocks = vi.hoisted(() => ({
|
||||
listShippingFieldAssets: vi.fn(),
|
||||
getShippingFieldAsset: vi.fn(),
|
||||
getShippingFieldAssetImpact: vi.fn(),
|
||||
listShippingFieldAssetAudits: vi.fn(),
|
||||
createShippingFieldExtension: vi.fn(),
|
||||
updateShippingFieldExtension: vi.fn(),
|
||||
retireShippingFieldExtension: vi.fn(),
|
||||
restoreShippingFieldExtension: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/admin/api/shipping-field-assets.api', async () => {
|
||||
const actual = await vi.importActual<Record<string, unknown>>(
|
||||
'@/features/admin/api/shipping-field-assets.api',
|
||||
);
|
||||
return { ...actual, ...apiMocks };
|
||||
});
|
||||
|
||||
enableAutoUnmount(afterEach);
|
||||
|
||||
const standardAsset = {
|
||||
id: 'std-1',
|
||||
field_code: 'customer_po_number',
|
||||
display_name_default: '客户 PO 号',
|
||||
asset_kind: 'system_standard',
|
||||
status: 'active',
|
||||
scope: 'header',
|
||||
value_type: 'string',
|
||||
storage_kind: 'typed_column',
|
||||
storage_path: 'customer_po_number',
|
||||
adoption_summary: { published: 1, draft: 0 },
|
||||
adoptions: [],
|
||||
updated_at: null,
|
||||
};
|
||||
const extensionAsset = {
|
||||
id: 'ext-1',
|
||||
field_code: 'wtp_special_flag',
|
||||
display_name_default: 'WTP 专用标记',
|
||||
asset_kind: 'extension',
|
||||
status: 'active',
|
||||
scope: 'line',
|
||||
value_type: 'boolean',
|
||||
storage_kind: 'extension_json',
|
||||
storage_path: 'extensions.wtp_special_flag',
|
||||
adoption_summary: { published: 0, draft: 1 },
|
||||
adoptions: [],
|
||||
updated_at: '2026-10-14T00:00:00',
|
||||
};
|
||||
|
||||
const mountPage = async () => {
|
||||
const wrapper = mount(ShippingFieldAssetsPage, { global: { plugins: [i18n] } });
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
describe('ShippingFieldAssetsPage EP 迁移冒烟', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
apiMocks.listShippingFieldAssets.mockResolvedValue({ items: [standardAsset, extensionAsset] });
|
||||
apiMocks.getShippingFieldAsset.mockImplementation(async (id: string) => (
|
||||
id === 'std-1' ? standardAsset : extensionAsset
|
||||
));
|
||||
apiMocks.getShippingFieldAssetImpact.mockResolvedValue({
|
||||
blocking_count: 0,
|
||||
blocking_items: [],
|
||||
blocking_kinds: [],
|
||||
historical: { observation_count: 61, immutable_schema_version_count: 3 },
|
||||
});
|
||||
apiMocks.listShippingFieldAssetAudits.mockResolvedValue({
|
||||
items: [{
|
||||
id: 'audit-1',
|
||||
event_type: 'created',
|
||||
actor_display_name: '管理员',
|
||||
request_id: 'req-1',
|
||||
created_at: '2026-10-14T10:00:00',
|
||||
change_summary: { action: 'create' },
|
||||
before: null,
|
||||
after: { field_code: 'wtp_special_flag' },
|
||||
}],
|
||||
});
|
||||
});
|
||||
|
||||
it('工具栏渲染 EP 控件且列表分组呈现两条资产', async () => {
|
||||
const wrapper = await mountPage();
|
||||
// 关键断言:EP 工具栏(搜索/两个筛选/刷新)与主从工作台列表分组齐全
|
||||
expect(wrapper.find('.toolbar .el-input').exists()).toBe(true);
|
||||
expect(wrapper.findAll('.toolbar .el-select')).toHaveLength(2);
|
||||
expect(wrapper.findAll('.toolbar .el-button').length).toBeGreaterThan(0);
|
||||
expect(wrapper.find('.assets-workbench .list-panel').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('客户 PO 号');
|
||||
expect(wrapper.text()).toContain('WTP 专用标记');
|
||||
});
|
||||
|
||||
it('选中扩展字段:详情 descriptions/tag 渲染且出现弃用操作', async () => {
|
||||
const wrapper = await mountPage();
|
||||
// 关键断言:详情走 EP descriptions + 状态 tag + 扩展编辑卡(弃用按钮)
|
||||
const listItems = wrapper.findAll('.list-item');
|
||||
await listItems[1].trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('.detail-panel .el-descriptions').exists()).toBe(true);
|
||||
expect(wrapper.find('.detail-panel .el-tag').exists()).toBe(true);
|
||||
expect(wrapper.find('.edit-card').exists()).toBe(true);
|
||||
expect(wrapper.find('.edit-card').text()).toContain('弃用');
|
||||
// 弃用打开原因对话框(EP dialog),审计时间线渲染
|
||||
await wrapper.find('.edit-card .el-button--danger').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('.el-dialog').exists()).toBe(true);
|
||||
expect(wrapper.find('.audit-timeline').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('新建扩展字段对话框可打开并提交调用 API', async () => {
|
||||
const wrapper = await mountPage();
|
||||
apiMocks.createShippingFieldExtension.mockResolvedValue({ ...extensionAsset, id: 'ext-2' });
|
||||
await wrapper.find('.page-header .el-button--primary').trigger('click');
|
||||
await flushPromises();
|
||||
// 关键断言:el-dialog 打开且表单控件为 EP 组件(两个输入 + 语义 textarea + 两个下拉)
|
||||
const dialog = wrapper.find('.el-dialog');
|
||||
expect(dialog.exists()).toBe(true);
|
||||
expect(dialog.findAll('.el-input').length).toBeGreaterThanOrEqual(2);
|
||||
expect(dialog.find('.el-textarea').exists()).toBe(true);
|
||||
expect(dialog.findAll('.el-select').length).toBe(2);
|
||||
await dialog.find('input').setValue('new_field');
|
||||
await dialog.find('.el-button--primary').trigger('click');
|
||||
await flushPromises();
|
||||
expect(apiMocks.createShippingFieldExtension).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
+80
-73
@@ -1,12 +1,18 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-field-assets/components/FieldImpactDrawer.vue
|
||||
用途:展示单字段影响分析(阻断对象明细/警告/历史只读),资产库与 Schema 页共用。
|
||||
依赖:ShippingFieldAssetImpact DTO、Vue I18n、Vue Router。
|
||||
逻辑:只读抽屉;列出具体配置对象与引用位置;不含订单正文或证据原文。
|
||||
依赖:element-plus(el-drawer 抽屉/el-skeleton 骨架/el-button 链接按钮,沿用管理端 element-trial 主题)、
|
||||
ShippingFieldAssetImpact DTO、Vue I18n、Vue Router。
|
||||
逻辑:只读抽屉(视觉层已迁移 Element Plus,v-model 对外契约保持不变);
|
||||
列出具体配置对象与引用位置;不含订单正文或证据原文。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ElButton, ElDrawer, ElSkeleton } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { ShippingFieldAssetImpact, ShippingFieldImpactItem } from '@/features/admin/types/shipping-field-assets.types';
|
||||
|
||||
defineProps<{
|
||||
@@ -39,80 +45,81 @@ function openAdminPath(item: ShippingFieldImpactItem): void {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="modelValue" class="impact-overlay" @click.self="$emit('update:modelValue', false)">
|
||||
<aside class="impact-drawer" role="dialog" aria-modal="true">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingFieldAssets.impactTitle') }}</h2>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="$emit('update:modelValue', false)">{{ t('common.close') }}</button>
|
||||
</header>
|
||||
<div v-if="loading" class="impact-loading">{{ t('common.loading') }}</div>
|
||||
<template v-else-if="impact">
|
||||
<section v-if="impact.blocking_items?.length" class="impact-section blocked">
|
||||
<h3>{{ t('admin.shippingFieldAssets.impactBlocked') }}</h3>
|
||||
<p class="muted">{{ t('admin.shippingFieldAssets.blockingCount', { count: impact.blocking_count }) }}</p>
|
||||
<ul class="object-list">
|
||||
<li v-for="item in impact.blocking_items" :key="`${item.kind}-${item.object_id}-${item.reference_path}`">
|
||||
<strong>{{ blockingLabel(item.kind) }} · {{ item.display_name }}</strong>
|
||||
<small>
|
||||
#{{ item.object_id }}
|
||||
<template v-if="item.version != null"> · v{{ item.version }}</template>
|
||||
· {{ item.status }}
|
||||
</small>
|
||||
<code>{{ item.reference_path }}</code>
|
||||
<button
|
||||
v-if="item.admin_path"
|
||||
type="button"
|
||||
class="link-button"
|
||||
@click="openAdminPath(item)"
|
||||
>
|
||||
{{ t('admin.shippingFieldAssets.impactOpenTarget') }}
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section v-else class="impact-section ok">
|
||||
<p>{{ t('admin.shippingFieldAssets.impactNoBlocking') }}</p>
|
||||
</section>
|
||||
<section class="impact-section historical">
|
||||
<h3>{{ t('admin.shippingFieldAssets.impactHistorical') }}</h3>
|
||||
<ul>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalVersions', { count: impact.historical.immutable_schema_version_count }) }}</li>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalObservations', { count: impact.historical.observation_count }) }}</li>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalValues', { count: impact.historical.value_count }) }}</li>
|
||||
</ul>
|
||||
<ul v-if="impact.historical.immutable_schema_versions?.length" class="object-list compact">
|
||||
<li
|
||||
v-for="item in impact.historical.immutable_schema_versions"
|
||||
:key="item.schema_version_id"
|
||||
<el-drawer
|
||||
:model-value="modelValue"
|
||||
:title="t('admin.shippingFieldAssets.impactTitle')"
|
||||
size="640px"
|
||||
resizable
|
||||
destroy-on-close
|
||||
@update:model-value="$emit('update:modelValue', $event)"
|
||||
>
|
||||
<div v-if="loading" class="impact-loading">
|
||||
<el-skeleton :rows="5" animated />
|
||||
</div>
|
||||
<template v-else-if="impact">
|
||||
<section v-if="impact.blocking_items?.length" class="impact-section blocked">
|
||||
<h3>{{ t('admin.shippingFieldAssets.impactBlocked') }}</h3>
|
||||
<p class="muted">{{ t('admin.shippingFieldAssets.blockingCount', { count: impact.blocking_count }) }}</p>
|
||||
<ul class="object-list">
|
||||
<li v-for="item in impact.blocking_items" :key="`${item.kind}-${item.object_id}-${item.reference_path}`">
|
||||
<strong>{{ blockingLabel(item.kind) }} · {{ item.display_name }}</strong>
|
||||
<small>
|
||||
#{{ item.object_id }}
|
||||
<template v-if="item.version != null"> · v{{ item.version }}</template>
|
||||
· {{ item.status }}
|
||||
</small>
|
||||
<code>{{ item.reference_path }}</code>
|
||||
<el-button
|
||||
v-if="item.admin_path"
|
||||
link
|
||||
type="primary"
|
||||
class="link-button"
|
||||
@click="openAdminPath(item)"
|
||||
>
|
||||
{{ item.schema_display_name || item.schema_code || 'Schema' }}
|
||||
V{{ item.version }} ({{ item.status }})
|
||||
</li>
|
||||
</ul>
|
||||
<small>{{ t('admin.shippingFieldAssets.impactHistoricalHint') }}</small>
|
||||
</section>
|
||||
</template>
|
||||
</aside>
|
||||
</div>
|
||||
{{ t('admin.shippingFieldAssets.impactOpenTarget') }}
|
||||
</el-button>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section v-else class="impact-section ok">
|
||||
<p>{{ t('admin.shippingFieldAssets.impactNoBlocking') }}</p>
|
||||
</section>
|
||||
<section class="impact-section historical">
|
||||
<h3>{{ t('admin.shippingFieldAssets.impactHistorical') }}</h3>
|
||||
<ul>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalVersions', { count: impact.historical.immutable_schema_version_count }) }}</li>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalObservations', { count: impact.historical.observation_count }) }}</li>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalValues', { count: impact.historical.value_count }) }}</li>
|
||||
</ul>
|
||||
<ul v-if="impact.historical.immutable_schema_versions?.length" class="object-list compact">
|
||||
<li
|
||||
v-for="item in impact.historical.immutable_schema_versions"
|
||||
:key="item.schema_version_id"
|
||||
>
|
||||
{{ item.schema_display_name || item.schema_code || 'Schema' }}
|
||||
V{{ item.version }} ({{ item.status }})
|
||||
</li>
|
||||
</ul>
|
||||
<small>{{ t('admin.shippingFieldAssets.impactHistoricalHint') }}</small>
|
||||
</section>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.impact-overlay { position: fixed; z-index: 60; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 38%); }
|
||||
.impact-drawer { display: grid; width: min(520px, 96vw); height: 100%; grid-template-rows: auto 1fr; gap: 12px; overflow: hidden; background: #fff; padding: 18px; box-shadow: -12px 0 40px rgb(15 23 42 / 18%); }
|
||||
.impact-drawer header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.impact-drawer h2, .impact-drawer h3 { margin: 0; color: #1e293b; font-size: 15px; }
|
||||
.impact-drawer h3 { font-size: 13px; }
|
||||
.link-button { border: 0; background: transparent; color: #64748b; font: inherit; font-size: 13px; cursor: pointer; }
|
||||
.link-button { color: #1d4ed8; padding: 0; text-align: left; }
|
||||
.impact-loading, .muted { color: #64748b; font-size: 13px; }
|
||||
.impact-section { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; overflow-y: auto; }
|
||||
.impact-section.blocked { border-color: #fecaca; background: #fef2f2; }
|
||||
.impact-section.ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; font-size: 13px; }
|
||||
.impact-section.historical { background: #f8fafc; }
|
||||
.impact-section ul { margin: 8px 0 0; padding-left: 18px; color: #475569; font-size: 12px; }
|
||||
.impact-loading, .muted { margin: 0; color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.impact-section { border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 12px; overflow-y: auto; }
|
||||
.impact-section.blocked { border-color: var(--el-color-danger-light-5); background: var(--el-color-danger-light-9); }
|
||||
.impact-section.ok { border-color: var(--el-color-success-light-5); background: var(--el-color-success-light-9); color: var(--el-color-success-dark-2); font-size: 13px; }
|
||||
.impact-section.ok p { margin: 0; }
|
||||
.impact-section.historical { background: var(--el-fill-color-light); }
|
||||
.impact-section h3 { margin: 0; color: var(--el-text-color-primary); font-size: 13px; }
|
||||
.impact-section ul { margin: 8px 0 0; padding-left: 18px; color: var(--el-text-color-regular); font-size: 12px; }
|
||||
.object-list { list-style: none; padding-left: 0 !important; display: grid; gap: 0.75rem; }
|
||||
.object-list li { display: grid; gap: 0.2rem; border: 1px solid #fecaca; border-radius: 0.5rem; background: #fff; padding: 0.65rem 0.75rem; }
|
||||
.object-list.compact li { border-color: #e2e8f0; }
|
||||
.object-list small, .object-list code { color: #64748b; font-size: 11px; word-break: break-all; }
|
||||
.impact-section small { display: block; margin-top: 8px; color: #94a3b8; font-size: 11px; line-height: 1.4; }
|
||||
.object-list li { display: grid; gap: 0.2rem; justify-items: start; border: 1px solid var(--el-color-danger-light-5); border-radius: 0.5rem; background: var(--el-bg-color); padding: 0.65rem 0.75rem; }
|
||||
.object-list.compact li { border-color: var(--el-border-color-lighter); }
|
||||
.object-list li strong { color: var(--el-text-color-primary); font-size: 12px; }
|
||||
.object-list small, .object-list code { color: var(--el-text-color-secondary); font-size: 12px; word-break: break-all; }
|
||||
.link-button { padding: 0; }
|
||||
.impact-section small { display: block; margin-top: 8px; color: var(--el-text-color-placeholder); font-size: 12px; line-height: 1.4; }
|
||||
</style>
|
||||
+200
-95
@@ -1,14 +1,42 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-identity-rules/ShippingIdentityRulesPage.vue
|
||||
用途:维护引用已发布订单上下文字段的客户/送货站点识别定义,并发布不可变规则集。
|
||||
依赖:规则 API、Vue Composition API、Vue I18n。
|
||||
逻辑:管理员只能选择服务端提供的已发布识别字段,运行时只消费该字段的已裁决值。
|
||||
依赖:element-plus(按钮/表单控件/标签/空态/骨架屏,沿用管理端 element-trial 主题)、
|
||||
shipping-identity-rules.api、BusinessError、useMessage、Vue I18n。
|
||||
逻辑:管理员只能选择服务端提供的已发布识别字段,运行时只消费该字段的已裁决值;
|
||||
业务脚本(目录/规则集加载、定义保存与自动化授权、草稿保存与发布)保持原逻辑
|
||||
不变,仅视觉层从手写控件迁移 Element Plus(与在途调拨类型页同一范式)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ArrowUpRight, Check, CircleDotDashed, CircleHelp, FileCheck2, Layers3, Plus, Send, Tags } from 'lucide-vue-next';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElCheckboxGroup,
|
||||
ElEmpty,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSkeleton,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import {
|
||||
Check,
|
||||
Collection,
|
||||
CollectionTag,
|
||||
DocumentChecked,
|
||||
Plus,
|
||||
Promotion,
|
||||
QuestionFilled,
|
||||
TopRight,
|
||||
} from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
@@ -211,8 +239,8 @@ onMounted(() => { void load(); });
|
||||
<section class="identity-rules-page">
|
||||
<header class="identity-hero">
|
||||
<div>
|
||||
<h1 class="section-title">{{ t('admin.shippingIdentityRules.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingIdentityRules.subtitle') }}</p>
|
||||
<h1 class="page-title">{{ t('admin.shippingIdentityRules.title') }}</h1>
|
||||
<p class="page-desc">{{ t('admin.shippingIdentityRules.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="identity-hero__meta">
|
||||
<div class="identity-hero__status">
|
||||
@@ -220,9 +248,10 @@ onMounted(() => { void load(); });
|
||||
<span v-if="publishedRuleSet">V{{ publishedRuleSet.version }} · {{ t('admin.shippingIdentityRules.status.published') }}</span>
|
||||
<span v-else>{{ t('admin.shippingIdentityRules.status.draft') }}</span>
|
||||
</div>
|
||||
<button type="button" class="btn-ghost identity-hero__link" @click="openCustomerMaster">
|
||||
{{ t('admin.shippingIdentityRules.openCustomerMaster') }}<ArrowUpRight class="h-4 w-4" />
|
||||
</button>
|
||||
<el-button @click="openCustomerMaster">
|
||||
{{ t('admin.shippingIdentityRules.openCustomerMaster') }}
|
||||
<TopRight class="identity-ico identity-hero__link-icon" />
|
||||
</el-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -233,43 +262,90 @@ onMounted(() => { void load(); });
|
||||
<div class="identity-flow__step"><span>03</span><div><strong>{{ t('admin.shippingIdentityRules.openCustomerMaster') }}</strong><small>{{ t('admin.shippingIdentityRules.workflowHint') }}</small></div></div>
|
||||
</section>
|
||||
|
||||
<p v-if="loading" class="identity-loading"><CircleDotDashed class="h-4 w-4 animate-spin" />{{ t('admin.shippingIdentityRules.loading') }}</p>
|
||||
<el-skeleton v-if="loading" class="identity-loading" :rows="6" animated />
|
||||
|
||||
<div v-else class="identity-workbench">
|
||||
<section class="identity-panel identity-panel--definitions">
|
||||
<div class="identity-panel__heading">
|
||||
<div><p class="identity-panel__eyebrow"><Tags class="h-4 w-4" />{{ t('admin.shippingIdentityRules.definitions') }}</p><h3>{{ activeDefinitions.length }}</h3></div>
|
||||
<div><p class="identity-panel__eyebrow"><CollectionTag class="identity-ico" />{{ t('admin.shippingIdentityRules.definitions') }}</p><h3>{{ activeDefinitions.length }}</h3></div>
|
||||
<p>{{ t('admin.shippingIdentityRules.definitionHint') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="catalog?.definitions.length" class="identity-definition-list">
|
||||
<article v-for="definition in catalog.definitions" :key="definition.id" class="identity-definition-row">
|
||||
<div class="identity-definition-row__icon"><Tags class="h-4 w-4" /></div>
|
||||
<div class="min-w-0"><strong>{{ definition.display_name }}</strong><p>{{ definition.description || sourceDisplay(definition) }}</p></div>
|
||||
<span class="identity-target">{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</span>
|
||||
<select class="identity-automation identity-automation-select" :class="{ 'identity-automation--enabled': definition.max_automation === 'conditional' }" :value="definition.max_automation" :disabled="saving" @change="updateDefinitionAutomation(definition, ($event.target as HTMLSelectElement).value as 'none' | 'conditional')"><option value="none">{{ t('admin.shippingIdentityRules.automations.none') }}</option><option value="conditional">{{ t('admin.shippingIdentityRules.automations.conditional') }}</option></select>
|
||||
<div class="identity-definition-row__icon"><CollectionTag class="identity-ico" /></div>
|
||||
<div class="identity-definition-row__copy"><strong>{{ definition.display_name }}</strong><p>{{ definition.description || sourceDisplay(definition) }}</p></div>
|
||||
<el-tag type="info" size="small" effect="plain">{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</el-tag>
|
||||
<!-- 受控回显 + @change 即保存:保存失败时展示值自动回落到服务端快照 -->
|
||||
<el-select
|
||||
class="identity-automation-select"
|
||||
size="small"
|
||||
:model-value="definition.max_automation"
|
||||
:class="{ 'identity-automation--enabled': definition.max_automation === 'conditional' }"
|
||||
:disabled="saving"
|
||||
@change="(value) => updateDefinitionAutomation(definition, value)"
|
||||
>
|
||||
<el-option value="none" :label="t('admin.shippingIdentityRules.automations.none')" />
|
||||
<el-option value="conditional" :label="t('admin.shippingIdentityRules.automations.conditional')" />
|
||||
</el-select>
|
||||
</article>
|
||||
</div>
|
||||
<div v-else class="identity-empty"><Tags class="h-5 w-5" /><span>{{ t('admin.shippingIdentityRules.definitionHint') }}</span></div>
|
||||
<el-empty v-else class="identity-empty" :image-size="60" :description="t('admin.shippingIdentityRules.definitionHint')" />
|
||||
|
||||
<form class="identity-definition-form" @submit.prevent="saveDefinition">
|
||||
<div class="identity-form-title"><Plus class="h-4 w-4" /><strong>{{ t('admin.shippingIdentityRules.addDefinition') }}</strong></div>
|
||||
<el-form class="identity-definition-form" label-position="top" @submit.prevent="saveDefinition">
|
||||
<div class="identity-form-title"><Plus class="identity-ico" /><strong>{{ t('admin.shippingIdentityRules.addDefinition') }}</strong></div>
|
||||
<p class="identity-form-guide">{{ t('admin.shippingIdentityRules.formGuide') }}</p>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.displayName') }}</span><input v-model="form.display_name" required class="input-field" :placeholder="t('admin.shippingIdentityRules.displayNamePlaceholder')"></label>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.selectField') }}</span><select v-model="form.context_field_id" required class="input-field"><option value="">{{ t('admin.shippingIdentityRules.selectField') }}</option><option v-for="field in catalog?.context_fields" :key="field.field_id" :value="field.field_id">{{ field.display_name }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.target') }}</span><select v-model="form.target_type" class="input-field"><option value="customer">{{ t('admin.shippingIdentityRules.targets.customer') }}</option><option value="site">{{ t('admin.shippingIdentityRules.targets.site') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.evidenceLabel') }}</span><input v-model="form.evidence_label" required class="input-field" :placeholder="t('admin.shippingIdentityRules.evidenceLabelPlaceholder')"></label>
|
||||
<label><span>{{ t('admin.shippingIdentityRules.description') }}</span><input v-model="form.description" class="input-field" :placeholder="t('admin.shippingIdentityRules.descriptionPlaceholder')"></label>
|
||||
<label><span class="identity-label-with-tip">{{ t('admin.shippingIdentityRules.automationPolicy') }}<CircleHelp class="identity-label-tip" :title="t('admin.shippingIdentityRules.automationPolicyHint')" :aria-label="t('admin.shippingIdentityRules.automationPolicyHint')" /></span><select v-model="form.max_automation" class="input-field"><option value="none">{{ t('admin.shippingIdentityRules.automations.none') }}</option><option value="conditional">{{ t('admin.shippingIdentityRules.automations.conditional') }}</option></select></label>
|
||||
<el-form-item :label="t('admin.shippingIdentityRules.displayName')">
|
||||
<el-input v-model="form.display_name" required :placeholder="t('admin.shippingIdentityRules.displayNamePlaceholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.shippingIdentityRules.selectField')">
|
||||
<el-select v-model="form.context_field_id">
|
||||
<el-option value="" :label="t('admin.shippingIdentityRules.selectField')" />
|
||||
<el-option v-for="field in catalog?.context_fields" :key="field.field_id" :value="field.field_id" :label="field.display_name" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.shippingIdentityRules.target')">
|
||||
<el-select v-model="form.target_type">
|
||||
<el-option value="customer" :label="t('admin.shippingIdentityRules.targets.customer')" />
|
||||
<el-option value="site" :label="t('admin.shippingIdentityRules.targets.site')" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.shippingIdentityRules.evidenceLabel')">
|
||||
<el-input v-model="form.evidence_label" required :placeholder="t('admin.shippingIdentityRules.evidenceLabelPlaceholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.shippingIdentityRules.description')">
|
||||
<el-input v-model="form.description" :placeholder="t('admin.shippingIdentityRules.descriptionPlaceholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<span class="identity-label-with-tip">
|
||||
{{ t('admin.shippingIdentityRules.automationPolicy') }}
|
||||
<QuestionFilled class="identity-label-tip" :title="t('admin.shippingIdentityRules.automationPolicyHint')" :aria-label="t('admin.shippingIdentityRules.automationPolicyHint')" />
|
||||
</span>
|
||||
</template>
|
||||
<el-select v-model="form.max_automation">
|
||||
<el-option value="none" :label="t('admin.shippingIdentityRules.automations.none')" />
|
||||
<el-option value="conditional" :label="t('admin.shippingIdentityRules.automations.conditional')" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="identity-source-help"><strong>{{ t('admin.shippingIdentityRules.selectionResult') }}</strong><span>{{ selectedSourceHint }}</span><small>{{ t(`admin.shippingIdentityRules.automations.${selectedAutomation}`) }}</small></div>
|
||||
<button type="submit" class="btn-primary identity-definition-form__submit" :disabled="saving || !form.context_field_id"><Plus class="h-4 w-4" />{{ t('admin.shippingIdentityRules.addDefinition') }}</button>
|
||||
</form>
|
||||
<el-button
|
||||
type="primary"
|
||||
native-type="submit"
|
||||
class="identity-definition-form__submit"
|
||||
:icon="Plus"
|
||||
:loading="saving"
|
||||
:disabled="saving || !form.context_field_id"
|
||||
>
|
||||
{{ t('admin.shippingIdentityRules.addDefinition') }}
|
||||
</el-button>
|
||||
</el-form>
|
||||
</section>
|
||||
|
||||
<aside class="identity-panel identity-panel--publication">
|
||||
<div class="identity-publication__header">
|
||||
<div class="identity-panel__eyebrow"><Layers3 class="h-4 w-4" />{{ t('admin.shippingIdentityRules.ruleSets') }}</div>
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="saving" @click="createDraft"><Plus class="h-4 w-4" />{{ t('admin.shippingIdentityRules.createDraft') }}</button>
|
||||
<div class="identity-panel__eyebrow"><Collection class="identity-ico" />{{ t('admin.shippingIdentityRules.ruleSets') }}</div>
|
||||
<el-button size="small" :icon="Plus" :disabled="saving" @click="createDraft">{{ t('admin.shippingIdentityRules.createDraft') }}</el-button>
|
||||
</div>
|
||||
<p class="identity-publication__hint">{{ t('admin.shippingIdentityRules.ruleSetHint') }}</p>
|
||||
|
||||
@@ -281,17 +357,20 @@ onMounted(() => { void load(); });
|
||||
|
||||
<div v-if="selectedRuleSet?.status === 'draft'" class="identity-selection">
|
||||
<div class="identity-selection__heading"><span>{{ t('admin.shippingIdentityRules.definitions') }}</span><strong>{{ selectedDefinitionCount }}/{{ activeDefinitions.length }}</strong></div>
|
||||
<label v-for="definition in activeDefinitions" :key="definition.id" class="identity-check-row">
|
||||
<input v-model="selectedDefinitionIds" type="checkbox" :value="definition.id"><span>{{ definition.display_name }}</span><small>{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</small>
|
||||
</label>
|
||||
<el-checkbox-group v-model="selectedDefinitionIds" class="identity-check-list">
|
||||
<el-checkbox v-for="definition in activeDefinitions" :key="definition.id" :value="definition.id" class="identity-check-row">
|
||||
<span class="identity-check-name">{{ definition.display_name }}</span>
|
||||
<small class="identity-check-target">{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</small>
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</div>
|
||||
<div v-else-if="selectedRuleSet" class="identity-published-definitions">
|
||||
<div class="identity-selection__heading"><span>{{ t('admin.shippingIdentityRules.publishedDefinitions') }}</span><strong>{{ selectedRuleSet.definition?.definitions.length || 0 }}</strong></div>
|
||||
<div v-if="selectedRuleSet.definition?.definitions.length" class="identity-published-definition-list">
|
||||
<div v-for="definition in selectedRuleSet.definition.definitions" :key="definition.id" class="identity-published-definition">
|
||||
<div><strong>{{ definition.display_name }}</strong><small>{{ definition.context_field?.display_name || definition.context_field?.field_code || '-' }}</small></div>
|
||||
<span class="identity-target">{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</span>
|
||||
<span class="identity-automation" :class="{ 'identity-automation--enabled': definition.max_automation === 'conditional' }">{{ t(`admin.shippingIdentityRules.automations.${definition.max_automation}`) }}</span>
|
||||
<div class="identity-published-definition__copy"><strong>{{ definition.display_name }}</strong><small>{{ definition.context_field?.display_name || definition.context_field?.field_code || '-' }}</small></div>
|
||||
<el-tag type="info" size="small" effect="plain">{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</el-tag>
|
||||
<el-tag :type="definition.max_automation === 'conditional' ? 'success' : 'info'" size="small">{{ t(`admin.shippingIdentityRules.automations.${definition.max_automation}`) }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="identity-published-empty">{{ t('admin.shippingIdentityRules.publishedDefinitionsEmpty') }}</p>
|
||||
@@ -299,10 +378,18 @@ onMounted(() => { void load(); });
|
||||
|
||||
<div v-if="selectedRuleSet" class="identity-publication__actions">
|
||||
<template v-if="selectedRuleSet.status === 'draft'">
|
||||
<button type="button" class="btn-ghost" :disabled="saving || !selectedDefinitionCount" @click="saveDraft"><FileCheck2 class="h-4 w-4" />{{ t('admin.shippingIdentityRules.saveDraft') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving || !selectedDefinitionCount" @click="publishDraft"><Send class="h-4 w-4" />{{ t('admin.shippingIdentityRules.publish') }}</button>
|
||||
<el-button size="small" :icon="DocumentChecked" :disabled="saving || !selectedDefinitionCount" @click="saveDraft">{{ t('admin.shippingIdentityRules.saveDraft') }}</el-button>
|
||||
<el-button type="primary" size="small" :icon="Promotion" :loading="saving" :disabled="saving || !selectedDefinitionCount" @click="publishDraft">{{ t('admin.shippingIdentityRules.publish') }}</el-button>
|
||||
</template>
|
||||
<div v-else class="identity-published"><Check class="h-4 w-4" /><span>{{ t('admin.shippingIdentityRules.status.published') }}</span><code>{{ selectedRuleSet.checksum || '-' }}</code></div>
|
||||
<el-alert v-else type="success" :closable="false" class="identity-published">
|
||||
<template #title>
|
||||
<span class="identity-published__line">
|
||||
<Check class="identity-ico" />
|
||||
<span>{{ t('admin.shippingIdentityRules.status.published') }}</span>
|
||||
<code>{{ selectedRuleSet.checksum || '-' }}</code>
|
||||
</span>
|
||||
</template>
|
||||
</el-alert>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
@@ -310,79 +397,97 @@ onMounted(() => { void load(); });
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.identity-rules-page { max-width: 1380px; margin: 0 auto; display: grid; gap: 1.25rem; color: #183253; }
|
||||
/* 全宽布局:水平内边距与居中由 AdminLayout 壳层统一持有,页面只保留内部块间距 */
|
||||
.identity-rules-page {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.identity-ico {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.identity-hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: .5rem .25rem .75rem; }
|
||||
.identity-panel__eyebrow { display: flex; align-items: center; gap: .45rem; color: #475569; font-size: .76rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
|
||||
.identity-hero h1 { margin: 0; }
|
||||
.identity-hero p { max-width: 760px; }
|
||||
.page-title { margin: 0; font-size: 20px; font-weight: 700; }
|
||||
.page-desc { margin: 4px 0 0; max-width: 760px; color: var(--el-text-color-secondary); font-size: 13px; line-height: 1.55; }
|
||||
.identity-panel__eyebrow { display: flex; align-items: center; gap: .45rem; color: var(--el-text-color-secondary); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
|
||||
.identity-hero__meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
|
||||
/* 状态/品牌色统一 Tailwind 标准语义值(brand=sky 系 #0284c7、启用=green、草稿=amber),不再使用自造蓝绿 */
|
||||
.identity-hero__status { display: inline-flex; align-items: center; gap: .48rem; padding: .5rem .75rem; border: 1px solid #bae6fd; border-radius: 999px; background: #f0f9ff; color: #0369a1; font-size: .78rem; font-weight: 700; white-space: nowrap; }
|
||||
.identity-pulse { width: .5rem; height: .5rem; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 4px #d1fae5; }.identity-pulse--draft { background: #f59e0b; box-shadow: 0 0 0 4px #fef3c7; }
|
||||
.identity-hero__link { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
|
||||
.identity-flow { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; padding: 1rem; overflow: hidden; border: 1px solid #dce9f2; border-radius: 1rem; background: linear-gradient(105deg, #f4fbff, #fff); }
|
||||
.identity-flow__rail { position: absolute; top: 1.84rem; left: 12%; right: 12%; height: 1px; background: #cce5f2; }
|
||||
/* 状态色统一走 EP 语义变量(品牌=primary 系、已发布=success、草稿=warning) */
|
||||
.identity-hero__status { display: inline-flex; align-items: center; gap: .48rem; padding: .5rem .75rem; border: 1px solid var(--el-color-primary-light-7); border-radius: 999px; background: var(--el-color-primary-light-9); color: var(--el-color-primary-dark-2); font-size: 12px; font-weight: 700; white-space: nowrap; }
|
||||
.identity-pulse { width: .5rem; height: .5rem; border-radius: 50%; background: var(--el-color-success); box-shadow: 0 0 0 4px var(--el-color-success-light-8); }
|
||||
.identity-pulse--draft { background: var(--el-color-warning); box-shadow: 0 0 0 4px var(--el-color-warning-light-8); }
|
||||
.identity-hero__link-icon { margin-left: 4px; }
|
||||
.identity-flow { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; padding: 1rem; overflow: hidden; border: 1px solid var(--el-border-color-lighter); border-radius: 1rem; background: linear-gradient(105deg, var(--el-color-primary-light-9), var(--el-bg-color)); }
|
||||
.identity-flow__rail { position: absolute; top: 1.84rem; left: 12%; right: 12%; height: 1px; background: var(--el-border-color-light); }
|
||||
.identity-flow__step { position: relative; z-index: 1; display: flex; gap: .75rem; align-items: flex-start; min-width: 0; }
|
||||
.identity-flow__step > span { display: grid; place-items: center; flex: 0 0 1.65rem; height: 1.65rem; border: 1px solid #b9d8e8; border-radius: 50%; background: #fff; color: #6b8298; font-size: .66rem; font-weight: 800; }
|
||||
.identity-flow__step--active > span { border-color: #0284c7; background: #0284c7; color: #fff; box-shadow: 0 0 0 4px #e0f2fe; }
|
||||
.identity-flow strong { display: block; color: #193652; font-size: .82rem; font-weight: 800; }
|
||||
.identity-flow small { display: -webkit-box; overflow: hidden; margin-top: .15rem; color: #7a8fa6; font-size: .72rem; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
|
||||
.identity-loading { display: flex; align-items: center; gap: .5rem; padding: 2rem; color: #6f839b; font-size: .9rem; }
|
||||
.identity-flow__step > span { display: grid; place-items: center; flex: 0 0 1.65rem; height: 1.65rem; border: 1px solid var(--el-border-color-light); border-radius: 50%; background: var(--el-bg-color); color: var(--el-text-color-secondary); font-size: 12px; font-weight: 700; }
|
||||
.identity-flow__step--active > span { border-color: var(--el-color-primary); background: var(--el-color-primary); color: var(--el-color-white); box-shadow: 0 0 0 4px var(--el-color-primary-light-8); }
|
||||
.identity-flow strong { display: block; color: var(--el-text-color-primary); font-size: 13px; font-weight: 700; }
|
||||
.identity-flow small { display: -webkit-box; overflow: hidden; margin-top: .15rem; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.45; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
|
||||
.identity-loading { padding: 2rem; }
|
||||
.identity-workbench { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr); gap: 1.25rem; align-items: start; }
|
||||
.identity-panel { border: 1px solid #dce8f0; border-radius: 1rem; background: #fff; box-shadow: 0 10px 28px rgba(32, 78, 114, .055); }
|
||||
.identity-panel { border: 1px solid var(--el-border-color-light); border-radius: 1rem; background: var(--el-bg-color); box-shadow: var(--el-box-shadow-lighter); }
|
||||
.identity-panel--definitions { overflow: hidden; }
|
||||
.identity-panel__heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.35rem 1rem; border-bottom: 1px solid #edf3f7; }
|
||||
.identity-panel__heading h3 { margin: .2rem 0 0; color: #12395a; font-size: 2rem; font-weight: 800; line-height: 1; }
|
||||
.identity-panel__heading > p { max-width: 28rem; color: #71879e; font-size: .78rem; line-height: 1.55; text-align: right; }
|
||||
.identity-panel__heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: 1.25rem 1.35rem 1rem; border-bottom: 1px solid var(--el-border-color-lighter); }
|
||||
.identity-panel__heading h3 { margin: .2rem 0 0; color: var(--el-text-color-primary); font-size: 2rem; font-weight: 700; line-height: 1; }
|
||||
.identity-panel__heading > p { max-width: 28rem; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.55; text-align: right; }
|
||||
.identity-definition-list { display: grid; }
|
||||
.identity-definition-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .78rem 1.35rem; border-bottom: 1px solid #edf3f7; transition: background .18s ease; }
|
||||
.identity-definition-row:hover { background: #f7fbfd; }
|
||||
.identity-definition-row__icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: #f0f9ff; color: #0284c7; }
|
||||
.identity-definition-row strong { color: #1a3856; font-size: .86rem; font-weight: 750; }
|
||||
.identity-definition-row p { overflow: hidden; margin-top: .18rem; color: #8194a8; font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.identity-target, .identity-automation { padding: .32rem .52rem; border-radius: 999px; background: #f1f5f8; color: #677f98; font-size: .7rem; white-space: nowrap; }
|
||||
.identity-automation-select { border: 1px solid #dce8ef; cursor: pointer; }
|
||||
.identity-automation--enabled { background: #dcfce7; color: #15803d; }
|
||||
.identity-empty { display: flex; align-items: center; gap: .55rem; min-height: 5.5rem; padding: 1.2rem 1.35rem; color: #7c91a7; font-size: .82rem; }
|
||||
.identity-definition-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; padding: 1.1rem 1.35rem 1.35rem; background: linear-gradient(135deg, #f7fbfd 0%, #f3f9fc 100%); }
|
||||
.identity-form-title { grid-column: 1 / -1; display: flex; align-items: center; gap: .42rem; color: #173857; font-size: .85rem; }
|
||||
.identity-form-guide { grid-column: 1 / -1; margin: -.45rem 0 .1rem; color: #73889e; font-size: .75rem; line-height: 1.55; }
|
||||
.identity-definition-form label { display: grid; gap: .35rem; color: #667f99; font-size: .72rem; font-weight: 700; }
|
||||
.identity-definition-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .78rem 1.35rem; border-bottom: 1px solid var(--el-border-color-lighter); transition: background .18s ease; }
|
||||
.identity-definition-row:hover { background: var(--el-fill-color-light); }
|
||||
.identity-definition-row__icon { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: var(--el-color-primary-light-9); color: var(--el-color-primary); }
|
||||
.identity-definition-row__copy { min-width: 0; }
|
||||
.identity-definition-row strong { color: var(--el-text-color-primary); font-size: 13px; font-weight: 700; }
|
||||
.identity-definition-row p { overflow: hidden; margin-top: .18rem; color: var(--el-text-color-secondary); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
/* 自动化授权下拉:conditional 时以成功色底提示,固定宽度避免挤压行 */
|
||||
.identity-automation-select { width: 128px; }
|
||||
.identity-automation-select :deep(.el-select__wrapper) { min-height: 28px; }
|
||||
.identity-automation--enabled :deep(.el-select__wrapper) { background: var(--el-color-success-light-9); }
|
||||
.identity-empty { padding: .6rem 0; }
|
||||
.identity-definition-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem 1rem; padding: 1.1rem 1.35rem 1.35rem; border-top: 1px solid var(--el-border-color-lighter); background: var(--el-fill-color-lighter); }
|
||||
.identity-form-title { grid-column: 1 / -1; display: flex; align-items: center; gap: .42rem; color: var(--el-text-color-primary); font-size: 13px; }
|
||||
.identity-form-guide { grid-column: 1 / -1; margin: 0; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.55; }
|
||||
.identity-definition-form :deep(.el-form-item) { margin-bottom: 0; }
|
||||
.identity-definition-form :deep(.el-form-item__label) { margin-bottom: 4px; color: var(--el-text-color-secondary); font-size: 12px; font-weight: 700; line-height: 1.35; }
|
||||
.identity-label-with-tip { display: inline-flex; align-items: center; gap: .28rem; }
|
||||
.identity-label-tip { width: .9rem; height: .9rem; color: #7d93a8; cursor: help; }
|
||||
.identity-label-tip:focus-visible { border-radius: 50%; outline: 2px solid #7dd3fc; outline-offset: 2px; }
|
||||
.identity-definition-form label small { color: #8295a8; font-size: .67rem; font-weight: 500; line-height: 1.35; }
|
||||
.identity-definition-form .input-field, .identity-static-field { box-sizing: border-box; min-width: 0; height: 2.75rem; padding: 0 .8rem; border-color: #d9e7ef; background: #fff; font-size: .83rem; line-height: 1.25; }
|
||||
.identity-definition-form select.input-field { padding-top: 0; padding-bottom: 0; line-height: 2.75rem; }
|
||||
.identity-static-field { display: flex; align-items: center; padding: 0 .8rem; border: 1px solid #d9e7ef; border-radius: .65rem; color: #5f7893; }
|
||||
.identity-source-help { display: grid; align-content: center; gap: .12rem; min-height: 2.75rem; padding: .48rem .7rem; border: 1px solid #d6eaf5; border-radius: .65rem; background: #edf8fe; color: #537189; font-size: .69rem; line-height: 1.35; }
|
||||
.identity-source-help strong { color: #0369a1; font-size: .72rem; }.identity-source-help small { color: #16a34a; font-size: .68rem; }
|
||||
.identity-definition-form__submit { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; align-self: end; min-height: 2.5rem; }
|
||||
.identity-label-tip { width: 14px; height: 14px; color: var(--el-text-color-placeholder); cursor: help; }
|
||||
.identity-source-help { grid-column: 1 / span 2; display: grid; align-content: center; gap: .12rem; min-height: 2.75rem; padding: .48rem .7rem; border: 1px solid var(--el-color-primary-light-8); border-radius: 8px; background: var(--el-color-primary-light-9); color: var(--el-text-color-regular); font-size: 12px; line-height: 1.35; }
|
||||
.identity-source-help strong { color: var(--el-color-primary-dark-2); font-size: 12px; }
|
||||
.identity-source-help small { color: var(--el-color-success); font-size: 12px; }
|
||||
.identity-definition-form__submit { grid-column: 3; align-self: end; min-height: 2.5rem; }
|
||||
.identity-panel--publication { position: sticky; top: 1rem; padding: 1.25rem; }
|
||||
.identity-publication__header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
|
||||
.identity-publication__header .btn-ghost, .identity-publication__actions button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
|
||||
.identity-publication__hint { margin: .75rem 0 1rem; color: #75899f; font-size: .78rem; line-height: 1.6; }
|
||||
.identity-version-list { display: flex; flex-wrap: wrap; gap: .5rem; padding-bottom: 1rem; border-bottom: 1px solid #e9f0f4; }
|
||||
.identity-version { display: inline-flex; align-items: center; gap: .35rem; padding: .46rem .6rem; border: 1px solid #dbe7ee; border-radius: .6rem; background: #fff; color: #668099; font-size: .73rem; transition: all .18s ease; }
|
||||
.identity-version:hover, .identity-version--selected { border-color: #0284c7; background: #f0f9ff; color: #0369a1; }
|
||||
.identity-version span { font-weight: 800; }.identity-version small { font-size: .68rem; }
|
||||
.identity-publication__hint { margin: .75rem 0 1rem; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.6; }
|
||||
.identity-version-list { display: flex; flex-wrap: wrap; gap: .5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--el-border-color-lighter); }
|
||||
.identity-version { display: inline-flex; align-items: center; gap: .35rem; padding: .46rem .6rem; border: 1px solid var(--el-border-color-light); border-radius: 8px; background: var(--el-bg-color); color: var(--el-text-color-regular); font-size: 12px; cursor: pointer; transition: all .18s ease; }
|
||||
.identity-version:hover, .identity-version--selected { border-color: var(--el-color-primary); background: var(--el-color-primary-light-9); color: var(--el-color-primary-dark-2); }
|
||||
.identity-version span { font-weight: 700; }
|
||||
.identity-version small { font-size: 12px; }
|
||||
.identity-selection { margin: 1rem 0; }
|
||||
.identity-selection__heading { display: flex; justify-content: space-between; margin-bottom: .6rem; color: var(--el-text-color-primary); font-size: 12px; font-weight: 700; }
|
||||
.identity-selection__heading strong { color: var(--el-color-primary); }
|
||||
.identity-check-list { display: grid; }
|
||||
.identity-check-row { width: 100%; height: auto; margin-right: 0; padding: .54rem 0; border-bottom: 1px dashed var(--el-border-color-lighter); }
|
||||
.identity-check-row :deep(.el-checkbox__label) { display: flex; flex: 1; align-items: baseline; justify-content: space-between; gap: .5rem; min-width: 0; }
|
||||
.identity-check-name { overflow: hidden; color: var(--el-text-color-regular); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.identity-check-target { flex: none; color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.identity-published-definitions { margin: 1rem 0; }
|
||||
.identity-published-definition-list { display: grid; gap: .45rem; }
|
||||
.identity-published-definition { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .5rem; align-items: center; padding: .58rem .65rem; border: 1px solid #e5eef3; border-radius: .6rem; background: #fbfdfe; }
|
||||
.identity-published-definition { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .5rem; align-items: center; padding: .58rem .65rem; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; background: var(--el-fill-color-lighter); }
|
||||
.identity-published-definition__copy { min-width: 0; }
|
||||
.identity-published-definition strong, .identity-published-definition small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.identity-published-definition strong { color: #294660; font-size: .76rem; }
|
||||
.identity-published-definition small { margin-top: .15rem; color: #8194a8; font-size: .68rem; }
|
||||
.identity-published-empty { margin: 0; color: #8194a8; font-size: .76rem; }
|
||||
.identity-selection__heading { display: flex; justify-content: space-between; margin-bottom: .6rem; color: #274563; font-size: .78rem; font-weight: 750; }
|
||||
.identity-selection__heading strong { color: #0284c7; }
|
||||
.identity-check-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .5rem; padding: .54rem 0; border-bottom: 1px dashed #e2ebf1; color: #37516c; font-size: .78rem; }
|
||||
/* @tailwindcss/forms 接管原生 checkbox 后 accent-color 无效:勾选填充取 currentColor,用 color 指定选中蓝 */
|
||||
.identity-check-row input { color: #0284c7; }.identity-check-row small { color: #8496a8; font-size: .68rem; }
|
||||
.identity-published-definition strong { color: var(--el-text-color-primary); font-size: 12px; }
|
||||
.identity-published-definition small { margin-top: .15rem; color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.identity-published-empty { margin: 0; color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.identity-publication__actions { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; padding-top: 1rem; }
|
||||
.identity-publication__actions .btn-primary, .identity-publication__actions .btn-ghost { min-width: 0; font-size: .79rem; }
|
||||
.identity-published { grid-column: 1 / -1; display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: .45rem; padding: .7rem; border-radius: .65rem; background: #dcfce7; color: #15803d; font-size: .78rem; font-weight: 700; }.identity-published code { overflow: hidden; color: #16a34a; font-size: .67rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.identity-publication__actions .el-button { min-width: 0; }
|
||||
.identity-publication__actions .el-button + .el-button { margin-left: 0; }
|
||||
.identity-published { grid-column: 1 / -1; }
|
||||
.identity-published__line { display: flex; align-items: center; gap: .45rem; min-width: 0; font-size: 12px; }
|
||||
.identity-published__line code { flex: 1; overflow: hidden; text-align: right; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
|
||||
@media (max-width: 980px) { .identity-workbench { grid-template-columns: 1fr; }.identity-panel--publication { position: static; }.identity-hero { align-items: flex-start; flex-direction: column; gap: .85rem; }.identity-hero__meta { justify-content: flex-start; }.identity-flow__rail { display: none; } }
|
||||
@media (max-width: 700px) { .identity-rules-page { gap: 1rem; }.identity-flow { grid-template-columns: 1fr; }.identity-definition-form { grid-template-columns: 1fr; }.identity-definition-row { grid-template-columns: auto minmax(0, 1fr); }.identity-target, .identity-automation { justify-self: start; }.identity-panel__heading { align-items: flex-start; flex-direction: column; }.identity-panel__heading > p { text-align: left; }.identity-definition-row__icon { grid-row: span 2; }.identity-publication__actions { grid-template-columns: 1fr; } }
|
||||
@media (max-width: 700px) { .identity-rules-page { gap: 1rem; }.identity-flow { grid-template-columns: 1fr; }.identity-definition-form { grid-template-columns: 1fr; }.identity-source-help, .identity-definition-form__submit { grid-column: auto; }.identity-definition-row { grid-template-columns: auto minmax(0, 1fr); }.identity-definition-row .el-tag, .identity-definition-row .identity-automation-select { justify-self: start; }.identity-panel__heading { align-items: flex-start; flex-direction: column; }.identity-panel__heading > p { text-align: left; }.identity-definition-row__icon { grid-row: span 2; }.identity-publication__actions { grid-template-columns: 1fr; } }
|
||||
@media (prefers-reduced-motion: reduce) { .identity-definition-row, .identity-version { transition: none; } }
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,29 +0,0 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-inventory/receiptReportConfigForm.ts
|
||||
* 用途:构建独立收料报表配置的受限保存载荷。
|
||||
* 依赖:无外部依赖。
|
||||
* 逻辑:页面仅将收料路径与查询条件提交到收料配置 API,与库存同构(查询条件可选,空=页面默认),
|
||||
* 隔离库存站点字段;收料无独立启停字段,是否运行统一由库存站点 enabled 决定。
|
||||
*/
|
||||
|
||||
export type ReceiptReportConfigInput = {
|
||||
report_path_json: Record<string, unknown>;
|
||||
query_parameters_json: Array<Record<string, unknown>>;
|
||||
/** 收料异动解析规则绑定;0/undefined 视为未绑定并归一为 null(显式解绑)。 */
|
||||
parsing_profile_id?: number | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 构造独立收料配置保存载荷。
|
||||
* 核心逻辑:白名单复制可配置业务字段,不允许调用方把库存源、Profile 或启停字段带入收料 API;
|
||||
* 异动解析绑定随配置一并提交(null=解绑)。
|
||||
* @param input - 抽屉中的收料配置表单状态。
|
||||
* @returns 仅包含收料配置 API 支持字段的深拷贝载荷。
|
||||
*/
|
||||
export function buildReceiptReportConfigPayload(input: ReceiptReportConfigInput): ReceiptReportConfigInput {
|
||||
return {
|
||||
report_path_json: { ...(input.report_path_json || {}) },
|
||||
query_parameters_json: (input.query_parameters_json || []).map((item) => ({ ...item })),
|
||||
parsing_profile_id: input.parsing_profile_id ? Number(input.parsing_profile_id) : null,
|
||||
};
|
||||
}
|
||||
+138
-38
@@ -1,16 +1,33 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileBlindTestPage.vue
|
||||
用途:维护订单模板草稿的独立盲测证据,并完成执行和批准。
|
||||
依赖:盲测 API、Profile 详情、Vue Router、统一业务错误提示和四语言文案。
|
||||
依赖:element-plus(el-select/el-checkbox/el-input/el-descriptions/el-tag/el-skeleton,
|
||||
沿用管理端 element-trial 主题)、盲测 API、Profile 详情、Vue Router、统一业务错误提示和四语言文案。
|
||||
逻辑:验证页进入本页;所有模板按统一视觉表候选和字段证据复核;
|
||||
末端值源差异由服务端 adapter 投影,管理员复核后写入真值,再执行并批准;
|
||||
XFA 以 datasets 为正式值:OCR 对照与视觉/镜像指标仅 soft 诊断,不硬拦;
|
||||
业务错误优先用扁平 errors key 翻译,并附带服务端 message 便于定位。
|
||||
视觉层已迁移 Element Plus;文件上传 label 保留原生 input[type=file](事件契约不变)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSkeleton,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import { Refresh } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -518,21 +535,31 @@ onBeforeUnmount(() => {
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderProfiles.blindTest.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderProfiles.blindTest.reviewHint') }}</p>
|
||||
</div>
|
||||
<div class="actions"><button type="button" class="btn-secondary" @click="backToValidation">{{ t('admin.shippingOrderProfiles.blindTest.backToValidation') }}</button><button v-if="suite?.status === 'approved'" type="button" class="btn-primary" @click="goToPublishCheck">{{ t('admin.shippingOrderProfiles.blindTest.goPublishCheck') }}</button></div>
|
||||
<div class="actions">
|
||||
<el-button @click="backToValidation">{{ t('admin.shippingOrderProfiles.blindTest.backToValidation') }}</el-button>
|
||||
<el-button v-if="suite?.status === 'approved'" type="primary" @click="goToPublishCheck">{{ t('admin.shippingOrderProfiles.blindTest.goPublishCheck') }}</el-button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<p v-if="loading">{{ t('admin.orderProfileValidation.loading') }}</p>
|
||||
<el-skeleton v-if="loading" :rows="4" animated />
|
||||
<template v-else-if="suite">
|
||||
<section class="card suite-summary"><div><h2>{{ t('admin.shippingOrderProfiles.blindTest.samples', { count: suite.sample_count, required: 1, status: t(`admin.shippingOrderProfiles.versionCenter.testStatus.${suite.status}`) }) }}</h2><p v-if="suite.latest_run">{{ t('admin.shippingOrderProfiles.blindTest.latestResult', { status: suite.latest_run.status, passed: suite.latest_run.passed_sample_count, count: suite.latest_run.sample_count }) }}</p><p v-else>{{ t('admin.shippingOrderProfiles.blindTest.notRun') }}</p></div><span :class="`status ${suite.status}`">{{ t(`admin.shippingOrderProfiles.versionCenter.testStatus.${suite.status}`) }}</span></section>
|
||||
<section class="card suite-summary">
|
||||
<div class="suite-summary__head">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.samples', { count: suite.sample_count, required: 1 }) }}</h2>
|
||||
<el-tag size="small" :type="suite.status === 'approved' ? 'success' : suite.status === 'superseded' ? 'danger' : 'warning'">{{ t(`admin.shippingOrderProfiles.versionCenter.testStatus.${suite.status}`) }}</el-tag>
|
||||
</div>
|
||||
<p v-if="suite.latest_run">{{ t('admin.shippingOrderProfiles.blindTest.latestResult', { status: suite.latest_run.status, passed: suite.latest_run.passed_sample_count, count: suite.latest_run.sample_count }) }}</p>
|
||||
<p v-else>{{ t('admin.shippingOrderProfiles.blindTest.notRun') }}</p>
|
||||
</section>
|
||||
|
||||
<section v-if="suite.latest_run?.metrics" class="card metrics-card">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.metricsTitle') }}</h2>
|
||||
<dl class="metrics">
|
||||
<div><dt>{{ t('admin.shippingOrderProfiles.blindTest.visualCoverage') }}</dt><dd>{{ formatMetricRate(suite.latest_run.metrics.visual_coverage_rate) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderProfiles.blindTest.evidenceRetention') }}</dt><dd>{{ formatMetricRate(suite.latest_run.metrics.evidence_retention_rate) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderProfiles.blindTest.mirrorConsistency') }}</dt><dd>{{ formatMetricRate(suite.latest_run.metrics.mirror_consistency_rate) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderProfiles.blindTest.keyFieldAccuracy') }}</dt><dd>{{ formatMetricRate(suite.latest_run.metrics.key_field_accuracy_rate) }}</dd></div>
|
||||
</dl>
|
||||
<el-descriptions class="metrics" :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.blindTest.visualCoverage')">{{ formatMetricRate(suite.latest_run.metrics.visual_coverage_rate) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.blindTest.evidenceRetention')">{{ formatMetricRate(suite.latest_run.metrics.evidence_retention_rate) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.blindTest.mirrorConsistency')">{{ formatMetricRate(suite.latest_run.metrics.mirror_consistency_rate) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.blindTest.keyFieldAccuracy')">{{ formatMetricRate(suite.latest_run.metrics.key_field_accuracy_rate) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
|
||||
<section v-if="failureDetails.length" class="card failure-details">
|
||||
@@ -551,9 +578,35 @@ onBeforeUnmount(() => {
|
||||
</section>
|
||||
|
||||
<section v-if="suite.status === 'draft'" class="card">
|
||||
<div class="sample-heading"><h2>{{ t('admin.shippingOrderProfiles.blindTest.selectIndependentSample') }}</h2><label class="btn-secondary upload-sample"><input type="file" accept=".pdf,.eml,application/pdf,message/rfc822" :disabled="uploadingSample" @change="uploadIndependentSample"><span>{{ uploadingSample ? t('admin.shippingOrderProfiles.wizard.uploading') : t('admin.shippingOrderProfiles.blindTest.uploadSample') }}</span></label></div>
|
||||
<div class="sample-heading">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.selectIndependentSample') }}</h2>
|
||||
<!-- 保留原生 input[type=file]:uploadIndependentSample 依赖原生 change 事件契约 -->
|
||||
<label class="upload-sample"><input type="file" accept=".pdf,.eml,application/pdf,message/rfc822" :disabled="uploadingSample" @change="uploadIndependentSample"><span>{{ uploadingSample ? t('admin.shippingOrderProfiles.wizard.uploading') : t('admin.shippingOrderProfiles.blindTest.uploadSample') }}</span></label>
|
||||
</div>
|
||||
<p v-if="availableSamplesLoaded && !availableSamples.length">{{ t('admin.shippingOrderProfiles.blindTest.noIndependentSamples') }}</p>
|
||||
<div class="sample-picker"><button v-if="!availableSamplesLoaded" type="button" class="btn-secondary" :disabled="availableSamplesLoading" @click="() => void loadAvailableSamples()">{{ availableSamplesLoading ? t('admin.shippingOrderProfiles.blindTest.loadingIndependentSamples') : t('admin.shippingOrderProfiles.blindTest.loadIndependentSamples') }}</button><template v-else-if="availableSamples.length"><select v-model="selectedSampleKey" class="select-field"><option value="">{{ t('admin.shippingOrderProfiles.blindTest.selectSamplePlaceholder') }}</option><option v-for="sample in availableSamples" :key="`${sample.document_id}:${sample.table_id}`" :value="`${sample.document_id}:${sample.table_id}`">{{ sampleLabel(sample) }}</option></select><button v-if="selectedSample?.review_mode === 'preparing'" type="button" class="btn-primary" :disabled="working" @click="reprocessSelectedSample">{{ t('admin.shippingOrderProfiles.blindTest.reprocessLayout') }}</button><button v-else type="button" class="btn-primary" :disabled="!selectedSample || working" @click="previewSample">{{ selectedSample?.review_mode === 'diagnostic' ? t('admin.shippingOrderProfiles.blindTest.viewDiagnostic') : t('admin.shippingOrderProfiles.blindTest.previewAndReview') }}</button><button type="button" class="btn-secondary" :disabled="availableSamplesLoading || working" @click="() => void loadAvailableSamples(true)">{{ t('admin.shippingOrderProfiles.blindTest.refreshSamples') }}</button></template></div>
|
||||
<div class="sample-picker">
|
||||
<el-button v-if="!availableSamplesLoaded" :disabled="availableSamplesLoading" :loading="availableSamplesLoading" @click="() => void loadAvailableSamples()">{{ availableSamplesLoading ? t('admin.shippingOrderProfiles.blindTest.loadingIndependentSamples') : t('admin.shippingOrderProfiles.blindTest.loadIndependentSamples') }}</el-button>
|
||||
<template v-else-if="availableSamples.length">
|
||||
<el-select
|
||||
v-model="selectedSampleKey"
|
||||
clearable
|
||||
fit-input-width
|
||||
:popper-options="{ strategy: 'fixed' }"
|
||||
:placeholder="t('admin.shippingOrderProfiles.blindTest.selectSamplePlaceholder')"
|
||||
>
|
||||
<el-option value="" :label="t('admin.shippingOrderProfiles.blindTest.selectSamplePlaceholder')" />
|
||||
<el-option
|
||||
v-for="sample in availableSamples"
|
||||
:key="`${sample.document_id}:${sample.table_id}`"
|
||||
:value="`${sample.document_id}:${sample.table_id}`"
|
||||
:label="sampleLabel(sample)"
|
||||
/>
|
||||
</el-select>
|
||||
<el-button v-if="selectedSample?.review_mode === 'preparing'" type="primary" :disabled="working" :loading="working" @click="reprocessSelectedSample">{{ t('admin.shippingOrderProfiles.blindTest.reprocessLayout') }}</el-button>
|
||||
<el-button v-else type="primary" :disabled="!selectedSample || working" :loading="working" @click="previewSample">{{ selectedSample?.review_mode === 'diagnostic' ? t('admin.shippingOrderProfiles.blindTest.viewDiagnostic') : t('admin.shippingOrderProfiles.blindTest.previewAndReview') }}</el-button>
|
||||
<el-button :icon="Refresh" :disabled="availableSamplesLoading || working" :loading="availableSamplesLoading" @click="() => void loadAvailableSamples(true)">{{ t('admin.shippingOrderProfiles.blindTest.refreshSamples') }}</el-button>
|
||||
</template>
|
||||
</div>
|
||||
<p v-if="pendingUpload" class="upload-status" :class="{ failed: pendingUpload.state === 'failed' }">{{ pendingUpload.filename }} · {{ pendingUpload.state === 'materializing' ? t('admin.shippingOrderProfiles.blindTest.sampleMaterializing') : sampleFailureMessage() }}</p>
|
||||
</section>
|
||||
|
||||
@@ -580,46 +633,93 @@ onBeforeUnmount(() => {
|
||||
<article v-for="(row, index) in candidate.rows" :key="index" class="review-item">
|
||||
<template v-if="rowReviews[index]">
|
||||
<h3>{{ t('admin.shippingOrderProfiles.blindTest.row', { index: index + 1 }) }}</h3><code>{{ JSON.stringify(row) }}</code>
|
||||
<label><input v-model="rowReviews[index].correct" type="checkbox">{{ t('admin.shippingOrderProfiles.blindTest.correct') }}</label>
|
||||
<textarea v-if="!rowReviews[index].correct" v-model="rowReviews[index].correction" class="input-field" :placeholder="t('admin.shippingOrderProfiles.blindTest.expectedRowsPlaceholder')" />
|
||||
<el-checkbox v-model="rowReviews[index].correct">{{ t('admin.shippingOrderProfiles.blindTest.correct') }}</el-checkbox>
|
||||
<el-input
|
||||
v-if="!rowReviews[index].correct"
|
||||
v-model="rowReviews[index].correction"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
class="correction-input"
|
||||
:placeholder="t('admin.shippingOrderProfiles.blindTest.expectedRowsPlaceholder')"
|
||||
/>
|
||||
</template>
|
||||
</article>
|
||||
<article v-for="field in candidate.order_fields" :key="field.field_id" class="review-item">
|
||||
<h3>{{ field.field_code }}</h3><code>{{ field.value ?? t('admin.shippingOrderProfiles.emptyCandidateValue') }}</code>
|
||||
<label><input :checked="orderFieldReview(orderFieldKey(field)).correct" type="checkbox" @change="updateOrderFieldReview(orderFieldKey(field), { correct: ($event.target as HTMLInputElement).checked })">{{ t('admin.shippingOrderProfiles.blindTest.correct') }}</label>
|
||||
<input v-if="!orderFieldReview(orderFieldKey(field)).correct" class="input-field" :value="orderFieldReview(orderFieldKey(field)).value" :placeholder="t('admin.shippingOrderProfiles.blindTest.correctedValue')" @input="updateOrderFieldReview(orderFieldKey(field), { value: ($event.target as HTMLInputElement).value })">
|
||||
<el-checkbox
|
||||
:model-value="orderFieldReview(orderFieldKey(field)).correct"
|
||||
@update:model-value="(checked) => updateOrderFieldReview(orderFieldKey(field), { correct: Boolean(checked) })"
|
||||
>{{ t('admin.shippingOrderProfiles.blindTest.correct') }}</el-checkbox>
|
||||
<el-input
|
||||
v-if="!orderFieldReview(orderFieldKey(field)).correct"
|
||||
class="value-input"
|
||||
:model-value="orderFieldReview(orderFieldKey(field)).value"
|
||||
:placeholder="t('admin.shippingOrderProfiles.blindTest.correctedValue')"
|
||||
@input="(value) => updateOrderFieldReview(orderFieldKey(field), { value: String(value) })"
|
||||
/>
|
||||
</article>
|
||||
<button v-if="candidate.confirmable" type="button" class="btn-primary" :disabled="working || !candidate.rows.length" @click="confirmReview">{{ t('admin.shippingOrderProfiles.blindTest.confirmReview') }}</button>
|
||||
<el-button v-if="candidate.confirmable" type="primary" :disabled="working || !candidate.rows.length" :loading="working" @click="confirmReview">{{ t('admin.shippingOrderProfiles.blindTest.confirmReview') }}</el-button>
|
||||
</section>
|
||||
|
||||
<section class="card"><h2>{{ t('admin.shippingOrderProfiles.blindTest.addedSamples') }}</h2><p>{{ t('admin.shippingOrderProfiles.blindTest.addedSamplesHint') }}</p><ul v-if="suite.samples.length"><li v-for="sample in suite.samples" :key="sample.id"><span>{{ sample.filename }} · P{{ sample.page_no }}</span><button v-if="suite.status === 'draft'" type="button" class="btn-secondary btn-sm" :disabled="working" @click="removeSample(sample.id)">{{ t('admin.shippingOrderProfiles.blindTest.removeSample') }}</button></li></ul><p v-else>{{ t('admin.shippingOrderProfiles.blindTest.noIndependentSamples') }}</p></section>
|
||||
<section class="card">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.addedSamples') }}</h2>
|
||||
<p>{{ t('admin.shippingOrderProfiles.blindTest.addedSamplesHint') }}</p>
|
||||
<ul v-if="suite.samples.length"><li v-for="sample in suite.samples" :key="sample.id"><span>{{ sample.filename }} · P{{ sample.page_no }}</span><el-button v-if="suite.status === 'draft'" size="small" :disabled="working" @click="removeSample(sample.id)">{{ t('admin.shippingOrderProfiles.blindTest.removeSample') }}</el-button></li></ul>
|
||||
<p v-else>{{ t('admin.shippingOrderProfiles.blindTest.noIndependentSamples') }}</p>
|
||||
</section>
|
||||
|
||||
<section class="card execution"><div><h2>{{ t('admin.shippingOrderProfiles.blindTest.execution') }}</h2><p>{{ t('admin.shippingOrderProfiles.blindTest.runHint') }}</p><p v-if="!hasTrainingSample" class="training-required">{{ t('admin.shippingOrderProfiles.blindTest.trainingRequired') }}</p></div><div class="actions"><button v-if="suite.status === 'draft'" type="button" class="btn-secondary" :disabled="working || !suite.sample_count" @click="executeSuite">{{ t('admin.shippingOrderProfiles.blindTest.run') }}</button><button v-if="suite.status === 'draft' && !hasTrainingSample" type="button" class="btn-secondary" :disabled="working" @click="goToEditor">{{ t('admin.shippingOrderProfiles.blindTest.goToEditor') }}</button><button v-if="suite.status === 'draft'" type="button" class="btn-primary" :disabled="working || !canApprove" @click="approveSuite">{{ t('admin.shippingOrderProfiles.blindTest.approve') }}</button></div></section>
|
||||
<section class="card execution">
|
||||
<div>
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.execution') }}</h2>
|
||||
<p>{{ t('admin.shippingOrderProfiles.blindTest.runHint') }}</p>
|
||||
<p v-if="!hasTrainingSample" class="training-required">{{ t('admin.shippingOrderProfiles.blindTest.trainingRequired') }}</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<el-button v-if="suite.status === 'draft'" :disabled="working || !suite.sample_count" :loading="working" @click="executeSuite">{{ t('admin.shippingOrderProfiles.blindTest.run') }}</el-button>
|
||||
<el-button v-if="suite.status === 'draft' && !hasTrainingSample" :disabled="working" @click="goToEditor">{{ t('admin.shippingOrderProfiles.blindTest.goToEditor') }}</el-button>
|
||||
<el-button v-if="suite.status === 'draft'" type="primary" :disabled="working || !canApprove" :loading="working" @click="approveSuite">{{ t('admin.shippingOrderProfiles.blindTest.approve') }}</el-button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.blind-test-page { padding: 24px; color: var(--text-secondary); }
|
||||
/* 根容器不再自带水平 padding:由 Admin 壳层统一持有,页面只保留卡片间距 */
|
||||
.blind-test-page { color: var(--el-text-color-regular); }
|
||||
header, .suite-summary, .execution, .actions, .sample-heading, .sample-picker, li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
header { align-items: flex-start; margin-bottom: 24px; } h1, h2, h3, p { margin: 0; } h2 { font-size: 16px; } h3 { font-size: 14px; } p:not(.section-desc) { margin-top: 6px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
|
||||
.card { display: grid; gap: 14px; margin-top: 14px; border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); padding: 18px; }
|
||||
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 0; }
|
||||
.metrics div { display: grid; gap: 4px; }
|
||||
.metrics dt { color: var(--text-muted); font-size: 12px; }
|
||||
.metrics dd { margin: 0; color: var(--text-primary); font-size: 14px; font-weight: 600; }
|
||||
.status { color: var(--status-warning-fg); font-weight: 700; } .status.approved { color: var(--status-success-fg); } .status.superseded { color: var(--status-error-fg); }
|
||||
.sample-heading { align-items: center; }.sample-picker { justify-content: flex-start; }.sample-picker .select-field { flex: 1; min-width: 0; } .sample-picker button, .upload-sample { flex: 0 0 auto; white-space: nowrap; } .candidate-card .input-field { padding: 8px; border-radius: 6px; } textarea.input-field { min-height: 72px; font-family: ui-monospace, monospace; }
|
||||
.upload-sample { position: relative; cursor: pointer; }.upload-sample input { position: absolute; width: 1px; height: 1px; opacity: 0; }.upload-status { margin: 10px 0 0; color: var(--status-info-fg); font-size: .85rem; }.upload-status.failed { color: var(--status-error-fg); }
|
||||
.candidate-card { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } .candidate-card > h2, .candidate-card > p, .candidate-card > button { grid-column: 1 / -1; }
|
||||
.review-item { display: grid; gap: 8px; border: 1px solid var(--border-default); border-radius: 8px; padding: 12px; } code { overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text-primary); font-size: 12px; } label { display: flex; gap: 6px; align-items: center; }
|
||||
ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; } li { border-top: 1px solid var(--border-default); padding-top: 8px; }
|
||||
.failure-details { border-color: var(--status-error-border); background: var(--status-error-bg); }.failure-details h2 { color: var(--status-error-fg); }.failure-details li { display: grid; gap: 4px; color: var(--status-error-fg); }.failure-details code { color: var(--status-error-fg); }
|
||||
.soft-diagnostics { border-color: var(--status-warning-border, #f59e0b); background: var(--status-warning-bg, #fffbeb); }
|
||||
.soft-diagnostics h2, .soft-diagnostics li, .ocr-diagnostic { color: var(--status-warning-fg) !important; }
|
||||
header { align-items: flex-start; margin-bottom: 24px; } h1, h2, h3, p { margin: 0; } h2 { font-size: 16px; } h3 { font-size: 14px; } p:not(.section-desc) { margin-top: 6px; color: var(--el-text-color-secondary); font-size: 13px; line-height: 1.5; }
|
||||
.card { display: grid; gap: 14px; margin-top: 14px; border: 1px solid var(--el-border-color-lighter); border-radius: 12px; background: var(--el-bg-color); padding: 18px; }
|
||||
.metrics { margin: 0; }
|
||||
.metrics :deep(.el-descriptions__label) { color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.metrics :deep(.el-descriptions__content) { color: var(--el-text-color-primary); font-size: 13px; font-weight: 600; }
|
||||
.sample-heading { align-items: center; }.suite-summary__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }.sample-picker { justify-content: flex-start; }.sample-picker .el-select { flex: 1 1 auto; min-width: 0; } .sample-picker .el-button, .upload-sample { flex: 0 0 auto; white-space: nowrap; } .candidate-card .correction-input, .candidate-card .value-input { width: 100%; }.correction-input :deep(.el-textarea__inner) { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
|
||||
/* 原生 file input 的外套 label:样式对齐 el-button 默认几何(32px 高),避免遗留 .btn-* 的大尺寸异形按钮 */
|
||||
.upload-sample {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 32px;
|
||||
padding: 0 15px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-bg-color);
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: color .2s, border-color .2s, background-color .2s;
|
||||
}
|
||||
.upload-sample:hover { color: var(--el-color-primary); border-color: var(--el-color-primary-light-7); background: var(--el-color-primary-light-9); }
|
||||
.upload-sample:has(input:disabled) { opacity: .5; cursor: not-allowed; }.upload-sample input { position: absolute; width: 1px; height: 1px; opacity: 0; }.upload-status { margin: 10px 0 0; color: var(--el-color-primary); font-size: 13px; }.upload-status.failed { color: var(--el-color-danger); }
|
||||
.candidate-card { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } .candidate-card > h2, .candidate-card > p, .candidate-card > .el-button { grid-column: 1 / -1; }
|
||||
.review-item { display: grid; gap: 8px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 12px; } code { overflow-wrap: anywhere; white-space: pre-wrap; color: var(--el-text-color-primary); font-size: 12px; }
|
||||
ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; } li { border-top: 1px solid var(--el-border-color-lighter); padding-top: 8px; }
|
||||
.failure-details { border-color: var(--el-color-danger-light-7); background: var(--el-color-danger-light-9); }.failure-details h2 { color: var(--el-color-danger); }.failure-details li { display: grid; gap: 4px; color: var(--el-color-danger); }.failure-details code { color: var(--el-color-danger); }
|
||||
.soft-diagnostics { border-color: var(--el-color-warning-light-7); background: var(--el-color-warning-light-9); }
|
||||
.soft-diagnostics h2, .soft-diagnostics li, .ocr-diagnostic { color: var(--el-color-warning) !important; }
|
||||
.ocr-diagnostic { font-weight: 600; grid-column: 1 / -1; }
|
||||
.ocr-diagnostic-list { grid-column: 1 / -1; margin: 0; padding-left: 1.2rem; color: var(--status-warning-fg); }
|
||||
.ocr-diagnostic-list { grid-column: 1 / -1; margin: 0; padding-left: 1.2rem; color: var(--el-color-warning); }
|
||||
.ocr-diagnostic-list li { margin: 4px 0; }
|
||||
.training-required { color: var(--status-warning-fg) !important; font-weight: 600; }
|
||||
@media (max-width: 700px) { header, .suite-summary, .execution, .sample-heading, .sample-picker { align-items: stretch; flex-direction: column; } .sample-picker .select-field { min-width: 0; width: 100%; } }
|
||||
.training-required { color: var(--el-color-warning) !important; font-weight: 600; }
|
||||
@media (max-width: 700px) { header, .suite-summary, .execution, .sample-heading, .sample-picker { align-items: stretch; flex-direction: column; } .sample-picker .el-select { min-width: 0; width: 100%; } }
|
||||
</style>
|
||||
+51
-20
@@ -1,14 +1,25 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileCreateWizardPage.vue
|
||||
用途:以三步向导创建订单文档模板草稿。
|
||||
依赖:Schema/样本/表格 API、步骤组件和 Vue Router。
|
||||
依赖:element-plus(el-steps 步骤条 / el-button 按钮,沿用管理端 element-trial 主题,图标为 @element-plus/icons-vue)、
|
||||
Schema/样本/表格 API、步骤组件和 Vue Router。
|
||||
逻辑:所有有明细的样本在第三步选择同一视觉主表;XFA datasets/OCR 差异只在编辑器的字段取值映射中配置。
|
||||
视觉层已迁移 Element Plus(手写步骤条→el-steps,btn-*→el-button),业务脚本与三步交互保持原样。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, ArrowRight, Check, FileText, Layers3, Sparkles } from 'lucide-vue-next';
|
||||
import {
|
||||
ElButton,
|
||||
ElIcon,
|
||||
ElStep,
|
||||
ElSteps,
|
||||
} from 'element-plus';
|
||||
import { ArrowLeft, ArrowRight, Check, Document, Files, MagicStick } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -45,9 +56,9 @@ const canNext = computed(() => {
|
||||
return Boolean(tableId.value);
|
||||
});
|
||||
const steps = computed(() => [
|
||||
{ number: 1, label: t('admin.shippingOrderProfiles.wizard.identityStep'), icon: FileText },
|
||||
{ number: 2, label: t('admin.shippingOrderProfiles.wizard.sampleStep'), icon: Layers3 },
|
||||
{ number: 3, label: stepThreeLabel.value, icon: Sparkles },
|
||||
{ number: 1, label: t('admin.shippingOrderProfiles.wizard.identityStep'), icon: Document },
|
||||
{ number: 2, label: t('admin.shippingOrderProfiles.wizard.sampleStep'), icon: Files },
|
||||
{ number: 3, label: stepThreeLabel.value, icon: MagicStick },
|
||||
]);
|
||||
|
||||
/** 接收首步身份快照;父级单一状态驱动下一步校验,避免子组件对象替换造成状态不同步。 */
|
||||
@@ -165,12 +176,25 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderProfiles.wizard.description') }}</p>
|
||||
</header>
|
||||
|
||||
<ol class="stepper" :aria-label="t('admin.shippingOrderProfiles.wizard.steps', { step })">
|
||||
<li v-for="item in steps" :key="item.number" :class="{ active: item.number === step, complete: item.number < step }">
|
||||
<span class="stepper-icon"><Check v-if="item.number < step" :size="16" /><component :is="item.icon" v-else :size="16" /></span>
|
||||
<span><small>{{ t('admin.shippingOrderProfiles.wizard.stepLabel', { step: item.number }) }}</small>{{ item.label }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
<!-- 步骤条迁移为 el-steps:active 绑当前步,完成步由 finish-status 出对勾 -->
|
||||
<el-steps
|
||||
:active="step - 1"
|
||||
align-center
|
||||
finish-status="success"
|
||||
class="wizard-steps"
|
||||
:aria-label="t('admin.shippingOrderProfiles.wizard.steps', { step })"
|
||||
>
|
||||
<el-step
|
||||
v-for="item in steps"
|
||||
:key="item.number"
|
||||
:title="item.label"
|
||||
:description="t('admin.shippingOrderProfiles.wizard.stepLabel', { step: item.number })"
|
||||
>
|
||||
<template #icon>
|
||||
<el-icon><Check v-if="item.number < step" /><component :is="item.icon" v-else /></el-icon>
|
||||
</template>
|
||||
</el-step>
|
||||
</el-steps>
|
||||
|
||||
<main class="wizard-card">
|
||||
<div class="wizard-card__heading">
|
||||
@@ -189,13 +213,19 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
</main>
|
||||
|
||||
<footer class="wizard-actions">
|
||||
<button type="button" class="btn-secondary" @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.cancel') }}</button>
|
||||
<el-button @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.cancel') }}</el-button>
|
||||
<span class="wizard-actions__spacer" />
|
||||
<button v-if="step > 1" type="button" class="btn-ghost" @click="step -= 1"><ArrowLeft :size="17" />{{ t('admin.shippingOrderProfiles.wizard.previous') }}</button>
|
||||
<button v-if="step < 3" type="button" class="btn-primary" :disabled="!canNext" @click="next">{{ t('admin.shippingOrderProfiles.wizard.next') }}<ArrowRight :size="17" /></button>
|
||||
<el-button v-if="step > 1" :icon="ArrowLeft" @click="step -= 1">{{ t('admin.shippingOrderProfiles.wizard.previous') }}</el-button>
|
||||
<el-button v-if="step < 3" type="primary" :disabled="!canNext" @click="next">
|
||||
{{ t('admin.shippingOrderProfiles.wizard.next') }}
|
||||
<el-icon class="el-icon--right"><ArrowRight /></el-icon>
|
||||
</el-button>
|
||||
<template v-else>
|
||||
<button type="button" class="btn-secondary" :disabled="saving || !canNext" @click="finish(false)">{{ t('admin.shippingOrderProfiles.wizard.createDraft') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving || !canNext" @click="finish(true)">{{ t('admin.shippingOrderProfiles.wizard.createAndEdit') }}<ArrowRight :size="17" /></button>
|
||||
<el-button :disabled="saving || !canNext" @click="finish(false)">{{ t('admin.shippingOrderProfiles.wizard.createDraft') }}</el-button>
|
||||
<el-button type="primary" :disabled="saving || !canNext" @click="finish(true)">
|
||||
{{ t('admin.shippingOrderProfiles.wizard.createAndEdit') }}
|
||||
<el-icon class="el-icon--right"><ArrowRight /></el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -203,11 +233,12 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wizard-page { min-height: 100%; padding: 24px; background: #f6f8fc; }
|
||||
/* 根容器不再自带水平 padding 与页面底色:由 Admin 壳层统一持有,页面只保留内部块间距 */
|
||||
.wizard-page { min-height: 100%; }
|
||||
.wizard-shell { width: 100%; }
|
||||
.wizard-heading { margin-bottom: 28px; }.wizard-heading h1, .wizard-heading p { margin: 0; }
|
||||
.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0 0 18px; padding: 0; list-style: none; }.stepper li { display: flex; align-items: center; gap: 10px; color: #94a3b8; font-size: .86rem; font-weight: 650; }.stepper li:not(:last-child)::after { width: 100%; height: 1px; margin-left: 10px; background: #dbe4f0; content: ''; }/* 步骤状态色统一 Tailwind 标准值:激活=brand-600、完成=green-600 */.stepper li.active { color: #0284c7; }.stepper li.complete { color: #16a34a; }.stepper-icon { display: inline-grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; border: 1px solid currentColor; border-radius: 50%; background: #fff; }.stepper .complete .stepper-icon { color: #fff; border-color: #16a34a; background: #16a34a; }.stepper small { display: block; margin-bottom: 1px; color: #94a3b8; font-size: .68rem; font-weight: 700; text-transform: uppercase; }
|
||||
.wizard-card { min-height: 360px; padding: clamp(24px, 4vw, 44px); border: 1px solid #e1e8f2; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgb(15 23 42 / .06); }.wizard-card__heading { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid #edf1f7; }.wizard-card__heading span { color: #0284c7; font-size: .76rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }.wizard-card__heading h2 { margin: 6px 0 0; color: #1e293b; font-size: 1.25rem; }
|
||||
.wizard-steps { margin: 0 0 18px; }
|
||||
.wizard-card { min-height: 360px; padding: clamp(24px, 4vw, 44px); border: 1px solid var(--el-border-color-light); border-radius: 12px; background: var(--el-bg-color); box-shadow: var(--el-box-shadow-light); }.wizard-card__heading { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid var(--el-border-color-lighter); }.wizard-card__heading span { color: var(--el-color-primary); font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }.wizard-card__heading h2 { margin: 6px 0 0; color: var(--el-text-color-primary); font-size: 1.25rem; }
|
||||
.wizard-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }.wizard-actions__spacer { flex: 1; }
|
||||
@media (max-width: 640px) { .wizard-page { padding: 24px 16px; }.stepper { grid-template-columns: 1fr; gap: 10px; }.stepper li:not(:last-child)::after { display: none; }.wizard-card { min-height: 300px; border-radius: 14px; }.wizard-actions { flex-wrap: wrap; }.wizard-actions__spacer { display: none; }.btn-secondary:first-child { margin-right: auto; } }
|
||||
@media (max-width: 640px) { .wizard-card { min-height: 300px; border-radius: 14px; }.wizard-actions { flex-wrap: wrap; }.wizard-actions__spacer { display: none; }.wizard-actions > .el-button:first-child { margin-right: auto; } }
|
||||
</style>
|
||||
+212
-261
@@ -15,6 +15,13 @@
|
||||
识别结果区:OCR 表头保留,datasets header_fields/lines 作正式值增量;保存后刷新 validation runs;
|
||||
整页 order-field OCR 可中止+超时,自动保存前取消,避免占满连接池卡在「保存中」;
|
||||
保存飞行中若又选了 datasets path,applySavedDraft 后 restoreConcurrentEdits,禁止冲掉未入库绑定。
|
||||
EP 迁移(定向,业务脚本零改动):页头/横幅/工具动作按钮迁移为 el-button(保存带 :loading);状态
|
||||
徽标迁移为 el-tag;三处自绘遮罩弹窗(datasets 选树 / 拆分规则 / 集合重确认)迁移为 el-dialog
|
||||
(单向 model-value + 关闭回调走原 close*() 函数,焦点陷阱 ref 与 destroy-on-close 保持原
|
||||
v-if 卸载语义,原「×」关闭按钮由 el-dialog 内置关闭键替代);右侧属性区原生 input/select
|
||||
迁移为 el-input / el-select(事件经内联适配保持原 handler 契约,识别结果行/未绑定 chip 保留
|
||||
原生按钮语义,与范式参考的 list-item 模式一致);@element-plus/icons-vue CSS 三件套已引入;
|
||||
画布组件(DocumentCanvas)几何/绘制逻辑未改动。脚本仅新增 import,无其他逻辑变更。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
@@ -28,6 +35,17 @@ import {
|
||||
} from "vue";
|
||||
import { onBeforeRouteLeave, useRoute, useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import {
|
||||
ElButton,
|
||||
ElDialog,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTag,
|
||||
} from "element-plus";
|
||||
import "element-plus/dist/index.css";
|
||||
import "element-plus/theme-chalk/dark/css-vars.css";
|
||||
import "@/features/admin/styles/element-trial.css";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { useMessage } from "@/shared/composables/useMessage";
|
||||
import { createRandomUuid } from "@/shared/utils/id";
|
||||
@@ -3424,41 +3442,37 @@ onBeforeUnmount(() => {
|
||||
<h1 class="section-title">{{ `${form.displayName || t("admin.shippingOrderProfiles.title")} · ${t("admin.shippingOrderProfiles.updateDraft")}` }}</h1>
|
||||
<p>
|
||||
{{ form.profileCode }}
|
||||
<span v-if="hasValueSourceMapping" class="template-mode-badge">{{ t('admin.shippingOrderProfiles.templateModes.xfa_dataset') }}</span>
|
||||
<el-tag v-if="hasValueSourceMapping" class="template-mode-badge" type="info" effect="plain" size="small">{{ t('admin.shippingOrderProfiles.templateModes.xfa_dataset') }}</el-tag>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<output class="save-status" :class="`save-status--${saveState}`">{{ t(`admin.shippingOrderProfiles.workbench.saveStatus.${saveState}`) }}</output>
|
||||
<el-tag class="save-status" :type="saveState === 'saved' ? 'success' : saveState === 'saving' ? 'primary' : 'danger'" effect="light">{{ t(`admin.shippingOrderProfiles.workbench.saveStatus.${saveState}`) }}</el-tag>
|
||||
<div v-if="saveState === 'readonly'" class="header-actions__lease">
|
||||
<button type="button" class="btn-secondary" @click="downloadLocalDraft">{{ t('admin.shippingOrderProfiles.workbench.headerExport') }}</button>
|
||||
<button type="button" class="btn-secondary" @click="() => void recoverEditLease()">{{ t('admin.shippingOrderProfiles.workbench.headerRecoverLease') }}</button>
|
||||
<button type="button" class="btn-secondary" @click="() => void recoverEditLease(true)">{{ t('admin.shippingOrderProfiles.workbench.headerTakeOverLease') }}</button>
|
||||
<el-button @click="downloadLocalDraft">{{ t('admin.shippingOrderProfiles.workbench.headerExport') }}</el-button>
|
||||
<el-button @click="() => void recoverEditLease()">{{ t('admin.shippingOrderProfiles.workbench.headerRecoverLease') }}</el-button>
|
||||
<el-button @click="() => void recoverEditLease(true)">{{ t('admin.shippingOrderProfiles.workbench.headerTakeOverLease') }}</el-button>
|
||||
</div>
|
||||
<output v-if="active && currentSampleIsTraining" class="training-sample-status">{{ t('admin.shippingOrderProfiles.workbench.headerTrainingSample') }}</output>
|
||||
<button
|
||||
<el-tag v-if="active && currentSampleIsTraining" class="training-sample-status" type="success" effect="light">{{ t('admin.shippingOrderProfiles.workbench.headerTrainingSample') }}</el-tag>
|
||||
<el-button
|
||||
v-else-if="active"
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
:disabled="!deskCanvasDocumentReady || saveState === 'readonly'"
|
||||
:disabled="!deskCanvasDocumentReady || saveState === 'readonly'"
|
||||
@click="() => void addCurrentTrainingSample()"
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.headerAddTrainingSample') }}</button>
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.headerAddTrainingSample') }}</el-button>
|
||||
<div class="header-actions__flow">
|
||||
<button
|
||||
<el-button
|
||||
v-if="active"
|
||||
type="button"
|
||||
type="primary"
|
||||
:disabled="deskSaveButtonDisabled"
|
||||
class="btn-primary"
|
||||
:loading="saving"
|
||||
@click="() => void save()"
|
||||
>{{ saving ? t("admin.shippingOrderProfiles.saving") : t("admin.shippingOrderProfiles.workbench.headerSaveDraft") }}</button>
|
||||
<button
|
||||
>{{ saving ? t("admin.shippingOrderProfiles.saving") : t("admin.shippingOrderProfiles.workbench.headerSaveDraft") }}</el-button>
|
||||
<el-button
|
||||
v-if="active"
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
:disabled="!draftSaveAdapter.canValidate"
|
||||
@click="validateProfile(active)"
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.headerValidate') }}</button>
|
||||
<button type="button" class="btn-secondary" @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.shippingOrderProfiles.workbench.headerReturnToLibrary') }}</button>
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.headerValidate') }}</el-button>
|
||||
<el-button @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.shippingOrderProfiles.workbench.headerReturnToLibrary') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@@ -3467,17 +3481,17 @@ onBeforeUnmount(() => {
|
||||
<template v-if="active">
|
||||
<div v-if="deskCanvasWarningVisible || canvasNeedsLayoutRecovery" class="canvas-warning">
|
||||
<span>{{ deskCanvasWarningVisible ? deskCanvasWarningText : t('admin.shippingOrderProfiles.workbench.noRecognizedTable') }}</span>
|
||||
<button v-if="deskCanvasWarningVisible" type="button" @click="onDeskCanvasRetry">
|
||||
<el-button v-if="deskCanvasWarningVisible" @click="onDeskCanvasRetry">
|
||||
{{ deskCanvasRetryLabel }}
|
||||
</button>
|
||||
<button
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canvasNeedsLayoutRecovery"
|
||||
type="button"
|
||||
:disabled="reparsingLayout"
|
||||
:loading="reparsingLayout"
|
||||
@click="() => void reprocessCurrentSampleLayout()"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.blindTest.reprocessLayout') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
<section v-if="suggestingRegions || pendingSuggestion" class="automark-status-panel" role="status" aria-live="polite">
|
||||
<div class="automark-status-panel__heading">
|
||||
@@ -3493,15 +3507,15 @@ onBeforeUnmount(() => {
|
||||
<div v-if="pendingSuggestion" class="automark-status-panel__body">
|
||||
<div v-if="pendingSuggestionIsOffCanvasPage" class="automark-candidate-page-notice" role="status">
|
||||
<span>{{ t('admin.shippingOrderProfiles.workbench.suggestionOnPage', { page: pendingSuggestionPageNo }) }}</span>
|
||||
<button type="button" class="btn-secondary" @click="returnToPendingSuggestionPage">{{ t('admin.shippingOrderProfiles.workbench.returnToSuggestionPage') }}</button>
|
||||
<el-button @click="returnToPendingSuggestionPage">{{ t('admin.shippingOrderProfiles.workbench.returnToSuggestionPage') }}</el-button>
|
||||
</div>
|
||||
<div v-if="hasAutomarkTableChoice" class="automark-choice-block">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.workbench.autoSuggestEvidenceSource') }}
|
||||
<select :value="selectedAutomarkTableSource" class="select-field" :disabled="saveState === 'readonly'" @change="(event) => void chooseAutomarkTableSource((event.target as HTMLSelectElement).value)">
|
||||
<option value="">{{ t('admin.shippingOrderProfiles.workbench.autoSuggestChooseEvidence') }}</option>
|
||||
<option v-for="candidate in automarkTableCandidates" :key="candidate.source" :value="candidate.source">{{ candidate.source }}</option>
|
||||
</select>
|
||||
<el-select :model-value="selectedAutomarkTableSource" :disabled="saveState === 'readonly'" @update:model-value="(value) => void chooseAutomarkTableSource(String(value))">
|
||||
<el-option value="" :label="t('admin.shippingOrderProfiles.workbench.autoSuggestChooseEvidence')" />
|
||||
<el-option v-for="candidate in automarkTableCandidates" :key="candidate.source" :value="candidate.source" :label="candidate.source" />
|
||||
</el-select>
|
||||
</label>
|
||||
<div class="suggestion-evidence-summary" aria-label="automark evidence summaries">
|
||||
<span v-for="summary in automarkTableCandidateSummaries" :key="summary.source" :class="{ 'is-conflict': summary.conflictCodes.length > 0 }">
|
||||
@@ -3513,17 +3527,17 @@ onBeforeUnmount(() => {
|
||||
<div v-if="automarkFieldConflicts.length > 0" class="automark-choice-block automark-choice-block--fields">
|
||||
<label v-for="conflict in automarkFieldConflicts" :key="conflict.field_id">
|
||||
{{ conflict.field_code || conflict.field_id }} · {{ t('admin.shippingOrderProfiles.workbench.autoSuggestEvidenceSource') }}
|
||||
<select :value="selectedAutomarkFieldSources[conflict.field_id] || ''" class="select-field" :disabled="saveState === 'readonly'" @change="(event) => void chooseAutomarkFieldSource(conflict.field_id, (event.target as HTMLSelectElement).value)">
|
||||
<option value="">{{ t('admin.shippingOrderProfiles.workbench.autoSuggestChooseEvidence') }}</option>
|
||||
<option v-for="source in conflict.sources" :key="source" :value="source">{{ source }}</option>
|
||||
</select>
|
||||
<el-select :model-value="selectedAutomarkFieldSources[conflict.field_id] || ''" :disabled="saveState === 'readonly'" @update:model-value="(value) => void chooseAutomarkFieldSource(conflict.field_id, String(value))">
|
||||
<el-option value="" :label="t('admin.shippingOrderProfiles.workbench.autoSuggestChooseEvidence')" />
|
||||
<el-option v-for="source in conflict.sources" :key="source" :value="source" :label="source" />
|
||||
</el-select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="automark-status-panel__actions">
|
||||
<select v-model="suggestionAdjustmentField" class="select-field" :disabled="saveState === 'readonly'" :aria-label="t('admin.shippingOrderProfiles.workbench.suggestionAdjustmentField')"><option value="">{{ t('admin.shippingOrderProfiles.workbench.suggestionAdjustmentField') }}</option><option v-for="field in lineFields" :key="field.field_code" :value="field.field_code">{{ field.display_name }} · {{ field.field_code }}</option></select>
|
||||
<button type="button" class="btn-primary" :disabled="saveState === 'readonly' || automarkTableChoiceRequired || automarkFieldChoiceRequired" @click="() => void decidePendingSuggestion('accepted')">{{ t('admin.shippingOrderProfiles.workbench.acceptSuggestion') }}</button>
|
||||
<button type="button" class="btn-secondary" :disabled="saveState === 'readonly' || !suggestionAdjustmentField" @click="() => void decidePendingSuggestion('accepted_adjusted')">{{ t('admin.shippingOrderProfiles.workbench.acceptAdjustedSuggestion') }}</button>
|
||||
<button type="button" class="btn-secondary" :disabled="saveState === 'readonly'" @click="() => void decidePendingSuggestion('rejected')">{{ t('admin.shippingOrderProfiles.workbench.rejectSuggestion') }}</button>
|
||||
<el-select v-model="suggestionAdjustmentField" :disabled="saveState === 'readonly'" :aria-label="t('admin.shippingOrderProfiles.workbench.suggestionAdjustmentField')"><el-option value="" :label="t('admin.shippingOrderProfiles.workbench.suggestionAdjustmentField')" /><el-option v-for="field in lineFields" :key="field.field_code" :value="field.field_code as string" :label="`${field.display_name} · ${field.field_code}`" /></el-select>
|
||||
<el-button type="primary" :disabled="saveState === 'readonly' || automarkTableChoiceRequired || automarkFieldChoiceRequired" @click="() => void decidePendingSuggestion('accepted')">{{ t('admin.shippingOrderProfiles.workbench.acceptSuggestion') }}</el-button>
|
||||
<el-button :disabled="saveState === 'readonly' || !suggestionAdjustmentField" @click="() => void decidePendingSuggestion('accepted_adjusted')">{{ t('admin.shippingOrderProfiles.workbench.acceptAdjustedSuggestion') }}</el-button>
|
||||
<el-button :disabled="saveState === 'readonly'" @click="() => void decidePendingSuggestion('rejected')">{{ t('admin.shippingOrderProfiles.workbench.rejectSuggestion') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -3536,14 +3550,14 @@ onBeforeUnmount(() => {
|
||||
<p>
|
||||
{{ t('admin.shippingOrderProfiles.workbench.unboundRegionsBanner', { count: unboundOrderFieldRegions.length }) }}
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary unbound-regions-banner__clear"
|
||||
<el-button
|
||||
class="unbound-regions-banner__clear"
|
||||
size="small"
|
||||
:disabled="saveState === 'readonly'"
|
||||
@click="clearUnboundOrderFieldRegions"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.workbench.clearUnboundRegions') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="unbound-regions-banner__list">
|
||||
<button
|
||||
@@ -3629,22 +3643,19 @@ onBeforeUnmount(() => {
|
||||
|
||||
<section v-if="!hasValueSourceMapping && active" class="reservation-region-config">
|
||||
<strong>Reservation ID 证据区域</strong>
|
||||
<p>只需圈选包含 Reservation ID 的备注区域;系统统一解析:无行号写订单头,带行号写对应明细。</p>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@click="onDeskCanvasDraw('reservation_id_region')"
|
||||
>
|
||||
{{ reservationIdRegion ? '重新标记 Reservation ID 区域' : '标记 Reservation ID 区域' }}
|
||||
</button>
|
||||
<button
|
||||
<p>使用左侧「{{ t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut') }}」工具,圈选包含 Reservation ID 的备注区域;系统统一解析:无行号写订单头,带行号写对应明细。</p>
|
||||
<!-- 标记入口只在左侧画布工具栏(同一 creationKind 路径),此处不再重复放置长按钮 -->
|
||||
<el-button
|
||||
v-if="reservationIdRegion"
|
||||
type="button"
|
||||
size="small"
|
||||
type="danger"
|
||||
plain
|
||||
class="reservation-region-config__clear"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@click="clearReservationIdRegion"
|
||||
>
|
||||
清除区域
|
||||
</button>
|
||||
</el-button>
|
||||
<small v-if="reservationIdRegion">已标记第 {{ reservationIdRegion.page_no }} 页区域;正式取值按 Vendor Comments→Terms 锚点,与验证/盲测/正式解析一致。</small>
|
||||
<p v-if="reservationIdCandidateState === 'loading'" class="reservation-region-config__status">正在识别 Reservation ID…</p>
|
||||
<p v-else-if="reservationIdCandidateState === 'failed'" class="reservation-region-config__status">区域预览失败;保存后可在盲测/复核中再次确认。</p>
|
||||
@@ -3691,83 +3702,76 @@ onBeforeUnmount(() => {
|
||||
<template v-if="selectedRegion">
|
||||
<label
|
||||
>{{ t("admin.shippingOrderProfiles.workbench.label")
|
||||
}}<input
|
||||
}}<el-input
|
||||
v-model="selectedRegion.label"
|
||||
class="input-field"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFormEdit"
|
||||
@change="finishFormEdit" /></label
|
||||
><label v-if="selectedRegion.kind === 'field'"
|
||||
>{{ t("admin.shippingOrderProfiles.workbench.lineLayout")
|
||||
}}<select
|
||||
}}<el-select
|
||||
v-model="selectedRegion.parentId"
|
||||
class="select-field"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFormEdit"
|
||||
@change="finishFormEdit"
|
||||
>
|
||||
<option
|
||||
<el-option
|
||||
v-for="line in pageRegions.filter(
|
||||
(item) => item.kind === 'line',
|
||||
)"
|
||||
:key="line.id"
|
||||
:value="line.id"
|
||||
>
|
||||
{{ line.label }}
|
||||
</option>
|
||||
</select></label
|
||||
:label="line.label"
|
||||
/>
|
||||
</el-select></label
|
||||
><label v-if="selectedRegion.kind === 'line'"
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.tableRegionRole')
|
||||
}}<select
|
||||
:value="selectedRegion.tableRegionRole || 'business_lines'"
|
||||
class="select-field"
|
||||
}}<el-select
|
||||
:model-value="selectedRegion.tableRegionRole || 'business_lines'"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFormEdit"
|
||||
@change="onSelectedLineTableRegionRoleChange"
|
||||
@update:model-value="(value) => onSelectedLineTableRegionRoleChange({ target: { value: String(value) } } as unknown as Event)"
|
||||
>
|
||||
<option value="business_lines">{{ t('admin.shippingOrderProfiles.workbench.tableRegionRoles.business_lines') }}</option>
|
||||
<option value="line_field_supplement">{{ t('admin.shippingOrderProfiles.workbench.tableRegionRoles.line_field_supplement') }}</option>
|
||||
</select>
|
||||
<el-option value="business_lines" :label="t('admin.shippingOrderProfiles.workbench.tableRegionRoles.business_lines')" />
|
||||
<el-option value="line_field_supplement" :label="t('admin.shippingOrderProfiles.workbench.tableRegionRoles.line_field_supplement')" />
|
||||
</el-select>
|
||||
<small>{{ t('admin.shippingOrderProfiles.workbench.tableRegionRoleHint') }}</small>
|
||||
</label
|
||||
><label v-if="['header_field', 'field', 'order_field'].includes(selectedRegion.kind)"
|
||||
>{{ t("admin.shippingOrderProfiles.workbench.schemaField")
|
||||
}}<select
|
||||
}}<el-select
|
||||
v-model="selectedRegion.fieldCode"
|
||||
class="select-field"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFieldBindingEdit"
|
||||
@change="finishFieldBindingEdit"
|
||||
>
|
||||
<option :value="null">
|
||||
{{ t("admin.shippingOrderProfiles.workbench.selectField") }}
|
||||
</option>
|
||||
<option
|
||||
<el-option :value="null as unknown as string" :label="t('admin.shippingOrderProfiles.workbench.selectField')" />
|
||||
<el-option
|
||||
v-for="field in (selectedRegion.kind === 'order_field' ? selectableOrderHeaderFields : lineFields)"
|
||||
:key="field.field_id"
|
||||
:value="field.field_code"
|
||||
>
|
||||
{{ field.display_name }} · {{ field.field_code }}
|
||||
</option>
|
||||
</select></label
|
||||
:value="field.field_code as string"
|
||||
:label="`${field.display_name} · ${field.field_code}`"
|
||||
/>
|
||||
</el-select></label
|
||||
>
|
||||
<template v-if="selectedRegion.kind === 'order_field'">
|
||||
<label>{{ t("admin.shippingOrderProfiles.workbench.orderFieldValueMode") }}<select v-model="selectedRegion.valueMode" class="select-field" :disabled="compactEditor || saveState === 'readonly'" @focus="beginFormEdit" @change="finishFormEdit">
|
||||
<option value="single_line">{{ t("admin.shippingOrderProfiles.workbench.orderFieldModes.singleLine") }}</option>
|
||||
<option value="right_of_anchor">{{ t("admin.shippingOrderProfiles.workbench.orderFieldModes.rightOfAnchor") }}</option>
|
||||
<option value="below_anchor">{{ t("admin.shippingOrderProfiles.workbench.orderFieldModes.belowAnchor") }}</option>
|
||||
<option value="multi_line">{{ t("admin.shippingOrderProfiles.workbench.orderFieldModes.multiLine") }}</option>
|
||||
</select></label>
|
||||
<label v-if="selectedRegion.valueMode === 'multi_line'">{{ t("admin.shippingOrderProfiles.workbench.orderFieldStopAnchor") }}<input v-model="selectedRegion.stopAnchorText" class="input-field" :disabled="compactEditor || saveState === 'readonly'" :placeholder="t('admin.shippingOrderProfiles.workbench.orderFieldStopAnchorPlaceholder')" @focus="beginFormEdit" @change="finishFormEdit" /></label>
|
||||
<label>{{ t("admin.shippingOrderProfiles.workbench.orderFieldValueMode") }}<el-select v-model="selectedRegion.valueMode" :disabled="compactEditor || saveState === 'readonly'" @focus="beginFormEdit" @change="finishFormEdit">
|
||||
<el-option value="single_line" :label="t('admin.shippingOrderProfiles.workbench.orderFieldModes.singleLine')" />
|
||||
<el-option value="right_of_anchor" :label="t('admin.shippingOrderProfiles.workbench.orderFieldModes.rightOfAnchor')" />
|
||||
<el-option value="below_anchor" :label="t('admin.shippingOrderProfiles.workbench.orderFieldModes.belowAnchor')" />
|
||||
<el-option value="multi_line" :label="t('admin.shippingOrderProfiles.workbench.orderFieldModes.multiLine')" />
|
||||
</el-select></label>
|
||||
<label v-if="selectedRegion.valueMode === 'multi_line'">{{ t("admin.shippingOrderProfiles.workbench.orderFieldStopAnchor") }}<el-input v-model="selectedRegion.stopAnchorText" :disabled="compactEditor || saveState === 'readonly'" :placeholder="t('admin.shippingOrderProfiles.workbench.orderFieldStopAnchorPlaceholder')" @focus="beginFormEdit" @change="finishFormEdit" /></label>
|
||||
</template>
|
||||
<button
|
||||
<el-button
|
||||
v-if="
|
||||
selectedRegion.kind === 'field' &&
|
||||
selectedFieldHeaderSuggestion &&
|
||||
selectedFieldHeaderSuggestion !== selectedRegion.fieldCode
|
||||
"
|
||||
type="button"
|
||||
class="binding-suggestion"
|
||||
type="primary"
|
||||
plain
|
||||
@click="
|
||||
applyFieldBindingSuggestion(
|
||||
selectedRegion.id,
|
||||
@@ -3780,15 +3784,15 @@ onBeforeUnmount(() => {
|
||||
field: previewFieldLabel(selectedFieldHeaderSuggestion),
|
||||
})
|
||||
}}
|
||||
</button>
|
||||
</el-button>
|
||||
<template v-if="selectedRegion.kind === 'header_field'">
|
||||
<button type="button" @click="suggestHeaders(true)">
|
||||
<el-button @click="suggestHeaders(true)">
|
||||
{{ t("admin.shippingOrderProfiles.workbench.matchCurrentHeader") }}
|
||||
</button>
|
||||
<button type="button" @click="suggestHeaders(false)">
|
||||
</el-button>
|
||||
<el-button @click="suggestHeaders(false)">
|
||||
{{ t("admin.shippingOrderProfiles.workbench.matchAllHeaders") }}
|
||||
</button>
|
||||
<button
|
||||
</el-button>
|
||||
<el-button
|
||||
v-for="entry in headerSuggestions
|
||||
.filter(
|
||||
(item) => item.layout_id === selectedHeaderLayoutId,
|
||||
@@ -3804,8 +3808,9 @@ onBeforeUnmount(() => {
|
||||
})),
|
||||
)"
|
||||
:key="`${entry.regionId}-${entry.field.text}`"
|
||||
type="button"
|
||||
class="binding-suggestion"
|
||||
type="primary"
|
||||
plain
|
||||
:disabled="!entry.regionId || !entry.field.field_code"
|
||||
@click="
|
||||
entry.regionId &&
|
||||
@@ -3832,7 +3837,7 @@ onBeforeUnmount(() => {
|
||||
{ text: entry.field.text || "-" },
|
||||
)
|
||||
}}
|
||||
</button>
|
||||
</el-button>
|
||||
</template>
|
||||
<p>{{ t("admin.shippingOrderProfiles.workbench.dragHint") }}</p>
|
||||
</template>
|
||||
@@ -3841,15 +3846,13 @@ onBeforeUnmount(() => {
|
||||
<template v-if="hasValueSourceMapping && ['order_field', 'header_field', 'field'].includes(selectedRegion?.kind || '')">
|
||||
<template v-if="valueAdapterDesk.showDatasetsSection">
|
||||
<label class="xfa-incremental-field">{{ t('admin.shippingOrderProfiles.xfaDesk.datasourceField') }}
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
<el-button
|
||||
:disabled="xfaConfigReadonly || valueAdapterDesk.loading || !valueAdapterDesk.tree"
|
||||
:title="valueAdapterDesk.selectedPathLabel || t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPath')"
|
||||
@click="valueAdapterDesk.openDatasetsPicker()"
|
||||
>
|
||||
{{ valueAdapterDesk.selectedPathLabel || t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPath') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</label>
|
||||
<section class="sample-value-card">
|
||||
<span>{{ t('admin.shippingOrderProfiles.xfaDesk.datasetsSampleValue') }}</span>
|
||||
@@ -3867,14 +3870,12 @@ onBeforeUnmount(() => {
|
||||
confirmed: valueAdapterDesk.splitRuleSummary.confirmed,
|
||||
}) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
<el-button
|
||||
:disabled="xfaConfigReadonly || !valueAdapterDesk.selectedPathId"
|
||||
@click="valueAdapterDesk.openSplitRulesForSelection()"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.editRules') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</label>
|
||||
<p class="xfa-header-inheritance-hint">{{ t('admin.shippingOrderProfiles.xfaSplit.splitVisualReuseHint') }}</p>
|
||||
<section class="xfa-datasource-summary">
|
||||
@@ -3883,14 +3884,12 @@ onBeforeUnmount(() => {
|
||||
authoritative: valueAdapterDesk.collectionSummaryLabel.authoritative,
|
||||
mirrors: valueAdapterDesk.collectionSummaryLabel.mirrors,
|
||||
}) }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
<el-button
|
||||
:disabled="saveState === 'readonly'"
|
||||
@click="valueAdapterDesk.openReconfirmCollections()"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollections') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -3938,34 +3937,33 @@ onBeforeUnmount(() => {
|
||||
<p v-if="!deskLineRecognitionResults.length" class="recognition-empty">{{ t('admin.shippingOrderProfiles.workbench.noRecognitionResults') }}</p>
|
||||
<div v-if="canRepairMainTable" class="main-table-repair">
|
||||
<p>{{ t('admin.shippingOrderProfiles.workbench.mainTableRepairHint') }}</p>
|
||||
<select class="select-field" :disabled="repairingMainTable" @change="(event) => { requestMainTableRepair((event.target as HTMLSelectElement).value); (event.target as HTMLSelectElement).value = ''; }">
|
||||
<option value="">{{ t('admin.shippingOrderProfiles.workbench.mainTableRepairChoose') }}</option>
|
||||
<option v-for="candidate in mainTableRepairCandidates" :key="candidate.table_id" :value="candidate.table_id">
|
||||
{{ t('admin.shippingOrderProfiles.workbench.mainTableRepairCandidate', { page: candidate.page_no, rows: candidate.row_count, columns: candidate.column_count }) }}
|
||||
</option>
|
||||
</select>
|
||||
<el-select :model-value="''" :disabled="repairingMainTable" @update:model-value="(value) => { if (value) requestMainTableRepair(String(value)); }">
|
||||
<el-option value="" :label="t('admin.shippingOrderProfiles.workbench.mainTableRepairChoose')" />
|
||||
<el-option v-for="candidate in mainTableRepairCandidates" :key="candidate.table_id" :value="candidate.table_id" :label="t('admin.shippingOrderProfiles.workbench.mainTableRepairCandidate', { page: candidate.page_no, rows: candidate.row_count, columns: candidate.column_count })" />
|
||||
</el-select>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div
|
||||
v-if="hasValueSourceMapping && valueAdapterDesk.datasetsPickerOpen"
|
||||
class="xfa-rule-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
<!-- EP 迁移:自绘遮罩弹窗 → el-dialog;单向 model-value,关闭统一回调原 close*() 以保留 composable 清理逻辑 -->
|
||||
<el-dialog
|
||||
v-if="hasValueSourceMapping"
|
||||
:model-value="valueAdapterDesk.datasetsPickerOpen"
|
||||
width="min(920px, 96vw)"
|
||||
top="4vh"
|
||||
destroy-on-close
|
||||
class="xfa-picker-dialog"
|
||||
:aria-label="t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPathTitle')"
|
||||
@keydown.esc.stop.prevent="valueAdapterDesk.closeDatasetsPicker()"
|
||||
@update:model-value="valueAdapterDesk.closeDatasetsPicker()"
|
||||
>
|
||||
<div class="xfa-rule-dialog__backdrop" @click="valueAdapterDesk.closeDatasetsPicker()" />
|
||||
<section :ref="assignXfaDatasetsPickerPanel" class="xfa-rule-dialog__panel xfa-datasets-picker-panel">
|
||||
<header class="xfa-rule-dialog__header">
|
||||
<div>
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPathTitle') }}</strong>
|
||||
<p>{{ t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPathHint') }}</p>
|
||||
</div>
|
||||
<button type="button" class="xfa-rule-dialog__close" :aria-label="t('common.close')" @click="valueAdapterDesk.closeDatasetsPicker()">×</button>
|
||||
</header>
|
||||
<template #header>
|
||||
<div class="xfa-rule-dialog__heading">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPathTitle') }}</strong>
|
||||
<p>{{ t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPathHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<section :ref="assignXfaDatasetsPickerPanel" class="xfa-datasets-picker-panel">
|
||||
<div class="xfa-datasets-picker-body">
|
||||
<XfaDatasetTree
|
||||
expand-samples
|
||||
@@ -3981,35 +3979,25 @@ onBeforeUnmount(() => {
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<div
|
||||
v-if="hasValueSourceMapping && valueAdapterDesk.splitRuleDialogOpen"
|
||||
class="xfa-rule-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
@keydown.esc.stop.prevent="valueAdapterDesk.closeSplitRuleDialog()"
|
||||
<el-dialog
|
||||
v-if="hasValueSourceMapping"
|
||||
:model-value="valueAdapterDesk.splitRuleDialogOpen"
|
||||
width="min(860px, 94vw)"
|
||||
top="5vh"
|
||||
destroy-on-close
|
||||
class="xfa-split-dialog"
|
||||
:aria-label="t('admin.shippingOrderProfiles.xfaSplit.title')"
|
||||
@update:model-value="valueAdapterDesk.closeSplitRuleDialog()"
|
||||
>
|
||||
<div class="xfa-rule-dialog__backdrop" @click="valueAdapterDesk.closeSplitRuleDialog()" />
|
||||
<section :ref="assignXfaSplitDialogPanel" class="xfa-rule-dialog__panel">
|
||||
<header class="xfa-rule-dialog__header">
|
||||
<div>
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaSplit.title') }}</strong>
|
||||
<p>{{ valueAdapterDesk.selectedPathLabel }}</p>
|
||||
</div>
|
||||
<div class="xfa-rule-dialog__actions">
|
||||
<button type="button" class="btn-secondary" :disabled="saveState === 'readonly'" @click="valueAdapterDesk.splitRulePanel?.addRule()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.addRule') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary" :disabled="!valueAdapterDesk.dialogHasRules" @click="valueAdapterDesk.splitRulePanel?.runPreview()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.preview') }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary" :disabled="saveState === 'readonly' || !valueAdapterDesk.dialogHasRules" @click="valueAdapterDesk.splitRulePanel?.confirmRules()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.confirm') }}
|
||||
</button>
|
||||
<button type="button" class="xfa-rule-dialog__close" :aria-label="t('common.close')" @click="valueAdapterDesk.closeSplitRuleDialog()">×</button>
|
||||
</div>
|
||||
</header>
|
||||
<template #header>
|
||||
<div class="xfa-rule-dialog__heading">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaSplit.title') }}</strong>
|
||||
<p>{{ valueAdapterDesk.selectedPathLabel }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<section :ref="assignXfaSplitDialogPanel" class="xfa-split-dialog-panel">
|
||||
<XfaSplitRulePanel
|
||||
v-if="active && (valueAdapterDesk.dialogDefinition || valueAdapterDesk.definition)"
|
||||
:ref="assignXfaSplitRulePanel"
|
||||
@@ -4031,24 +4019,38 @@ onBeforeUnmount(() => {
|
||||
@confirmed="valueAdapterDesk.commitDialogSplitRules"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="xfa-rule-dialog__actions">
|
||||
<el-button :disabled="saveState === 'readonly'" @click="valueAdapterDesk.splitRulePanel?.addRule()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.addRule') }}
|
||||
</el-button>
|
||||
<el-button :disabled="!valueAdapterDesk.dialogHasRules" @click="valueAdapterDesk.splitRulePanel?.runPreview()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.preview') }}
|
||||
</el-button>
|
||||
<el-button type="primary" :disabled="saveState === 'readonly' || !valueAdapterDesk.dialogHasRules" @click="valueAdapterDesk.splitRulePanel?.confirmRules()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<div
|
||||
v-if="hasValueSourceMapping && valueAdapterDesk.reconfirmCollectionsOpen"
|
||||
class="xfa-rule-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
@keydown.esc.stop.prevent="valueAdapterDesk.closeReconfirmCollections()"
|
||||
<el-dialog
|
||||
v-if="hasValueSourceMapping"
|
||||
:model-value="valueAdapterDesk.reconfirmCollectionsOpen"
|
||||
width="min(720px, 94vw)"
|
||||
top="6vh"
|
||||
destroy-on-close
|
||||
class="xfa-reconfirm-dialog"
|
||||
:aria-label="t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsTitle')"
|
||||
@update:model-value="valueAdapterDesk.closeReconfirmCollections()"
|
||||
>
|
||||
<div class="xfa-rule-dialog__backdrop" @click="valueAdapterDesk.closeReconfirmCollections()" />
|
||||
<section class="xfa-rule-dialog__panel xfa-reconfirm-panel">
|
||||
<header class="xfa-rule-dialog__header">
|
||||
<div>
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsTitle') }}</strong>
|
||||
<p>{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsHint') }}</p>
|
||||
</div>
|
||||
<button type="button" class="xfa-rule-dialog__close" :aria-label="t('common.close')" @click="valueAdapterDesk.closeReconfirmCollections()">×</button>
|
||||
</header>
|
||||
<template #header>
|
||||
<div class="xfa-rule-dialog__heading">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsTitle') }}</strong>
|
||||
<p>{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<div class="xfa-reconfirm-body">
|
||||
<XfaCollectionSelector
|
||||
:candidates="valueAdapterDesk.collections"
|
||||
:authoritative-path-id="valueAdapterDesk.draftAuthoritativePathId"
|
||||
@@ -4057,14 +4059,16 @@ onBeforeUnmount(() => {
|
||||
@update:authoritative-path-id="(id) => { valueAdapterDesk.draftAuthoritativePathId = id; }"
|
||||
@update:mirror-path-ids="(ids) => { valueAdapterDesk.draftMirrorPathIds = ids; }"
|
||||
/>
|
||||
<footer class="xfa-reconfirm-actions">
|
||||
<button type="button" class="btn-secondary" @click="valueAdapterDesk.closeReconfirmCollections()">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" @click="valueAdapterDesk.confirmReconfirmCollections()">
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="xfa-reconfirm-actions">
|
||||
<el-button @click="valueAdapterDesk.closeReconfirmCollections()">{{ t('common.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="valueAdapterDesk.confirmReconfirmCollections()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsConfirm') }}
|
||||
</button>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<DeleteConfirmDialog
|
||||
v-model="mainTableRepairConfirmOpen"
|
||||
@@ -4105,8 +4109,6 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
.template-mode-badge {
|
||||
margin-left: 0.5rem;
|
||||
color: #0369a1;
|
||||
font-weight: 700;
|
||||
}
|
||||
/* XFA 增量模块样式:禁止改共用 desk 网格/列宽/高度/滚动 */
|
||||
.xfa-candidate-inline {
|
||||
@@ -4191,50 +4193,18 @@ onBeforeUnmount(() => {
|
||||
gap: 8px;
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
.xfa-rule-dialog { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 24px; }
|
||||
.xfa-rule-dialog__backdrop { position: absolute; inset: 0; background: rgb(15 23 42 / .42); }
|
||||
.xfa-rule-dialog__panel {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: min(860px, 94vw);
|
||||
max-height: min(820px, 90vh);
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 0.75rem;
|
||||
background: #fff;
|
||||
box-shadow: 0 24px 70px rgb(15 23 42 / .24);
|
||||
}
|
||||
.xfa-rule-dialog__header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 14px 16px;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
.xfa-rule-dialog__header p { margin: 3px 0 0; color: #64748b; font-size: 0.76rem; }
|
||||
/* EP 迁移:三处自绘遮罩弹窗 → el-dialog;此处仅保留标题副文案、内容滚动尺寸与 footer 布局,
|
||||
遮罩/关闭键/ESC/焦点由 el-dialog 内建(关闭统一回调原 close*() 函数) */
|
||||
.xfa-rule-dialog__heading strong { display: block; font-size: 1rem; }
|
||||
.xfa-rule-dialog__heading p { margin: 3px 0 0; color: var(--el-text-color-secondary); font-size: 0.76rem; font-weight: 400; }
|
||||
.xfa-picker-dialog :deep(.el-dialog__body) { padding-top: 4px; }
|
||||
.xfa-datasets-picker-panel { display: flex; max-height: min(720px, 78vh); flex-direction: column; overflow: hidden; }
|
||||
.xfa-datasets-picker-body { display: flex; min-height: 0; flex: 1; flex-direction: column; overflow: hidden; padding: 12px 0 0; }
|
||||
.xfa-datasets-picker-body :deep(.xfa-tree) { min-height: 420px; }
|
||||
.xfa-split-dialog-panel { display: flex; min-height: 0; max-height: min(640px, 72vh); overflow: auto; flex-direction: column; }
|
||||
.xfa-reconfirm-body { max-height: min(560px, 66vh); overflow: auto; }
|
||||
.xfa-rule-dialog__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
|
||||
.xfa-rule-dialog__close {
|
||||
display: inline-grid;
|
||||
width: 34px;
|
||||
padding: 0;
|
||||
place-items: center;
|
||||
border: 0;
|
||||
border-radius: 0.45rem;
|
||||
background: transparent;
|
||||
color: #64748b;
|
||||
cursor: pointer;
|
||||
font-size: 1.15rem;
|
||||
}
|
||||
.xfa-reconfirm-panel { width: min(720px, 94vw); padding-bottom: 12px; }
|
||||
.xfa-reconfirm-panel > .xfa-collections { overflow: auto; padding: 12px 16px; min-height: 0; }
|
||||
.xfa-reconfirm-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 12px 16px;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
.xfa-reconfirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
|
||||
.link { border: 0; background: transparent; color: #0369a1; cursor: pointer; }
|
||||
.schema-warning,
|
||||
.schema-hint {
|
||||
@@ -4257,10 +4227,9 @@ onBeforeUnmount(() => {
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.config button,
|
||||
.page-nav button,
|
||||
.blind-test button,
|
||||
.canvas-warning button {
|
||||
/* EP 迁移:动作按钮已迁 el-button(样式交给 element-trial 主题);此规则仅保留
|
||||
识别结果行(recognition-row)这类原生列表按钮的基底外观 */
|
||||
.config button:not(.el-button) {
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 0.45rem;
|
||||
background: white;
|
||||
@@ -4317,22 +4286,15 @@ onBeforeUnmount(() => {
|
||||
color: #b91c1c;
|
||||
font-size: 0.72rem;
|
||||
}
|
||||
/* EP 迁移:原生 input/select → el-input / el-select;label 内控件占满整行 */
|
||||
.editor label {
|
||||
color: #475569;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.editor .input-field,
|
||||
.editor .select-field {
|
||||
display: block;
|
||||
.editor label :deep(.el-input),
|
||||
.editor label :deep(.el-select) {
|
||||
width: 100%;
|
||||
margin-top: 0.3rem;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 0.35rem;
|
||||
background: white;
|
||||
padding: 0.45rem;
|
||||
color: #172033;
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
.desk {
|
||||
display: grid;
|
||||
@@ -4457,8 +4419,9 @@ onBeforeUnmount(() => {
|
||||
display: grid;
|
||||
gap: 0.45rem;
|
||||
padding: 0.85rem;
|
||||
background: #f8fafc;
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
.reservation-region-config__clear { justify-self: start; }
|
||||
.reservation-region-config p,
|
||||
.reservation-region-config small {
|
||||
margin: 0;
|
||||
@@ -4555,9 +4518,6 @@ onBeforeUnmount(() => {
|
||||
.editor .binding-suggestion {
|
||||
width: 100%;
|
||||
margin-top: 0.5rem;
|
||||
border-color: var(--status-info-border);
|
||||
background: var(--status-info-bg);
|
||||
color: var(--status-info-fg);
|
||||
text-align: left;
|
||||
}
|
||||
.empty {
|
||||
@@ -4642,16 +4602,16 @@ onBeforeUnmount(() => {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
.save-status,
|
||||
.training-sample-status { border-radius: 999px; background: #e2e8f0; padding: .4rem .6rem; color: #334155; font-size: .72rem; }
|
||||
.save-status--saving { background: #dbeafe; color: #1d4ed8; }.save-status--failed,.save-status--readonly { background: #fee2e2; color: #b91c1c; }.save-status--saved { background: #dcfce7; color: #166534; }
|
||||
.training-sample-status { background: #dcfce7; color: #166534; }
|
||||
.editor-workbench { padding: 0; background: #0f172a; }
|
||||
.training-sample-status { margin-right: .25rem; }
|
||||
/* EP 迁移:保存状态/训练样本/模板模式徽标 → el-tag(类型映射:saved=success /
|
||||
saving=primary / failed|readonly=danger;训练样本=success;模板模式=info plain) */
|
||||
.editor-workbench { padding: 0; background: var(--el-fill-color-light); }
|
||||
.editor-mode-error {
|
||||
display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
|
||||
margin: 24px; padding: 20px; border: 1px solid #fecaca; border-radius: 0.75rem; background: #fef2f2; color: #991b1b;
|
||||
}
|
||||
.editor-workbench .bench-header { max-width: none; padding: .7rem 1rem; color: #e2e8f0; }
|
||||
.editor-workbench .bench-header p { color: #94a3b8; }
|
||||
.editor-workbench .bench-header { max-width: none; padding: .7rem 1rem; color: var(--el-text-color-primary); }
|
||||
.editor-workbench .bench-header p { color: var(--el-text-color-secondary); }
|
||||
.editor-title { min-width: 0; }
|
||||
.editor-workbench .desk { max-width: none; min-height: calc(100vh - 7rem); border-inline: 0; box-shadow: none; }
|
||||
.editor-desk { grid-template-columns: minmax(0, 1fr) 20rem; }
|
||||
@@ -4714,7 +4674,7 @@ onBeforeUnmount(() => {
|
||||
.automark-choice-block label { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; color: #334155; font-size: .74rem; font-weight: 700; }
|
||||
.automark-choice-block--fields { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
|
||||
.automark-status-panel__actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
|
||||
.automark-status-panel__actions .select-field { min-width: 12rem; }
|
||||
.automark-status-panel__actions .el-select { min-width: 12rem; }
|
||||
@media (max-width: 640px) {
|
||||
.automark-status-panel { top: 0; }
|
||||
.automark-status-panel__actions { align-items: stretch; }
|
||||
@@ -4897,22 +4857,13 @@ onBeforeUnmount(() => {
|
||||
.control-label {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.config button,
|
||||
.page-nav button,
|
||||
.blind-test button,
|
||||
.canvas-warning button {
|
||||
/* EP 迁移:仅识别结果行等原生按钮仍走应用 token;el-button 由 element-trial 主题接管 */
|
||||
.config button:not(.el-button) {
|
||||
border-color: var(--border-default);
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--bg-surface);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.editor input,
|
||||
.editor select {
|
||||
box-sizing: border-box;
|
||||
border-color: var(--border-default);
|
||||
background: var(--bg-surface);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.sample-control {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
+158
-118
@@ -1,13 +1,32 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileLibraryPage.vue
|
||||
用途:按 profile_code 聚合展示订单文档模板族,是创建和继续编辑的唯一首页。
|
||||
依赖:Profile family API、统一 binding 迁移 scan/dry-run API、Vue Router、Vue I18n。
|
||||
逻辑:列表只选择下一步路由;展示统一 binding 迁移状态与待补框筛选;支持批量 Dry Run。
|
||||
依赖:element-plus(按钮/搜索/筛选/表格/标签/空态/骨架屏,沿用管理端 element-trial 主题)、
|
||||
Profile family API、统一 binding 迁移 scan/dry-run API、DeleteConfirmDialog、
|
||||
Vue Router、Vue I18n。
|
||||
逻辑:列表只选择下一步路由;展示统一 binding 迁移状态与待补框筛选;支持批量 Dry Run;
|
||||
业务脚本(加载/筛选/复制/删除/Dry Run)保持原逻辑不变,仅视觉层迁移 EP
|
||||
(与在途调拨类型页同一范式:搜索+筛选一行、el-table 列语义不变)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElEmpty,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSkeleton,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import { Plus, Search } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
@@ -176,28 +195,37 @@ onMounted(loadFamilies);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="mx-auto max-w-7xl space-y-6 p-6">
|
||||
<!-- 全宽布局:水平内边距由 AdminLayout 壳层统一持有 -->
|
||||
<section class="space-y-6">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderProfiles.library.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderProfiles.library.subtitle') }}</p>
|
||||
<h1 class="page-title">{{ t('admin.shippingOrderProfiles.library.title') }}</h1>
|
||||
<p class="page-desc">{{ t('admin.shippingOrderProfiles.library.subtitle') }}</p>
|
||||
</div>
|
||||
<button class="btn-primary" type="button" @click="router.push({ name: 'AdminShippingOrderDocumentProfileCreate' })">
|
||||
<el-button type="primary" :icon="Plus" @click="router.push({ name: 'AdminShippingOrderDocumentProfileCreate' })">
|
||||
{{ t('admin.shippingOrderProfiles.library.create') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</header>
|
||||
|
||||
<!-- 筛选与搜索同一行:搜索(回车/清空即过滤,computed 实时生效)+ 迁移筛选 + 批量 Dry Run -->
|
||||
<div class="toolbar">
|
||||
<input v-model="query" class="toolbar-input" :placeholder="t('admin.shippingOrderProfiles.library.search')" type="search">
|
||||
<select v-model="migrationFilter" class="toolbar-select" data-testid="order-profile-unified-migration-filter">
|
||||
<option value="all">{{ t('admin.shippingOrderProfiles.unifiedMigration.filterAll') }}</option>
|
||||
<option value="needs_migration">{{ t('admin.shippingOrderProfiles.unifiedMigration.filterNeedsMigration') }}</option>
|
||||
<option value="pending_visual">{{ t('admin.shippingOrderProfiles.unifiedMigration.filterPendingVisual') }}</option>
|
||||
</select>
|
||||
<button
|
||||
class="btn-secondary btn-sm"
|
||||
type="button"
|
||||
<el-input
|
||||
v-model="query"
|
||||
class="toolbar-search"
|
||||
type="search"
|
||||
:placeholder="t('admin.shippingOrderProfiles.library.search')"
|
||||
:prefix-icon="Search"
|
||||
clearable
|
||||
/>
|
||||
<el-select v-model="migrationFilter" class="toolbar-filter" data-testid="order-profile-unified-migration-filter">
|
||||
<el-option value="all" :label="t('admin.shippingOrderProfiles.unifiedMigration.filterAll')" />
|
||||
<el-option value="needs_migration" :label="t('admin.shippingOrderProfiles.unifiedMigration.filterNeedsMigration')" />
|
||||
<el-option value="pending_visual" :label="t('admin.shippingOrderProfiles.unifiedMigration.filterPendingVisual')" />
|
||||
</el-select>
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="order-profile-unified-migration-batch-dry-run"
|
||||
:loading="batchDryRunLoading"
|
||||
:disabled="batchDryRunLoading || migrationTotals.needsMigration === 0"
|
||||
@click="runBatchUnifiedMigrationDryRun"
|
||||
>
|
||||
@@ -206,7 +234,7 @@ onMounted(loadFamilies);
|
||||
? t('admin.shippingOrderProfiles.unifiedMigration.batchDryRunRunning')
|
||||
: t('admin.shippingOrderProfiles.unifiedMigration.batchDryRun', { count: migrationTotals.needsMigration })
|
||||
}}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<p v-if="families.length" class="migration-summary" data-testid="order-profile-unified-migration-summary">
|
||||
@@ -220,69 +248,102 @@ onMounted(loadFamilies);
|
||||
</p>
|
||||
|
||||
<section class="library-card" :aria-busy="loading">
|
||||
<p v-if="loading" class="library-state">{{ t('admin.shippingOrderProfiles.library.loading') }}</p>
|
||||
<p v-else-if="!filteredFamilies.length" class="library-state">{{ t('admin.shippingOrderProfiles.library.empty') }}</p>
|
||||
<div v-else class="table-scroll">
|
||||
<table class="profile-table">
|
||||
<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.unifiedMigration.columnTitle') }}</th>
|
||||
<th class="actions-heading">{{ t('admin.shippingOrderProfiles.library.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in filteredFamilies" :key="item.profile_code">
|
||||
<td class="profile-name">{{ item.display_name }}</td>
|
||||
<td><code>{{ item.profile_code }}</code></td>
|
||||
<td>
|
||||
<span class="status-badge" :class="{ draft: item.draft_profile_id, published: !item.draft_profile_id && item.published_profile_id }">
|
||||
{{ 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') }}
|
||||
</span>
|
||||
<small v-if="item.published_profile_id && item.current_schema_version" class="schema-status" :class="{ warning: schemaMigrationRequired(item) }">
|
||||
{{ schemaMigrationRequired(item)
|
||||
? t('admin.shippingOrderProfiles.schemaMigration.versionMismatch', { bound: item.published_schema_version, current: item.current_schema_version })
|
||||
: t('admin.shippingOrderProfiles.schemaMigration.versionMatched', { version: item.current_schema_version }) }}
|
||||
</small>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
v-if="item.unified_binding_status"
|
||||
class="unified-migration-badge"
|
||||
:class="item.unified_binding_status"
|
||||
data-testid="order-profile-unified-migration-status"
|
||||
>
|
||||
{{ t(`admin.shippingOrderProfiles.unifiedMigration.status.${item.unified_binding_status}`) }}
|
||||
</span>
|
||||
<small v-if="(item.unified_pending_visual_count ?? 0) > 0" class="schema-status warning">
|
||||
{{ t('admin.shippingOrderProfiles.unifiedMigration.pendingVisualShort', { count: item.unified_pending_visual_count }) }}
|
||||
</small>
|
||||
</td>
|
||||
<td class="profile-library__actions">
|
||||
<!-- flex 必须放在 td 内层,避免破坏 table-cell 盒模型导致行分隔线错位 -->
|
||||
<div class="profile-library__actions-inner">
|
||||
<button v-if="item.draft_profile_id" class="btn-ghost btn-sm" type="button" @click="continueEditing(item)">{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}</button>
|
||||
<button v-if="item.draft_profile_id" class="btn-danger btn-sm" type="button" @click="requestDeleteDraft(item)">{{ t('admin.delete') }}</button>
|
||||
<button v-else-if="item.published_profile_id && !schemaMigrationRequired(item)" class="btn-secondary btn-sm" type="button" @click="createNewVersion(item)">{{ t('admin.shippingOrderProfiles.newVersion') }}</button>
|
||||
<button v-if="!item.draft_profile_id && item.published_profile_id && schemaMigrationRequired(item)" class="btn-secondary btn-sm" type="button" @click="openSchemaMigration(item)">{{ t('admin.shippingOrderProfiles.schemaMigration.listAction') }}</button>
|
||||
<button class="btn-ghost btn-sm" type="button" @click="viewVersion(item)">{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}</button>
|
||||
<button
|
||||
v-if="item.unified_binding_status === 'needs_migration' || item.unified_needs_migration"
|
||||
class="btn-ghost btn-sm"
|
||||
type="button"
|
||||
data-testid="order-profile-unified-migration-open"
|
||||
@click="openUnifiedMigration(item)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.unifiedMigration.open') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<el-skeleton v-if="loading" class="library-skeleton" :rows="6" animated />
|
||||
<el-empty
|
||||
v-else-if="!filteredFamilies.length"
|
||||
:description="t('admin.shippingOrderProfiles.library.empty')"
|
||||
:image-size="60"
|
||||
/>
|
||||
<el-table v-else :data="filteredFamilies" row-key="profile_code" class="profile-table">
|
||||
<el-table-column prop="display_name" :label="t('admin.shippingOrderProfiles.name')" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<span class="profile-name">{{ row.display_name }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderProfiles.code')" min-width="170">
|
||||
<template #default="{ row }">
|
||||
<code class="profile-code">{{ row.profile_code }}</code>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderProfiles.library.status')" min-width="210">
|
||||
<template #default="{ row }">
|
||||
<el-tag size="small" :type="row.draft_profile_id ? 'primary' : row.published_profile_id ? 'success' : 'info'">
|
||||
{{ row.draft_profile_id
|
||||
? t('admin.shippingOrderProfiles.library.draft')
|
||||
: row.published_profile_id
|
||||
? t('admin.shippingOrderProfiles.library.published', { version: row.published_version })
|
||||
: t('admin.shippingOrderProfiles.library.retired') }}
|
||||
</el-tag>
|
||||
<small
|
||||
v-if="row.published_profile_id && row.current_schema_version"
|
||||
class="schema-status"
|
||||
:class="{ 'schema-status--warning': schemaMigrationRequired(row as OrderProfileVersionFamilySummary) }"
|
||||
>
|
||||
{{ schemaMigrationRequired(row as OrderProfileVersionFamilySummary)
|
||||
? t('admin.shippingOrderProfiles.schemaMigration.versionMismatch', { bound: row.published_schema_version, current: row.current_schema_version })
|
||||
: t('admin.shippingOrderProfiles.schemaMigration.versionMatched', { version: row.current_schema_version }) }}
|
||||
</small>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderProfiles.unifiedMigration.columnTitle')" min-width="190">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
v-if="row.unified_binding_status"
|
||||
size="small"
|
||||
:type="row.unified_binding_status === 'needs_migration' ? 'warning' : row.unified_binding_status === 'pending_visual' ? 'danger' : 'success'"
|
||||
data-testid="order-profile-unified-migration-status"
|
||||
>
|
||||
{{ t(`admin.shippingOrderProfiles.unifiedMigration.status.${row.unified_binding_status}`) }}
|
||||
</el-tag>
|
||||
<small v-if="(row.unified_pending_visual_count ?? 0) > 0" class="schema-status schema-status--warning">
|
||||
{{ t('admin.shippingOrderProfiles.unifiedMigration.pendingVisualShort', { count: row.unified_pending_visual_count }) }}
|
||||
</small>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderProfiles.library.actions')" min-width="260">
|
||||
<template #default="{ row }">
|
||||
<div class="row-actions">
|
||||
<el-button v-if="row.draft_profile_id" link type="primary" size="small" @click="continueEditing(row as OrderProfileVersionFamilySummary)">
|
||||
{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}
|
||||
</el-button>
|
||||
<el-button v-if="row.draft_profile_id" link type="danger" size="small" @click="requestDeleteDraft(row as OrderProfileVersionFamilySummary)">
|
||||
{{ t('admin.delete') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else-if="row.published_profile_id && !schemaMigrationRequired(row as OrderProfileVersionFamilySummary)"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="createNewVersion(row as OrderProfileVersionFamilySummary)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.newVersion') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!row.draft_profile_id && row.published_profile_id && schemaMigrationRequired(row as OrderProfileVersionFamilySummary)"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="openSchemaMigration(row as OrderProfileVersionFamilySummary)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.schemaMigration.listAction') }}
|
||||
</el-button>
|
||||
<el-button link type="primary" size="small" @click="viewVersion(row as OrderProfileVersionFamilySummary)">
|
||||
{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.unified_binding_status === 'needs_migration' || row.unified_needs_migration"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
data-testid="order-profile-unified-migration-open"
|
||||
@click="openUnifiedMigration(row as OrderProfileVersionFamilySummary)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.unifiedMigration.open') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</section>
|
||||
<DeleteConfirmDialog
|
||||
v-model="deleteConfirmOpen"
|
||||
@@ -293,48 +354,27 @@ onMounted(loadFamilies);
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 全宽布局:水平内边距由 AdminLayout 壳层统一持有,页面只保留内部块间距(根 space-y-6) */
|
||||
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
.page-header h1 { margin: 0; }
|
||||
.page-header p { margin: 0; }
|
||||
.page-title { margin: 0; font-size: 20px; font-weight: 700; }
|
||||
.page-desc { margin: 4px 0 0; color: var(--el-text-color-secondary); font-size: 13px; }
|
||||
/* 筛选与搜索同一行 */
|
||||
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||
.toolbar-select {
|
||||
min-width: 180px; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff;
|
||||
padding: 7px 9px; color: #334155; font: inherit; font-size: 12px;
|
||||
}
|
||||
.migration-summary { margin: 0; color: #64748b; font-size: 12px; }
|
||||
.unified-migration-badge {
|
||||
display: inline-flex; border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc;
|
||||
padding: 3px 8px; color: #64748b; font-size: 11px; font-weight: 600; white-space: nowrap;
|
||||
}
|
||||
.unified-migration-badge.needs_migration { border-color: #fde68a; background: #fffbeb; color: #b45309; }
|
||||
.unified-migration-badge.pending_visual { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
|
||||
.unified-migration-badge.ready { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
|
||||
.toolbar-input {
|
||||
min-width: 220px; flex: 1 1 220px; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff;
|
||||
padding: 7px 9px; color: #334155; font: inherit; font-size: 12px; outline: none;
|
||||
}
|
||||
.toolbar-input:focus { border-color: #38bdf8; box-shadow: 0 0 0 2px rgb(56 189 248 / 12%); }
|
||||
.library-card { overflow: hidden; border: 1px solid #dfe7ef; border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 3%); }
|
||||
.library-state { margin: 0; padding: 48px 24px; color: #94a3b8; font-size: 13px; text-align: center; }
|
||||
.table-scroll { overflow-x: auto; }
|
||||
.profile-table { width: 100%; min-width: 720px; border-collapse: collapse; color: #475569; font-size: 13px; }
|
||||
.profile-table th { background: #f8fafc; color: #64748b; font-size: 12px; font-weight: 600; }
|
||||
.profile-table th, .profile-table td { padding: 13px 16px; border-bottom: 1px solid #e5ebf1; text-align: left; vertical-align: middle; }
|
||||
.profile-table tbody tr:last-child td { border-bottom: 0; }
|
||||
.profile-table tbody tr:hover { background: #fbfdff; }
|
||||
.profile-name { color: #334155; font-weight: 600; }
|
||||
.profile-table code { color: #64748b; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; white-space: nowrap; }
|
||||
.status-badge { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc; padding: 3px 8px; color: #64748b; font-size: 11px; font-weight: 600; white-space: nowrap; }
|
||||
.status-badge.draft { border-color: #bae6fd; background: #f0f9ff; color: #0369a1; }
|
||||
.status-badge.published { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
|
||||
.schema-status { display: block; margin-top: 5px; color: #64748b; font-size: 11px; white-space: nowrap; }.schema-status.warning { color: #b45309; }
|
||||
.actions-heading { min-width: 190px; }
|
||||
.profile-library__actions { vertical-align: middle; }
|
||||
.profile-library__actions-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
|
||||
.toolbar-search { width: 260px; }
|
||||
.toolbar-filter { width: 200px; }
|
||||
.migration-summary { margin: 0; color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.library-card { overflow: hidden; border: 1px solid var(--el-border-color-light); border-radius: 10px; background: var(--el-bg-color); box-shadow: var(--el-box-shadow-lighter); }
|
||||
.library-skeleton { padding: 16px; }
|
||||
.profile-name { color: var(--el-text-color-primary); font-weight: 600; }
|
||||
.profile-code { color: var(--el-text-color-secondary); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; white-space: nowrap; }
|
||||
.schema-status { display: block; margin-top: 5px; color: var(--el-text-color-secondary); font-size: 12px; white-space: nowrap; }
|
||||
.schema-status--warning { color: var(--el-color-warning); }
|
||||
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
|
||||
.row-actions .el-button + .el-button { margin-left: 0; }
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.page-header { flex-direction: column; }
|
||||
.btn-primary { width: 100%; }
|
||||
.toolbar-input { min-width: 0; }
|
||||
.page-header .el-button { width: 100%; }
|
||||
.toolbar-search { width: 100%; }
|
||||
}
|
||||
</style>
|
||||
+82
-54
@@ -1,14 +1,27 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfilePublishCheckPage.vue
|
||||
用途:展示版面签名、跨模板唯一性与发布阻断项,并在门禁通过后发布模板。
|
||||
依赖:发布检查 API、验证运行 API、Vue Router 和统一消息提示。
|
||||
依赖:element-plus(el-button/el-descriptions/el-tag/el-checkbox,沿用管理端 element-trial 主题)、
|
||||
发布检查 API、验证运行 API、Vue Router 和统一消息提示。
|
||||
逻辑:自动选择当前样本试读通过运行;服务端生成签名/重叠验证;阻断项不可绕过,语义差异须逐项确认;
|
||||
XFA path 覆盖不全时展示 missing_fields 的 scope.field_code,避免同名 header/line 误判。
|
||||
视觉层已迁移 Element Plus(指标 dl→el-descriptions,警告勾选→el-checkbox,状态→el-tag),业务脚本保持原样。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElCheckboxGroup,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -245,57 +258,69 @@ onMounted(loadRuns);
|
||||
<h1 class="section-title">{{ t('admin.orderProfilePublishCheck.title') }}</h1>
|
||||
<small class="section-desc mt-1">{{ t('admin.orderProfilePublishCheck.description') }}</small>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary" @click="backToValidation">{{ t('admin.orderProfilePublishCheck.back') }}</button>
|
||||
<el-button @click="backToValidation">{{ t('admin.orderProfilePublishCheck.back') }}</el-button>
|
||||
</header>
|
||||
|
||||
<section v-if="!report" class="card">
|
||||
<h2>{{ t('admin.orderProfilePublishCheck.readyTitle') }}</h2>
|
||||
<p>{{ validationRun ? t('admin.orderProfilePublishCheck.readyHint') : t('admin.orderProfilePublishCheck.noRun') }}</p>
|
||||
<button class="btn-primary" :disabled="busy || !validationRun" type="button" @click="createReport">
|
||||
<el-button type="primary" :disabled="busy || !validationRun" :loading="busy" @click="createReport">
|
||||
{{ t('admin.orderProfilePublishCheck.create') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</section>
|
||||
|
||||
<template v-else>
|
||||
<section class="card">
|
||||
<div class="card-head">
|
||||
<h2>{{ t('admin.orderProfilePublishCheck.reportTitle') }}</h2>
|
||||
<button class="btn-secondary" :disabled="busy || !validationRun" type="button" @click="createReport">
|
||||
<el-button :disabled="busy || !validationRun" :loading="busy" @click="createReport">
|
||||
{{ t('admin.orderProfilePublishCheck.rerun') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
<p :class="['gate-status', gateStatus]">{{ gateStatus === 'blocked' ? t('admin.orderProfilePublishCheck.blockedHint') : t('admin.orderProfilePublishCheck.reviewHint') }}</p>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h3>{{ t('admin.orderProfilePublishCheck.layoutSignatureTitle') }}</h3>
|
||||
<dl class="metrics">
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.signatureStatus') }}</dt><dd :class="`status-${signatureStatusDetail?.status || 'unknown'}`">{{ signatureStatus(signatureStatusDetail?.status) }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.signatureSampleCount') }}</dt><dd>{{ signatureStatusDetail?.source_sample_count ?? '—' }}</dd></div>
|
||||
<div v-for="metric in signatureIdentityMetrics" :key="metric.label"><dt>{{ metric.label }}</dt><dd>{{ metric.value }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.matcherPolicyVersion') }}</dt><dd>{{ report.matcher_policy_version || signatureStatusDetail?.matcher_policy_version || '—' }}</dd></div>
|
||||
</dl>
|
||||
<el-descriptions class="metrics" :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.signatureStatus')">
|
||||
<el-tag size="small" :type="signatureStatusDetail?.status === 'valid' ? 'success' : signatureStatusDetail?.status === 'stale' ? 'warning' : 'info'">
|
||||
{{ signatureStatus(signatureStatusDetail?.status) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.signatureSampleCount')">{{ signatureStatusDetail?.source_sample_count ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item
|
||||
v-for="metric in signatureIdentityMetrics"
|
||||
:key="metric.label"
|
||||
:label="metric.label"
|
||||
>{{ metric.value }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.matcherPolicyVersion')">{{ report.matcher_policy_version || signatureStatusDetail?.matcher_policy_version || '—' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
|
||||
<section class="card">
|
||||
<h3>{{ t('admin.orderProfilePublishCheck.uniquenessTitle') }}</h3>
|
||||
<dl class="metrics">
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.trainingUniqueRate') }}</dt><dd>{{ formatRate(report.overlap_summary?.self_unique_hit_rate_training) }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.blindUniqueRate') }}</dt><dd>{{ formatRate(report.overlap_summary?.self_unique_hit_rate_blind) }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.falseHitCount') }}</dt><dd>{{ report.overlap_summary?.false_hit_other_count ?? 0 }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.reverseFalseHitCount') }}</dt><dd>{{ report.overlap_summary?.reverse_false_hit_count ?? 0 }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.ambiguousCount') }}</dt><dd>{{ report.overlap_summary?.ambiguous_count ?? 0 }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.minEvidenceCoverage') }}</dt><dd>{{ formatRate(report.overlap_summary?.min_evidence_coverage) }} / ≥ {{ formatRate(report.overlap_summary?.thresholds?.evidence_coverage_minimum) }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.minMargin') }}</dt><dd>{{ report.overlap_summary?.min_margin ?? '—' }} / ≥ {{ report.overlap_summary?.thresholds?.minimum_margin ?? '—' }}</dd></div>
|
||||
<div><dt>{{ t('admin.orderProfilePublishCheck.parseFailedCount') }}</dt><dd>{{ report.overlap_summary?.parse_validation_failed_count ?? 0 }}</dd></div>
|
||||
</dl>
|
||||
<el-descriptions class="metrics" :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.trainingUniqueRate')">{{ formatRate(report.overlap_summary?.self_unique_hit_rate_training) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.blindUniqueRate')">{{ formatRate(report.overlap_summary?.self_unique_hit_rate_blind) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.falseHitCount')">{{ report.overlap_summary?.false_hit_other_count ?? 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.reverseFalseHitCount')">{{ report.overlap_summary?.reverse_false_hit_count ?? 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.ambiguousCount')">{{ report.overlap_summary?.ambiguous_count ?? 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.minEvidenceCoverage')">{{ formatRate(report.overlap_summary?.min_evidence_coverage) }} / ≥ {{ formatRate(report.overlap_summary?.thresholds?.evidence_coverage_minimum) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.minMargin')">{{ report.overlap_summary?.min_margin ?? '—' }} / ≥ {{ report.overlap_summary?.thresholds?.minimum_margin ?? '—' }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.orderProfilePublishCheck.parseFailedCount')">{{ report.overlap_summary?.parse_validation_failed_count ?? 0 }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
|
||||
<section v-if="adapterValidationMetrics.length" class="card">
|
||||
<h3>{{ t('admin.orderProfilePublishCheck.xfaUnifiedMetricsTitle') }}</h3>
|
||||
<dl class="metrics">
|
||||
<div v-for="metric in adapterValidationMetrics" :key="metric.label"><dt>{{ metric.label }}</dt><dd>{{ formatRate(metric.value) }}</dd></div>
|
||||
</dl>
|
||||
<el-descriptions class="metrics" :column="2" size="small">
|
||||
<el-descriptions-item
|
||||
v-for="metric in adapterValidationMetrics"
|
||||
:key="metric.label"
|
||||
:label="metric.label"
|
||||
>{{ formatRate(metric.value) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
|
||||
<section v-if="conflictProfiles.length" class="card">
|
||||
@@ -304,7 +329,7 @@ onMounted(loadRuns);
|
||||
<strong>{{ conflict.profile_code }} v{{ conflict.version }}</strong>
|
||||
<p class="reasons">{{ conflict.reason_codes.map(conflictReason).join(';') }}</p>
|
||||
<p>{{ conflict.suggestion }}</p>
|
||||
<button type="button" class="btn-secondary" @click="backToEditor">{{ t('admin.orderProfilePublishCheck.backToEditor') }}</button>
|
||||
<el-button @click="backToEditor">{{ t('admin.orderProfilePublishCheck.backToEditor') }}</el-button>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -316,49 +341,52 @@ onMounted(loadRuns);
|
||||
</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)">
|
||||
<span>{{ itemMessage(item) }}</span>
|
||||
</label>
|
||||
<el-checkbox-group v-model="confirmed">
|
||||
<el-checkbox
|
||||
v-for="item in report.warning_items"
|
||||
:key="String(item.key)"
|
||||
:value="String(item.key)"
|
||||
class="warning-item"
|
||||
>
|
||||
{{ itemMessage(item) }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
<p v-if="report.warning_items.length" class="hint">{{ t('admin.orderProfilePublishCheck.confirmHint') }}</p>
|
||||
<button class="btn-primary" :disabled="busy || !publishable" type="button" @click="publish">
|
||||
<el-button type="primary" class="publish-button" :disabled="busy || !publishable" :loading="busy" @click="publish">
|
||||
{{ t('admin.orderProfilePublishCheck.confirm') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</section>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.page { width: 100%; margin: 0; padding: 24px; color: #334155; }
|
||||
/* 根容器不再自带水平 padding:由 Admin 壳层统一持有,页面只保留卡片间距 */
|
||||
.page { width: 100%; color: var(--el-text-color-regular); }
|
||||
.page header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
.page h1 { margin: 0; }
|
||||
.page small:not(.section-desc), .card p { color: #64748b; font-size: 13px; line-height: 1.5; }
|
||||
.page small:not(.section-desc), .card p { color: var(--el-text-color-secondary); font-size: 13px; line-height: 1.5; }
|
||||
.page small { display: block; margin-top: 5px; }
|
||||
.card { margin-top: 20px; border: 1px solid #dfe7ef; border-radius: 10px; background: #fff; padding: 16px; box-shadow: 0 1px 2px rgb(15 23 42 / 3%); }
|
||||
.card { margin-top: 20px; border: 1px solid var(--el-border-color-lighter); border-radius: 10px; background: var(--el-bg-color); padding: 16px; box-shadow: var(--el-box-shadow-lighter); }
|
||||
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.card h2 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }
|
||||
.card h3 { margin: 0 0 12px; color: #1e293b; font-size: 14px; }
|
||||
.card label { display: flex; gap: 8px; margin: 10px 0; color: #475569; font-size: 13px; }
|
||||
.card input { accent-color: #0ea5e9; }
|
||||
.card .btn-primary { margin-top: 14px; }
|
||||
.good { color: #15803d; font-size: 13px; }
|
||||
.card h2 { margin: 0; color: var(--el-text-color-primary); font-size: 15px; font-weight: 600; }
|
||||
.card h3 { margin: 0 0 12px; color: var(--el-text-color-primary); font-size: 14px; }
|
||||
.warning-item { display: flex; margin: 10px 0; color: var(--el-text-color-regular); font-size: 13px; }
|
||||
.publish-button { margin-top: 14px; }
|
||||
.good { color: var(--el-color-success); font-size: 13px; }
|
||||
.gate-status { font-weight: 600; }
|
||||
.gate-status.blocked { color: #b91c1c; }
|
||||
.gate-status.pass, .status-valid { color: #15803d; }
|
||||
.status-missing, .status-stale { color: #b45309; }
|
||||
.gate-status.blocked { color: var(--el-color-danger); }
|
||||
.gate-status.pass { color: var(--el-color-success); }
|
||||
.hint { font-size: 13px; }
|
||||
ul { margin: 8px 0; padding-left: 20px; color: #b91c1c; font-size: 13px; }
|
||||
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 0; }
|
||||
.metrics div { display: grid; gap: 4px; }
|
||||
.metrics dt { color: #64748b; font-size: 12px; }
|
||||
.metrics dd { margin: 0; color: #1e293b; font-size: 14px; font-weight: 600; }
|
||||
.conflict-card { border: 1px solid #fecaca; background: #fef2f2; border-radius: 8px; padding: 12px; margin-top: 10px; }
|
||||
.conflict-card strong { color: #991b1b; font-size: 13px; }
|
||||
.conflict-card .reasons { color: #b45309; font-size: 12px; }
|
||||
.card ul { margin: 8px 0; padding-left: 20px; color: var(--el-color-danger); font-size: 13px; }
|
||||
.metrics { margin: 0; }
|
||||
.metrics :deep(.el-descriptions__label) { color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.metrics :deep(.el-descriptions__content) { color: var(--el-text-color-primary); font-size: 13px; font-weight: 600; }
|
||||
.conflict-card { border: 1px solid var(--el-color-danger-light-7); background: var(--el-color-danger-light-9); border-radius: 8px; padding: 12px; margin-top: 10px; }
|
||||
.conflict-card strong { color: var(--el-color-danger-dark-2); font-size: 13px; }
|
||||
.conflict-card .reasons { color: var(--el-color-warning); font-size: 12px; }
|
||||
@media (max-width: 767px) {
|
||||
.page { padding: 16px; }
|
||||
.page header, .card-head { display: grid; }
|
||||
.page header button, .card-head button { width: 100%; }
|
||||
.page header .el-button, .card-head .el-button { width: 100%; }
|
||||
}
|
||||
</style>
|
||||
+41
-24
@@ -1,14 +1,24 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileValidationPage.vue
|
||||
用途:验证当前订单模板草稿,并按“基础验证、盲测、发布检查”顺序引导管理员。
|
||||
依赖:Profile 验证 API、编辑租约、Vue Router、统一消息提示。
|
||||
依赖:element-plus(el-button/el-tag/el-skeleton,沿用管理端 element-trial 主题)、
|
||||
Profile 验证 API、编辑租约、Vue Router、统一消息提示。
|
||||
逻辑:一次动作依次执行结构检查和当前样本试读;XFA 从验证摘要展示完整字段级结果;
|
||||
盲测批准前不解锁发布检查入口。
|
||||
视觉层已迁移 Element Plus(运行状态→el-tag,加载态→el-skeleton,字段证据卡保留手写结构仅配色走 token),业务脚本保持原样。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElSkeleton,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -274,35 +284,42 @@ onMounted(async () => {
|
||||
<h1 class="section-title">{{ t('admin.orderProfileValidation.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.orderProfileValidation.description') }}</p>
|
||||
</div>
|
||||
<button class="btn-secondary" type="button" @click="backToEditor">{{ t('admin.orderProfileValidation.backToEditor') }}</button>
|
||||
<el-button @click="backToEditor">{{ t('admin.orderProfileValidation.backToEditor') }}</el-button>
|
||||
</header>
|
||||
|
||||
<section class="validation-state" :class="`state-${validationState}`">
|
||||
<div><b>{{ t(`admin.orderProfileValidation.state.${validationState}`) }}</b><p>{{ t(`admin.orderProfileValidation.stateHint.${validationState}`) }}</p></div>
|
||||
<button v-if="canStartBlindTest" type="button" class="btn-primary" :disabled="!canPublish" @click="goToPublishCheck">{{ t('admin.orderProfileValidation.goPublishCheck') }}</button>
|
||||
<el-button v-if="canStartBlindTest" type="primary" :disabled="!canPublish" @click="goToPublishCheck">{{ t('admin.orderProfileValidation.goPublishCheck') }}</el-button>
|
||||
</section>
|
||||
|
||||
<section class="validation-card current-draft-validation">
|
||||
<header>
|
||||
<div><h2>{{ t('admin.orderProfileValidation.currentDraft') }}</h2><p>{{ t('admin.orderProfileValidation.currentDraftHint') }}</p></div>
|
||||
<button type="button" class="btn-primary" :disabled="executing" @click="validateCurrentDraft">{{ executing ? t('admin.orderProfileValidation.validating') : t('admin.orderProfileValidation.validateCurrent') }}</button>
|
||||
<el-button type="primary" :disabled="executing" :loading="executing" @click="validateCurrentDraft">{{ executing ? t('admin.orderProfileValidation.validating') : t('admin.orderProfileValidation.validateCurrent') }}</el-button>
|
||||
</header>
|
||||
<p v-if="loading">{{ t('admin.orderProfileValidation.loading') }}</p>
|
||||
<el-skeleton v-if="loading" :rows="4" animated />
|
||||
<div v-else class="checks" :aria-label="t('admin.orderProfileValidation.currentDraft')">
|
||||
<article>
|
||||
<div><h3>{{ t('admin.orderProfileValidation.structureCheck') }}</h3><p>{{ t('admin.orderProfileValidation.structureCheckHint') }}</p></div>
|
||||
<strong :class="`status ${structureRun?.status || 'pending'}`">{{ t(`admin.orderProfileValidation.runStatus.${structureRun?.status || 'pending'}`) }}</strong>
|
||||
<el-tag size="small" :type="(structureRun?.status || 'pending') === 'passed' ? 'success' : ['failed', 'stale'].includes(structureRun?.status || '') ? 'danger' : 'info'">
|
||||
{{ t(`admin.orderProfileValidation.runStatus.${structureRun?.status || 'pending'}`) }}
|
||||
</el-tag>
|
||||
</article>
|
||||
<article>
|
||||
<div><h3>{{ t('admin.orderProfileValidation.sampleCheck') }}</h3><p>{{ t('admin.orderProfileValidation.sampleCheckHint') }}</p></div>
|
||||
<strong :class="`status ${sampleRun?.status || 'pending'}`">{{ t(`admin.orderProfileValidation.runStatus.${sampleRun?.status || 'pending'}`) }}</strong>
|
||||
<el-tag size="small" :type="(sampleRun?.status || 'pending') === 'passed' ? 'success' : ['failed', 'stale'].includes(sampleRun?.status || '') ? 'danger' : 'info'">
|
||||
{{ t(`admin.orderProfileValidation.runStatus.${sampleRun?.status || 'pending'}`) }}
|
||||
</el-tag>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="canStartBlindTest" class="blind-test-gate">
|
||||
<div><h2>{{ t('admin.shippingOrderProfiles.blindTest.gateTitle') }}</h2><p>{{ blindTestSuite?.status === 'approved' ? t('admin.shippingOrderProfiles.blindTest.gateApprovedHint') : t('admin.shippingOrderProfiles.blindTest.gateRequiredHint') }}</p></div>
|
||||
<div class="gate-actions"><strong :class="`status ${blindTestSuite?.status || 'pending'}`">{{ t(`admin.shippingOrderProfiles.blindTest.status.${blindTestSuite?.status || 'missing'}`) }}</strong><button type="button" class="btn-secondary" @click="goToBlindTest">{{ t('admin.shippingOrderProfiles.blindTest.title') }}</button></div>
|
||||
<div class="gate-actions">
|
||||
<el-tag size="small" :type="blindTestSuite?.status === 'approved' ? 'success' : 'warning'">{{ t(`admin.shippingOrderProfiles.blindTest.status.${blindTestSuite?.status || 'missing'}`) }}</el-tag>
|
||||
<el-button @click="goToBlindTest">{{ t('admin.shippingOrderProfiles.blindTest.title') }}</el-button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="profile && sample" class="results" :aria-label="t('admin.orderProfileValidation.resultsTitle')">
|
||||
@@ -376,23 +393,23 @@ onMounted(async () => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.validation-page { width: 100%; margin: 0; padding: 24px; color: #334155; }
|
||||
/* 根容器不再自带水平 padding:由 Admin 壳层统一持有,页面只保留卡片间距 */
|
||||
.validation-page { width: 100%; color: var(--el-text-color-regular); }
|
||||
header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
h1 { margin: 0; }
|
||||
header p:not(.section-desc), .validation-card p, .checks p, .validation-state p, .blind-test-gate p { margin: 5px 0 0; color: #64748b; font-size: 13px; line-height: 1.5; }
|
||||
button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.validation-state, .validation-card, .checks article, .blind-test-gate, .results { border: 1px solid #dfe7ef; border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 3%); }
|
||||
header p:not(.section-desc), .validation-card p, .checks p, .validation-state p, .blind-test-gate p { margin: 5px 0 0; color: var(--el-text-color-secondary); font-size: 13px; line-height: 1.5; }
|
||||
.validation-state, .validation-card, .checks article, .blind-test-gate, .results { border: 1px solid var(--el-border-color-lighter); border-radius: 10px; background: var(--el-bg-color); box-shadow: var(--el-box-shadow-lighter); }
|
||||
.validation-state { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 16px; }
|
||||
.validation-state { border-color: #bae6fd; background: #f0f9ff; }.validation-state b { color: #0369a1; font-size: 14px; }.state-ready { border-color: #bbf7d0; background: #f0fdf4; }.state-ready b { color: #15803d; }.state-stale, .state-failed { border-color: #fecaca; background: #fef2f2; }.state-stale b, .state-failed b { color: #b91c1c; }
|
||||
.validation-card h2, .checks h3 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }
|
||||
.current-draft-validation { display: grid; gap: 16px; margin-top: 20px; padding: 16px; }.current-draft-validation > header { align-items: center; }.current-draft-validation > header > div { min-width: 0; }.current-draft-validation > header button { flex: 0 0 auto; }.checks { display: grid; gap: 10px; }.checks article { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-radius: 8px; padding: 15px 16px; }.status { min-width: 72px; text-align: right; font-size: 13px; font-weight: 600; }.passed { color: #15803d; }.failed, .stale { color: #b91c1c; }.pending, .running { color: #64748b; }
|
||||
.blind-test-gate { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 16px; }.blind-test-gate h2 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }.gate-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }.gate-actions .approved { color: #15803d; }.gate-actions .draft, .gate-actions .missing { color: #b45309; }
|
||||
.results { margin-top: 20px; padding: 16px; }.results-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }.results h2, .results h3 { margin: 0; color: #1e293b; }.results h2 { font-size: 15px; }.results h3 { margin-top: 20px; font-size: 14px; }.results-heading p { margin: 5px 0 0; color: #64748b; font-size: 13px; line-height: 1.5; }.header-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0 0; }.header-results div { border: 1px solid #e5ebf1; border-radius: 6px; background: #fbfdff; padding: 10px; }.header-results dt { color: #475569; font-size: 13px; font-weight: 600; }.header-results dd { margin: 4px 0 0; overflow-wrap: anywhere; }.header-results .field-code, .line-results th small { color: #94a3b8; font-size: 11px; font-weight: 400; }.line-results { margin-top: 12px; overflow-x: auto; border: 1px solid #e5ebf1; border-radius: 6px; }.line-results table { width: 100%; min-width: 560px; border-collapse: collapse; }.line-results th, .line-results td { padding: 10px 12px; border-bottom: 1px solid #e5ebf1; text-align: left; vertical-align: top; overflow-wrap: anywhere; }.line-results tbody tr:last-child td { border-bottom: 0; }.line-results th { background: #f8fafc; color: #64748b; font-size: 12px; font-weight: 600; }.line-results th span, .line-results th small { display: block; }.deleted-row { color: #94a3b8; text-decoration: line-through; }.result-error { color: #b91c1c; }
|
||||
.header-results .field-needs_review, .header-results .field-unavailable, .header-results .field-failed, .header-results .field-missing { border-color: #fed7aa; background: #fff7ed; }.header-results .field-issues { color: #b45309; font-size: 11px; }
|
||||
.header-results .field-passed { border-color: #bbf7d0; background: #f0fdf4; }
|
||||
.reservation-region-review { margin-top: 16px; padding: 12px; border: 1px solid #fed7aa; border-radius: 8px; background: #fff7ed; }
|
||||
.reservation-region-review h3 { margin: 0; color: #9a3412; font-size: 14px; }
|
||||
.reservation-region-review p { margin: 6px 0 0; color: #b45309; font-size: 13px; }
|
||||
.xfa-line-card { margin-top: 12px; padding: 12px; border: 1px solid #e5ebf1; border-radius: 8px; background: #fbfdff; }.xfa-line-card h4 { margin: 0 0 8px; font-size: 13px; color: #475569; }
|
||||
@media (max-width: 767px) { .validation-page { padding: 16px; } header, .validation-state, .current-draft-validation > header, .checks article, .blind-test-gate, .results-heading { display: grid; }.validation-state button, .current-draft-validation > header button, .blind-test-gate button, .results-heading button { width: 100%; } }
|
||||
.validation-state { border-color: var(--el-color-primary-light-7); background: var(--el-color-primary-light-9); }.validation-state b { color: var(--el-color-primary); font-size: 14px; }.state-ready { border-color: var(--el-color-success-light-7); background: var(--el-color-success-light-9); }.state-ready b { color: var(--el-color-success); }.state-stale, .state-failed { border-color: var(--el-color-danger-light-7); background: var(--el-color-danger-light-9); }.state-stale b, .state-failed b { color: var(--el-color-danger); }
|
||||
.validation-card h2, .checks h3 { margin: 0; color: var(--el-text-color-primary); font-size: 15px; font-weight: 600; }
|
||||
.current-draft-validation { display: grid; gap: 16px; margin-top: 20px; padding: 16px; }.current-draft-validation > header { align-items: center; }.current-draft-validation > header > div { min-width: 0; }.current-draft-validation > header .el-button { flex: 0 0 auto; }.checks { display: grid; gap: 10px; }.checks article { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-radius: 8px; padding: 15px 16px; }
|
||||
.blind-test-gate { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 16px; }.blind-test-gate h2 { margin: 0; color: var(--el-text-color-primary); font-size: 15px; font-weight: 600; }.gate-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
|
||||
.results { margin-top: 20px; padding: 16px; }.results-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }.results h2, .results h3 { margin: 0; color: var(--el-text-color-primary); }.results h2 { font-size: 15px; }.results h3 { margin-top: 20px; font-size: 14px; }.results-heading p { margin: 5px 0 0; color: var(--el-text-color-secondary); font-size: 13px; line-height: 1.5; }.header-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0 0; }.header-results div { border: 1px solid var(--el-border-color-lighter); border-radius: 6px; background: var(--el-fill-color-lighter); padding: 10px; }.header-results dt { color: var(--el-text-color-secondary); font-size: 13px; font-weight: 600; }.header-results dd { margin: 4px 0 0; overflow-wrap: anywhere; }.header-results .field-code, .line-results th small { color: var(--el-text-color-placeholder); font-size: 12px; font-weight: 400; }.line-results { margin-top: 12px; overflow-x: auto; border: 1px solid var(--el-border-color-lighter); border-radius: 6px; }.line-results table { width: 100%; min-width: 560px; border-collapse: collapse; }.line-results th, .line-results td { padding: 10px 12px; border-bottom: 1px solid var(--el-border-color-lighter); text-align: left; vertical-align: top; overflow-wrap: anywhere; }.line-results tbody tr:last-child td { border-bottom: 0; }.line-results th { background: var(--el-fill-color-light); color: var(--el-text-color-secondary); font-size: 12px; font-weight: 600; }.line-results th span, .line-results th small { display: block; }.deleted-row { color: var(--el-text-color-placeholder); text-decoration: line-through; }.result-error { color: var(--el-color-danger); }
|
||||
.header-results .field-needs_review, .header-results .field-unavailable, .header-results .field-failed, .header-results .field-missing { border-color: var(--el-color-warning-light-7); background: var(--el-color-warning-light-9); }.header-results .field-issues { color: var(--el-color-warning); font-size: 12px; }
|
||||
.header-results .field-passed { border-color: var(--el-color-success-light-7); background: var(--el-color-success-light-9); }
|
||||
.reservation-region-review { margin-top: 16px; padding: 12px; border: 1px solid var(--el-color-warning-light-7); border-radius: 8px; background: var(--el-color-warning-light-9); }
|
||||
.reservation-region-review h3 { margin: 0; color: var(--el-color-warning-dark-2); font-size: 14px; }
|
||||
.reservation-region-review p { margin: 6px 0 0; color: var(--el-color-warning); font-size: 13px; }
|
||||
.xfa-line-card { margin-top: 12px; padding: 12px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; background: var(--el-fill-color-lighter); }.xfa-line-card h4 { margin: 0 0 8px; font-size: 13px; color: var(--el-text-color-secondary); }
|
||||
@media (max-width: 767px) { header, .validation-state, .current-draft-validation > header, .checks article, .blind-test-gate, .results-heading { display: grid; }.validation-state .el-button, .current-draft-validation > header .el-button, .blind-test-gate .el-button, .results-heading .el-button { width: 100%; } }
|
||||
</style>
|
||||
+68
-57
@@ -1,15 +1,28 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileVersionDetailPage.vue
|
||||
用途:订单模板版本中心详情页,支持刷新恢复与分享。
|
||||
依赖:版本详情 composable、配置概览组件、版本中心 API、统一迁移 API。
|
||||
依赖:element-plus(el-button/el-tag/el-select/el-skeleton,沿用管理端 element-trial 主题)、
|
||||
版本详情 composable、配置概览组件、版本中心 API、统一迁移 API。
|
||||
逻辑:当前已接入配置概览、只读样本画布、服务端语义 diff、审计时间线与实际使用;
|
||||
Schema 迁移弹窗按模态语义提供初始焦点、Tab 陷阱、Escape 关闭与焦点恢复;
|
||||
统一 binding 迁移提供 Dry Run 状态徽章入口。
|
||||
视觉层已迁移 Element Plus(按钮→el-button,徽章→el-tag,弹窗内 select→el-select,加载态→el-skeleton);
|
||||
迁移弹窗保留手写结构:ElButton 不暴露 focus(),cancel 按钮的模板 ref 与 Tab 陷阱/焦点恢复逻辑强耦合,换控件会破坏模态焦点契约。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import {
|
||||
ElButton,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSkeleton,
|
||||
ElTag,
|
||||
} from "element-plus";
|
||||
import "element-plus/dist/index.css";
|
||||
import "element-plus/theme-chalk/dark/css-vars.css";
|
||||
import "@/features/admin/styles/element-trial.css";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { useMessage } from "@/shared/composables/useMessage";
|
||||
import {
|
||||
@@ -369,22 +382,21 @@ watch(
|
||||
<p class="header-meta">{{ pageTitle }}</p>
|
||||
</div>
|
||||
<div class="header-actions" v-if="detail">
|
||||
<button type="button" class="btn-secondary" @click="goBackToWorkbench">
|
||||
<el-button @click="goBackToWorkbench">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.backToWorkbench") }}
|
||||
</button>
|
||||
<button
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="detail.status === 'draft'"
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
type="primary"
|
||||
@click="continueEditing"
|
||||
>
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.continueEditing") }}
|
||||
</button>
|
||||
<button
|
||||
</el-button>
|
||||
<el-button
|
||||
v-else
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
type="primary"
|
||||
:disabled="cloning"
|
||||
:loading="cloning"
|
||||
@click="createNewVersion"
|
||||
>
|
||||
{{
|
||||
@@ -392,20 +404,18 @@ watch(
|
||||
? t("admin.shippingOrderProfiles.saving")
|
||||
: t("admin.shippingOrderProfiles.newVersion")
|
||||
}}
|
||||
</button>
|
||||
<button
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="canMigrateSchema"
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
type="primary"
|
||||
@click="openSchemaMigration"
|
||||
>
|
||||
{{ t("admin.shippingOrderProfiles.schemaMigration.action", { version: publishedSchema?.version }) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost"
|
||||
</el-button>
|
||||
<el-button
|
||||
data-testid="order-profile-unified-migration-dry-run"
|
||||
:disabled="unifiedMigrating"
|
||||
:loading="unifiedMigrating"
|
||||
@click="runUnifiedMigrationDryRun"
|
||||
>
|
||||
{{
|
||||
@@ -413,9 +423,10 @@ watch(
|
||||
? t("admin.shippingOrderProfiles.unifiedMigration.running")
|
||||
: t("admin.shippingOrderProfiles.unifiedMigration.dryRun")
|
||||
}}
|
||||
</button>
|
||||
<span
|
||||
</el-button>
|
||||
<el-tag
|
||||
v-if="unifiedMigrationReport"
|
||||
size="small"
|
||||
class="unified-migration-badge"
|
||||
data-testid="order-profile-unified-migration-badge"
|
||||
>
|
||||
@@ -425,13 +436,13 @@ watch(
|
||||
diff: unifiedMigrationReport.field_diff_count ?? 0,
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div v-if="loading" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.loading") }}
|
||||
<el-skeleton :rows="4" animated />
|
||||
</div>
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
{{ errorMessage }}
|
||||
@@ -482,6 +493,8 @@ watch(
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 迁移弹窗保留手写模态结构:cancel 按钮的模板 ref(原生 button.focus())与 Tab 陷阱/焦点恢复逻辑耦合,
|
||||
data-testid 契约挂在 backdrop/dialog 节点上;仅将其中的 select 换为 el-select、配色走 token。 -->
|
||||
<div
|
||||
v-if="migrationOpen"
|
||||
class="migration-backdrop"
|
||||
@@ -506,15 +519,20 @@ watch(
|
||||
<span>{{ t("admin.shippingOrderProfiles.schemaMigration.reason", { reason: change.reason }) }}</span>
|
||||
<label>
|
||||
{{ t("admin.shippingOrderProfiles.schemaMigration.resolution") }}
|
||||
<select
|
||||
:value="migrationReplacementId(change.field_id)"
|
||||
@change="setMigrationResolution(change.field_id, ($event.target as HTMLSelectElement).value)"
|
||||
<el-select
|
||||
class="migration-select"
|
||||
:model-value="migrationReplacementId(change.field_id)"
|
||||
:placeholder="t('admin.shippingOrderProfiles.schemaMigration.unbind')"
|
||||
@update:model-value="(value) => setMigrationResolution(change.field_id, String(value))"
|
||||
>
|
||||
<option value="">{{ t("admin.shippingOrderProfiles.schemaMigration.unbind") }}</option>
|
||||
<option v-for="candidate in change.replacement_candidates || []" :key="candidate.field_id" :value="candidate.field_id">
|
||||
{{ candidate.display_name || candidate.field_code || candidate.field_id }}
|
||||
</option>
|
||||
</select>
|
||||
<el-option value="" :label="t('admin.shippingOrderProfiles.schemaMigration.unbind')" />
|
||||
<el-option
|
||||
v-for="candidate in change.replacement_candidates || []"
|
||||
:key="candidate.field_id"
|
||||
:value="candidate.field_id"
|
||||
:label="candidate.display_name || candidate.field_code || candidate.field_id"
|
||||
/>
|
||||
</el-select>
|
||||
</label>
|
||||
</article>
|
||||
</div>
|
||||
@@ -549,9 +567,9 @@ watch(
|
||||
.state-card,
|
||||
.version-switcher,
|
||||
.detail-panel {
|
||||
border: 1px solid var(--border-default);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 1rem;
|
||||
background: var(--bg-surface);
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.page-header {
|
||||
@@ -576,7 +594,7 @@ watch(
|
||||
.header-kicker,
|
||||
.header-meta {
|
||||
margin: 0;
|
||||
color: var(--text-muted);
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
@@ -586,22 +604,15 @@ watch(
|
||||
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; align-items: center; }
|
||||
|
||||
.unified-migration-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 999px;
|
||||
padding: 0.25rem 0.7rem;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-secondary);
|
||||
background: var(--bg-muted, transparent);
|
||||
}
|
||||
|
||||
.tab-button,
|
||||
.version-item {
|
||||
border: 1px solid var(--border-default);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 0.75rem;
|
||||
background: var(--bg-surface);
|
||||
color: var(--text-secondary);
|
||||
background: var(--el-bg-color);
|
||||
color: var(--el-text-color-regular);
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
@@ -621,9 +632,9 @@ watch(
|
||||
}
|
||||
|
||||
.tab-button.active {
|
||||
border-color: #0ea5e9;
|
||||
background: var(--status-info-bg);
|
||||
color: var(--status-info-fg);
|
||||
border-color: var(--el-color-primary);
|
||||
background: var(--el-color-primary-light-9);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.version-switcher {
|
||||
@@ -639,13 +650,13 @@ watch(
|
||||
gap: 0.1rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.version-switcher__label small {
|
||||
max-width: 15rem;
|
||||
overflow: hidden;
|
||||
color: var(--text-muted);
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 400;
|
||||
text-overflow: ellipsis;
|
||||
@@ -668,13 +679,13 @@ watch(
|
||||
}
|
||||
|
||||
.version-item.active {
|
||||
border-color: #0ea5e9;
|
||||
background: var(--status-info-bg);
|
||||
color: var(--status-info-fg);
|
||||
border-color: var(--el-color-primary);
|
||||
background: var(--el-color-primary-light-9);
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.version-item span {
|
||||
color: var(--text-muted);
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
@@ -684,13 +695,13 @@ watch(
|
||||
|
||||
.error-card {
|
||||
padding: 1rem;
|
||||
color: var(--status-error-fg);
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.migration-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgb(15 23 42 / 45%); }
|
||||
.migration-dialog { display: grid; grid-auto-rows: max-content; width: min(100%, 42rem); max-height: min(44rem, calc(100vh - 2rem)); gap: 1rem; overflow-y: auto; padding: 1.5rem; border-radius: 1rem; background: var(--bg-surface); box-shadow: 0 20px 40px rgb(15 23 42 / 25%); }
|
||||
.migration-dialog h2,.migration-dialog p { margin: 0; }.migration-note { color: var(--text-muted); font-size: .875rem; }.migration-changes { display: grid; gap: .75rem; }.migration-changes article { display: grid; gap: .45rem; padding: .85rem; border: 1px solid var(--border-default); border-radius: .75rem; }.migration-changes span { color: var(--text-muted); font-size: .8125rem; }.migration-changes label { display: grid; gap: .3rem; color: var(--text-secondary); font-size: .8125rem; font-weight: 600; }.migration-changes select { min-height: 2.25rem; border: 1px solid var(--border-default); border-radius: .5rem; background: var(--bg-surface); color: var(--text-primary); font: inherit; }/* footer 用 sticky 钉在对话框可视底部:breaking changes 列表长时取消/确认迁移按钮始终可见,不需滚回底部 */
|
||||
.migration-dialog footer { position: sticky; bottom: -1.5rem; display: flex; justify-content: flex-end; gap: .5rem; margin: 0 -1.5rem -1.5rem; border-top: 1px solid var(--border-default); background: var(--bg-surface); padding: 1rem 1.5rem 1.25rem; }
|
||||
.migration-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 1rem; background: var(--el-overlay-color-lighter); }
|
||||
.migration-dialog { display: grid; grid-auto-rows: max-content; width: min(100%, 42rem); max-height: min(44rem, calc(100vh - 2rem)); gap: 1rem; overflow-y: auto; padding: 1.5rem; border-radius: 1rem; background: var(--el-bg-color); box-shadow: var(--el-box-shadow-dark); }
|
||||
.migration-dialog h2,.migration-dialog p { margin: 0; }.migration-note { color: var(--el-text-color-secondary); font-size: .875rem; }.migration-changes { display: grid; gap: .75rem; }.migration-changes article { display: grid; gap: .45rem; padding: .85rem; border: 1px solid var(--el-border-color-lighter); border-radius: .75rem; }.migration-changes span { color: var(--el-text-color-secondary); font-size: .8125rem; }.migration-changes label { display: grid; gap: .3rem; color: var(--el-text-color-regular); font-size: .8125rem; font-weight: 600; }.migration-select { width: 100%; }/* footer 用 sticky 钉在对话框可视底部:breaking changes 列表长时取消/确认迁移按钮始终可见,不需滚回底部 */
|
||||
.migration-dialog footer { position: sticky; bottom: -1.5rem; display: flex; justify-content: flex-end; gap: .5rem; margin: 0 -1.5rem -1.5rem; border-top: 1px solid var(--el-border-color-lighter); background: var(--el-bg-color); padding: 1rem 1.5rem 1.25rem; }
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.header-main,
|
||||
|
||||
+124
-115
@@ -1,14 +1,24 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileAuditTimeline.vue
|
||||
用途:展示订单模板版本中心的治理审计时间线(含 XFA operation_id / checksum)。
|
||||
依赖:版本中心审计 API、版本详情 DTO、Vue I18n。
|
||||
依赖:element-plus(el-button / el-input / el-date-picker / el-tag / el-alert / el-empty /
|
||||
el-skeleton / el-timeline,沿用管理端 element-trial 主题)、版本中心审计 API、
|
||||
版本详情 DTO、Vue I18n。
|
||||
逻辑:使用 before_id 游标分页避免新增事件导致翻页重复;只展示安全 detail 摘要,
|
||||
以及 XFA 变更前后 definition checksum 与 operation_id;不展示 PDF、正文或盲测真值;
|
||||
对视觉绑定 / 拆分 / 统一迁移事件渲染分组标签与 visual before/after 摘要。
|
||||
对视觉绑定 / 拆分 / 迁移事件渲染分组标签与 visual before/after 摘要。
|
||||
EP 迁移:工具栏/分页/重试按钮迁移为 el-button(应用=primary);筛选输入迁移为 el-input 与
|
||||
el-date-picker(value-format 保持字符串契约);加载/错误/空态迁移为 el-skeleton /
|
||||
el-alert / el-empty;审计列表迁移为 el-timeline;visual/split 分组标签迁移为 el-tag;
|
||||
颜色统一 --el-* token;业务脚本(游标分页/筛选/错误兜底)零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ElAlert, ElButton, ElDatePicker, ElEmpty, ElInput, ElSkeleton, ElTag, ElTimeline, ElTimelineItem } from "element-plus";
|
||||
import "element-plus/dist/index.css";
|
||||
import "element-plus/theme-chalk/dark/css-vars.css";
|
||||
import "@/features/admin/styles/element-trial.css";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { listOrderDocumentProfileAuditEvents } from "@/features/admin/api/shipping-order-document-profile.api";
|
||||
import type {
|
||||
@@ -145,110 +155,123 @@ watch(
|
||||
<p>{{ t("admin.shippingOrderProfiles.versionCenter.audit.subtitle") }}</p>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading" @click="resetFilters">
|
||||
<el-button size="small" :disabled="loading" @click="resetFilters">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.reset") }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary btn-sm" :disabled="loading" @click="applyFilters">
|
||||
</el-button>
|
||||
<el-button size="small" type="primary" :disabled="loading" @click="applyFilters">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.apply") }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="filters">
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.eventType") }}</span>
|
||||
<input v-model="filters.eventType" class="input-field" type="text" />
|
||||
<el-input v-model="filters.eventType" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.actor") }}</span>
|
||||
<input v-model="filters.actor" class="input-field" type="text" />
|
||||
<el-input v-model="filters.actor" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.requestId") }}</span>
|
||||
<input v-model="filters.requestIdFilter" class="input-field" type="text" />
|
||||
<el-input v-model="filters.requestIdFilter" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.createdFrom") }}</span>
|
||||
<input v-model="filters.createdFrom" class="input-field" type="date" />
|
||||
<el-date-picker
|
||||
v-model="filters.createdFrom"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.createdTo") }}</span>
|
||||
<input v-model="filters.createdTo" class="input-field" type="date" />
|
||||
<el-date-picker
|
||||
v-model="filters.createdTo"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.loading") }}
|
||||
</div>
|
||||
<el-skeleton v-if="loading" class="state-card" :rows="5" animated />
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
<el-alert :title="errorMessage" type="error" :closable="false" />
|
||||
<el-button class="error-retry" size="small" @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</el-button>
|
||||
</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
|
||||
<el-empty
|
||||
v-else-if="!page?.items.length"
|
||||
class="state-card"
|
||||
:description="t('admin.shippingOrderProfiles.versionCenter.audit.empty')"
|
||||
:image-size="60"
|
||||
/>
|
||||
<el-timeline v-else class="timeline-list">
|
||||
<el-timeline-item
|
||||
v-for="item in page.items"
|
||||
:key="item.id"
|
||||
class="timeline-item"
|
||||
:timestamp="formatTime(item.created_at)"
|
||||
placement="top"
|
||||
>
|
||||
<header>
|
||||
<div>
|
||||
<p class="timeline-type">
|
||||
{{ item.event_type }}
|
||||
<span
|
||||
v-if="isUnifiedVisualOrSplitEvent(item.event_type)"
|
||||
class="event-tag"
|
||||
data-testid="order-profile-audit-visual-tag"
|
||||
>visual/split</span>
|
||||
</p>
|
||||
<h4>{{ item.actor.display_name }}</h4>
|
||||
<article class="timeline-item">
|
||||
<header>
|
||||
<div>
|
||||
<p class="timeline-type">
|
||||
{{ item.event_type }}
|
||||
<el-tag
|
||||
v-if="isUnifiedVisualOrSplitEvent(item.event_type)"
|
||||
size="small"
|
||||
type="info"
|
||||
data-testid="order-profile-audit-visual-tag"
|
||||
>visual/split</el-tag>
|
||||
</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>
|
||||
<code
|
||||
v-if="item.operation_id"
|
||||
data-testid="order-profile-audit-operation-id"
|
||||
>{{ item.operation_id }}</code>
|
||||
</div>
|
||||
</header>
|
||||
<dl
|
||||
v-if="item.definition_checksum || item.before_definition_checksum"
|
||||
class="checksum-row"
|
||||
data-testid="order-profile-audit-checksums"
|
||||
>
|
||||
<div v-if="item.before_definition_checksum">
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.audit.beforeChecksum") }}</dt>
|
||||
<dd><code>{{ item.before_definition_checksum }}</code></dd>
|
||||
</div>
|
||||
<div v-if="item.definition_checksum">
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.audit.afterChecksum") }}</dt>
|
||||
<dd><code>{{ item.definition_checksum }}</code></dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div
|
||||
v-if="visualPayload(item.detail as Record<string, unknown>)"
|
||||
class="visual-diff"
|
||||
data-testid="order-profile-audit-visual-diff"
|
||||
>
|
||||
<p class="visual-diff-title">{{ t("admin.shippingOrderProfiles.versionCenter.audit.visualDiff") }}</p>
|
||||
<pre>{{ formatJson(visualPayload(item.detail as Record<string, unknown>)) }}</pre>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<span>{{ formatTime(item.created_at) }}</span>
|
||||
<code v-if="item.request_id">{{ item.request_id }}</code>
|
||||
<code
|
||||
v-if="item.operation_id"
|
||||
data-testid="order-profile-audit-operation-id"
|
||||
>{{ item.operation_id }}</code>
|
||||
</div>
|
||||
</header>
|
||||
<dl
|
||||
v-if="item.definition_checksum || item.before_definition_checksum"
|
||||
class="checksum-row"
|
||||
data-testid="order-profile-audit-checksums"
|
||||
>
|
||||
<div v-if="item.before_definition_checksum">
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.audit.beforeChecksum") }}</dt>
|
||||
<dd><code>{{ item.before_definition_checksum }}</code></dd>
|
||||
</div>
|
||||
<div v-if="item.definition_checksum">
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.audit.afterChecksum") }}</dt>
|
||||
<dd><code>{{ item.definition_checksum }}</code></dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div
|
||||
v-if="visualPayload(item.detail as Record<string, unknown>)"
|
||||
class="visual-diff"
|
||||
data-testid="order-profile-audit-visual-diff"
|
||||
>
|
||||
<p class="visual-diff-title">{{ t("admin.shippingOrderProfiles.versionCenter.audit.visualDiff") }}</p>
|
||||
<pre>{{ formatJson(visualPayload(item.detail as Record<string, unknown>)) }}</pre>
|
||||
</div>
|
||||
<pre>{{ formatJson(item.detail) }}</pre>
|
||||
</article>
|
||||
</div>
|
||||
<pre>{{ formatJson(item.detail) }}</pre>
|
||||
</article>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
|
||||
<div class="pager">
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
<el-button size="small" :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.previous") }}
|
||||
</button>
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading || !hasNext" @click="loadNext">
|
||||
</el-button>
|
||||
<el-button size="small" :disabled="loading || !hasNext" @click="loadNext">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.next") }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -257,11 +280,10 @@ watch(
|
||||
.timeline-panel,
|
||||
.toolbar,
|
||||
.filters,
|
||||
.timeline-item,
|
||||
.state-card {
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 1rem;
|
||||
background: var(--bg-surface);
|
||||
.timeline-item {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.timeline-panel {
|
||||
@@ -286,13 +308,13 @@ watch(
|
||||
.toolbar h3,
|
||||
.timeline-item h4 {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.toolbar p {
|
||||
margin: 0.25rem 0 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.timeline-type {
|
||||
@@ -301,30 +323,21 @@ watch(
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
margin: 0.25rem 0 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.event-tag {
|
||||
display: inline-flex;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 999px;
|
||||
padding: 0.05rem 0.45rem;
|
||||
font-size: 0.65rem;
|
||||
color: var(--text-secondary);
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.visual-diff {
|
||||
margin-top: 0.65rem;
|
||||
padding: 0.65rem 0.75rem;
|
||||
border: 1px dashed var(--border-default);
|
||||
border-radius: 0.75rem;
|
||||
border: 1px dashed var(--el-border-color);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.visual-diff-title {
|
||||
margin: 0 0 0.35rem;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.toolbar-actions,
|
||||
@@ -342,18 +355,18 @@ watch(
|
||||
.filters label {
|
||||
display: grid;
|
||||
gap: 0.3rem;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.filters .input-field {
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
.error-card {
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.timeline-list {
|
||||
display: grid;
|
||||
gap: 0.8rem;
|
||||
padding: 4px 0 0 4px;
|
||||
}
|
||||
|
||||
.timeline-item header {
|
||||
@@ -367,11 +380,11 @@ watch(
|
||||
display: grid;
|
||||
gap: 0.35rem;
|
||||
margin: 0.5rem 0;
|
||||
font-size: 0.75rem;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.checksum-row dt {
|
||||
color: var(--text-muted);
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.checksum-row dd {
|
||||
@@ -379,7 +392,7 @@ watch(
|
||||
}
|
||||
|
||||
.checksum-row code {
|
||||
font-size: 0.7rem;
|
||||
font-size: 11px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@@ -387,26 +400,22 @@ watch(
|
||||
display: grid;
|
||||
justify-items: end;
|
||||
gap: 0.25rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.timeline-item pre {
|
||||
margin: 0.85rem 0 0;
|
||||
border-radius: 0.75rem;
|
||||
background: var(--bg-surface-strong);
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-light);
|
||||
padding: 0.8rem;
|
||||
color: var(--text-primary);
|
||||
font-size: 0.72rem;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 11px;
|
||||
line-height: 1.45;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.error-card {
|
||||
color: var(--status-error-fg);
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.filters {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
|
||||
+60
-70
@@ -1,7 +1,8 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileDocumentCanvas.vue
|
||||
用途:展示受控 PDF/XFA flatten 单页预览,并以相对坐标框支持选择、拖动和缩放区域。
|
||||
依赖:浏览器 fetch、认证请求头、OrderProfileCanvasRegion、isUnboundOrderFieldCanvasRegion。
|
||||
依赖:element-plus(el-button / el-input,沿用管理端 element-trial 主题)、浏览器 fetch、
|
||||
认证请求头、OrderProfileCanvasRegion、isUnboundOrderFieldCanvasRegion。
|
||||
逻辑:父级签发单页令牌并提供分页动作;mode=readonly 时只允许查看/缩放/切页,不允许写入任何标注改动;
|
||||
PNG 预览 token 为一次性消费,组件内按页缓存 blob,翻页回访不再重新拉 token;
|
||||
原 PDF(pdf-preview)令牌亦为 Redis getdel 单次消费:同 token 字节必须缓存,且仅 HTTP 401/403/404
|
||||
@@ -13,10 +14,19 @@
|
||||
绘制模式下仍允许操作当前选中框;整边 resize 热区便于矮标签拉高;
|
||||
画布区域 aria-label 走四语言 i18n;可选 emptyHint/loadError 区分 XFA page_unavailable 与 PDF 缺样本空态;
|
||||
订单字段标签在已有正式/OCR 值时优先展示,loading 仅在尚无值时显示「读取中」。
|
||||
EP 迁移(定向,仅外围 chrome):顶部工具栏(撤销/重做/复制/删除/保存/翻页/缩放/适配)与
|
||||
左侧绘制工具栏、画布重试按钮迁移为 el-button(lucide 图标保留,置于按钮内);
|
||||
页码输入迁移为 el-input(goToPage 内部本就做 Number 归一,契约不变);
|
||||
画布 stage/区域框/拖拽缩放热区等绘制与几何逻辑、及区域配色一律未改动;
|
||||
预览加载/token 缓存/reauth 业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElIcon, ElInput } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { Anchor, ArrowLeft, ArrowRight, Columns3, Copy, Eraser, MessageSquareText, Minus, Plus, Redo2, RotateCcw, Rows3, Save, TableProperties, Tag, TextCursorInput, Trash2, WandSparkles } from 'lucide-vue-next';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { loadPdfJs } from '@/shared/utils/pdfjs';
|
||||
@@ -504,13 +514,13 @@ onBeforeUnmount(() => {
|
||||
<header v-if="imageUrl || pdfRendered" class="canvas-toolbar">
|
||||
<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>
|
||||
<el-button :disabled="undoDisabled" :title="t('admin.shippingOrderProfiles.workbench.undo')" :aria-label="t('admin.shippingOrderProfiles.workbench.undo')" @click="emit('undo')"><el-icon><RotateCcw /></el-icon></el-button>
|
||||
<el-button :disabled="redoDisabled" :title="t('admin.shippingOrderProfiles.workbench.redo')" :aria-label="t('admin.shippingOrderProfiles.workbench.redo')" @click="emit('redo')"><el-icon><Redo2 /></el-icon></el-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>
|
||||
<el-button :disabled="duplicateDisabled" :title="t('admin.shippingOrderProfiles.workbench.duplicateRegionShortcut')" :aria-label="t('admin.shippingOrderProfiles.workbench.duplicateRegionShortcut')" @click="emit('duplicate')"><el-icon><Copy /></el-icon></el-button>
|
||||
<el-button class="delete-action" type="danger" plain :disabled="deleteDisabled" :title="t('admin.shippingOrderProfiles.workbench.deleteRegionShortcut')" :aria-label="t('admin.shippingOrderProfiles.workbench.deleteRegionShortcut')" @click="emit('delete')"><el-icon><Trash2 /></el-icon></el-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>
|
||||
<el-button class="save-action" type="primary" :disabled="saveDisabled || saving" :title="t('admin.save')" @click="emit('save')"><el-icon><Save /></el-icon><span>{{ saving ? t('admin.shippingOrderProfiles.saving') : t('admin.save') }}</span></el-button>
|
||||
<template v-if="pendingSuggestionCount">
|
||||
<span class="toolbar-divider" aria-hidden="true" />
|
||||
<span class="suggestion-count">{{ pendingSuggestionCount }}</span>
|
||||
@@ -520,37 +530,37 @@ onBeforeUnmount(() => {
|
||||
<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" class="input-field" 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>
|
||||
<el-button :disabled="pageNo <= 1" :title="t('admin.shippingOrderExtractionRuns.previous')" :aria-label="t('admin.shippingOrderExtractionRuns.previous')" @click="emit('page', pageNo - 1)"><el-icon><ArrowLeft /></el-icon></el-button>
|
||||
<label><el-input v-model="pageInput" type="number" min="1" :max="pageCount" :aria-label="t('admin.shippingOrderProfiles.workbench.pageNavigation')" @change="goToPage" @keydown.enter.prevent="goToPage" /><span>/ {{ pageCount }}</span></label>
|
||||
<el-button :disabled="pageNo >= pageCount" :title="t('admin.shippingOrderExtractionRuns.next')" :aria-label="t('admin.shippingOrderExtractionRuns.next')" @click="emit('page', pageNo + 1)"><el-icon><ArrowRight /></el-icon></el-button>
|
||||
</div>
|
||||
<div class="zoom-control">
|
||||
<button type="button" :disabled="zoom <= .5" :title="t('admin.shippingOrderProfiles.workbench.zoomOut')" @click="adjustZoom(-.25)"><Minus /></button>
|
||||
<el-button :disabled="zoom <= .5" :title="t('admin.shippingOrderProfiles.workbench.zoomOut')" :aria-label="t('admin.shippingOrderProfiles.workbench.zoomOut')" @click="adjustZoom(-.25)"><el-icon><Minus /></el-icon></el-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>
|
||||
<el-button :disabled="zoom >= 4" :title="t('admin.shippingOrderProfiles.workbench.zoomIn')" :aria-label="t('admin.shippingOrderProfiles.workbench.zoomIn')" @click="adjustZoom(.25)"><el-icon><Plus /></el-icon></el-button>
|
||||
<el-button class="fit-action" @click="resetZoom">{{ t('admin.shippingOrderProfiles.workbench.fitPage') }}</el-button>
|
||||
</div>
|
||||
</header>
|
||||
<div v-if="loading && !pdfPreview" class="canvas-state">{{ t('admin.shippingOrderProfiles.workbench.loadingPage') }}</div>
|
||||
<!-- PNG 路径仍可用整页错误态;原 PDF 路径必须保留 canvas 挂载,否则 renderPdfPage 必抛 canvas unavailable。 -->
|
||||
<div v-else-if="displayLoadError && !pdfPreview" class="canvas-state canvas-state--error" role="alert">
|
||||
<p>{{ displayLoadError }}</p>
|
||||
<button type="button" class="canvas-retry" @click="onRetryClick">
|
||||
<el-button class="canvas-retry" @click="onRetryClick">
|
||||
{{ t('admin.shippingOrderProfiles.workbench.retryCanvas') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-else-if="!imageUrl && !pdfRendered && !pdfPreview" class="canvas-state">{{ emptyStateText }}</div>
|
||||
<div v-else class="canvas-work-area" :class="{ readonly: readonlyMode }">
|
||||
<aside v-if="!readonlyMode" class="annotation-tools">
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :class="{ active: creationKind === 'document_anchor_label' || creationKind === 'document_anchor_value' }" @click="emit('draw', 'document_anchor_label')"><Anchor /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :class="{ active: creationKind === 'order_anchor' }" @click="emit('draw', 'order_anchor')"><Tag /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :class="{ active: creationKind === 'order_field' }" @click="emit('draw', 'order_field')"><TextCursorInput /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :class="{ active: creationKind === 'header_field' }" @click="emit('draw', 'header_field')"><TableProperties /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :class="{ active: creationKind === 'line' }" @click="emit('draw', 'line')"><Rows3 /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :class="{ active: creationKind === 'field' }" @click="emit('draw', 'field')"><Columns3 /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :class="{ active: creationKind === 'exclusion' }" @click="emit('draw', 'exclusion')"><Eraser /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut')" :class="{ active: creationKind === 'reservation_id_region' }" @click="emit('draw', 'reservation_id_region')"><MessageSquareText /></button>
|
||||
<button type="button" class="suggest" :aria-label="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :title="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :disabled="autoSuggestDisabled || suggesting" @click="emit('suggest')"><WandSparkles /></button>
|
||||
<el-button :aria-label="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :class="{ active: creationKind === 'document_anchor_label' || creationKind === 'document_anchor_value' }" @click="emit('draw', 'document_anchor_label')"><el-icon><Anchor /></el-icon></el-button>
|
||||
<el-button :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :class="{ active: creationKind === 'order_anchor' }" @click="emit('draw', 'order_anchor')"><el-icon><Tag /></el-icon></el-button>
|
||||
<el-button :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :class="{ active: creationKind === 'order_field' }" @click="emit('draw', 'order_field')"><el-icon><TextCursorInput /></el-icon></el-button>
|
||||
<el-button :aria-label="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :class="{ active: creationKind === 'header_field' }" @click="emit('draw', 'header_field')"><el-icon><TableProperties /></el-icon></el-button>
|
||||
<el-button :aria-label="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :class="{ active: creationKind === 'line' }" @click="emit('draw', 'line')"><el-icon><Rows3 /></el-icon></el-button>
|
||||
<el-button :aria-label="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :class="{ active: creationKind === 'field' }" @click="emit('draw', 'field')"><el-icon><Columns3 /></el-icon></el-button>
|
||||
<el-button :aria-label="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :class="{ active: creationKind === 'exclusion' }" @click="emit('draw', 'exclusion')"><el-icon><Eraser /></el-icon></el-button>
|
||||
<el-button :aria-label="t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut')" :class="{ active: creationKind === 'reservation_id_region' }" @click="emit('draw', 'reservation_id_region')"><el-icon><MessageSquareText /></el-icon></el-button>
|
||||
<el-button class="suggest" :aria-label="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :title="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :disabled="autoSuggestDisabled || suggesting" @click="emit('suggest')"><el-icon><WandSparkles /></el-icon></el-button>
|
||||
<p v-if="suggestionProgress" class="suggestion-progress" :class="{ failed: !suggesting }">{{ suggestionProgress }}</p>
|
||||
</aside>
|
||||
<div ref="viewport" class="canvas-viewport" :class="{ panning: !creationKind || readonlyMode }" @wheel.prevent="handleWheel">
|
||||
@@ -633,53 +643,35 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
<div v-if="displayLoadError && pdfPreview" class="canvas-error-overlay" role="alert">
|
||||
<p>{{ displayLoadError }}</p>
|
||||
<button type="button" class="canvas-retry" @click="onRetryClick">
|
||||
<el-button class="canvas-retry" @click="onRetryClick">
|
||||
{{ t('admin.shippingOrderProfiles.workbench.retryCanvas') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.canvas-shell { display: flex; height: calc(100vh - 5rem); min-height: 48rem; flex-direction: column; background: #101827; padding: 0 1rem 1rem; overflow: hidden; }
|
||||
.canvas-toolbar { position: sticky; top: 0; z-index: 4; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem; margin: 0 -1rem 1rem; padding: .55rem 1rem; border-bottom: 1px solid #26354b; background: rgb(15 23 42 / .98); color: #cbd5e1; font-size: .75rem; }
|
||||
/* 文档桌台:比界面底色深一档的中性冷灰,与白纸拉开图底关系(Figma/预览器惯例);暗色模式走 EP 深色填充 */
|
||||
.canvas-shell { display: flex; height: calc(100vh - 5rem); min-height: 48rem; flex-direction: column; background: #dfe5ec; padding: 0 1rem 1rem; overflow: hidden; }
|
||||
html.dark .canvas-shell { background: var(--el-fill-color-dark); }
|
||||
.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 var(--el-border-color-lighter); background: var(--el-bg-color); color: var(--el-text-color-regular); font-size: 12px; }
|
||||
.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; }
|
||||
.suggestion-count { display: inline-grid; min-width: 1.25rem; height: 1.25rem; place-items: center; border-radius: 999px; background: #f59e0b; color: #172033; font-size: .68rem; font-weight: 800; }
|
||||
.canvas-toolbar .suggestion-action { border-color: #22c55e; background: #15803d; }
|
||||
.canvas-toolbar .suggestion-action--reject { border-color: #64748b; background: transparent; }
|
||||
.canvas-toolbar svg, .annotation-tools svg { width: .95rem; height: .95rem; }
|
||||
/* EP 迁移:工具栏/绘制工具按钮统一 el-button 默认尺寸(32px 等高对齐);清除 EP 兄弟按钮默认 margin,间距由容器 gap 唯一控制 */
|
||||
.canvas-toolbar > div > .el-button + .el-button { margin-left: 0; }
|
||||
.canvas-toolbar .el-icon, .annotation-tools .el-icon { width: .95rem; height: .95rem; font-size: .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; }
|
||||
.toolbar-divider { width: 1px; height: 1.25rem; margin: 0 .15rem; background: var(--el-border-color-lighter); }
|
||||
.suggestion-count { display: inline-grid; min-width: 1.25rem; height: 1.25rem; place-items: center; border-radius: 999px; background: var(--el-color-warning); color: #fff; font-size: 12px; font-weight: 800; }
|
||||
.readonly-badge { display: inline-flex; align-items: center; min-height: 2rem; border: 1px solid var(--el-border-color-lighter); border-radius: .35rem; background: var(--el-fill-color-light); padding: 0 .65rem; color: var(--el-text-color-secondary); }
|
||||
.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-field { width: 3rem; border: 0; background: transparent; color: #f8fafc; font: 700 .76rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; outline: 0; }
|
||||
.page-control label { display: flex; height: 2rem; align-items: center; gap: .3rem; border: 1px solid var(--el-border-color-lighter); border-radius: .35rem; background: var(--el-fill-color-light); padding: 0 .45rem; color: var(--el-text-color-secondary); }
|
||||
.page-control .el-input { width: 3.4rem; }
|
||||
.page-control .el-input :deep(.el-input__inner) { color: var(--el-text-color-primary); font: 700 .76rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
|
||||
.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-toolbar output { min-width: 3.4rem; color: var(--el-text-color-primary); font-size: 13px; text-align: center; }
|
||||
.canvas-state { display: grid; min-height: 32rem; place-items: center; color: #94a3b8; font-size: .875rem; gap: .75rem; }
|
||||
.canvas-state--error { color: #fecaca; }
|
||||
.canvas-retry {
|
||||
display: inline-flex;
|
||||
min-height: 2rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid #475569;
|
||||
border-radius: .35rem;
|
||||
background: #1e293b;
|
||||
padding: .35rem .75rem;
|
||||
color: #e2e8f0;
|
||||
font-size: .78rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.canvas-retry:hover { border-color: #60a5fa; background: #26364f; }
|
||||
.canvas-state--error { color: var(--el-color-danger); }
|
||||
.canvas-work-area { position: relative; display: flex; min-height: 0; flex: 1; gap: .6rem; }
|
||||
.canvas-error-overlay {
|
||||
position: absolute;
|
||||
@@ -698,7 +690,7 @@ onBeforeUnmount(() => {
|
||||
.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 { position: relative; margin: auto; width: calc(100% * var(--canvas-zoom)); min-width: 42rem; box-shadow: var(--el-box-shadow-light); }
|
||||
.canvas-stage img { display: block; width: 100%; user-select: none; }
|
||||
.canvas-stage canvas.pdf-page { display: block; background: white; pointer-events: none; user-select: none; }
|
||||
.canvas-stage.drawing { cursor: crosshair; }
|
||||
@@ -706,14 +698,13 @@ onBeforeUnmount(() => {
|
||||
/* 绘制模式下仍可缩放/移动当前选中框,避免点了标签工具后高度完全拉不动。 */
|
||||
.canvas-stage.drawing .region.selected { pointer-events: auto; }
|
||||
.creation-region { position: absolute; z-index: 5; box-sizing: border-box; border: 2px dashed #34d399; background: rgb(16 185 129 / .18); pointer-events: none; }
|
||||
.annotation-tools { display: grid; align-content: start; gap: .3rem; flex: 0 0 2.65rem; padding: .3rem; border: 1px solid rgb(71 85 105 / .9); border-radius: .5rem; background: rgb(15 23 42 / .94); box-shadow: 0 8px 24px rgb(15 23 42 / .3); }
|
||||
.annotation-tools button { display: grid; min-height: 2rem; place-items: center; border: 1px solid transparent; border-radius: .35rem; background: #1e293b; padding: .35rem; color: #e2e8f0; }
|
||||
.annotation-tools button:hover, .annotation-tools button.active { border-color: #38bdf8; background: #0c4a6e; color: #f0f9ff; }
|
||||
.annotation-tools .suggest { border-color: #0ea5e9; background: #0284c7; }
|
||||
.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; }
|
||||
.suggestion-preview-badge { color: #fbbf24; font-size: .68rem; }
|
||||
.annotation-tools { display: grid; align-content: start; gap: .3rem; flex: 0 0 auto; width: max-content; padding: .3rem; border: 1px solid var(--el-border-color-lighter); border-radius: .5rem; background: var(--el-bg-color); box-shadow: var(--el-box-shadow-light); }
|
||||
.annotation-tools .el-button { display: grid; place-items: center; width: 100%; margin-left: 0; }
|
||||
.annotation-tools .el-button.active { border-color: var(--el-color-primary); background: var(--el-color-primary); color: #fff; }
|
||||
.annotation-tools .el-button:disabled { cursor: not-allowed; opacity: .45; }
|
||||
.suggestion-progress { margin: .1rem; color: var(--el-color-primary); font-size: 12px; line-height: 1.35; }
|
||||
.suggestion-progress.failed { color: var(--el-color-danger); }
|
||||
.suggestion-preview-badge { color: var(--el-color-warning); font-size: 12px; }
|
||||
.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; z-index: 2; top: -1.65rem; left: -2px; max-width: min(18rem, 100%); overflow: hidden; border: 1px solid rgb(255 255 255 / .7); border-radius: .25rem .25rem 0 0; background: #0369a1; padding: .2rem .45rem; color: white; font: 700 .7rem/1.15 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
|
||||
@@ -798,8 +789,7 @@ onBeforeUnmount(() => {
|
||||
@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; }
|
||||
.toolbar-actions .save-action span span, .fit-action { display: none; }
|
||||
.suggestion-progress { display: none; }
|
||||
}
|
||||
</style>
|
||||
+54
-73
@@ -1,12 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileFrozenEvidencePanel.vue
|
||||
用途:展示当前只读样本绑定的冻结证据信息。
|
||||
依赖:版本详情样本 DTO、i18n。
|
||||
依赖:element-plus(el-descriptions / el-empty / el-tag,沿用管理端 element-trial 主题)、
|
||||
版本详情样本 DTO、i18n。
|
||||
逻辑:只渲染冻结身份与快照摘要,不泄露正文、对象存储地址或盲测真值。
|
||||
EP 迁移:键值对 dl 迁移为 el-descriptions(:column="2" size=small);缺样本空态迁移为 el-empty;
|
||||
冻结状态以 el-tag 呈现(ready=success / missing=info);颜色统一 --el-* token;业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElDescriptions, ElDescriptionsItem, ElEmpty, ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { OrderProfileBoundSample } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -25,93 +32,67 @@ const frozenStatus = computed(() => (
|
||||
<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>
|
||||
<el-empty v-if="!sample" :description="t('admin.shippingOrderProfiles.versionCenter.selectSampleHint')" :image-size="60" />
|
||||
<el-descriptions v-else :column="2" size="small" class="grid">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.statusLabel')">
|
||||
<el-tag :type="sample.frozen_evidence_ready ? 'success' : 'info'" size="small">{{ frozenStatus }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.sampleFile')">
|
||||
{{ sample.source_filename_snapshot || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.layoutVersionId')">
|
||||
{{ sample.layout_version_id || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.evidenceFrozenAt')">
|
||||
{{ sample.evidence_frozen_at || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.pageCountPlain')">
|
||||
{{ sample.page_count_snapshot || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.parserIdentity')">
|
||||
{{ sample.parser_name || sample.parser_key || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.parserVersionTitle')">
|
||||
{{ sample.parser_version || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.frozenTableId')">
|
||||
{{ sample.table_identity_snapshot?.table_id || sample.table_id || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.frozenPageNo')">
|
||||
{{ sample.table_identity_snapshot?.page_no || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.frozenRowCount')">
|
||||
{{ sample.table_identity_snapshot?.row_count || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.layoutChecksumTitle')">
|
||||
<code>{{ sample.layout_payload_checksum || '-' }}</code>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.contentHashTitle')">
|
||||
<code>{{ sample.source_content_hash || '-' }}</code>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.panel {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 1rem;
|
||||
background: #fff;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 10px;
|
||||
background: var(--el-bg-color);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.panel h3 {
|
||||
margin: 0;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.empty {
|
||||
margin: 0.85rem 0 0;
|
||||
color: #64748b;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
gap: 0.85rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
margin: 0.9rem 0 0;
|
||||
margin-top: 0.9rem;
|
||||
}
|
||||
|
||||
.grid dt {
|
||||
color: #64748b;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.grid dd {
|
||||
margin: 0.3rem 0 0;
|
||||
color: #0f172a;
|
||||
.grid :deep(code) {
|
||||
color: var(--el-text-color-regular);
|
||||
word-break: break-word;
|
||||
}
|
||||
</style>
|
||||
+18
-4
@@ -1,12 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileIdentityStep.vue
|
||||
用途:收集模板名称与已发布 Schema。
|
||||
依赖:Schema DTO、Vue I18n。
|
||||
依赖:element-plus(el-input / el-select / el-option,沿用管理端 element-trial 主题)、
|
||||
Schema DTO、Vue I18n。
|
||||
逻辑:系统编码由服务端在创建时生成;父级拥有唯一表单状态,避免 v-model 对象替换丢失首步校验状态。
|
||||
EP 迁移:名称输入迁移为 el-input、Schema 下拉迁移为 el-select(update 快照契约不变);
|
||||
必填星号保留;颜色统一 --el-* token;业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElInput, ElOption, ElSelect } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { ShippingOrderSchemaVersion } from '@/features/admin/types/shipping-order-schema.types';
|
||||
type Identity = { displayName: string; schemaId: number };
|
||||
const props = defineProps<{ modelValue: Identity; schemas: ShippingOrderSchemaVersion[]; schemasResolved: boolean }>();
|
||||
@@ -19,12 +26,19 @@ function update(key: keyof Identity, value: string | number): void { emit('updat
|
||||
|
||||
<template>
|
||||
<div class="identity-step">
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.name') }}<b>*</b></span><input class="input-field" :value="modelValue.displayName" :placeholder="t('admin.shippingOrderProfiles.wizard.namePlaceholder')" @input="update('displayName', ($event.target as HTMLInputElement).value)" /></label>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.name') }}<b>*</b></span><el-input :model-value="modelValue.displayName" :placeholder="t('admin.shippingOrderProfiles.wizard.namePlaceholder')" @update:model-value="(value) => update('displayName', String(value))" /></label>
|
||||
<div class="system-code"><strong>{{ t('admin.shippingOrderProfiles.code') }}</strong><span>{{ t('admin.shippingOrderProfiles.wizard.systemCodeHint') }}</span></div>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.schema') }}<b>*</b></span><select class="select-field" :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><small v-if="schemasResolved && !publishedSchemas.length" class="field-warning">{{ t('admin.shippingOrderProfiles.wizard.schemaRequired') }}</small></label>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.schema') }}<b>*</b></span><el-select :model-value="modelValue.schemaId" @update:model-value="(value) => update('schemaId', Number(value))"><el-option :value="0" :label="t('admin.shippingOrderProfiles.wizard.selectSchema')" /><el-option v-for="schema in publishedSchemas" :key="schema.id" :value="schema.id" :label="`v${schema.version}`" /></el-select><small v-if="schemasResolved && !publishedSchemas.length" class="field-warning">{{ t('admin.shippingOrderProfiles.wizard.schemaRequired') }}</small></label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.identity-step { display: grid; gap: 22px; max-width: 560px; }.field { display: grid; gap: 8px; color: var(--text-secondary); font-weight: 700; }.field > span { display: flex; gap: 4px; }.field b { color: var(--status-error-fg); }.field .input-field,.field .select-field { min-height: 44px; box-sizing: border-box; font: inherit; }.field small { color: var(--text-muted); font-size: .8rem; font-weight: 500; }.system-code { display: grid; gap: 4px; padding: 13px 14px; border: 1px solid var(--border-default); border-radius: 9px; color: var(--text-secondary); background: var(--bg-surface-soft); font-size: .86rem; }.system-code strong { color: var(--text-primary); }.field-warning { color: var(--status-warning-fg) !important; }
|
||||
.identity-step { display: grid; gap: 22px; max-width: 560px; }
|
||||
.field { display: grid; gap: 8px; color: var(--el-text-color-regular); font-weight: 700; }
|
||||
.field > span { display: flex; gap: 4px; }
|
||||
.field b { color: var(--el-color-danger); }
|
||||
.field small { color: var(--el-text-color-secondary); font-size: .8rem; font-weight: 500; }
|
||||
.system-code { display: grid; gap: 4px; padding: 13px 14px; border: 1px solid var(--el-border-color-lighter); border-radius: 9px; color: var(--el-text-color-regular); background: var(--el-fill-color-lighter); font-size: .86rem; }
|
||||
.system-code strong { color: var(--el-text-color-primary); }
|
||||
.field-warning { color: var(--el-color-warning) !important; }
|
||||
</style>
|
||||
+12
-8
@@ -1,11 +1,17 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileIssuePanel.vue
|
||||
用途:统一呈现工作台保存前的配置问题与局部预览状态。
|
||||
依赖:无。
|
||||
依赖:element-plus(el-tag 状态徽标,沿用管理端 element-trial 主题)。
|
||||
逻辑:父页面计算问题码;本组件只呈现可操作的短提示,不保存样本正文或坐标。
|
||||
EP 迁移:预览状态徽标由手写 chip 迁移为 el-tag(idle=info / updating=primary / ready=success /
|
||||
failed=danger);问题列表与错误文本保留原结构,颜色统一走 --el-* token;业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
const props = defineProps<{ issues: string[]; previewState: 'idle' | 'updating' | 'ready' | 'failed'; previewError?: string }>();
|
||||
const { t } = useI18n();
|
||||
const previewStatusLabel = (state: 'idle' | 'updating' | 'ready' | 'failed') => ({
|
||||
@@ -18,7 +24,7 @@ const previewStatusLabel = (state: 'idle' | 'updating' | 'ready' | 'failed') =>
|
||||
|
||||
<template>
|
||||
<aside class="issue-panel">
|
||||
<div class="issue-title"><span>{{ t('admin.shippingOrderProfiles.workbench.review') }}</span><span :class="`state-${previewState}`">{{ previewStatusLabel(previewState) }}</span></div>
|
||||
<div class="issue-title"><span>{{ t('admin.shippingOrderProfiles.workbench.review') }}</span><el-tag :type="previewState === 'idle' ? 'info' : previewState === 'updating' ? 'primary' : previewState === 'ready' ? 'success' : 'danger'" size="small" effect="light">{{ previewStatusLabel(previewState) }}</el-tag></div>
|
||||
<p v-if="previewState === 'failed' && props.previewError" class="preview-error">{{ props.previewError }}</p>
|
||||
<p v-if="!issues.length" class="issue-empty">{{ t('admin.shippingOrderProfiles.workbench.noIssues') }}</p>
|
||||
<ul v-else><li v-for="issue in issues" :key="issue">{{ issue }}</li></ul>
|
||||
@@ -26,10 +32,8 @@ const previewStatusLabel = (state: 'idle' | 'updating' | 'ready' | 'failed') =>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.issue-panel { border-top: 1px solid #dbe4ef; background: #f8fafc; padding: .75rem 1rem; }
|
||||
.issue-title { display: flex; align-items: center; justify-content: space-between; color: #334155; font: 700 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
|
||||
.issue-title span:last-child { border-radius: 999px; padding: .25rem .5rem; font-size: .65rem; letter-spacing: normal; text-transform: none; }
|
||||
.state-idle { background: #e2e8f0; }.state-updating { background: #dbeafe; color: #1d4ed8; }.state-ready { background: #dcfce7; color: #166534; }.state-failed { background: #fee2e2; color: #b91c1c; }
|
||||
ul { margin: .6rem 0 0; padding-left: 1rem; color: #b45309; font-size: .75rem; line-height: 1.4; }.issue-empty { margin: .5rem 0 0; color: #64748b; font-size: .75rem; }
|
||||
.preview-error { margin: .55rem 0 0; color: #b91c1c; font-size: .75rem; line-height: 1.4; }
|
||||
.issue-panel { border-top: 1px solid var(--el-border-color-lighter); background: var(--el-fill-color-lighter); padding: .75rem 1rem; }
|
||||
.issue-title { display: flex; align-items: center; justify-content: space-between; color: var(--el-text-color-regular); font: 700 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
|
||||
ul { margin: .6rem 0 0; padding-left: 1rem; color: var(--el-color-warning); font-size: .75rem; line-height: 1.4; }.issue-empty { margin: .5rem 0 0; color: var(--el-text-color-secondary); font-size: .75rem; }
|
||||
.preview-error { margin: .55rem 0 0; color: var(--el-color-danger); font-size: .75rem; line-height: 1.4; }
|
||||
</style>
|
||||
+10
-3
@@ -1,14 +1,21 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileModelStartStep.vue
|
||||
用途:在多表样本中选择用于订单明细标注的表格。
|
||||
依赖:样本表格预览 DTO、Vue I18n。
|
||||
依赖:element-plus(el-select / el-option / el-alert,沿用管理端 element-trial 主题)、
|
||||
样本表格预览 DTO、Vue I18n。
|
||||
逻辑:只让用户选定服务端已发现的 table_id;预览限制在容器内横向滚动,避免宽表撑破页面。
|
||||
EP 迁移:表格下拉迁移为 el-select(update:modelValue 字符串契约不变);无表警告迁移为
|
||||
el-alert(warning);颜色统一 --el-* token;业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElAlert, ElOption, ElSelect } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
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"><div><label>{{ t('admin.shippingOrderProfiles.wizard.orderLineTable') }}<select class="select-field" :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 class="field-hint">{{ t('admin.shippingOrderProfiles.wizard.orderLineTableHint') }}</p></div><p v-if="!tables.length" class="warning">{{ t('admin.shippingOrderProfiles.wizard.noTable') }}</p><div v-else-if="modelValue" class="table-preview"><table><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></div></template>
|
||||
<style scoped>.wizard-step{display:grid;min-width:0;gap:1rem}.wizard-step label{display:grid;gap:.35rem;font-weight:600}.wizard-step .select-field{min-width:0}.field-hint{margin:.45rem 0 0;color:var(--text-muted);font-size:.875rem}.warning{color:var(--status-warning-fg)}.table-preview{max-width:100%;overflow-x:auto;border:1px solid var(--border-default);border-radius:.5rem}.table-preview table{width:max-content;min-width:100%;border-collapse:collapse}.table-preview td{max-width:16rem;padding:.55rem;border:1px solid var(--border-default);overflow-wrap:anywhere;vertical-align:top}</style>
|
||||
<template><div class="wizard-step"><div><label>{{ t('admin.shippingOrderProfiles.wizard.orderLineTable') }}<el-select :model-value="modelValue" @update:model-value="(value) => emit('update:modelValue', String(value))"><el-option value="" :label="t('admin.shippingOrderProfiles.selectTable')" /><el-option v-for="table in tables" :key="table.table_id" :value="table.table_id" :label="t('admin.shippingOrderProfiles.wizard.tableOption', { page: table.page_no, rows: table.row_count, columns: table.column_count })" /></el-select></label><p class="field-hint">{{ t('admin.shippingOrderProfiles.wizard.orderLineTableHint') }}</p></div><el-alert v-if="!tables.length" class="warning" :title="t('admin.shippingOrderProfiles.wizard.noTable')" type="warning" :closable="false" /><div v-else-if="modelValue" class="table-preview"><table><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></div></template>
|
||||
<style scoped>.wizard-step{display:grid;min-width:0;gap:1rem}.wizard-step label{display:grid;gap:.35rem;font-weight:600}.field-hint{margin:.45rem 0 0;color:var(--el-text-color-secondary);font-size:.875rem}.warning{max-width:100%}.table-preview{max-width:100%;overflow-x:auto;border:1px solid var(--el-border-color-lighter);border-radius:.5rem}.table-preview table{width:max-content;min-width:100%;border-collapse:collapse}.table-preview td{max-width:16rem;padding:.55rem;border:1px solid var(--el-border-color-lighter);overflow-wrap:anywhere;vertical-align:top}</style>
|
||||
+79
-97
@@ -1,13 +1,24 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileReadOnlyCanvas.vue
|
||||
用途:在版本详情页展示基于冻结样本绑定的只读画布。
|
||||
依赖:冻结样本预览 API、OrderProfileDocumentCanvas、冻结证据面板。
|
||||
依赖:element-plus(el-select / el-option / el-alert / el-skeleton / el-descriptions / el-tag,
|
||||
沿用管理端 element-trial 主题)、冻结样本预览 API、OrderProfileDocumentCanvas、
|
||||
冻结证据面板。
|
||||
逻辑:所有模板共用 annotation/training 冻结样本画布;XFA datasets 映射仅作为侧栏证据,
|
||||
blind_test 继续留在摘要层,不进入样本选择器。
|
||||
EP 迁移(定向,画布本体不动):样本选择下拉迁移为 el-select(selectedSampleId 数字契约经内联
|
||||
Number 适配保持);加载/错误态迁移为 el-skeleton / el-alert;冻结证据缺失提示迁移为
|
||||
el-alert(warning);区域摘要 dl 迁移为 el-descriptions,匹配结果以 el-tag(success/danger)
|
||||
呈现;颜色统一 --el-* token;OrderProfileDocumentCanvas 的 props/emits 与预览加载、
|
||||
区域诊断业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElAlert, ElDescriptions, ElDescriptionsItem, ElOption, ElSelect, ElSkeleton, ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import {
|
||||
authorizeOrderProfileFrozenSamplePreviewPages,
|
||||
@@ -141,29 +152,40 @@ watch([selectedSampleId, pageNo], () => {
|
||||
|
||||
<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>
|
||||
<el-alert
|
||||
v-if="!immutable"
|
||||
:title="t('admin.shippingOrderProfiles.versionCenter.draftCanvasHint')"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
<el-alert
|
||||
v-else-if="!readonlySamples.length"
|
||||
:title="t('admin.shippingOrderProfiles.versionCenter.noReadableSamples')"
|
||||
type="info"
|
||||
:closable="false"
|
||||
/>
|
||||
<template v-else>
|
||||
<div class="toolbar">
|
||||
<label class="field">
|
||||
<span>{{ t('admin.shippingOrderProfiles.versionCenter.readonlySample') }}</span>
|
||||
<select v-model.number="selectedSampleId" class="select-field">
|
||||
<option v-for="sample in readonlySamples" :key="sample.id" :value="sample.id">
|
||||
{{ sampleLabel(sample) }}
|
||||
</option>
|
||||
</select>
|
||||
<el-select
|
||||
:model-value="selectedSampleId ?? ''"
|
||||
@update:model-value="(value) => { selectedSampleId = Number(value); }"
|
||||
>
|
||||
<el-option v-for="sample in readonlySamples" :key="sample.id" :value="sample.id" :label="sampleLabel(sample)" />
|
||||
</el-select>
|
||||
</label>
|
||||
<p v-if="selectedSample && !selectedSample.frozen_evidence_ready" class="warning-text">
|
||||
{{ t('admin.shippingOrderProfiles.versionCenter.sampleFrozenEvidenceMissing') }}
|
||||
</p>
|
||||
<el-alert
|
||||
v-if="selectedSample && !selectedSample.frozen_evidence_ready"
|
||||
class="warning-text"
|
||||
:title="t('admin.shippingOrderProfiles.versionCenter.sampleFrozenEvidenceMissing')"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
/>
|
||||
</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>
|
||||
<el-alert v-if="errorMessage" :title="errorMessage" type="error" :closable="false" />
|
||||
<el-skeleton v-else-if="loading" :rows="6" animated />
|
||||
<div v-else-if="selectedSample && currentGrant" class="canvas-grid">
|
||||
<OrderProfileDocumentCanvas
|
||||
:profile-id="detail.id"
|
||||
@@ -184,40 +206,33 @@ watch([selectedSampleId, pageNo], () => {
|
||||
<h3>{{ t('admin.shippingOrderProfiles.versionCenter.regionSummaryTitle') }}</h3>
|
||||
<p v-if="diagnosticsLoading" class="diagnostic-state">{{ t('admin.shippingOrderProfiles.versionCenter.regionDiagnosticsLoading') }}</p>
|
||||
<p v-if="!selectedRegion" class="empty">{{ t('admin.shippingOrderProfiles.versionCenter.selectRegionHint') }}</p>
|
||||
<dl v-else class="grid">
|
||||
<div>
|
||||
<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>
|
||||
<div class="wide-row">
|
||||
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.recognizedValueTitle') }}</dt>
|
||||
<dd class="diagnostic-value">{{ selectedDiagnostic?.recognized_value || t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable') }}</dd>
|
||||
</div>
|
||||
<div v-if="selectedDiagnostic?.configured_value != null" class="wide-row">
|
||||
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.configuredValueTitle') }}</dt>
|
||||
<dd class="diagnostic-value">{{ selectedDiagnostic.configured_value }}</dd>
|
||||
</div>
|
||||
<div v-if="selectedDiagnostic?.matches_configured != null" class="wide-row">
|
||||
<dt>{{ t('admin.shippingOrderProfiles.versionCenter.matchResultTitle') }}</dt>
|
||||
<dd :class="selectedDiagnostic.matches_configured ? 'match-ok' : 'match-failed'">
|
||||
<el-descriptions v-else :column="2" size="small" class="grid">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.regionLabelTitle')">
|
||||
{{ selectedRegion.label }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.regionKindTitle')">
|
||||
{{ selectedRegion.kind }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.regionFieldCodeTitle')">
|
||||
{{ selectedRegion.fieldCode || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.regionPageTitle')">
|
||||
{{ selectedRegion.pageNo }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item class="wide-row" :label="t('admin.shippingOrderProfiles.versionCenter.recognizedValueTitle')">
|
||||
<span class="diagnostic-value">{{ selectedDiagnostic?.recognized_value || t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable') }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="selectedDiagnostic?.configured_value != null" class="wide-row" :label="t('admin.shippingOrderProfiles.versionCenter.configuredValueTitle')">
|
||||
<span class="diagnostic-value">{{ selectedDiagnostic.configured_value }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="selectedDiagnostic?.matches_configured != null" class="wide-row" :label="t('admin.shippingOrderProfiles.versionCenter.matchResultTitle')">
|
||||
<el-tag :type="selectedDiagnostic.matches_configured ? 'success' : 'danger'" size="small">
|
||||
{{ selectedDiagnostic.matches_configured
|
||||
? t('admin.shippingOrderProfiles.versionCenter.matchResultMatched')
|
||||
: t('admin.shippingOrderProfiles.versionCenter.matchResultMismatched') }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@@ -232,11 +247,10 @@ watch([selectedSampleId, pageNo], () => {
|
||||
}
|
||||
|
||||
.toolbar,
|
||||
.state-card,
|
||||
.panel {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 1rem;
|
||||
background: #fff;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
@@ -251,15 +265,10 @@ watch([selectedSampleId, pageNo], () => {
|
||||
}
|
||||
|
||||
.field span {
|
||||
color: #475569;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.field .select-field {
|
||||
min-height: 2.5rem;
|
||||
padding: 0 0.75rem;
|
||||
}
|
||||
|
||||
.canvas-grid {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
@@ -273,20 +282,16 @@ watch([selectedSampleId, pageNo], () => {
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
margin: 0.85rem 0 0;
|
||||
margin-top: 0.85rem;
|
||||
}
|
||||
|
||||
.grid dt {
|
||||
color: #64748b;
|
||||
font-size: 0.75rem;
|
||||
.grid :deep(.el-descriptions__label) {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.grid dd {
|
||||
margin: 0.25rem 0 0;
|
||||
color: #0f172a;
|
||||
.grid :deep(.el-descriptions__content) {
|
||||
color: var(--el-text-color-primary);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@@ -296,51 +301,28 @@ watch([selectedSampleId, pageNo], () => {
|
||||
|
||||
.diagnostic-state {
|
||||
margin: 0.75rem 0 0;
|
||||
color: #0369a1;
|
||||
color: var(--el-color-primary);
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.diagnostic-value {
|
||||
border-left: 3px solid #0ea5e9;
|
||||
background: #f0f9ff;
|
||||
display: block;
|
||||
border-left: 3px solid var(--el-color-primary);
|
||||
background: var(--el-color-primary-light-9);
|
||||
padding: 0.65rem 0.75rem;
|
||||
color: #0f172a;
|
||||
color: var(--el-text-color-primary);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
||||
line-height: 1.55;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.match-ok,
|
||||
.match-failed {
|
||||
display: inline-flex;
|
||||
width: fit-content;
|
||||
border-radius: 999px;
|
||||
padding: 0.3rem 0.65rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.match-ok {
|
||||
background: #dcfce7;
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
.match-failed {
|
||||
background: #fee2e2;
|
||||
color: #991b1b;
|
||||
}
|
||||
|
||||
.warning-text {
|
||||
margin: 0;
|
||||
color: #b45309;
|
||||
}
|
||||
|
||||
.error-card {
|
||||
color: #b91c1c;
|
||||
}
|
||||
|
||||
.empty {
|
||||
margin: 0.75rem 0 0;
|
||||
color: #64748b;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
@media (max-width: 1180px) {
|
||||
|
||||
+31
-4
@@ -1,13 +1,21 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileSampleStep.vue
|
||||
用途:上传新模板样本或复用已解析样本,并自动选择上传后解析完成的文档。
|
||||
依赖:模板样本 Intake 状态 API、文件资产上传 API、Vue I18n。
|
||||
依赖:element-plus(el-button / el-select / el-option,沿用管理端 element-trial 主题)、
|
||||
模板样本 Intake 状态 API、文件资产上传 API、Vue I18n。
|
||||
逻辑:上传后轮询同一 Intake;只有 ready 样本进入父级选择值,避免要求管理员重复选择刚上传的文件。
|
||||
EP 迁移:复用样本下拉迁移为 el-select(Number 契约经内联适配保持);「刷新样本」文字按钮迁移为
|
||||
el-button(link);文件上传保留原生 input[type=file](el-upload 涉及上传链路重构,不在本次
|
||||
定向范围);lucide 状态图标保留;颜色统一 --el-* token;轮询/上传业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { CheckCircle2, Clock3, UploadCloud } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElOption, ElSelect } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { uploadFileAsset } from '@/shared/api/file-assets.api';
|
||||
@@ -113,7 +121,7 @@ onBeforeUnmount(stopPolling);
|
||||
<strong>{{ pendingIntake.filename }}</strong>
|
||||
<p v-if="pendingIntake.state === 'failed'">{{ sampleFailureMessage(pendingIntake.errorCode) }}</p>
|
||||
<p v-else>{{ t(`admin.shippingOrderProfiles.wizard.sampleStatus.${pendingIntake.state}`) }}</p>
|
||||
<button v-if="pendingIntake.state !== 'uploading' && pendingIntake.state !== 'failed'" type="button" class="refresh-status" @click="emit('refresh')">{{ t('admin.shippingOrderProfiles.wizard.refreshSamples') }}</button>
|
||||
<el-button v-if="pendingIntake.state !== 'uploading' && pendingIntake.state !== 'failed'" link type="primary" size="small" class="refresh-status" @click="emit('refresh')">{{ t('admin.shippingOrderProfiles.wizard.refreshSamples') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -121,11 +129,30 @@ onBeforeUnmount(stopPolling);
|
||||
|
||||
<section class="reuse-panel">
|
||||
<div class="reuse-panel__heading"><h3>{{ t('admin.shippingOrderProfiles.wizard.reuseSample') }}</h3><p>{{ t('admin.shippingOrderProfiles.wizard.reuseSampleHint') }}</p></div>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.selectSample') }}</span><select class="select-field" :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>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.selectSample') }}</span><el-select :model-value="modelValue" @update:model-value="(value) => emit('update:modelValue', Number(value))"><el-option :value="0" :label="t('admin.shippingOrderProfiles.selectSample')" /><el-option v-for="sample in samples" :key="sample.document_id" :value="sample.document_id" :label="`${sample.filename || sample.intake_no} · ${sample.table_count} ${t('admin.shippingOrderProfiles.tablesUnit')}`" /></el-select></label>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--bg-surface-soft); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--status-info-fg); background: var(--status-info-bg); }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: var(--text-primary); font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .84rem; }.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: #0284c7; font-weight: 700; cursor: pointer; }.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--status-info-fg); background: var(--status-info-bg); }.parse-status strong,.selected-sample strong { display: block; color: var(--text-primary); }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--text-muted); font-size: .83rem; }.refresh-status { margin-top: 6px; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; text-decoration: underline; }.parse-status.failed { color: var(--status-error-fg); border-color: var(--status-error-border); background: var(--status-error-bg); }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--status-error-fg); font-weight: 800; }.selected-sample { color: var(--status-success-fg); border-color: var(--status-success-border); background: var(--status-success-bg); }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: var(--text-secondary); font-size: .88rem; font-weight: 700; }.field .select-field { min-height: 44px; font: inherit; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
|
||||
.sample-step { display: grid; gap: 18px; max-width: 640px; }
|
||||
.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--el-border-color-lighter); border-radius: 12px; background: var(--el-bg-color); }
|
||||
.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--el-fill-color-lighter); }
|
||||
.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--el-color-primary); background: var(--el-color-primary-light-9); }
|
||||
.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }
|
||||
.upload-panel h3,.reuse-panel h3 { color: var(--el-text-color-primary); font-size: 1rem; }
|
||||
.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--el-text-color-secondary); font-size: .84rem; }
|
||||
.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: var(--el-color-primary); font-weight: 700; cursor: pointer; }
|
||||
.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
|
||||
.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--el-color-primary); background: var(--el-color-primary-light-9); }
|
||||
.parse-status strong,.selected-sample strong { display: block; color: var(--el-text-color-primary); }
|
||||
.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--el-text-color-secondary); font-size: .83rem; }
|
||||
.refresh-status { margin-top: 6px; }
|
||||
.parse-status.failed { color: var(--el-color-danger); border-color: var(--el-color-danger-light-5); background: var(--el-color-danger-light-9); }
|
||||
.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--el-color-danger); font-weight: 800; }
|
||||
.selected-sample { color: var(--el-color-success); border-color: var(--el-color-success-light-5); background: var(--el-color-success-light-9); }
|
||||
.reuse-panel { padding: 18px; }
|
||||
.reuse-panel__heading { margin-bottom: 14px; }
|
||||
.field { display: grid; gap: 7px; color: var(--el-text-color-regular); font-size: .88rem; font-weight: 700; }
|
||||
@media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
|
||||
</style>
|
||||
+49
-51
@@ -1,13 +1,22 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileUsageTable.vue
|
||||
用途:展示订单模板版本的实际使用记录,并提供进入只读 Run 审计的入口。
|
||||
依赖:版本中心 usage API、Vue Router。
|
||||
逻辑:只读取每个 Unit 最新 RouteDecision 的安全投影;点击行跳转到管理员 Run 诊断页,不在当前页改动任何业务状态。
|
||||
依赖:element-plus(el-button / el-alert / el-empty / el-skeleton / el-tag,沿用管理端
|
||||
element-trial 主题)、版本中心 usage API、Vue Router。
|
||||
逻辑:只读取每个 Unit 最新 RouteDecision 的安全投影;点击行跳转到管理员 Run 诊断页,
|
||||
不在当前页改动任何业务状态。
|
||||
EP 迁移:刷新/翻页按钮迁移为 el-button(刷新带 :loading)、诊断入口迁移为 el-button(link);
|
||||
加载/错误/空态迁移为 el-skeleton / el-alert / el-empty;使用记录表保留原生 table 结构
|
||||
(列多需横向滚动,暂不迁移 el-table),颜色统一 --el-* token;业务脚本零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElAlert, ElButton, ElEmpty, ElSkeleton, ElTag } from "element-plus";
|
||||
import "element-plus/dist/index.css";
|
||||
import "element-plus/theme-chalk/dark/css-vars.css";
|
||||
import "@/features/admin/styles/element-trial.css";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { listOrderDocumentProfileUsages } from "@/features/admin/api/shipping-order-document-profile.api";
|
||||
import type {
|
||||
@@ -99,23 +108,24 @@ watch(
|
||||
<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">
|
||||
<el-button :disabled="loading" :loading="loading" @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.refresh") }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.loading") }}
|
||||
</div>
|
||||
<el-skeleton v-if="loading" class="state-card" :rows="5" animated />
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
<el-alert :title="errorMessage" type="error" :closable="false" />
|
||||
<el-button class="error-retry" size="small" @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="!page?.items.length" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.empty") }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-empty
|
||||
v-else-if="!page?.items.length"
|
||||
class="state-card"
|
||||
:description="t('admin.shippingOrderProfiles.versionCenter.usage.empty')"
|
||||
:image-size="60"
|
||||
/>
|
||||
<div v-else class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
@@ -141,8 +151,8 @@ watch(
|
||||
<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><el-tag size="small" effect="plain">{{ translateUsageValue("matchStatuses", item.match_status) }}</el-tag></td>
|
||||
<td><el-tag size="small" :type="item.execution_status === 'succeeded' ? 'success' : item.execution_status === 'failed' ? 'danger' : 'info'" effect="plain">{{ translateUsageValue("executionStatuses", item.execution_status) }}</el-tag></td>
|
||||
<td>{{ translateUsageValue("identityModes", item.identity_match_mode) }}</td>
|
||||
<td>
|
||||
{{
|
||||
@@ -159,9 +169,9 @@ watch(
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="link-button" @click="openDiagnostic(item)">
|
||||
<el-button link type="primary" @click="openDiagnostic(item)">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.openDiagnostic") }}
|
||||
</button>
|
||||
</el-button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -169,12 +179,12 @@ watch(
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
<button type="button" class="ghost-button" :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
<el-button :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.previous") }}
|
||||
</button>
|
||||
<button type="button" class="ghost-button" :disabled="loading || !hasNext" @click="loadNext">
|
||||
</el-button>
|
||||
<el-button :disabled="loading || !hasNext" @click="loadNext">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.next") }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -182,11 +192,10 @@ watch(
|
||||
<style scoped>
|
||||
.usage-panel,
|
||||
.toolbar,
|
||||
.table-wrapper,
|
||||
.state-card {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 1rem;
|
||||
background: #fff;
|
||||
.table-wrapper {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.usage-panel {
|
||||
@@ -210,26 +219,19 @@ watch(
|
||||
|
||||
.toolbar h3 {
|
||||
margin: 0;
|
||||
color: #0f172a;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.toolbar p {
|
||||
margin: 0.25rem 0 0;
|
||||
color: #64748b;
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.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;
|
||||
.error-card {
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.table-wrapper {
|
||||
@@ -240,19 +242,19 @@ table {
|
||||
width: 100%;
|
||||
min-width: 980px;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.84rem;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
thead {
|
||||
background: #f8fafc;
|
||||
color: #64748b;
|
||||
font-size: 0.75rem;
|
||||
background: var(--el-fill-color-lighter);
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
padding: 0.75rem;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
@@ -262,16 +264,12 @@ tbody tr:last-child td {
|
||||
}
|
||||
|
||||
.cell-title {
|
||||
color: #0f172a;
|
||||
color: var(--el-text-color-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
td small {
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.error-card {
|
||||
color: #b91c1c;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
|
||||
+99
-108
@@ -1,13 +1,23 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileVersionDiff.vue
|
||||
用途:展示订单模板版本中心的服务端语义 diff。
|
||||
依赖:版本中心 diff API、路由 query、版本摘要列表。
|
||||
依赖:element-plus(el-button / el-select / el-option / el-tag / el-alert / el-empty /
|
||||
el-skeleton / el-collapse,沿用管理端 element-trial 主题)、版本中心 diff API、
|
||||
路由 query、版本摘要列表。
|
||||
逻辑:始终由服务端计算差异;前端只负责选择对比版本、呈现 summary 和折叠原始 JSON 快照。
|
||||
EP 迁移:对比版本下拉迁移为 el-select(change 内联适配原有 Number 解析,保持路由 query 契约);
|
||||
重试迁移为 el-button;added/removed/modified/unchanged 摘要与变更类型迁移为 el-tag;
|
||||
加载/错误/空态迁移为 el-skeleton / el-alert / el-empty;原始 JSON 折叠迁移为 el-collapse;
|
||||
颜色统一 --el-* token;业务脚本(服务端 diff 加载/query 同步)零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ElAlert, ElButton, ElCollapse, ElCollapseItem, ElEmpty, ElOption, ElSelect, ElSkeleton, ElTag } from "element-plus";
|
||||
import "element-plus/dist/index.css";
|
||||
import "element-plus/theme-chalk/dark/css-vars.css";
|
||||
import "@/features/admin/styles/element-trial.css";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { getOrderDocumentProfileDiff } from "@/features/admin/api/shipping-order-document-profile.api";
|
||||
import type {
|
||||
@@ -134,44 +144,44 @@ watch(
|
||||
</div>
|
||||
<label class="compare-select">
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.diff.compareTarget") }}</span>
|
||||
<select
|
||||
class="select-field"
|
||||
:value="explicitAgainstProfileId || ''"
|
||||
@change="handleAgainstChange"
|
||||
<el-select
|
||||
:model-value="explicitAgainstProfileId || ''"
|
||||
class="compare-target"
|
||||
@change="(value) => handleAgainstChange({ target: { value: String(value) } } as unknown as Event)"
|
||||
>
|
||||
<option value="">{{ t("admin.shippingOrderProfiles.versionCenter.diff.defaultPrevious") }}</option>
|
||||
<option
|
||||
<el-option :label="t('admin.shippingOrderProfiles.versionCenter.diff.defaultPrevious')" value="" />
|
||||
<el-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="`v${item.version} · ${t(`admin.shippingOrderProfiles.versionCenter.status.${item.status === 'draft' ? 'currentDraft' : item.status === 'published' ? 'currentPublished' : 'retired'}`)}`"
|
||||
/>
|
||||
</el-select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.diff.loading") }}
|
||||
</div>
|
||||
<el-skeleton v-if="loading" class="state-card" :rows="5" animated />
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
<el-alert :title="errorMessage" type="error" :closable="false" />
|
||||
<el-button class="error-retry" size="small" @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</el-button>
|
||||
</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>
|
||||
<el-tag type="success" effect="light" round>{{ t("admin.shippingOrderProfiles.versionCenter.diff.summary.added", { count: diff.summary.added }) }}</el-tag>
|
||||
<el-tag type="danger" effect="light" round>{{ t("admin.shippingOrderProfiles.versionCenter.diff.summary.removed", { count: diff.summary.removed }) }}</el-tag>
|
||||
<el-tag type="primary" effect="light" round>{{ t("admin.shippingOrderProfiles.versionCenter.diff.summary.modified", { count: diff.summary.modified }) }}</el-tag>
|
||||
<el-tag type="info" effect="plain" round>{{ t("admin.shippingOrderProfiles.versionCenter.diff.summary.unchanged", { count: diff.summary.unchanged }) }}</el-tag>
|
||||
</div>
|
||||
|
||||
<div v-if="!changedItems.length" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.diff.noChanges") }}
|
||||
</div>
|
||||
<el-empty
|
||||
v-if="!changedItems.length"
|
||||
class="state-card"
|
||||
:description="t('admin.shippingOrderProfiles.versionCenter.diff.noChanges')"
|
||||
:image-size="60"
|
||||
/>
|
||||
|
||||
<article
|
||||
v-for="item in changedItems"
|
||||
@@ -184,7 +194,10 @@ watch(
|
||||
<p>{{ entityTypeLabel(item) }}</p>
|
||||
<h4>{{ item.label }}</h4>
|
||||
</div>
|
||||
<span class="change-type">{{ changeTypeLabel(item.change_type) }}</span>
|
||||
<el-tag
|
||||
size="small"
|
||||
:type="item.change_type === 'added' ? 'success' : item.change_type === 'removed' ? 'danger' : item.change_type === 'modified' ? 'primary' : 'info'"
|
||||
>{{ changeTypeLabel(item.change_type) }}</el-tag>
|
||||
</header>
|
||||
|
||||
<dl v-if="item.changes.length" class="change-list">
|
||||
@@ -207,19 +220,20 @@ watch(
|
||||
</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>
|
||||
<el-collapse class="raw-json">
|
||||
<el-collapse-item :title="t('admin.shippingOrderProfiles.versionCenter.diff.rawJson')" name="raw">
|
||||
<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>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</article>
|
||||
</template>
|
||||
</section>
|
||||
@@ -229,11 +243,10 @@ watch(
|
||||
.diff-panel,
|
||||
.toolbar,
|
||||
.summary-bar,
|
||||
.diff-item,
|
||||
.state-card {
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 1rem;
|
||||
background: #fff;
|
||||
.diff-item {
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 12px;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.diff-panel {
|
||||
@@ -256,30 +269,27 @@ watch(
|
||||
}
|
||||
|
||||
.toolbar h3,
|
||||
.diff-item h4,
|
||||
.raw-json h5 {
|
||||
.diff-item h4 {
|
||||
margin: 0;
|
||||
color: #0f172a;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.toolbar p,
|
||||
.diff-item header p {
|
||||
margin: 0 0 0.3rem;
|
||||
color: #64748b;
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.compare-select {
|
||||
display: grid;
|
||||
gap: 0.35rem;
|
||||
color: #475569;
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.compare-select .select-field {
|
||||
.compare-select .compare-target {
|
||||
min-width: 220px;
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.summary-bar {
|
||||
@@ -291,48 +301,17 @@ watch(
|
||||
|
||||
.summary-target {
|
||||
margin-right: 0.5rem;
|
||||
color: #334155;
|
||||
color: var(--el-text-color-regular);
|
||||
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.added { border-left-color: var(--el-color-success); }
|
||||
.diff-item.removed { border-left-color: var(--el-color-danger); }
|
||||
.diff-item.modified { border-left-color: var(--el-color-primary); }
|
||||
|
||||
.diff-item header {
|
||||
display: flex;
|
||||
@@ -354,16 +333,16 @@ watch(
|
||||
}
|
||||
|
||||
.change-list dt {
|
||||
color: #475569;
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.change-list dd {
|
||||
display: grid;
|
||||
gap: 0.3rem;
|
||||
margin: 0;
|
||||
color: #334155;
|
||||
font-size: 0.82rem;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
@@ -373,53 +352,65 @@ watch(
|
||||
}
|
||||
|
||||
del {
|
||||
color: #b91c1c;
|
||||
color: var(--el-color-danger);
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
ins {
|
||||
color: #15803d;
|
||||
color: var(--el-color-success);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.change-list small {
|
||||
color: #64748b;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.raw-json {
|
||||
margin-top: 0.9rem;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
padding-top: 0.9rem;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.raw-json summary {
|
||||
cursor: pointer;
|
||||
color: #334155;
|
||||
font-size: 0.8rem;
|
||||
.raw-json :deep(.el-collapse-item__header) {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
background: transparent;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.raw-json :deep(.el-collapse-item__wrap) {
|
||||
background: transparent;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.raw-json-grid {
|
||||
display: grid;
|
||||
gap: 0.85rem;
|
||||
margin-top: 0.75rem;
|
||||
margin-top: 0.35rem;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.raw-json h5 {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.raw-json pre {
|
||||
margin: 0.45rem 0 0;
|
||||
border-radius: 0.75rem;
|
||||
background: #0f172a;
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-dark);
|
||||
padding: 0.75rem;
|
||||
color: #e2e8f0;
|
||||
font-size: 0.72rem;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 11px;
|
||||
line-height: 1.45;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.error-card {
|
||||
color: #b91c1c;
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
@@ -435,7 +426,7 @@ ins {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.compare-select .select-field {
|
||||
.compare-select .compare-target {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
+137
-181
@@ -1,12 +1,20 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileVersionOverview.vue
|
||||
用途:展示模板版本详情的配置概览页签。
|
||||
依赖:订单模板详情 DTO、i18n。
|
||||
依赖:element-plus(el-tag / el-descriptions / el-collapse,沿用管理端 element-trial 主题)、
|
||||
订单模板详情 DTO、i18n。
|
||||
逻辑:仅渲染结构化摘要与冻结证据状态,不请求 PDF、Layout payload 或盲测真值。
|
||||
EP 迁移:概览徽标迁移为 el-tag(published=success / draft=warning / retired=danger,其余为
|
||||
info plain);五张摘要卡与源版本卡的 dl 键值对迁移为 el-descriptions;「技术细节」原生
|
||||
details 迁移为 el-collapse;颜色统一 --el-* token;业务逻辑零改动(statusClass 仅保留计算)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ElCollapse, ElCollapseItem, ElDescriptions, ElDescriptionsItem, ElTag } from "element-plus";
|
||||
import "element-plus/dist/index.css";
|
||||
import "element-plus/theme-chalk/dark/css-vars.css";
|
||||
import "@/features/admin/styles/element-trial.css";
|
||||
import type { ShippingOrderDocumentProfile } from "@/features/admin/types/shipping-order-document-profile.types";
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -55,14 +63,18 @@ const testStatusLabel = computed(() => {
|
||||
<p class="profile-identity">{{ detail.profile_code }}</p>
|
||||
</div>
|
||||
<div class="hero-meta">
|
||||
<span class="meta-chip meta-chip--status" :class="statusClass">{{ statusLabel }}</span>
|
||||
<span class="meta-chip">
|
||||
<el-tag
|
||||
class="meta-chip meta-chip--status"
|
||||
:class="statusClass"
|
||||
:type="detail.status === 'published' ? 'success' : detail.status === 'draft' ? 'warning' : 'danger'"
|
||||
>{{ statusLabel }}</el-tag>
|
||||
<el-tag class="meta-chip" type="info" effect="plain">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.schemaVersion") }}
|
||||
{{ detail.schema_summary?.version ?? "-" }}
|
||||
</span>
|
||||
<span class="meta-chip">
|
||||
</el-tag>
|
||||
<el-tag class="meta-chip" type="info" effect="plain">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.sampleCount", { count: detail.sample_summary?.sample_count || 0 }) }}
|
||||
</span>
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="detail.change_note" class="change-note">{{ detail.change_note }}</p>
|
||||
@@ -71,112 +83,92 @@ const testStatusLabel = computed(() => {
|
||||
<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>
|
||||
<el-descriptions :column="2" size="small" class="summary-list">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.tableRegions')">
|
||||
{{ detail.definition_stats?.table_region_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.headerLayouts')">
|
||||
{{ detail.definition_stats?.header_layout_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.lineLayouts')">
|
||||
{{ detail.definition_stats?.line_layout_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.orderFieldLayouts')">
|
||||
{{ detail.definition_stats?.order_field_layout_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</article>
|
||||
|
||||
<article v-if="valueSourceIdentity" class="summary-card">
|
||||
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.xfaStructureIdentity") }}</h3>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.xfaTemplateChecksum") }}</dt>
|
||||
<dd>{{ valueSourceIdentity.template_packet_checksum || "-" }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.xfaDatasetFingerprint") }}</dt>
|
||||
<dd>{{ valueSourceIdentity.dataset_structure_fingerprint || "-" }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.xfaAuthoritativeCollection") }}</dt>
|
||||
<dd>{{ valueSourceIdentity.has_authoritative_collection ? t("common.yes") : t("common.no") }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.mirrorCollections") }}</dt>
|
||||
<dd>{{ valueSourceIdentity.mirror_collection_count ?? 0 }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<el-descriptions :column="2" size="small" class="summary-list">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.xfaTemplateChecksum')">
|
||||
{{ valueSourceIdentity.template_packet_checksum || "-" }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.xfaDatasetFingerprint')">
|
||||
{{ valueSourceIdentity.dataset_structure_fingerprint || "-" }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.xfaAuthoritativeCollection')">
|
||||
{{ valueSourceIdentity.has_authoritative_collection ? t("common.yes") : t("common.no") }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.mirrorCollections')">
|
||||
{{ valueSourceIdentity.mirror_collection_count ?? 0 }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</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.blindTestSuiteSampleCount") }}</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>
|
||||
<el-descriptions :column="2" size="small" class="summary-list">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.statusLabel')">
|
||||
{{ frozenEvidenceLabel }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.blindTestSuiteSampleCount')">
|
||||
{{ detail.frozen_evidence?.sample_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.frozenSampleCount')">
|
||||
{{ detail.frozen_evidence?.frozen_sample_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.auditReady')">
|
||||
{{ detail.frozen_evidence?.audit_ready ? t("common.yes") : t("common.no") }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</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.boundBlindTestCount") }}</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>
|
||||
<el-descriptions :column="2" size="small" class="summary-list">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.annotationCount')">
|
||||
{{ detail.sample_summary?.annotation_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.trainingCount')">
|
||||
{{ detail.sample_summary?.training_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.boundBlindTestCount')">
|
||||
{{ detail.sample_summary?.blind_test_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.firstSample')">
|
||||
{{ detail.sample_summary?.samples?.[0]?.source_filename_snapshot || "-" }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</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>{{ formatDateTime(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>
|
||||
<el-descriptions :column="2" size="small" class="summary-list">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.statusLabel')">
|
||||
{{ testStatusLabel }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.sampleCountPlain')">
|
||||
{{ detail.test_summary?.sample_count || 0 }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.approvedAt')">
|
||||
{{ formatDateTime(detail.test_summary?.approved_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.latestRun')">
|
||||
{{ detail.test_summary?.latest_run?.status || "-" }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
@@ -189,27 +181,24 @@ const testStatusLabel = computed(() => {
|
||||
<p v-else>{{ t("admin.shippingOrderProfiles.versionCenter.noSourceVersion") }}</p>
|
||||
</article>
|
||||
|
||||
<details class="technical-details">
|
||||
<summary>{{ t("admin.shippingOrderProfiles.versionCenter.technicalDetails") }}</summary>
|
||||
<dl class="technical-grid">
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.publishedAt") }}</dt>
|
||||
<dd>{{ formatDateTime(detail.published_at) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.retiredAt") }}</dt>
|
||||
<dd>{{ formatDateTime(detail.retired_at) }}</dd>
|
||||
</div>
|
||||
<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>
|
||||
</dl>
|
||||
</details>
|
||||
<el-collapse class="technical-details">
|
||||
<el-collapse-item :title="t('admin.shippingOrderProfiles.versionCenter.technicalDetails')" name="technical">
|
||||
<el-descriptions :column="2" size="small" class="technical-grid">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.publishedAt')">
|
||||
{{ formatDateTime(detail.published_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.retiredAt')">
|
||||
{{ formatDateTime(detail.retired_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.checksum')">
|
||||
<code>{{ detail.checksum || "-" }}</code>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.versionCenter.schemaChecksum')">
|
||||
<code>{{ detail.schema_summary?.checksum || "-" }}</code>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -221,9 +210,9 @@ const testStatusLabel = computed(() => {
|
||||
|
||||
.hero-card,
|
||||
.summary-card {
|
||||
border: 1px solid var(--border-default);
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 0.9rem;
|
||||
background: var(--bg-surface);
|
||||
background: var(--el-bg-color);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
@@ -236,8 +225,8 @@ const testStatusLabel = computed(() => {
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 0.35rem;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
@@ -245,19 +234,19 @@ const testStatusLabel = computed(() => {
|
||||
.hero-card h2,
|
||||
.summary-card h3 {
|
||||
margin: 0;
|
||||
color: var(--text-primary);
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.profile-identity,
|
||||
.change-note {
|
||||
margin: 0.65rem 0 0;
|
||||
color: var(--text-secondary);
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.profile-identity { font-size: 0.875rem; }
|
||||
|
||||
.change-note {
|
||||
border-left: 3px solid var(--border-default);
|
||||
border-left: 3px solid var(--el-border-color);
|
||||
padding-left: 0.75rem;
|
||||
}
|
||||
|
||||
@@ -268,44 +257,19 @@ const testStatusLabel = computed(() => {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.meta-chip {
|
||||
border-radius: 999px;
|
||||
background: var(--bg-surface-soft);
|
||||
color: var(--text-secondary);
|
||||
padding: 0.35rem 0.65rem;
|
||||
font-size: 0.75rem;
|
||||
.summary-list {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.meta-chip--status {
|
||||
background: var(--status-success-bg);
|
||||
color: var(--status-success-fg);
|
||||
.summary-list :deep(.el-descriptions__label),
|
||||
.technical-grid :deep(.el-descriptions__label) {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.meta-chip--draft {
|
||||
background: var(--status-warning-bg);
|
||||
color: var(--status-warning-fg);
|
||||
}
|
||||
|
||||
.meta-chip--retired {
|
||||
background: var(--status-error-bg);
|
||||
color: var(--status-error-fg);
|
||||
}
|
||||
|
||||
.summary-card dl {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
margin: 1rem 0 0;
|
||||
}
|
||||
|
||||
.summary-card dt {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.summary-card dd {
|
||||
margin: 0.25rem 0 0;
|
||||
color: var(--text-primary);
|
||||
.summary-list :deep(.el-descriptions__content),
|
||||
.technical-grid :deep(.el-descriptions__content) {
|
||||
color: var(--el-text-color-primary);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@@ -317,40 +281,32 @@ const testStatusLabel = computed(() => {
|
||||
|
||||
.source-card p {
|
||||
margin: 0.75rem 0 0;
|
||||
color: var(--text-secondary);
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.technical-details {
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.technical-details summary {
|
||||
cursor: pointer;
|
||||
color: var(--text-secondary);
|
||||
.technical-details :deep(.el-collapse-item__header) {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
background: transparent;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.technical-details :deep(.el-collapse-item__wrap) {
|
||||
background: transparent;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.technical-grid {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
margin: 0.85rem 0 0;
|
||||
margin-top: 0.35rem;
|
||||
}
|
||||
|
||||
.technical-grid dt {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.technical-grid dd {
|
||||
margin: 0.25rem 0 0;
|
||||
color: var(--text-secondary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.technical-grid code {
|
||||
font-size: 0.75rem;
|
||||
.technical-grid :deep(code) {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
+56
-42
@@ -1,13 +1,22 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaCollectionSelector.vue
|
||||
用途:权威明细集合与镜像对账集合选择。
|
||||
依赖:vue-i18n、XfaCollectionCandidate。
|
||||
依赖:element-plus(el-checkbox / el-collapse / el-tag,沿用管理端 element-trial 主题)、
|
||||
vue-i18n、XfaCollectionCandidate。
|
||||
逻辑:以候选卡片直接展示完整路径、字段覆盖与样本证据;权威单选强制,镜像多选仅用于对账;
|
||||
selectable=false 的无效集合禁选;全部候选被排除时仍展示排除原因。
|
||||
EP 迁移:镜像多选原生 checkbox 迁移为 el-checkbox(toggleMirror 契约不变);推荐/已选角色徽标
|
||||
迁移为 el-tag(info);「排除集合」原生 details 迁移为 el-collapse(全排除时默认展开);
|
||||
权威单选保留原生 radio 卡片(整卡点击选择语义,不在本次控件替换范围);
|
||||
颜色统一 --el-* token;业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElCheckbox, ElCollapse, ElCollapseItem, ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { XfaCollectionCandidate } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import { listMirrorCollectionCandidates } from '../xfaProfileMapping.utils';
|
||||
|
||||
@@ -91,9 +100,9 @@ function reasonLabels(reasons?: string[]): string {
|
||||
<span class="candidate-body">
|
||||
<span class="candidate-title">
|
||||
<strong>{{ item.path_label || item.local_name }}</strong>
|
||||
<span v-if="item.recommended_role === 'authoritative'" class="role-badge">
|
||||
<el-tag v-if="item.recommended_role === 'authoritative'" size="small" type="info" effect="plain">
|
||||
{{ t('admin.shippingOrderProfiles.xfaWorkbench.recommendedAuthoritative') }}
|
||||
</span>
|
||||
</el-tag>
|
||||
<span>{{ t('admin.shippingOrderProfiles.xfaWorkbench.rowCount', { count: item.row_count }) }}</span>
|
||||
</span>
|
||||
<small>{{ t('admin.shippingOrderProfiles.xfaWorkbench.nonEmptyCoverage', {
|
||||
@@ -115,7 +124,7 @@ function reasonLabels(reasons?: string[]): string {
|
||||
<header>
|
||||
<div>
|
||||
<strong>{{ selectedAuthoritative.path_label || selectedAuthoritative.local_name }}</strong>
|
||||
<span class="role-badge">{{ t('admin.shippingOrderProfiles.xfaWorkbench.selectedAuthoritative') }}</span>
|
||||
<el-tag size="small" type="info">{{ t('admin.shippingOrderProfiles.xfaWorkbench.selectedAuthoritative') }}</el-tag>
|
||||
</div>
|
||||
<span>{{ t('admin.shippingOrderProfiles.xfaWorkbench.rowCount', { count: selectedAuthoritative.row_count }) }}</span>
|
||||
</header>
|
||||
@@ -134,12 +143,13 @@ function reasonLabels(reasons?: string[]): string {
|
||||
|
||||
<fieldset v-if="mirrors.length" class="mirror-fieldset">
|
||||
<legend>{{ t('admin.shippingOrderProfiles.xfaWorkbench.mirrorCollections') }}</legend>
|
||||
<label v-for="item in mirrors" :key="item.path_id" class="mirror">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="mirrorPathIds.includes(item.path_id)"
|
||||
@change="toggleMirror(item.path_id, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
<el-checkbox
|
||||
v-for="item in mirrors"
|
||||
:key="item.path_id"
|
||||
class="mirror"
|
||||
:model-value="mirrorPathIds.includes(item.path_id)"
|
||||
@change="(checked) => toggleMirror(item.path_id, Boolean(checked))"
|
||||
>
|
||||
<span class="mirror-copy">
|
||||
<strong>{{ item.path_label || item.local_name }}</strong>
|
||||
<small>{{ t('admin.shippingOrderProfiles.xfaWorkbench.nonEmptyCoverage', {
|
||||
@@ -149,50 +159,54 @@ function reasonLabels(reasons?: string[]): string {
|
||||
}) }}</small>
|
||||
<span>{{ (item.sample_fields || []).map((field) => `${field.field_name} ${field.display_value}`).join(' · ') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
</el-checkbox>
|
||||
</fieldset>
|
||||
|
||||
<details v-if="excludedCandidates?.length" class="excluded" :open="hasExcludedOnly">
|
||||
<summary>{{ t('admin.shippingOrderProfiles.xfaWorkbench.excludedCollections', { count: excludedCandidates.length }) }}</summary>
|
||||
<ul>
|
||||
<li v-for="item in excludedCandidates" :key="item.path_id">
|
||||
<span>{{ item.path_label || item.local_name }}</span>
|
||||
<small>{{ reasonLabels(item.exclusion_reasons || item.recommendation_reasons) || t('admin.shippingOrderProfiles.xfaWorkbench.emptyStructureReason') }}</small>
|
||||
</li>
|
||||
</ul>
|
||||
</details>
|
||||
<el-collapse
|
||||
v-if="excludedCandidates?.length"
|
||||
class="excluded"
|
||||
:model-value="hasExcludedOnly ? ['excluded'] : []"
|
||||
>
|
||||
<el-collapse-item :name="'excluded'" :title="t('admin.shippingOrderProfiles.xfaWorkbench.excludedCollections', { count: excludedCandidates.length })">
|
||||
<ul>
|
||||
<li v-for="item in excludedCandidates" :key="item.path_id">
|
||||
<span>{{ item.path_label || item.local_name }}</span>
|
||||
<small>{{ reasonLabels(item.exclusion_reasons || item.recommendation_reasons) || t('admin.shippingOrderProfiles.xfaWorkbench.emptyStructureReason') }}</small>
|
||||
</li>
|
||||
</ul>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.xfa-collections { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1fr); gap: 12px 16px; align-items: start; width: 100%; }
|
||||
.collection-heading { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 3px; color: var(--text-primary); }
|
||||
.collection-heading span { color: var(--text-muted); font-size: .82rem; }
|
||||
.empty-selectable { grid-column: 1 / -1; margin: 0; padding: 10px 12px; border: 1px solid var(--status-warning-border); border-radius: var(--radius-control); background: var(--status-warning-bg); color: var(--status-warning-fg); }
|
||||
.collection-heading { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 3px; color: var(--el-text-color-primary); }
|
||||
.collection-heading span { color: var(--el-text-color-secondary); font-size: .82rem; }
|
||||
.empty-selectable { grid-column: 1 / -1; margin: 0; padding: 10px 12px; border: 1px solid var(--el-color-warning-light-5); border-radius: var(--el-border-radius-base); background: var(--el-color-warning-light-9); color: var(--el-color-warning); }
|
||||
.auth-cards { grid-column: 1 / -1; display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
|
||||
.auth-cards[aria-invalid='true'] .candidate-card { border-color: var(--status-error-border); }
|
||||
.candidate-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border-default); border-radius: var(--radius-control); background: var(--bg-surface); cursor: pointer; }
|
||||
.candidate-card.selected, .candidate-card.recommended.selected { border-color: var(--status-info-border); background: var(--status-info-bg); }
|
||||
.candidate-body { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; color: var(--text-secondary); }
|
||||
.candidate-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--text-primary); }
|
||||
.role-badge { color: var(--status-info-fg); font-size: .75rem; }
|
||||
.fields, .samples { color: var(--text-muted); font-size: .78rem; }
|
||||
.auth-cards[aria-invalid='true'] .candidate-card { border-color: var(--el-color-danger); }
|
||||
.candidate-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--el-border-color-lighter); border-radius: var(--el-border-radius-base); background: var(--el-bg-color); cursor: pointer; }
|
||||
.candidate-card.selected, .candidate-card.recommended.selected { border-color: var(--el-color-primary-light-5); background: var(--el-color-primary-light-9); }
|
||||
.candidate-body { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; color: var(--el-text-color-regular); }
|
||||
.candidate-title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--el-text-color-primary); }
|
||||
.fields, .samples { color: var(--el-text-color-secondary); font-size: .78rem; }
|
||||
.samples { display: flex; flex-wrap: wrap; gap: 6px 12px; }
|
||||
.samples b { color: var(--text-primary); }
|
||||
.collection-card, .mirror-fieldset, .excluded { border: 1px solid var(--border-default); border-radius: var(--radius-control); padding: 12px; background: var(--bg-surface); }
|
||||
.collection-card.authoritative { border-color: var(--status-info-border); background: var(--status-info-bg); }
|
||||
.collection-card header { display: flex; justify-content: space-between; gap: 12px; color: var(--text-primary); }
|
||||
.samples b { color: var(--el-text-color-primary); }
|
||||
.collection-card, .mirror-fieldset, .excluded { border: 1px solid var(--el-border-color-lighter); border-radius: var(--el-border-radius-base); padding: 12px; background: var(--el-bg-color); }
|
||||
.collection-card.authoritative { border-color: var(--el-color-primary-light-5); background: var(--el-color-primary-light-9); }
|
||||
.collection-card header { display: flex; justify-content: space-between; gap: 12px; color: var(--el-text-color-primary); }
|
||||
.collection-card header div { display: flex; align-items: center; gap: 8px; }
|
||||
.collection-card p, .collection-card small { color: var(--text-muted); }
|
||||
.sample-grid { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 8px 0; color: var(--text-secondary); font-size: .82rem; }
|
||||
.sample-grid b { color: var(--text-primary); }
|
||||
.collection-card p, .collection-card small { color: var(--el-text-color-secondary); }
|
||||
.sample-grid { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 8px 0; color: var(--el-text-color-regular); font-size: .82rem; }
|
||||
.sample-grid b { color: var(--el-text-color-primary); }
|
||||
.mirror-fieldset { grid-column: 1 / -1; }
|
||||
.mirror { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
|
||||
.mirror-copy { display: flex; flex-direction: column; gap: 2px; color: var(--text-secondary); }
|
||||
.mirror-copy small, .mirror-copy span { color: var(--text-muted); font-size: .78rem; }
|
||||
.excluded { grid-column: 1 / -1; color: var(--text-secondary); }
|
||||
.mirror { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; width: 100%; }
|
||||
.mirror-copy { display: flex; flex-direction: column; gap: 2px; color: var(--el-text-color-regular); }
|
||||
.mirror-copy small, .mirror-copy span { color: var(--el-text-color-secondary); font-size: .78rem; }
|
||||
.excluded { grid-column: 1 / -1; color: var(--el-text-color-regular); }
|
||||
.excluded ul { margin: 8px 0 0; padding-left: 18px; }
|
||||
.excluded li { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.excluded small { color: var(--status-warning-fg); }
|
||||
.excluded small { color: var(--el-color-warning); }
|
||||
@media (max-width: 900px) { .xfa-collections { grid-template-columns: 1fr; } }
|
||||
</style>
|
||||
+39
-32
@@ -1,14 +1,23 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaDatasetTree.vue
|
||||
用途:XFA 受控数据树;主工作台用于绑定导航,高级诊断抽屉内只读展示。
|
||||
依赖:vue-i18n、xfaProfileMapping.utils。
|
||||
依赖:element-plus(el-input / el-empty,@element-plus/icons-vue Plus/Close,沿用管理端
|
||||
element-trial 主题)、vue-i18n、xfaProfileMapping.utils。
|
||||
逻辑:支持展开折叠、方向键导航与完整样本值展示;readonly 时隐藏增删改规则动作;
|
||||
expandSamples 用于弹窗选型场景,放宽样本列宽度并允许换行。
|
||||
EP 迁移:路径搜索迁移为 el-input(clearable);「+」新增规则与「×」删除规则的文字符号迁移为
|
||||
@element-plus/icons-vue 的 Plus / Close(el-icon 包裹,保留原 hover 显示与 24px 热区);
|
||||
树空态迁移为 el-empty;树展开折叠/编辑图标(lucide)与 WAI-ARIA 树键盘导航逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
import { ChevronDown, ChevronRight, Pencil } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElEmpty, ElIcon, ElInput } from 'element-plus';
|
||||
import { Close, Plus } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { XfaFieldTreeNode } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import type { XfaSplitRuleSet } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import {
|
||||
@@ -164,7 +173,7 @@ async function onKeydown(event: KeyboardEvent, pathId: string): Promise<void> {
|
||||
>
|
||||
<label class="xfa-tree__search">
|
||||
<span class="sr-only">{{ t('admin.shippingOrderProfiles.xfaWorkbench.searchPaths') }}</span>
|
||||
<input v-model="query" type="search" :placeholder="t('admin.shippingOrderProfiles.xfaWorkbench.searchPaths')" />
|
||||
<el-input v-model="query" :placeholder="t('admin.shippingOrderProfiles.xfaWorkbench.searchPaths')" clearable />
|
||||
</label>
|
||||
<ul class="xfa-tree__list" role="tree">
|
||||
<li v-for="(node, index) in visible" :key="node.pathId" role="none">
|
||||
@@ -199,15 +208,15 @@ async function onKeydown(event: KeyboardEvent, pathId: string): Promise<void> {
|
||||
<span v-if="node.isLeaf && parentPathHint(node)" class="path-hint">{{ parentPathHint(node) }}</span>
|
||||
</span>
|
||||
<span v-if="node.isCollectionCandidate" class="badge">{{ t('admin.shippingOrderProfiles.xfaWorkbench.collectionBadge') }}</span>
|
||||
<button
|
||||
<el-button
|
||||
v-if="node.isLeaf && !isReadonly"
|
||||
type="button"
|
||||
text
|
||||
class="add-rule"
|
||||
:class="{ 'add-rule--active': selectedPathId === node.pathId }"
|
||||
:title="t('admin.shippingOrderProfiles.xfaSplit.addRule')"
|
||||
:aria-label="t('admin.shippingOrderProfiles.xfaSplit.addRule')"
|
||||
@click.stop="emit('add-rule', node.pathId)"
|
||||
>+</button>
|
||||
><el-icon><Plus /></el-icon></el-button>
|
||||
<span v-if="node.sampleValueDisplay" class="sample" :title="node.sampleValueDisplay">
|
||||
{{ node.sampleValueDisplay }}
|
||||
</span>
|
||||
@@ -224,42 +233,41 @@ async function onKeydown(event: KeyboardEvent, pathId: string): Promise<void> {
|
||||
class="xfa-tree__rule"
|
||||
:class="{ selected: selectedRuleId === rule.rule_id }"
|
||||
>
|
||||
<button type="button" class="xfa-tree__rule-main" @click="emit('select-rule', node.pathId, rule.rule_id)">
|
||||
<el-button text class="xfa-tree__rule-main" @click="emit('select-rule', node.pathId, rule.rule_id)">
|
||||
<span class="rule-glyph">↳</span>
|
||||
<span class="rule-label">{{ t('admin.shippingOrderProfiles.xfaSplit.ruleLabel', { index: ruleIndex + 1 }) }} · {{ rule.segment.display_name || rule.segment.segment_code || t('admin.shippingOrderProfiles.xfaSplit.unnamedRule') }}</span>
|
||||
</button>
|
||||
<button
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!isReadonly"
|
||||
type="button"
|
||||
text
|
||||
class="rule-edit"
|
||||
:title="t('common.edit')"
|
||||
:aria-label="t('common.edit')"
|
||||
@click.stop="emit('edit-rule', node.pathId, rule.rule_id)"
|
||||
><Pencil :size="12" aria-hidden="true" /></button>
|
||||
<button v-if="!isReadonly" type="button" class="rule-delete" :title="t('admin.shippingOrderProfiles.xfaSplit.deleteRule')" @click.stop="emit('delete-rule', node.pathId, rule.rule_id)">×</button>
|
||||
><Pencil :size="12" aria-hidden="true" /></el-button>
|
||||
<el-button v-if="!isReadonly" text class="rule-delete" :title="t('admin.shippingOrderProfiles.xfaSplit.deleteRule')" :aria-label="t('admin.shippingOrderProfiles.xfaSplit.deleteRule')" @click.stop="emit('delete-rule', node.pathId, rule.rule_id)"><el-icon><Close /></el-icon></el-button>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<p v-if="!visible.length" class="xfa-tree__empty">{{ t('admin.shippingOrderProfiles.xfaWorkbench.treeEmpty') }}</p>
|
||||
<el-empty v-if="!visible.length" :description="t('admin.shippingOrderProfiles.xfaWorkbench.treeEmpty')" :image-size="48" />
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.xfa-tree { display: flex; flex-direction: column; min-height: 0; height: 100%; }
|
||||
.xfa-tree__search input { width: 100%; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-control); background: var(--bg-surface); color: var(--text-primary); }
|
||||
.xfa-tree__list { margin: 8px -6px 0 0; padding: 0 6px 0 0; list-style: none; overflow: auto; flex: 1; scrollbar-gutter: stable; }
|
||||
.xfa-tree__node { position: relative; display: flex; width: 100%; min-width: 0; gap: 5px; align-items: center; min-height: 34px; padding-block: 4px; padding-right: 6px; border: 0; border-radius: var(--radius-control); background: transparent; color: var(--text-secondary); text-align: left; cursor: pointer; }
|
||||
.xfa-tree__node::before { content: ''; position: absolute; top: 0; bottom: 0; left: max(13px, calc(var(--tree-guide-offset, 0px))); width: 1px; background: var(--border-default); opacity: .65; pointer-events: none; }
|
||||
.xfa-tree__node { position: relative; display: flex; width: 100%; min-width: 0; gap: 5px; align-items: center; min-height: 34px; padding-block: 4px; padding-right: 6px; border: 0; border-radius: var(--el-border-radius-base); background: transparent; color: var(--el-text-color-regular); text-align: left; cursor: pointer; }
|
||||
.xfa-tree__node::before { content: ''; position: absolute; top: 0; bottom: 0; left: max(13px, calc(var(--tree-guide-offset, 0px))); width: 1px; background: var(--el-border-color-lighter); opacity: .65; pointer-events: none; }
|
||||
.xfa-tree__node[aria-level='1']::before { display: none; }
|
||||
.xfa-tree__node:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
|
||||
.xfa-tree__node.selected { background: var(--status-info-bg); color: var(--status-info-fg); }
|
||||
.xfa-tree__node.mapped .name::after { content: ' ✓'; color: var(--status-success-fg); }
|
||||
.xfa-tree__node:focus-visible { outline: 2px solid var(--el-color-primary); outline-offset: 1px; }
|
||||
.xfa-tree__node.selected { background: var(--el-color-primary-light-9); color: var(--el-color-primary); }
|
||||
.xfa-tree__node.mapped .name::after { content: ' ✓'; color: var(--el-color-success); }
|
||||
.name-block { display: grid; min-width: 0; flex: 1; gap: 0; }
|
||||
.xfa-tree__node:not(.leaf) .name { font-weight: 650; }
|
||||
.xfa-tree__node .name { min-width: 0; overflow: hidden; font-size: .82rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.xfa-tree__node .path-hint { min-width: 0; overflow: hidden; color: var(--text-muted); font-size: .64rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.xfa-tree__node .sample { min-width: 3.2rem; margin-left: auto; max-width: 30%; overflow: hidden; color: var(--text-muted); font-size: .68rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.xfa-tree__node .path-hint { min-width: 0; overflow: hidden; color: var(--el-text-color-secondary); font-size: .64rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.xfa-tree__node .sample { min-width: 3.2rem; margin-left: auto; max-width: 30%; overflow: hidden; color: var(--el-text-color-secondary); font-size: .68rem; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.xfa-tree--expand-samples .xfa-tree__node { align-items: flex-start; }
|
||||
.xfa-tree--expand-samples .xfa-tree__node .sample {
|
||||
max-width: 48%;
|
||||
@@ -269,22 +277,21 @@ async function onKeydown(event: KeyboardEvent, pathId: string): Promise<void> {
|
||||
line-height: 1.25;
|
||||
text-align: left;
|
||||
}
|
||||
.xfa-tree__node .badge { color: var(--status-warning-fg); font-size: .72rem; font-weight: 700; }
|
||||
.xfa-tree__node .badge { color: var(--el-color-warning); font-size: .72rem; font-weight: 700; }
|
||||
.toggle, .toggle-spacer { display: inline-flex; width: 16px; flex: 0 0 16px; }
|
||||
.add-rule { display: none; position: relative; z-index: 1; min-width: 24px; min-height: 24px; align-items: center; justify-content: center; margin-left: 2px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--status-info-fg); font-size: 1rem; line-height: 1; cursor: pointer; }
|
||||
.add-rule--active { display: inline-flex; border-color: var(--status-info-border); background: var(--status-info-bg); }
|
||||
.add-rule { display: none; position: relative; z-index: 1; min-width: 24px; min-height: 24px; margin-left: 2px; }
|
||||
.add-rule--active { display: inline-flex; }
|
||||
.xfa-tree__node:hover .add-rule, .xfa-tree__node:focus-within .add-rule { display: inline-flex; }
|
||||
.xfa-tree__rules { position: relative; margin: 0; padding: 1px 0 5px var(--rule-indent); list-style: none; }
|
||||
.xfa-tree__rules::before { content: ''; position: absolute; top: 0; bottom: 8px; left: var(--rule-guide-offset); width: 1px; background: var(--border-default); }
|
||||
.xfa-tree__rules::before { content: ''; position: absolute; top: 0; bottom: 8px; left: var(--rule-guide-offset); width: 1px; background: var(--el-border-color-lighter); }
|
||||
.xfa-tree__rule { display: flex; min-width: 0; align-items: center; gap: 3px; border-radius: 4px; }
|
||||
.xfa-tree__rule.selected { background: var(--status-info-bg); }
|
||||
.xfa-tree__rule-main { display: flex; min-width: 0; flex: 1; gap: 4px; padding: 3px 2px; border: 0; background: transparent; color: var(--text-muted); text-align: left; font-size: .68rem; cursor: pointer; }
|
||||
.xfa-tree__rule.selected { background: var(--el-color-primary-light-9); }
|
||||
.xfa-tree__rule-main { display: flex; min-width: 0; flex: 1; gap: 4px; text-align: left; }
|
||||
.xfa-tree__rule-main > span { padding: 0; }
|
||||
.rule-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.rule-glyph { color: var(--status-info-fg); }
|
||||
.rule-edit, .rule-delete { display: inline-flex; width: 20px; height: 20px; flex: 0 0 20px; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 4px; background: transparent; cursor: pointer; }
|
||||
.rule-edit { color: var(--status-info-fg); }
|
||||
.rule-delete { color: var(--status-error-fg); font-size: .9rem; }
|
||||
.rule-edit:hover, .rule-delete:hover { background: var(--bg-page); }
|
||||
.xfa-tree__empty { color: var(--text-muted); font-size: .85rem; }
|
||||
.rule-glyph { color: var(--el-color-primary); }
|
||||
.rule-edit, .rule-delete { flex: 0 0 20px; width: 20px; height: 20px; padding: 0; }
|
||||
.rule-delete { color: var(--el-color-danger); }
|
||||
.xfa-tree__empty { color: var(--el-text-color-secondary); font-size: .85rem; }
|
||||
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
|
||||
</style>
|
||||
+46
-33
@@ -1,13 +1,20 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaReadOnlyMapping.vue
|
||||
用途:版本详情页统一值源 adapter 的只读证据面板。
|
||||
依赖:vue-i18n、Profile readonly mapping DTO。
|
||||
依赖:element-plus(el-alert / el-descriptions,沿用管理端 element-trial 主题)、vue-i18n、
|
||||
Profile readonly mapping DTO。
|
||||
逻辑:所有模板均挂载该面板;coordinate 没有额外值源证据时展示空态,
|
||||
XFA 才显示 datasets 结构身份、Header/Line 路径映射与集合策略;不请求 PDF 预览页。
|
||||
EP 迁移:结构身份 dl 迁移为 el-descriptions;无 PDF 提示迁移为 el-alert(info)、值源证据缺失
|
||||
迁移为 el-alert(warning);颜色统一 --el-* token;业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElAlert, ElDescriptions, ElDescriptionsItem } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { ShippingOrderDocumentProfile } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -35,33 +42,40 @@ const lineMaps = computed(() => mapping.value?.line_mappings || []);
|
||||
|
||||
<template>
|
||||
<section class="xfa-readonly" :aria-label="t('admin.shippingOrderProfiles.xfaReadonly.title')">
|
||||
<p v-if="hasValueSourceEvidence" class="hint">{{ t('admin.shippingOrderProfiles.xfaReadonly.noPdfHint') }}</p>
|
||||
<div v-if="!mapping" class="empty">{{ t('admin.shippingOrderProfiles.xfaReadonly.missing') }}</div>
|
||||
<el-alert
|
||||
v-if="hasValueSourceEvidence"
|
||||
:title="t('admin.shippingOrderProfiles.xfaReadonly.noPdfHint')"
|
||||
type="info"
|
||||
:closable="false"
|
||||
class="hint"
|
||||
/>
|
||||
<el-alert
|
||||
v-if="!mapping"
|
||||
:title="t('admin.shippingOrderProfiles.xfaReadonly.missing')"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
class="hint"
|
||||
/>
|
||||
<template v-else>
|
||||
<div class="identity">
|
||||
<h3>{{ t('admin.shippingOrderProfiles.xfaReadonly.identityTitle') }}</h3>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingOrderProfiles.xfaReadonly.templateChecksum') }}</dt>
|
||||
<dd>{{ source.template_packet_checksum || '-' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingOrderProfiles.xfaReadonly.structureFingerprint') }}</dt>
|
||||
<dd>{{ source.dataset_structure_fingerprint || '-' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingOrderProfiles.xfaReadonly.authoritativeCollection') }}</dt>
|
||||
<dd>{{ source.authoritative_line_collection_path || '-' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingOrderProfiles.xfaReadonly.mirrorCollections') }}</dt>
|
||||
<dd>{{ (source.mirror_collection_paths as string[] | undefined)?.join(', ') || '-' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingOrderProfiles.xfaReadonly.signatureChecksum') }}</dt>
|
||||
<dd>{{ mapping.matching_signature_checksum || '-' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<el-descriptions :column="1" size="small" class="identity-grid">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.xfaReadonly.templateChecksum')">
|
||||
{{ source.template_packet_checksum || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.xfaReadonly.structureFingerprint')">
|
||||
{{ source.dataset_structure_fingerprint || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.xfaReadonly.authoritativeCollection')">
|
||||
{{ source.authoritative_line_collection_path || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.xfaReadonly.mirrorCollections')">
|
||||
{{ (source.mirror_collection_paths as string[] | undefined)?.join(', ') || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderProfiles.xfaReadonly.signatureChecksum')">
|
||||
{{ mapping.matching_signature_checksum || '-' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<div class="maps">
|
||||
<div>
|
||||
@@ -86,14 +100,13 @@ const lineMaps = computed(() => mapping.value?.line_mappings || []);
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.xfa-readonly { border: 1px solid #dfe7ef; border-radius: 10px; background: #fff; padding: 16px; }
|
||||
.hint { margin: 0 0 12px; color: #64748b; font-size: 13px; }
|
||||
.identity dl { display: grid; gap: 8px; margin: 8px 0 0; }
|
||||
.identity dt { color: #64748b; font-size: 12px; }
|
||||
.identity dd { margin: 2px 0 0; overflow-wrap: anywhere; font-size: 13px; }
|
||||
.xfa-readonly { border: 1px solid var(--el-border-color-lighter); border-radius: 10px; background: var(--el-bg-color); padding: 16px; }
|
||||
.hint { margin: 0 0 12px; }
|
||||
.identity-grid { margin-top: 8px; }
|
||||
.identity-grid :deep(.el-descriptions__label) { color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.identity-grid :deep(.el-descriptions__content) { overflow-wrap: anywhere; font-size: 13px; }
|
||||
.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
|
||||
.maps h3, .identity h3 { margin: 0; font-size: 14px; color: #1e293b; }
|
||||
.maps ul { margin: 8px 0 0; padding-left: 18px; color: #334155; font-size: 13px; }
|
||||
.empty { color: #b45309; }
|
||||
.maps h3, .identity h3 { margin: 0; font-size: 14px; color: var(--el-text-color-primary); }
|
||||
.maps ul { margin: 8px 0 0; padding-left: 18px; color: var(--el-text-color-regular); font-size: 13px; }
|
||||
@media (max-width: 767px) { .maps { grid-template-columns: 1fr; } }
|
||||
</style>
|
||||
+223
-205
@@ -1,16 +1,28 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaSplitRulePanel.vue
|
||||
用途:XFA 字段拆分规则编辑——matcher 优先(prefix/regex/position),兼容历史 stages[] 投影。
|
||||
依赖:shipping-order-document-profile API、vue-i18n、Schema 字段列表。
|
||||
依赖:element-plus(el-button / el-input / el-select / el-option / el-checkbox / el-alert /
|
||||
el-empty / ElMessageBox,沿用管理端 element-trial 主题)、shipping-order-document-profile
|
||||
API、vue-i18n、Schema 字段列表。
|
||||
逻辑:编辑 definition.split_rules;新增/改提取方式同步写入 matcher;stages 仅保留编辑态;
|
||||
预览和确认统一投影为正式 matcher DTO,确认前须校验同一正式 DTO 哈希;
|
||||
连续多行提取投影为 position.line_end + join_with,引擎合并多行文本;
|
||||
预览优先 reveal 完整分段值(与映射台侧栏/数据源弹窗一致),权限不足再回退脱敏;
|
||||
确认门禁仅阻断真正影响取值可信度的诊断(与后端 informational 白名单对齐)。
|
||||
EP 迁移(定向):确认弹窗 window.confirm 迁移为 ElMessageBox.confirm(confirmRules 因等待用户
|
||||
确认改为 async,取消即 reject 返回;确认后逻辑语句顺序不变);规则工具栏/阶段工具栏按钮
|
||||
迁移为 el-button(删除=danger,高级折叠=link);segment/提取/阶段输入迁移为 el-input 与
|
||||
el-select/el-checkbox(事件经内联适配保持原 handler 契约,data-testid 保留);
|
||||
未保存确认横幅迁移为 el-alert(warning)、未选叶子空态迁移为 el-empty;
|
||||
其余规则计算/预览/确认门禁业务逻辑零改动。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElAlert, ElButton, ElCheckbox, ElEmpty, ElInput, ElMessageBox, ElOption, ElSelect } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -382,8 +394,9 @@ async function runPreview(): Promise<void> {
|
||||
* 管理员确认规则:须已预览当前 rule_set;阻断性诊断或 needs_review 时阻断。
|
||||
* 核心逻辑:确认事件携带完整规则数组与 preview_token,由父页面保存时交服务端校验;
|
||||
* line_match_candidates 与未匹配行(evidence_only)不视为阻断。
|
||||
* EP 迁移:window.confirm 换为 ElMessageBox.confirm,取消即返回;其余语句顺序不变。
|
||||
*/
|
||||
function confirmRules(): void {
|
||||
async function confirmRules(): Promise<void> {
|
||||
if (!activeRuleSet.value || isReadonly.value) return;
|
||||
if (activeRuleSet.value.rules.some((rule) => (
|
||||
rule.segment.handling === 'mapped'
|
||||
@@ -409,7 +422,19 @@ function confirmRules(): void {
|
||||
segments: segmentCount,
|
||||
diagnostics: diagCount,
|
||||
});
|
||||
if (!window.confirm(summary)) return;
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
summary,
|
||||
t('admin.shippingOrderProfiles.xfaSplit.confirm'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const confirmedRuleSet = {
|
||||
...(toFormalRuleSet(activeRuleSet.value) || {}),
|
||||
source: 'user',
|
||||
@@ -887,13 +912,20 @@ watch(activeRuleSet, (current, previous) => {
|
||||
class="xfa-split"
|
||||
:aria-label="t('admin.shippingOrderProfiles.xfaSplit.title')"
|
||||
>
|
||||
<div v-if="showUnsavedConfirmBanner" class="xfa-split__banner" role="status">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.unsavedAfterConfirm') }}
|
||||
</div>
|
||||
<el-alert
|
||||
v-if="showUnsavedConfirmBanner"
|
||||
class="xfa-split__banner"
|
||||
:title="t('admin.shippingOrderProfiles.xfaSplit.unsavedAfterConfirm')"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
role="status"
|
||||
/>
|
||||
|
||||
<div v-if="!selectedPathId" class="xfa-split__empty">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.selectLeafHint') }}
|
||||
</div>
|
||||
<el-empty
|
||||
v-if="!selectedPathId"
|
||||
:description="t('admin.shippingOrderProfiles.xfaSplit.selectLeafHint')"
|
||||
:image-size="60"
|
||||
/>
|
||||
<div v-else class="xfa-split__body">
|
||||
<p v-if="!activeRuleSet" class="hint">{{ t('admin.shippingOrderProfiles.xfaSplit.noRules') }}</p>
|
||||
|
||||
@@ -902,43 +934,39 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<legend>{{ t('admin.shippingOrderProfiles.xfaSplit.ruleSetSettings') }}</legend>
|
||||
<label class="xfa-split__policy">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.unmatchedPolicy') }}
|
||||
<select
|
||||
<el-select
|
||||
:disabled="isReadonly"
|
||||
:value="activeRuleSet.unmatched_line_policy || 'evidence_only'"
|
||||
@change="updateUnmatchedPolicy(($event.target as HTMLSelectElement).value as 'evidence_only' | 'needs_review')"
|
||||
:model-value="activeRuleSet.unmatched_line_policy || 'evidence_only'"
|
||||
@update:model-value="(value) => updateUnmatchedPolicy(value as 'evidence_only' | 'needs_review')"
|
||||
>
|
||||
<option value="evidence_only">{{ t('admin.shippingOrderProfiles.xfaSplit.evidenceOnly') }}</option>
|
||||
<option value="needs_review">{{ t('admin.shippingOrderProfiles.xfaSplit.needsReview') }}</option>
|
||||
</select>
|
||||
<el-option value="evidence_only" :label="t('admin.shippingOrderProfiles.xfaSplit.evidenceOnly')" />
|
||||
<el-option value="needs_review" :label="t('admin.shippingOrderProfiles.xfaSplit.needsReview')" />
|
||||
</el-select>
|
||||
</label>
|
||||
|
||||
<div class="xfa-split__normalization">
|
||||
<span>{{ t('admin.shippingOrderProfiles.xfaSplit.normalization') }}</span>
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
:disabled="isReadonly"
|
||||
:checked="activeRuleSet.normalization?.trim ?? true"
|
||||
@change="updateNormalization({ trim: ($event.target as HTMLInputElement).checked })"
|
||||
/>
|
||||
<el-checkbox
|
||||
:disabled="isReadonly"
|
||||
:model-value="activeRuleSet.normalization?.trim ?? true"
|
||||
@change="(checked) => updateNormalization({ trim: Boolean(checked) })"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageTrim') }}
|
||||
</label>
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
:disabled="isReadonly"
|
||||
:checked="activeRuleSet.normalization?.remove_empty_lines ?? true"
|
||||
@change="updateNormalization({ remove_empty_lines: ($event.target as HTMLInputElement).checked })"
|
||||
/>
|
||||
</el-checkbox>
|
||||
<el-checkbox
|
||||
:disabled="isReadonly"
|
||||
:model-value="activeRuleSet.normalization?.remove_empty_lines ?? true"
|
||||
@change="(checked) => updateNormalization({ remove_empty_lines: Boolean(checked) })"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageRemoveEmptyLines') }}
|
||||
</label>
|
||||
</el-checkbox>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.lineBreaks') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="lineBreaksToDisplay(activeRuleSet.normalization?.line_breaks)"
|
||||
:model-value="lineBreaksToDisplay(activeRuleSet.normalization?.line_breaks)"
|
||||
:placeholder="t('admin.shippingOrderProfiles.xfaSplit.lineBreaksPlaceholder')"
|
||||
@change="updateNormalization({ line_breaks: parseLineBreaks(($event.target as HTMLInputElement).value) })"
|
||||
@change="(value) => updateNormalization({ line_breaks: parseLineBreaks(String(value)) })"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
@@ -995,30 +1023,30 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<span class="rule-summary">{{ rule.segment.display_name || rule.segment.segment_code || t('admin.shippingOrderProfiles.xfaSplit.unnamedRule') }}</span>
|
||||
</button>
|
||||
<div class="xfa-split__rule-actions">
|
||||
<button type="button" :disabled="isReadonly || index === 0" @click="moveRule(rule.rule_id, -1)">
|
||||
<el-button size="small" :disabled="isReadonly || index === 0" @click="moveRule(rule.rule_id, -1)">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.moveUp') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
:disabled="isReadonly || index === sortedRules.length - 1"
|
||||
@click="moveRule(rule.rule_id, 1)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.moveDown') }}
|
||||
</button>
|
||||
<button type="button" class="danger" :disabled="isReadonly" @click="deleteRule(rule.rule_id)">
|
||||
</el-button>
|
||||
<el-button size="small" type="danger" plain :disabled="isReadonly" @click="deleteRule(rule.rule_id)">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.deleteRule') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!collapsedRules.has(rule.rule_id)" class="xfa-split__rule-detail">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.segmentCode') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.segment_code"
|
||||
:model-value="rule.segment.segment_code"
|
||||
:class="{ 'xfa-split__invalid': segmentCodeHint(rule.segment.segment_code) }"
|
||||
@input="updateRule(rule.rule_id, { segment: { segment_code: ($event.target as HTMLInputElement).value } })"
|
||||
@input="(value) => updateRule(rule.rule_id, { segment: { segment_code: String(value) } })"
|
||||
/>
|
||||
<small v-if="segmentCodeHint(rule.segment.segment_code)" class="xfa-split__hint-error">
|
||||
{{ segmentCodeHint(rule.segment.segment_code) }}
|
||||
@@ -1026,11 +1054,11 @@ watch(activeRuleSet, (current, previous) => {
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.displayName') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.display_name"
|
||||
:model-value="rule.segment.display_name"
|
||||
:class="{ 'xfa-split__invalid': displayNameHint(rule.segment.display_name) }"
|
||||
@input="updateRule(rule.rule_id, { segment: { display_name: ($event.target as HTMLInputElement).value } })"
|
||||
@input="(value) => updateRule(rule.rule_id, { segment: { display_name: String(value) } })"
|
||||
/>
|
||||
<small v-if="displayNameHint(rule.segment.display_name)" class="xfa-split__hint-error">
|
||||
{{ displayNameHint(rule.segment.display_name) }}
|
||||
@@ -1038,38 +1066,36 @@ watch(activeRuleSet, (current, previous) => {
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.note') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.note || ''"
|
||||
@input="updateRule(rule.rule_id, { segment: { note: ($event.target as HTMLInputElement).value || null } })"
|
||||
:model-value="rule.segment.note || ''"
|
||||
@input="(value) => updateRule(rule.rule_id, { segment: { note: (String(value) || null) } })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.handling') }}
|
||||
<select
|
||||
<el-select
|
||||
data-testid="xfa-split-handling"
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.handling"
|
||||
@change="updateSegmentHandling(rule.rule_id, ($event.target as HTMLSelectElement).value as XfaSplitSegment['handling'])"
|
||||
:model-value="rule.segment.handling"
|
||||
@update:model-value="(value) => updateSegmentHandling(rule.rule_id, value as XfaSplitSegment['handling'])"
|
||||
>
|
||||
<option value="evidence_only">{{ t('admin.shippingOrderProfiles.xfaSplit.evidenceOnly') }}</option>
|
||||
<option value="mapped">{{ t('admin.shippingOrderProfiles.xfaSplit.mapped') }}</option>
|
||||
</select>
|
||||
<el-option value="evidence_only" :label="t('admin.shippingOrderProfiles.xfaSplit.evidenceOnly')" />
|
||||
<el-option value="mapped" :label="t('admin.shippingOrderProfiles.xfaSplit.mapped')" />
|
||||
</el-select>
|
||||
</label>
|
||||
<label v-if="rule.segment.handling === 'mapped'">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.targetField') }}
|
||||
<select
|
||||
<el-select
|
||||
data-testid="xfa-split-target-field"
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.target_field_id || ''"
|
||||
:model-value="rule.segment.target_field_id || ''"
|
||||
:class="{ 'xfa-split__invalid': !rule.segment.target_field_id }"
|
||||
@change="updateSegmentTarget(rule.rule_id, ($event.target as HTMLSelectElement).value)"
|
||||
@update:model-value="(value) => updateSegmentTarget(rule.rule_id, String(value))"
|
||||
>
|
||||
<option value="">{{ t('admin.shippingOrderProfiles.xfaSplit.selectField') }}</option>
|
||||
<option v-for="field in splitTargetFields" :key="field.field_id" :value="field.field_id">
|
||||
{{ field.display_name }} ({{ field.field_code }})
|
||||
</option>
|
||||
</select>
|
||||
<el-option value="" :label="t('admin.shippingOrderProfiles.xfaSplit.selectField')" />
|
||||
<el-option v-for="field in splitTargetFields" :key="field.field_id" :value="field.field_id" :label="`${field.display_name} (${field.field_code})`" />
|
||||
</el-select>
|
||||
<small v-if="!rule.segment.target_field_id" class="xfa-split__hint-error">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.validationMappedTarget') }}
|
||||
</small>
|
||||
@@ -1078,89 +1104,89 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<div class="xfa-split__extraction">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.extractionMode') }}
|
||||
<select
|
||||
<el-select
|
||||
:disabled="isReadonly"
|
||||
:value="extractionMode(rule)"
|
||||
@change="changeExtractionMode(rule, ($event.target as HTMLSelectElement).value as ExtractionMode)"
|
||||
:model-value="extractionMode(rule)"
|
||||
@update:model-value="(value) => changeExtractionMode(rule, value as ExtractionMode)"
|
||||
>
|
||||
<option value="select_line">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByLine') }}</option>
|
||||
<option value="select_line_range">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByLineRange') }}</option>
|
||||
<option value="extract_prefix">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByLabel') }}</option>
|
||||
<option value="regex_capture">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex') }}</option>
|
||||
<option value="substring">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring') }}</option>
|
||||
</select>
|
||||
<el-option value="select_line" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByLine')" />
|
||||
<el-option value="select_line_range" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByLineRange')" />
|
||||
<el-option value="extract_prefix" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByLabel')" />
|
||||
<el-option value="regex_capture" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex')" />
|
||||
<el-option value="substring" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring')" />
|
||||
</el-select>
|
||||
</label>
|
||||
|
||||
<label v-if="extractionMode(rule) === 'select_line'">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.extractLineNumber') }}
|
||||
<input
|
||||
<el-input
|
||||
type="number"
|
||||
min="1"
|
||||
:disabled="isReadonly"
|
||||
:value="extractionStage(rule).line_index ?? (rule.order ?? 1)"
|
||||
@input="updateExtraction(rule, { line_index: Number(($event.target as HTMLInputElement).value) || 1 })"
|
||||
:model-value="extractionStage(rule).line_index ?? (rule.order ?? 1)"
|
||||
@input="(value) => updateExtraction(rule, { line_index: Number(value) || 1 })"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<template v-if="extractionMode(rule) === 'select_line_range'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.extractStartLine') }}
|
||||
<input
|
||||
<el-input
|
||||
type="number"
|
||||
min="1"
|
||||
:disabled="isReadonly"
|
||||
:value="extractionStage(rule).line_start ?? (rule.order ?? 1)"
|
||||
@input="updateExtraction(rule, { line_start: Number(($event.target as HTMLInputElement).value) || 1 })"
|
||||
:model-value="extractionStage(rule).line_start ?? (rule.order ?? 1)"
|
||||
@input="(value) => updateExtraction(rule, { line_start: Number(value) || 1 })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.extractEndLine') }}
|
||||
<input
|
||||
<el-input
|
||||
type="number"
|
||||
min="1"
|
||||
:disabled="isReadonly"
|
||||
:value="extractionStage(rule).line_end ?? (rule.order ?? 1) + 1"
|
||||
@input="updateExtraction(rule, { line_end: Number(($event.target as HTMLInputElement).value) || 1 })"
|
||||
:model-value="extractionStage(rule).line_end ?? (rule.order ?? 1) + 1"
|
||||
@input="(value) => updateExtraction(rule, { line_end: Number(value) || 1 })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.joinLinesWith') }}
|
||||
<select
|
||||
<el-select
|
||||
:disabled="isReadonly"
|
||||
:value="extractionStage(rule).join_with || 'newline'"
|
||||
@change="updateExtraction(rule, { join_with: ($event.target as HTMLSelectElement).value as 'newline' | 'space' | 'comma' })"
|
||||
:model-value="extractionStage(rule).join_with || 'newline'"
|
||||
@update:model-value="(value) => updateExtraction(rule, { join_with: value as 'newline' | 'space' | 'comma' })"
|
||||
>
|
||||
<option value="newline">{{ t('admin.shippingOrderProfiles.xfaSplit.joinWithNewline') }}</option>
|
||||
<option value="space">{{ t('admin.shippingOrderProfiles.xfaSplit.joinWithSpace') }}</option>
|
||||
<option value="comma">{{ t('admin.shippingOrderProfiles.xfaSplit.joinWithComma') }}</option>
|
||||
</select>
|
||||
<el-option value="newline" :label="t('admin.shippingOrderProfiles.xfaSplit.joinWithNewline')" />
|
||||
<el-option value="space" :label="t('admin.shippingOrderProfiles.xfaSplit.joinWithSpace')" />
|
||||
<el-option value="comma" :label="t('admin.shippingOrderProfiles.xfaSplit.joinWithComma')" />
|
||||
</el-select>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<template v-if="extractionMode(rule) === 'extract_prefix'">
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.prefix') }}
|
||||
<input :disabled="isReadonly" :value="extractionStage(rule).value || ''" @input="updateExtraction(rule, { value: ($event.target as HTMLInputElement).value })" />
|
||||
<el-input :disabled="isReadonly" :model-value="extractionStage(rule).value || ''" @input="(value) => updateExtraction(rule, { value: String(value) })" />
|
||||
</label>
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.separators') }}
|
||||
<input :disabled="isReadonly" :value="separatorsToString(extractionStage(rule).separators)" @input="updateExtraction(rule, { separators: parseSeparators(($event.target as HTMLInputElement).value) })" />
|
||||
<el-input :disabled="isReadonly" :model-value="separatorsToString(extractionStage(rule).separators)" @input="(value) => updateExtraction(rule, { separators: parseSeparators(String(value)) })" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<template v-if="extractionMode(rule) === 'regex_capture'">
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.regex') }}
|
||||
<input :disabled="isReadonly" :value="extractionStage(rule).pattern || ''" @input="updateExtraction(rule, { pattern: ($event.target as HTMLInputElement).value })" />
|
||||
<el-input :disabled="isReadonly" :model-value="extractionStage(rule).pattern || ''" @input="(value) => updateExtraction(rule, { pattern: String(value) })" />
|
||||
</label>
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.captureGroup') }}
|
||||
<input type="number" min="0" :disabled="isReadonly" :value="extractionStage(rule).capture_group ?? 1" @input="updateExtraction(rule, { capture_group: Number(($event.target as HTMLInputElement).value) || 0 })" />
|
||||
<el-input type="number" min="0" :disabled="isReadonly" :model-value="extractionStage(rule).capture_group ?? 1" @input="(value) => updateExtraction(rule, { capture_group: Number(value) || 0 })" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<template v-if="extractionMode(rule) === 'substring'">
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.substringStart') }}
|
||||
<input type="number" min="0" :disabled="isReadonly" :value="extractionStage(rule).start ?? 0" @input="updateExtraction(rule, { start: Number(($event.target as HTMLInputElement).value) || 0 })" />
|
||||
<el-input type="number" min="0" :disabled="isReadonly" :model-value="extractionStage(rule).start ?? 0" @input="(value) => updateExtraction(rule, { start: Number(value) || 0 })" />
|
||||
</label>
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.substringEnd') }}
|
||||
<input type="number" min="0" :disabled="isReadonly" :value="extractionStage(rule).end ?? ''" @input="updateExtraction(rule, { end: ($event.target as HTMLInputElement).value === '' ? null : Number(($event.target as HTMLInputElement).value) })" />
|
||||
<el-input type="number" min="0" :disabled="isReadonly" :model-value="extractionStage(rule).end ?? ''" @input="(value) => updateExtraction(rule, { end: (String(value) === '' ? null : Number(value)) })" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
@@ -1171,27 +1197,28 @@ watch(activeRuleSet, (current, previous) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="xfa-split__advanced-toggle" @click="toggleAdvanced(rule.rule_id)">
|
||||
<el-button link type="primary" size="small" class="xfa-split__advanced-toggle" @click="toggleAdvanced(rule.rule_id)">
|
||||
{{ advancedRules.has(rule.rule_id)
|
||||
? t('admin.shippingOrderProfiles.xfaSplit.hideAdvanced')
|
||||
: t('admin.shippingOrderProfiles.xfaSplit.showAdvanced') }}
|
||||
</button>
|
||||
</el-button>
|
||||
|
||||
<div v-if="advancedRules.has(rule.rule_id)" class="xfa-split__stages">
|
||||
<div class="xfa-split__stages-header">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaSplit.advancedProcessing') }}</strong>
|
||||
<select
|
||||
<el-select
|
||||
:disabled="isReadonly"
|
||||
:model-value="''"
|
||||
class="xfa-split__add-stage-select"
|
||||
@change="(e) => { addAdvancedStage(rule.rule_id, (e.target as HTMLSelectElement).value as XfaSplitStageType); (e.target as HTMLSelectElement).value = ''; }"
|
||||
:placeholder="t('admin.shippingOrderProfiles.xfaSplit.addAdvancedStep')"
|
||||
@update:model-value="(value) => { if (value) addAdvancedStage(rule.rule_id, value as XfaSplitStageType); }"
|
||||
>
|
||||
<option value="">{{ t('admin.shippingOrderProfiles.xfaSplit.addAdvancedStep') }}</option>
|
||||
<option value="extract_prefix">{{ t('admin.shippingOrderProfiles.xfaSplit.advancedExtractAfterLabel') }}</option>
|
||||
<option value="regex_capture">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex') }}</option>
|
||||
<option value="substring">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring') }}</option>
|
||||
<option value="replace">{{ stageTypeLabel('replace') }}</option>
|
||||
<option value="normalize">{{ stageTypeLabel('normalize') }}</option>
|
||||
</select>
|
||||
<el-option value="extract_prefix" :label="t('admin.shippingOrderProfiles.xfaSplit.advancedExtractAfterLabel')" />
|
||||
<el-option value="regex_capture" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex')" />
|
||||
<el-option value="substring" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring')" />
|
||||
<el-option value="replace" :label="stageTypeLabel('replace')" />
|
||||
<el-option value="normalize" :label="stageTypeLabel('normalize')" />
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<ul class="xfa-split__stage-list">
|
||||
@@ -1199,135 +1226,130 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<div class="xfa-split__stage-toolbar">
|
||||
<span>{{ stageTypeLabel(stage.type) }}</span>
|
||||
<div class="xfa-split__rule-actions">
|
||||
<button
|
||||
type="button"
|
||||
<el-button
|
||||
size="small"
|
||||
:disabled="isReadonly || stageIndex === 0"
|
||||
@click="moveStage(rule.rule_id, stage.stage_id, -1)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.moveUp') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
:disabled="isReadonly || stageIndex === advancedStages(rule).length - 1"
|
||||
@click="moveStage(rule.rule_id, stage.stage_id, 1)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.moveDown') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="danger"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
plain
|
||||
:disabled="isReadonly || (rule.stages || []).length <= 1"
|
||||
@click="deleteStage(rule.rule_id, stage.stage_id)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.deleteStage') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageType') }}
|
||||
<select
|
||||
<el-select
|
||||
:disabled="isReadonly"
|
||||
:value="stage.type"
|
||||
@change="changeStageType(rule.rule_id, stage.stage_id, ($event.target as HTMLSelectElement).value as XfaSplitStageType)"
|
||||
:model-value="stage.type"
|
||||
@update:model-value="(value) => changeStageType(rule.rule_id, stage.stage_id, value as XfaSplitStageType)"
|
||||
>
|
||||
<option value="extract_prefix">{{ t('admin.shippingOrderProfiles.xfaSplit.advancedExtractAfterLabel') }}</option>
|
||||
<option value="regex_capture">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex') }}</option>
|
||||
<option value="substring">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring') }}</option>
|
||||
<option value="replace">{{ stageTypeLabel('replace') }}</option>
|
||||
<option value="normalize">{{ stageTypeLabel('normalize') }}</option>
|
||||
</select>
|
||||
<el-option value="extract_prefix" :label="t('admin.shippingOrderProfiles.xfaSplit.advancedExtractAfterLabel')" />
|
||||
<el-option value="regex_capture" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex')" />
|
||||
<el-option value="substring" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring')" />
|
||||
<el-option value="replace" :label="stageTypeLabel('replace')" />
|
||||
<el-option value="normalize" :label="stageTypeLabel('normalize')" />
|
||||
</el-select>
|
||||
</label>
|
||||
|
||||
<small v-if="stageHint(stage)" class="xfa-split__hint-error">{{ stageHint(stage) }}</small>
|
||||
|
||||
<template v-if="stage.type === 'split_lines' || stage.type === 'normalize'">
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
:disabled="isReadonly"
|
||||
:checked="stage.trim ?? true"
|
||||
@change="updateStage(rule.rule_id, stage.stage_id, { trim: ($event.target as HTMLInputElement).checked })"
|
||||
/>
|
||||
<el-checkbox
|
||||
:disabled="isReadonly"
|
||||
:model-value="stage.trim ?? true"
|
||||
@change="(checked) => updateStage(rule.rule_id, stage.stage_id, { trim: Boolean(checked) })"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageTrim') }}
|
||||
</label>
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
:disabled="isReadonly"
|
||||
:checked="stage.remove_empty_lines ?? true"
|
||||
@change="updateStage(rule.rule_id, stage.stage_id, { remove_empty_lines: ($event.target as HTMLInputElement).checked })"
|
||||
/>
|
||||
</el-checkbox>
|
||||
<el-checkbox
|
||||
:disabled="isReadonly"
|
||||
:model-value="stage.remove_empty_lines ?? true"
|
||||
@change="(checked) => updateStage(rule.rule_id, stage.stage_id, { remove_empty_lines: Boolean(checked) })"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageRemoveEmptyLines') }}
|
||||
</label>
|
||||
</el-checkbox>
|
||||
</template>
|
||||
|
||||
<label v-if="stage.type === 'split_lines'">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.lineBreaks') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="lineBreaksToDisplay(stage.line_breaks)"
|
||||
:model-value="lineBreaksToDisplay(stage.line_breaks)"
|
||||
:placeholder="t('admin.shippingOrderProfiles.xfaSplit.lineBreaksPlaceholder')"
|
||||
@change="updateStage(rule.rule_id, stage.stage_id, { line_breaks: parseLineBreaks(($event.target as HTMLInputElement).value) })"
|
||||
@change="(value) => updateStage(rule.rule_id, stage.stage_id, { line_breaks: parseLineBreaks(String(value)) })"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label v-if="stage.type === 'select_line'">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.lineIndex') }}
|
||||
<input
|
||||
<el-input
|
||||
type="number"
|
||||
min="1"
|
||||
:disabled="isReadonly"
|
||||
:value="stage.line_index ?? 1"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { line_index: Number(($event.target as HTMLInputElement).value) || 1 })"
|
||||
:model-value="stage.line_index ?? 1"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { line_index: Number(value) || 1 })"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<template v-if="stage.type === 'extract_prefix'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.prefix') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="stage.value || ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { value: ($event.target as HTMLInputElement).value })"
|
||||
:model-value="stage.value || ''"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { value: String(value) })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.separators') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="separatorsToString(stage.separators)"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { separators: parseSeparators(($event.target as HTMLInputElement).value) })"
|
||||
:model-value="separatorsToString(stage.separators)"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { separators: parseSeparators(String(value)) })"
|
||||
/>
|
||||
</label>
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
:disabled="isReadonly"
|
||||
:checked="stage.case_sensitive ?? false"
|
||||
@change="updateStage(rule.rule_id, stage.stage_id, { case_sensitive: ($event.target as HTMLInputElement).checked })"
|
||||
/>
|
||||
<el-checkbox
|
||||
:disabled="isReadonly"
|
||||
:model-value="stage.case_sensitive ?? false"
|
||||
@change="(checked) => updateStage(rule.rule_id, stage.stage_id, { case_sensitive: Boolean(checked) })"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.caseSensitive') }}
|
||||
</label>
|
||||
</el-checkbox>
|
||||
</template>
|
||||
|
||||
<template v-if="stage.type === 'regex_capture'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.regex') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="stage.pattern || ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { pattern: ($event.target as HTMLInputElement).value })"
|
||||
:model-value="stage.pattern || ''"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { pattern: String(value) })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.captureGroup') }}
|
||||
<input
|
||||
<el-input
|
||||
type="number"
|
||||
min="0"
|
||||
:disabled="isReadonly"
|
||||
:value="stage.capture_group ?? 1"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { capture_group: Number(($event.target as HTMLInputElement).value) || 0 })"
|
||||
:model-value="stage.capture_group ?? 1"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { capture_group: Number(value) || 0 })"
|
||||
/>
|
||||
</label>
|
||||
</template>
|
||||
@@ -1335,18 +1357,18 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<template v-if="stage.type === 'replace'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.find') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="stage.find || ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { find: ($event.target as HTMLInputElement).value })"
|
||||
:model-value="stage.find || ''"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { find: String(value) })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.replaceWith') }}
|
||||
<input
|
||||
<el-input
|
||||
:disabled="isReadonly"
|
||||
:value="stage.replace_with || ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { replace_with: ($event.target as HTMLInputElement).value })"
|
||||
:model-value="stage.replace_with || ''"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { replace_with: String(value) })"
|
||||
/>
|
||||
</label>
|
||||
</template>
|
||||
@@ -1354,22 +1376,22 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<template v-if="stage.type === 'substring'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.substringStart') }}
|
||||
<input
|
||||
<el-input
|
||||
type="number"
|
||||
min="0"
|
||||
:disabled="isReadonly"
|
||||
:value="stage.start ?? 0"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { start: Number(($event.target as HTMLInputElement).value) || 0 })"
|
||||
:model-value="stage.start ?? 0"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { start: Number(value) || 0 })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.substringEnd') }}
|
||||
<input
|
||||
<el-input
|
||||
type="number"
|
||||
min="0"
|
||||
:disabled="isReadonly"
|
||||
:value="stage.end ?? ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { end: ($event.target as HTMLInputElement).value === '' ? null : Number(($event.target as HTMLInputElement).value) })"
|
||||
:model-value="stage.end ?? ''"
|
||||
@input="(value) => updateStage(rule.rule_id, stage.stage_id, { end: (String(value) === '' ? null : Number(value)) })"
|
||||
/>
|
||||
</label>
|
||||
</template>
|
||||
@@ -1387,46 +1409,42 @@ watch(activeRuleSet, (current, previous) => {
|
||||
|
||||
<style scoped>
|
||||
.xfa-split { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow: auto; }
|
||||
.xfa-split__banner { padding: 8px 10px; border-radius: 6px; background: var(--status-warning-bg); color: var(--status-warning-fg); font-size: 0.85rem; }
|
||||
.xfa-split__banner { border-radius: 6px; }
|
||||
.xfa-split__body { display: flex; flex-direction: column; gap: 8px; }
|
||||
.xfa-split__reveal { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; }
|
||||
.xfa-split__policy { display: grid; gap: 4px; font-size: 0.8rem; }
|
||||
.xfa-split__fieldset { border: 1px solid var(--border-default); border-radius: 6px; padding: 8px 10px; margin: 0; display: grid; gap: 6px; }
|
||||
.xfa-split__fieldset { border: 1px solid var(--el-border-color-lighter); border-radius: 6px; padding: 8px 10px; margin: 0; display: grid; gap: 6px; }
|
||||
.xfa-split__fieldset legend { font-size: 0.8rem; font-weight: 600; padding: 0 4px; }
|
||||
.xfa-split__normalization { display: grid; gap: 4px; font-size: 0.8rem; }
|
||||
.xfa-split__status-line { margin: 0; font-size: 0.75rem; color: var(--text-muted); }
|
||||
.xfa-split__status-line { margin: 0; font-size: 0.75rem; color: var(--el-text-color-secondary); }
|
||||
.xfa-split__rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
|
||||
.xfa-split__rules > li { padding: 10px; border: 1px solid var(--border-default); border-radius: 6px; display: grid; gap: 6px; }
|
||||
.xfa-split__rules > li { padding: 10px; border: 1px solid var(--el-border-color-lighter); border-radius: 6px; display: grid; gap: 6px; }
|
||||
.xfa-split__rule-toolbar { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
|
||||
.xfa-split__rule-title { display: flex; min-width: 0; align-items: center; gap: 6px; padding: 2px 0; border: 0; background: transparent; color: var(--text-primary); cursor: pointer; text-align: left; }
|
||||
.xfa-split__rule-title .rule-summary { overflow: hidden; color: var(--text-muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.xfa-split__rule-title .rule-chevron { width: 12px; color: var(--status-info-fg); font-size: 1rem; }
|
||||
.xfa-split__rule-title { display: flex; min-width: 0; align-items: center; gap: 6px; padding: 2px 0; border: 0; background: transparent; color: var(--el-text-color-primary); cursor: pointer; text-align: left; }
|
||||
.xfa-split__rule-title .rule-summary { overflow: hidden; color: var(--el-text-color-secondary); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.xfa-split__rule-title .rule-chevron { width: 12px; color: var(--el-color-primary); font-size: 1rem; }
|
||||
.xfa-split__rule-detail { display: grid; gap: 6px; }
|
||||
.xfa-split__extraction { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(160px, .7fr); gap: 8px 12px; padding: 10px; border: 1px solid var(--status-info-border); border-radius: 6px; background: var(--status-info-bg); }
|
||||
.xfa-split__inline-preview { grid-column: 1 / -1; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 7px; border-top: 1px solid var(--status-info-border); color: var(--text-muted); font-size: .75rem; }
|
||||
.xfa-split__inline-preview strong { max-width: 70%; overflow: hidden; color: var(--status-success-fg); white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
.xfa-split__advanced-toggle { justify-self: start; padding: 3px 0; border: 0; background: transparent; color: var(--status-info-fg); cursor: pointer; font-size: .75rem; }
|
||||
.xfa-split__extraction { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(160px, .7fr); gap: 8px 12px; padding: 10px; border: 1px solid var(--el-color-primary-light-5); border-radius: 6px; background: var(--el-color-primary-light-9); }
|
||||
.xfa-split__inline-preview { grid-column: 1 / -1; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 7px; border-top: 1px solid var(--el-color-primary-light-5); color: var(--el-text-color-secondary); font-size: .75rem; }
|
||||
.xfa-split__inline-preview strong { max-width: 70%; overflow: hidden; color: var(--el-color-success); white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
.xfa-split__advanced-toggle { justify-self: start; }
|
||||
.xfa-split__rule-actions { display: flex; flex-wrap: wrap; gap: 4px; }
|
||||
.xfa-split__rule-actions button { padding: 2px 6px; font-size: 0.72rem; border: 1px solid var(--border-default); border-radius: 4px; background: var(--bg-page); cursor: pointer; }
|
||||
.xfa-split__rule-actions button.danger { color: var(--status-error-fg); }
|
||||
.xfa-split__stages { margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--border-default); display: grid; gap: 6px; }
|
||||
.xfa-split__stages { margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--el-border-color-lighter); display: grid; gap: 6px; }
|
||||
.xfa-split__stages-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
|
||||
.xfa-split__add-stage-select { font-size: 0.75rem; padding: 2px 4px; }
|
||||
.xfa-split__add-stage-select { width: 11rem; }
|
||||
.xfa-split__stage-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
|
||||
.xfa-split__stage-list > li { padding: 8px; background: var(--bg-subtle, rgba(0,0,0,0.02)); border-radius: 4px; display: grid; gap: 4px; }
|
||||
.xfa-split__stage-list > li { padding: 8px; background: var(--el-fill-color-lighter); border-radius: 4px; display: grid; gap: 4px; }
|
||||
.xfa-split__stage-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 0.75rem; }
|
||||
.xfa-split__preview { max-height: 240px; margin: 0; padding: 10px; overflow: auto; border: 1px solid var(--status-info-border); border-radius: 6px; background: var(--status-info-bg); }
|
||||
.xfa-split__preview { max-height: 240px; margin: 0; padding: 10px; overflow: auto; border: 1px solid var(--el-color-primary-light-5); border-radius: 6px; background: var(--el-color-primary-light-9); }
|
||||
.xfa-split__preview h4, .xfa-split__preview h5 { margin: 8px 0 4px; font-size: 0.85rem; }
|
||||
.xfa-split__table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
|
||||
.xfa-split__table th, .xfa-split__table td { border: 1px solid var(--border-default); padding: 4px 6px; text-align: left; vertical-align: top; }
|
||||
.xfa-split__table th, .xfa-split__table td { border: 1px solid var(--el-border-color-lighter); padding: 4px 6px; text-align: left; vertical-align: top; }
|
||||
.xfa-split__table td:nth-child(4) { white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
.xfa-split__diagnostics li { font-size: 0.8rem; color: var(--status-warning-fg); }
|
||||
.xfa-split__hint-error { color: var(--status-error-fg); font-size: 0.72rem; }
|
||||
.xfa-split__invalid { border-color: var(--status-error-border); }
|
||||
.hint { color: var(--text-muted); font-size: 0.85rem; }
|
||||
.xfa-split__diagnostics li { font-size: 0.8rem; color: var(--el-color-warning); }
|
||||
.xfa-split__hint-error { color: var(--el-color-danger); font-size: 0.72rem; }
|
||||
.xfa-split__invalid :deep(.el-input__wrapper) { box-shadow: 0 0 0 1px var(--el-color-danger) inset; }
|
||||
.hint { color: var(--el-text-color-secondary); font-size: 0.85rem; }
|
||||
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
|
||||
.link { border: 0; background: transparent; color: var(--status-info-fg); cursor: pointer; }
|
||||
label { display: grid; gap: 2px; font-size: 0.8rem; }
|
||||
.xfa-split__checkbox { display: flex; align-items: center; gap: 6px; }
|
||||
input, select { padding: 4px 6px; font-size: 0.8rem; }
|
||||
label :deep(.el-select) { width: 100%; }
|
||||
label :deep(.el-input) { width: 100%; }
|
||||
</style>
|
||||
+524
-220
@@ -1,13 +1,37 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-extraction-runs/ShippingOrderExtractionRunsPage.vue
|
||||
用途:管理员订单识别运行诊断——健康聚合、积压/取消中筛选、只读详情与活跃 Run 取消。
|
||||
依赖:admin.api 脱敏诊断/健康/取消 DTO、Vue Composition API、Vue I18n。
|
||||
逻辑:健康面板 + 列表筛选;详情仍只读;取消走 admin cancel API 且强制填写原因。
|
||||
依赖:element-plus(表格/抽屉/分页/描述列表/骨架屏,沿用管理端 element-trial 主题)、
|
||||
admin.api 脱敏诊断/健康/取消 DTO、Vue Composition API、Vue I18n。
|
||||
逻辑:健康面板 + 列表筛选(与范式页同款:筛选一行、刷新带 loading);详情改为 el-drawer
|
||||
只读(键值对走 el-descriptions);取消仍走 admin cancel API 且强制填写原因;
|
||||
业务脚本(加载/筛选/取消/路由 runNo 联动)保持原逻辑不变,仅视觉层迁移 EP。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElDrawer,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElSkeleton,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
vLoading,
|
||||
} from 'element-plus';
|
||||
import { Refresh } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import {
|
||||
cancelShippingOrderExtractionRun,
|
||||
getShippingOrderExtractionDiagnosticRun,
|
||||
@@ -172,254 +196,534 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="space-y-5 p-5 md:p-7">
|
||||
<header class="flex flex-wrap items-start justify-between gap-4">
|
||||
<section class="extraction-runs-page">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderExtractionRuns.title') }}</h1>
|
||||
<p class="section-desc mt-1 max-w-3xl">{{ t('admin.shippingOrderExtractionRuns.subtitle') }}</p>
|
||||
<h1 class="page-title">{{ t('admin.shippingOrderExtractionRuns.title') }}</h1>
|
||||
<p class="page-desc">{{ t('admin.shippingOrderExtractionRuns.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="loading || healthLoading" @click="refreshAll">
|
||||
<el-button :icon="Refresh" :loading="loading || healthLoading" @click="refreshAll">
|
||||
{{ t('admin.shippingOrderExtractionRuns.refresh') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</header>
|
||||
|
||||
<div
|
||||
class="grid gap-3 rounded-xl border border-default bg-surface p-4 md:grid-cols-4"
|
||||
data-testid="shipping-order-extraction-health"
|
||||
>
|
||||
<div v-if="healthLoading" class="md:col-span-4 text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</div>
|
||||
<div class="health-panel" data-testid="shipping-order-extraction-health">
|
||||
<el-skeleton v-if="healthLoading" class="health-panel__skeleton" :rows="3" animated />
|
||||
<template v-else-if="health">
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.healthStatus') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold" :class="health.health_status === 'healthy' ? 'text-emerald-700' : 'text-amber-700'">
|
||||
<div class="health-stat">
|
||||
<div class="health-stat__label">{{ t('admin.shippingOrderExtractionRuns.healthStatus') }}</div>
|
||||
<div class="health-stat__value" :class="health.health_status === 'healthy' ? 'is-healthy' : 'is-degraded'">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.healthStatuses.${health.health_status}`, health.health_status) }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.activeCount') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold">{{ health.counts.active || 0 }}</div>
|
||||
<div class="health-stat">
|
||||
<div class="health-stat__label">{{ t('admin.shippingOrderExtractionRuns.activeCount') }}</div>
|
||||
<div class="health-stat__value">{{ health.counts.active || 0 }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.staleCount') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold">{{ health.counts.stale || 0 }}</div>
|
||||
<div class="health-stat">
|
||||
<div class="health-stat__label">{{ t('admin.shippingOrderExtractionRuns.staleCount') }}</div>
|
||||
<div class="health-stat__value">{{ health.counts.stale || 0 }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.failureRate') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold">{{ Math.round((health.failure_rate || 0) * 100) }}%</div>
|
||||
<div class="health-stat">
|
||||
<div class="health-stat__label">{{ t('admin.shippingOrderExtractionRuns.failureRate') }}</div>
|
||||
<div class="health-stat__value">{{ Math.round((health.failure_rate || 0) * 100) }}%</div>
|
||||
</div>
|
||||
<div class="md:col-span-4 text-xs text-secondary">
|
||||
<div class="health-panel__footnote">
|
||||
{{ t('admin.shippingOrderExtractionRuns.latencySummary', {
|
||||
p50: formatDuration(health.latency?.total?.p50_ms),
|
||||
p95: formatDuration(health.latency?.total?.p95_ms),
|
||||
max: formatDuration(health.latency?.total?.max_ms),
|
||||
}) }}
|
||||
<span v-if="health.stale_run_nos?.length" class="ml-2">
|
||||
<span v-if="health.stale_run_nos?.length" class="health-panel__stale">
|
||||
{{ t('admin.shippingOrderExtractionRuns.staleRuns', { runs: health.stale_run_nos.slice(0, 5).join(', ') }) }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="md:col-span-4 text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.healthUnavailable') }}</div>
|
||||
<p v-else class="health-panel__unavailable">{{ t('admin.shippingOrderExtractionRuns.healthUnavailable') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3 rounded-xl border border-default bg-surface p-3">
|
||||
<label class="flex items-center gap-2 text-sm text-secondary">
|
||||
{{ t('admin.shippingOrderExtractionRuns.status') }}
|
||||
<select v-model="status" class="select-field py-1.5" @change="applyFilters">
|
||||
<option value="">{{ t('admin.shippingOrderExtractionRuns.allStatuses') }}</option>
|
||||
<option v-for="value in ['queued', 'processing', 'completed', 'partially_completed', 'review_required', 'failed', 'cancelled']" :key="value" :value="value">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.statuses.${value}`) }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="staleOnly" type="checkbox" class="rounded border-default" @change="applyFilters">
|
||||
{{ t('admin.shippingOrderExtractionRuns.staleOnly') }}
|
||||
</label>
|
||||
<label class="flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="cancellationInFlight" type="checkbox" class="rounded border-default" @change="applyFilters">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationInFlight') }}
|
||||
</label>
|
||||
<span class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.total', { count: total }) }}</span>
|
||||
<!-- 筛选一行化:状态下拉 + 两个开关复选 + 总数,@change 即查 -->
|
||||
<div class="filter-bar">
|
||||
<span class="filter-bar__label">{{ t('admin.shippingOrderExtractionRuns.status') }}</span>
|
||||
<el-select v-model="status" class="filter-bar__select" @change="applyFilters">
|
||||
<el-option value="" :label="t('admin.shippingOrderExtractionRuns.allStatuses')" />
|
||||
<el-option
|
||||
v-for="value in ['queued', 'processing', 'completed', 'partially_completed', 'review_required', 'failed', 'cancelled']"
|
||||
:key="value"
|
||||
:value="value"
|
||||
:label="t(`admin.shippingOrderExtractionRuns.statuses.${value}`)"
|
||||
/>
|
||||
</el-select>
|
||||
<el-checkbox v-model="staleOnly" @change="applyFilters">{{ t('admin.shippingOrderExtractionRuns.staleOnly') }}</el-checkbox>
|
||||
<el-checkbox v-model="cancellationInFlight" @change="applyFilters">{{ t('admin.shippingOrderExtractionRuns.cancellationInFlight') }}</el-checkbox>
|
||||
<span class="filter-bar__total">{{ t('admin.shippingOrderExtractionRuns.total', { count: total }) }}</span>
|
||||
</div>
|
||||
|
||||
<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-[1040px] w-full text-left text-sm">
|
||||
<thead class="border-b border-default bg-surface-soft text-xs text-muted"><tr>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.runNo') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.status') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.stage') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.cancellation') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.attempts') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.createdAt') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.totalDuration') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.actions') }}</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr v-if="loading"><td colspan="9" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</td></tr>
|
||||
<tr v-else-if="!rows.length"><td colspan="9" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</td></tr>
|
||||
<tr v-for="row in rows" :key="row.run_no" class="border-b border-default last:border-0">
|
||||
<td class="px-4 py-3 font-mono text-xs">{{ row.run_no }}</td>
|
||||
<td class="px-4 py-3">{{ t(`admin.shippingOrderExtractionRuns.statuses.${row.status}`) }}</td>
|
||||
<td class="px-4 py-3">{{ row.current_event_code || '-' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span v-if="row.cancellation?.in_flight" class="rounded-full bg-amber-100 px-2 py-0.5 text-xs text-amber-800">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationStates.in_flight') }}
|
||||
</span>
|
||||
<span v-else-if="row.cancellation?.completed" class="text-xs text-muted">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationStates.completed') }}
|
||||
</span>
|
||||
<span v-else class="text-xs text-muted">—</span>
|
||||
</td>
|
||||
<td class="px-4 py-3">{{ row.attempt_count }}</td>
|
||||
<td class="px-4 py-3">{{ formatTime(row.created_at) }}</td>
|
||||
<td class="px-4 py-3">{{ formatDuration(row.durations_ms.total ?? row.durations_ms.elapsed_active) }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="flex flex-col gap-2">
|
||||
<button type="button" class="text-left text-brand-600 hover:underline" @click="openDetail(row.run_no)">{{ t('admin.shippingOrderExtractionRuns.viewDetail') }}</button>
|
||||
<template v-if="canCancelRun(row)">
|
||||
<div
|
||||
v-if="pendingCancelRunNo === row.run_no"
|
||||
class="min-w-[220px] space-y-1.5 rounded-md border border-rose-200 bg-rose-50/60 p-2 dark:border-rose-900/40 dark:bg-rose-950/20"
|
||||
<el-alert v-if="error" :title="error" type="error" :closable="false" />
|
||||
|
||||
<el-table v-loading="loading" :data="rows" class="runs-table" row-key="run_no">
|
||||
<el-table-column prop="run_no" :label="t('admin.shippingOrderExtractionRuns.runNo')" min-width="210">
|
||||
<template #default="{ row }">
|
||||
<span class="mono-cell">{{ row.run_no }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderExtractionRuns.status')" min-width="150">
|
||||
<template #default="{ row }">{{ t(`admin.shippingOrderExtractionRuns.statuses.${row.status}`) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderExtractionRuns.stage')" min-width="150">
|
||||
<template #default="{ row }">{{ row.current_event_code || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderExtractionRuns.cancellation')" min-width="130">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.cancellation?.in_flight" type="warning" size="small">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationStates.in_flight') }}
|
||||
</el-tag>
|
||||
<span v-else-if="row.cancellation?.completed" class="muted-cell">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationStates.completed') }}
|
||||
</span>
|
||||
<span v-else class="muted-cell">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="attempt_count" :label="t('admin.shippingOrderExtractionRuns.attempts')" width="90" />
|
||||
<el-table-column :label="t('admin.shippingOrderExtractionRuns.createdAt')" min-width="170">
|
||||
<template #default="{ row }">{{ formatTime(row.created_at) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderExtractionRuns.totalDuration')" width="110">
|
||||
<template #default="{ row }">{{ formatDuration(row.durations_ms.total ?? row.durations_ms.elapsed_active) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.shippingOrderExtractionRuns.actions')" min-width="270">
|
||||
<template #default="{ row }">
|
||||
<div class="run-actions">
|
||||
<el-button link type="primary" size="small" @click="openDetail(row.run_no)">
|
||||
{{ t('admin.shippingOrderExtractionRuns.viewDetail') }}
|
||||
</el-button>
|
||||
<template v-if="canCancelRun(row as ShippingOrderExtractionDiagnosticRun)">
|
||||
<div v-if="pendingCancelRunNo === row.run_no" class="cancel-form">
|
||||
<span class="cancel-form__label">{{ t('chat.shippingOrderExtractionCancel.reasonRequired') }}</span>
|
||||
<el-input v-model="cancelReason" type="textarea" :rows="2" />
|
||||
<div class="cancel-form__buttons">
|
||||
<el-button
|
||||
type="danger"
|
||||
link
|
||||
size="small"
|
||||
:loading="cancellingRunNo === row.run_no"
|
||||
:disabled="cancellingRunNo === row.run_no || !cancelReason.trim()"
|
||||
@click="submitCancelRun(row.run_no)"
|
||||
>
|
||||
<label class="block text-[11px] text-secondary">{{ t('chat.shippingOrderExtractionCancel.reasonRequired') }}</label>
|
||||
<textarea v-model="cancelReason" rows="2" class="input-field w-full py-1 text-xs" />
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs font-medium text-rose-700 hover:underline"
|
||||
:disabled="cancellingRunNo === row.run_no || !cancelReason.trim()"
|
||||
@click="submitCancelRun(row.run_no)"
|
||||
>
|
||||
{{ cancellingRunNo === row.run_no
|
||||
? t('chat.shippingOrderExtractionCancel.submitting')
|
||||
: t('admin.shippingOrderExtractionRuns.cancelRun') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs text-muted hover:underline"
|
||||
:disabled="cancellingRunNo === row.run_no"
|
||||
@click="pendingCancelRunNo = ''; cancelReason = ''"
|
||||
>
|
||||
{{ t('admin.cancel') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="text-left text-xs font-medium text-rose-700 hover:underline"
|
||||
:disabled="Boolean(cancellingRunNo)"
|
||||
@click="beginCancelRun(row.run_no)"
|
||||
{{ cancellingRunNo === row.run_no
|
||||
? t('chat.shippingOrderExtractionCancel.submitting')
|
||||
: t('admin.shippingOrderExtractionRuns.cancelRun') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
:disabled="cancellingRunNo === row.run_no"
|
||||
@click="pendingCancelRunNo = ''; cancelReason = ''"
|
||||
>
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancelRun') }}
|
||||
</button>
|
||||
</template>
|
||||
{{ t('admin.cancel') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</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-overlay" @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="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.cancellation') }}</dt>
|
||||
<dd>
|
||||
<template v-if="detail.run.cancellation?.in_flight">{{ t('admin.shippingOrderExtractionRuns.cancellationStates.in_flight') }}</template>
|
||||
<template v-else-if="detail.run.cancellation?.completed">{{ t('admin.shippingOrderExtractionRuns.cancellationStates.completed') }}</template>
|
||||
<template v-else>—</template>
|
||||
</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">
|
||||
<div class="font-semibold">{{ t('admin.shippingOrderExtractionRuns.autoFreezePolicy') }}</div>
|
||||
<dl class="mt-3 grid grid-cols-2 gap-x-3 gap-y-2">
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeEnabled') }}</dt>
|
||||
<dd>{{ t(detail.run.auto_freeze_policy.enabled ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeMode') }}</dt>
|
||||
<dd>{{ t(`admin.shippingOrderExtractionRuns.autoFreezeModes.${detail.run.auto_freeze_policy.mode}`) }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeQualificationStatus') }}</dt>
|
||||
<dd>{{ detail.run.auto_freeze_policy.qualification_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeQualificationStatuses.${detail.run.auto_freeze_policy.qualification_status}`) : '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeProfile') }}</dt>
|
||||
<dd>{{ detail.run.auto_freeze_policy.selected_profile_code || '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatus') }}</dt>
|
||||
<dd>{{ detail.run.auto_freeze_policy.customer_scope_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatuses.${detail.run.auto_freeze_policy.customer_scope_status}`) : '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatus') }}</dt>
|
||||
<dd>{{ detail.run.auto_freeze_policy.business_scenario_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatuses.${detail.run.auto_freeze_policy.business_scenario_status}`) : '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeCustomerConfirmation') }}</dt>
|
||||
<dd>{{ t(detail.run.auto_freeze_policy.customer_confirmation_required ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd>
|
||||
</dl>
|
||||
<div class="mt-3">
|
||||
<div class="text-xs font-medium text-secondary">{{ t('admin.shippingOrderExtractionRuns.autoFreezeBlockingReasons') }}</div>
|
||||
<div v-if="detail.run.auto_freeze_policy.blocking_reason_codes.length" class="mt-2 flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="code in detail.run.auto_freeze_policy.blocking_reason_codes"
|
||||
:key="code"
|
||||
class="rounded-full border border-default px-2 py-1 text-xs text-secondary"
|
||||
>
|
||||
{{ translateAutoFreezeReason(code) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-else class="mt-2 text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.autoFreezeNoBlockingReasons') }}</div>
|
||||
</div>
|
||||
</section>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.jobAttempts') }}</h3>
|
||||
<div class="mt-2 space-y-2">
|
||||
<div v-for="job in detail.job_attempts" :key="job.job_id" class="rounded-lg border border-default p-3 text-sm">
|
||||
<b>#{{ job.job_id }}</b> · {{ job.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ job.attempts }}/{{ job.max_attempts }} · {{ formatDuration(job.duration_ms) }}
|
||||
</div>
|
||||
<p v-if="!detail.job_attempts.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</div>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.units') }}</h3>
|
||||
<div class="mt-2 space-y-2">
|
||||
<div v-for="unit in detail.units" :key="unit.unit_id" class="rounded-lg border border-default p-3 text-sm">
|
||||
<b>#{{ unit.position + 1 }} {{ unit.unit_type }}</b> · {{ unit.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ unit.attempt_count }} · {{ formatDuration(unit.duration_ms) }}
|
||||
<span v-if="unit.error_code" class="ml-2 font-mono text-xs text-danger">{{ unit.error_code }}</span>
|
||||
<section v-for="routeItem in unit.route_decisions" :key="`${unit.unit_id}:${routeItem.attempt_no}`" class="mt-3 rounded border border-default bg-surface-soft p-3 text-xs">
|
||||
<h4 class="font-semibold text-primary">{{ t('admin.shippingOrderExtractionRuns.routeDecision') }} #{{ routeItem.attempt_no }}</h4>
|
||||
<dl class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1">
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.executionMode') }}</dt>
|
||||
<dd>{{ t(`admin.shippingOrderExtractionRuns.executionModes.${routeItem.execution_mode}`) }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.matchStatus') }}</dt>
|
||||
<dd>{{ t(`admin.shippingOrderExtractionRuns.matchStatuses.${routeItem.match_status}`) }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.selectedProfile') }}</dt>
|
||||
<dd>{{ routeItem.selected_profile_code ? `${routeItem.selected_profile_code} V${routeItem.selected_profile_version}` : '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoCreateApproved') }}</dt>
|
||||
<dd>{{ routeItem.auto_create_approved == null ? '-' : t(routeItem.auto_create_approved ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.fallbackReasons') }}</dt>
|
||||
<dd>{{ routeItem.fallback_reason_codes.length ? routeItem.fallback_reason_codes.map(code => t(`admin.shippingOrderExtractionRuns.reasonCodes.${code}`)).join(';') : '-' }}</dd>
|
||||
</dl>
|
||||
</section>
|
||||
</div>
|
||||
<p v-if="!detail.units.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</div>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.lifecycle') }}</h3>
|
||||
<div class="mt-2 space-y-2">
|
||||
<div v-for="event in detail.progress_events" :key="`${event.sequence_no}:${event.event_code}`" class="rounded-lg border border-default p-3 text-sm">
|
||||
<b>{{ event.event_code }}</b>
|
||||
<span class="ml-2 text-secondary">{{ event.status || '-' }}</span>
|
||||
<span class="ml-2 font-mono text-xs text-muted">{{ t(`admin.shippingOrderExtractionRuns.visibilities.${event.visibility}`) }}</span>
|
||||
<span v-if="event.reason_code" class="ml-2 font-mono text-xs text-muted">{{ event.reason_code }}</span>
|
||||
<time class="ml-2 text-xs text-muted">{{ formatTime(event.occurred_at) }}</time>
|
||||
</div>
|
||||
<p v-if="!detail.progress_events.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
<el-button
|
||||
v-else
|
||||
type="danger"
|
||||
link
|
||||
size="small"
|
||||
:disabled="Boolean(cancellingRunNo)"
|
||||
@click="beginCancelRun(row.run_no)"
|
||||
>
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancelRun') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</aside>
|
||||
</el-table-column>
|
||||
<template #empty>{{ t('admin.shippingOrderExtractionRuns.empty') }}</template>
|
||||
</el-table>
|
||||
|
||||
<div class="runs-pager">
|
||||
<el-pagination
|
||||
layout="prev, pager, next"
|
||||
:page-size="pageSize"
|
||||
:total="total"
|
||||
:current-page="page"
|
||||
:disabled="loading"
|
||||
@current-change="(value) => { page = value; load(); }"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<el-drawer
|
||||
:model-value="detail != null || detailLoading"
|
||||
:title="t('admin.shippingOrderExtractionRuns.detailTitle')"
|
||||
size="640px"
|
||||
resizable
|
||||
destroy-on-close
|
||||
class="run-drawer"
|
||||
@close="closeDetail"
|
||||
>
|
||||
<el-skeleton v-if="detailLoading" :rows="8" animated />
|
||||
<template v-else-if="detail">
|
||||
<el-descriptions :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.runNo')">
|
||||
<span class="mono-cell">{{ detail.run.run_no }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.currentEvent')">
|
||||
<span class="mono-cell">{{ detail.run.current_event_code || '-' }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.cancellation')">
|
||||
<template v-if="detail.run.cancellation?.in_flight">{{ t('admin.shippingOrderExtractionRuns.cancellationStates.in_flight') }}</template>
|
||||
<template v-else-if="detail.run.cancellation?.completed">{{ t('admin.shippingOrderExtractionRuns.cancellationStates.completed') }}</template>
|
||||
<template v-else>—</template>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.candidateMaterializedAt')">
|
||||
{{ formatTime(detail.run.candidate_materialized_at) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.errorCode')">
|
||||
{{ detail.run.error_code || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.totalDuration')">
|
||||
{{ formatDuration(detail.run.durations_ms.total) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<section class="drawer-section">
|
||||
<h3 class="drawer-section__title">{{ t('admin.shippingOrderExtractionRuns.autoFreezePolicy') }}</h3>
|
||||
<el-descriptions :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.autoFreezeEnabled')">
|
||||
{{ t(detail.run.auto_freeze_policy.enabled ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.autoFreezeMode')">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.autoFreezeModes.${detail.run.auto_freeze_policy.mode}`) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.autoFreezeQualificationStatus')">
|
||||
{{ detail.run.auto_freeze_policy.qualification_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeQualificationStatuses.${detail.run.auto_freeze_policy.qualification_status}`) : '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.autoFreezeProfile')">
|
||||
{{ detail.run.auto_freeze_policy.selected_profile_code || '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatus')">
|
||||
{{ detail.run.auto_freeze_policy.customer_scope_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatuses.${detail.run.auto_freeze_policy.customer_scope_status}`) : '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatus')">
|
||||
{{ detail.run.auto_freeze_policy.business_scenario_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatuses.${detail.run.auto_freeze_policy.business_scenario_status}`) : '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.autoFreezeCustomerConfirmation')">
|
||||
{{ t(detail.run.auto_freeze_policy.customer_confirmation_required ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="drawer-section__sub">{{ t('admin.shippingOrderExtractionRuns.autoFreezeBlockingReasons') }}</div>
|
||||
<div v-if="detail.run.auto_freeze_policy.blocking_reason_codes.length" class="reason-tags">
|
||||
<el-tag v-for="code in detail.run.auto_freeze_policy.blocking_reason_codes" :key="code" size="small">
|
||||
{{ translateAutoFreezeReason(code) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<p v-else class="muted-cell">{{ t('admin.shippingOrderExtractionRuns.autoFreezeNoBlockingReasons') }}</p>
|
||||
</section>
|
||||
|
||||
<h3 class="drawer-heading">{{ t('admin.shippingOrderExtractionRuns.jobAttempts') }}</h3>
|
||||
<div class="stack-list">
|
||||
<div v-for="job in detail.job_attempts" :key="job.job_id" class="stack-card">
|
||||
<b>#{{ job.job_id }}</b> · {{ job.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ job.attempts }}/{{ job.max_attempts }} · {{ formatDuration(job.duration_ms) }}
|
||||
</div>
|
||||
<p v-if="!detail.job_attempts.length" class="muted-cell">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</div>
|
||||
|
||||
<h3 class="drawer-heading">{{ t('admin.shippingOrderExtractionRuns.units') }}</h3>
|
||||
<div class="stack-list">
|
||||
<div v-for="unit in detail.units" :key="unit.unit_id" class="stack-card">
|
||||
<div class="stack-card__line">
|
||||
<b>#{{ unit.position + 1 }} {{ unit.unit_type }}</b>
|
||||
<span>· {{ unit.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ unit.attempt_count }} · {{ formatDuration(unit.duration_ms) }}</span>
|
||||
<span v-if="unit.error_code" class="mono-cell danger-cell">{{ unit.error_code }}</span>
|
||||
</div>
|
||||
<section
|
||||
v-for="routeItem in unit.route_decisions"
|
||||
:key="`${unit.unit_id}:${routeItem.attempt_no}`"
|
||||
class="nested-section"
|
||||
>
|
||||
<h4 class="nested-section__title">{{ t('admin.shippingOrderExtractionRuns.routeDecision') }} #{{ routeItem.attempt_no }}</h4>
|
||||
<el-descriptions :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.executionMode')">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.executionModes.${routeItem.execution_mode}`) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.matchStatus')">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.matchStatuses.${routeItem.match_status}`) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.selectedProfile')">
|
||||
{{ routeItem.selected_profile_code ? `${routeItem.selected_profile_code} V${routeItem.selected_profile_version}` : '-' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.autoCreateApproved')">
|
||||
{{ routeItem.auto_create_approved == null ? '-' : t(routeItem.auto_create_approved ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderExtractionRuns.fallbackReasons')">
|
||||
{{ routeItem.fallback_reason_codes.length ? routeItem.fallback_reason_codes.map(code => t(`admin.shippingOrderExtractionRuns.reasonCodes.${code}`)).join(';') : '-' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</section>
|
||||
</div>
|
||||
<p v-if="!detail.units.length" class="muted-cell">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</div>
|
||||
|
||||
<h3 class="drawer-heading">{{ t('admin.shippingOrderExtractionRuns.lifecycle') }}</h3>
|
||||
<div class="stack-list">
|
||||
<div
|
||||
v-for="event in detail.progress_events"
|
||||
:key="`${event.sequence_no}:${event.event_code}`"
|
||||
class="stack-card stack-card__line"
|
||||
>
|
||||
<b>{{ event.event_code }}</b>
|
||||
<span class="muted-cell">{{ event.status || '-' }}</span>
|
||||
<span class="mono-cell muted-cell">{{ t(`admin.shippingOrderExtractionRuns.visibilities.${event.visibility}`) }}</span>
|
||||
<span v-if="event.reason_code" class="mono-cell muted-cell">{{ event.reason_code }}</span>
|
||||
<time class="muted-cell">{{ formatTime(event.occurred_at) }}</time>
|
||||
</div>
|
||||
<p v-if="!detail.progress_events.length" class="muted-cell">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 全宽布局:水平内边距由 AdminLayout 壳层统一持有,页面只保留内部块间距 */
|
||||
.extraction-runs-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.page-desc {
|
||||
margin: 4px 0 0;
|
||||
max-width: 48rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
/* 健康聚合面板:md 及以上 4 列,之下逐列堆叠 */
|
||||
.health-panel {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 10px;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.health-panel__skeleton,
|
||||
.health-panel__footnote,
|
||||
.health-panel__unavailable {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.health-stat__label {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.health-stat__value {
|
||||
margin-top: 4px;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.health-stat__value.is-healthy {
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.health-stat__value.is-degraded {
|
||||
color: var(--el-color-warning);
|
||||
}
|
||||
|
||||
.health-panel__footnote {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.health-panel__stale {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.health-panel__unavailable {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* 筛选一行化:下拉 + 复选 + 总数,@change 即查 */
|
||||
.filter-bar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 10px;
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.filter-bar__label {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.filter-bar__select {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.filter-bar__total {
|
||||
margin-left: auto;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.mono-cell {
|
||||
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.muted-cell {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.danger-cell {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
/* 行内动作:详情 + 行内取消小表单(danger 淡底卡片) */
|
||||
.run-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.cancel-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
width: 240px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--el-color-danger-light-5);
|
||||
border-radius: 8px;
|
||||
background: var(--el-color-danger-light-9);
|
||||
}
|
||||
|
||||
.cancel-form__label {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.cancel-form__buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cancel-form__buttons .el-button + .el-button {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.runs-pager {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* 详情抽屉:键值对 el-descriptions + 卡片式清单 */
|
||||
.drawer-section {
|
||||
margin-top: 20px;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.drawer-section__title {
|
||||
margin: 0 0 12px;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.drawer-section__sub {
|
||||
margin-top: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.reason-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.drawer-heading {
|
||||
margin: 24px 0 8px;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.stack-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.stack-card {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.stack-card b {
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.stack-card__line > span {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.stack-card__line > b + span {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.nested-section {
|
||||
margin-top: 12px;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
background: var(--el-fill-color-lighter);
|
||||
}
|
||||
|
||||
.nested-section__title {
|
||||
margin: 0 0 8px;
|
||||
color: var(--el-color-primary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.health-panel {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+387
-397
File diff suppressed because it is too large.
Load diff
+47
-21
@@ -1,11 +1,17 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaAuditTimeline.vue
|
||||
用途:展示订单 Schema 配置的追加式审计时间线。
|
||||
依赖:ShippingOrderSchemaAuditEvent DTO、Vue I18n。
|
||||
依赖:element-plus(el-timeline 时间线/el-tag 徽标/el-button 加载更多/el-empty 空态,
|
||||
沿用管理端 element-trial 主题)、ShippingOrderSchemaAuditEvent DTO、Vue I18n。
|
||||
逻辑:父组件分页读取最小审计摘要;展示字段集合变更与自动建单策略变更,不展示完整快照。
|
||||
视觉层已迁移 Element Plus,props/emit 契约保持不变。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElEmpty, ElTag, ElTimeline, ElTimelineItem } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { ShippingOrderSchemaAuditEvent } from '@/features/admin/types/shipping-order-schema.types';
|
||||
|
||||
defineProps<{ events: ShippingOrderSchemaAuditEvent[]; total: number; loading: boolean }>();
|
||||
@@ -82,28 +88,48 @@ const autoCreationSummary = (event: ShippingOrderSchemaAuditEvent): string => {
|
||||
|
||||
<template>
|
||||
<section class="audit-timeline" :aria-label="t('admin.shippingOrderSchema.auditTitle')">
|
||||
<div class="audit-heading"><span>{{ t('admin.shippingOrderSchema.auditTitle') }}</span><small>{{ total }}</small></div>
|
||||
<p v-if="!events.length && !loading" class="audit-empty">{{ t('admin.shippingOrderSchema.auditEmpty') }}</p>
|
||||
<article v-for="event in events" :key="event.id" class="audit-event">
|
||||
<strong>{{ eventLabel(event.event_type) }}</strong><span v-if="event.version">V{{ event.version.version }}</span>
|
||||
<p>{{ formatDate(event.created_at) }} · {{ event.actor?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</p>
|
||||
<small v-if="hasFieldChanges(event)">{{ t('admin.shippingOrderSchema.auditFieldSummary', { added: (event.change_summary.added_field_ids as string[] | undefined)?.length || 0, removed: (event.change_summary.removed_field_ids as string[] | undefined)?.length || 0, changed: (event.change_summary.changed_field_ids as string[] | undefined)?.length || 0 }) }}</small>
|
||||
<small v-if="hasAutoCreationChange(event) && autoCreationSummary(event)" class="audit-auto-creation">{{ autoCreationSummary(event) }}</small>
|
||||
</article>
|
||||
<button v-if="events.length < total" type="button" :disabled="loading" @click="emit('loadMore')">{{ loading ? t('common.loading') : t('admin.shippingOrderSchema.auditLoadMore') }}</button>
|
||||
<div class="audit-heading">
|
||||
<span>{{ t('admin.shippingOrderSchema.auditTitle') }}</span>
|
||||
<el-tag size="small" effect="plain" round>{{ total }}</el-tag>
|
||||
</div>
|
||||
<el-empty
|
||||
v-if="!events.length && !loading"
|
||||
:description="t('admin.shippingOrderSchema.auditEmpty')"
|
||||
:image-size="60"
|
||||
/>
|
||||
<el-timeline v-else class="audit-events">
|
||||
<el-timeline-item
|
||||
v-for="event in events"
|
||||
:key="event.id"
|
||||
:timestamp="formatDate(event.created_at)"
|
||||
placement="top"
|
||||
>
|
||||
<article class="audit-event">
|
||||
<strong>{{ eventLabel(event.event_type) }}</strong>
|
||||
<el-tag v-if="event.version" size="small" effect="plain">V{{ event.version.version }}</el-tag>
|
||||
<p>{{ event.actor?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</p>
|
||||
<small v-if="hasFieldChanges(event)">{{ t('admin.shippingOrderSchema.auditFieldSummary', { added: (event.change_summary.added_field_ids as string[] | undefined)?.length || 0, removed: (event.change_summary.removed_field_ids as string[] | undefined)?.length || 0, changed: (event.change_summary.changed_field_ids as string[] | undefined)?.length || 0 }) }}</small>
|
||||
<small v-if="hasAutoCreationChange(event) && autoCreationSummary(event)" class="audit-auto-creation">{{ autoCreationSummary(event) }}</small>
|
||||
</article>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
<el-button
|
||||
v-if="events.length < total"
|
||||
class="audit-more"
|
||||
:disabled="loading"
|
||||
@click="emit('loadMore')"
|
||||
>
|
||||
{{ loading ? t('common.loading') : t('admin.shippingOrderSchema.auditLoadMore') }}
|
||||
</el-button>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.audit-timeline { margin-top: 22px; border-top: 1px solid #e5ebf1; padding-top: 18px; }
|
||||
.audit-heading { display: flex; align-items: center; gap: 8px; color: #64748b; font-size: 12px; font-weight: 700; }
|
||||
.audit-heading small { border-radius: 999px; background: #e0f2fe; padding: 2px 7px; color: #0369a1; }
|
||||
.audit-event { position: relative; margin: 10px 0 0 6px; border-left: 2px solid #bae6fd; padding: 0 0 10px 13px; }
|
||||
.audit-event::before { position: absolute; top: 3px; left: -5px; width: 8px; height: 8px; border-radius: 50%; background: #0ea5e9; content: ''; }
|
||||
.audit-event strong { color: #334155; font-size: 12px; }
|
||||
.audit-event > span { margin-left: 6px; color: #0369a1; font-size: 11px; }
|
||||
.audit-event p, .audit-event small { display: block; margin: 4px 0 0; color: #94a3b8; font-size: 11px; }
|
||||
.audit-auto-creation { color: #0f766e !important; }
|
||||
.audit-timeline > button { width: 100%; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; padding: 8px; color: #0284c7; font: inherit; font-size: 12px; cursor: pointer; }
|
||||
.audit-empty { color: #94a3b8; font-size: 12px; }
|
||||
.audit-timeline { margin-top: 22px; border-top: 1px solid var(--el-border-color-lighter); padding-top: 18px; }
|
||||
.audit-heading { display: flex; align-items: center; gap: 8px; color: var(--el-text-color-secondary); font-size: 12px; font-weight: 700; }
|
||||
.audit-events { padding-left: 2px; }
|
||||
.audit-event strong { margin-right: 6px; color: var(--el-text-color-regular); font-size: 12px; }
|
||||
.audit-event p, .audit-event small { display: block; margin: 4px 0 0; color: var(--el-text-color-placeholder); font-size: 12px; }
|
||||
.audit-auto-creation { color: var(--el-color-success) !important; }
|
||||
.audit-more { width: 100%; margin-top: 12px; }
|
||||
</style>
|
||||
+66
-21
@@ -1,12 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaExtractionAuditDrawer.vue
|
||||
用途:以只读方式展示一条订单解析的冻结输入、LLM 输出、裁决和字段证据。
|
||||
依赖:ShippingOrderExtractionAudit DTO、Vue I18n。
|
||||
依赖:element-plus(el-drawer 抽屉/el-descriptions 键值对/el-tag 状态徽标/el-alert 缺快照横幅/
|
||||
el-skeleton 骨架/el-empty 空态,沿用管理端 element-trial 主题)、
|
||||
ShippingOrderExtractionAudit DTO、Vue I18n。
|
||||
逻辑:复杂运行数据由服务端完整组装;组件使用 JSON 预格式化展示,禁止在审计视图编辑或重放解析。
|
||||
视觉层已迁移 Element Plus,v-model 对外契约保持不变。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElAlert, ElDescriptions, ElDescriptionsItem, ElDrawer, ElEmpty, ElSkeleton, ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { ShippingOrderExtractionAudit } from '@/features/admin/types/shipping-order-schema.types';
|
||||
|
||||
const props = defineProps<{ modelValue: boolean; audit: ShippingOrderExtractionAudit | null; loading: boolean }>();
|
||||
@@ -19,27 +26,65 @@ const documents = computed(() => Array.isArray(props.audit?.input_snapshot.docum
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="audit-detail-layer" role="presentation" @click.self="emit('update:modelValue', false)">
|
||||
<aside class="audit-detail-drawer" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderSchema.runtimeAuditTitle')">
|
||||
<header><div><p>{{ t('admin.shippingOrderSchema.runtimeAuditEyebrow') }}</p><h2>{{ t('admin.shippingOrderSchema.runtimeAuditTitle') }}</h2></div><button type="button" :aria-label="t('common.close')" @click="emit('update:modelValue', false)">×</button></header>
|
||||
<main v-if="loading" class="audit-detail-empty">{{ t('common.loading') }}</main>
|
||||
<main v-else-if="audit">
|
||||
<dl class="audit-meta"><div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditExtraction') }}</dt><dd>#{{ audit.extraction.id }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditVersion') }}</dt><dd>V{{ audit.schema_version.version }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditStatus') }}</dt><dd>{{ t(`admin.shippingOrderSchema.extractionStatus.${audit.extraction.status}`) }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditHash') }}</dt><dd><code>{{ audit.extraction.input_snapshot_hash }}</code></dd></div></dl>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditInput') }}</h3><p v-if="audit.input_snapshot.snapshot_available === false" class="snapshot-unavailable">{{ t('admin.shippingOrderSchema.runtimeAuditInputUnavailable') }}</p><article v-for="document in documents" :key="String(document.id)" class="audit-document"><strong>{{ String(document.filename || document.id) }}</strong><pre>{{ String(document.extracted_text || '') }}</pre></article></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditLlm') }}</h3><pre>{{ json(audit.raw_llm_output) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditNormalized') }}</h3><pre>{{ json(audit.normalized_result) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditValidation') }}</h3><pre>{{ json(audit.validation_result) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditDecisions') }} ({{ audit.decisions.length }})</h3><pre>{{ json(audit.decisions) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditEvidence') }} ({{ audit.observations.length }})</h3><pre>{{ json(audit.observations) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditValues') }} ({{ audit.field_values.length }})</h3><pre>{{ json(audit.field_values) }}</pre></section>
|
||||
</main>
|
||||
<main v-else class="audit-detail-empty">{{ t('admin.shippingOrderSchema.runtimeAuditEmpty') }}</main>
|
||||
</aside>
|
||||
</div>
|
||||
</Teleport>
|
||||
<el-drawer
|
||||
:model-value="modelValue"
|
||||
size="min(900px, 97vw)"
|
||||
resizable
|
||||
destroy-on-close
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
>
|
||||
<template #header>
|
||||
<div class="drawer-heading">
|
||||
<p>{{ t('admin.shippingOrderSchema.runtimeAuditEyebrow') }}</p>
|
||||
<h2>{{ t('admin.shippingOrderSchema.runtimeAuditTitle') }}</h2>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-skeleton v-if="loading" :rows="6" animated />
|
||||
<template v-else-if="audit">
|
||||
<el-descriptions class="audit-meta" :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.runtimeAuditExtraction')">#{{ audit.extraction.id }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.runtimeAuditVersion')">V{{ audit.schema_version.version }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.runtimeAuditStatus')">
|
||||
<el-tag size="small">{{ t(`admin.shippingOrderSchema.extractionStatus.${audit.extraction.status}`) }}</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.runtimeAuditHash')">
|
||||
<code>{{ audit.extraction.input_snapshot_hash }}</code>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<section>
|
||||
<h3>{{ t('admin.shippingOrderSchema.runtimeAuditInput') }}</h3>
|
||||
<el-alert
|
||||
v-if="audit.input_snapshot.snapshot_available === false"
|
||||
:title="t('admin.shippingOrderSchema.runtimeAuditInputUnavailable')"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
/>
|
||||
<article v-for="document in documents" :key="String(document.id)" class="audit-document">
|
||||
<strong>{{ String(document.filename || document.id) }}</strong>
|
||||
<pre>{{ String(document.extracted_text || '') }}</pre>
|
||||
</article>
|
||||
</section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditLlm') }}</h3><pre>{{ json(audit.raw_llm_output) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditNormalized') }}</h3><pre>{{ json(audit.normalized_result) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditValidation') }}</h3><pre>{{ json(audit.validation_result) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditDecisions') }} ({{ audit.decisions.length }})</h3><pre>{{ json(audit.decisions) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditEvidence') }} ({{ audit.observations.length }})</h3><pre>{{ json(audit.observations) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditValues') }} ({{ audit.field_values.length }})</h3><pre>{{ json(audit.field_values) }}</pre></section>
|
||||
</template>
|
||||
<el-empty v-else :description="t('admin.shippingOrderSchema.runtimeAuditEmpty')" :image-size="60" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.audit-detail-layer { position: fixed; z-index: 90; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 40%); backdrop-filter: blur(2px); }.audit-detail-drawer { display: flex; width: min(900px, 97vw); height: 100%; flex-direction: column; overflow: hidden; background: #f8fafc; box-shadow: -18px 0 48px rgb(15 23 42 / 22%); }.audit-detail-drawer > header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 22px 26px; }.audit-detail-drawer header p { margin: 0 0 4px; color: #0284c7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }.audit-detail-drawer h2 { margin: 0; color: #1e293b; font-size: 20px; }.audit-detail-drawer > header button { width: 32px; height: 32px; border: 1px solid #dbe5ee; border-radius: 50%; background: #fff; color: #475569; font-size: 22px; line-height: 1; cursor: pointer; }.audit-detail-drawer main { overflow-y: auto; padding: 24px 26px; }.audit-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 20px; }.audit-meta div { border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 10px; }.audit-meta dt { color: #94a3b8; font-size: 10px; }.audit-meta dd { margin: 5px 0 0; color: #334155; font-size: 12px; overflow-wrap: anywhere; }.audit-detail-drawer section { margin-top: 18px; }.audit-detail-drawer h3 { margin: 0 0 8px; color: #64748b; font-size: 12px; }.audit-detail-drawer pre { overflow: auto; max-height: 340px; margin: 0; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 12px; color: #334155; font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }.audit-document { margin-top: 8px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 12px; }.audit-document strong { color: #334155; font-size: 12px; }.audit-document pre { max-height: 220px; margin-top: 8px; border: 0; background: #f8fafc; }.snapshot-unavailable { margin: 0; border: 1px solid #fde68a; border-radius: 7px; background: #fffbeb; padding: 9px; color: #a16207; font-size: 12px; }.audit-detail-empty { display: grid; min-height: 240px; place-items: center; color: #94a3b8; font-size: 13px; }@media (max-width: 640px) { .audit-detail-drawer main { padding: 18px; }.audit-meta { grid-template-columns: 1fr; } }
|
||||
.drawer-heading p { margin: 0 0 4px; color: var(--el-color-primary); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
||||
.drawer-heading h2 { margin: 0; color: var(--el-text-color-primary); font-size: 20px; }
|
||||
.audit-meta { margin: 0 0 20px; }
|
||||
.audit-meta code { color: var(--el-color-primary); font-size: 12px; }
|
||||
section { margin-top: 18px; }
|
||||
section > h3 { margin: 0 0 8px; color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
pre { overflow: auto; max-height: 340px; margin: 0; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; background: var(--el-bg-color); padding: 12px; color: var(--el-text-color-regular); font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
.audit-document { margin-top: 8px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; background: var(--el-bg-color); padding: 12px; }
|
||||
.audit-document strong { color: var(--el-text-color-regular); font-size: 12px; }
|
||||
.audit-document pre { max-height: 220px; margin-top: 8px; border: 0; background: var(--el-fill-color-light); }
|
||||
</style>
|
||||
+71
-22
@@ -1,12 +1,18 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaVersionDiffDrawer.vue
|
||||
用途:只读展示两个订单 Schema 版本的服务端语义化字段差异。
|
||||
依赖:ShippingOrderSchemaVersionDiff DTO、Vue I18n。
|
||||
依赖:element-plus(el-drawer 抽屉/el-tag 差异徽标/el-skeleton 骨架/el-empty 空态,
|
||||
沿用管理端 element-trial 主题)、ShippingOrderSchemaVersionDiff DTO、Vue I18n。
|
||||
逻辑:父组件负责加载差异;本组件只根据后端 field_id 差异结构渲染,绝不自行推断字段是否重命名。
|
||||
视觉层已迁移 Element Plus,v-model 对外契约保持不变。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElDrawer, ElEmpty, ElSkeleton, ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type {
|
||||
ShippingOrderSchemaFieldChange,
|
||||
ShippingOrderSchemaFieldDiff,
|
||||
@@ -41,28 +47,71 @@ const valueText = (value: unknown): string => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="diff-layer" role="presentation" @click.self="emit('update:modelValue', false)">
|
||||
<aside class="diff-drawer" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderSchema.diffTitle')">
|
||||
<header><div><p>{{ t('admin.shippingOrderSchema.diffEyebrow') }}</p><h2>{{ t('admin.shippingOrderSchema.diffTitle') }}</h2></div><button type="button" :aria-label="t('common.close')" @click="emit('update:modelValue', false)">×</button></header>
|
||||
<main v-if="loading" class="empty">{{ t('common.loading') }}</main>
|
||||
<main v-else-if="diff">
|
||||
<p class="comparison">V{{ diff.base_version.version }} {{ t('admin.shippingOrderSchema.diffComparedWith') }} V{{ diff.compare_version.version }}</p>
|
||||
<div class="summary"><span v-for="key in ['added', 'removed', 'modified']" :key="key">{{ t(`admin.shippingOrderSchema.diffStatus.${key}`) }} <b>{{ diff.summary[key as 'added' | 'removed' | 'modified'] }}</b></span></div>
|
||||
<article v-for="field in changedFields" :key="field.field_id" class="diff-field" :class="field.change_type">
|
||||
<header><div><strong>{{ fieldLabel(field) }}</strong><code>{{ field.after?.field_code || field.before?.field_code }}</code></div><span>{{ t(`admin.shippingOrderSchema.diffStatus.${field.change_type}`) }}</span></header>
|
||||
<template v-if="field.change_type === 'added'"><p>{{ t('admin.shippingOrderSchema.diffAddedField') }}</p></template>
|
||||
<template v-else-if="field.change_type === 'removed'"><p>{{ t('admin.shippingOrderSchema.diffRemovedField') }}</p></template>
|
||||
<dl v-else><div v-for="change in field.changes" :key="change.key"><dt>{{ changeLabel(change) }}</dt><dd><del>{{ valueText(change.before) }}</del><ins>{{ valueText(change.after) }}</ins><small v-if="change.order_changed">{{ t('admin.shippingOrderSchema.diffOrderChanged') }}</small></dd></div></dl>
|
||||
</article>
|
||||
<p v-if="!changedFields.length" class="empty">{{ t('admin.shippingOrderSchema.diffNoChanges') }}</p>
|
||||
</main>
|
||||
<main v-else class="empty">{{ t('admin.shippingOrderSchema.diffNoChanges') }}</main>
|
||||
</aside>
|
||||
</div>
|
||||
</Teleport>
|
||||
<el-drawer
|
||||
:model-value="modelValue"
|
||||
size="min(760px, 96vw)"
|
||||
resizable
|
||||
destroy-on-close
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
>
|
||||
<template #header>
|
||||
<div class="drawer-heading">
|
||||
<p>{{ t('admin.shippingOrderSchema.diffEyebrow') }}</p>
|
||||
<h2>{{ t('admin.shippingOrderSchema.diffTitle') }}</h2>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-skeleton v-if="loading" :rows="6" animated />
|
||||
<template v-else-if="diff">
|
||||
<p class="comparison">V{{ diff.base_version.version }} {{ t('admin.shippingOrderSchema.diffComparedWith') }} V{{ diff.compare_version.version }}</p>
|
||||
<div class="summary">
|
||||
<el-tag size="small" type="success">{{ t('admin.shippingOrderSchema.diffStatus.added') }} {{ diff.summary.added }}</el-tag>
|
||||
<el-tag size="small" type="danger">{{ t('admin.shippingOrderSchema.diffStatus.removed') }} {{ diff.summary.removed }}</el-tag>
|
||||
<el-tag size="small">{{ t('admin.shippingOrderSchema.diffStatus.modified') }} {{ diff.summary.modified }}</el-tag>
|
||||
</div>
|
||||
<article v-for="field in changedFields" :key="field.field_id" class="diff-field" :class="field.change_type">
|
||||
<header>
|
||||
<div>
|
||||
<strong>{{ fieldLabel(field) }}</strong>
|
||||
<code>{{ field.after?.field_code || field.before?.field_code }}</code>
|
||||
</div>
|
||||
<el-tag size="small" :type="field.change_type === 'added' ? 'success' : field.change_type === 'removed' ? 'danger' : 'primary'">
|
||||
{{ t(`admin.shippingOrderSchema.diffStatus.${field.change_type}`) }}
|
||||
</el-tag>
|
||||
</header>
|
||||
<template v-if="field.change_type === 'added'"><p>{{ t('admin.shippingOrderSchema.diffAddedField') }}</p></template>
|
||||
<template v-else-if="field.change_type === 'removed'"><p>{{ t('admin.shippingOrderSchema.diffRemovedField') }}</p></template>
|
||||
<dl v-else><div v-for="change in field.changes" :key="change.key"><dt>{{ changeLabel(change) }}</dt><dd><del>{{ valueText(change.before) }}</del><ins>{{ valueText(change.after) }}</ins><small v-if="change.order_changed">{{ t('admin.shippingOrderSchema.diffOrderChanged') }}</small></dd></div></dl>
|
||||
</article>
|
||||
<el-empty
|
||||
v-if="!changedFields.length"
|
||||
:description="t('admin.shippingOrderSchema.diffNoChanges')"
|
||||
:image-size="60"
|
||||
/>
|
||||
</template>
|
||||
<el-empty v-else :description="t('admin.shippingOrderSchema.diffNoChanges')" :image-size="60" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.diff-layer { position: fixed; z-index: 80; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 35%); backdrop-filter: blur(2px); }.diff-drawer { display: flex; width: min(760px, 96vw); height: 100%; flex-direction: column; overflow: hidden; background: #f8fafc; box-shadow: -18px 0 48px rgb(15 23 42 / 18%); }.diff-drawer > header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 22px 26px; }.diff-drawer header p { margin: 0 0 4px; color: #0284c7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }.diff-drawer h2 { margin: 0; color: #1e293b; font-size: 20px; }.diff-drawer > header button { width: 32px; height: 32px; border: 1px solid #dbe5ee; border-radius: 50%; background: #fff; color: #475569; font-size: 22px; line-height: 1; cursor: pointer; }.diff-drawer main { overflow-y: auto; padding: 24px 26px; }.comparison { margin: 0 0 10px; color: #64748b; font-size: 13px; }.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }.summary span, .diff-field > header > span { border-radius: 999px; background: #e0f2fe; padding: 3px 7px; color: #0369a1; font-size: 11px; }.summary b { margin-left: 3px; }.diff-field { margin-top: 10px; border: 1px solid #e2e8f0; border-left-width: 3px; border-radius: 8px; background: #fff; padding: 13px; }.diff-field.added { border-left-color: #22c55e; }.diff-field.removed { border-left-color: #ef4444; }.diff-field.modified { border-left-color: #0ea5e9; }.diff-field > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }.diff-field strong { display: block; color: #1e293b; font-size: 13px; }.diff-field code { color: #64748b; font-size: 11px; }.diff-field > p { margin: 10px 0 0; color: #64748b; font-size: 12px; }.diff-field dl { display: grid; gap: 8px; margin: 12px 0 0; }.diff-field dl div { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 8px; }.diff-field dt { color: #64748b; font-size: 11px; }.diff-field dd { display: grid; gap: 4px; margin: 0; color: #475569; font-size: 12px; overflow-wrap: anywhere; }.diff-field del { color: #b91c1c; text-decoration: line-through; }.diff-field ins { color: #15803d; text-decoration: none; }.diff-field small { color: #a16207; font-size: 10px; }.empty { display: grid; min-height: 240px; place-items: center; color: #94a3b8; font-size: 13px; }@media (max-width: 640px) { .diff-drawer main { padding: 18px; }.diff-field dl div { grid-template-columns: 1fr; gap: 3px; } }
|
||||
.drawer-heading p { margin: 0 0 4px; color: var(--el-color-primary); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
||||
.drawer-heading h2 { margin: 0; color: var(--el-text-color-primary); font-size: 20px; }
|
||||
.comparison { margin: 0 0 10px; color: var(--el-text-color-secondary); font-size: 13px; }
|
||||
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
|
||||
.diff-field { margin-top: 10px; border: 1px solid var(--el-border-color-lighter); border-left-width: 3px; border-radius: 8px; background: var(--el-bg-color); padding: 13px; }
|
||||
.diff-field.added { border-left-color: var(--el-color-success); }
|
||||
.diff-field.removed { border-left-color: var(--el-color-danger); }
|
||||
.diff-field.modified { border-left-color: var(--el-color-primary); }
|
||||
.diff-field > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
|
||||
.diff-field strong { display: block; color: var(--el-text-color-primary); font-size: 13px; }
|
||||
.diff-field code { color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.diff-field > p { margin: 10px 0 0; color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.diff-field dl { display: grid; gap: 8px; margin: 12px 0 0; }
|
||||
.diff-field dl div { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 8px; }
|
||||
.diff-field dt { color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.diff-field dd { display: grid; gap: 4px; margin: 0; color: var(--el-text-color-regular); font-size: 12px; overflow-wrap: anywhere; }
|
||||
.diff-field del { color: var(--el-color-danger); text-decoration: line-through; }
|
||||
.diff-field ins { color: var(--el-color-success); text-decoration: none; }
|
||||
.diff-field small { color: var(--el-color-warning); font-size: 12px; }
|
||||
@media (max-width: 640px) { .diff-field dl div { grid-template-columns: 1fr; gap: 3px; } }
|
||||
</style>
|
||||
+141
-90
@@ -1,12 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaVersionHistoryDrawer.vue
|
||||
用途:以时间线和完整只读快照浏览订单 Schema 的草稿、发布及退役版本。
|
||||
依赖:ShippingOrderSchemaVersion DTO、Vue I18n。
|
||||
依赖:element-plus(el-drawer 抽屉/el-tag 状态徽标/el-descriptions 键值对/el-skeleton 骨架/
|
||||
el-button 动作与加载更多/el-empty 空态,沿用管理端 element-trial 主题)、
|
||||
ShippingOrderSchemaVersion DTO、Vue I18n、SchemaAuditTimeline。
|
||||
逻辑:父页面加载版本概要和按需详情;本组件仅展示并发出选择/关闭事件,不修改任何版本配置。
|
||||
视觉层已迁移 Element Plus,model-value 与 select/load-more/compare/usage/copy 事件契约保持不变。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDescriptions, ElDescriptionsItem, ElDrawer, ElEmpty, ElSkeleton, ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import SchemaAuditTimeline from '@/features/admin/modules/shipping-order-schema/components/SchemaAuditTimeline.vue';
|
||||
import type { ShippingOrderField, ShippingOrderSchemaVersion } from '@/features/admin/types/shipping-order-schema.types';
|
||||
import type { ShippingOrderSchemaAuditEvent } from '@/features/admin/types/shipping-order-schema.types';
|
||||
@@ -67,100 +74,144 @@ const close = (): void => emit('update:modelValue', false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="history-layer" role="presentation" @click.self="close">
|
||||
<aside class="history-drawer" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderSchema.historyTitle')">
|
||||
<header class="history-header">
|
||||
<div><p>{{ t('admin.shippingOrderSchema.historyEyebrow') }}</p><h2>{{ t('admin.shippingOrderSchema.historyTitle') }}</h2></div>
|
||||
<button type="button" class="history-close" :aria-label="t('common.close')" @click="close">×</button>
|
||||
</header>
|
||||
<el-drawer
|
||||
:model-value="modelValue"
|
||||
size="min(1060px, 96vw)"
|
||||
resizable
|
||||
destroy-on-close
|
||||
@update:model-value="!$event && close()"
|
||||
>
|
||||
<template #header>
|
||||
<div class="drawer-heading">
|
||||
<p>{{ t('admin.shippingOrderSchema.historyEyebrow') }}</p>
|
||||
<h2>{{ t('admin.shippingOrderSchema.historyTitle') }}</h2>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="history-content">
|
||||
<nav class="history-timeline" :aria-label="t('admin.shippingOrderSchema.historyTitle')">
|
||||
<button
|
||||
v-for="item in versions"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="history-item"
|
||||
:class="{ selected: selectedVersion?.id === item.id }"
|
||||
@click="emit('select', item.id)"
|
||||
<div class="history-content">
|
||||
<nav class="history-timeline" :aria-label="t('admin.shippingOrderSchema.historyTitle')">
|
||||
<button
|
||||
v-for="item in versions"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="history-item"
|
||||
:class="{ selected: selectedVersion?.id === item.id }"
|
||||
@click="emit('select', item.id)"
|
||||
>
|
||||
<span class="history-version">V{{ item.version }}</span>
|
||||
<el-tag size="small" :type="item.status === 'published' ? 'success' : item.status === 'draft' ? 'warning' : 'info'">
|
||||
{{ statusLabel(item.status) }}
|
||||
</el-tag>
|
||||
<strong>{{ item.change_note || t('admin.shippingOrderSchema.historyNoNote') }}</strong>
|
||||
<small>{{ formatDate(item.published_at || item.created_at) }}</small>
|
||||
<small>{{ item.published_by?.display_name || item.created_by?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</small>
|
||||
</button>
|
||||
<el-button
|
||||
v-if="versions.length < total"
|
||||
class="history-more"
|
||||
:disabled="loading"
|
||||
@click="emit('loadMore')"
|
||||
>
|
||||
{{ loading ? t('common.loading') : t('admin.shippingOrderSchema.historyLoadMore') }}
|
||||
</el-button>
|
||||
</nav>
|
||||
|
||||
<section class="history-detail">
|
||||
<el-skeleton v-if="detailLoading" class="detail-skeleton" :rows="6" animated />
|
||||
<template v-else-if="selectedVersion">
|
||||
<header class="detail-heading">
|
||||
<div><p>{{ t('admin.shippingOrderSchema.historyViewing') }}</p><h3>V{{ selectedVersion.version }}</h3></div>
|
||||
<el-tag size="small" type="info">{{ t('admin.shippingOrderSchema.readOnly') }}</el-tag>
|
||||
</header>
|
||||
<el-descriptions class="detail-meta" :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.historyPublishedAt')">{{ formatDate(selectedVersion.published_at || selectedVersion.created_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.historyPublisher')">{{ selectedVersion.published_by?.display_name || selectedVersion.created_by?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.historyChecksum')">
|
||||
<code>{{ selectedVersion.checksum || '-' }}</code>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.changeNote')">{{ selectedVersion.change_note || t('admin.shippingOrderSchema.historyNoNote') }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="history-actions">
|
||||
<el-button
|
||||
v-if="comparisonTarget"
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
@click="emit('compare', selectedVersion.id)"
|
||||
>
|
||||
<span class="history-version">V{{ item.version }}</span>
|
||||
<span class="history-status" :class="item.status">{{ statusLabel(item.status) }}</span>
|
||||
<strong>{{ item.change_note || t('admin.shippingOrderSchema.historyNoNote') }}</strong>
|
||||
<small>{{ formatDate(item.published_at || item.created_at) }}</small>
|
||||
<small>{{ item.published_by?.display_name || item.created_by?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</small>
|
||||
</button>
|
||||
<button v-if="versions.length < total" type="button" class="history-more" :disabled="loading" @click="emit('loadMore')">
|
||||
{{ loading ? t('common.loading') : t('admin.shippingOrderSchema.historyLoadMore') }}
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<section class="history-detail">
|
||||
<div v-if="detailLoading" class="history-empty">{{ t('common.loading') }}</div>
|
||||
<template v-else-if="selectedVersion">
|
||||
<header class="detail-heading">
|
||||
<div><p>{{ t('admin.shippingOrderSchema.historyViewing') }}</p><h3>V{{ selectedVersion.version }}</h3></div>
|
||||
<span class="detail-readonly">{{ t('admin.shippingOrderSchema.readOnly') }}</span>
|
||||
</header>
|
||||
<dl class="detail-meta">
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.historyPublishedAt') }}</dt><dd>{{ formatDate(selectedVersion.published_at || selectedVersion.created_at) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.historyPublisher') }}</dt><dd>{{ selectedVersion.published_by?.display_name || selectedVersion.created_by?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.historyChecksum') }}</dt><dd><code>{{ selectedVersion.checksum || '-' }}</code></dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.changeNote') }}</dt><dd>{{ selectedVersion.change_note || t('admin.shippingOrderSchema.historyNoNote') }}</dd></div>
|
||||
</dl>
|
||||
<button v-if="comparisonTarget" type="button" class="compare-button" @click="emit('compare', selectedVersion.id)">
|
||||
{{ t('admin.shippingOrderSchema.diffWithCurrent', { version: comparisonTarget.version }) }}
|
||||
</button>
|
||||
<div class="history-actions">
|
||||
<button type="button" class="compare-button" @click="emit('usage', selectedVersion.id)">{{ t('admin.shippingOrderSchema.usageOpen') }}</button>
|
||||
<button v-if="selectedVersion.status !== 'draft'" type="button" class="compare-button" :disabled="copying" @click="emit('copy', selectedVersion.id)">{{ t('admin.shippingOrderSchema.copyToDraft') }}</button>
|
||||
</div>
|
||||
<div class="snapshot-heading"><span>{{ t('admin.shippingOrderSchema.historySnapshotFields') }}</span><b>{{ fields.length }}</b></div>
|
||||
<article v-for="field in fields" :key="field.field_id" class="snapshot-field" :class="{ excluded: field.enabled === false }">
|
||||
<div class="snapshot-field-title"><strong>{{ field.display_name }}</strong><code>{{ field.field_code }}</code><span v-if="field.enabled === false">{{ t('admin.shippingOrderSchema.historyExcluded') }}</span></div>
|
||||
<p>{{ field.scope === 'header' ? t('admin.shippingOrderSchema.placementHeader') : t('admin.shippingOrderSchema.placementLine') }} · {{ t(`admin.shippingOrderSchema.fieldType.${field.value_type}`) }}</p>
|
||||
<dl v-if="field.field_category === 'general_context'"><div><dt>{{ t('admin.shippingOrderSchema.contextSource') }}</dt><dd>{{ contextSourceLabel(field) }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.deterministicCollection') }}</dt><dd>{{ t('admin.shippingOrderSchema.deterministicCollectionHint') }}</dd></div></dl>
|
||||
<dl v-else><div><dt>{{ t('admin.shippingOrderSchema.aliases') }}</dt><dd>{{ field.aliases.join(', ') || '-' }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.extractionInstruction') }}</dt><dd>{{ field.extraction_instruction || '-' }}</dd></div></dl>
|
||||
</article>
|
||||
<SchemaAuditTimeline
|
||||
:events="auditEvents"
|
||||
:total="auditTotal"
|
||||
:loading="auditLoading"
|
||||
@load-more="emit('loadMoreAudit')"
|
||||
/>
|
||||
</template>
|
||||
<div v-else class="history-empty">{{ t('admin.shippingOrderSchema.historySelectVersion') }}</div>
|
||||
</section>
|
||||
</div>
|
||||
</aside>
|
||||
{{ t('admin.shippingOrderSchema.diffWithCurrent', { version: comparisonTarget.version }) }}
|
||||
</el-button>
|
||||
<el-button size="small" @click="emit('usage', selectedVersion.id)">
|
||||
{{ t('admin.shippingOrderSchema.usageOpen') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="selectedVersion.status !== 'draft'"
|
||||
size="small"
|
||||
:loading="copying"
|
||||
@click="emit('copy', selectedVersion.id)"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.copyToDraft') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="snapshot-heading">
|
||||
<span>{{ t('admin.shippingOrderSchema.historySnapshotFields') }}</span>
|
||||
<el-tag size="small" effect="plain" round>{{ fields.length }}</el-tag>
|
||||
</div>
|
||||
<article v-for="field in fields" :key="field.field_id" class="snapshot-field" :class="{ excluded: field.enabled === false }">
|
||||
<div class="snapshot-field-title">
|
||||
<strong>{{ field.display_name }}</strong>
|
||||
<code>{{ field.field_code }}</code>
|
||||
<el-tag v-if="field.enabled === false" size="small" type="warning">{{ t('admin.shippingOrderSchema.historyExcluded') }}</el-tag>
|
||||
</div>
|
||||
<p>{{ field.scope === 'header' ? t('admin.shippingOrderSchema.placementHeader') : t('admin.shippingOrderSchema.placementLine') }} · {{ t(`admin.shippingOrderSchema.fieldType.${field.value_type}`) }}</p>
|
||||
<el-descriptions v-if="field.field_category === 'general_context'" :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.contextSource')">{{ contextSourceLabel(field) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.deterministicCollection')">{{ t('admin.shippingOrderSchema.deterministicCollectionHint') }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-descriptions v-else :column="2" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.aliases')">{{ field.aliases.join(', ') || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.extractionInstruction')">{{ field.extraction_instruction || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</article>
|
||||
<SchemaAuditTimeline
|
||||
:events="auditEvents"
|
||||
:total="auditTotal"
|
||||
:loading="auditLoading"
|
||||
@load-more="emit('loadMoreAudit')"
|
||||
/>
|
||||
</template>
|
||||
<el-empty v-else :description="t('admin.shippingOrderSchema.historySelectVersion')" :image-size="60" />
|
||||
</section>
|
||||
</div>
|
||||
</Teleport>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.history-layer { position: fixed; z-index: 70; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 30%); backdrop-filter: blur(2px); }
|
||||
.history-drawer { display: flex; width: min(1060px, 96vw); height: 100%; flex-direction: column; background: #f8fafc; box-shadow: -18px 0 48px rgb(15 23 42 / 18%); }
|
||||
.history-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 22px 26px; }
|
||||
.history-header p, .detail-heading p { margin: 0 0 4px; color: #0284c7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
||||
.history-header h2, .detail-heading h3 { margin: 0; color: #1e293b; font-size: 20px; }
|
||||
.history-close { width: 32px; height: 32px; border: 1px solid #dbe5ee; border-radius: 50%; background: #fff; color: #475569; font-size: 22px; line-height: 1; cursor: pointer; }
|
||||
.drawer-heading p { margin: 0 0 4px; color: var(--el-color-primary); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
||||
.drawer-heading h2 { margin: 0; color: var(--el-text-color-primary); font-size: 20px; }
|
||||
.history-content { display: grid; min-height: 0; flex: 1; grid-template-columns: 290px minmax(0, 1fr); }
|
||||
.history-timeline { overflow-y: auto; border-right: 1px solid #e2e8f0; background: #f1f5f9; padding: 14px 10px; }
|
||||
.history-item { display: grid; width: 100%; gap: 5px; margin-bottom: 6px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 12px; color: #475569; font: inherit; text-align: left; cursor: pointer; }
|
||||
.history-item:hover { background: #fff; }
|
||||
.history-item.selected { border-color: #bae6fd; background: #fff; box-shadow: inset 3px 0 #0ea5e9; }
|
||||
.history-version { color: #0f172a; font-size: 16px; font-weight: 700; }
|
||||
.history-status { width: fit-content; border-radius: 999px; padding: 2px 6px; font-size: 10px; font-weight: 700; }
|
||||
.history-status.published { background: #dcfce7; color: #15803d; }.history-status.retired { background: #e2e8f0; color: #475569; }.history-status.draft { background: #fef3c7; color: #a16207; }
|
||||
.history-item strong { overflow: hidden; color: #334155; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }.history-item small { color: #94a3b8; font-size: 11px; }
|
||||
.history-more { width: 100%; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; padding: 8px; color: #0284c7; font: inherit; font-size: 12px; cursor: pointer; }
|
||||
.history-detail { overflow-y: auto; background: #fff; padding: 26px; }.history-empty { display: grid; min-height: 300px; place-items: center; color: #94a3b8; font-size: 13px; }
|
||||
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; }.detail-readonly { border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc; padding: 4px 9px; color: #64748b; font-size: 11px; font-weight: 700; }
|
||||
.detail-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 22px 0; }.detail-meta div { border: 1px solid #e5ebf1; border-radius: 8px; background: #fbfdff; padding: 10px; }.detail-meta dt, .snapshot-field dt { color: #94a3b8; font-size: 10px; }.detail-meta dd, .snapshot-field dd { margin: 5px 0 0; color: #334155; font-size: 12px; overflow-wrap: anywhere; }.detail-meta code { color: #0369a1; font-size: 10px; }
|
||||
.snapshot-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: #64748b; font-size: 12px; font-weight: 700; }.snapshot-heading b { border-radius: 999px; background: #e0f2fe; padding: 2px 7px; color: #0369a1; }
|
||||
.compare-button { margin: -8px 0 16px; border: 1px solid #7dd3fc; border-radius: 6px; background: #f0f9ff; padding: 7px 10px; color: #0369a1; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
|
||||
.history-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 16px; }.history-actions .compare-button { margin: 0; }.compare-button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.snapshot-field { margin-top: 8px; border: 1px solid #e5ebf1; border-radius: 8px; padding: 13px; }.snapshot-field.excluded { border-style: dashed; opacity: .68; }.snapshot-field-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }.snapshot-field-title strong { color: #1e293b; font-size: 13px; }.snapshot-field-title code { color: #64748b; font-size: 11px; }.snapshot-field-title span { border-radius: 999px; background: #fef3c7; padding: 2px 6px; color: #a16207; font-size: 10px; }.snapshot-field p { margin: 6px 0 10px; color: #94a3b8; font-size: 11px; }.snapshot-field dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
|
||||
@media (max-width: 760px) { .history-drawer { width: 100vw; }.history-content { grid-template-columns: 1fr; }.history-timeline { max-height: 38vh; border-right: 0; border-bottom: 1px solid #e2e8f0; }.detail-meta, .snapshot-field dl { grid-template-columns: 1fr; }.history-detail { padding: 18px; } }
|
||||
.history-timeline { overflow-y: auto; border-right: 1px solid var(--el-border-color-lighter); background: var(--el-fill-color-light); padding: 14px 10px; }
|
||||
.history-item { display: grid; width: 100%; gap: 5px; justify-items: start; margin-bottom: 6px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 12px; color: var(--el-text-color-regular); font: inherit; text-align: left; cursor: pointer; }
|
||||
.history-item:hover { background: var(--el-bg-color); }
|
||||
.history-item.selected { border-color: var(--el-color-primary-light-7); background: var(--el-bg-color); box-shadow: inset 3px 0 var(--el-color-primary); }
|
||||
.history-version { color: var(--el-text-color-primary); font-size: 16px; font-weight: 700; }
|
||||
.history-item strong { overflow: hidden; color: var(--el-text-color-regular); font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.history-item small { color: var(--el-text-color-placeholder); font-size: 12px; }
|
||||
.history-more { width: 100%; }
|
||||
.history-detail { overflow-y: auto; background: var(--el-bg-color); padding: 26px; }
|
||||
.detail-skeleton { padding: 8px; }
|
||||
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; }
|
||||
.detail-heading p { margin: 0 0 4px; color: var(--el-color-primary); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
||||
.detail-heading h3 { margin: 0; color: var(--el-text-color-primary); font-size: 20px; }
|
||||
.detail-meta { margin: 22px 0; }
|
||||
.detail-meta code { color: var(--el-color-primary); font-size: 12px; }
|
||||
.snapshot-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--el-text-color-secondary); font-size: 12px; font-weight: 700; }
|
||||
.history-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
|
||||
.snapshot-field { margin-top: 8px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 13px; }
|
||||
.snapshot-field.excluded { border-style: dashed; opacity: .68; }
|
||||
.snapshot-field-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||
.snapshot-field-title strong { color: var(--el-text-color-primary); font-size: 13px; }
|
||||
.snapshot-field-title code { color: var(--el-text-color-secondary); font-size: 12px; }
|
||||
.snapshot-field p { margin: 6px 0 10px; color: var(--el-text-color-placeholder); font-size: 12px; }
|
||||
@media (max-width: 760px) { .history-content { grid-template-columns: 1fr; } .history-timeline { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--el-border-color-lighter); } .history-detail { padding: 18px; } }
|
||||
</style>
|
||||
+66
-22
@@ -1,11 +1,18 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaVersionUsageDrawer.vue
|
||||
用途:展示一个订单 Schema 版本实际参与解析的使用统计和分页运行记录。
|
||||
依赖:ShippingOrderSchemaVersionUsage DTO、Vue I18n。
|
||||
依赖:element-plus(el-drawer 抽屉/el-descriptions 键值对/el-tag 状态徽标/el-skeleton 骨架/
|
||||
el-button 加载更多/el-empty 空态,沿用管理端 element-trial 主题)、
|
||||
ShippingOrderSchemaVersionUsage DTO、Vue I18n。
|
||||
逻辑:父页面负责请求数据和打开单次审计,本组件只展示摘要并发出选择/翻页事件。
|
||||
视觉层已迁移 Element Plus,v-model 与 select/load-more 事件契约保持不变。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDescriptions, ElDescriptionsItem, ElDrawer, ElEmpty, ElSkeleton, ElTag } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import type { ShippingOrderSchemaVersionUsage } from '@/features/admin/types/shipping-order-schema.types';
|
||||
|
||||
defineProps<{ modelValue: boolean; usage: ShippingOrderSchemaVersionUsage | null; loading: boolean }>();
|
||||
@@ -19,28 +26,65 @@ const formatDate = (value?: string | null): string => value
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="usage-layer" role="presentation" @click.self="emit('update:modelValue', false)">
|
||||
<aside class="usage-drawer" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderSchema.usageTitle')">
|
||||
<header><div><p>{{ t('admin.shippingOrderSchema.usageEyebrow') }}</p><h2>{{ t('admin.shippingOrderSchema.usageTitle') }}</h2></div><button type="button" :aria-label="t('common.close')" @click="emit('update:modelValue', false)">×</button></header>
|
||||
<main v-if="loading" class="usage-empty">{{ t('common.loading') }}</main>
|
||||
<main v-else-if="usage">
|
||||
<p class="usage-version">V{{ usage.version.version }}</p>
|
||||
<dl class="usage-summary"><div><dt>{{ t('admin.shippingOrderSchema.usageTotal') }}</dt><dd>{{ usage.summary.total }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.usageFirst') }}</dt><dd>{{ formatDate(usage.summary.first_used_at) }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.usageLast') }}</dt><dd>{{ formatDate(usage.summary.last_used_at) }}</dd></div></dl>
|
||||
<div class="usage-statuses"><span v-for="(count, status) in usage.summary.status_counts" :key="status">{{ t(`admin.shippingOrderSchema.extractionStatus.${status}`) }} <b>{{ count }}</b></span></div>
|
||||
<h3>{{ t('admin.shippingOrderSchema.usageRecords') }}</h3>
|
||||
<p v-if="!usage.items.length" class="usage-empty">{{ t('admin.shippingOrderSchema.usageEmpty') }}</p>
|
||||
<button v-for="item in usage.items" :key="item.id" type="button" class="usage-record" @click="emit('select', item.id)">
|
||||
<strong>#{{ item.id }}</strong><span>{{ t(`admin.shippingOrderSchema.extractionStatus.${item.status}`) }}</span><small>{{ formatDate(item.created_at) }} · {{ item.input_snapshot_hash.slice(0, 12) }}</small>
|
||||
</button>
|
||||
<button v-if="usage.items.length < usage.total" type="button" class="usage-more" :disabled="loading" @click="emit('loadMore')">{{ t('admin.shippingOrderSchema.usageLoadMore') }}</button>
|
||||
</main>
|
||||
<main v-else class="usage-empty">{{ t('admin.shippingOrderSchema.usageEmpty') }}</main>
|
||||
</aside>
|
||||
</div>
|
||||
</Teleport>
|
||||
<el-drawer
|
||||
:model-value="modelValue"
|
||||
size="min(680px, 96vw)"
|
||||
resizable
|
||||
destroy-on-close
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
>
|
||||
<template #header>
|
||||
<div class="drawer-heading">
|
||||
<p>{{ t('admin.shippingOrderSchema.usageEyebrow') }}</p>
|
||||
<h2>{{ t('admin.shippingOrderSchema.usageTitle') }}</h2>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-skeleton v-if="loading" :rows="6" animated />
|
||||
<template v-else-if="usage">
|
||||
<p class="usage-version">V{{ usage.version.version }}</p>
|
||||
<el-descriptions class="usage-summary" :column="3" size="small">
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.usageTotal')">{{ usage.summary.total }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.usageFirst')">{{ formatDate(usage.summary.first_used_at) }}</el-descriptions-item>
|
||||
<el-descriptions-item :label="t('admin.shippingOrderSchema.usageLast')">{{ formatDate(usage.summary.last_used_at) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="usage-statuses">
|
||||
<el-tag v-for="(count, status) in usage.summary.status_counts" :key="status" size="small" effect="plain">
|
||||
{{ t(`admin.shippingOrderSchema.extractionStatus.${status}`) }} {{ count }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<h3 class="usage-records-title">{{ t('admin.shippingOrderSchema.usageRecords') }}</h3>
|
||||
<el-empty
|
||||
v-if="!usage.items.length"
|
||||
:description="t('admin.shippingOrderSchema.usageEmpty')"
|
||||
:image-size="60"
|
||||
/>
|
||||
<button v-for="item in usage.items" :key="item.id" type="button" class="usage-record" @click="emit('select', item.id)">
|
||||
<strong>#{{ item.id }}</strong>
|
||||
<el-tag size="small" effect="plain">{{ t(`admin.shippingOrderSchema.extractionStatus.${item.status}`) }}</el-tag>
|
||||
<small>{{ formatDate(item.created_at) }} · {{ item.input_snapshot_hash.slice(0, 12) }}</small>
|
||||
</button>
|
||||
<el-button
|
||||
v-if="usage.items.length < usage.total"
|
||||
class="usage-more"
|
||||
:disabled="loading"
|
||||
@click="emit('loadMore')"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.usageLoadMore') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-empty v-else :description="t('admin.shippingOrderSchema.usageEmpty')" :image-size="60" />
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.usage-layer { position: fixed; z-index: 80; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 35%); backdrop-filter: blur(2px); }.usage-drawer { display: flex; width: min(680px, 96vw); height: 100%; flex-direction: column; overflow: hidden; background: #f8fafc; box-shadow: -18px 0 48px rgb(15 23 42 / 18%); }.usage-drawer > header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 22px 26px; }.usage-drawer header p { margin: 0 0 4px; color: #0284c7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }.usage-drawer h2 { margin: 0; color: #1e293b; font-size: 20px; }.usage-drawer > header button { width: 32px; height: 32px; border: 1px solid #dbe5ee; border-radius: 50%; background: #fff; color: #475569; font-size: 22px; line-height: 1; cursor: pointer; }.usage-drawer main { overflow-y: auto; padding: 24px 26px; }.usage-version { margin: 0 0 12px; color: #0369a1; font-weight: 700; }.usage-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }.usage-summary div { border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 10px; }.usage-summary dt { color: #94a3b8; font-size: 10px; }.usage-summary dd { margin: 5px 0 0; color: #334155; font-size: 12px; overflow-wrap: anywhere; }.usage-statuses { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }.usage-statuses span { border-radius: 999px; background: #e0f2fe; padding: 3px 7px; color: #0369a1; font-size: 11px; }.usage-drawer h3 { margin: 22px 0 10px; color: #64748b; font-size: 12px; }.usage-record { display: grid; width: 100%; grid-template-columns: 70px 1fr; gap: 5px 10px; margin-top: 7px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 11px; color: #475569; font: inherit; text-align: left; cursor: pointer; }.usage-record:hover { border-color: #7dd3fc; background: #f0f9ff; }.usage-record strong { color: #1e293b; font-size: 12px; }.usage-record span { color: #0369a1; font-size: 12px; }.usage-record small { grid-column: 1 / -1; color: #94a3b8; font-size: 10px; }.usage-empty { display: grid; min-height: 220px; place-items: center; color: #94a3b8; font-size: 13px; }.usage-more { width: 100%; margin-top: 10px; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; padding: 8px; color: #0284c7; font: inherit; font-size: 12px; cursor: pointer; }@media (max-width: 640px) { .usage-drawer main { padding: 18px; }.usage-summary { grid-template-columns: 1fr; } }
|
||||
.drawer-heading p { margin: 0 0 4px; color: var(--el-color-primary); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
||||
.drawer-heading h2 { margin: 0; color: var(--el-text-color-primary); font-size: 20px; }
|
||||
.usage-version { margin: 0 0 12px; color: var(--el-color-primary); font-weight: 700; }
|
||||
.usage-statuses { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
|
||||
.usage-records-title { margin: 22px 0 10px; color: var(--el-text-color-secondary); font-size: 12px; }.usage-record { display: grid; width: 100%; grid-template-columns: 70px 1fr; gap: 5px 10px; justify-items: start; margin-top: 7px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; background: var(--el-bg-color); padding: 11px; color: var(--el-text-color-regular); font: inherit; text-align: left; cursor: pointer; }
|
||||
.usage-record:hover { border-color: var(--el-color-primary-light-5); background: var(--el-color-primary-light-9); }
|
||||
.usage-record strong { color: var(--el-text-color-primary); font-size: 12px; }
|
||||
.usage-record small { grid-column: 1 / -1; color: var(--el-text-color-placeholder); font-size: 12px; }
|
||||
.usage-more { width: 100%; margin-top: 10px; }
|
||||
</style>
|
||||
+863
-316
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,828 @@
|
||||
<!--
|
||||
features/admin/modules/transfer-types/TransferTypesPage.vue
|
||||
用途:在途调拨「调拨类型配置化」管理页——列表(搜索/状态筛选/空态)+ 编辑抽屉四块
|
||||
(基本信息 / 范围规则行编辑器 / 仓库定义 / 转换规则行编辑器),ADR 0002。
|
||||
依赖:element-plus(表格/抽屉/表单控件,沿用管理端 element-trial 主题)、
|
||||
transferTypes.api(受控词表与请求)、useTransferTypesAdmin(状态与动作编排)、vue-i18n。
|
||||
逻辑:页面只负责模板与样式;校验/保存/重叠比对/映射档校验全部在 composable。
|
||||
可用性契约:onBlur 行内校验,错误文本为固定 id 的 <p>(EP 2.14 不自动接
|
||||
aria-describedby,故由本页显式绑定)+ el-form-item :validate-status 出红框;提交失败
|
||||
顶部错误摘要(role=alert,锚点跳字段);保存按钮 loading→成功/失败反馈;关抽屉前
|
||||
脏检测确认(未保存不静默丢弃);范围重叠与映射档未命中仅黄色提示、不拦截保存(D10/D6)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCollapse,
|
||||
ElCollapseItem,
|
||||
ElDrawer,
|
||||
ElEmpty,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElInputTag,
|
||||
ElOption,
|
||||
ElRadio,
|
||||
ElRadioGroup,
|
||||
ElSegmented,
|
||||
ElSelect,
|
||||
ElSkeleton,
|
||||
ElSwitch,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
vLoading,
|
||||
} from 'element-plus';
|
||||
import { Delete, Edit, Plus, Search } from '@element-plus/icons-vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import {
|
||||
TRANSFER_SCOPE_FIELDS,
|
||||
TRANSFER_SCOPE_MATCHES,
|
||||
TRANSFORM_FIELDS,
|
||||
TRANSFORM_OPS,
|
||||
type TransferTypeRow,
|
||||
} from './transferTypes.api';
|
||||
import { useTransferTypesAdmin } from './useTransferTypesAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
const {
|
||||
isLoading,
|
||||
types,
|
||||
search,
|
||||
statusFilter,
|
||||
filteredTypes,
|
||||
loadTypes,
|
||||
drawerOpen,
|
||||
editingCode,
|
||||
form,
|
||||
openCreate,
|
||||
openEdit,
|
||||
requestClose,
|
||||
fieldErrors,
|
||||
errorSummary,
|
||||
overlapCodes,
|
||||
warehouseChecks,
|
||||
warehouseOptions,
|
||||
validateField,
|
||||
clearFieldError,
|
||||
focusField,
|
||||
addScopeRule,
|
||||
removeScopeRule,
|
||||
onScopeValuesChange,
|
||||
addTransformRule,
|
||||
removeTransformRule,
|
||||
saving,
|
||||
saveButtonLabel,
|
||||
save,
|
||||
} = useTransferTypesAdmin();
|
||||
|
||||
const drawerTitle = computed(() => (
|
||||
editingCode.value
|
||||
? t('admin.transferTypes.drawerEditTitle')
|
||||
: t('admin.transferTypes.drawerCreateTitle')
|
||||
));
|
||||
|
||||
/** 状态筛选分段选项(el-segmented:全部/启用/停用一击直达)。 */
|
||||
const statusOptions = computed(() => [
|
||||
{ label: t('admin.transferTypes.statusAll'), value: 'all' },
|
||||
{ label: t('admin.transferTypes.statusEnabled'), value: 'enabled' },
|
||||
{ label: t('admin.transferTypes.statusDisabled'), value: 'disabled' },
|
||||
]);
|
||||
|
||||
/** 列表行 class:行级定位供测试与样式使用(el-table 不支持行属性透传)。 */
|
||||
const rowClassName = (): string => 'type-row';
|
||||
|
||||
/** 清除搜索与状态筛选(筛选无结果空态的行动按钮)。 */
|
||||
const clearFilters = (): void => {
|
||||
search.value = '';
|
||||
statusFilter.value = 'all';
|
||||
};
|
||||
|
||||
/** 其他语言名称(zh-TW/en/th 选填)折叠态:新建收起,编辑回显已有值时展开。 */
|
||||
const otherNamesOpen = ref<string[]>([]);
|
||||
|
||||
const syncOtherNamesOpen = (): void => {
|
||||
otherNamesOpen.value = Boolean(form.nameZhTw || form.nameEn || form.nameTh) ? ['otherNames'] : [];
|
||||
};
|
||||
|
||||
const openCreateDrawer = (): void => {
|
||||
openCreate();
|
||||
otherNamesOpen.value = [];
|
||||
};
|
||||
|
||||
const openEditDrawer = (row: unknown): void => {
|
||||
// el-table 插槽 row 为 DefaultRow 宽类型,结构契约由 composable 的 rowToForm 兜底
|
||||
openEdit(row as TransferTypeRow);
|
||||
syncOtherNamesOpen();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
void loadTypes();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="transfer-types-page">
|
||||
<header class="page-heading">
|
||||
<div>
|
||||
<h2 data-testid="page-title">{{ t('admin.transferTypes.title') }}</h2>
|
||||
<p class="page-subtitle">{{ t('admin.transferTypes.subtitle') }}</p>
|
||||
</div>
|
||||
<el-button type="primary" :icon="Plus" data-testid="create-type" @click="openCreateDrawer">
|
||||
{{ t('admin.transferTypes.createType') }}
|
||||
</el-button>
|
||||
</header>
|
||||
|
||||
<div class="list-toolbar">
|
||||
<div class="toolbar-field">
|
||||
<span>{{ t('admin.transferTypes.searchLabel') }}</span>
|
||||
<el-input
|
||||
v-model="search"
|
||||
class="toolbar-search"
|
||||
:placeholder="t('admin.transferTypes.searchPlaceholder')"
|
||||
:prefix-icon="Search"
|
||||
clearable
|
||||
data-testid="search-input"
|
||||
/>
|
||||
</div>
|
||||
<div class="toolbar-field">
|
||||
<span>{{ t('admin.transferTypes.statusLabel') }}</span>
|
||||
<el-segmented
|
||||
v-model="statusFilter"
|
||||
:options="statusOptions"
|
||||
data-testid="status-filter"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-skeleton v-if="isLoading && !types.length" :rows="4" animated data-testid="loading" />
|
||||
|
||||
<div v-else-if="!filteredTypes.length" class="empty-state" data-testid="empty-state">
|
||||
<el-empty :description="types.length ? t('admin.transferTypes.noMatch') : t('admin.transferTypes.empty')">
|
||||
<template v-if="!types.length">
|
||||
<p class="empty-hint">{{ t('admin.transferTypes.emptyHint') }}</p>
|
||||
<el-button type="primary" :icon="Plus" data-testid="empty-create" @click="openCreateDrawer">
|
||||
{{ t('admin.transferTypes.createType') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-button v-else data-testid="clear-filters" @click="clearFilters">
|
||||
{{ t('admin.transferTypes.clearFilters') }}
|
||||
</el-button>
|
||||
</el-empty>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
v-else
|
||||
v-loading="isLoading"
|
||||
:data="filteredTypes"
|
||||
:row-class-name="rowClassName"
|
||||
row-key="code"
|
||||
class="type-table"
|
||||
>
|
||||
<el-table-column prop="code" :label="t('admin.transferTypes.colCode')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<span class="code-cell">{{ row.code }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.transferTypes.colName')" min-width="200">
|
||||
<template #default="{ row }">{{ row.names?.['zh-CN'] || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.transferTypes.colRules')" width="120">
|
||||
<template #default="{ row, $index }">
|
||||
<el-tag
|
||||
v-if="row.scope_rules?.length"
|
||||
:data-testid="`rule-count-${$index}`"
|
||||
size="small"
|
||||
>{{ row.scope_rules.length }}</el-tag>
|
||||
<el-tag
|
||||
v-else
|
||||
:data-testid="`rule-count-${$index}`"
|
||||
size="small"
|
||||
type="info"
|
||||
effect="plain"
|
||||
>{{ t('admin.transferTypes.noRules') }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.transferTypes.colStatus')" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.enabled ? 'success' : 'info'" size="small">
|
||||
{{ row.enabled ? t('admin.transferTypes.enabled') : t('admin.transferTypes.disabled') }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="t('admin.transferTypes.colActions')" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
:icon="Edit"
|
||||
data-testid="edit-type"
|
||||
@click="openEditDrawer(row)"
|
||||
>{{ t('admin.transferTypes.edit') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-drawer
|
||||
v-model="drawerOpen"
|
||||
:title="drawerTitle"
|
||||
size="640px"
|
||||
resizable
|
||||
:before-close="requestClose"
|
||||
destroy-on-close
|
||||
class="type-drawer"
|
||||
data-testid="type-drawer"
|
||||
>
|
||||
<el-form class="editor-form" label-position="top" @submit.prevent>
|
||||
<!-- 提交失败顶部错误摘要:role=alert、可聚焦,条目锚点跳到对应字段(行内错误保留) -->
|
||||
<div
|
||||
v-if="errorSummary.length"
|
||||
id="tt-error-summary"
|
||||
class="error-summary"
|
||||
role="alert"
|
||||
tabindex="-1"
|
||||
data-testid="error-summary"
|
||||
>
|
||||
<strong>{{ t('admin.transferTypes.errorSummaryTitle') }}</strong>
|
||||
<ul>
|
||||
<li v-for="item in errorSummary" :key="item.key">
|
||||
<button v-if="item.targetId" type="button" class="error-anchor" @click="focusField(item.key)">
|
||||
{{ item.message }}
|
||||
</button>
|
||||
<span v-else>{{ item.message }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- ① 基本信息 -->
|
||||
<h4 class="section-title">{{ t('admin.transferTypes.sectionBasic') }}</h4>
|
||||
<div class="basic-grid">
|
||||
<el-form-item
|
||||
:label="t('admin.transferTypes.codeLabel')"
|
||||
required
|
||||
:validate-status="fieldErrors.code ? 'error' : ''"
|
||||
>
|
||||
<el-input
|
||||
id="tt-code"
|
||||
v-model="form.code"
|
||||
:disabled="Boolean(editingCode)"
|
||||
:aria-invalid="fieldErrors.code ? 'true' : undefined"
|
||||
aria-describedby="tt-error-code"
|
||||
data-testid="type-code"
|
||||
@blur="validateField('code')"
|
||||
@input="clearFieldError('code')"
|
||||
/>
|
||||
<small v-if="!editingCode" class="field-hint">{{ t('admin.transferTypes.codeImmutableHint') }}</small>
|
||||
<p v-if="fieldErrors.code" id="tt-error-code" class="field-error" data-testid="code-error">
|
||||
{{ fieldErrors.code }}
|
||||
</p>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
:label="t('admin.transferTypes.nameZhCnLabel')"
|
||||
required
|
||||
:validate-status="fieldErrors.name ? 'error' : ''"
|
||||
>
|
||||
<el-input
|
||||
id="tt-name"
|
||||
v-model="form.nameZhCn"
|
||||
:aria-invalid="fieldErrors.name ? 'true' : undefined"
|
||||
aria-describedby="tt-error-name"
|
||||
data-testid="name-zh-CN"
|
||||
@blur="validateField('name')"
|
||||
@input="clearFieldError('name')"
|
||||
/>
|
||||
<p v-if="fieldErrors.name" id="tt-error-name" class="field-error" data-testid="name-error">
|
||||
{{ fieldErrors.name }}
|
||||
</p>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-collapse v-model="otherNamesOpen" class="other-names">
|
||||
<el-collapse-item :title="t('admin.transferTypes.otherNames')" name="otherNames">
|
||||
<div class="basic-grid">
|
||||
<el-form-item :label="t('admin.transferTypes.nameZhTwLabel')">
|
||||
<el-input v-model="form.nameZhTw" data-testid="name-zh-TW" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.transferTypes.nameEnLabel')">
|
||||
<el-input v-model="form.nameEn" data-testid="name-en" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.transferTypes.nameThLabel')">
|
||||
<el-input v-model="form.nameTh" data-testid="name-th" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
<div class="basic-grid">
|
||||
<el-form-item :label="t('admin.transferTypes.sortLabel')">
|
||||
<el-input-number v-model="form.sortOrder" :min="0" data-testid="sort-order" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('admin.transferTypes.enabledLabel')">
|
||||
<el-switch v-model="form.enabled" data-testid="enabled-switch" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<!-- ② 范围规则(规则间=且,规则内多值=或);重叠仅黄条提示不拦截(D10) -->
|
||||
<h4 class="section-title">{{ t('admin.transferTypes.sectionScope') }}</h4>
|
||||
<el-alert
|
||||
:title="t('admin.transferTypes.scopeHint')"
|
||||
type="info"
|
||||
:closable="false"
|
||||
class="section-alert"
|
||||
/>
|
||||
<el-alert
|
||||
v-if="overlapCodes.length"
|
||||
:title="t('admin.transferTypes.overlapWarning', { codes: overlapCodes.join('、') })"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
class="section-alert"
|
||||
data-testid="scope-overlap-warning"
|
||||
/>
|
||||
<div
|
||||
v-for="(rule, index) in form.scopeRules"
|
||||
:key="`scope-rule-${index}`"
|
||||
class="scope-rule-row"
|
||||
:data-testid="`scope-rule-row-${index}`"
|
||||
>
|
||||
<div :id="`tt-scope-field-${index}`" tabindex="-1" class="rule-cell">
|
||||
<el-form-item
|
||||
:label="t('admin.transferTypes.fieldLabel')"
|
||||
:validate-status="fieldErrors[`scope-field-${index}`] ? 'error' : ''"
|
||||
>
|
||||
<el-select
|
||||
v-model="rule.field"
|
||||
:placeholder="t('admin.transferTypes.chooseField')"
|
||||
:aria-invalid="fieldErrors[`scope-field-${index}`] ? 'true' : undefined"
|
||||
:aria-describedby="fieldErrors[`scope-field-${index}`] ? `tt-error-scope-field-${index}` : undefined"
|
||||
:data-testid="`scope-field-${index}`"
|
||||
@change="clearFieldError(`scope-field-${index}`)"
|
||||
>
|
||||
<el-option
|
||||
v-for="field in TRANSFER_SCOPE_FIELDS"
|
||||
:key="field"
|
||||
:value="field"
|
||||
:label="t(`admin.transferTypes.scopeFieldLabels.${field}`)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<p
|
||||
v-if="fieldErrors[`scope-field-${index}`]"
|
||||
:id="`tt-error-scope-field-${index}`"
|
||||
class="field-error"
|
||||
:data-testid="`scope-field-error-${index}`"
|
||||
>
|
||||
{{ fieldErrors[`scope-field-${index}`] }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="rule-cell">
|
||||
<el-form-item :label="t('admin.transferTypes.matchLabel')">
|
||||
<el-select v-model="rule.match" :data-testid="`scope-match-${index}`">
|
||||
<el-option
|
||||
v-for="match in TRANSFER_SCOPE_MATCHES"
|
||||
:key="match"
|
||||
:value="match"
|
||||
:label="t(`admin.transferTypes.matchLabels.${match}`)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div
|
||||
:id="`tt-scope-values-${index}`"
|
||||
tabindex="-1"
|
||||
class="rule-cell rule-values"
|
||||
:data-testid="`scope-values-root-${index}`"
|
||||
>
|
||||
<el-form-item
|
||||
:label="t('admin.transferTypes.valuesLabel')"
|
||||
:validate-status="fieldErrors[`scope-values-${index}`] ? 'error' : ''"
|
||||
>
|
||||
<el-input-tag
|
||||
v-model="rule.values"
|
||||
:placeholder="t('admin.transferTypes.valuesPlaceholder')"
|
||||
:aria-invalid="fieldErrors[`scope-values-${index}`] ? 'true' : undefined"
|
||||
:aria-describedby="fieldErrors[`scope-values-${index}`] ? `tt-error-scope-values-${index}` : undefined"
|
||||
:data-testid="`scope-value-input-${index}`"
|
||||
@change="(values) => onScopeValuesChange(index, values)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<p
|
||||
v-if="fieldErrors[`scope-values-${index}`]"
|
||||
:id="`tt-error-scope-values-${index}`"
|
||||
class="field-error"
|
||||
:data-testid="`scope-values-error-${index}`"
|
||||
>
|
||||
{{ fieldErrors[`scope-values-${index}`] }}
|
||||
</p>
|
||||
</div>
|
||||
<el-button
|
||||
class="rule-remove"
|
||||
type="danger"
|
||||
link
|
||||
:icon="Delete"
|
||||
:aria-label="t('admin.transferTypes.removeRule')"
|
||||
:data-testid="`remove-scope-rule-${index}`"
|
||||
@click="removeScopeRule(index)"
|
||||
/>
|
||||
</div>
|
||||
<el-button :icon="Plus" data-testid="add-scope-rule" @click="addScopeRule">
|
||||
{{ t('admin.transferTypes.addScopeRule') }}
|
||||
</el-button>
|
||||
|
||||
<!-- ③ 仓库定义(拨出/拨入各一角色;映射档未命中仅黄色提示不拦截,D6) -->
|
||||
<h4 class="section-title">{{ t('admin.transferTypes.sectionWarehouse') }}</h4>
|
||||
<div
|
||||
v-for="role in (['from', 'to'] as const)"
|
||||
:key="role"
|
||||
class="warehouse-role"
|
||||
>
|
||||
<el-form-item :label="role === 'from' ? t('admin.transferTypes.warehouseFrom') : t('admin.transferTypes.warehouseTo')">
|
||||
<el-radio-group
|
||||
v-model="form.warehouse[role].mode"
|
||||
:data-testid="`warehouse-${role}-mode`"
|
||||
@change="clearFieldError(`warehouse-${role}-code`)"
|
||||
>
|
||||
<el-radio value="mapped">{{ t('admin.transferTypes.modeMapped') }}</el-radio>
|
||||
<el-radio value="fixed">{{ t('admin.transferTypes.modeFixed') }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<template v-if="form.warehouse[role].mode === 'fixed'">
|
||||
<div :id="`tt-warehouse-${role}-code`" tabindex="-1" class="rule-cell">
|
||||
<el-form-item
|
||||
:label="t('admin.transferTypes.fixedCodeLabel')"
|
||||
:validate-status="fieldErrors[`warehouse-${role}-code`] ? 'error' : ''"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.warehouse[role].warehouseCode"
|
||||
filterable
|
||||
allow-create
|
||||
default-first-option
|
||||
:placeholder="t('admin.transferTypes.fixedCodePlaceholder')"
|
||||
:aria-invalid="fieldErrors[`warehouse-${role}-code`] ? 'true' : undefined"
|
||||
:aria-describedby="fieldErrors[`warehouse-${role}-code`] ? `tt-error-warehouse-${role}-code` : undefined"
|
||||
:data-testid="`warehouse-${role}-code`"
|
||||
@blur="validateField(`warehouse-${role}-code`)"
|
||||
@change="clearFieldError(`warehouse-${role}-code`)"
|
||||
>
|
||||
<el-option
|
||||
v-for="code in warehouseOptions[role]"
|
||||
:key="code"
|
||||
:value="code"
|
||||
:label="code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<p
|
||||
v-if="fieldErrors[`warehouse-${role}-code`]"
|
||||
:id="`tt-error-warehouse-${role}-code`"
|
||||
class="field-error"
|
||||
:data-testid="`warehouse-${role}-code-error`"
|
||||
>
|
||||
{{ fieldErrors[`warehouse-${role}-code`] }}
|
||||
</p>
|
||||
</div>
|
||||
<el-form-item :label="t('admin.transferTypes.orgLabel')">
|
||||
<el-input
|
||||
v-model="form.warehouse[role].externalOrg"
|
||||
:data-testid="`warehouse-${role}-org`"
|
||||
/>
|
||||
<small class="field-hint">{{ t('admin.transferTypes.orgHint') }}</small>
|
||||
</el-form-item>
|
||||
<el-alert
|
||||
v-if="warehouseChecks[role] === 'ok'"
|
||||
:title="t('admin.transferTypes.mappingCheckOk')"
|
||||
type="success"
|
||||
:closable="false"
|
||||
class="mapping-check"
|
||||
:data-testid="`warehouse-${role}-check`"
|
||||
/>
|
||||
<el-alert
|
||||
v-else-if="warehouseChecks[role] === 'missing'"
|
||||
:title="t('admin.transferTypes.mappingCheckMissing')"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
class="mapping-check"
|
||||
:data-testid="`warehouse-${role}-check`"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- ④ 转换规则(受控词表:当前仅批号前缀替换) -->
|
||||
<h4 class="section-title">{{ t('admin.transferTypes.sectionTransform') }}</h4>
|
||||
<div
|
||||
v-for="(rule, index) in form.transformRules"
|
||||
:key="`transform-${index}`"
|
||||
class="transform-row"
|
||||
:data-testid="`transform-row-${index}`"
|
||||
>
|
||||
<div class="rule-cell">
|
||||
<el-form-item :label="t('admin.transferTypes.transformField')">
|
||||
<el-select v-model="rule.field" :data-testid="`transform-field-${index}`">
|
||||
<el-option
|
||||
v-for="field in TRANSFORM_FIELDS"
|
||||
:key="field"
|
||||
:value="field"
|
||||
:label="t(`admin.transferTypes.transformFieldLabels.${field}`)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="rule-cell">
|
||||
<el-form-item :label="t('admin.transferTypes.transformOp')">
|
||||
<el-select v-model="rule.op" :data-testid="`transform-op-${index}`">
|
||||
<el-option
|
||||
v-for="op in TRANSFORM_OPS"
|
||||
:key="op"
|
||||
:value="op"
|
||||
:label="t(`admin.transferTypes.transformOpLabels.${op}`)"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div class="rule-cell">
|
||||
<el-form-item
|
||||
:label="t('admin.transferTypes.transformSource')"
|
||||
:validate-status="fieldErrors[`transform-source-${index}`] ? 'error' : ''"
|
||||
>
|
||||
<el-input
|
||||
:id="`tt-transform-source-${index}`"
|
||||
v-model="rule.source"
|
||||
:aria-invalid="fieldErrors[`transform-source-${index}`] ? 'true' : undefined"
|
||||
:aria-describedby="fieldErrors[`transform-source-${index}`] ? `tt-error-transform-source-${index}` : undefined"
|
||||
:data-testid="`transform-source-${index}`"
|
||||
@blur="validateField(`transform-source-${index}`)"
|
||||
@input="clearFieldError(`transform-source-${index}`)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<p
|
||||
v-if="fieldErrors[`transform-source-${index}`]"
|
||||
:id="`tt-error-transform-source-${index}`"
|
||||
class="field-error"
|
||||
:data-testid="`transform-source-error-${index}`"
|
||||
>
|
||||
{{ fieldErrors[`transform-source-${index}`] }}
|
||||
</p>
|
||||
</div>
|
||||
<span class="transform-arrow" aria-hidden="true">→</span>
|
||||
<div class="rule-cell">
|
||||
<el-form-item
|
||||
:label="t('admin.transferTypes.transformTarget')"
|
||||
:validate-status="fieldErrors[`transform-target-${index}`] ? 'error' : ''"
|
||||
>
|
||||
<el-input
|
||||
:id="`tt-transform-target-${index}`"
|
||||
v-model="rule.target"
|
||||
:aria-invalid="fieldErrors[`transform-target-${index}`] ? 'true' : undefined"
|
||||
:aria-describedby="fieldErrors[`transform-target-${index}`] ? `tt-error-transform-target-${index}` : undefined"
|
||||
:data-testid="`transform-target-${index}`"
|
||||
@blur="validateField(`transform-target-${index}`)"
|
||||
@input="clearFieldError(`transform-target-${index}`)"
|
||||
/>
|
||||
</el-form-item>
|
||||
<p
|
||||
v-if="fieldErrors[`transform-target-${index}`]"
|
||||
:id="`tt-error-transform-target-${index}`"
|
||||
class="field-error"
|
||||
:data-testid="`transform-target-error-${index}`"
|
||||
>
|
||||
{{ fieldErrors[`transform-target-${index}`] }}
|
||||
</p>
|
||||
</div>
|
||||
<el-button
|
||||
class="rule-remove"
|
||||
type="danger"
|
||||
link
|
||||
:icon="Delete"
|
||||
:aria-label="t('admin.transferTypes.removeTransform')"
|
||||
:data-testid="`remove-transform-rule-${index}`"
|
||||
@click="removeTransformRule(index)"
|
||||
/>
|
||||
</div>
|
||||
<el-button :icon="Plus" data-testid="add-transform-rule" @click="addTransformRule">
|
||||
{{ t('admin.transferTypes.addTransformRule') }}
|
||||
</el-button>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<div class="drawer-footer">
|
||||
<el-button data-testid="cancel-save" @click="requestClose">
|
||||
{{ t('admin.transferTypes.cancel') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="saving"
|
||||
data-testid="save-type"
|
||||
@click="save"
|
||||
>
|
||||
{{ saveButtonLabel }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 全宽布局:水平内边距由 AdminLayout 壳层统一持有,页面只保留内部块间距 */
|
||||
.transfer-types-page {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.page-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.page-heading h2 {
|
||||
margin: 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.page-subtitle {
|
||||
margin: 4px 0 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.list-toolbar {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: flex-end;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.toolbar-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.toolbar-search {
|
||||
min-width: 260px;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 24px 0;
|
||||
}
|
||||
|
||||
.empty-hint {
|
||||
margin: 0 0 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.code-cell {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 抽屉表单:分区标题 + 紧凑网格;控件外观统一走 element-trial 主题(暗色自动适配) */
|
||||
.section-title {
|
||||
margin: 8px 0 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
padding-top: 12px;
|
||||
}
|
||||
|
||||
.section-alert {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.basic-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0 16px;
|
||||
}
|
||||
|
||||
.other-names {
|
||||
margin-bottom: 4px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.other-names :deep(.el-collapse-item__header) {
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
border-bottom: 1px dashed var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.other-names :deep(.el-collapse-item__wrap) {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.error-summary {
|
||||
border: 1px solid var(--el-color-danger-light-5);
|
||||
background: var(--el-color-danger-light-9);
|
||||
color: var(--el-color-danger);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.error-summary ul {
|
||||
margin: 6px 0 0;
|
||||
padding-left: 18px;
|
||||
}
|
||||
|
||||
.error-anchor {
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: var(--el-color-danger);
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.field-hint {
|
||||
width: 100%;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.field-error {
|
||||
margin: 2px 0 8px;
|
||||
color: var(--el-color-danger);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.scope-rule-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(140px, 1.1fr) minmax(96px, 0.8fr) minmax(200px, 1.8fr) auto;
|
||||
gap: 0 10px;
|
||||
align-items: start;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
padding: 4px 12px 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.rule-cell :deep(.el-select),
|
||||
.rule-cell :deep(.el-input-tag),
|
||||
.rule-cell :deep(.el-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.rule-remove {
|
||||
align-self: center;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.warehouse-role {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
padding: 4px 12px 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.warehouse-role > .el-form-item {
|
||||
min-width: 220px;
|
||||
}
|
||||
|
||||
.mapping-check {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
/* 转换规则行:固定网格一行列完(字段/方式/原前缀/箭头/新前缀/删除),不再 flex 折行 */
|
||||
.transform-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(120px, 1.1fr) minmax(110px, 1fr) minmax(96px, 1fr) 20px minmax(96px, 1fr) auto;
|
||||
gap: 0 8px;
|
||||
align-items: start;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 8px;
|
||||
padding: 4px 12px 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.transform-row > .rule-cell {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.transform-arrow {
|
||||
text-align: center;
|
||||
padding-top: 32px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
/* 抽屉底部操作区:随 el-drawer footer 固定,长表单滚动时保存始终可见 */
|
||||
.drawer-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
</style>
|
||||
+631
@@ -0,0 +1,631 @@
|
||||
/**
|
||||
* features/admin/modules/transfer-types/__tests__/TransferTypesPage.spec.ts
|
||||
* 用途:锁定在途调拨「调拨类型」管理页的列表渲染、编辑抽屉四块(基本信息/范围规则/仓库定义/
|
||||
* 转换规则)、保存 payload 结构(规则间 AND)、onBlur 校验 + aria-describedby、顶部错误
|
||||
* 摘要锚点跳字段、保存 loading/成功/失败反馈、范围重叠与映射档未命中的黄色不拦截提示、
|
||||
* 空范围与未保存关闭的 ElMessageBox 显式确认、四语言 admin.json 键集一致与模块四处注册契约。
|
||||
* 依赖:@vue/test-utils、vitest、@/i18n、element-plus(组件断言与 ElMessageBox mock)、
|
||||
* transferTypes.api(mock)、constants/modules、admin.routes。
|
||||
* 逻辑:mock transferTypes.api 控制列表/写入返回;页面已迁移 Element Plus,DOM 交互按 EP
|
||||
* 组件结构适配(setValue 走组件 v-model、输入取内部 input、tag 取 el-input-tag 结构),
|
||||
* 行为断言(payload/错误摘要/aria 关联/黄色不拦截)与迁移前保持一致。
|
||||
*/
|
||||
import { enableAutoUnmount, flushPromises, mount, type VueWrapper } from '@vue/test-utils';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import i18n from '@/i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { config } from '@/config';
|
||||
import { ADMIN_MODULE_METAS } from '@/features/admin/constants/modules';
|
||||
import { adminRoutes } from '@/app/router/routes/admin.routes';
|
||||
import zhCnAdmin from '@/locales/zh-CN/admin.json';
|
||||
import zhTwAdmin from '@/locales/zh-TW/admin.json';
|
||||
import enAdmin from '@/locales/en/admin.json';
|
||||
import thAdmin from '@/locales/th/admin.json';
|
||||
import { TRANSFER_SCOPE_FIELDS } from '../transferTypes.api';
|
||||
import TransferTypesPage from '../TransferTypesPage.vue';
|
||||
|
||||
// el-table 布局依赖 ResizeObserver,jsdom 缺失需补齐桩实现
|
||||
class ResizeObserverStub {
|
||||
observe(): void {}
|
||||
|
||||
unobserve(): void {}
|
||||
|
||||
disconnect(): void {}
|
||||
}
|
||||
(globalThis as Record<string, unknown>).ResizeObserver
|
||||
= (globalThis as Record<string, unknown>).ResizeObserver || ResizeObserverStub;
|
||||
|
||||
const apiMocks = vi.hoisted(() => ({
|
||||
listTransferTypes: vi.fn(),
|
||||
createTransferType: vi.fn(),
|
||||
updateTransferType: vi.fn(),
|
||||
listExternalWarehouseMappings: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../transferTypes.api', async () => {
|
||||
const actual = await vi.importActual<Record<string, unknown>>('../transferTypes.api');
|
||||
return {
|
||||
...actual,
|
||||
listTransferTypes: apiMocks.listTransferTypes,
|
||||
createTransferType: apiMocks.createTransferType,
|
||||
updateTransferType: apiMocks.updateTransferType,
|
||||
listExternalWarehouseMappings: apiMocks.listExternalWarehouseMappings,
|
||||
};
|
||||
});
|
||||
|
||||
enableAutoUnmount(afterEach);
|
||||
|
||||
// EP 重型页面(表格+抽屉+20 余控件、attachTo 真实挂载)在全量并行渲染时较慢,放宽本文件超时
|
||||
vi.setConfig({ testTimeout: 20000 });
|
||||
|
||||
// ElMessageBox 默认拒绝(=取消),避免测试路径意外走进确认分支;需确认的用例再覆盖实现
|
||||
const mockMessageBoxCancel = (): void => {
|
||||
vi.spyOn(ElMessageBox, 'confirm').mockRejectedValue('cancelled');
|
||||
};
|
||||
|
||||
// ---- 测试夹具:两条类型(一条启用带 1 条范围规则,一条停用空规则) ----
|
||||
const mappedRole = { mode: 'mapped', warehouse_code: null, external_org: null };
|
||||
const rowEnabled = {
|
||||
code: 'in_transit_to_hub',
|
||||
names: { 'zh-CN': '在途仓至HUB仓' },
|
||||
enabled: true,
|
||||
sort_order: 10,
|
||||
scope_rules: [{ field: 'doc_no', match: 'prefix', values: ['HOM', 'HOX'] }],
|
||||
warehouse_config: { from: mappedRole, to: mappedRole },
|
||||
transform_rules: [],
|
||||
description: null,
|
||||
updated_at: '2026-10-13T00:00:00',
|
||||
};
|
||||
const rowDisabled = {
|
||||
code: 'hub_repair_out',
|
||||
names: { 'zh-CN': 'HUB仓维修出' },
|
||||
enabled: false,
|
||||
sort_order: 20,
|
||||
scope_rules: [],
|
||||
warehouse_config: { from: mappedRole, to: mappedRole },
|
||||
transform_rules: [],
|
||||
description: null,
|
||||
updated_at: null,
|
||||
};
|
||||
const mappingRows = [
|
||||
{ external_system_code: 'ERP', in_transit_warehouse_code: 'WH-TRANSIT-01', external_warehouse_code: 'WH-HUB', external_organization_code: 'ORG-1' },
|
||||
];
|
||||
|
||||
const mountPage = async () => {
|
||||
// attachTo:错误摘要锚点跳字段依赖 document.getElementById + focus,必须真实挂载
|
||||
const wrapper = mount(TransferTypesPage, { attachTo: document.body, global: { plugins: [i18n] } });
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
const openCreateDrawer = async (wrapper: VueWrapper) => {
|
||||
await wrapper.find('[data-testid="create-type"]').trigger('click');
|
||||
// 打开抽屉会异步懒加载仓库映射档(存在性校验数据源),统一冲刷后再断言
|
||||
await flushPromises();
|
||||
};
|
||||
|
||||
/** 取 EP 输入类组件的原生 input:el-input/el-input-tag 的 testid 直接落在 input 上,
|
||||
* el-input-number 的 testid 在根 div 上,两种落点统一兜底。 */
|
||||
const innerInput = (wrapper: VueWrapper, testId: string) => {
|
||||
const root = wrapper.find(`[data-testid="${testId}"]`);
|
||||
return root.element.tagName === 'INPUT' ? root : root.find('input');
|
||||
};
|
||||
|
||||
/** DIV 根组件(el-select/el-radio-group/el-segmented 等)的 v-model 赋值:
|
||||
* DOMWrapper.setValue 对 DIV 会抛错,必须走 VueWrapper 的 update:modelValue。 */
|
||||
const setControl = (wrapper: VueWrapper, testId: string, value: unknown) => (
|
||||
wrapper.getComponent(`[data-testid="${testId}"]`).setValue(value)
|
||||
);
|
||||
|
||||
/** 抽屉开关状态:el-drawer 关闭后面板节点仍留在 DOM(v-show),以 open class 为准。 */
|
||||
const isDrawerOpen = (wrapper: VueWrapper): boolean => {
|
||||
const panel = wrapper.find('[data-testid="type-drawer"]');
|
||||
return panel.exists() && panel.classes().includes('open');
|
||||
};
|
||||
|
||||
/**
|
||||
* 取字段的 aria-describedby 值:EP 组件的 aria 属性可能落在组件根或内部 input 上,
|
||||
* 逐层兜底,保证「错误文本与字段无障碍关联」这一行为契约与实现细节解耦。
|
||||
*/
|
||||
const getAriaDescribedBy = (wrapper: VueWrapper, testId: string): string | undefined => {
|
||||
const root = wrapper.find(`[data-testid="${testId}"]`);
|
||||
const fromRoot = root.attributes('aria-describedby');
|
||||
if (fromRoot) return fromRoot;
|
||||
const inner = root.find('[aria-describedby]');
|
||||
return inner.exists() ? inner.attributes('aria-describedby') : undefined;
|
||||
};
|
||||
|
||||
/** 读取 el-input-tag 中已提交的 tag 文本列表(tag 挂在字段容器下,是 input 的兄弟节点)。 */
|
||||
const scopeTagTexts = (wrapper: VueWrapper, index: number): string[] => (
|
||||
wrapper.find(`[data-testid="scope-values-root-${index}"]`).findAll('.el-tag')
|
||||
.map((tag) => tag.text().trim())
|
||||
);
|
||||
|
||||
/**
|
||||
* 在新建抽屉里填齐必填项并配置一条范围规则(field/match/value),供保存类测试复用。
|
||||
* 关键断言意图:value 通过「内部 input 输入 + Enter」提交为 tag,模拟真实多值编辑路径。
|
||||
*/
|
||||
const fillCreateFormWithRule = async (wrapper: VueWrapper, code = 'wtp_to_how') => {
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="type-code"]').setValue(code);
|
||||
await wrapper.find('[data-testid="name-zh-CN"]').setValue('WTP转HOW');
|
||||
await wrapper.find('[data-testid="add-scope-rule"]').trigger('click');
|
||||
await setControl(wrapper, 'scope-field-0', 'doc_no');
|
||||
await setControl(wrapper, 'scope-match-0', 'prefix');
|
||||
await innerInput(wrapper, 'scope-value-input-0').setValue('HOM');
|
||||
await innerInput(wrapper, 'scope-value-input-0').trigger('keydown.enter');
|
||||
await flushPromises();
|
||||
};
|
||||
|
||||
describe('TransferTypesPage 列表渲染', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockMessageBoxCancel();
|
||||
apiMocks.listTransferTypes.mockResolvedValue([rowEnabled, rowDisabled]);
|
||||
apiMocks.listExternalWarehouseMappings.mockResolvedValue(mappingRows);
|
||||
});
|
||||
|
||||
it('渲染列表行:编码/名称/规则数/状态/编辑', async () => {
|
||||
const wrapper = await mountPage();
|
||||
const rows = wrapper.findAll('tr.type-row');
|
||||
// 关键断言:两行数据齐全,启用行规则数=1、状态=启用;停用行零规则显示「无规则」tag、状态=停用
|
||||
expect(rows).toHaveLength(2);
|
||||
expect(rows[0].text()).toContain('in_transit_to_hub');
|
||||
expect(rows[0].text()).toContain('在途仓至HUB仓');
|
||||
expect(rows[0].find('[data-testid="rule-count-0"]').text()).toBe('1');
|
||||
expect(rows[0].text()).toContain('启用');
|
||||
expect(rows[1].find('[data-testid="rule-count-1"]').text()).toBe('无规则');
|
||||
expect(rows[1].text()).toContain('停用');
|
||||
expect(wrapper.findAll('[data-testid="edit-type"]')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('空列表渲染空态:消息 + 新建类型行动按钮', async () => {
|
||||
// 关键断言:空态必须「消息+行动」成对出现(可用性规则⑤)
|
||||
apiMocks.listTransferTypes.mockResolvedValue([]);
|
||||
const wrapper = await mountPage();
|
||||
const empty = wrapper.find('[data-testid="empty-state"]');
|
||||
expect(empty.exists()).toBe(true);
|
||||
expect(empty.text()).toContain('暂无调拨类型');
|
||||
expect(empty.find('[data-testid="empty-create"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('筛选无结果空态与无数据空态区分,清除筛选可恢复列表', async () => {
|
||||
const wrapper = await mountPage();
|
||||
// 关键断言:搜索无命中时给出「无匹配 + 清除筛选」出路(不产生死胡同)
|
||||
await wrapper.find('[data-testid="search-input"]').setValue('不存在的关键字');
|
||||
expect(wrapper.find('[data-testid="empty-state"]').text()).toContain('无匹配的调拨类型');
|
||||
await wrapper.find('[data-testid="clear-filters"]').trigger('click');
|
||||
expect(wrapper.findAll('tr.type-row')).toHaveLength(2);
|
||||
expect(wrapper.find('[data-testid="empty-state"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('搜索编码/名称与状态筛选联动过滤列表', async () => {
|
||||
const wrapper = await mountPage();
|
||||
// 按中文名称搜索「维修」只命中停用行
|
||||
await wrapper.find('[data-testid="search-input"]').setValue('维修');
|
||||
expect(wrapper.findAll('tr.type-row')).toHaveLength(1);
|
||||
expect(wrapper.find('tr.type-row').text()).toContain('hub_repair_out');
|
||||
// 状态筛选=启用 时清空搜索,只命中启用行
|
||||
await wrapper.find('[data-testid="search-input"]').setValue('');
|
||||
await setControl(wrapper, 'status-filter', 'enabled');
|
||||
expect(wrapper.findAll('tr.type-row')).toHaveLength(1);
|
||||
expect(wrapper.find('tr.type-row').text()).toContain('in_transit_to_hub');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferTypesPage 编辑抽屉基础块', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockMessageBoxCancel();
|
||||
apiMocks.listTransferTypes.mockResolvedValue([rowEnabled, rowDisabled]);
|
||||
apiMocks.listExternalWarehouseMappings.mockResolvedValue(mappingRows);
|
||||
});
|
||||
|
||||
it('编辑态打开抽屉:dialog 语义、编码只读且回显、名称四语言输入框齐全', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await wrapper.findAll('[data-testid="edit-type"]')[0].trigger('click');
|
||||
await flushPromises();
|
||||
const dialog = wrapper.find('[data-testid="type-drawer"]');
|
||||
// 关键断言:抽屉是 dialog 且编码创建后不可变(disabled + 回显)
|
||||
expect(dialog.exists()).toBe(true);
|
||||
expect(dialog.attributes('role')).toBe('dialog');
|
||||
const code = innerInput(wrapper, 'type-code');
|
||||
expect(code.exists()).toBe(true);
|
||||
expect((code.element as HTMLInputElement).disabled).toBe(true);
|
||||
expect((code.element as HTMLInputElement).value).toBe('in_transit_to_hub');
|
||||
// 名称四语言(zh-CN 必填)+ 排序 + 启用开关(其余语言折叠渲染但存在)
|
||||
for (const key of ['name-zh-CN', 'name-zh-TW', 'name-en', 'name-th']) {
|
||||
expect(wrapper.find(`[data-testid="${key}"]`).exists()).toBe(true);
|
||||
}
|
||||
expect((innerInput(wrapper, 'name-zh-CN').element as HTMLInputElement).value).toBe('在途仓至HUB仓');
|
||||
expect((innerInput(wrapper, 'sort-order').element as HTMLInputElement).value).toBe('10');
|
||||
// aria-checked 由 EP 渲染在内部 role=switch 元素上
|
||||
expect(wrapper.find('[data-testid="enabled-switch"] [role="switch"]').attributes('aria-checked')).toBe('true');
|
||||
});
|
||||
|
||||
it('抽屉原生 resizable:渲染拖拽手柄且拖动后宽度变化', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
const panel = wrapper.find('[data-testid="type-drawer"]');
|
||||
expect(panel.attributes('style')).toContain('width: 640px');
|
||||
const dragger = wrapper.find('.el-drawer__dragger');
|
||||
// 关键断言:原生 dragger 存在,mousedown + 向左 mousemove 后宽度脱离默认值
|
||||
//(jsdom 无布局,EP 以 offsetWidth 为起点,这里不断言精确尺寸只验证联动生效)
|
||||
expect(dragger.exists()).toBe(true);
|
||||
await dragger.trigger('mousedown', { clientX: 800, pageY: 300 });
|
||||
window.dispatchEvent(new MouseEvent('mousemove', { clientX: 720, pageY: 300 }));
|
||||
window.dispatchEvent(new MouseEvent('mouseup'));
|
||||
await flushPromises();
|
||||
const styleAfter = panel.attributes('style') || '';
|
||||
expect(styleAfter).toContain('width:');
|
||||
expect(styleAfter).not.toContain('width: 640px');
|
||||
});
|
||||
|
||||
it('仓库定义 mode 切换:fixed 才显示仓库编码与法人覆盖输入', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
// 关键断言:默认映射档不渲染固定仓库输入;切 fixed 出现,切回 mapped 消失
|
||||
expect(wrapper.find('[data-testid="warehouse-from-code"]').exists()).toBe(false);
|
||||
await setControl(wrapper, 'warehouse-from-mode', 'fixed');
|
||||
expect(wrapper.find('[data-testid="warehouse-from-code"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="warehouse-from-org"]').exists()).toBe(true);
|
||||
await setControl(wrapper, 'warehouse-from-mode', 'mapped');
|
||||
expect(wrapper.find('[data-testid="warehouse-from-code"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('映射档存在性校验:命中=成功提示、未命中=黄色警告提示,且均不拦截保存', async () => {
|
||||
// 本测试聚焦仓库校验,不放范围规则;空范围确认放行(默认拒绝语义不在此验证)
|
||||
vi.spyOn(ElMessageBox, 'confirm').mockResolvedValue('confirm');
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="type-code"]').setValue('wtp_to_how');
|
||||
await wrapper.find('[data-testid="name-zh-CN"]').setValue('WTP转HOW');
|
||||
await setControl(wrapper, 'warehouse-from-mode', 'fixed');
|
||||
// 未命中:黄色提示但不拦截
|
||||
await setControl(wrapper, 'warehouse-from-code', 'WH-REPAIR');
|
||||
const missing = wrapper.find('[data-testid="warehouse-from-check"]');
|
||||
expect(missing.exists()).toBe(true);
|
||||
expect(missing.text()).toContain('映射档未找到');
|
||||
// 拨入仓命中:成功提示
|
||||
await setControl(wrapper, 'warehouse-to-mode', 'fixed');
|
||||
await setControl(wrapper, 'warehouse-to-code', 'WH-HUB');
|
||||
expect(wrapper.find('[data-testid="warehouse-to-check"]').text()).toContain('映射档已包含');
|
||||
// 关键断言:映射档未命中不拦截保存(D6/D10),payload 固定仓 + 法人覆盖正确
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(apiMocks.createTransferType).toHaveBeenCalledTimes(1);
|
||||
const payload = apiMocks.createTransferType.mock.calls[0][0];
|
||||
expect(payload.warehouse_config.from).toEqual({ mode: 'fixed', warehouse_code: 'WH-REPAIR', external_org: null });
|
||||
expect(payload.warehouse_config.to).toEqual({ mode: 'fixed', warehouse_code: 'WH-HUB', external_org: null });
|
||||
// 法人覆盖非空时透传
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="type-code"]').setValue('wtp_to_how2');
|
||||
await wrapper.find('[data-testid="name-zh-CN"]').setValue('WTP转HOW2');
|
||||
await setControl(wrapper, 'warehouse-from-mode', 'fixed');
|
||||
await setControl(wrapper, 'warehouse-from-code', 'WH-REPAIR');
|
||||
await wrapper.find('[data-testid="warehouse-from-org"]').setValue('ORG-X');
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(apiMocks.createTransferType.mock.calls[1][0].warehouse_config.from).toEqual({ mode: 'fixed', warehouse_code: 'WH-REPAIR', external_org: 'ORG-X' });
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferTypesPage 范围规则与转换规则编辑器', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockMessageBoxCancel();
|
||||
apiMocks.listTransferTypes.mockResolvedValue([rowEnabled, rowDisabled]);
|
||||
apiMocks.listExternalWarehouseMappings.mockResolvedValue(mappingRows);
|
||||
});
|
||||
|
||||
it('添加规则:字段下拉=受控词表 18 项、匹配四选一、值输入 Enter 生成 tag', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="add-scope-rule"]').trigger('click');
|
||||
const fieldOptions = wrapper.getComponent('[data-testid="scope-field-0"]')
|
||||
.findAllComponents({ name: 'ElOption' });
|
||||
// 关键断言:后端受控词表 18 字段(占位走 placeholder 不再占 option),label 走 i18n(收料单号等)
|
||||
expect(fieldOptions).toHaveLength(TRANSFER_SCOPE_FIELDS.length);
|
||||
const optionLabels = fieldOptions.map((option) => String(option.props('label')));
|
||||
expect(optionLabels).toContain('收料单号');
|
||||
expect(optionLabels).toContain('供应商·客户编号');
|
||||
const matchLabels = wrapper.getComponent('[data-testid="scope-match-0"]')
|
||||
.findAllComponents({ name: 'ElOption' })
|
||||
.map((option) => String(option.props('label')));
|
||||
expect(matchLabels).toEqual(['前缀', '等于', '包含', '属于']);
|
||||
// Enter 提交 tag;逗号分隔多值拆分且重复值去重
|
||||
await setControl(wrapper, 'scope-field-0', 'doc_no');
|
||||
await innerInput(wrapper, 'scope-value-input-0').setValue('HOM');
|
||||
await innerInput(wrapper, 'scope-value-input-0').trigger('keydown.enter');
|
||||
await flushPromises();
|
||||
expect(scopeTagTexts(wrapper, 0)).toEqual(['HOM']);
|
||||
await innerInput(wrapper, 'scope-value-input-0').setValue('HOM, HOX');
|
||||
await innerInput(wrapper, 'scope-value-input-0').trigger('keydown.enter');
|
||||
await flushPromises();
|
||||
expect(scopeTagTexts(wrapper, 0)).toEqual(['HOM', 'HOX']);
|
||||
});
|
||||
|
||||
it('tag 可通过关闭按钮删除', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="add-scope-rule"]').trigger('click');
|
||||
await setControl(wrapper, 'scope-field-0', 'doc_no');
|
||||
await innerInput(wrapper, 'scope-value-input-0').setValue('HOM');
|
||||
await innerInput(wrapper, 'scope-value-input-0').trigger('keydown.enter');
|
||||
await flushPromises();
|
||||
const remove = wrapper.find('[data-testid="scope-values-root-0"] .el-tag__close');
|
||||
// 关键断言:tag 自带可访问的删除按钮,删除后 tag 消失
|
||||
expect(remove.exists()).toBe(true);
|
||||
await remove.trigger('click');
|
||||
await flushPromises();
|
||||
expect(scopeTagTexts(wrapper, 0)).toEqual([]);
|
||||
});
|
||||
|
||||
it('失焦提交值草稿为 tag;清空全部值后行内报错并 aria-describedby 关联', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="add-scope-rule"]').trigger('click');
|
||||
await setControl(wrapper, 'scope-field-0', 'doc_no');
|
||||
// 失焦提交草稿(el-input-tag save-on-blur 默认开启)→ 有值不报错
|
||||
await innerInput(wrapper, 'scope-value-input-0').setValue('HOM');
|
||||
await innerInput(wrapper, 'scope-value-input-0').trigger('blur');
|
||||
await flushPromises();
|
||||
expect(scopeTagTexts(wrapper, 0)).toEqual(['HOM']);
|
||||
expect(wrapper.find('[data-testid="scope-values-error-0"]').exists()).toBe(false);
|
||||
// 关键断言:删掉唯一 tag → 行内错误立即出现,aria-describedby 指向错误元素 id
|
||||
await wrapper.find('[data-testid="scope-values-root-0"] .el-tag__close').trigger('click');
|
||||
await flushPromises();
|
||||
const error = wrapper.find('[data-testid="scope-values-error-0"]');
|
||||
expect(error.exists()).toBe(true);
|
||||
expect(getAriaDescribedBy(wrapper, 'scope-value-input-0')).toBe(error.attributes('id'));
|
||||
});
|
||||
|
||||
it('保存 payload:scope_rules 为规则对象数组(规则间 AND),多值为 OR 数组', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await fillCreateFormWithRule(wrapper);
|
||||
// 第二条规则(规则间 AND)
|
||||
await wrapper.find('[data-testid="add-scope-rule"]').trigger('click');
|
||||
await setControl(wrapper, 'scope-field-1', 'source_code');
|
||||
await setControl(wrapper, 'scope-match-1', 'in');
|
||||
await innerInput(wrapper, 'scope-value-input-1').setValue('SRC-A, SRC-B');
|
||||
await innerInput(wrapper, 'scope-value-input-1').trigger('keydown.enter');
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
// 关键断言:payload.scope_rules 保序两条规则,多值成数组(或关系),即 AND-of-OR 结构
|
||||
expect(apiMocks.createTransferType).toHaveBeenCalledTimes(1);
|
||||
const payload = apiMocks.createTransferType.mock.calls[0][0];
|
||||
expect(payload.scope_rules).toEqual([
|
||||
{ field: 'doc_no', match: 'prefix', values: ['HOM'] },
|
||||
{ field: 'source_code', match: 'in', values: ['SRC-A', 'SRC-B'] },
|
||||
]);
|
||||
expect(payload.code).toBe('wtp_to_how');
|
||||
expect(payload.names['zh-CN']).toBe('WTP转HOW');
|
||||
expect(payload.enabled).toBe(true);
|
||||
expect(payload.sort_order).toBe(10);
|
||||
expect(payload.warehouse_config.from).toEqual({ mode: 'mapped', warehouse_code: null, external_org: null });
|
||||
});
|
||||
|
||||
it('编辑保存走 PUT,转换规则行可添加并写入 payload', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await wrapper.findAll('[data-testid="edit-type"]')[0].trigger('click');
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="add-transform-rule"]').trigger('click');
|
||||
expect(wrapper.find('[data-testid="transform-row-0"]').exists()).toBe(true);
|
||||
await wrapper.find('[data-testid="transform-source-0"]').setValue('WTP');
|
||||
await wrapper.find('[data-testid="transform-target-0"]').setValue('HOW');
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
// 关键断言:编辑态走 updateTransferType(code 不可变),转换规则含字段/方式/前后缀
|
||||
expect(apiMocks.updateTransferType).toHaveBeenCalledTimes(1);
|
||||
expect(apiMocks.updateTransferType.mock.calls[0][0]).toBe('in_transit_to_hub');
|
||||
expect(apiMocks.updateTransferType.mock.calls[0][1].transform_rules).toEqual([
|
||||
{ field: 'lot_no', op: 'prefix_replace', source: 'WTP', target: 'HOW' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('范围重叠:与其它启用类型字段+值有交集时黄条列出冲突编码,但不拦截保存', async () => {
|
||||
const wrapper = await mountPage();
|
||||
// doc_no 值 HOM 与启用行 rowEnabled 的 [HOM, HOX] 有交集(匹配方式不同也提示)
|
||||
await fillCreateFormWithRule(wrapper);
|
||||
const warning = wrapper.find('[data-testid="scope-overlap-warning"]');
|
||||
expect(warning.exists()).toBe(true);
|
||||
expect(warning.text()).toContain('in_transit_to_hub');
|
||||
// 关键断言:重叠仅黄条提示,保存照常提交(D10)
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(apiMocks.createTransferType).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('编辑自身不与自身重叠;与停用类型不提示', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await wrapper.findAll('[data-testid="edit-type"]')[0].trigger('click');
|
||||
await flushPromises();
|
||||
// 自身规则就是 [HOM, HOX],编辑自身不应把自身算入冲突
|
||||
expect(wrapper.find('[data-testid="scope-overlap-warning"]').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferTypesPage 校验、错误摘要与保存反馈', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockMessageBoxCancel();
|
||||
apiMocks.listTransferTypes.mockResolvedValue([rowEnabled, rowDisabled]);
|
||||
apiMocks.listExternalWarehouseMappings.mockResolvedValue(mappingRows);
|
||||
});
|
||||
|
||||
it('onBlur 校验:编码必填/格式错误在字段正下方展示并 aria-describedby 关联', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="type-code"]').setValue('');
|
||||
await innerInput(wrapper, 'type-code').trigger('blur');
|
||||
const error = wrapper.find('[data-testid="code-error"]');
|
||||
// 关键断言:行内错误(非只弹 toast)且 aria-describedby 指向错误元素 id
|
||||
expect(error.exists()).toBe(true);
|
||||
expect(getAriaDescribedBy(wrapper, 'type-code')).toBe(error.attributes('id'));
|
||||
await wrapper.find('[data-testid="type-code"]').setValue('ABC');
|
||||
await innerInput(wrapper, 'type-code').trigger('blur');
|
||||
expect(wrapper.find('[data-testid="code-error"]').text()).toContain('小写字母');
|
||||
});
|
||||
|
||||
it('zh-CN 名称 onBlur 必填校验', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="name-zh-CN"]').setValue('');
|
||||
await innerInput(wrapper, 'name-zh-CN').trigger('blur');
|
||||
expect(wrapper.find('[data-testid="name-error"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('提交失败渲染顶部错误摘要(role=alert),锚点跳到对应字段且行内错误保留', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
const summary = wrapper.find('[data-testid="error-summary"]');
|
||||
// 关键断言:错误摘要 role=alert 顶部呈现(可用性规则②)
|
||||
expect(summary.exists()).toBe(true);
|
||||
expect(summary.attributes('role')).toBe('alert');
|
||||
expect(summary.text()).toContain('请输入调拨类型编码');
|
||||
// 点击摘要条目 → 焦点跳到编码输入框;行内错误保留
|
||||
await summary.find('button').trigger('click');
|
||||
expect(document.activeElement).toBe(innerInput(wrapper, 'type-code').element);
|
||||
expect(wrapper.find('[data-testid="code-error"]').exists()).toBe(true);
|
||||
expect(apiMocks.createTransferType).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('保存按钮 loading 反馈:请求挂起时显示保存中并禁用', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await fillCreateFormWithRule(wrapper);
|
||||
apiMocks.createTransferType.mockImplementation(() => new Promise(() => {}));
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
const save = wrapper.find('[data-testid="save-type"]');
|
||||
// 关键断言:loading 态文案切换 + 禁用防重复提交(可用性规则③;EP 以 aria-disabled/is-loading 表达)
|
||||
expect(save.text()).toContain('保存中');
|
||||
expect(save.classes()).toContain('is-loading');
|
||||
expect(save.attributes('aria-disabled')).toBe('true');
|
||||
});
|
||||
|
||||
it('保存成功:提示反馈、抽屉关闭并刷新列表', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await fillCreateFormWithRule(wrapper);
|
||||
apiMocks.createTransferType.mockResolvedValue({ ...rowEnabled, code: 'wtp_to_how' });
|
||||
expect(apiMocks.listTransferTypes).toHaveBeenCalledTimes(1);
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
// 关键断言:成功后抽屉关闭 + 列表重新拉取(成功反馈)
|
||||
expect(isDrawerOpen(wrapper)).toBe(false);
|
||||
expect(apiMocks.listTransferTypes).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('保存失败:BusinessError 文案进入顶部摘要,抽屉保留可改', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await fillCreateFormWithRule(wrapper);
|
||||
apiMocks.createTransferType.mockRejectedValue(
|
||||
new BusinessError({ message: '调拨类型编码已存在。', code: 'TRANSFER.TRANSFER_TYPE_CODE_EXISTS' }),
|
||||
);
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
// 关键断言:失败后抽屉不关闭、错误码本地化文案进摘要(四语言 errors.json 契约)
|
||||
expect(isDrawerOpen(wrapper)).toBe(true);
|
||||
expect(wrapper.find('[data-testid="error-summary"]').text()).toContain('编码已存在');
|
||||
expect((wrapper.find('[data-testid="save-type"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('空范围规则保存需显式确认:拒绝不发请求,确认则携带 allow_empty_scope_rules', async () => {
|
||||
const confirmSpy = vi.spyOn(ElMessageBox, 'confirm');
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="type-code"]').setValue('no_scope');
|
||||
await wrapper.find('[data-testid="name-zh-CN"]').setValue('无范围类型');
|
||||
confirmSpy.mockRejectedValueOnce('cancelled');
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
// 关键断言:拒绝确认 → 不发请求(对齐后端 fail-closed 门禁)
|
||||
expect(confirmSpy).toHaveBeenCalledTimes(1);
|
||||
expect(apiMocks.createTransferType).not.toHaveBeenCalled();
|
||||
confirmSpy.mockResolvedValueOnce('confirm');
|
||||
await wrapper.find('[data-testid="save-type"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(apiMocks.createTransferType).toHaveBeenCalledTimes(1);
|
||||
expect(apiMocks.createTransferType.mock.calls[0][0].allow_empty_scope_rules).toBe(true);
|
||||
});
|
||||
|
||||
it('有未保存改动时关闭抽屉需确认:取消留在抽屉,确认后关闭', async () => {
|
||||
const confirmSpy = vi.spyOn(ElMessageBox, 'confirm');
|
||||
const wrapper = await mountPage();
|
||||
await openCreateDrawer(wrapper);
|
||||
// 未做任何修改:脏检测为假,直接关,不弹确认
|
||||
await wrapper.find('[data-testid="cancel-save"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(confirmSpy).not.toHaveBeenCalled();
|
||||
expect(isDrawerOpen(wrapper)).toBe(false);
|
||||
// 有改动:取消确认 → 抽屉保留不丢数据
|
||||
await openCreateDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="type-code"]').setValue('dirty_close');
|
||||
confirmSpy.mockRejectedValueOnce('cancelled');
|
||||
await wrapper.find('[data-testid="cancel-save"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(confirmSpy).toHaveBeenCalledTimes(1);
|
||||
expect(isDrawerOpen(wrapper)).toBe(true);
|
||||
// 确认放弃 → 抽屉关闭
|
||||
confirmSpy.mockResolvedValueOnce('confirm');
|
||||
await wrapper.find('[data-testid="cancel-save"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(isDrawerOpen(wrapper)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferTypesPage i18n 与模块注册契约', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockMessageBoxCancel();
|
||||
apiMocks.listTransferTypes.mockResolvedValue([]);
|
||||
apiMocks.listExternalWarehouseMappings.mockResolvedValue([]);
|
||||
});
|
||||
|
||||
it('四个 locale 的 admin.json transferTypes 键集一致且含模块/导航键', () => {
|
||||
// 关键断言:四语言键集完全一致(i18n 红线),导航键与页面标题键齐备
|
||||
const flatKeys = (obj: unknown, prefix = ''): string[] => {
|
||||
if (obj === null || typeof obj !== 'object') return prefix ? [prefix] : [];
|
||||
return Object.entries(obj as Record<string, unknown>)
|
||||
.flatMap(([key, value]) => flatKeys(value, prefix ? `${prefix}.${key}` : key))
|
||||
.sort();
|
||||
};
|
||||
const base = flatKeys(zhCnAdmin.transferTypes);
|
||||
expect(base.length).toBeGreaterThan(30);
|
||||
expect(flatKeys(zhTwAdmin.transferTypes)).toEqual(base);
|
||||
expect(flatKeys(enAdmin.transferTypes)).toEqual(base);
|
||||
expect(flatKeys(thAdmin.transferTypes)).toEqual(base);
|
||||
for (const messages of [zhCnAdmin, zhTwAdmin, enAdmin, thAdmin] as const) {
|
||||
expect(String((messages.nav as Record<string, unknown>).transferTypes)).toBeTruthy();
|
||||
expect(String((messages.transferTypes as Record<string, unknown>).title)).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
it('范围规则字段标签覆盖后端受控词表 18 字段(zh-CN)', () => {
|
||||
// 关键断言:受控词表逐字段有标签且不多不少(后端引擎校验,前端下拉固定 18 项)
|
||||
const labels = zhCnAdmin.transferTypes.scopeFieldLabels as Record<string, string>;
|
||||
expect(Object.keys(labels)).toHaveLength(TRANSFER_SCOPE_FIELDS.length);
|
||||
TRANSFER_SCOPE_FIELDS.forEach((field) => {
|
||||
expect(labels[field]).toBeTruthy();
|
||||
});
|
||||
expect(labels.doc_no).toBe('收料单号');
|
||||
expect(labels.source_code).toBe('收料来源实例');
|
||||
expect(labels.partner_code).toBe('供应商·客户编号');
|
||||
});
|
||||
|
||||
it('模块注册四处齐全:meta / 路由 / config 开关 / 导航标签', () => {
|
||||
// 关键断言:AdminModuleId 注册表、深链路由、config 开关、导航 labelKey 四处一致
|
||||
const meta = ADMIN_MODULE_METAS.find((item) => item.id === 'transfer_types');
|
||||
expect(meta).toEqual(expect.objectContaining({
|
||||
routeName: 'AdminTransferTypes',
|
||||
path: 'transfer-types',
|
||||
labelKey: 'admin.nav.transferTypes',
|
||||
configKey: 'transfer_types',
|
||||
}));
|
||||
const route = adminRoutes[0].children?.find((item) => item.name === 'AdminTransferTypes');
|
||||
expect(route?.path).toBe('transfer-types');
|
||||
expect(route?.meta).toEqual(expect.objectContaining({ requiresAdmin: true, adminModule: 'transfer_types' }));
|
||||
expect(config.admin.modules.transfer_types).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* features/admin/modules/transfer-types/transferTypes.api.ts
|
||||
* 用途:在途调拨「调拨类型」管理 API 客户端(列表/创建/更新),附仓库映射档查询
|
||||
* (固定仓库存在性黄色提示用)与范围/转换规则受控词表常量(ADR 0002 类型配置化)。
|
||||
* 依赖:@/shared/api/client(requestJson / BusinessError)。
|
||||
* 逻辑:薄封装 /api/admin/in-transit-transfer/transfer-types*;错误码(TRANSFER.*)
|
||||
* 由 requestJson 解析为四语言 errors.json 文案后以 BusinessError 抛出。
|
||||
* 词表常量与后端 scope_rules.SCOPE_FIELDS / field_transforms 保持一致,后端仍会兜底校验。
|
||||
*/
|
||||
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
|
||||
const BASE = '/api/admin/in-transit-transfer';
|
||||
|
||||
/** 范围规则字段受控词表(与后端 SCOPE_FIELDS 一致;下拉固定 18 项,新增须同步后端)。 */
|
||||
export const TRANSFER_SCOPE_FIELDS = [
|
||||
'source_code', 'doc_no', 'warehouse_code', 'storage_code', 'lot_no',
|
||||
'movement_date', 'record_kind', 'in_out_flag', 'order_type', 'odm_id',
|
||||
'odm_name', 'carton_id', 'pallet_id', 'material_code', 'doc_nature',
|
||||
'movement_type', 'reason_code', 'partner_code',
|
||||
] as const;
|
||||
|
||||
/** 匹配方式受控词表(与后端 _MATCHES 一致)。 */
|
||||
export const TRANSFER_SCOPE_MATCHES = ['prefix', 'equals', 'contains', 'in'] as const;
|
||||
|
||||
/** 转换规则字段/方式受控词表(与后端 TRANSFORM_FIELDS / TRANSFORM_OPS 一致)。 */
|
||||
export const TRANSFORM_FIELDS = ['lot_no'] as const;
|
||||
export const TRANSFORM_OPS = ['prefix_replace'] as const;
|
||||
|
||||
export type TransferScopeField = (typeof TRANSFER_SCOPE_FIELDS)[number];
|
||||
export type TransferScopeMatch = (typeof TRANSFER_SCOPE_MATCHES)[number];
|
||||
|
||||
/** 单条范围规则:规则间 AND,规则内 values 为 OR。 */
|
||||
export interface TransferScopeRule {
|
||||
field: string;
|
||||
match: string;
|
||||
values: string[];
|
||||
}
|
||||
|
||||
/** 仓库角色:mapped 沿用映射档;fixed 覆盖仓库编码,external_org 非空才覆盖法人。 */
|
||||
export interface TransferWarehouseRole {
|
||||
mode: 'mapped' | 'fixed';
|
||||
warehouse_code: string | null;
|
||||
external_org: string | null;
|
||||
}
|
||||
|
||||
/** 单条字段转换规则(当前仅批号前缀替换)。 */
|
||||
export interface TransferTransformRule {
|
||||
field: string;
|
||||
op: string;
|
||||
source: string;
|
||||
target: string;
|
||||
}
|
||||
|
||||
/** 创建/更新 payload(code 创建后不可变;空范围规则需显式 allow_empty_scope_rules)。 */
|
||||
export interface TransferTypePayload {
|
||||
code: string;
|
||||
names: Record<string, string>;
|
||||
enabled: boolean;
|
||||
sort_order: number;
|
||||
scope_rules: TransferScopeRule[];
|
||||
warehouse_config: { from: TransferWarehouseRole; to: TransferWarehouseRole };
|
||||
transform_rules: TransferTransformRule[];
|
||||
allow_empty_scope_rules?: boolean;
|
||||
}
|
||||
|
||||
/** 管理端类型配置全量视图(列表与写响应同形)。 */
|
||||
export interface TransferTypeRow {
|
||||
code: string;
|
||||
names: Record<string, string>;
|
||||
enabled: boolean;
|
||||
sort_order: number;
|
||||
scope_rules: TransferScopeRule[];
|
||||
warehouse_config: { from: TransferWarehouseRole; to: TransferWarehouseRole };
|
||||
transform_rules: TransferTransformRule[];
|
||||
description: string | null;
|
||||
updated_at: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全量类型配置(含停用),sort_order 升序——管理页列表数据源。
|
||||
* @returns 类型配置数组
|
||||
*/
|
||||
export const listTransferTypes = () =>
|
||||
requestJson<TransferTypeRow[]>(`${BASE}/transfer-types`);
|
||||
|
||||
/**
|
||||
* 创建类型配置。
|
||||
* @param payload - 表单规范化后的完整 payload
|
||||
* @returns 新建的类型配置(后端 201)
|
||||
* @throws BusinessError 重复编码 → 422 TRANSFER.TRANSFER_TYPE_CODE_EXISTS 等本地化错误
|
||||
*/
|
||||
export const createTransferType = (payload: TransferTypePayload) =>
|
||||
requestJson<TransferTypeRow>(`${BASE}/transfer-types`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
/**
|
||||
* 更新类型配置(code 不可变,由路径携带)。
|
||||
* @param code - 类型编码(业务主键)
|
||||
* @param payload - 表单规范化后的完整 payload
|
||||
* @returns 更新后的类型配置
|
||||
* @throws BusinessError 目标不存在 → 404 TRANSFER.TRANSFER_TYPE_NOT_CONFIGURED 等
|
||||
*/
|
||||
export const updateTransferType = (code: string, payload: TransferTypePayload) =>
|
||||
requestJson<TransferTypeRow>(`${BASE}/transfer-types/${encodeURIComponent(code)}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
/**
|
||||
* 拉取货代库存外部仓库映射档,仅用于固定仓库编码的存在性黄色提示校验。
|
||||
* 核心逻辑:请求 /api/admin/freight-rpa/onhand/external-mappings;失败时返回空数组,不阻断类型配置。
|
||||
* @returns 映射行数组;请求失败返回空数组(校验静默降级为「未命中」语义之外的不提示)
|
||||
*/
|
||||
export const listExternalWarehouseMappings = async (): Promise<Array<Record<string, unknown>>> => {
|
||||
try {
|
||||
return await requestJson<Array<Record<string, unknown>>>('/api/admin/freight-rpa/onhand/external-mappings');
|
||||
} catch {
|
||||
// 校验属辅助提示,加载失败不影响配置主流程
|
||||
return [];
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,527 @@
|
||||
/**
|
||||
* features/admin/modules/transfer-types/useTransferTypesAdmin.ts
|
||||
* 用途:调拨类型管理页的状态与动作编排——列表筛选排序、编辑抽屉表单、onBlur 校验、
|
||||
* 顶部错误摘要、范围重叠提示、映射档存在性校验与保存流程(ADR 0002 类型配置化)。
|
||||
* 依赖:transferTypes.api、useMessage、vue-i18n、element-plus(ElMessageBox)。
|
||||
* 逻辑:TransferTypesPage 调用本 composable 驱动列表与抽屉。校验失败时行内错误
|
||||
* (el-form-item :error 承接)+ 顶部错误摘要(role=alert,锚点跳字段);范围重叠与
|
||||
* 固定仓库未命中映射档仅黄色提示、不拦截保存(D10/D6);关抽屉前做脏检测,有未保存
|
||||
* 改动经 ElMessageBox 确认;空范围规则保存前经 ElMessageBox 显式确认后携带
|
||||
* allow_empty_scope_rules(对齐后端 fail-closed 门禁)。
|
||||
*/
|
||||
|
||||
import { computed, nextTick, reactive, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
createTransferType,
|
||||
listExternalWarehouseMappings,
|
||||
listTransferTypes,
|
||||
updateTransferType,
|
||||
type TransferScopeRule,
|
||||
type TransferTransformRule,
|
||||
type TransferTypeRow,
|
||||
type TransferWarehouseRole,
|
||||
} from './transferTypes.api';
|
||||
|
||||
/** code 契约:小写字母开头,仅小写字母/数字/下划线,总长 2..64(与后端 CODE_PATTERN 一致)。 */
|
||||
const CODE_PATTERN = /^[a-z][a-z0-9_]{1,63}$/;
|
||||
|
||||
/** 仓库角色表单态(mapped 时固定仓/法人字段不参与提交)。 */
|
||||
export interface TransferWarehouseRoleForm {
|
||||
mode: 'mapped' | 'fixed';
|
||||
warehouseCode: string;
|
||||
externalOrg: string;
|
||||
}
|
||||
|
||||
/** 编辑抽屉表单态(names 拆四语言字段便于逐输入框绑定)。 */
|
||||
export interface TransferTypeFormState {
|
||||
code: string;
|
||||
nameZhCn: string;
|
||||
nameZhTw: string;
|
||||
nameEn: string;
|
||||
nameTh: string;
|
||||
enabled: boolean;
|
||||
sortOrder: number;
|
||||
scopeRules: TransferScopeRule[];
|
||||
warehouse: { from: TransferWarehouseRoleForm; to: TransferWarehouseRoleForm };
|
||||
transformRules: TransferTransformRule[];
|
||||
}
|
||||
|
||||
/** 新建空表单:默认启用、排序 10、双角色映射档。 */
|
||||
export const createEmptyTransferTypeForm = (): TransferTypeFormState => ({
|
||||
code: '',
|
||||
nameZhCn: '',
|
||||
nameZhTw: '',
|
||||
nameEn: '',
|
||||
nameTh: '',
|
||||
enabled: true,
|
||||
sortOrder: 10,
|
||||
scopeRules: [],
|
||||
warehouse: {
|
||||
from: { mode: 'mapped', warehouseCode: '', externalOrg: '' },
|
||||
to: { mode: 'mapped', warehouseCode: '', externalOrg: '' },
|
||||
},
|
||||
transformRules: [],
|
||||
});
|
||||
|
||||
/** 后端仓库角色 JSON → 表单态。 */
|
||||
const roleToForm = (role?: TransferWarehouseRole): TransferWarehouseRoleForm => ({
|
||||
mode: role?.mode === 'fixed' ? 'fixed' : 'mapped',
|
||||
warehouseCode: role?.warehouse_code || '',
|
||||
externalOrg: role?.external_org || '',
|
||||
});
|
||||
|
||||
/** 列表行 → 抽屉表单态(深拷贝规则数组,避免编辑直接改列表数据)。 */
|
||||
export const rowToForm = (row: TransferTypeRow): TransferTypeFormState => ({
|
||||
code: row.code,
|
||||
nameZhCn: row.names?.['zh-CN'] || '',
|
||||
nameZhTw: row.names?.['zh-TW'] || '',
|
||||
nameEn: row.names?.en || '',
|
||||
nameTh: row.names?.th || '',
|
||||
enabled: row.enabled,
|
||||
sortOrder: row.sort_order,
|
||||
scopeRules: (row.scope_rules || []).map((rule) => ({
|
||||
field: rule.field,
|
||||
match: rule.match,
|
||||
values: [...(rule.values || [])],
|
||||
})),
|
||||
warehouse: {
|
||||
from: roleToForm(row.warehouse_config?.from),
|
||||
to: roleToForm(row.warehouse_config?.to),
|
||||
},
|
||||
transformRules: (row.transform_rules || []).map((rule) => ({ ...rule })),
|
||||
});
|
||||
|
||||
/** 错误摘要条目:key 同时是字段 DOM 元素 id(tt-<key>)与行内错误键。 */
|
||||
export interface TransferTypeErrorItem {
|
||||
key: string;
|
||||
targetId: string | null;
|
||||
message: string;
|
||||
}
|
||||
|
||||
/** 映射档存在性校验结果:idle=不适用 / ok=命中 / missing=未命中(仅黄色提示)。 */
|
||||
export type MappingCheckState = 'idle' | 'ok' | 'missing';
|
||||
|
||||
/**
|
||||
* 调拨类型管理页 composable。
|
||||
* @returns 列表/筛选/抽屉/校验/保存全部状态与动作,供 TransferTypesPage 模板绑定
|
||||
*/
|
||||
export function useTransferTypesAdmin() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const types = ref<TransferTypeRow[]>([]);
|
||||
const isLoading = ref(false);
|
||||
const saving = ref(false);
|
||||
const search = ref('');
|
||||
const statusFilter = ref<'all' | 'enabled' | 'disabled'>('all');
|
||||
|
||||
const drawerOpen = ref(false);
|
||||
const editingCode = ref<string | null>(null);
|
||||
const form = reactive<TransferTypeFormState>(createEmptyTransferTypeForm());
|
||||
const fieldErrors = reactive<Record<string, string>>({});
|
||||
const errorSummary = ref<TransferTypeErrorItem[]>([]);
|
||||
/** 打开抽屉时的表单快照(JSON 串),用于关闭前脏检测。 */
|
||||
const formSnapshot = ref('');
|
||||
|
||||
/** 记录当前表单快照(openCreate/openEdit 装填完成后调用)。 */
|
||||
const snapshotForm = (): void => {
|
||||
formSnapshot.value = JSON.stringify(form);
|
||||
};
|
||||
|
||||
/** 仓库映射档缓存(打开抽屉时懒加载一次),用于固定仓存在性提示与编码候选项。 */
|
||||
const mappings = ref<Array<Record<string, unknown>>>([]);
|
||||
let mappingsRequested = false;
|
||||
|
||||
/** 表单相对打开快照是否有未保存改动(仅抽屉打开期间有意义)。 */
|
||||
const isFormDirty = computed(() => drawerOpen.value && formSnapshot.value !== JSON.stringify(form));
|
||||
|
||||
/** 列表过滤:编码/任意语言名称命中关键字 + 启停状态筛选,按 sort_order 升序、编码次序稳定排序。 */
|
||||
const filteredTypes = computed(() => {
|
||||
const keyword = search.value.trim().toLowerCase();
|
||||
return types.value.filter((row) => {
|
||||
if (statusFilter.value === 'enabled' && !row.enabled) return false;
|
||||
if (statusFilter.value === 'disabled' && row.enabled) return false;
|
||||
if (!keyword) return true;
|
||||
const names = Object.values(row.names || {}).join(' ').toLowerCase();
|
||||
return row.code.toLowerCase().includes(keyword) || names.includes(keyword);
|
||||
})
|
||||
.sort((a, b) => (a.sort_order - b.sort_order) || a.code.localeCompare(b.code));
|
||||
});
|
||||
|
||||
/**
|
||||
* 固定仓编码候选项(来自映射档缓存):拨出仓取映射档在途仓、拨入仓取映射仓,去重升序,
|
||||
* 供 el-select 可搜索下拉(allow-create 保留自由输入兜底)。
|
||||
*/
|
||||
const warehouseOptions = computed<{ from: string[]; to: string[] }>(() => {
|
||||
const collect = (key: string) => {
|
||||
const set = new Set<string>();
|
||||
mappings.value.forEach((row) => {
|
||||
const value = String(row[key] ?? '').trim();
|
||||
if (value) set.add(value);
|
||||
});
|
||||
return [...set].sort((a, b) => a.localeCompare(b));
|
||||
};
|
||||
return { from: collect('in_transit_warehouse_code'), to: collect('external_warehouse_code') };
|
||||
});
|
||||
|
||||
/**
|
||||
* 范围重叠客户端比对(保存前后常驻):当前规则与「其它启用类型」同字段且值有交集
|
||||
* 即列出对方编码;仅黄色提示,不拦截保存(D10)。编辑自身不计入。
|
||||
*/
|
||||
const overlapCodes = computed(() => {
|
||||
const mine = form.scopeRules.filter((rule) => rule.field && rule.values.length);
|
||||
if (!mine.length) return [];
|
||||
const upperValues = (values: string[]) => values.map((value) => value.trim().toUpperCase());
|
||||
return types.value
|
||||
.filter((row) => row.enabled && row.code !== editingCode.value)
|
||||
.filter((row) => (row.scope_rules || []).some((other) =>
|
||||
mine.some((rule) => rule.field === other.field
|
||||
&& upperValues(rule.values).some((value) => upperValues(other.values || []).includes(value)))))
|
||||
.map((row) => row.code);
|
||||
});
|
||||
|
||||
/** 打开抽屉时懒加载映射档(失败静默为空表,存在性提示退化为不展示)。 */
|
||||
const ensureMappings = async (): Promise<void> => {
|
||||
if (mappingsRequested) return;
|
||||
mappingsRequested = true;
|
||||
mappings.value = await listExternalWarehouseMappings();
|
||||
};
|
||||
|
||||
/**
|
||||
* 固定仓库编码存在性校验:拨出仓比对映射档在途仓、拨入仓比对映射仓;
|
||||
* mapped 模式或未填编码返回 idle(不提示)。
|
||||
*/
|
||||
const warehouseCheckFor = (role: 'from' | 'to'): MappingCheckState => {
|
||||
const cfg = form.warehouse[role];
|
||||
if (cfg.mode !== 'fixed' || !cfg.warehouseCode.trim()) return 'idle';
|
||||
const code = cfg.warehouseCode.trim().toUpperCase();
|
||||
const hit = mappings.value.some((row) => {
|
||||
const candidate = role === 'from' ? row.in_transit_warehouse_code : row.external_warehouse_code;
|
||||
return String(candidate ?? '').trim().toUpperCase() === code;
|
||||
});
|
||||
return hit ? 'ok' : 'missing';
|
||||
};
|
||||
|
||||
const warehouseChecks = computed<{ from: MappingCheckState; to: MappingCheckState }>(
|
||||
() => ({ from: warehouseCheckFor('from'), to: warehouseCheckFor('to') }),
|
||||
);
|
||||
|
||||
const loadTypes = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
try {
|
||||
types.value = await listTransferTypes();
|
||||
} catch (error) {
|
||||
console.error('Failed to load transfer types', error);
|
||||
msg.error(
|
||||
error instanceof BusinessError ? error.message : t('admin.transferTypes.loadFailed'),
|
||||
t('admin.transferTypes.loadFailedTitle'),
|
||||
);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 单字段校验(onBlur 触发):按 key 前缀分发到编码/名称/范围规则/固定仓/转换规则。
|
||||
* @param key - 错误键,同时是字段元素 id(tt-<key>)
|
||||
*/
|
||||
const validateField = (key: string): void => {
|
||||
let message = '';
|
||||
if (key === 'code' && !editingCode.value) {
|
||||
const code = form.code.trim();
|
||||
if (!code) message = t('admin.transferTypes.errors.codeRequired');
|
||||
else if (!CODE_PATTERN.test(code)) message = t('admin.transferTypes.errors.codeFormat');
|
||||
} else if (key === 'name') {
|
||||
if (!form.nameZhCn.trim()) message = t('admin.transferTypes.errors.nameRequired');
|
||||
} else if (key.startsWith('scope-field-')) {
|
||||
const index = Number(key.slice('scope-field-'.length));
|
||||
if (!form.scopeRules[index]?.field) message = t('admin.transferTypes.errors.ruleFieldRequired');
|
||||
} else if (key.startsWith('scope-values-')) {
|
||||
const index = Number(key.slice('scope-values-'.length));
|
||||
if (form.scopeRules[index] && !form.scopeRules[index].values.length) {
|
||||
message = t('admin.transferTypes.errors.ruleValuesRequired');
|
||||
}
|
||||
} else if (key === 'warehouse-from-code' || key === 'warehouse-to-code') {
|
||||
const role = key === 'warehouse-from-code' ? 'from' : 'to';
|
||||
if (form.warehouse[role].mode === 'fixed' && !form.warehouse[role].warehouseCode.trim()) {
|
||||
message = t('admin.transferTypes.errors.fixedCodeRequired');
|
||||
}
|
||||
} else if (key.startsWith('transform-source-') || key.startsWith('transform-target-')) {
|
||||
const index = Number(key.split('-').pop());
|
||||
const rule = form.transformRules[index];
|
||||
if (rule) {
|
||||
if (key.startsWith('transform-source-') && !rule.source.trim()) {
|
||||
message = t('admin.transferTypes.errors.transformSourceRequired');
|
||||
}
|
||||
if (key.startsWith('transform-target-') && !rule.target.trim()) {
|
||||
message = t('admin.transferTypes.errors.transformTargetRequired');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (message) fieldErrors[key] = message;
|
||||
else delete fieldErrors[key];
|
||||
};
|
||||
|
||||
/** 输入时清除该字段行内错误,避免打字过程残留旧错误。 */
|
||||
const clearFieldError = (key: string): void => {
|
||||
delete fieldErrors[key];
|
||||
};
|
||||
|
||||
/** 关抽屉/重开表单时清空全部行内错误与顶部摘要。 */
|
||||
const resetErrors = (): void => {
|
||||
Object.keys(fieldErrors).forEach((key) => delete fieldErrors[key]);
|
||||
errorSummary.value = [];
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存前全量校验:收集全部错误写回 fieldErrors(行内保留)并生成摘要条目。
|
||||
* @returns 错误摘要数组(空 = 可提交)
|
||||
*/
|
||||
const collectErrors = (): TransferTypeErrorItem[] => {
|
||||
const errors: TransferTypeErrorItem[] = [];
|
||||
const push = (key: string, message: string) => {
|
||||
fieldErrors[key] = message;
|
||||
errors.push({ key, targetId: `tt-${key}`, message });
|
||||
};
|
||||
if (!editingCode.value) {
|
||||
const code = form.code.trim();
|
||||
if (!code) push('code', t('admin.transferTypes.errors.codeRequired'));
|
||||
else if (!CODE_PATTERN.test(code)) push('code', t('admin.transferTypes.errors.codeFormat'));
|
||||
}
|
||||
if (!form.nameZhCn.trim()) push('name', t('admin.transferTypes.errors.nameRequired'));
|
||||
form.scopeRules.forEach((rule, index) => {
|
||||
if (!rule.field) push(`scope-field-${index}`, t('admin.transferTypes.errors.ruleFieldRequired'));
|
||||
if (!rule.values.length) push(`scope-values-${index}`, t('admin.transferTypes.errors.ruleValuesRequired'));
|
||||
});
|
||||
(['from', 'to'] as const).forEach((role) => {
|
||||
if (form.warehouse[role].mode === 'fixed' && !form.warehouse[role].warehouseCode.trim()) {
|
||||
push(`warehouse-${role}-code`, t('admin.transferTypes.errors.fixedCodeRequired'));
|
||||
}
|
||||
});
|
||||
form.transformRules.forEach((rule, index) => {
|
||||
if (!rule.source.trim()) push(`transform-source-${index}`, t('admin.transferTypes.errors.transformSourceRequired'));
|
||||
if (!rule.target.trim()) push(`transform-target-${index}`, t('admin.transferTypes.errors.transformTargetRequired'));
|
||||
});
|
||||
return errors;
|
||||
};
|
||||
|
||||
/** 表单态 → 后端 payload;mapped 角色规范化为空值(与后端读写对称)。 */
|
||||
const buildPayload = (allowEmptyScopeRules: boolean) => {
|
||||
const rolePayload = (role: TransferWarehouseRoleForm): TransferWarehouseRole => (
|
||||
role.mode === 'fixed'
|
||||
? { mode: 'fixed', warehouse_code: role.warehouseCode.trim(), external_org: role.externalOrg.trim() || null }
|
||||
: { mode: 'mapped', warehouse_code: null, external_org: null }
|
||||
);
|
||||
const names: Record<string, string> = {};
|
||||
if (form.nameZhCn.trim()) names['zh-CN'] = form.nameZhCn.trim();
|
||||
if (form.nameZhTw.trim()) names['zh-TW'] = form.nameZhTw.trim();
|
||||
if (form.nameEn.trim()) names.en = form.nameEn.trim();
|
||||
if (form.nameTh.trim()) names.th = form.nameTh.trim();
|
||||
return {
|
||||
code: form.code.trim(),
|
||||
names,
|
||||
enabled: form.enabled,
|
||||
sort_order: Number(form.sortOrder) || 0,
|
||||
scope_rules: form.scopeRules
|
||||
.filter((rule) => rule.field)
|
||||
.map((rule) => ({ field: rule.field, match: rule.match, values: [...rule.values] })),
|
||||
warehouse_config: { from: rolePayload(form.warehouse.from), to: rolePayload(form.warehouse.to) },
|
||||
transform_rules: form.transformRules
|
||||
.filter((rule) => rule.source.trim() && rule.target.trim())
|
||||
.map((rule) => ({ field: rule.field, op: rule.op, source: rule.source.trim(), target: rule.target.trim() })),
|
||||
...(allowEmptyScopeRules ? { allow_empty_scope_rules: true } : {}),
|
||||
};
|
||||
};
|
||||
|
||||
/** 摘要条目点击 → 焦点跳到对应字段(targetId 即元素 id)。 */
|
||||
const focusField = (key: string): void => {
|
||||
document.getElementById(`tt-${key}`)?.focus();
|
||||
};
|
||||
|
||||
const save = async (): Promise<void> => {
|
||||
// [STEP 1] 全量校验:失败时渲染顶部错误摘要(role=alert)并聚焦,行内错误保留,不发请求
|
||||
const errors = collectErrors();
|
||||
Object.keys(fieldErrors).forEach((key) => {
|
||||
if (!errors.some((item) => item.key === key)) delete fieldErrors[key];
|
||||
});
|
||||
errorSummary.value = errors;
|
||||
if (errors.length) {
|
||||
void nextTick(() => document.getElementById('tt-error-summary')?.focus());
|
||||
return;
|
||||
}
|
||||
// [STEP 2] 空范围规则需显式确认:后端 fail-closed 默认拒绝,确认后才携带 allow_empty_scope_rules
|
||||
let allowEmptyScopeRules = false;
|
||||
if (!form.scopeRules.length) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.transferTypes.emptyScopeConfirm'),
|
||||
t('admin.transferTypes.emptyScopeTitle'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
allowEmptyScopeRules = true;
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// [STEP 3] 提交:范围重叠/映射档未命中仅黄条提示,不在此拦截(D10/D6);失败落顶部摘要
|
||||
saving.value = true;
|
||||
try {
|
||||
const payload = buildPayload(allowEmptyScopeRules);
|
||||
if (editingCode.value) await updateTransferType(editingCode.value, payload);
|
||||
else await createTransferType(payload);
|
||||
msg.success(t('admin.transferTypes.saveSuccess'));
|
||||
drawerOpen.value = false;
|
||||
resetErrors();
|
||||
await loadTypes();
|
||||
} catch (error) {
|
||||
const message = error instanceof BusinessError ? error.message : t('admin.transferTypes.saveFailed');
|
||||
errorSummary.value = [{ key: 'request', targetId: null, message }];
|
||||
msg.error(message, t('admin.transferTypes.saveFailed'));
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 关闭请求:无未保存改动直接关;有改动先经 ElMessageBox 确认,放弃改动才关。
|
||||
* 供 el-drawer before-close(ESC/遮罩/×)与底部「取消」按钮共用;保存成功路径不经此函数。
|
||||
*/
|
||||
const requestClose = async (): Promise<void> => {
|
||||
if (!isFormDirty.value) {
|
||||
closeDrawer();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.transferTypes.unsavedConfirm'),
|
||||
t('admin.transferTypes.unsavedTitle'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
closeDrawer();
|
||||
};
|
||||
|
||||
const openCreate = (): void => {
|
||||
Object.assign(form, createEmptyTransferTypeForm());
|
||||
editingCode.value = null;
|
||||
resetErrors();
|
||||
snapshotForm();
|
||||
drawerOpen.value = true;
|
||||
void ensureMappings();
|
||||
};
|
||||
|
||||
const openEdit = (row: TransferTypeRow): void => {
|
||||
Object.assign(form, rowToForm(row));
|
||||
editingCode.value = row.code;
|
||||
resetErrors();
|
||||
snapshotForm();
|
||||
drawerOpen.value = true;
|
||||
void ensureMappings();
|
||||
};
|
||||
|
||||
const closeDrawer = (): void => {
|
||||
drawerOpen.value = false;
|
||||
resetErrors();
|
||||
};
|
||||
|
||||
/** 新增空范围规则(默认前缀匹配)。 */
|
||||
const addScopeRule = (): void => {
|
||||
form.scopeRules.push({ field: '', match: 'prefix', values: [] });
|
||||
};
|
||||
|
||||
const removeScopeRule = (index: number): void => {
|
||||
form.scopeRules.splice(index, 1);
|
||||
resetErrors();
|
||||
};
|
||||
|
||||
/**
|
||||
* el-input-tag 值变更归一:拆分逗号(中英文)/空白、去重后写回,保留「一次粘贴多值」体验;
|
||||
* 清空全部值时立即行内报错,非空则清除错误。
|
||||
* @param index - 范围规则行下标
|
||||
* @param values - el-input-tag 回传的原始值数组
|
||||
*/
|
||||
const onScopeValuesChange = (index: number, rawValues?: Array<string | number>): void => {
|
||||
const rule = form.scopeRules[index];
|
||||
if (!rule) return;
|
||||
const normalized: string[] = [];
|
||||
(rawValues ?? []).forEach((value) => {
|
||||
String(value)
|
||||
.split(/[,,\s]+/)
|
||||
.map((part) => part.trim())
|
||||
.filter(Boolean)
|
||||
.forEach((part) => {
|
||||
if (!normalized.includes(part)) normalized.push(part);
|
||||
});
|
||||
});
|
||||
rule.values = normalized;
|
||||
const key = `scope-values-${index}`;
|
||||
if (rule.values.length) delete fieldErrors[key];
|
||||
else fieldErrors[key] = t('admin.transferTypes.errors.ruleValuesRequired');
|
||||
};
|
||||
|
||||
/** 新增转换规则行(受控词表当前仅批号前缀替换)。 */
|
||||
const addTransformRule = (): void => {
|
||||
form.transformRules.push({ field: 'lot_no', op: 'prefix_replace', source: '', target: '' });
|
||||
};
|
||||
|
||||
const removeTransformRule = (index: number): void => {
|
||||
form.transformRules.splice(index, 1);
|
||||
};
|
||||
|
||||
const saveButtonLabel = computed(() => (
|
||||
saving.value ? t('admin.transferTypes.saving') : t('admin.transferTypes.save')
|
||||
));
|
||||
|
||||
return {
|
||||
// 列表
|
||||
types,
|
||||
isLoading,
|
||||
search,
|
||||
statusFilter,
|
||||
filteredTypes,
|
||||
loadTypes,
|
||||
// 抽屉与表单
|
||||
drawerOpen,
|
||||
editingCode,
|
||||
form,
|
||||
isFormDirty,
|
||||
openCreate,
|
||||
openEdit,
|
||||
closeDrawer,
|
||||
requestClose,
|
||||
// 校验与提示
|
||||
fieldErrors,
|
||||
errorSummary,
|
||||
overlapCodes,
|
||||
warehouseChecks,
|
||||
warehouseOptions,
|
||||
validateField,
|
||||
clearFieldError,
|
||||
focusField,
|
||||
// 范围规则编辑
|
||||
addScopeRule,
|
||||
removeScopeRule,
|
||||
onScopeValuesChange,
|
||||
// 转换规则编辑
|
||||
addTransformRule,
|
||||
removeTransformRule,
|
||||
// 保存
|
||||
saving,
|
||||
saveButtonLabel,
|
||||
save,
|
||||
};
|
||||
}
|
||||
@@ -7,11 +7,12 @@
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { adminRoutes } from '@/app/router/routes/admin.routes';
|
||||
import zhCnAdmin from '@/locales/zh-CN/admin.json';
|
||||
import { ADMIN_MODULE_METAS, SHIPPING_CONFIG_SUB_MODULE_METAS } from './constants/modules';
|
||||
import type { ShippingManagementGroupKey } from './stores/admin-nav.store';
|
||||
|
||||
const shippingRoutes = adminRoutes[0].children?.filter((route) =>
|
||||
route.name === 'AdminShippingInventory'
|
||||
route.name === 'AdminFreightRpa'
|
||||
|| route.name === 'AdminShippingFieldAssets'
|
||||
|| route.name === 'AdminShippingOrderSchema'
|
||||
|| route.name === 'AdminShippingIdentityRules'
|
||||
@@ -22,12 +23,20 @@ const shippingRoutes = adminRoutes[0].children?.filter((route) =>
|
||||
) ?? [];
|
||||
|
||||
describe('shipping configuration navigation contract', () => {
|
||||
it('exposes renamed freight RPA entry labels in zh-CN admin locale', () => {
|
||||
// 关键断言:管理端入口文案与规格一致(报表规则 / 来源站点 / 入站报表配置)。
|
||||
expect(zhCnAdmin.freightRpa.parsingProfiles).toBe('报表规则');
|
||||
expect(zhCnAdmin.freightRpa.sources).toBe('来源站点');
|
||||
expect(zhCnAdmin.freightRpa.inboundReportConfig).toBe('入站报表配置');
|
||||
expect(zhCnAdmin.freightRpa.outboundReportConfig).toBe('出站报表配置');
|
||||
});
|
||||
|
||||
it('keeps shipping management between schedules and announcements', () => {
|
||||
// 关键断言:货代管理必须保持在排程管理之后、公告管理之前,匹配后台约定的信息架构。
|
||||
const moduleIds = ADMIN_MODULE_METAS.map((item) => item.id);
|
||||
expect(moduleIds.slice(moduleIds.indexOf('schedules'), moduleIds.indexOf('announcements') + 1)).toEqual([
|
||||
'schedules',
|
||||
'shipping_inventory',
|
||||
'freight_rpa',
|
||||
'announcements',
|
||||
]);
|
||||
});
|
||||
@@ -40,16 +49,18 @@ describe('shipping configuration navigation contract', () => {
|
||||
{ id: 'order_document_profiles', routeName: 'AdminShippingOrderDocumentProfiles', path: 'shipping-order-document-profiles', labelKey: 'admin.nav.shippingOrderDocumentProfiles', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'identity_rules', routeName: 'AdminShippingIdentityRules', path: 'shipping-identity-rules', labelKey: 'admin.nav.shippingIdentityRules', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'order_extraction_runs', routeName: 'AdminShippingOrderExtractionRuns', path: 'shipping-order-extraction-runs', labelKey: 'admin.nav.shippingOrderExtractionRuns', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
{ id: 'inventory_fields', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.parsingProfiles', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'parsing' } },
|
||||
{ id: 'connections', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.connections', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'profiles' } },
|
||||
{ id: 'inventory_sites', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.sources', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'sources' } },
|
||||
{ id: 'warehouse_mappings', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.externalMappings', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'mappings' } },
|
||||
{ id: 'routing_rules', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.rules', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'rules' } },
|
||||
{ id: 'shipping_templates', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.excelTemplates', groupKey: 'admin.nav.shippingInventoryManagement', query: { section: 'templates' } },
|
||||
{ id: 'inventory_fields', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.parsingProfiles', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'parsing' } },
|
||||
{ id: 'connections', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.connections', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'profiles' } },
|
||||
{ id: 'inventory_sites', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.sources', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'sources' } },
|
||||
{ id: 'warehouse_mappings', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.externalMappings', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'mappings' } },
|
||||
{ id: 'routing_rules', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.rules', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'rules' } },
|
||||
// 调拨类型(原顶级入口移入,路由独立注册于 AdminTransferTypes,故不在 shippingRoutes 深链集合内)
|
||||
{ id: 'transfer_types', routeName: 'AdminTransferTypes', path: 'transfer-types', labelKey: 'admin.nav.transferTypes', groupKey: 'admin.nav.freightRpaManagement' },
|
||||
{ id: 'shipping_templates', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.excelTemplates', groupKey: 'admin.nav.freightRpaManagement', query: { section: 'templates' } },
|
||||
{ id: 'shipping_audit', routeName: 'AdminShippingAudit', path: 'shipping-audit', labelKey: 'admin.nav.shippingAudit', groupKey: 'admin.nav.shippingRunAudit' },
|
||||
{ id: 'process_gates', routeName: 'AdminShippingProcessGates', path: 'shipping-process-gates', labelKey: 'admin.nav.shippingProcessGates', groupKey: 'admin.nav.shippingRunAudit' },
|
||||
{ id: 'inventory_snapshots', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.snapshots', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'snapshots' } },
|
||||
{ id: 'export_records', routeName: 'AdminShippingInventory', path: 'shipping-notice', labelKey: 'admin.shippingInventory.exports', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'exports' } },
|
||||
{ id: 'inventory_snapshots', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.snapshots', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'snapshots' } },
|
||||
{ id: 'export_records', routeName: 'AdminFreightRpa', path: 'shipping-notice', labelKey: 'admin.freightRpa.exports', groupKey: 'admin.nav.shippingRunAudit', query: { section: 'exports' } },
|
||||
]);
|
||||
expect(shippingRoutes).toHaveLength(8);
|
||||
expect(shippingRoutes.some((route) => route.name === 'AdminShippingReviewSupervision')).toBe(false);
|
||||
@@ -60,7 +71,7 @@ describe('shipping configuration navigation contract', () => {
|
||||
const groups = [...new Set(SHIPPING_CONFIG_SUB_MODULE_METAS.map((item) => item.groupKey))] satisfies ShippingManagementGroupKey[];
|
||||
expect(groups).toEqual([
|
||||
'admin.nav.shippingOrderRecognition',
|
||||
'admin.nav.shippingInventoryManagement',
|
||||
'admin.nav.freightRpaManagement',
|
||||
'admin.nav.shippingRunAudit',
|
||||
]);
|
||||
});
|
||||
@@ -68,14 +79,14 @@ describe('shipping configuration navigation contract', () => {
|
||||
it('keeps all deep links behind the shared shipping inventory admin boundary', () => {
|
||||
// 关键断言:菜单可见性不是授权;所有页面均须保留 requiresAdmin 和共享模块权限标识。
|
||||
expect(shippingRoutes.map((route) => route.meta)).toEqual([
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'inventory' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'field_assets' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'order_schema' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'identity_rules' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'order_extraction_runs' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'shipping_audit' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'process_gates' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'shipping_inventory', adminSubModule: 'order_document_profiles' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'freight_rpa', adminSubModule: 'inventory' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'freight_rpa', adminSubModule: 'field_assets' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'freight_rpa', adminSubModule: 'order_schema' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'freight_rpa', adminSubModule: 'identity_rules' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'freight_rpa', adminSubModule: 'order_extraction_runs' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'freight_rpa', adminSubModule: 'shipping_audit' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'freight_rpa', adminSubModule: 'process_gates' }),
|
||||
expect.objectContaining({ requiresAdmin: true, adminModule: 'freight_rpa', adminSubModule: 'order_document_profiles' }),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -87,7 +98,7 @@ describe('shipping configuration navigation contract', () => {
|
||||
expect(editorRoute?.path).toBe('shipping-order-document-profiles/:profileCode/drafts/:profileId/edit');
|
||||
expect(editorRoute?.meta).toEqual(expect.objectContaining({
|
||||
requiresAdmin: true,
|
||||
adminModule: 'shipping_inventory',
|
||||
adminModule: 'freight_rpa',
|
||||
adminSubModule: 'order_document_profiles',
|
||||
}));
|
||||
});
|
||||
|
||||
@@ -17,10 +17,11 @@ export type AdminModuleId =
|
||||
| 'linked_services'
|
||||
| 'permissions'
|
||||
| 'platform_apps'
|
||||
| 'shipping_inventory'
|
||||
| 'freight_rpa'
|
||||
| 'procurement_contract'
|
||||
| 'training_config'
|
||||
| 'integration_connector'
|
||||
| 'transfer_types'
|
||||
| 'reports';
|
||||
|
||||
/** 货代管理领域下可由侧栏展示和高亮的稳定业务页面。 */
|
||||
@@ -37,6 +38,7 @@ export type ShippingConfigSubModuleId =
|
||||
| 'inventory_sites'
|
||||
| 'warehouse_mappings'
|
||||
| 'routing_rules'
|
||||
| 'transfer_types'
|
||||
| 'shipping_templates'
|
||||
| 'inventory_snapshots'
|
||||
| 'export_records';
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
/**
|
||||
* features/admin/views/AdminLayout.vue
|
||||
* 管理后台壳层:顶栏 + AdminNav + 子路由出口。
|
||||
* 逻辑:桌面端将导航与业务内容拆成独立纵向滚动区,任一侧滚动不会带动另一侧。
|
||||
* 依赖:AdminNav、admin-nav.store、AppHeaderTools。
|
||||
* 逻辑:桌面端导航与业务内容为独立纵向滚动区,任一侧滚动不带动另一侧。
|
||||
* 【间距所有权】布局间距统一由本壳层持有:导航↔内容 gap 16px(gap-4)、
|
||||
* 内容区左内边距 20px(md:pl-5,与外层 8px 栅格对齐),各业务页面根容器
|
||||
* 不得自带水平 padding / max-w 居中,页面只负责内部块间距与内容样式。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ArrowLeft } from 'lucide-vue-next';
|
||||
@@ -37,11 +41,11 @@ const navStore = useAdminNavStore();
|
||||
<AppHeaderTools />
|
||||
</header>
|
||||
|
||||
<main class="flex min-h-0 flex-1 w-full mx-auto flex-col gap-8 overflow-hidden px-4 py-6 md:flex-row md:items-stretch md:px-8 md:py-8">
|
||||
<main class="flex min-h-0 flex-1 w-full flex-col gap-4 overflow-hidden px-4 py-6 md:flex-row md:items-stretch md:px-8 md:py-8">
|
||||
<aside class="min-h-0 shrink-0 overflow-y-auto md:pr-1">
|
||||
<AdminNav />
|
||||
</aside>
|
||||
<section class="min-h-0 w-full flex-1 space-y-8 overflow-y-auto md:pr-1">
|
||||
<section class="min-h-0 w-full flex-1 space-y-8 overflow-y-auto md:pl-5 md:pr-1">
|
||||
<router-view />
|
||||
</section>
|
||||
</main>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('shipping API runtime entrypoints', () => {
|
||||
it('does not expose direct inventory match or Excel generation actions', () => {
|
||||
expect(Object.prototype.hasOwnProperty.call(shippingApi, 'matchWorkspaceShippingInventory')).toBe(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(shippingApi, 'matchWorkspaceShippingOnhand')).toBe(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(shippingApi, 'generateWorkspaceShippingExcel')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -60,7 +60,7 @@ import type {
|
||||
ShippingOrderReviewLlmSuggestionResponse,
|
||||
ShippingOrderReviewReparseResponse,
|
||||
ShippingOrderReviewRun,
|
||||
ShippingTaskInventoryCandidatesResponse,
|
||||
ShippingTaskOnhandCandidatesResponse,
|
||||
ShippingTaskUiState,
|
||||
} from '../types/shipping.api.types';
|
||||
|
||||
@@ -205,7 +205,7 @@ export const workspaceShippingNoticeExportUrl = (businessNo: string) =>
|
||||
`/api/workspace/shipping-notices/${encodeURIComponent(businessNo)}/export`;
|
||||
|
||||
/** 当前任务已关联库存快照的受控下载 URL;后端会再次校验任务归属与活动 link。 */
|
||||
export const workspaceShippingInventoryFileUrl = (taskNo: string) =>
|
||||
export const workspaceShippingOnhandFileUrl = (taskNo: string) =>
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/inventory-file`;
|
||||
|
||||
/** 当前任务指定明细匹配快照的受控下载 URL;文件号必须由行级投影提供。 */
|
||||
@@ -622,7 +622,7 @@ export const getWorkspaceTaskInventoryCandidates = (
|
||||
if (options?.version != null) params.set('version', String(options.version));
|
||||
if (options?.includeHistory != null) params.set('include_history', String(options.includeHistory));
|
||||
const query = params.toString();
|
||||
return requestJson<ShippingTaskInventoryCandidatesResponse>(
|
||||
return requestJson<ShippingTaskOnhandCandidatesResponse>(
|
||||
`/api/workspace/shipping-notice/tasks/${encodeURIComponent(taskNo)}/inventory-candidates${query ? `?${query}` : ''}`,
|
||||
);
|
||||
};
|
||||
@@ -1348,7 +1348,7 @@ export async function removeWorkspaceShippingNoticeLine(
|
||||
* @param file - 已按库存源发布方案导出的 xls/xlsx/csv 文件
|
||||
* @returns 库存解析与后续匹配结果
|
||||
*/
|
||||
export async function uploadWorkspaceShippingInventory(taskNo: string, file: File) {
|
||||
export async function uploadWorkspaceShippingOnhand(taskNo: string, file: File) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* 用途:锁定在途仓自动调拨 JSON POST 请求头契约——必须携带 Content-Type: application/json,
|
||||
* 否则后端 Flask request.get_json 解析不到 body,导致默认 source_codes=[] 返回 400;
|
||||
* 另锁定 D8 异步 202 契约(requestJson 对 200/202 均透传 envelope.data)与
|
||||
* D9 调拨单清单(GET /runs/{run_no} 返回体 orders 数组透传)。
|
||||
* D9 调拨单清单(GET /runs/{run_no} 返回体 orders 数组透传);
|
||||
* 当前归档重解析 POST /sources/{code}/reparse(body 仅 record_kind)。
|
||||
* 依赖:Vitest、vi.mock(@/shared/api/client)、transfer.api、getAuthHeaders。
|
||||
* 逻辑:POST(create/execute/cancel/retry/manual-close)断言 headers 含 application/json,
|
||||
* 且 body 序列化正确;GET/blob 端点不强制 Content-Type;
|
||||
@@ -28,7 +29,13 @@ vi.mock('@/shared/utils/auth', () => ({
|
||||
import {
|
||||
cancelTransferRun,
|
||||
createTransferMatching,
|
||||
downloadTransferInboundFiles,
|
||||
downloadTransferSourceFiles,
|
||||
executeTransferItems,
|
||||
listEvidenceFiles,
|
||||
reparseCurrentFile,
|
||||
retryTransferSourceRpa,
|
||||
retryTransferSourcesRpaBatch,
|
||||
getTransferBacklogSummary,
|
||||
getTransferMatching,
|
||||
getTransferRun,
|
||||
@@ -52,6 +59,63 @@ describe('transfer.api JSON request contract', () => {
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], business_date: '2026-08-18' }));
|
||||
});
|
||||
|
||||
it('创建匹配查询范围参数名为 movement_date_from/to(Task 3 契约更名)', () => {
|
||||
// [断言意图] 后端 /matchings 入参更名(Task 3):查询范围参数名为
|
||||
// movement_date_from/to;body 键名必须逐字对齐,错名会被后端当作缺省
|
||||
// (范围不生效)而非报错。
|
||||
createTransferMatching({ source_codes: ['DBS-AWSBI'], movement_date_from: '2026-09-26', movement_date_to: '2026-09-26' });
|
||||
const [, init] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], movement_date_from: '2026-09-26', movement_date_to: '2026-09-26' }));
|
||||
});
|
||||
|
||||
it('下载出入站来源文件走 GET /runs/{run_no}/inbound-files(Task 3 路由更名)', () => {
|
||||
// [断言意图] Task 3 路由更名(出入站来源文件 inbound-files)后前端 URL 逐字对齐;
|
||||
// blob 端点只需鉴权头(既有契约)。
|
||||
downloadTransferInboundFiles('RUN-1');
|
||||
const [url, init] = requestBlob.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/runs/RUN-1/inbound-files');
|
||||
expect(init.headers).toBeDefined();
|
||||
});
|
||||
|
||||
it('按来源打包下载走 POST /sources/inbound-files,body 含 transfer_type', () => {
|
||||
// [断言意图] 证据打包按所选调拨类型决定打进包的流,body 必须同时有 source_codes 与 transfer_type。
|
||||
downloadTransferSourceFiles(['DBS-AWSBI'], 'in_transit_to_hub');
|
||||
const [url, init] = requestBlob.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/sources/inbound-files');
|
||||
expect(init.method).toBe('POST');
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], transfer_type: 'in_transit_to_hub' }));
|
||||
});
|
||||
|
||||
it('单源重试 POST retry-rpa,body 带 record_kind,缺省 inbound', () => {
|
||||
// [断言意图] 旧调用不传种类时仍提交 inbound;来源卡传 outbound 时 body 必须是该流。
|
||||
retryTransferSourceRpa('DBS-AWSBI');
|
||||
retryTransferSourceRpa('DBS-AWSBI', 'outbound');
|
||||
const calls = requestJson.mock.calls as [string, RequestInit][];
|
||||
expect(calls[0][0]).toBe('/api/in-transit-transfer/sources/DBS-AWSBI/retry-rpa');
|
||||
expect(calls[0][1].body).toBe(JSON.stringify({ record_kind: 'inbound' }));
|
||||
expect(calls[1][1].body).toBe(JSON.stringify({ record_kind: 'outbound' }));
|
||||
});
|
||||
|
||||
it('批量重试 POST retry-rpa-batch,带来源类型时 body 含 transfer_type', () => {
|
||||
retryTransferSourcesRpaBatch(['DBS-AWSBI'], 'hub_to_hub');
|
||||
const [url, init] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/sources/retry-rpa-batch');
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], transfer_type: 'hub_to_hub' }));
|
||||
});
|
||||
|
||||
it('列出证据文件走 GET evidence-files 并带 record_kind', () => {
|
||||
listEvidenceFiles('DSV360', 'outbound');
|
||||
const [url] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/sources/DSV360/evidence-files?record_kind=outbound');
|
||||
});
|
||||
|
||||
it('当前文件重解析 POST reparse,body 只有 record_kind', () => {
|
||||
reparseCurrentFile('DSV360_AWSDU', 'outbound');
|
||||
const calls = requestJson.mock.calls as [string, RequestInit][];
|
||||
expect(calls[0][0]).toBe('/api/in-transit-transfer/sources/DSV360_AWSDU/reparse');
|
||||
expect(JSON.parse(String(calls[0][1].body))).toEqual({ record_kind: 'outbound' });
|
||||
});
|
||||
|
||||
it('按明细行执行调拨 POST /items/execute 带 application/json 与 item_ids 契约', () => {
|
||||
// [断言意图] 行式执行(2026-09-23 item-centric 重构):执行不再挂在旧匹配详情端点下,
|
||||
// 改为独立 items/execute,body 键从 invoice_nos 改为 item_ids;JSON 头契约不变。
|
||||
@@ -88,7 +152,7 @@ describe('transfer.api JSON request contract', () => {
|
||||
// (Task 11)一致,前端只透传不加工;类型层 TransferRunResult 必含 orders: TransferOrder[]。
|
||||
const order: TransferOrder = {
|
||||
doc_no: 'HTT-OR-26092300001',
|
||||
receipt_date: '2026-09-23',
|
||||
movement_date: '2026-09-23',
|
||||
from_warehouse: 'HTT-B25',
|
||||
to_warehouse: 'HTT-B02',
|
||||
status: 'success',
|
||||
@@ -153,7 +217,7 @@ describe('transfer.api D8 异步 202 契约(真实 requestJson:200/202 均
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
const order: TransferOrder = {
|
||||
doc_no: 'HTT-OR-26092300002',
|
||||
receipt_date: '2026-09-23',
|
||||
movement_date: '2026-09-23',
|
||||
from_warehouse: 'HTT-B25',
|
||||
to_warehouse: 'HTT-B02',
|
||||
status: 'executing',
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
* 用途:在途仓自动调拨 API 客户端(统一 requestJson / requestBlob,不重复造客户端)。
|
||||
* 依赖:@/shared/api/client(requestJson / requestBlob / BusinessError)、getAuthHeaders。
|
||||
* 逻辑:薄封装后端 /api/in-transit-transfer 全部端点;二进制下载走 requestBlob。
|
||||
* 来源重试 body 带 record_kind;批量重试与证据打包在带来源类型时带 transfer_type;
|
||||
* 证据清单走 GET sources/{code}/evidence-files;
|
||||
* 当前归档重解析走 POST sources/{code}/reparse(body 仅 record_kind,不触发 RPA)。
|
||||
*/
|
||||
import { requestBlob, requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
@@ -18,9 +21,14 @@ import type {
|
||||
TransferMatchingItem,
|
||||
TransferMatchingSummary,
|
||||
TransferRunResult,
|
||||
TransferPendingMatchRecord,
|
||||
TransferCurrentReparseResult,
|
||||
TransferEvidenceFile,
|
||||
TransferRecordKind,
|
||||
TransferSourceFileStatus,
|
||||
TransferSourceOption,
|
||||
TransferType,
|
||||
TransferTypeOption,
|
||||
} from '../types/transfer.types';
|
||||
|
||||
const BASE = '/api/in-transit-transfer';
|
||||
@@ -31,12 +39,22 @@ const jsonHeaders = () => ({ 'Content-Type': 'application/json', ...getAuthHeade
|
||||
export interface CreateMatchingPayload {
|
||||
source_codes: string[];
|
||||
business_date?: string;
|
||||
receipt_date_from?: string;
|
||||
receipt_date_to?: string;
|
||||
/** 调拨业务类型;缺省为在途仓至HUB仓 */
|
||||
/** 匹配查询范围(异动日期;Task 3 契约更名后参数名,旧名见 git 历史) */
|
||||
movement_date_from?: string;
|
||||
movement_date_to?: string;
|
||||
/** 调拨业务类型 code(Task 7 接口化:来源选择卡接口选项所选值;缺省行为由后端匹配链路决定) */
|
||||
transfer_type?: TransferType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调拨类型配置列表(仅 enabled、sort_order 升序)。
|
||||
* 每项含 code、names、sort_order、transform_rules,以及由范围规则推导的
|
||||
* record_kinds;不回传 scope_rules / warehouse_config / description。
|
||||
* 配置缺失返回空数组。来源选择卡类型选项的唯一数据源。
|
||||
*/
|
||||
export const fetchTransferTypes = () =>
|
||||
requestJson<TransferTypeOption[]>(`${BASE}/transfer-types`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 创建匹配(只读) */
|
||||
export const createTransferMatching = (payload: CreateMatchingPayload) =>
|
||||
requestJson<TransferMatchingSummary>(BASE + '/matchings', {
|
||||
@@ -166,9 +184,9 @@ export const manualCloseTransferItem = (itemId: number, reason: string) =>
|
||||
body: JSON.stringify({ reason }),
|
||||
});
|
||||
|
||||
/** 下载收料来源文件(zip) */
|
||||
export const downloadTransferReceiptFiles = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/receipt-files`, { headers: getAuthHeaders() });
|
||||
/** 下载出入站来源文件(zip;Task 3 路由更名后端点为 inbound-files) */
|
||||
export const downloadTransferInboundFiles = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/inbound-files`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 下载匹配冻结的 ERP 库存表(csv) */
|
||||
export const downloadTransferErpInventory = (runNo: string) =>
|
||||
@@ -201,26 +219,134 @@ export const requeryTransferMatchingItems = (matchingNo: string, invoiceNos?: st
|
||||
{ method: 'POST', body: JSON.stringify(invoiceNos ? { invoice_nos: invoiceNos } : {}), headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' } },
|
||||
);
|
||||
|
||||
/** 按选中来源打包下载各自最新归档收料文件(zip) */
|
||||
export const downloadTransferSourceFiles = (sourceCodes: string[]) =>
|
||||
requestBlob(`${BASE}/sources/receipt-files`, {
|
||||
/**
|
||||
* 按选中来源与调拨类型打包最新可用证据文件。
|
||||
* 核心逻辑:POST /sources/inbound-files,body 为 source_codes + transfer_type;
|
||||
* 压缩包文件名用响应 Content-Disposition(后端 evidence-files-N.zip)。
|
||||
* @param sourceCodes - 要打包的来源编码
|
||||
* @param transferType - 当前所选调拨类型 code,后端据此决定打进包的证据流
|
||||
* @returns zip Blob 与后端给出的文件名
|
||||
*/
|
||||
export const downloadTransferSourceFiles = (sourceCodes: string[], transferType: string) =>
|
||||
requestBlob(`${BASE}/sources/inbound-files`, {
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ source_codes: sourceCodes }),
|
||||
body: JSON.stringify({ source_codes: sourceCodes, transfer_type: transferType }),
|
||||
});
|
||||
|
||||
/** 待处理异常列表(可恢复/已关闭/结果未知 + 老化等级) */
|
||||
export const listTransferBacklog = () =>
|
||||
requestJson<TransferBacklogItem[]>(`${BASE}/backlog`, { headers: getAuthHeaders() });
|
||||
/**
|
||||
* 待处理异常池分页查询(2026-10-16 服务端分页 + 筛选下推:池为无界增长集合,
|
||||
* 全量拉取在千行级放大载荷与老化查询规模;后端不带分页参数时返回全量数组为
|
||||
* 兼容口径,本前端恒走分页)。
|
||||
* keyword/resultFilter 对应后端 keyword/result_filter(筛选在服务端执行,
|
||||
* total=筛选后全量计数);返回 {items=当前页切片, total, page, page_size}。
|
||||
*/
|
||||
export interface TransferBacklogPageQuery {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
keyword?: string;
|
||||
resultFilter?: 'all' | 'recoverable' | 'closed' | 'unknown';
|
||||
}
|
||||
|
||||
/** 待处理异常汇总(含 3/5/7 天老化分级) */
|
||||
export const listTransferBacklogPage = (query: TransferBacklogPageQuery) => {
|
||||
const params = new URLSearchParams({
|
||||
page: String(query.page),
|
||||
page_size: String(query.pageSize),
|
||||
});
|
||||
if (query.keyword?.trim()) params.set('keyword', query.keyword.trim());
|
||||
if (query.resultFilter && query.resultFilter !== 'all') params.set('result_filter', query.resultFilter);
|
||||
return requestJson<{ items: TransferBacklogItem[]; total: number; page: number; page_size: number }>(
|
||||
`${BASE}/backlog?${params.toString()}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
};
|
||||
|
||||
/** 待处理异常汇总(含老化分级、待匹配全量 pending_match、可匹配 matchable_count) */
|
||||
export const getTransferBacklogSummary = () =>
|
||||
requestJson<TransferBacklogSummary>(`${BASE}/backlog/summary`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 来源实例列表(平台 DBS/Crane 仅分组,每来源附收料文件状态) */
|
||||
/**
|
||||
* 跨页全选支持(2026-10-22):拉取当前筛选下全部待处理明细 id。
|
||||
* 核心逻辑:GET /backlog/item-ids(keyword/result_filter 与分页接口同口径);
|
||||
* 返回 { ids(item_id 升序,后端上限 5000), total(筛选后全量计数), truncated }——
|
||||
* 供待处理池「选择全部 N 行」合并进勾选集合;批量端点按 item_ids 列表逐行
|
||||
* 校验,直接复用无需新批量契约。
|
||||
*/
|
||||
export const fetchBacklogSelectableItemIds = (
|
||||
query: Pick<TransferBacklogPageQuery, 'keyword' | 'resultFilter'> = {},
|
||||
) => {
|
||||
const params = new URLSearchParams();
|
||||
if (query.keyword?.trim()) params.set('keyword', query.keyword.trim());
|
||||
if (query.resultFilter && query.resultFilter !== 'all') params.set('result_filter', query.resultFilter);
|
||||
const qs = params.toString();
|
||||
return requestJson<{ ids: number[]; total: number; truncated: boolean }>(
|
||||
`${BASE}/backlog/item-ids${qs ? `?${qs}` : ''}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 分页拉取待匹配清单的一段。
|
||||
* 核心逻辑:拼 page、page_size、segment 后 GET /backlog/pending-match。
|
||||
* 无 item_id,不可勾选执行。
|
||||
* @param query.page - 页码,从 1 起
|
||||
* @param query.pageSize - 每页行数
|
||||
* @param query.segment - matchable=启用类型现在圈得住;outside=其余已落档;缺省 all
|
||||
* @returns 当前页记录与该段总数
|
||||
*/
|
||||
export const listPendingMatchRecordsPage = (query: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
segment?: 'all' | 'matchable' | 'outside';
|
||||
}) => {
|
||||
const params = new URLSearchParams({
|
||||
page: String(query.page),
|
||||
page_size: String(query.pageSize),
|
||||
});
|
||||
if (query.segment) params.set('segment', query.segment);
|
||||
return requestJson<{ records: TransferPendingMatchRecord[]; total: number; page: number; page_size: number }>(
|
||||
`${BASE}/backlog/pending-match?${params.toString()}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
};
|
||||
|
||||
/** 来源实例列表(平台 DBS/Crane 仅分组,每来源附入站扁平状态与 streams) */
|
||||
export const listTransferSources = () =>
|
||||
requestJson<TransferSourceOption[]>(`${BASE}/sources`, { headers: getAuthHeaders() });
|
||||
|
||||
/**
|
||||
* 列出某来源当天某条证据流的可用文件。
|
||||
* 核心逻辑:GET /sources/{code}/evidence-files?record_kind=,只取元数据与预签地址,不解析 Excel。
|
||||
* @param sourceCode - 来源实例编码
|
||||
* @param recordKind - inbound 或 outbound
|
||||
* @returns 当天可用证据文件列表(含 original_filename、created_at、sha256、file_size、presigned_url、download_url)
|
||||
*/
|
||||
export const listEvidenceFiles = (sourceCode: string, recordKind: TransferRecordKind) =>
|
||||
requestJson<TransferEvidenceFile[]>(
|
||||
`${BASE}/sources/${encodeURIComponent(sourceCode)}/evidence-files?record_kind=${encodeURIComponent(recordKind)}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
|
||||
/**
|
||||
* 对来源当前最新归档文件重新解析(不触发 RPA)。
|
||||
* 核心逻辑:POST /sources/{code}/reparse,body 只带 record_kind,后端重放最新归档 Excel。
|
||||
* @param sourceCode - 来源实例编码
|
||||
* @param recordKind - inbound 或 outbound
|
||||
* @returns 重解析统计与来源文件状态投影
|
||||
*/
|
||||
export const reparseCurrentFile = (
|
||||
sourceCode: string,
|
||||
recordKind: TransferRecordKind,
|
||||
) =>
|
||||
requestJson<TransferCurrentReparseResult>(
|
||||
`${BASE}/sources/${encodeURIComponent(sourceCode)}/reparse`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ record_kind: recordKind }),
|
||||
},
|
||||
);
|
||||
|
||||
/** retry-rpa 响应:parse_failed 本地重解析路径返回 {ok, file_status, reparsed};RPA 触发路径返回原状态投影 */
|
||||
export interface TransferRetryRpaReparseResult {
|
||||
source_code: string;
|
||||
@@ -229,12 +355,22 @@ export interface TransferRetryRpaReparseResult {
|
||||
reparsed: true;
|
||||
}
|
||||
|
||||
/** 来源重试(解析失败分层 2026-09-29):parse_failed 先本地重解析返回 200 reparse 结果,
|
||||
* 其余状态重新触发一次收料 RPA 抓取(202 + fetching / 配置缺失 fail-closed) */
|
||||
export const retryTransferSourceRpa = (sourceCode: string) =>
|
||||
/**
|
||||
* 按证据流重试一个来源。
|
||||
* 核心逻辑:POST /sources/{code}/retry-rpa,body 只带 record_kind。
|
||||
* 未传来源种类的旧调用方缺省 inbound;来源卡始终传入该括号对应的流。
|
||||
* @param sourceCode - 来源实例编码
|
||||
* @param recordKind - inbound 或 outbound,缺省 inbound
|
||||
* @returns 重解析结果或来源文件状态投影
|
||||
*/
|
||||
export const retryTransferSourceRpa = (
|
||||
sourceCode: string,
|
||||
recordKind: TransferRecordKind = 'inbound',
|
||||
) =>
|
||||
requestJson<TransferRetryRpaReparseResult | TransferSourceFileStatus>(`${BASE}/sources/${encodeURIComponent(sourceCode)}/retry-rpa`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ record_kind: recordKind }),
|
||||
});
|
||||
|
||||
/** 批量来源重试响应:triggered=是否写了 batch trigger;results 逐来源真实结果 */
|
||||
@@ -252,11 +388,22 @@ export interface TransferRetryRpaBatchResult {
|
||||
}>;
|
||||
}
|
||||
|
||||
/** 批量重试(2026-10-09):多来源合并写一个 batch trigger 文件,
|
||||
* Worker 单次浏览器会话串行导出全部来源(逐来源单文件会开/关 N 次浏览器) */
|
||||
export const retryTransferSourcesRpaBatch = (sourceCodes: string[]) =>
|
||||
/**
|
||||
* 批量重试所选来源。
|
||||
* 核心逻辑:POST /sources/retry-rpa-batch。带来源所选调拨类型时 body 为
|
||||
* {source_codes, transfer_type},后端按该类型的证据流分组;不传类型时只发
|
||||
* source_codes,保持旧的整批入站契约。
|
||||
* @param sourceCodes - 要重试的来源编码
|
||||
* @param transferType - 当前调拨类型 code;来源卡批量按钮始终传入
|
||||
* @returns 逐来源(及证据流)的触发结果
|
||||
*/
|
||||
export const retryTransferSourcesRpaBatch = (sourceCodes: string[], transferType?: string) =>
|
||||
requestJson<TransferRetryRpaBatchResult>(`${BASE}/sources/retry-rpa-batch`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ source_codes: sourceCodes }),
|
||||
body: JSON.stringify(
|
||||
transferType
|
||||
? { source_codes: sourceCodes, transfer_type: transferType }
|
||||
: { source_codes: sourceCodes },
|
||||
),
|
||||
});
|
||||
@@ -672,7 +672,7 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
@add-remote-url="page.addRemoteUrlAttachment"
|
||||
|
||||
@shipping-inventory-selected="page.handleShippingInventorySelected"
|
||||
@shipping-inventory-selected="page.handleShippingOnhandSelected"
|
||||
|
||||
@use-shipping-suggested-prompt="page.useShippingSuggestedPrompt"
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferBacklogSummaryCard.spec.ts
|
||||
* 用途:锁定待处理异常卡「跨页全选」(Gmail 式,2026-10-22)交互契约。
|
||||
* 依赖:@vue/test-utils、i18n、vi.mock transfer.api / useMessage。
|
||||
* 逻辑:服务端分页下表头全选只覆盖当前页——未全选时透出「选择全部 N 行
|
||||
* (按当前筛选)」独立入口(testid=transfer-backlog-select-all-matching,
|
||||
* 与表头全选 checkbox 的 transfer-backlog-select-all 区分),点击按当前
|
||||
* keyword/resultFilter 拉全量 id 合并进勾选集合(批量条计数随之计入
|
||||
* 全量),全选后入口自动隐藏;API 失败经 useMessage 行内报错且不改
|
||||
* 勾选集合。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
|
||||
const fetchIds = vi.fn();
|
||||
const messageMocks = vi.hoisted(() => ({
|
||||
error: vi.fn(),
|
||||
success: vi.fn(),
|
||||
warning: vi.fn(),
|
||||
info: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => messageMocks,
|
||||
}));
|
||||
|
||||
vi.mock('../../api/transfer.api', async (importOriginal) => ({
|
||||
...(await importOriginal<object>()),
|
||||
fetchBacklogSelectableItemIds: (...args: unknown[]) => fetchIds(...args),
|
||||
}));
|
||||
|
||||
import i18n from '@/i18n';
|
||||
import TransferBacklogSummaryCard from './TransferBacklogSummaryCard.vue';
|
||||
import type { TransferTypeOption } from '../../types/transfer.types';
|
||||
|
||||
const mountOptions = { global: { plugins: [i18n] } };
|
||||
|
||||
/** 构造一行可恢复阻断行(status/result_code 决定可勾选与批量可用性)。 */
|
||||
const row = (id: number, invoice: string) => ({
|
||||
item_id: id,
|
||||
invoice_no: invoice,
|
||||
source_code: 'DBS-AWSBI',
|
||||
material_no: 'MAT-1',
|
||||
material_name: '物料',
|
||||
movement_date: '2026-10-01',
|
||||
lot_no: '',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
from_quantity: '1',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
to_quantity: '1',
|
||||
status: 'blocked_recoverable',
|
||||
result_code: 'blocked_quantity_mismatch',
|
||||
result_message: '',
|
||||
aging_level: 'normal',
|
||||
updated_at: '',
|
||||
});
|
||||
|
||||
describe('待处理异常卡跨页全选(Gmail 式)', () => {
|
||||
beforeEach(() => {
|
||||
fetchIds.mockReset();
|
||||
messageMocks.error.mockReset();
|
||||
});
|
||||
|
||||
it('未全选时透出「选择全部 N 行」,点击按当前筛选拉全量 id 合并勾选集合', async () => {
|
||||
// [断言意图] 服务端分页(当前页 2 行/总量 3 行)下表头全选只覆盖当前页;
|
||||
// 独立入口文案带全量计数;点击携带当前 keyword/resultFilter 拉取 id;
|
||||
// 合并后批量条计入全量勾选数,入口因「未选中行=0」自动隐藏(表头全选
|
||||
// checkbox 的 testid 不受影响)。
|
||||
fetchIds.mockResolvedValue({ ids: [11, 12, 13], total: 3, truncated: false });
|
||||
const wrapper = mount(TransferBacklogSummaryCard, {
|
||||
props: { items: [row(11, 'INV-1'), row(12, 'INV-2')], total: 3 },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const link = wrapper.find('[data-testid="transfer-backlog-select-all-matching"]');
|
||||
expect(link.exists()).toBe(true);
|
||||
expect(link.text()).toContain('3');
|
||||
await link.trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
expect(fetchIds).toHaveBeenCalledWith({ keyword: '', resultFilter: 'all' });
|
||||
expect(
|
||||
wrapper.find('[data-testid="transfer-backlog-selected-count"]').text(),
|
||||
).toContain('3');
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('拉取失败行内报错且不改勾选集合;入口保持可重试', async () => {
|
||||
// [断言意图] API 异常不吞错(useMessage.error 透出)也不部分改写勾选集合
|
||||
//(批量条不出现);入口保留供重试。
|
||||
fetchIds.mockRejectedValue(new Error('backlog ids unavailable'));
|
||||
const wrapper = mount(TransferBacklogSummaryCard, {
|
||||
props: { items: [row(11, 'INV-1')], total: 2 },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
expect(messageMocks.error).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-selected-count"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('调拨类型列显示当前语言名称', async () => {
|
||||
// [断言意图] 待恢复行展示出生匹配的类型名称,而不是只留仓库编码。
|
||||
const types: TransferTypeOption[] = [{
|
||||
code: 'in_transit_to_hub',
|
||||
names: { 'zh-CN': '在途仓至HUB仓', en: 'In-transit to HUB' },
|
||||
sort_order: 1,
|
||||
transform_rules: [],
|
||||
record_kinds: ['inbound'],
|
||||
}];
|
||||
const wrapper = mount(TransferBacklogSummaryCard, {
|
||||
props: {
|
||||
items: [{ ...row(11, 'INV-1'), transfer_type: 'in_transit_to_hub' }],
|
||||
total: 1,
|
||||
transferTypes: types,
|
||||
},
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-type-INV-1"]').text()).toBe('在途仓至HUB仓');
|
||||
});
|
||||
});
|
||||
@@ -1,42 +1,100 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferBacklogSummaryCard.vue
|
||||
用途:待处理异常卡(可恢复/已关闭/结果未知三组)——列与匹配窗口一致,
|
||||
支持关键字/结果筛选、多选批量操作(重查/恢复/关闭)与行级快捷操作。
|
||||
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo、transferFormat.formatQuantity。
|
||||
逻辑:仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
|
||||
支持关键字/结果筛选、多选批量操作(重查库存/关闭)与行级快捷操作。
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElSelect/ElOption/ElPagination/
|
||||
ElInput/ElButton/ElTag/ElCheckbox(2026-10-20:勾选列一并 EP;testid 挂
|
||||
el-checkbox,规格经内层 input 读写)、
|
||||
props.items(服务端返回的当前页切片)+ props.total(筛选后全量计数)、
|
||||
i18n chat.transfer.*、transferBatch.deriveBatchNo、transferFormat.formatQuantity。
|
||||
逻辑:2026-10-16 服务端分页 + 筛选下推(后端 GET /backlog page/page_size/
|
||||
keyword/result_filter)——本组件只持有筛选 UI 态并向父级上抛 query-change,
|
||||
由宿主经 useChatTransfer.loadBacklog 拉取当前页;行渲染/勾选/批量语义:
|
||||
仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
|
||||
可恢复行按 result_code 细分徽标(blocked_file_removed=文件已移除);
|
||||
blocked_file_removed 行行内仅留「关闭」(重查不可恢复——消失证据
|
||||
无法由重查翻回,唯一出口=人工关闭或等文件重新同步);
|
||||
批量按钮与行内按钮同用短文案键(重查/恢复/关闭,2026-10-12 文案一致化,
|
||||
完整语义经 title 悬浮),勾选计数保留;
|
||||
勾选集合为卡片本地态,操作经 emit 交父组件调用批量端点并刷新。
|
||||
blocked_file_removed 行行内仅留「关闭」(消失证据无法由重查翻回,
|
||||
唯一出口=人工关闭或等文件重新同步);
|
||||
批量与行内都只有「重查库存」和「关闭」。重查库存与恢复是同一次 ERP 核对,
|
||||
2026-10-22 起不再并列两个按钮。
|
||||
调拨类型列取行上 transfer_type,按启用类型配置显示当前语言名称。
|
||||
勾选集合跨页保留(翻页/筛选不清空;批量计数=勾选总数,后端逐行校验兜底);
|
||||
关键字 300ms 防抖后上抛,筛选/翻页变更即上抛,首挂载上抛初始切片查询
|
||||
(首页计数卡进入时 initialFilter 直接生效)。
|
||||
行定位:el-table 行不支持逐行 attr,行 testid 改经 row-class-name 注入
|
||||
(transfer-backlog-row-<invoice_no>,spec/e2e 用类选择器等价定位)。
|
||||
[2026-10-22 跨页全选] 服务端分页下表头全选只能覆盖当前页——Gmail 式补链:
|
||||
有勾选且未全选时透出「选择全部 N 行(按当前筛选)」,点击经
|
||||
GET /backlog/item-ids 按同一筛选口径拉全量 id 合并进勾选集合(批量端点
|
||||
按 item_ids 列表逐行校验,无需新批量契约);拉取失败经 useMessage 行内报错。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import type { CheckboxValueType } from 'element-plus';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { fetchBacklogSelectableItemIds } from '../../api/transfer.api';
|
||||
import { TRANSFER_PAGE_SIZE } from '../../composables/useChatTransfer';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
import { formatQuantity } from './transferFormat';
|
||||
import type { TransferBacklogItem } from '../../types/transfer.types';
|
||||
import { transferTypeDisplay } from './transferTypeLabel';
|
||||
import type { TransferBacklogItem, TransferTypeOption } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 当前页行切片(服务端分页返回;筛选在服务端执行)。 */
|
||||
items: TransferBacklogItem[];
|
||||
/** 筛选后全量计数(分页器数据源;不传视为 0=隐藏分页条)。 */
|
||||
total?: number;
|
||||
busy?: boolean;
|
||||
/** 初始结果筛选(首页计数卡切片进入:closed 卡落「已关闭」切片等)。 */
|
||||
initialFilter?: 'all' | 'recoverable' | 'closed' | 'unknown';
|
||||
}>();
|
||||
/** 启用中的调拨类型。用来把行上的 code 显示成当前语言名称。 */
|
||||
transferTypes?: TransferTypeOption[];
|
||||
}>(), {
|
||||
transferTypes: () => [],
|
||||
});
|
||||
|
||||
const { locale } = useI18n();
|
||||
|
||||
/**
|
||||
* 把待处理行的调拨类型 code 显示成名称。
|
||||
* 核心逻辑:复用 transferTypeDisplay;没有类型时显示 —。
|
||||
* @param code - 行上的 transfer_type
|
||||
* @returns 当前语言名称、编码或占位
|
||||
*/
|
||||
function typeLabel(code: string | null | undefined): string {
|
||||
return transferTypeDisplay(code, props.transferTypes, locale.value);
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
refresh: [];
|
||||
retry: [itemId: number];
|
||||
resume: [itemIds: number[]];
|
||||
/** 行级与批量共用:按明细 id 重查 ERP 库存。 */
|
||||
requery: [itemIds: number[]];
|
||||
close: [item: TransferBacklogItem];
|
||||
batchClose: [itemIds: number[]];
|
||||
/** 查询变更(翻页/筛选/首挂载):宿主据此调用 loadBacklog 拉取对应页。 */
|
||||
'query-change': [query: { page: number; keyword: string; resultFilter: 'all' | 'recoverable' | 'closed' | 'unknown' }];
|
||||
}>();
|
||||
|
||||
/** 勾选集合(本地视图态;仅可恢复行可勾选)。 */
|
||||
/** 每页行数(与组合式函数 loadBacklog 默认 pageSize 同源:TRANSFER_PAGE_SIZE)。 */
|
||||
const PAGE_SIZE = TRANSFER_PAGE_SIZE;
|
||||
|
||||
/** 勾选集合(本地视图态;仅可恢复行可勾选;跨页保留——批量计数=勾选总数,
|
||||
* 行状态变化由后端批量端点逐行校验兜底)。 */
|
||||
const selectedIds = ref<Set<number>>(new Set());
|
||||
const keyword = ref('');
|
||||
const resultFilter = ref<'all' | 'recoverable' | 'closed' | 'unknown'>(props.initialFilter ?? 'all');
|
||||
const currentPage = ref(1);
|
||||
|
||||
function isActionable(item: TransferBacklogItem): boolean {
|
||||
return item.status === 'blocked_recoverable';
|
||||
@@ -50,27 +108,10 @@ function isFileRemoved(item: TransferBacklogItem): boolean {
|
||||
return item.result_code === 'blocked_file_removed';
|
||||
}
|
||||
|
||||
const filtered = computed(() =>
|
||||
props.items.filter((item) => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
if (kw) {
|
||||
const haystack = [item.invoice_no, item.material_no, item.material_name, item.source_code]
|
||||
.map((value) => String(value ?? '').toLowerCase());
|
||||
if (!haystack.some((value) => value.includes(kw))) return false;
|
||||
}
|
||||
if (resultFilter.value === 'recoverable' && item.status !== 'blocked_recoverable') return false;
|
||||
if (resultFilter.value === 'closed' && item.status !== 'manually_closed') return false;
|
||||
if (resultFilter.value === 'unknown' && item.status !== 'result_unknown') return false;
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
|
||||
const selectedActionableIds = computed(() =>
|
||||
filtered.value.filter((item) => isActionable(item) && selectedIds.value.has(item.item_id)).map((item) => item.item_id),
|
||||
);
|
||||
const selectedActionableIds = computed(() => [...selectedIds.value]);
|
||||
|
||||
const allFilteredSelected = computed(() => {
|
||||
const actionable = filtered.value.filter(isActionable);
|
||||
const actionable = props.items.filter(isActionable);
|
||||
return actionable.length > 0 && actionable.every((item) => selectedIds.value.has(item.item_id));
|
||||
});
|
||||
|
||||
@@ -83,7 +124,7 @@ function toggleRow(item: TransferBacklogItem, checked: boolean) {
|
||||
|
||||
function toggleAll(checked: boolean) {
|
||||
const next = new Set(selectedIds.value);
|
||||
for (const item of filtered.value.filter(isActionable)) {
|
||||
for (const item of props.items.filter(isActionable)) {
|
||||
if (checked) next.add(item.item_id);
|
||||
else next.delete(item.item_id);
|
||||
}
|
||||
@@ -94,12 +135,68 @@ function clearSelection() {
|
||||
selectedIds.value = new Set();
|
||||
}
|
||||
|
||||
/** 行操作后/刷新后清理已消失行的勾选残留。 */
|
||||
function pruneSelection() {
|
||||
const alive = new Set(props.items.map((item) => item.item_id));
|
||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => alive.has(id)));
|
||||
const { error: notifyError } = useMessage();
|
||||
|
||||
/** 跨页全选拉取进行中(防重入)。 */
|
||||
const selectAllBusy = ref(false);
|
||||
|
||||
/** 跨页全选入口可见性:有筛选总量且勾选未覆盖全量时透出(选完后自动隐藏)。 */
|
||||
const showSelectAll = computed(() => (props.total ?? 0) > selectedIds.value.size);
|
||||
|
||||
/**
|
||||
* 跨页全选(Gmail 式,2026-10-22):按当前筛选拉取全部待处理明细 id 合并进勾选集合。
|
||||
* 服务端分页下表头全选只覆盖当前页;批量端点按 item_ids 列表逐行校验,全量 id 直接复用
|
||||
* (GET /backlog/item-ids,keyword/result_filter 与当前筛选同源)。
|
||||
*/
|
||||
async function selectAllMatching() {
|
||||
if (selectAllBusy.value) return;
|
||||
selectAllBusy.value = true;
|
||||
try {
|
||||
const data = await fetchBacklogSelectableItemIds({
|
||||
keyword: keyword.value,
|
||||
resultFilter: resultFilter.value,
|
||||
});
|
||||
selectedIds.value = new Set(data.ids.map((id) => Number(id)));
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
selectAllBusy.value = false;
|
||||
}
|
||||
}
|
||||
defineExpose({ pruneSelection });
|
||||
|
||||
// [STEP 1] 查询上抛:翻页/筛选立即上抛,关键字 300ms 防抖(服务端逐次查询防抖动);
|
||||
// 首挂载即上抛初始切片查询(宿主不再兜底首拉,避免双请求)。
|
||||
function emitQuery() {
|
||||
emit('query-change', { page: currentPage.value, keyword: keyword.value.trim(), resultFilter: resultFilter.value });
|
||||
}
|
||||
|
||||
watch(currentPage, () => emitQuery());
|
||||
|
||||
watch(resultFilter, () => {
|
||||
if (currentPage.value !== 1) currentPage.value = 1; // 翻页 watch 负责上抛
|
||||
else emitQuery();
|
||||
});
|
||||
|
||||
let keywordTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
watch(keyword, () => {
|
||||
clearTimeout(keywordTimer);
|
||||
keywordTimer = setTimeout(() => {
|
||||
if (currentPage.value !== 1) currentPage.value = 1;
|
||||
else emitQuery();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => clearTimeout(keywordTimer));
|
||||
|
||||
onMounted(() => emitQuery());
|
||||
|
||||
// [STEP 2] 行操作/刷新后总行数变小:收拢当前页防空白页(越界时回落末页并重查)。
|
||||
watch(() => props.total, (total = 0) => {
|
||||
const maxPage = Math.max(1, Math.ceil(total / PAGE_SIZE));
|
||||
if (currentPage.value > maxPage) {
|
||||
currentPage.value = maxPage; // 翻页 watch 负责上抛
|
||||
}
|
||||
});
|
||||
|
||||
function agingLabel(level: string): string {
|
||||
const map: Record<string, string> = {
|
||||
@@ -116,6 +213,16 @@ function rowKey(item: TransferBacklogItem): string {
|
||||
return `${item.item_id}|${item.invoice_no}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* el-table 行类:注入行定位类(替代旧行 testid)+ 不可操作行置灰(同旧行样式)。
|
||||
*/
|
||||
function rowClassName({ row }: { row: TransferBacklogItem }): string {
|
||||
return [
|
||||
`transfer-backlog-row-${row.invoice_no}`,
|
||||
isActionable(row) ? '' : 'bg-surface-soft text-muted',
|
||||
].filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
/** 结果徽标文案键:可恢复行按 result_code 细分(blocked_file_removed=文件已移除),其余按状态。 */
|
||||
function resultLabelKey(item: TransferBacklogItem): string {
|
||||
if (item.status === 'result_unknown') return 'chat.transfer.resultUnknown';
|
||||
@@ -130,201 +237,214 @@ function resultLabelKey(item: TransferBacklogItem): string {
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-backlog-card">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h3 class="text-sm font-bold text-primary">{{ $t('chat.transfer.backlogTitle') }}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 text-xs text-secondary hover-surface-soft"
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-backlog-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 批量操作条:勾选 ≥1 行时原位替换筛选区 -->
|
||||
<!-- 跨页全选入口(Gmail 式,2026-10-22):服务端分页下表头全选只覆盖当前页,
|
||||
有未选中行时透出「选择全部 N 行」,按当前筛选拉全量 id 合并进勾选集合
|
||||
(testid 独立于表头全选 checkbox 的 transfer-backlog-select-all) -->
|
||||
<div v-if="showSelectAll" class="mb-2 text-xs">
|
||||
<button
|
||||
type="button"
|
||||
class="text-secondary underline decoration-dotted underline-offset-2 disabled:opacity-50"
|
||||
:disabled="selectAllBusy"
|
||||
data-testid="transfer-backlog-select-all-matching"
|
||||
@click="selectAllMatching"
|
||||
>{{ $t('chat.transfer.selectAllRows', { count: total ?? 0 }) }}</button>
|
||||
</div>
|
||||
|
||||
<!-- 批量操作条:勾选 ≥1 行时原位替换筛选区(跨页勾选同样计入) -->
|
||||
<div v-if="selectedActionableIds.length" class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs font-bold text-secondary" data-testid="transfer-backlog-selected-count">
|
||||
{{ $t('chat.transfer.selectedRows', { count: selectedActionableIds.length }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 bg-brand-50 px-3 py-1 text-xs font-bold text-brand-700 transition hover:bg-brand-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
data-testid="transfer-backlog-batch-requery"
|
||||
:disabled="busy"
|
||||
@click="emit('requery', selectedActionableIds)"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 bg-brand-50 px-3 py-1 text-xs font-bold text-brand-700 transition hover:bg-brand-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
data-testid="transfer-backlog-batch-resume"
|
||||
:disabled="busy"
|
||||
:title="$t('chat.transfer.resumeAction')"
|
||||
@click="emit('resume', selectedActionableIds)"
|
||||
>
|
||||
<!-- [2026-10-12 文案一致化] 批量按钮与行内按钮同用短文案键(恢复/关闭),
|
||||
勾选计数保留;完整语义经 title 悬浮透出(与行内按钮同模式) -->
|
||||
{{ $t('chat.transfer.resumeActionShort') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-red-200 bg-red-50 px-3 py-1 text-xs font-bold text-red-600 transition hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
{{ $t('chat.transfer.requeryStock') }}({{ selectedActionableIds.length }})
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
plain
|
||||
data-testid="transfer-backlog-batch-close"
|
||||
:disabled="busy"
|
||||
:title="$t('chat.transfer.manualClose')"
|
||||
@click="emit('batchClose', selectedActionableIds)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualCloseShort') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 text-xs text-secondary hover-surface-soft"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-backlog-clear-selection"
|
||||
@click="clearSelection"
|
||||
>
|
||||
{{ $t('chat.transfer.clearSelection') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-else class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
class="w-56 rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
:placeholder="$t('chat.transfer.filterPlaceholder')"
|
||||
data-testid="transfer-backlog-filter"
|
||||
/>
|
||||
<select
|
||||
v-model="resultFilter"
|
||||
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
data-testid="transfer-backlog-result-filter"
|
||||
>
|
||||
<option value="all">{{ $t('chat.transfer.filterAll') }}</option>
|
||||
<option value="recoverable">{{ $t('chat.transfer.homeRecoverable') }}</option>
|
||||
<option value="closed">{{ $t('chat.transfer.homeClosed') }}</option>
|
||||
<option value="unknown">{{ $t('chat.transfer.homeUnknown') }}</option>
|
||||
</select>
|
||||
<div class="w-56 shrink-0">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
size="small"
|
||||
clearable
|
||||
:placeholder="$t('chat.transfer.filterPlaceholder')"
|
||||
data-testid="transfer-backlog-filter"
|
||||
/>
|
||||
</div>
|
||||
<!-- el-select 默认 width:100%(EP 样式会覆盖工具类),外包定宽容器锁定紧凑尺寸,
|
||||
与关键字输入并排一行,避免筛选区独占两行 -->
|
||||
<div class="w-32 shrink-0">
|
||||
<el-select
|
||||
v-model="resultFilter"
|
||||
size="small"
|
||||
data-testid="transfer-backlog-result-filter"
|
||||
:aria-label="$t('chat.transfer.colResult')"
|
||||
>
|
||||
<el-option value="all" :label="$t('chat.transfer.filterAll')" />
|
||||
<el-option value="recoverable" :label="$t('chat.transfer.homeRecoverable')" />
|
||||
<el-option value="closed" :label="$t('chat.transfer.homeClosed')" />
|
||||
<el-option value="unknown" :label="$t('chat.transfer.homeUnknown')" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="filtered.length" class="overflow-x-auto">
|
||||
<table class="w-full min-w-[1360px] text-xs" data-testid="transfer-backlog-table">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
|
||||
<th class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allFilteredSelected"
|
||||
data-testid="transfer-backlog-select-all"
|
||||
@change="toggleAll(($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</th>
|
||||
<!-- 表头全列 nowrap:防「拨出仓库/匹配结果」等折行;品名列吃剩余宽度 -->
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromQty') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colResult') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAging') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAction') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in filtered"
|
||||
:key="rowKey(item)"
|
||||
class="border-b border-subtle"
|
||||
:class="{ 'bg-surface-soft text-muted': !isActionable(item) }"
|
||||
:data-testid="`transfer-backlog-${item.invoice_no}`"
|
||||
<!-- EP 表格壳:数据=服务端返回的当前页切片;横向滚动由 el-table 内建(列 min-width 撑开) -->
|
||||
<el-table
|
||||
v-if="items.length"
|
||||
:data="items"
|
||||
:row-key="rowKey"
|
||||
:row-class-name="rowClassName"
|
||||
size="small"
|
||||
class="text-xs"
|
||||
data-testid="transfer-backlog-table"
|
||||
>
|
||||
<el-table-column width="48" class-name="whitespace-nowrap">
|
||||
<template #header>
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="allFilteredSelected"
|
||||
data-testid="transfer-backlog-select-all"
|
||||
@change="(val: CheckboxValueType) => toggleAll(Boolean(val))"
|
||||
/>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="selectedIds.has(row.item_id)"
|
||||
:disabled="!isActionable(row as TransferBacklogItem) || busy"
|
||||
:data-testid="`transfer-backlog-check-${row.invoice_no}`"
|
||||
@change="(val: CheckboxValueType) => toggleRow(row as TransferBacklogItem, Boolean(val))"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
|
||||
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<span :data-testid="`transfer-backlog-type-${row.invoice_no}`">{{ typeLabel(row.transfer_type) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="130" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<span class="font-semibold">{{ row.invoice_no }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="100" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" class-name="whitespace-nowrap" />
|
||||
<el-table-column :label="$t('chat.transfer.colName')" min-width="140">
|
||||
<template #default="{ row }">{{ row.material_name || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" min-width="110" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.from_warehouse || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="110" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ deriveBatchNo(row.lot_no ?? '') || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="90" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ formatQuantity(row.external_quantity) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colToWarehouse')" min-width="110" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.to_warehouse || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ formatQuantity(row.movement_quantity) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colResult')" min-width="110">
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
size="small"
|
||||
effect="light"
|
||||
:type="row.status === 'blocked_recoverable' ? 'danger' : row.status === 'result_unknown' ? 'warning' : 'info'"
|
||||
:title="row.reason || undefined"
|
||||
data-testid="transfer-backlog-result"
|
||||
>
|
||||
<td class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selectedIds.has(item.item_id)"
|
||||
:disabled="!isActionable(item) || busy"
|
||||
:data-testid="`transfer-backlog-check-${item.invoice_no}`"
|
||||
@change="toggleRow(item, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</td>
|
||||
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行;
|
||||
操作列三按钮保持一行 -->
|
||||
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
|
||||
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.material_no }}</td>
|
||||
<td class="p-2">{{ item.material_name || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.from_warehouse || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ deriveBatchNo(item.lot_no ?? '') || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.external_quantity) }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.to_warehouse || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.receipt_quantity) }}</td>
|
||||
<td class="p-2">
|
||||
<span
|
||||
class="whitespace-nowrap rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-red-50 text-red-700': item.status === 'blocked_recoverable',
|
||||
'bg-amber-50 text-amber-700': item.status === 'result_unknown',
|
||||
'bg-surface-soft text-muted': item.status === 'manually_closed',
|
||||
}"
|
||||
:title="item.reason || undefined"
|
||||
data-testid="transfer-backlog-result"
|
||||
>
|
||||
{{
|
||||
$t(resultLabelKey(item))
|
||||
}}
|
||||
</span>
|
||||
</td>
|
||||
<td class="whitespace-nowrap p-2">{{ $t(agingLabel(item.aging_level)) }}</td>
|
||||
<td class="whitespace-nowrap p-2">
|
||||
<template v-if="isActionable(item)">
|
||||
<!-- 失效行(文件已移除)隐藏重查/恢复处理:重查会被后端拒绝
|
||||
(TRANSFER.RETRY_NOT_ALLOWED),恢复处理也无济于事,只留关闭出口 -->
|
||||
<button
|
||||
v-if="!isFileRemoved(item)"
|
||||
type="button"
|
||||
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-backlog-requery-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('retry', item.item_id)"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!isFileRemoved(item)"
|
||||
type="button"
|
||||
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:title="$t('chat.transfer.resumeAction')"
|
||||
:data-testid="`transfer-backlog-resume-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('resume', [item.item_id])"
|
||||
>
|
||||
{{ $t('chat.transfer.resumeActionShort') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-red-200 px-1 py-0.5 text-[10px] font-bold text-red-600 transition hover:bg-red-50 disabled:opacity-40"
|
||||
:title="$t('chat.transfer.manualClose')"
|
||||
:data-testid="`transfer-backlog-close-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('close', item)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualCloseShort') }}
|
||||
</button>
|
||||
</template>
|
||||
<span v-else-if="item.status === 'result_unknown'" class="text-[11px] text-muted">
|
||||
{{ $t('chat.transfer.resultUnknownReadonly') }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ $t(resultLabelKey(row as TransferBacklogItem)) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colAging')" min-width="90" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ $t(agingLabel(row.aging_level)) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colAction')" min-width="150" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<template v-if="isActionable(row as TransferBacklogItem)">
|
||||
<!-- 失效行(文件已移除)只留关闭:重查会被后端拒绝(TRANSFER.RETRY_NOT_ALLOWED)。 -->
|
||||
<el-button
|
||||
v-if="!isFileRemoved(row as TransferBacklogItem)"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:data-testid="`transfer-backlog-requery-${row.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('requery', [row.item_id])"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryStock') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
size="small"
|
||||
:title="$t('chat.transfer.manualClose')"
|
||||
:data-testid="`transfer-backlog-close-${row.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('close', row as TransferBacklogItem)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualCloseShort') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<span v-else-if="row.status === 'result_unknown'" class="text-[11px] text-muted">
|
||||
{{ $t('chat.transfer.resultUnknownReadonly') }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div v-else class="rounded-lg bg-surface-soft p-3 text-xs text-muted">
|
||||
{{ $t('chat.transfer.noBacklog') }}
|
||||
</div>
|
||||
<!-- 服务端分页条(单页时隐藏):total=筛选后全量计数;文案走全局 ElConfigProvider 四语言 -->
|
||||
<el-pagination
|
||||
v-if="(total ?? 0) > PAGE_SIZE"
|
||||
:current-page="currentPage"
|
||||
:total="total ?? 0"
|
||||
:page-size="PAGE_SIZE"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
size="small"
|
||||
class="mt-2 justify-end"
|
||||
data-testid="transfer-backlog-pagination"
|
||||
@current-change="(page: number) => { currentPage = page }"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
Loaded 100 of 790 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user