fix(admin): 管理控制台全面替换为element plus
This commit is contained in:
1 parent
b69c725992
commit
627da80e65
72 files changed
+12370
-8437
No files matched your search
@@ -1,27 +1,32 @@
|
||||
/**
|
||||
* features/admin/modules/approvals/ApprovalsPage.vue
|
||||
* 用户注册审批独立页面。路由:/admin/approvals
|
||||
* 用途:用户注册审批列表。一张卡片里放标题和待审表格。
|
||||
* 依赖:AdminListPage、useApprovalsAdmin、useElementProvider、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, ElConfigProvider, 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 { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { adminRoleLabel } from '@/features/admin/utils/roleLabel';
|
||||
import type { AdminUserRow } from '@/features/admin/types/admin.types';
|
||||
import { useApprovalsAdmin } from './composables/useApprovalsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
|
||||
const {
|
||||
pendingUsers,
|
||||
isLoading,
|
||||
showConfirmDialog,
|
||||
confirmMessage,
|
||||
loadAll,
|
||||
approveUser,
|
||||
rejectUser,
|
||||
closeConfirm,
|
||||
confirmActionHandler,
|
||||
} = useApprovalsAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
@@ -30,80 +35,60 @@ 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>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<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>
|
||||
</ElConfigProvider>
|
||||
</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,16 +1,15 @@
|
||||
/**
|
||||
* features/admin/modules/departments/DepartmentsPage.vue
|
||||
* 用途:部门管理列表。一张卡片里放标题、添加按钮、搜索、表格。
|
||||
* 依赖:AdminListPage、useDepartmentsAdmin、useElementProvider、element-plus、lucide-vue-next、部门表单和员工名单弹窗。
|
||||
* 依赖:AdminListPage、useDepartmentsAdmin、useElementProvider、element-plus、部门表单和员工名单弹窗。
|
||||
* 逻辑:路由 /admin/departments。骨架用 AdminListPage。筛选、列和两个弹窗留在本页。
|
||||
* 名称、编码、公司用表头排序,排的是当前过滤结果。删除用 Element 确认框。
|
||||
* 表格用 Element stripe 斑马纹。员工、编辑、删除保持图标按钮,悬停文案走 i18n title。
|
||||
* 表格用 Element stripe 斑马纹。员工数、编辑、删除用 Element 链接按钮,悬停文案走 i18n title。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import { Edit, Trash2, Users } from 'lucide-vue-next';
|
||||
import { Delete, Edit, Plus, User } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
@@ -157,36 +156,34 @@ onMounted(() => {
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.dept.headers.members')" width="120" align="center">
|
||||
<template #default="{ row }">
|
||||
<button
|
||||
type="button"
|
||||
class="dept-member-btn"
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:icon="User"
|
||||
:title="t('admin.dept.actions.viewMembers')"
|
||||
@click="openDepartmentMembers((row as AdminDepartmentRow).id)"
|
||||
>
|
||||
<Users class="dept-member-icon" />
|
||||
<span>{{ row.member_count || 0 }}</span>
|
||||
</button>
|
||||
{{ 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">
|
||||
<button
|
||||
type="button"
|
||||
class="dept-icon-btn dept-icon-btn--edit"
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:icon="Edit"
|
||||
:title="t('admin.dept.actions.edit')"
|
||||
@click="editDepartment(row as AdminDepartmentRow)"
|
||||
>
|
||||
<Edit class="dept-action-icon" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="dept-icon-btn dept-icon-btn--delete"
|
||||
/>
|
||||
<ElButton
|
||||
link
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
:title="t('admin.dept.actions.delete')"
|
||||
@click="deleteDepartment((row as AdminDepartmentRow).id)"
|
||||
>
|
||||
<Trash2 class="dept-action-icon" />
|
||||
</button>
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
@@ -219,69 +216,9 @@ onMounted(() => {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dept-member-btn,
|
||||
.dept-icon-btn {
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.dept-member-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 8px;
|
||||
border-radius: 8px;
|
||||
background: #eff6ff;
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
.dept-member-btn:hover {
|
||||
background: #dbeafe;
|
||||
}
|
||||
|
||||
.dept-member-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.dept-member-btn span {
|
||||
margin-left: 4px;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.dept-row-actions {
|
||||
display: inline-flex;
|
||||
justify-content: flex-end;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.dept-icon-btn {
|
||||
padding: 6px;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
transition: background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.dept-action-icon {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.dept-icon-btn--edit {
|
||||
color: #4f46e5;
|
||||
}
|
||||
|
||||
.dept-icon-btn--edit:hover {
|
||||
background: #eef2ff;
|
||||
}
|
||||
|
||||
.dept-icon-btn--delete {
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
.dept-icon-btn--delete:hover {
|
||||
background: #fef2f2;
|
||||
}
|
||||
</style>
|
||||
+24
-10
@@ -7,8 +7,9 @@
|
||||
* 逻辑:mock 列表固定返回 2 行(同 operation_id 两步),详情按用例切换 soap /
|
||||
* database / 无 wire 三种 wire_json 形态,断言渲染与复制链路。
|
||||
*/
|
||||
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils';
|
||||
import { DOMWrapper, enableAutoUnmount, flushPromises, mount } from '@vue/test-utils';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { ElOption, ElSelect, ElTag } from 'element-plus';
|
||||
import i18n from '@/i18n';
|
||||
import IntegrationCallLogsPanel from './components/IntegrationCallLogsPanel.vue';
|
||||
import { getIntegrationCall, listIntegrationCalls } from './api/integration-connector.api';
|
||||
@@ -73,7 +74,19 @@ const databaseDetail = makeDetail({ id: 260, status: 'success', elapsed_ms: 2366
|
||||
const noWireDetail = makeDetail({}, null);
|
||||
|
||||
function mountPanel() {
|
||||
return mount(IntegrationCallLogsPanel, { global: { plugins: [i18n] } });
|
||||
return mount(IntegrationCallLogsPanel, {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 从行内 testid 回到所在的表格行,状态标签在同一行的另一列。
|
||||
* @param cell - 带 data-testid="call-row" 的单元格内容
|
||||
*/
|
||||
function tableRowOf(cell: DOMWrapper<Element>) {
|
||||
const tr = cell.element.closest('tr');
|
||||
expect(tr).toBeTruthy();
|
||||
return new DOMWrapper(tr as HTMLElement);
|
||||
}
|
||||
|
||||
enableAutoUnmount(afterEach);
|
||||
@@ -194,19 +207,20 @@ 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 !== '');
|
||||
const statusSelect = wrapper.findAllComponents(ElSelect).find((item) => item.attributes('data-testid') === 'call-filter-status');
|
||||
expect(statusSelect).toBeTruthy();
|
||||
const options = statusSelect!.findAllComponents(ElOption).map((item) => item.props('value'));
|
||||
expect(options).toEqual([
|
||||
'success', 'duplicate_success', 'duplicate_unverified',
|
||||
'business_failed', 'technical_failed', 'timeout', 'result_unknown',
|
||||
]);
|
||||
// [断言意图] 成功族判定:duplicate_success(幂等重放命中,业务已成功)徽章走绿色成功侧
|
||||
const dupOkRow = wrapper.findAll('[data-testid="call-row"]')[0];
|
||||
// [断言意图] 成功族判定:duplicate_success(幂等重放命中,业务已成功)标签走 success
|
||||
const dupOkRow = tableRowOf(wrapper.findAll('[data-testid="call-row"]')[0]);
|
||||
expect(dupOkRow.text()).toContain('duplicate_success');
|
||||
expect(dupOkRow.find('span.bg-green-100').exists()).toBe(true);
|
||||
// [断言意图] duplicate_unverified(回执未核实)保守归非成功态,徽章保持红色 ✗
|
||||
const dupUnknownRow = wrapper.findAll('[data-testid="call-row"]')[1];
|
||||
expect(dupOkRow.findComponent(ElTag).props('type')).toBe('success');
|
||||
// [断言意图] duplicate_unverified(回执未核实)保守归非成功态,标签保持 danger
|
||||
const dupUnknownRow = tableRowOf(wrapper.findAll('[data-testid="call-row"]')[1]);
|
||||
expect(dupUnknownRow.text()).toContain('duplicate_unverified');
|
||||
expect(dupUnknownRow.find('span.bg-red-100').exists()).toBe(true);
|
||||
expect(dupUnknownRow.findComponent(ElTag).props('type')).toBe('danger');
|
||||
});
|
||||
});
|
||||
+515
-300
@@ -1,22 +1,42 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/components/IntegrationCallLogsPanel.vue
|
||||
用途:集成调用日志面板——筛选条 + 分页列表 + 行点击详情抽屉(能力无关通用口径)。
|
||||
依赖:../api/integration-connector.api(listIntegrationCalls / getIntegrationCall)、
|
||||
依赖:element-plus 表单/表格/分页/抽屉、../api/integration-connector.api(listIntegrationCalls / getIntegrationCall)、
|
||||
../utils/integration-call-replay(buildCurl / buildSqlReplay)、
|
||||
useMessage、copyTextToClipboard、formatLocalDateTime、useI18n。
|
||||
本组件有独立单测,入口引一次 Element 样式。
|
||||
逻辑:筛选(接口编码/客户端编码/连接类型/状态/operation_id/trace_id/业务单号/
|
||||
参数关键字/执行时间起止)回车或点「查询」生效(查询回第一页),「重置」清空;
|
||||
列表按 id 倒序分页,行点击拉取全量详情开右侧抽屉;抽屉含步骤时间线
|
||||
(同 operation_id 各步、当前步高亮)、线级请求与业务参数双栏、原始报文与
|
||||
归一化 JSON 双栏;复制按钮组按连接类型分流:soap/rest=复制 body / 复制 curl,
|
||||
database=复制 SQL(绑定已内联、写入类自动包事务并红字警示),
|
||||
database=复制 SQL(绑定已内联、写入类自动包事务并警示),
|
||||
另有复制原始报文 / 复制 JSON / 复制 operation_id / 复制 trace_id;
|
||||
wire_json 为 NULL(历史存量行)时如实显示「无线级详情(历史记录)」,不回填。
|
||||
空筛选下拉传 undefined,清空写回空串。查询参数字段名不改。
|
||||
列表表格传 default-sort 且 prop 为空,避免表头挂载时解构 undefined。详情抽屉留在组件树内。
|
||||
-->
|
||||
<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 {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElDrawer,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
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 { useMessage } from '@/shared/composables/useMessage';
|
||||
import { copyTextToClipboard } from '@/shared/utils/clipboard';
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
@@ -30,6 +50,8 @@ import {
|
||||
} from '../types/integration-connector.types';
|
||||
import { buildCurl, buildSqlReplay } from '../utils/integration-call-replay';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
/**
|
||||
* 调用状态固定枚举(与后端 RESULT_STATUSES 七值对齐,含幂等重放的
|
||||
* duplicate_success / duplicate_unverified 审计行;下拉直接用原始值,未注册翻译兜底)。
|
||||
@@ -39,6 +61,9 @@ const CALL_STATUS_OPTIONS = [
|
||||
'technical_failed', 'timeout', 'result_unknown',
|
||||
] as const;
|
||||
|
||||
/** 可选下拉的空态占位,不作为选项值。 */
|
||||
const EMPTY_PLACEHOLDER = '—';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { error: notifyError, success: notifySuccess } = useMessage();
|
||||
|
||||
@@ -46,12 +71,10 @@ const filters = ref<IntegrationCallFilters>({});
|
||||
const items = ref<IntegrationCallLogRow[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = 20;
|
||||
const pageSize = ref(20);
|
||||
const loading = ref(false);
|
||||
const detail = ref<IntegrationCallDetail | null>(null);
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize)));
|
||||
|
||||
/** 当前详情的线级事实(null = 历史存量行或未捕获场景,抽屉如实显示「无线级详情」)。 */
|
||||
const wire = computed<IntegrationCallWire | null>(() => detail.value?.call.wire_json ?? null);
|
||||
|
||||
@@ -70,7 +93,7 @@ const sqlReplayText = computed(() =>
|
||||
wire.value && wire.value.kind === 'database' ? buildSqlReplay(wire.value) : '',
|
||||
);
|
||||
|
||||
/** database 写入类语句红字警示显隐(防复现时误写目标库)。 */
|
||||
/** database 写入类语句警示显隐(防复现时误写目标库)。 */
|
||||
const hasWriteStatement = computed(() =>
|
||||
(wire.value?.statements ?? []).some((s) => /^\s*(INSERT|UPDATE|DELETE|MERGE)/im.test(s.sql)),
|
||||
);
|
||||
@@ -90,11 +113,40 @@ const rawResponseText = computed(() => {
|
||||
return `HTTP ${w.http_status ?? '-'}\n${w.response_body ?? ''}`;
|
||||
});
|
||||
|
||||
/**
|
||||
* 文本筛选项写回。空串保留,与原先输入框清空后的查询参数一致。
|
||||
* @param key - 筛选字段名
|
||||
* @param value - 输入框文本
|
||||
*/
|
||||
function onFilterText(key: 'interface_code' | 'client_code' | 'operation_id' | 'trace_id' | 'business_ref' | 'keyword' | 'date_from' | 'date_to', value: string) {
|
||||
filters.value[key] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉筛选项写回。清空时写回空串,避免 ElSelect 把空串当成未注册选项。
|
||||
* 回传值和当前值相同时不赋值,避免空串与 undefined 来回触发更新。
|
||||
* @param key - connector_type 或 status
|
||||
* @param value - 选中值;清空不是字符串
|
||||
*/
|
||||
function onFilterSelect(key: 'connector_type' | 'status', value: unknown) {
|
||||
const next = typeof value === 'string' ? value : '';
|
||||
if ((filters.value[key] ?? '') === next) return;
|
||||
filters.value[key] = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* ElSelect 空字符串会落到默认「请选择」。未选时传 undefined。
|
||||
* @param value - 当前筛选值
|
||||
*/
|
||||
function filterSelectValue(value: string | undefined): string | undefined {
|
||||
return value ? value : undefined;
|
||||
}
|
||||
|
||||
/** 拉取列表(当前筛选 + 当前页);失败经全局错误弹窗提示。 */
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await listIntegrationCalls({ ...filters.value, page: page.value, page_size: pageSize });
|
||||
const data = await listIntegrationCalls({ ...filters.value, page: page.value, page_size: pageSize.value });
|
||||
items.value = data.items;
|
||||
total.value = data.total;
|
||||
} catch (e) {
|
||||
@@ -116,21 +168,29 @@ function resetFilters() {
|
||||
query();
|
||||
}
|
||||
|
||||
function goPrev() {
|
||||
if (page.value > 1) {
|
||||
page.value -= 1;
|
||||
void load();
|
||||
}
|
||||
/**
|
||||
* 翻页。页码由分页条回传,page_size 保持当前值。
|
||||
* @param next - 目标页,从 1 开始
|
||||
*/
|
||||
function onPageChange(next: number) {
|
||||
page.value = next;
|
||||
void load();
|
||||
}
|
||||
|
||||
function goNext() {
|
||||
if (page.value < totalPages.value) {
|
||||
page.value += 1;
|
||||
void load();
|
||||
}
|
||||
/**
|
||||
* 改每页条数后回到第一页再拉列表。
|
||||
* @param next - 新的 page_size
|
||||
*/
|
||||
function onSizeChange(next: number) {
|
||||
pageSize.value = next;
|
||||
page.value = 1;
|
||||
void load();
|
||||
}
|
||||
|
||||
/** 点列表行拉全量详情(含 wire_json 与同 operation_id 时间线)并开抽屉。 */
|
||||
/**
|
||||
* 点列表行拉全量详情(含 wire_json 与同 operation_id 时间线)并开抽屉。
|
||||
* @param row - 表格行;插槽里先收成调用日志行再传入
|
||||
*/
|
||||
async function openDetail(row: IntegrationCallLogRow) {
|
||||
try {
|
||||
detail.value = await getIntegrationCall(row.id);
|
||||
@@ -139,13 +199,20 @@ async function openDetail(row: IntegrationCallLogRow) {
|
||||
}
|
||||
}
|
||||
|
||||
function closeDetail() {
|
||||
detail.value = null;
|
||||
/**
|
||||
* 表格行点击。Element 行对象在插槽外先收成业务类型。
|
||||
* @param row - ElTable 回传的行
|
||||
*/
|
||||
function onCallRowClick(row: unknown) {
|
||||
void openDetail(row as IntegrationCallLogRow);
|
||||
}
|
||||
|
||||
/** 抽屉打开时 Esc 关闭(与表单抽屉行为一致)。 */
|
||||
function onEscKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape' && detail.value) closeDetail();
|
||||
/**
|
||||
* 详情抽屉关闭。Element 在关闭动画结束后把 model 置 false。
|
||||
* @param open - 抽屉是否仍打开
|
||||
*/
|
||||
function onDetailVisible(open: boolean) {
|
||||
if (!open) detail.value = null;
|
||||
}
|
||||
|
||||
/** 复制文本到剪贴板(带降级方案),成功后弹「已复制」提示。 */
|
||||
@@ -162,9 +229,9 @@ 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';
|
||||
/** 状态标签配色:成功 success,其余 danger。 */
|
||||
function statusTagType(status: string): 'success' | 'danger' {
|
||||
return isSuccess(status) ? 'success' : 'danger';
|
||||
}
|
||||
|
||||
/** 状态图标:✓ 成功 / ✗ 失败。 */
|
||||
@@ -205,289 +272,437 @@ 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">
|
||||
<div class="call-logs">
|
||||
<ElForm class="call-filters" label-position="top" @submit.prevent @keyup.enter="query">
|
||||
<ElFormItem class="call-filter call-filter--wide" :label="t('admin.integrationConnector.callLogs.filterInterface')">
|
||||
<ElInput
|
||||
:model-value="filters.interface_code ?? ''"
|
||||
data-testid="call-filter-interface"
|
||||
@update:model-value="onFilterText('interface_code', $event)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter call-filter--wide" :label="t('admin.integrationConnector.callLogs.filterClient')">
|
||||
<ElInput
|
||||
:model-value="filters.client_code ?? ''"
|
||||
data-testid="call-filter-client"
|
||||
@update:model-value="onFilterText('client_code', $event)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter" :label="t('admin.integrationConnector.callLogs.filterConnector')">
|
||||
<ElSelect
|
||||
:model-value="filterSelectValue(filters.connector_type)"
|
||||
clearable
|
||||
:placeholder="EMPTY_PLACEHOLDER"
|
||||
data-testid="call-filter-connector"
|
||||
@update:model-value="onFilterSelect('connector_type', $event)"
|
||||
>
|
||||
<ElOption v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :label="t(opt.labelKey)" :value="opt.value" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter" :label="t('admin.integrationConnector.callLogs.filterStatus')">
|
||||
<ElSelect
|
||||
:model-value="filterSelectValue(filters.status)"
|
||||
clearable
|
||||
:placeholder="EMPTY_PLACEHOLDER"
|
||||
data-testid="call-filter-status"
|
||||
@update:model-value="onFilterSelect('status', $event)"
|
||||
>
|
||||
<ElOption v-for="s in CALL_STATUS_OPTIONS" :key="s" :label="s" :value="s" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter call-filter--wide" :label="t('admin.integrationConnector.callLogs.filterOperationId')">
|
||||
<ElInput
|
||||
:model-value="filters.operation_id ?? ''"
|
||||
data-testid="call-filter-operation-id"
|
||||
@update:model-value="onFilterText('operation_id', $event)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter call-filter--wide" :label="t('admin.integrationConnector.callLogs.filterTraceId')">
|
||||
<ElInput
|
||||
:model-value="filters.trace_id ?? ''"
|
||||
data-testid="call-filter-trace-id"
|
||||
@update:model-value="onFilterText('trace_id', $event)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter call-filter--wide" :label="t('admin.integrationConnector.callLogs.filterBusinessRef')">
|
||||
<ElInput
|
||||
:model-value="filters.business_ref ?? ''"
|
||||
data-testid="call-filter-business-ref"
|
||||
@update:model-value="onFilterText('business_ref', $event)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter call-filter--wide" :label="t('admin.integrationConnector.callLogs.filterKeyword')">
|
||||
<ElInput
|
||||
:model-value="filters.keyword ?? ''"
|
||||
data-testid="call-filter-keyword"
|
||||
@update:model-value="onFilterText('keyword', $event)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter" :label="t('admin.integrationConnector.callLogs.dateFrom')">
|
||||
<ElInput
|
||||
:model-value="filters.date_from ?? ''"
|
||||
type="date"
|
||||
data-testid="call-filter-date-from"
|
||||
@update:model-value="onFilterText('date_from', $event)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="call-filter" :label="t('admin.integrationConnector.callLogs.dateTo')">
|
||||
<ElInput
|
||||
:model-value="filters.date_to ?? ''"
|
||||
type="date"
|
||||
data-testid="call-filter-date-to"
|
||||
@update:model-value="onFilterText('date_to', $event)"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<div class="call-filter-actions">
|
||||
<ElButton type="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">
|
||||
</ElButton>
|
||||
<ElButton data-testid="call-filter-reset" @click="resetFilters">
|
||||
{{ t('admin.integrationConnector.callLogs.reset') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</ElForm>
|
||||
|
||||
<!-- 调用记录列表(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>
|
||||
<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"
|
||||
: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"
|
||||
: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"
|
||||
data-testid="call-detail-drawer"
|
||||
@click.self="closeDetail"
|
||||
<!-- default-sort 的 prop 留空:表头挂载会解构该字段,缺省 undefined 会抛错。空 prop 不会对任何列排序。 -->
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="hx-admin-table"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
:default-sort="{ prop: '', order: 'ascending' }"
|
||||
:empty-text="t('admin.integrationConnector.empty')"
|
||||
@row-click="onCallRowClick"
|
||||
>
|
||||
<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>
|
||||
</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>
|
||||
</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>
|
||||
</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)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyOperationId') }}
|
||||
</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)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyTraceId') }}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<ElTableColumn label="#" width="80">
|
||||
<template #default="{ row }">
|
||||
<span data-testid="call-row">{{ (row as IntegrationCallLogRow).id }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.callLogs.colTime')" min-width="160">
|
||||
<template #default="{ row }">{{ formatLocalDateTime((row as IntegrationCallLogRow).created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.callLogs.colCapability')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="call-ellipsis" :title="(row as IntegrationCallLogRow).capability">{{ (row as IntegrationCallLogRow).capability }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.callLogs.colInterface')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span class="call-ellipsis" :title="(row as IntegrationCallLogRow).interface_code || ''">
|
||||
{{ (row as IntegrationCallLogRow).interface_code || '—' }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.callLogs.colRef')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span :title="(row as IntegrationCallLogRow).business_ref || (row as IntegrationCallLogRow).operation_id">
|
||||
{{ refTextOf(row as IntegrationCallLogRow) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.callLogs.colStep')" width="90">
|
||||
<template #default="{ row }">{{ stepText(row as IntegrationCallLogRow) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.callLogs.colStatus')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="statusTagType((row as IntegrationCallLogRow).status)" effect="light">
|
||||
{{ statusIcon((row as IntegrationCallLogRow).status) }} {{ (row as IntegrationCallLogRow).status }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.integrationConnector.callLogs.colElapsed')" width="110" align="right">
|
||||
<template #default="{ row }">{{ (row as IntegrationCallLogRow).elapsed_ms }}ms</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<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>
|
||||
|
||||
<!-- 请求:线级请求(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>
|
||||
</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>
|
||||
</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>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</aside>
|
||||
<div class="hx-admin-pager">
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:current-page="page"
|
||||
:page-sizes="[20, 50, 100]"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ElDrawer
|
||||
:model-value="detail != null"
|
||||
:title="detail ? `${t('admin.integrationConnector.callLogs.detailTitle')} #${detail.call.id}` : ''"
|
||||
direction="rtl"
|
||||
size="896px"
|
||||
data-testid="call-detail-drawer"
|
||||
@update:model-value="onDetailVisible"
|
||||
>
|
||||
<template v-if="detail">
|
||||
<div class="call-meta">
|
||||
<span>{{ t('admin.integrationConnector.callLogs.colCapability') }}: {{ detail.call.capability }}</span>
|
||||
<span>
|
||||
{{ t('admin.integrationConnector.callLogs.colStatus') }}:
|
||||
<ElTag :type="statusTagType(detail.call.status)" effect="light">
|
||||
{{ statusIcon(detail.call.status) }} {{ detail.call.status }}
|
||||
</ElTag>
|
||||
</span>
|
||||
<span>{{ t('admin.integrationConnector.callLogs.colElapsed') }}: {{ detail.call.elapsed_ms }}ms</span>
|
||||
<span v-if="detail.call.business_ref">
|
||||
{{ t('admin.integrationConnector.callLogs.filterBusinessRef') }}: {{ detail.call.business_ref }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="call-meta">
|
||||
<span class="call-id">
|
||||
<span>operation:</span>
|
||||
<span :title="detail.call.operation_id">{{ detail.call.operation_id }}</span>
|
||||
<ElButton link type="primary" data-testid="call-copy-operation-id" @click="copy(detail.call.operation_id)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyOperationId') }}
|
||||
</ElButton>
|
||||
</span>
|
||||
<span class="call-id">
|
||||
<span>trace:</span>
|
||||
<span :title="detail.call.trace_id">{{ detail.call.trace_id }}</span>
|
||||
<ElButton link type="primary" data-testid="call-copy-trace-id" @click="copy(detail.call.trace_id)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyTraceId') }}
|
||||
</ElButton>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<section class="call-block">
|
||||
<h4 class="call-block__title">{{ t('admin.integrationConnector.callLogs.timeline') }}</h4>
|
||||
<div class="call-timeline">
|
||||
<template v-for="(entry, idx) in detail.timeline" :key="entry.id">
|
||||
<div class="call-step" :class="{ 'is-current': isCurrentStep(entry) }">
|
||||
<span>{{ stepLabel(entry, idx) }}</span>
|
||||
<span>{{ entry.interface_code || '—' }}</span>
|
||||
<ElTag :type="statusTagType(entry.status)" effect="light">
|
||||
{{ statusIcon(entry.status) }} {{ entry.status }}
|
||||
</ElTag>
|
||||
<span>{{ entry.elapsed_ms }}ms</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="call-block">
|
||||
<h4 class="call-block__title">{{ t('admin.integrationConnector.callLogs.request') }}</h4>
|
||||
<div class="call-split">
|
||||
<div class="call-pane">
|
||||
<h5 class="call-pane__title">{{ t('admin.integrationConnector.callLogs.wire') }}</h5>
|
||||
<template v-if="wire">
|
||||
<template v-if="wire.kind !== 'database'">
|
||||
<pre class="call-pre">{{ wireMetaText }}</pre>
|
||||
<div class="hx-element-hint">── request_body ──</div>
|
||||
<pre class="call-pre">{{ wire.request_body }}</pre>
|
||||
<div class="call-actions">
|
||||
<ElButton data-testid="call-copy-body" @click="copy(wire.request_body || '')">
|
||||
{{ t('admin.integrationConnector.callLogs.copyBody') }}
|
||||
</ElButton>
|
||||
<ElButton data-testid="call-copy-curl" @click="copy(curlCommand)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyCurl') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div v-for="(s, idx) in wire.statements || []" :key="idx" class="call-statement">
|
||||
<div class="call-statement__head">
|
||||
<ElTag effect="light">{{ s.phase }}</ElTag>
|
||||
<span v-if="statementRowCount(s)" class="hx-element-hint">rows: {{ statementRowCount(s) }}</span>
|
||||
</div>
|
||||
<pre class="call-pre">{{ s.sql }}</pre>
|
||||
<pre v-if="s.binds && Object.keys(s.binds).length > 0" class="call-pre">{{ prettyJson(s.binds) }}</pre>
|
||||
</div>
|
||||
<div v-if="wire.rowcount !== undefined" class="hx-element-hint">rowcount: {{ wire.rowcount }}</div>
|
||||
<ElAlert
|
||||
v-if="hasWriteStatement"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
data-testid="call-sql-write-warning"
|
||||
:title="t('admin.integrationConnector.callLogs.sqlWriteWarning')"
|
||||
/>
|
||||
<ElButton data-testid="call-copy-sql" @click="copy(sqlReplayText)">
|
||||
{{ t('admin.integrationConnector.callLogs.copySql') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</template>
|
||||
<p v-else class="hx-element-hint" data-testid="call-no-wire">
|
||||
{{ t('admin.integrationConnector.callLogs.noWire') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="call-pane">
|
||||
<h5 class="call-pane__title">{{ t('admin.integrationConnector.callLogs.normalized') }}</h5>
|
||||
<pre class="call-pre">{{ prettyJson(detail.call.request_summary_json) }}</pre>
|
||||
<ElButton data-testid="call-copy-request-json" @click="copy(prettyJson(detail.call.request_summary_json))">
|
||||
{{ t('admin.integrationConnector.callLogs.copyJson') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="call-block">
|
||||
<h4 class="call-block__title">{{ t('admin.integrationConnector.callLogs.response') }}</h4>
|
||||
<div class="call-split">
|
||||
<div class="call-pane">
|
||||
<h5 class="call-pane__title">{{ t('admin.integrationConnector.callLogs.rawPayload') }}</h5>
|
||||
<pre v-if="wire" class="call-pre">{{ rawResponseText }}</pre>
|
||||
<p v-else class="hx-element-hint" data-testid="call-no-wire-response">{{ t('admin.integrationConnector.callLogs.noWire') }}</p>
|
||||
<ElButton v-if="wire" data-testid="call-copy-raw" @click="copy(rawResponseText)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyRaw') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="call-pane">
|
||||
<h5 class="call-pane__title">{{ t('admin.integrationConnector.callLogs.normalizedJson') }}</h5>
|
||||
<pre class="call-pre">{{ prettyJson(detail.call.response_summary_json) }}</pre>
|
||||
<ElButton data-testid="call-copy-response-json" @click="copy(prettyJson(detail.call.response_summary_json))">
|
||||
{{ t('admin.integrationConnector.callLogs.copyJson') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
</ElDrawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.call-filters {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-end;
|
||||
gap: 12px;
|
||||
padding: 16px 32px;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.call-filters :deep(.el-form-item) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.call-filter {
|
||||
width: 11rem;
|
||||
}
|
||||
|
||||
.call-filter--wide {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
.call-filter :deep(.el-select),
|
||||
.call-filter :deep(.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.call-filter-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.call-ellipsis {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.call-logs :deep(.el-table__row) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.call-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 16px;
|
||||
margin-bottom: 12px;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.call-id {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.call-block {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.call-block__title,
|
||||
.call-pane__title {
|
||||
margin: 0 0 8px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.call-timeline {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.call-step {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 10px;
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.call-step.is-current {
|
||||
background: var(--el-color-primary-light-9);
|
||||
outline: 1px solid var(--el-color-primary-light-5);
|
||||
}
|
||||
|
||||
.call-split {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.call-pane {
|
||||
min-width: 0;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
}
|
||||
|
||||
.call-pre {
|
||||
margin: 0 0 8px;
|
||||
padding: 10px;
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-regular);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
max-height: 18rem;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.call-actions,
|
||||
.call-statement__head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.call-statement {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.call-split {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+65
-33
@@ -1,11 +1,13 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/components/IntegrationCapabilityCallModal.vue
|
||||
用途:手动调用一个已注册能力(输入 params / context JSON),展示调用结果与 trace。
|
||||
依赖:showCallModal、callParamsText、callContextText、callResult、callBusy。
|
||||
逻辑:由 IntegrationConnectorPage 打开;emit close/run。
|
||||
用途:手动调用一个已注册能力(展示 params / context JSON),展示调用结果与 trace。
|
||||
依赖:element-plus 对话框和表单、IntegrationCallResultRow、useI18n。
|
||||
样式跟 IntegrationConnectorPage 已引入的 Element 皮肤走,本组件不再引 css。
|
||||
逻辑:由 IntegrationConnectorPage 打开;emit close/run。入参与上下文只读,不改提交字段。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElForm, ElFormItem, ElInput } from 'element-plus';
|
||||
import type { IntegrationCallResultRow } from '../types/integration-connector.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -23,37 +25,67 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。调用进行中不收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (open || props.busy) return;
|
||||
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">{{ t('admin.integrationConnector.callModal.title', { capability }) }}</h3>
|
||||
<p class="section-desc mt-1">{{ t('admin.integrationConnector.callModal.hint') }}</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>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="t('admin.integrationConnector.callModal.title', { capability })"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!busy"
|
||||
:show-close="!busy"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<p class="section-desc">{{ t('admin.integrationConnector.callModal.hint') }}</p>
|
||||
<ElForm class="call-modal-form" label-position="top">
|
||||
<ElFormItem :label="t('admin.integrationConnector.callModal.params')">
|
||||
<ElInput :model-value="paramsText" type="textarea" :rows="6" readonly spellcheck="false" />
|
||||
<p class="hx-element-hint">{{ t('admin.integrationConnector.callModal.paramsHint') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.integrationConnector.callModal.context')">
|
||||
<ElInput :model-value="contextText" type="textarea" :rows="4" readonly spellcheck="false" />
|
||||
<p class="hx-element-hint">{{ t('admin.integrationConnector.callModal.contextHint') }}</p>
|
||||
</ElFormItem>
|
||||
<ElFormItem v-if="result" :label="t('admin.integrationConnector.callModal.result')">
|
||||
<pre class="call-modal-result">{{ JSON.stringify(result, null, 2) }}</pre>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="busy" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="busy" @click="emit('run')">
|
||||
{{ busy ? t('admin.integrationConnector.callModal.running') : t('admin.integrationConnector.callModal.run') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.call-modal-form {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.call-modal-result {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-regular);
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
+180
-117
@@ -6,10 +6,13 @@
|
||||
* 以及抽屉化后的 JSON 编辑字段(格式化/失焦校验)、脏检查关闭确认与 Esc 关闭行为。
|
||||
* 依赖:@vue/test-utils、vitest、i18n。
|
||||
* 逻辑:切换 connector_type 断言字段可见性;对 JsonTextareaField 断言格式化改写
|
||||
* 与非法 JSON 提示;mock window.confirm 断言脏表单关闭拦截与放行。
|
||||
* 与非法 JSON 提示;mock ElMessageBox.confirm 断言脏表单关闭拦截与放行。
|
||||
* 下拉用 ElOption 点击,JSON 写入真正的 textarea。
|
||||
* 抽屉正文在挂载后下一拍才渲染,mountDrawer 内会 flushPromises。
|
||||
*/
|
||||
import { mount, enableAutoUnmount } from '@vue/test-utils';
|
||||
import { mount, enableAutoUnmount, flushPromises, type VueWrapper } from '@vue/test-utils';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { ElMessageBox, ElOption, ElSelect } from 'element-plus';
|
||||
import i18n from '@/i18n';
|
||||
import IntegrationConnectorFormDrawer from './IntegrationConnectorFormDrawer.vue';
|
||||
import JsonTextareaField from './JsonTextareaField.vue';
|
||||
@@ -25,8 +28,62 @@ import {
|
||||
|
||||
enableAutoUnmount(afterEach);
|
||||
|
||||
function mountDrawer(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
return mount(IntegrationConnectorFormDrawer, {
|
||||
/**
|
||||
* 按 data-testid 找到 Element 下拉。
|
||||
* @param wrapper - 抽屉挂载结果
|
||||
* @param testId - 下拉上的 data-testid
|
||||
*/
|
||||
function selectOf(wrapper: VueWrapper, testId: string) {
|
||||
const select = wrapper.findAllComponents(ElSelect).find((item) => item.attributes('data-testid') === testId);
|
||||
expect(select, `未找到下拉 ${testId}`).toBeTruthy();
|
||||
return select!;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取下拉选项展示文案。
|
||||
* @param select - ElSelect 组件包装
|
||||
*/
|
||||
function optionLabelList(select: ReturnType<typeof selectOf>): string[] {
|
||||
return select.findAllComponents(ElOption).map((item) => String(item.props('label')));
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击指定选项,走 Element 的选中逻辑而不是原生 select 的 setValue。
|
||||
* @param wrapper - 抽屉挂载结果
|
||||
* @param testId - 下拉上的 data-testid
|
||||
* @param value - 选项值
|
||||
*/
|
||||
async function chooseOption(wrapper: VueWrapper, testId: string, value: string) {
|
||||
const option = selectOf(wrapper, testId).findAllComponents(ElOption).find((item) => item.props('value') === value);
|
||||
expect(option, `未找到选项 ${value}`).toBeTruthy();
|
||||
await option!.trigger('click');
|
||||
}
|
||||
|
||||
/**
|
||||
* JsonTextareaField 内部真正的 textarea。testid 也在这个元素上,测试不依赖根节点 setValue。
|
||||
* @param field - JSON 字段组件
|
||||
*/
|
||||
function jsonTextarea(field: VueWrapper) {
|
||||
return field.get('textarea');
|
||||
}
|
||||
|
||||
/**
|
||||
* 点抽屉遮罩。Element 遮罩要先按下再松开,点击才算落在遮罩上。
|
||||
* @param wrapper - 抽屉挂载结果
|
||||
*/
|
||||
async function clickOverlay(wrapper: VueWrapper) {
|
||||
const overlay = wrapper.get('.el-overlay');
|
||||
await overlay.trigger('mousedown');
|
||||
await overlay.trigger('mouseup');
|
||||
await overlay.trigger('click');
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂载抽屉并等到正文渲染。ElDrawer 的表单槽在 mounted 之后才出现。
|
||||
* @param overrides - 覆盖默认 props
|
||||
*/
|
||||
async function mountDrawer(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
const wrapper = mount(IntegrationConnectorFormDrawer, {
|
||||
props: {
|
||||
visible: true,
|
||||
activeEntity: 'client',
|
||||
@@ -49,19 +106,20 @@ function mountDrawer(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
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 chooseOption(wrapper, 'client-connector-type', 'soap');
|
||||
// 连接地址仍是同一 client-endpoint 字段,仅 label 变 WSDL
|
||||
expect(wrapper.find('[data-testid="client-endpoint"]').exists()).toBe(true);
|
||||
// 超时在 SOAP 下也显示
|
||||
@@ -70,8 +128,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 +138,26 @@ 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 chooseOption(wrapper, 'interface-client', '1001');
|
||||
// 编码留空 → 按客户端编码 + 名称 slug 自动建议
|
||||
expect(interfaceForm.code).toBe('1001-topgp-getitemstocklist');
|
||||
// 连接器类型与客户端实例同款下拉控件,仅禁用只读:随所选客户端联动展示
|
||||
const typeSelect = wrapper.find('[data-testid="interface-connector-type"]');
|
||||
const typeSelect = selectOf(wrapper, 'interface-connector-type');
|
||||
expect(typeSelect.text()).toContain('SOAP');
|
||||
expect(typeSelect.attributes('disabled')).toBeDefined();
|
||||
expect(typeSelect.props('disabled')).toBe(true);
|
||||
// 只渲染当前类型单项,不提供其他选项(不可改选)
|
||||
expect(typeSelect.findAll('option').length).toBe(1);
|
||||
expect(typeSelect.findAllComponents(ElOption)).toHaveLength(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 +167,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 +180,7 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
|
||||
it('绑定:添加步骤并选接口后,只读提示该步接口归属的客户端实例', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountDrawer({
|
||||
const wrapper = await mountDrawer({
|
||||
activeEntity: 'binding',
|
||||
bindingForm,
|
||||
clientOptions: [
|
||||
@@ -135,21 +193,20 @@ 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 chooseOption(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([
|
||||
// 能力下拉选项不再出现原始注册名裸文案
|
||||
expect(optionLabelList(selectOf(wrapper, 'binding-capability'))).toEqual([
|
||||
'在途库存查询(in_transit_transfer.query_inventory)',
|
||||
'unknown.capability',
|
||||
]);
|
||||
@@ -158,16 +215,15 @@ 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();
|
||||
expect(optionLabelList(selectOf(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"]');
|
||||
expect(dbKind.exists()).toBe(true);
|
||||
// db_kind 专属下拉四选一(含未选占位项),label 即库名
|
||||
expect(dbKind.findAll('option').map((o) => o.text())).toEqual(['—', 'MySQL', 'Oracle', 'SQL Server', 'PostgreSQL']);
|
||||
await chooseOption(wrapper, 'client-connector-type', 'database');
|
||||
const dbKind = selectOf(wrapper, 'client-db-kind');
|
||||
// 空条件走 placeholder「—」,选项本身是四库
|
||||
expect(dbKind.props('placeholder')).toBe('—');
|
||||
expect(optionLabelList(dbKind)).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 +232,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 chooseOption(wrapper, 'interface-client', 'erp-db');
|
||||
// 接口类型随客户端联动为 database
|
||||
expect(interfaceForm.connector_type).toBe('database');
|
||||
const labels = wrapper.findAll('label').map((l) => l.text());
|
||||
@@ -193,23 +249,27 @@ 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 chooseOption(wrapper, 'client-connector-type', 'database');
|
||||
await chooseOption(wrapper, 'client-db-kind', 'oracle');
|
||||
expect(clientForm.db_kind).toBe('oracle');
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('rest');
|
||||
await chooseOption(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 chooseOption(wrapper, 'client-connector-type', 'database');
|
||||
expect(wrapper.text()).toContain('"oracle_lib_dir"');
|
||||
});
|
||||
});
|
||||
|
||||
describe('IntegrationConnectorFormDrawer binding steps editor', () => {
|
||||
/**
|
||||
* 挂载绑定表单。复用 mountDrawer,等正文渲染完再返回。
|
||||
* @param overrides - 覆盖默认 props
|
||||
*/
|
||||
function mountBinding(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
return mountDrawer({
|
||||
activeEntity: 'binding',
|
||||
@@ -227,15 +287,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 chooseOption(wrapper, 'binding-step-interface-0', 'IF-STAGE');
|
||||
await chooseOption(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 +303,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 chooseOption(wrapper, 'binding-step-interface-0', 'IF-STAGE');
|
||||
await chooseOption(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,12 +322,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"]')
|
||||
await jsonTextarea(stepRows[0].findComponent(JsonTextareaField))
|
||||
.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 +337,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 +346,15 @@ 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');
|
||||
expect(selectOf(wrapper, 'binding-step-interface-0').props('modelValue')).toBe('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 +362,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,9 +373,9 @@ 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 jsonTextarea(field!).setValue('{"method":"POST","params":["erp_org"]}');
|
||||
await field!.find('[data-testid="json-format-button"]').trigger('click');
|
||||
// 断言格式化结果写回父级表单对象(v-model 链路)
|
||||
expect(interfaceForm.request_spec_json).toBe('{\n "method": "POST",\n "params": [\n "erp_org"\n ]\n}');
|
||||
@@ -323,9 +383,9 @@ 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"]');
|
||||
const textarea = jsonTextarea(field!);
|
||||
await textarea.setValue('{ invalid');
|
||||
expect(field!.find('[data-testid="json-error"]').exists()).toBe(false);
|
||||
await textarea.trigger('blur');
|
||||
@@ -337,10 +397,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 +410,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 +419,51 @@ 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');
|
||||
const confirmSpy = vi.spyOn(ElMessageBox, 'confirm').mockResolvedValue('confirm');
|
||||
const wrapper = await mountDrawer();
|
||||
await clickOverlay(wrapper);
|
||||
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();
|
||||
const confirmSpy = vi.spyOn(ElMessageBox, 'confirm').mockRejectedValue('cancel');
|
||||
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 clickOverlay(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 clickOverlay(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('cancel');
|
||||
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 +476,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 chooseOption(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 chooseOption(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 +502,12 @@ 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(['界面维护(加密保存)', '环境变量']);
|
||||
it('新建态:类型/来源下拉选项本地化渲染(与列表徽章一致),状态不进表单,无只读信息区', async () => {
|
||||
const wrapper = await mountDrawer({ activeEntity: 'credential' });
|
||||
expect(optionLabelList(selectOf(wrapper, 'credential-type'))).toEqual(['账密', '令牌']);
|
||||
expect(optionLabelList(selectOf(wrapper, 'credential-provider'))).toEqual(['界面维护(加密保存)', '环境变量']);
|
||||
// 状态由列表生命周期按钮流转,凭据表单只有来源/类型两个下拉
|
||||
expect(wrapper.findAll('select').length).toBe(2);
|
||||
expect(wrapper.findAllComponents(ElSelect)).toHaveLength(2);
|
||||
// 新建态没有只读信息区
|
||||
expect(wrapper.find('[data-testid="credential-meta"]').exists()).toBe(false);
|
||||
// 正文分组:基本信息 + 凭据值
|
||||
@@ -453,32 +515,32 @@ 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();
|
||||
const providerSelect = selectOf(wrapper, 'credential-provider');
|
||||
expect(providerSelect.props('disabled')).toBe(true);
|
||||
expect(providerSelect.text()).toContain('界面维护(加密保存)');
|
||||
const typeSelect = wrapper.find('[data-testid="credential-type"]');
|
||||
expect(typeSelect.attributes('disabled')).toBeDefined();
|
||||
const typeSelect = selectOf(wrapper, 'credential-type');
|
||||
expect(typeSelect.props('disabled')).toBe(true);
|
||||
expect(typeSelect.text()).toContain('账密');
|
||||
// 状态 = 底部操作条启用开关(随保存生效),悬停 title 说明停用断流后果
|
||||
const row = wrapper.find('[data-testid="credential-enabled-row"]');
|
||||
expect(row.exists()).toBe(true);
|
||||
expect(row.text()).toContain('随保存操作生效');
|
||||
const switchBtn = wrapper.find('[data-testid="credential-enabled-switch"]');
|
||||
expect(switchBtn.attributes('aria-checked')).toBe('true');
|
||||
expect(switchBtn.attributes('title')).toContain('立即失败');
|
||||
expect(switchBtn.get('[role="switch"]').attributes('aria-checked')).toBe('true');
|
||||
// 变更路径一句话提示
|
||||
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 +549,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,37 +561,38 @@ 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(['开发', '测试', '生产']);
|
||||
expect(optionLabelList(selectOf(wrapper, 'client-connector-type'))).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
|
||||
expect(optionLabelList(selectOf(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']);
|
||||
const credSelect = selectOf(wrapper, 'client-credential-ref');
|
||||
expect(credSelect.props('placeholder')).toBe('无(匿名访问)');
|
||||
expect(optionLabelList(credSelect)).toEqual(['tiptop-erp', 'wms-token']);
|
||||
// REST:高级配置提示列出生效键 headers
|
||||
expect(wrapper.text()).toContain('"headers"');
|
||||
// 切到 SOAP:提示变为「暂无额外生效键」语义
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('soap');
|
||||
await chooseOption(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" 开关
|
||||
expect(row.exists()).toBe(true);
|
||||
expect(wrapper.findAll('input[type="checkbox"]').length).toBe(0);
|
||||
const checks = wrapper.findAll('input[type="checkbox"]');
|
||||
expect(checks).toHaveLength(1);
|
||||
expect(checks[0].attributes('role')).toBe('switch');
|
||||
const switchBtn = wrapper.find('[data-testid="client-enabled-switch"]');
|
||||
expect(switchBtn.attributes('role')).toBe('switch');
|
||||
expect(switchBtn.get('[role="switch"]').attributes('role')).toBe('switch');
|
||||
// 小字「随保存操作生效」与列表行内开关的即时生效区分;悬停 title 携带停用后果
|
||||
expect(row.text()).toContain('随保存操作生效');
|
||||
expect(switchBtn.attributes('title')).toContain('连接测试不受影响');
|
||||
@@ -537,13 +600,13 @@ describe('IntegrationConnectorFormDrawer client form redesign', () => {
|
||||
expect(clientForm.enabled).toBe(true);
|
||||
await switchBtn.trigger('click');
|
||||
expect(clientForm.enabled).toBe(false);
|
||||
expect(switchBtn.attributes('aria-checked')).toBe('false');
|
||||
expect(switchBtn.get('[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);
|
||||
});
|
||||
|
||||
+614
-386
File diff suppressed because it is too large.
Load diff
+55
-18
@@ -1,15 +1,17 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/components/JsonTextareaField.vue
|
||||
用途:JSON 配置字段统一编辑器——全宽等宽 textarea + 格式化按钮 + 失焦即时校验,
|
||||
用途:JSON 配置字段统一编辑器——全宽等宽多行输入 + 格式化按钮 + 失焦即时校验,
|
||||
供本模块四实体表单(请求模板/Schema/映射/连接配置/上下文选择器)复用。
|
||||
依赖:useI18n。
|
||||
依赖:element-plus 的 ElInput / ElButton、useI18n。样式跟表单抽屉已引入的 Element 皮肤走。
|
||||
逻辑:v-model 承载 JSON 文本(由父级表单 state 持有);失焦时校验,非法显示红字
|
||||
提示;「格式化」仅在合法 JSON 时 pretty-print 改写,非法时只提示不改写内容。
|
||||
空值视为合法(与保存链路 parseJsonField 的「空串返回 {}」一致)。
|
||||
data-testid 落在真正的 textarea 上(ElInput 把多余属性转到内部 textarea)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElInput } from 'element-plus';
|
||||
|
||||
const props = defineProps<{
|
||||
/** 字段标签,同时用于错误提示中的字段名。 */
|
||||
@@ -39,44 +41,79 @@ const isValid = computed(() => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 失焦后才展示校验结果,输入过程中不打断。
|
||||
*/
|
||||
function onBlur() {
|
||||
touched.value = true;
|
||||
}
|
||||
|
||||
/** 格式化(pretty-print);内容为空或非法时仅标记已触碰以显示校验提示。 */
|
||||
/**
|
||||
* 格式化(pretty-print)。
|
||||
* 核心逻辑:内容为空或非法时只标记已触碰,不改写文本。
|
||||
*/
|
||||
function format() {
|
||||
touched.value = true;
|
||||
if (!isValid.value || !props.modelValue.trim()) return;
|
||||
emit('update:modelValue', JSON.stringify(JSON.parse(props.modelValue.trim()), null, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* 把多行输入写回 v-model。
|
||||
* @param value - Element 文本域回传的字符串
|
||||
*/
|
||||
function onInput(value: string) {
|
||||
emit('update:modelValue', value);
|
||||
}
|
||||
</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"
|
||||
:disabled="!modelValue.trim()"
|
||||
<div class="json-field">
|
||||
<div class="json-field__head">
|
||||
<span class="json-field__label">{{ label }}</span>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="json-format-button"
|
||||
:disabled="!modelValue.trim()"
|
||||
@click="format"
|
||||
>
|
||||
{{ t('admin.integrationConnector.formatJson') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<textarea
|
||||
:value="modelValue"
|
||||
rows="12"
|
||||
class="input-field text-sm font-mono leading-5"
|
||||
spellcheck="false"
|
||||
<ElInput
|
||||
type="textarea"
|
||||
:model-value="modelValue"
|
||||
:rows="12"
|
||||
:placeholder="placeholder"
|
||||
spellcheck="false"
|
||||
data-testid="json-textarea"
|
||||
@input="emit('update:modelValue', ($event.target as HTMLTextAreaElement).value)"
|
||||
@update:model-value="onInput"
|
||||
@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__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.json-field__label {
|
||||
color: var(--el-text-color-regular);
|
||||
font-size: var(--el-font-size-base);
|
||||
}
|
||||
|
||||
.json-field__error {
|
||||
margin: 4px 0 0;
|
||||
color: var(--el-color-danger);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
}
|
||||
</style>
|
||||
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,23 +1,29 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/SchedulesPage.vue
|
||||
* 定时任务管理独立页面壳层。路由:/admin/schedules
|
||||
* 依赖:useSchedulesAdmin、schedules.context、子 panel/overlays 组件。
|
||||
* 逻辑:reactive + provide admin 上下文;onMounted 加载列表。
|
||||
* 用途:定时任务管理页入口。概览和工作台共用一张列表卡片,弹窗跟在页面里。
|
||||
* 依赖:useSchedulesAdmin、useElementProvider、element-plus、AdminListPage、子面板与弹窗层。
|
||||
* 逻辑:路由 /admin/schedules。provide admin 上下文;本页只引一次 Element 样式。子组件不再重复引样式。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted, provide, reactive } from 'vue';
|
||||
import { ElConfigProvider } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { useSchedulesAdmin } from './composables/useSchedulesAdmin';
|
||||
import { SCHEDULES_ADMIN_KEY, SCHEDULE_CREATE_MODAL_OPEN_KEY, type SchedulesAdminContextProvided } from './composables/schedules.context';
|
||||
import SchedulePageHeader from './components/SchedulePageHeader.vue';
|
||||
import ScheduleOverviewPanel from './components/ScheduleOverviewPanel.vue';
|
||||
import ScheduleWorkbenchPanel from './components/ScheduleWorkbenchPanel.vue';
|
||||
import SchedulesPageOverlays from './components/SchedulesPageOverlays.vue';
|
||||
|
||||
const { elementLocale } = useElementProvider();
|
||||
const adminApi = useSchedulesAdmin();
|
||||
const admin = reactive(adminApi) as SchedulesAdminContextProvided;
|
||||
provide(SCHEDULES_ADMIN_KEY, admin);
|
||||
/** 弹窗 v-if 须绑定原始 ref,避免 reactive 属性赋值破坏 ref 链接 */
|
||||
provide(SCHEDULE_CREATE_MODAL_OPEN_KEY, adminApi.showScheduleCreateModal);
|
||||
|
||||
onMounted(async () => {
|
||||
await admin.loadAll();
|
||||
await admin.applyFromRouteQuery();
|
||||
@@ -25,10 +31,9 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="section-gap animate-fade-in-up">
|
||||
<SchedulePageHeader />
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<ScheduleOverviewPanel v-if="admin.scheduleViewMode === 'overview'" />
|
||||
<ScheduleWorkbenchPanel v-else />
|
||||
</section>
|
||||
<SchedulesPageOverlays />
|
||||
<SchedulesPageOverlays />
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
+214
-119
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/DynamicTaskParamsForm.vue
|
||||
* 用途:平台任务参数通用表单——按注册表 params_schema 渲染控件并输出统一 job_params。
|
||||
* 依赖:schedule.api(PlatformTaskDefinition/listAdminPlatformTaskOptions)、vue-i18n。
|
||||
* 依赖:schedule.api(PlatformTaskDefinition/listAdminPlatformTaskOptions)、vue-i18n、element-plus。
|
||||
* 逻辑:ScheduleCreateEditModal 传入选中任务的 definition;本组件只认识控件 type 与
|
||||
* options_source,不认识具体任务(红框参数区完全由 schema 决定);
|
||||
* 高级配置折叠 JSON 与 schema type=json 字段均本地校验,非法时 emit valid=false 阻止保存;
|
||||
@@ -10,6 +10,17 @@
|
||||
*/
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElCheckbox,
|
||||
ElCollapse,
|
||||
ElCollapseItem,
|
||||
ElDatePicker,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSwitch,
|
||||
} from 'element-plus';
|
||||
import {
|
||||
listAdminPlatformTaskOptions,
|
||||
type PlatformTaskDefinition,
|
||||
@@ -37,6 +48,7 @@ const optionsLoading = reactive<Record<string, boolean>>({});
|
||||
|
||||
const advancedJsonText = ref('');
|
||||
const advancedJsonError = ref(false);
|
||||
const advancedPanels = ref<string[]>([]);
|
||||
/** schema type=json 字段的本地文本与非法标记(key → text/error) */
|
||||
const jsonFieldTexts = reactive<Record<string, string>>({});
|
||||
const jsonFieldErrors = reactive<Record<string, boolean>>({});
|
||||
@@ -119,6 +131,57 @@ const setField = (key: string, value: any): void => {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 单选在控件上的值。空字符串和 null 都显示成未选择,避免下拉出现「请选择」占位被当成已选值。
|
||||
* @param key - 参数字段名
|
||||
*/
|
||||
const selectFieldValue = (key: string): string | number | undefined => {
|
||||
const value = params.value[key];
|
||||
if (value === null || value === undefined || value === '') return undefined;
|
||||
return value as string | number;
|
||||
};
|
||||
|
||||
/**
|
||||
* 单选变更。控件清空是 undefined,写回 job_params 时仍用 null,不把空字符串写进任务参数。
|
||||
* @param field - schema 字段
|
||||
* @param value - 选中的选项值;清空时为空
|
||||
*/
|
||||
const onSelectField = (field: PlatformTaskParamField, value: string | number | undefined): void => {
|
||||
if (value === undefined || value === '') {
|
||||
setField(field.key, null);
|
||||
return;
|
||||
}
|
||||
const matched = (optionsCache[field.options_source || ''] || []).find((option) => String(option.value) === String(value));
|
||||
setField(field.key, matched ? matched.value : value);
|
||||
};
|
||||
|
||||
/**
|
||||
* 日期或时间清空后写回 null,与原先空输入一致。
|
||||
* @param key - 参数字段名
|
||||
* @param value - 日期组件回传的字符串;清空时为空
|
||||
*/
|
||||
const onDateField = (key: string, value: string | null | undefined): void => {
|
||||
setField(key, value || null);
|
||||
};
|
||||
|
||||
/**
|
||||
* 数字清空后写回 null。0 是合法值,不能当成空。
|
||||
* @param key - 参数字段名
|
||||
* @param value - 数字组件的值
|
||||
*/
|
||||
const onNumberField = (key: string, value: number | null | undefined): void => {
|
||||
setField(key, value === undefined || value === null ? null : value);
|
||||
};
|
||||
|
||||
/**
|
||||
* 多选是否已勾选该选项。
|
||||
* @param key - 参数字段名
|
||||
* @param value - 选项值
|
||||
*/
|
||||
const isMultiChecked = (key: string, value: string | number): boolean => (
|
||||
Array.isArray(params.value[key]) && params.value[key].includes(value)
|
||||
);
|
||||
|
||||
/** 拉取并缓存某个 options_source 的动态选项。 */
|
||||
const loadOptions = async (source: string): Promise<void> => {
|
||||
if (optionsCache[source] || optionsLoading[source]) return;
|
||||
@@ -158,8 +221,10 @@ const toggleMultiValue = (key: string, value: string | number): void => {
|
||||
|
||||
/**
|
||||
* 高级 JSON 文本变更:合法时写入 _advanced,空文本移除该键。
|
||||
* @param raw - 输入框当前文本;不传时读本地 ref
|
||||
*/
|
||||
const handleAdvancedInput = (): void => {
|
||||
const handleAdvancedInput = (raw?: string): void => {
|
||||
if (typeof raw === 'string') advancedJsonText.value = raw;
|
||||
const text = advancedJsonText.value.trim();
|
||||
if (!text) {
|
||||
advancedJsonError.value = false;
|
||||
@@ -231,174 +296,204 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rounded-xl border border-blue-200 bg-blue-50/40 p-4 space-y-3">
|
||||
<!-- 任务说明块(schema 之外的任务级描述) -->
|
||||
<p v-if="descriptionText" class="text-sm text-blue-900">{{ descriptionText }}</p>
|
||||
<div class="schedule-params">
|
||||
<p v-if="descriptionText">{{ descriptionText }}</p>
|
||||
|
||||
<div v-for="field in schemaFields" :key="field.key">
|
||||
<!-- info:纯说明块 -->
|
||||
<p v-if="field.type === 'info'" class="text-xs text-muted">
|
||||
<div v-for="field in schemaFields" :key="field.key" class="schedule-param-field">
|
||||
<p v-if="field.type === 'info'" class="hx-element-hint">
|
||||
{{ resolveText(field.help_key, field.help) || resolveText(field.label_key, field.label) }}
|
||||
</p>
|
||||
|
||||
<template v-else>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">
|
||||
<label class="schedule-param-label">
|
||||
{{ resolveText(field.label_key, field.label) }}
|
||||
<span v-if="field.required" class="text-rose-500">*</span>
|
||||
<span v-if="field.required" class="schedule-field-error">*</span>
|
||||
</label>
|
||||
|
||||
<!-- text / cron / date / datetime -->
|
||||
<input
|
||||
<ElInput
|
||||
v-if="field.type === 'text' || field.type === 'cron'"
|
||||
:value="params[field.key] ?? ''"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
:class="field.type === 'cron' ? 'font-mono' : ''"
|
||||
:model-value="params[field.key] ?? ''"
|
||||
:class="field.type === 'cron' ? 'schedule-mono' : ''"
|
||||
:placeholder="resolveText(field.placeholder_key, field.placeholder)"
|
||||
@input="setField(field.key, ($event.target as HTMLInputElement).value)"
|
||||
@update:model-value="setField(field.key, $event)"
|
||||
/>
|
||||
<input
|
||||
<ElDatePicker
|
||||
v-else-if="field.type === 'date'"
|
||||
class="schedule-control"
|
||||
:model-value="params[field.key] || undefined"
|
||||
type="date"
|
||||
:value="params[field.key] ?? ''"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
@input="setField(field.key, ($event.target as HTMLInputElement).value === '' ? null : ($event.target as HTMLInputElement).value)"
|
||||
value-format="YYYY-MM-DD"
|
||||
@update:model-value="onDateField(field.key, $event)"
|
||||
/>
|
||||
<input
|
||||
<ElDatePicker
|
||||
v-else-if="field.type === 'datetime'"
|
||||
type="datetime-local"
|
||||
:value="params[field.key] ?? ''"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
@input="setField(field.key, ($event.target as HTMLInputElement).value)"
|
||||
class="schedule-control"
|
||||
:model-value="params[field.key] || undefined"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm"
|
||||
@update:model-value="onDateField(field.key, $event)"
|
||||
/>
|
||||
|
||||
<!-- number -->
|
||||
<input
|
||||
<ElInputNumber
|
||||
v-else-if="field.type === 'number'"
|
||||
type="number"
|
||||
:value="params[field.key] ?? ''"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
class="schedule-control"
|
||||
:model-value="typeof params[field.key] === 'number' ? params[field.key] : undefined"
|
||||
:value-on-clear="null"
|
||||
controls-position="right"
|
||||
:placeholder="resolveText(field.placeholder_key, field.placeholder)"
|
||||
@input="setField(field.key, ($event.target as HTMLInputElement).value === '' ? null : Number(($event.target as HTMLInputElement).value))"
|
||||
@update:model-value="onNumberField(field.key, $event)"
|
||||
/>
|
||||
<ElSwitch
|
||||
v-else-if="field.type === 'boolean'"
|
||||
:model-value="!!params[field.key]"
|
||||
@change="setField(field.key, $event)"
|
||||
/>
|
||||
<span v-if="field.type === 'boolean'" class="hx-element-hint">
|
||||
{{ resolveText(field.placeholder_key, field.placeholder) }}
|
||||
</span>
|
||||
|
||||
<ElInput
|
||||
v-else-if="field.type === 'textarea'"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
class="schedule-mono"
|
||||
:model-value="typeof params[field.key] === 'string' ? params[field.key] : (params[field.key] ? String(params[field.key]) : '')"
|
||||
:placeholder="resolveText(field.placeholder_key, field.placeholder)"
|
||||
@update:model-value="setField(field.key, $event)"
|
||||
/>
|
||||
|
||||
<!-- boolean -->
|
||||
<label v-else-if="field.type === 'boolean'" class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded text-blue-600"
|
||||
:checked="!!params[field.key]"
|
||||
@change="setField(field.key, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
{{ resolveText(field.placeholder_key, field.placeholder) }}
|
||||
</label>
|
||||
|
||||
<!-- textarea -->
|
||||
<textarea
|
||||
v-else-if="field.type === 'textarea'"
|
||||
:value="typeof params[field.key] === 'string' ? params[field.key] : (params[field.key] ? String(params[field.key]) : '')"
|
||||
class="w-full min-h-[80px] input-field p-3 text-xs leading-relaxed text-secondary font-mono resize-y"
|
||||
:placeholder="resolveText(field.placeholder_key, field.placeholder)"
|
||||
@input="setField(field.key, ($event.target as HTMLTextAreaElement).value)"
|
||||
></textarea>
|
||||
|
||||
<!-- json:本地解析,非法时阻止保存 -->
|
||||
<div v-else-if="field.type === 'json'" class="space-y-1">
|
||||
<textarea
|
||||
:value="jsonFieldTexts[field.key] ?? ''"
|
||||
class="w-full min-h-[80px] input-field p-3 text-xs leading-relaxed text-secondary font-mono resize-y"
|
||||
:class="jsonFieldErrors[field.key] ? 'border-red-400 focus:border-red-500' : ''"
|
||||
<div v-else-if="field.type === 'json'">
|
||||
<ElInput
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
class="schedule-mono"
|
||||
:model-value="jsonFieldTexts[field.key] ?? ''"
|
||||
:placeholder="resolveText(field.placeholder_key, field.placeholder) || $t('admin.schedule.form.dynamicParamsAdvancedPlaceholder')"
|
||||
@input="handleJsonFieldInput(field.key, ($event.target as HTMLTextAreaElement).value)"
|
||||
></textarea>
|
||||
<p v-if="jsonFieldErrors[field.key]" class="text-xs text-red-600">
|
||||
@update:model-value="handleJsonFieldInput(field.key, $event)"
|
||||
/>
|
||||
<p v-if="jsonFieldErrors[field.key]" class="schedule-field-error">
|
||||
{{ $t('admin.schedule.form.dynamicParamsJsonInvalid') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- select(单选,动态选项) -->
|
||||
<select
|
||||
<ElSelect
|
||||
v-else-if="field.type === 'select'"
|
||||
:value="params[field.key] ?? ''"
|
||||
class="input-field w-full !text-sm !leading-5"
|
||||
@change="setField(field.key, ($event.target as HTMLSelectElement).value === '' ? null : (optionsCache[field.options_source || '']?.find((o) => String(o.value) === ($event.target as HTMLSelectElement).value)?.value ?? ($event.target as HTMLSelectElement).value))"
|
||||
class="schedule-control"
|
||||
:model-value="selectFieldValue(field.key)"
|
||||
clearable
|
||||
:placeholder="resolveText(field.placeholder_key, field.placeholder) || $t('admin.schedule.form.dynamicParamsSelectPlaceholder')"
|
||||
@update:model-value="onSelectField(field, $event)"
|
||||
>
|
||||
<option value="">{{ resolveText(field.placeholder_key, field.placeholder) || $t('admin.schedule.form.dynamicParamsSelectPlaceholder') }}</option>
|
||||
<option
|
||||
<ElOption
|
||||
v-for="option in optionsCache[field.options_source || ''] || []"
|
||||
:key="String(option.value)"
|
||||
:value="String(option.value)"
|
||||
>
|
||||
{{ option.label }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<!-- multi_select(多选,动态选项,复选框列表) -->
|
||||
<div
|
||||
v-else-if="field.type === 'multi_select'"
|
||||
class="max-h-52 space-y-1 overflow-y-auto rounded-xl border border-default bg-surface p-2"
|
||||
>
|
||||
<input
|
||||
v-model="multiSearch[field.key]"
|
||||
type="text"
|
||||
class="mb-1 w-full rounded-lg border border-default px-2 py-1.5 text-sm outline-none focus:border-blue-500"
|
||||
:placeholder="resolveText(field.placeholder_key, field.placeholder) || $t('admin.schedule.form.dynamicParamsSearchPlaceholder')"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
<p v-if="optionsLoading[field.options_source || '']" class="px-2 py-1 text-xs text-muted">
|
||||
</ElSelect>
|
||||
|
||||
<div v-else-if="field.type === 'multi_select'" class="schedule-multi">
|
||||
<ElInput
|
||||
:model-value="multiSearch[field.key] || ''"
|
||||
:placeholder="resolveText(field.placeholder_key, field.placeholder) || $t('admin.schedule.form.dynamicParamsSearchPlaceholder')"
|
||||
@update:model-value="multiSearch[field.key] = $event"
|
||||
/>
|
||||
<p v-if="optionsLoading[field.options_source || '']" class="hx-element-hint">
|
||||
{{ $t('admin.schedule.form.dynamicParamsOptionsLoading') }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="!(optionsCache[field.options_source || ''] || []).length"
|
||||
class="px-2 py-1 text-xs text-muted"
|
||||
>
|
||||
<p v-else-if="!(optionsCache[field.options_source || ''] || []).length" class="hx-element-hint">
|
||||
{{ $t('admin.schedule.form.dynamicParamsNoOptions') }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="!filteredMultiOptions(field).length"
|
||||
class="px-2 py-1 text-xs text-muted"
|
||||
>
|
||||
<p v-else-if="!filteredMultiOptions(field).length" class="hx-element-hint">
|
||||
{{ $t('admin.schedule.form.dynamicParamsSearchNoMatch') }}
|
||||
</p>
|
||||
<label
|
||||
v-for="option in filteredMultiOptions(field)"
|
||||
:key="String(option.value)"
|
||||
class="flex cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 text-sm transition hover:bg-surface-soft"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="mt-0.5 h-3.5 w-3.5 rounded text-blue-600"
|
||||
:checked="Array.isArray(params[field.key]) && params[field.key].includes(option.value)"
|
||||
<label v-for="option in filteredMultiOptions(field)" :key="String(option.value)" class="schedule-multi-option">
|
||||
<ElCheckbox
|
||||
:model-value="isMultiChecked(field.key, option.value)"
|
||||
@change="toggleMultiValue(field.key, option.value)"
|
||||
/>
|
||||
<span class="min-w-0">
|
||||
<span class="block text-secondary">{{ option.label }}</span>
|
||||
<span v-if="option.description" class="block text-xs text-muted">{{ option.description }}</span>
|
||||
<span>
|
||||
<span>{{ option.label }}</span>
|
||||
<span v-if="option.description" class="hx-element-hint">{{ option.description }}</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<p v-if="resolveText(field.help_key, field.help)" class="mt-1 text-xs text-muted">
|
||||
<p v-if="resolveText(field.help_key, field.help)" class="hx-element-hint">
|
||||
{{ resolveText(field.help_key, field.help) }}
|
||||
</p>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 高级配置折叠 JSON(写入 job_params._advanced,兜底历史/特殊任务) -->
|
||||
<details class="rounded-xl border border-default bg-surface">
|
||||
<summary class="cursor-pointer rounded-xl px-3 py-2 text-xs font-semibold text-secondary hover:bg-surface-soft">
|
||||
{{ $t('admin.schedule.form.dynamicParamsAdvanced') }}
|
||||
</summary>
|
||||
<div class="px-3 pb-3 pt-1">
|
||||
<textarea
|
||||
<ElCollapse v-model="advancedPanels">
|
||||
<ElCollapseItem :title="$t('admin.schedule.form.dynamicParamsAdvanced')" name="advanced">
|
||||
<ElInput
|
||||
v-model="advancedJsonText"
|
||||
class="w-full min-h-[72px] input-field p-3 text-xs leading-relaxed text-secondary font-mono resize-y"
|
||||
:class="advancedJsonError ? '!border-rose-300' : ''"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
class="schedule-mono"
|
||||
:placeholder="$t('admin.schedule.form.dynamicParamsAdvancedPlaceholder')"
|
||||
@input="handleAdvancedInput"
|
||||
></textarea>
|
||||
<p v-if="advancedJsonError" class="mt-1 text-xs text-rose-600">
|
||||
/>
|
||||
<p v-if="advancedJsonError" class="schedule-field-error">
|
||||
{{ $t('admin.schedule.form.dynamicParamsAdvancedInvalid') }}
|
||||
</p>
|
||||
</div>
|
||||
</details>
|
||||
</ElCollapseItem>
|
||||
</ElCollapse>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-params {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.schedule-param-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.schedule-param-label {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
}
|
||||
|
||||
.schedule-control {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.schedule-field-error {
|
||||
margin: 0;
|
||||
color: var(--el-color-danger);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
}
|
||||
|
||||
.schedule-mono :deep(.el-textarea__inner),
|
||||
.schedule-mono :deep(.el-input__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
.schedule-multi {
|
||||
display: flex;
|
||||
max-height: 13rem;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
overflow: auto;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.schedule-multi-option {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
</style>
|
||||
+532
-479
File diff suppressed because it is too large.
Load diff
+219
-192
@@ -1,8 +1,21 @@
|
||||
/**
|
||||
* ScheduleCronDesigner.vue
|
||||
* 排程运行时间图形化 / 高级 Cron 设计器。
|
||||
* features/admin/modules/schedules/components/ScheduleCronDesigner.vue
|
||||
* 用途:排程运行时间的图形化 / 高级 Cron 设计器。
|
||||
* 依赖:useScheduleCronDesigner、element-plus。
|
||||
* 逻辑:放在创建/编辑对话框里。控件换成 Element,仍调用原设计器方法生成 Cron,不改表达式语义。样式跟页面入口走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCheckTag,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElRadio,
|
||||
ElRadioButton,
|
||||
ElRadioGroup,
|
||||
} from 'element-plus';
|
||||
import type { useScheduleCronDesigner } from '../composables/useScheduleCronDesigner';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -13,251 +26,265 @@ const props = defineProps<{
|
||||
const d = props.designer;
|
||||
const { state, timezone, cronExpr, cronRisky, isValid, nextRunAt, weekdayOptions } = d;
|
||||
|
||||
/**
|
||||
* 切到图形化。已在该模式时不重算。
|
||||
*/
|
||||
const handleSwitchVisual = () => {
|
||||
if (state.value.editorMode === 'visual') return;
|
||||
d.switchToVisual();
|
||||
};
|
||||
|
||||
/**
|
||||
* 切到高级 Cron。已在该模式时不重算。
|
||||
*/
|
||||
const handleSwitchAdvanced = () => {
|
||||
if (state.value.editorMode === 'advanced') return;
|
||||
d.switchToAdvanced();
|
||||
};
|
||||
|
||||
/**
|
||||
* 编辑模式切换。解析失败时设计器会留在高级模式,单选跟着 model 走。
|
||||
* @param mode - 图形化或高级
|
||||
*/
|
||||
function onEditorModeChange(mode: string | number | boolean | undefined): void {
|
||||
if (mode === 'visual') handleSwitchVisual();
|
||||
else if (mode === 'advanced') handleSwitchAdvanced();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="rounded-2xl border border-default bg-surface-soft/40 p-4">
|
||||
<div class="mb-4 space-y-3">
|
||||
<div class="min-w-0">
|
||||
<h4 class="text-base font-bold text-primary">{{ $t('admin.schedule.form.cronTitle') }}</h4>
|
||||
<p class="mt-1 text-sm leading-relaxed text-muted">{{ $t('admin.schedule.form.cronHint') }}</p>
|
||||
<p class="mt-1 text-xs text-muted">{{ $t('admin.schedule.form.cronTimezoneHint', { tz: timezone }) }}</p>
|
||||
</div>
|
||||
<div
|
||||
class="segment-control segment-control--cols-2 segment-control--sm w-full max-w-xs"
|
||||
role="radiogroup"
|
||||
:aria-label="$t('admin.schedule.form.cronTitle')"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
role="radio"
|
||||
:aria-checked="state.editorMode === 'visual'"
|
||||
class="segment-item"
|
||||
:class="state.editorMode === 'visual' ? 'segment-item--active' : ''"
|
||||
@click="handleSwitchVisual"
|
||||
>
|
||||
{{ $t('admin.schedule.form.editorVisual') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="radio"
|
||||
:aria-checked="state.editorMode === 'advanced'"
|
||||
class="segment-item"
|
||||
:class="state.editorMode === 'advanced' ? 'segment-item--active' : ''"
|
||||
@click="handleSwitchAdvanced"
|
||||
>
|
||||
{{ $t('admin.schedule.form.editorAdvanced') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="schedule-cron">
|
||||
<div>
|
||||
<h4 class="schedule-cron-title">{{ $t('admin.schedule.form.cronTitle') }}</h4>
|
||||
<p class="hx-element-hint">{{ $t('admin.schedule.form.cronHint') }}</p>
|
||||
<p class="hx-element-hint">{{ $t('admin.schedule.form.cronTimezoneHint', { tz: timezone }) }}</p>
|
||||
</div>
|
||||
<ElRadioGroup :model-value="state.editorMode" @change="onEditorModeChange">
|
||||
<ElRadioButton value="visual">{{ $t('admin.schedule.form.editorVisual') }}</ElRadioButton>
|
||||
<ElRadioButton value="advanced">{{ $t('admin.schedule.form.editorAdvanced') }}</ElRadioButton>
|
||||
</ElRadioGroup>
|
||||
|
||||
<p
|
||||
<ElAlert
|
||||
v-if="state.parseFailed && state.editorMode === 'advanced'"
|
||||
class="mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800"
|
||||
>
|
||||
{{ $t('admin.schedule.form.parseFailedHint') }}
|
||||
</p>
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
:title="$t('admin.schedule.form.parseFailedHint')"
|
||||
/>
|
||||
|
||||
<template v-if="state.editorMode === 'visual'">
|
||||
<div class="mb-4">
|
||||
<div class="mb-2">
|
||||
<span class="text-xs font-semibold uppercase text-muted">{{ $t('admin.schedule.form.presetsTitle') }}</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" class="rounded-lg border border-default bg-surface px-3 py-1.5 text-xs font-medium text-secondary transition hover:border-blue-300 hover:text-primary" @click="d.setPreset('every_minutes')">
|
||||
{{ $t('admin.schedule.form.everyMinutes') }}
|
||||
</button>
|
||||
<button type="button" class="rounded-lg border border-default bg-surface px-3 py-1.5 text-xs font-medium text-secondary transition hover:border-blue-300 hover:text-primary" @click="d.setPreset('hourly')">
|
||||
{{ $t('admin.schedule.form.hourly') }}
|
||||
</button>
|
||||
<button type="button" class="rounded-lg border border-default bg-surface px-3 py-1.5 text-xs font-medium text-secondary transition hover:border-blue-300 hover:text-primary" @click="d.setPreset('daily')">
|
||||
{{ $t('admin.schedule.form.daily') }}
|
||||
</button>
|
||||
<button type="button" class="rounded-lg border border-default bg-surface px-3 py-1.5 text-xs font-medium text-secondary transition hover:border-blue-300 hover:text-primary" @click="d.setPreset('weekly')">
|
||||
{{ $t('admin.schedule.form.weekly') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default bg-surface px-3 py-1.5 text-xs font-medium text-secondary transition hover:border-blue-300 hover:text-primary"
|
||||
@click="d.applyAdvancedCron('0 12,17 * * *')"
|
||||
>
|
||||
{{ $t('admin.schedule.form.twiceDaily') }}
|
||||
</button>
|
||||
<div>
|
||||
<p class="schedule-cron-label">{{ $t('admin.schedule.form.presetsTitle') }}</p>
|
||||
<div class="schedule-cron-presets">
|
||||
<ElButton @click="d.setPreset('every_minutes')">{{ $t('admin.schedule.form.everyMinutes') }}</ElButton>
|
||||
<ElButton @click="d.setPreset('hourly')">{{ $t('admin.schedule.form.hourly') }}</ElButton>
|
||||
<ElButton @click="d.setPreset('daily')">{{ $t('admin.schedule.form.daily') }}</ElButton>
|
||||
<ElButton @click="d.setPreset('weekly')">{{ $t('admin.schedule.form.weekly') }}</ElButton>
|
||||
<ElButton @click="d.applyAdvancedCron('0 12,17 * * *')">{{ $t('admin.schedule.form.twiceDaily') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 月别 -->
|
||||
<div class="mb-4">
|
||||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-xs font-semibold uppercase text-muted">{{ $t('admin.schedule.form.months') }}</span>
|
||||
<div class="flex gap-2 text-xs">
|
||||
<button type="button" class="text-blue-600 hover:underline" @click="d.selectAllMonths()">{{ $t('admin.schedule.form.selectAll') }}</button>
|
||||
<button type="button" class="text-muted hover:underline" @click="d.clearAllMonths()">{{ $t('admin.schedule.form.clearAll') }}</button>
|
||||
</div>
|
||||
<div>
|
||||
<div class="schedule-cron-row">
|
||||
<span class="schedule-cron-label">{{ $t('admin.schedule.form.months') }}</span>
|
||||
<ElButton link type="primary" @click="d.selectAllMonths()">{{ $t('admin.schedule.form.selectAll') }}</ElButton>
|
||||
<ElButton link @click="d.clearAllMonths()">{{ $t('admin.schedule.form.clearAll') }}</ElButton>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-1.5">
|
||||
<label
|
||||
v-for="m in 12"
|
||||
:key="m"
|
||||
class="inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-1 text-xs transition"
|
||||
:class="d.isMonthSelected(m) ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-default bg-surface text-secondary'"
|
||||
<div class="schedule-cron-tags">
|
||||
<ElCheckTag
|
||||
v-for="month in 12"
|
||||
:key="month"
|
||||
:checked="d.isMonthSelected(month)"
|
||||
@change="d.toggleMonth(month)"
|
||||
>
|
||||
<input type="checkbox" class="sr-only" :checked="d.isMonthSelected(m)" @change="d.toggleMonth(m)" />
|
||||
{{ String(m).padStart(2, '0') }}
|
||||
</label>
|
||||
{{ String(month).padStart(2, '0') }}
|
||||
</ElCheckTag>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 周别 -->
|
||||
<div class="mb-4">
|
||||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-xs font-semibold uppercase text-muted">{{ $t('admin.schedule.form.weekdays') }}</span>
|
||||
<div class="flex gap-2 text-xs">
|
||||
<button type="button" class="text-blue-600 hover:underline" @click="d.selectAllWeekdays()">{{ $t('admin.schedule.form.selectAll') }}</button>
|
||||
<button type="button" class="text-muted hover:underline" @click="d.clearAllWeekdays()">{{ $t('admin.schedule.form.clearAll') }}</button>
|
||||
</div>
|
||||
<div>
|
||||
<div class="schedule-cron-row">
|
||||
<span class="schedule-cron-label">{{ $t('admin.schedule.form.weekdays') }}</span>
|
||||
<ElButton link type="primary" @click="d.selectAllWeekdays()">{{ $t('admin.schedule.form.selectAll') }}</ElButton>
|
||||
<ElButton link @click="d.clearAllWeekdays()">{{ $t('admin.schedule.form.clearAll') }}</ElButton>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-1.5">
|
||||
<label
|
||||
v-for="wd in weekdayOptions"
|
||||
:key="wd.value"
|
||||
class="inline-flex cursor-pointer items-center gap-1 rounded-md border px-2.5 py-1 text-xs transition"
|
||||
:class="d.isWeekdaySelected(wd.value) ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-default bg-surface text-secondary'"
|
||||
<div class="schedule-cron-tags">
|
||||
<ElCheckTag
|
||||
v-for="weekday in weekdayOptions"
|
||||
:key="weekday.value"
|
||||
:checked="d.isWeekdaySelected(weekday.value)"
|
||||
@change="d.toggleWeekday(weekday.value)"
|
||||
>
|
||||
<input type="checkbox" class="sr-only" :checked="d.isWeekdaySelected(wd.value)" @change="d.toggleWeekday(wd.value)" />
|
||||
{{ wd.label }}
|
||||
</label>
|
||||
{{ weekday.label }}
|
||||
</ElCheckTag>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 日别 -->
|
||||
<div class="mb-4">
|
||||
<div class="mb-2 flex flex-wrap items-center justify-between gap-2">
|
||||
<span class="text-xs font-semibold uppercase text-muted">{{ $t('admin.schedule.form.daysOfMonth') }}</span>
|
||||
<div class="flex gap-2 text-xs">
|
||||
<button type="button" class="text-blue-600 hover:underline" @click="d.selectAllDaysOfMonth()">{{ $t('admin.schedule.form.selectAll') }}</button>
|
||||
<button type="button" class="text-muted hover:underline" @click="d.clearAllDaysOfMonth()">{{ $t('admin.schedule.form.clearAll') }}</button>
|
||||
</div>
|
||||
<div>
|
||||
<div class="schedule-cron-row">
|
||||
<span class="schedule-cron-label">{{ $t('admin.schedule.form.daysOfMonth') }}</span>
|
||||
<ElButton link type="primary" @click="d.selectAllDaysOfMonth()">{{ $t('admin.schedule.form.selectAll') }}</ElButton>
|
||||
<ElButton link @click="d.clearAllDaysOfMonth()">{{ $t('admin.schedule.form.clearAll') }}</ElButton>
|
||||
</div>
|
||||
<p class="mb-2 text-xs text-muted">{{ $t('admin.schedule.form.domDowHint') }}</p>
|
||||
<div class="grid grid-cols-7 gap-1.5">
|
||||
<label
|
||||
<p class="hx-element-hint">{{ $t('admin.schedule.form.domDowHint') }}</p>
|
||||
<div class="schedule-cron-days">
|
||||
<ElCheckTag
|
||||
v-for="day in 31"
|
||||
:key="day"
|
||||
class="inline-flex cursor-pointer items-center justify-center rounded-md border py-1 text-xs transition"
|
||||
:class="d.isDayOfMonthSelected(day) ? 'border-blue-300 bg-blue-50 text-blue-700' : 'border-default bg-surface text-secondary'"
|
||||
:checked="d.isDayOfMonthSelected(day)"
|
||||
@change="d.toggleDayOfMonth(day)"
|
||||
>
|
||||
<input type="checkbox" class="sr-only" :checked="d.isDayOfMonthSelected(day)" @change="d.toggleDayOfMonth(day)" />
|
||||
{{ String(day).padStart(2, '0') }}
|
||||
</label>
|
||||
</ElCheckTag>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 执行时刻 -->
|
||||
<div class="mb-4 rounded-xl border border-default bg-surface p-4">
|
||||
<div class="mb-3 text-xs font-semibold uppercase text-muted">{{ $t('admin.schedule.form.timeModeTitle') }}</div>
|
||||
<div class="mb-4 flex flex-wrap gap-4">
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="state.timeMode" type="radio" value="fixed" class="h-4 w-4 text-blue-600" />
|
||||
{{ $t('admin.schedule.form.timeModeFixed') }}
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="state.timeMode" type="radio" value="interval" class="h-4 w-4 text-blue-600" />
|
||||
{{ $t('admin.schedule.form.timeModeInterval') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="schedule-cron-time">
|
||||
<p class="schedule-cron-label">{{ $t('admin.schedule.form.timeModeTitle') }}</p>
|
||||
<ElRadioGroup v-model="state.timeMode">
|
||||
<ElRadio value="fixed">{{ $t('admin.schedule.form.timeModeFixed') }}</ElRadio>
|
||||
<ElRadio value="interval">{{ $t('admin.schedule.form.timeModeInterval') }}</ElRadio>
|
||||
</ElRadioGroup>
|
||||
|
||||
<div v-if="state.timeMode === 'fixed'" class="grid grid-cols-2 gap-3 md:grid-cols-4">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.hour') }}</label>
|
||||
<input
|
||||
v-model.number="state.fixedHour"
|
||||
type="number"
|
||||
min="0"
|
||||
max="23"
|
||||
class="input-field !text-sm !leading-5"
|
||||
<div v-if="state.timeMode === 'fixed'" class="schedule-cron-grid">
|
||||
<ElFormItem :label="$t('admin.schedule.form.hour')">
|
||||
<ElInputNumber
|
||||
v-model="state.fixedHour"
|
||||
class="schedule-control"
|
||||
:min="0"
|
||||
:max="23"
|
||||
:value-on-clear="0"
|
||||
:disabled="state.wildcardHour"
|
||||
controls-position="right"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.minute') }}</label>
|
||||
<input v-model.number="state.fixedMinute" type="number" min="0" max="59" class="input-field !text-sm !leading-5" />
|
||||
</div>
|
||||
<div v-if="state.wildcardHour" class="col-span-2 flex items-end">
|
||||
<span class="text-xs text-muted">{{ $t('admin.schedule.form.hourlyHint') }}</span>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('admin.schedule.form.minute')">
|
||||
<ElInputNumber v-model="state.fixedMinute" class="schedule-control" :min="0" :max="59" :value-on-clear="0" controls-position="right" />
|
||||
</ElFormItem>
|
||||
<p v-if="state.wildcardHour" class="hx-element-hint">{{ $t('admin.schedule.form.hourlyHint') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="grid grid-cols-2 gap-3 md:grid-cols-4">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.timeStart') }}</label>
|
||||
<div class="flex gap-1">
|
||||
<input v-model.number="state.rangeStartHour" type="number" min="0" max="23" class="input-field !text-sm !leading-5 w-full" :placeholder="$t('admin.schedule.form.hour')" />
|
||||
<span class="self-center text-muted">:</span>
|
||||
<input v-model.number="state.rangeStartMinute" type="number" min="0" max="59" class="input-field !text-sm !leading-5 w-full" :placeholder="$t('admin.schedule.form.minute')" />
|
||||
<div v-else class="schedule-cron-grid">
|
||||
<ElFormItem :label="$t('admin.schedule.form.timeStart')">
|
||||
<div class="schedule-cron-clock">
|
||||
<ElInputNumber v-model="state.rangeStartHour" :min="0" :max="23" :value-on-clear="0" controls-position="right" />
|
||||
<span>:</span>
|
||||
<ElInputNumber v-model="state.rangeStartMinute" :min="0" :max="59" :value-on-clear="0" controls-position="right" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.timeEnd') }}</label>
|
||||
<div class="flex gap-1">
|
||||
<input v-model.number="state.rangeEndHour" type="number" min="0" max="23" class="input-field !text-sm !leading-5 w-full" :placeholder="$t('admin.schedule.form.hour')" />
|
||||
<span class="self-center text-muted">:</span>
|
||||
<input v-model.number="state.rangeEndMinute" type="number" min="0" max="59" class="input-field !text-sm !leading-5 w-full" :placeholder="$t('admin.schedule.form.minute')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('admin.schedule.form.timeEnd')">
|
||||
<div class="schedule-cron-clock">
|
||||
<ElInputNumber v-model="state.rangeEndHour" :min="0" :max="23" :value-on-clear="0" controls-position="right" />
|
||||
<span>:</span>
|
||||
<ElInputNumber v-model="state.rangeEndMinute" :min="0" :max="59" :value-on-clear="0" controls-position="right" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.intervalMinutes') }}</label>
|
||||
<input v-model.number="state.intervalMinutes" type="number" min="1" max="59" class="input-field !text-sm !leading-5" />
|
||||
</div>
|
||||
<div class="col-span-2 flex items-end md:col-span-1">
|
||||
<p class="text-xs text-muted">{{ $t('admin.schedule.form.intervalHourHint') }}</p>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="$t('admin.schedule.form.intervalMinutes')">
|
||||
<ElInputNumber v-model="state.intervalMinutes" class="schedule-control" :min="1" :max="59" :value-on-clear="1" controls-position="right" />
|
||||
</ElFormItem>
|
||||
<p class="hx-element-hint">{{ $t('admin.schedule.form.intervalHourHint') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.advancedCronInput') }}</label>
|
||||
<input
|
||||
v-model="state.advancedCronExpr"
|
||||
type="text"
|
||||
class="input-field font-mono !text-sm"
|
||||
placeholder="0 9 * * 1-5"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-muted">{{ $t('admin.schedule.form.advancedCronHint') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
<ElFormItem v-else :label="$t('admin.schedule.form.advancedCronInput')">
|
||||
<ElInput v-model="state.advancedCronExpr" class="schedule-mono" placeholder="0 9 * * 1-5" spellcheck="false" />
|
||||
<p class="hx-element-hint">{{ $t('admin.schedule.form.advancedCronHint') }}</p>
|
||||
</ElFormItem>
|
||||
|
||||
<p
|
||||
<ElAlert
|
||||
v-if="cronRisky"
|
||||
class="mb-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800"
|
||||
>
|
||||
{{ $t('admin.schedule.form.cronRiskyHint') }}
|
||||
</p>
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
:title="$t('admin.schedule.form.cronRiskyHint')"
|
||||
/>
|
||||
|
||||
<div
|
||||
class="mt-4 flex flex-col gap-1.5 rounded-xl border border-dashed px-4 py-3 text-xs sm:flex-row sm:flex-wrap sm:items-center sm:gap-x-4"
|
||||
:class="isValid ? 'border-default bg-surface-soft text-secondary' : 'border-red-200 bg-red-50 text-red-700'"
|
||||
>
|
||||
<span>
|
||||
{{ $t('admin.schedule.form.cronPreview') }}:<span class="font-mono text-primary">{{ cronExpr }}</span>
|
||||
</span>
|
||||
<div class="schedule-cron-preview" :class="isValid ? '' : 'is-invalid'">
|
||||
<span>{{ $t('admin.schedule.form.cronPreview') }}:<span class="schedule-mono-text">{{ cronExpr }}</span></span>
|
||||
<span v-if="nextRunAt && isValid">
|
||||
{{ $t('admin.schedule.form.nextRun') }}:
|
||||
<span class="font-medium text-primary">{{ formatDateTime(nextRunAt.toISOString()) }}</span>
|
||||
{{ $t('admin.schedule.form.nextRun') }}:{{ formatDateTime(nextRunAt.toISOString()) }}
|
||||
</span>
|
||||
<span v-if="!isValid">{{ $t('admin.schedule.form.cronInvalid') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-cron {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 16px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.schedule-cron-title {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-base);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.schedule-cron-label {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-extra-small);
|
||||
}
|
||||
|
||||
.schedule-cron-row,
|
||||
.schedule-cron-presets,
|
||||
.schedule-cron-tags,
|
||||
.schedule-cron-days,
|
||||
.schedule-cron-preview,
|
||||
.schedule-cron-clock {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.schedule-cron-days {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.schedule-cron-time {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-bg-color);
|
||||
}
|
||||
|
||||
.schedule-cron-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.schedule-control {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.schedule-cron-preview {
|
||||
padding: 12px;
|
||||
border: 1px dashed var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.schedule-cron-preview.is-invalid {
|
||||
border-color: var(--el-color-danger);
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.schedule-mono-text,
|
||||
.schedule-mono :deep(.el-input__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
</style>
|
||||
+191
-134
@@ -1,153 +1,210 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleOverviewPanel.vue
|
||||
* 定时任务概览模式:统计卡片与任务卡片网格。
|
||||
* 依赖:schedules.context、lucide-vue-next。
|
||||
* 逻辑:inject admin;展示 schedules 列表与快捷操作。
|
||||
* 用途:排程概览。一张列表卡片里放标题、刷新/新增、统计和排程卡片。
|
||||
* 依赖:AdminListPage、SchedulePageHeader、schedules.context、element-plus。
|
||||
* 逻辑:SchedulesPage 在 overview 模式渲染本组件。点卡片进入工作台。样式跟页面入口走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { Edit3, FlaskConical, Plus, Power, PowerOff, Rocket, Settings2, Trash2 } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Opportunity, Plus, Promotion, Refresh, VideoPause, VideoPlay } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElCard, ElEmpty, ElSpace, ElStatistic, ElTag } from 'element-plus';
|
||||
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import type { ScheduleTask } from '@/shared/types/schedule.types';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
import SchedulePageHeader from './SchedulePageHeader.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
|
||||
/**
|
||||
* 进入指定排程的工作台。
|
||||
* @param taskId - 排程主键
|
||||
*/
|
||||
function openWorkbench(taskId: number): void {
|
||||
void admin.openScheduleRunSubmenu(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新排程列表。
|
||||
*/
|
||||
function refreshSchedules(): void {
|
||||
void admin.loadSchedules();
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开编辑对话框。
|
||||
* @param task - 当前排程卡片
|
||||
*/
|
||||
function editSchedule(task: ScheduleTask): void {
|
||||
admin.openScheduleEditModal(task);
|
||||
}
|
||||
</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>
|
||||
<AdminListPage :loading="admin.scheduleLoading">
|
||||
<template #title>
|
||||
<SchedulePageHeader />
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElSpace wrap>
|
||||
<ElButton :icon="Refresh" @click="refreshSchedules">
|
||||
{{ t('admin.schedule.refresh') }}
|
||||
</ElButton>
|
||||
<ElButton type="primary" :icon="Plus" @click="admin.openScheduleCreateModal">
|
||||
{{ t('admin.schedule.addButton') }}
|
||||
</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
<template #filters>
|
||||
<div class="schedule-stats">
|
||||
<ElStatistic :title="t('admin.schedule.stats.total')" :value="admin.schedules.length" />
|
||||
<ElStatistic :title="t('admin.schedule.stats.enabled')" :value="admin.scheduleEnabledCount" />
|
||||
<ElStatistic :title="t('admin.schedule.stats.disabled')" :value="admin.scheduleDisabledCount" />
|
||||
<ElStatistic :title="t('admin.schedule.stats.running')" :value="admin.scheduleRunningCount" />
|
||||
</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>
|
||||
<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>
|
||||
<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>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<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="schedule-overview">
|
||||
<p class="hx-element-hint">{{ t('admin.schedule.switchByCard') }}</p>
|
||||
<div class="schedule-grid">
|
||||
<ElCard shadow="hover" class="schedule-card">
|
||||
<p class="schedule-card-title">{{ t('admin.schedule.addTitle') }}</p>
|
||||
<p class="hx-element-hint">{{ t('admin.schedule.addHint') }}</p>
|
||||
<div class="schedule-card-actions">
|
||||
<ElButton type="primary" :icon="Plus" @click="admin.openScheduleCreateModal">
|
||||
{{ t('admin.schedule.addButton') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElCard>
|
||||
|
||||
<ElCard
|
||||
v-for="task in admin.schedules"
|
||||
:key="task.id"
|
||||
shadow="hover"
|
||||
class="schedule-card schedule-card--link"
|
||||
@click="openWorkbench(task.id)"
|
||||
>
|
||||
<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 class="schedule-card-head">
|
||||
<div class="schedule-card-name">
|
||||
<p class="schedule-card-title">{{ task.name }}</p>
|
||||
<p class="hx-element-hint" :title="task.schedule_no">{{ task.schedule_no }}</p>
|
||||
</div>
|
||||
<ElTag :type="task.enabled ? 'success' : 'info'" effect="light">
|
||||
{{ task.enabled ? t('admin.schedule.enabled') : t('admin.schedule.disabled') }}
|
||||
</ElTag>
|
||||
</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>
|
||||
<p class="schedule-card-meta">Cron:{{ task.cron_expr }}</p>
|
||||
<p class="schedule-card-meta">{{ t('admin.schedule.owner') }}:{{ task.owner_username || task.owner_user_id }}</p>
|
||||
<p class="schedule-card-meta">{{ t('admin.schedule.lastRun') }}:{{ admin.formatDateTime(task.last_run_at) }}</p>
|
||||
<p class="schedule-card-meta">{{ t('admin.schedule.nextRun') }}:{{ admin.formatDateTime(task.next_run_at) }}</p>
|
||||
<div class="schedule-card-actions" @click.stop>
|
||||
<ElButton link type="primary" @click="editSchedule(task)">
|
||||
{{ t('admin.schedule.actions.edit') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!task.enabled"
|
||||
link
|
||||
:icon="VideoPlay"
|
||||
@click="admin.setScheduleEnabled(task.id, true)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.start') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-else
|
||||
link
|
||||
:icon="VideoPause"
|
||||
@click="admin.setScheduleEnabled(task.id, false)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.pause') }}
|
||||
</ElButton>
|
||||
<ElButton link :icon="Promotion" @click="admin.runScheduleNow(task.id)">
|
||||
{{ t('admin.schedule.actions.run') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="task.schedule_type === 'data_pipeline' && task.data_source_type === 'database'"
|
||||
link
|
||||
:icon="Opportunity"
|
||||
@click="admin.openTestRunDialog(task)"
|
||||
>
|
||||
{{ t('admin.schedule.actions.test') }}
|
||||
</ElButton>
|
||||
<ElButton link type="danger" @click="admin.deleteSchedule(task)">
|
||||
{{ 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>
|
||||
</ElCard>
|
||||
</div>
|
||||
<ElEmpty v-if="admin.schedules.length === 0" :description="t('admin.schedule.emptyList')" />
|
||||
</div>
|
||||
</div>
|
||||
</AdminListPage>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-stats {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 16px 32px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.schedule-overview {
|
||||
padding: 16px 32px 24px;
|
||||
}
|
||||
|
||||
.schedule-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 16px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.schedule-card {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.schedule-card--link {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.schedule-card :deep(.el-card__body) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
min-height: 220px;
|
||||
}
|
||||
|
||||
.schedule-card-head {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.schedule-card-name {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.schedule-card-title {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-base);
|
||||
font-weight: 600;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.schedule-card-meta {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-small);
|
||||
}
|
||||
|
||||
.schedule-card-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 8px;
|
||||
margin-top: auto;
|
||||
padding-top: 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,46 +1,40 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/components/SchedulePageHeader.vue
|
||||
* 定时任务页顶栏:返回、标题、刷新。
|
||||
* 依赖:schedules.context、lucide-vue-next。
|
||||
* 逻辑:inject admin 上下文;概览/工作台模式切换标题与返回按钮。
|
||||
* 用途:排程列表卡片的标题区。概览与工作台共用,工作台多一个返回按钮。
|
||||
* 依赖:schedules.context、element-plus 的 ElButton、@element-plus/icons-vue。
|
||||
* 逻辑:由 ScheduleOverviewPanel / ScheduleWorkbenchPanel 放进 AdminListPage 的 #title。样式跟页面入口走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ArrowLeft, RefreshCw, Settings2 } from 'lucide-vue-next';
|
||||
import { ArrowLeft } from '@element-plus/icons-vue';
|
||||
import { ElButton } from 'element-plus';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
|
||||
const admin = useSchedulesAdminContext();
|
||||
</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"
|
||||
@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>
|
||||
</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 class="schedule-page-title">
|
||||
<ElButton
|
||||
v-if="admin.scheduleViewMode === 'workbench'"
|
||||
:icon="ArrowLeft"
|
||||
:title="$t('admin.schedule.overviewTitle')"
|
||||
@click="admin.backToScheduleOverview"
|
||||
/>
|
||||
<div>
|
||||
<h2 class="section-title">
|
||||
{{ admin.scheduleViewMode === 'overview' ? $t('admin.schedule.overviewTitle') : $t('admin.schedule.workbenchTitle') }}
|
||||
</h2>
|
||||
<p class="section-desc mt-1">
|
||||
{{ admin.scheduleViewMode === 'overview' ? $t('admin.schedule.overviewSubtitle') : $t('admin.schedule.workbenchSubtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-page-title {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
}
|
||||
</style>
|
||||
+209
-169
@@ -1,183 +1,223 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/schedules/components/ScheduleTestRunDialog.vue
|
||||
* 定时任务试运行弹窗。
|
||||
* 用途:定时任务试运行对话框。SQL、条数和是否写入知识库。
|
||||
* 依赖:schedules.context、element-plus。
|
||||
* 逻辑:SchedulesPageOverlays 挂载。只换控件,试运行仍调用原来的 handleTestRun。样式跟页面入口走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElStatistic,
|
||||
ElSwitch,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const admin = useSchedulesAdminContext();
|
||||
|
||||
/**
|
||||
* 对话框关闭时收起。试运行过程中不收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onDialogVisible(open: boolean): void {
|
||||
if (open || admin.testRunLoading) return;
|
||||
admin.showTestRunDialog = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 步骤日志对应的标签色。
|
||||
* @param status - 步骤状态
|
||||
* @returns Element 标签类型
|
||||
*/
|
||||
function stepTagType(status: string): 'success' | 'danger' | 'info' {
|
||||
if (status === 'success') return 'success';
|
||||
if (status === 'failed') return 'danger';
|
||||
return 'info';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="admin.showTestRunDialog" class="admin-modal-overlay items-center">
|
||||
<div class="admin-modal-panel max-w-4xl max-h-[90vh] overflow-y-auto">
|
||||
<div class="admin-modal-header sticky top-0 z-10 px-6 py-4 rounded-t-3xl">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-primary">{{ $t('admin.schedule.testRun.title', { name: admin.testRunSchedule?.name }) }}</h3>
|
||||
<p class="text-xs text-muted mt-0.5">{{ $t('admin.schedule.testRun.subtitle') }}</p>
|
||||
</div>
|
||||
<button @click="admin.showTestRunDialog = false" class="rounded-xl border border-default px-3 py-1.5 text-sm text-muted hover:bg-surface-soft">{{ $t('admin.schedule.testRun.close') }}</button>
|
||||
<ElDialog
|
||||
:model-value="admin.showTestRunDialog"
|
||||
:title="t('admin.schedule.testRun.title', { name: admin.testRunSchedule?.name })"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!admin.testRunLoading"
|
||||
:show-close="!admin.testRunLoading"
|
||||
@update:model-value="onDialogVisible"
|
||||
>
|
||||
<p class="hx-element-hint">{{ t('admin.schedule.testRun.subtitle') }}</p>
|
||||
<ElForm label-position="top">
|
||||
<ElFormItem :label="t('admin.schedule.testRun.baseFetchSqlReadonly')">
|
||||
<ElInput :model-value="admin.testRunBaseFetchSql" type="textarea" :rows="6" readonly class="schedule-mono" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.form.fetchWhereConditions')">
|
||||
<ElInput v-model="admin.testRunWhere" type="textarea" :rows="4" class="schedule-mono" />
|
||||
</ElFormItem>
|
||||
<div class="schedule-form-grid">
|
||||
<ElFormItem :label="t('admin.schedule.form.fetchOrderBy')">
|
||||
<ElInput v-model="admin.testRunOrderBy" class="schedule-mono" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.schedule.testRun.limitRows')">
|
||||
<ElInputNumber v-model="admin.testRunLimit" class="schedule-control" :min="1" :max="10" :value-on-clear="1" controls-position="right" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="p-6 space-y-4">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.testRun.baseFetchSqlReadonly') }}</label>
|
||||
<textarea
|
||||
:value="admin.testRunBaseFetchSql"
|
||||
readonly
|
||||
class="w-full min-h-[120px] rounded-xl border border-default bg-surface-soft p-3 text-xs leading-relaxed text-muted font-mono resize-y cursor-default"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-semibold text-muted uppercase">{{ $t('admin.schedule.form.fetchWhereConditions') }}</label>
|
||||
<textarea
|
||||
v-model="admin.testRunWhere"
|
||||
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"
|
||||
/>
|
||||
</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.fetchOrderBy') }}</label>
|
||||
<input v-model="admin.testRunOrderBy" 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.testRun.limitRows') }}</label>
|
||||
<input type="number" v-model.number="admin.testRunLimit" min="1" max="10" 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="rounded-xl border border-emerald-200 bg-emerald-50/40 px-4 py-3">
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input
|
||||
v-model="admin.testRunKbSync"
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-default text-emerald-600 focus:ring-emerald-300"
|
||||
:disabled="!admin.testRunKbSyncAvailable"
|
||||
/>
|
||||
{{ $t('admin.schedule.testRun.writeToKb') }}
|
||||
</label>
|
||||
<p class="mt-1 text-xs text-muted">
|
||||
{{ admin.testRunKbSyncAvailable ? $t('admin.schedule.testRun.writeToKbHint') : $t('admin.schedule.testRun.noKbGroupHint') }}
|
||||
<div class="schedule-block">
|
||||
<ElSwitch v-model="admin.testRunKbSync" :disabled="!admin.testRunKbSyncAvailable" />
|
||||
<span>{{ t('admin.schedule.testRun.writeToKb') }}</span>
|
||||
<p class="hx-element-hint">
|
||||
{{ admin.testRunKbSyncAvailable ? t('admin.schedule.testRun.writeToKbHint') : t('admin.schedule.testRun.noKbGroupHint') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="schedule-inline-actions">
|
||||
<ElButton type="primary" :loading="admin.testRunLoading" @click="admin.handleTestRun">
|
||||
{{ admin.testRunLoading ? t('admin.schedule.testRun.running') : t('admin.schedule.testRun.start') }}
|
||||
</ElButton>
|
||||
<span v-if="admin.testRunLoading" class="hx-element-hint">{{ t('admin.schedule.testRun.waitingHint') }}</span>
|
||||
</div>
|
||||
</ElForm>
|
||||
|
||||
<div v-if="admin.testRunResult" class="schedule-test-result">
|
||||
<div class="schedule-stats">
|
||||
<ElStatistic :title="t('admin.schedule.testRun.total')" :value="admin.testRunResult.total_count" />
|
||||
<ElStatistic :title="t('admin.schedule.testRun.success')" :value="admin.testRunResult.success_count" />
|
||||
<ElStatistic :title="t('admin.schedule.testRun.failed')" :value="admin.testRunResult.failed_count" />
|
||||
<ElStatistic :title="t('admin.schedule.testRun.skipped')" :value="admin.testRunResult.skipped_count" />
|
||||
</div>
|
||||
<p class="hx-element-hint">
|
||||
{{ t('admin.schedule.testRun.limitSummary', { limit: admin.testRunResult.limit, agentId: admin.testRunResult.dify_agent_id || t('admin.schedule.testRun.noAgent') }) }}
|
||||
</p>
|
||||
|
||||
<div v-if="admin.testRunResult.dify_execution_snapshot" class="schedule-block">
|
||||
<h4 class="schedule-block-title">{{ t('admin.schedule.difySnapshot.title') }}</h4>
|
||||
<template v-if="admin.testRunResult.dify_execution_snapshot.dify_enabled">
|
||||
<p>
|
||||
{{ t('admin.schedule.difySnapshot.agent') }}:
|
||||
{{ admin.testRunResult.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
{{ t('admin.schedule.difySnapshot.agentId', { id: admin.testRunResult.dify_execution_snapshot.dify_agent_id ?? '-' }) }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-violet-600 px-4 py-2 text-sm font-semibold text-white transition hover:bg-violet-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="admin.testRunLoading"
|
||||
@click="admin.handleTestRun"
|
||||
>
|
||||
{{ admin.testRunLoading ? $t('admin.schedule.testRun.running') : $t('admin.schedule.testRun.start') }}
|
||||
</button>
|
||||
<span v-if="admin.testRunLoading" class="text-xs text-muted">{{ $t('admin.schedule.testRun.waitingHint') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="admin.testRunResult" class="space-y-4 mt-2">
|
||||
<div class="flex items-center gap-4 rounded-xl border border-default bg-surface-soft/50 px-4 py-3">
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold text-primary">{{ admin.testRunResult.total_count }}</div>
|
||||
<div class="text-[10px] text-muted">{{ $t('admin.schedule.testRun.total') }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold text-emerald-600">{{ admin.testRunResult.success_count }}</div>
|
||||
<div class="text-[10px] text-muted">{{ $t('admin.schedule.testRun.success') }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold text-rose-600">{{ admin.testRunResult.failed_count }}</div>
|
||||
<div class="text-[10px] text-muted">{{ $t('admin.schedule.testRun.failed') }}</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold text-amber-600">{{ admin.testRunResult.skipped_count }}</div>
|
||||
<div class="text-[10px] text-muted">{{ $t('admin.schedule.testRun.skipped') }}</div>
|
||||
</div>
|
||||
<div class="ml-auto text-xs text-muted">
|
||||
{{ $t('admin.schedule.testRun.limitSummary', { limit: admin.testRunResult.limit, agentId: admin.testRunResult.dify_agent_id || $t('admin.schedule.testRun.noAgent') }) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="admin.testRunResult.dify_execution_snapshot"
|
||||
class="rounded-xl border border-indigo-200 bg-indigo-50/50 p-3"
|
||||
>
|
||||
<h4 class="mb-2 text-sm font-bold text-indigo-900">{{ $t('admin.schedule.difySnapshot.title') }}</h4>
|
||||
<div v-if="admin.testRunResult.dify_execution_snapshot.dify_enabled" class="space-y-2 text-xs text-secondary">
|
||||
<div>
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.difySnapshot.agent') }}:</span>
|
||||
{{ admin.testRunResult.dify_execution_snapshot.dify_agent_name || '-' }}
|
||||
{{ $t('admin.schedule.difySnapshot.agentId', { id: admin.testRunResult.dify_execution_snapshot.dify_agent_id ?? '-' }) }}
|
||||
</div>
|
||||
<div>
|
||||
<span class="mb-1 block font-semibold text-muted">{{ $t('admin.schedule.difySnapshot.systemPrompt') }}:</span>
|
||||
<pre
|
||||
v-if="admin.testRunResult.dify_execution_snapshot.dify_system_prompt"
|
||||
class="max-h-[200px] overflow-auto whitespace-pre-wrap rounded-lg border border-indigo-100 bg-surface p-3 font-mono text-[11px] text-primary"
|
||||
>{{ admin.testRunResult.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<span v-else class="text-muted">{{ $t('admin.schedule.difySnapshot.notConfigured') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="text-xs text-muted">{{ $t('admin.schedule.difySnapshot.notEnabledTest') }}</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4 class="text-sm font-bold text-secondary mb-2">{{ $t('admin.schedule.testRun.stepLogs') }}</h4>
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="(log, li) in admin.testRunResult.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>
|
||||
|
||||
<details>
|
||||
<summary class="cursor-pointer text-xs font-semibold text-muted hover:text-secondary">{{ $t('admin.schedule.testRun.viewSql') }}</summary>
|
||||
<pre class="admin-pre-block admin-pre-block--sql">{{ admin.testRunResult.sql }}</pre>
|
||||
</details>
|
||||
|
||||
<details v-if="admin.testRunResult.errors && admin.testRunResult.errors.length > 0">
|
||||
<summary class="cursor-pointer text-xs font-semibold text-rose-600 hover:text-rose-800">{{ $t('admin.schedule.testRun.errors', { count: admin.testRunResult.errors.length }) }}</summary>
|
||||
<pre class="mt-1 whitespace-pre-wrap rounded-lg bg-rose-50 p-3 text-xs text-rose-700 font-mono">{{ admin.testRunResult.errors.join('\n') }}</pre>
|
||||
</details>
|
||||
|
||||
<div
|
||||
v-if="admin.testRunKbSyncAttempted"
|
||||
class="rounded-xl border px-4 py-3 text-xs text-secondary"
|
||||
:class="admin.testRunResult.kb_sync_status === 'success' ? 'border-emerald-200 bg-emerald-50/40' : admin.testRunResult.kb_sync_status === 'failed' ? 'border-rose-200 bg-rose-50/40' : 'border-amber-200 bg-amber-50/40'"
|
||||
>
|
||||
<div class="font-bold" :class="admin.testRunResult.kb_sync_status === 'success' ? 'text-emerald-800' : admin.testRunResult.kb_sync_status === 'failed' ? 'text-rose-800' : 'text-amber-800'">
|
||||
{{ $t('admin.schedule.kbSync.title') }}
|
||||
</div>
|
||||
<div v-if="admin.testRunResult.kb_sync_status" class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.kbSync.status') }}:</span>
|
||||
{{ admin.testRunResult.kb_sync_status }}
|
||||
</div>
|
||||
<div v-else class="mt-1 text-amber-700">
|
||||
{{ $t('admin.schedule.testRun.kbSyncNoStatus') }}
|
||||
</div>
|
||||
<div v-if="admin.testRunResult.kb_document_id" class="mt-1">
|
||||
<span class="font-semibold text-muted">{{ $t('admin.schedule.kbSync.document') }}:</span>
|
||||
{{ admin.testRunResult.kb_document_id }}
|
||||
</div>
|
||||
<div v-if="admin.testRunResult.kb_sync_error" class="mt-1 text-rose-600">
|
||||
{{ admin.testRunResult.kb_sync_error }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>{{ t('admin.schedule.difySnapshot.systemPrompt') }}:</p>
|
||||
<pre v-if="admin.testRunResult.dify_execution_snapshot.dify_system_prompt" class="schedule-pre">{{ admin.testRunResult.dify_execution_snapshot.dify_system_prompt }}</pre>
|
||||
<p v-else class="hx-element-hint">{{ t('admin.schedule.difySnapshot.notConfigured') }}</p>
|
||||
</template>
|
||||
<p v-else class="hx-element-hint">{{ t('admin.schedule.difySnapshot.notEnabledTest') }}</p>
|
||||
</div>
|
||||
|
||||
<h4 class="schedule-block-title">{{ t('admin.schedule.testRun.stepLogs') }}</h4>
|
||||
<div v-for="(log, index) in admin.testRunResult.step_logs" :key="index" class="schedule-step">
|
||||
<ElTag :type="stepTagType(log.status)" effect="light">
|
||||
{{ (admin.stepStatusMap[log.status] || { label: log.status }).label }}
|
||||
</ElTag>
|
||||
<span>{{ admin.stepLabelMap[log.step] || log.step }}</span>
|
||||
<span v-if="log.row_id" class="hx-element-hint">row_id={{ log.row_id }}</span>
|
||||
<span v-if="log.duration_ms != null" class="hx-element-hint">{{ log.duration_ms }}ms</span>
|
||||
<details v-if="log.detail">
|
||||
<summary>{{ t('admin.schedule.viewDetail') }}</summary>
|
||||
<pre class="schedule-pre">{{ JSON.stringify(log.detail, null, 2) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<details>
|
||||
<summary>{{ t('admin.schedule.testRun.viewSql') }}</summary>
|
||||
<pre class="schedule-pre">{{ admin.testRunResult.sql }}</pre>
|
||||
</details>
|
||||
<details v-if="admin.testRunResult.errors && admin.testRunResult.errors.length > 0">
|
||||
<summary>{{ t('admin.schedule.testRun.errors', { count: admin.testRunResult.errors.length }) }}</summary>
|
||||
<pre class="schedule-pre">{{ admin.testRunResult.errors.join('\n') }}</pre>
|
||||
</details>
|
||||
|
||||
<ElAlert
|
||||
v-if="admin.testRunKbSyncAttempted"
|
||||
:type="admin.testRunResult.kb_sync_status === 'success' ? 'success' : admin.testRunResult.kb_sync_status === 'failed' ? 'error' : 'warning'"
|
||||
:closable="false"
|
||||
:title="t('admin.schedule.kbSync.title')"
|
||||
>
|
||||
<p v-if="admin.testRunResult.kb_sync_status">{{ t('admin.schedule.kbSync.status') }}:{{ admin.testRunResult.kb_sync_status }}</p>
|
||||
<p v-else>{{ t('admin.schedule.testRun.kbSyncNoStatus') }}</p>
|
||||
<p v-if="admin.testRunResult.kb_document_id">{{ t('admin.schedule.kbSync.document') }}:{{ admin.testRunResult.kb_document_id }}</p>
|
||||
<p v-if="admin.testRunResult.kb_sync_error">{{ admin.testRunResult.kb_sync_error }}</p>
|
||||
</ElAlert>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<ElButton :disabled="admin.testRunLoading" @click="admin.showTestRunDialog = false">
|
||||
{{ t('admin.schedule.testRun.close') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.schedule-form-grid,
|
||||
.schedule-stats,
|
||||
.schedule-inline-actions,
|
||||
.schedule-step {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 16px;
|
||||
}
|
||||
|
||||
.schedule-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.schedule-control {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.schedule-block,
|
||||
.schedule-test-result {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.schedule-block {
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.schedule-block-title {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-base);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.schedule-step {
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
}
|
||||
|
||||
.schedule-mono :deep(.el-textarea__inner),
|
||||
.schedule-mono :deep(.el-input__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
.schedule-pre {
|
||||
max-height: 200px;
|
||||
overflow: auto;
|
||||
margin: 8px 0 0;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
white-space: pre-wrap;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
</style>
|
||||
+583
-402
File diff suppressed because it is too large.
Load diff
@@ -1,24 +1,15 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/schedules/components/SchedulesPageOverlays.vue
|
||||
* 定时任务页弹窗层:试运行、创建/编辑、删除确认。
|
||||
* 用途:排程页弹窗层,挂试运行和创建/编辑对话框。
|
||||
* 依赖:ScheduleCreateEditModal、ScheduleTestRunDialog。
|
||||
* 逻辑:SchedulesPage 放在 ElConfigProvider 内。两个对话框自行 inject admin。删除确认由列表 composable 的 ElMessageBox 处理。
|
||||
*/
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { useSchedulesAdminContext } from '../composables/schedules.context';
|
||||
<script setup lang="ts">
|
||||
import ScheduleCreateEditModal from './ScheduleCreateEditModal.vue';
|
||||
import ScheduleTestRunDialog from './ScheduleTestRunDialog.vue';
|
||||
|
||||
const admin = useSchedulesAdminContext();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ScheduleTestRunDialog />
|
||||
<ScheduleCreateEditModal />
|
||||
<DeleteConfirmDialog
|
||||
v-model="admin.showDeleteConfirmDialog"
|
||||
:title="admin.deleteConfirmTitle"
|
||||
:message="admin.deleteConfirmMessage"
|
||||
@cancel="admin.closeDeleteConfirm"
|
||||
@confirm="admin.confirmDelete"
|
||||
/>
|
||||
</template>
|
||||
+7
-1
@@ -85,7 +85,12 @@ export function useScheduleAdminForm(
|
||||
platformJobParamsValid.value = true;
|
||||
};
|
||||
|
||||
const formatUserOptionLabel = (u: AdminUserRow) =>
|
||||
/**
|
||||
* 负责人下拉的展示文案:姓名优先,有工号时附在后面。
|
||||
* @param u - 管理端用户
|
||||
* @returns 下拉选项文字
|
||||
*/
|
||||
const formatUserOptionLabel = (u: AdminUserRow): string =>
|
||||
`${u.real_name || u.username}${u.employee_id ? `(${u.employee_id})` : ''}`;
|
||||
|
||||
const filteredNotifyUsers = computed(() => {
|
||||
@@ -478,6 +483,7 @@ export function useScheduleAdminForm(
|
||||
selectScheduleOwner,
|
||||
handleScheduleOwnerInput,
|
||||
scheduleCloseOwnerDropdown,
|
||||
formatUserOptionLabel,
|
||||
getUserName,
|
||||
toggleNotifyUser,
|
||||
removeNotifyUser,
|
||||
|
||||
+33
-19
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminList.ts
|
||||
* 任务列表加载、概览统计、启停/立即执行/删除与视图切换。
|
||||
* 依赖:schedule.api、useMessage、element-plus 的 ElMessageBox。
|
||||
* 逻辑:SchedulesPage 经 useSchedulesAdmin 调用。删除先弹 Element 确认框,取消则不请求。
|
||||
* 等待轮询策略:点「立即执行」后只轻量刷新任务 last_status(不刷执行记录 runs),
|
||||
* 直到离开 running 再拉一次 runs;与「执行记录=历史查询、不做定时刷新」对齐。
|
||||
* 同一任务仅保留一个轮询、上一轮未返回时跳过,并设 RUN_NOW_POLL_MAX_MS 上限。
|
||||
@@ -9,6 +11,7 @@
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
deleteAdminSchedule,
|
||||
listAdminSchedules,
|
||||
@@ -37,7 +40,6 @@ export function useScheduleAdminList(
|
||||
selectedScheduleId,
|
||||
selectedScheduleRuns,
|
||||
scheduleViewMode,
|
||||
openDeleteConfirm,
|
||||
} = state;
|
||||
|
||||
/** 各任务运行中的单实例等待轮询句柄(重复点「立即执行」复用同一句柄) */
|
||||
@@ -149,24 +151,36 @@ export function useScheduleAdminList(
|
||||
}
|
||||
};
|
||||
|
||||
const deleteSchedule = (task: ScheduleTask) => {
|
||||
openDeleteConfirm(
|
||||
t('admin.schedule.deleteConfirmMessage', { name: task.name }),
|
||||
async () => {
|
||||
try {
|
||||
await deleteAdminSchedule(task.id);
|
||||
} catch (err: any) {
|
||||
msg.error(err?.message || t('admin.schedule.msg.deleteFailed'));
|
||||
return;
|
||||
}
|
||||
if (selectedScheduleId.value === task.id) {
|
||||
selectedScheduleId.value = null;
|
||||
selectedScheduleRuns.value = [];
|
||||
}
|
||||
await loadSchedules();
|
||||
},
|
||||
t('admin.schedule.deleteDialogTitle'),
|
||||
);
|
||||
/**
|
||||
* 删除指定排程。先用 Element 确认框询问,取消则不请求。
|
||||
* 核心逻辑:MessageBox 取消时 reject,这里吞掉;确定后调删除接口并刷新列表。
|
||||
* @param task - 要删除的排程
|
||||
*/
|
||||
const deleteSchedule = async (task: ScheduleTask): Promise<void> => {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.schedule.deleteConfirmMessage', { name: task.name }),
|
||||
t('common.deleteDialog.defaultTitle'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await deleteAdminSchedule(task.id);
|
||||
} catch (err: any) {
|
||||
msg.error(err?.message || t('admin.schedule.msg.deleteFailed'));
|
||||
return;
|
||||
}
|
||||
if (selectedScheduleId.value === task.id) {
|
||||
selectedScheduleId.value = null;
|
||||
selectedScheduleRuns.value = [];
|
||||
}
|
||||
await loadSchedules();
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,14 +1,32 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-audit/ShippingAuditCenterPage.vue
|
||||
用途:管理员货代统一审计中心——按 Conversation/Run/Candidate/Task/Gate/节点分组筛选、详情 Diff、关联链、哈希校验、受控导出。
|
||||
依赖:shipping-audit.api、shippingAuditDisplay、ShippingAuditEventDetailDrawer、Vue I18n、BusinessError、useMessage。
|
||||
逻辑:列表不含快照全文;详情抽屉按权限脱敏;导出/校验写服务端访问审计;
|
||||
事件分组含复核/对话/Process Gate/资格/节点;支持 candidate_no / gate_code;
|
||||
窄屏用卡片列表;桌面表无横滚,Case/Task 在业务关联列,WF/Item/Run 芯片可复制。
|
||||
-->
|
||||
/**
|
||||
* features/admin/modules/shipping-audit/ShippingAuditCenterPage.vue
|
||||
* 用途:管理员货代统一审计中心列表。按会话、运行、候选、任务、Gate 和节点筛选,并打开详情。
|
||||
* 依赖:AdminListPage、useElementProvider、element-plus、shipping-audit.api、shippingAuditDisplay、ShippingAuditEventDetailDrawer。
|
||||
* 逻辑:列表不含快照全文。骨架用 AdminListPage。详情抽屉按权限脱敏。导出和哈希校验仍走原接口。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download, Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
ElDatePicker,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
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 { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
@@ -26,15 +44,17 @@ import ShippingAuditEventDetailDrawer from './ShippingAuditEventDetailDrawer.vue
|
||||
import { shippingAuditBusinessLabel } from './shippingAuditDisplay';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const vLoading = ElLoading.directive;
|
||||
const msg = useMessage();
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const exporting = ref(false);
|
||||
const verifying = ref(false);
|
||||
const moreOpen = ref(false);
|
||||
const error = ref('');
|
||||
const page = ref(1);
|
||||
const pageSize = 25;
|
||||
const pageSize = ref(25);
|
||||
const pageSizes = [10, 25, 50, 100];
|
||||
const total = ref(0);
|
||||
const rows = ref<ShippingAuditEventSummary[]>([]);
|
||||
const detail = ref<ShippingAuditEventDetail | null>(null);
|
||||
@@ -155,7 +175,7 @@ async function load() {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const response = await listShippingAuditEvents(page.value, pageSize, buildFilterPayload());
|
||||
const response = await listShippingAuditEvents(page.value, pageSize.value, buildFilterPayload());
|
||||
rows.value = response.items;
|
||||
total.value = response.total;
|
||||
} catch (err) {
|
||||
@@ -194,7 +214,6 @@ async function openDetail(eventId: number) {
|
||||
async function loadAssociationChain() {
|
||||
error.value = '';
|
||||
chainHint.value = '';
|
||||
moreOpen.value = false;
|
||||
try {
|
||||
const payload = buildFilterPayload();
|
||||
const hasSeed = Boolean(
|
||||
@@ -225,7 +244,6 @@ async function runHashVerify() {
|
||||
verifying.value = true;
|
||||
error.value = '';
|
||||
verifyResult.value = null;
|
||||
moreOpen.value = false;
|
||||
try {
|
||||
const payload = buildFilterPayload();
|
||||
verifyResult.value = await verifyShippingAuditHashChain({
|
||||
@@ -256,7 +274,62 @@ async function exportCsv() {
|
||||
}
|
||||
}
|
||||
|
||||
const pageLabel = computed(() => String(page.value));
|
||||
/**
|
||||
* 操作者筛选。清空写回空字符串。
|
||||
* @param value - 选中的操作者类型
|
||||
*/
|
||||
function onActorTypeFilter(value: string | undefined): void {
|
||||
filters.value.actor_type = value ?? '';
|
||||
void applyFilters();
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件分组筛选。清空写回空字符串。
|
||||
* @param value - 选中的分组
|
||||
*/
|
||||
function onEventGroupFilter(value: string | undefined): void {
|
||||
filters.value.event_type_group = value ?? '';
|
||||
void applyFilters();
|
||||
}
|
||||
|
||||
/**
|
||||
* 时间筛选清空时写回空字符串。
|
||||
* @param key - created_from 或 created_to
|
||||
* @param value - 日期控件的值
|
||||
*/
|
||||
function onCreatedFilter(key: 'created_from' | 'created_to', value: string | null | undefined): void {
|
||||
filters.value[key] = value ?? '';
|
||||
void applyFilters();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每页条数变化后回到第一页再拉列表。
|
||||
*/
|
||||
function onPageSizeChange(): void {
|
||||
page.value = 1;
|
||||
void load();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从表格行打开详情。
|
||||
* @param row - 当前审计摘要
|
||||
*/
|
||||
function openAuditDetail(row: ShippingAuditEventSummary): void {
|
||||
void openDetail(row.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结果标签色。成功为成功色,失败为危险色。
|
||||
* @param code - 结果码
|
||||
* @returns Element 标签类型
|
||||
*/
|
||||
function resultTagType(code?: string | null): 'success' | 'warning' | 'info' | 'danger' {
|
||||
const key = String(code || '').toLowerCase();
|
||||
if (key === 'success' || key === 'ok') return 'success';
|
||||
if (key === 'failed' || key === 'error') return 'danger';
|
||||
if (!key) return 'info';
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
@@ -264,310 +337,197 @@ 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>
|
||||
</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">
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<AdminListPage data-testid="shipping-audit-center">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.shippingAudit.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingAudit.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton :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">
|
||||
</ElButton>
|
||||
<ElButton :icon="Download" :loading="exporting" data-testid="shipping-audit-export" @click="exportCsv">
|
||||
{{ exporting ? t('admin.shippingAudit.exporting') : t('admin.shippingAudit.export') }}
|
||||
</button>
|
||||
<div class="relative">
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary btn-sm md:hidden"
|
||||
data-testid="shipping-audit-more"
|
||||
@click="moreOpen = !moreOpen"
|
||||
>
|
||||
{{ t('admin.shippingAudit.moreActions') }}
|
||||
</button>
|
||||
<div
|
||||
class="absolute right-0 z-10 mt-1 w-44 rounded-lg border border-default bg-surface p-1 shadow-md md:static md:mt-0 md:flex md:w-auto md:items-center md:gap-2 md:border-0 md:bg-transparent md:p-0 md:shadow-none"
|
||||
:class="moreOpen ? 'block' : 'hidden md:flex'"
|
||||
>
|
||||
<button type="button" class="btn-secondary btn-sm w-full justify-start md:w-auto" :disabled="verifying" @click="runHashVerify">
|
||||
{{ verifying ? t('admin.shippingAudit.verifying') : t('admin.shippingAudit.verifyChain') }}
|
||||
</button>
|
||||
<button type="button" class="btn-secondary btn-sm w-full justify-start md:w-auto" @click="loadAssociationChain">
|
||||
{{ t('admin.shippingAudit.loadChain') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<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">
|
||||
<span>{{ t('admin.shippingAudit.filters.workflowId') }}</span>
|
||||
<input v-model="filters.workflow_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.workflowItemId') }}</span>
|
||||
<input v-model="filters.workflow_item_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.runNo') }}</span>
|
||||
<input v-model="filters.run_no" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.documentId') }}</span>
|
||||
<input v-model="filters.document_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.reviewCaseNo') }}</span>
|
||||
<input v-model="filters.review_case_no" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.taskNo') }}</span>
|
||||
<input v-model="filters.task_no" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.candidateNo') }}</span>
|
||||
<input
|
||||
v-model="filters.candidate_no"
|
||||
class="input-field text-sm"
|
||||
data-testid="shipping-audit-filter-candidate-no"
|
||||
@keyup.enter="applyFilters"
|
||||
</ElButton>
|
||||
<ElButton :loading="verifying" @click="runHashVerify">
|
||||
{{ verifying ? t('admin.shippingAudit.verifying') : t('admin.shippingAudit.verifyChain') }}
|
||||
</ElButton>
|
||||
<ElButton @click="loadAssociationChain">{{ t('admin.shippingAudit.loadChain') }}</ElButton>
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElInput v-model="filters.workflow_id" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.workflowId')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.workflow_item_id" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.workflowItemId')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.run_no" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.runNo')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.document_id" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.documentId')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.review_case_no" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.reviewCaseNo')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.task_no" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.taskNo')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.candidate_no" class="audit-filter" clearable data-testid="shipping-audit-filter-candidate-no" :placeholder="t('admin.shippingAudit.filters.candidateNo')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.gate_code" class="audit-filter" clearable data-testid="shipping-audit-filter-gate-code" :placeholder="t('admin.shippingAudit.filters.gateCode')" @keyup.enter="applyFilters" />
|
||||
<ElSelect
|
||||
:model-value="filters.actor_type || undefined"
|
||||
class="audit-filter"
|
||||
clearable
|
||||
:placeholder="t('admin.shippingAudit.filters.actorType')"
|
||||
@update:model-value="onActorTypeFilter"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.gateCode') }}</span>
|
||||
<input
|
||||
v-model="filters.gate_code"
|
||||
class="input-field text-sm"
|
||||
data-testid="shipping-audit-filter-gate-code"
|
||||
@keyup.enter="applyFilters"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.actorType') }}</span>
|
||||
<select v-model="filters.actor_type" class="select-field text-sm" @change="applyFilters">
|
||||
<option value="">{{ t('admin.shippingAudit.filters.all') }}</option>
|
||||
<option value="user">{{ t('admin.shippingAudit.labels.actorTypes.user') }}</option>
|
||||
<option value="admin">{{ t('admin.shippingAudit.labels.actorTypes.admin') }}</option>
|
||||
<option value="system">{{ t('admin.shippingAudit.labels.actorTypes.system') }}</option>
|
||||
<option value="rpa">{{ t('admin.shippingAudit.labels.actorTypes.rpa') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.actorId') }}</span>
|
||||
<input v-model="filters.actor_id" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.eventTypeGroup') }}</span>
|
||||
<select
|
||||
v-model="filters.event_type_group"
|
||||
class="select-field text-sm"
|
||||
<ElOption value="user" :label="t('admin.shippingAudit.labels.actorTypes.user')" />
|
||||
<ElOption value="admin" :label="t('admin.shippingAudit.labels.actorTypes.admin')" />
|
||||
<ElOption value="system" :label="t('admin.shippingAudit.labels.actorTypes.system')" />
|
||||
<ElOption value="rpa" :label="t('admin.shippingAudit.labels.actorTypes.rpa')" />
|
||||
</ElSelect>
|
||||
<ElInput v-model="filters.actor_id" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.actorId')" @keyup.enter="applyFilters" />
|
||||
<ElSelect
|
||||
:model-value="filters.event_type_group || undefined"
|
||||
class="audit-filter"
|
||||
clearable
|
||||
data-testid="shipping-audit-filter-event-type-group"
|
||||
@change="applyFilters"
|
||||
:placeholder="t('admin.shippingAudit.filters.eventTypeGroup')"
|
||||
@update:model-value="onEventGroupFilter"
|
||||
>
|
||||
<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>
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.profileId') }}</span>
|
||||
<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">
|
||||
<span>{{ t('admin.shippingAudit.filters.bindingId') }}</span>
|
||||
<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">
|
||||
<span>{{ t('admin.shippingAudit.filters.eventType') }}</span>
|
||||
<input v-model="filters.event_type" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.reasonCode') }}</span>
|
||||
<input v-model="filters.reason_code" class="input-field text-sm" data-testid="shipping-audit-filter-reason-code" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.result') }}</span>
|
||||
<input v-model="filters.result" class="input-field text-sm" @keyup.enter="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.createdFrom') }}</span>
|
||||
<input v-model="filters.created_from" type="datetime-local" class="input-field text-sm" @change="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary">
|
||||
<span>{{ t('admin.shippingAudit.filters.createdTo') }}</span>
|
||||
<input v-model="filters.created_to" type="datetime-local" class="input-field text-sm" @change="applyFilters">
|
||||
</label>
|
||||
<label class="space-y-1 text-xs text-secondary md:col-span-2 lg:col-span-1">
|
||||
<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>
|
||||
</label>
|
||||
</div>
|
||||
<ElOption value="review_workbench" :label="t('admin.shippingAudit.filters.eventTypeGroupReviewWorkbench')" />
|
||||
<ElOption value="formal_task_edit" :label="t('admin.shippingAudit.filters.eventTypeGroupFormalTaskEdit')" />
|
||||
<ElOption value="chat_workbench" :label="t('admin.shippingAudit.filters.eventTypeGroupChatWorkbench')" />
|
||||
<ElOption value="process_gate" :label="t('admin.shippingAudit.filters.eventTypeGroupProcessGate')" />
|
||||
<ElOption value="candidate_qualification" :label="t('admin.shippingAudit.filters.eventTypeGroupQualification')" />
|
||||
<ElOption value="workflow_node" :label="t('admin.shippingAudit.filters.eventTypeGroupWorkflowNode')" />
|
||||
<ElOption value="xfa_visual" :label="t('admin.shippingAudit.filters.eventTypeGroupXfaVisual')" />
|
||||
<ElOption value="xfa_split" :label="t('admin.shippingAudit.filters.eventTypeGroupXfaSplit')" />
|
||||
<ElOption value="xfa_unified" :label="t('admin.shippingAudit.filters.eventTypeGroupXfaUnified')" />
|
||||
</ElSelect>
|
||||
<ElInput v-model="filters.profile_id" class="audit-filter" clearable data-testid="shipping-audit-filter-profile-id" :placeholder="t('admin.shippingAudit.filters.profileId')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.binding_id" class="audit-filter" clearable data-testid="shipping-audit-filter-binding-id" :placeholder="t('admin.shippingAudit.filters.bindingId')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.event_type" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.eventType')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.reason_code" class="audit-filter" clearable data-testid="shipping-audit-filter-reason-code" :placeholder="t('admin.shippingAudit.filters.reasonCode')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.result" class="audit-filter" clearable :placeholder="t('admin.shippingAudit.filters.result')" @keyup.enter="applyFilters" />
|
||||
<ElDatePicker
|
||||
:model-value="filters.created_from || undefined"
|
||||
class="audit-filter-time"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm"
|
||||
:placeholder="t('admin.shippingAudit.filters.createdFrom')"
|
||||
@update:model-value="onCreatedFilter('created_from', $event)"
|
||||
/>
|
||||
<ElDatePicker
|
||||
:model-value="filters.created_to || undefined"
|
||||
class="audit-filter-time"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm"
|
||||
:placeholder="t('admin.shippingAudit.filters.createdTo')"
|
||||
@update:model-value="onCreatedFilter('created_to', $event)"
|
||||
/>
|
||||
<ElInput v-model="filters.q" class="audit-filter-search" clearable :placeholder="t('admin.shippingAudit.filters.q')" @keyup.enter="applyFilters" />
|
||||
<ElButton @click="applyFilters">{{ t('admin.shippingAudit.apply') }}</ElButton>
|
||||
</template>
|
||||
|
||||
<p v-if="chainHint" class="rounded-lg border border-default bg-surface-soft px-3 py-2 text-xs text-secondary">{{ chainHint }}</p>
|
||||
<p
|
||||
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', {
|
||||
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>
|
||||
<ElAlert v-if="chainHint" :title="chainHint" type="info" :closable="false" show-icon />
|
||||
<ElAlert
|
||||
v-if="verifyResult"
|
||||
data-testid="shipping-audit-verify-result"
|
||||
:title="t('admin.shippingAudit.verifySummary', {
|
||||
ok: verifyResult.ok ? t('admin.shippingAudit.verifyOk') : t('admin.shippingAudit.verifyFailedShort'),
|
||||
checked: verifyResult.checked_chains,
|
||||
failed: verifyResult.failed_chains,
|
||||
})"
|
||||
:type="verifyResult.ok ? 'success' : 'warning'"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
<ElAlert v-if="error" :title="error" type="error" :closable="false" show-icon />
|
||||
|
||||
<!-- 窄屏卡片列表:避免 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"
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="hx-admin-table"
|
||||
data-testid="shipping-audit-desktop-table"
|
||||
:data="rows"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.shippingAudit.empty')"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<div class="text-sm font-medium text-secondary">{{ businessLabel('eventTypes', row.event_type) }}</div>
|
||||
<div class="mt-0.5 text-xs text-muted">{{ businessLabel('actions', row.action) }}</div>
|
||||
</div>
|
||||
<button type="button" class="shrink-0 text-sm text-brand-600 hover:underline" @click="openDetail(row.id)">
|
||||
{{ t('admin.shippingAudit.diff') }}
|
||||
</button>
|
||||
</div>
|
||||
<dl class="mt-2 grid gap-1 text-xs text-secondary">
|
||||
<div><dt class="inline text-muted">{{ t('admin.shippingAudit.columns.time') }}:</dt><dd class="inline">{{ formatTime(row.created_at) }}</dd></div>
|
||||
<div><dt class="inline text-muted">{{ t('admin.shippingAudit.columns.actor') }}:</dt><dd class="inline">{{ businessLabel('actorTypes', row.actor_type) }}</dd></div>
|
||||
<div><dt class="inline text-muted">{{ t('admin.shippingAudit.columns.reasonCode') }}:</dt><dd class="inline font-medium">{{ businessLabel('reasonCodes', row.reason_code) }}</dd></div>
|
||||
<div><dt class="inline text-muted">{{ t('admin.shippingAudit.columns.result') }}:</dt><dd class="inline">{{ businessLabel('results', row.result) }}</dd></div>
|
||||
<div v-if="primaryBusinessRefs(row) !== '—'">
|
||||
<dt class="inline text-muted">{{ t('admin.shippingAudit.columns.businessRefs') }}:</dt>
|
||||
<dd class="inline">{{ primaryBusinessRefs(row) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div
|
||||
v-if="techRefChips(row).length"
|
||||
class="mt-2 flex flex-wrap items-center gap-1.5"
|
||||
data-testid="shipping-audit-tech-ref-chips"
|
||||
>
|
||||
<span class="text-[10px] text-muted">{{ t('admin.shippingAudit.techRefs') }}</span>
|
||||
<button
|
||||
v-for="item in techRefChips(row)"
|
||||
:key="`${row.id}-m-tech-${item.label}`"
|
||||
type="button"
|
||||
class="rounded border border-default px-2 py-1 font-mono text-[11px] text-muted"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- 桌面表:table-fixed + 无横滚;技术编号行内次要芯片,无需额外展开 -->
|
||||
<div class="hidden overflow-x-hidden rounded-xl border border-default bg-surface lg:block" data-testid="shipping-audit-desktop-table">
|
||||
<table class="w-full table-fixed text-left text-sm">
|
||||
<thead class="border-b border-default bg-surface-soft text-xs text-muted">
|
||||
<tr>
|
||||
<th class="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"
|
||||
<ElTableColumn :label="t('admin.shippingAudit.columns.time')" width="16%">
|
||||
<template #default="{ row }">{{ formatTime(row.created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingAudit.columns.event')" width="20%">
|
||||
<template #default="{ row }">
|
||||
<div>{{ businessLabel('eventTypes', row.event_type) }}</div>
|
||||
<div>{{ businessLabel('actions', row.action) }}</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingAudit.columns.actor')" width="10%">
|
||||
<template #default="{ row }">{{ businessLabel('actorTypes', row.actor_type) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingAudit.columns.reasonCode')" width="18%">
|
||||
<template #default="{ row }">{{ businessLabel('reasonCodes', row.reason_code) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingAudit.columns.result')" width="10%">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="resultTagType(row.result)" effect="light">{{ businessLabel('results', row.result) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingAudit.columns.businessRefs')" width="16%">
|
||||
<template #default="{ row }">
|
||||
<div>{{ primaryBusinessRefs(row as ShippingAuditEventSummary) }}</div>
|
||||
<div
|
||||
v-if="techRefChips(row as ShippingAuditEventSummary).length"
|
||||
class="audit-tech-refs"
|
||||
data-testid="shipping-audit-tech-ref-chips"
|
||||
>
|
||||
<ElButton
|
||||
v-for="item in techRefChips(row as ShippingAuditEventSummary)"
|
||||
:key="`${row.id}-tech-${item.label}`"
|
||||
link
|
||||
type="primary"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
<button
|
||||
v-for="item in techRefChips(row)"
|
||||
:key="`${row.id}-tech-${item.label}`"
|
||||
type="button"
|
||||
class="rounded border border-default bg-surface-soft px-1 py-0.5 font-mono text-[10px] text-muted"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-2 align-top">
|
||||
<button type="button" class="text-brand-600 hover:underline" @click="openDetail(row.id)">
|
||||
{{ t('admin.shippingAudit.diff') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ item.label }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn width="10%" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openAuditDetail(row as ShippingAuditEventSummary)">
|
||||
{{ t('admin.shippingAudit.diff') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<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>
|
||||
<template #pagination>
|
||||
<ElPagination
|
||||
v-model:current-page="page"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
:page-sizes="pageSizes"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
@current-change="load"
|
||||
@size-change="onPageSizeChange"
|
||||
/>
|
||||
</template>
|
||||
</AdminListPage>
|
||||
|
||||
<ShippingAuditEventDetailDrawer
|
||||
:detail="detail"
|
||||
:loading="detailLoading"
|
||||
@close="detail = null"
|
||||
/>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.audit-tech-refs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
:deep(.audit-filter) {
|
||||
width: 11rem;
|
||||
}
|
||||
|
||||
:deep(.audit-filter-search),
|
||||
:deep(.audit-filter-time) {
|
||||
width: 16rem;
|
||||
}
|
||||
</style>
|
||||
+40
-20
@@ -5,7 +5,7 @@
|
||||
* 逻辑:敏感脱敏文案可见;事件/操作者/结果用业务标签;技术编号不直接平铺主区;Diff 行按 key 渲染。
|
||||
*/
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import ShippingAuditEventDetailDrawer from './ShippingAuditEventDetailDrawer.vue';
|
||||
import type { ShippingAuditEventDetail } from '@/features/admin/api/shipping-audit.api';
|
||||
@@ -78,18 +78,35 @@ const messages = {
|
||||
};
|
||||
|
||||
/**
|
||||
* 挂载详情抽屉。
|
||||
* 挂载详情抽屉。ElDrawer 会传送到 body,断言前先等渲染结束。
|
||||
* @param detail - 详情;空表示未打开
|
||||
* @param loading - 是否处于加载
|
||||
* @returns 已挂载的包装器
|
||||
*/
|
||||
function mountDrawer(detail: ShippingAuditEventDetail | null, loading = false) {
|
||||
async function mountDrawer(detail: ShippingAuditEventDetail | null, loading = false): Promise<VueWrapper> {
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages });
|
||||
return mount(ShippingAuditEventDetailDrawer, {
|
||||
const wrapper = mount(ShippingAuditEventDetailDrawer, {
|
||||
props: { detail, loading },
|
||||
attachTo: document.body,
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在传送后的文档里找详情节点。
|
||||
* @param testId - data-testid
|
||||
* @returns 匹配到的元素
|
||||
*/
|
||||
function queryDetail(testId: string): HTMLElement {
|
||||
const node = document.body.querySelector(`[data-testid="${testId}"]`);
|
||||
if (!(node instanceof HTMLElement)) throw new Error(`missing ${testId}`);
|
||||
return node;
|
||||
}
|
||||
|
||||
describe('ShippingAuditEventDetailDrawer', () => {
|
||||
it('shows sensitive redaction banner when snapshots are trimmed', () => {
|
||||
it('shows sensitive redaction banner when snapshots are trimmed', async () => {
|
||||
const detail: ShippingAuditEventDetail = {
|
||||
id: 1,
|
||||
event_type: 'order_review_confirmed',
|
||||
@@ -100,12 +117,12 @@ describe('ShippingAuditEventDetailDrawer', () => {
|
||||
sensitive_redacted: true,
|
||||
diff: [],
|
||||
};
|
||||
const wrapper = mountDrawer(detail);
|
||||
expect(wrapper.find('[data-testid="shipping-audit-sensitive-redacted"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('敏感快照已按权限脱敏');
|
||||
const wrapper = await mountDrawer(detail);
|
||||
expect(queryDetail('shipping-audit-sensitive-redacted').textContent).toContain('敏感快照已按权限脱敏');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('uses business labels and does not flatten raw event_type in primary meta', () => {
|
||||
it('uses business labels and does not flatten raw event_type in primary meta', async () => {
|
||||
const detail: ShippingAuditEventDetail = {
|
||||
id: 3,
|
||||
event_type: 'order_review_confirmed',
|
||||
@@ -121,16 +138,17 @@ describe('ShippingAuditEventDetailDrawer', () => {
|
||||
sensitive_redacted: false,
|
||||
diff: [],
|
||||
};
|
||||
const wrapper = mountDrawer(detail);
|
||||
const text = wrapper.text();
|
||||
expect(wrapper.get('[data-testid="shipping-audit-detail-event"]').text()).toContain('订单复核已确认');
|
||||
expect(wrapper.get('[data-testid="shipping-audit-detail-actor"]').text()).toContain('业务用户');
|
||||
expect(wrapper.get('[data-testid="shipping-audit-detail-result"]').text()).toContain('成功');
|
||||
const wrapper = await mountDrawer(detail);
|
||||
const text = document.body.textContent || '';
|
||||
expect(queryDetail('shipping-audit-detail-event').textContent).toContain('订单复核已确认');
|
||||
expect(queryDetail('shipping-audit-detail-actor').textContent).toContain('业务用户');
|
||||
expect(queryDetail('shipping-audit-detail-result').textContent).toContain('成功');
|
||||
expect(text).not.toContain('order_review_confirmed');
|
||||
expect(wrapper.find('[data-testid="shipping-audit-detail-tech-refs"]').exists()).toBe(true);
|
||||
expect(queryDetail('shipping-audit-detail-tech-refs')).toBeTruthy();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('renders whitelist diff rows', () => {
|
||||
it('renders whitelist diff rows', async () => {
|
||||
const detail: ShippingAuditEventDetail = {
|
||||
id: 2,
|
||||
event_type: 'status_changed',
|
||||
@@ -141,9 +159,11 @@ describe('ShippingAuditEventDetailDrawer', () => {
|
||||
sensitive_redacted: false,
|
||||
diff: [{ key: 'status', change: 'changed', before: 'queued', after: 'processing' }],
|
||||
};
|
||||
const wrapper = mountDrawer(detail);
|
||||
expect(wrapper.find('[data-testid="shipping-audit-diff-rows"]').text()).toContain('status');
|
||||
expect(wrapper.text()).toContain('queued');
|
||||
expect(wrapper.text()).toContain('processing');
|
||||
const wrapper = await mountDrawer(detail);
|
||||
const text = document.body.textContent || '';
|
||||
expect(queryDetail('shipping-audit-diff-rows').textContent).toContain('status');
|
||||
expect(text).toContain('queued');
|
||||
expect(text).toContain('processing');
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
+122
-118
@@ -1,18 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-audit/ShippingAuditEventDetailDrawer.vue
|
||||
用途:审计事件详情抽屉——业务化元数据、敏感脱敏提示、白名单 Diff、XFA 快照引用、哈希摘要。
|
||||
依赖:shipping-audit.api 类型、shippingAuditDisplay、Vue I18n、useMessage。
|
||||
逻辑:由 ShippingAuditCenterPage 传入 detail;事件/动作/结果与列表同源业务标签;
|
||||
展示 before/after checksum 与 XFA snapshot_ref;技术编号以复制芯片展示;
|
||||
若快照/metadata 含视觉绑定前后摘要则单独渲染;关闭时 emit close;不自行拉接口。
|
||||
-->
|
||||
/**
|
||||
* features/admin/modules/shipping-audit/ShippingAuditEventDetailDrawer.vue
|
||||
* 用途:审计事件详情抽屉。业务化元数据、敏感脱敏提示、白名单 Diff、XFA 快照引用和哈希摘要。
|
||||
* 依赖:element-plus 抽屉、shipping-audit.api 类型、shippingAuditDisplay、Vue I18n、useMessage。
|
||||
* 逻辑:由 ShippingAuditCenterPage 传入 detail。关闭时 emit close。不自行拉接口。样式跟列表页已引入的 Element 皮肤走。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElAlert, ElButton, ElDrawer, ElLoading, ElTag } from 'element-plus';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { ShippingAuditEventDetail } from '@/features/admin/api/shipping-audit.api';
|
||||
import { shippingAuditBusinessLabel } from './shippingAuditDisplay';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const props = defineProps<{
|
||||
detail: ShippingAuditEventDetail | null;
|
||||
loading?: boolean;
|
||||
@@ -29,6 +30,9 @@ const open = computed(() => Boolean(props.detail || props.loading));
|
||||
|
||||
/**
|
||||
* 与列表页一致的业务化标签。
|
||||
* @param kind - 标签类别
|
||||
* @param code - 原始码
|
||||
* @returns 业务文案
|
||||
*/
|
||||
function label(kind: 'eventTypes' | 'actions' | 'reasonCodes' | 'actorTypes' | 'results', code?: string | null): string {
|
||||
return shippingAuditBusinessLabel({ t, te }, kind, code);
|
||||
@@ -36,8 +40,9 @@ function label(kind: 'eventTypes' | 'actions' | 'reasonCodes' | 'actorTypes' | '
|
||||
|
||||
/**
|
||||
* 复制技术编号。
|
||||
* @param value - 要复制的编号
|
||||
*/
|
||||
async function copyTechId(value?: string | null) {
|
||||
async function copyTechId(value?: string | null): Promise<void> {
|
||||
const text = String(value || '').trim();
|
||||
if (!text || !navigator?.clipboard?.writeText) return;
|
||||
try {
|
||||
@@ -97,172 +102,171 @@ const visualBindingDiff = computed(() => {
|
||||
|
||||
/**
|
||||
* 关闭抽屉。
|
||||
* @param next - 抽屉是否仍打开
|
||||
*/
|
||||
function onClose() {
|
||||
emit('close');
|
||||
function onVisibleChange(next: boolean): void {
|
||||
if (!next) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex justify-end bg-overlay"
|
||||
data-testid="shipping-audit-detail-drawer"
|
||||
@click.self="onClose"
|
||||
<ElDrawer
|
||||
:model-value="open"
|
||||
:title="t('admin.shippingAudit.detailTitle')"
|
||||
direction="rtl"
|
||||
size="680px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<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
|
||||
<div v-loading="loading" data-testid="shipping-audit-detail-drawer">
|
||||
<template v-if="detail">
|
||||
<ElAlert
|
||||
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"
|
||||
:title="t('admin.shippingAudit.sensitiveRedacted')"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
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">
|
||||
/>
|
||||
<dl class="audit-detail-meta">
|
||||
<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">
|
||||
<dt>{{ t('admin.shippingAudit.columns.event') }}</dt>
|
||||
<dd data-testid="shipping-audit-detail-event">
|
||||
{{ label('eventTypes', detail.event_type) }}
|
||||
</dd>
|
||||
<dd class="text-xs text-muted">{{ label('actions', detail.action) }}</dd>
|
||||
<dd>{{ label('actions', detail.action) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingAudit.columns.actor') }}</dt>
|
||||
<dd class="mt-0.5" data-testid="shipping-audit-detail-actor">
|
||||
<dt>{{ t('admin.shippingAudit.columns.actor') }}</dt>
|
||||
<dd 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>
|
||||
<span v-if="detail.actor_id"> · {{ t('admin.shippingAudit.copyId') }}</span>
|
||||
</dd>
|
||||
<button
|
||||
<ElButton
|
||||
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"
|
||||
link
|
||||
type="primary"
|
||||
:title="String(detail.actor_id)"
|
||||
@click="copyTechId(detail.actor_id)"
|
||||
>
|
||||
{{ detail.actor_id }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</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>
|
||||
<dt>{{ t('admin.shippingAudit.columns.reasonCode') }}</dt>
|
||||
<dd>{{ 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) }}
|
||||
<dt>{{ t('admin.shippingAudit.columns.result') }}</dt>
|
||||
<dd data-testid="shipping-audit-detail-result">
|
||||
<ElTag effect="light">{{ label('results', detail.result) }}</ElTag>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<section class="mt-5" data-testid="shipping-audit-detail-tech-refs">
|
||||
<h3 class="text-sm font-semibold">{{ t('admin.shippingAudit.columns.refs') }}</h3>
|
||||
<p class="mt-1 text-[11px] text-muted">{{ t('admin.shippingAudit.techRefsHint') }}</p>
|
||||
<div v-if="techRefs.length" class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
<section data-testid="shipping-audit-detail-tech-refs">
|
||||
<h3>{{ t('admin.shippingAudit.columns.refs') }}</h3>
|
||||
<p>{{ t('admin.shippingAudit.techRefsHint') }}</p>
|
||||
<div v-if="techRefs.length" class="audit-detail-refs">
|
||||
<ElButton
|
||||
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"
|
||||
link
|
||||
type="primary"
|
||||
:title="item.value"
|
||||
@click="copyTechId(item.value)"
|
||||
>
|
||||
<span class="text-muted">{{ item.label }}</span>
|
||||
· {{ t('admin.shippingAudit.copyId') }}
|
||||
</button>
|
||||
{{ item.label }} · {{ t('admin.shippingAudit.copyId') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<p v-else class="mt-2 text-xs text-muted">—</p>
|
||||
<p v-else>—</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 class="audit-detail-block">
|
||||
<summary>{{ t('admin.shippingAudit.hashSection') }}</summary>
|
||||
<dl>
|
||||
<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>
|
||||
|
||||
<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" data-testid="shipping-audit-visual-binding-diff">
|
||||
<h3>{{ t('admin.shippingAudit.visualBindingDiff') }}</h3>
|
||||
<p>{{ t('admin.shippingAudit.visualBindingDiffHint') }}</p>
|
||||
<div>
|
||||
<div>{{ t('admin.shippingAudit.before') }}</div>
|
||||
<pre>{{ visualBindingDiff.before == null ? '—' : JSON.stringify(visualBindingDiff.before, null, 2) }}</pre>
|
||||
<div>{{ t('admin.shippingAudit.after') }}</div>
|
||||
<pre>{{ visualBindingDiff.after == null ? '—' : JSON.stringify(visualBindingDiff.after, null, 2) }}</pre>
|
||||
</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"
|
||||
>
|
||||
<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"
|
||||
<section v-if="detail.xfa_snapshot_refs?.length" data-testid="shipping-audit-xfa-snapshots">
|
||||
<h3>{{ t('admin.shippingAudit.xfaSnapshots') }}</h3>
|
||||
<p>{{ t('admin.shippingAudit.xfaSnapshotsHint') }}</p>
|
||||
<ul>
|
||||
<li v-for="item in detail.xfa_snapshot_refs" :key="item.snapshot_ref">
|
||||
<div>{{ item.purpose }}</div>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
:title="item.snapshot_ref"
|
||||
data-testid="shipping-audit-xfa-snapshot-ref"
|
||||
@click="copyTechId(ref.snapshot_ref)"
|
||||
@click="copyTechId(item.snapshot_ref)"
|
||||
>
|
||||
{{ t('admin.shippingAudit.copyId') }} · {{ ref.snapshot_ref.slice(0, 12) }}…
|
||||
</button>
|
||||
{{ t('admin.shippingAudit.copyId') }} · {{ item.snapshot_ref.slice(0, 12) }}…
|
||||
</ElButton>
|
||||
</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
|
||||
v-for="row in detail.diff"
|
||||
:key="row.key"
|
||||
class="rounded-lg border border-default p-3 text-xs"
|
||||
>
|
||||
<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>
|
||||
<h3>{{ t('admin.shippingAudit.diff') }}</h3>
|
||||
<div v-if="detail.diff?.length" data-testid="shipping-audit-diff-rows">
|
||||
<div v-for="row in detail.diff" :key="row.key" class="audit-detail-block">
|
||||
<div>{{ row.key }} · {{ row.change }}</div>
|
||||
<div>{{ t('admin.shippingAudit.before') }}: {{ row.before == null ? '—' : JSON.stringify(row.before) }}</div>
|
||||
<div>{{ 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>
|
||||
<p v-else>{{ t('admin.shippingAudit.noDiff') }}</p>
|
||||
</template>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</ElDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.audit-detail-meta,
|
||||
.audit-detail-refs {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.audit-detail-meta {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.audit-detail-block {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.audit-detail-block pre,
|
||||
.audit-detail-block dd {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
</style>
|
||||
+179
-144
@@ -1,15 +1,31 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-field-assets/ShippingFieldAssetsPage.vue
|
||||
* 用途:字段资产库主工作台——标准/扩展列表、详情、扩展弃用恢复、影响与审计。
|
||||
* 依赖:shipping-field-assets.api、BusinessError、useMessage、Vue I18n。
|
||||
* 逻辑:由 Admin 路由挂载;视觉与订单 Schema 页对齐(页眉、双栏工作台、选中态、主次按钮);
|
||||
* 采用记录可跳转唯一发货订单 Schema 的历史版本;Schema 采用规则在独立页面编辑;
|
||||
* 审计优先展示属性级差异摘要,原始 JSON 折叠为技术详情。
|
||||
* 用途:字段资产库主工作台。标准字段和扩展字段列表、详情、弃用恢复、影响与审计。
|
||||
* 依赖:AdminListPage、useElementProvider、element-plus、shipping-field-assets.api、useMessage。
|
||||
* 逻辑:路由挂载本页。骨架用 AdminListPage。创建和弃用原因用对话框。采用记录仍跳转订单 Schema。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { RouterLink } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Plus, Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElConfigProvider,
|
||||
ElDialog,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
@@ -30,6 +46,8 @@ import type {
|
||||
} from '@/features/admin/types/shipping-field-assets.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const vLoading = ElLoading.directive;
|
||||
const message = useMessage();
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -61,6 +79,32 @@ const selected = computed(() => selectedDetail.value || items.value.find((item)
|
||||
const standardItems = computed(() => items.value.filter((item) => item.asset_kind === 'system_standard'));
|
||||
const extensionItems = computed(() => items.value.filter((item) => item.asset_kind === 'extension'));
|
||||
|
||||
/**
|
||||
* 资产类型筛选。清空写回空字符串,接口仍查全部类型。
|
||||
* @param value - 选中的资产类型
|
||||
*/
|
||||
function onKindFilter(value: 'system_standard' | 'extension' | undefined): void {
|
||||
kindFilter.value = value ?? '';
|
||||
void loadList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态筛选。清空写回空字符串,接口仍查全部状态。
|
||||
* @param value - 选中的状态
|
||||
*/
|
||||
function onStatusFilter(value: 'active' | 'retired' | undefined): void {
|
||||
statusFilter.value = value ?? '';
|
||||
void loadList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 选中左侧资产,详情区跟着切换。
|
||||
* @param item - 被点中的字段资产
|
||||
*/
|
||||
function selectAsset(item: ShippingFieldAsset): void {
|
||||
selectedId.value = item.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载字段资产列表并保持当前选中项。
|
||||
* 核心逻辑:调用 listShippingFieldAssets;若选中项消失则回退到首项。
|
||||
@@ -472,41 +516,41 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="mx-auto max-w-7xl space-y-6 p-6">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<h1 class="section-title">{{ t('admin.shippingFieldAssets.title') }}</h1>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.shippingFieldAssets.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingFieldAssets.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-primary" @click="showCreate = true">
|
||||
{{ t('admin.shippingFieldAssets.createExtension') }}
|
||||
</button>
|
||||
</header>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton :icon="Refresh" :loading="loading" @click="loadList">{{ t('admin.shippingFieldAssets.refresh') }}</ElButton>
|
||||
<ElButton type="primary" :icon="Plus" @click="showCreate = true">{{ t('admin.shippingFieldAssets.createExtension') }}</ElButton>
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElInput v-model="q" class="field-asset-search" clearable :placeholder="t('admin.shippingFieldAssets.search')" @keyup.enter="loadList" />
|
||||
<ElSelect
|
||||
:model-value="kindFilter || undefined"
|
||||
class="field-asset-filter"
|
||||
clearable
|
||||
:placeholder="t('admin.shippingFieldAssets.kindAll')"
|
||||
@update:model-value="onKindFilter"
|
||||
>
|
||||
<ElOption value="system_standard" :label="t('admin.shippingFieldAssets.kindStandard')" />
|
||||
<ElOption value="extension" :label="t('admin.shippingFieldAssets.kindExtension')" />
|
||||
</ElSelect>
|
||||
<ElSelect
|
||||
:model-value="statusFilter || undefined"
|
||||
class="field-asset-filter"
|
||||
clearable
|
||||
:placeholder="t('admin.shippingFieldAssets.statusAll')"
|
||||
@update:model-value="onStatusFilter"
|
||||
>
|
||||
<ElOption value="active" :label="t('admin.shippingFieldAssets.statusActive')" />
|
||||
<ElOption value="retired" :label="t('admin.shippingFieldAssets.statusRetired')" />
|
||||
</ElSelect>
|
||||
</template>
|
||||
|
||||
<div class="toolbar">
|
||||
<input
|
||||
v-model="q"
|
||||
type="search"
|
||||
class="input-field toolbar-input"
|
||||
:placeholder="t('admin.shippingFieldAssets.search')"
|
||||
@keyup.enter="loadList"
|
||||
>
|
||||
<select v-model="kindFilter" class="select-field toolbar-select" @change="loadList">
|
||||
<option value="">{{ t('admin.shippingFieldAssets.kindAll') }}</option>
|
||||
<option value="system_standard">{{ t('admin.shippingFieldAssets.kindStandard') }}</option>
|
||||
<option value="extension">{{ t('admin.shippingFieldAssets.kindExtension') }}</option>
|
||||
</select>
|
||||
<select v-model="statusFilter" class="select-field toolbar-select" @change="loadList">
|
||||
<option value="">{{ t('admin.shippingFieldAssets.statusAll') }}</option>
|
||||
<option value="active">{{ t('admin.shippingFieldAssets.statusActive') }}</option>
|
||||
<option value="retired">{{ t('admin.shippingFieldAssets.statusRetired') }}</option>
|
||||
</select>
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="loading" @click="loadList">
|
||||
{{ t('admin.shippingFieldAssets.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="assets-workbench">
|
||||
<div v-loading="loading" class="assets-workbench">
|
||||
<aside class="list-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
@@ -520,39 +564,39 @@ onMounted(() => {
|
||||
<div class="field-group-toggle">
|
||||
<span class="field-group-title">{{ t('admin.shippingFieldAssets.standardGroup', { count: standardItems.length }) }}</span>
|
||||
</div>
|
||||
<button
|
||||
<ElButton
|
||||
v-for="item in standardItems"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
text
|
||||
class="list-item"
|
||||
:class="{ selected: item.id === selectedId }"
|
||||
@click="selectedId = item.id"
|
||||
@click="selectAsset(item)"
|
||||
>
|
||||
<span class="list-identity">
|
||||
<strong>{{ displayLabel(item) }}</strong>
|
||||
<code>{{ item.field_code }}</code>
|
||||
<small>{{ listMeta(item) }}</small>
|
||||
</span>
|
||||
</button>
|
||||
</ElButton>
|
||||
</section>
|
||||
<section class="field-group">
|
||||
<div class="field-group-toggle">
|
||||
<span class="field-group-title">{{ t('admin.shippingFieldAssets.extensionGroup', { count: extensionItems.length }) }}</span>
|
||||
</div>
|
||||
<button
|
||||
<ElButton
|
||||
v-for="item in extensionItems"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
text
|
||||
class="list-item"
|
||||
:class="{ selected: item.id === selectedId }"
|
||||
@click="selectedId = item.id"
|
||||
@click="selectAsset(item)"
|
||||
>
|
||||
<span class="list-identity">
|
||||
<strong>{{ displayLabel(item) }}</strong>
|
||||
<code>{{ item.field_code }}</code>
|
||||
<small>{{ listMeta(item) }}</small>
|
||||
</span>
|
||||
</button>
|
||||
</ElButton>
|
||||
</section>
|
||||
<p v-if="!items.length" class="panel-empty">{{ t('admin.shippingFieldAssets.empty') }}</p>
|
||||
</div>
|
||||
@@ -622,36 +666,22 @@ onMounted(() => {
|
||||
|
||||
<template v-if="selected.asset_kind === 'extension'">
|
||||
<div class="section-card edit-card">
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.displayName') }}</span>
|
||||
<input v-model="editName" class="input-field" type="text">
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.semantic') }}</span>
|
||||
<textarea v-model="editSemantic" class="input-field" rows="3" />
|
||||
</label>
|
||||
<ElForm label-position="top" @submit.prevent="saveExtensionMeta">
|
||||
<ElFormItem :label="t('admin.shippingFieldAssets.displayName')">
|
||||
<ElInput v-model="editName" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingFieldAssets.semantic')">
|
||||
<ElInput v-model="editSemantic" type="textarea" :rows="3" />
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<div class="actions">
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="saving" @click="saveExtensionMeta">
|
||||
{{ t('admin.shippingFieldAssets.saveMeta') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="selected.status === 'active'"
|
||||
type="button"
|
||||
class="btn-danger btn-sm"
|
||||
:disabled="saving"
|
||||
@click="openReasonDialog('retire')"
|
||||
>
|
||||
<ElButton :loading="saving" @click="saveExtensionMeta">{{ t('admin.shippingFieldAssets.saveMeta') }}</ElButton>
|
||||
<ElButton v-if="selected.status === 'active'" type="danger" :disabled="saving" @click="openReasonDialog('retire')">
|
||||
{{ t('admin.shippingFieldAssets.retire') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="btn-secondary btn-sm"
|
||||
:disabled="saving"
|
||||
@click="openReasonDialog('restore')"
|
||||
>
|
||||
</ElButton>
|
||||
<ElButton v-else :disabled="saving" @click="openReasonDialog('restore')">
|
||||
{{ t('admin.shippingFieldAssets.restore') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -725,78 +755,80 @@ onMounted(() => {
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div v-if="showCreate" class="impact-overlay" @click.self="showCreate = false">
|
||||
<div class="impact-dialog">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingFieldAssets.createExtension') }}</h2>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="showCreate = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
</header>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.fieldCode') }}</span>
|
||||
<input v-model="createForm.field_code" class="input-field">
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.displayName') }}</span>
|
||||
<input v-model="createForm.display_name" class="input-field">
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.scope') }}</span>
|
||||
<select v-model="createForm.scope" class="select-field">
|
||||
<option value="header">header</option>
|
||||
<option value="line">line</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.valueType') }}</span>
|
||||
<select v-model="createForm.value_type" class="select-field">
|
||||
<option value="string">string</option>
|
||||
<option value="decimal">decimal</option>
|
||||
<option value="integer">integer</option>
|
||||
<option value="date">date</option>
|
||||
<option value="boolean">boolean</option>
|
||||
<option value="enum">enum</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.semantic') }}</span>
|
||||
<textarea v-model="createForm.semantic_description" class="input-field" rows="3" />
|
||||
</label>
|
||||
<footer>
|
||||
<button type="button" class="btn-secondary" @click="showCreate = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="submitCreate">{{ t('admin.shippingFieldAssets.confirm') }}</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</AdminListPage>
|
||||
|
||||
<div v-if="showReasonDialog" class="impact-overlay" @click.self="showReasonDialog = false">
|
||||
<div class="impact-dialog">
|
||||
<header>
|
||||
<h2>{{ reasonAction === 'retire' ? t('admin.shippingFieldAssets.retire') : t('admin.shippingFieldAssets.restore') }}</h2>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="showReasonDialog = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
</header>
|
||||
<p class="muted">{{ t('admin.shippingFieldAssets.reasonHint') }}</p>
|
||||
<template v-if="reasonAction === 'retire'">
|
||||
<div class="impact-summary">
|
||||
<p>{{ t('admin.shippingFieldAssets.retireImpactSummary', { count: impact?.blocking_count || 0 }) }}</p>
|
||||
<ul v-if="impact?.blocking_items?.length">
|
||||
<li v-for="item in impact.blocking_items" :key="`${item.kind}-${item.object_id}`">
|
||||
{{ blockingLabel(item.kind) }} · {{ item.display_name }} ({{ item.status }})
|
||||
</li>
|
||||
</ul>
|
||||
<label v-if="(impact?.blocking_count || 0) > 0" class="confirm-row">
|
||||
<input v-model="confirmImpactChecked" type="checkbox">
|
||||
{{ t('admin.shippingFieldAssets.retireConfirmCheckbox') }}
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
<textarea v-model="reasonText" class="input-field" rows="4" />
|
||||
<footer>
|
||||
<button type="button" class="btn-secondary" @click="showReasonDialog = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="submitReasonAction">{{ t('admin.shippingFieldAssets.confirm') }}</button>
|
||||
</footer>
|
||||
<ElDialog
|
||||
v-model="showCreate"
|
||||
:title="t('admin.shippingFieldAssets.createExtension')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!saving"
|
||||
:show-close="!saving"
|
||||
>
|
||||
<ElForm label-position="top" :model="createForm" @submit.prevent="submitCreate">
|
||||
<ElFormItem :label="t('admin.shippingFieldAssets.fieldCode')">
|
||||
<ElInput v-model="createForm.field_code" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingFieldAssets.displayName')">
|
||||
<ElInput v-model="createForm.display_name" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingFieldAssets.scope')">
|
||||
<ElSelect v-model="createForm.scope">
|
||||
<ElOption value="header" label="header" />
|
||||
<ElOption value="line" label="line" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingFieldAssets.valueType')">
|
||||
<ElSelect v-model="createForm.value_type">
|
||||
<ElOption value="string" label="string" />
|
||||
<ElOption value="decimal" label="decimal" />
|
||||
<ElOption value="integer" label="integer" />
|
||||
<ElOption value="date" label="date" />
|
||||
<ElOption value="boolean" label="boolean" />
|
||||
<ElOption value="enum" label="enum" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingFieldAssets.semantic')">
|
||||
<ElInput v-model="createForm.semantic_description" type="textarea" :rows="3" />
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="saving" @click="showCreate = false">{{ t('admin.shippingFieldAssets.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="saving" @click="submitCreate">{{ t('admin.shippingFieldAssets.confirm') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
<ElDialog
|
||||
v-model="showReasonDialog"
|
||||
:title="reasonAction === 'retire' ? t('admin.shippingFieldAssets.retire') : t('admin.shippingFieldAssets.restore')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!saving"
|
||||
:show-close="!saving"
|
||||
>
|
||||
<p>{{ t('admin.shippingFieldAssets.reasonHint') }}</p>
|
||||
<div v-if="reasonAction === 'retire'" class="impact-summary">
|
||||
<p>{{ t('admin.shippingFieldAssets.retireImpactSummary', { count: impact?.blocking_count || 0 }) }}</p>
|
||||
<ul v-if="impact?.blocking_items?.length">
|
||||
<li v-for="item in impact.blocking_items" :key="`${item.kind}-${item.object_id}`">
|
||||
{{ blockingLabel(item.kind) }} · {{ item.display_name }} ({{ item.status }})
|
||||
</li>
|
||||
</ul>
|
||||
<ElCheckbox v-if="(impact?.blocking_count || 0) > 0" v-model="confirmImpactChecked">
|
||||
{{ t('admin.shippingFieldAssets.retireConfirmCheckbox') }}
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<ElInput v-model="reasonText" type="textarea" :rows="4" />
|
||||
<template #footer>
|
||||
<ElButton :disabled="saving" @click="showReasonDialog = false">{{ t('admin.shippingFieldAssets.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="saving" @click="submitReasonAction">{{ t('admin.shippingFieldAssets.confirm') }}</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -828,7 +860,7 @@ onMounted(() => {
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
.list-item {
|
||||
display: flex; width: 100%; align-items: center; gap: 8px; margin-top: 2px;
|
||||
display: flex; width: 100%; height: auto; align-items: center; justify-content: flex-start; gap: 8px; margin-top: 2px;
|
||||
border: 0; border-radius: 7px; background: transparent; padding: 6px 8px; color: #475569;
|
||||
text-align: left; cursor: pointer;
|
||||
}
|
||||
@@ -936,6 +968,9 @@ onMounted(() => {
|
||||
}
|
||||
.confirm-row { display: flex !important; align-items: flex-start; gap: 8px; color: #334155; font-size: 13px; }
|
||||
|
||||
:deep(.field-asset-search) { width: 16rem; }
|
||||
:deep(.field-asset-filter) { width: 11rem; }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.assets-workbench { grid-template-columns: 1fr; height: auto; min-height: 0; }
|
||||
.list-panel { border-right: 0; border-bottom: 1px solid #e5ebf1; max-height: 320px; }
|
||||
|
||||
+62
-57
@@ -1,27 +1,34 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-field-assets/components/FieldImpactDrawer.vue
|
||||
用途:展示单字段影响分析(阻断对象明细/警告/历史只读),资产库与 Schema 页共用。
|
||||
依赖:ShippingFieldAssetImpact DTO、Vue I18n、Vue Router。
|
||||
逻辑:只读抽屉;列出具体配置对象与引用位置;不含订单正文或证据原文。
|
||||
-->
|
||||
/**
|
||||
* features/admin/modules/shipping-field-assets/components/FieldImpactDrawer.vue
|
||||
* 用途:展示单字段影响分析。阻断对象、警告和历史只读引用。
|
||||
* 依赖:element-plus 抽屉、ShippingFieldAssetImpact、Vue I18n、Vue Router。
|
||||
* 逻辑:资产库和 Schema 页共用。只读侧抽屉。打开下游配置时走 admin_path。不含订单正文。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ElButton, ElDrawer, ElLoading } 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<{
|
||||
const props = defineProps<{
|
||||
modelValue: boolean;
|
||||
impact: ShippingFieldAssetImpact | null;
|
||||
loading: boolean;
|
||||
}>();
|
||||
|
||||
defineEmits<{ 'update:modelValue': [value: boolean] }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: boolean] }>();
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
|
||||
/**
|
||||
* 将后端 blocking kind 映射为管理员可读的下游对象名称。
|
||||
* @param kind - 后端阻断类型
|
||||
* @returns 已翻译的对象名;没有词条时回落原码
|
||||
*/
|
||||
function blockingLabel(kind: string): string {
|
||||
const key = `admin.shippingFieldAssets.impactKind.${kind}`;
|
||||
@@ -31,27 +38,39 @@ function blockingLabel(kind: string): string {
|
||||
|
||||
/**
|
||||
* 打开下游配置处理入口(若提供 admin_path)。
|
||||
* @param item - 一条阻断对象
|
||||
*/
|
||||
function openAdminPath(item: ShippingFieldImpactItem): void {
|
||||
if (!item.admin_path) return;
|
||||
void router.push(item.admin_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 抽屉关闭时写回 v-model。
|
||||
* @param open - 抽屉是否仍打开
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('update:modelValue', false);
|
||||
}
|
||||
</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">
|
||||
<ElDrawer
|
||||
:model-value="props.modelValue"
|
||||
:title="t('admin.shippingFieldAssets.impactTitle')"
|
||||
direction="rtl"
|
||||
size="480px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<div v-loading="props.loading">
|
||||
<template v-if="!props.loading && props.impact">
|
||||
<section v-if="props.impact.blocking_items?.length">
|
||||
<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}`">
|
||||
<p>{{ t('admin.shippingFieldAssets.blockingCount', { count: props.impact.blocking_count }) }}</p>
|
||||
<ul class="impact-list">
|
||||
<li v-for="item in props.impact.blocking_items" :key="`${item.kind}-${item.object_id}-${item.reference_path}`">
|
||||
<strong>{{ blockingLabel(item.kind) }} · {{ item.display_name }}</strong>
|
||||
<small>
|
||||
#{{ item.object_id }}
|
||||
@@ -59,32 +78,24 @@ function openAdminPath(item: ShippingFieldImpactItem): void {
|
||||
· {{ item.status }}
|
||||
</small>
|
||||
<code>{{ item.reference_path }}</code>
|
||||
<button
|
||||
v-if="item.admin_path"
|
||||
type="button"
|
||||
class="link-button"
|
||||
@click="openAdminPath(item)"
|
||||
>
|
||||
<ElButton v-if="item.admin_path" link type="primary" @click="openAdminPath(item)">
|
||||
{{ t('admin.shippingFieldAssets.impactOpenTarget') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
<section v-else class="impact-section ok">
|
||||
<section v-else>
|
||||
<p>{{ t('admin.shippingFieldAssets.impactNoBlocking') }}</p>
|
||||
</section>
|
||||
<section class="impact-section historical">
|
||||
<section>
|
||||
<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>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalVersions', { count: props.impact.historical.immutable_schema_version_count }) }}</li>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalObservations', { count: props.impact.historical.observation_count }) }}</li>
|
||||
<li>{{ t('admin.shippingFieldAssets.impactHistoricalValues', { count: props.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"
|
||||
>
|
||||
<ul v-if="props.impact.historical.immutable_schema_versions?.length">
|
||||
<li v-for="item in props.impact.historical.immutable_schema_versions" :key="item.schema_version_id">
|
||||
{{ item.schema_display_name || item.schema_code || 'Schema' }}
|
||||
V{{ item.version }} ({{ item.status }})
|
||||
</li>
|
||||
@@ -92,27 +103,21 @@ function openAdminPath(item: ShippingFieldImpactItem): void {
|
||||
<small>{{ t('admin.shippingFieldAssets.impactHistoricalHint') }}</small>
|
||||
</section>
|
||||
</template>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</ElDrawer>
|
||||
</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; }
|
||||
.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; }
|
||||
.impact-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.impact-list li {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
</style>
|
||||
+145
-59
@@ -1,14 +1,34 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-identity-rules/ShippingIdentityRulesPage.vue
|
||||
用途:维护引用已发布订单上下文字段的客户/送货站点识别定义,并发布不可变规则集。
|
||||
依赖:规则 API、Vue Composition API、Vue I18n。
|
||||
逻辑:管理员只能选择服务端提供的已发布识别字段,运行时只消费该字段的已裁决值。
|
||||
-->
|
||||
/**
|
||||
* features/admin/modules/shipping-identity-rules/ShippingIdentityRulesPage.vue
|
||||
* 用途:维护引用已发布订单上下文字段的客户和送货站点识别定义,并发布不可变规则集。
|
||||
* 依赖:AdminListPage、useElementProvider、element-plus、识别规则 API、useMessage。
|
||||
* 逻辑:管理员只能选择服务端提供的已发布识别字段。列表骨架用 AdminListPage。发布仍走原接口。
|
||||
*/
|
||||
<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 { Check, Plus, Promotion, QuestionFilled, TopRight } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElCheckboxGroup,
|
||||
ElConfigProvider,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElRadioButton,
|
||||
ElRadioGroup,
|
||||
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 AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
@@ -22,6 +42,7 @@ import {
|
||||
import type { ShippingIdentityDefinition, ShippingIdentityRuleCatalog, ShippingIdentityRuleSet } from '@/features/admin/types/shipping-identity-rules.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const router = useRouter();
|
||||
const message = useMessage();
|
||||
const catalog = ref<ShippingIdentityRuleCatalog | null>(null);
|
||||
@@ -204,27 +225,52 @@ const openCustomerMaster = (): void => {
|
||||
router.push({ name: 'workspace-shipping-customers' });
|
||||
};
|
||||
|
||||
/**
|
||||
* 识别字段筛选。清空写回空字符串。
|
||||
* @param value - 选中的上下文字段
|
||||
*/
|
||||
function onContextField(value: string | undefined): void {
|
||||
form.context_field_id = value ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新已有定义的自动化授权。空值不提交。
|
||||
* @param definition - 当前识别定义
|
||||
* @param value - none 或 conditional
|
||||
*/
|
||||
function onDefinitionAutomation(
|
||||
definition: ShippingIdentityDefinition,
|
||||
value: 'none' | 'conditional' | undefined,
|
||||
): void {
|
||||
if (!value) return;
|
||||
void updateDefinitionAutomation(definition, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按规则集 id 选中版本。
|
||||
* @param id - 规则集主键
|
||||
*/
|
||||
function selectRuleSet(id: string | number | boolean | undefined): void {
|
||||
selectedRuleSet.value = ruleSets.value.find((item) => item.id === id) || null;
|
||||
}
|
||||
|
||||
onMounted(() => { void load(); });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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>
|
||||
</div>
|
||||
<div class="identity-hero__meta">
|
||||
<div class="identity-hero__status">
|
||||
<span class="identity-pulse" :class="{ 'identity-pulse--draft': !publishedRuleSet }" />
|
||||
<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>
|
||||
</div>
|
||||
</header>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<AdminListPage :loading="loading">
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.shippingIdentityRules.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingIdentityRules.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElTag :type="publishedRuleSet ? 'success' : 'warning'" effect="light">
|
||||
<span v-if="publishedRuleSet">V{{ publishedRuleSet.version }} · {{ t('admin.shippingIdentityRules.status.published') }}</span>
|
||||
<span v-else>{{ t('admin.shippingIdentityRules.status.draft') }}</span>
|
||||
</ElTag>
|
||||
<ElButton :icon="TopRight" @click="openCustomerMaster">{{ t('admin.shippingIdentityRules.openCustomerMaster') }}</ElButton>
|
||||
</template>
|
||||
|
||||
<section class="identity-flow" aria-label="workflow">
|
||||
<div class="identity-flow__rail" />
|
||||
@@ -233,65 +279,104 @@ 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>
|
||||
|
||||
<div v-else class="identity-workbench">
|
||||
<div 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">{{ 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>
|
||||
<ElTag effect="light">{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</ElTag>
|
||||
<ElSelect
|
||||
:model-value="definition.max_automation"
|
||||
class="identity-automation-select"
|
||||
:disabled="saving"
|
||||
@update:model-value="onDefinitionAutomation(definition, $event)"
|
||||
>
|
||||
<ElOption value="none" :label="t('admin.shippingIdentityRules.automations.none')" />
|
||||
<ElOption value="conditional" :label="t('admin.shippingIdentityRules.automations.conditional')" />
|
||||
</ElSelect>
|
||||
</article>
|
||||
</div>
|
||||
<div v-else class="identity-empty"><Tags class="h-5 w-5" /><span>{{ t('admin.shippingIdentityRules.definitionHint') }}</span></div>
|
||||
<div v-else class="identity-empty"><span>{{ t('admin.shippingIdentityRules.definitionHint') }}</span></div>
|
||||
|
||||
<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>
|
||||
<ElForm class="identity-definition-form" label-position="top" @submit.prevent="saveDefinition">
|
||||
<div class="identity-form-title"><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>
|
||||
<ElFormItem :label="t('admin.shippingIdentityRules.displayName')">
|
||||
<ElInput v-model="form.display_name" :placeholder="t('admin.shippingIdentityRules.displayNamePlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingIdentityRules.selectField')">
|
||||
<ElSelect
|
||||
:model-value="form.context_field_id || undefined"
|
||||
clearable
|
||||
:placeholder="t('admin.shippingIdentityRules.selectField')"
|
||||
@update:model-value="onContextField"
|
||||
>
|
||||
<ElOption v-for="field in catalog?.context_fields" :key="field.field_id" :label="field.display_name" :value="field.field_id" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingIdentityRules.target')">
|
||||
<ElSelect v-model="form.target_type">
|
||||
<ElOption value="customer" :label="t('admin.shippingIdentityRules.targets.customer')" />
|
||||
<ElOption value="site" :label="t('admin.shippingIdentityRules.targets.site')" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingIdentityRules.evidenceLabel')">
|
||||
<ElInput v-model="form.evidence_label" :placeholder="t('admin.shippingIdentityRules.evidenceLabelPlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.shippingIdentityRules.description')">
|
||||
<ElInput v-model="form.description" :placeholder="t('admin.shippingIdentityRules.descriptionPlaceholder')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="identity-label-with-tip">
|
||||
{{ t('admin.shippingIdentityRules.automationPolicy') }}
|
||||
<ElIcon :title="t('admin.shippingIdentityRules.automationPolicyHint')"><QuestionFilled /></ElIcon>
|
||||
</span>
|
||||
</template>
|
||||
<ElSelect v-model="form.max_automation">
|
||||
<ElOption value="none" :label="t('admin.shippingIdentityRules.automations.none')" />
|
||||
<ElOption value="conditional" :label="t('admin.shippingIdentityRules.automations.conditional')" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<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>
|
||||
<ElButton type="primary" :icon="Plus" :loading="saving" :disabled="!form.context_field_id" @click="saveDefinition">{{ t('admin.shippingIdentityRules.addDefinition') }}</ElButton>
|
||||
</ElForm>
|
||||
</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">{{ t('admin.shippingIdentityRules.ruleSets') }}</div>
|
||||
<ElButton :icon="Plus" :loading="saving" @click="createDraft">{{ t('admin.shippingIdentityRules.createDraft') }}</ElButton>
|
||||
</div>
|
||||
<p class="identity-publication__hint">{{ t('admin.shippingIdentityRules.ruleSetHint') }}</p>
|
||||
|
||||
<div class="identity-version-list">
|
||||
<button v-for="item in ruleSets" :key="item.id" type="button" class="identity-version" :class="{ 'identity-version--selected': selectedRuleSet?.id === item.id }" @click="selectedRuleSet = item">
|
||||
<span>V{{ item.version }}</span><small>{{ t(`admin.shippingIdentityRules.status.${item.status}`) }}</small>
|
||||
</button>
|
||||
</div>
|
||||
<ElRadioGroup class="identity-version-list" :model-value="selectedRuleSet?.id" @update:model-value="selectRuleSet">
|
||||
<ElRadioButton v-for="item in ruleSets" :key="item.id" :value="item.id">
|
||||
V{{ item.version }} {{ t(`admin.shippingIdentityRules.status.${item.status}`) }}
|
||||
</ElRadioButton>
|
||||
</ElRadioGroup>
|
||||
|
||||
<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>
|
||||
<ElCheckboxGroup v-model="selectedDefinitionIds" class="identity-checks">
|
||||
<ElCheckbox v-for="definition in activeDefinitions" :key="definition.id" :value="definition.id">
|
||||
{{ definition.display_name }}
|
||||
<small>{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</small>
|
||||
</ElCheckbox>
|
||||
</ElCheckboxGroup>
|
||||
</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>
|
||||
<ElTag effect="light">{{ t(`admin.shippingIdentityRules.targets.${definition.target_type}`) }}</ElTag>
|
||||
<ElTag :type="definition.max_automation === 'conditional' ? 'success' : 'info'" effect="light">{{ t(`admin.shippingIdentityRules.automations.${definition.max_automation}`) }}</ElTag>
|
||||
</div>
|
||||
</div>
|
||||
<p v-else class="identity-published-empty">{{ t('admin.shippingIdentityRules.publishedDefinitionsEmpty') }}</p>
|
||||
@@ -299,14 +384,15 @@ 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>
|
||||
<ElButton :loading="saving" :disabled="!selectedDefinitionCount" @click="saveDraft">{{ t('admin.shippingIdentityRules.saveDraft') }}</ElButton>
|
||||
<ElButton type="primary" :icon="Promotion" :loading="saving" :disabled="!selectedDefinitionCount" @click="publishDraft">{{ t('admin.shippingIdentityRules.publish') }}</ElButton>
|
||||
</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>
|
||||
<div v-else class="identity-published"><ElIcon><Check /></ElIcon><span>{{ t('admin.shippingIdentityRules.status.published') }}</span><code>{{ selectedRuleSet.checksum || '-' }}</code></div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
</AdminListPage>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -335,7 +421,7 @@ onMounted(() => { void load(); });
|
||||
.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-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 { display: grid; grid-template-columns: minmax(0, 1fr) auto 11rem; 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; }
|
||||
|
||||
+618
-324
File diff suppressed because it is too large.
Load diff
+37
-12
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileBlindTestPage.vue
|
||||
用途:维护订单模板草稿的独立盲测证据,并完成执行和批准。
|
||||
依赖:盲测 API、Profile 详情、Vue Router、统一业务错误提示和四语言文案。
|
||||
依赖:element-plus、盲测 API、Profile 详情、Vue Router、统一业务错误提示和四语言文案。
|
||||
逻辑:验证页进入本页;所有模板按统一视觉表候选和字段证据复核;
|
||||
末端值源差异由服务端 adapter 投影,管理员复核后写入真值,再执行并批准;
|
||||
XFA 以 datasets 为正式值:OCR 对照与视觉/镜像指标仅 soft 诊断,不硬拦;
|
||||
@@ -11,6 +11,11 @@
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElCheckbox, ElConfigProvider, ElInput, ElOption, ElSelect } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -38,11 +43,20 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const message = useMessage();
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const profileId = Number(route.params.profileId);
|
||||
const sessionId = String(route.query.editorSessionId || '').trim() || createRandomUuid();
|
||||
const suite = ref<OrderProfileTestSuite | null>(null);
|
||||
const availableSamples = ref<OrderProfileBlindTestAvailableSample[]>([]);
|
||||
const selectedSampleKey = ref('');
|
||||
const blindSampleInput = ref<HTMLInputElement | null>(null);
|
||||
|
||||
/**
|
||||
* 打开隐藏文件框。上传仍走原来的 file input,按钮只负责触发选择。
|
||||
*/
|
||||
function openBlindSamplePicker(): void {
|
||||
blindSampleInput.value?.click();
|
||||
}
|
||||
const candidate = ref<OrderProfileBlindTestCandidate | null>(null);
|
||||
const rowReviews = ref<Array<{ correct: boolean; correction: string }>>([]);
|
||||
const orderFieldReviews = ref<Record<string, { correct: boolean; value: string }>>({});
|
||||
@@ -512,13 +526,14 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="blind-test-page">
|
||||
<header>
|
||||
<div>
|
||||
<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"><ElButton @click="backToValidation">{{ t('admin.shippingOrderProfiles.blindTest.backToValidation') }}</ElButton><ElButton type="primary" v-if="suite?.status === 'approved'" @click="goToPublishCheck">{{ t('admin.shippingOrderProfiles.blindTest.goPublishCheck') }}</ElButton></div>
|
||||
</header>
|
||||
|
||||
<p v-if="loading">{{ t('admin.orderProfileValidation.loading') }}</p>
|
||||
@@ -551,9 +566,17 @@ 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>
|
||||
<ElButton :disabled="uploadingSample" @click="openBlindSamplePicker">
|
||||
{{ uploadingSample ? t('admin.shippingOrderProfiles.wizard.uploading') : t('admin.shippingOrderProfiles.blindTest.uploadSample') }}
|
||||
</ElButton>
|
||||
<input ref="blindSampleInput" class="sr-file" type="file" accept=".pdf,.eml,application/pdf,message/rfc822" :disabled="uploadingSample" @change="uploadIndependentSample">
|
||||
</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"><ElButton v-if="!availableSamplesLoaded" :disabled="availableSamplesLoading" @click="() => void loadAvailableSamples()">{{ availableSamplesLoading ? t('admin.shippingOrderProfiles.blindTest.loadingIndependentSamples') : t('admin.shippingOrderProfiles.blindTest.loadIndependentSamples') }}</ElButton><template v-else-if="availableSamples.length"><ElSelect v-model="selectedSampleKey" :placeholder="t('admin.shippingOrderProfiles.blindTest.selectSamplePlaceholder')" clearable>
|
||||
<ElOption v-for="sample in availableSamples" :key="`${sample.document_id}:${sample.table_id}`" :value="`${sample.document_id}:${sample.table_id}`" :label="sampleLabel(sample)" />
|
||||
</ElSelect><ElButton type="primary" v-if="selectedSample?.review_mode === 'preparing'" :disabled="working" @click="reprocessSelectedSample">{{ t('admin.shippingOrderProfiles.blindTest.reprocessLayout') }}</ElButton><ElButton type="primary" v-else :disabled="!selectedSample || working" @click="previewSample">{{ selectedSample?.review_mode === 'diagnostic' ? t('admin.shippingOrderProfiles.blindTest.viewDiagnostic') : t('admin.shippingOrderProfiles.blindTest.previewAndReview') }}</ElButton><ElButton :disabled="availableSamplesLoading || working" @click="() => void loadAvailableSamples(true)">{{ t('admin.shippingOrderProfiles.blindTest.refreshSamples') }}</ElButton></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,23 +603,24 @@ 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')" />
|
||||
<label><ElCheckbox v-model="rowReviews[index].correct">{{ t('admin.shippingOrderProfiles.blindTest.correct') }}</label>
|
||||
<ElInput type="textarea" v-if="!rowReviews[index].correct" v-model="rowReviews[index].correction" :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 })">
|
||||
<label><ElCheckbox :model-value="orderFieldReview(orderFieldKey(field)).correct" @update:model-value="updateOrderFieldReview(orderFieldKey(field), { correct: $event === true })">{{ t('admin.shippingOrderProfiles.blindTest.correct') }}</label>
|
||||
<ElInput v-if="!orderFieldReview(orderFieldKey(field)).correct" :value="orderFieldReview(orderFieldKey(field)).value" :placeholder="t('admin.shippingOrderProfiles.blindTest.correctedValue')" @input="updateOrderFieldReview(orderFieldKey(field), { value: String($event ?? '') })">
|
||||
</article>
|
||||
<button v-if="candidate.confirmable" type="button" class="btn-primary" :disabled="working || !candidate.rows.length" @click="confirmReview">{{ t('admin.shippingOrderProfiles.blindTest.confirmReview') }}</button>
|
||||
<ElButton type="primary" v-if="candidate.confirmable" :disabled="working || !candidate.rows.length" @click="confirmReview">{{ t('admin.shippingOrderProfiles.blindTest.confirmReview') }}</ElButton>
|
||||
</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><ElButton v-if="suite.status === 'draft'" :disabled="working" @click="removeSample(sample.id)">{{ t('admin.shippingOrderProfiles.blindTest.removeSample') }}</ElButton></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"><ElButton v-if="suite.status === 'draft'" :disabled="working || !suite.sample_count" @click="executeSuite">{{ t('admin.shippingOrderProfiles.blindTest.run') }}</ElButton><ElButton v-if="suite.status === 'draft' && !hasTrainingSample" :disabled="working" @click="goToEditor">{{ t('admin.shippingOrderProfiles.blindTest.goToEditor') }}</ElButton><ElButton type="primary" v-if="suite.status === 'draft'" :disabled="working || !canApprove" @click="approveSuite">{{ t('admin.shippingOrderProfiles.blindTest.approve') }}</ElButton></div></section>
|
||||
</template>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -610,7 +634,8 @@ header { align-items: flex-start; margin-bottom: 24px; } h1, h2, h3, p { margin:
|
||||
.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); }
|
||||
.sr-file { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
|
||||
.upload-sample { position: relative; cursor: pointer; }.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; }
|
||||
|
||||
+26
-12
@@ -1,14 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileCreateWizardPage.vue
|
||||
用途:以三步向导创建订单文档模板草稿。
|
||||
依赖:Schema/样本/表格 API、步骤组件和 Vue Router。
|
||||
依赖:element-plus、Schema/样本/表格 API、步骤组件和 Vue Router。
|
||||
逻辑:所有有明细的样本在第三步选择同一视觉主表;XFA datasets/OCR 差异只在编辑器的字段取值映射中配置。
|
||||
-->
|
||||
<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 { ArrowLeft, ArrowRight, Check, Document, Files, MagicStick } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElConfigProvider, ElIcon } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -23,6 +28,7 @@ import OrderProfileModelStartStep from './components/OrderProfileModelStartStep.
|
||||
type Identity = { displayName: string; schemaId: number };
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const router = useRouter();
|
||||
const message = useMessage();
|
||||
const step = ref(1);
|
||||
@@ -45,9 +51,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 },
|
||||
]);
|
||||
|
||||
/** 接收首步身份快照;父级单一状态驱动下一步校验,避免子组件对象替换造成状态不同步。 */
|
||||
@@ -158,6 +164,7 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="wizard-page">
|
||||
<div class="wizard-shell">
|
||||
<header class="wizard-heading">
|
||||
@@ -167,7 +174,7 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
|
||||
<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 class="stepper-icon"><ElIcon v-if="item.number < step"><Check /></ElIcon><ElIcon v-else><component :is="item.icon" /></ElIcon></span>
|
||||
<span><small>{{ t('admin.shippingOrderProfiles.wizard.stepLabel', { step: item.number }) }}</small>{{ item.label }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
@@ -189,17 +196,24 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
</main>
|
||||
|
||||
<footer class="wizard-actions">
|
||||
<button type="button" class="btn-secondary" @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.cancel') }}</button>
|
||||
<ElButton @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.cancel') }}</ElButton>
|
||||
<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>
|
||||
<ElButton v-if="step > 1" :icon="ArrowLeft" @click="step -= 1">{{ t('admin.shippingOrderProfiles.wizard.previous') }}</ElButton>
|
||||
<ElButton v-if="step < 3" type="primary" :disabled="!canNext" @click="next">
|
||||
{{ t('admin.shippingOrderProfiles.wizard.next') }}
|
||||
<ElIcon class="el-icon--right"><ArrowRight /></ElIcon>
|
||||
</ElButton>
|
||||
<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>
|
||||
<ElButton :disabled="saving || !canNext" :loading="saving" @click="finish(false)">{{ t('admin.shippingOrderProfiles.wizard.createDraft') }}</ElButton>
|
||||
<ElButton type="primary" :disabled="!canNext" :loading="saving" @click="finish(true)">
|
||||
{{ t('admin.shippingOrderProfiles.wizard.createAndEdit') }}
|
||||
<ElIcon class="el-icon--right"><ArrowRight /></ElIcon>
|
||||
</ElButton>
|
||||
</template>
|
||||
</footer>
|
||||
</div>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -209,5 +223,5 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
.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-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-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; } }
|
||||
</style>
|
||||
+230
-235
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileEditorPage.vue
|
||||
用途:订单文档 Profile 统一草稿标注编辑页(普通 PDF 坐标 + XFA 混合数据源共享画布)。
|
||||
依赖:受控预览 API、Schema API、DocumentCanvas、useOrderProfileValueAdapter、
|
||||
依赖:element-plus、受控预览 API、Schema API、DocumentCanvas、useOrderProfileValueAdapter、
|
||||
XfaDatasetTree、XfaCollectionSelector、XfaSplitRulePanel、shippingOrderField.utils。
|
||||
逻辑:PDF 与 XFA 共用同一 desk DOM(main + aside.config + OrderProfileDocumentCanvas);
|
||||
XFA 仅在属性区插入读取方式/数据源/拆分/样本显示增量;OCR 建议进入普通建议区;
|
||||
@@ -28,6 +28,11 @@ import {
|
||||
} from "vue";
|
||||
import { onBeforeRouteLeave, useRoute, useRouter } from "vue-router";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ElButton, ElConfigProvider, ElDialog, ElInput, ElMessageBox, ElOption, ElSelect } from "element-plus";
|
||||
import "element-plus/dist/index.css";
|
||||
import "element-plus/theme-chalk/dark/css-vars.css";
|
||||
import "@/features/admin/styles/element-trial.css";
|
||||
import { useElementProvider } from "@/features/admin/composables/useElementProvider";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { useMessage } from "@/shared/composables/useMessage";
|
||||
import { createRandomUuid } from "@/shared/utils/id";
|
||||
@@ -79,7 +84,6 @@ import type {
|
||||
ShippingOrderSchemaVersion,
|
||||
} from "@/features/admin/types/shipping-order-schema.types";
|
||||
import OrderProfileDocumentCanvas from "./components/OrderProfileDocumentCanvas.vue";
|
||||
import DeleteConfirmDialog from "@/shared/components/DeleteConfirmDialog.vue";
|
||||
import XfaCollectionSelector from "./components/XfaCollectionSelector.vue";
|
||||
import XfaDatasetTree from "./components/XfaDatasetTree.vue";
|
||||
import XfaSplitRulePanel from "./components/XfaSplitRulePanel.vue";
|
||||
@@ -122,6 +126,7 @@ import {
|
||||
} from "./orderProfileForm.utils";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const message = useMessage();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -230,8 +235,6 @@ const captureRegionForRegionText = (region: OrderProfileRelativeRegion): string
|
||||
const previewState = ref<"idle" | "updating" | "ready" | "failed">("idle");
|
||||
const canvasUnavailable = ref(false);
|
||||
const saving = ref(false);
|
||||
const leaveConfirmOpen = ref(false);
|
||||
let resolveRouteLeave: ((allowed: boolean) => void) | null = null;
|
||||
const suggestingRegions = ref(false);
|
||||
const suggestionProgress = ref("");
|
||||
type AutomarkStage = 'idle' | 'checking' | 'queued' | 'analyzing' | 'building' | 'review' | 'failed' | 'complete';
|
||||
@@ -299,21 +302,8 @@ const canvasNeedsLayoutRecovery = computed(() => Boolean(
|
||||
));
|
||||
|
||||
/**
|
||||
* 绑定拆分弹窗 DOM,供焦点陷阱使用。
|
||||
*/
|
||||
function assignXfaSplitDialogPanel(el: unknown): void {
|
||||
valueAdapterDesk.splitRuleDialogPanel = (el as HTMLElement | null) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定 datasets 字段选择弹窗 DOM,供焦点陷阱使用。
|
||||
*/
|
||||
function assignXfaDatasetsPickerPanel(el: unknown): void {
|
||||
valueAdapterDesk.datasetsPickerPanel = (el as HTMLElement | null) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定拆分规则面板实例,供 Header 动作调用。
|
||||
* 绑定拆分规则面板实例,供弹窗头部动作调用。
|
||||
* @param el - 面板组件实例
|
||||
*/
|
||||
function assignXfaSplitRulePanel(el: unknown): void {
|
||||
valueAdapterDesk.splitRulePanel = (el as typeof valueAdapterDesk.splitRulePanel) || null;
|
||||
@@ -472,9 +462,6 @@ const form = reactive({
|
||||
});
|
||||
/** 冻结的模板主表身份;与当前 PDF 页用于预览的表身份严格分离。 */
|
||||
const mainTableId = ref('');
|
||||
/** 管理员选择候选表后,须经二次确认才允许覆盖冻结主表。 */
|
||||
const pendingMainTableRepairId = ref('');
|
||||
const mainTableRepairConfirmOpen = ref(false);
|
||||
const regions = ref<OrderProfileCanvasRegion[]>([]);
|
||||
/** 已提交版面重解析时禁用重复请求;不修改草稿或样本绑定。 */
|
||||
const reparsingLayout = ref(false);
|
||||
@@ -2761,17 +2748,76 @@ const repairMainTable = async (tableId: string): Promise<void> => {
|
||||
repairingMainTable.value = false;
|
||||
}
|
||||
};
|
||||
/** 打开受控恢复确认;选择候选本身绝不写入草稿。 */
|
||||
const requestMainTableRepair = (tableId: string): void => {
|
||||
|
||||
/**
|
||||
* 写回自动标注的表来源。空值不切换。
|
||||
* @param value - 表来源标识
|
||||
*/
|
||||
function onAutomarkTableSource(value: string | undefined): void {
|
||||
if (value) void chooseAutomarkTableSource(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写回字段冲突来源。清空回到空字符串,表示尚未选择。
|
||||
* @param fieldId - 冲突字段
|
||||
* @param value - 来源标识
|
||||
*/
|
||||
function onAutomarkFieldSource(fieldId: string, value: string | undefined): void {
|
||||
void chooseAutomarkFieldSource(fieldId, value || "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择候选主表后立刻确认。下拉不保留选中值。
|
||||
* @param value - 候选 table id;清空为 undefined
|
||||
*/
|
||||
function onMainTableRepairPick(value: string | undefined): void {
|
||||
if (value) void requestMainTableRepair(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭 datasets 路径弹窗。打开由适配器状态驱动。
|
||||
* @param visible - 弹窗是否仍打开
|
||||
*/
|
||||
function onDatasetsPickerVisible(visible: boolean): void {
|
||||
if (!visible) valueAdapterDesk.closeDatasetsPicker();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭拆分规则弹窗。
|
||||
* @param visible - 弹窗是否仍打开
|
||||
*/
|
||||
function onSplitRuleDialogVisible(visible: boolean): void {
|
||||
if (!visible) valueAdapterDesk.closeSplitRuleDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭集合复核弹窗。
|
||||
* @param visible - 弹窗是否仍打开
|
||||
*/
|
||||
function onReconfirmCollectionsVisible(visible: boolean): void {
|
||||
if (!visible) valueAdapterDesk.closeReconfirmCollections();
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择候选主表后先确认,确认前绝不写入草稿。
|
||||
* @param tableId - 候选表 id
|
||||
*/
|
||||
const requestMainTableRepair = async (tableId: string): Promise<void> => {
|
||||
if (!tableId) return;
|
||||
pendingMainTableRepairId.value = tableId;
|
||||
mainTableRepairConfirmOpen.value = true;
|
||||
};
|
||||
/** 确认后才执行预检和原子保存。 */
|
||||
const confirmMainTableRepair = (): void => {
|
||||
const tableId = pendingMainTableRepairId.value;
|
||||
pendingMainTableRepairId.value = '';
|
||||
if (tableId) void repairMainTable(tableId);
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t("admin.shippingOrderProfiles.workbench.mainTableRepairConfirmMessage"),
|
||||
t("admin.shippingOrderProfiles.workbench.mainTableRepairConfirmTitle"),
|
||||
{
|
||||
confirmButtonText: t("admin.shippingOrderProfiles.workbench.mainTableRepairConfirmAction"),
|
||||
cancelButtonText: t("common.deleteDialog.cancel"),
|
||||
type: "warning",
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
void repairMainTable(tableId);
|
||||
};
|
||||
/** 请求当前或全部表头的只读精确别名建议;结果不自动修改人工字段绑定。 */
|
||||
const suggestHeaders = async (currentOnly: boolean) => {
|
||||
@@ -3363,16 +3409,23 @@ const handleShortcut = (event: KeyboardEvent) => {
|
||||
}
|
||||
};
|
||||
/** 路由切换前提示未保存区域编辑,避免误点版本/导航导致草稿状态丢失。 */
|
||||
onBeforeRouteLeave(() => {
|
||||
onBeforeRouteLeave(async () => {
|
||||
if (!dirty.value) return true;
|
||||
leaveConfirmOpen.value = true;
|
||||
return new Promise<boolean>((resolve) => { resolveRouteLeave = resolve; });
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t("admin.shippingOrderProfiles.workbench.leaveConfirm"),
|
||||
t("admin.shippingOrderProfiles.workbench.leaveConfirm"),
|
||||
{
|
||||
confirmButtonText: t("common.deleteDialog.confirm"),
|
||||
cancelButtonText: t("common.deleteDialog.cancel"),
|
||||
type: "warning",
|
||||
},
|
||||
);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
const resolveLeave = (allowed: boolean) => {
|
||||
leaveConfirmOpen.value = false;
|
||||
resolveRouteLeave?.(allowed);
|
||||
resolveRouteLeave = null;
|
||||
};
|
||||
onMounted(async () => {
|
||||
window.addEventListener("beforeunload", beforeUnload);
|
||||
window.addEventListener("keydown", handleShortcut);
|
||||
@@ -3417,6 +3470,7 @@ onBeforeUnmount(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="workbench editor-workbench">
|
||||
<header class="bench-header">
|
||||
<div class="editor-title">
|
||||
@@ -3431,34 +3485,31 @@ onBeforeUnmount(() => {
|
||||
<div class="header-actions">
|
||||
<output class="save-status" :class="`save-status--${saveState}`">{{ t(`admin.shippingOrderProfiles.workbench.saveStatus.${saveState}`) }}</output>
|
||||
<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>
|
||||
<ElButton @click="downloadLocalDraft">{{ t('admin.shippingOrderProfiles.workbench.headerExport') }}</ElButton>
|
||||
<ElButton @click="() => void recoverEditLease()">{{ t('admin.shippingOrderProfiles.workbench.headerRecoverLease') }}</ElButton>
|
||||
<ElButton @click="() => void recoverEditLease(true)">{{ t('admin.shippingOrderProfiles.workbench.headerTakeOverLease') }}</ElButton>
|
||||
</div>
|
||||
<output v-if="active && currentSampleIsTraining" class="training-sample-status">{{ t('admin.shippingOrderProfiles.workbench.headerTrainingSample') }}</output>
|
||||
<button
|
||||
<ElButton
|
||||
v-else-if="active"
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
|
||||
:disabled="!deskCanvasDocumentReady || saveState === 'readonly'"
|
||||
@click="() => void addCurrentTrainingSample()"
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.headerAddTrainingSample') }}</button>
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.headerAddTrainingSample') }}</ElButton>
|
||||
<div class="header-actions__flow">
|
||||
<button
|
||||
<ElButton type="primary"
|
||||
v-if="active"
|
||||
type="button"
|
||||
:disabled="deskSaveButtonDisabled"
|
||||
class="btn-primary"
|
||||
|
||||
@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") }}</ElButton>
|
||||
<ElButton
|
||||
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') }}</ElButton>
|
||||
<ElButton @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.shippingOrderProfiles.workbench.headerReturnToLibrary') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@@ -3467,17 +3518,16 @@ 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">
|
||||
<ElButton v-if="deskCanvasWarningVisible" @click="onDeskCanvasRetry">
|
||||
{{ deskCanvasRetryLabel }}
|
||||
</button>
|
||||
<button
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="canvasNeedsLayoutRecovery"
|
||||
type="button"
|
||||
:disabled="reparsingLayout"
|
||||
@click="() => void reprocessCurrentSampleLayout()"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.blindTest.reprocessLayout') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<section v-if="suggestingRegions || pendingSuggestion" class="automark-status-panel" role="status" aria-live="polite">
|
||||
<div class="automark-status-panel__heading">
|
||||
@@ -3493,15 +3543,14 @@ 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>
|
||||
<ElButton @click="returnToPendingSuggestionPage">{{ t('admin.shippingOrderProfiles.workbench.returnToSuggestionPage') }}</ElButton>
|
||||
</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>
|
||||
<ElSelect :model-value="selectedAutomarkTableSource" :disabled="saveState === 'readonly'" @update:model-value="onAutomarkTableSource($event)" :placeholder="t('admin.shippingOrderProfiles.workbench.autoSuggestChooseEvidence')" clearable>
|
||||
<ElOption v-for="candidate in automarkTableCandidates" :key="candidate.source" :value="candidate.source" :label="candidate.source" />
|
||||
</ElSelect>
|
||||
</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 +3562,18 @@ 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>
|
||||
<ElSelect :model-value="selectedAutomarkFieldSources[conflict.field_id] || undefined" :disabled="saveState === 'readonly'" @update:model-value="onAutomarkFieldSource(conflict.field_id, $event)" :placeholder="t('admin.shippingOrderProfiles.workbench.autoSuggestChooseEvidence')" clearable>
|
||||
<ElOption v-for="source in conflict.sources" :key="source" :value="source" :label="source" />
|
||||
</ElSelect>
|
||||
</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>
|
||||
<ElSelect v-model="suggestionAdjustmentField" :disabled="saveState === 'readonly'" :aria-label="t('admin.shippingOrderProfiles.workbench.suggestionAdjustmentField')" :placeholder="t('admin.shippingOrderProfiles.workbench.suggestionAdjustmentField')" clearable>
|
||||
<ElOption v-for="field in lineFields" :key="field.field_code || field.field_id" :value="field.field_code || ''" :label="`${field.display_name || ''} · ${field.field_code || ''}`" />
|
||||
</ElSelect>
|
||||
<ElButton type="primary" :disabled="saveState === 'readonly' || automarkTableChoiceRequired || automarkFieldChoiceRequired" @click="() => void decidePendingSuggestion('accepted')">{{ t('admin.shippingOrderProfiles.workbench.acceptSuggestion') }}</ElButton>
|
||||
<ElButton :disabled="saveState === 'readonly' || !suggestionAdjustmentField" @click="() => void decidePendingSuggestion('accepted_adjusted')">{{ t('admin.shippingOrderProfiles.workbench.acceptAdjustedSuggestion') }}</ElButton>
|
||||
<ElButton :disabled="saveState === 'readonly'" @click="() => void decidePendingSuggestion('rejected')">{{ t('admin.shippingOrderProfiles.workbench.rejectSuggestion') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -3536,20 +3586,18 @@ onBeforeUnmount(() => {
|
||||
<p>
|
||||
{{ t('admin.shippingOrderProfiles.workbench.unboundRegionsBanner', { count: unboundOrderFieldRegions.length }) }}
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary unbound-regions-banner__clear"
|
||||
<ElButton
|
||||
class="unbound-regions-banner__clear"
|
||||
:disabled="saveState === 'readonly'"
|
||||
@click="clearUnboundOrderFieldRegions"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.workbench.clearUnboundRegions') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<div class="unbound-regions-banner__list">
|
||||
<button
|
||||
<ElButton
|
||||
v-for="region in unboundOrderFieldRegions"
|
||||
:key="region.id"
|
||||
type="button"
|
||||
class="unbound-regions-banner__item"
|
||||
:class="{ active: selectedId === region.id }"
|
||||
@click="() => void focusUnboundOrderFieldRegion(region.id)"
|
||||
@@ -3558,7 +3606,7 @@ onBeforeUnmount(() => {
|
||||
page: region.pageNo,
|
||||
label: region.label,
|
||||
}) }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</section>
|
||||
<OrderProfileDocumentCanvas
|
||||
@@ -3630,21 +3678,19 @@ onBeforeUnmount(() => {
|
||||
<section v-if="!hasValueSourceMapping && active" class="reservation-region-config">
|
||||
<strong>Reservation ID 证据区域</strong>
|
||||
<p>只需圈选包含 Reservation ID 的备注区域;系统统一解析:无行号写订单头,带行号写对应明细。</p>
|
||||
<button
|
||||
type="button"
|
||||
<ElButton
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@click="onDeskCanvasDraw('reservation_id_region')"
|
||||
>
|
||||
{{ reservationIdRegion ? '重新标记 Reservation ID 区域' : '标记 Reservation ID 区域' }}
|
||||
</button>
|
||||
<button
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="reservationIdRegion"
|
||||
type="button"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@click="clearReservationIdRegion"
|
||||
>
|
||||
清除区域
|
||||
</button>
|
||||
</ElButton>
|
||||
<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,82 +3737,72 @@ onBeforeUnmount(() => {
|
||||
<template v-if="selectedRegion">
|
||||
<label
|
||||
>{{ t("admin.shippingOrderProfiles.workbench.label")
|
||||
}}<input
|
||||
}}<ElInput
|
||||
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
|
||||
}}<ElSelect
|
||||
v-model="selectedRegion.parentId"
|
||||
class="select-field"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFormEdit"
|
||||
@change="finishFormEdit"
|
||||
>
|
||||
<option
|
||||
v-for="line in pageRegions.filter(
|
||||
(item) => item.kind === 'line',
|
||||
)"
|
||||
<ElOption
|
||||
v-for="line in pageRegions.filter((item) => item.kind === 'line')"
|
||||
:key="line.id"
|
||||
:value="line.id"
|
||||
>
|
||||
{{ line.label }}
|
||||
</option>
|
||||
</select></label
|
||||
:label="line.label"
|
||||
/>
|
||||
</ElSelect></label
|
||||
><label v-if="selectedRegion.kind === 'line'"
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.tableRegionRole')
|
||||
}}<select
|
||||
:value="selectedRegion.tableRegionRole || 'business_lines'"
|
||||
class="select-field"
|
||||
}}<ElSelect
|
||||
:model-value="selectedRegion.tableRegionRole || 'business_lines'"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFormEdit"
|
||||
@change="onSelectedLineTableRegionRoleChange"
|
||||
>
|
||||
<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>
|
||||
<ElOption value="business_lines" :label="t('admin.shippingOrderProfiles.workbench.tableRegionRoles.business_lines')" />
|
||||
<ElOption value="line_field_supplement" :label="t('admin.shippingOrderProfiles.workbench.tableRegionRoles.line_field_supplement')" />
|
||||
</ElSelect>
|
||||
<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
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.schemaField')
|
||||
}}<ElSelect
|
||||
v-model="selectedRegion.fieldCode"
|
||||
class="select-field"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
:placeholder="t('admin.shippingOrderProfiles.workbench.selectField')"
|
||||
clearable
|
||||
@focus="beginFieldBindingEdit"
|
||||
@change="finishFieldBindingEdit"
|
||||
>
|
||||
<option :value="null">
|
||||
{{ t("admin.shippingOrderProfiles.workbench.selectField") }}
|
||||
</option>
|
||||
<option
|
||||
<ElOption
|
||||
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 || ''"
|
||||
:label="`${field.display_name || ''} · ${field.field_code || ''}`"
|
||||
/>
|
||||
</ElSelect></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') }}<ElSelect v-model="selectedRegion.valueMode" :disabled="compactEditor || saveState === 'readonly'" @focus="beginFormEdit" @change="finishFormEdit">
|
||||
<ElOption value="single_line" :label="t('admin.shippingOrderProfiles.workbench.orderFieldModes.singleLine')" />
|
||||
<ElOption value="right_of_anchor" :label="t('admin.shippingOrderProfiles.workbench.orderFieldModes.rightOfAnchor')" />
|
||||
<ElOption value="below_anchor" :label="t('admin.shippingOrderProfiles.workbench.orderFieldModes.belowAnchor')" />
|
||||
<ElOption value="multi_line" :label="t('admin.shippingOrderProfiles.workbench.orderFieldModes.multiLine')" />
|
||||
</ElSelect></label>
|
||||
<label v-if="selectedRegion.valueMode === 'multi_line'">{{ t("admin.shippingOrderProfiles.workbench.orderFieldStopAnchor") }}<ElInput v-model="selectedRegion.stopAnchorText" :disabled="compactEditor || saveState === 'readonly'" :placeholder="t('admin.shippingOrderProfiles.workbench.orderFieldStopAnchorPlaceholder')" @focus="beginFormEdit" @change="finishFormEdit" /></label>
|
||||
</template>
|
||||
<button
|
||||
<ElButton
|
||||
v-if="
|
||||
selectedRegion.kind === 'field' &&
|
||||
selectedFieldHeaderSuggestion &&
|
||||
selectedFieldHeaderSuggestion !== selectedRegion.fieldCode
|
||||
"
|
||||
type="button"
|
||||
class="binding-suggestion"
|
||||
@click="
|
||||
applyFieldBindingSuggestion(
|
||||
@@ -3780,15 +3816,15 @@ onBeforeUnmount(() => {
|
||||
field: previewFieldLabel(selectedFieldHeaderSuggestion),
|
||||
})
|
||||
}}
|
||||
</button>
|
||||
</ElButton>
|
||||
<template v-if="selectedRegion.kind === 'header_field'">
|
||||
<button type="button" @click="suggestHeaders(true)">
|
||||
<ElButton @click="suggestHeaders(true)">
|
||||
{{ t("admin.shippingOrderProfiles.workbench.matchCurrentHeader") }}
|
||||
</button>
|
||||
<button type="button" @click="suggestHeaders(false)">
|
||||
</ElButton>
|
||||
<ElButton @click="suggestHeaders(false)">
|
||||
{{ t("admin.shippingOrderProfiles.workbench.matchAllHeaders") }}
|
||||
</button>
|
||||
<button
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-for="entry in headerSuggestions
|
||||
.filter(
|
||||
(item) => item.layout_id === selectedHeaderLayoutId,
|
||||
@@ -3804,7 +3840,6 @@ onBeforeUnmount(() => {
|
||||
})),
|
||||
)"
|
||||
:key="`${entry.regionId}-${entry.field.text}`"
|
||||
type="button"
|
||||
class="binding-suggestion"
|
||||
:disabled="!entry.regionId || !entry.field.field_code"
|
||||
@click="
|
||||
@@ -3832,7 +3867,7 @@ onBeforeUnmount(() => {
|
||||
{ text: entry.field.text || "-" },
|
||||
)
|
||||
}}
|
||||
</button>
|
||||
</ElButton>
|
||||
</template>
|
||||
<p>{{ t("admin.shippingOrderProfiles.workbench.dragHint") }}</p>
|
||||
</template>
|
||||
@@ -3841,15 +3876,14 @@ 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"
|
||||
<ElButton
|
||||
|
||||
: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>
|
||||
</ElButton>
|
||||
</label>
|
||||
<section class="sample-value-card">
|
||||
<span>{{ t('admin.shippingOrderProfiles.xfaDesk.datasetsSampleValue') }}</span>
|
||||
@@ -3867,14 +3901,13 @@ onBeforeUnmount(() => {
|
||||
confirmed: valueAdapterDesk.splitRuleSummary.confirmed,
|
||||
}) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
<ElButton
|
||||
|
||||
:disabled="xfaConfigReadonly || !valueAdapterDesk.selectedPathId"
|
||||
@click="valueAdapterDesk.openSplitRulesForSelection()"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.editRules') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</label>
|
||||
<p class="xfa-header-inheritance-hint">{{ t('admin.shippingOrderProfiles.xfaSplit.splitVisualReuseHint') }}</p>
|
||||
<section class="xfa-datasource-summary">
|
||||
@@ -3883,14 +3916,13 @@ onBeforeUnmount(() => {
|
||||
authoritative: valueAdapterDesk.collectionSummaryLabel.authoritative,
|
||||
mirrors: valueAdapterDesk.collectionSummaryLabel.mirrors,
|
||||
}) }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
<ElButton
|
||||
|
||||
:disabled="saveState === 'readonly'"
|
||||
@click="valueAdapterDesk.openReconfirmCollections()"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollections') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -3908,25 +3940,23 @@ onBeforeUnmount(() => {
|
||||
<p v-if="previewState === 'failed'" class="recognition-error">{{ previewError }}</p>
|
||||
<section class="recognition-group">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.workbench.orderHeaderResults') }}</h2>
|
||||
<button
|
||||
<ElButton
|
||||
v-for="item in deskHeaderRecognitionResults"
|
||||
:key="item.key"
|
||||
type="button"
|
||||
class="recognition-row"
|
||||
@click="selectDeskRecognitionRegion(item.id)"
|
||||
>
|
||||
<span :title="schemaFieldLabel(item.fieldCode)">{{ schemaFieldLabel(item.fieldCode) }}</span>
|
||||
<strong :class="{ empty: !item.value }" :title="item.value || (item.status === 'loading' ? t('admin.shippingOrderProfiles.workbench.orderFieldValueReading') : t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable'))">{{ item.value || (item.status === 'loading' ? t('admin.shippingOrderProfiles.workbench.orderFieldValueReading') : t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable')) }}</strong>
|
||||
<small :class="`evidence-status--${item.status}`">{{ t(`admin.shippingOrderProfiles.workbench.evidenceStatus.${item.status}`) }}</small>
|
||||
</button>
|
||||
</ElButton>
|
||||
<p v-if="!deskHeaderRecognitionResults.length" class="recognition-empty">{{ t('admin.shippingOrderProfiles.workbench.noRecognitionResults') }}</p>
|
||||
</section>
|
||||
<section class="recognition-group">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.workbench.orderLineResults') }}</h2>
|
||||
<button
|
||||
<ElButton
|
||||
v-for="item in deskLineRecognitionResults"
|
||||
:key="item.key"
|
||||
type="button"
|
||||
class="recognition-row"
|
||||
:disabled="!item.id"
|
||||
@click="selectDeskRecognitionRegion(item.id)"
|
||||
@@ -3934,39 +3964,29 @@ onBeforeUnmount(() => {
|
||||
<span :title="t('admin.shippingOrderProfiles.workbench.lineResultField', { row: item.rowNo || 1, field: schemaFieldLabel(item.fieldCode) })">{{ t('admin.shippingOrderProfiles.workbench.lineResultField', { row: item.rowNo || 1, field: schemaFieldLabel(item.fieldCode) }) }}</span>
|
||||
<strong :class="{ empty: !item.value }" :title="item.value || t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable')">{{ item.value || t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable') }}</strong>
|
||||
<small :class="`evidence-status--${item.status}`">{{ t(`admin.shippingOrderProfiles.workbench.evidenceStatus.${item.status}`) }}</small>
|
||||
</button>
|
||||
</ElButton>
|
||||
<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>
|
||||
<ElSelect :disabled="repairingMainTable" @update:model-value="onMainTableRepairPick($event)" :placeholder="t('admin.shippingOrderProfiles.workbench.mainTableRepairChoose')" clearable>
|
||||
<ElOption 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 })" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</aside>
|
||||
|
||||
<div
|
||||
v-if="hasValueSourceMapping && valueAdapterDesk.datasetsPickerOpen"
|
||||
class="xfa-rule-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPathTitle')"
|
||||
@keydown.esc.stop.prevent="valueAdapterDesk.closeDatasetsPicker()"
|
||||
<ElDialog
|
||||
:model-value="Boolean(hasValueSourceMapping && valueAdapterDesk.datasetsPickerOpen)"
|
||||
:title="t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPathTitle')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onDatasetsPickerVisible"
|
||||
>
|
||||
<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>
|
||||
<div class="xfa-datasets-picker-body">
|
||||
<p>{{ t('admin.shippingOrderProfiles.xfaDesk.pickDatasetsPathHint') }}</p>
|
||||
<div class="xfa-datasets-picker-body">
|
||||
<XfaDatasetTree
|
||||
expand-samples
|
||||
:tree="valueAdapterDesk.tree"
|
||||
@@ -3980,36 +4000,29 @@ onBeforeUnmount(() => {
|
||||
@select-rule="valueAdapterDesk.selectSplitRuleFromTree"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</ElDialog>
|
||||
|
||||
<div
|
||||
v-if="hasValueSourceMapping && valueAdapterDesk.splitRuleDialogOpen"
|
||||
class="xfa-rule-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
@keydown.esc.stop.prevent="valueAdapterDesk.closeSplitRuleDialog()"
|
||||
<ElDialog
|
||||
:model-value="Boolean(hasValueSourceMapping && valueAdapterDesk.splitRuleDialogOpen)"
|
||||
:title="t('admin.shippingOrderProfiles.xfaSplit.title')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onSplitRuleDialogVisible"
|
||||
>
|
||||
<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()">
|
||||
<p>{{ valueAdapterDesk.selectedPathLabel }}</p>
|
||||
<div class="xfa-rule-dialog__actions">
|
||||
<ElButton :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()">
|
||||
</ElButton>
|
||||
<ElButton :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()">
|
||||
</ElButton>
|
||||
<ElButton type="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>
|
||||
</ElButton>
|
||||
</div>
|
||||
</header>
|
||||
<XfaSplitRulePanel
|
||||
v-if="active && (valueAdapterDesk.dialogDefinition || valueAdapterDesk.definition)"
|
||||
:ref="assignXfaSplitRulePanel"
|
||||
@@ -4030,25 +4043,18 @@ onBeforeUnmount(() => {
|
||||
@update:split-rules="valueAdapterDesk.onDialogSplitRulesUpdate"
|
||||
@confirmed="valueAdapterDesk.commitDialogSplitRules"
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</ElDialog>
|
||||
|
||||
<div
|
||||
v-if="hasValueSourceMapping && valueAdapterDesk.reconfirmCollectionsOpen"
|
||||
class="xfa-rule-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
@keydown.esc.stop.prevent="valueAdapterDesk.closeReconfirmCollections()"
|
||||
<ElDialog
|
||||
:model-value="Boolean(hasValueSourceMapping && valueAdapterDesk.reconfirmCollectionsOpen)"
|
||||
:title="t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsTitle')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onReconfirmCollectionsVisible"
|
||||
>
|
||||
<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>
|
||||
<p>{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsHint') }}</p>
|
||||
<XfaCollectionSelector
|
||||
:candidates="valueAdapterDesk.collections"
|
||||
:authoritative-path-id="valueAdapterDesk.draftAuthoritativePathId"
|
||||
@@ -4057,27 +4063,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()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsConfirm') }}
|
||||
</button>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
<template #footer>
|
||||
<ElButton @click="valueAdapterDesk.closeReconfirmCollections()">{{ t('common.cancel') }}</ElButton>
|
||||
<ElButton type="primary" @click="valueAdapterDesk.confirmReconfirmCollections()">
|
||||
{{ t('admin.shippingOrderProfiles.xfaDesk.reconfirmCollectionsConfirm') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</div>
|
||||
<DeleteConfirmDialog
|
||||
v-model="mainTableRepairConfirmOpen"
|
||||
:title="t('admin.shippingOrderProfiles.workbench.mainTableRepairConfirmTitle')"
|
||||
:message="t('admin.shippingOrderProfiles.workbench.mainTableRepairConfirmMessage')"
|
||||
:confirm-text="t('admin.shippingOrderProfiles.workbench.mainTableRepairConfirmAction')"
|
||||
confirm-tone="primary"
|
||||
:confirm-loading="repairingMainTable"
|
||||
@confirm="confirmMainTableRepair"
|
||||
@cancel="() => { pendingMainTableRepairId = ''; }"
|
||||
/>
|
||||
<DeleteConfirmDialog v-model="leaveConfirmOpen" :message="t('admin.shippingOrderProfiles.workbench.leaveConfirm')" confirm-tone="primary" @update:model-value="(visible: boolean) => { if (!visible) resolveLeave(false); }" @confirm="() => resolveLeave(true)" @cancel="() => resolveLeave(false)" />
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
+242
-168
@@ -1,16 +1,34 @@
|
||||
<!--
|
||||
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。
|
||||
依赖:AdminListPage、useElementProvider、element-plus、Profile family API、统一 binding 迁移 scan/dry-run API、Vue Router、Vue I18n。
|
||||
逻辑:列表骨架用 AdminListPage;只选择下一步路由;展示统一 binding 迁移状态与待补框筛选;支持批量 Dry Run。删除草稿用 Element 确认框。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Plus } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElMessageBox,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
ElText,
|
||||
} 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 { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import {
|
||||
cloneOrderDocumentProfile,
|
||||
deleteOrderDocumentProfile,
|
||||
@@ -19,21 +37,37 @@ import {
|
||||
} from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import type { OrderProfileVersionFamilySummary } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const router = useRouter();
|
||||
const message = useMessage();
|
||||
const loading = ref(false);
|
||||
const batchDryRunLoading = ref(false);
|
||||
const query = ref('');
|
||||
const migrationFilter = ref<'all' | 'needs_migration' | 'pending_visual'>('all');
|
||||
const migrationFilter = ref<'' | 'needs_migration' | 'pending_visual'>('');
|
||||
const families = ref<OrderProfileVersionFamilySummary[]>([]);
|
||||
const deletingDraft = ref<OrderProfileVersionFamilySummary | null>(null);
|
||||
const deleteConfirmOpen = computed({
|
||||
get: () => deletingDraft.value !== null,
|
||||
set: (visible: boolean) => {
|
||||
if (!visible) deletingDraft.value = null;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 统一迁移状态对应的标签颜色。
|
||||
* @param status - 服务端返回的 unified_binding_status
|
||||
*/
|
||||
function unifiedTagType(status: string): 'warning' | 'danger' | 'success' | 'info' {
|
||||
if (status === 'needs_migration') return 'warning';
|
||||
if (status === 'pending_visual') return 'danger';
|
||||
if (status === 'ready') return 'success';
|
||||
return 'info';
|
||||
}
|
||||
|
||||
/**
|
||||
* 迁移筛选。清空写回空字符串,表示全部模板族。
|
||||
* @param value - 选中的筛选值;清空为 undefined
|
||||
*/
|
||||
function onMigrationFilterChange(value: string | undefined): void {
|
||||
migrationFilter.value = value === 'needs_migration' || value === 'pending_visual' ? value : '';
|
||||
}
|
||||
|
||||
const filteredFamilies = computed(() => {
|
||||
const keyword = query.value.trim().toLowerCase();
|
||||
@@ -96,9 +130,24 @@ async function createNewVersion(item: OrderProfileVersionFamilySummary): Promise
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开系统内确认框,避免浏览器原生弹窗中断管理员的模板管理流程。 */
|
||||
function requestDeleteDraft(item: OrderProfileVersionFamilySummary): void {
|
||||
if (item.draft_profile_id) deletingDraft.value = item;
|
||||
/**
|
||||
* 删除草稿前弹出 Element 确认框,取消则不请求。
|
||||
* 核心逻辑:标题和按钮用通用删除文案,正文用模板草稿已有确认句。MessageBox 取消时 reject,这里直接返回。
|
||||
* @param item - 当前模板族
|
||||
*/
|
||||
async function requestDeleteDraft(item: OrderProfileVersionFamilySummary): Promise<void> {
|
||||
if (!item.draft_profile_id) return;
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.shippingOrderProfiles.deleteConfirm'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
deletingDraft.value = item;
|
||||
await confirmDeleteDraft();
|
||||
}
|
||||
|
||||
/** 删除已确认的草稿;服务端仍拒绝删除已发布或退役的历史版本。 */
|
||||
@@ -176,165 +225,190 @@ onMounted(loadFamilies);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="mx-auto max-w-7xl space-y-6 p-6">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderProfiles.library.title') }}</h1>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.shippingOrderProfiles.library.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderProfiles.library.subtitle') }}</p>
|
||||
</div>
|
||||
<button class="btn-primary" type="button" @click="router.push({ name: 'AdminShippingOrderDocumentProfileCreate' })">
|
||||
{{ t('admin.shippingOrderProfiles.library.create') }}
|
||||
</button>
|
||||
</header>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton type="primary" :icon="Plus" @click="router.push({ name: 'AdminShippingOrderDocumentProfileCreate' })">
|
||||
{{ t('admin.shippingOrderProfiles.library.create') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElInput
|
||||
v-model="query"
|
||||
clearable
|
||||
class="library-search"
|
||||
:placeholder="t('admin.shippingOrderProfiles.library.search')"
|
||||
/>
|
||||
<ElSelect
|
||||
:model-value="migrationFilter || undefined"
|
||||
class="library-filter"
|
||||
clearable
|
||||
data-testid="order-profile-unified-migration-filter"
|
||||
:placeholder="t('admin.shippingOrderProfiles.unifiedMigration.filterAll')"
|
||||
@update:model-value="onMigrationFilterChange"
|
||||
>
|
||||
<ElOption
|
||||
value="needs_migration"
|
||||
:label="t('admin.shippingOrderProfiles.unifiedMigration.filterNeedsMigration')"
|
||||
/>
|
||||
<ElOption
|
||||
value="pending_visual"
|
||||
:label="t('admin.shippingOrderProfiles.unifiedMigration.filterPendingVisual')"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElButton
|
||||
data-testid="order-profile-unified-migration-batch-dry-run"
|
||||
:loading="batchDryRunLoading"
|
||||
:disabled="migrationTotals.needsMigration === 0"
|
||||
@click="runBatchUnifiedMigrationDryRun"
|
||||
>
|
||||
{{
|
||||
batchDryRunLoading
|
||||
? t('admin.shippingOrderProfiles.unifiedMigration.batchDryRunRunning')
|
||||
: t('admin.shippingOrderProfiles.unifiedMigration.batchDryRun', { count: migrationTotals.needsMigration })
|
||||
}}
|
||||
</ElButton>
|
||||
<span v-if="families.length" class="library-summary" data-testid="order-profile-unified-migration-summary">
|
||||
{{
|
||||
t('admin.shippingOrderProfiles.unifiedMigration.librarySummary', {
|
||||
total: migrationTotals.total,
|
||||
needs: migrationTotals.needsMigration,
|
||||
pending: migrationTotals.pendingVisual,
|
||||
})
|
||||
}}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<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"
|
||||
data-testid="order-profile-unified-migration-batch-dry-run"
|
||||
:disabled="batchDryRunLoading || migrationTotals.needsMigration === 0"
|
||||
@click="runBatchUnifiedMigrationDryRun"
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="hx-admin-table"
|
||||
:data="filteredFamilies"
|
||||
row-key="profile_code"
|
||||
:empty-text="t('admin.shippingOrderProfiles.library.empty')"
|
||||
>
|
||||
{{
|
||||
batchDryRunLoading
|
||||
? t('admin.shippingOrderProfiles.unifiedMigration.batchDryRunRunning')
|
||||
: t('admin.shippingOrderProfiles.unifiedMigration.batchDryRun', { count: migrationTotals.needsMigration })
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p v-if="families.length" class="migration-summary" data-testid="order-profile-unified-migration-summary">
|
||||
{{
|
||||
t('admin.shippingOrderProfiles.unifiedMigration.librarySummary', {
|
||||
total: migrationTotals.total,
|
||||
needs: migrationTotals.needsMigration,
|
||||
pending: migrationTotals.pendingVisual,
|
||||
})
|
||||
}}
|
||||
</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>
|
||||
</section>
|
||||
<DeleteConfirmDialog
|
||||
v-model="deleteConfirmOpen"
|
||||
:message="t('admin.shippingOrderProfiles.deleteConfirm')"
|
||||
@confirm="confirmDeleteDraft"
|
||||
/>
|
||||
</section>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.name')" min-width="180">
|
||||
<template #default="{ row }">{{ (row as OrderProfileVersionFamilySummary).display_name }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.code')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<code>{{ (row as OrderProfileVersionFamilySummary).profile_code }}</code>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.library.status')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<ElTag
|
||||
effect="light"
|
||||
:type="(row as OrderProfileVersionFamilySummary).draft_profile_id
|
||||
? 'primary'
|
||||
: (row as OrderProfileVersionFamilySummary).published_profile_id
|
||||
? 'success'
|
||||
: 'info'"
|
||||
>
|
||||
{{
|
||||
(row as OrderProfileVersionFamilySummary).draft_profile_id
|
||||
? t('admin.shippingOrderProfiles.library.draft')
|
||||
: (row as OrderProfileVersionFamilySummary).published_profile_id
|
||||
? t('admin.shippingOrderProfiles.library.published', { version: (row as OrderProfileVersionFamilySummary).published_version })
|
||||
: t('admin.shippingOrderProfiles.library.retired')
|
||||
}}
|
||||
</ElTag>
|
||||
<ElText
|
||||
v-if="(row as OrderProfileVersionFamilySummary).published_profile_id && (row as OrderProfileVersionFamilySummary).current_schema_version"
|
||||
tag="div"
|
||||
:type="schemaMigrationRequired(row as OrderProfileVersionFamilySummary) ? 'warning' : 'info'"
|
||||
>
|
||||
{{
|
||||
schemaMigrationRequired(row as OrderProfileVersionFamilySummary)
|
||||
? t('admin.shippingOrderProfiles.schemaMigration.versionMismatch', {
|
||||
bound: (row as OrderProfileVersionFamilySummary).published_schema_version,
|
||||
current: (row as OrderProfileVersionFamilySummary).current_schema_version,
|
||||
})
|
||||
: t('admin.shippingOrderProfiles.schemaMigration.versionMatched', {
|
||||
version: (row as OrderProfileVersionFamilySummary).current_schema_version,
|
||||
})
|
||||
}}
|
||||
</ElText>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.unifiedMigration.columnTitle')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<ElTag
|
||||
v-if="(row as OrderProfileVersionFamilySummary).unified_binding_status"
|
||||
effect="light"
|
||||
:type="unifiedTagType((row as OrderProfileVersionFamilySummary).unified_binding_status || '')"
|
||||
data-testid="order-profile-unified-migration-status"
|
||||
>
|
||||
{{ t(`admin.shippingOrderProfiles.unifiedMigration.status.${(row as OrderProfileVersionFamilySummary).unified_binding_status}`) }}
|
||||
</ElTag>
|
||||
<ElText
|
||||
v-if="((row as OrderProfileVersionFamilySummary).unified_pending_visual_count ?? 0) > 0"
|
||||
tag="div"
|
||||
type="warning"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.unifiedMigration.pendingVisualShort', { count: (row as OrderProfileVersionFamilySummary).unified_pending_visual_count }) }}
|
||||
</ElText>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.library.actions')" width="360" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton
|
||||
v-if="(row as OrderProfileVersionFamilySummary).draft_profile_id"
|
||||
link
|
||||
type="primary"
|
||||
@click="continueEditing(row as OrderProfileVersionFamilySummary)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="(row as OrderProfileVersionFamilySummary).draft_profile_id"
|
||||
link
|
||||
type="danger"
|
||||
@click="requestDeleteDraft(row as OrderProfileVersionFamilySummary)"
|
||||
>
|
||||
{{ t('admin.delete') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-else-if="(row as OrderProfileVersionFamilySummary).published_profile_id && !schemaMigrationRequired(row as OrderProfileVersionFamilySummary)"
|
||||
link
|
||||
type="primary"
|
||||
@click="createNewVersion(row as OrderProfileVersionFamilySummary)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.newVersion') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!(row as OrderProfileVersionFamilySummary).draft_profile_id && (row as OrderProfileVersionFamilySummary).published_profile_id && schemaMigrationRequired(row as OrderProfileVersionFamilySummary)"
|
||||
link
|
||||
type="primary"
|
||||
@click="openSchemaMigration(row as OrderProfileVersionFamilySummary)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.schemaMigration.listAction') }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" @click="viewVersion(row as OrderProfileVersionFamilySummary)">
|
||||
{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="(row as OrderProfileVersionFamilySummary).unified_binding_status === 'needs_migration' || (row as OrderProfileVersionFamilySummary).unified_needs_migration"
|
||||
link
|
||||
type="primary"
|
||||
data-testid="order-profile-unified-migration-open"
|
||||
@click="openUnifiedMigration(row as OrderProfileVersionFamilySummary)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.unifiedMigration.open') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</AdminListPage>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.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; }
|
||||
.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; }
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.page-header { flex-direction: column; }
|
||||
.btn-primary { width: 100%; }
|
||||
.toolbar-input { min-width: 0; }
|
||||
}
|
||||
.library-search { width: 16rem; }
|
||||
.library-filter { width: 11rem; }
|
||||
.library-summary { margin-left: auto; color: var(--el-text-color-secondary); }
|
||||
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
|
||||
</style>
|
||||
+24
-16
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfilePublishCheckPage.vue
|
||||
用途:展示版面签名、跨模板唯一性与发布阻断项,并在门禁通过后发布模板。
|
||||
依赖:发布检查 API、验证运行 API、Vue Router 和统一消息提示。
|
||||
依赖:element-plus、发布检查 API、验证运行 API、Vue Router 和统一消息提示。
|
||||
逻辑:自动选择当前样本试读通过运行;服务端生成签名/重叠验证;阻断项不可绕过,语义差异须逐项确认;
|
||||
XFA path 覆盖不全时展示 missing_fields 的 scope.field_code,避免同名 header/line 误判。
|
||||
-->
|
||||
@@ -9,6 +9,11 @@
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElCheckbox, ElCheckboxGroup, ElConfigProvider } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -28,6 +33,7 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const message = useMessage();
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const profileId = Number(route.params.profileId);
|
||||
const runs = ref<OrderProfileValidationRun[]>([]);
|
||||
const report = ref<OrderProfilePublishCheckReport | null>(null);
|
||||
@@ -239,30 +245,31 @@ onMounted(loadRuns);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="page">
|
||||
<header>
|
||||
<div>
|
||||
<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>
|
||||
<ElButton @click="backToValidation">{{ t('admin.orderProfilePublishCheck.back') }}</ElButton>
|
||||
</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">
|
||||
<ElButton type="primary" :disabled="busy || !validationRun" :loading="busy" @click="createReport">
|
||||
{{ t('admin.orderProfilePublishCheck.create') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</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">
|
||||
<ElButton :disabled="busy || !validationRun" :loading="busy" @click="createReport">
|
||||
{{ t('admin.orderProfilePublishCheck.rerun') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<p :class="['gate-status', gateStatus]">{{ gateStatus === 'blocked' ? t('admin.orderProfilePublishCheck.blockedHint') : t('admin.orderProfilePublishCheck.reviewHint') }}</p>
|
||||
</section>
|
||||
@@ -304,7 +311,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>
|
||||
<ElButton @click="backToEditor">{{ t('admin.orderProfilePublishCheck.backToEditor') }}</ElButton>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@@ -316,17 +323,19 @@ 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>
|
||||
<ElCheckboxGroup v-model="confirmed" class="warning-checks">
|
||||
<ElCheckbox v-for="item in report.warning_items" :key="String(item.key)" :value="String(item.key)">
|
||||
{{ itemMessage(item) }}
|
||||
</ElCheckbox>
|
||||
</ElCheckboxGroup>
|
||||
<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">
|
||||
<ElButton type="primary" :disabled="busy || !publishable" :loading="busy" @click="publish">
|
||||
{{ t('admin.orderProfilePublishCheck.confirm') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</section>
|
||||
</template>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -339,9 +348,8 @@ onMounted(loadRuns);
|
||||
.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; }
|
||||
.warning-checks { display: grid; gap: 8px; margin: 10px 0; }
|
||||
.card .el-button { margin-top: 14px; }
|
||||
.good { color: #15803d; font-size: 13px; }
|
||||
.gate-status { font-weight: 600; }
|
||||
.gate-status.blocked { color: #b91c1c; }
|
||||
|
||||
+13
-5
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileValidationPage.vue
|
||||
用途:验证当前订单模板草稿,并按“基础验证、盲测、发布检查”顺序引导管理员。
|
||||
依赖:Profile 验证 API、编辑租约、Vue Router、统一消息提示。
|
||||
依赖:element-plus、Profile 验证 API、编辑租约、Vue Router、统一消息提示。
|
||||
逻辑:一次动作依次执行结构检查和当前样本试读;XFA 从验证摘要展示完整字段级结果;
|
||||
盲测批准前不解锁发布检查入口。
|
||||
-->
|
||||
@@ -9,6 +9,11 @@
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElConfigProvider } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -34,6 +39,7 @@ import type {
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t, te } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const message = useMessage();
|
||||
const profileId = Number(route.params.profileId);
|
||||
const runs = ref<OrderProfileValidationRun[]>([]);
|
||||
@@ -268,24 +274,25 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="validation-page">
|
||||
<header>
|
||||
<div>
|
||||
<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>
|
||||
<ElButton @click="backToEditor">{{ t('admin.orderProfileValidation.backToEditor') }}</ElButton>
|
||||
</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>
|
||||
<ElButton v-if="canStartBlindTest" type="primary" :disabled="!canPublish" @click="goToPublishCheck">{{ t('admin.orderProfileValidation.goPublishCheck') }}</ElButton>
|
||||
</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>
|
||||
<ElButton type="primary" :loading="executing" @click="validateCurrentDraft">{{ executing ? t('admin.orderProfileValidation.validating') : t('admin.orderProfileValidation.validateCurrent') }}</ElButton>
|
||||
</header>
|
||||
<p v-if="loading">{{ t('admin.orderProfileValidation.loading') }}</p>
|
||||
<div v-else class="checks" :aria-label="t('admin.orderProfileValidation.currentDraft')">
|
||||
@@ -302,7 +309,7 @@ onMounted(async () => {
|
||||
|
||||
<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"><strong :class="`status ${blindTestSuite?.status || 'pending'}`">{{ t(`admin.shippingOrderProfiles.blindTest.status.${blindTestSuite?.status || 'missing'}`) }}</strong><ElButton @click="goToBlindTest">{{ t('admin.shippingOrderProfiles.blindTest.title') }}</ElButton></div>
|
||||
</section>
|
||||
|
||||
<section v-if="profile && sample" class="results" :aria-label="t('admin.orderProfileValidation.resultsTitle')">
|
||||
@@ -373,6 +380,7 @@ onMounted(async () => {
|
||||
<p v-else class="result-error">{{ t('admin.orderProfileValidation.resultsFailed') }}</p>
|
||||
</section>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
+111
-168
@@ -1,15 +1,21 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileVersionDetailPage.vue
|
||||
用途:订单模板版本中心详情页,支持刷新恢复与分享。
|
||||
依赖:版本详情 composable、配置概览组件、版本中心 API、统一迁移 API。
|
||||
依赖:element-plus、版本详情 composable、配置概览组件、版本中心 API、统一迁移 API。
|
||||
逻辑:当前已接入配置概览、只读样本画布、服务端语义 diff、审计时间线与实际使用;
|
||||
Schema 迁移弹窗按模态语义提供初始焦点、Tab 陷阱、Escape 关闭与焦点恢复;
|
||||
Schema 迁移使用 ElDialog,焦点由 Element 接管;
|
||||
统一 binding 迁移提供 Dry Run 状态徽章入口。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
import { computed, onMounted, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ElButton, ElConfigProvider, ElDialog, ElForm, ElFormItem, ElOption, ElSelect } from "element-plus";
|
||||
import "element-plus/dist/index.css";
|
||||
import "element-plus/theme-chalk/dark/css-vars.css";
|
||||
import "@/features/admin/styles/element-trial.css";
|
||||
import { useElementProvider } from "@/features/admin/composables/useElementProvider";
|
||||
import AdminListTabs from "@/features/admin/components/AdminListTabs.vue";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { useMessage } from "@/shared/composables/useMessage";
|
||||
import {
|
||||
@@ -31,6 +37,7 @@ import {
|
||||
} from "./composables/useOrderProfileVersionDetail";
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const message = useMessage();
|
||||
@@ -46,18 +53,6 @@ const unifiedMigrationReport = ref<{
|
||||
const migrationOpen = ref(false);
|
||||
const publishedSchema = ref<ShippingOrderSchemaVersion | null>(null);
|
||||
const migrationResolutions = ref<Record<string, { action: "unbind" } | { replacement_field_id: string }>>({});
|
||||
const migrationPanelRef = ref<HTMLElement | null>(null);
|
||||
const migrationCancelRef = ref<HTMLButtonElement | null>(null);
|
||||
let previouslyFocused: HTMLElement | null = null;
|
||||
|
||||
const FOCUSABLE_SELECTOR = [
|
||||
"a[href]",
|
||||
"button:not([disabled])",
|
||||
"textarea:not([disabled])",
|
||||
"input:not([disabled])",
|
||||
"select:not([disabled])",
|
||||
'[tabindex]:not([tabindex="-1"])',
|
||||
].join(",");
|
||||
|
||||
const {
|
||||
activeTab,
|
||||
@@ -86,51 +81,31 @@ const loadPublishedSchema = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 收集迁移弹窗内可聚焦控件。 */
|
||||
function migrationFocusableNodes(): HTMLElement[] {
|
||||
if (!migrationPanelRef.value) return [];
|
||||
return Array.from(migrationPanelRef.value.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR))
|
||||
.filter((node) => !node.hasAttribute("disabled") && node.getAttribute("aria-hidden") !== "true");
|
||||
}
|
||||
|
||||
/** 关闭 Schema 迁移弹窗。 */
|
||||
/** 关闭 Schema 迁移弹窗。迁移进行中保持打开,避免中途丢掉决议。 */
|
||||
function closeSchemaMigration(): void {
|
||||
if (migrating.value) return;
|
||||
migrationOpen.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape 关闭;Tab 在弹窗内循环,阻止焦点逃逸到背景页。
|
||||
* 同步 ElDialog 显隐。关闭时走同一条迁移中保护。
|
||||
* @param visible - 弹窗是否仍打开
|
||||
*/
|
||||
function onMigrationKeydown(event: KeyboardEvent): void {
|
||||
if (!migrationOpen.value) return;
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
closeSchemaMigration();
|
||||
function onMigrationVisible(visible: boolean): void {
|
||||
if (visible) {
|
||||
migrationOpen.value = true;
|
||||
return;
|
||||
}
|
||||
if (event.key !== "Tab") return;
|
||||
const nodes = migrationFocusableNodes();
|
||||
const first = nodes[0];
|
||||
const last = nodes[nodes.length - 1];
|
||||
if (!first || !last) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
const active = document.activeElement as HTMLElement | null;
|
||||
const inside = Boolean(active && migrationPanelRef.value?.contains(active));
|
||||
if (event.shiftKey) {
|
||||
if (!inside || active === first) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!inside || active === last) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
closeSchemaMigration();
|
||||
}
|
||||
|
||||
/**
|
||||
* 写回破坏性变更的替换字段。清空表示解除绑定。
|
||||
* @param fieldId - 原字段 id
|
||||
* @param replacementId - 替换字段 id;清空为 undefined
|
||||
*/
|
||||
function onMigrationFieldChange(fieldId: string, replacementId: string | undefined): void {
|
||||
setMigrationResolution(fieldId, replacementId || "");
|
||||
}
|
||||
|
||||
const openSchemaMigration = () => {
|
||||
@@ -196,35 +171,6 @@ const migrateSchema = async () => {
|
||||
|
||||
onMounted(() => { void loadPublishedSchema(); });
|
||||
|
||||
watch(
|
||||
() => migrationOpen.value,
|
||||
async (open, wasOpen) => {
|
||||
if (typeof document === "undefined") return;
|
||||
if (open && !wasOpen) {
|
||||
previouslyFocused = document.activeElement instanceof HTMLElement
|
||||
? document.activeElement
|
||||
: null;
|
||||
document.addEventListener("keydown", onMigrationKeydown, true);
|
||||
await nextTick();
|
||||
(migrationCancelRef.value || migrationFocusableNodes()[0])?.focus();
|
||||
return;
|
||||
}
|
||||
if (!open && wasOpen) {
|
||||
document.removeEventListener("keydown", onMigrationKeydown, true);
|
||||
const restoreTarget = previouslyFocused;
|
||||
previouslyFocused = null;
|
||||
await nextTick();
|
||||
restoreTarget?.focus?.();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (typeof document !== "undefined") {
|
||||
document.removeEventListener("keydown", onMigrationKeydown, true);
|
||||
}
|
||||
});
|
||||
|
||||
watch([detail, publishedSchema, () => route.query.migrate], () => {
|
||||
if (route.query.migrate !== "1" || !canMigrateSchema.value || migrationOpen.value) return;
|
||||
openSchemaMigration();
|
||||
@@ -249,6 +195,20 @@ const pageTitle = computed(() => {
|
||||
const statusKey = (status: "draft" | "published" | "retired") =>
|
||||
status === "draft" ? "currentDraft" : status === "published" ? "currentPublished" : "retired";
|
||||
|
||||
const adminTabs = computed(() => tabOptions.value.map((tab) => ({
|
||||
name: tab.key,
|
||||
label: t(`admin.shippingOrderProfiles.versionCenter.tabs.${tab.key}`),
|
||||
badge: tab.count ?? undefined,
|
||||
})));
|
||||
|
||||
/**
|
||||
* 把页签写回路由 query。页签内容由页面自己渲染,AdminListTabs 只负责切换。
|
||||
* @param name - 页签名
|
||||
*/
|
||||
function onDetailTabChange(name: string): void {
|
||||
openTab(name as OrderProfileVersionDetailTab);
|
||||
}
|
||||
|
||||
const openTab = (tab: OrderProfileVersionDetailTab) => {
|
||||
void router.replace({
|
||||
query: {
|
||||
@@ -360,6 +320,7 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section class="version-detail-page">
|
||||
<header class="page-header">
|
||||
<div class="header-main">
|
||||
@@ -369,22 +330,20 @@ watch(
|
||||
<p class="header-meta">{{ pageTitle }}</p>
|
||||
</div>
|
||||
<div class="header-actions" v-if="detail">
|
||||
<button type="button" class="btn-secondary" @click="goBackToWorkbench">
|
||||
<ElButton @click="goBackToWorkbench">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.backToWorkbench") }}
|
||||
</button>
|
||||
<button
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="detail.status === 'draft'"
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
type="primary"
|
||||
@click="continueEditing"
|
||||
>
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.continueEditing") }}
|
||||
</button>
|
||||
<button
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-else
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="cloning"
|
||||
type="primary"
|
||||
:loading="cloning"
|
||||
@click="createNewVersion"
|
||||
>
|
||||
{{
|
||||
@@ -392,20 +351,17 @@ watch(
|
||||
? t("admin.shippingOrderProfiles.saving")
|
||||
: t("admin.shippingOrderProfiles.newVersion")
|
||||
}}
|
||||
</button>
|
||||
<button
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="canMigrateSchema"
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
type="primary"
|
||||
@click="openSchemaMigration"
|
||||
>
|
||||
{{ t("admin.shippingOrderProfiles.schemaMigration.action", { version: publishedSchema?.version }) }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost"
|
||||
</ElButton>
|
||||
<ElButton
|
||||
data-testid="order-profile-unified-migration-dry-run"
|
||||
:disabled="unifiedMigrating"
|
||||
:loading="unifiedMigrating"
|
||||
@click="runUnifiedMigrationDryRun"
|
||||
>
|
||||
{{
|
||||
@@ -413,7 +369,7 @@ watch(
|
||||
? t("admin.shippingOrderProfiles.unifiedMigration.running")
|
||||
: t("admin.shippingOrderProfiles.unifiedMigration.dryRun")
|
||||
}}
|
||||
</button>
|
||||
</ElButton>
|
||||
<span
|
||||
v-if="unifiedMigrationReport"
|
||||
class="unified-migration-badge"
|
||||
@@ -437,19 +393,11 @@ watch(
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
<template v-else-if="detail">
|
||||
<nav class="tab-nav" :aria-label="t('admin.shippingOrderProfiles.versionCenter.tabsLabel')">
|
||||
<button
|
||||
v-for="tab in tabOptions"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
class="tab-button"
|
||||
:class="{ active: activeTab === tab.key }"
|
||||
@click="openTab(tab.key)"
|
||||
>
|
||||
<span>{{ t(`admin.shippingOrderProfiles.versionCenter.tabs.${tab.key}`) }}</span>
|
||||
<small v-if="tab.count !== undefined && tab.count !== null">{{ tab.count }}</small>
|
||||
</button>
|
||||
</nav>
|
||||
<AdminListTabs
|
||||
:model-value="activeTab"
|
||||
:items="adminTabs"
|
||||
@update:model-value="onDetailTabChange"
|
||||
/>
|
||||
|
||||
<section class="version-switcher" :aria-label="t('admin.shippingOrderProfiles.versionCenter.familyVersions')">
|
||||
<div class="version-switcher__label">
|
||||
@@ -457,17 +405,16 @@ watch(
|
||||
<small>{{ detail.profile_code }}</small>
|
||||
</div>
|
||||
<div class="version-switcher__list">
|
||||
<button
|
||||
<ElButton
|
||||
v-for="item in versions"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="version-item"
|
||||
:class="{ active: item.id === detail.id }"
|
||||
@click="openVersion(item.profile_code, item.version)"
|
||||
>
|
||||
<strong>v{{ item.version }}</strong>
|
||||
<span>{{ t(`admin.shippingOrderProfiles.versionCenter.status.${statusKey(item.status)}`) }}</span>
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -482,61 +429,57 @@ watch(
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
v-if="migrationOpen"
|
||||
class="migration-backdrop"
|
||||
role="presentation"
|
||||
data-testid="order-profile-schema-migration-backdrop"
|
||||
@click.self="closeSchemaMigration"
|
||||
<ElDialog
|
||||
:model-value="migrationOpen"
|
||||
:title="t('admin.shippingOrderProfiles.schemaMigration.title')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
data-testid="order-profile-schema-migration-dialog"
|
||||
@update:model-value="onMigrationVisible"
|
||||
>
|
||||
<section
|
||||
ref="migrationPanelRef"
|
||||
class="migration-dialog"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="t('admin.shippingOrderProfiles.schemaMigration.title')"
|
||||
data-testid="order-profile-schema-migration-dialog"
|
||||
>
|
||||
<h2>{{ t("admin.shippingOrderProfiles.schemaMigration.title") }}</h2>
|
||||
<p>{{ t("admin.shippingOrderProfiles.schemaMigration.description", { from: detail?.schema_version, to: publishedSchema?.version }) }}</p>
|
||||
<p class="migration-note">{{ t("admin.shippingOrderProfiles.schemaMigration.revalidation") }}</p>
|
||||
<div v-if="breakingChanges.length" class="migration-changes">
|
||||
<article v-for="change in breakingChanges" :key="change.field_id">
|
||||
<strong>{{ change.before || change.field_id }}</strong>
|
||||
<span>{{ t("admin.shippingOrderProfiles.schemaMigration.reason", { reason: change.reason }) }}</span>
|
||||
<label>
|
||||
{{ t("admin.shippingOrderProfiles.schemaMigration.resolution") }}
|
||||
<select
|
||||
:value="migrationReplacementId(change.field_id)"
|
||||
@change="setMigrationResolution(change.field_id, ($event.target as HTMLSelectElement).value)"
|
||||
<p>{{ t("admin.shippingOrderProfiles.schemaMigration.description", { from: detail?.schema_version, to: publishedSchema?.version }) }}</p>
|
||||
<p class="migration-note">{{ t("admin.shippingOrderProfiles.schemaMigration.revalidation") }}</p>
|
||||
<div v-if="breakingChanges.length" class="migration-changes">
|
||||
<article v-for="change in breakingChanges" :key="change.field_id">
|
||||
<strong>{{ change.before || change.field_id }}</strong>
|
||||
<span>{{ t("admin.shippingOrderProfiles.schemaMigration.reason", { reason: change.reason }) }}</span>
|
||||
<ElForm label-position="top">
|
||||
<ElFormItem :label="t('admin.shippingOrderProfiles.schemaMigration.resolution')">
|
||||
<ElSelect
|
||||
:model-value="migrationReplacementId(change.field_id) || undefined"
|
||||
:placeholder="t('admin.shippingOrderProfiles.schemaMigration.unbind')"
|
||||
clearable
|
||||
@update:model-value="onMigrationFieldChange(change.field_id, $event)"
|
||||
>
|
||||
<option value="">{{ t("admin.shippingOrderProfiles.schemaMigration.unbind") }}</option>
|
||||
<option v-for="candidate in change.replacement_candidates || []" :key="candidate.field_id" :value="candidate.field_id">
|
||||
{{ candidate.display_name || candidate.field_code || candidate.field_id }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</article>
|
||||
</div>
|
||||
<p v-else class="migration-note">{{ t("admin.shippingOrderProfiles.schemaMigration.noBreakingChanges") }}</p>
|
||||
<footer>
|
||||
<button
|
||||
ref="migrationCancelRef"
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
:disabled="migrating"
|
||||
data-testid="order-profile-schema-migration-cancel"
|
||||
@click="closeSchemaMigration"
|
||||
>
|
||||
{{ t("admin.shippingOrderProfiles.schemaMigration.cancel") }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary" :disabled="migrating" @click="migrateSchema">
|
||||
{{ migrating ? t("admin.shippingOrderProfiles.saving") : t("admin.shippingOrderProfiles.schemaMigration.confirm") }}
|
||||
</button>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
<ElOption
|
||||
v-for="candidate in change.replacement_candidates || []"
|
||||
:key="candidate.field_id"
|
||||
:label="candidate.display_name || candidate.field_code || candidate.field_id"
|
||||
:value="candidate.field_id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
</article>
|
||||
</div>
|
||||
<p v-else class="migration-note">{{ t("admin.shippingOrderProfiles.schemaMigration.noBreakingChanges") }}</p>
|
||||
<template #footer>
|
||||
<ElButton
|
||||
:disabled="migrating"
|
||||
data-testid="order-profile-schema-migration-cancel"
|
||||
@click="closeSchemaMigration"
|
||||
>
|
||||
{{ t("admin.shippingOrderProfiles.schemaMigration.cancel") }}
|
||||
</ElButton>
|
||||
<ElButton type="primary" :loading="migrating" @click="migrateSchema">
|
||||
{{ migrating ? t("admin.shippingOrderProfiles.saving") : t("admin.shippingOrderProfiles.schemaMigration.confirm") }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
+19
-17
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileAuditTimeline.vue
|
||||
用途:展示订单模板版本中心的治理审计时间线(含 XFA operation_id / checksum)。
|
||||
依赖:版本中心审计 API、版本详情 DTO、Vue I18n。
|
||||
依赖:element-plus、版本中心审计 API、版本详情 DTO、Vue I18n。
|
||||
逻辑:使用 before_id 游标分页避免新增事件导致翻页重复;只展示安全 detail 摘要,
|
||||
以及 XFA 变更前后 definition checksum 与 operation_id;不展示 PDF、正文或盲测真值;
|
||||
对视觉绑定 / 拆分 / 统一迁移事件渲染分组标签与 visual before/after 摘要。
|
||||
@@ -9,6 +9,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { ElButton, ElInput, ElLoading } from "element-plus";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { listOrderDocumentProfileAuditEvents } from "@/features/admin/api/shipping-order-document-profile.api";
|
||||
import type {
|
||||
@@ -19,6 +20,7 @@ import type {
|
||||
const props = defineProps<{ detail: ShippingOrderDocumentProfile }>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const vLoading = ElLoading.directive;
|
||||
const loading = ref(false);
|
||||
const errorMessage = ref("");
|
||||
const page = ref<OrderProfileAuditEventPage | null>(null);
|
||||
@@ -138,42 +140,42 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="timeline-panel">
|
||||
<section v-loading="loading" class="timeline-panel">
|
||||
<div class="toolbar">
|
||||
<div>
|
||||
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.audit.title") }}</h3>
|
||||
<p>{{ t("admin.shippingOrderProfiles.versionCenter.audit.subtitle") }}</p>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading" @click="resetFilters">
|
||||
<ElButton :disabled="loading" @click="resetFilters">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.reset") }}
|
||||
</button>
|
||||
<button type="button" class="btn-primary btn-sm" :disabled="loading" @click="applyFilters">
|
||||
</ElButton>
|
||||
<ElButton type="primary" :loading="loading" @click="applyFilters">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.apply") }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="filters">
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.eventType") }}</span>
|
||||
<input v-model="filters.eventType" class="input-field" type="text" />
|
||||
<ElInput v-model="filters.eventType" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.actor") }}</span>
|
||||
<input v-model="filters.actor" class="input-field" type="text" />
|
||||
<ElInput v-model="filters.actor" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.requestId") }}</span>
|
||||
<input v-model="filters.requestIdFilter" class="input-field" type="text" />
|
||||
<ElInput v-model="filters.requestIdFilter" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.createdFrom") }}</span>
|
||||
<input v-model="filters.createdFrom" class="input-field" type="date" />
|
||||
<ElInput v-model="filters.createdFrom" type="date" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.createdTo") }}</span>
|
||||
<input v-model="filters.createdTo" class="input-field" type="date" />
|
||||
<ElInput v-model="filters.createdTo" type="date" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -182,9 +184,9 @@ watch(
|
||||
</div>
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
<ElButton @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<div v-else-if="!page?.items.length" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.empty") }}
|
||||
@@ -243,12 +245,12 @@ watch(
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
<ElButton :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.previous") }}
|
||||
</button>
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading || !hasNext" @click="loadNext">
|
||||
</ElButton>
|
||||
<ElButton :disabled="loading || !hasNext" @click="loadNext">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.next") }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
+74
-32
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileDocumentCanvas.vue
|
||||
用途:展示受控 PDF/XFA flatten 单页预览,并以相对坐标框支持选择、拖动和缩放区域。
|
||||
依赖:浏览器 fetch、认证请求头、OrderProfileCanvasRegion、isUnboundOrderFieldCanvasRegion。
|
||||
依赖:element-plus 工具栏控件、浏览器 fetch、认证请求头、OrderProfileCanvasRegion、isUnboundOrderFieldCanvasRegion。
|
||||
逻辑:父级签发单页令牌并提供分页动作;mode=readonly 时只允许查看/缩放/切页,不允许写入任何标注改动;
|
||||
PNG 预览 token 为一次性消费,组件内按页缓存 blob,翻页回访不再重新拉 token;
|
||||
原 PDF(pdf-preview)令牌亦为 Redis getdel 单次消费:同 token 字节必须缓存,且仅 HTTP 401/403/404
|
||||
@@ -17,7 +17,27 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Anchor, ArrowLeft, ArrowRight, Columns3, Copy, Eraser, MessageSquareText, Minus, Plus, Redo2, RotateCcw, Rows3, Save, TableProperties, Tag, TextCursorInput, Trash2, WandSparkles } from 'lucide-vue-next';
|
||||
import {
|
||||
Aim,
|
||||
ArrowLeft,
|
||||
ArrowRight,
|
||||
ChatLineSquare,
|
||||
CopyDocument,
|
||||
Crop,
|
||||
Delete,
|
||||
EditPen,
|
||||
Finished,
|
||||
Grid,
|
||||
MagicStick,
|
||||
Minus,
|
||||
Operation,
|
||||
Plus,
|
||||
PriceTag,
|
||||
RefreshLeft,
|
||||
RefreshRight,
|
||||
Tickets,
|
||||
} from '@element-plus/icons-vue';
|
||||
import { ElButton, ElInput } from 'element-plus';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { loadPdfJs } from '@/shared/utils/pdfjs';
|
||||
import type { OrderProfileCanvasRegion, OrderProfilePreviewPageGrant } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
@@ -418,6 +438,11 @@ const handleWheel = (event: WheelEvent) => {
|
||||
if (activeDrag || activePan || creationStart) return;
|
||||
adjustZoom(event.deltaY < 0 ? .1 : -.1);
|
||||
};
|
||||
/** 接收页码输入。ElInput 清空时按当前页回退,避免写出 NaN。 */
|
||||
function onPageInput(value: string | number): void {
|
||||
pageInput.value = Number(value);
|
||||
}
|
||||
|
||||
/** 校验页码输入并请求父工作台切页;超出范围时吸附到最近有效页。 */
|
||||
const goToPage = () => {
|
||||
const nextPage = Math.max(1, Math.min(props.pageCount || 1, Math.round(Number(pageInput.value) || props.pageNo)));
|
||||
@@ -504,53 +529,68 @@ onBeforeUnmount(() => {
|
||||
<header v-if="imageUrl || pdfRendered" class="canvas-toolbar">
|
||||
<div class="toolbar-actions">
|
||||
<template v-if="!readonlyMode">
|
||||
<button type="button" :disabled="undoDisabled" :title="t('admin.shippingOrderProfiles.workbench.undo')" @click="emit('undo')"><RotateCcw /></button>
|
||||
<button type="button" :disabled="redoDisabled" :title="t('admin.shippingOrderProfiles.workbench.redo')" @click="emit('redo')"><Redo2 /></button>
|
||||
<ElButton :disabled="undoDisabled" :title="t('admin.shippingOrderProfiles.workbench.undo')" :icon="RefreshLeft" @click="emit('undo')" />
|
||||
<ElButton :disabled="redoDisabled" :title="t('admin.shippingOrderProfiles.workbench.redo')" :icon="RefreshRight" @click="emit('redo')" />
|
||||
<span class="toolbar-divider" aria-hidden="true" />
|
||||
<button type="button" :disabled="duplicateDisabled" :title="t('admin.shippingOrderProfiles.workbench.duplicateRegionShortcut')" @click="emit('duplicate')"><Copy /></button>
|
||||
<button type="button" class="delete-action" :disabled="deleteDisabled" :title="t('admin.shippingOrderProfiles.workbench.deleteRegionShortcut')" @click="emit('delete')"><Trash2 /></button>
|
||||
<ElButton :disabled="duplicateDisabled" :title="t('admin.shippingOrderProfiles.workbench.duplicateRegionShortcut')" :icon="CopyDocument" @click="emit('duplicate')" />
|
||||
<ElButton class="delete-action" :disabled="deleteDisabled" :title="t('admin.shippingOrderProfiles.workbench.deleteRegionShortcut')" :icon="Delete" @click="emit('delete')" />
|
||||
<span class="toolbar-divider" aria-hidden="true" />
|
||||
<button type="button" class="save-action" :disabled="saveDisabled || saving" :title="t('admin.save')" @click="emit('save')"><Save /><span>{{ saving ? t('admin.shippingOrderProfiles.saving') : t('admin.save') }}</span></button>
|
||||
<template v-if="pendingSuggestionCount">
|
||||
<span class="toolbar-divider" aria-hidden="true" />
|
||||
<span class="suggestion-count">{{ pendingSuggestionCount }}</span>
|
||||
<span class="suggestion-preview-badge">{{ t('admin.shippingOrderProfiles.workbench.suggestionPreviewBadge') }}</span>
|
||||
</template>
|
||||
<ElButton class="save-action" :disabled="saveDisabled || saving" :title="t('admin.save')" :icon="Finished" @click="emit('save')">
|
||||
{{ saving ? t('admin.shippingOrderProfiles.saving') : t('admin.save') }}
|
||||
</ElButton>
|
||||
<template v-if="pendingSuggestionCount">
|
||||
<span class="toolbar-divider" aria-hidden="true" />
|
||||
<span class="suggestion-count">{{ pendingSuggestionCount }}</span>
|
||||
<span class="suggestion-preview-badge">{{ t('admin.shippingOrderProfiles.workbench.suggestionPreviewBadge') }}</span>
|
||||
</template>
|
||||
</template>
|
||||
<span v-else class="readonly-badge">{{ t('admin.shippingOrderProfiles.versionCenter.readonlyCanvasBadge') }}</span>
|
||||
</div>
|
||||
<div class="page-control">
|
||||
<button type="button" :disabled="pageNo <= 1" :title="t('admin.shippingOrderExtractionRuns.previous')" @click="emit('page', pageNo - 1)"><ArrowLeft /></button>
|
||||
<label><input v-model.number="pageInput" class="input-field" type="number" min="1" :max="pageCount" :aria-label="t('admin.shippingOrderProfiles.workbench.pageNavigation')" @change="goToPage" @keydown.enter.prevent="goToPage" /><span>/ {{ pageCount }}</span></label>
|
||||
<button type="button" :disabled="pageNo >= pageCount" :title="t('admin.shippingOrderExtractionRuns.next')" @click="emit('page', pageNo + 1)"><ArrowRight /></button>
|
||||
<ElButton :disabled="pageNo <= 1" :title="t('admin.shippingOrderExtractionRuns.previous')" :icon="ArrowLeft" @click="emit('page', pageNo - 1)" />
|
||||
<label>
|
||||
<ElInput
|
||||
class="page-input"
|
||||
:model-value="pageInput"
|
||||
type="number"
|
||||
:min="1"
|
||||
:max="pageCount"
|
||||
:aria-label="t('admin.shippingOrderProfiles.workbench.pageNavigation')"
|
||||
@update:model-value="onPageInput"
|
||||
@change="goToPage"
|
||||
@keydown.enter.prevent="goToPage"
|
||||
/>
|
||||
<span>/ {{ pageCount }}</span>
|
||||
</label>
|
||||
<ElButton :disabled="pageNo >= pageCount" :title="t('admin.shippingOrderExtractionRuns.next')" :icon="ArrowRight" @click="emit('page', pageNo + 1)" />
|
||||
</div>
|
||||
<div class="zoom-control">
|
||||
<button type="button" :disabled="zoom <= .5" :title="t('admin.shippingOrderProfiles.workbench.zoomOut')" @click="adjustZoom(-.25)"><Minus /></button>
|
||||
<ElButton :disabled="zoom <= .5" :title="t('admin.shippingOrderProfiles.workbench.zoomOut')" :icon="Minus" @click="adjustZoom(-.25)" />
|
||||
<output>{{ zoomPercent }}%</output>
|
||||
<button type="button" :disabled="zoom >= 4" :title="t('admin.shippingOrderProfiles.workbench.zoomIn')" @click="adjustZoom(.25)"><Plus /></button>
|
||||
<button type="button" class="fit-action" @click="resetZoom">{{ t('admin.shippingOrderProfiles.workbench.fitPage') }}</button>
|
||||
<ElButton :disabled="zoom >= 4" :title="t('admin.shippingOrderProfiles.workbench.zoomIn')" :icon="Plus" @click="adjustZoom(.25)" />
|
||||
<ElButton class="fit-action" @click="resetZoom">{{ t('admin.shippingOrderProfiles.workbench.fitPage') }}</ElButton>
|
||||
</div>
|
||||
</header>
|
||||
<div v-if="loading && !pdfPreview" class="canvas-state">{{ t('admin.shippingOrderProfiles.workbench.loadingPage') }}</div>
|
||||
<!-- PNG 路径仍可用整页错误态;原 PDF 路径必须保留 canvas 挂载,否则 renderPdfPage 必抛 canvas unavailable。 -->
|
||||
<div v-else-if="displayLoadError && !pdfPreview" class="canvas-state canvas-state--error" role="alert">
|
||||
<p>{{ displayLoadError }}</p>
|
||||
<button type="button" class="canvas-retry" @click="onRetryClick">
|
||||
<ElButton class="canvas-retry" @click="onRetryClick">
|
||||
{{ t('admin.shippingOrderProfiles.workbench.retryCanvas') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<div v-else-if="!imageUrl && !pdfRendered && !pdfPreview" class="canvas-state">{{ emptyStateText }}</div>
|
||||
<div v-else class="canvas-work-area" :class="{ readonly: readonlyMode }">
|
||||
<aside v-if="!readonlyMode" class="annotation-tools">
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :class="{ active: creationKind === 'document_anchor_label' || creationKind === 'document_anchor_value' }" @click="emit('draw', 'document_anchor_label')"><Anchor /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :class="{ active: creationKind === 'order_anchor' }" @click="emit('draw', 'order_anchor')"><Tag /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :class="{ active: creationKind === 'order_field' }" @click="emit('draw', 'order_field')"><TextCursorInput /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :class="{ active: creationKind === 'header_field' }" @click="emit('draw', 'header_field')"><TableProperties /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :class="{ active: creationKind === 'line' }" @click="emit('draw', 'line')"><Rows3 /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :class="{ active: creationKind === 'field' }" @click="emit('draw', 'field')"><Columns3 /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :class="{ active: creationKind === 'exclusion' }" @click="emit('draw', 'exclusion')"><Eraser /></button>
|
||||
<button type="button" :aria-label="t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut')" :class="{ active: creationKind === 'reservation_id_region' }" @click="emit('draw', 'reservation_id_region')"><MessageSquareText /></button>
|
||||
<button type="button" class="suggest" :aria-label="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :title="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :disabled="autoSuggestDisabled || suggesting" @click="emit('suggest')"><WandSparkles /></button>
|
||||
<ElButton :aria-label="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawDocumentMatchAnchorShortcut')" :class="{ active: creationKind === 'document_anchor_label' || creationKind === 'document_anchor_value' }" :icon="Aim" @click="emit('draw', 'document_anchor_label')" />
|
||||
<ElButton :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderAnchorShortcut')" :class="{ active: creationKind === 'order_anchor' }" :icon="PriceTag" @click="emit('draw', 'order_anchor')" />
|
||||
<ElButton :aria-label="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawOrderFieldShortcut')" :class="{ active: creationKind === 'order_field' }" :icon="EditPen" @click="emit('draw', 'order_field')" />
|
||||
<ElButton :aria-label="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawHeaderShortcut')" :class="{ active: creationKind === 'header_field' }" :icon="Grid" @click="emit('draw', 'header_field')" />
|
||||
<ElButton :aria-label="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawLineShortcut')" :class="{ active: creationKind === 'line' }" :icon="Operation" @click="emit('draw', 'line')" />
|
||||
<ElButton :aria-label="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawFieldShortcut')" :class="{ active: creationKind === 'field' }" :icon="Tickets" @click="emit('draw', 'field')" />
|
||||
<ElButton :aria-label="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawExclusionShortcut')" :class="{ active: creationKind === 'exclusion' }" :icon="Crop" @click="emit('draw', 'exclusion')" />
|
||||
<ElButton :aria-label="t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut')" :title="t('admin.shippingOrderProfiles.workbench.drawReservationIdRegionShortcut')" :class="{ active: creationKind === 'reservation_id_region' }" :icon="ChatLineSquare" @click="emit('draw', 'reservation_id_region')" />
|
||||
<ElButton class="suggest" :aria-label="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :title="t('admin.shippingOrderProfiles.workbench.autoSuggestShortcut')" :disabled="autoSuggestDisabled || suggesting" :icon="MagicStick" @click="emit('suggest')" />
|
||||
<p v-if="suggestionProgress" class="suggestion-progress" :class="{ failed: !suggesting }">{{ suggestionProgress }}</p>
|
||||
</aside>
|
||||
<div ref="viewport" class="canvas-viewport" :class="{ panning: !creationKind || readonlyMode }" @wheel.prevent="handleWheel">
|
||||
@@ -633,9 +673,9 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
<div v-if="displayLoadError && pdfPreview" class="canvas-error-overlay" role="alert">
|
||||
<p>{{ displayLoadError }}</p>
|
||||
<button type="button" class="canvas-retry" @click="onRetryClick">
|
||||
<ElButton class="canvas-retry" @click="onRetryClick">
|
||||
{{ t('admin.shippingOrderProfiles.workbench.retryCanvas') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -660,7 +700,9 @@ onBeforeUnmount(() => {
|
||||
.readonly-badge { display: inline-flex; align-items: center; min-height: 2rem; border: 1px solid #475569; border-radius: .35rem; background: #0f172a; padding: 0 .65rem; color: #cbd5e1; }
|
||||
.page-control { justify-self: center; }
|
||||
.page-control label { display: flex; height: 2rem; align-items: center; gap: .3rem; border: 1px solid #475569; border-radius: .35rem; background: #0f172a; padding: 0 .45rem; color: #94a3b8; }
|
||||
.page-control .input-field { width: 3rem; border: 0; background: transparent; color: #f8fafc; font: 700 .76rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; outline: 0; }
|
||||
.page-control .page-input { width: 4.2rem; }
|
||||
.page-control :deep(.page-input .el-input__wrapper) { background: transparent; box-shadow: none; padding: 0 4px; }
|
||||
.page-control :deep(.page-input input) { color: #f8fafc; font: 700 .76rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; }
|
||||
.zoom-control { justify-self: end; }
|
||||
.canvas-toolbar output { min-width: 3.4rem; color: #f8fafc; text-align: center; }
|
||||
.zoom-control .fit-action { padding-inline: .65rem; }
|
||||
|
||||
+57
-7
@@ -1,30 +1,80 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileIdentityStep.vue
|
||||
用途:收集模板名称与已发布 Schema。
|
||||
依赖:Schema DTO、Vue I18n。
|
||||
依赖:element-plus ElInput / ElSelect、Schema DTO、Vue I18n。
|
||||
逻辑:系统编码由服务端在创建时生成;父级拥有唯一表单状态,避免 v-model 对象替换丢失首步校验状态。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { ElInput, ElOption, ElSelect } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderSchemaVersion } from '@/features/admin/types/shipping-order-schema.types';
|
||||
|
||||
type Identity = { displayName: string; schemaId: number };
|
||||
const props = defineProps<{ modelValue: Identity; schemas: ShippingOrderSchemaVersion[]; schemasResolved: boolean }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: Identity] }>();
|
||||
const { t } = useI18n();
|
||||
const publishedSchemas = computed(() => props.schemas.filter((item) => item.status === 'published'));
|
||||
/** 每次更新都提交完整快照,确保父级的下一步校验始终读取最新值。 */
|
||||
function update(key: keyof Identity, value: string | number): void { emit('update:modelValue', { ...props.modelValue, [key]: value }); }
|
||||
|
||||
/**
|
||||
* 每次更新都提交完整快照,确保父级的下一步校验始终读取最新值。
|
||||
* @param key - 要更新的身份字段
|
||||
* @param value - 新值
|
||||
*/
|
||||
function update(key: keyof Identity, value: string | number): void {
|
||||
emit('update:modelValue', { ...props.modelValue, [key]: value });
|
||||
}
|
||||
|
||||
/**
|
||||
* 写回 Schema 版本。清空时写回 0,表示尚未选择。
|
||||
* @param value - 已发布版本 id;清空为 undefined
|
||||
*/
|
||||
function onSchemaChange(value: number | undefined): void {
|
||||
update('schemaId', Number(value || 0));
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="identity-step">
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.name') }}<b>*</b></span><input class="input-field" :value="modelValue.displayName" :placeholder="t('admin.shippingOrderProfiles.wizard.namePlaceholder')" @input="update('displayName', ($event.target as HTMLInputElement).value)" /></label>
|
||||
<div class="system-code"><strong>{{ t('admin.shippingOrderProfiles.code') }}</strong><span>{{ t('admin.shippingOrderProfiles.wizard.systemCodeHint') }}</span></div>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.schema') }}<b>*</b></span><select class="select-field" :value="modelValue.schemaId" @change="update('schemaId', Number(($event.target as HTMLSelectElement).value))"><option :value="0">{{ t('admin.shippingOrderProfiles.wizard.selectSchema') }}</option><option v-for="schema in publishedSchemas" :key="schema.id" :value="schema.id">v{{ schema.version }}</option></select><small v-if="schemasResolved && !publishedSchemas.length" class="field-warning">{{ t('admin.shippingOrderProfiles.wizard.schemaRequired') }}</small></label>
|
||||
<label class="field">
|
||||
<span>{{ t('admin.shippingOrderProfiles.name') }}<b>*</b></span>
|
||||
<ElInput
|
||||
:model-value="modelValue.displayName"
|
||||
:placeholder="t('admin.shippingOrderProfiles.wizard.namePlaceholder')"
|
||||
@update:model-value="update('displayName', String($event ?? ''))"
|
||||
/>
|
||||
</label>
|
||||
<div class="system-code">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.code') }}</strong>
|
||||
<span>{{ t('admin.shippingOrderProfiles.wizard.systemCodeHint') }}</span>
|
||||
</div>
|
||||
<label class="field">
|
||||
<span>{{ t('admin.shippingOrderProfiles.schema') }}<b>*</b></span>
|
||||
<ElSelect
|
||||
:model-value="modelValue.schemaId || undefined"
|
||||
:placeholder="t('admin.shippingOrderProfiles.wizard.selectSchema')"
|
||||
clearable
|
||||
@update:model-value="onSchemaChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="schema in publishedSchemas"
|
||||
:key="schema.id"
|
||||
:label="`v${schema.version}`"
|
||||
:value="schema.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
<small v-if="schemasResolved && !publishedSchemas.length" class="field-warning">
|
||||
{{ t('admin.shippingOrderProfiles.wizard.schemaRequired') }}
|
||||
</small>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.identity-step { display: grid; gap: 22px; max-width: 560px; }.field { display: grid; gap: 8px; color: var(--text-secondary); font-weight: 700; }.field > span { display: flex; gap: 4px; }.field b { color: var(--status-error-fg); }.field .input-field,.field .select-field { min-height: 44px; box-sizing: border-box; font: inherit; }.field small { color: var(--text-muted); font-size: .8rem; font-weight: 500; }.system-code { display: grid; gap: 4px; padding: 13px 14px; border: 1px solid var(--border-default); border-radius: 9px; color: var(--text-secondary); background: var(--bg-surface-soft); font-size: .86rem; }.system-code strong { color: var(--text-primary); }.field-warning { color: var(--status-warning-fg) !important; }
|
||||
.identity-step { display: grid; gap: 22px; max-width: 560px; }
|
||||
.field { display: grid; gap: 8px; color: var(--el-text-color-regular); font-weight: 700; }
|
||||
.field > span { display: flex; gap: 4px; }
|
||||
.field b { color: var(--el-color-danger); }
|
||||
.field-warning { color: var(--el-color-warning); }
|
||||
.system-code { display: grid; gap: 4px; padding: 13px 14px; border: 1px solid var(--el-border-color); border-radius: 9px; background: var(--el-fill-color-light); }
|
||||
</style>
|
||||
+71
-4
@@ -1,14 +1,81 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileModelStartStep.vue
|
||||
用途:在多表样本中选择用于订单明细标注的表格。
|
||||
依赖:样本表格预览 DTO、Vue I18n。
|
||||
依赖:element-plus ElSelect / ElTable、样本表格预览 DTO、Vue I18n。
|
||||
逻辑:只让用户选定服务端已发现的 table_id;预览限制在容器内横向滚动,避免宽表撑破页面。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { ElOption, ElSelect, ElTable, ElTableColumn } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
const props = defineProps<{ tables: Array<{ table_id: string; page_no: number; row_count: number; column_count: number; rows: string[][] }>; modelValue: string }>();
|
||||
|
||||
type PreviewRow = { id: string; cells: string[] };
|
||||
|
||||
const props = defineProps<{
|
||||
tables: Array<{ table_id: string; page_no: number; row_count: number; column_count: number; rows: string[][] }>;
|
||||
modelValue: string;
|
||||
}>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: string] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
const previewRows = computed((): PreviewRow[] => {
|
||||
const table = props.tables.find((item) => item.table_id === props.modelValue);
|
||||
return (table?.rows.slice(0, 4) || []).map((cells, index) => ({ id: String(index), cells }));
|
||||
});
|
||||
const previewColumnCount = computed(() => Math.max(0, ...previewRows.value.map((row) => row.cells.length)));
|
||||
|
||||
/**
|
||||
* 写回选中的 table_id。清空时回到空字符串,表示尚未选择表格。
|
||||
* @param value - 下拉值;清空为 undefined
|
||||
*/
|
||||
function onTableChange(value: string | undefined): void {
|
||||
emit('update:modelValue', value || '');
|
||||
}
|
||||
</script>
|
||||
<template><div class="wizard-step"><div><label>{{ t('admin.shippingOrderProfiles.wizard.orderLineTable') }}<select class="select-field" :value="modelValue" @change="emit('update:modelValue', ($event.target as HTMLSelectElement).value)"><option value="">{{ t('admin.shippingOrderProfiles.selectTable') }}</option><option v-for="table in tables" :key="table.table_id" :value="table.table_id">{{ t('admin.shippingOrderProfiles.wizard.tableOption', { page: table.page_no, rows: table.row_count, columns: table.column_count }) }}</option></select></label><p class="field-hint">{{ t('admin.shippingOrderProfiles.wizard.orderLineTableHint') }}</p></div><p v-if="!tables.length" class="warning">{{ t('admin.shippingOrderProfiles.wizard.noTable') }}</p><div v-else-if="modelValue" class="table-preview"><table><tbody><tr v-for="row in tables.find((item) => item.table_id === modelValue)?.rows.slice(0, 4) || []" :key="row.join('|')"><td v-for="cell in row" :key="cell">{{ cell }}</td></tr></tbody></table></div></div></template>
|
||||
<style scoped>.wizard-step{display:grid;min-width:0;gap:1rem}.wizard-step label{display:grid;gap:.35rem;font-weight:600}.wizard-step .select-field{min-width:0}.field-hint{margin:.45rem 0 0;color:var(--text-muted);font-size:.875rem}.warning{color:var(--status-warning-fg)}.table-preview{max-width:100%;overflow-x:auto;border:1px solid var(--border-default);border-radius:.5rem}.table-preview table{width:max-content;min-width:100%;border-collapse:collapse}.table-preview td{max-width:16rem;padding:.55rem;border:1px solid var(--border-default);overflow-wrap:anywhere;vertical-align:top}</style>
|
||||
|
||||
<template>
|
||||
<div class="wizard-step">
|
||||
<div>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.wizard.orderLineTable') }}
|
||||
<ElSelect
|
||||
class="table-select"
|
||||
:model-value="modelValue || undefined"
|
||||
:placeholder="t('admin.shippingOrderProfiles.selectTable')"
|
||||
clearable
|
||||
@update:model-value="onTableChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="table in tables"
|
||||
:key="table.table_id"
|
||||
:label="t('admin.shippingOrderProfiles.wizard.tableOption', { page: table.page_no, rows: table.row_count, columns: table.column_count })"
|
||||
:value="table.table_id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
<p class="field-hint">{{ t('admin.shippingOrderProfiles.wizard.orderLineTableHint') }}</p>
|
||||
</div>
|
||||
<p v-if="!tables.length" class="warning">{{ t('admin.shippingOrderProfiles.wizard.noTable') }}</p>
|
||||
<div v-else-if="modelValue" class="table-preview">
|
||||
<ElTable :data="previewRows" row-key="id">
|
||||
<ElTableColumn
|
||||
v-for="index in previewColumnCount"
|
||||
:key="index"
|
||||
:label="String(index)"
|
||||
min-width="120"
|
||||
>
|
||||
<template #default="{ row }">{{ (row as PreviewRow).cells[index - 1] }}</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wizard-step { display: grid; min-width: 0; gap: 1rem; }
|
||||
.wizard-step label { display: grid; gap: .35rem; font-weight: 600; }
|
||||
.table-select { width: 100%; max-width: 28rem; }
|
||||
.field-hint { margin: .45rem 0 0; color: var(--el-text-color-secondary); }
|
||||
.warning { color: var(--el-color-warning); }
|
||||
.table-preview { max-width: 100%; overflow-x: auto; }
|
||||
</style>
|
||||
+23
-10
@@ -1,13 +1,14 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileReadOnlyCanvas.vue
|
||||
用途:在版本详情页展示基于冻结样本绑定的只读画布。
|
||||
依赖:冻结样本预览 API、OrderProfileDocumentCanvas、冻结证据面板。
|
||||
依赖:element-plus、冻结样本预览 API、OrderProfileDocumentCanvas、冻结证据面板。
|
||||
逻辑:所有模板共用 annotation/training 冻结样本画布;XFA datasets 映射仅作为侧栏证据,
|
||||
blind_test 继续留在摘要层,不进入样本选择器。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElOption, ElSelect } from 'element-plus';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import {
|
||||
authorizeOrderProfileFrozenSamplePreviewPages,
|
||||
@@ -121,6 +122,14 @@ const loadRegionDiagnostics = async (): Promise<void> => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换只读画布样本。清空时回到 null,由现有样本 watch 再落到首个可用样本。
|
||||
* @param value - 冻结样本 id
|
||||
*/
|
||||
function onReadonlySampleChange(value: number | undefined): void {
|
||||
selectedSampleId.value = value ?? null;
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.detail.id,
|
||||
() => {
|
||||
@@ -151,11 +160,18 @@ watch([selectedSampleId, pageNo], () => {
|
||||
<div class="toolbar">
|
||||
<label class="field">
|
||||
<span>{{ t('admin.shippingOrderProfiles.versionCenter.readonlySample') }}</span>
|
||||
<select v-model.number="selectedSampleId" class="select-field">
|
||||
<option v-for="sample in readonlySamples" :key="sample.id" :value="sample.id">
|
||||
{{ sampleLabel(sample) }}
|
||||
</option>
|
||||
</select>
|
||||
<ElSelect
|
||||
class="sample-select"
|
||||
:model-value="selectedSampleId ?? undefined"
|
||||
@update:model-value="onReadonlySampleChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="sample in readonlySamples"
|
||||
:key="sample.id"
|
||||
:label="sampleLabel(sample)"
|
||||
:value="sample.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
<p v-if="selectedSample && !selectedSample.frozen_evidence_ready" class="warning-text">
|
||||
{{ t('admin.shippingOrderProfiles.versionCenter.sampleFrozenEvidenceMissing') }}
|
||||
@@ -255,10 +271,7 @@ watch([selectedSampleId, pageNo], () => {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.field .select-field {
|
||||
min-height: 2.5rem;
|
||||
padding: 0 0.75rem;
|
||||
}
|
||||
.sample-select { width: 100%; max-width: 28rem; }
|
||||
|
||||
.canvas-grid {
|
||||
display: grid;
|
||||
|
||||
+47
-9
@@ -1,12 +1,13 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileSampleStep.vue
|
||||
用途:上传新模板样本或复用已解析样本,并自动选择上传后解析完成的文档。
|
||||
依赖:模板样本 Intake 状态 API、文件资产上传 API、Vue I18n。
|
||||
依赖:element-plus、模板样本 Intake 状态 API、文件资产上传 API、Vue I18n。
|
||||
逻辑:上传后轮询同一 Intake;只有 ready 样本进入父级选择值,避免要求管理员重复选择刚上传的文件。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { CheckCircle2, Clock3, UploadCloud } from 'lucide-vue-next';
|
||||
import { CircleCheck, Clock, Upload } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElIcon, ElOption, ElSelect } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
@@ -96,36 +97,73 @@ async function upload(event: Event): Promise<void> {
|
||||
message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.wizard.uploadFailed'));
|
||||
} finally { uploading.value = false; }
|
||||
}
|
||||
const fileInput = ref<HTMLInputElement | null>(null);
|
||||
|
||||
/**
|
||||
* 打开隐藏文件框。上传控件保留原生 file input,按钮只负责触发选择。
|
||||
*/
|
||||
function openFilePicker(): void {
|
||||
fileInput.value?.click();
|
||||
}
|
||||
|
||||
/**
|
||||
* 写回已选样本。清空时写回 0,表示尚未选择。
|
||||
* @param value - 样本文档 id;清空为 undefined
|
||||
*/
|
||||
function onSampleChange(value: number | undefined): void {
|
||||
emit('update:modelValue', Number(value || 0));
|
||||
}
|
||||
|
||||
onBeforeUnmount(stopPolling);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="sample-step">
|
||||
<section class="upload-panel">
|
||||
<div class="upload-panel__icon"><UploadCloud :size="22" /></div>
|
||||
<div class="upload-panel__icon"><ElIcon :size="22"><Upload /></ElIcon></div>
|
||||
<div><h3>{{ t('admin.shippingOrderProfiles.wizard.uploadNewSample') }}</h3><p>{{ t('admin.shippingOrderProfiles.wizard.uploadNewSampleHint') }}</p></div>
|
||||
<label class="upload-action"><input type="file" accept=".pdf,.eml,application/pdf,message/rfc822" :disabled="uploading" @change="upload"><span>{{ uploading ? t('admin.shippingOrderProfiles.wizard.uploading') : t('admin.shippingOrderProfiles.uploadSample') }}</span></label>
|
||||
<ElButton type="primary" :loading="uploading" @click="openFilePicker">
|
||||
{{ uploading ? t('admin.shippingOrderProfiles.wizard.uploading') : t('admin.shippingOrderProfiles.uploadSample') }}
|
||||
</ElButton>
|
||||
<input ref="fileInput" class="sr-file" type="file" accept=".pdf,.eml,application/pdf,message/rfc822" :disabled="uploading" @change="upload">
|
||||
</section>
|
||||
|
||||
<div v-if="pendingIntake" class="parse-status" :class="{ failed: pendingIntake.state === 'failed' }">
|
||||
<Clock3 v-if="pendingIntake.state !== 'failed'" :size="19" /><span v-else>!</span>
|
||||
<ElIcon v-if="pendingIntake.state !== 'failed'" :size="19"><Clock /></ElIcon><span v-else>!</span>
|
||||
<div>
|
||||
<strong>{{ pendingIntake.filename }}</strong>
|
||||
<p v-if="pendingIntake.state === 'failed'">{{ sampleFailureMessage(pendingIntake.errorCode) }}</p>
|
||||
<p v-else>{{ t(`admin.shippingOrderProfiles.wizard.sampleStatus.${pendingIntake.state}`) }}</p>
|
||||
<button v-if="pendingIntake.state !== 'uploading' && pendingIntake.state !== 'failed'" type="button" class="refresh-status" @click="emit('refresh')">{{ t('admin.shippingOrderProfiles.wizard.refreshSamples') }}</button>
|
||||
<ElButton v-if="pendingIntake.state !== 'uploading' && pendingIntake.state !== 'failed'" link type="primary" @click="emit('refresh')">{{ t('admin.shippingOrderProfiles.wizard.refreshSamples') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedSample" class="selected-sample"><CheckCircle2 :size="20" /><div><strong>{{ t('admin.shippingOrderProfiles.wizard.sampleSelected') }}</strong><span>{{ selectedSample.filename || selectedSample.intake_no }} · {{ selectedSample.table_count }} {{ t('admin.shippingOrderProfiles.tablesUnit') }}</span></div></div>
|
||||
<div v-if="selectedSample" class="selected-sample"><ElIcon :size="20"><CircleCheck /></ElIcon><div><strong>{{ t('admin.shippingOrderProfiles.wizard.sampleSelected') }}</strong><span>{{ selectedSample.filename || selectedSample.intake_no }} · {{ selectedSample.table_count }} {{ t('admin.shippingOrderProfiles.tablesUnit') }}</span></div></div>
|
||||
|
||||
<section class="reuse-panel">
|
||||
<div class="reuse-panel__heading"><h3>{{ t('admin.shippingOrderProfiles.wizard.reuseSample') }}</h3><p>{{ t('admin.shippingOrderProfiles.wizard.reuseSampleHint') }}</p></div>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.selectSample') }}</span><select class="select-field" :value="modelValue" @change="emit('update:modelValue', Number(($event.target as HTMLSelectElement).value))"><option :value="0">{{ t('admin.shippingOrderProfiles.selectSample') }}</option><option v-for="sample in samples" :key="sample.document_id" :value="sample.document_id">{{ sample.filename || sample.intake_no }} · {{ sample.table_count }} {{ t('admin.shippingOrderProfiles.tablesUnit') }}</option></select></label>
|
||||
<label class="field">
|
||||
<span>{{ t('admin.shippingOrderProfiles.selectSample') }}</span>
|
||||
<ElSelect
|
||||
class="sample-select"
|
||||
:model-value="modelValue || undefined"
|
||||
:placeholder="t('admin.shippingOrderProfiles.selectSample')"
|
||||
clearable
|
||||
@update:model-value="onSampleChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="sample in samples"
|
||||
:key="sample.document_id"
|
||||
:label="`${sample.filename || sample.intake_no} · ${sample.table_count} ${t('admin.shippingOrderProfiles.tablesUnit')}`"
|
||||
:value="sample.document_id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--bg-surface-soft); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--status-info-fg); background: var(--status-info-bg); }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: var(--text-primary); font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .84rem; }.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: #0284c7; font-weight: 700; cursor: pointer; }.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--status-info-fg); background: var(--status-info-bg); }.parse-status strong,.selected-sample strong { display: block; color: var(--text-primary); }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--text-muted); font-size: .83rem; }.refresh-status { margin-top: 6px; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; text-decoration: underline; }.parse-status.failed { color: var(--status-error-fg); border-color: var(--status-error-border); background: var(--status-error-bg); }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--status-error-fg); font-weight: 800; }.selected-sample { color: var(--status-success-fg); border-color: var(--status-success-border); background: var(--status-success-bg); }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: var(--text-secondary); font-size: .88rem; font-weight: 700; }.field .select-field { min-height: 44px; font: inherit; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
|
||||
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--bg-surface-soft); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--status-info-fg); background: var(--status-info-bg); }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: var(--text-primary); font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .84rem; }.upload-action { display: none; }
|
||||
.sr-file { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--status-info-fg); background: var(--status-info-bg); }.parse-status strong,.selected-sample strong { display: block; color: var(--text-primary); }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--text-muted); font-size: .83rem; }.refresh-status { margin-top: 6px; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-size: .8rem; font-weight: 700; cursor: pointer; text-decoration: underline; }.parse-status.failed { color: var(--status-error-fg); border-color: var(--status-error-border); background: var(--status-error-bg); }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--status-error-fg); font-weight: 800; }.selected-sample { color: var(--status-success-fg); border-color: var(--status-success-border); background: var(--status-success-bg); }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: var(--text-secondary); font-size: .88rem; font-weight: 700; }.sample-select { width: 100%; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
|
||||
</style>
|
||||
+62
-59
@@ -1,13 +1,14 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileUsageTable.vue
|
||||
用途:展示订单模板版本的实际使用记录,并提供进入只读 Run 审计的入口。
|
||||
依赖:版本中心 usage API、Vue Router。
|
||||
依赖:element-plus、版本中心 usage API、Vue Router。
|
||||
逻辑:只读取每个 Unit 最新 RouteDecision 的安全投影;点击行跳转到管理员 Run 诊断页,不在当前页改动任何业务状态。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRouter } from "vue-router";
|
||||
import { ElButton, ElLoading, ElTable, ElTableColumn } from "element-plus";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { listOrderDocumentProfileUsages } from "@/features/admin/api/shipping-order-document-profile.api";
|
||||
import type {
|
||||
@@ -20,6 +21,7 @@ const props = defineProps<{ detail: ShippingOrderDocumentProfile }>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const vLoading = ElLoading.directive;
|
||||
const loading = ref(false);
|
||||
const errorMessage = ref("");
|
||||
const page = ref<OrderProfileUsagePage | null>(null);
|
||||
@@ -99,9 +101,9 @@ watch(
|
||||
<h3>{{ t("admin.shippingOrderProfiles.versionCenter.usage.title") }}</h3>
|
||||
<p>{{ t("admin.shippingOrderProfiles.versionCenter.usage.subtitle") }}</p>
|
||||
</div>
|
||||
<button type="button" class="ghost-button" :disabled="loading" @click="load">
|
||||
<ElButton :loading="loading" @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.refresh") }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="state-card">
|
||||
@@ -109,72 +111,73 @@ watch(
|
||||
</div>
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
<ElButton @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<div v-else-if="!page?.items.length" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.empty") }}
|
||||
</div>
|
||||
<div v-else class="table-wrapper">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.runNo") }}</th>
|
||||
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.document") }}</th>
|
||||
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.matchStatus") }}</th>
|
||||
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.executionStatus") }}</th>
|
||||
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.identityMode") }}</th>
|
||||
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.autoCreateApproved") }}</th>
|
||||
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.createdAt") }}</th>
|
||||
<th>{{ t("admin.shippingOrderProfiles.versionCenter.usage.columns.reasonCodes") }}</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in page.items" :key="item.route_decision_id">
|
||||
<td>
|
||||
<div class="cell-title">{{ item.run_no }}</div>
|
||||
<small>{{ translateUsageValue("runStatuses", item.run_status) }}</small>
|
||||
</td>
|
||||
<td>
|
||||
<div class="cell-title">{{ item.document_label }}</div>
|
||||
<small>#{{ item.unit_position + 1 }}</small>
|
||||
</td>
|
||||
<td>{{ translateUsageValue("matchStatuses", item.match_status) }}</td>
|
||||
<td>{{ translateUsageValue("executionStatuses", item.execution_status) }}</td>
|
||||
<td>{{ translateUsageValue("identityModes", item.identity_match_mode) }}</td>
|
||||
<td>
|
||||
{{
|
||||
item.auto_create_approved == null
|
||||
? "-"
|
||||
: t(item.auto_create_approved
|
||||
? "admin.shippingOrderProfiles.versionCenter.usage.yes"
|
||||
: "admin.shippingOrderProfiles.versionCenter.usage.no")
|
||||
}}
|
||||
</td>
|
||||
<td>{{ formatTime(item.created_at) }}</td>
|
||||
<td>
|
||||
<span v-if="item.reason_codes.length">{{ item.reason_codes.join(", ") }}</span>
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="link-button" @click="openDiagnostic(item)">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.openDiagnostic") }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-else class="table-wrapper" v-loading="loading">
|
||||
<ElTable :data="page.items" row-key="route_decision_id">
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.versionCenter.usage.columns.runNo')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<div class="cell-title">{{ (row as OrderProfileUsageRow).run_no }}</div>
|
||||
<small>{{ translateUsageValue("runStatuses", (row as OrderProfileUsageRow).run_status) }}</small>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.versionCenter.usage.columns.document')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<div class="cell-title">{{ (row as OrderProfileUsageRow).document_label }}</div>
|
||||
<small>#{{ (row as OrderProfileUsageRow).unit_position + 1 }}</small>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.versionCenter.usage.columns.matchStatus')" min-width="120">
|
||||
<template #default="{ row }">{{ translateUsageValue("matchStatuses", (row as OrderProfileUsageRow).match_status) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.versionCenter.usage.columns.executionStatus')" min-width="120">
|
||||
<template #default="{ row }">{{ translateUsageValue("executionStatuses", (row as OrderProfileUsageRow).execution_status) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.versionCenter.usage.columns.identityMode')" min-width="120">
|
||||
<template #default="{ row }">{{ translateUsageValue("identityModes", (row as OrderProfileUsageRow).identity_match_mode) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.versionCenter.usage.columns.autoCreateApproved')" min-width="120">
|
||||
<template #default="{ row }">
|
||||
{{
|
||||
(row as OrderProfileUsageRow).auto_create_approved == null
|
||||
? "-"
|
||||
: t((row as OrderProfileUsageRow).auto_create_approved
|
||||
? "admin.shippingOrderProfiles.versionCenter.usage.yes"
|
||||
: "admin.shippingOrderProfiles.versionCenter.usage.no")
|
||||
}}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.versionCenter.usage.columns.createdAt')" min-width="160">
|
||||
<template #default="{ row }">{{ formatTime((row as OrderProfileUsageRow).created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.versionCenter.usage.columns.reasonCodes')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span v-if="(row as OrderProfileUsageRow).reason_codes.length">{{ (row as OrderProfileUsageRow).reason_codes.join(", ") }}</span>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openDiagnostic(row as OrderProfileUsageRow)">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.openDiagnostic") }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
<button type="button" class="ghost-button" :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
<ElButton :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.previous") }}
|
||||
</button>
|
||||
<button type="button" class="ghost-button" :disabled="loading || !hasNext" @click="loadNext">
|
||||
</ElButton>
|
||||
<ElButton :disabled="loading || !hasNext" @click="loadNext">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.next") }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
+22
-17
@@ -1,13 +1,14 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileVersionDiff.vue
|
||||
用途:展示订单模板版本中心的服务端语义 diff。
|
||||
依赖:版本中心 diff API、路由 query、版本摘要列表。
|
||||
依赖:element-plus、版本中心 diff API、路由 query、版本摘要列表。
|
||||
逻辑:始终由服务端计算差异;前端只负责选择对比版本、呈现 summary 和折叠原始 JSON 快照。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ElButton, ElOption, ElSelect } from "element-plus";
|
||||
import { BusinessError } from "@/shared/api/client";
|
||||
import { getOrderDocumentProfileDiff } from "@/features/admin/api/shipping-order-document-profile.api";
|
||||
import type {
|
||||
@@ -98,10 +99,14 @@ const syncAgainstProfileId = (againstProfileId: number | null) => {
|
||||
void router.replace({ query });
|
||||
};
|
||||
|
||||
const handleAgainstChange = (event: Event) => {
|
||||
const value = Number((event.target as HTMLSelectElement).value || 0);
|
||||
syncAgainstProfileId(Number.isFinite(value) && value > 0 ? value : null);
|
||||
};
|
||||
/**
|
||||
* 写回对比版本。清空表示与上一版比较。
|
||||
* @param value - 目标版本 id;清空为 undefined
|
||||
*/
|
||||
function onAgainstChange(value: number | undefined): void {
|
||||
const numeric = Number(value || 0);
|
||||
syncAgainstProfileId(Number.isFinite(numeric) && numeric > 0 ? numeric : null);
|
||||
}
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true;
|
||||
@@ -134,20 +139,20 @@ watch(
|
||||
</div>
|
||||
<label class="compare-select">
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.diff.compareTarget") }}</span>
|
||||
<select
|
||||
class="select-field"
|
||||
:value="explicitAgainstProfileId || ''"
|
||||
@change="handleAgainstChange"
|
||||
<ElSelect
|
||||
class="compare-select__control"
|
||||
:model-value="explicitAgainstProfileId || undefined"
|
||||
:placeholder="t('admin.shippingOrderProfiles.versionCenter.diff.defaultPrevious')"
|
||||
clearable
|
||||
@update:model-value="onAgainstChange"
|
||||
>
|
||||
<option value="">{{ t("admin.shippingOrderProfiles.versionCenter.diff.defaultPrevious") }}</option>
|
||||
<option
|
||||
<ElOption
|
||||
v-for="item in comparableVersions"
|
||||
:key="item.id"
|
||||
:value="item.id"
|
||||
>
|
||||
v{{ item.version }} · {{ t(`admin.shippingOrderProfiles.versionCenter.status.${item.status === "draft" ? "currentDraft" : item.status === "published" ? "currentPublished" : "retired"}`) }}
|
||||
</option>
|
||||
</select>
|
||||
:label="`v${item.version} · ${t(`admin.shippingOrderProfiles.versionCenter.status.${item.status === 'draft' ? 'currentDraft' : item.status === 'published' ? 'currentPublished' : 'retired'}`)}`"
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -156,9 +161,9 @@ watch(
|
||||
</div>
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
<ElButton @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
<template v-else-if="diff">
|
||||
<div class="summary-bar">
|
||||
|
||||
+18
-9
@@ -1,13 +1,14 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaCollectionSelector.vue
|
||||
用途:权威明细集合与镜像对账集合选择。
|
||||
依赖:vue-i18n、XfaCollectionCandidate。
|
||||
依赖:element-plus、vue-i18n、XfaCollectionCandidate。
|
||||
逻辑:以候选卡片直接展示完整路径、字段覆盖与样本证据;权威单选强制,镜像多选仅用于对账;
|
||||
selectable=false 的无效集合禁选;全部候选被排除时仍展示排除原因。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElCheckbox, ElRadio } from 'element-plus';
|
||||
import type { XfaCollectionCandidate } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import { listMirrorCollectionCandidates } from '../xfaProfileMapping.utils';
|
||||
|
||||
@@ -35,6 +36,8 @@ function percent(value?: number): string {
|
||||
|
||||
/**
|
||||
* 切换镜像集合勾选。
|
||||
* @param pathId - 候选路径
|
||||
* @param checked - 是否勾选
|
||||
*/
|
||||
function toggleMirror(pathId: string, checked: boolean): void {
|
||||
const next = new Set(props.mirrorPathIds);
|
||||
@@ -43,6 +46,15 @@ function toggleMirror(pathId: string, checked: boolean): void {
|
||||
emit('update:mirrorPathIds', [...next]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 勾选镜像集合。Element 复选框的变更值统一收成布尔。
|
||||
* @param pathId - 候选路径
|
||||
* @param checked - 是否勾选
|
||||
*/
|
||||
function onMirrorChange(pathId: string, checked: boolean | string | number): void {
|
||||
toggleMirror(pathId, checked === true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将排除/推荐原因码映射为可读文案。
|
||||
* @param reasons 原因码列表
|
||||
@@ -80,11 +92,9 @@ function reasonLabels(reasons?: string[]): string {
|
||||
disabled: item.selectable === false,
|
||||
}"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="xfa-authoritative-collection"
|
||||
<ElRadio
|
||||
:model-value="authoritativePathId"
|
||||
:value="item.path_id"
|
||||
:checked="authoritativePathId === item.path_id"
|
||||
:disabled="item.selectable === false"
|
||||
@change="emit('update:authoritativePathId', item.path_id)"
|
||||
/>
|
||||
@@ -135,10 +145,9 @@ function reasonLabels(reasons?: string[]): string {
|
||||
<fieldset v-if="mirrors.length" class="mirror-fieldset">
|
||||
<legend>{{ t('admin.shippingOrderProfiles.xfaWorkbench.mirrorCollections') }}</legend>
|
||||
<label v-for="item in mirrors" :key="item.path_id" class="mirror">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="mirrorPathIds.includes(item.path_id)"
|
||||
@change="toggleMirror(item.path_id, ($event.target as HTMLInputElement).checked)"
|
||||
<ElCheckbox
|
||||
:model-value="mirrorPathIds.includes(item.path_id)"
|
||||
@change="onMirrorChange(item.path_id, $event)"
|
||||
/>
|
||||
<span class="mirror-copy">
|
||||
<strong>{{ item.path_label || item.local_name }}</strong>
|
||||
|
||||
+16
-14
@@ -1,13 +1,14 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaDatasetTree.vue
|
||||
用途:XFA 受控数据树;主工作台用于绑定导航,高级诊断抽屉内只读展示。
|
||||
依赖:vue-i18n、xfaProfileMapping.utils。
|
||||
依赖:element-plus、vue-i18n、xfaProfileMapping.utils。
|
||||
逻辑:支持展开折叠、方向键导航与完整样本值展示;readonly 时隐藏增删改规则动作;
|
||||
expandSamples 用于弹窗选型场景,放宽样本列宽度并允许换行。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, ref } from 'vue';
|
||||
import { ChevronDown, ChevronRight, Pencil } from 'lucide-vue-next';
|
||||
import { ArrowDown, ArrowRight, Edit } from '@element-plus/icons-vue';
|
||||
import { ElButton, ElIcon, ElInput } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { XfaFieldTreeNode } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import type { XfaSplitRuleSet } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
@@ -164,7 +165,7 @@ async function onKeydown(event: KeyboardEvent, pathId: string): Promise<void> {
|
||||
>
|
||||
<label class="xfa-tree__search">
|
||||
<span class="sr-only">{{ t('admin.shippingOrderProfiles.xfaWorkbench.searchPaths') }}</span>
|
||||
<input v-model="query" type="search" :placeholder="t('admin.shippingOrderProfiles.xfaWorkbench.searchPaths')" />
|
||||
<ElInput v-model="query" class="xfa-tree__search-input" :placeholder="t('admin.shippingOrderProfiles.xfaWorkbench.searchPaths')" />
|
||||
</label>
|
||||
<ul class="xfa-tree__list" role="tree">
|
||||
<li v-for="(node, index) in visible" :key="node.pathId" role="none">
|
||||
@@ -190,8 +191,8 @@ async function onKeydown(event: KeyboardEvent, pathId: string): Promise<void> {
|
||||
@keydown="onKeydown($event, node.pathId)"
|
||||
>
|
||||
<span v-if="!node.isLeaf" class="toggle" @click.stop="toggle(node.pathId)">
|
||||
<ChevronRight v-if="collapsed.has(node.pathId)" :size="14" aria-hidden="true" />
|
||||
<ChevronDown v-else :size="14" aria-hidden="true" />
|
||||
<ElIcon v-if="collapsed.has(node.pathId)" :size="14" aria-hidden="true"><ArrowRight /></ElIcon>
|
||||
<ElIcon v-else :size="14" aria-hidden="true"><ArrowDown /></ElIcon>
|
||||
</span>
|
||||
<span v-else class="toggle-spacer" />
|
||||
<span class="name-block">
|
||||
@@ -199,15 +200,14 @@ async function onKeydown(event: KeyboardEvent, pathId: string): Promise<void> {
|
||||
<span v-if="node.isLeaf && parentPathHint(node)" class="path-hint">{{ parentPathHint(node) }}</span>
|
||||
</span>
|
||||
<span v-if="node.isCollectionCandidate" class="badge">{{ t('admin.shippingOrderProfiles.xfaWorkbench.collectionBadge') }}</span>
|
||||
<button
|
||||
<ElButton
|
||||
v-if="node.isLeaf && !isReadonly"
|
||||
type="button"
|
||||
class="add-rule"
|
||||
:class="{ 'add-rule--active': selectedPathId === node.pathId }"
|
||||
:title="t('admin.shippingOrderProfiles.xfaSplit.addRule')"
|
||||
:aria-label="t('admin.shippingOrderProfiles.xfaSplit.addRule')"
|
||||
@click.stop="emit('add-rule', node.pathId)"
|
||||
>+</button>
|
||||
>+</ElButton>
|
||||
<span v-if="node.sampleValueDisplay" class="sample" :title="node.sampleValueDisplay">
|
||||
{{ node.sampleValueDisplay }}
|
||||
</span>
|
||||
@@ -224,19 +224,21 @@ async function onKeydown(event: KeyboardEvent, pathId: string): Promise<void> {
|
||||
class="xfa-tree__rule"
|
||||
:class="{ selected: selectedRuleId === rule.rule_id }"
|
||||
>
|
||||
<button type="button" class="xfa-tree__rule-main" @click="emit('select-rule', node.pathId, rule.rule_id)">
|
||||
<ElButton class="xfa-tree__rule-main" @click="emit('select-rule', node.pathId, rule.rule_id)">
|
||||
<span class="rule-glyph">↳</span>
|
||||
<span class="rule-label">{{ t('admin.shippingOrderProfiles.xfaSplit.ruleLabel', { index: ruleIndex + 1 }) }} · {{ rule.segment.display_name || rule.segment.segment_code || t('admin.shippingOrderProfiles.xfaSplit.unnamedRule') }}</span>
|
||||
</button>
|
||||
<button
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!isReadonly"
|
||||
type="button"
|
||||
link
|
||||
type="primary"
|
||||
class="rule-edit"
|
||||
:title="t('common.edit')"
|
||||
:aria-label="t('common.edit')"
|
||||
:icon="Edit"
|
||||
@click.stop="emit('edit-rule', node.pathId, rule.rule_id)"
|
||||
><Pencil :size="12" aria-hidden="true" /></button>
|
||||
<button v-if="!isReadonly" type="button" class="rule-delete" :title="t('admin.shippingOrderProfiles.xfaSplit.deleteRule')" @click.stop="emit('delete-rule', node.pathId, rule.rule_id)">×</button>
|
||||
/>
|
||||
<ElButton v-if="!isReadonly" link type="danger" class="rule-delete" :title="t('admin.shippingOrderProfiles.xfaSplit.deleteRule')" @click.stop="emit('delete-rule', node.pathId, rule.rule_id)">×</ElButton>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
+62
-26
@@ -6,8 +6,9 @@
|
||||
*/
|
||||
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { mount, flushPromises, type VueWrapper } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import XfaSplitRulePanel from './XfaSplitRulePanel.vue';
|
||||
import type { OrderXfaDatasetProfileDefinition } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
@@ -208,6 +209,48 @@ function mountPanel(overrides: Record<string, unknown> = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父弹窗可调用的组件操作,验证头部按钮迁移后仍保持原有业务行为。
|
||||
* @param wrapper - 已挂载的拆分规则组件
|
||||
* @returns 组件通过 defineExpose 暴露的新增、预览与确认方法
|
||||
*/
|
||||
/**
|
||||
* 在 Element 下拉上发出选中值,等价于原先对原生 select 的 setValue。
|
||||
* @param wrapper - 已挂载面板
|
||||
* @param testId - 下拉 test id
|
||||
* @param value - 要写回的业务值
|
||||
*/
|
||||
function emitElSelect(wrapper: VueWrapper, testId: string, value: string): void {
|
||||
const select = wrapper.findAllComponents({ name: 'ElSelect' }).find((item) => item.attributes('data-testid') === testId);
|
||||
expect(select).toBeTruthy();
|
||||
select!.vm.$emit('update:modelValue', value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按字段标签找到提取方式等下拉并写回模式。
|
||||
* @param wrapper - 已挂载面板
|
||||
* @param label - 标签文案片段
|
||||
* @param value - 提取模式
|
||||
*/
|
||||
function emitElSelectInLabel(wrapper: VueWrapper, label: string, value: string): void {
|
||||
const select = wrapper.findAllComponents({ name: 'ElSelect' }).find((item) => (
|
||||
item.element.closest('label')?.textContent?.includes(label)
|
||||
));
|
||||
expect(select).toBeTruthy();
|
||||
select!.vm.$emit('update:modelValue', value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择高级处理步骤。下拉保持空值,重复选择仍会追加。
|
||||
* @param wrapper - 已挂载面板
|
||||
* @param value - 步骤类型
|
||||
*/
|
||||
function emitAddStage(wrapper: VueWrapper, value: string): void {
|
||||
const select = wrapper.findAllComponents({ name: 'ElSelect' }).find((item) => item.classes().includes('xfa-split__add-stage-select'));
|
||||
expect(select).toBeTruthy();
|
||||
select!.vm.$emit('update:modelValue', value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取父弹窗可调用的组件操作,验证头部按钮迁移后仍保持原有业务行为。
|
||||
* @param wrapper - 已挂载的拆分规则组件
|
||||
@@ -217,7 +260,7 @@ function exposedActions(wrapper: ReturnType<typeof mountPanel>) {
|
||||
return wrapper.vm as unknown as {
|
||||
addRule: () => void;
|
||||
runPreview: () => Promise<void>;
|
||||
confirmRules: () => void;
|
||||
confirmRules: () => Promise<void>;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -225,7 +268,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
beforeEach(() => {
|
||||
previewMock.mockReset();
|
||||
messageError.mockReset();
|
||||
vi.spyOn(window, 'confirm').mockReturnValue(true);
|
||||
vi.spyOn(ElMessageBox, 'confirm').mockResolvedValue('confirm' as never);
|
||||
});
|
||||
|
||||
it('adds a rule with default pipeline stages and emits updated split_rules', async () => {
|
||||
@@ -293,17 +336,18 @@ describe('XfaSplitRulePanel', () => {
|
||||
],
|
||||
});
|
||||
|
||||
await wrapper.get('[data-testid="xfa-split-handling"]').setValue('mapped');
|
||||
emitElSelect(wrapper, 'xfa-split-handling', 'mapped');
|
||||
let emitted = wrapper.emitted('update:split-rules');
|
||||
let nextDefinition = {
|
||||
...baseDefinition,
|
||||
split_rules: emitted?.[emitted.length - 1]?.[0] as typeof baseDefinition.split_rules,
|
||||
};
|
||||
await wrapper.setProps({ definition: nextDefinition });
|
||||
const target = wrapper.get('[data-testid="xfa-split-target-field"]');
|
||||
expect(target.text()).toContain('unit_price');
|
||||
expect(target.text()).not.toContain('price_unit');
|
||||
await target.setValue('unit-price-id');
|
||||
const target = wrapper.findAllComponents({ name: 'ElSelect' }).find((item) => item.attributes('data-testid') === 'xfa-split-target-field');
|
||||
const labels = (target?.findAllComponents({ name: 'ElOption' }) || []).map((option) => String(option.props('label') || ''));
|
||||
expect(labels.join(' ')).toContain('unit_price');
|
||||
expect(labels.join(' ')).not.toContain('price_unit');
|
||||
emitElSelect(wrapper, 'xfa-split-target-field', 'unit-price-id');
|
||||
|
||||
emitted = wrapper.emitted('update:split-rules');
|
||||
let rule = (emitted?.[emitted.length - 1]?.[0] as typeof baseDefinition.split_rules)?.[0]?.rules[0];
|
||||
@@ -313,7 +357,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
target_field_code: 'unit_price',
|
||||
});
|
||||
|
||||
await wrapper.get('[data-testid="xfa-split-handling"]').setValue('evidence_only');
|
||||
emitElSelect(wrapper, 'xfa-split-handling', 'evidence_only');
|
||||
emitted = wrapper.emitted('update:split-rules');
|
||||
rule = (emitted?.[emitted.length - 1]?.[0] as typeof baseDefinition.split_rules)?.[0]?.rules[0];
|
||||
expect(rule?.segment).toMatchObject({ handling: 'evidence_only' });
|
||||
@@ -367,7 +411,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
});
|
||||
await exposedActions(wrapper).runPreview();
|
||||
await flushPromises();
|
||||
exposedActions(wrapper).confirmRules();
|
||||
await exposedActions(wrapper).confirmRules();
|
||||
expect(messageError).toHaveBeenCalledWith('诊断阻断');
|
||||
const confirmed = wrapper.emitted('update:split-rules')?.some((entry) => {
|
||||
const rules = entry[0] as typeof baseDefinition.split_rules;
|
||||
@@ -420,7 +464,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
await exposedActions(wrapper).runPreview();
|
||||
await flushPromises();
|
||||
expect(wrapper.text()).not.toContain('line_match_candidates');
|
||||
exposedActions(wrapper).confirmRules();
|
||||
await exposedActions(wrapper).confirmRules();
|
||||
expect(messageError).not.toHaveBeenCalledWith('诊断阻断');
|
||||
const confirmed = wrapper.emitted('confirmed');
|
||||
expect(confirmed?.[0]?.[1]).toMatchObject({ 'path-matnr': 'tok-info-diag' });
|
||||
@@ -455,7 +499,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
});
|
||||
await exposedActions(wrapper).runPreview();
|
||||
await flushPromises();
|
||||
exposedActions(wrapper).confirmRules();
|
||||
await exposedActions(wrapper).confirmRules();
|
||||
|
||||
expect(messageError).toHaveBeenCalledWith('目标必填');
|
||||
expect(wrapper.emitted('confirmed')).toBeUndefined();
|
||||
@@ -465,11 +509,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
const wrapper = mountPanel({
|
||||
definition: { ...baseDefinition, split_rules: [makePipelineRuleSet()] },
|
||||
});
|
||||
const extractionSelect = wrapper.findAll('select').find((select) => (
|
||||
select.element.closest('label')?.textContent?.includes('提取方式')
|
||||
));
|
||||
expect(extractionSelect).toBeTruthy();
|
||||
await extractionSelect!.setValue('select_line_range');
|
||||
emitElSelectInLabel(wrapper, '提取方式', 'select_line_range');
|
||||
const emitted = wrapper.emitted('update:split-rules');
|
||||
const last = emitted?.[emitted.length - 1]?.[0] as typeof baseDefinition.split_rules;
|
||||
const range = last?.[0]?.rules?.[0]?.stages?.find((stage) => stage.type === 'select_line_range');
|
||||
@@ -565,7 +605,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
});
|
||||
await exposedActions(wrapper).runPreview();
|
||||
await flushPromises();
|
||||
exposedActions(wrapper).confirmRules();
|
||||
await exposedActions(wrapper).confirmRules();
|
||||
|
||||
const confirmed = wrapper.emitted('confirmed');
|
||||
const rules = confirmed?.[0]?.[0] as typeof baseDefinition.split_rules;
|
||||
@@ -652,9 +692,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
});
|
||||
const advancedButton = wrapper.findAll('button').find((btn) => btn.text().includes('高级处理'));
|
||||
await advancedButton!.trigger('click');
|
||||
const addAdvanced = wrapper.find('.xfa-split__add-stage-select');
|
||||
await addAdvanced.setValue('extract_prefix');
|
||||
await addAdvanced.trigger('change');
|
||||
emitAddStage(wrapper, 'extract_prefix');
|
||||
const emitted = wrapper.emitted('update:split-rules');
|
||||
const last = emitted?.[emitted.length - 1]?.[0] as typeof baseDefinition.split_rules;
|
||||
expect(last?.[0]?.rules[0]?.stages.map((stage) => stage.type)).toEqual([
|
||||
@@ -674,9 +712,7 @@ describe('XfaSplitRulePanel', () => {
|
||||
});
|
||||
const advancedButton = wrapper.findAll('button').find((btn) => btn.text().includes('高级处理'));
|
||||
await advancedButton!.trigger('click');
|
||||
const addAdvanced = wrapper.find('.xfa-split__add-stage-select');
|
||||
await addAdvanced.setValue('extract_prefix');
|
||||
await addAdvanced.trigger('change');
|
||||
emitAddStage(wrapper, 'extract_prefix');
|
||||
const emitted = wrapper.emitted('update:split-rules');
|
||||
const last = emitted?.[emitted.length - 1]?.[0] as typeof baseDefinition.split_rules;
|
||||
expect(last?.[0]?.rules[0]?.stages.map((stage) => stage.type)).toEqual([
|
||||
@@ -795,10 +831,10 @@ describe('XfaSplitRulePanel', () => {
|
||||
expect(wrapper.findAll('input').some((input) => input.element.value === 'MPN')).toBe(true);
|
||||
});
|
||||
|
||||
it('ignores exposed edit actions when canEdit is false', () => {
|
||||
it('ignores exposed edit actions when canEdit is false', async () => {
|
||||
const wrapper = mountPanel({ canEdit: false });
|
||||
exposedActions(wrapper).addRule();
|
||||
exposedActions(wrapper).confirmRules();
|
||||
await exposedActions(wrapper).confirmRules();
|
||||
expect(wrapper.emitted('update:split-rules')).toBeUndefined();
|
||||
expect(wrapper.emitted('confirmed')).toBeUndefined();
|
||||
});
|
||||
|
||||
+206
-168
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaSplitRulePanel.vue
|
||||
用途:XFA 字段拆分规则编辑——matcher 优先(prefix/regex/position),兼容历史 stages[] 投影。
|
||||
依赖:shipping-order-document-profile API、vue-i18n、Schema 字段列表。
|
||||
依赖:element-plus、shipping-order-document-profile API、vue-i18n、Schema 字段列表。
|
||||
逻辑:编辑 definition.split_rules;新增/改提取方式同步写入 matcher;stages 仅保留编辑态;
|
||||
预览和确认统一投影为正式 matcher DTO,确认前须校验同一正式 DTO 哈希;
|
||||
连续多行提取投影为 position.line_end + join_with,引擎合并多行文本;
|
||||
@@ -11,6 +11,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElCheckbox, ElInput, ElMessageBox, ElOption, ElSelect, ElTable, ElTableColumn } from 'element-plus';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { createRandomUuid } from '@/shared/utils/id';
|
||||
@@ -40,6 +41,7 @@ type XfaSplitRulePatch = Omit<Partial<XfaSplitRule>, 'segment' | 'stages' | 'mat
|
||||
type XfaSplitStagePatch = Partial<XfaSplitStage>;
|
||||
type ExtractionMode = 'select_line' | 'select_line_range' | 'extract_prefix' | 'regex_capture' | 'substring';
|
||||
type XfaSplitPreviewDiagnostic = XfaSplitPreviewResult['diagnostics'][number];
|
||||
type PreviewSegmentRow = NonNullable<XfaSplitPreviewResult['segments']>[number];
|
||||
|
||||
/**
|
||||
* 与后端 xfa_profile_extraction._SPLIT_INFORMATIONAL_DIAGNOSTIC_CODES 对齐。
|
||||
@@ -383,7 +385,7 @@ async function runPreview(): Promise<void> {
|
||||
* 核心逻辑:确认事件携带完整规则数组与 preview_token,由父页面保存时交服务端校验;
|
||||
* line_match_candidates 与未匹配行(evidence_only)不视为阻断。
|
||||
*/
|
||||
function confirmRules(): void {
|
||||
async function confirmRules(): Promise<void> {
|
||||
if (!activeRuleSet.value || isReadonly.value) return;
|
||||
if (activeRuleSet.value.rules.some((rule) => (
|
||||
rule.segment.handling === 'mapped'
|
||||
@@ -409,7 +411,15 @@ function confirmRules(): void {
|
||||
segments: segmentCount,
|
||||
diagnostics: diagCount,
|
||||
});
|
||||
if (!window.confirm(summary)) return;
|
||||
try {
|
||||
await ElMessageBox.confirm(summary, t('admin.shippingOrderProfiles.xfaSplit.confirm'), {
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
type: 'warning',
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const confirmedRuleSet = {
|
||||
...(toFormalRuleSet(activeRuleSet.value) || {}),
|
||||
source: 'user',
|
||||
@@ -464,7 +474,20 @@ onMounted(() => {
|
||||
/**
|
||||
* 删除指定 rule_id 的规则并重排 order。
|
||||
*/
|
||||
function deleteRule(ruleId: string): void {
|
||||
async function deleteRule(ruleId: string): Promise<void> {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.shippingOrderProfiles.xfaSplit.deleteConfirm'),
|
||||
t('common.deleteDialog.defaultTitle'),
|
||||
{
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
type: 'warning',
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
applyRuleSetChange((current) => ({
|
||||
...current,
|
||||
rules: normalizeRuleOrders(current.rules.filter((item) => item.rule_id !== ruleId)),
|
||||
@@ -870,6 +893,28 @@ watch(() => props.selectedPathId, () => {
|
||||
invalidatePreview();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 追加高级处理步骤。空值表示未选择,不写入规则。
|
||||
* @param ruleId - 规则 id
|
||||
* @param value - 步骤类型;清空为 undefined
|
||||
*/
|
||||
function onAddAdvancedStage(ruleId: string, value: string | undefined): void {
|
||||
if (!value) return;
|
||||
addAdvancedStage(ruleId, value as XfaSplitStageType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换高级步骤类型。空值不改规则。
|
||||
* @param ruleId - 规则 id
|
||||
* @param stageId - 步骤 id
|
||||
* @param value - 步骤类型;Element 清空时可能不是字符串
|
||||
*/
|
||||
function onStageTypeChange(ruleId: string, stageId: string, value: string | number | undefined): void {
|
||||
if (!value) return;
|
||||
changeStageType(ruleId, stageId, String(value) as XfaSplitStageType);
|
||||
}
|
||||
|
||||
defineExpose({ addRule, runPreview, confirmRules });
|
||||
|
||||
watch(activeRuleSet, (current, previous) => {
|
||||
@@ -902,43 +947,43 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<legend>{{ t('admin.shippingOrderProfiles.xfaSplit.ruleSetSettings') }}</legend>
|
||||
<label class="xfa-split__policy">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.unmatchedPolicy') }}
|
||||
<select
|
||||
<ElSelect
|
||||
:disabled="isReadonly"
|
||||
:value="activeRuleSet.unmatched_line_policy || 'evidence_only'"
|
||||
@change="updateUnmatchedPolicy(($event.target as HTMLSelectElement).value as 'evidence_only' | 'needs_review')"
|
||||
:model-value="activeRuleSet.unmatched_line_policy || 'evidence_only'"
|
||||
@update:model-value="updateUnmatchedPolicy($event)"
|
||||
>
|
||||
<option value="evidence_only">{{ t('admin.shippingOrderProfiles.xfaSplit.evidenceOnly') }}</option>
|
||||
<option value="needs_review">{{ t('admin.shippingOrderProfiles.xfaSplit.needsReview') }}</option>
|
||||
</select>
|
||||
<ElOption value="evidence_only" :label="t('admin.shippingOrderProfiles.xfaSplit.evidenceOnly')" />
|
||||
<ElOption value="needs_review" :label="t('admin.shippingOrderProfiles.xfaSplit.needsReview')" />
|
||||
</ElSelect>
|
||||
</label>
|
||||
|
||||
<div class="xfa-split__normalization">
|
||||
<span>{{ t('admin.shippingOrderProfiles.xfaSplit.normalization') }}</span>
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
<ElCheckbox
|
||||
|
||||
:disabled="isReadonly"
|
||||
:checked="activeRuleSet.normalization?.trim ?? true"
|
||||
@change="updateNormalization({ trim: ($event.target as HTMLInputElement).checked })"
|
||||
:model-value="activeRuleSet.normalization?.trim ?? true"
|
||||
@update:model-value="updateNormalization({ trim: $event === true })"
|
||||
/>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageTrim') }}
|
||||
</label>
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
<ElCheckbox
|
||||
|
||||
:disabled="isReadonly"
|
||||
:checked="activeRuleSet.normalization?.remove_empty_lines ?? true"
|
||||
@change="updateNormalization({ remove_empty_lines: ($event.target as HTMLInputElement).checked })"
|
||||
:model-value="activeRuleSet.normalization?.remove_empty_lines ?? true"
|
||||
@update:model-value="updateNormalization({ remove_empty_lines: $event === true })"
|
||||
/>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageRemoveEmptyLines') }}
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.lineBreaks') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="lineBreaksToDisplay(activeRuleSet.normalization?.line_breaks)"
|
||||
:placeholder="t('admin.shippingOrderProfiles.xfaSplit.lineBreaksPlaceholder')"
|
||||
@change="updateNormalization({ line_breaks: parseLineBreaks(($event.target as HTMLInputElement).value) })"
|
||||
@update:model-value="updateNormalization({ line_breaks: parseLineBreaks(String($event ?? '')) })"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
@@ -955,26 +1000,23 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<p v-if="preview.full_values_revealed">{{ t('admin.shippingOrderProfiles.xfaSplit.fullValuesRevealed') }}</p>
|
||||
|
||||
<h5>{{ t('admin.shippingOrderProfiles.xfaSplit.previewSegments') }}</h5>
|
||||
<table v-if="preview.segments?.length" class="xfa-split__table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ t('admin.shippingOrderProfiles.xfaSplit.lineIndex') }}</th>
|
||||
<th>{{ t('admin.shippingOrderProfiles.xfaSplit.segmentCode') }}</th>
|
||||
<th>{{ t('admin.shippingOrderProfiles.xfaSplit.stageType') }}</th>
|
||||
<th>{{ t('admin.shippingOrderProfiles.xfaSplit.previewValue') }}</th>
|
||||
<th>{{ t('admin.shippingOrderProfiles.xfaSplit.previewRuleStatus') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="seg in preview.segments" :key="seg.segment_id">
|
||||
<td>{{ previewLineLabel(seg.line_no, seg.line_end_no) }}</td>
|
||||
<td>{{ seg.segment_code }}</td>
|
||||
<td>{{ seg.matcher_type }} <small>({{ seg.rule_id }})</small></td>
|
||||
<td>{{ seg.normalized_text || seg.raw_text }}</td>
|
||||
<td>{{ seg.status }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<ElTable v-if="preview.segments?.length" :data="preview.segments" row-key="segment_id" class="xfa-split__table">
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.xfaSplit.lineIndex')" min-width="90">
|
||||
<template #default="{ row }">{{ previewLineLabel((row as PreviewSegmentRow).line_no, (row as PreviewSegmentRow).line_end_no) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.xfaSplit.segmentCode')" min-width="120">
|
||||
<template #default="{ row }">{{ (row as PreviewSegmentRow).segment_code }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.xfaSplit.stageType')" min-width="140">
|
||||
<template #default="{ row }">{{ (row as PreviewSegmentRow).matcher_type }} <small>({{ (row as PreviewSegmentRow).rule_id }})</small></template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.xfaSplit.previewValue')" min-width="160">
|
||||
<template #default="{ row }">{{ (row as PreviewSegmentRow).normalized_text || (row as PreviewSegmentRow).raw_text }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderProfiles.xfaSplit.previewRuleStatus')" min-width="100">
|
||||
<template #default="{ row }">{{ (row as PreviewSegmentRow).status }}</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<p v-else class="hint">{{ t('admin.shippingOrderProfiles.xfaSplit.previewNoSegments') }}</p>
|
||||
|
||||
<h5 v-if="blockingDiagnostics.length">{{ t('admin.shippingOrderProfiles.xfaSplit.diagnostics') }}</h5>
|
||||
@@ -989,36 +1031,36 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<ul class="xfa-split__rules">
|
||||
<li v-for="(rule, index) in sortedRules" :key="rule.rule_id">
|
||||
<div class="xfa-split__rule-toolbar">
|
||||
<button type="button" class="xfa-split__rule-title" @click="toggleRule(rule.rule_id)">
|
||||
<ElButton class="xfa-split__rule-title" @click="toggleRule(rule.rule_id)">
|
||||
<span class="rule-chevron">{{ collapsedRules.has(rule.rule_id) ? '›' : '⌄' }}</span>
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaSplit.ruleLabel', { index: index + 1 }) }}</strong>
|
||||
<span class="rule-summary">{{ rule.segment.display_name || rule.segment.segment_code || t('admin.shippingOrderProfiles.xfaSplit.unnamedRule') }}</span>
|
||||
</button>
|
||||
</ElButton>
|
||||
<div class="xfa-split__rule-actions">
|
||||
<button type="button" :disabled="isReadonly || index === 0" @click="moveRule(rule.rule_id, -1)">
|
||||
<ElButton :disabled="isReadonly || index === 0" @click="moveRule(rule.rule_id, -1)">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.moveUp') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
</ElButton>
|
||||
<ElButton
|
||||
|
||||
:disabled="isReadonly || index === sortedRules.length - 1"
|
||||
@click="moveRule(rule.rule_id, 1)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.moveDown') }}
|
||||
</button>
|
||||
<button type="button" class="danger" :disabled="isReadonly" @click="deleteRule(rule.rule_id)">
|
||||
</ElButton>
|
||||
<ElButton link type="danger" :disabled="isReadonly" @click="deleteRule(rule.rule_id)">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.deleteRule') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="!collapsedRules.has(rule.rule_id)" class="xfa-split__rule-detail">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.segmentCode') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.segment_code"
|
||||
:class="{ 'xfa-split__invalid': segmentCodeHint(rule.segment.segment_code) }"
|
||||
@input="updateRule(rule.rule_id, { segment: { segment_code: ($event.target as HTMLInputElement).value } })"
|
||||
@update:model-value="updateRule(rule.rule_id, { segment: { segment_code: String($event ?? '') } })"
|
||||
/>
|
||||
<small v-if="segmentCodeHint(rule.segment.segment_code)" class="xfa-split__hint-error">
|
||||
{{ segmentCodeHint(rule.segment.segment_code) }}
|
||||
@@ -1026,11 +1068,11 @@ watch(activeRuleSet, (current, previous) => {
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.displayName') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.display_name"
|
||||
:class="{ 'xfa-split__invalid': displayNameHint(rule.segment.display_name) }"
|
||||
@input="updateRule(rule.rule_id, { segment: { display_name: ($event.target as HTMLInputElement).value } })"
|
||||
@update:model-value="updateRule(rule.rule_id, { segment: { display_name: String($event ?? '') } })"
|
||||
/>
|
||||
<small v-if="displayNameHint(rule.segment.display_name)" class="xfa-split__hint-error">
|
||||
{{ displayNameHint(rule.segment.display_name) }}
|
||||
@@ -1038,38 +1080,35 @@ watch(activeRuleSet, (current, previous) => {
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.note') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.note || ''"
|
||||
@input="updateRule(rule.rule_id, { segment: { note: ($event.target as HTMLInputElement).value || null } })"
|
||||
@update:model-value="updateRule(rule.rule_id, { segment: { note: String($event ?? '') || null } })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.handling') }}
|
||||
<select
|
||||
<ElSelect
|
||||
data-testid="xfa-split-handling"
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.handling"
|
||||
@change="updateSegmentHandling(rule.rule_id, ($event.target as HTMLSelectElement).value as XfaSplitSegment['handling'])"
|
||||
:model-value="rule.segment.handling"
|
||||
@update:model-value="updateSegmentHandling(rule.rule_id, $event)"
|
||||
>
|
||||
<option value="evidence_only">{{ t('admin.shippingOrderProfiles.xfaSplit.evidenceOnly') }}</option>
|
||||
<option value="mapped">{{ t('admin.shippingOrderProfiles.xfaSplit.mapped') }}</option>
|
||||
</select>
|
||||
<ElOption value="evidence_only" :label="t('admin.shippingOrderProfiles.xfaSplit.evidenceOnly')" />
|
||||
<ElOption value="mapped" :label="t('admin.shippingOrderProfiles.xfaSplit.mapped')" />
|
||||
</ElSelect>
|
||||
</label>
|
||||
<label v-if="rule.segment.handling === 'mapped'">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.targetField') }}
|
||||
<select
|
||||
<ElSelect
|
||||
data-testid="xfa-split-target-field"
|
||||
:disabled="isReadonly"
|
||||
:value="rule.segment.target_field_id || ''"
|
||||
:model-value="rule.segment.target_field_id || undefined"
|
||||
:class="{ 'xfa-split__invalid': !rule.segment.target_field_id }"
|
||||
@change="updateSegmentTarget(rule.rule_id, ($event.target as HTMLSelectElement).value)"
|
||||
>
|
||||
<option value="">{{ t('admin.shippingOrderProfiles.xfaSplit.selectField') }}</option>
|
||||
<option v-for="field in splitTargetFields" :key="field.field_id" :value="field.field_id">
|
||||
{{ field.display_name }} ({{ field.field_code }})
|
||||
</option>
|
||||
</select>
|
||||
@update:model-value="updateSegmentTarget(rule.rule_id, $event)"
|
||||
:placeholder="t('admin.shippingOrderProfiles.xfaSplit.selectField')" clearable>
|
||||
<ElOption v-for="field in splitTargetFields" :key="field.field_id" :value="field.field_id" :label="`${field.display_name} (${field.field_code})`" />
|
||||
</ElSelect>
|
||||
<small v-if="!rule.segment.target_field_id" class="xfa-split__hint-error">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.validationMappedTarget') }}
|
||||
</small>
|
||||
@@ -1078,89 +1117,89 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<div class="xfa-split__extraction">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.extractionMode') }}
|
||||
<select
|
||||
<ElSelect
|
||||
:disabled="isReadonly"
|
||||
:value="extractionMode(rule)"
|
||||
@change="changeExtractionMode(rule, ($event.target as HTMLSelectElement).value as ExtractionMode)"
|
||||
:model-value="extractionMode(rule)"
|
||||
@update:model-value="changeExtractionMode(rule, $event)"
|
||||
>
|
||||
<option value="select_line">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByLine') }}</option>
|
||||
<option value="select_line_range">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByLineRange') }}</option>
|
||||
<option value="extract_prefix">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByLabel') }}</option>
|
||||
<option value="regex_capture">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex') }}</option>
|
||||
<option value="substring">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring') }}</option>
|
||||
</select>
|
||||
<ElOption value="select_line" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByLine')" />
|
||||
<ElOption value="select_line_range" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByLineRange')" />
|
||||
<ElOption value="extract_prefix" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByLabel')" />
|
||||
<ElOption value="regex_capture" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex')" />
|
||||
<ElOption value="substring" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring')" />
|
||||
</ElSelect>
|
||||
</label>
|
||||
|
||||
<label v-if="extractionMode(rule) === 'select_line'">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.extractLineNumber') }}
|
||||
<input
|
||||
type="number"
|
||||
<ElInput
|
||||
|
||||
min="1"
|
||||
:disabled="isReadonly"
|
||||
:value="extractionStage(rule).line_index ?? (rule.order ?? 1)"
|
||||
@input="updateExtraction(rule, { line_index: Number(($event.target as HTMLInputElement).value) || 1 })"
|
||||
@update:model-value="updateExtraction(rule, { line_index: Number($event) || 1 })"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<template v-if="extractionMode(rule) === 'select_line_range'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.extractStartLine') }}
|
||||
<input
|
||||
type="number"
|
||||
<ElInput
|
||||
|
||||
min="1"
|
||||
:disabled="isReadonly"
|
||||
:value="extractionStage(rule).line_start ?? (rule.order ?? 1)"
|
||||
@input="updateExtraction(rule, { line_start: Number(($event.target as HTMLInputElement).value) || 1 })"
|
||||
@update:model-value="updateExtraction(rule, { line_start: Number($event) || 1 })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.extractEndLine') }}
|
||||
<input
|
||||
type="number"
|
||||
<ElInput
|
||||
|
||||
min="1"
|
||||
:disabled="isReadonly"
|
||||
:value="extractionStage(rule).line_end ?? (rule.order ?? 1) + 1"
|
||||
@input="updateExtraction(rule, { line_end: Number(($event.target as HTMLInputElement).value) || 1 })"
|
||||
@update:model-value="updateExtraction(rule, { line_end: Number($event) || 1 })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.joinLinesWith') }}
|
||||
<select
|
||||
<ElSelect
|
||||
:disabled="isReadonly"
|
||||
:value="extractionStage(rule).join_with || 'newline'"
|
||||
@change="updateExtraction(rule, { join_with: ($event.target as HTMLSelectElement).value as 'newline' | 'space' | 'comma' })"
|
||||
:model-value="extractionStage(rule).join_with || 'newline'"
|
||||
@update:model-value="updateExtraction(rule, { join_with: $event })"
|
||||
>
|
||||
<option value="newline">{{ t('admin.shippingOrderProfiles.xfaSplit.joinWithNewline') }}</option>
|
||||
<option value="space">{{ t('admin.shippingOrderProfiles.xfaSplit.joinWithSpace') }}</option>
|
||||
<option value="comma">{{ t('admin.shippingOrderProfiles.xfaSplit.joinWithComma') }}</option>
|
||||
</select>
|
||||
<ElOption value="newline" :label="t('admin.shippingOrderProfiles.xfaSplit.joinWithNewline')" />
|
||||
<ElOption value="space" :label="t('admin.shippingOrderProfiles.xfaSplit.joinWithSpace')" />
|
||||
<ElOption value="comma" :label="t('admin.shippingOrderProfiles.xfaSplit.joinWithComma')" />
|
||||
</ElSelect>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<template v-if="extractionMode(rule) === 'extract_prefix'">
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.prefix') }}
|
||||
<input :disabled="isReadonly" :value="extractionStage(rule).value || ''" @input="updateExtraction(rule, { value: ($event.target as HTMLInputElement).value })" />
|
||||
<ElInput :disabled="isReadonly" :value="extractionStage(rule).value || ''" @update:model-value="updateExtraction(rule, { value: String($event ?? '') })" />
|
||||
</label>
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.separators') }}
|
||||
<input :disabled="isReadonly" :value="separatorsToString(extractionStage(rule).separators)" @input="updateExtraction(rule, { separators: parseSeparators(($event.target as HTMLInputElement).value) })" />
|
||||
<ElInput :disabled="isReadonly" :value="separatorsToString(extractionStage(rule).separators)" @update:model-value="updateExtraction(rule, { separators: parseSeparators(String($event ?? '')) })" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<template v-if="extractionMode(rule) === 'regex_capture'">
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.regex') }}
|
||||
<input :disabled="isReadonly" :value="extractionStage(rule).pattern || ''" @input="updateExtraction(rule, { pattern: ($event.target as HTMLInputElement).value })" />
|
||||
<ElInput :disabled="isReadonly" :value="extractionStage(rule).pattern || ''" @update:model-value="updateExtraction(rule, { pattern: String($event ?? '') })" />
|
||||
</label>
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.captureGroup') }}
|
||||
<input type="number" min="0" :disabled="isReadonly" :value="extractionStage(rule).capture_group ?? 1" @input="updateExtraction(rule, { capture_group: Number(($event.target as HTMLInputElement).value) || 0 })" />
|
||||
<ElInput min="0" :disabled="isReadonly" :value="extractionStage(rule).capture_group ?? 1" @update:model-value="updateExtraction(rule, { capture_group: Number($event) || 0 })" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
<template v-if="extractionMode(rule) === 'substring'">
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.substringStart') }}
|
||||
<input type="number" min="0" :disabled="isReadonly" :value="extractionStage(rule).start ?? 0" @input="updateExtraction(rule, { start: Number(($event.target as HTMLInputElement).value) || 0 })" />
|
||||
<ElInput min="0" :disabled="isReadonly" :value="extractionStage(rule).start ?? 0" @update:model-value="updateExtraction(rule, { start: Number($event) || 0 })" />
|
||||
</label>
|
||||
<label>{{ t('admin.shippingOrderProfiles.xfaSplit.substringEnd') }}
|
||||
<input type="number" min="0" :disabled="isReadonly" :value="extractionStage(rule).end ?? ''" @input="updateExtraction(rule, { end: ($event.target as HTMLInputElement).value === '' ? null : Number(($event.target as HTMLInputElement).value) })" />
|
||||
<ElInput min="0" :disabled="isReadonly" :value="extractionStage(rule).end ?? ''" @update:model-value="updateExtraction(rule, { end: ($event === '' || $event == null) ? null : Number($event) })" />
|
||||
</label>
|
||||
</template>
|
||||
|
||||
@@ -1171,27 +1210,26 @@ watch(activeRuleSet, (current, previous) => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="xfa-split__advanced-toggle" @click="toggleAdvanced(rule.rule_id)">
|
||||
<ElButton class="xfa-split__advanced-toggle" @click="toggleAdvanced(rule.rule_id)">
|
||||
{{ advancedRules.has(rule.rule_id)
|
||||
? t('admin.shippingOrderProfiles.xfaSplit.hideAdvanced')
|
||||
: t('admin.shippingOrderProfiles.xfaSplit.showAdvanced') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
|
||||
<div v-if="advancedRules.has(rule.rule_id)" class="xfa-split__stages">
|
||||
<div class="xfa-split__stages-header">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaSplit.advancedProcessing') }}</strong>
|
||||
<select
|
||||
<ElSelect
|
||||
:disabled="isReadonly"
|
||||
class="xfa-split__add-stage-select"
|
||||
@change="(e) => { addAdvancedStage(rule.rule_id, (e.target as HTMLSelectElement).value as XfaSplitStageType); (e.target as HTMLSelectElement).value = ''; }"
|
||||
>
|
||||
<option value="">{{ t('admin.shippingOrderProfiles.xfaSplit.addAdvancedStep') }}</option>
|
||||
<option value="extract_prefix">{{ t('admin.shippingOrderProfiles.xfaSplit.advancedExtractAfterLabel') }}</option>
|
||||
<option value="regex_capture">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex') }}</option>
|
||||
<option value="substring">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring') }}</option>
|
||||
<option value="replace">{{ stageTypeLabel('replace') }}</option>
|
||||
<option value="normalize">{{ stageTypeLabel('normalize') }}</option>
|
||||
</select>
|
||||
@update:model-value="onAddAdvancedStage(rule.rule_id, $event)"
|
||||
:placeholder="t('admin.shippingOrderProfiles.xfaSplit.addAdvancedStep')" clearable>
|
||||
<ElOption value="extract_prefix" :label="t('admin.shippingOrderProfiles.xfaSplit.advancedExtractAfterLabel')" />
|
||||
<ElOption value="regex_capture" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex')" />
|
||||
<ElOption value="substring" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring')" />
|
||||
<ElOption value="replace" :label="stageTypeLabel('replace')" />
|
||||
<ElOption value="normalize" :label="stageTypeLabel('normalize')" />
|
||||
</ElSelect>
|
||||
</div>
|
||||
|
||||
<ul class="xfa-split__stage-list">
|
||||
@@ -1199,64 +1237,64 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<div class="xfa-split__stage-toolbar">
|
||||
<span>{{ stageTypeLabel(stage.type) }}</span>
|
||||
<div class="xfa-split__rule-actions">
|
||||
<button
|
||||
type="button"
|
||||
<ElButton
|
||||
|
||||
:disabled="isReadonly || stageIndex === 0"
|
||||
@click="moveStage(rule.rule_id, stage.stage_id, -1)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.moveUp') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
</ElButton>
|
||||
<ElButton
|
||||
|
||||
:disabled="isReadonly || stageIndex === advancedStages(rule).length - 1"
|
||||
@click="moveStage(rule.rule_id, stage.stage_id, 1)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.moveDown') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="danger"
|
||||
</ElButton>
|
||||
<ElButton
|
||||
|
||||
link type="danger"
|
||||
:disabled="isReadonly || (rule.stages || []).length <= 1"
|
||||
@click="deleteStage(rule.rule_id, stage.stage_id)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.deleteStage') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageType') }}
|
||||
<select
|
||||
<ElSelect
|
||||
:disabled="isReadonly"
|
||||
:value="stage.type"
|
||||
@change="changeStageType(rule.rule_id, stage.stage_id, ($event.target as HTMLSelectElement).value as XfaSplitStageType)"
|
||||
:model-value="stage.type"
|
||||
@update:model-value="onStageTypeChange(rule.rule_id, stage.stage_id, $event)"
|
||||
>
|
||||
<option value="extract_prefix">{{ t('admin.shippingOrderProfiles.xfaSplit.advancedExtractAfterLabel') }}</option>
|
||||
<option value="regex_capture">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex') }}</option>
|
||||
<option value="substring">{{ t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring') }}</option>
|
||||
<option value="replace">{{ stageTypeLabel('replace') }}</option>
|
||||
<option value="normalize">{{ stageTypeLabel('normalize') }}</option>
|
||||
</select>
|
||||
<ElOption value="extract_prefix" :label="t('admin.shippingOrderProfiles.xfaSplit.advancedExtractAfterLabel')" />
|
||||
<ElOption value="regex_capture" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionByRegex')" />
|
||||
<ElOption value="substring" :label="t('admin.shippingOrderProfiles.xfaSplit.extractionBySubstring')" />
|
||||
<ElOption value="replace" :label="stageTypeLabel('replace')" />
|
||||
<ElOption value="normalize" :label="stageTypeLabel('normalize')" />
|
||||
</ElSelect>
|
||||
</label>
|
||||
|
||||
<small v-if="stageHint(stage)" class="xfa-split__hint-error">{{ stageHint(stage) }}</small>
|
||||
|
||||
<template v-if="stage.type === 'split_lines' || stage.type === 'normalize'">
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
<ElCheckbox
|
||||
|
||||
:disabled="isReadonly"
|
||||
:checked="stage.trim ?? true"
|
||||
@change="updateStage(rule.rule_id, stage.stage_id, { trim: ($event.target as HTMLInputElement).checked })"
|
||||
:model-value="stage.trim ?? true"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { trim: $event === true })"
|
||||
/>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageTrim') }}
|
||||
</label>
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
<ElCheckbox
|
||||
|
||||
:disabled="isReadonly"
|
||||
:checked="stage.remove_empty_lines ?? true"
|
||||
@change="updateStage(rule.rule_id, stage.stage_id, { remove_empty_lines: ($event.target as HTMLInputElement).checked })"
|
||||
:model-value="stage.remove_empty_lines ?? true"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { remove_empty_lines: $event === true })"
|
||||
/>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.stageRemoveEmptyLines') }}
|
||||
</label>
|
||||
@@ -1264,48 +1302,48 @@ watch(activeRuleSet, (current, previous) => {
|
||||
|
||||
<label v-if="stage.type === 'split_lines'">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.lineBreaks') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="lineBreaksToDisplay(stage.line_breaks)"
|
||||
:placeholder="t('admin.shippingOrderProfiles.xfaSplit.lineBreaksPlaceholder')"
|
||||
@change="updateStage(rule.rule_id, stage.stage_id, { line_breaks: parseLineBreaks(($event.target as HTMLInputElement).value) })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { line_breaks: parseLineBreaks(String($event ?? '')) })"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label v-if="stage.type === 'select_line'">
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.lineIndex') }}
|
||||
<input
|
||||
type="number"
|
||||
<ElInput
|
||||
|
||||
min="1"
|
||||
:disabled="isReadonly"
|
||||
:value="stage.line_index ?? 1"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { line_index: Number(($event.target as HTMLInputElement).value) || 1 })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { line_index: Number($event) || 1 })"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<template v-if="stage.type === 'extract_prefix'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.prefix') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="stage.value || ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { value: ($event.target as HTMLInputElement).value })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { value: String($event ?? '') })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.separators') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="separatorsToString(stage.separators)"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { separators: parseSeparators(($event.target as HTMLInputElement).value) })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { separators: parseSeparators(String($event ?? '')) })"
|
||||
/>
|
||||
</label>
|
||||
<label class="xfa-split__checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
<ElCheckbox
|
||||
|
||||
:disabled="isReadonly"
|
||||
:checked="stage.case_sensitive ?? false"
|
||||
@change="updateStage(rule.rule_id, stage.stage_id, { case_sensitive: ($event.target as HTMLInputElement).checked })"
|
||||
:model-value="stage.case_sensitive ?? false"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { case_sensitive: $event === true })"
|
||||
/>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.caseSensitive') }}
|
||||
</label>
|
||||
@@ -1314,20 +1352,20 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<template v-if="stage.type === 'regex_capture'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.regex') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="stage.pattern || ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { pattern: ($event.target as HTMLInputElement).value })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { pattern: String($event ?? '') })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.captureGroup') }}
|
||||
<input
|
||||
type="number"
|
||||
<ElInput
|
||||
|
||||
min="0"
|
||||
:disabled="isReadonly"
|
||||
:value="stage.capture_group ?? 1"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { capture_group: Number(($event.target as HTMLInputElement).value) || 0 })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { capture_group: Number($event) || 0 })"
|
||||
/>
|
||||
</label>
|
||||
</template>
|
||||
@@ -1335,18 +1373,18 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<template v-if="stage.type === 'replace'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.find') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="stage.find || ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { find: ($event.target as HTMLInputElement).value })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { find: String($event ?? '') })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.replaceWith') }}
|
||||
<input
|
||||
<ElInput
|
||||
:disabled="isReadonly"
|
||||
:value="stage.replace_with || ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { replace_with: ($event.target as HTMLInputElement).value })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { replace_with: String($event ?? '') })"
|
||||
/>
|
||||
</label>
|
||||
</template>
|
||||
@@ -1354,22 +1392,22 @@ watch(activeRuleSet, (current, previous) => {
|
||||
<template v-if="stage.type === 'substring'">
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.substringStart') }}
|
||||
<input
|
||||
type="number"
|
||||
<ElInput
|
||||
|
||||
min="0"
|
||||
:disabled="isReadonly"
|
||||
:value="stage.start ?? 0"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { start: Number(($event.target as HTMLInputElement).value) || 0 })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { start: Number($event) || 0 })"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
{{ t('admin.shippingOrderProfiles.xfaSplit.substringEnd') }}
|
||||
<input
|
||||
type="number"
|
||||
<ElInput
|
||||
|
||||
min="0"
|
||||
:disabled="isReadonly"
|
||||
:value="stage.end ?? ''"
|
||||
@input="updateStage(rule.rule_id, stage.stage_id, { end: ($event.target as HTMLInputElement).value === '' ? null : Number(($event.target as HTMLInputElement).value) })"
|
||||
@update:model-value="updateStage(rule.rule_id, stage.stage_id, { end: ($event === '' || $event == null) ? null : Number($event) })"
|
||||
/>
|
||||
</label>
|
||||
</template>
|
||||
|
||||
+446
-259
@@ -1,13 +1,39 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-extraction-runs/ShippingOrderExtractionRunsPage.vue
|
||||
用途:管理员订单识别运行诊断——健康聚合、积压/取消中筛选、只读详情与活跃 Run 取消。
|
||||
依赖:admin.api 脱敏诊断/健康/取消 DTO、Vue Composition API、Vue I18n。
|
||||
逻辑:健康面板 + 列表筛选;详情仍只读;取消走 admin cancel API 且强制填写原因。
|
||||
-->
|
||||
/**
|
||||
* features/admin/modules/shipping-order-extraction-runs/ShippingOrderExtractionRunsPage.vue
|
||||
* 用途:管理员订单识别运行诊断列表。健康摘要、筛选、分页和只读详情。
|
||||
* 依赖:AdminListPage、useElementProvider、element-plus、admin.api 脱敏诊断/健康/取消。
|
||||
* 逻辑:路由挂载本页。列表骨架用 AdminListPage。详情用侧抽屉。取消用短对话框并强制填写原因。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElConfigProvider,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElDialog,
|
||||
ElDrawer,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
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 { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import {
|
||||
cancelShippingOrderExtractionRun,
|
||||
getShippingOrderExtractionDiagnosticRun,
|
||||
@@ -18,7 +44,9 @@ import {
|
||||
type ShippingOrderExtractionHealth,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const loading = ref(false);
|
||||
@@ -28,7 +56,8 @@ const cancellingRunNo = ref('');
|
||||
const pendingCancelRunNo = ref('');
|
||||
const cancelReason = ref('');
|
||||
const page = ref(1);
|
||||
const pageSize = 25;
|
||||
const pageSize = ref(25);
|
||||
const pageSizes = [10, 25, 50, 100];
|
||||
const total = ref(0);
|
||||
const status = ref('');
|
||||
const staleOnly = ref(false);
|
||||
@@ -37,6 +66,10 @@ const rows = ref<ShippingOrderExtractionDiagnosticRun[]>([]);
|
||||
const health = ref<ShippingOrderExtractionHealth | null>(null);
|
||||
const detail = ref<ShippingOrderExtractionDiagnosticDetail | null>(null);
|
||||
const error = ref('');
|
||||
const runStatuses = ['queued', 'processing', 'completed', 'partially_completed', 'review_required', 'failed', 'cancelled'] as const;
|
||||
|
||||
const detailOpen = computed(() => Boolean(detail.value || detailLoading.value));
|
||||
const cancelOpen = computed(() => Boolean(pendingCancelRunNo.value));
|
||||
|
||||
const formatTime = (value?: string | null) => value ? new Date(value).toLocaleString() : '-';
|
||||
const formatDuration = (value?: number | null) => value == null ? '-' : `${(value / 1000).toFixed(value < 10000 ? 1 : 0)} s`;
|
||||
@@ -44,16 +77,34 @@ const translateAutoFreezeReason = (code: string) =>
|
||||
t(`admin.shippingOrderExtractionRuns.autoFreezeReasonCodes.${code}`, code);
|
||||
|
||||
/**
|
||||
* 判断管理员是否可对 Run 发起取消(活跃且未完成取消)。
|
||||
* 运行状态对应的标签色。完成为成功,失败为危险,取消为信息,待复核为警告。
|
||||
* @param value - 运行状态码
|
||||
* @returns Element 标签类型
|
||||
*/
|
||||
const canCancelRun = (row: ShippingOrderExtractionDiagnosticRun) => (
|
||||
['queued', 'processing'].includes(row.status)
|
||||
&& !row.cancellation?.completed
|
||||
&& !row.cancellation?.in_flight
|
||||
);
|
||||
function runStatusTag(value: string): 'success' | 'warning' | 'info' | 'danger' | 'primary' {
|
||||
if (value === 'completed') return 'success';
|
||||
if (value === 'failed') return 'danger';
|
||||
if (value === 'cancelled') return 'info';
|
||||
if (value === 'review_required' || value === 'partially_completed') return 'warning';
|
||||
return 'primary';
|
||||
}
|
||||
|
||||
/** 展开/收起列表行取消表单。 */
|
||||
const beginCancelRun = (runNo: string) => {
|
||||
/**
|
||||
* 判断管理员是否可对 Run 发起取消(活跃且未完成取消)。
|
||||
* @param row - 诊断列表行
|
||||
* @returns 是否显示取消
|
||||
*/
|
||||
function canCancelRun(row: ShippingOrderExtractionDiagnosticRun): boolean {
|
||||
return ['queued', 'processing'].includes(row.status)
|
||||
&& !row.cancellation?.completed
|
||||
&& !row.cancellation?.in_flight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开取消原因对话框。再次点同一条则收起。
|
||||
* @param runNo - 运行编号
|
||||
*/
|
||||
function beginCancelRun(runNo: string): void {
|
||||
if (pendingCancelRunNo.value === runNo) {
|
||||
pendingCancelRunNo.value = '';
|
||||
cancelReason.value = '';
|
||||
@@ -61,14 +112,50 @@ const beginCancelRun = (runNo: string) => {
|
||||
}
|
||||
pendingCancelRunNo.value = runNo;
|
||||
cancelReason.value = '';
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 从表格行打开取消对话框。
|
||||
* @param row - 当前诊断行
|
||||
*/
|
||||
function beginCancelFromRow(row: ShippingOrderExtractionDiagnosticRun): void {
|
||||
beginCancelRun(row.run_no);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态筛选。清空写回空字符串,接口仍按全部状态查询。
|
||||
* @param value - 选中的状态;清空为 undefined
|
||||
*/
|
||||
function onStatusFilter(value: string | undefined): void {
|
||||
status.value = value ?? '';
|
||||
void applyFilters();
|
||||
}
|
||||
|
||||
/**
|
||||
* 每页条数变化后回到第一页再拉列表。
|
||||
*/
|
||||
function onPageSizeChange(): void {
|
||||
page.value = 1;
|
||||
void load();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭取消对话框。提交过程中不允许点遮罩关掉。
|
||||
* @param open - 对话框是否仍打开
|
||||
*/
|
||||
function onCancelVisible(open: boolean): void {
|
||||
if (open || cancellingRunNo.value) return;
|
||||
pendingCancelRunNo.value = '';
|
||||
cancelReason.value = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员取消 Run;后端强制要求 reason。
|
||||
*/
|
||||
const submitCancelRun = async (runNo: string) => {
|
||||
async function submitCancelRun(): Promise<void> {
|
||||
const runNo = pendingCancelRunNo.value;
|
||||
const reason = String(cancelReason.value || '').trim();
|
||||
if (!reason || cancellingRunNo.value) return;
|
||||
if (!runNo || !reason || cancellingRunNo.value) return;
|
||||
cancellingRunNo.value = runNo;
|
||||
error.value = '';
|
||||
try {
|
||||
@@ -81,10 +168,10 @@ const submitCancelRun = async (runNo: string) => {
|
||||
} finally {
|
||||
cancellingRunNo.value = '';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** 加载健康聚合;失败不阻断列表。 */
|
||||
const loadHealth = async () => {
|
||||
async function loadHealth(): Promise<void> {
|
||||
healthLoading.value = true;
|
||||
try {
|
||||
health.value = await getShippingOrderExtractionHealth(24);
|
||||
@@ -93,16 +180,16 @@ const loadHealth = async () => {
|
||||
} finally {
|
||||
healthLoading.value = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** 加载安全摘要;服务端已完成管理员鉴权、审计及敏感字段剔除。 */
|
||||
const load = async () => {
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const response = await listShippingOrderExtractionDiagnosticRuns(
|
||||
page.value,
|
||||
pageSize,
|
||||
pageSize.value,
|
||||
status.value,
|
||||
{
|
||||
staleOnly: staleOnly.value,
|
||||
@@ -116,14 +203,17 @@ const load = async () => {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const refreshAll = async () => {
|
||||
/**
|
||||
* 同时刷新健康摘要和当前页列表。
|
||||
*/
|
||||
async function refreshAll(): Promise<void> {
|
||||
await Promise.all([loadHealth(), load()]);
|
||||
};
|
||||
}
|
||||
|
||||
/** 按需打开一条 Run 的脱敏执行尝试和节点生命周期,不预取详情以减少诊断审计噪声。 */
|
||||
const openDetail = async (runNo: string) => {
|
||||
async function openDetail(runNo: string): Promise<void> {
|
||||
detailLoading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
@@ -136,21 +226,43 @@ const openDetail = async (runNo: string) => {
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const closeDetail = () => {
|
||||
/**
|
||||
* 从表格行打开详情抽屉。
|
||||
* @param row - 当前诊断行
|
||||
*/
|
||||
function openRunDetail(row: ShippingOrderExtractionDiagnosticRun): void {
|
||||
void openDetail(row.run_no);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭详情抽屉,并清掉地址栏上的 runNo。
|
||||
*/
|
||||
function closeDetail(): void {
|
||||
detail.value = null;
|
||||
if (route.query.runNo) {
|
||||
const nextQuery = { ...route.query };
|
||||
delete nextQuery.runNo;
|
||||
void router.replace({ query: nextQuery });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const applyFilters = async () => {
|
||||
/**
|
||||
* 抽屉开关写回详情状态。
|
||||
* @param open - 抽屉是否打开
|
||||
*/
|
||||
function onDetailVisible(open: boolean): void {
|
||||
if (!open) closeDetail();
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选变化后回到第一页再查询。
|
||||
*/
|
||||
async function applyFilters(): Promise<void> {
|
||||
page.value = 1;
|
||||
await load();
|
||||
};
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void refreshAll();
|
||||
@@ -172,254 +284,329 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="space-y-5 p-5 md:p-7">
|
||||
<header class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderExtractionRuns.title') }}</h1>
|
||||
<p class="section-desc mt-1 max-w-3xl">{{ t('admin.shippingOrderExtractionRuns.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="loading || healthLoading" @click="refreshAll">
|
||||
{{ t('admin.shippingOrderExtractionRuns.refresh') }}
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div
|
||||
class="grid gap-3 rounded-xl border border-default bg-surface p-4 md:grid-cols-4"
|
||||
data-testid="shipping-order-extraction-health"
|
||||
>
|
||||
<div v-if="healthLoading" class="md:col-span-4 text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</div>
|
||||
<template v-else-if="health">
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.healthStatus') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold" :class="health.health_status === 'healthy' ? 'text-emerald-700' : 'text-amber-700'">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.healthStatuses.${health.health_status}`, health.health_status) }}
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<div class="extraction-runs">
|
||||
<div class="extraction-health" data-testid="shipping-order-extraction-health">
|
||||
<p v-if="healthLoading">{{ t('admin.shippingOrderExtractionRuns.loading') }}</p>
|
||||
<template v-else-if="health">
|
||||
<div>
|
||||
<p>{{ t('admin.shippingOrderExtractionRuns.healthStatus') }}</p>
|
||||
<ElTag :type="health.health_status === 'healthy' ? 'success' : 'warning'" effect="light">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.healthStatuses.${health.health_status}`, health.health_status) }}
|
||||
</ElTag>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.activeCount') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold">{{ health.counts.active || 0 }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.staleCount') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold">{{ health.counts.stale || 0 }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.failureRate') }}</div>
|
||||
<div class="mt-1 text-lg font-semibold">{{ Math.round((health.failure_rate || 0) * 100) }}%</div>
|
||||
</div>
|
||||
<div class="md:col-span-4 text-xs text-secondary">
|
||||
{{ t('admin.shippingOrderExtractionRuns.latencySummary', {
|
||||
p50: formatDuration(health.latency?.total?.p50_ms),
|
||||
p95: formatDuration(health.latency?.total?.p95_ms),
|
||||
max: formatDuration(health.latency?.total?.max_ms),
|
||||
}) }}
|
||||
<span v-if="health.stale_run_nos?.length" class="ml-2">
|
||||
{{ t('admin.shippingOrderExtractionRuns.staleRuns', { runs: health.stale_run_nos.slice(0, 5).join(', ') }) }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
<div v-else class="md:col-span-4 text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.healthUnavailable') }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<p>{{ t('admin.shippingOrderExtractionRuns.activeCount') }}</p>
|
||||
<strong>{{ health.counts.active || 0 }}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<p>{{ t('admin.shippingOrderExtractionRuns.staleCount') }}</p>
|
||||
<strong>{{ health.counts.stale || 0 }}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<p>{{ t('admin.shippingOrderExtractionRuns.failureRate') }}</p>
|
||||
<strong>{{ Math.round((health.failure_rate || 0) * 100) }}%</strong>
|
||||
</div>
|
||||
<p class="extraction-health__latency">
|
||||
{{ t('admin.shippingOrderExtractionRuns.latencySummary', {
|
||||
p50: formatDuration(health.latency?.total?.p50_ms),
|
||||
p95: formatDuration(health.latency?.total?.p95_ms),
|
||||
max: formatDuration(health.latency?.total?.max_ms),
|
||||
}) }}
|
||||
<span v-if="health.stale_run_nos?.length">
|
||||
{{ t('admin.shippingOrderExtractionRuns.staleRuns', { runs: health.stale_run_nos.slice(0, 5).join(', ') }) }}
|
||||
</span>
|
||||
</p>
|
||||
</template>
|
||||
<p v-else>{{ t('admin.shippingOrderExtractionRuns.healthUnavailable') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3 rounded-xl border border-default bg-surface p-3">
|
||||
<label class="flex items-center gap-2 text-sm text-secondary">
|
||||
{{ t('admin.shippingOrderExtractionRuns.status') }}
|
||||
<select v-model="status" class="select-field py-1.5" @change="applyFilters">
|
||||
<option value="">{{ t('admin.shippingOrderExtractionRuns.allStatuses') }}</option>
|
||||
<option v-for="value in ['queued', 'processing', 'completed', 'partially_completed', 'review_required', 'failed', 'cancelled']" :key="value" :value="value">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.statuses.${value}`) }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="staleOnly" type="checkbox" class="rounded border-default" @change="applyFilters">
|
||||
{{ t('admin.shippingOrderExtractionRuns.staleOnly') }}
|
||||
</label>
|
||||
<label class="flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="cancellationInFlight" type="checkbox" class="rounded border-default" @change="applyFilters">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationInFlight') }}
|
||||
</label>
|
||||
<span class="text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.total', { count: total }) }}</span>
|
||||
</div>
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.shippingOrderExtractionRuns.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderExtractionRuns.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton :icon="Refresh" :loading="loading || healthLoading" @click="refreshAll">
|
||||
{{ t('admin.shippingOrderExtractionRuns.refresh') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElSelect
|
||||
:model-value="status || undefined"
|
||||
class="extraction-filter-status"
|
||||
clearable
|
||||
:placeholder="t('admin.shippingOrderExtractionRuns.allStatuses')"
|
||||
@update:model-value="onStatusFilter"
|
||||
>
|
||||
<ElOption
|
||||
v-for="value in runStatuses"
|
||||
:key="value"
|
||||
:label="t(`admin.shippingOrderExtractionRuns.statuses.${value}`)"
|
||||
:value="value"
|
||||
/>
|
||||
</ElSelect>
|
||||
<ElCheckbox v-model="staleOnly" @change="applyFilters">
|
||||
{{ t('admin.shippingOrderExtractionRuns.staleOnly') }}
|
||||
</ElCheckbox>
|
||||
<ElCheckbox v-model="cancellationInFlight" @change="applyFilters">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationInFlight') }}
|
||||
</ElCheckbox>
|
||||
</template>
|
||||
|
||||
<p v-if="error" class="rounded-lg border border-rose-200 bg-rose-50 p-3 text-sm text-rose-700">{{ error }}</p>
|
||||
<div class="overflow-x-auto rounded-xl border border-default bg-surface">
|
||||
<table class="min-w-[1040px] w-full text-left text-sm">
|
||||
<thead class="border-b border-default bg-surface-soft text-xs text-muted"><tr>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.runNo') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.status') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.stage') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.cancellation') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.attempts') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.createdAt') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.totalDuration') }}</th>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.actions') }}</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr v-if="loading"><td colspan="9" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</td></tr>
|
||||
<tr v-else-if="!rows.length"><td colspan="9" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</td></tr>
|
||||
<tr v-for="row in rows" :key="row.run_no" class="border-b border-default last:border-0">
|
||||
<td class="px-4 py-3 font-mono text-xs">{{ row.run_no }}</td>
|
||||
<td class="px-4 py-3">{{ t(`admin.shippingOrderExtractionRuns.statuses.${row.status}`) }}</td>
|
||||
<td class="px-4 py-3">{{ row.current_event_code || '-' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span v-if="row.cancellation?.in_flight" class="rounded-full bg-amber-100 px-2 py-0.5 text-xs text-amber-800">
|
||||
<ElAlert v-if="error" :title="error" type="error" :closable="false" show-icon />
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="hx-admin-table"
|
||||
:data="rows"
|
||||
row-key="run_no"
|
||||
:empty-text="t('admin.shippingOrderExtractionRuns.empty')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.shippingOrderExtractionRuns.runNo')" min-width="180">
|
||||
<template #default="{ row }">{{ row.run_no }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderExtractionRuns.status')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="runStatusTag(row.status)" effect="light">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.statuses.${row.status}`) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderExtractionRuns.stage')" min-width="140">
|
||||
<template #default="{ row }">{{ row.current_event_code || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderExtractionRuns.cancellation')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag v-if="row.cancellation?.in_flight" type="warning" effect="light">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationStates.in_flight') }}
|
||||
</span>
|
||||
<span v-else-if="row.cancellation?.completed" class="text-xs text-muted">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancellationStates.completed') }}
|
||||
</span>
|
||||
<span v-else class="text-xs text-muted">—</span>
|
||||
</td>
|
||||
<td class="px-4 py-3">{{ row.attempt_count }}</td>
|
||||
<td class="px-4 py-3">{{ formatTime(row.created_at) }}</td>
|
||||
<td class="px-4 py-3">{{ formatDuration(row.durations_ms.total ?? row.durations_ms.elapsed_active) }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<div class="flex flex-col gap-2">
|
||||
<button type="button" class="text-left text-brand-600 hover:underline" @click="openDetail(row.run_no)">{{ t('admin.shippingOrderExtractionRuns.viewDetail') }}</button>
|
||||
<template v-if="canCancelRun(row)">
|
||||
<div
|
||||
v-if="pendingCancelRunNo === row.run_no"
|
||||
class="min-w-[220px] space-y-1.5 rounded-md border border-rose-200 bg-rose-50/60 p-2 dark:border-rose-900/40 dark:bg-rose-950/20"
|
||||
>
|
||||
<label class="block text-[11px] text-secondary">{{ t('chat.shippingOrderExtractionCancel.reasonRequired') }}</label>
|
||||
<textarea v-model="cancelReason" rows="2" class="input-field w-full py-1 text-xs" />
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs font-medium text-rose-700 hover:underline"
|
||||
:disabled="cancellingRunNo === row.run_no || !cancelReason.trim()"
|
||||
@click="submitCancelRun(row.run_no)"
|
||||
>
|
||||
{{ cancellingRunNo === row.run_no
|
||||
? t('chat.shippingOrderExtractionCancel.submitting')
|
||||
: t('admin.shippingOrderExtractionRuns.cancelRun') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs text-muted hover:underline"
|
||||
:disabled="cancellingRunNo === row.run_no"
|
||||
@click="pendingCancelRunNo = ''; cancelReason = ''"
|
||||
>
|
||||
{{ t('admin.cancel') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="text-left text-xs font-medium text-rose-700 hover:underline"
|
||||
:disabled="Boolean(cancellingRunNo)"
|
||||
@click="beginCancelRun(row.run_no)"
|
||||
>
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancelRun') }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="flex items-center justify-end gap-3 text-sm">
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page <= 1 || loading" @click="page -= 1; load()">{{ t('admin.shippingOrderExtractionRuns.previous') }}</button>
|
||||
<span>{{ page }}</span>
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">{{ t('admin.shippingOrderExtractionRuns.next') }}</button>
|
||||
</ElTag>
|
||||
<span v-else-if="row.cancellation?.completed">{{ t('admin.shippingOrderExtractionRuns.cancellationStates.completed') }}</span>
|
||||
<span v-else>—</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderExtractionRuns.attempts')" min-width="90">
|
||||
<template #default="{ row }">{{ row.attempt_count }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderExtractionRuns.createdAt')" min-width="180">
|
||||
<template #default="{ row }">{{ formatTime(row.created_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderExtractionRuns.totalDuration')" min-width="120">
|
||||
<template #default="{ row }">{{ formatDuration(row.durations_ms.total ?? row.durations_ms.elapsed_active) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingOrderExtractionRuns.actions')" width="180" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openRunDetail(row as ShippingOrderExtractionDiagnosticRun)">
|
||||
{{ t('admin.shippingOrderExtractionRuns.viewDetail') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="canCancelRun(row as ShippingOrderExtractionDiagnosticRun)"
|
||||
link
|
||||
type="danger"
|
||||
:disabled="Boolean(cancellingRunNo)"
|
||||
@click="beginCancelFromRow(row as ShippingOrderExtractionDiagnosticRun)"
|
||||
>
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancelRun') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<template #pagination>
|
||||
<ElPagination
|
||||
v-model:current-page="page"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
:page-sizes="pageSizes"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
@current-change="load"
|
||||
@size-change="onPageSizeChange"
|
||||
/>
|
||||
</template>
|
||||
</AdminListPage>
|
||||
</div>
|
||||
|
||||
<div v-if="detail || detailLoading" class="fixed inset-0 z-50 flex justify-end bg-overlay" @click.self="closeDetail">
|
||||
<aside class="h-full w-full max-w-2xl overflow-y-auto bg-surface p-6 shadow-2xl">
|
||||
<div class="flex items-center justify-between"><h2 class="text-lg font-bold">{{ t('admin.shippingOrderExtractionRuns.detailTitle') }}</h2><button type="button" class="text-secondary" @click="closeDetail">{{ t('admin.close') }}</button></div>
|
||||
<p v-if="detailLoading" class="mt-6 text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</p>
|
||||
<template v-else-if="detail">
|
||||
<dl class="mt-5 grid grid-cols-2 gap-3 text-sm">
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.runNo') }}</dt><dd class="font-mono text-xs">{{ detail.run.run_no }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.currentEvent') }}</dt><dd class="font-mono text-xs">{{ detail.run.current_event_code || '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.cancellation') }}</dt>
|
||||
<dd>
|
||||
<ElDialog
|
||||
:model-value="cancelOpen"
|
||||
:title="t('admin.shippingOrderExtractionRuns.cancelRun')"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="!cancellingRunNo"
|
||||
:show-close="!cancellingRunNo"
|
||||
@update:model-value="onCancelVisible"
|
||||
>
|
||||
<ElForm label-position="top" @submit.prevent="submitCancelRun">
|
||||
<ElFormItem :label="t('chat.shippingOrderExtractionCancel.reasonRequired')">
|
||||
<ElInput v-model="cancelReason" type="textarea" :rows="4" />
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="Boolean(cancellingRunNo)" @click="onCancelVisible(false)">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="Boolean(cancellingRunNo)" :disabled="!cancelReason.trim()" @click="submitCancelRun">
|
||||
{{ t('admin.shippingOrderExtractionRuns.cancelRun') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
<ElDrawer
|
||||
:model-value="detailOpen"
|
||||
:title="t('admin.shippingOrderExtractionRuns.detailTitle')"
|
||||
direction="rtl"
|
||||
size="680px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onDetailVisible"
|
||||
>
|
||||
<div v-loading="detailLoading">
|
||||
<template v-if="detail">
|
||||
<ElDescriptions :column="2" border>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.runNo')">{{ detail.run.run_no }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.currentEvent')">{{ detail.run.current_event_code || '-' }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.cancellation')">
|
||||
<template v-if="detail.run.cancellation?.in_flight">{{ t('admin.shippingOrderExtractionRuns.cancellationStates.in_flight') }}</template>
|
||||
<template v-else-if="detail.run.cancellation?.completed">{{ t('admin.shippingOrderExtractionRuns.cancellationStates.completed') }}</template>
|
||||
<template v-else>—</template>
|
||||
</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.candidateMaterializedAt') }}</dt><dd>{{ formatTime(detail.run.candidate_materialized_at) }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.errorCode') }}</dt><dd>{{ detail.run.error_code || '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.totalDuration') }}</dt><dd>{{ formatDuration(detail.run.durations_ms.total) }}</dd>
|
||||
</dl>
|
||||
<section class="mt-6 rounded-lg border border-default p-4 text-sm">
|
||||
<div class="font-semibold">{{ t('admin.shippingOrderExtractionRuns.autoFreezePolicy') }}</div>
|
||||
<dl class="mt-3 grid grid-cols-2 gap-x-3 gap-y-2">
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeEnabled') }}</dt>
|
||||
<dd>{{ t(detail.run.auto_freeze_policy.enabled ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeMode') }}</dt>
|
||||
<dd>{{ t(`admin.shippingOrderExtractionRuns.autoFreezeModes.${detail.run.auto_freeze_policy.mode}`) }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeQualificationStatus') }}</dt>
|
||||
<dd>{{ detail.run.auto_freeze_policy.qualification_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeQualificationStatuses.${detail.run.auto_freeze_policy.qualification_status}`) : '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeProfile') }}</dt>
|
||||
<dd>{{ detail.run.auto_freeze_policy.selected_profile_code || '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatus') }}</dt>
|
||||
<dd>{{ detail.run.auto_freeze_policy.customer_scope_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatuses.${detail.run.auto_freeze_policy.customer_scope_status}`) : '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatus') }}</dt>
|
||||
<dd>{{ detail.run.auto_freeze_policy.business_scenario_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatuses.${detail.run.auto_freeze_policy.business_scenario_status}`) : '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeCustomerConfirmation') }}</dt>
|
||||
<dd>{{ t(detail.run.auto_freeze_policy.customer_confirmation_required ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd>
|
||||
</dl>
|
||||
<div class="mt-3">
|
||||
<div class="text-xs font-medium text-secondary">{{ t('admin.shippingOrderExtractionRuns.autoFreezeBlockingReasons') }}</div>
|
||||
<div v-if="detail.run.auto_freeze_policy.blocking_reason_codes.length" class="mt-2 flex flex-wrap gap-2">
|
||||
<span
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.candidateMaterializedAt')">{{ formatTime(detail.run.candidate_materialized_at) }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.errorCode')">{{ detail.run.error_code || '-' }}</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.totalDuration')">{{ formatDuration(detail.run.durations_ms.total) }}</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
|
||||
<section class="extraction-detail-block">
|
||||
<h3>{{ t('admin.shippingOrderExtractionRuns.autoFreezePolicy') }}</h3>
|
||||
<ElDescriptions :column="2" border>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.autoFreezeEnabled')">
|
||||
{{ t(detail.run.auto_freeze_policy.enabled ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.autoFreezeMode')">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.autoFreezeModes.${detail.run.auto_freeze_policy.mode}`) }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.autoFreezeQualificationStatus')">
|
||||
{{ detail.run.auto_freeze_policy.qualification_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeQualificationStatuses.${detail.run.auto_freeze_policy.qualification_status}`) : '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.autoFreezeProfile')">
|
||||
{{ detail.run.auto_freeze_policy.selected_profile_code || '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatus')">
|
||||
{{ detail.run.auto_freeze_policy.customer_scope_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatuses.${detail.run.auto_freeze_policy.customer_scope_status}`) : '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatus')">
|
||||
{{ detail.run.auto_freeze_policy.business_scenario_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatuses.${detail.run.auto_freeze_policy.business_scenario_status}`) : '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.autoFreezeCustomerConfirmation')">
|
||||
{{ t(detail.run.auto_freeze_policy.customer_confirmation_required ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
<div class="extraction-detail-block">
|
||||
<h3>{{ t('admin.shippingOrderExtractionRuns.autoFreezeBlockingReasons') }}</h3>
|
||||
<div v-if="detail.run.auto_freeze_policy.blocking_reason_codes.length" class="extraction-tags">
|
||||
<ElTag
|
||||
v-for="code in detail.run.auto_freeze_policy.blocking_reason_codes"
|
||||
:key="code"
|
||||
class="rounded-full border border-default px-2 py-1 text-xs text-secondary"
|
||||
effect="light"
|
||||
>
|
||||
{{ translateAutoFreezeReason(code) }}
|
||||
</span>
|
||||
</ElTag>
|
||||
</div>
|
||||
<div v-else class="mt-2 text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.autoFreezeNoBlockingReasons') }}</div>
|
||||
<p v-else>{{ t('admin.shippingOrderExtractionRuns.autoFreezeNoBlockingReasons') }}</p>
|
||||
</div>
|
||||
</section>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.jobAttempts') }}</h3>
|
||||
<div class="mt-2 space-y-2">
|
||||
<div v-for="job in detail.job_attempts" :key="job.job_id" class="rounded-lg border border-default p-3 text-sm">
|
||||
|
||||
<h3>{{ t('admin.shippingOrderExtractionRuns.jobAttempts') }}</h3>
|
||||
<div class="extraction-stack">
|
||||
<article v-for="job in detail.job_attempts" :key="job.job_id" class="extraction-card">
|
||||
<b>#{{ job.job_id }}</b> · {{ job.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ job.attempts }}/{{ job.max_attempts }} · {{ formatDuration(job.duration_ms) }}
|
||||
</div>
|
||||
<p v-if="!detail.job_attempts.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</article>
|
||||
<p v-if="!detail.job_attempts.length">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</div>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.units') }}</h3>
|
||||
<div class="mt-2 space-y-2">
|
||||
<div v-for="unit in detail.units" :key="unit.unit_id" class="rounded-lg border border-default p-3 text-sm">
|
||||
<h3>{{ t('admin.shippingOrderExtractionRuns.units') }}</h3>
|
||||
<div class="extraction-stack">
|
||||
<article v-for="unit in detail.units" :key="unit.unit_id" class="extraction-card">
|
||||
<b>#{{ unit.position + 1 }} {{ unit.unit_type }}</b> · {{ unit.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ unit.attempt_count }} · {{ formatDuration(unit.duration_ms) }}
|
||||
<span v-if="unit.error_code" class="ml-2 font-mono text-xs text-danger">{{ unit.error_code }}</span>
|
||||
<section v-for="routeItem in unit.route_decisions" :key="`${unit.unit_id}:${routeItem.attempt_no}`" class="mt-3 rounded border border-default bg-surface-soft p-3 text-xs">
|
||||
<h4 class="font-semibold text-primary">{{ t('admin.shippingOrderExtractionRuns.routeDecision') }} #{{ routeItem.attempt_no }}</h4>
|
||||
<dl class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1">
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.executionMode') }}</dt>
|
||||
<dd>{{ t(`admin.shippingOrderExtractionRuns.executionModes.${routeItem.execution_mode}`) }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.matchStatus') }}</dt>
|
||||
<dd>{{ t(`admin.shippingOrderExtractionRuns.matchStatuses.${routeItem.match_status}`) }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.selectedProfile') }}</dt>
|
||||
<dd>{{ routeItem.selected_profile_code ? `${routeItem.selected_profile_code} V${routeItem.selected_profile_version}` : '-' }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.autoCreateApproved') }}</dt>
|
||||
<dd>{{ routeItem.auto_create_approved == null ? '-' : t(routeItem.auto_create_approved ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd>
|
||||
<dt>{{ t('admin.shippingOrderExtractionRuns.fallbackReasons') }}</dt>
|
||||
<dd>{{ routeItem.fallback_reason_codes.length ? routeItem.fallback_reason_codes.map(code => t(`admin.shippingOrderExtractionRuns.reasonCodes.${code}`)).join(';') : '-' }}</dd>
|
||||
</dl>
|
||||
<span v-if="unit.error_code">{{ unit.error_code }}</span>
|
||||
<section v-for="routeItem in unit.route_decisions" :key="`${unit.unit_id}:${routeItem.attempt_no}`" class="extraction-card">
|
||||
<h4>{{ t('admin.shippingOrderExtractionRuns.routeDecision') }} #{{ routeItem.attempt_no }}</h4>
|
||||
<ElDescriptions :column="2" border>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.executionMode')">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.executionModes.${routeItem.execution_mode}`) }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.matchStatus')">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.matchStatuses.${routeItem.match_status}`) }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.selectedProfile')">
|
||||
{{ routeItem.selected_profile_code ? `${routeItem.selected_profile_code} V${routeItem.selected_profile_version}` : '-' }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.autoCreateApproved')">
|
||||
{{ routeItem.auto_create_approved == null ? '-' : t(routeItem.auto_create_approved ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem :label="t('admin.shippingOrderExtractionRuns.fallbackReasons')">
|
||||
{{ routeItem.fallback_reason_codes.length ? routeItem.fallback_reason_codes.map((code) => t(`admin.shippingOrderExtractionRuns.reasonCodes.${code}`)).join(';') : '-' }}
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
</section>
|
||||
</div>
|
||||
<p v-if="!detail.units.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</article>
|
||||
<p v-if="!detail.units.length">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</div>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.lifecycle') }}</h3>
|
||||
<div class="mt-2 space-y-2">
|
||||
<div v-for="event in detail.progress_events" :key="`${event.sequence_no}:${event.event_code}`" class="rounded-lg border border-default p-3 text-sm">
|
||||
<h3>{{ t('admin.shippingOrderExtractionRuns.lifecycle') }}</h3>
|
||||
<div class="extraction-stack">
|
||||
<article v-for="event in detail.progress_events" :key="`${event.sequence_no}:${event.event_code}`" class="extraction-card">
|
||||
<b>{{ event.event_code }}</b>
|
||||
<span class="ml-2 text-secondary">{{ event.status || '-' }}</span>
|
||||
<span class="ml-2 font-mono text-xs text-muted">{{ t(`admin.shippingOrderExtractionRuns.visibilities.${event.visibility}`) }}</span>
|
||||
<span v-if="event.reason_code" class="ml-2 font-mono text-xs text-muted">{{ event.reason_code }}</span>
|
||||
<time class="ml-2 text-xs text-muted">{{ formatTime(event.occurred_at) }}</time>
|
||||
</div>
|
||||
<p v-if="!detail.progress_events.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
<span>{{ event.status || '-' }}</span>
|
||||
<span>{{ t(`admin.shippingOrderExtractionRuns.visibilities.${event.visibility}`) }}</span>
|
||||
<span v-if="event.reason_code">{{ event.reason_code }}</span>
|
||||
<time>{{ formatTime(event.occurred_at) }}</time>
|
||||
</article>
|
||||
<p v-if="!detail.progress_events.length">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</aside>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</ElDrawer>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.extraction-runs {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.extraction-health {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
padding: 16px 32px;
|
||||
}
|
||||
|
||||
.extraction-health__latency {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.extraction-health p {
|
||||
margin: 0 0 4px;
|
||||
}
|
||||
|
||||
.extraction-detail-block,
|
||||
.extraction-stack {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.extraction-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.extraction-card {
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
}
|
||||
|
||||
:deep(.extraction-filter-status) {
|
||||
width: 11rem;
|
||||
}
|
||||
</style>
|
||||
+345
-254
@@ -1,14 +1,31 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/ShippingOrderSchemaPage.vue
|
||||
用途:单一发货订单 Schema 的版本采用与版本级识别规则编辑;字段身份由全局字段资产库维护。
|
||||
依赖:shipping-order-schema.api、shipping-field-assets.api、FieldImpactDrawer、版本/审计抽屉组件、Vue I18n。
|
||||
依赖:shipping-order-schema.api、shipping-field-assets.api、FieldImpactDrawer、版本/审计抽屉、useElementProvider、element-plus、Vue I18n。
|
||||
逻辑:左侧勾选采用资产目录,右侧编辑已采用字段规则;草稿保存/发布与历史追溯由服务端冻结。无多族切换。
|
||||
「Schema 级策略」仅收纳自动建单总开关;订单项次由系统按单据内顺序生成。
|
||||
「Schema 级策略」仅收纳自动建单总开关;订单项次由系统按单据内顺序生成。按钮、输入、下拉和确认框使用 Element Plus。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElConfigProvider,
|
||||
ElDialog,
|
||||
ElInput,
|
||||
ElInputNumber,
|
||||
ElLoading,
|
||||
ElMessageBox,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElSwitch,
|
||||
} from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { getShippingFieldAssetImpact, listShippingFieldAssets } from '@/features/admin/api/shipping-field-assets.api';
|
||||
@@ -48,11 +65,15 @@ import type {
|
||||
type DraftFieldEditor = ShippingOrderFieldConfig & { enabled: boolean };
|
||||
type AdoptionGroupKey = 'headerStandard' | 'lineStandard' | 'extensions';
|
||||
type SuggestedPreviewItem = { field_id: string; display_name: string; field_code: string };
|
||||
const businessPurposeOptions = ['general', 'part_number', 'quantity', 'reservation_id', 'inventory_source_hint'] as const;
|
||||
const coordinateSourceOptions = ['pdf_coordinate', 'ocr_coordinate'] as const;
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const message = useMessage();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const state = ref<ShippingOrderSchemaState | null>(null);
|
||||
const retiredExtensions = ref<ShippingOrderField[]>([]);
|
||||
@@ -434,14 +455,11 @@ const saveDraft = async (): Promise<void> => {
|
||||
|
||||
/**
|
||||
* 拦截自动建单开关变更:仅草稿可改,且须二次确认;确认后仅写入本地,随保存草稿/发布生效。
|
||||
* @param event - checkbox change 事件
|
||||
* 核心逻辑:开关使用受控值,未确认前不写回 autoCreationEnabled。
|
||||
* @param nextValue - ElSwitch 打算切到的值
|
||||
*/
|
||||
const onAutoCreationToggle = (event: Event): void => {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const nextEnabled = input.checked;
|
||||
// 先回滚 DOM/v-model,确认后再写入,避免误触立即改值。
|
||||
autoCreationEnabled.value = !nextEnabled;
|
||||
input.checked = !nextEnabled;
|
||||
const onAutoCreationToggle = (nextValue: string | number | boolean): void => {
|
||||
const nextEnabled = nextValue === true;
|
||||
if (!draft.value) {
|
||||
message.warning(t('admin.shippingOrderSchema.autoCreationRequiresDraft'));
|
||||
return;
|
||||
@@ -507,9 +525,21 @@ const confirmPublishWithImpact = async (): Promise<void> => {
|
||||
}
|
||||
};
|
||||
|
||||
/** 删除配置错误的草稿,释放下一版本创建门禁。 */
|
||||
/**
|
||||
* 删除配置错误的草稿,释放下一版本创建门禁。
|
||||
* 核心逻辑:先弹出删除确认,取消则不请求。
|
||||
*/
|
||||
const deleteDraft = async (): Promise<void> => {
|
||||
if (!draft.value) return;
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.shippingOrderSchema.deleteDraft'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
await deleteShippingOrderSchemaDraft(draft.value.id);
|
||||
@@ -719,9 +749,81 @@ const groupHasSelectedField = (_key: AdoptionGroupKey, fields: ShippingOrderFiel
|
||||
/** 将逗号分隔输入规范化为去重字符串列表。 */
|
||||
const splitValues = (value: string): string[] => [...new Set(value.split(',').map((item) => item.trim()).filter(Boolean))];
|
||||
|
||||
/** 切换多选目录项,保持字段配置列表去重。 */
|
||||
const toggleValue = (values: string[], value: string): string[] =>
|
||||
(values.includes(value) ? values.filter((item) => item !== value) : [...values, value]);
|
||||
/**
|
||||
* 写回别名列表。只读或未采用时忽略输入。
|
||||
* @param value - 逗号分隔的别名
|
||||
*/
|
||||
const onAliasesInput = (value: string): void => {
|
||||
if (isReadOnly.value || !selectedDraftField.value?.enabled || !selectedRuleConfig.value) return;
|
||||
selectedRuleConfig.value.aliases = splitValues(value);
|
||||
};
|
||||
|
||||
/**
|
||||
* 写回关联角色。清空时保持 null,避免把空字符串提交给发布校验。
|
||||
* @param value - 选中的角色;清空为 undefined
|
||||
*/
|
||||
const onRelationRoleChange = (value: string | undefined): void => {
|
||||
if (isReadOnly.value || !selectedRuleConfig.value) return;
|
||||
selectedRuleConfig.value.relation_role = value || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 按勾选结果增删多选目录项。
|
||||
* @param values - 当前已选值
|
||||
* @param value - 被切换的项
|
||||
* @param checked - 勾选后的状态
|
||||
*/
|
||||
const setIncluded = (values: string[], value: string, checked: string | number | boolean): string[] => (
|
||||
checked === true
|
||||
? (values.includes(value) ? values : [...values, value])
|
||||
: values.filter((item) => item !== value)
|
||||
);
|
||||
|
||||
/**
|
||||
* 切换坐标来源勾选,并保持后端允许的来源联合类型。
|
||||
* @param item - pdf_coordinate 或 ocr_coordinate
|
||||
* @param checked - 勾选后的状态
|
||||
*/
|
||||
const onCoordinateSourceChange = (item: 'pdf_coordinate' | 'ocr_coordinate', checked: string | number | boolean): void => {
|
||||
if (isReadOnly.value || !selectedRuleConfig.value) return;
|
||||
const next = setIncluded(selectedRuleConfig.value.allowed_sources || [], item, checked);
|
||||
selectedRuleConfig.value.allowed_sources = next.filter(
|
||||
(source): source is 'pdf_coordinate' | 'ocr_coordinate' => source === 'pdf_coordinate' || source === 'ocr_coordinate',
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换校验器勾选。
|
||||
* @param item - 校验器键
|
||||
* @param checked - 勾选后的状态
|
||||
*/
|
||||
const onValidatorChange = (item: string, checked: string | number | boolean): void => {
|
||||
if (isReadOnly.value || !selectedRuleConfig.value) return;
|
||||
selectedRuleConfig.value.validator_keys = setIncluded(selectedRuleConfig.value.validator_keys, item, checked);
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换证据来源优先级勾选。
|
||||
* @param item - 来源类型
|
||||
* @param checked - 勾选后的状态
|
||||
*/
|
||||
const onSourcePrecedenceChange = (item: string, checked: string | number | boolean): void => {
|
||||
if (isReadOnly.value || !selectedRuleConfig.value) return;
|
||||
selectedRuleConfig.value.evidence_policy.source_precedence = setIncluded(
|
||||
selectedRuleConfig.value.evidence_policy.source_precedence,
|
||||
item,
|
||||
checked,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换建单关键字段。未确认的勾选值按布尔写入必填与最低置信度。
|
||||
* @param checked - 勾选后的状态
|
||||
*/
|
||||
const onAutoCreateKeyChange = (checked: string | number | boolean): void => {
|
||||
if (isReadOnly.value || !selectedRuleConfig.value) return;
|
||||
setAutoCreateKeyField(selectedRuleConfig.value, checked === true);
|
||||
};
|
||||
|
||||
/** 切换建单关键字段时同步业务必填与最低置信度,避免提交不完整的自动建单门禁。 */
|
||||
const setAutoCreateKeyField = (config: ShippingOrderFieldConfig, enabled: boolean): void => {
|
||||
@@ -815,15 +917,14 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="mx-auto max-w-7xl space-y-6 p-6">
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<section v-loading="loading" class="mx-auto max-w-7xl space-y-6 p-6">
|
||||
<header>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderSchema.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderSchema.subtitle') }}</p>
|
||||
</header>
|
||||
|
||||
<div v-if="loading" class="rounded-xl border border-default p-8 text-center text-muted">{{ t('common.loading') }}</div>
|
||||
|
||||
<form v-else-if="!state?.schema" class="schema-setup" @submit.prevent="initialize">
|
||||
<form v-if="!loading && !state?.schema" class="schema-setup" @submit.prevent="initialize">
|
||||
<div class="schema-setup-copy">
|
||||
<p class="schema-setup-kicker">{{ t('admin.shippingOrderSchema.setupKicker') }}</p>
|
||||
<h2>{{ t('admin.shippingOrderSchema.setupTitle') }}</h2>
|
||||
@@ -836,11 +937,11 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="schema-setup-form">
|
||||
<p>{{ t('admin.shippingOrderSchema.setupActionHintPhase4') }}</p>
|
||||
<button :disabled="saving" class="btn-primary">{{ t('admin.shippingOrderSchema.initialize') }}</button>
|
||||
<ElButton native-type="submit" type="primary" :loading="saving">{{ t('admin.shippingOrderSchema.initialize') }}</ElButton>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<section v-else-if="!hasAnyVersion" class="no-version-card">
|
||||
<section v-else-if="!loading && !hasAnyVersion" class="no-version-card">
|
||||
<div class="no-version-copy">
|
||||
<p class="schema-setup-kicker">{{ t('admin.shippingOrderSchema.noVersionKicker') }}</p>
|
||||
<h2>{{ t('admin.shippingOrderSchema.noVersionTitle') }}</h2>
|
||||
@@ -848,13 +949,13 @@ onMounted(async () => {
|
||||
<p class="field-asset-hint">{{ t('admin.shippingOrderSchema.fieldAssetLibraryHint') }}</p>
|
||||
</div>
|
||||
<div class="no-version-actions">
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="createDraft">
|
||||
<ElButton type="primary" :loading="saving" @click="createDraft">
|
||||
{{ t('admin.shippingOrderSchema.createFirstDraft') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<template v-else>
|
||||
<template v-else-if="!loading">
|
||||
<div class="schema-toolbar">
|
||||
<div>
|
||||
<strong>{{ t('admin.shippingOrderSchema.ruleWorkspace') }}</strong>
|
||||
@@ -867,30 +968,28 @@ onMounted(async () => {
|
||||
</span>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<button type="button" class="btn-secondary" :disabled="saving" @click="openHistory">
|
||||
<ElButton :disabled="saving" @click="openHistory">
|
||||
{{ t('admin.shippingOrderSchema.historyOpen') }}
|
||||
</button>
|
||||
<button
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="!draft && published"
|
||||
type="button"
|
||||
class="btn-secondary"
|
||||
:disabled="saving"
|
||||
@click="createDraft"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.createDraft') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
<template v-if="draft">
|
||||
<button type="button" class="btn-secondary" :disabled="saving" @click="saveDraft">
|
||||
<ElButton :disabled="saving" @click="saveDraft">
|
||||
{{ t('admin.shippingOrderSchema.saveDraft') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="saving || !draftFields.some((item) => item.enabled)"
|
||||
</ElButton>
|
||||
<ElButton
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="!draftFields.some((item) => item.enabled)"
|
||||
@click="publishDraft"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.publish') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -909,13 +1008,12 @@ onMounted(async () => {
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<label class="auto-creation-switch">
|
||||
<input
|
||||
:checked="autoCreationEnabled"
|
||||
<div class="auto-creation-switch">
|
||||
<ElSwitch
|
||||
:model-value="autoCreationEnabled"
|
||||
:disabled="saving || !draft"
|
||||
type="checkbox"
|
||||
@change="onAutoCreationToggle"
|
||||
>
|
||||
/>
|
||||
<span>
|
||||
<strong>{{ t('admin.shippingOrderSchema.autoCreationEnabled') }}</strong>
|
||||
<small>{{ t('admin.shippingOrderSchema.autoCreationHint') }}</small>
|
||||
@@ -934,7 +1032,7 @@ onMounted(async () => {
|
||||
</template>
|
||||
</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="schema-gate-note">{{ t('admin.shippingOrderSchema.effectiveReservationGate') }}</p>
|
||||
|
||||
</section>
|
||||
@@ -946,19 +1044,17 @@ onMounted(async () => {
|
||||
<h2>{{ t('admin.shippingOrderSchema.adoptionPanel') }}</h2>
|
||||
<p>{{ t('admin.shippingOrderSchema.adoptionPanelHint') }}</p>
|
||||
</div>
|
||||
<button
|
||||
<ElButton
|
||||
v-if="draft"
|
||||
type="button"
|
||||
class="btn-secondary btn-sm"
|
||||
:disabled="saving || !suggestedPreviewCount"
|
||||
@click="openSuggestPreview"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.adoptSuggested', { count: suggestedPreviewCount || suggestedAdoptionCount }) }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
|
||||
<div class="field-search">
|
||||
<input v-model="fieldSearch" class="input-field" type="search" :placeholder="t('admin.shippingOrderSchema.searchFields')">
|
||||
<ElInput v-model="fieldSearch" class="schema-field-search" clearable :placeholder="t('admin.shippingOrderSchema.searchFields')" />
|
||||
<span>{{ t('admin.shippingOrderSchema.adoptedCount', { adopted: adoptedCount, total: catalogFields.length }) }}</span>
|
||||
</div>
|
||||
|
||||
@@ -979,8 +1075,7 @@ onMounted(async () => {
|
||||
|
||||
<div class="field-list">
|
||||
<section v-for="group in groupedAdoptionCatalog" :key="group.key" class="field-group">
|
||||
<button
|
||||
type="button"
|
||||
<ElButton
|
||||
class="field-group-toggle"
|
||||
:aria-expanded="groupIsExpanded(group.key)"
|
||||
@click="toggleGroup(group.key)"
|
||||
@@ -995,7 +1090,7 @@ onMounted(async () => {
|
||||
</b>
|
||||
<em>{{ group.fields.length }}</em>
|
||||
</span>
|
||||
</button>
|
||||
</ElButton>
|
||||
<div v-if="groupIsExpanded(group.key)" class="field-group-items">
|
||||
<div
|
||||
v-for="field in group.fields"
|
||||
@@ -1008,26 +1103,26 @@ onMounted(async () => {
|
||||
}"
|
||||
@click="fieldAdopted(field) && (selectedDraftFieldId = field.id)"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="fieldAdopted(field)"
|
||||
<ElCheckbox
|
||||
:model-value="fieldAdopted(field)"
|
||||
:disabled="isReadOnly || saving || field.status === 'retired'"
|
||||
@click.stop
|
||||
@change="toggleAdoption(field, ($event.target as HTMLInputElement).checked)"
|
||||
>
|
||||
@change="toggleAdoption(field, $event === true)"
|
||||
/>
|
||||
<span class="adoption-identity">
|
||||
<strong>{{ displayNameForField(field) }}</strong>
|
||||
<code :title="field.field_code">{{ field.field_code }}</code>
|
||||
<small v-if="field.status === 'retired'">{{ t('admin.shippingOrderSchema.retiredNotAdoptable') }}</small>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
<ElButton
|
||||
class="adoption-select"
|
||||
link
|
||||
:disabled="!fieldAdopted(field)"
|
||||
:title="t('admin.shippingOrderSchema.adoptionLegendAdopted')"
|
||||
@click.stop="selectedDraftFieldId = field.id"
|
||||
>
|
||||
<span class="field-state" :class="{ included: fieldAdopted(field) }" />
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -1050,15 +1145,14 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="rule-heading-actions">
|
||||
<span v-if="isReadOnly" class="read-only-badge">{{ t('admin.shippingOrderSchema.readOnly') }}</span>
|
||||
<button
|
||||
<ElButton
|
||||
v-if="selectedField"
|
||||
type="button"
|
||||
class="btn-secondary btn-sm compact-button"
|
||||
:disabled="fieldImpactLoading"
|
||||
:loading="fieldImpactLoading"
|
||||
@click="openFieldImpact(selectedField.id)"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.viewFieldImpact') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -1066,38 +1160,36 @@ onMounted(async () => {
|
||||
<div class="rule-basics">
|
||||
<label>
|
||||
<span class="help-label" :data-help="fieldHelp('displayName')">{{ t('admin.shippingOrderSchema.displayName') }}</span>
|
||||
<input v-model="selectedRuleConfig.display_name" class="input-field" :disabled="isReadOnly">
|
||||
<ElInput v-model="selectedRuleConfig.display_name" :disabled="isReadOnly" />
|
||||
</label>
|
||||
<label>
|
||||
<span class="help-label" :data-help="fieldHelp('businessPurpose')">{{ t('admin.shippingOrderSchema.businessPurpose') }}</span>
|
||||
<select
|
||||
<ElSelect
|
||||
v-model="selectedRuleConfig.business_purpose"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled || selectedField.scope !== 'line'"
|
||||
>
|
||||
<option
|
||||
v-for="item in ['general', 'part_number', 'quantity', 'reservation_id', 'inventory_source_hint']"
|
||||
<ElOption
|
||||
v-for="item in businessPurposeOptions"
|
||||
:key="item"
|
||||
:label="t(`admin.shippingOrderSchema.businessPurposeOption.${item}`)"
|
||||
:value="item"
|
||||
>
|
||||
{{ t(`admin.shippingOrderSchema.businessPurposeOption.${item}`) }}
|
||||
</option>
|
||||
</select>
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
<label class="span-two">
|
||||
<span class="help-label" :data-help="fieldHelp('aliases')">{{ t('admin.shippingOrderSchema.aliases') }}</span>
|
||||
<input
|
||||
class="input-field"
|
||||
:value="selectedRuleConfig.aliases.join(', ')"
|
||||
<ElInput
|
||||
:model-value="selectedRuleConfig.aliases.join(', ')"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
@input="!isReadOnly && (selectedRuleConfig.aliases = splitValues(($event.target as HTMLInputElement).value))"
|
||||
>
|
||||
@update:model-value="onAliasesInput"
|
||||
/>
|
||||
</label>
|
||||
<label class="span-two">
|
||||
<span class="help-label" :data-help="fieldHelp('extractionInstruction')">{{ t('admin.shippingOrderSchema.extractionInstruction') }}</span>
|
||||
<textarea
|
||||
<ElInput
|
||||
v-model="selectedRuleConfig.extraction_instruction"
|
||||
class="input-field"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
:placeholder="t('admin.shippingOrderSchema.extractionInstructionPlaceholder')"
|
||||
/>
|
||||
@@ -1105,69 +1197,58 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<div class="rule-switches">
|
||||
<label>
|
||||
<input
|
||||
v-model="selectedRuleConfig.required"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled || selectedRuleConfig.auto_create_key_field"
|
||||
type="checkbox"
|
||||
>
|
||||
<ElCheckbox
|
||||
v-model="selectedRuleConfig.required"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled || selectedRuleConfig.auto_create_key_field"
|
||||
>
|
||||
<span class="help-label" :data-help="fieldHelp('required')"><strong>{{ t('admin.shippingOrderSchema.required') }}</strong></span>
|
||||
</label>
|
||||
<label class="key-field-switch">
|
||||
<input
|
||||
</ElCheckbox>
|
||||
<div class="key-field-switch">
|
||||
<ElCheckbox
|
||||
:model-value="selectedRuleConfig.auto_create_key_field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
:checked="selectedRuleConfig.auto_create_key_field"
|
||||
type="checkbox"
|
||||
@change="!isReadOnly && setAutoCreateKeyField(selectedRuleConfig, ($event.target as HTMLInputElement).checked)"
|
||||
@change="onAutoCreateKeyChange"
|
||||
>
|
||||
<span class="help-label" :data-help="fieldHelp('autoCreateKeyField')"><strong>{{ t('admin.shippingOrderSchema.autoCreateKeyField') }}</strong></span>
|
||||
<input
|
||||
<span class="help-label" :data-help="fieldHelp('autoCreateKeyField')"><strong>{{ t('admin.shippingOrderSchema.autoCreateKeyField') }}</strong></span>
|
||||
</ElCheckbox>
|
||||
<ElInputNumber
|
||||
v-if="selectedRuleConfig.auto_create_key_field"
|
||||
v-model.number="selectedRuleConfig.minimum_confidence"
|
||||
class="input-field"
|
||||
v-model="selectedRuleConfig.minimum_confidence"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
:required="selectedRuleConfig.auto_create_key_field"
|
||||
:aria-label="fieldHelp('minimumKeyFieldConfidence')"
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.01"
|
||||
type="number"
|
||||
>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
v-model="selectedRuleConfig.auto_annotation_enabled"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
type="checkbox"
|
||||
>
|
||||
:min="0"
|
||||
:max="1"
|
||||
:step="0.01"
|
||||
:controls="false"
|
||||
/>
|
||||
</div>
|
||||
<ElCheckbox
|
||||
v-model="selectedRuleConfig.auto_annotation_enabled"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<span class="help-label" :data-help="fieldHelp('autoAnnotationEnabled')"><strong>{{ t('admin.shippingOrderSchema.autoAnnotationEnabled') }}</strong></span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
v-model="selectedRuleConfig.evidence_policy.required"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
type="checkbox"
|
||||
>
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
v-model="selectedRuleConfig.evidence_policy.required"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<span class="help-label" :data-help="fieldHelp('evidenceRequired')"><strong>{{ t('admin.shippingOrderSchema.evidenceRequired') }}</strong></span>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
v-model="selectedRuleConfig.evidence_policy.allow_single_source"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
type="checkbox"
|
||||
>
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
v-model="selectedRuleConfig.evidence_policy.allow_single_source"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<span class="help-label" :data-help="fieldHelp('allowSingleSource')"><strong>{{ t('admin.shippingOrderSchema.allowSingleSource') }}</strong></span>
|
||||
</label>
|
||||
<label v-if="selectedIsOrderHeader">
|
||||
<input
|
||||
v-model="selectedRuleConfig.available_for_customer_identity"
|
||||
:disabled="isReadOnly"
|
||||
type="checkbox"
|
||||
>
|
||||
</ElCheckbox>
|
||||
<ElCheckbox
|
||||
v-if="selectedIsOrderHeader"
|
||||
v-model="selectedRuleConfig.available_for_customer_identity"
|
||||
:disabled="isReadOnly"
|
||||
>
|
||||
<span class="help-label" :data-help="fieldHelp('availableForCustomerIdentity')">
|
||||
<strong>{{ t('admin.shippingOrderSchema.availableForCustomerIdentity') }}</strong>
|
||||
</span>
|
||||
</label>
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
|
||||
<details class="advanced-rules">
|
||||
@@ -1176,95 +1257,105 @@ onMounted(async () => {
|
||||
<div class="rule-grid">
|
||||
<label>
|
||||
<span class="help-label" :data-help="fieldHelp('normalizer')">{{ t('admin.shippingOrderSchema.normalizer') }}</span>
|
||||
<select
|
||||
<ElSelect
|
||||
v-model="selectedRuleConfig.normalizer_key"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<option v-for="item in compatibleRules(selectedRuleConfig, 'type_normalizers')" :key="item" :value="item">
|
||||
{{ ruleLabel(item) }}
|
||||
</option>
|
||||
</select>
|
||||
<ElOption
|
||||
v-for="item in compatibleRules(selectedRuleConfig, 'type_normalizers')"
|
||||
:key="item"
|
||||
:label="ruleLabel(item)"
|
||||
:value="item"
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
<label>
|
||||
<span class="help-label" :data-help="fieldHelp('comparator')">{{ t('admin.shippingOrderSchema.comparator') }}</span>
|
||||
<select
|
||||
<ElSelect
|
||||
v-model="selectedRuleConfig.comparator_key"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<option v-for="item in compatibleRules(selectedRuleConfig, 'type_comparators')" :key="item" :value="item">
|
||||
{{ ruleLabel(item) }}
|
||||
</option>
|
||||
</select>
|
||||
<ElOption
|
||||
v-for="item in compatibleRules(selectedRuleConfig, 'type_comparators')"
|
||||
:key="item"
|
||||
:label="ruleLabel(item)"
|
||||
:value="item"
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
<label>
|
||||
<span class="help-label" :data-help="fieldHelp('relationRole')">{{ t('admin.shippingOrderSchema.relationRole') }}</span>
|
||||
<select
|
||||
v-model="selectedRuleConfig.relation_role"
|
||||
class="select-field"
|
||||
<ElSelect
|
||||
:model-value="selectedRuleConfig.relation_role || undefined"
|
||||
clearable
|
||||
:placeholder="t('admin.shippingOrderSchema.notSet')"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
@update:model-value="onRelationRoleChange"
|
||||
>
|
||||
<option :value="null">{{ t('admin.shippingOrderSchema.notSet') }}</option>
|
||||
<option v-for="item in state?.catalog.relation_roles || []" :key="item" :value="item">
|
||||
{{ ruleLabel(item) }}
|
||||
</option>
|
||||
</select>
|
||||
<ElOption
|
||||
v-for="item in state?.catalog.relation_roles || []"
|
||||
:key="item"
|
||||
:label="ruleLabel(item)"
|
||||
:value="item"
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
<label>
|
||||
<span class="help-label" :data-help="fieldHelp('conflictPolicy')">{{ t('admin.shippingOrderSchema.conflictPolicy') }}</span>
|
||||
<select
|
||||
<ElSelect
|
||||
v-model="selectedRuleConfig.evidence_policy.conflict_policy"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<option v-for="item in state?.catalog.conflict_policies || []" :key="item" :value="item">
|
||||
{{ ruleLabel(item) }}
|
||||
</option>
|
||||
</select>
|
||||
<ElOption
|
||||
v-for="item in state?.catalog.conflict_policies || []"
|
||||
:key="item"
|
||||
:label="ruleLabel(item)"
|
||||
:value="item"
|
||||
/>
|
||||
</ElSelect>
|
||||
</label>
|
||||
</div>
|
||||
<fieldset>
|
||||
<legend class="help-label" :data-help="fieldHelp('coordinateSources')">{{ t('admin.shippingOrderSchema.coordinateSources') }}</legend>
|
||||
<div class="check-row compact-check-row">
|
||||
<label v-for="item in ['pdf_coordinate', 'ocr_coordinate'] as const" :key="item">
|
||||
<input
|
||||
:checked="selectedRuleConfig.allowed_sources?.includes(item)"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
type="checkbox"
|
||||
@change="!isReadOnly && (selectedRuleConfig.allowed_sources = toggleValue(selectedRuleConfig.allowed_sources || [], item) as Array<'pdf_coordinate' | 'ocr_coordinate'>)"
|
||||
>
|
||||
<ElCheckbox
|
||||
v-for="item in coordinateSourceOptions"
|
||||
:key="item"
|
||||
:model-value="selectedRuleConfig.allowed_sources?.includes(item)"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
@change="onCoordinateSourceChange(item, $event)"
|
||||
>
|
||||
{{ t(`admin.shippingOrderSchema.coordinateSourceOption.${item}`) }}
|
||||
</label>
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
<small>{{ t('admin.shippingOrderSchema.coordinateSourcesHint') }}</small>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend class="help-label" :data-help="fieldHelp('validators')">{{ t('admin.shippingOrderSchema.validators') }}</legend>
|
||||
<div class="check-row">
|
||||
<label v-for="item in compatibleRules(selectedRuleConfig, 'type_validators')" :key="item">
|
||||
<input
|
||||
:checked="selectedRuleConfig.validator_keys.includes(item)"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
type="checkbox"
|
||||
@change="!isReadOnly && (selectedRuleConfig.validator_keys = toggleValue(selectedRuleConfig.validator_keys, item))"
|
||||
>
|
||||
<ElCheckbox
|
||||
v-for="item in compatibleRules(selectedRuleConfig, 'type_validators')"
|
||||
:key="item"
|
||||
:model-value="selectedRuleConfig.validator_keys.includes(item)"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
@change="onValidatorChange(item, $event)"
|
||||
>
|
||||
{{ ruleLabel(item) }}
|
||||
</label>
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend class="help-label" :data-help="fieldHelp('sourcePrecedence')">{{ t('admin.shippingOrderSchema.sourcePrecedence') }}</legend>
|
||||
<div class="check-row">
|
||||
<label v-for="item in state?.catalog.source_types || []" :key="item">
|
||||
<input
|
||||
:checked="selectedRuleConfig.evidence_policy.source_precedence.includes(item)"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
type="checkbox"
|
||||
@change="!isReadOnly && (selectedRuleConfig.evidence_policy.source_precedence = toggleValue(selectedRuleConfig.evidence_policy.source_precedence, item))"
|
||||
>
|
||||
<ElCheckbox
|
||||
v-for="item in state?.catalog.source_types || []"
|
||||
:key="item"
|
||||
:model-value="selectedRuleConfig.evidence_policy.source_precedence.includes(item)"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
@change="onSourcePrecedenceChange(item, $event)"
|
||||
>
|
||||
{{ sourceLabel(item) }}
|
||||
</label>
|
||||
</ElCheckbox>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -1274,11 +1365,11 @@ onMounted(async () => {
|
||||
<footer v-if="!isReadOnly" class="rule-footer">
|
||||
<label>
|
||||
<span>{{ t('admin.shippingOrderSchema.changeNote') }}</span>
|
||||
<input v-model="changeNote" class="input-field" :placeholder="t('admin.shippingOrderSchema.changeNotePlaceholder')">
|
||||
<ElInput v-model="changeNote" :placeholder="t('admin.shippingOrderSchema.changeNotePlaceholder')" />
|
||||
</label>
|
||||
<button type="button" :disabled="saving" class="btn-danger btn-sm" @click="deleteDraft">
|
||||
<ElButton link type="danger" :disabled="saving" @click="deleteDraft">
|
||||
{{ t('admin.shippingOrderSchema.deleteDraft') }}
|
||||
</button>
|
||||
</ElButton>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
@@ -1328,39 +1419,43 @@ onMounted(async () => {
|
||||
/>
|
||||
<FieldImpactDrawer v-model="fieldImpactOpen" :impact="fieldImpact" :loading="fieldImpactLoading" />
|
||||
|
||||
<div v-if="autoCreationConfirmOpen" class="impact-overlay" @click.self="cancelAutoCreationToggle">
|
||||
<section class="impact-dialog">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingOrderSchema.autoCreationConfirmTitle') }}</h2>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="cancelAutoCreationToggle">{{ t('common.close') }}</button>
|
||||
</header>
|
||||
<p>
|
||||
{{ t('admin.shippingOrderSchema.autoCreationConfirmBody', {
|
||||
next: pendingAutoCreationEnabled
|
||||
? t('admin.shippingOrderSchema.autoCreationOn')
|
||||
: t('admin.shippingOrderSchema.autoCreationOff'),
|
||||
published: publishedAutoCreationEnabled
|
||||
? t('admin.shippingOrderSchema.autoCreationOn')
|
||||
: t('admin.shippingOrderSchema.autoCreationOff'),
|
||||
}) }}
|
||||
</p>
|
||||
<p class="muted">{{ t('admin.shippingOrderSchema.autoCreationConfirmHint') }}</p>
|
||||
<footer>
|
||||
<button type="button" class="btn-secondary" @click="cancelAutoCreationToggle">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" @click="confirmAutoCreationToggle">
|
||||
{{ t('admin.shippingOrderSchema.autoCreationConfirmAction') }}
|
||||
</button>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
<ElDialog
|
||||
v-model="autoCreationConfirmOpen"
|
||||
:title="t('admin.shippingOrderSchema.autoCreationConfirmTitle')"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@close="cancelAutoCreationToggle"
|
||||
>
|
||||
<p>
|
||||
{{ t('admin.shippingOrderSchema.autoCreationConfirmBody', {
|
||||
next: pendingAutoCreationEnabled
|
||||
? t('admin.shippingOrderSchema.autoCreationOn')
|
||||
: t('admin.shippingOrderSchema.autoCreationOff'),
|
||||
published: publishedAutoCreationEnabled
|
||||
? t('admin.shippingOrderSchema.autoCreationOn')
|
||||
: t('admin.shippingOrderSchema.autoCreationOff'),
|
||||
}) }}
|
||||
</p>
|
||||
<p class="muted">{{ t('admin.shippingOrderSchema.autoCreationConfirmHint') }}</p>
|
||||
<template #footer>
|
||||
<ElButton @click="cancelAutoCreationToggle">{{ t('common.cancel') }}</ElButton>
|
||||
<ElButton type="primary" @click="confirmAutoCreationToggle">
|
||||
{{ t('admin.shippingOrderSchema.autoCreationConfirmAction') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
|
||||
<div v-if="profileImpactOpen && profileImpact" class="impact-overlay" @click.self="profileImpactOpen = false">
|
||||
<section class="impact-dialog">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingOrderSchema.profileImpactTitle') }}</h2>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="profileImpactOpen = false">{{ t('common.close') }}</button>
|
||||
</header>
|
||||
<ElDialog
|
||||
v-model="profileImpactOpen"
|
||||
:title="t('admin.shippingOrderSchema.profileImpactTitle')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<template v-if="profileImpact">
|
||||
<p>{{ t('admin.shippingOrderSchema.profileImpactSummary', profileImpact.summary) }}</p>
|
||||
<div class="impact-list">
|
||||
<article v-for="item in profileImpact.items.filter((entry) => entry.status !== 'compatible')" :key="item.profile_id">
|
||||
@@ -1373,47 +1468,44 @@ onMounted(async () => {
|
||||
</ul>
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<button type="button" class="btn-secondary" @click="profileImpactOpen = false">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="confirmPublishWithImpact">
|
||||
{{ t('admin.shippingOrderSchema.confirmImpactPublish') }}
|
||||
</button>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<ElButton @click="profileImpactOpen = false">{{ t('common.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="saving" @click="confirmPublishWithImpact">
|
||||
{{ t('admin.shippingOrderSchema.confirmImpactPublish') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
|
||||
<div v-if="suggestPreviewOpen" class="impact-overlay" @click.self="suggestPreviewOpen = false">
|
||||
<section class="impact-dialog suggest-preview-dialog">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingOrderSchema.suggestPreviewTitle') }}</h2>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="suggestPreviewOpen = false">{{ t('common.close') }}</button>
|
||||
</header>
|
||||
<p v-if="suggestedPreviewCount">
|
||||
{{ t('admin.shippingOrderSchema.suggestPreviewIntro', { count: suggestedPreviewCount }) }}
|
||||
</p>
|
||||
<p v-else>{{ t('admin.shippingOrderSchema.suggestPreviewEmpty') }}</p>
|
||||
<ul v-if="suggestedPreviewCount" class="suggest-preview-list">
|
||||
<li v-for="item in suggestedPreviewItems" :key="item.field_id">
|
||||
<strong>{{ item.display_name }}</strong>
|
||||
<code>{{ item.field_code }}</code>
|
||||
</li>
|
||||
</ul>
|
||||
<footer>
|
||||
<button type="button" class="btn-secondary" @click="suggestPreviewOpen = false">
|
||||
{{ t('admin.shippingOrderSchema.suggestCancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="!suggestedPreviewCount"
|
||||
@click="confirmAdoptSuggested"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.suggestConfirm') }}
|
||||
</button>
|
||||
</footer>
|
||||
</section>
|
||||
</div>
|
||||
<ElDialog
|
||||
v-model="suggestPreviewOpen"
|
||||
:title="t('admin.shippingOrderSchema.suggestPreviewTitle')"
|
||||
width="480px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p v-if="suggestedPreviewCount">
|
||||
{{ t('admin.shippingOrderSchema.suggestPreviewIntro', { count: suggestedPreviewCount }) }}
|
||||
</p>
|
||||
<p v-else>{{ t('admin.shippingOrderSchema.suggestPreviewEmpty') }}</p>
|
||||
<ul v-if="suggestedPreviewCount" class="suggest-preview-list">
|
||||
<li v-for="item in suggestedPreviewItems" :key="item.field_id">
|
||||
<strong>{{ item.display_name }}</strong>
|
||||
<code>{{ item.field_code }}</code>
|
||||
</li>
|
||||
</ul>
|
||||
<template #footer>
|
||||
<ElButton @click="suggestPreviewOpen = false">
|
||||
{{ t('admin.shippingOrderSchema.suggestCancel') }}
|
||||
</ElButton>
|
||||
<ElButton type="primary" :disabled="!suggestedPreviewCount" @click="confirmAdoptSuggested">
|
||||
{{ t('admin.shippingOrderSchema.suggestConfirm') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@@ -1489,7 +1581,7 @@ onMounted(async () => {
|
||||
.panel-heading h2, .rule-heading h2 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }
|
||||
.panel-heading p { margin: 5px 0 0; color: #94a3b8; font-size: 12px; line-height: 1.5; }
|
||||
.field-search { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #e5ebf1; padding: 8px 12px 12px; }
|
||||
.field-search .input-field { min-width: 0; flex: 1; padding: 7px 9px; font: inherit; font-size: 12px; }
|
||||
.schema-field-search { width: 16rem; max-width: 100%; }
|
||||
.field-search span { flex: 0 0 auto; color: #94a3b8; font-size: 11px; }
|
||||
.adoption-guide { margin: 0 12px 8px; border: 1px solid #dbe6ef; border-radius: 7px; background: #f8fafc; padding: 8px 9px; color: #64748b; font-size: 11px; line-height: 1.4; }
|
||||
.field-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 12px; }
|
||||
@@ -1533,7 +1625,6 @@ onMounted(async () => {
|
||||
.rule-basics .span-two { grid-column: 1 / -1; }
|
||||
.rule-basics { border: 1px solid #edf1f5; border-radius: 8px; background: #fcfdff; padding: 12px; }
|
||||
.rule-body label, .rule-footer label { display: grid; gap: 3px; color: #64748b; font-size: 12px; }
|
||||
.rule-body .input-field, .rule-body .select-field, .rule-footer .input-field { min-width: 0; padding: 6px 8px; font: inherit; font-size: 13px; }
|
||||
.rule-body input:disabled, .rule-body select:disabled, .rule-body textarea:disabled { background: #f8fafc; color: #64748b; }
|
||||
.rule-body input[type="checkbox"]:disabled { appearance: auto; opacity: 1; accent-color: #0ea5e9; }
|
||||
.rule-body textarea { min-height: 56px; resize: vertical; }
|
||||
|
||||
+5
-2
@@ -5,6 +5,7 @@
|
||||
逻辑:父组件分页读取最小审计摘要;展示字段集合变更与自动建单策略变更,不展示完整快照。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ElButton } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderSchemaAuditEvent } from '@/features/admin/types/shipping-order-schema.types';
|
||||
|
||||
@@ -90,7 +91,9 @@ const autoCreationSummary = (event: ShippingOrderSchemaAuditEvent): string => {
|
||||
<small v-if="hasFieldChanges(event)">{{ t('admin.shippingOrderSchema.auditFieldSummary', { added: (event.change_summary.added_field_ids as string[] | undefined)?.length || 0, removed: (event.change_summary.removed_field_ids as string[] | undefined)?.length || 0, changed: (event.change_summary.changed_field_ids as string[] | undefined)?.length || 0 }) }}</small>
|
||||
<small v-if="hasAutoCreationChange(event) && autoCreationSummary(event)" class="audit-auto-creation">{{ autoCreationSummary(event) }}</small>
|
||||
</article>
|
||||
<button v-if="events.length < total" type="button" :disabled="loading" @click="emit('loadMore')">{{ loading ? t('common.loading') : t('admin.shippingOrderSchema.auditLoadMore') }}</button>
|
||||
<ElButton v-if="events.length < total" class="audit-more" :loading="loading" :disabled="loading" @click="emit('loadMore')">
|
||||
{{ t('admin.shippingOrderSchema.auditLoadMore') }}
|
||||
</ElButton>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -104,6 +107,6 @@ const autoCreationSummary = (event: ShippingOrderSchemaAuditEvent): string => {
|
||||
.audit-event > span { margin-left: 6px; color: #0369a1; font-size: 11px; }
|
||||
.audit-event p, .audit-event small { display: block; margin: 4px 0 0; color: #94a3b8; font-size: 11px; }
|
||||
.audit-auto-creation { color: #0f766e !important; }
|
||||
.audit-timeline > button { width: 100%; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; padding: 8px; color: #0284c7; font: inherit; font-size: 12px; cursor: pointer; }
|
||||
.audit-more { width: 100%; margin-top: 8px; }
|
||||
.audit-empty { color: #94a3b8; font-size: 12px; }
|
||||
</style>
|
||||
+52
-21
@@ -1,17 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaExtractionAuditDrawer.vue
|
||||
用途:以只读方式展示一条订单解析的冻结输入、LLM 输出、裁决和字段证据。
|
||||
依赖:ShippingOrderExtractionAudit DTO、Vue I18n。
|
||||
逻辑:复杂运行数据由服务端完整组装;组件使用 JSON 预格式化展示,禁止在审计视图编辑或重放解析。
|
||||
依赖:element-plus ElDrawer、ShippingOrderExtractionAudit DTO、Vue I18n。
|
||||
逻辑:复杂运行数据由服务端完整组装;组件使用 JSON 预格式化展示,禁止在审计视图编辑或重放解析。侧栏用 ElDrawer。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { ElDrawer, ElLoading } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderExtractionAudit } from '@/features/admin/types/shipping-order-schema.types';
|
||||
|
||||
const props = defineProps<{ modelValue: boolean; audit: ShippingOrderExtractionAudit | null; loading: boolean }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [visible: boolean] }>();
|
||||
const { t } = useI18n();
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
/** 保持审计载荷原样可读,并安全处理缺失或非对象值。 */
|
||||
const json = (value: unknown): string => JSON.stringify(value ?? null, null, 2);
|
||||
@@ -19,27 +21,56 @@ const documents = computed(() => Array.isArray(props.audit?.input_snapshot.docum
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="audit-detail-layer" role="presentation" @click.self="emit('update:modelValue', false)">
|
||||
<aside class="audit-detail-drawer" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderSchema.runtimeAuditTitle')">
|
||||
<header><div><p>{{ t('admin.shippingOrderSchema.runtimeAuditEyebrow') }}</p><h2>{{ t('admin.shippingOrderSchema.runtimeAuditTitle') }}</h2></div><button type="button" :aria-label="t('common.close')" @click="emit('update:modelValue', false)">×</button></header>
|
||||
<main v-if="loading" class="audit-detail-empty">{{ t('common.loading') }}</main>
|
||||
<main v-else-if="audit">
|
||||
<dl class="audit-meta"><div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditExtraction') }}</dt><dd>#{{ audit.extraction.id }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditVersion') }}</dt><dd>V{{ audit.schema_version.version }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditStatus') }}</dt><dd>{{ t(`admin.shippingOrderSchema.extractionStatus.${audit.extraction.status}`) }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditHash') }}</dt><dd><code>{{ audit.extraction.input_snapshot_hash }}</code></dd></div></dl>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditInput') }}</h3><p v-if="audit.input_snapshot.snapshot_available === false" class="snapshot-unavailable">{{ t('admin.shippingOrderSchema.runtimeAuditInputUnavailable') }}</p><article v-for="document in documents" :key="String(document.id)" class="audit-document"><strong>{{ String(document.filename || document.id) }}</strong><pre>{{ String(document.extracted_text || '') }}</pre></article></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditLlm') }}</h3><pre>{{ json(audit.raw_llm_output) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditNormalized') }}</h3><pre>{{ json(audit.normalized_result) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditValidation') }}</h3><pre>{{ json(audit.validation_result) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditDecisions') }} ({{ audit.decisions.length }})</h3><pre>{{ json(audit.decisions) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditEvidence') }} ({{ audit.observations.length }})</h3><pre>{{ json(audit.observations) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditValues') }} ({{ audit.field_values.length }})</h3><pre>{{ json(audit.field_values) }}</pre></section>
|
||||
</main>
|
||||
<main v-else class="audit-detail-empty">{{ t('admin.shippingOrderSchema.runtimeAuditEmpty') }}</main>
|
||||
</aside>
|
||||
<ElDrawer
|
||||
:model-value="modelValue"
|
||||
:title="t('admin.shippingOrderSchema.runtimeAuditTitle')"
|
||||
direction="rtl"
|
||||
size="900px"
|
||||
append-to-body
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
>
|
||||
<p class="drawer-kicker">{{ t('admin.shippingOrderSchema.runtimeAuditEyebrow') }}</p>
|
||||
<div v-loading="loading" class="audit-body">
|
||||
<template v-if="audit">
|
||||
<dl class="audit-meta">
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditExtraction') }}</dt><dd>#{{ audit.extraction.id }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditVersion') }}</dt><dd>V{{ audit.schema_version.version }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditStatus') }}</dt><dd>{{ t(`admin.shippingOrderSchema.extractionStatus.${audit.extraction.status}`) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.runtimeAuditHash') }}</dt><dd><code>{{ audit.extraction.input_snapshot_hash }}</code></dd></div>
|
||||
</dl>
|
||||
<section>
|
||||
<h3>{{ t('admin.shippingOrderSchema.runtimeAuditInput') }}</h3>
|
||||
<p v-if="audit.input_snapshot.snapshot_available === false" class="snapshot-unavailable">{{ t('admin.shippingOrderSchema.runtimeAuditInputUnavailable') }}</p>
|
||||
<article v-for="document in documents" :key="String(document.id)" class="audit-document">
|
||||
<strong>{{ String(document.filename || document.id) }}</strong>
|
||||
<pre>{{ String(document.extracted_text || '') }}</pre>
|
||||
</article>
|
||||
</section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditLlm') }}</h3><pre>{{ json(audit.raw_llm_output) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditNormalized') }}</h3><pre>{{ json(audit.normalized_result) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditValidation') }}</h3><pre>{{ json(audit.validation_result) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditDecisions') }} ({{ audit.decisions.length }})</h3><pre>{{ json(audit.decisions) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditEvidence') }} ({{ audit.observations.length }})</h3><pre>{{ json(audit.observations) }}</pre></section>
|
||||
<section><h3>{{ t('admin.shippingOrderSchema.runtimeAuditValues') }} ({{ audit.field_values.length }})</h3><pre>{{ json(audit.field_values) }}</pre></section>
|
||||
</template>
|
||||
<p v-else-if="!loading" class="audit-empty">{{ t('admin.shippingOrderSchema.runtimeAuditEmpty') }}</p>
|
||||
</div>
|
||||
</Teleport>
|
||||
</ElDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.audit-detail-layer { position: fixed; z-index: 90; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 40%); backdrop-filter: blur(2px); }.audit-detail-drawer { display: flex; width: min(900px, 97vw); height: 100%; flex-direction: column; overflow: hidden; background: #f8fafc; box-shadow: -18px 0 48px rgb(15 23 42 / 22%); }.audit-detail-drawer > header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 22px 26px; }.audit-detail-drawer header p { margin: 0 0 4px; color: #0284c7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }.audit-detail-drawer h2 { margin: 0; color: #1e293b; font-size: 20px; }.audit-detail-drawer > header button { width: 32px; height: 32px; border: 1px solid #dbe5ee; border-radius: 50%; background: #fff; color: #475569; font-size: 22px; line-height: 1; cursor: pointer; }.audit-detail-drawer main { overflow-y: auto; padding: 24px 26px; }.audit-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 20px; }.audit-meta div { border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 10px; }.audit-meta dt { color: #94a3b8; font-size: 10px; }.audit-meta dd { margin: 5px 0 0; color: #334155; font-size: 12px; overflow-wrap: anywhere; }.audit-detail-drawer section { margin-top: 18px; }.audit-detail-drawer h3 { margin: 0 0 8px; color: #64748b; font-size: 12px; }.audit-detail-drawer pre { overflow: auto; max-height: 340px; margin: 0; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 12px; color: #334155; font: 11px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }.audit-document { margin-top: 8px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 12px; }.audit-document strong { color: #334155; font-size: 12px; }.audit-document pre { max-height: 220px; margin-top: 8px; border: 0; background: #f8fafc; }.snapshot-unavailable { margin: 0; border: 1px solid #fde68a; border-radius: 7px; background: #fffbeb; padding: 9px; color: #a16207; font-size: 12px; }.audit-detail-empty { display: grid; min-height: 240px; place-items: center; color: #94a3b8; font-size: 13px; }@media (max-width: 640px) { .audit-detail-drawer main { padding: 18px; }.audit-meta { grid-template-columns: 1fr; } }
|
||||
.drawer-kicker { margin: 0 0 12px; color: var(--el-color-primary); font-weight: 700; }
|
||||
.audit-body { min-height: 240px; }
|
||||
.audit-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 20px; }
|
||||
.audit-meta div { border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 10px; }
|
||||
.audit-meta dt { color: var(--el-text-color-secondary); }
|
||||
.audit-meta dd { margin: 5px 0 0; overflow-wrap: anywhere; }
|
||||
.audit-body section { margin-top: 18px; }
|
||||
.audit-body h3 { margin: 0 0 8px; color: var(--el-text-color-secondary); }
|
||||
.audit-body pre { overflow: auto; max-height: 340px; margin: 0; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 12px; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
|
||||
.audit-document { margin-top: 8px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 12px; }
|
||||
.audit-document pre { max-height: 220px; margin-top: 8px; }
|
||||
.snapshot-unavailable { margin: 0; border: 1px solid var(--el-color-warning-light-5); border-radius: 7px; background: var(--el-color-warning-light-9); padding: 9px; color: var(--el-color-warning); }
|
||||
.audit-empty { display: grid; min-height: 180px; place-items: center; color: var(--el-text-color-secondary); }
|
||||
@media (max-width: 640px) { .audit-meta { grid-template-columns: 1fr; } }
|
||||
</style>
|
||||
+91
-25
@@ -1,11 +1,12 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaVersionDiffDrawer.vue
|
||||
用途:只读展示两个订单 Schema 版本的服务端语义化字段差异。
|
||||
依赖:ShippingOrderSchemaVersionDiff DTO、Vue I18n。
|
||||
逻辑:父组件负责加载差异;本组件只根据后端 field_id 差异结构渲染,绝不自行推断字段是否重命名。
|
||||
依赖:element-plus ElDrawer、ShippingOrderSchemaVersionDiff DTO、Vue I18n。
|
||||
逻辑:父组件负责加载差异;本组件只根据后端 field_id 差异结构渲染,绝不自行推断字段是否重命名。侧栏用 ElDrawer。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { ElDrawer, ElLoading, ElTag } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type {
|
||||
ShippingOrderSchemaFieldChange,
|
||||
@@ -16,22 +17,43 @@ import type {
|
||||
const props = defineProps<{ modelValue: boolean; diff: ShippingOrderSchemaVersionDiff | null; loading: boolean }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [visible: boolean] }>();
|
||||
const { t } = useI18n();
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
/** 隐藏未变化字段,审计人员只聚焦实际配置差异。 */
|
||||
const changedFields = computed(() => props.diff?.fields.filter((item) => item.change_type !== 'unchanged') || []);
|
||||
const summaryKeys = ['added', 'removed', 'modified'] as const;
|
||||
|
||||
/** 为差异条目提供当前或历史快照中最具识别性的字段名称。 */
|
||||
/**
|
||||
* 读取差异摘要计数,未知键按 0 处理。
|
||||
* @param key - added / removed / modified
|
||||
*/
|
||||
function summaryCount(key: string): number {
|
||||
if (!props.diff) return 0;
|
||||
if (key === 'added' || key === 'removed' || key === 'modified') return props.diff.summary[key];
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为差异条目提供当前或历史快照中最具识别性的字段名称。
|
||||
* @param field - 单字段差异
|
||||
*/
|
||||
const fieldLabel = (field: ShippingOrderSchemaFieldDiff): string =>
|
||||
field.after?.display_name || field.before?.display_name || field.after?.field_code || field.before?.field_code || field.field_id;
|
||||
|
||||
/** 将后端属性键映射为可本地化的审计标签,未知键仍保留原键以防信息丢失。 */
|
||||
/**
|
||||
* 将后端属性键映射为可本地化的审计标签,未知键仍保留原键以防信息丢失。
|
||||
* @param change - 字段属性变更
|
||||
*/
|
||||
const changeLabel = (change: ShippingOrderSchemaFieldChange): string => {
|
||||
const key = `admin.shippingOrderSchema.diffField.${change.key}`;
|
||||
const translated = t(key);
|
||||
return translated === key ? change.key : translated;
|
||||
};
|
||||
|
||||
/** 标量和集合使用紧凑文本;结构化来源使用稳定 JSON,避免退化为 [object Object]。 */
|
||||
/**
|
||||
* 标量和集合使用紧凑文本;结构化来源使用稳定 JSON,避免退化为 [object Object]。
|
||||
* @param value - 差异前后的原始值
|
||||
*/
|
||||
const valueText = (value: unknown): string => {
|
||||
if (value === null || value === undefined || value === '') return t('admin.shippingOrderSchema.diffEmpty');
|
||||
if (Array.isArray(value)) return value.join(', ') || t('admin.shippingOrderSchema.diffEmpty');
|
||||
@@ -41,28 +63,72 @@ const valueText = (value: unknown): string => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="diff-layer" role="presentation" @click.self="emit('update:modelValue', false)">
|
||||
<aside class="diff-drawer" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderSchema.diffTitle')">
|
||||
<header><div><p>{{ t('admin.shippingOrderSchema.diffEyebrow') }}</p><h2>{{ t('admin.shippingOrderSchema.diffTitle') }}</h2></div><button type="button" :aria-label="t('common.close')" @click="emit('update:modelValue', false)">×</button></header>
|
||||
<main v-if="loading" class="empty">{{ t('common.loading') }}</main>
|
||||
<main v-else-if="diff">
|
||||
<p class="comparison">V{{ diff.base_version.version }} {{ t('admin.shippingOrderSchema.diffComparedWith') }} V{{ diff.compare_version.version }}</p>
|
||||
<div class="summary"><span v-for="key in ['added', 'removed', 'modified']" :key="key">{{ t(`admin.shippingOrderSchema.diffStatus.${key}`) }} <b>{{ diff.summary[key as 'added' | 'removed' | 'modified'] }}</b></span></div>
|
||||
<article v-for="field in changedFields" :key="field.field_id" class="diff-field" :class="field.change_type">
|
||||
<header><div><strong>{{ fieldLabel(field) }}</strong><code>{{ field.after?.field_code || field.before?.field_code }}</code></div><span>{{ t(`admin.shippingOrderSchema.diffStatus.${field.change_type}`) }}</span></header>
|
||||
<template v-if="field.change_type === 'added'"><p>{{ t('admin.shippingOrderSchema.diffAddedField') }}</p></template>
|
||||
<template v-else-if="field.change_type === 'removed'"><p>{{ t('admin.shippingOrderSchema.diffRemovedField') }}</p></template>
|
||||
<dl v-else><div v-for="change in field.changes" :key="change.key"><dt>{{ changeLabel(change) }}</dt><dd><del>{{ valueText(change.before) }}</del><ins>{{ valueText(change.after) }}</ins><small v-if="change.order_changed">{{ t('admin.shippingOrderSchema.diffOrderChanged') }}</small></dd></div></dl>
|
||||
</article>
|
||||
<p v-if="!changedFields.length" class="empty">{{ t('admin.shippingOrderSchema.diffNoChanges') }}</p>
|
||||
</main>
|
||||
<main v-else class="empty">{{ t('admin.shippingOrderSchema.diffNoChanges') }}</main>
|
||||
</aside>
|
||||
<ElDrawer
|
||||
:model-value="modelValue"
|
||||
:title="t('admin.shippingOrderSchema.diffTitle')"
|
||||
direction="rtl"
|
||||
size="760px"
|
||||
append-to-body
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
>
|
||||
<p class="drawer-kicker">{{ t('admin.shippingOrderSchema.diffEyebrow') }}</p>
|
||||
<div v-loading="loading" class="diff-body">
|
||||
<template v-if="diff">
|
||||
<p class="comparison">V{{ diff.base_version.version }} {{ t('admin.shippingOrderSchema.diffComparedWith') }} V{{ diff.compare_version.version }}</p>
|
||||
<div class="summary">
|
||||
<ElTag v-for="key in summaryKeys" :key="key" effect="light">
|
||||
{{ t(`admin.shippingOrderSchema.diffStatus.${key}`) }}
|
||||
<b>{{ summaryCount(key) }}</b>
|
||||
</ElTag>
|
||||
</div>
|
||||
<article v-for="field in changedFields" :key="field.field_id" class="diff-field" :class="field.change_type">
|
||||
<header>
|
||||
<div>
|
||||
<strong>{{ fieldLabel(field) }}</strong>
|
||||
<code>{{ field.after?.field_code || field.before?.field_code }}</code>
|
||||
</div>
|
||||
<ElTag effect="light">{{ t(`admin.shippingOrderSchema.diffStatus.${field.change_type}`) }}</ElTag>
|
||||
</header>
|
||||
<template v-if="field.change_type === 'added'"><p>{{ t('admin.shippingOrderSchema.diffAddedField') }}</p></template>
|
||||
<template v-else-if="field.change_type === 'removed'"><p>{{ t('admin.shippingOrderSchema.diffRemovedField') }}</p></template>
|
||||
<dl v-else>
|
||||
<div v-for="change in field.changes" :key="change.key">
|
||||
<dt>{{ changeLabel(change) }}</dt>
|
||||
<dd>
|
||||
<del>{{ valueText(change.before) }}</del>
|
||||
<ins>{{ valueText(change.after) }}</ins>
|
||||
<small v-if="change.order_changed">{{ t('admin.shippingOrderSchema.diffOrderChanged') }}</small>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</article>
|
||||
<p v-if="!changedFields.length" class="empty">{{ t('admin.shippingOrderSchema.diffNoChanges') }}</p>
|
||||
</template>
|
||||
<p v-else-if="!loading" class="empty">{{ t('admin.shippingOrderSchema.diffNoChanges') }}</p>
|
||||
</div>
|
||||
</Teleport>
|
||||
</ElDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.diff-layer { position: fixed; z-index: 80; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 35%); backdrop-filter: blur(2px); }.diff-drawer { display: flex; width: min(760px, 96vw); height: 100%; flex-direction: column; overflow: hidden; background: #f8fafc; box-shadow: -18px 0 48px rgb(15 23 42 / 18%); }.diff-drawer > header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 22px 26px; }.diff-drawer header p { margin: 0 0 4px; color: #0284c7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }.diff-drawer h2 { margin: 0; color: #1e293b; font-size: 20px; }.diff-drawer > header button { width: 32px; height: 32px; border: 1px solid #dbe5ee; border-radius: 50%; background: #fff; color: #475569; font-size: 22px; line-height: 1; cursor: pointer; }.diff-drawer main { overflow-y: auto; padding: 24px 26px; }.comparison { margin: 0 0 10px; color: #64748b; font-size: 13px; }.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }.summary span, .diff-field > header > span { border-radius: 999px; background: #e0f2fe; padding: 3px 7px; color: #0369a1; font-size: 11px; }.summary b { margin-left: 3px; }.diff-field { margin-top: 10px; border: 1px solid #e2e8f0; border-left-width: 3px; border-radius: 8px; background: #fff; padding: 13px; }.diff-field.added { border-left-color: #22c55e; }.diff-field.removed { border-left-color: #ef4444; }.diff-field.modified { border-left-color: #0ea5e9; }.diff-field > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }.diff-field strong { display: block; color: #1e293b; font-size: 13px; }.diff-field code { color: #64748b; font-size: 11px; }.diff-field > p { margin: 10px 0 0; color: #64748b; font-size: 12px; }.diff-field dl { display: grid; gap: 8px; margin: 12px 0 0; }.diff-field dl div { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 8px; }.diff-field dt { color: #64748b; font-size: 11px; }.diff-field dd { display: grid; gap: 4px; margin: 0; color: #475569; font-size: 12px; overflow-wrap: anywhere; }.diff-field del { color: #b91c1c; text-decoration: line-through; }.diff-field ins { color: #15803d; text-decoration: none; }.diff-field small { color: #a16207; font-size: 10px; }.empty { display: grid; min-height: 240px; place-items: center; color: #94a3b8; font-size: 13px; }@media (max-width: 640px) { .diff-drawer main { padding: 18px; }.diff-field dl div { grid-template-columns: 1fr; gap: 3px; } }
|
||||
.drawer-kicker { margin: 0 0 12px; color: var(--el-color-primary); font-weight: 700; }
|
||||
.diff-body { min-height: 240px; }
|
||||
.comparison { margin: 0 0 10px; color: var(--el-text-color-secondary); }
|
||||
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
|
||||
.summary b { margin-left: 3px; }
|
||||
.diff-field { margin-top: 10px; border: 1px solid var(--el-border-color); border-left-width: 3px; border-radius: 8px; padding: 13px; }
|
||||
.diff-field.added { border-left-color: var(--el-color-success); }
|
||||
.diff-field.removed { border-left-color: var(--el-color-danger); }
|
||||
.diff-field.modified { border-left-color: var(--el-color-primary); }
|
||||
.diff-field > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
|
||||
.diff-field strong { display: block; }
|
||||
.diff-field code { color: var(--el-text-color-secondary); }
|
||||
.diff-field > p { margin: 10px 0 0; color: var(--el-text-color-secondary); }
|
||||
.diff-field dl { display: grid; gap: 8px; margin: 12px 0 0; }
|
||||
.diff-field dl div { display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 8px; }
|
||||
.diff-field dt { color: var(--el-text-color-secondary); }
|
||||
.diff-field dd { display: grid; gap: 4px; margin: 0; overflow-wrap: anywhere; }
|
||||
.diff-field del { color: var(--el-color-danger); text-decoration: line-through; }
|
||||
.diff-field ins { color: var(--el-color-success); text-decoration: none; }
|
||||
.empty { display: grid; min-height: 180px; place-items: center; color: var(--el-text-color-secondary); }
|
||||
@media (max-width: 640px) { .diff-field dl div { grid-template-columns: 1fr; gap: 3px; } }
|
||||
</style>
|
||||
+87
-63
@@ -1,11 +1,12 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaVersionHistoryDrawer.vue
|
||||
用途:以时间线和完整只读快照浏览订单 Schema 的草稿、发布及退役版本。
|
||||
依赖:ShippingOrderSchemaVersion DTO、Vue I18n。
|
||||
逻辑:父页面加载版本概要和按需详情;本组件仅展示并发出选择/关闭事件,不修改任何版本配置。
|
||||
依赖:element-plus ElDrawer / ElButton / ElTag、ShippingOrderSchemaVersion DTO、Vue I18n。
|
||||
逻辑:父页面加载版本概要和按需详情;本组件仅展示并发出选择/关闭事件,不修改任何版本配置。侧栏用 ElDrawer。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { ElButton, ElDrawer, ElTag } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import SchemaAuditTimeline from '@/features/admin/modules/shipping-order-schema/components/SchemaAuditTimeline.vue';
|
||||
import type { ShippingOrderField, ShippingOrderSchemaVersion } from '@/features/admin/types/shipping-order-schema.types';
|
||||
@@ -48,6 +49,16 @@ const formatDate = (value?: string | null): string => {
|
||||
const statusLabel = (status: ShippingOrderSchemaVersion['status']): string =>
|
||||
t(`admin.shippingOrderSchema.historyStatus.${status}`);
|
||||
|
||||
/**
|
||||
* 版本状态对应的标签颜色。发布为成功,草稿为警告,退役为信息。
|
||||
* @param status - 版本状态
|
||||
*/
|
||||
const statusTagType = (status: ShippingOrderSchemaVersion['status']): 'success' | 'warning' | 'info' => {
|
||||
if (status === 'published') return 'success';
|
||||
if (status === 'draft') return 'warning';
|
||||
return 'info';
|
||||
};
|
||||
|
||||
/** 历史通用字段直接展示冻结来源键,不依赖当前可能已停用或改名的来源目录。 */
|
||||
const contextSourceLabel = (field: NonNullable<ShippingOrderSchemaVersion['definition']>['fields'][number]): string =>
|
||||
field.context_source?.source_key || '-';
|
||||
@@ -61,40 +72,44 @@ const fields = computed(() => {
|
||||
return leftOrder - rightOrder;
|
||||
});
|
||||
});
|
||||
|
||||
/** 关闭抽屉时由父页面同步清除 URL 中的版本查询参数。 */
|
||||
const close = (): void => emit('update:modelValue', false);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="history-layer" role="presentation" @click.self="close">
|
||||
<aside class="history-drawer" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderSchema.historyTitle')">
|
||||
<header class="history-header">
|
||||
<div><p>{{ t('admin.shippingOrderSchema.historyEyebrow') }}</p><h2>{{ t('admin.shippingOrderSchema.historyTitle') }}</h2></div>
|
||||
<button type="button" class="history-close" :aria-label="t('common.close')" @click="close">×</button>
|
||||
</header>
|
||||
<ElDrawer
|
||||
:model-value="modelValue"
|
||||
direction="rtl"
|
||||
size="1060px"
|
||||
append-to-body
|
||||
class="history-drawer"
|
||||
:aria-label="t('admin.shippingOrderSchema.historyTitle')"
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
>
|
||||
<template #header>
|
||||
<div>
|
||||
<p class="drawer-kicker">{{ t('admin.shippingOrderSchema.historyEyebrow') }}</p>
|
||||
<span class="drawer-title">{{ t('admin.shippingOrderSchema.historyTitle') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="history-content">
|
||||
<nav class="history-timeline" :aria-label="t('admin.shippingOrderSchema.historyTitle')">
|
||||
<button
|
||||
v-for="item in versions"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="history-item"
|
||||
:class="{ selected: selectedVersion?.id === item.id }"
|
||||
@click="emit('select', item.id)"
|
||||
>
|
||||
<span class="history-version">V{{ item.version }}</span>
|
||||
<span class="history-status" :class="item.status">{{ statusLabel(item.status) }}</span>
|
||||
<strong>{{ item.change_note || t('admin.shippingOrderSchema.historyNoNote') }}</strong>
|
||||
<small>{{ formatDate(item.published_at || item.created_at) }}</small>
|
||||
<small>{{ item.published_by?.display_name || item.created_by?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</small>
|
||||
</button>
|
||||
<button v-if="versions.length < total" type="button" class="history-more" :disabled="loading" @click="emit('loadMore')">
|
||||
{{ loading ? t('common.loading') : t('admin.shippingOrderSchema.historyLoadMore') }}
|
||||
</button>
|
||||
</nav>
|
||||
<div class="history-content">
|
||||
<nav class="history-timeline" :aria-label="t('admin.shippingOrderSchema.historyTitle')">
|
||||
<ElButton
|
||||
v-for="item in versions"
|
||||
:key="item.id"
|
||||
class="history-item"
|
||||
:class="{ selected: selectedVersion?.id === item.id }"
|
||||
@click="emit('select', item.id)"
|
||||
>
|
||||
<span class="history-version">V{{ item.version }}</span>
|
||||
<ElTag class="history-status" :type="statusTagType(item.status)" effect="light">{{ statusLabel(item.status) }}</ElTag>
|
||||
<strong>{{ item.change_note || t('admin.shippingOrderSchema.historyNoNote') }}</strong>
|
||||
<small>{{ formatDate(item.published_at || item.created_at) }}</small>
|
||||
<small>{{ item.published_by?.display_name || item.created_by?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</small>
|
||||
</ElButton>
|
||||
<ElButton v-if="versions.length < total" class="history-more" :loading="loading" :disabled="loading" @click="emit('loadMore')">
|
||||
{{ t('admin.shippingOrderSchema.historyLoadMore') }}
|
||||
</ElButton>
|
||||
</nav>
|
||||
|
||||
<section class="history-detail">
|
||||
<div v-if="detailLoading" class="history-empty">{{ t('common.loading') }}</div>
|
||||
@@ -109,12 +124,12 @@ const close = (): void => emit('update:modelValue', false);
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.historyChecksum') }}</dt><dd><code>{{ selectedVersion.checksum || '-' }}</code></dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.changeNote') }}</dt><dd>{{ selectedVersion.change_note || t('admin.shippingOrderSchema.historyNoNote') }}</dd></div>
|
||||
</dl>
|
||||
<button v-if="comparisonTarget" type="button" class="compare-button" @click="emit('compare', selectedVersion.id)">
|
||||
<ElButton v-if="comparisonTarget" link type="primary" @click="emit('compare', selectedVersion.id)">
|
||||
{{ t('admin.shippingOrderSchema.diffWithCurrent', { version: comparisonTarget.version }) }}
|
||||
</button>
|
||||
</ElButton>
|
||||
<div class="history-actions">
|
||||
<button type="button" class="compare-button" @click="emit('usage', selectedVersion.id)">{{ t('admin.shippingOrderSchema.usageOpen') }}</button>
|
||||
<button v-if="selectedVersion.status !== 'draft'" type="button" class="compare-button" :disabled="copying" @click="emit('copy', selectedVersion.id)">{{ t('admin.shippingOrderSchema.copyToDraft') }}</button>
|
||||
<ElButton link type="primary" @click="emit('usage', selectedVersion.id)">{{ t('admin.shippingOrderSchema.usageOpen') }}</ElButton>
|
||||
<ElButton v-if="selectedVersion.status !== 'draft'" link type="primary" :disabled="copying" :loading="copying" @click="emit('copy', selectedVersion.id)">{{ t('admin.shippingOrderSchema.copyToDraft') }}</ElButton>
|
||||
</div>
|
||||
<div class="snapshot-heading"><span>{{ t('admin.shippingOrderSchema.historySnapshotFields') }}</span><b>{{ fields.length }}</b></div>
|
||||
<article v-for="field in fields" :key="field.field_id" class="snapshot-field" :class="{ excluded: field.enabled === false }">
|
||||
@@ -132,35 +147,44 @@ const close = (): void => emit('update:modelValue', false);
|
||||
</template>
|
||||
<div v-else class="history-empty">{{ t('admin.shippingOrderSchema.historySelectVersion') }}</div>
|
||||
</section>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</Teleport>
|
||||
</ElDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.history-layer { position: fixed; z-index: 70; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 30%); backdrop-filter: blur(2px); }
|
||||
.history-drawer { display: flex; width: min(1060px, 96vw); height: 100%; flex-direction: column; background: #f8fafc; box-shadow: -18px 0 48px rgb(15 23 42 / 18%); }
|
||||
.history-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 22px 26px; }
|
||||
.history-header p, .detail-heading p { margin: 0 0 4px; color: #0284c7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
|
||||
.history-header h2, .detail-heading h3 { margin: 0; color: #1e293b; font-size: 20px; }
|
||||
.history-close { width: 32px; height: 32px; border: 1px solid #dbe5ee; border-radius: 50%; background: #fff; color: #475569; font-size: 22px; line-height: 1; cursor: pointer; }
|
||||
.history-content { display: grid; min-height: 0; flex: 1; grid-template-columns: 290px minmax(0, 1fr); }
|
||||
.history-timeline { overflow-y: auto; border-right: 1px solid #e2e8f0; background: #f1f5f9; padding: 14px 10px; }
|
||||
.history-item { display: grid; width: 100%; gap: 5px; margin-bottom: 6px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 12px; color: #475569; font: inherit; text-align: left; cursor: pointer; }
|
||||
.history-item:hover { background: #fff; }
|
||||
.history-item.selected { border-color: #bae6fd; background: #fff; box-shadow: inset 3px 0 #0ea5e9; }
|
||||
.history-version { color: #0f172a; font-size: 16px; font-weight: 700; }
|
||||
.history-status { width: fit-content; border-radius: 999px; padding: 2px 6px; font-size: 10px; font-weight: 700; }
|
||||
.history-status.published { background: #dcfce7; color: #15803d; }.history-status.retired { background: #e2e8f0; color: #475569; }.history-status.draft { background: #fef3c7; color: #a16207; }
|
||||
.history-item strong { overflow: hidden; color: #334155; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }.history-item small { color: #94a3b8; font-size: 11px; }
|
||||
.history-more { width: 100%; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; padding: 8px; color: #0284c7; font: inherit; font-size: 12px; cursor: pointer; }
|
||||
.history-detail { overflow-y: auto; background: #fff; padding: 26px; }.history-empty { display: grid; min-height: 300px; place-items: center; color: #94a3b8; font-size: 13px; }
|
||||
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; }.detail-readonly { border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc; padding: 4px 9px; color: #64748b; font-size: 11px; font-weight: 700; }
|
||||
.detail-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 22px 0; }.detail-meta div { border: 1px solid #e5ebf1; border-radius: 8px; background: #fbfdff; padding: 10px; }.detail-meta dt, .snapshot-field dt { color: #94a3b8; font-size: 10px; }.detail-meta dd, .snapshot-field dd { margin: 5px 0 0; color: #334155; font-size: 12px; overflow-wrap: anywhere; }.detail-meta code { color: #0369a1; font-size: 10px; }
|
||||
.snapshot-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: #64748b; font-size: 12px; font-weight: 700; }.snapshot-heading b { border-radius: 999px; background: #e0f2fe; padding: 2px 7px; color: #0369a1; }
|
||||
.compare-button { margin: -8px 0 16px; border: 1px solid #7dd3fc; border-radius: 6px; background: #f0f9ff; padding: 7px 10px; color: #0369a1; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
|
||||
.history-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 16px; }.history-actions .compare-button { margin: 0; }.compare-button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.snapshot-field { margin-top: 8px; border: 1px solid #e5ebf1; border-radius: 8px; padding: 13px; }.snapshot-field.excluded { border-style: dashed; opacity: .68; }.snapshot-field-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }.snapshot-field-title strong { color: #1e293b; font-size: 13px; }.snapshot-field-title code { color: #64748b; font-size: 11px; }.snapshot-field-title span { border-radius: 999px; background: #fef3c7; padding: 2px 6px; color: #a16207; font-size: 10px; }.snapshot-field p { margin: 6px 0 10px; color: #94a3b8; font-size: 11px; }.snapshot-field dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
|
||||
@media (max-width: 760px) { .history-drawer { width: 100vw; }.history-content { grid-template-columns: 1fr; }.history-timeline { max-height: 38vh; border-right: 0; border-bottom: 1px solid #e2e8f0; }.detail-meta, .snapshot-field dl { grid-template-columns: 1fr; }.history-detail { padding: 18px; } }
|
||||
.drawer-kicker { margin: 0 0 4px; color: var(--el-color-primary); font-weight: 700; }
|
||||
.drawer-title { color: var(--el-text-color-primary); font-size: var(--el-font-size-large); }
|
||||
.history-drawer :deep(.el-drawer__body) { display: flex; min-height: 0; flex: 1; padding: 0; overflow: hidden; }
|
||||
.history-content { display: grid; min-height: 0; width: 100%; grid-template-columns: 290px minmax(0, 1fr); }
|
||||
.history-timeline { overflow-y: auto; border-right: 1px solid var(--el-border-color-lighter); padding: 14px 10px; }
|
||||
.history-item { display: grid; width: 100%; height: auto; gap: 5px; margin: 0 0 6px; justify-content: start; padding: 12px; text-align: left; white-space: normal; }
|
||||
.history-item.selected { box-shadow: inset 3px 0 var(--el-color-primary); }
|
||||
.history-version { color: var(--el-text-color-primary); font-weight: 700; }
|
||||
.history-status { width: fit-content; }
|
||||
.history-item strong { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.history-item small { color: var(--el-text-color-secondary); }
|
||||
.history-more { width: 100%; }
|
||||
.history-detail { overflow-y: auto; padding: 26px; }
|
||||
.history-empty { display: grid; min-height: 300px; place-items: center; color: var(--el-text-color-secondary); }
|
||||
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; }
|
||||
.detail-heading p { margin: 0 0 4px; color: var(--el-color-primary); }
|
||||
.detail-heading h3 { margin: 0; }
|
||||
.detail-readonly { border: 1px solid var(--el-border-color); border-radius: 999px; padding: 4px 9px; color: var(--el-text-color-secondary); }
|
||||
.detail-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 22px 0; }
|
||||
.detail-meta div { border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 10px; }
|
||||
.detail-meta dt, .snapshot-field dt { color: var(--el-text-color-secondary); }
|
||||
.detail-meta dd, .snapshot-field dd { margin: 5px 0 0; overflow-wrap: anywhere; }
|
||||
.snapshot-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--el-text-color-secondary); font-weight: 700; }
|
||||
.history-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
|
||||
.snapshot-field { margin-top: 8px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 13px; }
|
||||
.snapshot-field.excluded { border-style: dashed; opacity: .68; }
|
||||
.snapshot-field-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||
.snapshot-field p { margin: 6px 0 10px; color: var(--el-text-color-secondary); }
|
||||
.snapshot-field dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
|
||||
@media (max-width: 760px) {
|
||||
.history-content { grid-template-columns: 1fr; }
|
||||
.history-timeline { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--el-border-color-lighter); }
|
||||
.detail-meta, .snapshot-field dl { grid-template-columns: 1fr; }
|
||||
.history-detail { padding: 18px; }
|
||||
}
|
||||
</style>
|
||||
+69
-23
@@ -1,46 +1,92 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-schema/components/SchemaVersionUsageDrawer.vue
|
||||
用途:展示一个订单 Schema 版本实际参与解析的使用统计和分页运行记录。
|
||||
依赖:ShippingOrderSchemaVersionUsage DTO、Vue I18n。
|
||||
逻辑:父页面负责请求数据和打开单次审计,本组件只展示摘要并发出选择/翻页事件。
|
||||
依赖:element-plus ElDrawer、ShippingOrderSchemaVersionUsage DTO、Vue I18n。
|
||||
逻辑:父页面负责请求数据和打开单次审计,本组件只展示摘要并发出选择/翻页事件。侧栏用 ElDrawer。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ElButton, ElDrawer, ElLoading } from 'element-plus';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderSchemaVersionUsage } from '@/features/admin/types/shipping-order-schema.types';
|
||||
|
||||
defineProps<{ modelValue: boolean; usage: ShippingOrderSchemaVersionUsage | null; loading: boolean }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [visible: boolean]; select: [extractionId: number]; loadMore: [] }>();
|
||||
const { t } = useI18n();
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
/** 将可选 UTC 时间统一展示为本地阅读格式。 */
|
||||
/**
|
||||
* 将可选 UTC 时间统一展示为本地阅读格式。
|
||||
* @param value - ISO 时间;缺失时返回未知时间文案
|
||||
*/
|
||||
const formatDate = (value?: string | null): string => value
|
||||
? new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(new Date(value))
|
||||
: t('admin.shippingOrderSchema.historyUnknownTime');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-if="modelValue" class="usage-layer" role="presentation" @click.self="emit('update:modelValue', false)">
|
||||
<aside class="usage-drawer" role="dialog" aria-modal="true" :aria-label="t('admin.shippingOrderSchema.usageTitle')">
|
||||
<header><div><p>{{ t('admin.shippingOrderSchema.usageEyebrow') }}</p><h2>{{ t('admin.shippingOrderSchema.usageTitle') }}</h2></div><button type="button" :aria-label="t('common.close')" @click="emit('update:modelValue', false)">×</button></header>
|
||||
<main v-if="loading" class="usage-empty">{{ t('common.loading') }}</main>
|
||||
<main v-else-if="usage">
|
||||
<p class="usage-version">V{{ usage.version.version }}</p>
|
||||
<dl class="usage-summary"><div><dt>{{ t('admin.shippingOrderSchema.usageTotal') }}</dt><dd>{{ usage.summary.total }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.usageFirst') }}</dt><dd>{{ formatDate(usage.summary.first_used_at) }}</dd></div><div><dt>{{ t('admin.shippingOrderSchema.usageLast') }}</dt><dd>{{ formatDate(usage.summary.last_used_at) }}</dd></div></dl>
|
||||
<div class="usage-statuses"><span v-for="(count, status) in usage.summary.status_counts" :key="status">{{ t(`admin.shippingOrderSchema.extractionStatus.${status}`) }} <b>{{ count }}</b></span></div>
|
||||
<h3>{{ t('admin.shippingOrderSchema.usageRecords') }}</h3>
|
||||
<p v-if="!usage.items.length" class="usage-empty">{{ t('admin.shippingOrderSchema.usageEmpty') }}</p>
|
||||
<button v-for="item in usage.items" :key="item.id" type="button" class="usage-record" @click="emit('select', item.id)">
|
||||
<strong>#{{ item.id }}</strong><span>{{ t(`admin.shippingOrderSchema.extractionStatus.${item.status}`) }}</span><small>{{ formatDate(item.created_at) }} · {{ item.input_snapshot_hash.slice(0, 12) }}</small>
|
||||
</button>
|
||||
<button v-if="usage.items.length < usage.total" type="button" class="usage-more" :disabled="loading" @click="emit('loadMore')">{{ t('admin.shippingOrderSchema.usageLoadMore') }}</button>
|
||||
</main>
|
||||
<main v-else class="usage-empty">{{ t('admin.shippingOrderSchema.usageEmpty') }}</main>
|
||||
</aside>
|
||||
<ElDrawer
|
||||
:model-value="modelValue"
|
||||
:title="t('admin.shippingOrderSchema.usageTitle')"
|
||||
direction="rtl"
|
||||
size="680px"
|
||||
append-to-body
|
||||
@update:model-value="emit('update:modelValue', $event)"
|
||||
>
|
||||
<p class="drawer-kicker">{{ t('admin.shippingOrderSchema.usageEyebrow') }}</p>
|
||||
<div v-loading="loading" class="usage-body">
|
||||
<template v-if="usage">
|
||||
<p class="usage-version">V{{ usage.version.version }}</p>
|
||||
<dl class="usage-summary">
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.usageTotal') }}</dt><dd>{{ usage.summary.total }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.usageFirst') }}</dt><dd>{{ formatDate(usage.summary.first_used_at) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingOrderSchema.usageLast') }}</dt><dd>{{ formatDate(usage.summary.last_used_at) }}</dd></div>
|
||||
</dl>
|
||||
<div class="usage-statuses">
|
||||
<span v-for="(count, status) in usage.summary.status_counts" :key="status">
|
||||
{{ t(`admin.shippingOrderSchema.extractionStatus.${status}`) }} <b>{{ count }}</b>
|
||||
</span>
|
||||
</div>
|
||||
<h3>{{ t('admin.shippingOrderSchema.usageRecords') }}</h3>
|
||||
<p v-if="!usage.items.length" class="usage-empty">{{ t('admin.shippingOrderSchema.usageEmpty') }}</p>
|
||||
<ElButton
|
||||
v-for="item in usage.items"
|
||||
:key="item.id"
|
||||
class="usage-record"
|
||||
@click="emit('select', item.id)"
|
||||
>
|
||||
<strong>#{{ item.id }}</strong>
|
||||
<span>{{ t(`admin.shippingOrderSchema.extractionStatus.${item.status}`) }}</span>
|
||||
<small>{{ formatDate(item.created_at) }} · {{ item.input_snapshot_hash.slice(0, 12) }}</small>
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="usage.items.length < usage.total"
|
||||
class="usage-more"
|
||||
:loading="loading"
|
||||
:disabled="loading"
|
||||
@click="emit('loadMore')"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.usageLoadMore') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<p v-else-if="!loading" class="usage-empty">{{ t('admin.shippingOrderSchema.usageEmpty') }}</p>
|
||||
</div>
|
||||
</Teleport>
|
||||
</ElDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.usage-layer { position: fixed; z-index: 80; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 35%); backdrop-filter: blur(2px); }.usage-drawer { display: flex; width: min(680px, 96vw); height: 100%; flex-direction: column; overflow: hidden; background: #f8fafc; box-shadow: -18px 0 48px rgb(15 23 42 / 18%); }.usage-drawer > header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 22px 26px; }.usage-drawer header p { margin: 0 0 4px; color: #0284c7; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }.usage-drawer h2 { margin: 0; color: #1e293b; font-size: 20px; }.usage-drawer > header button { width: 32px; height: 32px; border: 1px solid #dbe5ee; border-radius: 50%; background: #fff; color: #475569; font-size: 22px; line-height: 1; cursor: pointer; }.usage-drawer main { overflow-y: auto; padding: 24px 26px; }.usage-version { margin: 0 0 12px; color: #0369a1; font-weight: 700; }.usage-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }.usage-summary div { border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 10px; }.usage-summary dt { color: #94a3b8; font-size: 10px; }.usage-summary dd { margin: 5px 0 0; color: #334155; font-size: 12px; overflow-wrap: anywhere; }.usage-statuses { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }.usage-statuses span { border-radius: 999px; background: #e0f2fe; padding: 3px 7px; color: #0369a1; font-size: 11px; }.usage-drawer h3 { margin: 22px 0 10px; color: #64748b; font-size: 12px; }.usage-record { display: grid; width: 100%; grid-template-columns: 70px 1fr; gap: 5px 10px; margin-top: 7px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 11px; color: #475569; font: inherit; text-align: left; cursor: pointer; }.usage-record:hover { border-color: #7dd3fc; background: #f0f9ff; }.usage-record strong { color: #1e293b; font-size: 12px; }.usage-record span { color: #0369a1; font-size: 12px; }.usage-record small { grid-column: 1 / -1; color: #94a3b8; font-size: 10px; }.usage-empty { display: grid; min-height: 220px; place-items: center; color: #94a3b8; font-size: 13px; }.usage-more { width: 100%; margin-top: 10px; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; padding: 8px; color: #0284c7; font: inherit; font-size: 12px; cursor: pointer; }@media (max-width: 640px) { .usage-drawer main { padding: 18px; }.usage-summary { grid-template-columns: 1fr; } }
|
||||
.drawer-kicker { margin: 0 0 12px; color: var(--el-color-primary); font-weight: 700; }
|
||||
.usage-body { min-height: 220px; }
|
||||
.usage-version { margin: 0 0 12px; color: var(--el-color-primary); font-weight: 700; }
|
||||
.usage-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
|
||||
.usage-summary div { border: 1px solid var(--el-border-color-lighter); border-radius: 8px; padding: 10px; }
|
||||
.usage-summary dt { color: var(--el-text-color-secondary); }
|
||||
.usage-summary dd { margin: 5px 0 0; overflow-wrap: anywhere; }
|
||||
.usage-statuses { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0; }
|
||||
.usage-statuses span { border-radius: 999px; background: var(--el-color-primary-light-9); padding: 3px 7px; color: var(--el-color-primary); }
|
||||
.usage-body h3 { margin: 22px 0 10px; color: var(--el-text-color-secondary); }
|
||||
.usage-record { display: grid; width: 100%; height: auto; grid-template-columns: 70px 1fr; gap: 5px 10px; margin: 7px 0 0; justify-content: start; padding: 11px; text-align: left; white-space: normal; }
|
||||
.usage-record small { grid-column: 1 / -1; color: var(--el-text-color-secondary); }
|
||||
.usage-empty { display: grid; min-height: 160px; place-items: center; color: var(--el-text-color-secondary); }
|
||||
.usage-more { width: 100%; margin-top: 10px; }
|
||||
@media (max-width: 640px) { .usage-summary { grid-template-columns: 1fr; } }
|
||||
</style>
|
||||
+399
-395
@@ -1,16 +1,33 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-process-gates/ShippingProcessGateDiagnosticsPage.vue
|
||||
用途:管理员 Process Gate Execution 诊断——列表、Gate 轨道与 Attempt 明细。
|
||||
依赖:process-gates.api、Vue Router、Vue I18n(admin + workspace.processGate 动作文案)。
|
||||
逻辑:只读诊断;多维度筛选(status/gate/reason/party/q/时间);小屏卡片列表 + 详情下置;
|
||||
lg+ 主从布局(左侧 ~38% Execution 紧凑列表 + 分页,右侧 sticky 详情:Gate/findings/attempts);
|
||||
状态/动作展示业务标签并附技术码;Gate 诊断结构化卡片(findings/blocking/effective_result);
|
||||
Attempt 展示 snapshot_diff 摘要并可跳转 AdminShippingAudit。
|
||||
-->
|
||||
/**
|
||||
* features/admin/modules/shipping-process-gates/ShippingProcessGateDiagnosticsPage.vue
|
||||
* 用途:管理员 Process Gate Execution 诊断列表。筛选、分页、Gate 轨道与 Attempt 明细。
|
||||
* 依赖:AdminListPage、useElementProvider、element-plus、process-gates.api、Vue Router、Vue I18n。
|
||||
* 逻辑:只读诊断。列表骨架用 AdminListPage。详情仍在右侧;Gate 表用 ElTable。Attempt 可跳转审计中心。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
ElDatePicker,
|
||||
ElInput,
|
||||
ElLoading,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
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 { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import {
|
||||
getAdminProcessExecution,
|
||||
listAdminProcessExecutions,
|
||||
@@ -21,14 +38,18 @@ import {
|
||||
type AdminProcessGateAttemptsPayload,
|
||||
} from '@/features/shipping-process-gates/api/process-gates.api';
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const router = useRouter();
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const attemptsLoading = ref(false);
|
||||
const error = ref('');
|
||||
const page = ref(1);
|
||||
const pageSize = 25;
|
||||
const pageSize = ref(25);
|
||||
const pageSizes = [10, 25, 50, 100];
|
||||
const total = ref(0);
|
||||
const filters = ref<AdminProcessExecutionListFilters>({
|
||||
status: '',
|
||||
@@ -91,7 +112,15 @@ const EMPTY_FILTERS: AdminProcessExecutionListFilters = {
|
||||
updated_to: '',
|
||||
};
|
||||
|
||||
const formatTime = (value?: string | null) => (value ? new Date(value).toLocaleString() : '—');
|
||||
/**
|
||||
* 把时间值格式化为本地字符串。非字符串或空值显示占位。
|
||||
* @param value - 接口返回的时间
|
||||
* @returns 本地时间或占位符
|
||||
*/
|
||||
function formatTime(value?: unknown): string {
|
||||
if (typeof value !== 'string' || !value) return '—';
|
||||
return new Date(value).toLocaleString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 datetime-local 值规范为 ISO 字符串供 API 查询。
|
||||
@@ -330,7 +359,7 @@ async function load() {
|
||||
loading.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const response = await listAdminProcessExecutions(page.value, pageSize, buildListFilters());
|
||||
const response = await listAdminProcessExecutions(page.value, pageSize.value, buildListFilters());
|
||||
rows.value = response.items;
|
||||
total.value = response.total;
|
||||
} catch {
|
||||
@@ -394,13 +423,6 @@ async function loadAttempts(gateCode: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断 Execution 是否为当前详情选中项,供 lg+ 主从列表行高亮。
|
||||
*/
|
||||
function isExecutionSelected(executionNo: string): boolean {
|
||||
return Boolean(detail.value?.execution_no && detail.value.execution_no === executionNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭详情面板。
|
||||
*/
|
||||
@@ -410,387 +432,369 @@ function closeDetail() {
|
||||
attemptsPayload.value = null;
|
||||
}
|
||||
|
||||
type ProcessGateRow = {
|
||||
sequence_no?: number | string;
|
||||
gate_code?: string;
|
||||
status?: string;
|
||||
blocking_reason_code?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* 状态筛选。清空写回空字符串,列表仍按全部状态查询。
|
||||
* @param value - 选中的状态;清空为 undefined
|
||||
*/
|
||||
function onStatusFilter(value: string | undefined): void {
|
||||
filters.value.status = value ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期筛选清空时写回空字符串,避免日期控件把 null 传给查询。
|
||||
* @param key - updated_from 或 updated_to
|
||||
* @param value - 日期控件的值
|
||||
*/
|
||||
function onDateFilter(key: 'updated_from' | 'updated_to', value: string | null | undefined): void {
|
||||
filters.value[key] = value ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 每页条数变化后回到第一页再拉列表。
|
||||
*/
|
||||
function onPageSizeChange(): void {
|
||||
page.value = 1;
|
||||
void load();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从表格行打开 Execution 详情。
|
||||
* @param row - 当前执行摘要
|
||||
*/
|
||||
function openExecutionDetail(row: AdminProcessExecutionSummary): void {
|
||||
void openDetail(row.execution_no);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 Gate 行加载 Attempt。
|
||||
* @param row - Gate 诊断行
|
||||
*/
|
||||
function openGateAttempts(row: ProcessGateRow): void {
|
||||
void loadAttempts(String(row.gate_code || ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Execution 状态标签色。阻断和失败为危险,完成成功,等待为警告。
|
||||
* @param code - 状态码
|
||||
* @returns Element 标签类型
|
||||
*/
|
||||
function statusTagType(code?: string | null): 'success' | 'warning' | 'info' | 'danger' | 'primary' {
|
||||
const key = String(code || '');
|
||||
if (key === 'completed') return 'success';
|
||||
if (key === 'failed' || key === 'blocked') return 'danger';
|
||||
if (key === 'cancelled') return 'info';
|
||||
if (key === 'waiting_external') return 'warning';
|
||||
return 'primary';
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
void load();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-6 p-4 sm:p-6">
|
||||
<header>
|
||||
<h1 class="text-xl font-bold">{{ t('admin.shippingProcessGates.title') }}</h1>
|
||||
<p class="mt-1 max-w-3xl text-sm text-muted">{{ t('admin.shippingProcessGates.subtitle') }}</p>
|
||||
</header>
|
||||
|
||||
<section class="rounded-xl border border-default bg-surface p-4">
|
||||
<div class="grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
|
||||
<label class="text-sm">
|
||||
<span class="mb-1 block text-xs text-muted">{{ t('admin.shippingProcessGates.status') }}</span>
|
||||
<select v-model="filters.status" class="w-full rounded border border-default px-2 py-1.5 text-sm">
|
||||
<option value="">{{ t('admin.shippingProcessGates.allStatuses') }}</option>
|
||||
<option v-for="code in EXECUTION_STATUS_OPTIONS" :key="code" :value="code">
|
||||
{{ statusLabel(code) }}
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="text-sm">
|
||||
<span class="mb-1 block text-xs text-muted">{{ t('admin.shippingProcessGates.filterGate') }}</span>
|
||||
<input
|
||||
v-model="filters.gate_code"
|
||||
type="text"
|
||||
class="w-full rounded border border-default px-2 py-1.5 text-sm font-mono"
|
||||
:placeholder="t('admin.shippingProcessGates.gateCode')"
|
||||
/>
|
||||
</label>
|
||||
<label class="text-sm">
|
||||
<span class="mb-1 block text-xs text-muted">{{ t('admin.shippingProcessGates.filterReason') }}</span>
|
||||
<input
|
||||
v-model="filters.blocking_reason_code"
|
||||
type="text"
|
||||
class="w-full rounded border border-default px-2 py-1.5 text-sm font-mono"
|
||||
:placeholder="t('admin.shippingProcessGates.blockingReasonCode')"
|
||||
/>
|
||||
</label>
|
||||
<label class="text-sm">
|
||||
<span class="mb-1 block text-xs text-muted">{{ t('admin.shippingProcessGates.filterParty') }}</span>
|
||||
<input
|
||||
v-model="filters.responsible_party"
|
||||
type="text"
|
||||
class="w-full rounded border border-default px-2 py-1.5 text-sm"
|
||||
:placeholder="t('admin.shippingProcessGates.responsibleParty')"
|
||||
/>
|
||||
</label>
|
||||
<label class="text-sm sm:col-span-2 lg:col-span-1">
|
||||
<span class="mb-1 block text-xs text-muted">{{ t('admin.shippingProcessGates.filterSearch') }}</span>
|
||||
<input
|
||||
v-model="filters.q"
|
||||
type="search"
|
||||
class="w-full rounded border border-default px-2 py-1.5 text-sm"
|
||||
:placeholder="t('admin.shippingProcessGates.executionNo')"
|
||||
/>
|
||||
</label>
|
||||
<label class="text-sm">
|
||||
<span class="mb-1 block text-xs text-muted">{{ t('admin.shippingProcessGates.filterFrom') }}</span>
|
||||
<input v-model="filters.updated_from" type="datetime-local" class="w-full rounded border border-default px-2 py-1.5 text-sm" />
|
||||
</label>
|
||||
<label class="text-sm">
|
||||
<span class="mb-1 block text-xs text-muted">{{ t('admin.shippingProcessGates.filterTo') }}</span>
|
||||
<input v-model="filters.updated_to" type="datetime-local" class="w-full rounded border border-default px-2 py-1.5 text-sm" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="mt-3 flex flex-wrap items-center gap-2">
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 text-sm" @click="applyFilters">
|
||||
{{ t('admin.shippingProcessGates.applyFilters') }}
|
||||
</button>
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 text-sm" @click="resetFilters">
|
||||
{{ t('admin.shippingProcessGates.resetFilters') }}
|
||||
</button>
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 text-sm" @click="load">
|
||||
{{ t('admin.shippingProcessGates.refresh') }}
|
||||
</button>
|
||||
<span class="text-xs text-muted">{{ t('admin.shippingProcessGates.total', { count: total }) }}</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p v-if="error" class="text-sm text-rose-600">{{ error }}</p>
|
||||
|
||||
<!-- 小屏:卡片列表,避免列标题逐字换行 -->
|
||||
<div class="space-y-3 lg:hidden" data-testid="shipping-process-gate-cards">
|
||||
<p v-if="loading" class="rounded-xl border border-default px-4 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.shippingProcessGates.loading') }}
|
||||
</p>
|
||||
<p v-else-if="!rows.length" class="rounded-xl border border-default px-4 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.shippingProcessGates.empty') }}
|
||||
</p>
|
||||
<article
|
||||
v-for="row in rows"
|
||||
:key="row.execution_no"
|
||||
class="rounded-xl border border-default bg-surface px-4 py-3 text-sm"
|
||||
>
|
||||
<div class="font-mono text-xs break-all">{{ row.execution_no }}</div>
|
||||
<dl class="mt-2 grid grid-cols-1 gap-1.5 sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingProcessGates.status') }}</dt>
|
||||
<dd>
|
||||
<span>{{ statusLabel(row.status) }}</span>
|
||||
<span class="ml-1 font-mono text-[11px] text-muted">{{ row.status }}</span>
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingProcessGates.currentGate') }}</dt>
|
||||
<dd class="font-mono text-xs break-all">{{ row.current_gate_code || '—' }}</dd>
|
||||
</div>
|
||||
<div class="sm:col-span-2">
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingProcessGates.nextAction') }}</dt>
|
||||
<dd class="text-xs">{{ actionLabel(row.primary_next_action_code) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ t('admin.shippingProcessGates.updatedAt') }}</dt>
|
||||
<dd class="text-xs">{{ formatTime(row.updated_at) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 text-sm text-brand-600 hover:underline"
|
||||
@click="openDetail(row.execution_no)"
|
||||
>
|
||||
{{ t('admin.shippingProcessGates.viewDetail') }}
|
||||
</button>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<!-- lg+ 主从:左列表+分页,右 sticky 详情;小屏在网格外卡片列表,网格内仅分页+详情 -->
|
||||
<div class="grid lg:grid-cols-[minmax(280px,38%)_minmax(0,1fr)] gap-4 items-start">
|
||||
<div class="space-y-3">
|
||||
<!-- lg+:紧凑 Execution 行列表 -->
|
||||
<div class="hidden lg:block space-y-1.5" data-testid="shipping-process-gate-list">
|
||||
<p v-if="loading" class="rounded-xl border border-default px-4 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.shippingProcessGates.loading') }}
|
||||
</p>
|
||||
<p v-else-if="!rows.length" class="rounded-xl border border-default px-4 py-8 text-center text-sm text-muted">
|
||||
{{ t('admin.shippingProcessGates.empty') }}
|
||||
</p>
|
||||
<button
|
||||
v-for="row in rows"
|
||||
:key="row.execution_no"
|
||||
type="button"
|
||||
class="w-full rounded-lg border px-3 py-2.5 text-left text-sm transition-colors"
|
||||
:class="isExecutionSelected(row.execution_no)
|
||||
? 'border-brand-500 bg-brand-50/80 ring-1 ring-brand-500/40 dark:bg-brand-950/30'
|
||||
: 'border-default bg-surface hover:bg-surface-soft'"
|
||||
@click="openDetail(row.execution_no)"
|
||||
>
|
||||
<div class="font-mono text-xs break-all">{{ row.execution_no }}</div>
|
||||
<div class="mt-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-xs">
|
||||
<span>{{ statusLabel(row.status) }}</span>
|
||||
<span class="font-mono text-[11px] text-muted">{{ row.status }}</span>
|
||||
</div>
|
||||
<div class="mt-1 truncate font-mono text-[11px] text-muted">
|
||||
{{ row.current_gate_code || '—' }}
|
||||
</div>
|
||||
<div class="mt-1 truncate text-[11px] text-muted">{{ actionLabel(row.primary_next_action_code) }}</div>
|
||||
<div class="mt-1 text-[11px] text-muted">{{ formatTime(row.updated_at) }}</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 text-sm">
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page <= 1 || loading" @click="page -= 1; load()">
|
||||
{{ t('admin.shippingProcessGates.previous') }}
|
||||
</button>
|
||||
<span>{{ page }}</span>
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">
|
||||
{{ t('admin.shippingProcessGates.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside
|
||||
v-if="detail"
|
||||
class="rounded-xl border border-default bg-surface p-4 lg:sticky lg:top-24 lg:max-h-[calc(100vh-8rem)] lg:overflow-y-auto"
|
||||
data-testid="shipping-process-gate-detail"
|
||||
>
|
||||
<div class="mb-4 flex items-center justify-between gap-2">
|
||||
<h2 class="text-lg font-semibold">{{ t('admin.shippingProcessGates.detailTitle') }}</h2>
|
||||
<button type="button" class="text-sm text-muted hover:text-primary" @click="closeDetail">{{ t('admin.close') }}</button>
|
||||
</div>
|
||||
<p v-if="detailLoading" class="text-sm text-muted">{{ t('admin.shippingProcessGates.loading') }}</p>
|
||||
<template v-else>
|
||||
<dl class="grid gap-2 text-sm sm:grid-cols-2">
|
||||
<div><dt class="text-muted">{{ t('admin.shippingProcessGates.executionNo') }}</dt><dd class="font-mono text-xs break-all">{{ detail.execution_no }}</dd></div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingProcessGates.status') }}</dt>
|
||||
<dd>
|
||||
{{ statusLabel(detail.status) }}
|
||||
<span class="ml-1 font-mono text-[11px] text-muted">{{ detail.status }}</span>
|
||||
</dd>
|
||||
</div>
|
||||
<div><dt class="text-muted">{{ t('admin.shippingProcessGates.taskNo') }}</dt><dd class="font-mono text-xs">{{ detail.task_no || '—' }}</dd></div>
|
||||
<div><dt class="text-muted">{{ t('admin.shippingProcessGates.caseNo') }}</dt><dd class="font-mono text-xs">{{ detail.review_case_no || detail.case_no || '—' }}</dd></div>
|
||||
</dl>
|
||||
|
||||
<h3 class="mt-6 text-sm font-semibold">{{ t('admin.shippingProcessGates.gates') }}</h3>
|
||||
<div class="mt-2 space-y-2 lg:hidden">
|
||||
<article
|
||||
v-for="gate in diagnosticGates"
|
||||
:key="String(gate.gate_code)"
|
||||
class="rounded-lg border border-default px-3 py-2 text-xs"
|
||||
:class="{ 'bg-amber-50/60 dark:bg-amber-950/20': selectedGateCode === gate.gate_code }"
|
||||
>
|
||||
<div class="font-semibold">#{{ gate.sequence_no }} · {{ gate.gate_code }}</div>
|
||||
<div class="mt-1">{{ statusLabel(String(gate.status)) }} <span class="font-mono text-muted">{{ gate.status }}</span></div>
|
||||
<div class="mt-1 font-mono text-muted">{{ gate.blocking_reason_code || '—' }}</div>
|
||||
<button type="button" class="mt-2 text-brand-600 hover:underline" @click="loadAttempts(String(gate.gate_code))">
|
||||
{{ t('admin.shippingProcessGates.viewAttempts') }}
|
||||
</button>
|
||||
</article>
|
||||
</div>
|
||||
<div class="mt-2 hidden overflow-x-auto rounded-lg border border-default lg:block">
|
||||
<table class="min-w-[640px] w-full text-xs">
|
||||
<thead class="bg-surface-soft text-left text-muted">
|
||||
<tr>
|
||||
<th class="whitespace-nowrap px-3 py-2">#</th>
|
||||
<th class="whitespace-nowrap px-3 py-2">{{ t('admin.shippingProcessGates.gateCode') }}</th>
|
||||
<th class="whitespace-nowrap px-3 py-2">{{ t('admin.shippingProcessGates.gateStatus') }}</th>
|
||||
<th class="whitespace-nowrap px-3 py-2">{{ t('admin.shippingProcessGates.blockingReason') }}</th>
|
||||
<th class="whitespace-nowrap px-3 py-2">{{ t('admin.shippingProcessGates.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="gate in diagnosticGates"
|
||||
:key="String(gate.gate_code)"
|
||||
class="border-t border-default"
|
||||
:class="{ 'bg-amber-50/60 dark:bg-amber-950/20': selectedGateCode === gate.gate_code }"
|
||||
>
|
||||
<td class="whitespace-nowrap px-3 py-2">{{ gate.sequence_no }}</td>
|
||||
<td class="whitespace-nowrap px-3 py-2 font-mono">{{ gate.gate_code }}</td>
|
||||
<td class="px-3 py-2">
|
||||
<div>{{ statusLabel(String(gate.status)) }}</div>
|
||||
<div class="font-mono text-[11px] text-muted">{{ gate.status }}</div>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-3 py-2 font-mono">{{ gate.blocking_reason_code || '—' }}</td>
|
||||
<td class="whitespace-nowrap px-3 py-2">
|
||||
<button type="button" class="text-brand-600 hover:underline" @click="loadAttempts(String(gate.gate_code))">
|
||||
{{ t('admin.shippingProcessGates.viewAttempts') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<section v-if="selectedGateDetail" class="mt-4 rounded-lg border border-default px-3 py-3 text-xs">
|
||||
<h4 class="font-semibold">{{ t('admin.shippingProcessGates.gateDiagnostics') }}</h4>
|
||||
<p class="mt-1 text-muted">
|
||||
{{ t('admin.shippingProcessGates.nextAction') }}:
|
||||
<span>{{ actionLabel(String(selectedGateDetail.next_action_code || '')) }}</span>
|
||||
</p>
|
||||
|
||||
<div class="mt-3">
|
||||
<div class="font-medium text-muted">{{ t('admin.shippingProcessGates.findingsStructured') }}</div>
|
||||
<p v-if="!selectedGateFindings.length" class="mt-1 text-muted">{{ t('admin.shippingProcessGates.noFindings') }}</p>
|
||||
<div v-else class="mt-2 space-y-2">
|
||||
<article
|
||||
v-for="(finding, index) in selectedGateFindings"
|
||||
:key="`${finding.finding_code || finding.reason_code || index}`"
|
||||
class="rounded border border-default bg-surface-soft px-3 py-2"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="rounded px-1.5 py-0.5 font-mono text-[11px]"
|
||||
:class="finding.severity === 'blocking'
|
||||
? 'bg-rose-100 text-rose-800 dark:bg-rose-950 dark:text-rose-200'
|
||||
: 'bg-slate-100 text-slate-700 dark:bg-slate-900 dark:text-slate-200'"
|
||||
>
|
||||
{{ t('admin.shippingProcessGates.severity') }}: {{ finding.severity || '—' }}
|
||||
</span>
|
||||
</div>
|
||||
<dl class="mt-2 grid gap-1 sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingProcessGates.field') }}</dt>
|
||||
<dd class="font-mono">{{ findingField(finding) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingProcessGates.party') }}</dt>
|
||||
<dd>{{ findingParty(finding) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ t('admin.shippingProcessGates.reason') }}</dt>
|
||||
<dd class="font-mono">{{ findingReason(finding) }}</dd>
|
||||
</div>
|
||||
<div class="sm:col-span-2">
|
||||
<dt class="text-muted">{{ t('admin.shippingProcessGates.message') }}</dt>
|
||||
<dd class="break-words">{{ findingMessage(finding) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<div class="font-medium text-muted">{{ t('admin.shippingProcessGates.blockingReasonDetail') }}</div>
|
||||
<p v-if="!selectedBlockingReasonRows.length" class="mt-1 text-muted">—</p>
|
||||
<dl v-else class="mt-2 divide-y divide-default rounded border border-default">
|
||||
<div
|
||||
v-for="row in selectedBlockingReasonRows"
|
||||
:key="row.key"
|
||||
class="grid gap-1 px-3 py-2 sm:grid-cols-[minmax(8rem,30%)_1fr]"
|
||||
>
|
||||
<dt class="font-mono text-muted">{{ row.key }}</dt>
|
||||
<dd class="break-words">{{ row.value }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<div class="font-medium text-muted">{{ t('admin.shippingProcessGates.effectiveResult') }}</div>
|
||||
<p v-if="!selectedEffectiveResultSummary.length && !selectedEffectiveResultRemainder" class="mt-1 text-muted">—</p>
|
||||
<div v-else class="mt-2 space-y-2">
|
||||
<div v-if="selectedEffectiveResultSummary.length" class="flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="chip in selectedEffectiveResultSummary"
|
||||
:key="chip.key"
|
||||
class="rounded-full border border-default bg-surface-soft px-2 py-0.5 font-mono text-[11px]"
|
||||
>
|
||||
{{ chip.key }}: {{ chip.value }}
|
||||
</span>
|
||||
</div>
|
||||
<details v-if="selectedEffectiveResultRemainder">
|
||||
<summary class="cursor-pointer text-brand-600">
|
||||
{{ Object.keys(selectedEffectiveResultRemainder).join(', ') }}
|
||||
</summary>
|
||||
<pre class="mt-2 max-h-48 overflow-auto rounded bg-surface-soft p-2">{{ formatJson(selectedEffectiveResultRemainder) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="mt-6 flex flex-wrap items-center justify-between gap-2">
|
||||
<h3 class="text-sm font-semibold">
|
||||
{{ t('admin.shippingProcessGates.attempts') }}
|
||||
<span v-if="selectedGateCode" class="font-mono text-xs text-muted">({{ selectedGateCode }})</span>
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs text-brand-600 hover:underline"
|
||||
@click="openAuditForExecution(detail.execution_no)"
|
||||
>
|
||||
{{ t('admin.shippingProcessGates.openAudit') }}
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-xs text-muted">{{ t('admin.shippingProcessGates.auditLink') }}</p>
|
||||
<p v-if="attemptsLoading" class="mt-2 text-sm text-muted">{{ t('admin.shippingProcessGates.loading') }}</p>
|
||||
<div v-else-if="attemptRows.length" class="mt-2 space-y-2">
|
||||
<article
|
||||
v-for="attempt in attemptRows"
|
||||
:key="String(attempt.id || attempt.attempt_no)"
|
||||
class="rounded-lg border border-default px-3 py-2 text-xs"
|
||||
>
|
||||
<div class="font-mono">#{{ attempt.attempt_no }} · {{ statusLabel(String(attempt.status)) }} <span class="text-muted">({{ attempt.status }})</span></div>
|
||||
<div v-if="attempt.error_code" class="mt-1 text-rose-700">{{ attempt.error_code }}: {{ attempt.error_summary }}</div>
|
||||
<div class="mt-1 text-muted">{{ formatTime(attempt.started_at as string) }} → {{ formatTime(attempt.finished_at as string) }}</div>
|
||||
<div class="mt-1 text-muted">
|
||||
hash:
|
||||
in={{ attempt.input_snapshot_hash || '—' }}
|
||||
/ out={{ attempt.output_snapshot_hash || '—' }}
|
||||
</div>
|
||||
<ul v-if="formatAttemptDiffSummary(attempt.snapshot_diff).length" class="mt-2 space-y-0.5 text-muted">
|
||||
<li v-for="(line, lineIndex) in formatAttemptDiffSummary(attempt.snapshot_diff)" :key="lineIndex">
|
||||
{{ line }}
|
||||
</li>
|
||||
</ul>
|
||||
<details v-if="attempt.input_snapshot || attempt.output_snapshot" class="mt-2">
|
||||
<summary class="cursor-pointer text-brand-600">{{ t('admin.shippingProcessGates.viewSnapshots') }}</summary>
|
||||
<div class="mt-2 grid gap-2 md:grid-cols-2">
|
||||
<pre class="max-h-48 overflow-auto rounded bg-surface-soft p-2">{{ formatJson(attempt.input_snapshot) }}</pre>
|
||||
<pre class="max-h-48 overflow-auto rounded bg-surface-soft p-2">{{ formatJson(attempt.output_snapshot) }}</pre>
|
||||
</div>
|
||||
</details>
|
||||
</article>
|
||||
</div>
|
||||
<p v-else class="mt-2 text-sm text-muted">{{ t('admin.shippingProcessGates.noAttempts') }}</p>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.shippingProcessGates.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingProcessGates.subtitle') }}</p>
|
||||
</template>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
<template #actions>
|
||||
<ElButton @click="applyFilters">{{ t('admin.shippingProcessGates.applyFilters') }}</ElButton>
|
||||
<ElButton @click="resetFilters">{{ t('admin.shippingProcessGates.resetFilters') }}</ElButton>
|
||||
<ElButton :icon="Refresh" :loading="loading" @click="load">{{ t('admin.shippingProcessGates.refresh') }}</ElButton>
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElSelect
|
||||
:model-value="filters.status || undefined"
|
||||
class="process-gate-filter"
|
||||
clearable
|
||||
:placeholder="t('admin.shippingProcessGates.allStatuses')"
|
||||
@update:model-value="onStatusFilter"
|
||||
>
|
||||
<ElOption v-for="code in EXECUTION_STATUS_OPTIONS" :key="code" :label="statusLabel(code)" :value="code" />
|
||||
</ElSelect>
|
||||
<ElInput v-model="filters.gate_code" class="process-gate-filter" clearable :placeholder="t('admin.shippingProcessGates.filterGate')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.blocking_reason_code" class="process-gate-filter" clearable :placeholder="t('admin.shippingProcessGates.filterReason')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.responsible_party" class="process-gate-filter" clearable :placeholder="t('admin.shippingProcessGates.filterParty')" @keyup.enter="applyFilters" />
|
||||
<ElInput v-model="filters.q" class="process-gate-filter-search" clearable :placeholder="t('admin.shippingProcessGates.filterSearch')" @keyup.enter="applyFilters" />
|
||||
<ElDatePicker
|
||||
:model-value="filters.updated_from || undefined"
|
||||
class="process-gate-filter-time"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm"
|
||||
:placeholder="t('admin.shippingProcessGates.filterFrom')"
|
||||
@update:model-value="onDateFilter('updated_from', $event)"
|
||||
/>
|
||||
<ElDatePicker
|
||||
:model-value="filters.updated_to || undefined"
|
||||
class="process-gate-filter-time"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DDTHH:mm"
|
||||
:placeholder="t('admin.shippingProcessGates.filterTo')"
|
||||
@update:model-value="onDateFilter('updated_to', $event)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<ElAlert v-if="error" :title="error" type="error" :closable="false" show-icon />
|
||||
<div class="process-gate-layout">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
class="hx-admin-table"
|
||||
data-testid="shipping-process-gate-list"
|
||||
:data="rows"
|
||||
row-key="execution_no"
|
||||
:empty-text="t('admin.shippingProcessGates.empty')"
|
||||
highlight-current-row
|
||||
@row-click="openExecutionDetail"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.executionNo')" min-width="180">
|
||||
<template #default="{ row }">{{ row.execution_no }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.status')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="statusTagType(row.status)" effect="light">{{ statusLabel(row.status) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.currentGate')" min-width="140">
|
||||
<template #default="{ row }">{{ row.current_gate_code || '—' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.nextAction')" min-width="180">
|
||||
<template #default="{ row }">{{ actionLabel(row.primary_next_action_code) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.updatedAt')" min-width="160">
|
||||
<template #default="{ row }">{{ formatTime(row.updated_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.actions')" width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click.stop="openExecutionDetail(row as AdminProcessExecutionSummary)">
|
||||
{{ t('admin.shippingProcessGates.viewDetail') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<aside v-if="detail" class="process-gate-detail" data-testid="shipping-process-gate-detail">
|
||||
<div class="process-gate-detail__head">
|
||||
<h3>{{ t('admin.shippingProcessGates.detailTitle') }}</h3>
|
||||
<ElButton @click="closeDetail">{{ t('admin.close') }}</ElButton>
|
||||
</div>
|
||||
<div v-loading="detailLoading">
|
||||
<template v-if="!detailLoading">
|
||||
<dl class="process-gate-meta">
|
||||
<div><dt>{{ t('admin.shippingProcessGates.executionNo') }}</dt><dd>{{ detail.execution_no }}</dd></div>
|
||||
<div>
|
||||
<dt>{{ t('admin.shippingProcessGates.status') }}</dt>
|
||||
<dd><ElTag :type="statusTagType(detail.status)" effect="light">{{ statusLabel(detail.status) }}</ElTag></dd>
|
||||
</div>
|
||||
<div><dt>{{ t('admin.shippingProcessGates.taskNo') }}</dt><dd>{{ detail.task_no || '—' }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingProcessGates.caseNo') }}</dt><dd>{{ detail.review_case_no || detail.case_no || '—' }}</dd></div>
|
||||
</dl>
|
||||
|
||||
<h3>{{ t('admin.shippingProcessGates.gates') }}</h3>
|
||||
<ElTable
|
||||
:data="diagnosticGates"
|
||||
row-key="gate_code"
|
||||
:empty-text="t('admin.shippingProcessGates.empty')"
|
||||
>
|
||||
<ElTableColumn label="#" width="64">
|
||||
<template #default="{ row }">{{ row.sequence_no }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.gateCode')" min-width="140">
|
||||
<template #default="{ row }">{{ row.gate_code }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.gateStatus')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="statusTagType(String(row.status || ''))" effect="light">{{ statusLabel(String(row.status || '')) }}</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.blockingReason')" min-width="160">
|
||||
<template #default="{ row }">{{ row.blocking_reason_code || '—' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.shippingProcessGates.actions')" width="140" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton link type="primary" @click="openGateAttempts(row as ProcessGateRow)">
|
||||
{{ t('admin.shippingProcessGates.viewAttempts') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<section v-if="selectedGateDetail" class="process-gate-panel">
|
||||
<h4>{{ t('admin.shippingProcessGates.gateDiagnostics') }}</h4>
|
||||
<p>
|
||||
{{ t('admin.shippingProcessGates.nextAction') }}:
|
||||
{{ actionLabel(String(selectedGateDetail.next_action_code || '')) }}
|
||||
</p>
|
||||
<div>
|
||||
<h4>{{ t('admin.shippingProcessGates.findingsStructured') }}</h4>
|
||||
<p v-if="!selectedGateFindings.length">{{ t('admin.shippingProcessGates.noFindings') }}</p>
|
||||
<article v-for="(finding, index) in selectedGateFindings" :key="`${finding.finding_code || finding.reason_code || index}`" class="process-gate-panel">
|
||||
<ElTag :type="finding.severity === 'blocking' ? 'danger' : 'info'" effect="light">
|
||||
{{ t('admin.shippingProcessGates.severity') }}: {{ finding.severity || '—' }}
|
||||
</ElTag>
|
||||
<dl class="process-gate-meta">
|
||||
<div><dt>{{ t('admin.shippingProcessGates.field') }}</dt><dd>{{ findingField(finding) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingProcessGates.party') }}</dt><dd>{{ findingParty(finding) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingProcessGates.reason') }}</dt><dd>{{ findingReason(finding) }}</dd></div>
|
||||
<div><dt>{{ t('admin.shippingProcessGates.message') }}</dt><dd>{{ findingMessage(finding) }}</dd></div>
|
||||
</dl>
|
||||
</article>
|
||||
</div>
|
||||
<div>
|
||||
<h4>{{ t('admin.shippingProcessGates.blockingReasonDetail') }}</h4>
|
||||
<p v-if="!selectedBlockingReasonRows.length">—</p>
|
||||
<dl v-else class="process-gate-meta">
|
||||
<div v-for="row in selectedBlockingReasonRows" :key="row.key">
|
||||
<dt>{{ row.key }}</dt>
|
||||
<dd>{{ row.value }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
<div>
|
||||
<h4>{{ t('admin.shippingProcessGates.effectiveResult') }}</h4>
|
||||
<p v-if="!selectedEffectiveResultSummary.length && !selectedEffectiveResultRemainder">—</p>
|
||||
<div v-else>
|
||||
<div v-if="selectedEffectiveResultSummary.length" class="process-gate-tags">
|
||||
<ElTag v-for="chip in selectedEffectiveResultSummary" :key="chip.key" effect="light">
|
||||
{{ chip.key }}: {{ chip.value }}
|
||||
</ElTag>
|
||||
</div>
|
||||
<details v-if="selectedEffectiveResultRemainder">
|
||||
<summary>{{ Object.keys(selectedEffectiveResultRemainder).join(', ') }}</summary>
|
||||
<pre>{{ formatJson(selectedEffectiveResultRemainder) }}</pre>
|
||||
</details>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="process-gate-detail__head">
|
||||
<h3>
|
||||
{{ t('admin.shippingProcessGates.attempts') }}
|
||||
<span v-if="selectedGateCode">({{ selectedGateCode }})</span>
|
||||
</h3>
|
||||
<ElButton link type="primary" @click="openAuditForExecution(detail.execution_no)">
|
||||
{{ t('admin.shippingProcessGates.openAudit') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<p>{{ t('admin.shippingProcessGates.auditLink') }}</p>
|
||||
<p v-if="attemptsLoading">{{ t('admin.shippingProcessGates.loading') }}</p>
|
||||
<div v-else-if="attemptRows.length" class="process-gate-stack">
|
||||
<article v-for="attempt in attemptRows" :key="String(attempt.id || attempt.attempt_no)" class="process-gate-panel">
|
||||
<div>#{{ attempt.attempt_no }} · {{ statusLabel(String(attempt.status)) }} ({{ attempt.status }})</div>
|
||||
<div v-if="attempt.error_code">{{ attempt.error_code }}: {{ attempt.error_summary }}</div>
|
||||
<div>{{ formatTime(attempt.started_at) }} → {{ formatTime(attempt.finished_at) }}</div>
|
||||
<div>hash: in={{ attempt.input_snapshot_hash || '—' }} / out={{ attempt.output_snapshot_hash || '—' }}</div>
|
||||
<ul v-if="formatAttemptDiffSummary(attempt.snapshot_diff).length">
|
||||
<li v-for="(line, lineIndex) in formatAttemptDiffSummary(attempt.snapshot_diff)" :key="lineIndex">{{ line }}</li>
|
||||
</ul>
|
||||
<details v-if="attempt.input_snapshot || attempt.output_snapshot">
|
||||
<summary>{{ t('admin.shippingProcessGates.viewSnapshots') }}</summary>
|
||||
<div class="process-gate-snapshots">
|
||||
<pre>{{ formatJson(attempt.input_snapshot) }}</pre>
|
||||
<pre>{{ formatJson(attempt.output_snapshot) }}</pre>
|
||||
</div>
|
||||
</details>
|
||||
</article>
|
||||
</div>
|
||||
<p v-else>{{ t('admin.shippingProcessGates.noAttempts') }}</p>
|
||||
</template>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<template #pagination>
|
||||
<ElPagination
|
||||
v-model:current-page="page"
|
||||
v-model:page-size="pageSize"
|
||||
:total="total"
|
||||
:page-sizes="pageSizes"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
@current-change="load"
|
||||
@size-change="onPageSizeChange"
|
||||
/>
|
||||
</template>
|
||||
</AdminListPage>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.process-gate-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
|
||||
gap: 16px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.process-gate-detail {
|
||||
padding: 0 32px 16px 0;
|
||||
}
|
||||
|
||||
.process-gate-detail__head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.process-gate-meta {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px 16px;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.process-gate-panel,
|
||||
.process-gate-stack {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.process-gate-tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.process-gate-snapshots {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.process-gate-snapshots pre,
|
||||
.process-gate-panel pre {
|
||||
max-height: 12rem;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
:deep(.process-gate-filter) {
|
||||
width: 11rem;
|
||||
}
|
||||
|
||||
:deep(.process-gate-filter-search),
|
||||
:deep(.process-gate-filter-time) {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.process-gate-layout {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.process-gate-detail {
|
||||
padding-right: 32px;
|
||||
padding-left: 32px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
File diff suppressed because it is too large.
Load diff
+123
-71
@@ -1,14 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/training-config/components/LeanTargetModal.vue
|
||||
* 用途:精益周任务"受训对象"选择弹窗,支持按角色、按员工两个维度多选(两个范围取并集生效)。
|
||||
* 依赖:vue-i18n、lucide 图标与父级培训配置页面传入的目标状态(角色/用户 ID/用户列表)。
|
||||
* 逻辑:弹窗打开时从 props 快照到本地草稿(取消不污染外部状态);员工支持关键字搜索;
|
||||
* 确认后 emit save({ roles, userIds }),由父级写回表单并随"保存任务"统一落库。
|
||||
* 用途:精益周任务受训对象选择对话框,按角色和员工两个维度多选。
|
||||
* 依赖:element-plus 对话框、复选框和搜索框、vue-i18n、父级传入的用户列表。
|
||||
* 逻辑:打开时把父级选择快照到本地草稿,取消不回写。确认后 emit save,由父级随保存任务提交。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Search } from 'lucide-vue-next';
|
||||
import { ElButton, ElCheckbox, ElDialog, ElForm, ElFormItem, ElInput, ElText } from 'element-plus';
|
||||
import type { AdminUserRow } from '../../../types/admin.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -48,91 +47,144 @@ const summaryLabel = computed(() => t('admin.trainingConfig.lean.targetSelectedC
|
||||
users: draftUserIds.value.length,
|
||||
}));
|
||||
|
||||
/**
|
||||
* 切换一个角色是否进入本次草稿。
|
||||
* @param role - 角色名
|
||||
*/
|
||||
const toggleRole = (role: string) => {
|
||||
draftRoles.value = draftRoles.value.includes(role)
|
||||
? draftRoles.value.filter((item) => item !== role)
|
||||
: [...draftRoles.value, role];
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换一名员工是否进入本次草稿。
|
||||
* @param userId - 用户主键
|
||||
*/
|
||||
const toggleUser = (userId: number) => {
|
||||
draftUserIds.value = draftUserIds.value.includes(userId)
|
||||
? draftUserIds.value.filter((item) => item !== userId)
|
||||
: [...draftUserIds.value, userId];
|
||||
};
|
||||
|
||||
/**
|
||||
* 把草稿交回父级。落库仍等父级保存周任务。
|
||||
*/
|
||||
const handleSave = () => {
|
||||
emit('save', { roles: [...draftRoles.value], userIds: [...draftUserIds.value] });
|
||||
};
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="props.visible" class="admin-modal-overlay animate-fade-in items-center" @click.self="emit('close')">
|
||||
<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.trainingConfig.lean.targetModalTitle') }}</h3>
|
||||
<p class="mt-1 text-xs text-muted">{{ t('admin.trainingConfig.lean.targetsHint') }}</p>
|
||||
<ElDialog
|
||||
:model-value="props.visible"
|
||||
:title="t('admin.trainingConfig.lean.targetModalTitle')"
|
||||
width="680px"
|
||||
align-center
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@update:model-value="onVisibleChange"
|
||||
>
|
||||
<ElText type="info">{{ t('admin.trainingConfig.lean.targetsHint') }}</ElText>
|
||||
<ElForm label-position="top" class="lean-target-form">
|
||||
<div class="lean-target-grid">
|
||||
<ElFormItem :label="t('admin.trainingConfig.lean.targetRoles')">
|
||||
<div class="lean-target-list">
|
||||
<ElCheckbox
|
||||
v-for="role in props.roleOptions"
|
||||
:key="role"
|
||||
:model-value="draftRoles.includes(role)"
|
||||
@change="toggleRole(role)"
|
||||
>
|
||||
{{ role }}
|
||||
</ElCheckbox>
|
||||
<ElText v-if="!props.roleOptions.length" type="info">{{ t('admin.trainingConfig.lean.targetRolesEmpty') }}</ElText>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.trainingConfig.lean.targetUsers')">
|
||||
<ElInput
|
||||
v-model="keyword"
|
||||
class="lean-target-search"
|
||||
clearable
|
||||
:placeholder="t('admin.trainingConfig.lean.targetSearchPlaceholder')"
|
||||
/>
|
||||
<div class="lean-target-list lean-target-list--scroll">
|
||||
<ElCheckbox
|
||||
v-for="user in filteredUsers"
|
||||
:key="user.id"
|
||||
:model-value="draftUserIds.includes(user.id)"
|
||||
@change="toggleUser(user.id)"
|
||||
>
|
||||
{{ user.real_name || user.username }}
|
||||
<ElText type="info">{{ user.username }}</ElText>
|
||||
</ElCheckbox>
|
||||
<ElText v-if="!filteredUsers.length" type="info">{{ t('admin.trainingConfig.lean.targetUsersEmpty') }}</ElText>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 overflow-y-auto">
|
||||
<div class="grid gap-5 md:grid-cols-2">
|
||||
<!-- 按角色选择 -->
|
||||
<div class="space-y-2">
|
||||
<label class="label-field">{{ t('admin.trainingConfig.lean.targetRoles') }}</label>
|
||||
<div class="space-y-2 rounded-xl border border-default bg-surface p-3">
|
||||
<label
|
||||
v-for="role in props.roleOptions"
|
||||
:key="role"
|
||||
class="flex cursor-pointer items-center gap-3 rounded-lg px-2 py-2 text-sm transition hover:bg-surface-soft"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-default text-emerald-600 focus:ring-emerald-500"
|
||||
:checked="draftRoles.includes(role)"
|
||||
@change="toggleRole(role)"
|
||||
/>
|
||||
<span class="text-primary">{{ role }}</span>
|
||||
</label>
|
||||
<p v-if="!props.roleOptions.length" class="px-2 py-3 text-xs text-muted">{{ t('admin.trainingConfig.lean.targetRolesEmpty') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 按员工选择 -->
|
||||
<div class="space-y-2">
|
||||
<label class="label-field">{{ t('admin.trainingConfig.lean.targetUsers') }}</label>
|
||||
<div class="relative">
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
class="input-field pl-9 text-sm"
|
||||
:placeholder="t('admin.trainingConfig.lean.targetSearchPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<div class="max-h-64 space-y-1 overflow-y-auto rounded-xl border border-default bg-surface p-2">
|
||||
<label
|
||||
v-for="user in filteredUsers"
|
||||
:key="user.id"
|
||||
class="flex cursor-pointer items-center gap-3 rounded-lg px-2 py-2 text-sm transition hover:bg-surface-soft"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4 rounded border-default text-emerald-600 focus:ring-emerald-500"
|
||||
:checked="draftUserIds.includes(user.id)"
|
||||
@change="toggleUser(user.id)"
|
||||
/>
|
||||
<span class="min-w-0 flex-1 truncate text-primary">{{ user.real_name || user.username }}</span>
|
||||
<span class="shrink-0 text-xs text-muted">{{ user.username }}</span>
|
||||
</label>
|
||||
<p v-if="!filteredUsers.length" class="px-2 py-3 text-xs text-muted">{{ t('admin.trainingConfig.lean.targetUsersEmpty') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<div class="lean-target-footer">
|
||||
<ElText type="info">{{ summaryLabel }}</ElText>
|
||||
<div>
|
||||
<ElButton @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" @click="handleSave">{{ t('admin.trainingConfig.lean.targetConfirm') }}</ElButton>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<p class="mr-auto text-xs text-muted">{{ summaryLabel }}</p>
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" @click="handleSave">
|
||||
{{ t('admin.trainingConfig.lean.targetConfirm') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.lean-target-form {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.lean-target-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.lean-target-list {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
}
|
||||
|
||||
.lean-target-list--scroll {
|
||||
max-height: 16rem;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:deep(.lean-target-search) {
|
||||
width: 16rem;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.lean-target-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.lean-target-grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+42
-33
@@ -1,11 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/training-config/components/TrainingTypeFormModal.vue
|
||||
* 用途:提供培训类型 code 与名称的新增、编辑弹窗。
|
||||
* 依赖:vue-i18n 与父级培训配置页面的表单状态。
|
||||
* 逻辑:允许管理员输入符合编码规范的自定义类型 code,并将保存动作交由父级处理。
|
||||
* 用途:培训类型编码和名称的新增、编辑对话框。
|
||||
* 依赖:element-plus 对话框和表单、vue-i18n、父级传入的类型表单。
|
||||
* 逻辑:TrainingConfigPage 打开本组件。字段仍写回父级 form 对象,保存由父级校验并调接口。样式跟页面已引入的 Element 皮肤走。
|
||||
*/
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElForm, ElFormItem, ElInput } from 'element-plus';
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
@@ -16,37 +17,45 @@ const props = defineProps<{
|
||||
|
||||
const emit = defineEmits<{ close: []; save: [] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
/**
|
||||
* 对话框关闭时通知页面收起。提交中不响应关闭。
|
||||
* @param open - Element 对话框的打开状态
|
||||
*/
|
||||
function onVisibleChange(open: boolean): void {
|
||||
if (!open && !props.isSaving) emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="props.visible" class="admin-modal-overlay animate-fade-in items-center" @click.self="emit('close')">
|
||||
<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">{{ props.editing ? t('admin.trainingConfig.editType') : t('admin.trainingConfig.addType') }}</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.trainingConfig.fields.type') }}</label>
|
||||
<input
|
||||
v-model="props.form.training_type"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
maxlength="50"
|
||||
pattern="[a-z][a-z0-9_-]*"
|
||||
:placeholder="t('admin.trainingConfig.placeholders.typeCode')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.trainingConfig.fields.name') }}</label>
|
||||
<input v-model="props.form.name" type="text" class="input-field text-sm" :placeholder="t('admin.trainingConfig.fields.name')" />
|
||||
</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="props.isSaving" @click="emit('save')">
|
||||
{{ props.isSaving ? `${t('admin.save')}...` : props.editing ? t('admin.update') : t('admin.add') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ElDialog
|
||||
:model-value="visible"
|
||||
:title="editing ? t('admin.trainingConfig.editType') : t('admin.trainingConfig.addType')"
|
||||
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.trainingConfig.fields.type')">
|
||||
<ElInput
|
||||
v-model="form.training_type"
|
||||
maxlength="50"
|
||||
:placeholder="t('admin.trainingConfig.placeholders.typeCode')"
|
||||
/>
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.trainingConfig.fields.name')">
|
||||
<ElInput v-model="form.name" :placeholder="t('admin.trainingConfig.fields.name')" />
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
<template #footer>
|
||||
<ElButton :disabled="isSaving" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||
{{ editing ? t('admin.update') : t('admin.add') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElDialog>
|
||||
</template>
|
||||
@@ -1,26 +1,24 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/WecomLayout.vue
|
||||
* 企微管理壳层:二级 Tab、共享 composable、子路由出口。
|
||||
* 用途:企微管理壳层。注入共享数据,并提供 Element 语言与样式。
|
||||
* 依赖:useWecomAdmin、useElementProvider、element-plus、WECOM_ADMIN_KEY。
|
||||
* 逻辑:路由 /admin/wecom 的父级。首屏等 loadAll 结束后再渲染子页。子页自己放页签和列表,解绑确认在 composable 里完成。
|
||||
*/
|
||||
import { onMounted, provide } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { RefreshCw } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import WecomSubNav from './components/WecomSubNav.vue';
|
||||
import { ElConfigProvider, ElLoading } from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/features/admin/styles/element-trial.css';
|
||||
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { useWecomAdmin } from './composables/useWecomAdmin';
|
||||
import { WECOM_ADMIN_KEY } from './wecom.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const vLoading = ElLoading.directive;
|
||||
const { elementLocale } = useElementProvider();
|
||||
const wecomAdmin = useWecomAdmin();
|
||||
const { isLoading } = wecomAdmin;
|
||||
provide(WECOM_ADMIN_KEY, wecomAdmin);
|
||||
const {
|
||||
isLoading,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
confirmDelete,
|
||||
refreshWecomData,
|
||||
} = wecomAdmin;
|
||||
|
||||
onMounted(() => {
|
||||
void wecomAdmin.loadAll();
|
||||
@@ -28,33 +26,15 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<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>
|
||||
|
||||
<section v-else class="section-gap animate-fade-in-up space-y-6">
|
||||
<div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.wecom.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary inline-flex items-center gap-2 px-4 py-2 text-secondary rounded-xl hover-surface-soft transition-all shadow-sm"
|
||||
@click="refreshWecomData()"
|
||||
>
|
||||
<RefreshCw class="w-4 h-4" />
|
||||
{{ t('admin.wecom.refresh') }}
|
||||
</button>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<div v-loading="isLoading" class="wecom-layout">
|
||||
<router-view v-if="!isLoading" />
|
||||
</div>
|
||||
|
||||
<WecomSubNav />
|
||||
<router-view />
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wecom-layout {
|
||||
min-height: 16rem;
|
||||
}
|
||||
</style>
|
||||
@@ -1,10 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/components/WecomOverviewCards.vue
|
||||
* 企微 userid 绑定概览统计卡片。
|
||||
* 用途:企微 userid 绑定概览。四张统计卡,不是列表。
|
||||
* 依赖:getAdminWecomBindingStats、element-plus 的卡片和统计。
|
||||
* 逻辑:绑定管理页放在列表卡片正文里。数字用 ElStatistic;说明句用文字块。refreshKey 变化时重拉。
|
||||
*/
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElCard, ElStatistic, ElText } from 'element-plus';
|
||||
import { getAdminWecomBindingStats } from '@/features/admin/api/admin.api';
|
||||
import type { WecomBindingStats } from '@/features/admin/types/wecom.types';
|
||||
|
||||
@@ -16,7 +19,8 @@ const { t } = useI18n();
|
||||
const stats = ref<WecomBindingStats | null>(null);
|
||||
|
||||
/**
|
||||
* 拉取绑定统计,供设置页概览卡片展示。
|
||||
* 拉取绑定统计,供概览卡片展示。
|
||||
* 核心逻辑:请求失败时清空卡片,避免留下过期数字。
|
||||
*/
|
||||
const loadStats = async (): Promise<void> => {
|
||||
try {
|
||||
@@ -42,22 +46,43 @@ defineExpose({ reload: loadStats });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="stats" class="grid grid-cols-2 xl:grid-cols-4 gap-3">
|
||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.bound') }}</div>
|
||||
<div class="mt-1 text-xl font-semibold text-primary">{{ stats.bound }} / {{ stats.total_active }}</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.unbound') }}</div>
|
||||
<div class="mt-1 text-xl font-semibold text-amber-700">{{ stats.unbound }}</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.boundRate') }}</div>
|
||||
<div class="mt-1 text-xl font-semibold text-emerald-700">{{ stats.bound_rate }}%</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.hint') }}</div>
|
||||
<div class="mt-1 text-sm text-secondary leading-5">{{ t('admin.wecom.overview.hintDesc') }}</div>
|
||||
</div>
|
||||
<div v-if="stats" class="wecom-overview">
|
||||
<ElCard shadow="never">
|
||||
<ElStatistic
|
||||
:title="t('admin.wecom.overview.bound')"
|
||||
:value="stats.bound"
|
||||
:suffix="` / ${stats.total_active}`"
|
||||
/>
|
||||
</ElCard>
|
||||
<ElCard shadow="never">
|
||||
<ElStatistic :title="t('admin.wecom.overview.unbound')" :value="stats.unbound" />
|
||||
</ElCard>
|
||||
<ElCard shadow="never">
|
||||
<ElStatistic :title="t('admin.wecom.overview.boundRate')" :value="stats.bound_rate" suffix="%" />
|
||||
</ElCard>
|
||||
<ElCard shadow="never">
|
||||
<div class="wecom-overview__hint-title">{{ t('admin.wecom.overview.hint') }}</div>
|
||||
<ElText type="info">{{ t('admin.wecom.overview.hintDesc') }}</ElText>
|
||||
</ElCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wecom-overview {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.wecom-overview__hint-title {
|
||||
margin-bottom: 8px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-small);
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
.wecom-overview {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,33 +1,43 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/components/WecomSubNav.vue
|
||||
* 企微管理二级 Tab 导航。
|
||||
* 用途:企微管理的设置、绑定、审计页签。
|
||||
* 依赖:AdminListTabs、vue-router、vue-i18n。
|
||||
* 逻辑:放进各子页 AdminListPage 的 tabs 插槽。页签名就是现有路由名,点击只做 router.push。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const tabs = [
|
||||
{ name: 'AdminWecomSettings', labelKey: 'admin.wecom.nav.settings' },
|
||||
{ name: 'AdminWecomBindings', labelKey: 'admin.wecom.nav.bindings' },
|
||||
{ name: 'AdminWecomAudits', labelKey: 'admin.wecom.nav.audits' },
|
||||
] as const;
|
||||
|
||||
const tabItems = computed(() => tabs.map((tab) => ({
|
||||
name: tab.name,
|
||||
label: t(tab.labelKey),
|
||||
})));
|
||||
|
||||
const activeTab = computed(() => String(route.name || 'AdminWecomSettings'));
|
||||
|
||||
/**
|
||||
* 切换企微子页。
|
||||
* 核心逻辑:页签名与路由名相同,只跳转,不改路由表。
|
||||
* @param name - AdminListTabs 当前 name
|
||||
*/
|
||||
function onTabChange(name: string): void {
|
||||
if (name === activeTab.value) return;
|
||||
void router.push({ name });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-2 border-b border-subtle pb-3">
|
||||
<router-link
|
||||
v-for="tab in tabs"
|
||||
:key="tab.name"
|
||||
:to="{ name: tab.name }"
|
||||
class="rounded-xl px-4 py-2 text-sm font-medium transition-colors"
|
||||
:class="route.name === tab.name
|
||||
? 'bg-brand-50 text-brand-700 ring-1 ring-brand-200'
|
||||
: 'text-secondary hover:bg-surface-soft hover:text-primary'"
|
||||
>
|
||||
{{ t(tab.labelKey) }}
|
||||
</router-link>
|
||||
</div>
|
||||
<AdminListTabs :model-value="activeTab" :items="tabItems" @update:model-value="onTabChange" />
|
||||
</template>
|
||||
@@ -1,14 +1,23 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/components/WecomSyncPanel.vue
|
||||
* OA userInfo_view 工号→wecom_userid 同步面板(预览 + 确认写入)。
|
||||
* 依赖:useWecomSync、WECOM_ADMIN_KEY.refreshWecomData。
|
||||
* 逻辑:绑定管理页调用;先扫本地工号,再按 IN 查 OA userInfo_view 匹配写入。
|
||||
* 用途:OA userInfo_view 工号到 wecom_userid 的预览和确认写入面板。
|
||||
* 依赖:useWecomSync、WECOM_ADMIN_KEY.refreshWecomData、element-plus。
|
||||
* 逻辑:绑定管理页调用。先扫本地工号,再按 IN 查 OA 匹配。确认写入在 composable 里弹 Element 确认框。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { RefreshCw } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElLoading,
|
||||
ElStatistic,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElText,
|
||||
} from 'element-plus';
|
||||
import type { WecomSyncPendingUpdate } from '@/features/admin/types/wecom.types';
|
||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||
import { useWecomSync } from '../composables/useWecomSync';
|
||||
|
||||
@@ -16,146 +25,190 @@ const emit = defineEmits<{
|
||||
applied: [];
|
||||
}>();
|
||||
|
||||
const vLoading = ElLoading.directive;
|
||||
const { t } = useI18n();
|
||||
const { refreshWecomData } = inject(WECOM_ADMIN_KEY)!;
|
||||
|
||||
const {
|
||||
isSyncing,
|
||||
previewSummary,
|
||||
showApplyConfirm,
|
||||
canApplySync,
|
||||
applyBlockHint,
|
||||
previewSync,
|
||||
requestApplySync,
|
||||
confirmApplySync,
|
||||
} = useWecomSync({
|
||||
onApplied: async () => {
|
||||
await refreshWecomData();
|
||||
emit('applied');
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* 预览表的行键。同一工号待写入的 userid 唯一。
|
||||
* @param row - 待更新行
|
||||
* @returns 工号与 userid 拼成的键
|
||||
*/
|
||||
function pendingRowKey(row: WecomSyncPendingUpdate): string {
|
||||
return `${row.employee_id}-${row.wecom_userid}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<div>
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.sync.title') }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">{{ t('admin.wecom.sync.desc') }}</p>
|
||||
<p class="mt-2 text-xs text-sky-900 bg-sky-50 border border-sky-100 rounded-lg px-3 py-2">
|
||||
{{ t('admin.wecom.sync.oaSourceNote') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="wecom-sync">
|
||||
<h3 class="wecom-sync__title">{{ t('admin.wecom.sync.title') }}</h3>
|
||||
<ElText type="info">{{ t('admin.wecom.sync.desc') }}</ElText>
|
||||
<ElAlert
|
||||
class="wecom-sync__note"
|
||||
type="info"
|
||||
:closable="false"
|
||||
:title="t('admin.wecom.sync.oaSourceNote')"
|
||||
/>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 text-sm">
|
||||
<div class="wecom-sync__fields">
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.oaWorkcodeField') }}</div>
|
||||
<div class="mt-1 font-mono text-primary">userInfo_view.workcode</div>
|
||||
<div class="wecom-sync__label">{{ t('admin.wecom.sync.oaWorkcodeField') }}</div>
|
||||
<div class="wecom-sync__mono">userInfo_view.workcode</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.oaWecomIdField') }}</div>
|
||||
<div class="mt-1 font-mono text-primary">userInfo_view.id</div>
|
||||
<div class="wecom-sync__label">{{ t('admin.wecom.sync.oaWecomIdField') }}</div>
|
||||
<div class="wecom-sync__mono">userInfo_view.id</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2"
|
||||
:class="isSyncing ? 'btn-secondary opacity-60' : 'btn-primary'"
|
||||
:disabled="isSyncing"
|
||||
@click="previewSync"
|
||||
>
|
||||
<RefreshCw class="w-4 h-4" :class="{ 'animate-spin': isSyncing }" />
|
||||
{{ t('admin.wecom.sync.preview') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="canApplySync && !isSyncing ? 'btn-primary' : 'btn-secondary opacity-60'"
|
||||
:disabled="isSyncing"
|
||||
:title="applyBlockHint || undefined"
|
||||
@click="requestApplySync"
|
||||
>
|
||||
{{ t('admin.wecom.sync.apply') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="applyBlockHint && !isSyncing" class="text-xs text-muted">
|
||||
{{ applyBlockHint }}
|
||||
</p>
|
||||
<div class="wecom-sync__actions">
|
||||
<ElButton type="primary" :icon="Refresh" :loading="isSyncing" @click="previewSync">
|
||||
{{ t('admin.wecom.sync.preview') }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
:type="canApplySync ? 'primary' : 'default'"
|
||||
:disabled="isSyncing"
|
||||
:title="applyBlockHint || undefined"
|
||||
@click="requestApplySync"
|
||||
>
|
||||
{{ t('admin.wecom.sync.apply') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
<ElText v-if="applyBlockHint && !isSyncing" type="info">{{ applyBlockHint }}</ElText>
|
||||
|
||||
<div v-if="previewSummary" class="rounded-xl border border-subtle bg-surface-soft p-4 space-y-3 text-sm">
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-3">
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.stats.localCandidates') }}</div>
|
||||
<div class="font-semibold text-primary">{{ previewSummary.local_candidates }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.stats.oaMatched') }}</div>
|
||||
<div class="font-semibold text-primary">{{ previewSummary.local_matched }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.stats.wouldUpdate') }}</div>
|
||||
<div class="font-semibold text-brand-700">{{ previewSummary.would_update }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.stats.conflicts') }}</div>
|
||||
<div class="font-semibold" :class="previewSummary.conflicts?.length ? 'text-red-600' : 'text-emerald-700'">
|
||||
{{ previewSummary.conflicts?.length || 0 }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="previewSummary" v-loading="isSyncing" class="wecom-sync__result">
|
||||
<div class="wecom-sync__stats">
|
||||
<ElStatistic :title="t('admin.wecom.sync.stats.localCandidates')" :value="previewSummary.local_candidates" />
|
||||
<ElStatistic :title="t('admin.wecom.sync.stats.oaMatched')" :value="previewSummary.local_matched" />
|
||||
<ElStatistic :title="t('admin.wecom.sync.stats.wouldUpdate')" :value="previewSummary.would_update" />
|
||||
<ElStatistic :title="t('admin.wecom.sync.stats.conflicts')" :value="previewSummary.conflicts?.length || 0" />
|
||||
</div>
|
||||
|
||||
<div v-if="previewSummary.local_missing > 0" class="text-xs text-muted">
|
||||
<ElText v-if="previewSummary.local_missing > 0" type="info">
|
||||
{{ t('admin.wecom.sync.localMissingHint', { count: previewSummary.local_missing }) }}
|
||||
</div>
|
||||
</ElText>
|
||||
|
||||
<div v-if="previewSummary.pending_updates?.length" class="overflow-x-auto">
|
||||
<table class="admin-table min-w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.employeeId') }}</th>
|
||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.user') }}</th>
|
||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.wecomUserId') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in previewSummary.pending_updates" :key="`${row.employee_id}-${row.wecom_userid}`">
|
||||
<td class="px-3 py-2 text-xs">{{ row.employee_id }}</td>
|
||||
<td class="px-3 py-2 text-xs">
|
||||
{{ row.username }}
|
||||
<span v-if="row.name" class="text-muted"> · {{ row.name }}</span>
|
||||
</td>
|
||||
<td class="px-3 py-2 text-xs font-mono">{{ row.wecom_userid }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-if="previewSummary.would_update > previewSummary.pending_updates.length" class="mt-2 text-xs text-muted">
|
||||
{{ t('admin.wecom.sync.previewTruncated', { total: previewSummary.would_update }) }}
|
||||
</p>
|
||||
</div>
|
||||
<ElTable
|
||||
v-if="previewSummary.pending_updates?.length"
|
||||
class="hx-admin-table"
|
||||
:data="previewSummary.pending_updates"
|
||||
:row-key="pendingRowKey"
|
||||
:empty-text="t('admin.wecom.noData')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.employeeId')" min-width="140">
|
||||
<template #default="{ row }">{{ (row as WecomSyncPendingUpdate).employee_id }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.user')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
{{ (row as WecomSyncPendingUpdate).username }}
|
||||
<ElText v-if="(row as WecomSyncPendingUpdate).name" type="info">
|
||||
· {{ (row as WecomSyncPendingUpdate).name }}
|
||||
</ElText>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.wecomUserId')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span class="wecom-sync__mono">{{ (row as WecomSyncPendingUpdate).wecom_userid }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<ElText
|
||||
v-if="previewSummary.pending_updates?.length && previewSummary.would_update > previewSummary.pending_updates.length"
|
||||
type="info"
|
||||
>
|
||||
{{ t('admin.wecom.sync.previewTruncated', { total: previewSummary.would_update }) }}
|
||||
</ElText>
|
||||
|
||||
<div v-if="previewSummary.conflicts?.length" class="space-y-2">
|
||||
<div class="text-xs font-medium text-red-700">{{ t('admin.wecom.sync.conflictsTitle') }}</div>
|
||||
<div
|
||||
<div v-if="previewSummary.conflicts?.length" class="wecom-sync__conflicts">
|
||||
<ElText type="danger">{{ t('admin.wecom.sync.conflictsTitle') }}</ElText>
|
||||
<ElAlert
|
||||
v-for="(conflict, idx) in previewSummary.conflicts"
|
||||
:key="idx"
|
||||
class="rounded-lg border border-red-100 bg-red-50 px-3 py-2 text-xs text-red-800"
|
||||
type="error"
|
||||
:closable="false"
|
||||
:title="conflict.employee_id + ' / ' + conflict.username"
|
||||
>
|
||||
{{ conflict.employee_id }} / {{ conflict.username }}
|
||||
<span v-if="conflict.old_wecom_userid"> · {{ conflict.old_wecom_userid }} → {{ conflict.new_wecom_userid }}</span>
|
||||
<span v-else-if="conflict.occupied_by_username"> · {{ t('admin.wecom.sync.occupiedBy', { user: conflict.occupied_by_username }) }}</span>
|
||||
</div>
|
||||
<span v-if="conflict.old_wecom_userid">{{ conflict.old_wecom_userid }} → {{ conflict.new_wecom_userid }}</span>
|
||||
<span v-else-if="conflict.occupied_by_username">
|
||||
{{ t('admin.wecom.sync.occupiedBy', { user: conflict.occupied_by_username }) }}
|
||||
</span>
|
||||
</ElAlert>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showApplyConfirm"
|
||||
:title="t('admin.wecom.sync.applyConfirmTitle')"
|
||||
:message="t('admin.wecom.sync.applyConfirm', { count: previewSummary?.would_update || 0 })"
|
||||
:confirm-text="t('admin.wecom.sync.applyConfirmButton')"
|
||||
confirm-tone="primary"
|
||||
@confirm="confirmApplySync"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wecom-sync {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 16px 32px 24px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.wecom-sync__title {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-large);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wecom-sync__note {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.wecom-sync__fields,
|
||||
.wecom-sync__stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.wecom-sync__label {
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: var(--el-font-size-small);
|
||||
}
|
||||
|
||||
.wecom-sync__mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
.wecom-sync__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.wecom-sync__result {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.wecom-sync__conflicts {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.wecom-sync__stats {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/wecom/composables/useWecomAdmin.ts
|
||||
* 企业微信:绑定、系统配置、通知、登录审计。
|
||||
* 依赖:admin.api、useMessage、wecom 展示工具、PaginationBar 所需的审计分页状态。
|
||||
* 逻辑:绑定走服务端分页;登录审计仍一次拉取最近 200 条,由前端切片分页。
|
||||
* 依赖:admin.api、useMessage、wecom 展示工具、element-plus 确认框。
|
||||
* 逻辑:绑定走服务端分页;登录审计仍一次拉取最近 200 条,由前端切片分页。解绑用 ElMessageBox。
|
||||
*/
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import * as XLSX from 'xlsx';
|
||||
import {
|
||||
bindAdminWecomUser,
|
||||
@@ -90,10 +91,6 @@ export function useWecomAdmin() {
|
||||
const wecomSystemSettings = ref<WecomSystemSettings>(createDefaultWecomSystemSettings());
|
||||
const wecomIntegrationManifest = ref<WecomIntegrationManifest | null>(null);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
const wecomBindUserOptions = computed(() => {
|
||||
const keyword = wecomBindUserQuery.value.trim().toLowerCase();
|
||||
return users.value
|
||||
@@ -110,26 +107,6 @@ export function useWecomAdmin() {
|
||||
}));
|
||||
});
|
||||
|
||||
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 loadUsers = async (): Promise<void> => {
|
||||
try {
|
||||
users.value = await listAdminUsers();
|
||||
@@ -428,19 +405,31 @@ export function useWecomAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 管理员解绑企微 userid。取消确认则不请求。
|
||||
* 核心逻辑:Element 确认框使用通用删除标题和按钮;确定后仍调用既有解绑接口并刷新列表。
|
||||
* @param userId - 本地用户主键
|
||||
*/
|
||||
const unbindWecomUserByAdmin = async (userId: number): Promise<void> => {
|
||||
openDeleteConfirm(t('admin.wecom.confirmUnbind'), async () => {
|
||||
isSaving.value = true;
|
||||
try {
|
||||
await unbindAdminWecomUser(userId);
|
||||
await refreshWecomData();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.wecom.msg.unbindFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
await ElMessageBox.confirm(t('admin.wecom.confirmUnbind'), t('common.deleteDialog.defaultTitle'), {
|
||||
type: 'warning',
|
||||
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
});
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
await unbindAdminWecomUser(userId);
|
||||
await refreshWecomData();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.wecom.msg.unbindFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const exportWecomAudits = (): void => {
|
||||
@@ -522,8 +511,6 @@ export function useWecomAdmin() {
|
||||
wecomNotifyMetrics,
|
||||
wecomSystemSettings,
|
||||
wecomIntegrationManifest,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
refreshWecomData,
|
||||
selectWecomBindUser,
|
||||
@@ -539,6 +526,5 @@ export function useWecomAdmin() {
|
||||
bindWecomUser,
|
||||
unbindWecomUserByAdmin,
|
||||
exportWecomAudits,
|
||||
confirmDelete,
|
||||
};
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* features/admin/modules/wecom/composables/useWecomSync.ts
|
||||
* OA userInfo_view → 本地 wecom_userid 同步:预览 dry-run 与确认写入。
|
||||
* 用途:OA userInfo_view 工号到本地 wecom_userid 的预览与确认写入。
|
||||
* 依赖:admin.api 的 syncAdminWecomUserids、useMessage、element-plus 确认框。
|
||||
* 逻辑:WecomSyncPanel 调用。先 dry-run,确认后再 apply。确认框取消则不写库。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElMessageBox } from 'element-plus';
|
||||
import { syncAdminWecomUserids } from '@/features/admin/api/admin.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { WecomSyncSummary } from '@/features/admin/types/wecom.types';
|
||||
@@ -17,7 +20,6 @@ export function useWecomSync(options?: { onApplied?: () => void | Promise<void>
|
||||
|
||||
const isSyncing = ref(false);
|
||||
const previewSummary = ref<WecomSyncSummary | null>(null);
|
||||
const showApplyConfirm = ref(false);
|
||||
const previewAttempted = ref(false);
|
||||
const previewFailed = ref(false);
|
||||
|
||||
@@ -79,9 +81,29 @@ export function useWecomSync(options?: { onApplied?: () => void | Promise<void>
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开确认写入对话框;不可写入时弹出对应提示。
|
||||
* 确认后把预览结果写入数据库。
|
||||
* 核心逻辑:调用 syncAdminWecomUserids({ apply: true }),成功后刷新预览摘要并通知页面。
|
||||
*/
|
||||
const requestApplySync = (): void => {
|
||||
const confirmApplySync = async (): Promise<void> => {
|
||||
isSyncing.value = true;
|
||||
try {
|
||||
const summary = await syncAdminWecomUserids({ apply: true });
|
||||
previewSummary.value = summary;
|
||||
msg.success(t('admin.wecom.sync.applyDone', { count: summary.updated || 0 }));
|
||||
await options?.onApplied?.();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.wecom.sync.applyFailed'));
|
||||
} finally {
|
||||
isSyncing.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 请求确认写入。不可写入时只提示原因;可以写入时先弹确认框,取消则不写库。
|
||||
* 核心逻辑:拦截条件与原来一致。确认文案仍用同步模块自己的标题和按钮,取消按钮用通用文案。
|
||||
*/
|
||||
const requestApplySync = async (): Promise<void> => {
|
||||
if (isSyncing.value) return;
|
||||
if (previewFailed.value || (previewAttempted.value && !previewSummary.value)) {
|
||||
msg.warning(t('admin.wecom.sync.previewFirstAfterFail'));
|
||||
@@ -99,36 +121,28 @@ export function useWecomSync(options?: { onApplied?: () => void | Promise<void>
|
||||
msg.info(t('admin.wecom.sync.nothingToUpdate'));
|
||||
return;
|
||||
}
|
||||
showApplyConfirm.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 确认后将预览结果写入数据库。
|
||||
*/
|
||||
const confirmApplySync = async (): Promise<void> => {
|
||||
isSyncing.value = true;
|
||||
try {
|
||||
const summary = await syncAdminWecomUserids({ apply: true });
|
||||
previewSummary.value = summary;
|
||||
showApplyConfirm.value = false;
|
||||
msg.success(t('admin.wecom.sync.applyDone', { count: summary.updated || 0 }));
|
||||
await options?.onApplied?.();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.wecom.sync.applyFailed'));
|
||||
} finally {
|
||||
isSyncing.value = false;
|
||||
await ElMessageBox.confirm(
|
||||
t('admin.wecom.sync.applyConfirm', { count: previewSummary.value.would_update || 0 }),
|
||||
t('admin.wecom.sync.applyConfirmTitle'),
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: t('admin.wecom.sync.applyConfirmButton'),
|
||||
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||
},
|
||||
);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
await confirmApplySync();
|
||||
};
|
||||
|
||||
return {
|
||||
isSyncing,
|
||||
previewSummary,
|
||||
showApplyConfirm,
|
||||
canApplySync,
|
||||
applyBlockHint,
|
||||
previewSync,
|
||||
requestApplySync,
|
||||
confirmApplySync,
|
||||
};
|
||||
}
|
||||
@@ -1,18 +1,37 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/pages/WecomAuditsPage.vue
|
||||
* 企微与密码登录审计列表。
|
||||
* 依赖:WECOM_ADMIN_KEY、PaginationBar、formatLocalDateTime。
|
||||
* 逻辑:表格渲染当前页切片;分页条对已拉取的最近 200 条做前端翻页。
|
||||
* 用途:企微与密码登录审计列表。
|
||||
* 依赖:AdminListPage、AdminListTabs、WECOM_ADMIN_KEY、element-plus、formatLocalDateTime。
|
||||
* 逻辑:路由 AdminWecomAudits。页签仍跳原来的三个子路由。表格渲染当前页切片;分页对已拉取的最近 200 条做前端翻页。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download } from 'lucide-vue-next';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { Download, Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElConfigProvider,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElSpace,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
ElText,
|
||||
} 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 { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import type { WecomLoginAuditRow } from '@/features/admin/types/wecom.types';
|
||||
import WecomSubNav from '../components/WecomSubNav.vue';
|
||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const {
|
||||
wecomAuditSourceFilter,
|
||||
wecomAuditStatusFilter,
|
||||
@@ -20,83 +39,134 @@ const {
|
||||
wecomAuditsPageSize,
|
||||
wecomAuditsPageSizeOptions,
|
||||
wecomAuditsTotal,
|
||||
filteredWecomLoginAudits,
|
||||
pagedWecomLoginAudits,
|
||||
exportWecomAudits,
|
||||
refreshWecomData,
|
||||
getWecomAuditReasonText,
|
||||
getWecomAuditMetaText,
|
||||
} = inject(WECOM_ADMIN_KEY)!;
|
||||
|
||||
/**
|
||||
* 登录来源筛选。空值表示全部,写回 composable 的 all。
|
||||
* 核心逻辑:ElSelect 不用空字符串当选项值,业务判断仍看 all。
|
||||
* @param value - 选中的来源;清空为 undefined 或空串
|
||||
*/
|
||||
function onAuditSourceChange(value: 'wecom' | 'password' | '' | undefined): void {
|
||||
wecomAuditSourceFilter.value = value ? value : 'all';
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录结果筛选。空值表示全部,写回 composable 的 all。
|
||||
* @param value - 选中的状态;清空为 undefined 或空串
|
||||
*/
|
||||
function onAuditStatusChange(value: 'success' | 'failed' | '' | undefined): void {
|
||||
wecomAuditStatusFilter.value = value ? value : 'all';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="admin-table-section">
|
||||
<div class="admin-table-header admin-table-header--stacked px-5 py-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.auditTitle') }}</h3>
|
||||
<div class="flex w-full md:w-auto flex-wrap md:flex-nowrap items-center justify-start md:justify-end gap-2">
|
||||
<select v-model="wecomAuditSourceFilter" class="admin-table-filter-input h-11 min-w-[112px] shrink-0">
|
||||
<option value="all">{{ t('admin.wecom.filters.allSources') }}</option>
|
||||
<option value="wecom">{{ t('admin.wecom.sources.wecom') }}</option>
|
||||
<option value="password">{{ t('admin.wecom.sources.password') }}</option>
|
||||
</select>
|
||||
<select v-model="wecomAuditStatusFilter" class="admin-table-filter-input h-11 min-w-[112px] shrink-0">
|
||||
<option value="all">{{ t('admin.wecom.filters.allStatus') }}</option>
|
||||
<option value="success">{{ t('admin.wecom.auditStatus.success') }}</option>
|
||||
<option value="failed">{{ t('admin.wecom.auditStatus.failed') }}</option>
|
||||
</select>
|
||||
<button type="button" class="btn-secondary h-11 shrink-0 text-sm" @click="exportWecomAudits()">
|
||||
<Download class="w-4 h-4" />
|
||||
{{ t('admin.wecom.exportAudit') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.time') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.source') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.user') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.status') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.reason') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.ip') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="filteredWecomLoginAudits.length === 0">
|
||||
<td colspan="6" class="px-4 admin-table-empty">{{ t('admin.wecom.noAuditData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in pagedWecomLoginAudits" :key="row.id">
|
||||
<td class="px-4 py-3 text-xs text-muted whitespace-nowrap" :title="row.created_at || '-'">{{ formatLocalDateTime(row.created_at) }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary">{{ t('admin.wecom.sources.' + row.source) }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary">{{ row.username || '-' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span
|
||||
class="inline-flex px-2 py-0.5 rounded-full text-[11px] font-medium"
|
||||
:class="row.status === 'success' ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700'"
|
||||
>
|
||||
{{ t('admin.wecom.auditStatus.' + row.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-muted max-w-[360px] align-top">
|
||||
<div class="max-w-[360px] whitespace-normal break-words">
|
||||
<div class="text-xs text-secondary leading-5">{{ getWecomAuditReasonText(row) }}</div>
|
||||
<div v-if="getWecomAuditMetaText(row)" class="mt-1 text-[11px] text-muted leading-5" :title="getWecomAuditMetaText(row)">
|
||||
{{ getWecomAuditMetaText(row) }}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-muted font-mono">{{ row.ip || '-' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="px-4 pb-4 pt-2">
|
||||
<PaginationBar
|
||||
v-model:page="wecomAuditsPage"
|
||||
v-model:page-size="wecomAuditsPageSize"
|
||||
:total="wecomAuditsTotal"
|
||||
:page-size-options="[...wecomAuditsPageSizeOptions]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.wecom.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElSpace>
|
||||
<ElButton :icon="Refresh" @click="refreshWecomData()">{{ t('admin.wecom.refresh') }}</ElButton>
|
||||
<ElButton :icon="Download" @click="exportWecomAudits()">{{ t('admin.wecom.exportAudit') }}</ElButton>
|
||||
</ElSpace>
|
||||
</template>
|
||||
<template #tabs>
|
||||
<WecomSubNav />
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElSelect
|
||||
class="wecom-filter-select"
|
||||
:model-value="wecomAuditSourceFilter === 'all' ? undefined : wecomAuditSourceFilter"
|
||||
clearable
|
||||
:placeholder="t('admin.wecom.filters.allSources')"
|
||||
@update:model-value="onAuditSourceChange"
|
||||
>
|
||||
<ElOption :label="t('admin.wecom.sources.wecom')" value="wecom" />
|
||||
<ElOption :label="t('admin.wecom.sources.password')" value="password" />
|
||||
</ElSelect>
|
||||
<ElSelect
|
||||
class="wecom-filter-select"
|
||||
:model-value="wecomAuditStatusFilter === 'all' ? undefined : wecomAuditStatusFilter"
|
||||
clearable
|
||||
:placeholder="t('admin.wecom.filters.allStatus')"
|
||||
@update:model-value="onAuditStatusChange"
|
||||
>
|
||||
<ElOption :label="t('admin.wecom.auditStatus.success')" value="success" />
|
||||
<ElOption :label="t('admin.wecom.auditStatus.failed')" value="failed" />
|
||||
</ElSelect>
|
||||
</template>
|
||||
|
||||
<ElTable
|
||||
class="hx-admin-table"
|
||||
:data="pagedWecomLoginAudits"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.wecom.noAuditData')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.wecom.auditHeaders.time')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
{{ formatLocalDateTime((row as WecomLoginAuditRow).created_at) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.auditHeaders.source')" min-width="120">
|
||||
<template #default="{ row }">
|
||||
{{ t('admin.wecom.sources.' + (row as WecomLoginAuditRow).source) }}
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.auditHeaders.user')" min-width="140">
|
||||
<template #default="{ row }">{{ (row as WecomLoginAuditRow).username || '-' }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.auditHeaders.status')" min-width="110">
|
||||
<template #default="{ row }">
|
||||
<ElTag
|
||||
effect="light"
|
||||
:type="(row as WecomLoginAuditRow).status === 'success' ? 'success' : 'danger'"
|
||||
>
|
||||
{{ t('admin.wecom.auditStatus.' + (row as WecomLoginAuditRow).status) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.auditHeaders.reason')" min-width="240">
|
||||
<template #default="{ row }">
|
||||
<div>{{ getWecomAuditReasonText(row as WecomLoginAuditRow) }}</div>
|
||||
<ElText v-if="getWecomAuditMetaText(row as WecomLoginAuditRow)" type="info">
|
||||
{{ getWecomAuditMetaText(row as WecomLoginAuditRow) }}
|
||||
</ElText>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.auditHeaders.ip')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<span class="wecom-audit-mono">{{ (row as WecomLoginAuditRow).ip || '-' }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<template #pagination>
|
||||
<ElPagination
|
||||
v-model:current-page="wecomAuditsPage"
|
||||
v-model:page-size="wecomAuditsPageSize"
|
||||
:total="wecomAuditsTotal"
|
||||
:page-sizes="[...wecomAuditsPageSizeOptions]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
/>
|
||||
</template>
|
||||
</AdminListPage>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.wecom-filter-select) {
|
||||
width: 11rem;
|
||||
}
|
||||
|
||||
.wecom-audit-mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
</style>
|
||||
@@ -1,291 +1,273 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/pages/WecomBindingsPage.vue
|
||||
* 企微 OA 同步、快速绑定与绑定列表(搜索 + 服务端分页)。
|
||||
* 依赖:WECOM_ADMIN_KEY、WecomSyncPanel、PaginationBar。
|
||||
* 用途:企微绑定概览、OA 同步、快速绑定和绑定列表。
|
||||
* 依赖:AdminListPage、AdminListTabs、WecomOverviewCards、WecomSyncPanel、WECOM_ADMIN_KEY、element-plus。
|
||||
* 逻辑:路由 AdminWecomBindings。概览和同步在页签卡片里;绑定列表单独一张 AdminListPage,搜索和分页只服务这张表。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Link2, Search, Unlink2 } from 'lucide-vue-next';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { Link, Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElConfigProvider,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
ElText,
|
||||
} 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 { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import type { WecomBindingRow } from '@/features/admin/types/wecom.types';
|
||||
import WecomOverviewCards from '../components/WecomOverviewCards.vue';
|
||||
import WecomSyncPanel from '../components/WecomSyncPanel.vue';
|
||||
import WecomSubNav from '../components/WecomSubNav.vue';
|
||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const {
|
||||
|
||||
wecomBindUserQuery,
|
||||
|
||||
wecomBindUserDropdownOpen,
|
||||
|
||||
wecomBindUserOptions,
|
||||
|
||||
wecomBindUserQuery,
|
||||
wecomBindForm,
|
||||
|
||||
isSaving,
|
||||
|
||||
wecomBoundOnly,
|
||||
|
||||
wecomBindings,
|
||||
|
||||
wecomBindingsKeyword,
|
||||
|
||||
wecomBindingsPage,
|
||||
|
||||
wecomBindingsPageSize,
|
||||
|
||||
wecomBindingsTotal,
|
||||
|
||||
wecomBindingsPages,
|
||||
|
||||
wecomBindingsPageSizeOptions,
|
||||
|
||||
selectWecomBindUser,
|
||||
|
||||
scheduleCloseWecomBindUserDropdown,
|
||||
|
||||
bindWecomUser,
|
||||
|
||||
unbindWecomUserByAdmin,
|
||||
|
||||
refreshWecomData,
|
||||
|
||||
} = inject(WECOM_ADMIN_KEY)!;
|
||||
|
||||
/**
|
||||
* 同步写入成功后刷新绑定列表和配置。
|
||||
* 核心逻辑:面板内部已经刷新过一次,这里再拉一次,保持原来的 applied 回调。
|
||||
*/
|
||||
const onSyncApplied = async (): Promise<void> => {
|
||||
await refreshWecomData();
|
||||
};
|
||||
|
||||
/**
|
||||
* 选择要绑定的本地用户。清空时把 user_id 写回空串。
|
||||
* 核心逻辑:下拉自己按姓名过滤,不再占用原来的搜索词,避免选项被收成一条。
|
||||
* @param value - 用户 id;清空为 undefined 或空串
|
||||
*/
|
||||
function onBindUserChange(value: number | string | undefined): void {
|
||||
if (value == null || value === '') {
|
||||
wecomBindForm.value.user_id = '';
|
||||
wecomBindUserQuery.value = '';
|
||||
return;
|
||||
}
|
||||
wecomBindForm.value.user_id = Number(value);
|
||||
wecomBindUserQuery.value = '';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<WecomOverviewCards />
|
||||
<WecomSyncPanel @applied="onSyncApplied" />
|
||||
|
||||
<p class="text-sm text-muted">{{ t('admin.wecom.bindingsHint') }}</p>
|
||||
|
||||
|
||||
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.quickBind') }}</h3>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-3">
|
||||
|
||||
<div class="relative md:col-span-1">
|
||||
|
||||
<input
|
||||
|
||||
v-model="wecomBindUserQuery"
|
||||
|
||||
type="text"
|
||||
|
||||
class="input-field"
|
||||
|
||||
:placeholder="t('admin.wecom.fields.userSelect')"
|
||||
|
||||
@focus="wecomBindUserDropdownOpen = true"
|
||||
|
||||
@input="wecomBindUserDropdownOpen = true"
|
||||
|
||||
@blur="scheduleCloseWecomBindUserDropdown()"
|
||||
|
||||
/>
|
||||
|
||||
<div v-if="wecomBindUserDropdownOpen" class="admin-dropdown w-72">
|
||||
|
||||
<button
|
||||
|
||||
v-for="u in wecomBindUserOptions"
|
||||
|
||||
:key="u.id"
|
||||
|
||||
type="button"
|
||||
|
||||
class="flex w-full items-center justify-between gap-3 px-3 py-2 text-left hover:bg-blue-50"
|
||||
|
||||
@mousedown.prevent="selectWecomBindUser(u.id, u.label)"
|
||||
|
||||
>
|
||||
|
||||
<span class="text-sm text-primary">{{ u.label }}</span>
|
||||
|
||||
<span class="text-xs text-muted">{{ u.employeeId || '' }}</span>
|
||||
|
||||
</button>
|
||||
|
||||
<div v-if="wecomBindUserOptions.length === 0" class="px-3 py-2 text-sm text-muted">
|
||||
|
||||
{{ t('admin.wecom.noData') }}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<div class="wecom-bindings">
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.wecom.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton :icon="Refresh" @click="refreshWecomData()">{{ t('admin.wecom.refresh') }}</ElButton>
|
||||
</template>
|
||||
<template #tabs>
|
||||
<WecomSubNav />
|
||||
</template>
|
||||
|
||||
<div class="wecom-bindings__block">
|
||||
<WecomOverviewCards />
|
||||
</div>
|
||||
|
||||
<input v-model="wecomBindForm.wecom_userid" :placeholder="t('admin.wecom.fields.wecomUserId')" class="input-field md:col-span-2" />
|
||||
|
||||
<input v-model="wecomBindForm.wecom_unionid" :placeholder="t('admin.wecom.fields.wecomUnionId')" class="input-field" />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
|
||||
<button type="button" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60" @click="bindWecomUser()">
|
||||
|
||||
<Link2 class="w-4 h-4" /> {{ t('admin.wecom.bind') }}
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="admin-table-section space-y-0">
|
||||
|
||||
<div class="admin-table-header px-5 py-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.bindingList') }}</h3>
|
||||
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
|
||||
<div class="relative min-w-[240px]">
|
||||
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
|
||||
|
||||
<input
|
||||
|
||||
v-model="wecomBindingsKeyword"
|
||||
|
||||
type="search"
|
||||
|
||||
class="input-field pl-9"
|
||||
|
||||
:placeholder="t('admin.wecom.searchBindings')"
|
||||
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary whitespace-nowrap">
|
||||
|
||||
<input v-model="wecomBoundOnly" type="checkbox" class="w-4 h-4 rounded text-brand-600 border-default" />
|
||||
|
||||
{{ t('admin.wecom.boundOnly') }}
|
||||
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
|
||||
<table class="admin-table">
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.user') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.employeeId') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.roleStatus') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.wecomUserId') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.unionId') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs text-right">{{ t('admin.wecom.headers.actions') }}</th>
|
||||
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr v-if="wecomBindings.length === 0">
|
||||
|
||||
<td colspan="6" class="px-4 admin-table-empty">{{ t('admin.wecom.noData') }}</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr v-for="u in wecomBindings" :key="u.id">
|
||||
|
||||
<td class="px-4 py-3">
|
||||
|
||||
<div class="text-sm font-medium text-primary">{{ u.username }} <span class="text-muted">(#{{ u.id }})</span></div>
|
||||
|
||||
<div class="text-xs text-muted">{{ u.real_name || '-' }} · {{ u.email }}</div>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-sm text-secondary font-mono">{{ u.employee_id || '-' }}</td>
|
||||
|
||||
<td class="px-4 py-3 text-sm text-secondary">{{ t('admin.role.' + u.role) }} / {{ t('admin.status.' + u.status) }}</td>
|
||||
|
||||
<td class="px-4 py-3 text-sm text-secondary font-mono">{{ u.wecom_userid || '-' }}</td>
|
||||
|
||||
<td class="px-4 py-3 text-sm text-secondary font-mono">{{ u.wecom_unionid || '-' }}</td>
|
||||
|
||||
<td class="px-4 py-3 text-right">
|
||||
|
||||
<button
|
||||
|
||||
v-if="u.wecom_userid"
|
||||
|
||||
type="button"
|
||||
|
||||
class="inline-flex items-center gap-1 px-3 py-1.5 text-xs text-red-600 bg-red-50 rounded-lg hover:bg-red-100"
|
||||
|
||||
@click="unbindWecomUserByAdmin(u.id)"
|
||||
|
||||
<WecomSyncPanel @applied="onSyncApplied" />
|
||||
<div class="wecom-bindings__block">
|
||||
<ElText type="info">{{ t('admin.wecom.bindingsHint') }}</ElText>
|
||||
<h3 class="wecom-bindings__heading">{{ t('admin.wecom.quickBind') }}</h3>
|
||||
<ElForm label-position="top" :model="wecomBindForm" @submit.prevent="bindWecomUser()">
|
||||
<div class="wecom-bindings__form">
|
||||
<ElFormItem :label="t('admin.wecom.fields.userSelect')">
|
||||
<ElSelect
|
||||
:model-value="wecomBindForm.user_id === '' ? undefined : wecomBindForm.user_id"
|
||||
filterable
|
||||
clearable
|
||||
:placeholder="t('admin.wecom.fields.userSelect')"
|
||||
@update:model-value="onBindUserChange"
|
||||
>
|
||||
<ElOption
|
||||
v-for="user in wecomBindUserOptions"
|
||||
:key="user.id"
|
||||
:label="user.label"
|
||||
:value="user.id"
|
||||
/>
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem class="wecom-bindings__wide" :label="t('admin.wecom.fields.wecomUserId')">
|
||||
<ElInput v-model="wecomBindForm.wecom_userid" :placeholder="t('admin.wecom.fields.wecomUserId')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.wecom.fields.wecomUnionId')">
|
||||
<ElInput v-model="wecomBindForm.wecom_unionid" :placeholder="t('admin.wecom.fields.wecomUnionId')" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
<div class="wecom-bindings__submit">
|
||||
<ElButton type="primary" :icon="Link" :loading="isSaving" @click="bindWecomUser()">
|
||||
{{ t('admin.wecom.bind') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElForm>
|
||||
</div>
|
||||
</AdminListPage>
|
||||
|
||||
<Unlink2 class="w-3.5 h-3.5" />
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.wecom.bindingList') }}</h2>
|
||||
</template>
|
||||
<template #filters>
|
||||
<ElInput
|
||||
v-model="wecomBindingsKeyword"
|
||||
class="wecom-filter-search"
|
||||
clearable
|
||||
:placeholder="t('admin.wecom.searchBindings')"
|
||||
/>
|
||||
<ElCheckbox v-model="wecomBoundOnly">{{ t('admin.wecom.boundOnly') }}</ElCheckbox>
|
||||
</template>
|
||||
|
||||
{{ t('admin.wecom.unbind') }}
|
||||
|
||||
</button>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="px-4 pb-4 pt-2">
|
||||
|
||||
<PaginationBar
|
||||
|
||||
v-model:page="wecomBindingsPage"
|
||||
|
||||
v-model:page-size="wecomBindingsPageSize"
|
||||
|
||||
:total="wecomBindingsTotal"
|
||||
|
||||
:pages="wecomBindingsPages"
|
||||
|
||||
:page-size-options="[...wecomBindingsPageSizeOptions]"
|
||||
|
||||
:visible="wecomBindingsTotal > 0 || !!wecomBindingsKeyword.trim()"
|
||||
|
||||
/>
|
||||
|
||||
</div>
|
||||
<ElTable
|
||||
class="hx-admin-table"
|
||||
:data="wecomBindings"
|
||||
row-key="id"
|
||||
:empty-text="t('admin.wecom.noData')"
|
||||
>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.user')" min-width="220">
|
||||
<template #default="{ row }">
|
||||
<div>
|
||||
{{ (row as WecomBindingRow).username }}
|
||||
<ElText type="info">(#{{ (row as WecomBindingRow).id }})</ElText>
|
||||
</div>
|
||||
<ElText type="info">
|
||||
{{ (row as WecomBindingRow).real_name || '-' }} · {{ (row as WecomBindingRow).email }}
|
||||
</ElText>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.employeeId')" min-width="140">
|
||||
<template #default="{ row }">
|
||||
<span class="wecom-bindings__mono">{{ (row as WecomBindingRow).employee_id || '-' }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.roleStatus')" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<span>{{ t('admin.role.' + (row as WecomBindingRow).role) }}</span>
|
||||
<ElTag
|
||||
class="wecom-bindings__status"
|
||||
effect="light"
|
||||
:type="(row as WecomBindingRow).status === 'active' ? 'success' : 'info'"
|
||||
>
|
||||
{{ t('admin.status.' + (row as WecomBindingRow).status) }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.wecomUserId')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span class="wecom-bindings__mono">{{ (row as WecomBindingRow).wecom_userid || '-' }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.unionId')" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span class="wecom-bindings__mono">{{ (row as WecomBindingRow).wecom_unionid || '-' }}</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn :label="t('admin.wecom.headers.actions')" width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<ElButton
|
||||
v-if="(row as WecomBindingRow).wecom_userid"
|
||||
link
|
||||
type="danger"
|
||||
@click="unbindWecomUserByAdmin((row as WecomBindingRow).id)"
|
||||
>
|
||||
{{ t('admin.wecom.unbind') }}
|
||||
</ElButton>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
|
||||
<template #pagination v-if="wecomBindingsTotal > 0 || !!wecomBindingsKeyword.trim()">
|
||||
<ElPagination
|
||||
v-model:current-page="wecomBindingsPage"
|
||||
v-model:page-size="wecomBindingsPageSize"
|
||||
:total="wecomBindingsTotal"
|
||||
:page-sizes="[...wecomBindingsPageSizeOptions]"
|
||||
layout="total, sizes, prev, pager, next"
|
||||
background
|
||||
/>
|
||||
</template>
|
||||
</AdminListPage>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wecom-bindings {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.wecom-bindings__block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 16px 32px 24px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.wecom-bindings__heading {
|
||||
margin: 0;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-large);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wecom-bindings__form {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
column-gap: 16px;
|
||||
}
|
||||
|
||||
.wecom-bindings__submit {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.wecom-bindings__mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
.wecom-bindings__status {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
:deep(.wecom-filter-search) {
|
||||
width: 16rem;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.wecom-bindings__form {
|
||||
grid-template-columns: 1fr 2fr 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,16 +1,42 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/pages/WecomSettingsPage.vue
|
||||
* 企微系统配置、通知与集成复制。
|
||||
* 依赖:WECOM_ADMIN_KEY、lucide CircleHelp。
|
||||
* 逻辑:绑定概览卡片只在绑定管理页展示,本页仅编辑系统/通知配置。
|
||||
* 用途:企微系统配置、通知指标和集成复制。
|
||||
* 依赖:AdminListPage、AdminListTabs、WECOM_ADMIN_KEY、element-plus。
|
||||
* 逻辑:路由 AdminWecomSettings。绑定概览不在本页。表单仍写回同一个 settings 对象,保存函数不变。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { computed, inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { CircleHelp } from 'lucide-vue-next';
|
||||
import { QuestionFilled, Refresh } from '@element-plus/icons-vue';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCard,
|
||||
ElCollapse,
|
||||
ElCollapseItem,
|
||||
ElConfigProvider,
|
||||
ElForm,
|
||||
ElFormItem,
|
||||
ElIcon,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElSelect,
|
||||
ElStatistic,
|
||||
ElSwitch,
|
||||
ElText,
|
||||
ElTooltip,
|
||||
} 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 { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||
import type { WecomIntegrationManifest } from '@/features/admin/types/wecom.types';
|
||||
import WecomSubNav from '../components/WecomSubNav.vue';
|
||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { elementLocale } = useElementProvider();
|
||||
const {
|
||||
wecomSystemSettings,
|
||||
isSaving,
|
||||
@@ -23,238 +49,426 @@ const {
|
||||
generateWecomEncodingAesKey,
|
||||
saveWecomSystemSettings,
|
||||
saveWecomNotifySettings,
|
||||
refreshWecomData,
|
||||
copyText,
|
||||
} = inject(WECOM_ADMIN_KEY)!;
|
||||
|
||||
const copyFieldDefs: Array<{ key: keyof WecomIntegrationManifest; labelKey: string }> = [
|
||||
{ key: 'public_base_url', labelKey: 'admin.wecom.copyFields.publicBaseUrl' },
|
||||
{ key: 'callback_url', labelKey: 'admin.wecom.copyFields.callbackUrl' },
|
||||
{ key: 'callback_token', labelKey: 'admin.wecom.copyFields.callbackToken' },
|
||||
{ key: 'encoding_aes_key', labelKey: 'admin.wecom.copyFields.encodingAesKey' },
|
||||
{ key: 'oauth_redirect_uri', labelKey: 'admin.wecom.copyFields.oauthRedirectUri' },
|
||||
{ key: 'homepage_url', labelKey: 'admin.wecom.copyFields.homepageUrl' },
|
||||
{ key: 'trusted_domain', labelKey: 'admin.wecom.copyFields.trustedDomain' },
|
||||
{ key: 'authorize_api', labelKey: 'admin.wecom.copyFields.authorizeApi' },
|
||||
{ key: 'login_api', labelKey: 'admin.wecom.copyFields.loginApi' },
|
||||
];
|
||||
|
||||
const copyItems = computed(() => {
|
||||
const manifest = wecomIntegrationManifest.value;
|
||||
if (!manifest) return [];
|
||||
return copyFieldDefs.map((item) => ({
|
||||
key: item.key,
|
||||
label: t(item.labelKey),
|
||||
value: manifest[item.key] || '',
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.systemSettings') }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomSystemSettings.enabled" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.enabled') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.enabled')" />
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomSystemSettings.auto_create_user" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.autoCreateUser') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.autoCreateUser')" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.corpId') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.corpId')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.corp_id" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.agentId') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.agentId')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.agent_id" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.secret') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.secret')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.secret" type="password" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.redirectUri') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.redirectUri')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.redirect_uri" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.publicBaseUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.publicBaseUrl')" />
|
||||
</label>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<input
|
||||
v-model="wecomSystemSettings.public_base_url"
|
||||
:placeholder="t('admin.wecom.publicBasePlaceholder')"
|
||||
class="input-field flex-1 min-w-[200px]"
|
||||
/>
|
||||
<button type="button" class="btn-secondary px-4 shrink-0" @click="generateWecomAddressesFromPublicBase()">
|
||||
{{ t('admin.wecom.generateAddresses') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.callbackToken') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.callbackToken')" />
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<input v-model="wecomSystemSettings.callback_token" class="input-field flex-1 min-w-0" />
|
||||
<button type="button" class="btn-secondary px-3 shrink-0 text-xs" @click="generateWecomCallbackToken()">
|
||||
{{ t('admin.wecom.generateToken') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.encodingAesKey') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.encodingAesKey')" />
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<input v-model="wecomSystemSettings.encoding_aes_key" class="input-field flex-1 min-w-0 font-mono text-xs" />
|
||||
<button type="button" class="btn-secondary px-3 shrink-0 text-xs" @click="generateWecomEncodingAesKey()">
|
||||
{{ t('admin.wecom.generateEncodingKey') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.callbackUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.callbackUrl')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.callback_url" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.homepageUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.homepageUrl')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.homepage_url" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.trustedDomain') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.trustedDomain')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.trusted_domain" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.matchRules') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.matchRules')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.match_rules" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.matchOperator') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.matchOperator')" />
|
||||
</label>
|
||||
<select v-model="wecomSystemSettings.match_operator" class="input-field">
|
||||
<option value="AND">AND</option>
|
||||
<option value="OR">OR</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.firstLoginBindMode') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.firstLoginBindMode')" />
|
||||
</label>
|
||||
<select v-model="wecomSystemSettings.first_login_bind_mode" class="input-field">
|
||||
<option value="match_rules">{{ t('admin.wecom.bindModes.match_rules') }}</option>
|
||||
<option value="input_verify">{{ t('admin.wecom.bindModes.input_verify') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.firstLoginInputFields') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.firstLoginInputFields')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.first_login_input_fields" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.employeeIdSource') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.employeeIdSource')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.employee_id_source" class="input-field" />
|
||||
</div>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary pt-7">
|
||||
<input v-model="wecomSystemSettings.mobile_normalize" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.mobileNormalize') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.mobileNormalize')" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="button" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60" @click="saveWecomSystemSettings()">
|
||||
{{ t('admin.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<ElConfigProvider :locale="elementLocale">
|
||||
<AdminListPage>
|
||||
<template #title>
|
||||
<h2 class="section-title">{{ t('admin.wecom.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||
</template>
|
||||
<template #actions>
|
||||
<ElButton :icon="Refresh" @click="refreshWecomData()">{{ t('admin.wecom.refresh') }}</ElButton>
|
||||
</template>
|
||||
<template #tabs>
|
||||
<WecomSubNav />
|
||||
</template>
|
||||
|
||||
<div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.notifySettings') }}</h3>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomNotifySettings.enabled" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.notifyEnabled') }}
|
||||
</label>
|
||||
<input v-model="wecomNotifySettings.base_url" :placeholder="t('admin.wecom.notifyBaseUrl')" class="input-field" />
|
||||
<input v-model="wecomNotifyEventsText" :placeholder="t('admin.wecom.notifyEvents')" class="input-field" />
|
||||
<div class="flex justify-end">
|
||||
<button type="button" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60" @click="saveWecomNotifySettings()">
|
||||
{{ t('admin.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.notifyMetrics') }}</h3>
|
||||
<div v-if="wecomNotifyMetrics" class="grid grid-cols-2 gap-3 text-sm">
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricTotal') }}</div>
|
||||
<div class="text-lg font-semibold text-primary">{{ wecomNotifyMetrics.total }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricSuccessRate') }}</div>
|
||||
<div class="text-lg font-semibold text-emerald-700">{{ wecomNotifyMetrics.send_success_rate }}%</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricOpenedRate') }}</div>
|
||||
<div class="text-lg font-semibold text-blue-700">{{ wecomNotifyMetrics.opened_24h_rate }}%</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricWindowDays') }}</div>
|
||||
<div class="text-lg font-semibold text-primary">{{ wecomNotifyMetrics.window_days }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<details class="card shadow-sm p-5">
|
||||
<summary class="cursor-pointer font-semibold text-primary">{{ t('admin.wecom.integrationCopyTitle') }}</summary>
|
||||
<div class="mt-4 space-y-4">
|
||||
<p class="text-xs text-muted">{{ t('admin.wecom.integrationCopyDesc') }}</p>
|
||||
<p class="text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded-lg px-3 py-2">{{ t('admin.wecom.integrationCopySecretsNote') }}</p>
|
||||
<div v-if="wecomIntegrationManifest" class="grid grid-cols-1 gap-3">
|
||||
<div
|
||||
v-for="item in [
|
||||
{ key: 'public_base_url', label: t('admin.wecom.copyFields.publicBaseUrl') },
|
||||
{ key: 'callback_url', label: t('admin.wecom.copyFields.callbackUrl') },
|
||||
{ key: 'callback_token', label: t('admin.wecom.copyFields.callbackToken') },
|
||||
{ key: 'encoding_aes_key', label: t('admin.wecom.copyFields.encodingAesKey') },
|
||||
{ key: 'oauth_redirect_uri', label: t('admin.wecom.copyFields.oauthRedirectUri') },
|
||||
{ key: 'homepage_url', label: t('admin.wecom.copyFields.homepageUrl') },
|
||||
{ key: 'trusted_domain', label: t('admin.wecom.copyFields.trustedDomain') },
|
||||
{ key: 'authorize_api', label: t('admin.wecom.copyFields.authorizeApi') },
|
||||
{ key: 'login_api', label: t('admin.wecom.copyFields.loginApi') },
|
||||
]"
|
||||
:key="item.key"
|
||||
>
|
||||
<label class="mb-1.5 block text-xs text-muted">{{ item.label }}</label>
|
||||
<div class="flex gap-2">
|
||||
<input :value="(wecomIntegrationManifest as any)[item.key] || ''" readonly class="input-field flex-1 bg-surface-soft font-mono text-xs" />
|
||||
<button type="button" class="btn-secondary px-3" @click="copyText(String((wecomIntegrationManifest as any)[item.key] || ''))">
|
||||
{{ t('admin.wecom.copy') }}
|
||||
</button>
|
||||
<div class="wecom-settings">
|
||||
<section class="wecom-settings__section">
|
||||
<h3 class="wecom-settings__heading">{{ t('admin.wecom.systemSettings') }}</h3>
|
||||
<ElForm label-position="top" :model="wecomSystemSettings" @submit.prevent="saveWecomSystemSettings()">
|
||||
<div class="wecom-settings__grid">
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.enabled') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.enabled')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElSwitch v-model="wecomSystemSettings.enabled" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.autoCreateUser') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.autoCreateUser')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElSwitch v-model="wecomSystemSettings.auto_create_user" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.corpId') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.corpId')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.corp_id" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.agentId') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.agentId')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.agent_id" />
|
||||
</ElFormItem>
|
||||
<ElFormItem class="wecom-settings__span">
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.secret') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.secret')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.secret" type="password" show-password />
|
||||
</ElFormItem>
|
||||
<ElFormItem class="wecom-settings__span">
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.redirectUri') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.redirectUri')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.redirect_uri" />
|
||||
</ElFormItem>
|
||||
<ElFormItem class="wecom-settings__span">
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.publicBaseUrl') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.publicBaseUrl')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<div class="wecom-settings__inline">
|
||||
<ElInput
|
||||
v-model="wecomSystemSettings.public_base_url"
|
||||
:placeholder="t('admin.wecom.publicBasePlaceholder')"
|
||||
/>
|
||||
<ElButton @click="generateWecomAddressesFromPublicBase()">
|
||||
{{ t('admin.wecom.generateAddresses') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.callbackToken') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.callbackToken')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<div class="wecom-settings__inline">
|
||||
<ElInput v-model="wecomSystemSettings.callback_token" />
|
||||
<ElButton @click="generateWecomCallbackToken()">{{ t('admin.wecom.generateToken') }}</ElButton>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.encodingAesKey') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.encodingAesKey')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<div class="wecom-settings__inline">
|
||||
<ElInput v-model="wecomSystemSettings.encoding_aes_key" class="wecom-settings__mono" />
|
||||
<ElButton @click="generateWecomEncodingAesKey()">{{ t('admin.wecom.generateEncodingKey') }}</ElButton>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.callbackUrl') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.callbackUrl')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.callback_url" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.homepageUrl') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.homepageUrl')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.homepage_url" />
|
||||
</ElFormItem>
|
||||
<ElFormItem class="wecom-settings__span">
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.trustedDomain') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.trustedDomain')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.trusted_domain" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.matchRules') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.matchRules')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.match_rules" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.matchOperator') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.matchOperator')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElSelect v-model="wecomSystemSettings.match_operator">
|
||||
<ElOption label="AND" value="AND" />
|
||||
<ElOption label="OR" value="OR" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.firstLoginBindMode') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.firstLoginBindMode')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElSelect v-model="wecomSystemSettings.first_login_bind_mode">
|
||||
<ElOption :label="t('admin.wecom.bindModes.match_rules')" value="match_rules" />
|
||||
<ElOption :label="t('admin.wecom.bindModes.input_verify')" value="input_verify" />
|
||||
</ElSelect>
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.firstLoginInputFields') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.firstLoginInputFields')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.first_login_input_fields" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.employeeIdSource') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.employeeIdSource')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElInput v-model="wecomSystemSettings.employee_id_source" />
|
||||
</ElFormItem>
|
||||
<ElFormItem>
|
||||
<template #label>
|
||||
<span class="wecom-settings__label">
|
||||
{{ t('admin.wecom.fields.mobileNormalize') }}
|
||||
<ElTooltip :content="t('admin.wecom.tips.mobileNormalize')" placement="top">
|
||||
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||
</ElTooltip>
|
||||
</span>
|
||||
</template>
|
||||
<ElSwitch v-model="wecomSystemSettings.mobile_normalize" />
|
||||
</ElFormItem>
|
||||
</div>
|
||||
</div>
|
||||
<div class="wecom-settings__submit">
|
||||
<ElButton type="primary" :loading="isSaving" @click="saveWecomSystemSettings()">
|
||||
{{ t('admin.save') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElForm>
|
||||
</section>
|
||||
|
||||
<div class="wecom-settings__split">
|
||||
<section class="wecom-settings__section">
|
||||
<h3 class="wecom-settings__heading">{{ t('admin.wecom.notifySettings') }}</h3>
|
||||
<ElForm label-position="top" :model="wecomNotifySettings" @submit.prevent="saveWecomNotifySettings()">
|
||||
<ElFormItem :label="t('admin.wecom.notifyEnabled')">
|
||||
<ElSwitch v-model="wecomNotifySettings.enabled" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.wecom.notifyBaseUrl')">
|
||||
<ElInput v-model="wecomNotifySettings.base_url" :placeholder="t('admin.wecom.notifyBaseUrl')" />
|
||||
</ElFormItem>
|
||||
<ElFormItem :label="t('admin.wecom.notifyEvents')">
|
||||
<ElInput v-model="wecomNotifyEventsText" :placeholder="t('admin.wecom.notifyEvents')" />
|
||||
</ElFormItem>
|
||||
<div class="wecom-settings__submit">
|
||||
<ElButton type="primary" :loading="isSaving" @click="saveWecomNotifySettings()">
|
||||
{{ t('admin.save') }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</ElForm>
|
||||
</section>
|
||||
<section class="wecom-settings__section">
|
||||
<h3 class="wecom-settings__heading">{{ t('admin.wecom.notifyMetrics') }}</h3>
|
||||
<div v-if="wecomNotifyMetrics" class="wecom-settings__metrics">
|
||||
<ElCard shadow="never">
|
||||
<ElStatistic :title="t('admin.wecom.metricTotal')" :value="wecomNotifyMetrics.total" />
|
||||
</ElCard>
|
||||
<ElCard shadow="never">
|
||||
<ElStatistic :title="t('admin.wecom.metricSuccessRate')" :value="wecomNotifyMetrics.send_success_rate" suffix="%" />
|
||||
</ElCard>
|
||||
<ElCard shadow="never">
|
||||
<ElStatistic :title="t('admin.wecom.metricOpenedRate')" :value="wecomNotifyMetrics.opened_24h_rate" suffix="%" />
|
||||
</ElCard>
|
||||
<ElCard shadow="never">
|
||||
<ElStatistic :title="t('admin.wecom.metricWindowDays')" :value="wecomNotifyMetrics.window_days" />
|
||||
</ElCard>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section class="wecom-settings__section">
|
||||
<ElCollapse>
|
||||
<ElCollapseItem :title="t('admin.wecom.integrationCopyTitle')" name="copy">
|
||||
<ElText class="wecom-settings__copy-desc" type="info">{{ t('admin.wecom.integrationCopyDesc') }}</ElText>
|
||||
<ElAlert
|
||||
class="wecom-settings__copy-note"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
:title="t('admin.wecom.integrationCopySecretsNote')"
|
||||
/>
|
||||
<ElForm v-if="copyItems.length" label-position="top">
|
||||
<ElFormItem v-for="item in copyItems" :key="item.key" :label="item.label">
|
||||
<div class="wecom-settings__inline">
|
||||
<ElInput :model-value="item.value" readonly class="wecom-settings__mono" />
|
||||
<ElButton @click="copyText(item.value)">{{ t('admin.wecom.copy') }}</ElButton>
|
||||
</div>
|
||||
</ElFormItem>
|
||||
</ElForm>
|
||||
</ElCollapseItem>
|
||||
</ElCollapse>
|
||||
</section>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</AdminListPage>
|
||||
</ElConfigProvider>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.wecom-settings__section {
|
||||
padding: 16px 32px 8px;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.wecom-settings__heading {
|
||||
margin: 0 0 12px;
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: var(--el-font-size-large);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wecom-settings__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
column-gap: 16px;
|
||||
}
|
||||
|
||||
.wecom-settings__label {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.wecom-settings__help {
|
||||
color: var(--el-text-color-secondary);
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.wecom-settings__inline {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.wecom-settings__inline .el-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.wecom-settings__submit {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.wecom-settings__split {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.wecom-settings__metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
.wecom-settings__copy-desc,
|
||||
.wecom-settings__copy-note {
|
||||
display: block;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.wecom-settings__mono :deep(.el-input__inner) {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.wecom-settings__grid {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.wecom-settings__span {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1280px) {
|
||||
.wecom-settings__split {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -5288,7 +5288,7 @@
|
||||
"types": "Training Types",
|
||||
"typeCount": "{count} configurations",
|
||||
"detail": "Configuration Details",
|
||||
"headerMeta": "Type: {type} · Current version: {version}",
|
||||
"headerMeta": "Type code: {type}",
|
||||
"addType": "Add Training Type",
|
||||
"editType": "Edit Training Type",
|
||||
"empty": "No training configurations",
|
||||
@@ -5339,6 +5339,7 @@
|
||||
},
|
||||
"placeholders": {
|
||||
"onePerLine": "Enter one item per line",
|
||||
"typeCode": "Example: onboarding",
|
||||
"oneQuestionPerLine": "Enter one question per line",
|
||||
"progressItemLabel": "Example: Watch video",
|
||||
"progressHintText": "Example: Training is complete only after the video, knowledge review, and exam are all finished.",
|
||||
@@ -5357,6 +5358,11 @@
|
||||
"progressHintText": "Training progress note",
|
||||
"stepIntroText": "Training step guide copy",
|
||||
"requiredDuration": "Required time (minutes)",
|
||||
"requiredDurationPlaceholder": "0 means no limit",
|
||||
"stageSummaryTitle": "Level summaries (one item per line)",
|
||||
"stageSummaryCompany": "Company summary",
|
||||
"stageSummaryDepartment": "Department summary",
|
||||
"stageSummaryTeam": "Team summary",
|
||||
"summaryPoints": "Review points",
|
||||
"summaryChecklist": "Pre-exam checklist",
|
||||
"employeeQuestions": "Employee FAQs",
|
||||
@@ -5473,12 +5479,6 @@
|
||||
"eyebrow": "Training Operations Center",
|
||||
"pageHint": "Configuration changes take effect after saving",
|
||||
"footerHint": "All configuration items can be adjusted after saving",
|
||||
"stats": {
|
||||
"total": "Total Configs",
|
||||
"published": "Published",
|
||||
"resources": "Current Materials",
|
||||
"levels": "Configured Levels"
|
||||
},
|
||||
"questionBankTitle": "Onboarding Question Bank"
|
||||
},
|
||||
"integrationConnector": {
|
||||
|
||||
@@ -5288,7 +5288,7 @@
|
||||
"types": "ประเภทการฝึกอบรม",
|
||||
"typeCount": "ทั้งหมด {count} การกำหนดค่า",
|
||||
"detail": "รายละเอียดการกำหนดค่า",
|
||||
"headerMeta": "ประเภท: {type} · เวอร์ชันปัจจุบัน: {version}",
|
||||
"headerMeta": "รหัสประเภท: {type}",
|
||||
"addType": "เพิ่มประเภทการฝึกอบรม",
|
||||
"editType": "แก้ไขประเภทการฝึกอบรม",
|
||||
"empty": "ยังไม่มีการกำหนดค่า",
|
||||
@@ -5339,6 +5339,7 @@
|
||||
},
|
||||
"placeholders": {
|
||||
"onePerLine": "กรอกหนึ่งรายการต่อบรรทัด",
|
||||
"typeCode": "ตัวอย่าง: onboarding",
|
||||
"oneQuestionPerLine": "กรอกหนึ่งคำถามต่อบรรทัด",
|
||||
"progressItemLabel": "ตัวอย่าง: ดูวิดีโอ",
|
||||
"progressHintText": "ตัวอย่าง: จะถือว่าเสร็จสิ้นเมื่อทำวิดีโอ ทบทวนความรู้ และข้อสอบครบแล้ว",
|
||||
@@ -5357,6 +5358,11 @@
|
||||
"progressHintText": "คำอธิบายความคืบหน้าการฝึกอบรม",
|
||||
"stepIntroText": "ข้อความแนะนำขั้นตอนการฝึกอบรม",
|
||||
"requiredDuration": "เวลาที่ต้องใช้ (นาที)",
|
||||
"requiredDurationPlaceholder": "0 หมายถึงไม่จำกัด",
|
||||
"stageSummaryTitle": "สรุปตามระดับ (หนึ่งรายการต่อบรรทัด)",
|
||||
"stageSummaryCompany": "สรุประดับบริษัท",
|
||||
"stageSummaryDepartment": "สรุประดับแผนก",
|
||||
"stageSummaryTeam": "สรุประดับทีม",
|
||||
"summaryPoints": "ประเด็นทบทวน",
|
||||
"summaryChecklist": "รายการก่อนสอบ",
|
||||
"employeeQuestions": "คำถามที่พบบ่อยของพนักงาน",
|
||||
@@ -5473,12 +5479,6 @@
|
||||
"eyebrow": "培训运营中心",
|
||||
"pageHint": "配置变更将在保存后生效",
|
||||
"footerHint": "所有配置项均支持保存后继续调整",
|
||||
"stats": {
|
||||
"total": "配置总数",
|
||||
"published": "已发布",
|
||||
"resources": "当前资料",
|
||||
"levels": "已配置级别"
|
||||
},
|
||||
"questionBankTitle": "入职培训题库"
|
||||
},
|
||||
"integrationConnector": {
|
||||
|
||||
@@ -5321,16 +5321,10 @@
|
||||
"subtitle": "按培训类型管理版本、考试规则、资源与题目",
|
||||
"pageHint": "配置变更将在保存后生效",
|
||||
"footerHint": "所有配置项均支持保存后继续调整",
|
||||
"stats": {
|
||||
"total": "配置总数",
|
||||
"published": "已发布",
|
||||
"resources": "当前资料",
|
||||
"levels": "已配置级别"
|
||||
},
|
||||
"types": "培训类型",
|
||||
"typeCount": "共 {count} 个配置",
|
||||
"detail": "配置详情",
|
||||
"headerMeta": "类型编码:{type} · 当前版本:{version}",
|
||||
"headerMeta": "类型编码:{type}",
|
||||
"addType": "新增培训类型",
|
||||
"editType": "编辑培训类型",
|
||||
"empty": "暂无培训配置",
|
||||
@@ -5382,6 +5376,7 @@
|
||||
},
|
||||
"placeholders": {
|
||||
"onePerLine": "每行填写一项",
|
||||
"typeCode": "例如 onboarding,小写字母开头",
|
||||
"oneQuestionPerLine": "每行填写一个问题",
|
||||
"progressItemLabel": "例如:观看视频",
|
||||
"progressHintText": "例如:按 HR 要求完成视频、知识点、考试三个环节后才能视为完成。",
|
||||
@@ -5400,6 +5395,11 @@
|
||||
"progressHintText": "培训进度说明",
|
||||
"stepIntroText": "培训步骤引导文案",
|
||||
"requiredDuration": "所需时间(分钟)",
|
||||
"requiredDurationPlaceholder": "0 表示不限制",
|
||||
"stageSummaryTitle": "分级培训总结(按行分隔)",
|
||||
"stageSummaryCompany": "公司级总结",
|
||||
"stageSummaryDepartment": "部门级总结",
|
||||
"stageSummaryTeam": "班组级总结",
|
||||
"summaryPoints": "复盘要点",
|
||||
"summaryChecklist": "考前清单",
|
||||
"employeeQuestions": "员工常见问题",
|
||||
|
||||
@@ -5288,7 +5288,7 @@
|
||||
"types": "培訓類型",
|
||||
"typeCount": "共 {count} 個配置",
|
||||
"detail": "配置詳情",
|
||||
"headerMeta": "類型編碼:{type} · 目前版本:{version}",
|
||||
"headerMeta": "類型編碼:{type}",
|
||||
"addType": "新增培訓類型",
|
||||
"editType": "編輯培訓類型",
|
||||
"empty": "暫無培訓配置",
|
||||
@@ -5339,6 +5339,7 @@
|
||||
},
|
||||
"placeholders": {
|
||||
"onePerLine": "每行填寫一項",
|
||||
"typeCode": "例如 onboarding,小寫字母開頭",
|
||||
"oneQuestionPerLine": "每行填寫一個問題",
|
||||
"progressItemLabel": "例如:觀看影片",
|
||||
"progressHintText": "例如:按 HR 要求完成影片、知識點、考試三個環節後才算完成。",
|
||||
@@ -5357,6 +5358,11 @@
|
||||
"progressHintText": "培訓進度說明",
|
||||
"stepIntroText": "培訓步驟引導文案",
|
||||
"requiredDuration": "所需時間(分鐘)",
|
||||
"requiredDurationPlaceholder": "0 表示不限制",
|
||||
"stageSummaryTitle": "分級培訓總結(按行分隔)",
|
||||
"stageSummaryCompany": "公司級總結",
|
||||
"stageSummaryDepartment": "部門級總結",
|
||||
"stageSummaryTeam": "班組級總結",
|
||||
"summaryPoints": "複盤要點",
|
||||
"summaryChecklist": "考前清單",
|
||||
"employeeQuestions": "員工常見問題",
|
||||
@@ -5473,12 +5479,6 @@
|
||||
"eyebrow": "培训运营中心",
|
||||
"pageHint": "配置变更将在保存后生效",
|
||||
"footerHint": "所有配置项均支持保存后继续调整",
|
||||
"stats": {
|
||||
"total": "配置总数",
|
||||
"published": "已发布",
|
||||
"resources": "当前资料",
|
||||
"levels": "已配置级别"
|
||||
},
|
||||
"questionBankTitle": "入职培训题库"
|
||||
},
|
||||
"integrationConnector": {
|
||||
|
||||
Reference in new issue
Block a user