Merge branch 'dev' into branch-statement-button
# Conflicts: # docs/funclist.md
This commit is contained in:
commit
97c46625e4
986 files changed
+96142
-38961
No files matched your search
+15
-9
@@ -2,12 +2,15 @@
|
||||
/**
|
||||
* App.vue
|
||||
* 根组件:主题初始化、全局消息弹窗、401 登出监听、html lang 与 i18n locale 同步。
|
||||
* 依赖:useTheme、useGlobalMessageDialog、auth、linked-nav.store。
|
||||
* 依赖:useTheme、useGlobalMessageDialog、auth、linked-nav.store、useElementProvider。
|
||||
* 逻辑:已登录时预取关联服务侧栏入口,避免页面切换后入口后闪现。
|
||||
* 书签/刷新冷启动遇到 401 时只回登录页;本页已确认会话后中途失效才弹窗。
|
||||
* Element 内置文案由根上的 ElConfigProvider 跟随 vue-i18n。页面不要再包一层。
|
||||
*/
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { watch, onMounted, onBeforeUnmount } from 'vue';
|
||||
import { ElConfigProvider } from 'element-plus';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { useTheme } from '@/shared/composables/useTheme';
|
||||
import LevelMessageDialog from '@/shared/components/LevelMessageDialog.vue';
|
||||
import { useGlobalMessageDialog } from '@/shared/composables/useGlobalMessageDialog';
|
||||
@@ -18,6 +21,7 @@ import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store';
|
||||
|
||||
const router = useRouter();
|
||||
const { locale, t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const { themePreference, initTheme, setThemePreference } = useTheme();
|
||||
const {
|
||||
messageDialogVisible,
|
||||
@@ -136,12 +140,14 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<router-view />
|
||||
<LevelMessageDialog
|
||||
v-model="messageDialogVisible"
|
||||
:level="messageDialogLevel"
|
||||
:title="messageDialogTitle"
|
||||
:message="messageDialogContent"
|
||||
@close="closeMessageDialog"
|
||||
/>
|
||||
<el-config-provider :locale="elementLocale">
|
||||
<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 };
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* features/admin/components/AdminListPage.vue
|
||||
* 用途:管理端列表页的唯一卡片骨架。标题、操作、页签、筛选、表格、分页按固定顺序和 32px 内边距排列。
|
||||
* 依赖:element-plus 的加载指令、components-ds.css 的 admin-table-section / admin-table-header、element-trial.css 的分页条。
|
||||
* 逻辑:AdminLayout 提供菜单和内容区外边距;各业务页把文案和控件填进插槽。本组件不请求数据。
|
||||
* 用户管理、部门管理、常用问题等列表调用本组件。页签用 AdminListTabs。页签、筛选、分页没有内容时不占一行。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ElLoading } from 'element-plus';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
|
||||
defineProps<{
|
||||
/** 首屏整卡加载。为 true 时先盖住卡片,数据回来再画出标题和表格。 */
|
||||
loading?: boolean;
|
||||
}>();
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section v-loading="loading" class="admin-table-section admin-list-page min-h-64">
|
||||
<template v-if="!loading">
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div class="min-w-0">
|
||||
<slot name="title" />
|
||||
</div>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
<div v-if="$slots.tabs" class="admin-list-page__tabs">
|
||||
<slot name="tabs" />
|
||||
</div>
|
||||
<div v-if="$slots.filters" class="admin-list-page__filters">
|
||||
<slot name="filters" />
|
||||
</div>
|
||||
<slot />
|
||||
<div v-if="$slots.pagination" class="hx-admin-pager">
|
||||
<slot name="pagination" />
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-list-page__tabs {
|
||||
padding: 0 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.admin-list-page__filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.admin-list-page__filters :deep(.el-input),
|
||||
.admin-list-page__filters :deep(.el-select) {
|
||||
flex: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* features/admin/components/AdminListTabs.vue
|
||||
* 用途:管理端列表卡片里的页签条。只负责切换,不放表格和筛选。
|
||||
* 依赖:element-plus 的 ElTabs、ElTabPane、ElTag。
|
||||
* 逻辑:放进 AdminListPage 的 tabs 插槽。当前页签用 v-model 交给页面,页面再决定筛选和表格。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ElTabPane, ElTabs, ElTag } from 'element-plus';
|
||||
|
||||
/** 一个页签。badge 为 0 或空时不显示数字。 */
|
||||
export interface AdminListTabItem {
|
||||
name: string;
|
||||
label: string;
|
||||
badge?: number | string;
|
||||
}
|
||||
|
||||
defineProps<{
|
||||
/** 当前页签名,对应 items 里的 name。 */
|
||||
modelValue: string;
|
||||
items: AdminListTabItem[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string];
|
||||
}>();
|
||||
|
||||
/**
|
||||
* 把 Element 页签切换写回 v-model。
|
||||
* @param name - 被点中的页签名
|
||||
*/
|
||||
function onTabChange(name: string | number): void {
|
||||
emit('update:modelValue', String(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字为 0 或空时不画角标。
|
||||
* @param badge - 页签上的数量
|
||||
* @returns 是否显示角标
|
||||
*/
|
||||
function showBadge(badge: number | string | undefined): boolean {
|
||||
return badge != null && badge !== '' && badge !== 0;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElTabs :model-value="modelValue" class="admin-list-tabs" @tab-change="onTabChange">
|
||||
<ElTabPane v-for="item in items" :key="item.name" :name="item.name">
|
||||
<template #label>
|
||||
<span class="admin-list-tabs__label">
|
||||
{{ item.label }}
|
||||
<ElTag v-if="showBadge(item.badge)" type="warning" effect="light" size="small">
|
||||
{{ item.badge }}
|
||||
</ElTag>
|
||||
</span>
|
||||
</template>
|
||||
</ElTabPane>
|
||||
</ElTabs>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-list-tabs :deep(.el-tabs__header) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.admin-list-tabs :deep(.el-tabs__nav-wrap::after) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-list-tabs :deep(.el-tabs__content) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.admin-list-tabs :deep(.el-tabs__item) {
|
||||
height: 40px;
|
||||
padding: 0 16px;
|
||||
font-size: var(--el-font-size-base);
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.admin-list-tabs :deep(.el-tabs__active-bar + .el-tabs__item) {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
.admin-list-tabs__label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
</style>
|
||||
@@ -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"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
/**
|
||||
* features/admin/composables/useElementProvider.ts
|
||||
* 用途:管理端 Element Plus 试点的界面语言。
|
||||
* 用途:把当前界面语言映射成 Element Plus 语言包。
|
||||
* 依赖:element-plus locale、vue-i18n。
|
||||
* 逻辑:UsersPage、AgentsPage、KbAdminPanel 把 elementLocale 传给 ElConfigProvider;亮暗靠 html.dark 与 Element 暗色变量,不在这里重复切换。
|
||||
* 逻辑:只由 App.vue 根上的 ElConfigProvider 使用。页面和弹窗不要再包一层。
|
||||
* 亮暗靠 html.dark 与 Element 暗色变量,不在这里切换。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -20,8 +21,8 @@ const ELEMENT_LOCALES = {
|
||||
|
||||
/**
|
||||
* 取当前界面语言对应的 Element Plus 语言包。
|
||||
* 核心逻辑:未知语言回退简体中文。
|
||||
* @returns elementLocale,随 vue-i18n 语言变化
|
||||
* 核心逻辑:zh-CN、zh-TW、en、th 各用官方语言包,未知语言回退简体中文。
|
||||
* @returns elementLocale,随 vue-i18n 语言变化。交给 App.vue 的 ElConfigProvider。
|
||||
*/
|
||||
export function useElementProvider() {
|
||||
const { locale } = useI18n();
|
||||
|
||||
@@ -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';
|
||||
@@ -4,6 +4,7 @@
|
||||
* 用途:管理控制台的应用管理页,提供应用列表、创建/编辑弹窗、测试与授权入口。
|
||||
* 依赖:useAgentsAdmin 业务编排、Element Plus 表格与按钮、AgentFormModal/AgentTestModal/AgentPermissionModal 弹窗。
|
||||
* 逻辑:页面加载后先展示应用列表;目录、用户和排程在后台补齐。权限组启用后隐藏按人授权按钮。
|
||||
* 列表使用 Element stripe 斑马纹。选中行浅底画在单元格上,盖过斑马纹。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue';
|
||||
@@ -11,7 +12,6 @@ import { useI18n } from 'vue-i18n';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
ElEmpty,
|
||||
ElLoading,
|
||||
ElTable,
|
||||
@@ -21,7 +21,6 @@ import {
|
||||
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 AgentFormModal from './components/AgentFormModal.vue';
|
||||
import AgentPermissionModal from './components/AgentPermissionModal.vue';
|
||||
import AgentTestModal from './components/AgentTestModal.vue';
|
||||
@@ -29,7 +28,6 @@ import { useAgentsAdmin } from './composables/useAgentsAdmin';
|
||||
import type { AgentRow } from '@/features/admin/types/agent.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const {
|
||||
@@ -182,7 +180,6 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="admin-table-section min-h-64">
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
@@ -201,6 +198,7 @@ onMounted(() => {
|
||||
:data="agents"
|
||||
row-key="id"
|
||||
class="agents-element-table hx-admin-table"
|
||||
stripe
|
||||
:row-class-name="agentRowClass"
|
||||
@row-click="onRowClick"
|
||||
>
|
||||
@@ -296,12 +294,11 @@ onMounted(() => {
|
||||
@toggle-user="togglePermissionUser"
|
||||
/>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.agents-element-table :deep(.agents-row-selected) {
|
||||
--el-table-tr-bg-color: color-mix(in srgb, #0284c7 8%, transparent);
|
||||
.agents-element-table :deep(.agents-row-selected td.el-table__cell) {
|
||||
background: color-mix(in srgb, #0284c7 8%, var(--el-bg-color, #fff));
|
||||
}
|
||||
|
||||
.agents-element-table :deep(.el-table__row) {
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
* features/admin/modules/agents/components/AgentCapabilitiesConfig.vue
|
||||
*
|
||||
* 用途:应用管理表单中的 capabilities 能力开关面板。
|
||||
* 依赖:agent.types AgentFormState、useAgentsAdminRegistry catalog 辅助函数、vue-i18n。
|
||||
* 逻辑:AgentFormModal 挂载本组件;Catalog forced_capabilities 对应项只读展示。
|
||||
* 依赖:element-plus 复选框、agent.types AgentFormState、useAgentsAdminRegistry catalog 辅助函数、vue-i18n。
|
||||
* 逻辑:AgentFormModal 挂载本组件;Catalog forced_capabilities 对应项只读展示。内部字段已换 Element。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElCheckbox, ElTag } from 'element-plus';
|
||||
import type { AgentCapabilities, AgentFormState } from '@/features/admin/types/agent.types';
|
||||
import {
|
||||
catalogForcesCapability,
|
||||
@@ -41,51 +42,92 @@ const capabilityItems = computed(() => (
|
||||
));
|
||||
|
||||
/**
|
||||
* 切换 task_progress 时同步 tool_run_progress_enabled,供进度配置面板联动。
|
||||
* 切换能力开关,并在任务进度上同步 tool_run_progress_enabled。
|
||||
* 核心逻辑:Catalog 强制项由复选框 disabled 拦住;这里只写用户可改的布尔值。
|
||||
* @param key - capabilities 字段
|
||||
* @param checked - Element 复选框回传的新值
|
||||
*/
|
||||
const handleCapabilityChange = (key: keyof AgentCapabilities, checked: boolean) => {
|
||||
props.form.capabilities[key] = checked;
|
||||
const handleCapabilityChange = (key: keyof AgentCapabilities, checked: string | number | boolean) => {
|
||||
const enabled = checked === true;
|
||||
props.form.capabilities[key] = enabled;
|
||||
if (key === 'task_progress') {
|
||||
props.form.tool_run_progress_enabled = checked;
|
||||
props.form.tool_run_progress_enabled = enabled;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-4">
|
||||
<div class="mb-4">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">
|
||||
{{ t('admin.agent.capabilities.title') }}
|
||||
</div>
|
||||
<p class="mt-1 text-sm leading-6 text-secondary">
|
||||
{{ t('admin.agent.capabilities.subtitle') }}
|
||||
</p>
|
||||
<div class="agent-form-span agent-form-panel">
|
||||
<div class="agent-panel-head">
|
||||
<div class="agent-panel-title">{{ t('admin.agent.capabilities.title') }}</div>
|
||||
<p class="hx-element-hint">{{ t('admin.agent.capabilities.subtitle') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-3 md:grid-cols-2">
|
||||
<label
|
||||
<div class="agent-cap-grid">
|
||||
<ElCheckbox
|
||||
v-for="item in capabilityItems"
|
||||
:key="item.key"
|
||||
class="inline-flex items-start gap-2 rounded-xl border border-default bg-white px-3 py-2 text-sm text-secondary"
|
||||
:class="{ 'opacity-80': item.forced }"
|
||||
:model-value="form.capabilities[item.key]"
|
||||
:disabled="item.forced"
|
||||
@change="handleCapabilityChange(item.key, $event)"
|
||||
>
|
||||
<input
|
||||
v-model="form.capabilities[item.key]"
|
||||
type="checkbox"
|
||||
class="mt-0.5 accent-brand-600"
|
||||
:disabled="item.forced"
|
||||
@change="item.key === 'task_progress'
|
||||
? handleCapabilityChange('task_progress', ($event.target as HTMLInputElement).checked)
|
||||
: undefined"
|
||||
/>
|
||||
<span>
|
||||
<span class="font-medium text-primary">{{ item.label }}</span>
|
||||
<span class="mt-1 block text-xs leading-5 text-muted">{{ item.hint }}</span>
|
||||
<span v-if="item.forced" class="mt-1 block text-xs leading-5 text-amber-600">
|
||||
{{ t('admin.agent.capabilities.forcedByCatalog') }}
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<span>{{ item.label }}</span>
|
||||
<span class="hx-element-hint">{{ item.hint }}</span>
|
||||
<ElTag v-if="item.forced" type="warning" effect="light">
|
||||
{{ t('admin.agent.capabilities.forcedByCatalog') }}
|
||||
</ElTag>
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.agent-form-span {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.agent-form-panel {
|
||||
margin-bottom: 14px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.agent-panel-head {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.agent-panel-title {
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.agent-cap-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.agent-cap-grid :deep(.el-checkbox) {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
align-items: flex-start;
|
||||
margin-right: 0;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.agent-cap-grid :deep(.el-checkbox__label) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 4px;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.agent-cap-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
+138
-71
@@ -1,71 +1,138 @@
|
||||
/**␍
|
||||
* features/admin/modules/agents/components/AgentToolRunProgressConfig.vue␍
|
||||
* 用途:应用管理表单中的任务进度关联配置(排程绑定、轮询间隔、运行期锁输入)。␍
|
||||
* 依赖:agent.types AgentFormState、schedule.types ScheduleTask、vue-i18n。␍
|
||||
* 逻辑:task_progress 能力开关由 AgentCapabilitiesConfig 维护;本组件只写 bound_schedule_task_id 与 handler_config 轮询参数。␍
|
||||
*/␍
|
||||
<script setup lang="ts">␍
|
||||
import type { AgentFormState } from '@/features/admin/types/agent.types';␍
|
||||
import type { ScheduleTask } from '@/shared/types/schedule.types';␍
|
||||
␍
|
||||
defineProps<{␍
|
||||
form: AgentFormState;␍
|
||||
scheduleTasks: ScheduleTask[];␍
|
||||
/** file_check 等类型需绑定排程任务时才展示关联字段。 */␍
|
||||
requiresScheduleTask?: boolean;␍
|
||||
}>();␍
|
||||
</script>␍
|
||||
␍
|
||||
<template>␍
|
||||
<div class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-5 space-y-4">␍
|
||||
<div>␍
|
||||
<h4 class="text-sm font-semibold text-primary">{{ $t('admin.agent.toolRunProgress.title') }}</h4>␍
|
||||
<p class="mt-1 text-xs text-muted">{{ $t('admin.agent.toolRunProgress.subtitle') }}</p>␍
|
||||
</div>␍
|
||||
␍
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">␍
|
||||
<div v-if="requiresScheduleTask" class="space-y-2">␍
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">␍
|
||||
{{ $t('admin.agent.toolRunProgress.scheduleTaskId') }}␍
|
||||
</label>␍
|
||||
<select␍
|
||||
v-model="form.bound_schedule_task_id"␍
|
||||
class="w-full input-field text-sm"␍
|
||||
:disabled="scheduleTasks.length === 0"␍
|
||||
@change="form.schedule_task_id = form.bound_schedule_task_id"␍
|
||||
>␍
|
||||
<option :value="null">␍
|
||||
{{ scheduleTasks.length === 0␍
|
||||
? $t('admin.agent.toolRunProgress.noScheduleTasks')␍
|
||||
: $t('admin.agent.toolRunProgress.selectScheduleTask') }}␍
|
||||
</option>␍
|
||||
<option v-for="task in scheduleTasks" :key="task.id" :value="task.id">␍
|
||||
{{ task.name }}␍
|
||||
</option>␍
|
||||
</select>␍
|
||||
<p class="text-xs text-muted">{{ $t('admin.agent.toolRunProgress.scheduleTaskHint') }}</p>␍
|
||||
</div>␍
|
||||
␍
|
||||
<div v-if="requiresScheduleTask" class="space-y-2">␍
|
||||
<label class="text-xs font-bold text-muted uppercase tracking-wider">␍
|
||||
{{ $t('admin.agent.toolRunProgress.pollInterval') }}␍
|
||||
</label>␍
|
||||
<input␍
|
||||
v-model.number="form.poll_interval_seconds"␍
|
||||
type="number"␍
|
||||
min="1"␍
|
||||
max="30"␍
|
||||
class="w-full input-field text-sm"␍
|
||||
/>␍
|
||||
</div>␍
|
||||
␍
|
||||
<div v-if="requiresScheduleTask" class="md:col-span-2">␍
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">␍
|
||||
<input v-model="form.lock_input_when_running" type="checkbox" class="admin-checkbox" />␍
|
||||
<span>{{ $t('admin.agent.toolRunProgress.lockInput') }}</span>␍
|
||||
</label>␍
|
||||
</div>␍
|
||||
</div>␍
|
||||
</div>␍
|
||||
</template>␍
|
||||
␍
|
||||
/**
|
||||
* features/admin/modules/agents/components/AgentToolRunProgressConfig.vue
|
||||
* 用途:应用管理表单中的任务进度关联配置(排程绑定、轮询间隔、运行期锁输入)。
|
||||
* 依赖:element-plus 表单控件、agent.types AgentFormState、schedule.types ScheduleTask、vue-i18n。
|
||||
* 逻辑:task_progress 能力开关由 AgentCapabilitiesConfig 维护;本组件只写 bound_schedule_task_id 与 handler_config 轮询参数。内部字段已换 Element。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElCheckbox,
|
||||
ElFormItem,
|
||||
ElInputNumber,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
} from 'element-plus';
|
||||
import type { AgentFormState } from '@/features/admin/types/agent.types';
|
||||
import type { ScheduleTask } from '@/shared/types/schedule.types';
|
||||
|
||||
const props = defineProps<{
|
||||
form: AgentFormState;
|
||||
scheduleTasks: ScheduleTask[];
|
||||
/** file_check 等类型需绑定排程任务时才展示关联字段。 */
|
||||
requiresScheduleTask?: boolean;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 选择关联排程。清空写回 null,并同步 schedule_task_id。
|
||||
* @param value - 选中的排程 id;清空为 undefined
|
||||
*/
|
||||
function onScheduleTaskChange(value: number | null | undefined): void {
|
||||
const taskId = typeof value === 'number' ? value : null;
|
||||
props.form.bound_schedule_task_id = taskId;
|
||||
props.form.schedule_task_id = taskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮询间隔限制在 1 到 30 秒。清空时回落到 1,避免写成空值。
|
||||
* @param value - 数字输入框的新值
|
||||
*/
|
||||
function onPollIntervalChange(value: number | null | undefined): void {
|
||||
const next = Number(value);
|
||||
props.form.poll_interval_seconds = Number.isFinite(next) ? Math.min(30, Math.max(1, next)) : 1;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="agent-form-span agent-form-panel">
|
||||
<div class="agent-panel-head">
|
||||
<div class="agent-panel-title">{{ t('admin.agent.toolRunProgress.title') }}</div>
|
||||
<p class="hx-element-hint">{{ t('admin.agent.toolRunProgress.subtitle') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="requiresScheduleTask" class="agent-inner-grid">
|
||||
<ElFormItem :label="t('admin.agent.toolRunProgress.scheduleTaskId')">
|
||||
<ElSelect
|
||||
:model-value="form.bound_schedule_task_id ?? undefined"
|
||||
clearable
|
||||
:disabled="scheduleTasks.length === 0"
|
||||
:placeholder="scheduleTasks.length === 0
|
||||
? t('admin.agent.toolRunProgress.noScheduleTasks')
|
||||
: t('admin.agent.toolRunProgress.selectScheduleTask')"
|
||||
@update:model-value="onScheduleTaskChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="task in scheduleTasks"
|
||||
:key="task.id"
|
||||
:label="task.name"
|
||||
:value="task.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
<p class="hx-element-hint">{{ t('admin.agent.toolRunProgress.scheduleTaskHint') }}</p>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem :label="t('admin.agent.toolRunProgress.pollInterval')">
|
||||
<ElInputNumber
|
||||
:model-value="form.poll_interval_seconds"
|
||||
:min="1"
|
||||
:max="30"
|
||||
:step="1"
|
||||
controls-position="right"
|
||||
@update:model-value="onPollIntervalChange"
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem class="agent-inner-span">
|
||||
<ElCheckbox v-model="form.lock_input_when_running">
|
||||
{{ t('admin.agent.toolRunProgress.lockInput') }}
|
||||
</ElCheckbox>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.agent-form-span {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.agent-form-panel {
|
||||
margin-bottom: 14px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.agent-panel-head {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.agent-panel-title {
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.agent-inner-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
column-gap: 16px;
|
||||
}
|
||||
|
||||
.agent-inner-grid :deep(.el-select),
|
||||
.agent-inner-grid :deep(.el-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.agent-inner-span {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.agent-inner-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,14 +1,19 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/AnnouncementsPage.vue
|
||||
* 公告管理独立页面:全宽表格列表 + 发布/编辑/详情居中弹窗。
|
||||
* 依赖:useAnnouncementsAdmin、AnnouncementFormModal、AnnouncementDetailModal、DeleteConfirmDialog。
|
||||
* 逻辑:路由 /admin/announcements 挂载本页;列表摘要截断,完整内容在详情弹窗查看。
|
||||
* 用途:公告管理列表。一张卡片里放标题、发布按钮和表格。
|
||||
* 依赖:AdminListPage、useAnnouncementsAdmin、element-plus、公告表单和详情对话框。
|
||||
* 逻辑:路由 /admin/announcements。骨架用 AdminListPage。发布、编辑、查看仍由本页的两个对话框完成。删除用 Element 确认框。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Eye, Plus, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElTable, ElTableColumn } 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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import type { AdminAnnouncementRow } from '@/features/admin/types/admin.types';
|
||||
import AnnouncementDetailModal from './components/AnnouncementDetailModal.vue';
|
||||
import AnnouncementFormModal from './components/AnnouncementFormModal.vue';
|
||||
import { useAnnouncementsAdmin } from './composables/useAnnouncementsAdmin';
|
||||
@@ -23,8 +28,6 @@ const {
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDetailModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
@@ -34,98 +37,65 @@ const {
|
||||
editFromDetail,
|
||||
saveAnnouncement,
|
||||
deleteAnnouncementItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
truncateAnnouncementPreview,
|
||||
formatPublishedAt,
|
||||
} = useAnnouncementsAdmin();
|
||||
|
||||
/**
|
||||
* 打开编辑对话框。表格行类型较宽,这里收成公告行。
|
||||
* @param row - 当前表格行
|
||||
*/
|
||||
function editAnnouncement(row: AdminAnnouncementRow): void {
|
||||
openEditModal(row);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
<AdminListPage :loading="isLoading">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.announcement.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.announcement.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateModal">
|
||||
{{ t('admin.announcement.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.announcement.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.announcement.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span>{{ t('admin.announcement.add') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.announcement.headers.title') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-44">{{ t('admin.announcement.headers.publishedAt') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.announcement.headers.preview') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-36">{{ t('admin.announcement.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="announcements.length === 0">
|
||||
<td colspan="4" class="px-6 admin-table-empty">{{ t('admin.announcement.noData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="ann in announcements" :key="ann.id" class="group">
|
||||
<td class="px-6 py-4">
|
||||
<div class="font-medium text-primary text-sm">{{ ann.title }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-muted whitespace-nowrap">
|
||||
{{ formatPublishedAt(ann.created_at) }}
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm text-secondary truncate max-w-md" :title="ann.content">
|
||||
{{ truncateAnnouncementPreview(ann.content) }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-end gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-blue-600 hover:bg-blue-50 rounded-lg transition-colors"
|
||||
:title="t('admin.announcement.actions.view')"
|
||||
@click="openDetailModal(ann)"
|
||||
>
|
||||
<Eye class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors"
|
||||
:title="t('admin.announcement.actions.edit')"
|
||||
@click="openEditModal(ann)"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg transition-colors"
|
||||
:title="t('admin.announcement.actions.delete')"
|
||||
@click="deleteAnnouncementItem(ann.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
<ElTable
|
||||
class="hx-admin-table"
|
||||
:data="announcements"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.announcement.noData')"
|
||||
>
|
||||
<ElTableColumn prop="title" :label="t('admin.announcement.headers.title')" min-width="180" />
|
||||
<ElTableColumn :label="t('admin.announcement.headers.publishedAt')" min-width="180">
|
||||
<template #default="{ row }">{{ formatPublishedAt(row.created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.announcement.headers.preview')" min-width="240">
|
||||
<template #default="{ row }">
|
||||
<p class="announcement-preview" :title="row.content">{{ truncateAnnouncementPreview(row.content) }}</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.announcement.headers.actions')" width="200" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openDetailModal(row as AdminAnnouncementRow)">
|
||||
{{ t('admin.announcement.actions.view') }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="editAnnouncement(row as AdminAnnouncementRow)">
|
||||
{{ t('admin.announcement.actions.edit') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="deleteAnnouncementItem((row as AdminAnnouncementRow).id)">
|
||||
{{ t('admin.announcement.actions.delete') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</AdminListPage>
|
||||
|
||||
<AnnouncementFormModal
|
||||
:visible="showFormModal"
|
||||
@@ -134,19 +104,18 @@ onMounted(() => {
|
||||
@close="closeFormModal"
|
||||
@save="saveAnnouncement"
|
||||
/>
|
||||
|
||||
<AnnouncementDetailModal
|
||||
:visible="showDetailModal"
|
||||
:announcement="viewingAnnouncement"
|
||||
@close="closeDetailModal"
|
||||
@edit="editFromDetail"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@cancel="closeDeleteConfirm"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.announcement-preview {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
+52
-30
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/components/AnnouncementDetailModal.vue
|
||||
* 公告详情居中弹窗,展示完整标题、时间与正文。
|
||||
* 依赖:AdminAnnouncementRow、admin 通用 modal 样式。
|
||||
* 逻辑:AnnouncementsPage 列表「查看」打开;可跳转编辑或关闭。
|
||||
* 用途:只读展示公告标题、发布时间和正文。
|
||||
* 依赖:element-plus 对话框和描述列表、AdminAnnouncementRow。
|
||||
* 逻辑:AnnouncementsPage 点「查看」后传入。可关闭,或 emit edit 交给页面打开编辑框。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDescriptions, ElDescriptionsItem, ElDialog } from 'element-plus';
|
||||
import type { AdminAnnouncementRow } from '@/features/admin/types/admin.types';
|
||||
|
||||
defineProps<{
|
||||
@@ -25,34 +26,55 @@ const { t } = useI18n();
|
||||
* @param iso - 后端返回的 created_at
|
||||
* @returns 本地化日期时间字符串
|
||||
*/
|
||||
const formatDateTime = (iso: string): string => new Date(iso).toLocaleString();
|
||||
function formatDateTime(iso: string): string {
|
||||
return new Date(iso).toLocaleString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible && announcement" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-3xl 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.announcement.viewDetail') }}</h3>
|
||||
<p class="text-xs text-muted mt-2">{{ formatDateTime(announcement.created_at) }}</p>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 overflow-y-auto space-y-4">
|
||||
<div>
|
||||
<p class="text-xs font-semibold text-muted uppercase tracking-wider mb-1.5">
|
||||
{{ t('admin.announcement.fields.title') }}
|
||||
</p>
|
||||
<p class="text-base font-semibold text-primary">{{ announcement.title }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xs font-semibold text-muted uppercase tracking-wider mb-1.5">
|
||||
{{ t('admin.announcement.fields.content') }}
|
||||
</p>
|
||||
<p class="text-sm text-secondary whitespace-pre-wrap leading-relaxed">{{ announcement.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.close') }}</button>
|
||||
<button type="button" class="btn-primary" @click="emit('edit')">{{ t('admin.edit') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible && !!announcement"
|
||||
:title="t('admin.announcement.viewDetail')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<template v-if="announcement">
|
||||
<p class="section-desc">{{ formatDateTime(announcement.created_at) }}</p>
|
||||
<ElDescriptions class="announcement-detail" :column="1" border>
|
||||
<ElDescriptionsItem :label="t('admin.announcement.fields.title')">
|
||||
{{ announcement.title }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.announcement.fields.content')">
|
||||
<p class="announcement-detail__content">{{ announcement.content }}</p>
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
</template>
|
||||
<template #footer>
|
||||
<ElButton @click="emit('close')">{{ t('admin.close') }}</ElButton>
|
||||
<ElButton type="primary" @click="emit('edit')">{{ t('admin.edit') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.announcement-detail {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.announcement-detail__content {
|
||||
white-space: pre-wrap;
|
||||
max-height: 50vh;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
+38
-34
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/components/AnnouncementFormModal.vue
|
||||
* 公告创建/编辑居中弹窗。
|
||||
* 依赖:AnnouncementFormState、admin 通用 modal 样式。
|
||||
* 逻辑:AnnouncementsPage 打开本组件;提交时 emit save,由 composable 调 API。
|
||||
* 用途:公告发布和编辑对话框。标题一行,正文多行。
|
||||
* 依赖:element-plus 对话框和表单、AnnouncementFormState。
|
||||
* 逻辑:AnnouncementsPage 打开本组件。提交时 emit save,由 composable 调接口。样式跟页面已引入的 Element 皮肤走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElForm, ElFormItem, ElInput } from 'element-plus';
|
||||
import type { AnnouncementFormState } from '@/features/admin/types/announcement.types';
|
||||
|
||||
defineProps<{
|
||||
@@ -20,38 +21,41 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</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">
|
||||
{{ form.id ? t('admin.announcement.edit') : t('admin.announcement.add') }}
|
||||
</h3>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.announcement.fields.title') }}</label>
|
||||
<input v-model="form.title" type="text" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.announcement.fields.content') }}</label>
|
||||
<textarea v-model="form.content" rows="10" class="input-field text-sm resize-y min-h-[200px]" />
|
||||
</div>
|
||||
</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="isSaving" @click="emit('save')">
|
||||
{{
|
||||
isSaving
|
||||
? t('admin.save') + '...'
|
||||
: form.id
|
||||
? t('admin.update')
|
||||
: t('admin.announcement.publish')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="form.id ? t('admin.announcement.edit') : t('admin.announcement.add')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!isSaving"
|
||||
:show-close="!isSaving"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<ElForm label-position="top" :model="form" @submit.prevent="emit('save')">
|
||||
<ElFormItem :label="t('admin.announcement.fields.title')" required>
|
||||
<ElInput v-model="form.title" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.announcement.fields.content')" required>
|
||||
<ElInput v-model="form.content" type="textarea" :rows="8" />
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ form.id ? t('admin.update') : t('admin.announcement.publish') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
+24
-53
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/announcements/composables/useAnnouncementsAdmin.ts
|
||||
* 公告管理:列表、发布/编辑弹窗、详情弹窗、删除。
|
||||
* 依赖:admin.api、announcement.types、useMessage。
|
||||
* 逻辑:AnnouncementsPage 调用本 composable 驱动表格与两个居中弹窗。
|
||||
* 依赖:admin.api、announcement.types、useMessage、element-plus 确认框。
|
||||
* 逻辑:AnnouncementsPage 调用本 composable 驱动表格与两个对话框。删除用 ElMessageBox。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
createAnnouncement,
|
||||
deleteAnnouncement,
|
||||
@@ -33,10 +34,6 @@ export function useAnnouncementsAdmin() {
|
||||
const showFormModal = ref(false);
|
||||
const showDetailModal = ref(false);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/**
|
||||
* 拉取公告列表并写入 announcements。
|
||||
* @returns Promise<void>
|
||||
@@ -60,36 +57,6 @@ export function useAnnouncementsAdmin() {
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开删除确认对话框并绑定确认后的删除动作。
|
||||
* @param message - 确认文案
|
||||
* @param action - 用户确认后执行的异步删除逻辑
|
||||
*/
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
/** 关闭删除确认对话框并清空待执行动作。 */
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行删除确认对话框中绑定的删除动作。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
}
|
||||
};
|
||||
|
||||
/** 打开「发布公告」弹窗并重置表单。 */
|
||||
const openCreateModal = (): void => {
|
||||
form.value = createEmptyAnnouncementForm();
|
||||
@@ -168,22 +135,30 @@ export function useAnnouncementsAdmin() {
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除指定公告,删除前弹出确认框。
|
||||
* 删除指定公告。先用 Element 确认框询问,取消则不请求。
|
||||
* 核心逻辑:MessageBox 取消时 reject,这里吞掉;确定后删除并刷新列表。
|
||||
* @param id - 公告主键
|
||||
*/
|
||||
const deleteAnnouncementItem = (id: number): void => {
|
||||
openDeleteConfirm(t('admin.announcement.confirmDelete'), async () => {
|
||||
try {
|
||||
await deleteAnnouncement(id);
|
||||
if (viewingAnnouncement.value?.id === id) {
|
||||
closeDetailModal();
|
||||
}
|
||||
await loadAnnouncements();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
const deleteAnnouncementItem = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.announcement.confirmDelete'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteAnnouncement(id);
|
||||
if (viewingAnnouncement.value?.id === id) {
|
||||
closeDetailModal();
|
||||
}
|
||||
});
|
||||
await loadAnnouncements();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -201,8 +176,6 @@ export function useAnnouncementsAdmin() {
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDetailModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
@@ -212,8 +185,6 @@ export function useAnnouncementsAdmin() {
|
||||
editFromDetail,
|
||||
saveAnnouncement,
|
||||
deleteAnnouncementItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
truncateAnnouncementPreview,
|
||||
formatPublishedAt,
|
||||
};
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
/**
|
||||
* features/admin/modules/approvals/ApprovalsPage.vue
|
||||
* 用户注册审批独立页面。路由:/admin/approvals
|
||||
* 用途:用户注册审批列表。一张卡片里放标题和待审表格。
|
||||
* 依赖:AdminListPage、useApprovalsAdmin、element-plus、roleLabel。
|
||||
* 逻辑:路由未挂进当前菜单。通过和拒绝由 composable 弹出 Element 确认框后调接口。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ShieldCheck, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { CircleCheck, Delete } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElTable, ElTableColumn, 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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import { adminRoleLabel } from '@/features/admin/utils/roleLabel';
|
||||
import type { AdminUserRow } from '@/features/admin/types/admin.types';
|
||||
import { useApprovalsAdmin } from './composables/useApprovalsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -15,13 +22,9 @@ const { t } = useI18n();
|
||||
const {
|
||||
pendingUsers,
|
||||
isLoading,
|
||||
showConfirmDialog,
|
||||
confirmMessage,
|
||||
loadAll,
|
||||
approveUser,
|
||||
rejectUser,
|
||||
closeConfirm,
|
||||
confirmActionHandler,
|
||||
} = useApprovalsAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
@@ -30,80 +33,58 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
<AdminListPage :loading="isLoading">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.approval.title') }}</h2>
|
||||
<p class="section-desc">{{ t('admin.approval.subtitle') }}</p>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.approval.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.approval.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.username') }}</th>
|
||||
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.nameId') }}</th>
|
||||
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.contact') }}</th>
|
||||
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.role') }}</th>
|
||||
<th class="px-8 py-4 text-right text-xs">{{ t('admin.approval.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="pendingUsers.length === 0">
|
||||
<td colspan="5" class="px-8 admin-table-empty">{{ t('admin.approval.noPending') }}</td>
|
||||
</tr>
|
||||
<tr v-for="user in pendingUsers" :key="user.id">
|
||||
<td class="px-8 py-5 text-sm font-medium text-primary">
|
||||
<div>{{ user.username }}</div>
|
||||
<div class="text-xs text-muted font-normal">{{ user.email }}</div>
|
||||
</td>
|
||||
<td class="px-8 py-5 text-sm text-muted">
|
||||
<div>{{ user.real_name || '-' }}</div>
|
||||
<div class="text-xs text-muted font-mono">{{ user.employee_id || '-' }}</div>
|
||||
</td>
|
||||
<td class="px-8 py-5 text-sm text-muted">{{ user.phone_number || '-' }}</td>
|
||||
<td class="px-8 py-5">
|
||||
<span
|
||||
class="px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 border border-yellow-200"
|
||||
>
|
||||
{{ adminRoleLabel(t, user.role, user.role_name) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-8 py-5 text-right flex items-center justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 text-green-600 bg-green-50 rounded-lg hover:bg-green-100 transition-colors"
|
||||
:title="t('admin.approval.confirmApprove')"
|
||||
@click="approveUser(user.id)"
|
||||
>
|
||||
<ShieldCheck class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 text-red-600 bg-red-50 rounded-lg hover:bg-red-100 transition-colors"
|
||||
:title="t('admin.approval.confirmReject')"
|
||||
@click="rejectUser(user.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showConfirmDialog"
|
||||
:message="confirmMessage"
|
||||
@cancel="closeConfirm"
|
||||
@confirm="confirmActionHandler"
|
||||
/>
|
||||
</section>
|
||||
<ElTable
|
||||
class="hx-admin-table"
|
||||
:data="pendingUsers"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.approval.noPending')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.approval.headers.username')" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div>{{ (row as AdminUserRow).username }}</div>
|
||||
<p class="hx-element-hint">{{ (row as AdminUserRow).email }}</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.approval.headers.nameId')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<div>{{ (row as AdminUserRow).real_name || '-' }}</div>
|
||||
<p class="hx-element-hint">{{ (row as AdminUserRow).employee_id || '-' }}</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.approval.headers.contact')" min-width="140">
|
||||
<template #default="{ row }">{{ (row as AdminUserRow).phone_number || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.approval.headers.role')" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<ElTag effect="light" type="warning">
|
||||
{{ adminRoleLabel(t, (row as AdminUserRow).role, (row as AdminUserRow).role_name) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.approval.headers.actions')" width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:icon="CircleCheck"
|
||||
:title="t('admin.approval.confirmApprove')"
|
||||
@click="approveUser((row as AdminUserRow).id)"
|
||||
/>
|
||||
<ElButton
|
||||
link
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
:title="t('admin.approval.confirmReject')"
|
||||
@click="rejectUser((row as AdminUserRow).id)"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</AdminListPage>
|
||||
</template>
|
||||
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/approvals/composables/useApprovalsAdmin.ts
|
||||
* 用户注册审批:待审列表、通过、拒绝。
|
||||
* 用途:用户注册审批的待审列表、通过和拒绝。
|
||||
* 依赖:admin.api、useMessage、useAdminNavBadges、element-plus 的确认框。
|
||||
* 逻辑:ApprovalsPage 调用本模块;通过和拒绝都先弹出 Element 确认框,成功后刷新列表和导航角标。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import { approveAdminUser, listAdminUsers, rejectAdminUser } from '@/features/admin/api/admin.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { useAdminNavBadges } from '@/features/admin/composables/useAdminNavBadges';
|
||||
@@ -17,10 +20,6 @@ export function useApprovalsAdmin() {
|
||||
const users = ref<AdminUserRow[]>([]);
|
||||
const isLoading = ref(true);
|
||||
|
||||
const showConfirmDialog = ref(false);
|
||||
const confirmMessage = ref('');
|
||||
let confirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
const pendingUsers = computed(() => users.value.filter((u) => u.status === 'pending'));
|
||||
|
||||
const loadUsers = async (): Promise<void> => {
|
||||
@@ -38,61 +37,61 @@ export function useApprovalsAdmin() {
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
const openConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
confirmMessage.value = message;
|
||||
confirmAction = action;
|
||||
showConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
const closeConfirm = (): void => {
|
||||
showConfirmDialog.value = false;
|
||||
confirmAction = null;
|
||||
};
|
||||
|
||||
const confirmActionHandler = async (): Promise<void> => {
|
||||
if (!confirmAction) return;
|
||||
/**
|
||||
* 弹出确认框。点取消时 Element 会拒绝 Promise,这里吞掉,不当成失败。
|
||||
* @param message - 确认正文
|
||||
* @returns 用户是否点了确定
|
||||
*/
|
||||
async function confirmAction(message: string): Promise<boolean> {
|
||||
try {
|
||||
await confirmAction();
|
||||
} finally {
|
||||
closeConfirm();
|
||||
await ElMessageBox.confirm(message, t('common.deleteDialog.defaultTitle'), {
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
type: 'warning',
|
||||
});
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const approveUser = (userId: number): void => {
|
||||
openConfirm(t('admin.approval.confirmApprove'), async () => {
|
||||
try {
|
||||
await approveAdminUser(userId);
|
||||
await loadUsers();
|
||||
await refreshBadges();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 通过一条待审注册。先确认,再调审批接口并刷新角标。
|
||||
* @param userId - 待审用户主键
|
||||
*/
|
||||
async function approveUser(userId: number): Promise<void> {
|
||||
if (!(await confirmAction(t('admin.approval.confirmApprove')))) return;
|
||||
try {
|
||||
await approveAdminUser(userId);
|
||||
await loadUsers();
|
||||
await refreshBadges();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
||||
}
|
||||
}
|
||||
|
||||
const rejectUser = (userId: number): void => {
|
||||
openConfirm(t('admin.approval.confirmReject'), async () => {
|
||||
try {
|
||||
await rejectAdminUser(userId);
|
||||
await loadUsers();
|
||||
await refreshBadges();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 拒绝一条待审注册。先确认,再调拒绝接口并刷新角标。
|
||||
* @param userId - 待审用户主键
|
||||
*/
|
||||
async function rejectUser(userId: number): Promise<void> {
|
||||
if (!(await confirmAction(t('admin.approval.confirmReject')))) return;
|
||||
try {
|
||||
await rejectAdminUser(userId);
|
||||
await loadUsers();
|
||||
await refreshBadges();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
pendingUsers,
|
||||
isLoading,
|
||||
showConfirmDialog,
|
||||
confirmMessage,
|
||||
loadAll,
|
||||
approveUser,
|
||||
rejectUser,
|
||||
closeConfirm,
|
||||
confirmActionHandler,
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,21 @@
|
||||
/**
|
||||
* features/admin/modules/dashboard/DashboardPage.vue
|
||||
* 管理后台仪表盘。路由:/admin/dashboard
|
||||
* 用途:管理后台仪表盘,四张可点击的统计卡。
|
||||
* 依赖:useDashboardAdmin、element-plus。
|
||||
* 逻辑:路由 /admin/dashboard。统计来自 useDashboardAdmin。点击分别进入应用配置、应用权限和数据报表。本页不是列表,不用 AdminListPage。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { BarChart2, Bot, MessageSquare, Users } from 'lucide-vue-next';
|
||||
import { ChatDotRound, DataAnalysis, Monitor, User } from '@element-plus/icons-vue';
|
||||
import { ElCard, ElIcon, ElLoading, ElStatistic, 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 { useDashboardAdmin } from './composables/useDashboardAdmin';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
@@ -21,74 +28,87 @@ const {
|
||||
loadAll,
|
||||
} = useDashboardAdmin();
|
||||
|
||||
/**
|
||||
* 进入指定管理页。
|
||||
* @param name - 路由名
|
||||
* @param table - 数据报表表名;其它页面不传
|
||||
*/
|
||||
function openAdmin(name: string, table?: string): void {
|
||||
if (table) {
|
||||
void router.push({ name, params: { table } });
|
||||
return;
|
||||
}
|
||||
void router.push({ name });
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section>
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<div v-else class="grid grid-cols-1 sm:grid-cols-2 gap-6 animate-fade-in">
|
||||
<div
|
||||
class="card card-ds-interactive p-6 group cursor-pointer"
|
||||
@click="router.push({ name: 'AdminAgents' })"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="p-3 bg-brand-50 rounded-xl group-hover:bg-brand-100 transition-colors">
|
||||
<Bot class="w-6 h-6 text-brand-600" />
|
||||
<section v-loading="isLoading" class="admin-dash">
|
||||
<h2 class="section-title">{{ t('admin.nav.dashboard') }}</h2>
|
||||
<div v-if="!isLoading" class="admin-dash__grid">
|
||||
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminAgents')">
|
||||
<div class="admin-dash__row">
|
||||
<ElIcon :size="22"><Monitor /></ElIcon>
|
||||
<ElTag type="success" effect="light">+2 {{ t('admin.dash.new') }}</ElTag>
|
||||
</div>
|
||||
<span class="text-xs font-medium text-green-600 bg-green-50 px-2 py-1 rounded-full">
|
||||
+2 {{ t('admin.dash.new') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-primary mb-1">{{ agentCount }}</div>
|
||||
<div class="text-sm text-muted font-medium">{{ t('admin.dash.activeAgents') }}</div>
|
||||
</div>
|
||||
<ElStatistic :title="t('admin.dash.activeAgents')" :value="agentCount" />
|
||||
</ElCard>
|
||||
|
||||
<div
|
||||
class="card card-ds-interactive p-6 group cursor-pointer"
|
||||
@click="router.push({ name: 'AdminPermissions' })"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="p-3 bg-purple-50 rounded-xl group-hover:bg-purple-100 transition-colors">
|
||||
<Users class="w-6 h-6 text-purple-600" />
|
||||
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminPermissions')">
|
||||
<div class="admin-dash__row">
|
||||
<ElIcon :size="22"><User /></ElIcon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-primary mb-1">{{ userCount }}</div>
|
||||
<div class="text-sm text-muted font-medium">{{ t('admin.dash.totalUsers') }}</div>
|
||||
</div>
|
||||
<ElStatistic :title="t('admin.dash.totalUsers')" :value="userCount" />
|
||||
</ElCard>
|
||||
|
||||
<div
|
||||
class="card card-ds-interactive p-6 group cursor-pointer"
|
||||
@click="router.push({ name: 'AdminReports', params: { table: 'chat_logs' } })"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="p-3 bg-indigo-50 rounded-xl group-hover:bg-indigo-100 transition-colors">
|
||||
<MessageSquare class="w-6 h-6 text-indigo-600" />
|
||||
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminReports', 'chat_logs')">
|
||||
<div class="admin-dash__row">
|
||||
<ElIcon :size="22"><ChatDotRound /></ElIcon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-primary mb-1">{{ totalConversations }}</div>
|
||||
<div class="text-sm text-muted font-medium">{{ t('admin.dash.totalConversations') }}</div>
|
||||
</div>
|
||||
<ElStatistic :title="t('admin.dash.totalConversations')" :value="totalConversations" />
|
||||
</ElCard>
|
||||
|
||||
<div
|
||||
class="card card-ds-interactive p-6 group cursor-pointer"
|
||||
@click="router.push({ name: 'AdminReports', params: { table: 'feedbacks' } })"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="p-3 bg-orange-50 rounded-xl group-hover:bg-orange-100 transition-colors">
|
||||
<BarChart2 class="w-6 h-6 text-orange-600" />
|
||||
<ElCard shadow="hover" class="admin-dash__card" @click="openAdmin('AdminReports', 'feedbacks')">
|
||||
<div class="admin-dash__row">
|
||||
<ElIcon :size="22"><DataAnalysis /></ElIcon>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-primary mb-1">
|
||||
{{ avgScore.toFixed(1) }}
|
||||
</div>
|
||||
<div class="text-sm text-muted font-medium">{{ t('admin.dash.avgRating') }}</div>
|
||||
<ElStatistic :title="t('admin.dash.avgRating')" :value="avgScore" :precision="1" />
|
||||
</ElCard>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-dash {
|
||||
min-height: 16rem;
|
||||
}
|
||||
|
||||
.admin-dash__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.admin-dash__card {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.admin-dash__row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.admin-dash__grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,22 +1,35 @@
|
||||
/**
|
||||
* features/admin/modules/departments/DepartmentsPage.vue
|
||||
* 用途:部门管理独立页面——全宽表格列表 + 列排序 + 创建/编辑居中弹窗。
|
||||
* 依赖:useDepartmentsAdmin、SortableTableHeader、DepartmentFormModal、DeleteConfirmDialog。
|
||||
* 逻辑:路由 /admin/departments;表头排序复用 shared SortableTableHeader + useTableSort。
|
||||
* 用途:部门管理列表。一张卡片里放标题、添加按钮、搜索、表格。
|
||||
* 依赖:AdminListPage、useDepartmentsAdmin、element-plus、部门表单和员工名单弹窗。
|
||||
* 逻辑:路由 /admin/departments。骨架用 AdminListPage。筛选、列和两个弹窗留在本页。
|
||||
* 名称、编码、公司用表头排序,排的是当前过滤结果。删除用 Element 确认框。
|
||||
* 表格用 Element stripe 斑马纹。员工数、编辑、删除用 Element 链接按钮,悬停文案走 i18n title。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Plus, Search, Trash2, Users } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import SortableTableHeader from '@/shared/components/SortableTableHeader.vue';
|
||||
import { Delete, Edit, Plus, User } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
} 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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import type { AdminDepartmentMembersResponse, AdminDepartmentRow } from '@/features/admin/types/admin.types';
|
||||
import DepartmentFormModal from './components/DepartmentFormModal.vue';
|
||||
import DepartmentMembersModal from './components/DepartmentMembersModal.vue';
|
||||
import { useDepartmentsAdmin } from './composables/useDepartmentsAdmin';
|
||||
import { useDepartmentsAdmin, type DeptSortKey } from './composables/useDepartmentsAdmin';
|
||||
import { listAdminDepartmentMembers } from '@/features/admin/api/admin.api';
|
||||
import type { AdminDepartmentMembersResponse } from '@/features/admin/types/admin.types';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const showMembersModal = ref(false);
|
||||
@@ -29,169 +42,149 @@ const {
|
||||
sortKey,
|
||||
sortDir,
|
||||
isLoading,
|
||||
isListLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
toggleSort,
|
||||
applySort,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
closeFormModal,
|
||||
saveDepartment,
|
||||
deleteDepartment,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
} = useDepartmentsAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
const defaultSort = computed(() => ({
|
||||
prop: sortKey.value || 'name',
|
||||
order: sortDir.value === 'desc' ? 'descending' as const : 'ascending' as const,
|
||||
}));
|
||||
|
||||
/** 加载并展示指定部门的员工名单。 */
|
||||
const openDepartmentMembers = async (departmentId: number): Promise<void> => {
|
||||
const emptyText = computed(() => (
|
||||
searchQuery.value.trim() ? t('admin.dept.noSearchResults') : t('admin.dept.noDepts')
|
||||
));
|
||||
|
||||
/**
|
||||
* 把 Element 表头排序交给本地列表。
|
||||
* 核心逻辑:只接受名称、编码、公司;第三次点击 order 为空时清空排序。
|
||||
* @param payload.prop - 列字段
|
||||
* @param payload.order - ascending、descending 或空
|
||||
*/
|
||||
function onSortChange(payload: { prop: string | null; order: string | null }): void {
|
||||
const field = payload.prop;
|
||||
const sortable = field === 'name' || field === 'code' || field === 'company';
|
||||
if (sortable && payload.order) {
|
||||
applySort(field as DeptSortKey, payload.order === 'descending' ? 'desc' : 'asc');
|
||||
return;
|
||||
}
|
||||
applySort('', '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开编辑弹窗。表格插槽行类型较宽,这里收成部门行。
|
||||
* @param row - 当前表格行
|
||||
*/
|
||||
function editDepartment(row: AdminDepartmentRow): void {
|
||||
openEditModal(row);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载并展示指定部门的员工名单。
|
||||
* 核心逻辑:请求成功才打开弹窗;失败只提示,不打开空名单。
|
||||
* @param departmentId - 部门主键
|
||||
*/
|
||||
async function openDepartmentMembers(departmentId: number): Promise<void> {
|
||||
try {
|
||||
departmentMembers.value = await listAdminDepartmentMembers(departmentId) as AdminDepartmentMembersResponse;
|
||||
showMembersModal.value = true;
|
||||
} catch (error) {
|
||||
msg.error((error as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
<AdminListPage :loading="isLoading">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.dept.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.dept.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateModal">
|
||||
{{ t('admin.dept.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElInput
|
||||
v-model="searchQuery"
|
||||
clearable
|
||||
class="dept-filter-search"
|
||||
:placeholder="t('admin.dept.searchPlaceholder')"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.dept.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.dept.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span>{{ t('admin.dept.add') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-filters--inline gap-3">
|
||||
<div class="relative flex-1 min-w-[200px] max-w-sm">
|
||||
<Search class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted pointer-events-none" />
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
type="search"
|
||||
class="admin-table-filter-input w-full pl-9"
|
||||
:placeholder="t('admin.dept.searchPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<!-- 列宽:名称 / 编码 / 公司 / 员工 / 操作 -->
|
||||
<table class="admin-table table-fixed">
|
||||
<colgroup>
|
||||
<col class="w-[25%]" />
|
||||
<col class="w-[20%]" />
|
||||
<col class="w-[30%]" />
|
||||
<col class="w-[12%]" />
|
||||
<col class="w-[13%]" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">
|
||||
<SortableTableHeader
|
||||
column-key="name"
|
||||
:label="t('admin.dept.headers.name')"
|
||||
:active-key="sortKey"
|
||||
:direction="sortDir"
|
||||
@sort="toggleSort"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-xs">
|
||||
<SortableTableHeader
|
||||
column-key="code"
|
||||
:label="t('admin.dept.headers.code')"
|
||||
:active-key="sortKey"
|
||||
:direction="sortDir"
|
||||
@sort="toggleSort"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-xs">
|
||||
<SortableTableHeader
|
||||
column-key="company"
|
||||
:label="t('admin.dept.headers.company')"
|
||||
:active-key="sortKey"
|
||||
:direction="sortDir"
|
||||
@sort="toggleSort"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-center text-xs">{{ t('admin.dept.headers.members') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs">{{ t('admin.dept.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="filteredDepartments.length === 0">
|
||||
<td colspan="5" class="px-6 admin-table-empty">
|
||||
{{ searchQuery.trim() ? t('admin.dept.noSearchResults') : t('admin.dept.noDepts') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="d in filteredDepartments" :key="d.id" class="group">
|
||||
<td class="px-6 py-4">
|
||||
<div class="font-medium text-primary text-sm truncate" :title="d.name">{{ d.name }}</div>
|
||||
<div
|
||||
v-if="d.description"
|
||||
class="text-xs text-muted truncate mt-0.5"
|
||||
:title="d.description"
|
||||
>
|
||||
{{ d.description }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-muted font-mono whitespace-nowrap truncate" :title="d.code || '-'">
|
||||
{{ d.code || '-' }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-muted truncate" :title="d.company || '-'">
|
||||
{{ d.company || '-' }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-center">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center rounded-lg bg-blue-50 p-2 text-blue-600 hover:bg-blue-100"
|
||||
:title="t('admin.dept.actions.viewMembers')"
|
||||
@click="openDepartmentMembers(d.id)"
|
||||
><Users class="w-5 h-5" /><span class="ml-1 text-xs">{{ d.member_count || 0 }}</span></button>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-end gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors"
|
||||
:title="t('admin.dept.actions.edit')"
|
||||
@click="openEditModal(d)"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg transition-colors"
|
||||
:title="t('admin.dept.actions.delete')"
|
||||
@click="deleteDepartment(d.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
<ElTable
|
||||
v-loading="isListLoading"
|
||||
class="hx-admin-table"
|
||||
:data="filteredDepartments"
|
||||
row-key="id"
|
||||
stripe
|
||||
:default-sort="defaultSort"
|
||||
:empty-text="emptyText"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<ElTableColumn prop="name" :label="t('admin.dept.headers.name')" sortable="custom" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div :title="row.name">{{ row.name }}</div>
|
||||
<p v-if="row.description" class="hx-element-hint dept-desc" :title="row.description">
|
||||
{{ row.description }}
|
||||
</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="code" :label="t('admin.dept.headers.code')" sortable="custom" min-width="140">
|
||||
<template #default="{ row }">{{ row.code || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="company" :label="t('admin.dept.headers.company')" sortable="custom" min-width="180">
|
||||
<template #default="{ row }">{{ row.company || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.dept.headers.members')" width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:icon="User"
|
||||
:title="t('admin.dept.actions.viewMembers')"
|
||||
@click="openDepartmentMembers((row as AdminDepartmentRow).id)"
|
||||
>
|
||||
{{ row.member_count || 0 }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.dept.headers.actions')" width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<div class="dept-row-actions">
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:icon="Edit"
|
||||
:title="t('admin.dept.actions.edit')"
|
||||
@click="editDepartment(row as AdminDepartmentRow)"
|
||||
/>
|
||||
<ElButton
|
||||
link
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
:title="t('admin.dept.actions.delete')"
|
||||
@click="deleteDepartment((row as AdminDepartmentRow).id)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</AdminListPage>
|
||||
|
||||
<DepartmentFormModal
|
||||
:visible="showFormModal"
|
||||
@@ -205,12 +198,22 @@ const openDepartmentMembers = async (departmentId: number): Promise<void> => {
|
||||
:data="departmentMembers"
|
||||
@close="showMembersModal = false"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@cancel="closeDeleteConfirm"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.dept-filter-search) {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
.dept-desc {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dept-row-actions {
|
||||
display: inline-flex;
|
||||
justify-content: flex-end;
|
||||
gap: 4px;
|
||||
}
|
||||
</style>
|
||||
+49
-71
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/departments/components/DepartmentFormModal.vue
|
||||
* 用途:部门创建/编辑居中弹窗。
|
||||
* 依赖:DepartmentFormState、admin 通用 modal 样式。
|
||||
* 逻辑:DepartmentsPage 打开本组件;提交时 emit save,由 useDepartmentsAdmin 调 API。
|
||||
* 用途:部门创建和编辑对话框。四个字段,单列。
|
||||
* 依赖:element-plus 对话框和表单、DepartmentFormState。
|
||||
* 逻辑:DepartmentsPage 打开本组件。提交时 emit save,由 useDepartmentsAdmin 调接口。样式跟页面已引入的 Element 皮肤走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElForm, ElFormItem, ElInput } from 'element-plus';
|
||||
import type { DepartmentFormState } from '@/features/admin/types/department.types';
|
||||
|
||||
defineProps<{
|
||||
@@ -20,75 +21,52 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起并重置表单。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-lg 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">
|
||||
{{ form.id ? t('admin.dept.edit') : t('admin.dept.add') }}
|
||||
</h3>
|
||||
</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.dept.fields.name') }}</label>
|
||||
<input
|
||||
v-model="form.name"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.dept.fields.namePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.dept.fields.code') }}</label>
|
||||
<input
|
||||
v-model="form.code"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.dept.fields.codePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.dept.fields.company') }}</label>
|
||||
<input
|
||||
v-model="form.company"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.dept.fields.companyPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.dept.fields.description') }}</label>
|
||||
<textarea
|
||||
v-model="form.description"
|
||||
rows="3"
|
||||
class="input-field text-sm resize-y"
|
||||
:placeholder="t('admin.dept.fields.descriptionPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
</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="isSaving"
|
||||
@click="emit('save')"
|
||||
>
|
||||
{{
|
||||
isSaving
|
||||
? t('admin.save') + '...'
|
||||
: form.id
|
||||
? t('admin.update')
|
||||
: t('admin.add')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="form.id ? t('admin.dept.edit') : t('admin.dept.add')"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!isSaving"
|
||||
:show-close="!isSaving"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<ElForm label-position="top" :model="form" @submit.prevent="emit('save')">
|
||||
<ElFormItem :label="t('admin.dept.fields.name')" required>
|
||||
<ElInput v-model="form.name" :placeholder="t('admin.dept.fields.namePlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.dept.fields.code')">
|
||||
<ElInput v-model="form.code" :placeholder="t('admin.dept.fields.codePlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.dept.fields.company')">
|
||||
<ElInput v-model="form.company" :placeholder="t('admin.dept.fields.companyPlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.dept.fields.description')">
|
||||
<ElInput
|
||||
v-model="form.description"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
:placeholder="t('admin.dept.fields.descriptionPlaceholder')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ form.id ? t('admin.update') : t('admin.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
+59
-31
@@ -1,44 +1,72 @@
|
||||
/**
|
||||
* features/admin/modules/departments/components/DepartmentMembersModal.vue
|
||||
* 用途:展示部门对应的员工数量和名单。
|
||||
* 依赖:部门成员只读 API 响应与 Vue 事件。
|
||||
* 逻辑:DepartmentsPage 点击员工图标后传入数据,本组件只负责呈现与关闭。
|
||||
* 用途:只读展示某个部门的员工数量和名单。
|
||||
* 依赖:element-plus 对话框和表格、部门成员响应类型。
|
||||
* 逻辑:DepartmentsPage 拉到名单后传入。本组件不请求接口,只展示和关闭。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Users, X } from 'lucide-vue-next';
|
||||
import { ElButton, ElDialog, ElTable, ElTableColumn } from 'element-plus';
|
||||
import type { AdminDepartmentMembersResponse } from '@/features/admin/types/admin.types';
|
||||
|
||||
defineProps<{ visible: boolean; data: AdminDepartmentMembersResponse | null }>();
|
||||
defineProps<{
|
||||
visible: boolean;
|
||||
data: AdminDepartmentMembersResponse | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ close: [] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible && data" class="admin-modal-overlay items-center" @click.self="emit('close')">
|
||||
<section class="admin-modal-panel max-w-2xl max-h-[90vh] animate-fade-in-up">
|
||||
<header class="px-8 py-6 border-b border-subtle flex items-center justify-between">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-primary">{{ t('admin.dept.members.title', { name: data.department.name }) }}</h3>
|
||||
<p class="text-sm text-muted mt-1">{{ t('admin.dept.members.count', { count: data.count }) }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds rounded-full" :title="t('admin.close')" @click="emit('close')"><X class="w-5 h-5" /></button>
|
||||
</header>
|
||||
<div class="max-h-[60vh] overflow-y-auto p-6">
|
||||
<div v-if="data.members.length === 0" class="py-12 text-center text-muted">
|
||||
<Users class="w-9 h-9 mx-auto mb-3 opacity-60" />
|
||||
{{ t('admin.dept.members.empty') }}
|
||||
</div>
|
||||
<ul v-else class="divide-y divide-subtle">
|
||||
<li v-for="member in data.members" :key="member.id" class="py-3 flex items-center justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<p class="font-medium text-primary">{{ member.real_name || member.username }}</p>
|
||||
<p class="text-xs text-muted truncate">{{ member.employee_id || member.username }} · {{ member.email || '-' }}</p>
|
||||
</div>
|
||||
<span class="text-xs text-muted whitespace-nowrap">{{ member.status }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible && !!data"
|
||||
:title="data ? t('admin.dept.members.title', { name: data.department.name }) : ''"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<template v-if="data">
|
||||
<p class="section-desc">{{ t('admin.dept.members.count', { count: data.count }) }}</p>
|
||||
<ElTable
|
||||
class="dept-members-table"
|
||||
:data="data.members"
|
||||
row-key="id"
|
||||
max-height="60vh"
|
||||
:empty-text="t('admin.dept.members.empty')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.user.fields.realName')" min-width="140">
|
||||
<template #default="{ row }">{{ row.real_name || row.username }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.user.fields.employeeId')" min-width="120">
|
||||
<template #default="{ row }">{{ row.employee_id || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.user.fields.email')" min-width="180">
|
||||
<template #default="{ row }">{{ row.email || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.user.headers.status')" min-width="100">
|
||||
<template #default="{ row }">{{ row.status || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</template>
|
||||
<template #footer>
|
||||
<ElButton @click="emit('close')">{{ t('admin.close') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dept-members-table {
|
||||
margin-top: 16px;
|
||||
}
|
||||
</style>
|
||||
+45
-48
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/departments/composables/useDepartmentsAdmin.ts
|
||||
* 用途:部门管理列表、搜索过滤、列排序、创建/编辑弹窗、删除。
|
||||
* 依赖:admin.api、department.types、useMessage、useTableSort。
|
||||
* 逻辑:DepartmentsPage 调用本 composable;排序状态委托 shared useTableSort。
|
||||
* 依赖:admin.api、department.types、useMessage、useTableSort、element-plus 的确认框。
|
||||
* 逻辑:DepartmentsPage 调用本 composable。表头排序由页面把 Element 的 sort-change 交给 applySort,仍在本地对过滤后的列表排序。删除用 ElMessageBox,不再使用 DeleteConfirmDialog。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
createAdminDepartment,
|
||||
deleteAdminDepartment,
|
||||
@@ -14,6 +15,7 @@ import {
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { useTableSort } from '@/shared/composables/useTableSort';
|
||||
import type { SortDir } from '@/shared/utils/table-sort';
|
||||
import type { AdminDepartmentRow } from '@/features/admin/types/admin.types';
|
||||
import {
|
||||
createEmptyDepartmentForm,
|
||||
@@ -24,6 +26,11 @@ import {
|
||||
/** 部门表可排序列 */
|
||||
export type DeptSortKey = 'name' | 'code' | 'company';
|
||||
|
||||
/**
|
||||
* 部门管理页的列表、表单和删除状态。
|
||||
* 核心逻辑:拉全量部门后在本地过滤和排序,保存与删除成功后再拉一次列表。
|
||||
* @returns 页面绑定的状态和打开弹窗、排序、保存、删除方法
|
||||
*/
|
||||
export function useDepartmentsAdmin() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
@@ -31,18 +38,15 @@ export function useDepartmentsAdmin() {
|
||||
const departments = ref<AdminDepartmentRow[]>([]);
|
||||
const form = ref<DepartmentFormState>(createEmptyDepartmentForm());
|
||||
const searchQuery = ref('');
|
||||
const { sortKey, sortDir, toggleSort, sortItems } = useTableSort<DeptSortKey>({
|
||||
const { sortKey, sortDir, sortItems } = useTableSort<DeptSortKey>({
|
||||
initialKey: 'name',
|
||||
initialDir: 'asc',
|
||||
});
|
||||
const isLoading = ref(true);
|
||||
const isListLoading = ref(false);
|
||||
const isSaving = ref(false);
|
||||
const showFormModal = ref(false);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/**
|
||||
* 先按关键词过滤,再按当前排序列排序。
|
||||
* 核心逻辑:模糊匹配四字段 → useTableSort.sortItems。
|
||||
@@ -71,11 +75,14 @@ export function useDepartmentsAdmin() {
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const loadDepartments = async (): Promise<void> => {
|
||||
isListLoading.value = true;
|
||||
try {
|
||||
departments.value = await listAdminDepartments();
|
||||
} catch (e) {
|
||||
console.error('Failed to load departments', e);
|
||||
departments.value = [];
|
||||
} finally {
|
||||
isListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -90,33 +97,18 @@ export function useDepartmentsAdmin() {
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开删除确认对话框并绑定确认后的删除动作。
|
||||
* @param message - 确认文案
|
||||
* @param action - 用户确认后执行的异步删除逻辑
|
||||
* 把 Element 表头排序写回本地排序状态。
|
||||
* 核心逻辑:第三次点击清空排序时回到接口原顺序;有效列只排当前过滤结果,不请求接口。
|
||||
* @param key - 名称、编码、公司;空字符串表示取消排序
|
||||
* @param dir - asc、desc,或空
|
||||
*/
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
/** 关闭删除确认对话框并清空待执行动作。 */
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 执行删除确认对话框中绑定的删除动作。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
const applySort = (key: DeptSortKey | '', dir: SortDir | ''): void => {
|
||||
if (key === '' || dir === '') {
|
||||
sortKey.value = undefined;
|
||||
return;
|
||||
}
|
||||
sortKey.value = key;
|
||||
sortDir.value = dir;
|
||||
};
|
||||
|
||||
/** 打开「添加部门」弹窗并重置表单。 */
|
||||
@@ -173,19 +165,27 @@ export function useDepartmentsAdmin() {
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除指定部门,删除前弹出确认框。
|
||||
* 删除指定部门。先用 Element 确认框询问,取消则不请求。
|
||||
* 核心逻辑:MessageBox 在取消时 reject,这里吞掉;确定后再调删除接口并刷新列表。
|
||||
* @param id - 部门主键
|
||||
*/
|
||||
const deleteDepartment = (id: number): void => {
|
||||
openDeleteConfirm(t('admin.dept.confirmDelete'), async () => {
|
||||
try {
|
||||
await deleteAdminDepartment(id);
|
||||
await loadDepartments();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
const deleteDepartment = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.dept.confirmDelete'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteAdminDepartment(id);
|
||||
await loadDepartments();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -196,18 +196,15 @@ export function useDepartmentsAdmin() {
|
||||
sortKey,
|
||||
sortDir,
|
||||
isLoading,
|
||||
isListLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
toggleSort,
|
||||
applySort,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
closeFormModal,
|
||||
saveDepartment,
|
||||
deleteDepartment,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
};
|
||||
}
|
||||
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>;
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/sourceCloneDraft.spec.ts
|
||||
* 用途:锁定来源站点复制草稿的字段边界。
|
||||
* 依赖:sourceCloneDraft、vitest。
|
||||
* 逻辑:复制必须清空唯一编号、强制停用,并深拷贝查询条件;没有的入站或出站不得变成空配置。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildSourceCloneDraft, type SourceCloneInput } from './sourceCloneDraft';
|
||||
|
||||
function sourceInput(overrides: Partial<SourceCloneInput> = {}): SourceCloneInput {
|
||||
return {
|
||||
source_code: 'BYAWSATL01',
|
||||
display_name: 'DSV 360 / Bison / AWSBI',
|
||||
connector_type: 'dbs',
|
||||
rpa_profile_id: 7,
|
||||
excel_template_id: 3,
|
||||
warehouse_resolution_mode: 'fixed',
|
||||
fixed_warehouse_id: 'WH-ATL',
|
||||
snapshot_ttl_seconds: 86400,
|
||||
onhand_report_config: {
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inventory', report_name: 'On Hand' },
|
||||
query_parameters_json: [{ name: 'Site', mode: 'single', values: ['ATL'], required: true, select_all: false }],
|
||||
parsing_profile_id: 11,
|
||||
},
|
||||
inbound_report_config: {
|
||||
report_path_json: { program_group: 'Bison', program_label: 'AWSBI', report_group: 'Inbound', report_name: 'Receipt' },
|
||||
query_parameters_json: [{ name: 'Warehouse', mode: 'multi_text', values: ['ATL'], required: false, select_all: false }],
|
||||
parsing_profile_id: 21,
|
||||
},
|
||||
outbound_report_config: null,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('buildSourceCloneDraft', () => {
|
||||
it('clears the unique code, suffixes the name, and forces the draft to stay disabled', () => {
|
||||
// 关键断言:编号必须由管理员重填,名称带副本后缀,且不能继承已启用状态。
|
||||
const draft = buildSourceCloneDraft(sourceInput(), '副本');
|
||||
|
||||
expect(draft.source_code).toBe('');
|
||||
expect(draft.display_name).toBe('DSV 360 / Bison / AWSBI 副本');
|
||||
expect(draft.enabled).toBe(false);
|
||||
expect(draft.clone_from).toEqual({ source_code: 'BYAWSATL01', display_name: 'DSV 360 / Bison / AWSBI' });
|
||||
expect(draft.rpa_profile_id).toBe(7);
|
||||
expect(draft.excel_template_id).toBe(3);
|
||||
expect(draft.fixed_warehouse_id).toBe('WH-ATL');
|
||||
expect(draft.onhand_report_config.parsing_profile_id).toBe(11);
|
||||
expect(draft.onhand_report_config.report_path_json.report_name).toBe('On Hand');
|
||||
});
|
||||
|
||||
it('deep-copies query values so editing the draft does not change the source', () => {
|
||||
const input = sourceInput();
|
||||
const draft = buildSourceCloneDraft(input, '副本');
|
||||
|
||||
draft.onhand_report_config.query_parameters_json[0].values.push('FRA');
|
||||
draft.inbound_report_config?.query_parameters_json[0].values.push('FRA');
|
||||
|
||||
// 关键断言:来源卡片上的条件数组保持原值,草稿修改不得回写。
|
||||
expect(input.onhand_report_config.query_parameters_json[0].values).toEqual(['ATL']);
|
||||
expect(input.inbound_report_config?.query_parameters_json[0].values).toEqual(['ATL']);
|
||||
});
|
||||
|
||||
it('omits inbound and outbound configs that the source does not have', () => {
|
||||
const draft = buildSourceCloneDraft(sourceInput({ inbound_report_config: null, outbound_report_config: null }), 'Copy');
|
||||
|
||||
// 关键断言:缺失的报表配置保持 null,保存时才不会建出空的入站或出站行。
|
||||
expect(draft.inbound_report_config).toBeNull();
|
||||
expect(draft.outbound_report_config).toBeNull();
|
||||
expect(draft.display_name).toBe('DSV 360 / Bison / AWSBI Copy');
|
||||
});
|
||||
|
||||
it('does not carry identity, activation, or unrelated records', () => {
|
||||
const draft = buildSourceCloneDraft({
|
||||
...sourceInput(),
|
||||
id: 99,
|
||||
enabled: true,
|
||||
activation: { ready: true, checks: [{ code: 'configuration_test' }] },
|
||||
external_mappings: [{ external_warehouse_code: 'SHOULD-NOT-COPY' }],
|
||||
} as SourceCloneInput & Record<string, unknown>, '副本');
|
||||
|
||||
// 关键断言:主键、启用检查、仓库映射不属于可复制配置。
|
||||
expect(draft).not.toHaveProperty('id');
|
||||
expect(draft).not.toHaveProperty('activation');
|
||||
expect(draft).not.toHaveProperty('external_mappings');
|
||||
expect(draft.enabled).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* features/admin/modules/freight-rpa/sourceCloneDraft.ts
|
||||
* 用途:把已有来源站点配置变成一份尚未落库的新建草稿。
|
||||
* 依赖:无。
|
||||
* 逻辑:FreightRpaPage 在卡片或抽屉点击「复制新增」时调用;保存仍走既有新建接口。
|
||||
*/
|
||||
|
||||
export type SourceCloneParameter = {
|
||||
name: string;
|
||||
mode: string;
|
||||
values: string[];
|
||||
required: boolean;
|
||||
select_all: boolean;
|
||||
joiner?: string;
|
||||
};
|
||||
|
||||
export type SourceCloneReportConfig = {
|
||||
report_path_json: Record<string, string>;
|
||||
query_parameters_json: SourceCloneParameter[];
|
||||
parsing_profile_id: number | null;
|
||||
};
|
||||
|
||||
export type SourceCloneInput = {
|
||||
source_code: string;
|
||||
display_name: string;
|
||||
connector_type: string;
|
||||
rpa_profile_id: number;
|
||||
excel_template_id: number;
|
||||
warehouse_resolution_mode: string;
|
||||
fixed_warehouse_id: string;
|
||||
snapshot_ttl_seconds: number;
|
||||
onhand_report_config: {
|
||||
report_path_json: Record<string, string>;
|
||||
query_parameters_json: SourceCloneParameter[];
|
||||
parsing_profile_id: number;
|
||||
};
|
||||
inbound_report_config: SourceCloneReportConfig | null;
|
||||
outbound_report_config: SourceCloneReportConfig | null;
|
||||
};
|
||||
|
||||
export type SourceCloneDraft = {
|
||||
source_code: '';
|
||||
display_name: string;
|
||||
connector_type: string;
|
||||
rpa_profile_id: number;
|
||||
excel_template_id: number;
|
||||
warehouse_resolution_mode: string;
|
||||
fixed_warehouse_id: string;
|
||||
snapshot_ttl_seconds: number;
|
||||
enabled: false;
|
||||
onhand_report_config: {
|
||||
report_path_json: Record<string, string>;
|
||||
query_parameters_json: SourceCloneParameter[];
|
||||
parsing_profile_id: number;
|
||||
};
|
||||
inbound_report_config: SourceCloneReportConfig | null;
|
||||
outbound_report_config: SourceCloneReportConfig | null;
|
||||
clone_from: { source_code: string; display_name: string };
|
||||
};
|
||||
|
||||
/**
|
||||
* 深拷贝查询条件,避免草稿里改值时回写到来源对象。
|
||||
* @param parameters - 来源站点上的查询条件。
|
||||
* @returns 条件与取值都是新数组的副本。
|
||||
*/
|
||||
function cloneParameters(parameters: SourceCloneParameter[] | undefined): SourceCloneParameter[] {
|
||||
return (parameters || []).map((parameter) => ({
|
||||
...parameter,
|
||||
values: [...(parameter.values || [])],
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制一份报表配置;没有配置时返回 null,避免保存时建出空的入站或出站行。
|
||||
* @param config - 已有报表配置;空表示该站点没有这块配置。
|
||||
* @returns 深拷贝后的配置,或 null。
|
||||
*/
|
||||
function cloneReport(config: SourceCloneReportConfig | null | undefined): SourceCloneReportConfig | null {
|
||||
if (!config) return null;
|
||||
return {
|
||||
report_path_json: { ...(config.report_path_json || {}) },
|
||||
query_parameters_json: cloneParameters(config.query_parameters_json),
|
||||
parsing_profile_id: config.parsing_profile_id ? Number(config.parsing_profile_id) : null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 从来源站点生成未保存草稿。
|
||||
* 核心逻辑:配置字段逐项深拷贝;库存源编号清空;名称追加副本后缀;启用状态固定为停用。
|
||||
* 不复制主键、启用检查、快照、仓库映射和路由规则。
|
||||
* @param input - 来源站点当前可见配置,入站或出站没有配置时传 null。
|
||||
* @param copySuffix - 追加在名称后的本地化后缀,例如「副本」。
|
||||
* @returns 可直接填入新建表单的草稿,source_code 恒为空字符串。
|
||||
*/
|
||||
export function buildSourceCloneDraft(input: SourceCloneInput, copySuffix: string): SourceCloneDraft {
|
||||
const displayName = String(input.display_name || input.source_code || '').trim();
|
||||
const suffix = String(copySuffix || '').trim();
|
||||
return {
|
||||
source_code: '',
|
||||
display_name: suffix ? `${displayName} ${suffix}` : displayName,
|
||||
connector_type: input.connector_type,
|
||||
rpa_profile_id: Number(input.rpa_profile_id) || 0,
|
||||
excel_template_id: Number(input.excel_template_id) || 0,
|
||||
warehouse_resolution_mode: input.warehouse_resolution_mode,
|
||||
fixed_warehouse_id: input.fixed_warehouse_id || '',
|
||||
snapshot_ttl_seconds: Number(input.snapshot_ttl_seconds) || 86400,
|
||||
enabled: false,
|
||||
onhand_report_config: {
|
||||
report_path_json: { ...(input.onhand_report_config?.report_path_json || {}) },
|
||||
query_parameters_json: cloneParameters(input.onhand_report_config?.query_parameters_json),
|
||||
parsing_profile_id: Number(input.onhand_report_config?.parsing_profile_id) || 0,
|
||||
},
|
||||
inbound_report_config: cloneReport(input.inbound_report_config),
|
||||
outbound_report_config: cloneReport(input.outbound_report_config),
|
||||
clone_from: {
|
||||
source_code: String(input.source_code || ''),
|
||||
display_name: displayName,
|
||||
},
|
||||
};
|
||||
}
|
||||
+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);
|
||||
});
|
||||
});
|
||||
+15
-2
@@ -7,8 +7,19 @@
|
||||
* 列表按类型标签/非密账号/来源本地化与布尔启停开关渲染。
|
||||
*/
|
||||
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 { mount } from '@vue/test-utils';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createMemoryHistory, createRouter } from 'vue-router';
|
||||
import i18n from '@/i18n';
|
||||
import IntegrationConnectorPage from './IntegrationConnectorPage.vue';
|
||||
@@ -79,8 +90,10 @@ function mountPage() {
|
||||
}
|
||||
|
||||
describe('IntegrationConnectorPage credential list', () => {
|
||||
it('按重设计列渲染:类型徽标 + 非密账号 + 来源徽标 + 启停开关,不再显示 secret_ref 原文', () => {
|
||||
it('按重设计列渲染:类型徽标 + 非密账号 + 来源徽标 + 启停开关,不再显示 secret_ref 原文', async () => {
|
||||
const wrapper = mountPage();
|
||||
// Element 表格要等列宽计算完才把单元格写进文档,原生 table 是同步的。
|
||||
await flushPromises();
|
||||
const text = wrapper.text();
|
||||
// password 类型:类型标签 + 非密账号(username 值)+ 来源本地化;状态不走文字(开关 + 悬停提示)
|
||||
expect(text).toContain('tiptop-erp');
|
||||
|
||||
+377
-386
@@ -1,29 +1,36 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/IntegrationConnectorPage.vue
|
||||
用途:集成连接器管理页——四个配置实体(客户端实例/接口定义/绑定/凭据引用)tab 列表 +
|
||||
能力清单与手动调用测试;创建/编辑抽屉 + 行内连接测试;调用日志 tab
|
||||
承载筛选/分页列表/详情抽屉(能力无关通用口径)。
|
||||
依赖:useIntegrationConnectorAdmin、抽屉与调用测试弹窗组件、useI18n。
|
||||
逻辑:按 tab 展示列表与「新增」;客户端列表展示类型/环境徽章、行内启停开关与
|
||||
连接测试结果(徽章 + 可展开详情);接口定义与绑定列表均以状态徽章 + 生命周期行内
|
||||
按钮(发布/撤回/退役/恢复,绑定发布由后端就绪门禁校验接口已发布且客户端启用)
|
||||
驱动状态,表单内状态只读;凭据列表布尔启停走行内开关
|
||||
(与客户端实例一致,表头同为「启用」,开关不带状态文字,精确状态走悬停提示);
|
||||
能力清单为只读注册表(能力中文名为主行 + 注册名次行,写入/幂等本地化,未注册翻译兜底原值);
|
||||
接口/绑定列表的客户端与接口
|
||||
引用列统一展示「名称 + 编码」两行;类型/环境/状态取值均本地化,
|
||||
未知值兜底原样显示;配置「绑定」是让自动调拨跑起来的最小闭环核心。
|
||||
-->
|
||||
/**
|
||||
* features/admin/modules/integration-connector/IntegrationConnectorPage.vue
|
||||
* 用途:集成连接器管理页。一张卡片里放标题、新增、六个页签和对应表格。
|
||||
* 依赖:AdminListPage、AdminListTabs、useIntegrationConnectorAdmin、element-plus、表单抽屉、调用弹窗、调用日志面板。
|
||||
* 逻辑:路由挂载本页。页签切换仍走 selectTab;能力清单和调用日志只读。创建/编辑抽屉和调用日志面板仍由子组件负责。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Plus, Edit, Trash2, Plug, PlayCircle } from 'lucide-vue-next';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElSwitch,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
|
||||
import IntegrationConnectorFormDrawer from './components/IntegrationConnectorFormDrawer.vue';
|
||||
import IntegrationCapabilityCallModal from './components/IntegrationCapabilityCallModal.vue';
|
||||
import IntegrationCallLogsPanel from './components/IntegrationCallLogsPanel.vue';
|
||||
import { CONNECTOR_TYPE_OPTIONS, ENVIRONMENT_OPTIONS } from './types/integration-connector.types';
|
||||
import { useIntegrationConnectorAdmin } from './composables/useIntegrationConnectorAdmin';
|
||||
import type { IntegrationBindingRow } from './types/integration-connector.types';
|
||||
import type {
|
||||
IntegrationBindingRow,
|
||||
IntegrationClientInstanceRow,
|
||||
IntegrationCredentialReferenceRow,
|
||||
IntegrationInterfaceDefinitionRow,
|
||||
} from './types/integration-connector.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -54,6 +61,14 @@ const tabs: Array<{ key: TabKey; labelKey: string }> = [
|
||||
// 均不属于可编辑实体);初始取 activeEntity,保证携带实体态进入页面时列表与 tab 一致。
|
||||
const activeTab = ref<TabKey>(activeEntity.value);
|
||||
|
||||
/**
|
||||
* 六个页签交给公共页签组件。名称用实体键,文字用现有文案。
|
||||
*/
|
||||
const connectorTabs = computed(() => tabs.map((tab) => ({
|
||||
name: tab.key,
|
||||
label: t(tab.labelKey),
|
||||
})));
|
||||
|
||||
/** 客户端选项带 connector_type:接口表单联动展示连接器类型用。 */
|
||||
const clientOptions = computed(() => clients.value.map((c) => ({ code: c.code, name: c.name, connector_type: c.connector_type })));
|
||||
/** 接口选项带 client_instance_code:绑定表单联动带出并锁定客户端实例用。 */
|
||||
@@ -97,18 +112,27 @@ 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);
|
||||
}
|
||||
|
||||
/** 能力本地化标签;未注册翻译的能力兜底原值(能力名含点号,i18n 按嵌套路径组织)。 */
|
||||
/** 能力本地化标签。空名称不查文案。未注册翻译时兜底原值(能力名含点号,i18n 按嵌套路径组织)。 */
|
||||
function capabilityLabelOf(name: string) {
|
||||
if (!name) return '';
|
||||
return t(`admin.integrationConnector.capabilityLabels.${name}`, name);
|
||||
}
|
||||
|
||||
/** 幂等语义本地化标签;未知值兜底原样显示。 */
|
||||
/** 幂等语义本地化标签。空值不查文案,未知值兜底原样显示。 */
|
||||
function idempotencyLabel(value: string) {
|
||||
if (!value) return '';
|
||||
return t(`admin.integrationConnector.idempotencyLabels.${value}`, value);
|
||||
}
|
||||
|
||||
@@ -129,11 +153,14 @@ function credentialAccountText(row: { secret_provider: string; secret_fields: Re
|
||||
return values.length ? values.join(' / ') : '—';
|
||||
}
|
||||
|
||||
/** 状态徽标配色:启用中绿 / 轮换中橙 / 其余中性。 */
|
||||
function statusBadgeClass(value: string) {
|
||||
if (value === 'active' || value === 'published') return 'bg-emerald-50 text-emerald-700';
|
||||
if (value === 'rotating') return 'bg-amber-50 text-amber-700';
|
||||
return 'bg-surface-soft text-secondary';
|
||||
/**
|
||||
* 状态标签颜色。启用和已发布为成功,轮换中为警告,其余为中性。
|
||||
* @param value - 状态码
|
||||
*/
|
||||
function statusTagType(value: string): 'success' | 'warning' | 'info' {
|
||||
if (value === 'active' || value === 'published') return 'success';
|
||||
if (value === 'rotating') return 'warning';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
/** 行内测试结果(无结果返回 null,供模板 v-if 使用)。 */
|
||||
@@ -141,13 +168,6 @@ function testResultOf(code: string) {
|
||||
return testResults.value[code] ?? null;
|
||||
}
|
||||
|
||||
/** 测试徽章配色:成功绿 / 失败红。 */
|
||||
function testBadgeClass(code: string) {
|
||||
return testResultOf(code)?.ok
|
||||
? 'bg-green-100 text-green-700 hover:bg-green-200'
|
||||
: 'bg-red-100 text-red-700 hover:bg-red-200';
|
||||
}
|
||||
|
||||
/** 测试徽章文案。 */
|
||||
function testBadgeText(code: string) {
|
||||
return testResultOf(code)?.ok
|
||||
@@ -162,377 +182,336 @@ function testDetailText(code: string) {
|
||||
return r.message ? `${r.code} · ${r.message}` : r.code;
|
||||
}
|
||||
|
||||
function selectTab(key: TabKey) {
|
||||
/**
|
||||
* 切换页签。能力清单和调用日志只读,不改当前可编辑实体。
|
||||
* @param key - 页签名
|
||||
*/
|
||||
function selectTab(key: TabKey): void {
|
||||
activeTab.value = key;
|
||||
// capability/calls tab 只读展示(无新增/表单入口),activeEntity 保持最后一个可编辑实体供抽屉复用。
|
||||
if (key !== 'capability' && key !== 'calls') activeEntity.value = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共页签只回传字符串,这里收成六个已知页签后再切换。
|
||||
* @param name - AdminListTabs 当前 name
|
||||
*/
|
||||
function onListTab(name: string): void {
|
||||
if (name === 'client' || name === 'interface' || name === 'binding' || name === 'credential' || name === 'capability' || name === 'calls') {
|
||||
selectTab(name);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<AdminListPage :loading="isLoading">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.integrationConnector.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.integrationConnector.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
v-if="activeTab !== 'capability' && activeTab !== 'calls'"
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal(activeEntity)"
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton
|
||||
v-if="activeTab !== 'capability' && activeTab !== 'calls'"
|
||||
type="primary"
|
||||
:icon="Plus"
|
||||
@click="openCreateModal(activeEntity)"
|
||||
>
|
||||
{{ t('admin.integrationConnector.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #tabs>
|
||||
<AdminListTabs :model-value="activeTab" :items="connectorTabs" @update:model-value="onListTab" />
|
||||
</template>
|
||||
|
||||
<template v-if="!isLoading">
|
||||
<ElTable
|
||||
v-if="activeTab === 'client'"
|
||||
class="hx-admin-table"
|
||||
:data="clients"
|
||||
row-key="code"
|
||||
:empty-text="t('admin.integrationConnector.empty')"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span>{{ t('admin.integrationConnector.add') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-1 border-b border-default" role="tablist">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors"
|
||||
:class="activeTab === tab.key ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-secondary'"
|
||||
:aria-selected="activeTab === tab.key"
|
||||
@click="selectTab(tab.key)"
|
||||
>
|
||||
{{ t(tab.labelKey) }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<!-- 客户端实例 -->
|
||||
<div v-if="activeTab === 'client'" class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.name') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.connectorType') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.environment') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.endpoint') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.fields.enabled') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.testStatus') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-36">{{ t('admin.integrationConnector.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="clients.length === 0"><td colspan="7" class="px-6 admin-table-empty">{{ t('admin.integrationConnector.empty') }}</td></tr>
|
||||
<template v-for="row in clients" :key="row.code">
|
||||
<tr>
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm font-medium text-primary">{{ row.name }}</p>
|
||||
<p class="text-xs text-muted mono mt-0.5">{{ row.code }}</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium bg-surface-soft text-secondary">{{ connectorTypeLabel(row.connector_type) }}</span>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span
|
||||
class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium"
|
||||
:class="row.environment === 'prod' ? 'bg-green-100 text-green-700' : row.environment === 'test' ? 'bg-amber-100 text-amber-700' : 'bg-surface-soft text-secondary'"
|
||||
>{{ envLabel(row.environment) }}</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 max-w-[240px]">
|
||||
<span v-if="row.endpoint" class="block truncate text-xs font-mono text-secondary" :title="row.endpoint">{{ row.endpoint }}</span>
|
||||
<span v-else class="text-xs text-muted">—</span>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
:aria-checked="row.enabled"
|
||||
:title="t('admin.integrationConnector.fields.enabled')"
|
||||
class="relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors"
|
||||
:class="row.enabled ? 'bg-brand-600' : 'bg-slate-300'"
|
||||
data-testid="client-toggle"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="toggleClient(row)"
|
||||
>
|
||||
<span class="inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform" :class="row.enabled ? 'translate-x-4' : 'translate-x-0.5'" />
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span v-if="testingClientCode === row.code" class="text-xs text-muted">{{ t('admin.integrationConnector.msg.testing') }}</span>
|
||||
<button
|
||||
v-else-if="testResultOf(row.code)"
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium"
|
||||
:class="testBadgeClass(row.code)"
|
||||
:title="t('admin.integrationConnector.testDetailToggle')"
|
||||
data-testid="client-test-badge"
|
||||
@click="expandedTestCode = expandedTestCode === row.code ? '' : row.code"
|
||||
>
|
||||
{{ testBadgeText(row.code) }}
|
||||
</button>
|
||||
<span v-else class="text-xs text-muted">—</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<button type="button" class="p-2 rounded-lg text-muted hover:bg-brand-50 hover:text-brand-600" :title="t('admin.integrationConnector.test')" @click="testConnection(row.code)">
|
||||
<Plug class="w-4 h-4" />
|
||||
</button>
|
||||
<button type="button" class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary" :title="t('admin.edit')" @click="openEditModal('client', row)">
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button type="button" class="p-2 rounded-lg text-muted hover:bg-red-50 hover:text-red-600" :title="t('admin.delete')" @click="deleteClient(row)">
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- 测试详情展开行:原因码 + 脱敏消息 -->
|
||||
<tr v-if="expandedTestCode === row.code && testResultOf(row.code)">
|
||||
<td colspan="7" class="px-6 py-3 bg-surface-soft" data-testid="client-test-detail">
|
||||
<p class="text-xs font-mono text-secondary break-all">{{ testDetailText(row.code) }}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.name')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div>{{ row.name }}</div>
|
||||
<p class="hx-element-hint">{{ row.code }}</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.connectorType')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag effect="light">{{ connectorTypeLabel(row.connector_type) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.environment')" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="envTagType(row.environment)" effect="light">{{ envLabel(row.environment) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.endpoint')" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.endpoint" class="connector-ellipsis" :title="row.endpoint">{{ row.endpoint }}</span>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.fields.enabled')" width="100">
|
||||
<template #default="{ row }">
|
||||
<ElSwitch
|
||||
:model-value="row.enabled"
|
||||
data-testid="client-toggle"
|
||||
:disabled="lifecycleBusy"
|
||||
:title="t('admin.integrationConnector.fields.enabled')"
|
||||
@change="toggleClient(row as IntegrationClientInstanceRow)"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.testStatus')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<span v-if="testingClientCode === row.code">{{ t('admin.integrationConnector.msg.testing') }}</span>
|
||||
<template v-else-if="testResultOf(row.code)">
|
||||
<ElTag
|
||||
:type="testResultOf(row.code)?.ok ? 'success' : 'danger'"
|
||||
effect="light"
|
||||
class="connector-test-tag"
|
||||
data-testid="client-test-badge"
|
||||
:title="t('admin.integrationConnector.testDetailToggle')"
|
||||
@click="expandedTestCode = expandedTestCode === row.code ? '' : row.code"
|
||||
>
|
||||
{{ testBadgeText(row.code) }}
|
||||
</ElTag>
|
||||
<p v-if="expandedTestCode === row.code" class="hx-element-hint" data-testid="client-test-detail">
|
||||
{{ testDetailText(row.code) }}
|
||||
</p>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.actions')" width="200" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="testConnection(row.code)">{{ t('admin.integrationConnector.test') }}</ElButton>
|
||||
<ElButton link type="primary" @click="openEditModal('client', row as IntegrationClientInstanceRow)">{{ t('admin.edit') }}</ElButton>
|
||||
<ElButton link type="danger" @click="deleteClient(row as IntegrationClientInstanceRow)">{{ t('admin.delete') }}</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<!-- 接口定义:状态徽章 + 生命周期行内按钮(发布/撤回/退役/恢复,后端转移表校验) -->
|
||||
<div v-else-if="activeTab === 'interface'" class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.code') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.name') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.clientInstance') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-28">{{ t('admin.integrationConnector.headers.status') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-48">{{ t('admin.integrationConnector.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="interfaces.length === 0"><td colspan="5" class="px-6 admin-table-empty">{{ t('admin.integrationConnector.empty') }}</td></tr>
|
||||
<tr v-for="row in interfaces" :key="row.code">
|
||||
<td class="px-6 py-4 text-sm font-medium text-primary mono">{{ row.code }}</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary">{{ row.name }}</td>
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm text-primary">{{ clientNameOf(row.client_instance_code) || row.client_instance_code }}</p>
|
||||
<p class="text-xs text-muted mono mt-0.5">{{ row.client_instance_code }}</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium" :class="statusBadgeClass(row.status)" data-testid="interface-status">{{ statusLabel(row.status) }}</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<!-- 生命周期按钮按当前状态显隐:draft→发布;published→撤回+退役;retired→恢复;按钮不换行防窄列折字 -->
|
||||
<button
|
||||
v-if="row.status === 'draft'"
|
||||
type="button"
|
||||
class="whitespace-nowrap px-2 py-1 rounded-md text-xs font-medium text-brand-600 hover:bg-brand-50 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
data-testid="interface-publish"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeInterfaceLifecycle(row, 'publish')"
|
||||
>{{ t('admin.integrationConnector.lifecycle.publish') }}</button>
|
||||
<template v-else-if="row.status === 'published'">
|
||||
<button
|
||||
type="button"
|
||||
class="whitespace-nowrap px-2 py-1 rounded-md text-xs font-medium text-secondary hover:bg-surface-soft disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
data-testid="interface-unpublish"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeInterfaceLifecycle(row, 'unpublish')"
|
||||
>{{ t('admin.integrationConnector.lifecycle.unpublish') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="whitespace-nowrap px-2 py-1 rounded-md text-xs font-medium text-amber-600 hover:bg-amber-50 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
data-testid="interface-retire"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeInterfaceLifecycle(row, 'retire')"
|
||||
>{{ t('admin.integrationConnector.lifecycle.retire') }}</button>
|
||||
</template>
|
||||
<button
|
||||
v-else-if="row.status === 'retired'"
|
||||
type="button"
|
||||
class="whitespace-nowrap px-2 py-1 rounded-md text-xs font-medium text-secondary hover:bg-surface-soft disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
data-testid="interface-reopen"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeInterfaceLifecycle(row, 'reopen')"
|
||||
>{{ t('admin.integrationConnector.lifecycle.reopen') }}</button>
|
||||
<button type="button" class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary" :title="t('admin.edit')" @click="openEditModal('interface', row)">
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<ElTable
|
||||
v-else-if="activeTab === 'interface'"
|
||||
class="hx-admin-table"
|
||||
:data="interfaces"
|
||||
row-key="code"
|
||||
:empty-text="t('admin.integrationConnector.empty')"
|
||||
>
|
||||
<ElTableColumn prop="code" :label="t('admin.integrationConnector.headers.code')" min-width="160" />
|
||||
<ElTableColumn prop="name" :label="t('admin.integrationConnector.headers.name')" min-width="160" />
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.clientInstance')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div>{{ clientNameOf(row.client_instance_code) || row.client_instance_code }}</div>
|
||||
<p class="hx-element-hint">{{ row.client_instance_code }}</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.status')" width="120">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="statusTagType(row.status)" effect="light" data-testid="interface-status">
|
||||
{{ statusLabel(row.status) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.actions')" width="280" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton
|
||||
v-if="row.status === 'draft'"
|
||||
link
|
||||
type="primary"
|
||||
data-testid="interface-publish"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeInterfaceLifecycle(row as IntegrationInterfaceDefinitionRow, 'publish')"
|
||||
>
|
||||
{{ t('admin.integrationConnector.lifecycle.publish') }}
|
||||
</ElButton>
|
||||
<template v-else-if="row.status === 'published'">
|
||||
<ElButton
|
||||
link
|
||||
data-testid="interface-unpublish"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeInterfaceLifecycle(row as IntegrationInterfaceDefinitionRow, 'unpublish')"
|
||||
>
|
||||
{{ t('admin.integrationConnector.lifecycle.unpublish') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="warning"
|
||||
data-testid="interface-retire"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeInterfaceLifecycle(row as IntegrationInterfaceDefinitionRow, 'retire')"
|
||||
>
|
||||
{{ t('admin.integrationConnector.lifecycle.retire') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<ElButton
|
||||
v-else-if="row.status === 'retired'"
|
||||
link
|
||||
data-testid="interface-reopen"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeInterfaceLifecycle(row as IntegrationInterfaceDefinitionRow, 'reopen')"
|
||||
>
|
||||
{{ t('admin.integrationConnector.lifecycle.reopen') }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="openEditModal('interface', row as IntegrationInterfaceDefinitionRow)">{{ t('admin.edit') }}</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<!-- 绑定:状态徽章 + 生命周期行内按钮(发布/撤回/退役/恢复,后端转移表 + 发布就绪门禁校验) -->
|
||||
<div v-else-if="activeTab === 'binding'" class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.capability') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.clientInstance') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.interfaceDef') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-28">{{ t('admin.integrationConnector.headers.status') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-48">{{ t('admin.integrationConnector.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="bindings.length === 0"><td colspan="5" class="px-6 admin-table-empty">{{ t('admin.integrationConnector.empty') }}</td></tr>
|
||||
<tr v-for="row in bindings" :key="row.id">
|
||||
<!-- 能力引用列与客户端/接口引用列同款「名称 + 编码」两行;无中文翻译时只显注册名避免重复 -->
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm text-primary">{{ capabilityLabelOf(row.capability) }}</p>
|
||||
<p v-if="capabilityLabelOf(row.capability) !== row.capability" class="text-xs text-muted mono mt-0.5">{{ row.capability }}</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<!-- 有序步骤:逐步渲染客户端(与接口步骤列对齐) -->
|
||||
<p v-for="(step, idx) in bindingStepsOf(row)" :key="`c-${step.interface_code}-${idx}`" class="text-sm text-primary">
|
||||
<span class="mr-1 text-xs text-muted">{{ idx + 1 }}.</span>{{ clientNameOf(step.client_code) || step.client_code }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<!-- 有序步骤编排:编号 + 接口名,悬停显示接口编码;旧单步行兜底为一步 -->
|
||||
<p v-for="(step, idx) in bindingStepsOf(row)" :key="`i-${step.interface_code}-${idx}`" class="text-sm text-primary">
|
||||
<span class="mr-1 text-xs text-muted">{{ idx + 1 }}.</span><span :title="step.interface_code">{{ interfaceNameOf(step.interface_code) || step.interface_code }}</span>
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium" :class="statusBadgeClass(row.status)" data-testid="binding-status">{{ statusLabel(row.status) }}</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<!-- 生命周期按钮按当前状态显隐:draft→发布;published→撤回+退役;retired→恢复;按钮不换行防窄列折字 -->
|
||||
<button
|
||||
v-if="row.status === 'draft'"
|
||||
type="button"
|
||||
class="whitespace-nowrap px-2 py-1 rounded-md text-xs font-medium text-brand-600 hover:bg-brand-50 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
data-testid="binding-publish"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeBindingLifecycle(row, 'publish')"
|
||||
>{{ t('admin.integrationConnector.lifecycle.publish') }}</button>
|
||||
<template v-else-if="row.status === 'published'">
|
||||
<button
|
||||
type="button"
|
||||
class="whitespace-nowrap px-2 py-1 rounded-md text-xs font-medium text-secondary hover:bg-surface-soft disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
data-testid="binding-unpublish"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeBindingLifecycle(row, 'unpublish')"
|
||||
>{{ t('admin.integrationConnector.lifecycle.unpublish') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="whitespace-nowrap px-2 py-1 rounded-md text-xs font-medium text-amber-600 hover:bg-amber-50 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
data-testid="binding-retire"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeBindingLifecycle(row, 'retire')"
|
||||
>{{ t('admin.integrationConnector.lifecycle.retire') }}</button>
|
||||
</template>
|
||||
<button
|
||||
v-else-if="row.status === 'retired'"
|
||||
type="button"
|
||||
class="whitespace-nowrap px-2 py-1 rounded-md text-xs font-medium text-secondary hover:bg-surface-soft disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
data-testid="binding-reopen"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeBindingLifecycle(row, 'reopen')"
|
||||
>{{ t('admin.integrationConnector.lifecycle.reopen') }}</button>
|
||||
<button type="button" class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary" :title="t('admin.edit')" @click="openEditModal('binding', row)">
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<ElTable
|
||||
v-else-if="activeTab === 'binding'"
|
||||
class="hx-admin-table"
|
||||
:data="bindings"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.integrationConnector.empty')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.capability')" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div>{{ capabilityLabelOf(row.capability) }}</div>
|
||||
<p v-if="capabilityLabelOf(row.capability) !== row.capability" class="hx-element-hint">{{ row.capability }}</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.clientInstance')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<p v-for="(step, idx) in bindingStepsOf(row as IntegrationBindingRow)" :key="`c-${step.interface_code}-${idx}`">
|
||||
{{ idx + 1 }}. {{ clientNameOf(step.client_code) || step.client_code }}
|
||||
</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.interfaceDef')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<p v-for="(step, idx) in bindingStepsOf(row as IntegrationBindingRow)" :key="`i-${step.interface_code}-${idx}`">
|
||||
{{ idx + 1 }}. <span :title="step.interface_code">{{ interfaceNameOf(step.interface_code) || step.interface_code }}</span>
|
||||
</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.status')" width="120">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="statusTagType(row.status)" effect="light" data-testid="binding-status">
|
||||
{{ statusLabel(row.status) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.actions')" width="280" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton
|
||||
v-if="row.status === 'draft'"
|
||||
link
|
||||
type="primary"
|
||||
data-testid="binding-publish"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeBindingLifecycle(row as IntegrationBindingRow, 'publish')"
|
||||
>
|
||||
{{ t('admin.integrationConnector.lifecycle.publish') }}
|
||||
</ElButton>
|
||||
<template v-else-if="row.status === 'published'">
|
||||
<ElButton
|
||||
link
|
||||
data-testid="binding-unpublish"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeBindingLifecycle(row as IntegrationBindingRow, 'unpublish')"
|
||||
>
|
||||
{{ t('admin.integrationConnector.lifecycle.unpublish') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="warning"
|
||||
data-testid="binding-retire"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeBindingLifecycle(row as IntegrationBindingRow, 'retire')"
|
||||
>
|
||||
{{ t('admin.integrationConnector.lifecycle.retire') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<ElButton
|
||||
v-else-if="row.status === 'retired'"
|
||||
link
|
||||
data-testid="binding-reopen"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="changeBindingLifecycle(row as IntegrationBindingRow, 'reopen')"
|
||||
>
|
||||
{{ t('admin.integrationConnector.lifecycle.reopen') }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="openEditModal('binding', row as IntegrationBindingRow)">{{ t('admin.edit') }}</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<!-- 凭据引用 -->
|
||||
<div v-else-if="activeTab === 'credential'" class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.code') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.connectorType') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.account') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.secretProvider') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.fields.enabled') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-32">{{ t('admin.integrationConnector.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="credentials.length === 0"><td colspan="6" class="px-6 admin-table-empty">{{ t('admin.integrationConnector.empty') }}</td></tr>
|
||||
<tr v-for="row in credentials" :key="row.code">
|
||||
<td class="px-6 py-4 text-sm font-medium text-primary mono">{{ row.code }}</td>
|
||||
<td class="px-6 py-4 text-sm">
|
||||
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium bg-surface-soft text-secondary">{{ credentialTypeLabel(row.credential_type) }}</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary mono">{{ credentialAccountText(row) }}</td>
|
||||
<td class="px-6 py-4 text-sm">
|
||||
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium bg-surface-soft text-secondary" :title="row.secret_provider === 'db' ? statusLabel('db') : row.secret_ref">{{ secretProviderLabel(row.secret_provider) }}</span>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<!-- 行内启停开关:布尔语义,与客户端实例开关完全同款(含 title 用同一 i18n 键);rotating 视为启用侧,点击即停用;解析层只认 active,停用即断流 -->
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
:aria-checked="row.status !== 'retired'"
|
||||
:title="t('admin.integrationConnector.fields.enabled')"
|
||||
class="relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors"
|
||||
:class="row.status !== 'retired' ? 'bg-brand-600' : 'bg-slate-300'"
|
||||
data-testid="credential-status-toggle"
|
||||
:disabled="lifecycleBusy"
|
||||
@click="toggleCredential(row)"
|
||||
>
|
||||
<span class="inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform" :class="row.status !== 'retired' ? 'translate-x-4' : 'translate-x-0.5'" />
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<button type="button" class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary" :title="t('admin.edit')" @click="openEditModal('credential', row)">
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<ElTable
|
||||
v-else-if="activeTab === 'credential'"
|
||||
class="hx-admin-table"
|
||||
:data="credentials"
|
||||
row-key="code"
|
||||
:empty-text="t('admin.integrationConnector.empty')"
|
||||
>
|
||||
<ElTableColumn prop="code" :label="t('admin.integrationConnector.headers.code')" min-width="160" />
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.connectorType')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag effect="light">{{ credentialTypeLabel(row.credential_type) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.account')" min-width="160">
|
||||
<template #default="{ row }">{{ credentialAccountText(row as IntegrationCredentialReferenceRow) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.secretProvider')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<ElTag effect="light" :title="row.secret_provider === 'db' ? statusLabel('db') : row.secret_ref">
|
||||
{{ secretProviderLabel(row.secret_provider) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.fields.enabled')" width="100">
|
||||
<template #default="{ row }">
|
||||
<ElSwitch
|
||||
:model-value="row.status !== 'retired'"
|
||||
data-testid="credential-status-toggle"
|
||||
:disabled="lifecycleBusy"
|
||||
:title="t('admin.integrationConnector.fields.enabled')"
|
||||
@change="toggleCredential(row as IntegrationCredentialReferenceRow)"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.actions')" width="100" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openEditModal('credential', row as IntegrationCredentialReferenceRow)">{{ t('admin.edit') }}</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<!-- 调用日志:筛选 + 分页列表 + 详情抽屉(能力无关通用口径;只读 tab,无新增入口) -->
|
||||
<IntegrationCallLogsPanel v-else-if="activeTab === 'calls'" />
|
||||
|
||||
<!-- 能力清单 -->
|
||||
<div v-else class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.name') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.write') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.integrationConnector.headers.idempotency') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-28">{{ t('admin.integrationConnector.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="capabilities.length === 0"><td colspan="4" class="px-6 admin-table-empty">{{ t('admin.integrationConnector.empty') }}</td></tr>
|
||||
<tr v-for="row in capabilities" :key="row.name">
|
||||
<!-- 中文名称为主行,注册名作为精确标识(绑定引用用)保留为次行;无中文翻译时只显注册名避免重复 -->
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm font-medium text-primary">{{ capabilityLabelOf(row.name) }}</p>
|
||||
<p v-if="capabilityLabelOf(row.name) !== row.name" class="text-xs text-muted mono mt-0.5">{{ row.name }}</p>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary">{{ row.write ? t('admin.integrationConnector.writeLabels.yes') : t('admin.integrationConnector.writeLabels.no') }}</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary">{{ idempotencyLabel(row.idempotency) }}</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<button type="button" class="inline-flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium text-brand-600 hover:bg-brand-50" @click="openCallModal(row.name)">
|
||||
<PlayCircle class="w-4 h-4" />
|
||||
{{ t('admin.integrationConnector.call') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<ElTable
|
||||
v-else
|
||||
class="hx-admin-table"
|
||||
:data="capabilities"
|
||||
row-key="name"
|
||||
:empty-text="t('admin.integrationConnector.empty')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.name')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<div>{{ capabilityLabelOf(row.name) }}</div>
|
||||
<p v-if="capabilityLabelOf(row.name) !== row.name" class="hx-element-hint">{{ row.name }}</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.write')" width="100">
|
||||
<template #default="{ row }">
|
||||
{{ row.write ? t('admin.integrationConnector.writeLabels.yes') : t('admin.integrationConnector.writeLabels.no') }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.idempotency')" min-width="160">
|
||||
<template #default="{ row }">{{ idempotencyLabel(row.idempotency) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.headers.actions')" width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openCallModal(row.name)">{{ t('admin.integrationConnector.call') }}</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</template>
|
||||
</AdminListPage>
|
||||
|
||||
<IntegrationConnectorFormDrawer
|
||||
:visible="showFormModal"
|
||||
@@ -561,5 +540,17 @@ function selectTab(key: TabKey) {
|
||||
@close="closeCallModal"
|
||||
@run="runCall"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.connector-ellipsis {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.connector-test-tag {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
+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>
|
||||
+46
-10
@@ -11,12 +11,14 @@
|
||||
* param_mapping_json),client 由各步接口归属自带、不再发送旧单步顶层字段;
|
||||
* 凭据状态只经列表行内开关流转(启用↔停用,表单不维护状态);
|
||||
* 全部行内状态操作经 lifecycleBusy 互斥(进行中忽略新触发);接口/绑定退役
|
||||
* 接近终态需 window.confirm 二次确认,可逆转移直达;
|
||||
* 连接测试结果按行存放(列表徽章+展开详情);
|
||||
* 启停支持行内开关(失败回滚);删除带确认。保存/删除后刷新对应列表。
|
||||
* 接近终态仍走现有 window.confirm,可逆转移直达;
|
||||
* 连接测试结果按行存放(列表标签+展开详情);
|
||||
* 启停支持行内开关(失败回滚);删除用 Element 确认框,取消则返回。
|
||||
* 首屏 isLoading 盖住整张卡片;保存、删除和生命周期刷新后的 isListLoading 只盖表格。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
callIntegrationCapability,
|
||||
@@ -87,7 +89,10 @@ export function useIntegrationConnectorAdmin() {
|
||||
const credentials = ref<IntegrationCredentialReferenceRow[]>([]);
|
||||
const capabilities = ref<IntegrationCapabilityRow[]>([]);
|
||||
const credentialTypes = ref<IntegrationCredentialTypeSpec[]>([]);
|
||||
/** 首屏整卡加载。为 true 时列表卡片先不画出表格。 */
|
||||
const isLoading = ref(true);
|
||||
/** 首屏之后的列表刷新。只盖住当前表格,不把标题和页签再盖住。 */
|
||||
const isListLoading = ref(false);
|
||||
|
||||
// ---- 表单弹窗态 ----
|
||||
const activeEntity = ref<EditableEntity>('client');
|
||||
@@ -145,11 +150,21 @@ export function useIntegrationConnectorAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 刷新一个实体的列表,并只在表格上显示加载。
|
||||
* 核心逻辑:保存成功后按当前实体重拉;加载标记在请求结束后关掉,失败继续抛给调用方。
|
||||
* @param entity - 要刷新的客户端、接口、绑定或凭据
|
||||
*/
|
||||
const reloadOne = async (entity: EditableEntity) => {
|
||||
if (entity === 'client') await loadClients();
|
||||
else if (entity === 'interface') await loadInterfaces();
|
||||
else if (entity === 'binding') await loadBindings();
|
||||
else await loadCredentials();
|
||||
isListLoading.value = true;
|
||||
try {
|
||||
if (entity === 'client') await loadClients();
|
||||
else if (entity === 'interface') await loadInterfaces();
|
||||
else if (entity === 'binding') await loadBindings();
|
||||
else await loadCredentials();
|
||||
} finally {
|
||||
isListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// ---- 弹窗打开/关闭 ----
|
||||
@@ -380,10 +395,13 @@ export function useIntegrationConnectorAdmin() {
|
||||
if (action === 'retire' && !window.confirm(t('admin.integrationConnector.msg.retireInterfaceConfirm'))) return;
|
||||
try {
|
||||
await changeIntegrationInterfaceLifecycle(row.code, action);
|
||||
isListLoading.value = true;
|
||||
await loadInterfaces();
|
||||
msg.success(t('admin.integrationConnector.msg.statusUpdated'));
|
||||
} catch (e) {
|
||||
msg.error((e as Error).message || t('admin.integrationConnector.msg.statusUpdateFailed'));
|
||||
} finally {
|
||||
isListLoading.value = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -394,10 +412,13 @@ export function useIntegrationConnectorAdmin() {
|
||||
if (action === 'retire' && !window.confirm(t('admin.integrationConnector.msg.retireBindingConfirm'))) return;
|
||||
try {
|
||||
await changeIntegrationBindingLifecycle(row.id, action);
|
||||
isListLoading.value = true;
|
||||
await loadBindings();
|
||||
msg.success(t('admin.integrationConnector.msg.statusUpdated'));
|
||||
} catch (e) {
|
||||
msg.error((e as Error).message || t('admin.integrationConnector.msg.statusUpdateFailed'));
|
||||
} finally {
|
||||
isListLoading.value = false;
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -431,24 +452,39 @@ export function useIntegrationConnectorAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/** 删除客户端实例:先确认(提示语带名称),确认后才调 API。 */
|
||||
/**
|
||||
* 删除客户端实例。先用 Element 确认框询问,取消则不请求。
|
||||
* 核心逻辑:确认框取消时 reject,这里直接返回;确定后才调删除接口并刷新列表。
|
||||
* @param row - 要删除的客户端实例行
|
||||
*/
|
||||
const deleteClient = async (row: IntegrationClientInstanceRow) => {
|
||||
const summary = t('admin.integrationConnector.msg.deleteConfirm', { code: row.code, name: row.name });
|
||||
if (!window.confirm(summary)) return;
|
||||
try {
|
||||
await ElMessageBox.confirm(summary, t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteIntegrationClientInstance(row.code);
|
||||
const { [row.code]: _removed, ...rest } = testResults.value;
|
||||
testResults.value = rest;
|
||||
isListLoading.value = true;
|
||||
await loadClients();
|
||||
msg.success(t('admin.integrationConnector.msg.deleted'));
|
||||
} catch (e) {
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
clients, interfaces, bindings, credentials, capabilities, credentialTypes,
|
||||
isLoading, activeEntity, showFormModal, isSaving,
|
||||
isLoading, isListLoading, activeEntity, showFormModal, isSaving,
|
||||
clientForm, interfaceForm, bindingForm, credentialForm,
|
||||
showCallModal, callCapability, callParamsText, callContextText, callResult, callBusy,
|
||||
testingClientCode, testResults,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
/**
|
||||
* features/admin/modules/knowledge-base/KnowledgeBasePage.vue
|
||||
* 知识库配置页(治理面)。路由:/admin/knowledge-base
|
||||
* 用途:管理端知识库配置页入口。
|
||||
* 依赖:KbAdminPanel。
|
||||
* 逻辑:路由 /admin/knowledge-base。卡片骨架在 KbAdminPanel 的 AdminListPage 里,本页不再套第二层卡片。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import KbAdminPanel from '@/features/kb/components/KbAdminPanel.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section overflow-hidden animate-fade-in-up">
|
||||
<KbAdminPanel />
|
||||
</section>
|
||||
<KbAdminPanel />
|
||||
</template>
|
||||
@@ -1,14 +1,24 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/LinkedServicesPage.vue
|
||||
* 关联服务管理独立页面:表格列表 + 新增/编辑弹窗。
|
||||
* 依赖:useLinkedServicesAdmin、LinkedServiceFormModal、DeleteConfirmDialog。
|
||||
* 逻辑:路由 /admin/linked-services;启用项自动出现在 Chat/工作台侧栏底部。
|
||||
* 用途:关联服务列表。一张卡片里放标题、新增按钮和表格。
|
||||
* 依赖:AdminListPage、useLinkedServicesAdmin、element-plus、关联服务表单对话框。
|
||||
* 逻辑:路由 /admin/linked-services。启用项会出现在对话和工作台侧栏。删除用 Element 确认框。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Plus, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElSwitch,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
} 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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import type { AdminLinkedServiceRow } from '@/features/admin/types/linked-service.types';
|
||||
import LinkedServiceFormModal from './components/LinkedServiceFormModal.vue';
|
||||
import { useLinkedServicesAdmin } from './composables/useLinkedServicesAdmin';
|
||||
|
||||
@@ -20,8 +30,6 @@ const {
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
@@ -29,93 +37,67 @@ const {
|
||||
saveService,
|
||||
toggleEnabled,
|
||||
deleteServiceItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
} = useLinkedServicesAdmin();
|
||||
|
||||
/**
|
||||
* 打开编辑对话框。表格行类型较宽,这里收成关联服务行。
|
||||
* @param row - 当前表格行
|
||||
*/
|
||||
function editService(row: AdminLinkedServiceRow): void {
|
||||
openEditModal(row);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
<AdminListPage :loading="isLoading">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.linkedServices.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.linkedServices.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton type="primary" :icon="Plus" @click="openCreateModal">
|
||||
{{ t('admin.linkedServices.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.linkedServices.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.linkedServices.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span>{{ t('admin.linkedServices.add') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.linkedServices.headers.name') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.linkedServices.headers.url') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-28">{{ t('admin.linkedServices.headers.status') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-24">{{ t('admin.linkedServices.headers.sortOrder') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-40">{{ t('admin.linkedServices.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="services.length === 0">
|
||||
<td colspan="5" class="px-6 admin-table-empty">{{ t('admin.linkedServices.empty') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in services" :key="row.id">
|
||||
<td class="px-6 py-4 text-sm font-medium text-primary">{{ row.name }}</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary font-mono break-all">{{ row.url }}</td>
|
||||
<td class="px-6 py-4">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium transition-colors"
|
||||
:class="row.is_enabled
|
||||
? 'bg-emerald-50 text-emerald-700 hover:bg-emerald-100'
|
||||
: 'bg-surface-soft text-muted hover:bg-surface'"
|
||||
@click="toggleEnabled(row)"
|
||||
>
|
||||
{{ row.is_enabled ? t('admin.linkedServices.status.enabled') : t('admin.linkedServices.status.disabled') }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary">{{ row.sort_order }}</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary"
|
||||
:title="t('admin.edit')"
|
||||
@click="openEditModal(row)"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 rounded-lg text-muted hover:bg-red-50 hover:text-red-600"
|
||||
:title="t('admin.delete')"
|
||||
@click="deleteServiceItem(row.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
<ElTable
|
||||
class="hx-admin-table"
|
||||
:data="services"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.linkedServices.empty')"
|
||||
>
|
||||
<ElTableColumn prop="name" :label="t('admin.linkedServices.headers.name')" min-width="160" />
|
||||
<ElTableColumn prop="url" :label="t('admin.linkedServices.headers.url')" min-width="240">
|
||||
<template #default="{ row }">
|
||||
<span class="linked-service-url">{{ row.url }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.linkedServices.headers.status')" width="120">
|
||||
<template #default="{ row }">
|
||||
<ElSwitch
|
||||
:model-value="row.is_enabled"
|
||||
:title="row.is_enabled ? t('admin.linkedServices.status.enabled') : t('admin.linkedServices.status.disabled')"
|
||||
@change="toggleEnabled(row as AdminLinkedServiceRow)"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="sort_order" :label="t('admin.linkedServices.headers.sortOrder')" width="100" />
|
||||
<ElTableColumn :label="t('admin.linkedServices.headers.actions')" width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="editService(row as AdminLinkedServiceRow)">
|
||||
{{ t('admin.edit') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="deleteServiceItem((row as AdminLinkedServiceRow).id)">
|
||||
{{ t('admin.delete') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</AdminListPage>
|
||||
|
||||
<LinkedServiceFormModal
|
||||
:visible="showFormModal"
|
||||
@@ -124,12 +106,10 @@ onMounted(() => {
|
||||
@close="closeFormModal"
|
||||
@save="saveService"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@cancel="closeDeleteConfirm"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.linked-service-url {
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
+63
-47
@@ -1,11 +1,20 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/components/LinkedServiceFormModal.vue
|
||||
* 关联服务创建/编辑居中弹窗。
|
||||
* 依赖:LinkedServiceFormState、admin 通用 modal 样式。
|
||||
* 逻辑:LinkedServicesPage 打开本组件;提交时 emit save。
|
||||
* 用途:关联服务创建和编辑对话框。名称、地址、排序和启用开关。
|
||||
* 依赖:element-plus 对话框和表单、LinkedServiceFormState。
|
||||
* 逻辑:LinkedServicesPage 打开本组件。提交时 emit save,由 composable 调接口。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElSwitch,
|
||||
} from 'element-plus';
|
||||
import type { LinkedServiceFormState } from '@/features/admin/types/linked-service.types';
|
||||
|
||||
defineProps<{
|
||||
@@ -20,51 +29,58 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-lg 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">
|
||||
{{ form.id ? t('admin.linkedServices.edit') : t('admin.linkedServices.add') }}
|
||||
</h3>
|
||||
<p class="section-desc mt-1">{{ t('admin.linkedServices.formHint') }}</p>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.name') }}</label>
|
||||
<input
|
||||
v-model="form.name"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.linkedServices.placeholders.name')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.url') }}</label>
|
||||
<input
|
||||
v-model="form.url"
|
||||
type="url"
|
||||
class="input-field text-sm font-mono"
|
||||
:placeholder="t('admin.linkedServices.placeholders.url')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.sortOrder') }}</label>
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field text-sm" min="0" />
|
||||
</div>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary cursor-pointer">
|
||||
<input v-model="form.is_enabled" type="checkbox" class="w-4 h-4 rounded text-brand-600 border-default" />
|
||||
{{ t('admin.linkedServices.fields.enabled') }}
|
||||
</label>
|
||||
</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="isSaving" @click="emit('save')">
|
||||
{{ isSaving ? t('admin.save') + '...' : form.id ? t('admin.update') : t('admin.add') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="form.id ? t('admin.linkedServices.edit') : t('admin.linkedServices.add')"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!isSaving"
|
||||
:show-close="!isSaving"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<p class="section-desc">{{ t('admin.linkedServices.formHint') }}</p>
|
||||
<ElForm class="linked-service-form" label-position="top" :model="form" @submit.prevent="emit('save')">
|
||||
<ElFormItem :label="t('admin.linkedServices.fields.name')" required>
|
||||
<ElInput v-model="form.name" :placeholder="t('admin.linkedServices.placeholders.name')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.linkedServices.fields.url')" required>
|
||||
<ElInput v-model="form.url" :placeholder="t('admin.linkedServices.placeholders.url')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.linkedServices.fields.sortOrder')">
|
||||
<ElInputNumber v-model="form.sort_order" :min="0" controls-position="right" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.linkedServices.fields.enabled')">
|
||||
<ElSwitch v-model="form.is_enabled" />
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ form.id ? t('admin.update') : t('admin.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.linked-service-form {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.linked-service-form :deep(.el-input-number) {
|
||||
width: 9rem;
|
||||
}
|
||||
</style>
|
||||
+24
-46
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/composables/useLinkedServicesAdmin.ts
|
||||
* 关联服务管理:列表、新增/编辑弹窗、启用开关、删除。
|
||||
* 依赖:admin.api、linked-service.types、linked-nav.store、useMessage。
|
||||
* 逻辑:LinkedServicesPage 调用本 composable;保存/删除后刷新侧栏入口缓存。
|
||||
* 依赖:admin.api、linked-service.types、linked-nav.store、useMessage、element-plus 确认框。
|
||||
* 逻辑:LinkedServicesPage 调用本 composable;保存/删除后刷新侧栏入口缓存。删除用 ElMessageBox。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
createLinkedService,
|
||||
deleteLinkedService,
|
||||
@@ -32,10 +33,6 @@ export function useLinkedServicesAdmin() {
|
||||
const isSaving = ref(false);
|
||||
const showFormModal = ref(false);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/**
|
||||
* 拉取关联服务列表。
|
||||
* @returns Promise<void>
|
||||
@@ -60,29 +57,6 @@ export function useLinkedServicesAdmin() {
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
/** 打开删除确认对话框。 */
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
/** 关闭删除确认对话框。 */
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
/** 执行删除确认动作。 */
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
}
|
||||
};
|
||||
|
||||
/** 打开「新增关联服务」弹窗。 */
|
||||
const openCreateModal = (): void => {
|
||||
form.value = createEmptyLinkedServiceForm();
|
||||
@@ -160,21 +134,29 @@ export function useLinkedServicesAdmin() {
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除指定关联服务。
|
||||
* 删除指定关联服务。先用 Element 确认框询问,取消则不请求。
|
||||
* 核心逻辑:确定后删除、刷新列表,并更新侧栏入口缓存。
|
||||
* @param id - 主键
|
||||
*/
|
||||
const deleteServiceItem = (id: number): void => {
|
||||
openDeleteConfirm(t('admin.linkedServices.confirmDelete'), async () => {
|
||||
try {
|
||||
await deleteLinkedService(id);
|
||||
await loadServices();
|
||||
void linkedNav.refresh();
|
||||
msg.success(t('admin.linkedServices.msg.deleted'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
const deleteServiceItem = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.linkedServices.confirmDelete'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteLinkedService(id);
|
||||
await loadServices();
|
||||
void linkedNav.refresh();
|
||||
msg.success(t('admin.linkedServices.msg.deleted'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -183,8 +165,6 @@ export function useLinkedServicesAdmin() {
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
@@ -192,7 +172,5 @@ export function useLinkedServicesAdmin() {
|
||||
saveService,
|
||||
toggleEnabled,
|
||||
deleteServiceItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
};
|
||||
}
|
||||
@@ -1,24 +1,46 @@
|
||||
/**
|
||||
* features/admin/modules/permissions/PermissionsPage.vue
|
||||
* 用途:应用权限页。已种子权限组时以角色包为主、矩阵只读;否则保留历史按人勾选。
|
||||
* 依赖:usePermissionsAdmin、RoleEditModal、UserPickerDialog、PaginationBar、roleLabel、getUserAvatarLabel。
|
||||
* 逻辑:路由 /admin/permissions;点人数打开选人弹窗,确定后必须确认增减才写库。
|
||||
* 依赖:AdminListPage、AdminListTabs、usePermissionsAdmin、element-plus、RoleEditModal、RoleMembersConfirmDialog、UserPickerDialog、BatchPermissionModal。
|
||||
* 逻辑:路由 /admin/permissions。骨架用 AdminListPage。角色/矩阵用 AdminListTabs。
|
||||
* 点人数打开选人弹窗,确定后必须确认增减才写库。删除和重写入口确认用 ElMessageBox。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download, FileText, Plus, Shield, Users } from 'lucide-vue-next';
|
||||
import { Download, Plus, Upload, User } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
|
||||
import BatchPermissionModal from '@/features/admin/modules/users/components/BatchPermissionModal.vue';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import UserPickerDialog from '@/shared/components/UserPickerDialog.vue';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import type { AdminUserRow } from '@/features/admin/types/admin.types';
|
||||
import type { PermissionRoleRow } from '@/features/admin/types/permissionRole.types';
|
||||
import { adminRoleLabel, LEGACY_ROLE_OPTIONS } from '@/features/admin/utils/roleLabel';
|
||||
import RoleEditModal from './components/RoleEditModal.vue';
|
||||
import RoleMembersConfirmDialog from './components/RoleMembersConfirmDialog.vue';
|
||||
import { usePermissionsAdmin } from './composables/usePermissionsAdmin';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t } = useI18n();
|
||||
const csvInputRef = ref<HTMLInputElement | null>(null);
|
||||
|
||||
const {
|
||||
agents,
|
||||
@@ -28,13 +50,13 @@ const {
|
||||
permissionFilters,
|
||||
selectedUserIds,
|
||||
paginatedUsers,
|
||||
allUsersSelectedOnPage,
|
||||
permissionPage,
|
||||
permissionPageSize,
|
||||
permissionPageSizeOptions,
|
||||
permissionTotalRows,
|
||||
permissionTotalPages,
|
||||
allUsersSelectedOnPage,
|
||||
isLoading,
|
||||
isListLoading,
|
||||
isSaving,
|
||||
activeTab,
|
||||
rolesConfigured,
|
||||
@@ -43,8 +65,6 @@ const {
|
||||
showRoleEditor,
|
||||
editingExisting,
|
||||
roleDraft,
|
||||
editingMemberCount,
|
||||
showRoleSaveConfirm,
|
||||
pickerRole,
|
||||
showPicker,
|
||||
pickerSelectedIds,
|
||||
@@ -64,7 +84,6 @@ const {
|
||||
openEditRole,
|
||||
closeRoleEditor,
|
||||
requestSaveRole,
|
||||
persistRole,
|
||||
removeRole,
|
||||
openMembersPicker,
|
||||
handlePickerConfirm,
|
||||
@@ -72,285 +91,272 @@ const {
|
||||
applyMembers,
|
||||
} = usePermissionsAdmin();
|
||||
|
||||
/** 角色表只在已配置权限组、并且停在角色页时显示。 */
|
||||
const showRoles = computed(() => rolesConfigured.value && activeTab.value === 'roles');
|
||||
/** 未配置权限组时直接看矩阵;已配置时跟页签走。 */
|
||||
const showMatrix = computed(() => !rolesConfigured.value || activeTab.value === 'matrix');
|
||||
|
||||
/** 角色表和权限矩阵两个页签。没有权限组时不渲染这一条。 */
|
||||
const permissionTabs = computed(() => [
|
||||
{ name: 'roles', label: t('admin.permRoles.tabs.roles') },
|
||||
{ name: 'matrix', label: t('admin.permRoles.tabs.matrix') },
|
||||
]);
|
||||
|
||||
/**
|
||||
* 公共页签回传字符串,这里收成角色或矩阵。
|
||||
* @param name - AdminListTabs 当前 name
|
||||
*/
|
||||
function onPermissionTab(name: string): void {
|
||||
if (name === 'roles' || name === 'matrix') activeTab.value = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色筛选。清空时写回空字符串,矩阵仍按「所有角色」过滤。
|
||||
* @param value - 选中的角色编码;清空不是字符串
|
||||
*/
|
||||
function onRoleFilterChange(value: unknown): void {
|
||||
permissionFilters.value.role = typeof value === 'string' ? value : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开隐藏的 CSV 文件框,选中后仍走 importPermissions。
|
||||
*/
|
||||
function openCsvImport(): void {
|
||||
csvInputRef.value?.click();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="section-gap animate-fade-in-up">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.perm.title') }}</h2>
|
||||
<p class="section-desc mt-1">
|
||||
{{ rolesConfigured ? t('admin.permRoles.subtitle') : t('admin.perm.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<button
|
||||
<AdminListPage :loading="isLoading">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.perm.title') }}</h2>
|
||||
<p class="section-desc mt-1">
|
||||
{{ rolesConfigured ? t('admin.permRoles.subtitle') : t('admin.perm.subtitle') }}
|
||||
</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<div class="perm-actions">
|
||||
<ElSpace wrap>
|
||||
<ElButton
|
||||
v-if="!rolesConfigured && selectedUserIds.length > 0"
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white rounded-xl hover:bg-indigo-700 transition-all shadow-lg shadow-indigo-200 active:scale-95"
|
||||
type="primary"
|
||||
:icon="User"
|
||||
@click="openBatchPermissionModal"
|
||||
>
|
||||
<Users class="w-4 h-4" />
|
||||
<span class="font-medium">{{ t('admin.perm.batchAssign') }}</span>
|
||||
</button>
|
||||
<label
|
||||
v-if="!rolesConfigured"
|
||||
class="flex items-center gap-2 px-4 py-2 btn-secondary cursor-pointer text-sm font-medium transition-all shadow-sm"
|
||||
>
|
||||
<input type="file" accept=".csv" class="hidden" @change="importPermissions" />
|
||||
<FileText class="w-4 h-4" />
|
||||
{{ t('admin.perm.batchAssign') }}
|
||||
</ElButton>
|
||||
<ElButton v-if="!rolesConfigured" :icon="Upload" @click="openCsvImport">
|
||||
{{ t('admin.perm.importCsv') }}
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 btn-secondary text-sm font-medium transition-all shadow-sm"
|
||||
@click="exportPermissions"
|
||||
>
|
||||
<Download class="w-4 h-4" />
|
||||
</ElButton>
|
||||
<ElButton :icon="Download" @click="exportPermissions">
|
||||
{{ t('admin.perm.exportCsv') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="rolesConfigured"
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 text-sm font-medium"
|
||||
@click="openCreateRole"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
</ElButton>
|
||||
<ElButton v-if="rolesConfigured" type="primary" :icon="Plus" @click="openCreateRole">
|
||||
{{ t('admin.permRoles.create') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
<input
|
||||
ref="csvInputRef"
|
||||
type="file"
|
||||
accept=".csv"
|
||||
class="perm-csv-input"
|
||||
@change="importPermissions"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="rolesConfigured" class="flex gap-1 border-b border-default">
|
||||
<button
|
||||
type="button"
|
||||
class="px-4 py-2 text-sm font-medium"
|
||||
:class="activeTab === 'roles' ? 'border-b-2 border-brand-600 text-brand-700' : 'text-muted'"
|
||||
@click="activeTab = 'roles'"
|
||||
</template>
|
||||
<template v-if="rolesConfigured" #tabs>
|
||||
<AdminListTabs :model-value="activeTab" :items="permissionTabs" @update:model-value="onPermissionTab" />
|
||||
</template>
|
||||
<template v-if="showMatrix" #filters>
|
||||
<ElInput
|
||||
v-model="permissionFilters.username"
|
||||
clearable
|
||||
class="perm-filter-search"
|
||||
:placeholder="t('admin.perm.filterName')"
|
||||
/>
|
||||
<ElInput
|
||||
v-model="permissionFilters.department"
|
||||
clearable
|
||||
class="perm-filter-search"
|
||||
:placeholder="t('admin.perm.filterDept')"
|
||||
/>
|
||||
<ElSelect
|
||||
:model-value="permissionFilters.role || undefined"
|
||||
class="perm-filter-role"
|
||||
clearable
|
||||
:placeholder="t('admin.perm.allRoles')"
|
||||
@update:model-value="onRoleFilterChange"
|
||||
>
|
||||
{{ t('admin.permRoles.tabs.roles') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="px-4 py-2 text-sm font-medium"
|
||||
:class="activeTab === 'matrix' ? 'border-b-2 border-brand-600 text-brand-700' : 'text-muted'"
|
||||
@click="activeTab = 'matrix'"
|
||||
<ElOption v-for="role in roles" :key="role.code" :label="role.name" :value="role.code" />
|
||||
<template v-if="!roles.length">
|
||||
<ElOption
|
||||
v-for="option in LEGACY_ROLE_OPTIONS"
|
||||
:key="option.code"
|
||||
:label="t(option.i18nKey)"
|
||||
:value="option.code"
|
||||
/>
|
||||
</template>
|
||||
</ElSelect>
|
||||
<span v-if="rolesConfigured" class="hx-element-hint perm-matrix-hint">
|
||||
{{ t('admin.permRoles.matrixHint') }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<ElTable
|
||||
v-if="showRoles"
|
||||
v-loading="isListLoading"
|
||||
class="hx-admin-table"
|
||||
:data="roles"
|
||||
row-key="code"
|
||||
:empty-text="t('admin.wecom.noData')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.permRoles.headers.name')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<div>{{ row.name }}</div>
|
||||
<div v-if="row.is_default || row.is_platform_admin" class="perm-role-badges">
|
||||
<ElTag v-if="row.is_default" effect="light">{{ t('admin.permRoles.badge.default') }}</ElTag>
|
||||
<ElTag v-if="row.is_platform_admin" type="warning" effect="light">
|
||||
{{ t('admin.permRoles.badge.admin') }}
|
||||
</ElTag>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.permRoles.headers.description')" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<span class="perm-secondary">{{ row.description || '-' }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.permRoles.headers.members')" width="120">
|
||||
<template #default="{ row }">
|
||||
<ElButton
|
||||
v-if="!row.is_platform_admin"
|
||||
link
|
||||
type="primary"
|
||||
@click="openMembersPicker(row as PermissionRoleRow)"
|
||||
>
|
||||
{{ t('admin.permRoles.memberCount', { count: row.member_count }) }}
|
||||
</ElButton>
|
||||
<span v-else class="perm-secondary">
|
||||
{{ t('admin.permRoles.memberCount', { count: row.member_count }) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.permRoles.headers.apps')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<span class="perm-secondary">
|
||||
{{
|
||||
row.is_platform_admin
|
||||
? t('admin.permRoles.allApps')
|
||||
: (row.agent_names || []).join('、') || '-'
|
||||
}}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.user.headers.actions')" width="160" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openEditRole(row as PermissionRoleRow)">
|
||||
{{ t('admin.edit') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!row.is_system && !row.is_platform_admin"
|
||||
link
|
||||
type="danger"
|
||||
@click="removeRole(row as PermissionRoleRow)"
|
||||
>
|
||||
{{ t('admin.delete') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<ElTable
|
||||
v-if="showMatrix"
|
||||
v-loading="isListLoading"
|
||||
class="hx-admin-table"
|
||||
:data="paginatedUsers"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.user.noUsers')"
|
||||
>
|
||||
<ElTableColumn v-if="!rolesConfigured" width="64" align="center" fixed="left">
|
||||
<template #header>
|
||||
<ElCheckbox
|
||||
class="perm-check"
|
||||
:model-value="allUsersSelectedOnPage"
|
||||
@change="toggleAllUsers"
|
||||
/>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<ElCheckbox
|
||||
class="perm-check"
|
||||
:model-value="selectedUserIds.includes(row.id)"
|
||||
@change="toggleUserSelection(row.id)"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.perm.headers.user')" min-width="200" fixed="left">
|
||||
<template #default="{ row }">
|
||||
<span class="perm-user">
|
||||
<span class="perm-avatar">{{ getUserAvatarLabel(row) }}</span>
|
||||
<span class="perm-ellipsis" :title="row.username">{{ row.username }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.perm.headers.realName')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<span class="perm-ellipsis" :title="row.real_name || '-'">{{ row.real_name || '-' }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.perm.headers.dept')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span class="perm-secondary perm-ellipsis" :title="row.department || '-'">
|
||||
{{ row.department || '-' }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.user.headers.role')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
{{ adminRoleLabel(t, row.role, row.role_name) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
:label="agent.name"
|
||||
min-width="120"
|
||||
align="center"
|
||||
>
|
||||
{{ t('admin.permRoles.tabs.matrix') }}
|
||||
</button>
|
||||
</div>
|
||||
<template #header>
|
||||
<div class="perm-agent-head">
|
||||
<span>{{ agent.name }}</span>
|
||||
<ElTag v-if="agent.type" effect="light">{{ agent.type }}</ElTag>
|
||||
</div>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<ElCheckbox
|
||||
class="perm-check"
|
||||
:model-value="userHasAgent(row as AdminUserRow, agent.id)"
|
||||
:disabled="rolesConfigured"
|
||||
@change="toggleUserAgentPermission(row as AdminUserRow, agent.id)"
|
||||
/>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<div v-if="rolesConfigured && activeTab === 'roles'" class="space-y-4">
|
||||
<template v-if="rolesConfigured">
|
||||
<div class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-sm">{{ t('admin.permRoles.headers.name') }}</th>
|
||||
<th class="px-6 py-4 text-left text-sm">{{ t('admin.permRoles.headers.description') }}</th>
|
||||
<th class="px-6 py-4 text-left text-sm">{{ t('admin.permRoles.headers.members') }}</th>
|
||||
<th class="px-6 py-4 text-left text-sm">{{ t('admin.permRoles.headers.apps') }}</th>
|
||||
<th class="px-6 py-4 text-right text-sm">{{ t('admin.user.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="role in roles" :key="role.code">
|
||||
<td class="px-6 py-4">
|
||||
<div class="font-medium text-primary">{{ role.name }}</div>
|
||||
<div class="mt-1 flex flex-wrap gap-1.5">
|
||||
<span
|
||||
v-if="role.is_default"
|
||||
class="inline-flex rounded-full border border-brand-100 bg-brand-50 px-2 py-0.5 text-[11px] text-brand-700"
|
||||
>
|
||||
{{ t('admin.permRoles.badge.default') }}
|
||||
</span>
|
||||
<span
|
||||
v-if="role.is_platform_admin"
|
||||
class="inline-flex items-center gap-1 rounded-full border border-purple-100 bg-purple-50 px-2 py-0.5 text-[11px] text-purple-700"
|
||||
>
|
||||
<Shield class="w-3 h-3" />
|
||||
{{ t('admin.permRoles.badge.admin') }}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-muted max-w-xs">{{ role.description || '-' }}</td>
|
||||
<td class="px-6 py-4">
|
||||
<button
|
||||
v-if="!role.is_platform_admin"
|
||||
type="button"
|
||||
class="text-brand-600 hover:text-brand-800 font-semibold"
|
||||
@click="openMembersPicker(role)"
|
||||
>
|
||||
{{ t('admin.permRoles.memberCount', { count: role.member_count }) }}
|
||||
</button>
|
||||
<span v-else class="text-sm text-muted">
|
||||
{{ t('admin.permRoles.memberCount', { count: role.member_count }) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-muted">
|
||||
{{
|
||||
role.is_platform_admin
|
||||
? t('admin.permRoles.allApps')
|
||||
: (role.agent_names || []).join('、') || '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right whitespace-nowrap">
|
||||
<button
|
||||
type="button"
|
||||
class="text-brand-600 hover:text-brand-900 font-medium text-xs px-3 py-1.5 rounded-lg hover:bg-brand-50"
|
||||
@click="openEditRole(role)"
|
||||
>
|
||||
{{ t('admin.edit') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!role.is_system && !role.is_platform_admin"
|
||||
type="button"
|
||||
class="text-red-600 hover:text-red-800 font-medium text-xs px-3 py-1.5 rounded-lg hover:bg-red-50"
|
||||
@click="removeRole(role)"
|
||||
>
|
||||
{{ t('admin.delete') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<template v-if="!rolesConfigured || activeTab === 'matrix'">
|
||||
<p v-if="rolesConfigured" class="text-sm text-muted">{{ t('admin.permRoles.matrixHint') }}</p>
|
||||
<div class="admin-table-filters--inline">
|
||||
<input
|
||||
v-model="permissionFilters.username"
|
||||
:placeholder="t('admin.perm.filterName')"
|
||||
class="admin-table-filter-input w-48"
|
||||
/>
|
||||
<input
|
||||
v-model="permissionFilters.department"
|
||||
:placeholder="t('admin.perm.filterDept')"
|
||||
class="admin-table-filter-input w-48"
|
||||
/>
|
||||
<select v-model="permissionFilters.role" class="admin-table-filter-input w-40">
|
||||
<option value="">{{ t('admin.perm.allRoles') }}</option>
|
||||
<option v-for="role in roles" :key="role.code" :value="role.code">{{ role.name }}</option>
|
||||
<template v-if="!roles.length">
|
||||
<option
|
||||
v-for="option in LEGACY_ROLE_OPTIONS"
|
||||
:key="option.code"
|
||||
:value="option.code"
|
||||
>
|
||||
{{ t(option.i18nKey) }}
|
||||
</option>
|
||||
</template>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th v-if="!rolesConfigured" class="px-4 py-4 w-12 text-center sticky left-0 admin-table-sticky-head z-20">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500"
|
||||
:checked="allUsersSelectedOnPage"
|
||||
@change="toggleAllUsers"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-sm sticky left-0 admin-table-sticky-head z-20 w-56">
|
||||
{{ t('admin.perm.headers.user') }}
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-sm w-36">{{ t('admin.perm.headers.realName') }}</th>
|
||||
<th class="px-6 py-4 text-left text-sm w-40 border-r border-subtle">
|
||||
{{ t('admin.perm.headers.dept') }}
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-sm w-32">{{ t('admin.user.headers.role') }}</th>
|
||||
<th
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="px-4 py-4 text-center text-sm min-w-[100px]"
|
||||
>
|
||||
<div class="flex flex-col items-center gap-1">
|
||||
<span>{{ agent.name }}</span>
|
||||
<span class="text-[10px] text-muted font-normal border border-default px-1 rounded">
|
||||
{{ agent.type }}
|
||||
</span>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="user in paginatedUsers" :key="user.id">
|
||||
<td v-if="!rolesConfigured" class="px-4 py-4 text-center sticky left-0 admin-table-sticky-cell z-20">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500"
|
||||
:checked="selectedUserIds.includes(user.id)"
|
||||
@change="toggleUserSelection(user.id)"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-6 py-4 sticky left-0 admin-table-sticky-cell z-20">
|
||||
<div class="flex items-center gap-3">
|
||||
<div
|
||||
class="w-8 h-8 rounded-full bg-gradient-to-br from-brand-100 to-indigo-100 text-brand-600 flex items-center justify-center font-bold text-sm"
|
||||
>
|
||||
{{ getUserAvatarLabel(user) }}
|
||||
</div>
|
||||
<div class="font-medium text-primary text-sm truncate max-w-[120px]" :title="user.username">
|
||||
{{ user.username }}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="text-sm text-primary truncate" :title="user.real_name || '-'">
|
||||
{{ user.real_name || '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 border-r border-subtle">
|
||||
<div class="text-sm text-muted truncate" :title="user.department">
|
||||
{{ user.department || '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-primary">
|
||||
{{ adminRoleLabel(t, user.role, user.role_name) }}
|
||||
</td>
|
||||
<td
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="px-4 py-4 text-center border-l border-dashed border-subtle"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="admin-checkbox-lg"
|
||||
:checked="userHasAgent(user, agent.id)"
|
||||
:disabled="rolesConfigured"
|
||||
@change="toggleUserAgentPermission(user, agent.id)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<PaginationBar
|
||||
v-model:page="permissionPage"
|
||||
<template v-if="showMatrix" #pagination>
|
||||
<ElPagination
|
||||
v-model:current-page="permissionPage"
|
||||
v-model:page-size="permissionPageSize"
|
||||
:total="permissionTotalRows"
|
||||
:pages="permissionTotalPages"
|
||||
:page-size-options="permissionPageSizeOptions"
|
||||
class="mt-5"
|
||||
:page-sizes="permissionPageSizeOptions"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
/>
|
||||
</template>
|
||||
</template>
|
||||
</AdminListPage>
|
||||
|
||||
<BatchPermissionModal
|
||||
:visible="showBatchPermissionModal"
|
||||
@@ -374,16 +380,6 @@ onMounted(() => {
|
||||
@update:draft="roleDraft = $event"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showRoleSaveConfirm"
|
||||
:title="t('admin.permRoles.saveConfirm.title')"
|
||||
:message="t('admin.permRoles.saveConfirm.message', { count: editingMemberCount })"
|
||||
:confirm-text="t('admin.save')"
|
||||
confirm-tone="primary"
|
||||
:confirm-loading="isSaving"
|
||||
@confirm="persistRole"
|
||||
/>
|
||||
|
||||
<UserPickerDialog
|
||||
v-model="showPicker"
|
||||
:users="pickerUsers"
|
||||
@@ -400,5 +396,83 @@ onMounted(() => {
|
||||
@cancel="cancelMembersConfirm"
|
||||
@confirm="applyMembers"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.perm-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.perm-csv-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.perm-filter-search) {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
:deep(.perm-filter-role) {
|
||||
width: 11rem;
|
||||
}
|
||||
|
||||
.perm-matrix-hint {
|
||||
margin-top: 0;
|
||||
flex: 1 1 12rem;
|
||||
min-width: 12rem;
|
||||
}
|
||||
|
||||
.perm-role-badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.perm-secondary {
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.perm-user {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.perm-avatar {
|
||||
display: flex;
|
||||
height: 2.25rem;
|
||||
width: 2.25rem;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 9999px;
|
||||
background-image: linear-gradient(to bottom right, #0ea5e9, #4f46e5);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.perm-ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.perm-agent-head {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.perm-check :deep(.el-checkbox) {
|
||||
height: auto;
|
||||
margin-right: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
@@ -1,13 +1,23 @@
|
||||
/**
|
||||
* features/admin/modules/permissions/components/RoleEditModal.vue
|
||||
* 用途:新建/编辑权限组:名称、应用入口,以及挂在各应用下的功能权限。
|
||||
* 依赖:permissionRole.types、rolePackage.utils、vue-i18n、lucide-vue-next。
|
||||
* 逻辑:PermissionsPage 打开;应用按对话形态分组;能力默认折叠,点右侧展开后再勾选。
|
||||
* 依赖:permissionRole.types、rolePackage.utils、vue-i18n、element-plus。
|
||||
* 逻辑:PermissionsPage 打开;应用按对话形态分组;能力默认折叠,点右侧展开后再勾选。样式跟权限页已引入的 Element 皮肤走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ChevronDown, Search } from 'lucide-vue-next';
|
||||
import { ArrowDown, Search } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import type {
|
||||
PermissionRoleCatalog,
|
||||
PermissionRoleCatalogAgent,
|
||||
@@ -41,6 +51,14 @@ const { t, te } = useI18n();
|
||||
const appQuery = ref('');
|
||||
const expandedAgentIds = ref<number[]>([]);
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起编辑框。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(open) => {
|
||||
@@ -171,266 +189,257 @@ function toggleFeature(agent: PermissionRoleCatalogAgent, key: string, checked:
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in">
|
||||
<div class="admin-modal-panel max-w-3xl 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">
|
||||
{{ isCreate ? t('admin.permRoles.edit.createTitle') : t('admin.permRoles.edit.title') }}
|
||||
</h3>
|
||||
<p class="section-desc mt-1">{{ t('admin.permRoles.edit.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto">
|
||||
<div class="space-y-4">
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
{{ t('admin.permRoles.edit.name') }}
|
||||
</label>
|
||||
<input
|
||||
:value="draft.name"
|
||||
type="text"
|
||||
class="w-full border-default rounded-xl px-4 py-3 text-sm"
|
||||
@input="patch({ name: ($event.target as HTMLInputElement).value })"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="isCreate" class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
{{ t('admin.permRoles.edit.code') }}
|
||||
</label>
|
||||
<input
|
||||
:value="draft.code"
|
||||
type="text"
|
||||
class="w-full border-default rounded-xl px-4 py-3 text-sm"
|
||||
:placeholder="t('admin.permRoles.edit.codeHint')"
|
||||
@input="patch({ code: ($event.target as HTMLInputElement).value })"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="block text-xs font-semibold text-muted uppercase tracking-wider">
|
||||
{{ t('admin.permRoles.edit.description') }}
|
||||
</label>
|
||||
<textarea
|
||||
:value="draft.description"
|
||||
rows="2"
|
||||
class="w-full border-default rounded-xl px-4 py-3 text-sm"
|
||||
@input="patch({ description: ($event.target as HTMLTextAreaElement).value })"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<label class="flex items-center gap-2 text-sm text-primary">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600"
|
||||
:checked="draft.is_default"
|
||||
:disabled="draft.is_default && !isCreate"
|
||||
@change="patch({ is_default: ($event.target as HTMLInputElement).checked })"
|
||||
/>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="isCreate ? t('admin.permRoles.edit.createTitle') : t('admin.permRoles.edit.title')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!isSaving"
|
||||
:show-close="!isSaving"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<ElForm class="perm-role-form" label-position="top" :model="draft" @submit.prevent>
|
||||
<p class="hx-element-hint">{{ t('admin.permRoles.edit.subtitle') }}</p>
|
||||
<ElFormItem :label="t('admin.permRoles.edit.name')">
|
||||
<ElInput
|
||||
:model-value="draft.name"
|
||||
@update:model-value="patch({ name: String($event) })"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="isCreate" :label="t('admin.permRoles.edit.code')">
|
||||
<ElInput
|
||||
:model-value="draft.code"
|
||||
:placeholder="t('admin.permRoles.edit.codeHint')"
|
||||
@update:model-value="patch({ code: String($event) })"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.permRoles.edit.description')">
|
||||
<ElInput
|
||||
:model-value="draft.description"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
@update:model-value="patch({ description: String($event) })"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<ElCheckbox
|
||||
:model-value="draft.is_default"
|
||||
:disabled="draft.is_default && !isCreate"
|
||||
@change="patch({ is_default: Boolean($event) })"
|
||||
>
|
||||
{{ t('admin.permRoles.edit.isDefault') }}
|
||||
</label>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="flex flex-wrap items-end justify-between gap-2">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-wider text-muted">
|
||||
{{ t('admin.permRoles.edit.apps') }}
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-muted">
|
||||
{{ isPlatformAdmin ? t('admin.permRoles.edit.adminAllApps') : t('admin.permRoles.edit.appsHint') }}
|
||||
</p>
|
||||
</div>
|
||||
<span class="text-xs font-medium text-brand-700">
|
||||
</ElCheckbox>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="role-apps-item">
|
||||
<template #label>
|
||||
<span class="role-apps-label">
|
||||
<span>{{ t('admin.permRoles.edit.apps') }}</span>
|
||||
<ElTag effect="light">
|
||||
{{ t('admin.permRoles.edit.selectedCount', { count: selectedCount }) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="relative">
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted" />
|
||||
<input
|
||||
v-model="appQuery"
|
||||
type="search"
|
||||
class="w-full rounded-xl border-default py-2 pl-9 pr-3 text-sm"
|
||||
:placeholder="t('admin.permRoles.edit.filterPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="role-app-list">
|
||||
<p v-if="!groupedAgents.length" class="px-4 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.permRoles.edit.noMatch') }}
|
||||
</p>
|
||||
<section v-for="group in groupedAgents" :key="group.mode" class="role-app-group">
|
||||
<h4 class="role-app-group-title">{{ group.label }}</h4>
|
||||
<div
|
||||
v-for="agent in group.agents"
|
||||
:key="agent.id"
|
||||
class="role-app-row"
|
||||
:class="agentSelected(agent.id) ? 'is-on' : ''"
|
||||
>
|
||||
<div class="flex items-center gap-2.5">
|
||||
<label
|
||||
class="flex min-w-0 flex-1 items-center gap-2.5"
|
||||
:class="isPlatformAdmin ? 'cursor-default' : 'cursor-pointer'"
|
||||
</ElTag>
|
||||
</span>
|
||||
</template>
|
||||
<p class="hx-element-hint">
|
||||
{{ isPlatformAdmin ? t('admin.permRoles.edit.adminAllApps') : t('admin.permRoles.edit.appsHint') }}
|
||||
</p>
|
||||
<ElInput
|
||||
v-model="appQuery"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
:placeholder="t('admin.permRoles.edit.filterPlaceholder')"
|
||||
/>
|
||||
<div class="role-app-list">
|
||||
<p v-if="!groupedAgents.length" class="role-app-empty">
|
||||
{{ t('admin.permRoles.edit.noMatch') }}
|
||||
</p>
|
||||
<section v-for="group in groupedAgents" :key="group.mode" class="role-app-group">
|
||||
<h4 class="role-app-group-title">{{ group.label }}</h4>
|
||||
<div
|
||||
v-for="agent in group.agents"
|
||||
:key="agent.id"
|
||||
class="role-app-row"
|
||||
:class="{ 'is-on': agentSelected(agent.id) }"
|
||||
>
|
||||
<div class="role-app-main">
|
||||
<ElCheckbox
|
||||
class="role-agent-check"
|
||||
:model-value="agentSelected(agent.id)"
|
||||
:disabled="isPlatformAdmin"
|
||||
@change="toggleAgent(agent.id)"
|
||||
>
|
||||
<span class="perm-ellipsis">{{ agent.name }}</span>
|
||||
</ElCheckbox>
|
||||
<ElButton
|
||||
v-if="agentFeatures(agent).length"
|
||||
link
|
||||
type="primary"
|
||||
:aria-expanded="isExpanded(agent.id)"
|
||||
@click="toggleExpanded(agent.id)"
|
||||
>
|
||||
{{ t('admin.permRoles.edit.featureCount', { count: agentFeatures(agent).length }) }}
|
||||
<ElIcon class="role-expand-icon" :class="{ 'is-open': isExpanded(agent.id) }">
|
||||
<ArrowDown />
|
||||
</ElIcon>
|
||||
</ElButton>
|
||||
</div>
|
||||
<div v-if="isExpanded(agent.id) && agentFeatures(agent).length" class="role-feat-row">
|
||||
<div
|
||||
v-for="feature in agentFeatures(agent)"
|
||||
:key="feature.key"
|
||||
class="role-feat"
|
||||
:class="{ 'is-on': draft.feature_permissions[feature.key] }"
|
||||
:title="featureHint(feature)"
|
||||
>
|
||||
<ElCheckbox
|
||||
:model-value="Boolean(draft.feature_permissions[feature.key])"
|
||||
@change="toggleFeature(agent, feature.key, Boolean($event))"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="role-check appearance-none"
|
||||
:checked="agentSelected(agent.id)"
|
||||
:disabled="isPlatformAdmin"
|
||||
@change="toggleAgent(agent.id)"
|
||||
/>
|
||||
<span class="min-w-0 truncate text-sm font-medium text-primary">{{ agent.name }}</span>
|
||||
</label>
|
||||
<button
|
||||
v-if="agentFeatures(agent).length"
|
||||
type="button"
|
||||
class="role-expand"
|
||||
:aria-expanded="isExpanded(agent.id)"
|
||||
@click="toggleExpanded(agent.id)"
|
||||
>
|
||||
{{ t('admin.permRoles.edit.featureCount', { count: agentFeatures(agent).length }) }}
|
||||
<ChevronDown class="h-3.5 w-3.5 transition-transform" :class="isExpanded(agent.id) ? 'rotate-180' : ''" />
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="isExpanded(agent.id) && agentFeatures(agent).length" class="role-feat-row">
|
||||
<label
|
||||
v-for="feature in agentFeatures(agent)"
|
||||
:key="feature.key"
|
||||
class="role-feat"
|
||||
:class="draft.feature_permissions[feature.key] ? 'is-on' : ''"
|
||||
:title="featureHint(feature)"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="role-check role-check--sm appearance-none"
|
||||
:checked="Boolean(draft.feature_permissions[feature.key])"
|
||||
@change="toggleFeature(agent, feature.key, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
<span class="truncate">{{ featureLabel(feature) }}</span>
|
||||
</label>
|
||||
<span class="perm-ellipsis">{{ featureLabel(feature) }}</span>
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</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="isSaving" @click="emit('save')">
|
||||
{{ isSaving ? t('admin.save') + '...' : t('admin.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ t('admin.save') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.perm-role-form {
|
||||
max-height: min(68vh, 640px);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.role-apps-item :deep(.el-form-item__label) {
|
||||
width: 100%;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.role-apps-item :deep(.el-form-item__content) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.role-apps-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.role-app-list {
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 16px;
|
||||
background: var(--bg-surface);
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.role-app-empty {
|
||||
margin: 0;
|
||||
padding: 32px 16px;
|
||||
text-align: center;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.role-app-group + .role-app-group {
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.role-app-group-title {
|
||||
margin: 0;
|
||||
padding: 10px 14px 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.06em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-muted);
|
||||
background: var(--bg-surface-soft);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
font-weight: 400;
|
||||
color: var(--el-text-color-secondary);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.role-app-row {
|
||||
padding: 9px 14px;
|
||||
}
|
||||
|
||||
.role-app-row + .role-app-row {
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.role-app-row.is-on {
|
||||
background: color-mix(in srgb, var(--status-info-bg) 72%, var(--bg-surface));
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
.role-app-row:hover {
|
||||
background: var(--bg-surface-soft);
|
||||
|
||||
.role-app-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
.role-app-row.is-on:hover {
|
||||
background: color-mix(in srgb, var(--status-info-bg) 88%, var(--bg-surface));
|
||||
|
||||
.role-app-main :deep(.el-button) {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.role-agent-check {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.role-agent-check :deep(.el-checkbox__label) {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.role-expand-icon {
|
||||
margin-left: 2px;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.role-expand-icon.is-open {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
.role-feat-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin: 8px 0 2px 28px;
|
||||
}
|
||||
.role-check {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
flex: none;
|
||||
margin: 0;
|
||||
border: 1.5px solid #64748b;
|
||||
border-radius: 4px;
|
||||
background-color: #fff;
|
||||
background-image: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
.role-check:hover:not(:disabled) {
|
||||
border-color: var(--status-info-fg);
|
||||
}
|
||||
.role-check:checked {
|
||||
background: var(--status-info-fg);
|
||||
border-color: var(--status-info-fg);
|
||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-6'/></svg>");
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: 12px 12px;
|
||||
}
|
||||
.role-check:disabled {
|
||||
cursor: default;
|
||||
opacity: 0.55;
|
||||
}
|
||||
.role-check--sm {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
.role-expand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 2px;
|
||||
flex: none;
|
||||
padding: 2px 6px;
|
||||
border: 0;
|
||||
border-radius: 6px;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
.role-expand:hover {
|
||||
background: var(--bg-surface-strong);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.role-feat {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
max-width: 100%;
|
||||
padding: 3px 8px 3px 6px;
|
||||
border: 1px solid var(--border-default);
|
||||
padding: 2px 8px 2px 6px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 999px;
|
||||
background: var(--bg-surface);
|
||||
color: var(--text-secondary);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 1.35;
|
||||
cursor: pointer;
|
||||
}
|
||||
.role-feat:hover {
|
||||
border-color: color-mix(in srgb, var(--status-info-fg) 35%, var(--border-default));
|
||||
color: var(--status-info-fg);
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.role-feat.is-on {
|
||||
border-color: color-mix(in srgb, var(--status-info-fg) 40%, transparent);
|
||||
background: var(--status-info-bg);
|
||||
color: var(--status-info-fg);
|
||||
border-color: var(--el-color-primary-light-5);
|
||||
background: var(--el-color-primary-light-9);
|
||||
}
|
||||
|
||||
.role-feat :deep(.el-checkbox) {
|
||||
height: auto;
|
||||
margin-right: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.perm-ellipsis {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
+115
-58
@@ -1,14 +1,16 @@
|
||||
/**
|
||||
* features/admin/modules/permissions/components/RoleMembersConfirmDialog.vue
|
||||
* 用途:选人确定后展示将改入/移出的人及来源角色,确认才写库。
|
||||
* 依赖:permissionRole.types、vue-i18n。
|
||||
* 逻辑:PermissionsPage 在 UserPickerDialog 之后打开;取消不改变成员。
|
||||
* 用途:选人确定后展示将加入/移出本角色的人,以及仍保留的其他角色。确认才写库。
|
||||
* 依赖:permissionRole.types、vue-i18n、element-plus 对话框。
|
||||
* 逻辑:PermissionsPage 在 UserPickerDialog 之后打开;取消不改变成员。样式跟权限页已引入的 Element 皮肤走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElTag } from 'element-plus';
|
||||
import type { PermissionRoleMembersPreview, PermissionRolePerson } from '@/features/admin/types/permissionRole.types';
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
preview: PermissionRoleMembersPreview | null;
|
||||
isSaving: boolean;
|
||||
@@ -21,68 +23,123 @@ const emit = defineEmits<{
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 把人员和仍保留的角色拼成一行。
|
||||
* @param person - 预览里的成员
|
||||
* @returns 姓名,或姓名 · 仍保留的角色
|
||||
*/
|
||||
function personLine(person: PermissionRolePerson): string {
|
||||
const name = person.real_name || person.username;
|
||||
const from = person.role_name || person.role;
|
||||
return `${name} · ${from}`;
|
||||
const kept = (person.retained_role_names || []).filter(Boolean).join('、');
|
||||
return kept ? `${name} · ${kept}` : name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有需要写库的增减。
|
||||
* @returns 有加入或移出时为 true
|
||||
*/
|
||||
const hasChanges = computed(() => Boolean(props.preview && (props.preview.added.length || props.preview.removed.length)));
|
||||
|
||||
/**
|
||||
* 移出后是否有人会回到默认权限组。
|
||||
*/
|
||||
const returnsToDefault = computed(() =>
|
||||
Boolean(props.preview?.removed.some((person) => person.returns_to_default)),
|
||||
);
|
||||
|
||||
/**
|
||||
* 移出后是否还有人保留其他业务角色。
|
||||
*/
|
||||
const keepsOtherRoles = computed(() =>
|
||||
Boolean(props.preview?.removed.some((person) => (person.retained_role_names || []).length > 0)),
|
||||
);
|
||||
|
||||
/**
|
||||
* 点关闭或按 Esc 时通知页面放弃本次调整。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('cancel');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible && preview" class="admin-modal-overlay items-center">
|
||||
<div class="admin-modal-panel max-w-lg max-h-[90vh] animate-fade-in-up">
|
||||
<div class="px-8 py-6 border-b border-subtle">
|
||||
<h3 class="text-lg font-bold text-primary">{{ t('admin.permRoles.confirm.title') }}</h3>
|
||||
<p class="text-sm text-muted mt-1">
|
||||
{{ t('admin.permRoles.confirm.subtitle', { name: preview.role_name }) }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="p-8 space-y-4 overflow-y-auto">
|
||||
<div v-if="preview.added.length">
|
||||
<div class="text-xs font-semibold uppercase tracking-wider text-muted mb-2">
|
||||
{{ t('admin.permRoles.confirm.added', { count: preview.added.length }) }}
|
||||
</div>
|
||||
<ul class="space-y-1 text-sm text-primary">
|
||||
<li v-for="person in preview.added" :key="person.id">
|
||||
{{ personLine(person) }}
|
||||
<span
|
||||
v-if="preview.stolen.some((row) => row.id === person.id)"
|
||||
class="ml-1 text-amber-700"
|
||||
>
|
||||
{{ t('admin.permRoles.confirm.stolenHint') }}
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<ElDialog
|
||||
:model-value="visible && Boolean(preview)"
|
||||
:title="t('admin.permRoles.confirm.title')"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!isSaving"
|
||||
:show-close="!isSaving"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<div v-if="preview" class="perm-member-body">
|
||||
<p class="hx-element-hint">
|
||||
{{ t('admin.permRoles.confirm.subtitle', { name: preview.role_name }) }}
|
||||
</p>
|
||||
<div v-if="preview.added.length" class="perm-member-block">
|
||||
<div class="hx-element-hint">
|
||||
{{ t('admin.permRoles.confirm.added', { count: preview.added.length }) }}
|
||||
</div>
|
||||
<div v-if="preview.removed.length">
|
||||
<div class="text-xs font-semibold uppercase tracking-wider text-muted mb-2">
|
||||
{{ t('admin.permRoles.confirm.removed', { count: preview.removed.length }) }}
|
||||
</div>
|
||||
<ul class="space-y-1 text-sm text-primary">
|
||||
<li v-for="person in preview.removed" :key="person.id">{{ personLine(person) }}</li>
|
||||
</ul>
|
||||
<p class="text-xs text-muted mt-2">
|
||||
{{ t('admin.permRoles.confirm.backToDefault') }}
|
||||
</p>
|
||||
<ul class="perm-member-list">
|
||||
<li v-for="person in preview.added" :key="person.id">
|
||||
{{ personLine(person) }}
|
||||
<ElTag
|
||||
v-if="preview.stolen.some((row) => row.id === person.id)"
|
||||
class="perm-stolen-tag"
|
||||
type="warning"
|
||||
effect="light"
|
||||
>
|
||||
{{ t('admin.permRoles.confirm.stolenHint') }}
|
||||
</ElTag>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="preview.removed.length" class="perm-member-block">
|
||||
<div class="hx-element-hint">
|
||||
{{ t('admin.permRoles.confirm.removed', { count: preview.removed.length }) }}
|
||||
</div>
|
||||
<p
|
||||
v-if="!preview.added.length && !preview.removed.length"
|
||||
class="text-sm text-muted"
|
||||
>
|
||||
{{ t('admin.permRoles.confirm.noChanges') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="admin-modal-footer admin-modal-footer--muted px-8 py-6">
|
||||
<button type="button" class="btn-ghost" @click="emit('cancel')">{{ t('admin.cancel') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary disabled:opacity-50"
|
||||
:disabled="isSaving || (!preview.added.length && !preview.removed.length)"
|
||||
@click="emit('confirm')"
|
||||
>
|
||||
{{ isSaving ? t('admin.save') + '...' : t('admin.permRoles.confirm.apply') }}
|
||||
</button>
|
||||
<ul class="perm-member-list">
|
||||
<li v-for="person in preview.removed" :key="person.id">{{ personLine(person) }}</li>
|
||||
</ul>
|
||||
<p v-if="returnsToDefault" class="hx-element-hint">{{ t('admin.permRoles.confirm.backToDefault') }}</p>
|
||||
<p v-if="keepsOtherRoles" class="hx-element-hint">{{ t('admin.permRoles.confirm.keepOthers') }}</p>
|
||||
</div>
|
||||
<p v-if="!preview.added.length && !preview.removed.length" class="hx-element-hint">
|
||||
{{ t('admin.permRoles.confirm.noChanges') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="emit('cancel')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" :disabled="!hasChanges" @click="emit('confirm')">
|
||||
{{ t('admin.permRoles.confirm.apply') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.perm-member-body {
|
||||
max-height: min(60vh, 420px);
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.perm-member-block + .perm-member-block {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.perm-member-list {
|
||||
margin: 8px 0 0;
|
||||
padding-left: 1.25rem;
|
||||
}
|
||||
|
||||
.perm-member-list li + li {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.perm-stolen-tag {
|
||||
margin-left: 6px;
|
||||
}
|
||||
</style>
|
||||
+67
-17
@@ -1,12 +1,14 @@
|
||||
/**
|
||||
* features/admin/modules/permissions/composables/usePermissionsAdmin.ts
|
||||
* 用途:应用权限页:权限组 CRUD/选人确认,以及用户×应用核对矩阵。
|
||||
* 依赖:admin.api、UserPickerDialog 数据、rolePackage.utils、useMessage。
|
||||
* 依赖:admin.api、UserPickerDialog 数据、rolePackage.utils、useMessage、element-plus 的确认框。
|
||||
* 逻辑:已种子权限组时矩阵只读、禁止按人打勾;未种子时保留历史批量勾选。
|
||||
* 保存角色仅在应用/能力勾选变化时弹出「重写入口」确认。
|
||||
* 保存仅在应用/能力勾选变化时用 ElMessageBox 确认;删除也先确认。
|
||||
* 首屏用 isLoading 盖整张卡片,之后刷新列表只用 isListLoading。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import * as XLSX from 'xlsx';
|
||||
import {
|
||||
applyAdminPermissionRoleMembers,
|
||||
@@ -52,6 +54,7 @@ export function usePermissionsAdmin() {
|
||||
const permissionFilters = ref<PermissionFilters>(createEmptyPermissionFilters());
|
||||
const selectedUserIds = ref<number[]>([]);
|
||||
const isLoading = ref(true);
|
||||
const isListLoading = ref(false);
|
||||
const isSaving = ref(false);
|
||||
const permissionPage = ref(1);
|
||||
const permissionPageSize = ref(10);
|
||||
@@ -69,7 +72,6 @@ export function usePermissionsAdmin() {
|
||||
feature_permissions: {},
|
||||
});
|
||||
const editingRoleCode = ref('');
|
||||
const showRoleSaveConfirm = ref(false);
|
||||
|
||||
const pickerRole = ref<PermissionRoleRow | null>(null);
|
||||
const showPicker = ref(false);
|
||||
@@ -178,6 +180,7 @@ export function usePermissionsAdmin() {
|
||||
|
||||
/**
|
||||
* 并行拉取角色包、目录与核对矩阵数据。
|
||||
* 核心逻辑:只在首屏把 isLoading 设为 true,让整张卡片转圈;列表刷新不走这里。
|
||||
*/
|
||||
const loadAll = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
@@ -186,6 +189,20 @@ export function usePermissionsAdmin() {
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 列表已经画出来之后再刷新,只把加载态记在表格上。
|
||||
* 核心逻辑:不改变 task 里的接口,只包一层 isListLoading。
|
||||
* @param task - 现有的角色或用户列表刷新
|
||||
*/
|
||||
const refreshVisibleLists = async (task: () => Promise<unknown>): Promise<void> => {
|
||||
isListLoading.value = true;
|
||||
try {
|
||||
await task();
|
||||
} finally {
|
||||
isListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const toggleUserSelection = (userId: number): void => {
|
||||
const index = selectedUserIds.value.indexOf(userId);
|
||||
if (index === -1) {
|
||||
@@ -232,7 +249,7 @@ export function usePermissionsAdmin() {
|
||||
agent_ids: batchPermissionForm.value.agent_ids,
|
||||
action: batchPermissionForm.value.action,
|
||||
});
|
||||
await loadUsers();
|
||||
await refreshVisibleLists(() => loadUsers());
|
||||
showBatchPermissionModal.value = false;
|
||||
selectedUserIds.value = [];
|
||||
} catch (e) {
|
||||
@@ -287,6 +304,11 @@ export function usePermissionsAdmin() {
|
||||
XLSX.writeFile(wb, 'user_permissions.csv');
|
||||
};
|
||||
|
||||
/**
|
||||
* 导入权限 CSV。隐藏的文件框选中文件后由页面传入 change 事件。
|
||||
* 核心逻辑:角色包启用时拒绝按人导入;成功后只刷新用户矩阵。
|
||||
* @param event - 文件 input 的 change 事件
|
||||
*/
|
||||
const importPermissions = async (event: Event): Promise<void> => {
|
||||
if (rolesConfigured.value) {
|
||||
msg.warning(t('admin.permRoles.directGrantDisabled'));
|
||||
@@ -302,7 +324,7 @@ export function usePermissionsAdmin() {
|
||||
isSaving.value = true;
|
||||
try {
|
||||
await importAdminPermissions(formData);
|
||||
await loadUsers();
|
||||
await refreshVisibleLists(() => loadUsers());
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
@@ -344,9 +366,11 @@ export function usePermissionsAdmin() {
|
||||
showRoleEditor.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 关闭权限组编辑框。
|
||||
*/
|
||||
const closeRoleEditor = (): void => {
|
||||
showRoleEditor.value = false;
|
||||
showRoleSaveConfirm.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -375,8 +399,9 @@ export function usePermissionsAdmin() {
|
||||
|
||||
/**
|
||||
* 已有成员且应用/能力勾选变化时先确认;只改名称或说明直接保存。
|
||||
* 核心逻辑:确认框取消时 MessageBox reject,这里直接返回,不调用保存。
|
||||
*/
|
||||
const requestSaveRole = (): void => {
|
||||
const requestSaveRole = async (): Promise<void> => {
|
||||
if (!roleDraft.value.name.trim()) {
|
||||
msg.warning(t('admin.permRoles.msg.nameRequired'));
|
||||
return;
|
||||
@@ -391,12 +416,27 @@ export function usePermissionsAdmin() {
|
||||
feature_permissions: (payload.feature_permissions as Record<string, boolean>) || {},
|
||||
});
|
||||
if (editingExisting.value && editingMemberCount.value > 0 && grantsChanged) {
|
||||
showRoleSaveConfirm.value = true;
|
||||
return;
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.permRoles.saveConfirm.message', { count: editingMemberCount.value }),
|
||||
t('admin.permRoles.saveConfirm.title'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('admin.save'),
|
||||
cancelButtonText: t('admin.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
void persistRole();
|
||||
await persistRole();
|
||||
};
|
||||
|
||||
/**
|
||||
* 把当前草稿写入权限组。新建走创建接口,编辑走更新接口。
|
||||
* 核心逻辑:校验已在 requestSaveRole 完成;成功后关弹窗并只刷新表格。
|
||||
*/
|
||||
const persistRole = async (): Promise<void> => {
|
||||
isSaving.value = true;
|
||||
try {
|
||||
@@ -406,9 +446,8 @@ export function usePermissionsAdmin() {
|
||||
} else {
|
||||
await createAdminPermissionRole(payload);
|
||||
}
|
||||
showRoleSaveConfirm.value = false;
|
||||
showRoleEditor.value = false;
|
||||
await Promise.all([loadRoles(), loadUsers()]);
|
||||
await refreshVisibleLists(() => Promise.all([loadRoles(), loadUsers()]));
|
||||
msg.success(t('admin.permRoles.msg.saved'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -419,17 +458,28 @@ export function usePermissionsAdmin() {
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除无人使用的非内置权限组。
|
||||
* 删除非内置、非管理员权限组。
|
||||
* 核心逻辑:先用 Element 确认框询问,取消则不请求;确定后再调删除接口并刷新角色表。
|
||||
* @param role - 当前行的权限组
|
||||
*/
|
||||
const removeRole = async (role: PermissionRoleRow): Promise<void> => {
|
||||
if (role.is_system || role.is_platform_admin) {
|
||||
msg.warning(t('admin.permRoles.msg.systemLocked'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ElMessageBox.confirm(role.name || role.code, t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
await deleteAdminPermissionRole(role.code);
|
||||
await loadRoles();
|
||||
await refreshVisibleLists(() => loadRoles());
|
||||
msg.success(t('admin.permRoles.msg.deleted'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -449,7 +499,7 @@ export function usePermissionsAdmin() {
|
||||
}
|
||||
pickerRole.value = role;
|
||||
pickerSelectedIds.value = pickerUsers.value
|
||||
.filter((person) => person.role === role.code)
|
||||
.filter((person) => (person.role_codes?.length ? person.role_codes : [person.role]).includes(role.code))
|
||||
.map((person) => person.id);
|
||||
showPicker.value = true;
|
||||
};
|
||||
@@ -488,7 +538,7 @@ export function usePermissionsAdmin() {
|
||||
await applyAdminPermissionRoleMembers(pickerRole.value.code, pickerSelectedIds.value);
|
||||
showMembersConfirm.value = false;
|
||||
membersPreview.value = null;
|
||||
await Promise.all([loadRoles(), loadUsers(), loadPickerUsers()]);
|
||||
await refreshVisibleLists(() => Promise.all([loadRoles(), loadUsers(), loadPickerUsers()]));
|
||||
msg.success(t('admin.permRoles.msg.membersUpdated'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -515,6 +565,7 @@ export function usePermissionsAdmin() {
|
||||
permissionTotalPages,
|
||||
allUsersSelectedOnPage,
|
||||
isLoading,
|
||||
isListLoading,
|
||||
isSaving,
|
||||
activeTab,
|
||||
rolesConfigured,
|
||||
@@ -524,7 +575,6 @@ export function usePermissionsAdmin() {
|
||||
editingExisting,
|
||||
roleDraft,
|
||||
editingMemberCount,
|
||||
showRoleSaveConfirm,
|
||||
pickerRole,
|
||||
showPicker,
|
||||
pickerSelectedIds,
|
||||
|
||||
@@ -1,15 +1,44 @@
|
||||
/**
|
||||
* features/admin/modules/platform-apps/PlatformAppsPage.vue
|
||||
* 用途:平台应用说明(新手指南)管理——按 Agent 维护指南资料上传、启停与排序。
|
||||
* 依赖:admin.api 指南 CRUD/上传、vue-i18n、lucide 图标。
|
||||
* 逻辑:Admin 路由挂载;选择应用后拉取指南列表,弹窗内上传并保存元数据。
|
||||
* 用途:平台应用说明(新手指南)管理。按应用筛选指南,维护上传、启停与排序。
|
||||
* 依赖:AdminListPage、element-plus、admin.api 指南 CRUD/上传、vue-i18n。
|
||||
* 逻辑:Admin 路由挂载。选择应用后拉取指南列表。创建/编辑用对话框,删除用 Element 确认框。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Plus, Trash2, Edit2, Play, FileText, Image as ImageIcon } from 'lucide-vue-next';
|
||||
import { listAdminAgents, listAdminAgentGuides, createAdminAgentGuide, updateAdminAgentGuide, deleteAdminAgentGuide, uploadAdminAgentGuideFile } from '@/features/admin/api/admin.api';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElMessageBox,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
ElUpload,
|
||||
} from 'element-plus';
|
||||
import type { UploadRequestOptions } 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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import {
|
||||
createAdminAgentGuide,
|
||||
deleteAdminAgentGuide,
|
||||
listAdminAgentGuides,
|
||||
listAdminAgents,
|
||||
updateAdminAgentGuide,
|
||||
uploadAdminAgentGuideFile,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -21,6 +50,7 @@ const isLoading = ref(false);
|
||||
const isModalOpen = ref(false);
|
||||
const isEditing = ref(false);
|
||||
const editingId = ref<number | null>(null);
|
||||
const isSaving = ref(false);
|
||||
|
||||
const form = ref({
|
||||
file_name: '',
|
||||
@@ -30,13 +60,11 @@ const form = ref({
|
||||
file_size: 0,
|
||||
remark: '',
|
||||
sort_order: 0,
|
||||
status: 1
|
||||
status: 1,
|
||||
});
|
||||
|
||||
const isUploading = ref(false);
|
||||
const uploadError = ref('');
|
||||
const deleteDialogOpen = ref(false);
|
||||
const pendingDeleteGuideId = ref<number | null>(null);
|
||||
|
||||
const safetyVideoUsages = new Set([
|
||||
'training_safety_video',
|
||||
@@ -45,12 +73,25 @@ const safetyVideoUsages = new Set([
|
||||
'training_safety_team_video',
|
||||
]);
|
||||
|
||||
/**
|
||||
* 判断用途是否必须对应视频文件。
|
||||
* @param usage - 指南用途编码
|
||||
* @returns 培训视频或安全视频为 true
|
||||
*/
|
||||
const isVideoUsage = (usage: string) => usage === 'training_video' || safetyVideoUsages.has(usage);
|
||||
|
||||
/**
|
||||
* 判断用途是否必须对应 PDF 文件。
|
||||
* @param usage - 指南用途编码
|
||||
* @returns 培训试题或安全 PDF 为 true
|
||||
*/
|
||||
const isPdfUsage = (usage: string) => usage === 'training_exam_pdf' || usage === 'training_safety_pdf';
|
||||
|
||||
/**
|
||||
* 把指南用途编码翻译成管理端可读名称。
|
||||
* AI 触发时机:平台应用说明列表与弹窗下拉都依赖这层映射,新增资料用途时必须统一从这里出文案,避免表格和表单各自写死分叉。
|
||||
* 核心逻辑:列表和弹窗下拉共用这一层,避免两处文案分叉。
|
||||
* @param usage - 指南用途编码
|
||||
* @returns 已有 i18n 文案
|
||||
*/
|
||||
const getGuideUsageLabel = (usage: string) => {
|
||||
if (usage === 'training_video') return t('admin.platformApps.trainingVideo');
|
||||
@@ -63,6 +104,25 @@ const getGuideUsageLabel = (usage: string) => {
|
||||
return t('admin.platformApps.generalGuide');
|
||||
};
|
||||
|
||||
/**
|
||||
* 表格没有行时的说明。未选应用和该应用没有指南用不同文案。
|
||||
* @returns 已有 i18n 空状态
|
||||
*/
|
||||
const tableEmptyText = computed(() => (
|
||||
selectedAgentId.value
|
||||
? t('admin.platformApps.emptyGuides')
|
||||
: t('admin.platformApps.selectAgentFirst')
|
||||
));
|
||||
|
||||
/**
|
||||
* 当前选中应用的名称,供表格「Agent应用」列展示。
|
||||
* @returns 应用名;未选中时为 -
|
||||
*/
|
||||
const currentAgentName = computed(() => {
|
||||
const agent = agents.value.find(a => a.id === selectedAgentId.value);
|
||||
return agent ? agent.name : '-';
|
||||
});
|
||||
|
||||
/**
|
||||
* 拉取 Agent 列表并默认选中第一项,再加载其指南。
|
||||
*/
|
||||
@@ -93,10 +153,19 @@ const fetchGuides = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const currentAgentName = computed(() => {
|
||||
const agent = agents.value.find(a => a.id === selectedAgentId.value);
|
||||
return agent ? agent.name : '-';
|
||||
});
|
||||
/**
|
||||
* 切换应用筛选并重新拉取指南。
|
||||
* 核心逻辑:ElSelect 不用空字符串当选项值,清空时写回 '',避免下拉显示默认「请选择」。
|
||||
* @param value - 选中的应用 id;清空时为空
|
||||
*/
|
||||
const onAgentChange = (value: number | string | undefined) => {
|
||||
if (value === undefined || value === '') {
|
||||
selectedAgentId.value = '';
|
||||
} else {
|
||||
selectedAgentId.value = Number(value);
|
||||
}
|
||||
void fetchGuides();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchAgents();
|
||||
@@ -116,7 +185,7 @@ const openCreateModal = () => {
|
||||
file_size: 0,
|
||||
remark: '',
|
||||
sort_order: 0,
|
||||
status: 1
|
||||
status: 1,
|
||||
};
|
||||
uploadError.value = '';
|
||||
isModalOpen.value = true;
|
||||
@@ -137,7 +206,7 @@ const openEditModal = (guide: any) => {
|
||||
file_size: guide.file_size,
|
||||
remark: guide.remark,
|
||||
sort_order: guide.sort_order,
|
||||
status: guide.status
|
||||
status: guide.status,
|
||||
};
|
||||
uploadError.value = '';
|
||||
isModalOpen.value = true;
|
||||
@@ -145,15 +214,14 @@ const openEditModal = (guide: any) => {
|
||||
|
||||
/**
|
||||
* 上传指南文件并回填 path/type/size;必要时校正 guide_usage 与文件类型一致性。
|
||||
* @param event - input file change 事件
|
||||
* @param file - 用户选择的指南文件
|
||||
*/
|
||||
const handleFileUpload = async (event: Event) => {
|
||||
const file = (event.target as HTMLInputElement).files?.[0];
|
||||
const handleFileUpload = async (file: File) => {
|
||||
if (!file) return;
|
||||
|
||||
isUploading.value = true;
|
||||
uploadError.value = '';
|
||||
|
||||
|
||||
try {
|
||||
const res = await uploadAdminAgentGuideFile(file);
|
||||
form.value.file_path = res.file_path;
|
||||
@@ -175,53 +243,67 @@ const handleFileUpload = async (event: Event) => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 把 Element 上传组件选中的文件交给现有上传逻辑。
|
||||
* 核心逻辑:不请求组件 action 地址,仍调用 uploadAdminAgentGuideFile。
|
||||
* @param options - ElUpload 自定义请求参数,file 为原始文件
|
||||
*/
|
||||
const uploadGuideRequest = async (options: UploadRequestOptions) => {
|
||||
await handleFileUpload(options.file);
|
||||
};
|
||||
|
||||
/**
|
||||
* 提交新建或更新指南元数据。
|
||||
* 核心逻辑:编辑走 update,新建补上 agent_id 后走 create;请求体与原来一致。
|
||||
*/
|
||||
const submitForm = async () => {
|
||||
if (!selectedAgentId.value || !form.value.file_path || !form.value.file_name) return;
|
||||
|
||||
if (isSaving.value || !selectedAgentId.value || !form.value.file_path || !form.value.file_name) return;
|
||||
|
||||
isSaving.value = true;
|
||||
try {
|
||||
if (isEditing.value && editingId.value) {
|
||||
await updateAdminAgentGuide(editingId.value, form.value);
|
||||
} else {
|
||||
await createAdminAgentGuide({
|
||||
...form.value,
|
||||
agent_id: selectedAgentId.value
|
||||
agent_id: selectedAgentId.value,
|
||||
});
|
||||
}
|
||||
isModalOpen.value = false;
|
||||
await fetchGuides();
|
||||
} catch (error) {
|
||||
console.error('Failed to save guide:', error);
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteGuide = (id: number) => {
|
||||
pendingDeleteGuideId.value = id;
|
||||
deleteDialogOpen.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 确认后删除指南(由 DeleteConfirmDialog 的 @confirm 触发)。
|
||||
* @param id - 指南主键,取自 pendingDeleteGuideId
|
||||
* 删除指南。先弹出 Element 确认框,取消则不请求。
|
||||
* 核心逻辑:正文用平台应用已有删除提示,标题和按钮用通用删除对话框文案。MessageBox 取消时 reject,这里直接返回。
|
||||
* @param id - 指南主键
|
||||
*/
|
||||
const confirmDeleteGuide = async () => {
|
||||
const id = pendingDeleteGuideId.value;
|
||||
if (!id) return;
|
||||
const deleteGuide = async (id: number) => {
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.platformApps.confirmDelete'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteAdminAgentGuide(id);
|
||||
await fetchGuides();
|
||||
} catch (error) {
|
||||
console.error('Failed to delete guide:', error);
|
||||
} finally {
|
||||
pendingDeleteGuideId.value = null;
|
||||
deleteDialogOpen.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换指南启停状态。
|
||||
* 核心逻辑:仍调用 updateAdminAgentGuide,只提交翻转后的 status。
|
||||
* @param guide - 列表行指南对象
|
||||
*/
|
||||
const toggleStatus = async (guide: any) => {
|
||||
@@ -245,192 +327,194 @@ const formatSize = (bytes: number) => {
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
};
|
||||
|
||||
/**
|
||||
* 按文件类型返回列表图标组件。
|
||||
* @param type - 文件类型(video/pdf/其它)
|
||||
*/
|
||||
const getIcon = (type: string) => {
|
||||
if (type === 'video') return Play;
|
||||
if (type === 'pdf') return FileText;
|
||||
return ImageIcon;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col h-full gap-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold tracking-tight text-default">
|
||||
{{ t('admin.nav.platformApps') }}
|
||||
</h2>
|
||||
<p class="text-sm text-muted mt-1">
|
||||
{{ t('admin.platformApps.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="surface-panel rounded-2xl p-6 shadow-sm border border-subtle flex-1 flex flex-col gap-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-4">
|
||||
<label class="font-medium text-sm text-default">{{ t('admin.platformApps.selectAgent') }}</label>
|
||||
<select v-model="selectedAgentId" class="input-field w-64" @change="fetchGuides">
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<button v-if="selectedAgentId" type="button" class="btn-primary" @click="openCreateModal">
|
||||
<Plus class="w-5 h-5 mr-1" />
|
||||
<span>{{ t('admin.platformApps.addGuide') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.nav.platformApps') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.platformApps.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton v-if="selectedAgentId" type="primary" :icon="Plus" @click="openCreateModal">
|
||||
{{ t('admin.platformApps.addGuide') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElSelect
|
||||
:model-value="selectedAgentId === '' ? undefined : selectedAgentId"
|
||||
class="platform-apps-filter-agent"
|
||||
:placeholder="t('admin.platformApps.selectAgent')"
|
||||
@update:model-value="onAgentChange"
|
||||
>
|
||||
<ElOption v-for="agent in agents" :key="agent.id" :label="agent.name" :value="agent.id" />
|
||||
</ElSelect>
|
||||
</template>
|
||||
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-10">
|
||||
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
<ElTable
|
||||
v-loading="isLoading"
|
||||
class="hx-admin-table"
|
||||
:data="guides"
|
||||
row-key="id"
|
||||
:empty-text="tableEmptyText"
|
||||
>
|
||||
<ElTableColumn prop="file_type" :label="t('admin.platformApps.colType')" width="100" />
|
||||
<ElTableColumn :label="t('admin.platformApps.colFileName')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<div :title="row.file_name">{{ row.file_name }}</div>
|
||||
<p v-if="row.remark" class="hx-element-hint platform-apps-remark" :title="row.remark">
|
||||
{{ row.remark }}
|
||||
</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.platformApps.guideUsage')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
{{ getGuideUsageLabel(row.guide_usage || 'general') }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.platformApps.colAgent')" min-width="140">
|
||||
<template #default>{{ currentAgentName }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.platformApps.colFileSize')" width="120">
|
||||
<template #default="{ row }">{{ formatSize(row.file_size) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="sort_order" :label="t('admin.platformApps.colSort')" width="90" />
|
||||
<ElTableColumn :label="t('admin.platformApps.colStatus')" width="120">
|
||||
<template #default="{ row }">
|
||||
<ElTag
|
||||
:type="row.status === 1 ? 'success' : 'info'"
|
||||
effect="light"
|
||||
class="platform-apps-status"
|
||||
@click="toggleStatus(row)"
|
||||
>
|
||||
{{ row.status === 1 ? t('admin.platformApps.statusEnabled') : t('admin.platformApps.statusDisabled') }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.platformApps.colActions')" width="160" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openEditModal(row)">
|
||||
{{ t('common.edit') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="deleteGuide(row.id)">
|
||||
{{ t('common.delete') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</AdminListPage>
|
||||
|
||||
<div v-else-if="!selectedAgentId" class="flex flex-col items-center justify-center py-20 text-muted">
|
||||
{{ t('admin.platformApps.selectAgentFirst') }}
|
||||
</div>
|
||||
|
||||
<div v-else-if="guides.length === 0" class="flex flex-col items-center justify-center py-20 text-muted">
|
||||
{{ t('admin.platformApps.emptyGuides') }}
|
||||
</div>
|
||||
|
||||
<div v-else class="overflow-x-auto rounded-xl border border-subtle">
|
||||
<table class="w-full text-left text-sm whitespace-nowrap">
|
||||
<thead class="bg-muted text-muted uppercase text-xs font-semibold tracking-wider border-b border-subtle">
|
||||
<tr>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colType') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colFileName') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.guideUsage') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colAgent') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colFileSize') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colSort') }}</th>
|
||||
<th class="px-6 py-4">{{ t('admin.platformApps.colStatus') }}</th>
|
||||
<th class="px-6 py-4 text-right">{{ t('admin.platformApps.colActions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-subtle">
|
||||
<tr v-for="guide in guides" :key="guide.id" class="hover:bg-muted/50 transition-colors">
|
||||
<td class="px-6 py-4">
|
||||
<component :is="getIcon(guide.file_type)" class="w-5 h-5 text-muted" />
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="font-medium text-default">{{ guide.file_name }}</div>
|
||||
<div class="text-xs text-muted mt-1 truncate max-w-[200px]">{{ guide.remark }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-muted">
|
||||
<span>{{ getGuideUsageLabel(guide.guide_usage || 'general') }}</span>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="inline-flex items-center px-2 py-1 rounded-md text-xs font-medium bg-brand-50 text-brand-700 border border-brand-100">
|
||||
{{ currentAgentName }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-muted">{{ formatSize(guide.file_size) }}</td>
|
||||
<td class="px-6 py-4 text-muted">{{ guide.sort_order }}</td>
|
||||
<td class="px-6 py-4">
|
||||
<button
|
||||
class="px-2 py-1 text-xs font-medium rounded-full transition-colors"
|
||||
:class="guide.status === 1 ? 'bg-green-100 text-green-700 hover:bg-green-200' : 'bg-gray-100 text-gray-700 hover:bg-gray-200'"
|
||||
@click="toggleStatus(guide)"
|
||||
>
|
||||
{{ guide.status === 1 ? t('admin.platformApps.statusEnabled') : t('admin.platformApps.statusDisabled') }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-right space-x-2">
|
||||
<button type="button" class="btn-icon-ds" @click="openEditModal(guide)" :title="t('common.edit')">
|
||||
<Edit2 class="w-4 h-4" />
|
||||
</button>
|
||||
<button type="button" class="btn-icon-ds text-red-500 hover:bg-red-50" @click="deleteGuide(guide.id)" :title="t('common.delete')">
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div v-if="isModalOpen" class="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-2xl shadow-xl w-full max-w-lg overflow-hidden flex flex-col max-h-[90vh]">
|
||||
<div class="px-6 py-4 border-b border-subtle flex justify-between items-center">
|
||||
<h3 class="text-lg font-bold text-default">{{ isEditing ? t('admin.platformApps.editGuide') : t('admin.platformApps.addGuide') }}</h3>
|
||||
<button @click="isModalOpen = false" class="text-muted hover:text-default text-xl leading-none">×</button>
|
||||
</div>
|
||||
|
||||
<div class="p-6 overflow-y-auto space-y-4">
|
||||
<div v-if="!isEditing" class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.uploadFile') }}</label>
|
||||
<input
|
||||
type="file"
|
||||
accept="video/mp4,video/webm,application/pdf,image/png,image/jpeg"
|
||||
class="w-full text-sm text-muted file:mr-4 file:py-2 file:px-4 file:rounded-full file:border-0 file:text-sm file:font-semibold file:bg-blue-50 file:text-blue-700 hover:file:bg-blue-100"
|
||||
@change="handleFileUpload"
|
||||
/>
|
||||
<div v-if="isUploading" class="text-sm text-blue-600 mt-2 flex items-center gap-2">
|
||||
<div class="animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"></div> {{ t('admin.platformApps.uploading') }}
|
||||
</div>
|
||||
<div v-if="uploadError" class="text-sm text-red-500 mt-2">{{ uploadError }}</div>
|
||||
<div v-if="form.file_path && !isUploading" class="text-sm text-green-600 mt-2">{{ t('admin.platformApps.uploadReady') }}</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.fileName') }}</label>
|
||||
<input v-model="form.file_name" type="text" class="input-field w-full" :placeholder="t('admin.platformApps.fileNamePlaceholder')" />
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.remark') }}</label>
|
||||
<textarea v-model="form.remark" class="input-field w-full h-20" :placeholder="t('admin.platformApps.remarkPlaceholder')"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.guideUsage') }}</label>
|
||||
<select v-model="form.guide_usage" class="input-field w-full">
|
||||
<option value="general">{{ t('admin.platformApps.generalGuide') }}</option>
|
||||
<option value="training_video" :disabled="form.file_type !== 'video'">{{ t('admin.platformApps.trainingVideo') }}</option>
|
||||
<option value="training_exam_pdf" :disabled="form.file_type !== 'pdf'">{{ t('admin.platformApps.trainingExamPdf') }}</option>
|
||||
<option value="training_safety_company_video" :disabled="form.file_type !== 'video'">{{ t('admin.platformApps.trainingSafetyCompanyVideo') }}</option>
|
||||
<option value="training_safety_department_video" :disabled="form.file_type !== 'video'">{{ t('admin.platformApps.trainingSafetyDepartmentVideo') }}</option>
|
||||
<option value="training_safety_team_video" :disabled="form.file_type !== 'video'">{{ t('admin.platformApps.trainingSafetyTeamVideo') }}</option>
|
||||
<option value="training_safety_video" :disabled="form.file_type !== 'video'">{{ t('admin.platformApps.trainingSafetyVideo') }}</option>
|
||||
<option value="training_safety_pdf" :disabled="form.file_type !== 'pdf'">{{ t('admin.platformApps.trainingSafetyPdf') }}</option>
|
||||
</select>
|
||||
<p class="text-xs text-muted">{{ t('admin.platformApps.guideUsageHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.sortOrder') }}</label>
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field w-full" />
|
||||
<p class="text-xs text-muted">{{ t('admin.platformApps.sortOrderHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-sm font-medium text-default">{{ t('admin.platformApps.status') }}</label>
|
||||
<select v-model="form.status" class="input-field w-full">
|
||||
<option :value="1">{{ t('admin.platformApps.enable') }}</option>
|
||||
<option :value="0">{{ t('admin.platformApps.disable') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-6 py-4 border-t border-subtle bg-muted flex justify-end gap-3">
|
||||
<button type="button" class="btn-secondary" @click="isModalOpen = false">{{ t('admin.cancel') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
@click="submitForm"
|
||||
:disabled="isUploading || !form.file_path || !form.file_name"
|
||||
<ElDialog
|
||||
v-model="isModalOpen"
|
||||
:title="isEditing ? t('admin.platformApps.editGuide') : t('admin.platformApps.addGuide')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!isSaving"
|
||||
:show-close="!isSaving"
|
||||
>
|
||||
<ElForm label-position="top" :model="form" @submit.prevent="submitForm">
|
||||
<ElFormItem v-if="!isEditing" :label="t('admin.platformApps.uploadFile')">
|
||||
<ElUpload
|
||||
action="#"
|
||||
:http-request="uploadGuideRequest"
|
||||
:show-file-list="false"
|
||||
accept="video/mp4,video/webm,application/pdf,image/png,image/jpeg"
|
||||
:disabled="isUploading"
|
||||
>
|
||||
{{ t('admin.platformApps.save') }}
|
||||
</button>
|
||||
<ElButton :loading="isUploading" :disabled="isUploading">
|
||||
{{ t('admin.platformApps.uploadFile') }}
|
||||
</ElButton>
|
||||
</ElUpload>
|
||||
<p v-if="isUploading" class="hx-element-hint">{{ t('admin.platformApps.uploading') }}</p>
|
||||
<ElAlert
|
||||
v-if="uploadError"
|
||||
:title="uploadError"
|
||||
type="error"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
<ElAlert
|
||||
v-else-if="form.file_path && !isUploading"
|
||||
:title="t('admin.platformApps.uploadReady')"
|
||||
type="success"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem :label="t('admin.platformApps.fileName')">
|
||||
<ElInput v-model="form.file_name" :placeholder="t('admin.platformApps.fileNamePlaceholder')" />
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem :label="t('admin.platformApps.remark')">
|
||||
<ElInput
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
:placeholder="t('admin.platformApps.remarkPlaceholder')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
|
||||
<div class="platform-apps-form-grid">
|
||||
<ElFormItem :label="t('admin.platformApps.guideUsage')">
|
||||
<ElSelect v-model="form.guide_usage">
|
||||
<ElOption value="general" :label="t('admin.platformApps.generalGuide')" />
|
||||
<ElOption value="training_video" :label="t('admin.platformApps.trainingVideo')" :disabled="form.file_type !== 'video'" />
|
||||
<ElOption value="training_exam_pdf" :label="t('admin.platformApps.trainingExamPdf')" :disabled="form.file_type !== 'pdf'" />
|
||||
<ElOption value="training_safety_company_video" :label="t('admin.platformApps.trainingSafetyCompanyVideo')" :disabled="form.file_type !== 'video'" />
|
||||
<ElOption value="training_safety_department_video" :label="t('admin.platformApps.trainingSafetyDepartmentVideo')" :disabled="form.file_type !== 'video'" />
|
||||
<ElOption value="training_safety_team_video" :label="t('admin.platformApps.trainingSafetyTeamVideo')" :disabled="form.file_type !== 'video'" />
|
||||
<ElOption value="training_safety_video" :label="t('admin.platformApps.trainingSafetyVideo')" :disabled="form.file_type !== 'video'" />
|
||||
<ElOption value="training_safety_pdf" :label="t('admin.platformApps.trainingSafetyPdf')" :disabled="form.file_type !== 'pdf'" />
|
||||
</ElSelect>
|
||||
<p class="hx-element-hint">{{ t('admin.platformApps.guideUsageHint') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.platformApps.sortOrder')">
|
||||
<ElInput v-model.number="form.sort_order" type="number" />
|
||||
<p class="hx-element-hint">{{ t('admin.platformApps.sortOrderHint') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.platformApps.status')">
|
||||
<ElSelect v-model="form.status">
|
||||
<ElOption :value="1" :label="t('admin.platformApps.enable')" />
|
||||
<ElOption :value="0" :label="t('admin.platformApps.disable')" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<DeleteConfirmDialog v-model="deleteDialogOpen" title="{{ t('admin.platformApps.deleteGuide') }}" message="{{ t('admin.platformApps.confirmDelete') }}" confirm-tone="danger" @confirm="confirmDeleteGuide" />
|
||||
</div>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="isModalOpen = false">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="isSaving"
|
||||
:disabled="isUploading || !form.file_path || !form.file_name"
|
||||
@click="submitForm"
|
||||
>
|
||||
{{ t('admin.platformApps.save') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.platform-apps-filter-agent) {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
.platform-apps-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
column-gap: 16px;
|
||||
}
|
||||
|
||||
.platform-apps-remark {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.platform-apps-status {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
+764
-602
File diff suppressed because it is too large.
Load diff
+301
-326
@@ -1,13 +1,33 @@
|
||||
/**
|
||||
* features/admin/modules/procurement-contract/components/ContractRiskRulesPanel.vue
|
||||
* 用途:采购合同风险红线规则列表与新增/编辑(含迁移种子默认规则)。
|
||||
* 依赖:procurement-contract.api、DeleteConfirmDialog、useMessage、vue-i18n。
|
||||
* 逻辑:由 ProcurementContractPage「风险规则」Tab 挂载;CRUD 走 Admin rules API。
|
||||
* 用途:采购合同风险规则表格、编辑对话框和删除确认。
|
||||
* 依赖:procurement-contract.api、element-plus、useMessage、vue-i18n。
|
||||
* 逻辑:由 ProcurementContractPage「风险规则」页签放入 AdminListPage 的表格区。
|
||||
* 进入页签或切换状态筛选时拉列表;「新增规则」在页面页头。本组件不再套卡片。
|
||||
* 样式随页面已引入的 Element 皮肤。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { CircleHelp, Plus, ShieldAlert, ShieldCheck, SlidersHorizontal } from 'lucide-vue-next';
|
||||
import { QuestionFilled } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElLoading,
|
||||
ElMessageBox,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
ElTooltip,
|
||||
} from 'element-plus';
|
||||
import {
|
||||
createAdminContractRiskRule,
|
||||
deleteAdminContractRiskRule,
|
||||
@@ -15,16 +35,23 @@ import {
|
||||
updateAdminContractRiskRule,
|
||||
type ContractRiskRuleRow,
|
||||
} from '@/features/admin/api/procurement-contract.api';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 状态筛选。空字符串表示全部;由页面筛选条写入。 */
|
||||
statusFilter?: string;
|
||||
}>(), {
|
||||
statusFilter: '',
|
||||
});
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const loading = ref(false);
|
||||
const saving = ref(false);
|
||||
const rules = ref<ContractRiskRuleRow[]>([]);
|
||||
const filterStatus = ref('');
|
||||
|
||||
const showForm = ref(false);
|
||||
const editing = ref<ContractRiskRuleRow | null>(null);
|
||||
@@ -51,10 +78,6 @@ const clauseCategories = [
|
||||
'other',
|
||||
] as const;
|
||||
|
||||
const showDeleteConfirm = ref(false);
|
||||
const pendingDelete = ref<ContractRiskRuleRow | null>(null);
|
||||
const deleting = ref(false);
|
||||
|
||||
const isEditMode = computed(() => Boolean(editing.value));
|
||||
const formTitleText = computed(() =>
|
||||
isEditMode.value
|
||||
@@ -69,49 +92,28 @@ const keywordLogicHint = computed(() =>
|
||||
? t('admin.procurementContract.keywordPresentLogicHint')
|
||||
: t('admin.procurementContract.keywordMissingLogicHint'),
|
||||
);
|
||||
|
||||
/**
|
||||
* 汇总当前列表里的规则数量,供页面筛选行右侧展示。
|
||||
* 核心逻辑:数量跟当前筛选结果走,不另请求统计接口。
|
||||
*/
|
||||
const ruleStats = computed(() => ({
|
||||
total: rules.value.length,
|
||||
enabled: rules.value.filter((rule) => rule.status === 'enabled').length,
|
||||
highRisk: rules.value.filter((rule) => rule.risk_level === 'high').length,
|
||||
}));
|
||||
|
||||
/**
|
||||
* 生成风险规则统计卡片,帮助管理员先扫状态再进入列表维护。
|
||||
*/
|
||||
const ruleSummaryCards = computed(() => [
|
||||
{
|
||||
key: 'total',
|
||||
label: t('admin.procurementContract.ruleStatTotal'),
|
||||
value: ruleStats.value.total,
|
||||
icon: SlidersHorizontal,
|
||||
className: 'border-slate-200 bg-white text-slate-600',
|
||||
},
|
||||
{
|
||||
key: 'enabled',
|
||||
label: t('admin.procurementContract.ruleStatEnabled'),
|
||||
value: ruleStats.value.enabled,
|
||||
icon: ShieldCheck,
|
||||
className: 'border-emerald-100 bg-emerald-50/80 text-emerald-700',
|
||||
},
|
||||
{
|
||||
key: 'highRisk',
|
||||
label: t('admin.procurementContract.ruleStatHighRisk'),
|
||||
value: ruleStats.value.highRisk,
|
||||
icon: ShieldAlert,
|
||||
className: 'border-rose-100 bg-rose-50/80 text-rose-700',
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* 加载风险规则列表。
|
||||
* @param options.silent - 为 true 时不切换 loading,避免启停时整表闪烁
|
||||
* 核心逻辑:状态筛选取页面传入的空字符串时不传给接口,表示全部。
|
||||
* @param options.silent - 为 true 时不切换 loading,避免保存后整表闪烁
|
||||
*/
|
||||
async function loadRules(options?: { silent?: boolean }): Promise<void> {
|
||||
const silent = Boolean(options?.silent);
|
||||
if (!silent) loading.value = true;
|
||||
try {
|
||||
rules.value = await listAdminContractRiskRules({
|
||||
status: filterStatus.value || undefined,
|
||||
status: props.statusFilter || undefined,
|
||||
});
|
||||
} catch (e: unknown) {
|
||||
console.error(e);
|
||||
@@ -121,16 +123,13 @@ async function loadRules(options?: { silent?: boolean }): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应筛选条件变更并刷新规则列表。
|
||||
*/
|
||||
async function onFilterStatusChange(): Promise<void> {
|
||||
await loadRules();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadRules();
|
||||
});
|
||||
watch(
|
||||
() => props.statusFilter,
|
||||
() => {
|
||||
void loadRules();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* 重置规则表单为新建默认值。
|
||||
@@ -150,7 +149,7 @@ function resetForm(): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开新建规则弹窗。
|
||||
* 打开新建规则对话框。
|
||||
*/
|
||||
function openCreate(): void {
|
||||
resetForm();
|
||||
@@ -158,7 +157,8 @@ function openCreate(): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开编辑规则弹窗(种子规则也可改,code 只读)。
|
||||
* 打开编辑规则对话框。内置规则的分类、关键词和触发条件不可改。
|
||||
* @param row - 当前规则行
|
||||
*/
|
||||
function openEdit(row: ContractRiskRuleRow): void {
|
||||
editing.value = row;
|
||||
@@ -177,17 +177,25 @@ function openEdit(row: ContractRiskRuleRow): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭规则表单。
|
||||
* 关闭规则对话框。编辑对象等到关闭动画结束后再清,避免标题闪一下。
|
||||
*/
|
||||
function closeForm(): void {
|
||||
showForm.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对话框关闭后丢掉正在编辑的规则。
|
||||
*/
|
||||
function onFormClosed(): void {
|
||||
editing.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交新建或更新规则。
|
||||
* 核心逻辑:关键词按中英文逗号拆开;合同类型固定为通用采购,与现有保存接口一致。
|
||||
*/
|
||||
async function submitForm(): Promise<void> {
|
||||
if (saving.value) return;
|
||||
if (!formTitle.value.trim() || !formCategory.value.trim()) {
|
||||
msg.error(t('admin.procurementContract.ruleRequiredFields'));
|
||||
return;
|
||||
@@ -240,8 +248,9 @@ async function submitForm(): Promise<void> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换规则启停(种子与自定义规则均可)。
|
||||
* 核心逻辑:先乐观更新本地行,成功后再静默对齐服务端;失败则回滚。
|
||||
* 切换规则启停。
|
||||
* 核心逻辑:先改本地行,成功后再对齐服务端;当前筛选对不上时把该行移出列表。失败则回滚。
|
||||
* @param row - 当前规则行
|
||||
*/
|
||||
async function toggleStatus(row: ContractRiskRuleRow): Promise<void> {
|
||||
const prev = row.status;
|
||||
@@ -250,9 +259,8 @@ async function toggleStatus(row: ContractRiskRuleRow): Promise<void> {
|
||||
try {
|
||||
const updated = await updateAdminContractRiskRule(row.id, { status: next });
|
||||
Object.assign(row, updated);
|
||||
// 当前筛选为「启用/停用」时,状态变更后该项应离开列表
|
||||
if (filterStatus.value && filterStatus.value !== next) {
|
||||
rules.value = rules.value.filter((r) => r.id !== row.id);
|
||||
if (props.statusFilter && props.statusFilter !== next) {
|
||||
rules.value = rules.value.filter((item) => item.id !== row.id);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
row.status = prev;
|
||||
@@ -261,41 +269,34 @@ async function toggleStatus(row: ContractRiskRuleRow): Promise<void> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开删除确认。
|
||||
* 确认后删除规则。取消确认框时不请求接口。
|
||||
* @param row - 待删除的规则
|
||||
*/
|
||||
function openDelete(row: ContractRiskRuleRow): void {
|
||||
pendingDelete.value = row;
|
||||
showDeleteConfirm.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭删除确认。
|
||||
*/
|
||||
function closeDelete(): void {
|
||||
showDeleteConfirm.value = false;
|
||||
pendingDelete.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认删除规则。
|
||||
*/
|
||||
async function confirmDelete(): Promise<void> {
|
||||
const row = pendingDelete.value;
|
||||
if (!row) return;
|
||||
deleting.value = true;
|
||||
async function deleteRule(row: ContractRiskRuleRow): Promise<void> {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.procurementContract.confirmDeleteRule', { title: row.title }),
|
||||
t('common.deleteDialog.defaultTitle'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteAdminContractRiskRule(row.id);
|
||||
closeDelete();
|
||||
rules.value = rules.value.filter((r) => r.id !== row.id);
|
||||
rules.value = rules.value.filter((item) => item.id !== row.id);
|
||||
} catch (e: unknown) {
|
||||
msg.error(e instanceof Error ? e.message : t('admin.procurementContract.actionFailed'));
|
||||
} finally {
|
||||
deleting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 风险等级文案。
|
||||
* @param level - high / medium / low
|
||||
*/
|
||||
function riskLabel(level: string): string {
|
||||
if (level === 'high') return t('admin.procurementContract.riskHigh');
|
||||
@@ -304,8 +305,19 @@ function riskLabel(level: string): string {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* 风险等级对应的标签色。
|
||||
* @param level - high / medium / low
|
||||
*/
|
||||
function riskTagType(level: string): 'danger' | 'warning' | 'info' {
|
||||
if (level === 'high') return 'danger';
|
||||
if (level === 'medium') return 'warning';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发类型文案。
|
||||
* @param type - keyword_present 或缺失触发
|
||||
*/
|
||||
function triggerLabel(type: string): string {
|
||||
if (type === 'keyword_present') return t('admin.procurementContract.triggerPresent');
|
||||
@@ -313,7 +325,8 @@ function triggerLabel(type: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态文案。
|
||||
* 启停文案。
|
||||
* @param status - enabled / disabled
|
||||
*/
|
||||
function statusLabel(status: string): string {
|
||||
if (status === 'enabled') return t('admin.procurementContract.enable');
|
||||
@@ -322,8 +335,16 @@ function statusLabel(status: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则关键词展示文本。
|
||||
* @param row - 风险规则行;关键词为空时返回短横线占位,避免表格空洞。
|
||||
* 启停对应的标签色。
|
||||
* @param status - enabled / disabled
|
||||
*/
|
||||
function statusTagType(status: string): 'success' | 'info' {
|
||||
return status === 'enabled' ? 'success' : 'info';
|
||||
}
|
||||
|
||||
/**
|
||||
* 把规则关键词拼成一行展示。没有关键词时用短横线占位。
|
||||
* @param row - 风险规则行
|
||||
*/
|
||||
function keywordText(row: ContractRiskRuleRow): string {
|
||||
const keywords = row.keywords || [];
|
||||
@@ -331,10 +352,9 @@ function keywordText(row: ContractRiskRuleRow): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将内部条款分类编码转换为与规则弹窗一致的可读名称。
|
||||
* 核心逻辑:规则仍保存稳定编码,列表仅负责展示本地化文案。
|
||||
* @param category - 后端返回的条款分类编码。
|
||||
* @returns 用户可读的分类名称;历史未知编码保持原样,避免丢失信息。
|
||||
* 将条款分类编码转成与规则对话框一致的名称。
|
||||
* 核心逻辑:规则仍保存稳定编码,列表只展示已有文案;未知编码保持原样。
|
||||
* @param category - 后端返回的条款分类编码
|
||||
*/
|
||||
function categoryLabel(category: string): string {
|
||||
const key = `admin.procurementContract.category_${category}`;
|
||||
@@ -342,249 +362,204 @@ function categoryLabel(category: string): string {
|
||||
return translated === key ? category : translated;
|
||||
}
|
||||
|
||||
defineExpose({ loadRules, openCreate });
|
||||
defineExpose({ loadRules, openCreate, ruleStats });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-5">
|
||||
<div class="grid gap-3 md:grid-cols-3">
|
||||
<div
|
||||
v-for="card in ruleSummaryCards"
|
||||
:key="card.key"
|
||||
class="rounded-xl border px-4 py-3 shadow-sm"
|
||||
:class="card.className"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-xs font-medium text-muted">{{ card.label }}</div>
|
||||
<div class="mt-1 text-2xl font-semibold text-primary">{{ card.value }}</div>
|
||||
</div>
|
||||
<span class="inline-flex h-9 w-9 items-center justify-center rounded-lg bg-white/80 shadow-sm">
|
||||
<component :is="card.icon" class="h-4 w-4" />
|
||||
</span>
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="hx-admin-table"
|
||||
:data="rules"
|
||||
row-key="id"
|
||||
:empty-text="loading ? t('admin.procurementContract.loading') : t('admin.procurementContract.emptyRules')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.procurementContract.colRuleTitle')" min-width="180">
|
||||
<template #default="{ row }">{{ row.title }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.procurementContract.colCategory')" min-width="120">
|
||||
<template #default="{ row }">
|
||||
<ElTag effect="light">{{ categoryLabel(row.clause_category) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.procurementContract.colKeywords')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<div class="rule-keywords" :title="keywordText(row as ContractRiskRuleRow)">
|
||||
{{ keywordText(row as ContractRiskRuleRow) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 rounded-xl border border-subtle bg-white px-4 py-3 shadow-sm sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
<label class="flex shrink-0 items-center gap-2 text-sm font-medium text-secondary">
|
||||
<span>{{ t('admin.procurementContract.colStatus') }}</span>
|
||||
<select
|
||||
v-model="filterStatus"
|
||||
class="input-field h-10 w-48 min-w-48 py-0 text-sm"
|
||||
@change="onFilterStatusChange"
|
||||
>
|
||||
<option value="">{{ t('admin.procurementContract.all') }}</option>
|
||||
<option value="enabled">{{ t('admin.procurementContract.enable') }}</option>
|
||||
<option value="disabled">{{ t('admin.procurementContract.disable') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<button type="button" class="btn-primary inline-flex h-10 items-center gap-2 px-4 shadow-sm" @click="openCreate">
|
||||
<Plus class="h-4 w-4" />
|
||||
{{ t('admin.procurementContract.addRule') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="overflow-hidden rounded-xl border border-subtle bg-white shadow-sm">
|
||||
<div class="overflow-auto">
|
||||
<table class="w-full min-w-[1030px] whitespace-nowrap text-sm">
|
||||
<thead class="bg-slate-50/80 text-xs font-semibold text-muted">
|
||||
<tr>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colRuleTitle') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colCategory') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colKeywords') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colTrigger') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colRisk') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colStatus') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colSort') }}</th>
|
||||
<th class="px-5 py-3 text-left">{{ t('admin.procurementContract.colActions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="loading">
|
||||
<td colspan="8" class="px-4 py-8 text-center text-muted">
|
||||
{{ t('admin.procurementContract.loading') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-else-if="!rules.length">
|
||||
<td colspan="8" class="px-4 py-8 text-center text-muted">
|
||||
{{ t('admin.procurementContract.emptyRules') }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="row in rules" :key="row.id" class="border-t border-subtle transition-colors hover:bg-slate-50/70">
|
||||
<td class="px-5 py-4 align-top">
|
||||
<div class="font-semibold text-primary">{{ row.title }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-4 align-top">
|
||||
<span class="inline-flex rounded-md border border-slate-200 bg-slate-50 px-2 py-1 text-xs font-medium text-slate-700">
|
||||
{{ categoryLabel(row.clause_category) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="max-w-[260px] px-5 py-4 align-top text-xs text-muted" :title="keywordText(row)">
|
||||
<div class="line-clamp-2 whitespace-normal leading-5">{{ keywordText(row) }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-4 align-top text-secondary">{{ triggerLabel(row.trigger_type) }}</td>
|
||||
<td class="px-5 py-4 align-top">
|
||||
<span
|
||||
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="{
|
||||
'bg-rose-50 text-rose-700': row.risk_level === 'high',
|
||||
'bg-amber-50 text-amber-800': row.risk_level === 'medium',
|
||||
'bg-sky-50 text-sky-700': row.risk_level === 'low',
|
||||
}"
|
||||
>
|
||||
{{ riskLabel(row.risk_level) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-5 py-4 align-top">
|
||||
<span
|
||||
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="row.status === 'enabled' ? 'bg-emerald-50 text-emerald-700' : 'bg-slate-100 text-slate-600'"
|
||||
>
|
||||
{{ statusLabel(row.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-5 py-4 align-top font-mono text-xs text-muted">{{ row.sort_order }}</td>
|
||||
<td class="px-5 py-4 align-top">
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-8 items-center rounded-lg border border-[#d8e0ec] bg-white px-3 text-xs font-semibold text-[#2f80d1] transition-colors hover:border-[#2f80d1] hover:bg-[#eaf4ff]"
|
||||
@click="openEdit(row)"
|
||||
>
|
||||
{{ t('admin.edit') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-8 items-center rounded-lg border border-[#d8e0ec] bg-white px-3 text-xs font-semibold text-[#172033] transition-colors hover:border-[#667792] hover:bg-slate-50"
|
||||
@click="toggleStatus(row)"
|
||||
>
|
||||
{{ row.status === 'enabled' ? t('admin.procurementContract.disable') : t('admin.procurementContract.enable') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex h-8 items-center rounded-lg border border-rose-200 bg-white px-3 text-xs font-semibold text-rose-600 transition-colors hover:border-rose-300 hover:bg-rose-50"
|
||||
@click="openDelete(row)"
|
||||
>
|
||||
{{ t('admin.delete') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="showForm"
|
||||
class="admin-modal-overlay animate-fade-in"
|
||||
@click.self="closeForm"
|
||||
>
|
||||
<div class="admin-modal-panel max-w-2xl max-h-[92vh] my-auto scale-100" role="dialog" aria-modal="true">
|
||||
<div class="admin-modal-header flex items-center justify-between gap-3">
|
||||
<h3 class="section-title">{{ formTitleText }}</h3>
|
||||
<button type="button" class="btn-ghost h-9 px-3 text-sm" @click="closeForm">
|
||||
{{ t('admin.close') }}
|
||||
</button>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.procurementContract.colTrigger')" min-width="160">
|
||||
<template #default="{ row }">{{ triggerLabel(row.trigger_type) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.procurementContract.colRisk')" width="110">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="riskTagType(row.risk_level)" effect="light">{{ riskLabel(row.risk_level) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.procurementContract.colStatus')" width="100">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="statusTagType(row.status)" effect="light">{{ statusLabel(row.status) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="sort_order" :label="t('admin.procurementContract.colSort')" width="90" />
|
||||
<ElTableColumn :label="t('admin.procurementContract.colActions')" width="220" align="right">
|
||||
<template #default="{ row }">
|
||||
<div class="contract-row-actions">
|
||||
<ElButton link type="primary" @click="openEdit(row as ContractRiskRuleRow)">
|
||||
{{ t('admin.edit') }}
|
||||
</ElButton>
|
||||
<ElButton link @click="toggleStatus(row as ContractRiskRuleRow)">
|
||||
{{ row.status === 'enabled' ? t('admin.procurementContract.disable') : t('admin.procurementContract.enable') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="deleteRule(row as ContractRiskRuleRow)">
|
||||
{{ t('admin.delete') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="admin-modal-body min-h-0 !space-y-0 grid grid-cols-1 gap-4 sm:grid-cols-2 items-start">
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colRuleTitle') }}</span>
|
||||
<input v-model="formTitle" type="text" class="input-field w-full" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colCategory') }}</span>
|
||||
<select v-model="formCategory" class="input-field w-full" :disabled="isBuiltinRule">
|
||||
<option v-for="category in clauseCategories" :key="category" :value="category">
|
||||
{{ t(`admin.procurementContract.category_${category}`) }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm sm:col-span-2">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colKeywords') }}</span>
|
||||
<input
|
||||
v-model="formKeywords"
|
||||
type="text"
|
||||
class="input-field w-full"
|
||||
:disabled="isBuiltinRule"
|
||||
:placeholder="t('admin.procurementContract.ruleKeywordsPlaceholder')"
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<ElDialog
|
||||
v-model="showForm"
|
||||
:title="formTitleText"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!saving"
|
||||
:show-close="!saving"
|
||||
@closed="onFormClosed"
|
||||
>
|
||||
<ElForm label-position="top" @submit.prevent="submitForm">
|
||||
<div class="contract-form-grid">
|
||||
<ElFormItem :label="t('admin.procurementContract.colRuleTitle')" required>
|
||||
<ElInput v-model="formTitle" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.procurementContract.colCategory')" required>
|
||||
<ElSelect v-model="formCategory" class="contract-field" :disabled="isBuiltinRule">
|
||||
<ElOption
|
||||
v-for="category in clauseCategories"
|
||||
:key="category"
|
||||
:label="t(`admin.procurementContract.category_${category}`)"
|
||||
:value="category"
|
||||
/>
|
||||
<span class="text-xs leading-5 text-muted">{{ keywordLogicHint }}</span>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colTrigger') }}</span>
|
||||
<select v-model="formTriggerType" class="input-field w-full" :disabled="isBuiltinRule">
|
||||
<option value="keyword_missing">{{ t('admin.procurementContract.triggerMissing') }}</option>
|
||||
<option value="keyword_present">{{ t('admin.procurementContract.triggerPresent') }}</option>
|
||||
</select>
|
||||
<span v-if="isBuiltinRule" class="text-xs leading-5 text-amber-700">{{ t('admin.procurementContract.builtinRuleLogicHint') }}</span>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colRisk') }}</span>
|
||||
<select v-model="formRiskLevel" class="input-field w-full">
|
||||
<option value="high">{{ t('admin.procurementContract.riskHigh') }}</option>
|
||||
<option value="medium">{{ t('admin.procurementContract.riskMedium') }}</option>
|
||||
<option value="low">{{ t('admin.procurementContract.riskLow') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colStatus') }}</span>
|
||||
<select v-model="formStatus" class="input-field w-full">
|
||||
<option value="enabled">{{ t('admin.procurementContract.enable') }}</option>
|
||||
<option value="disabled">{{ t('admin.procurementContract.disable') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="flex flex-col gap-1.5 text-sm">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<label for="risk-rule-sort-order" class="font-medium text-secondary">{{ t('admin.procurementContract.colSort') }}</label>
|
||||
<span class="group relative inline-flex">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex text-muted transition-colors hover:text-brand-600 focus:outline-none focus-visible:text-brand-600"
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="contract-form-span" :label="t('admin.procurementContract.colKeywords')" required>
|
||||
<ElInput
|
||||
v-model="formKeywords"
|
||||
:disabled="isBuiltinRule"
|
||||
:placeholder="t('admin.procurementContract.ruleKeywordsPlaceholder')"
|
||||
/>
|
||||
<p class="hx-element-hint">{{ keywordLogicHint }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.procurementContract.colTrigger')">
|
||||
<ElSelect v-model="formTriggerType" class="contract-field" :disabled="isBuiltinRule">
|
||||
<ElOption :label="t('admin.procurementContract.triggerMissing')" value="keyword_missing" />
|
||||
<ElOption :label="t('admin.procurementContract.triggerPresent')" value="keyword_present" />
|
||||
</ElSelect>
|
||||
<ElAlert
|
||||
v-if="isBuiltinRule"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
:title="t('admin.procurementContract.builtinRuleLogicHint')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.procurementContract.colRisk')">
|
||||
<ElSelect v-model="formRiskLevel" class="contract-field">
|
||||
<ElOption :label="t('admin.procurementContract.riskHigh')" value="high" />
|
||||
<ElOption :label="t('admin.procurementContract.riskMedium')" value="medium" />
|
||||
<ElOption :label="t('admin.procurementContract.riskLow')" value="low" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.procurementContract.colStatus')">
|
||||
<ElSelect v-model="formStatus" class="contract-field">
|
||||
<ElOption :label="t('admin.procurementContract.enable')" value="enabled" />
|
||||
<ElOption :label="t('admin.procurementContract.disable')" value="disabled" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="contract-sort-label">
|
||||
{{ t('admin.procurementContract.colSort') }}
|
||||
<ElTooltip :content="t('admin.procurementContract.ruleSortHint')" placement="top">
|
||||
<ElIcon
|
||||
class="contract-help-icon"
|
||||
tabindex="0"
|
||||
:aria-label="t('admin.procurementContract.ruleSortHint')"
|
||||
>
|
||||
<CircleHelp class="h-4 w-4" />
|
||||
</button>
|
||||
<span class="pointer-events-none absolute bottom-full left-1/2 z-10 mb-2 hidden w-60 -translate-x-1/2 rounded-lg border border-subtle bg-white px-3 py-2 text-xs font-normal leading-5 text-secondary shadow-lg group-hover:block group-focus-within:block">
|
||||
{{ t('admin.procurementContract.ruleSortHint') }}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<input id="risk-rule-sort-order" v-model.number="formSortOrder" type="number" class="input-field w-full" min="0" />
|
||||
</div>
|
||||
<label class="flex flex-col gap-1.5 text-sm sm:col-span-2">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colRiskHint') }}</span>
|
||||
<textarea v-model="formRiskHint" rows="2" class="input-field w-full resize-y" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm sm:col-span-2">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colSuggestion') }}</span>
|
||||
<textarea v-model="formSuggestion" rows="2" class="input-field w-full resize-y" />
|
||||
</label>
|
||||
<label class="flex flex-col gap-1.5 text-sm sm:col-span-2">
|
||||
<span class="font-medium text-secondary">{{ t('admin.procurementContract.colNegotiation') }}</span>
|
||||
<textarea v-model="formNegotiation" rows="2" class="input-field w-full resize-y" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="admin-modal-footer flex justify-end gap-2">
|
||||
<button type="button" class="btn-ghost h-10 px-4" @click="closeForm">
|
||||
{{ t('admin.cancel') }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary h-10 px-4 disabled:opacity-70" :disabled="saving" @click="submitForm">
|
||||
{{ saving ? t('admin.procurementContract.saving') : t('admin.procurementContract.saveChanges') }}
|
||||
</button>
|
||||
</div>
|
||||
<QuestionFilled />
|
||||
</ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInputNumber
|
||||
v-model="formSortOrder"
|
||||
class="contract-field"
|
||||
:min="0"
|
||||
:step="1"
|
||||
controls-position="right"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="contract-form-span" :label="t('admin.procurementContract.colRiskHint')" required>
|
||||
<ElInput v-model="formRiskHint" type="textarea" :rows="4" />
|
||||
</ElFormItem>
|
||||
<ElFormItem class="contract-form-span" :label="t('admin.procurementContract.colSuggestion')" required>
|
||||
<ElInput v-model="formSuggestion" type="textarea" :rows="4" />
|
||||
</ElFormItem>
|
||||
<ElFormItem class="contract-form-span" :label="t('admin.procurementContract.colNegotiation')">
|
||||
<ElInput v-model="formNegotiation" type="textarea" :rows="4" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirm"
|
||||
:message="t('admin.procurementContract.confirmDeleteRule', { title: pendingDelete?.title || '' })"
|
||||
:confirm-loading="deleting"
|
||||
@confirm="confirmDelete"
|
||||
@cancel="closeDelete"
|
||||
/>
|
||||
</div>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="saving" @click="closeForm">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="saving" @click="submitForm">
|
||||
{{ t('admin.procurementContract.saveChanges') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.contract-row-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
gap: 2px 8px;
|
||||
}
|
||||
|
||||
.rule-keywords {
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
white-space: normal;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.contract-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
column-gap: 16px;
|
||||
}
|
||||
|
||||
.contract-form-span {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.contract-field {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.contract-sort-label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.contract-help-icon {
|
||||
cursor: help;
|
||||
}
|
||||
</style>
|
||||
@@ -1,490 +1,271 @@
|
||||
/**
|
||||
|
||||
* features/admin/modules/questions/QuestionsPage.vue
|
||||
|
||||
* 常用问题管理:Tab「常用问题」+「热点发现」(离线聚合候选)。
|
||||
|
||||
* 依赖:useQuestionsAdmin、HotFaqCandidatesPanel、QuestionFormModal。
|
||||
|
||||
* 逻辑:路由 /admin/questions;热点候选晋升后写入 QuickQuestion 并由 Phase 1 FAQ 在线命中。
|
||||
|
||||
* 用途:常用问题管理页。一张卡片里放标题、添加按钮、页签、筛选和表格。
|
||||
* 依赖:AdminListPage、AdminListTabs、useQuestionsAdmin、element-plus、QuestionFormModal、HotFaqCandidatesPanel。
|
||||
* 逻辑:路由 /admin/questions。骨架用 AdminListPage,页签用 AdminListTabs。
|
||||
* 筛选、表格留在本页;热点候选由页签内容区的面板自己渲染。删除在 composable 里用 Element 确认框。
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { Edit, Plus, Trash2, Zap } from 'lucide-vue-next';
|
||||
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
|
||||
import type { AdminQuickQuestionRow } from '@/features/admin/types/question.types';
|
||||
import HotFaqCandidatesPanel from './components/HotFaqCandidatesPanel.vue';
|
||||
|
||||
import QuestionFormModal from './components/QuestionFormModal.vue';
|
||||
|
||||
import { useQuestionsAdmin } from './composables/useQuestionsAdmin';
|
||||
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const activeTab = ref<'manual' | 'hot'>('manual');
|
||||
|
||||
|
||||
|
||||
const {
|
||||
|
||||
filteredQuestions,
|
||||
|
||||
agents,
|
||||
|
||||
form,
|
||||
|
||||
isLoading,
|
||||
|
||||
isSaving,
|
||||
|
||||
showFormModal,
|
||||
|
||||
showDeleteConfirmDialog,
|
||||
|
||||
deleteConfirmMessage,
|
||||
|
||||
filterAgentId,
|
||||
|
||||
filterCacheOnly,
|
||||
|
||||
filterStaleOnly,
|
||||
|
||||
staleCount,
|
||||
|
||||
searchKeyword,
|
||||
|
||||
loadAll,
|
||||
|
||||
openCreateModal,
|
||||
|
||||
openEditModal,
|
||||
|
||||
closeFormModal,
|
||||
|
||||
saveQuestion,
|
||||
|
||||
saveReviewQuestion,
|
||||
|
||||
deleteQuestion,
|
||||
|
||||
closeDeleteConfirm,
|
||||
|
||||
confirmDelete,
|
||||
|
||||
truncateQuestionPreview,
|
||||
|
||||
truncateAnswerPreview,
|
||||
|
||||
} = useQuestionsAdmin();
|
||||
|
||||
/**
|
||||
* 常用问题和热点发现两个页签。待审数量大于 0 时显示在第一个页签上。
|
||||
*/
|
||||
const questionTabs = computed(() => [
|
||||
{
|
||||
name: 'manual',
|
||||
label: t('admin.question.tabs.manual'),
|
||||
badge: staleCount.value > 0 ? staleCount.value : undefined,
|
||||
},
|
||||
{
|
||||
name: 'hot',
|
||||
label: t('admin.question.tabs.hotDiscovery'),
|
||||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* 只接受本页的两个页签名,避免公共页签回传任意字符串。
|
||||
* @param name - AdminListTabs 当前选中的 name
|
||||
*/
|
||||
function onQuestionTabChange(name: string): void {
|
||||
if (name === 'manual' || name === 'hot') activeTab.value = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用筛选。清空时写回空字符串,表示全部应用。
|
||||
* @param value - 选中的应用 id;清空为 undefined
|
||||
*/
|
||||
function onAgentFilterChange(value: number | undefined): void {
|
||||
filterAgentId.value = value ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开编辑弹窗。表格插槽行类型较宽,这里收成常用问题行。
|
||||
* @param row - 当前表格行
|
||||
*/
|
||||
function editQuestion(row: AdminQuickQuestionRow): void {
|
||||
openEditModal(row);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
void loadAll();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
|
||||
<div class="admin-table-header admin-table-header--stacked mb-4">
|
||||
|
||||
<div>
|
||||
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.question.title') }}</h2>
|
||||
|
||||
<p class="section-desc mt-1">{{ t('admin.question.subtitle') }}</p>
|
||||
|
||||
</div>
|
||||
|
||||
<button
|
||||
|
||||
v-if="activeTab === 'manual'"
|
||||
|
||||
type="button"
|
||||
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
|
||||
@click="openCreateModal"
|
||||
|
||||
>
|
||||
|
||||
<Plus class="w-4 h-4" />
|
||||
|
||||
<span>{{ t('admin.question.add') }}</span>
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="mb-6 flex gap-1 border-b border-default">
|
||||
|
||||
<button
|
||||
|
||||
type="button"
|
||||
|
||||
class="px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors"
|
||||
|
||||
:class="activeTab === 'manual' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-secondary'"
|
||||
|
||||
@click="activeTab = 'manual'"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.tabs.manual') }}
|
||||
|
||||
<span
|
||||
v-if="staleCount > 0"
|
||||
class="ml-1.5 inline-flex min-w-[1.25rem] items-center justify-center rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-800"
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton
|
||||
v-if="activeTab === 'manual'"
|
||||
type="primary"
|
||||
:icon="Plus"
|
||||
@click="openCreateModal"
|
||||
>
|
||||
{{ staleCount }}
|
||||
{{ t('admin.question.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #tabs>
|
||||
<AdminListTabs :model-value="activeTab" :items="questionTabs" @update:model-value="onQuestionTabChange" />
|
||||
</template>
|
||||
<template v-if="activeTab === 'manual'" #filters>
|
||||
<ElInput
|
||||
v-model="searchKeyword"
|
||||
clearable
|
||||
class="question-filter-search"
|
||||
:placeholder="t('admin.question.filters.search')"
|
||||
/>
|
||||
<ElSelect
|
||||
:model-value="filterAgentId === '' ? undefined : filterAgentId"
|
||||
class="question-filter-agent"
|
||||
clearable
|
||||
:placeholder="t('admin.question.filters.allAgents')"
|
||||
@update:model-value="onAgentFilterChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
:label="agent.name"
|
||||
:value="agent.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElCheckbox v-model="filterCacheOnly">{{ t('admin.question.filters.cacheOnly') }}</ElCheckbox>
|
||||
<ElCheckbox v-model="filterStaleOnly">{{ t('admin.question.filters.staleOnly') }}</ElCheckbox>
|
||||
<span class="question-filter-count">
|
||||
{{ t('admin.question.filters.resultCount', { count: filteredQuestions.length }) }}
|
||||
</span>
|
||||
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
||||
type="button"
|
||||
|
||||
class="px-4 py-2.5 text-sm font-medium border-b-2 -mb-px transition-colors"
|
||||
|
||||
:class="activeTab === 'hot' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-secondary'"
|
||||
|
||||
@click="activeTab = 'hot'"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.tabs.hotDiscovery') }}
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<HotFaqCandidatesPanel v-if="activeTab === 'hot'" />
|
||||
|
||||
|
||||
|
||||
<template v-else>
|
||||
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<template v-else>
|
||||
|
||||
<div class="mb-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
|
||||
<div class="flex flex-1 flex-wrap items-center gap-3">
|
||||
|
||||
<input
|
||||
|
||||
v-model="searchKeyword"
|
||||
|
||||
type="search"
|
||||
|
||||
class="input-field text-sm w-full max-w-xs"
|
||||
|
||||
:placeholder="t('admin.question.filters.search')"
|
||||
|
||||
/>
|
||||
|
||||
<select v-model="filterAgentId" class="input-field text-sm w-full max-w-[200px]">
|
||||
|
||||
<option value="">{{ t('admin.question.filters.allAgents') }}</option>
|
||||
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
|
||||
{{ agent.name }}
|
||||
|
||||
</option>
|
||||
|
||||
</select>
|
||||
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary whitespace-nowrap">
|
||||
|
||||
<input v-model="filterCacheOnly" type="checkbox" class="accent-brand-600" />
|
||||
|
||||
<span>{{ t('admin.question.filters.cacheOnly') }}</span>
|
||||
|
||||
</label>
|
||||
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary whitespace-nowrap">
|
||||
|
||||
<input v-model="filterStaleOnly" type="checkbox" class="accent-brand-600" />
|
||||
|
||||
<span>{{ t('admin.question.filters.staleOnly') }}</span>
|
||||
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
<p class="text-xs text-muted">
|
||||
|
||||
{{ t('admin.question.filters.resultCount', { count: filteredQuestions.length }) }}
|
||||
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
|
||||
<table class="admin-table">
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.question.headers.title') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.question.headers.agent') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.question.headers.content') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.question.headers.answer') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs w-28">{{ t('admin.question.headers.cache') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs w-20">{{ t('admin.question.headers.hits') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-left text-xs w-16">{{ t('admin.question.headers.order') }}</th>
|
||||
|
||||
<th class="px-6 py-4 text-right text-xs w-28">{{ t('admin.question.headers.actions') }}</th>
|
||||
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr v-if="filteredQuestions.length === 0">
|
||||
|
||||
<td colspan="8" class="px-6 admin-table-empty">{{ t('admin.question.noData') }}</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr v-for="q in filteredQuestions" :key="q.id" class="group">
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
|
||||
<div class="font-medium text-primary text-sm">{{ q.title }}</div>
|
||||
|
||||
<span
|
||||
|
||||
v-if="q.stale_at"
|
||||
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium bg-amber-50 text-amber-800 border border-amber-100"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.badges.stale') }}
|
||||
|
||||
</span>
|
||||
|
||||
<span
|
||||
|
||||
v-if="!q.is_enabled"
|
||||
|
||||
class="inline-flex items-center rounded-full px-2 py-0.5 text-[10px] font-medium bg-surface-soft text-muted border border-default"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.badges.disabled') }}
|
||||
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<span
|
||||
|
||||
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-50 text-blue-700 border border-blue-100"
|
||||
|
||||
>
|
||||
|
||||
{{ q.agent_name || 'Unknown' }}
|
||||
|
||||
</span>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<p class="text-sm text-secondary truncate max-w-[180px]" :title="q.question">
|
||||
|
||||
{{ truncateQuestionPreview(q.question) }}
|
||||
|
||||
</p>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<p
|
||||
|
||||
v-if="q.cache_enabled && q.answer"
|
||||
|
||||
class="text-sm text-secondary truncate max-w-[160px]"
|
||||
|
||||
:title="q.answer"
|
||||
|
||||
>
|
||||
|
||||
{{ truncateAnswerPreview(q.answer) }}
|
||||
|
||||
</p>
|
||||
|
||||
<span v-else class="text-xs text-muted">—</span>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<span
|
||||
|
||||
v-if="q.cache_enabled"
|
||||
|
||||
class="inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium bg-emerald-50 text-emerald-700 border border-emerald-100"
|
||||
|
||||
>
|
||||
|
||||
<Zap class="w-3 h-3" />
|
||||
|
||||
{{ t('admin.question.badges.cacheOn') }}
|
||||
|
||||
</span>
|
||||
|
||||
<span
|
||||
|
||||
v-else
|
||||
|
||||
class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium bg-surface-soft text-muted border border-default"
|
||||
|
||||
>
|
||||
|
||||
{{ t('admin.question.badges.cacheOff') }}
|
||||
|
||||
</span>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-6 py-4 text-sm text-muted tabular-nums">{{ q.hit_count || 0 }}</td>
|
||||
|
||||
<td class="px-6 py-4 text-sm text-muted tabular-nums">{{ q.sort_order }}</td>
|
||||
|
||||
<td class="px-6 py-4">
|
||||
|
||||
<div class="flex justify-end gap-1">
|
||||
|
||||
<button
|
||||
|
||||
type="button"
|
||||
|
||||
class="p-1.5 text-indigo-600 hover:bg-indigo-50 rounded-lg transition-colors"
|
||||
|
||||
@click="openEditModal(q)"
|
||||
|
||||
>
|
||||
|
||||
<Edit class="w-4 h-4" />
|
||||
|
||||
</button>
|
||||
|
||||
<button
|
||||
|
||||
type="button"
|
||||
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg transition-colors"
|
||||
|
||||
@click="deleteQuestion(q.id)"
|
||||
|
||||
>
|
||||
|
||||
<Trash2 class="w-4 h-4" />
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<ElTable
|
||||
v-if="activeTab === 'manual'"
|
||||
v-loading="isLoading"
|
||||
class="hx-admin-table"
|
||||
:data="filteredQuestions"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.question.noData')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.question.headers.title')" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div class="question-title">
|
||||
<span>{{ (row as AdminQuickQuestionRow).title }}</span>
|
||||
<ElTag v-if="(row as AdminQuickQuestionRow).stale_at" type="warning" effect="light">
|
||||
{{ t('admin.question.badges.stale') }}
|
||||
</ElTag>
|
||||
<ElTag v-if="!(row as AdminQuickQuestionRow).is_enabled" type="info" effect="light">
|
||||
{{ t('admin.question.badges.disabled') }}
|
||||
</ElTag>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.question.headers.agent')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag effect="light">{{ (row as AdminQuickQuestionRow).agent_name || 'Unknown' }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.question.headers.content')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="question-ellipsis" :title="(row as AdminQuickQuestionRow).question">
|
||||
{{ truncateQuestionPreview((row as AdminQuickQuestionRow).question) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.question.headers.answer')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span
|
||||
v-if="(row as AdminQuickQuestionRow).cache_enabled && (row as AdminQuickQuestionRow).answer"
|
||||
class="question-ellipsis"
|
||||
:title="(row as AdminQuickQuestionRow).answer || ''"
|
||||
>
|
||||
{{ truncateAnswerPreview((row as AdminQuickQuestionRow).answer || '') }}
|
||||
</span>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.question.headers.cache')" width="120">
|
||||
<template #default="{ row }">
|
||||
<ElTag
|
||||
:type="(row as AdminQuickQuestionRow).cache_enabled ? 'success' : 'info'"
|
||||
effect="light"
|
||||
>
|
||||
{{
|
||||
(row as AdminQuickQuestionRow).cache_enabled
|
||||
? t('admin.question.badges.cacheOn')
|
||||
: t('admin.question.badges.cacheOff')
|
||||
}}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.question.headers.hits')" width="88">
|
||||
<template #default="{ row }">{{ (row as AdminQuickQuestionRow).hit_count || 0 }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.question.headers.order')" width="88">
|
||||
<template #default="{ row }">{{ (row as AdminQuickQuestionRow).sort_order }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.question.headers.actions')" width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="editQuestion(row as AdminQuickQuestionRow)">
|
||||
{{ t('admin.question.actions.edit') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="deleteQuestion((row as AdminQuickQuestionRow).id)">
|
||||
{{ t('admin.question.actions.delete') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<HotFaqCandidatesPanel v-if="activeTab === 'hot'" />
|
||||
</AdminListPage>
|
||||
|
||||
<QuestionFormModal
|
||||
|
||||
:visible="showFormModal"
|
||||
|
||||
:form="form"
|
||||
|
||||
:agents="agents"
|
||||
|
||||
:is-saving="isSaving"
|
||||
|
||||
@close="closeFormModal"
|
||||
|
||||
@save="saveQuestion"
|
||||
|
||||
@review="saveReviewQuestion"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<DeleteConfirmDialog
|
||||
|
||||
v-model="showDeleteConfirmDialog"
|
||||
|
||||
:message="deleteConfirmMessage"
|
||||
|
||||
@cancel="closeDeleteConfirm"
|
||||
|
||||
@confirm="confirmDelete"
|
||||
|
||||
/>
|
||||
|
||||
</template>
|
||||
|
||||
</section>
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.question-filter-search) {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
:deep(.question-filter-agent) {
|
||||
width: 11rem;
|
||||
}
|
||||
|
||||
.question-filter-count {
|
||||
margin-left: auto;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-small);
|
||||
}
|
||||
|
||||
.question-title {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.question-ellipsis {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
+215
-145
@@ -1,14 +1,29 @@
|
||||
/**
|
||||
* features/admin/modules/questions/components/HotFaqCandidatesPanel.vue
|
||||
* 热点 FAQ 候选列表:离线聚合结果展示、刷新、晋升、忽略。
|
||||
* 依赖:useHotFaqCandidates。
|
||||
* 逻辑:QuestionsPage「热点发现」Tab 挂载本组件。
|
||||
* 用途:热点 FAQ 候选列表。展示离线聚合结果,并提供刷新、晋升、忽略。
|
||||
* 依赖:useHotFaqCandidates、element-plus 的表格、筛选和按钮。
|
||||
* 逻辑:QuestionsPage「热点发现」页签把本组件放在内容区,不再套一层 AdminListPage。样式随页面入口引入。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowUpCircle, Info, RefreshCw, XCircle } from 'lucide-vue-next';
|
||||
import { useHotFaqCandidates } from '../composables/useHotFaqCandidates';
|
||||
import { InfoFilled, Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import {
|
||||
useHotFaqCandidates,
|
||||
type HotFaqCandidateRow,
|
||||
} from '../composables/useHotFaqCandidates';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -30,159 +45,214 @@ const {
|
||||
truncatePreview,
|
||||
} = useHotFaqCandidates();
|
||||
|
||||
/**
|
||||
* 切换热点候选的应用筛选。
|
||||
* 核心逻辑:清空时写回空字符串,表示全部应用;随后按应用重新拉取候选。
|
||||
* @param value - 选中的应用 id;清空为 undefined
|
||||
*/
|
||||
function onAgentFilterChange(value: number | undefined): void {
|
||||
filterAgentId.value = value ?? '';
|
||||
void loadCandidates();
|
||||
}
|
||||
|
||||
/**
|
||||
* 表格行主键。同一应用下的归一化问句唯一。
|
||||
* @param row - 候选行
|
||||
*/
|
||||
function candidateRowKey(row: HotFaqCandidateRow): string {
|
||||
return `${row.agent_id}-${row.q_norm}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取聚合规则里的文案或数字。
|
||||
* 核心逻辑:规则结构由接口返回,字段缺失时显示空字符串。
|
||||
* @param group - selection 或 answer
|
||||
* @param field - 规则字段名
|
||||
*/
|
||||
function ruleValue(group: 'selection' | 'answer', field: string): string {
|
||||
const source = rules.value?.[group];
|
||||
if (!source || typeof source !== 'object') return '';
|
||||
const value = (source as Record<string, unknown>)[field];
|
||||
if (value == null || value === '') return '';
|
||||
return String(value);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
|
||||
const onAgentFilterChange = () => {
|
||||
void loadCandidates();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<div class="rounded-2xl border border-default bg-surface-soft/40 p-4 text-sm text-secondary">
|
||||
<div class="hot-faq-panel">
|
||||
<div class="hot-faq-intro">
|
||||
<p>{{ t('admin.hotFaq.intro') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-2 inline-flex items-center gap-1 text-xs font-medium text-brand-600 hover:underline"
|
||||
@click="showRules = !showRules"
|
||||
>
|
||||
<Info class="w-3.5 h-3.5" />
|
||||
<ElButton link type="primary" :icon="InfoFilled" @click="showRules = !showRules">
|
||||
{{ showRules ? t('admin.hotFaq.hideRules') : t('admin.hotFaq.showRules') }}
|
||||
</button>
|
||||
<div v-if="showRules && rules" class="mt-3 space-y-2 text-xs text-muted border-t border-subtle pt-3">
|
||||
<div>
|
||||
<span class="font-semibold text-secondary">{{ t('admin.hotFaq.rules.selection') }}</span>
|
||||
{{ (rules as any).selection?.description }}
|
||||
</div>
|
||||
<ul class="list-disc pl-5 space-y-0.5">
|
||||
<li>{{ t('admin.hotFaq.rules.windowDays', { n: (rules as any).selection?.window_days }) }}</li>
|
||||
<li>{{ t('admin.hotFaq.rules.minCount', { n: (rules as any).selection?.min_count }) }}</li>
|
||||
<li>{{ t('admin.hotFaq.rules.minUsers', { n: (rules as any).selection?.min_users }) }}</li>
|
||||
</ElButton>
|
||||
<div v-if="showRules && rules" class="hot-faq-rules">
|
||||
<p>
|
||||
<strong>{{ t('admin.hotFaq.rules.selection') }}</strong>
|
||||
{{ ruleValue('selection', 'description') }}
|
||||
</p>
|
||||
<ul>
|
||||
<li>{{ t('admin.hotFaq.rules.windowDays', { n: ruleValue('selection', 'window_days') }) }}</li>
|
||||
<li>{{ t('admin.hotFaq.rules.minCount', { n: ruleValue('selection', 'min_count') }) }}</li>
|
||||
<li>{{ t('admin.hotFaq.rules.minUsers', { n: ruleValue('selection', 'min_users') }) }}</li>
|
||||
</ul>
|
||||
<div class="pt-1">
|
||||
<span class="font-semibold text-secondary">{{ t('admin.hotFaq.rules.answer') }}</span>
|
||||
{{ (rules as any).answer?.description }}
|
||||
</div>
|
||||
<p>
|
||||
<strong>{{ t('admin.hotFaq.rules.answer') }}</strong>
|
||||
{{ ruleValue('answer', 'description') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div class="flex flex-1 flex-wrap items-center gap-3">
|
||||
<input
|
||||
v-model="searchKeyword"
|
||||
type="search"
|
||||
class="input-field text-sm w-full max-w-xs"
|
||||
:placeholder="t('admin.hotFaq.filters.search')"
|
||||
/>
|
||||
<select
|
||||
v-model="filterAgentId"
|
||||
class="input-field text-sm w-full max-w-[200px]"
|
||||
@change="onAgentFilterChange"
|
||||
>
|
||||
<option value="">{{ t('admin.hotFaq.filters.allAgents') }}</option>
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs text-muted">
|
||||
{{ t('admin.hotFaq.stats.summary', {
|
||||
count: stats.total_candidates ?? 0,
|
||||
asks: stats.total_ask_count_7d ?? 0,
|
||||
}) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost text-sm"
|
||||
:disabled="isRefreshing"
|
||||
@click="refreshCandidates(true)"
|
||||
>
|
||||
{{ t('admin.hotFaq.actions.dryRun') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 text-sm font-medium disabled:opacity-70"
|
||||
:disabled="isRefreshing"
|
||||
@click="refreshCandidates(false)"
|
||||
>
|
||||
<RefreshCw class="w-4 h-4" :class="{ 'animate-spin': isRefreshing }" />
|
||||
{{ t('admin.hotFaq.actions.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="hot-faq-filters">
|
||||
<ElInput
|
||||
v-model="searchKeyword"
|
||||
clearable
|
||||
class="hot-faq-filter-search"
|
||||
:placeholder="t('admin.hotFaq.filters.search')"
|
||||
/>
|
||||
<ElSelect
|
||||
:model-value="filterAgentId === '' ? undefined : filterAgentId"
|
||||
class="hot-faq-filter-agent"
|
||||
clearable
|
||||
:placeholder="t('admin.hotFaq.filters.allAgents')"
|
||||
@update:model-value="onAgentFilterChange"
|
||||
>
|
||||
<ElOption v-for="agent in agents" :key="agent.id" :label="agent.name" :value="agent.id" />
|
||||
</ElSelect>
|
||||
<span class="hot-faq-stats">
|
||||
{{ t('admin.hotFaq.stats.summary', {
|
||||
count: stats.total_candidates ?? 0,
|
||||
asks: stats.total_ask_count_7d ?? 0,
|
||||
}) }}
|
||||
</span>
|
||||
<ElButton :disabled="isRefreshing" @click="refreshCandidates(true)">
|
||||
{{ t('admin.hotFaq.actions.dryRun') }}
|
||||
</ElButton>
|
||||
<ElButton type="primary" :icon="Refresh" :loading="isRefreshing" @click="refreshCandidates(false)">
|
||||
{{ t('admin.hotFaq.actions.refresh') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-16">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<div v-else class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.hotFaq.headers.query') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.hotFaq.headers.agent') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.hotFaq.headers.answer') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-20">{{ t('admin.hotFaq.headers.asks') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-20">{{ t('admin.hotFaq.headers.users') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-24">{{ t('admin.hotFaq.headers.tokens') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-20">{{ t('admin.hotFaq.headers.dominance') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-36">{{ t('admin.hotFaq.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="filteredItems.length === 0">
|
||||
<td colspan="8" class="px-6 admin-table-empty">{{ t('admin.hotFaq.noData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in filteredItems" :key="`${row.agent_id}-${row.q_norm}`">
|
||||
<td class="px-6 py-4">
|
||||
<div class="font-medium text-primary text-sm">{{ row.canonical_query }}</div>
|
||||
<p v-if="row.sample_queries?.length" class="text-[11px] text-muted mt-1 truncate max-w-[200px]">
|
||||
{{ row.sample_queries.slice(0, 2).join(' / ') }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="inline-flex px-2.5 py-0.5 rounded-full text-xs bg-blue-50 text-blue-700 border border-blue-100">
|
||||
{{ row.agent_name || row.agent_id }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm text-secondary truncate max-w-[180px]" :title="row.answer">
|
||||
{{ truncatePreview(row.answer) }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm tabular-nums text-muted">{{ row.ask_count_7d }}</td>
|
||||
<td class="px-6 py-4 text-sm tabular-nums text-muted">{{ row.user_count_7d }}</td>
|
||||
<td class="px-6 py-4 text-sm tabular-nums text-muted">{{ row.avg_tokens }}</td>
|
||||
<td class="px-6 py-4 text-sm tabular-nums text-muted">
|
||||
{{ row.answer_dominance != null ? `${Math.round(row.answer_dominance * 100)}%` : '—' }}
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-end gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 px-2.5 py-1.5 text-xs font-medium text-emerald-700 bg-emerald-50 hover:bg-emerald-100 rounded-lg border border-emerald-100"
|
||||
:title="t('admin.hotFaq.actions.promote')"
|
||||
@click="promoteCandidate(row)"
|
||||
>
|
||||
<ArrowUpCircle class="w-3.5 h-3.5" />
|
||||
{{ t('admin.hotFaq.actions.promote') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 text-red-600 hover:bg-red-50 rounded-lg"
|
||||
:title="t('admin.hotFaq.actions.dismiss')"
|
||||
@click="dismissCandidate(row)"
|
||||
>
|
||||
<XCircle class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<ElTable
|
||||
v-loading="isLoading"
|
||||
class="hx-admin-table"
|
||||
:data="filteredItems"
|
||||
:row-key="candidateRowKey"
|
||||
:empty-text="t('admin.hotFaq.noData')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.hotFaq.headers.query')" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div>{{ (row as HotFaqCandidateRow).canonical_query }}</div>
|
||||
<p
|
||||
v-if="(row as HotFaqCandidateRow).sample_queries?.length"
|
||||
class="hx-element-hint question-ellipsis"
|
||||
:title="(row as HotFaqCandidateRow).sample_queries?.slice(0, 2).join(' / ')"
|
||||
>
|
||||
{{ (row as HotFaqCandidateRow).sample_queries?.slice(0, 2).join(' / ') }}
|
||||
</p>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.hotFaq.headers.agent')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag effect="light">
|
||||
{{ (row as HotFaqCandidateRow).agent_name || (row as HotFaqCandidateRow).agent_id }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.hotFaq.headers.answer')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="question-ellipsis" :title="(row as HotFaqCandidateRow).answer">
|
||||
{{ truncatePreview((row as HotFaqCandidateRow).answer) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.hotFaq.headers.asks')" width="100">
|
||||
<template #default="{ row }">{{ (row as HotFaqCandidateRow).ask_count_7d }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.hotFaq.headers.users')" width="100">
|
||||
<template #default="{ row }">{{ (row as HotFaqCandidateRow).user_count_7d }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.hotFaq.headers.tokens')" width="110">
|
||||
<template #default="{ row }">{{ (row as HotFaqCandidateRow).avg_tokens }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.hotFaq.headers.dominance')" width="110">
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
(row as HotFaqCandidateRow).answer_dominance != null
|
||||
? `${Math.round(((row as HotFaqCandidateRow).answer_dominance || 0) * 100)}%`
|
||||
: '—'
|
||||
}}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.hotFaq.headers.actions')" width="220" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="promoteCandidate(row as HotFaqCandidateRow)">
|
||||
{{ t('admin.hotFaq.actions.promote') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="dismissCandidate(row as HotFaqCandidateRow)">
|
||||
{{ t('admin.hotFaq.actions.dismiss') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.hot-faq-intro {
|
||||
padding: 16px 32px 0;
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.hot-faq-rules {
|
||||
margin-top: 12px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
}
|
||||
|
||||
.hot-faq-rules ul {
|
||||
margin: 8px 0;
|
||||
padding-left: 1.25rem;
|
||||
}
|
||||
|
||||
.hot-faq-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.hot-faq-filters :deep(.el-input),
|
||||
.hot-faq-filters :deep(.el-select) {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
:deep(.hot-faq-filter-search) {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
:deep(.hot-faq-filter-agent) {
|
||||
width: 11rem;
|
||||
}
|
||||
|
||||
.hot-faq-stats {
|
||||
margin-left: auto;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-small);
|
||||
}
|
||||
|
||||
.question-ellipsis {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
@@ -1,13 +1,28 @@
|
||||
/**
|
||||
* features/admin/modules/questions/components/QuestionFormModal.vue
|
||||
* 常用问题 / FAQ 缓存创建与编辑居中弹窗。
|
||||
* 依赖:QuestionFormState、admin 通用 modal 样式。
|
||||
* 逻辑:QuestionsPage 打开本组件;提交时 emit save,由 composable 调 API。
|
||||
* is_enabled 仅控制工作台首页入口;cache_enabled 单独控制聊天是否跳过 Dify。
|
||||
* 用途:常用问题 / FAQ 缓存的创建与编辑对话框。字段多,宽 680px,两列短字段。
|
||||
* 依赖:element-plus 对话框和表单、QuestionFormState、AdminAgentOption。
|
||||
* 逻辑:QuestionsPage 打开本组件。提交时 emit save 或 review,由 useQuestionsAdmin 调接口。样式跟页面已引入的 Element 皮肤走。
|
||||
* is_enabled 仅控制工作台首页入口;cache_enabled 单独控制聊天是否跳过 Dify;
|
||||
* fuzzy_enabled 在精确未命中时按阈值兜底直答,以 cache_enabled 为前提(关闭缓存时联动取消勾选)。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { computed, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElDatePicker,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import type { AdminAgentOption } from '@/features/admin/types/admin.types';
|
||||
import type { QuestionFormState } from '@/features/admin/types/question.types';
|
||||
|
||||
@@ -29,175 +44,258 @@ const { t } = useI18n();
|
||||
/** 启用 FAQ 缓存时标准答案为必填。 */
|
||||
const answerRequired = computed(() => props.form.cache_enabled);
|
||||
|
||||
/** 模糊匹配只在 FAQ 缓存开启时有意义,控制阈值输入的显隐与开关可用态。 */
|
||||
const fuzzyAvailable = computed(() => props.form.cache_enabled && props.form.fuzzy_enabled);
|
||||
|
||||
/**
|
||||
* 关闭 FAQ 缓存时联动取消模糊匹配,避免提交出「缓存关、模糊开」的无效组合。
|
||||
*/
|
||||
watch(
|
||||
() => props.form.cache_enabled,
|
||||
(enabled) => {
|
||||
if (!enabled) props.form.fuzzy_enabled = false;
|
||||
},
|
||||
);
|
||||
|
||||
/** 是否处于 KB 更新后的待复审状态。 */
|
||||
const isStale = computed(() => Boolean(props.form.stale_at));
|
||||
|
||||
/**
|
||||
* 待复审原因的现有文案。
|
||||
* 核心逻辑:删除和更新共用同一段提示,只替换原因短语。
|
||||
*/
|
||||
const staleReasonLabel = computed(() => (
|
||||
props.form.stale_reason === 'kb_document_deleted'
|
||||
? t('admin.question.stale.reasonDeleted')
|
||||
: t('admin.question.stale.reasonUpdated')
|
||||
));
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起并重置表单。提交过程中不收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (open || props.isSaving) return;
|
||||
emit('close');
|
||||
}
|
||||
|
||||
/**
|
||||
* 过期时间选择。清空后写回空字符串,提交时仍按长期有效处理。
|
||||
* @param value - 日期组件回传的值;只有字符串会写进表单
|
||||
*/
|
||||
function onExpiresChange(value: string | number | Date | string[] | number[] | Date[] | null | undefined): void {
|
||||
props.form.expires_at = typeof value === 'string' ? value : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 按当前状态提交保存或完成复审。
|
||||
*/
|
||||
function submitForm(): void {
|
||||
if (isStale.value) {
|
||||
emit('review');
|
||||
return;
|
||||
}
|
||||
emit('save');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-3xl 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">
|
||||
{{ form.id ? t('admin.question.edit') : t('admin.question.add') }}
|
||||
</h3>
|
||||
<p class="text-sm text-muted mt-1">{{ t('admin.question.formHint') }}</p>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="form.id ? t('admin.question.edit') : t('admin.question.add')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!isSaving"
|
||||
:show-close="!isSaving"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<div class="question-dialog-body">
|
||||
<p class="hx-element-hint">{{ t('admin.question.formHint') }}</p>
|
||||
<ElAlert
|
||||
v-if="isStale"
|
||||
class="question-stale"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
:title="t('admin.question.stale.bannerTitle')"
|
||||
>
|
||||
<p>
|
||||
{{ t('admin.question.stale.bannerBody', {
|
||||
doc: form.stale_kb_document_title || t('admin.question.stale.unknownDoc'),
|
||||
reason: staleReasonLabel,
|
||||
}) }}
|
||||
</p>
|
||||
<p>{{ t('admin.question.stale.bannerHint') }}</p>
|
||||
</ElAlert>
|
||||
|
||||
<div class="px-5 sm:px-8 py-5 space-y-6 overflow-y-auto">
|
||||
<div
|
||||
v-if="isStale"
|
||||
class="rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900"
|
||||
>
|
||||
<p class="font-medium">{{ t('admin.question.stale.bannerTitle') }}</p>
|
||||
<p class="mt-1 text-xs text-amber-800">
|
||||
{{ t('admin.question.stale.bannerBody', {
|
||||
doc: form.stale_kb_document_title || t('admin.question.stale.unknownDoc'),
|
||||
reason: form.stale_reason === 'kb_document_deleted'
|
||||
? t('admin.question.stale.reasonDeleted')
|
||||
: t('admin.question.stale.reasonUpdated'),
|
||||
}) }}
|
||||
</p>
|
||||
<p class="mt-1 text-xs text-amber-700">{{ t('admin.question.stale.bannerHint') }}</p>
|
||||
</div>
|
||||
<ElForm label-position="top" :model="form" @submit.prevent="submitForm">
|
||||
<p class="question-section-label">{{ t('admin.question.sections.basic') }}</p>
|
||||
<div class="question-form">
|
||||
<ElFormItem class="question-form-span" :label="t('admin.question.fields.title')" required>
|
||||
<ElInput v-model="form.title" :placeholder="t('admin.question.fields.titlePlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.question.fields.targetAgent')" required>
|
||||
<ElSelect
|
||||
v-model="form.agent_id"
|
||||
class="question-field-full"
|
||||
:placeholder="t('admin.perm.batchModal.selectAgents')"
|
||||
>
|
||||
<ElOption v-for="agent in agents" :key="agent.id" :label="agent.name" :value="agent.id" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.question.fields.sortOrder')">
|
||||
<ElInputNumber v-model="form.sort_order" class="question-field-full" :min="0" controls-position="right" />
|
||||
</ElFormItem>
|
||||
<ElFormItem class="question-form-span">
|
||||
<ElCheckbox v-model="form.is_enabled">
|
||||
<span class="question-check-label">{{ t('admin.question.fields.isEnabled') }}</span>
|
||||
<span class="hx-element-hint question-check-hint">{{ t('admin.question.fields.isEnabledHelp') }}</span>
|
||||
</ElCheckbox>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="question-form-span">
|
||||
<ElCheckbox v-model="form.cache_enabled">{{ t('admin.question.fields.cacheEnabled') }}</ElCheckbox>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="question-form-span">
|
||||
<ElCheckbox v-model="form.fuzzy_enabled" :disabled="!form.cache_enabled">
|
||||
<span class="question-check-label">{{ t('admin.question.fields.fuzzyEnabled') }}</span>
|
||||
<span class="hx-element-hint question-check-hint">{{ t('admin.question.fields.fuzzyEnabledHelp') }}</span>
|
||||
</ElCheckbox>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="fuzzyAvailable" class="question-form-span" :label="t('admin.question.fields.fuzzyThreshold')">
|
||||
<ElInputNumber
|
||||
v-model="form.fuzzy_threshold"
|
||||
:min="0.5"
|
||||
:max="1"
|
||||
:step="0.05"
|
||||
:precision="2"
|
||||
controls-position="right"
|
||||
/>
|
||||
<p class="hx-element-hint">{{ t('admin.question.fields.fuzzyThresholdHelp') }}</p>
|
||||
</ElFormItem>
|
||||
|
||||
<section class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">
|
||||
{{ t('admin.question.sections.basic') }}
|
||||
</h4>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div class="space-y-1.5 md:col-span-2">
|
||||
<label class="label-field">{{ t('admin.question.fields.title') }}</label>
|
||||
<input
|
||||
v-model="form.title"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.question.fields.titlePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.targetAgent') }}</label>
|
||||
<select v-model="form.agent_id" class="input-field text-sm">
|
||||
<option :value="undefined" disabled>{{ t('admin.perm.batchModal.selectAgents') }}</option>
|
||||
<option v-for="agent in agents" :key="agent.id" :value="agent.id">
|
||||
{{ agent.name }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.sortOrder') }}</label>
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field text-sm" />
|
||||
</div>
|
||||
<div class="md:col-span-2 space-y-3">
|
||||
<label class="flex items-start gap-2 text-sm text-secondary cursor-pointer">
|
||||
<input v-model="form.is_enabled" type="checkbox" class="mt-0.5 accent-brand-600" />
|
||||
<span>
|
||||
<span class="block">{{ t('admin.question.fields.isEnabled') }}</span>
|
||||
<span class="block text-xs text-muted mt-0.5">{{ t('admin.question.fields.isEnabledHelp') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label class="flex items-start gap-2 text-sm text-secondary cursor-pointer">
|
||||
<input v-model="form.cache_enabled" type="checkbox" class="mt-0.5 accent-brand-600" />
|
||||
<span>{{ t('admin.question.fields.cacheEnabled') }}</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">
|
||||
{{ t('admin.question.sections.matching') }}
|
||||
</h4>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.content') }}</label>
|
||||
<textarea
|
||||
<p class="question-section-label question-form-span">{{ t('admin.question.sections.matching') }}</p>
|
||||
<ElFormItem class="question-form-span" :label="t('admin.question.fields.content')" required>
|
||||
<ElInput
|
||||
v-model="form.question"
|
||||
rows="3"
|
||||
class="input-field text-sm resize-y min-h-[88px]"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
:placeholder="t('admin.question.fields.contentPlaceholder')"
|
||||
/>
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.contentHelp') }}</p>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.aliases') }}</label>
|
||||
<textarea
|
||||
<p class="hx-element-hint">{{ t('admin.question.fields.contentHelp') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="question-form-span" :label="t('admin.question.fields.aliases')">
|
||||
<ElInput
|
||||
v-model="form.aliasesText"
|
||||
rows="3"
|
||||
class="input-field text-sm resize-y min-h-[88px] font-mono"
|
||||
class="question-aliases"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
:placeholder="t('admin.question.fields.aliasesPlaceholder')"
|
||||
/>
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.aliasesHelp') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<p class="hx-element-hint">{{ t('admin.question.fields.aliasesHelp') }}</p>
|
||||
</ElFormItem>
|
||||
|
||||
<section class="space-y-4 rounded-2xl border border-default bg-surface-soft/60 p-4">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h4 class="text-xs font-bold uppercase tracking-wider text-muted">
|
||||
{{ t('admin.question.sections.cache') }}
|
||||
</h4>
|
||||
<p class="text-xs text-muted mt-1">{{ t('admin.question.fields.cacheHelp') }}</p>
|
||||
</div>
|
||||
<span
|
||||
class="inline-flex shrink-0 items-center rounded-full px-2.5 py-0.5 text-xs font-medium"
|
||||
:class="form.cache_enabled ? 'bg-emerald-50 text-emerald-700 border border-emerald-100' : 'bg-surface-soft text-muted border border-default'"
|
||||
>
|
||||
<div class="question-form-span question-section-head">
|
||||
<p class="question-section-label">{{ t('admin.question.sections.cache') }}</p>
|
||||
<ElTag :type="form.cache_enabled ? 'success' : 'info'" effect="light">
|
||||
{{ form.cache_enabled ? t('admin.question.badges.cacheOn') : t('admin.question.badges.cacheOff') }}
|
||||
</span>
|
||||
</ElTag>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">
|
||||
{{ t('admin.question.fields.answer') }}
|
||||
<span v-if="answerRequired" class="text-red-500">*</span>
|
||||
</label>
|
||||
<textarea
|
||||
<p class="hx-element-hint question-form-span">{{ t('admin.question.fields.cacheHelp') }}</p>
|
||||
<ElFormItem class="question-form-span" :label="t('admin.question.fields.answer')" :required="answerRequired">
|
||||
<ElInput
|
||||
v-model="form.answer"
|
||||
rows="6"
|
||||
class="input-field text-sm resize-y min-h-[140px]"
|
||||
type="textarea"
|
||||
:rows="6"
|
||||
:placeholder="t('admin.question.fields.answerPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.question.fields.expiresAt') }}</label>
|
||||
<input v-model="form.expires_at" type="datetime-local" class="input-field text-sm" />
|
||||
<p class="text-xs text-muted">{{ t('admin.question.fields.expiresAtHelp') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button
|
||||
v-if="isStale"
|
||||
type="button"
|
||||
class="btn-primary disabled:opacity-70"
|
||||
:disabled="isSaving"
|
||||
@click="emit('review')"
|
||||
>
|
||||
{{
|
||||
isSaving
|
||||
? t('admin.save') + '...'
|
||||
: t('admin.question.stale.completeReview')
|
||||
}}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="btn-primary disabled:opacity-70"
|
||||
:disabled="isSaving"
|
||||
@click="emit('save')"
|
||||
>
|
||||
{{
|
||||
isSaving
|
||||
? t('admin.save') + '...'
|
||||
: form.id
|
||||
? t('admin.update')
|
||||
: t('admin.add')
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="question-form-span" :label="t('admin.question.fields.expiresAt')">
|
||||
<ElDatePicker
|
||||
:model-value="form.expires_at || undefined"
|
||||
class="question-field-full"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
clearable
|
||||
:placeholder="t('admin.question.fields.expiresAt')"
|
||||
@update:model-value="onExpiresChange"
|
||||
/>
|
||||
<p class="hx-element-hint">{{ t('admin.question.fields.expiresAtHelp') }}</p>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</ElForm>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton v-if="isStale" type="primary" :loading="isSaving" @click="emit('review')">
|
||||
{{ t('admin.question.stale.completeReview') }}
|
||||
</ElButton>
|
||||
<ElButton v-else type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ form.id ? t('admin.update') : t('admin.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.question-dialog-body {
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.question-stale {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.question-form {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
column-gap: 16px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.question-form :deep(.el-form-item) {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.question-form-span {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.question-section-label {
|
||||
margin: 8px 0 0;
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.question-section-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.question-check-label,
|
||||
.question-check-hint {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.question-form :deep(.question-field-full) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.question-aliases :deep(.el-textarea__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.question-form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/questions/composables/useQuestionsAdmin.ts
|
||||
* 常用问题 / FAQ 缓存管理:列表筛选、创建/编辑弹窗、删除。
|
||||
* 依赖:admin.api、question.types、useMessage。
|
||||
* 逻辑:QuestionsPage 调用本 composable 驱动表格与居中表单弹窗。
|
||||
* 用途:常用问题 / FAQ 缓存管理:列表筛选、创建/编辑弹窗、删除。
|
||||
* 依赖:admin.api、question.types、useMessage、element-plus 的确认框。
|
||||
* 逻辑:QuestionsPage 调用本 composable 驱动表格与表单弹窗。删除用 ElMessageBox,不再使用 DeleteConfirmDialog。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
deleteAdminQuickQuestion,
|
||||
listAdminAgents,
|
||||
@@ -40,10 +41,6 @@ export function useQuestionsAdmin() {
|
||||
const filterStaleOnly = ref(false);
|
||||
const searchKeyword = ref('');
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
const staleCount = computed(() => questions.value.filter((q) => Boolean(q.stale_at)).length);
|
||||
|
||||
const filteredQuestions = computed(() => {
|
||||
@@ -85,26 +82,6 @@ export function useQuestionsAdmin() {
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 重置表单为空白状态。
|
||||
*/
|
||||
@@ -131,6 +108,8 @@ export function useQuestionsAdmin() {
|
||||
aliasesText: aliasesToText(q.aliases),
|
||||
cache_enabled: q.cache_enabled,
|
||||
is_enabled: q.is_enabled,
|
||||
fuzzy_enabled: Boolean(q.fuzzy_enabled),
|
||||
fuzzy_threshold: typeof q.fuzzy_threshold === 'number' ? q.fuzzy_threshold : 0.8,
|
||||
agent_id: q.agent_id,
|
||||
sort_order: q.sort_order,
|
||||
expires_at: q.expires_at ? q.expires_at.slice(0, 16) : '',
|
||||
@@ -225,16 +204,28 @@ export function useQuestionsAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
const deleteQuestion = (id: number): void => {
|
||||
openDeleteConfirm(t('admin.question.confirmDelete'), async () => {
|
||||
try {
|
||||
await deleteAdminQuickQuestion(id);
|
||||
await loadQuestions();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 删除指定常用问题。先用 Element 确认框询问,取消则不请求。
|
||||
* 核心逻辑:MessageBox 在取消时 reject,这里吞掉;确定后再调删除接口并刷新列表。
|
||||
* @param id - 常用问题主键
|
||||
*/
|
||||
const deleteQuestion = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.question.confirmDelete'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteAdminQuickQuestion(id);
|
||||
await loadQuestions();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -245,8 +236,6 @@ export function useQuestionsAdmin() {
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
filterAgentId,
|
||||
filterCacheOnly,
|
||||
filterStaleOnly,
|
||||
@@ -259,8 +248,6 @@ export function useQuestionsAdmin() {
|
||||
saveQuestion,
|
||||
saveReviewQuestion,
|
||||
deleteQuestion,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
truncateQuestionPreview,
|
||||
truncateAnswerPreview,
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/admin/modules/reports/composables/useReportsAdmin.ts
|
||||
* 用途:管理后台报表(多表浏览、筛选、排序、chat_logs 批量删除、使用分析与应用运营看板)。
|
||||
* 依赖:admin.api、useReportLayoutStorage、useOffsetPagination、useMessage、dateTime、vue-router。
|
||||
* 逻辑:ReportsPage 调用本 composable;使用分析按用户服务端分页、按应用前端分页,均复用 PaginationBar;
|
||||
* 依赖:admin.api、useReportLayoutStorage、useOffsetPagination、useMessage、dateTime、vue-router、element-plus(ElMessageBox)。
|
||||
* 逻辑:ReportsPage 调用本 composable;使用分析按用户服务端分页、按应用前端分页,页码状态交给页面的 ElPagination;
|
||||
* 低使用应用优先消费后端 low_agents(含零使用启用应用),与应用运营口径对齐;
|
||||
* 统计范围统一为开始/结束日期(默认近 30 天),经 start_date/end_date 传给后端,聊天日志走 created_from/created_to;
|
||||
* 趋势 by_day 前端按日期升序兜底;问题分析优先问题表前端分页;非表页切换时清空通用表状态防幽灵分页。
|
||||
@@ -10,6 +10,7 @@
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import * as XLSX from 'xlsx';
|
||||
import {
|
||||
batchDeleteAdminChatLogs,
|
||||
@@ -655,30 +656,6 @@ export function useReportsAdmin() {
|
||||
};
|
||||
const isLoading = ref(true);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
}
|
||||
};
|
||||
|
||||
const resolveTableFromRoute = (): AdminReportTableId => {
|
||||
const table = route.params.table;
|
||||
if (typeof table === 'string' && (ADMIN_REPORT_TABLES as readonly string[]).includes(table)) {
|
||||
@@ -1575,25 +1552,41 @@ const toggleAllReportRows = () => {
|
||||
selectedReportRowIds.value = Array.from(merged);
|
||||
};
|
||||
|
||||
const batchDeleteChatLogs = async () => {
|
||||
/**
|
||||
* 批量删除已勾选的聊天日志。
|
||||
* 核心逻辑:先弹出 Element 确认框;取消则直接返回。确认后按当前选中 id 调用原批量删除接口并刷新列表与总数。
|
||||
* @returns 无。取消确认时不请求接口。
|
||||
*/
|
||||
const batchDeleteChatLogs = async (): Promise<void> => {
|
||||
if (!isChatLogsTable.value) return;
|
||||
if (selectedReportRowIds.value.length === 0) return;
|
||||
const targetRowIds = [...selectedReportRowIds.value];
|
||||
openDeleteConfirm(`Delete ${targetRowIds.length} selected chat logs?`, async () => {
|
||||
isDeletingChatLogs.value = true;
|
||||
try {
|
||||
const data = await batchDeleteAdminChatLogs(targetRowIds);
|
||||
msg.success(`Deleted ${data.deleted_count ?? 0} chat logs.`);
|
||||
selectedReportRowIds.value = [];
|
||||
await loadTableData();
|
||||
chatLogsTotal.value = await loadTableCount('chat_logs');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
||||
} finally {
|
||||
isDeletingChatLogs.value = false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.report.deleteSelected', { count: targetRowIds.length }),
|
||||
t('common.deleteDialog.defaultTitle'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
isDeletingChatLogs.value = true;
|
||||
try {
|
||||
const data = await batchDeleteAdminChatLogs(targetRowIds);
|
||||
msg.success(`Deleted ${data.deleted_count ?? 0} chat logs.`);
|
||||
selectedReportRowIds.value = [];
|
||||
await loadTableData();
|
||||
chatLogsTotal.value = await loadTableCount('chat_logs');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
||||
} finally {
|
||||
isDeletingChatLogs.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(currentTable, async () => {
|
||||
@@ -1913,8 +1906,6 @@ watch([reportPageSize, issueQuestionTotal], () => {
|
||||
reportRangeStart,
|
||||
reportRangeEnd,
|
||||
reportPageButtons,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
handleFilterChange,
|
||||
resetChatLogsColumns,
|
||||
@@ -1941,6 +1932,5 @@ watch([reportPageSize, issueQuestionTotal], () => {
|
||||
goToReportPage,
|
||||
prevReportPage,
|
||||
nextReportPage,
|
||||
confirmDelete,
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,20 @@
|
||||
/**
|
||||
* 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;概览/工作台切换。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted, provide, reactive } from 'vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
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';
|
||||
@@ -18,6 +25,7 @@ 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 +33,10 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="section-gap animate-fade-in-up">
|
||||
<SchedulePageHeader />
|
||||
<ScheduleOverviewPanel v-if="admin.scheduleViewMode === 'overview'" />
|
||||
<ScheduleWorkbenchPanel v-else />
|
||||
</section>
|
||||
<SchedulesPageOverlays />
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<SchedulePageHeader />
|
||||
<ScheduleOverviewPanel v-if="admin.scheduleViewMode === 'overview'" />
|
||||
<ScheduleWorkbenchPanel v-else />
|
||||
</section>
|
||||
<SchedulesPageOverlays />
|
||||
</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>
|
||||
Loaded 100 of 986 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user