Merge branch 'dev' into picture-feedback

This commit is contained in:
HTEWJ\26070045 committed 2026-10-29 11:04:59 +08:00
commit 34ad40778b
180 files changed
+13262 -5333

No files matched your search

+6 -24
View File
@@ -2,17 +2,15 @@
/**
* App.vue
* 根组件:主题初始化、全局消息弹窗、401 登出监听、html lang 与 i18n locale 同步。
* 依赖:useTheme、useGlobalMessageDialog、auth、linked-nav.store。
* 依赖:useTheme、useGlobalMessageDialog、auth、linked-nav.store、useElementProvider。
* 逻辑:已登录时预取关联服务侧栏入口,避免页面切换后入口后闪现。
* 书签/刷新冷启动遇到 401 时只回登录页;本页已确认会话后中途失效才弹窗。
* Element 内置文案由根上的 ElConfigProvider 跟随 vue-i18n。页面不要再包一层。
*/
import { useI18n } from 'vue-i18n';
import { computed, watch, onMounted, onBeforeUnmount } from 'vue';
import { watch, onMounted, onBeforeUnmount } from 'vue';
import { ElConfigProvider } from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';
import zhTw from 'element-plus/es/locale/lang/zh-tw';
import en from 'element-plus/es/locale/lang/en';
import th from 'element-plus/es/locale/lang/th';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import { useTheme } from '@/shared/composables/useTheme';
import LevelMessageDialog from '@/shared/components/LevelMessageDialog.vue';
import { useGlobalMessageDialog } from '@/shared/composables/useGlobalMessageDialog';
@@ -23,23 +21,7 @@ import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store';
const router = useRouter();
const { locale, t } = useI18n();
/**
* Element Plus 组件内置文案(下拉占位/日期面板/分页等)跟随应用语言:
* EP 有独立 locale 体系,默认英文,必须在根部经 el-config-provider 注入当前语言包。
*/
const elementPlusLocale = computed(() => {
switch (locale.value) {
case 'zh-TW':
return zhTw;
case 'en':
return en;
case 'th':
return th;
default:
return zhCn;
}
});
const { elementLocale } = useElementProvider();
const { themePreference, initTheme, setThemePreference } = useTheme();
const {
messageDialogVisible,
@@ -158,7 +140,7 @@ onBeforeUnmount(() => {
</script>
<template>
<el-config-provider :locale="elementPlusLocale">
<el-config-provider :locale="elementLocale">
<router-view />
<LevelMessageDialog
v-model="messageDialogVisible"
@@ -1,8 +1,9 @@
/**
* features/admin/composables/useElementProvider.ts
* 用途:管理端 Element Plus 试点的界面语言。
* 用途:把当前界面语言映射成 Element Plus 语言包。
* 依赖:element-plus locale、vue-i18n。
* 逻辑:UsersPage、AgentsPage、KbAdminPanel 把 elementLocale 传给 ElConfigProvider;亮暗靠 html.dark 与 Element 暗色变量,不在这里重复切换。
* 逻辑:只由 App.vue 根上的 ElConfigProvider 使用。页面和弹窗不要再包一层。
* 亮暗靠 html.dark 与 Element 暗色变量,不在这里切换。
*/
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
@@ -20,8 +21,8 @@ const ELEMENT_LOCALES = {
/**
* 取当前界面语言对应的 Element Plus 语言包。
* 核心逻辑:未知语言回退简体中文。
* @returns elementLocale,随 vue-i18n 语言变化
* 核心逻辑:zh-CN、zh-TW、en、th 各用官方语言包,未知语言回退简体中文。
* @returns elementLocale,随 vue-i18n 语言变化。交给 App.vue 的 ElConfigProvider。
*/
export function useElementProvider() {
const { locale } = useI18n();
@@ -12,7 +12,6 @@ import { useI18n } from 'vue-i18n';
import { Plus } from '@element-plus/icons-vue';
import {
ElButton,
ElConfigProvider,
ElEmpty,
ElLoading,
ElTable,
@@ -22,7 +21,6 @@ import {
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import AgentFormModal from './components/AgentFormModal.vue';
import AgentPermissionModal from './components/AgentPermissionModal.vue';
import AgentTestModal from './components/AgentTestModal.vue';
@@ -30,7 +28,6 @@ import { useAgentsAdmin } from './composables/useAgentsAdmin';
import type { AgentRow } from '@/features/admin/types/agent.types';
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const vLoading = ElLoading.directive;
const {
@@ -183,7 +180,6 @@ onMounted(() => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<section class="admin-table-section min-h-64">
<div class="admin-table-header admin-table-header--stacked">
<div>
@@ -298,7 +294,6 @@ onMounted(() => {
@toggle-user="togglePermissionUser"
/>
</section>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,26 +1,24 @@
/**
* features/admin/modules/announcements/AnnouncementsPage.vue
* 用途:公告管理列表。一张卡片里放标题、发布按钮和表格。
* 依赖:AdminListPage、useAnnouncementsAdmin、useElementProvider、element-plus、公告表单和详情对话框。
* 依赖:AdminListPage、useAnnouncementsAdmin、element-plus、公告表单和详情对话框。
* 逻辑:路由 /admin/announcements。骨架用 AdminListPage。发布、编辑、查看仍由本页的两个对话框完成。删除用 Element 确认框。
*/
<script setup lang="ts">
import { onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { Plus } from '@element-plus/icons-vue';
import { ElButton, ElConfigProvider, ElTable, ElTableColumn } from 'element-plus';
import { ElButton, ElTable, ElTableColumn } from 'element-plus';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import type { AdminAnnouncementRow } from '@/features/admin/types/admin.types';
import AnnouncementDetailModal from './components/AnnouncementDetailModal.vue';
import AnnouncementFormModal from './components/AnnouncementFormModal.vue';
import { useAnnouncementsAdmin } from './composables/useAnnouncementsAdmin';
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const {
announcements,
@@ -57,7 +55,6 @@ onMounted(() => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage :loading="isLoading">
<template #title>
<h2 class="section-title">{{ t('admin.announcement.title') }}</h2>
@@ -113,7 +110,6 @@ onMounted(() => {
@close="closeDetailModal"
@edit="editFromDetail"
/>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,13 +1,20 @@
/**
* features/admin/modules/approvals/ApprovalsPage.vue
* 用户注册审批独立页面。路由:/admin/approvals
* 用途:用户注册审批列表。一张卡片里放标题和待审表格。
* 依赖:AdminListPage、useApprovalsAdmin、element-plus、roleLabel。
* 逻辑:路由未挂进当前菜单。通过和拒绝由 composable 弹出 Element 确认框后调接口。
*/
<script setup lang="ts">
import { onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { ShieldCheck, Trash2 } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import { CircleCheck, Delete } from '@element-plus/icons-vue';
import { ElButton, ElTable, ElTableColumn, ElTag } from 'element-plus';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import { adminRoleLabel } from '@/features/admin/utils/roleLabel';
import type { AdminUserRow } from '@/features/admin/types/admin.types';
import { useApprovalsAdmin } from './composables/useApprovalsAdmin';
const { t } = useI18n();
@@ -15,13 +22,9 @@ const { t } = useI18n();
const {
pendingUsers,
isLoading,
showConfirmDialog,
confirmMessage,
loadAll,
approveUser,
rejectUser,
closeConfirm,
confirmActionHandler,
} = useApprovalsAdmin();
onMounted(() => {
@@ -30,80 +33,58 @@ onMounted(() => {
</script>
<template>
<section class="admin-table-section">
<div v-if="isLoading" class="flex items-center justify-center py-20">
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
</div>
<AdminListPage :loading="isLoading">
<template #title>
<h2 class="section-title">{{ t('admin.approval.title') }}</h2>
<p class="section-desc">{{ t('admin.approval.subtitle') }}</p>
</template>
<template v-else>
<div class="admin-table-header">
<div>
<h2 class="section-title">{{ t('admin.approval.title') }}</h2>
<p class="section-desc mt-1">{{ t('admin.approval.subtitle') }}</p>
</div>
</div>
<div class="admin-table-wrap">
<table class="admin-table">
<thead>
<tr>
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.username') }}</th>
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.nameId') }}</th>
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.contact') }}</th>
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.role') }}</th>
<th class="px-8 py-4 text-right text-xs">{{ t('admin.approval.headers.actions') }}</th>
</tr>
</thead>
<tbody>
<tr v-if="pendingUsers.length === 0">
<td colspan="5" class="px-8 admin-table-empty">{{ t('admin.approval.noPending') }}</td>
</tr>
<tr v-for="user in pendingUsers" :key="user.id">
<td class="px-8 py-5 text-sm font-medium text-primary">
<div>{{ user.username }}</div>
<div class="text-xs text-muted font-normal">{{ user.email }}</div>
</td>
<td class="px-8 py-5 text-sm text-muted">
<div>{{ user.real_name || '-' }}</div>
<div class="text-xs text-muted font-mono">{{ user.employee_id || '-' }}</div>
</td>
<td class="px-8 py-5 text-sm text-muted">{{ user.phone_number || '-' }}</td>
<td class="px-8 py-5">
<span
class="px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 border border-yellow-200"
>
{{ adminRoleLabel(t, user.role, user.role_name) }}
</span>
</td>
<td class="px-8 py-5 text-right flex items-center justify-end gap-2">
<button
type="button"
class="p-2 text-green-600 bg-green-50 rounded-lg hover:bg-green-100 transition-colors"
:title="t('admin.approval.confirmApprove')"
@click="approveUser(user.id)"
>
<ShieldCheck class="w-4 h-4" />
</button>
<button
type="button"
class="p-2 text-red-600 bg-red-50 rounded-lg hover:bg-red-100 transition-colors"
:title="t('admin.approval.confirmReject')"
@click="rejectUser(user.id)"
>
<Trash2 class="w-4 h-4" />
</button>
</td>
</tr>
</tbody>
</table>
</div>
</template>
<DeleteConfirmDialog
v-model="showConfirmDialog"
:message="confirmMessage"
@cancel="closeConfirm"
@confirm="confirmActionHandler"
/>
</section>
<ElTable
class="hx-admin-table"
:data="pendingUsers"
row-key="id"
:empty-text="t('admin.approval.noPending')"
>
<ElTableColumn :label="t('admin.approval.headers.username')" min-width="200">
<template #default="{ row }">
<div>{{ (row as AdminUserRow).username }}</div>
<p class="hx-element-hint">{{ (row as AdminUserRow).email }}</p>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.approval.headers.nameId')" min-width="160">
<template #default="{ row }">
<div>{{ (row as AdminUserRow).real_name || '-' }}</div>
<p class="hx-element-hint">{{ (row as AdminUserRow).employee_id || '-' }}</p>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.approval.headers.contact')" min-width="140">
<template #default="{ row }">{{ (row as AdminUserRow).phone_number || '-' }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.approval.headers.role')" min-width="120">
<template #default="{ row }">
<ElTag effect="light" type="warning">
{{ adminRoleLabel(t, (row as AdminUserRow).role, (row as AdminUserRow).role_name) }}
</ElTag>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.approval.headers.actions')" width="120" align="right">
<template #default="{ row }">
<ElButton
link
type="primary"
:icon="CircleCheck"
:title="t('admin.approval.confirmApprove')"
@click="approveUser((row as AdminUserRow).id)"
/>
<ElButton
link
type="danger"
:icon="Delete"
:title="t('admin.approval.confirmReject')"
@click="rejectUser((row as AdminUserRow).id)"
/>
</template>
</ElTableColumn>
</ElTable>
</AdminListPage>
</template>
@@ -1,9 +1,12 @@
/**
* features/admin/modules/approvals/composables/useApprovalsAdmin.ts
* 用户注册审批:待审列表、通过、拒绝。
* 用途:用户注册审批的待审列表、通过和拒绝。
* 依赖:admin.api、useMessage、useAdminNavBadges、element-plus 的确认框。
* 逻辑:ApprovalsPage 调用本模块;通过和拒绝都先弹出 Element 确认框,成功后刷新列表和导航角标。
*/
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { ElMessageBox } from 'element-plus';
import { approveAdminUser, listAdminUsers, rejectAdminUser } from '@/features/admin/api/admin.api';
import { useMessage } from '@/shared/composables/useMessage';
import { useAdminNavBadges } from '@/features/admin/composables/useAdminNavBadges';
@@ -17,10 +20,6 @@ export function useApprovalsAdmin() {
const users = ref<AdminUserRow[]>([]);
const isLoading = ref(true);
const showConfirmDialog = ref(false);
const confirmMessage = ref('');
let confirmAction: (() => Promise<void> | void) | null = null;
const pendingUsers = computed(() => users.value.filter((u) => u.status === 'pending'));
const loadUsers = async (): Promise<void> => {
@@ -38,61 +37,61 @@ export function useApprovalsAdmin() {
isLoading.value = false;
};
const openConfirm = (message: string, action: () => Promise<void> | void): void => {
confirmMessage.value = message;
confirmAction = action;
showConfirmDialog.value = true;
};
const closeConfirm = (): void => {
showConfirmDialog.value = false;
confirmAction = null;
};
const confirmActionHandler = async (): Promise<void> => {
if (!confirmAction) return;
/**
* 弹出确认框。点取消时 Element 会拒绝 Promise,这里吞掉,不当成失败。
* @param message - 确认正文
* @returns 用户是否点了确定
*/
async function confirmAction(message: string): Promise<boolean> {
try {
await confirmAction();
} finally {
closeConfirm();
await ElMessageBox.confirm(message, t('common.deleteDialog.defaultTitle'), {
confirmButtonText: t('common.deleteDialog.confirm'),
cancelButtonText: t('common.deleteDialog.cancel'),
type: 'warning',
});
return true;
} catch {
return false;
}
};
}
const approveUser = (userId: number): void => {
openConfirm(t('admin.approval.confirmApprove'), async () => {
try {
await approveAdminUser(userId);
await loadUsers();
await refreshBadges();
} catch (e) {
console.error(e);
msg.error((e as Error).message || t('admin.msg.failed'));
}
});
};
/**
* 通过一条待审注册。先确认,再调审批接口并刷新角标。
* @param userId - 待审用户主键
*/
async function approveUser(userId: number): Promise<void> {
if (!(await confirmAction(t('admin.approval.confirmApprove')))) return;
try {
await approveAdminUser(userId);
await loadUsers();
await refreshBadges();
} catch (e) {
console.error(e);
msg.error((e as Error).message || t('admin.msg.failed'));
}
}
const rejectUser = (userId: number): void => {
openConfirm(t('admin.approval.confirmReject'), async () => {
try {
await rejectAdminUser(userId);
await loadUsers();
await refreshBadges();
} catch (e) {
console.error(e);
msg.error((e as Error).message || t('admin.msg.requestFailed'));
}
});
};
/**
* 拒绝一条待审注册。先确认,再调拒绝接口并刷新角标。
* @param userId - 待审用户主键
*/
async function rejectUser(userId: number): Promise<void> {
if (!(await confirmAction(t('admin.approval.confirmReject')))) return;
try {
await rejectAdminUser(userId);
await loadUsers();
await refreshBadges();
} catch (e) {
console.error(e);
msg.error((e as Error).message || t('admin.msg.requestFailed'));
}
}
return {
pendingUsers,
isLoading,
showConfirmDialog,
confirmMessage,
loadAll,
approveUser,
rejectUser,
closeConfirm,
confirmActionHandler,
};
}
@@ -1,7 +1,7 @@
/**
* features/admin/modules/dashboard/DashboardPage.vue
* 用途:管理后台仪表盘,四张可点击的统计卡。
* 依赖:useDashboardAdmin、useElementProvider、element-plus。
* 依赖:useDashboardAdmin、element-plus。
* 逻辑:路由 /admin/dashboard。统计来自 useDashboardAdmin。点击分别进入应用配置、应用权限和数据报表。本页不是列表,不用 AdminListPage。
*/
<script setup lang="ts">
@@ -9,17 +9,15 @@ import { onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { ChatDotRound, DataAnalysis, Monitor, User } from '@element-plus/icons-vue';
import { ElCard, ElConfigProvider, ElIcon, ElLoading, ElStatistic, ElTag } from 'element-plus';
import { ElCard, ElIcon, ElLoading, ElStatistic, ElTag } from 'element-plus';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import { useDashboardAdmin } from './composables/useDashboardAdmin';
const vLoading = ElLoading.directive;
const { t } = useI18n();
const router = useRouter();
const { elementLocale } = useElementProvider();
const {
agentCount,
@@ -49,7 +47,6 @@ onMounted(() => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<section v-loading="isLoading" class="admin-dash">
<h2 class="section-title">{{ t('admin.nav.dashboard') }}</h2>
<div v-if="!isLoading" class="admin-dash__grid">
@@ -83,7 +80,6 @@ onMounted(() => {
</ElCard>
</div>
</section>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,19 +1,17 @@
/**
* features/admin/modules/departments/DepartmentsPage.vue
* 用途:部门管理列表。一张卡片里放标题、添加按钮、搜索、表格。
* 依赖:AdminListPage、useDepartmentsAdmin、useElementProvider、element-plus、lucide-vue-next、部门表单和员工名单弹窗。
* 依赖:AdminListPage、useDepartmentsAdmin、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,
ElInput,
ElLoading,
ElTable,
@@ -23,7 +21,6 @@ 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 { AdminDepartmentMembersResponse, AdminDepartmentRow } from '@/features/admin/types/admin.types';
import DepartmentFormModal from './components/DepartmentFormModal.vue';
import DepartmentMembersModal from './components/DepartmentMembersModal.vue';
@@ -35,7 +32,6 @@ const vLoading = ElLoading.directive;
const { t } = useI18n();
const msg = useMessage();
const { elementLocale } = useElementProvider();
const showMembersModal = ref(false);
const departmentMembers = ref<AdminDepartmentMembersResponse | null>(null);
@@ -111,7 +107,6 @@ onMounted(() => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage :loading="isLoading">
<template #title>
<h2 class="section-title">{{ t('admin.dept.title') }}</h2>
@@ -157,36 +152,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>
@@ -205,7 +198,6 @@ onMounted(() => {
:data="departmentMembers"
@close="showMembersModal = false"
/>
</ElConfigProvider>
</template>
<style scoped>
@@ -219,69 +211,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>
@@ -8,6 +8,7 @@
来源站点详情三块折叠——库存报表|入站报表|出站报表;入站/出站走独立 get/save API。
复制新增只预填未保存草稿(sourceCloneDraft),保存后新站点保持停用。卡片入口是右上角复制图标,抽屉底栏保留文字按钮。
报表规则列表按用途分段(库存→入站→出站),组内按 profile_code / version 排序。
系统连接回显用户名明文,密码留空表示不修改。自动上传只保存开关,页面动作在连接器代码里。
视觉层已迁移 Element Plus(element-trial 主题),间距由 AdminLayout 壳层持有。
-->
<template>
@@ -143,28 +144,10 @@
<label><span>{{ t('admin.freightRpa.connectionName') }}</span><el-input v-model="profile.display_name" required /></label>
<label><span>{{ t('admin.freightRpa.connectorType') }}</span><el-select v-model="profile.connector_type"><el-option value="dbs" :label="t('admin.freightRpa.platform.dbs')" /><el-option value="crane" :label="t('admin.freightRpa.platform.crane')" /></el-select></label>
<label><span>{{ t('admin.freightRpa.loginUrl') }}</span><el-input v-model="profile.login_url" type="url" required /></label>
<label><span>{{ t('admin.freightRpa.username') }}</span><el-input v-model="profile.username" name="shipping-rpa-credential-user" autocomplete="one-time-code" readonly :placeholder="t('admin.freightRpa.writeOnlyHint')" @focus="unlockCredentialField" /></label>
<label><span>{{ t('admin.freightRpa.username') }}</span><el-input v-model="profile.username" name="shipping-rpa-username" autocomplete="off" /></label>
<label><span>{{ t('admin.freightRpa.password') }}</span><el-input v-model="profile.password" name="shipping-rpa-credential-password" type="password" autocomplete="new-password" readonly :placeholder="t('admin.freightRpa.writeOnlyHint')" @focus="unlockCredentialField" /></label>
<div class="switch-field"><span>{{ t('admin.freightRpa.enabled') }}</span><div class="switch-control"><el-switch v-model="profile.enabled" /><b>{{ profile.enabled ? t('admin.freightRpa.enabledState') : t('admin.freightRpa.disabledState') }}</b></div></div>
<section class="upload-config-section full">
<header class="upload-config-heading">
<b>{{ t('admin.freightRpa.uploadConfigTitle') }}</b>
<small>{{ t('admin.freightRpa.uploadConfigHint') }}</small>
</header>
<div class="switch-field"><span>{{ t('admin.freightRpa.uploadAutoEnabled') }}</span><div class="switch-control"><el-switch v-model="profile.upload_config_json.enabled" /><b>{{ profile.upload_config_json.enabled ? t('admin.freightRpa.enabledState') : t('admin.freightRpa.disabledState') }}</b></div></div>
<label><span>{{ t('admin.freightRpa.uploadEntryUrl') }}</span><el-input v-model="profile.upload_config_json.entry_url" type="url" /></label>
<label><span>{{ t('admin.freightRpa.uploadFileSelector') }}</span><el-input v-model="profile.upload_config_json.file_input_selector" /></label>
<label><span>{{ t('admin.freightRpa.uploadSubmitMode') }}</span><el-select v-model="profile.upload_config_json.submit_mode"><el-option value="auto_after_file" :label="t('admin.freightRpa.uploadSubmitAuto')" /><el-option value="click_submit" :label="t('admin.freightRpa.uploadSubmitClick')" /></el-select></label>
<label v-if="profile.upload_config_json.submit_mode === 'click_submit'"><span>{{ t('admin.freightRpa.uploadSubmitSelector') }}</span><el-input v-model="profile.upload_config_json.submit_selector" /></label>
<label><span>{{ t('admin.freightRpa.uploadResultMode') }}</span><el-select v-model="profile.upload_config_json.result_mode"><el-option value="page_notice" :label="t('admin.freightRpa.uploadResultPageNotice')" /><el-option value="history_record" :label="t('admin.freightRpa.uploadResultHistory')" /></el-select></label>
<label><span>{{ t('admin.freightRpa.uploadResultSelector') }}</span><el-input v-model="profile.upload_config_json.result_selector" /></label>
<label><span>{{ t('admin.freightRpa.uploadSuccessTexts') }}</span><el-input v-model="successTextsInput" type="textarea" :rows="2" :placeholder="t('admin.freightRpa.uploadSuccessTextsHint')" /></label>
<label><span>{{ t('admin.freightRpa.uploadTimeout') }}</span><el-input-number v-model="profile.upload_config_json.timeout_seconds" :min="1" /></label>
<div class="form-tip full">{{ t('admin.freightRpa.uploadConfigBoundary') }}</div>
</section>
<div class="form-tip full">{{ t('admin.freightRpa.connectionBoundary') }}</div>
<div class="switch-field"><span>{{ t('admin.freightRpa.uploadAutoEnabled') }}</span><div class="switch-control"><el-switch v-model="profile.upload_config_json.enabled" /><b>{{ profile.upload_config_json.enabled ? t('admin.freightRpa.enabledState') : t('admin.freightRpa.disabledState') }}</b></div></div>
</template>
<template v-else-if="activeTab === 'sources'">
@@ -746,33 +729,12 @@ const filenameVariableCandidates = computed(() => {
return filenameVariables.filter((item) => item.key.toLowerCase().includes(query) || t(item.labelKey).toLowerCase().includes(query));
});
/** 连接级“发货 Excel 自动上传”配置的受控 JSON 形状(字段与后端白名单一致)。 */
interface ProfileUploadConfig {
enabled: boolean;
entry_url: string;
file_input_selector: string;
submit_mode: 'auto_after_file' | 'click_submit';
submit_selector: string | null;
result_mode: 'page_notice' | 'history_record';
result_selector: string | null;
success_texts: string[];
timeout_seconds: number;
}
/** 连接级“发货 Excel 自动上传”默认配置:DSV 为已确认 URL+input#file2;Crane 保持未启用待管理员补全。 */
function defaultUploadConfig(connectorType: string): ProfileUploadConfig {
if (connectorType === 'crane') {
return { enabled: false, entry_url: 'https://wms-portal.craneww.com/#/shipping-order-upload', file_input_selector: 'input[name="OrderFileUpload"]', submit_mode: 'click_submit', submit_selector: null, result_mode: 'page_notice', result_selector: null, success_texts: [], timeout_seconds: 120 };
}
return { enabled: true, entry_url: 'https://s360.dbschenker.com/main/portal/frame/WMSUpload2', file_input_selector: 'input#file2', submit_mode: 'auto_after_file', submit_selector: null, result_mode: 'page_notice', result_selector: null, success_texts: [], timeout_seconds: 120 };
/** 系统连接只保存是否启用自动上传;页面路径和成功判断在连接器代码里。 */
function defaultUploadConfig(connectorType: string): { enabled: boolean } {
return { enabled: connectorType !== 'crane' };
}
const profile = reactive({ profile_code: '', display_name: '', connector_type: 'dbs', login_url: '', username: '', password: '', login_config_json: { auth_mode: 'password' }, enabled: true, upload_config_json: defaultUploadConfig('dbs') });
/** 成功文本以换行分隔的输入视图,写回 success_texts 数组。 */
const successTextsInput = computed<string>({
get: () => (profile.upload_config_json.success_texts || []).join('\n'),
set: (value) => { profile.upload_config_json.success_texts = String(value || '').split(/\r?\n/).map((item) => item.trim()).filter(Boolean); },
});
const parsing = reactive({
profile_code: '', display_name: '', file_format: 'xlsx', sheet_name: '', header_row_index: 1,
purpose: 'onhand' as 'onhand' | 'inbound' | 'outbound',
@@ -1130,7 +1092,7 @@ watch(
{ immediate: true },
);
/** 新建连接时按货代类型切换上传配置默认值;编辑既有连接不覆盖已保存配置。 */
/** 新建连接时按货代类型决定自动上传默认开关;编辑既有连接不覆盖已保存配置。 */
watch(
() => profile.connector_type,
(nextType) => {
@@ -1176,11 +1138,11 @@ function createNew(): void {
drawerOpen.value = true;
}
/** 将列表对象复制到当前编辑表单,凭据字段永远不从列表回填。 */
/** 将列表对象复制到当前编辑表单。用户名回填明文,密码不回填。 */
function selectItem(item: Item): void {
selectedId.value = Number(item.id);
sourceCloneFrom.value = null;
if (activeTab.value === 'profiles') Object.assign(profile, { ...item, username: '', password: '', login_config_json: item.login_config_json || { auth_mode: 'password' }, upload_config_json: item.upload_config_json || defaultUploadConfig(item.connector_type) });
if (activeTab.value === 'profiles') Object.assign(profile, { ...item, username: String(item.username || ''), password: '', login_config_json: item.login_config_json || { auth_mode: 'password' }, upload_config_json: { enabled: Boolean(item.upload_config_json?.enabled) } });
if (activeTab.value === 'parsing') Object.assign(parsing, {
profile_code: item.profile_code, display_name: item.display_name, file_format: item.file_format,
sheet_name: item.definition?.sheet_name || '', header_row_index: item.definition?.header_row_index ?? 0,
@@ -1504,7 +1466,7 @@ function duplicateSourceFromDrawer(): void {
async function saveCurrent(): Promise<void> {
saving.value = true;
try {
if (activeTab.value === 'profiles') await saveShippingRpaProfile({ ...profile, display_name: profile.display_name || profile.profile_code, upload_config_json: profile.upload_config_json }, selectedId.value || undefined);
if (activeTab.value === 'profiles') await saveShippingRpaProfile({ ...profile, display_name: profile.display_name || profile.profile_code, upload_config_json: { enabled: Boolean(profile.upload_config_json?.enabled) } }, selectedId.value || undefined);
if (activeTab.value === 'parsing') {
const payload = parsingUsesMovementContract.value ? {
profile_code: parsing.profile_code, display_name: parsing.display_name || parsing.profile_code, file_format: parsing.file_format,
@@ -1956,11 +1918,16 @@ function rowTitle(item: Item): string {
/**
* 列表卡副标题。
* 核心逻辑:mappings 展示「在途仓编码 → 目标仓编码」;缺在途仓时退化为仅目标编码。
* 核心逻辑:mappings 展示「在途仓编码 → 目标仓编码」;系统连接展示平台与用户名。
* @param item - 当前列表行对象
* @returns 副标题文案
*/
function rowMeta(item: Item): string {
if (activeTab.value === 'profiles') {
const platform = item.connector_type ? t(`admin.freightRpa.platform.${item.connector_type}`) : String(item.profile_code || '');
const username = String(item.username || '').trim();
return username ? `${platform} · ${username}` : platform;
}
if (activeTab.value === 'mappings') {
const targetCode = String(item.external_warehouse_code || '-');
const inTransit = String(item.in_transit_warehouse_code || '').trim();
@@ -2191,11 +2158,6 @@ onMounted(load);
.filename-variable-menu code { color: var(--el-color-primary-dark-2); font-size: 12px; }
.filename-variable-menu p { margin: 0; padding: 8px; color: var(--el-text-color-placeholder); font-size: 12px; }
.form-tip { border-radius: 8px; background: var(--el-fill-color-light); padding: 11px; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.55; }
.upload-config-section { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 1px solid var(--el-border-color-lighter); border-radius: 9px; background: var(--el-bg-color); padding: 0 12px 12px; }
.upload-config-heading { display: grid; gap: 2px; grid-column: 1 / -1; padding: 11px 0 8px; }
.upload-config-heading b { color: var(--el-text-color-regular); font-size: 12px; }
.upload-config-heading small { color: var(--el-text-color-placeholder); font-size: 12px; }
.upload-config-section .full { grid-column: 1 / -1; }
.sample-evidence-card { display: grid; gap: 12px; border: 1px solid var(--el-border-color-lighter); border-radius: 8px; background: var(--el-fill-color-lighter); padding: 14px; }
.sample-evidence-card > div { display: grid; gap: 3px; }
.sample-evidence-card strong { color: var(--el-text-color-regular); font-size: 13px; }
@@ -10,7 +10,6 @@ import { useI18n } from 'vue-i18n';
import { Plus } from '@element-plus/icons-vue';
import {
ElButton,
ElConfigProvider,
ElSwitch,
ElTable,
ElTableColumn,
@@ -21,7 +20,6 @@ import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import IntegrationConnectorFormDrawer from './components/IntegrationConnectorFormDrawer.vue';
import IntegrationCapabilityCallModal from './components/IntegrationCapabilityCallModal.vue';
import IntegrationCallLogsPanel from './components/IntegrationCallLogsPanel.vue';
@@ -35,7 +33,6 @@ import type {
} from './types/integration-connector.types';
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const {
clients, interfaces, bindings, credentials, capabilities, credentialTypes,
@@ -207,7 +204,6 @@ function onListTab(name: string): void {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage :loading="isLoading">
<template #title>
<h2 class="section-title">{{ t('admin.integrationConnector.title') }}</h2>
@@ -544,7 +540,6 @@ function onListTab(name: string): void {
@close="closeCallModal"
@run="runCall"
/>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,7 +1,7 @@
/**
* features/admin/modules/linked-services/LinkedServicesPage.vue
* 用途:关联服务列表。一张卡片里放标题、新增按钮和表格。
* 依赖:AdminListPage、useLinkedServicesAdmin、useElementProvider、element-plus、关联服务表单对话框。
* 依赖:AdminListPage、useLinkedServicesAdmin、element-plus、关联服务表单对话框。
* 逻辑:路由 /admin/linked-services。启用项会出现在对话和工作台侧栏。删除用 Element 确认框。
*/
<script setup lang="ts">
@@ -10,7 +10,6 @@ import { useI18n } from 'vue-i18n';
import { Plus } from '@element-plus/icons-vue';
import {
ElButton,
ElConfigProvider,
ElSwitch,
ElTable,
ElTableColumn,
@@ -19,13 +18,11 @@ 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 { AdminLinkedServiceRow } from '@/features/admin/types/linked-service.types';
import LinkedServiceFormModal from './components/LinkedServiceFormModal.vue';
import { useLinkedServicesAdmin } from './composables/useLinkedServicesAdmin';
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const {
services,
@@ -56,7 +53,6 @@ onMounted(() => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage :loading="isLoading">
<template #title>
<h2 class="section-title">{{ t('admin.linkedServices.title') }}</h2>
@@ -110,7 +106,6 @@ onMounted(() => {
@close="closeFormModal"
@save="saveService"
/>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,7 +1,7 @@
/**
* features/admin/modules/permissions/PermissionsPage.vue
* 用途:应用权限页。已种子权限组时以角色包为主、矩阵只读;否则保留历史按人勾选。
* 依赖:AdminListPage、AdminListTabs、usePermissionsAdmin、useElementProvider、element-plus、RoleEditModal、RoleMembersConfirmDialog、UserPickerDialog、BatchPermissionModal。
* 依赖:AdminListPage、AdminListTabs、usePermissionsAdmin、element-plus、RoleEditModal、RoleMembersConfirmDialog、UserPickerDialog、BatchPermissionModal。
* 逻辑:路由 /admin/permissions。骨架用 AdminListPage。角色/矩阵用 AdminListTabs。
* 点人数打开选人弹窗,确定后必须确认增减才写库。删除和重写入口确认用 ElMessageBox。
*/
@@ -12,7 +12,6 @@ import { Download, Plus, Upload, User } from '@element-plus/icons-vue';
import {
ElButton,
ElCheckbox,
ElConfigProvider,
ElInput,
ElLoading,
ElOption,
@@ -28,7 +27,6 @@ import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import BatchPermissionModal from '@/features/admin/modules/users/components/BatchPermissionModal.vue';
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
import UserPickerDialog from '@/shared/components/UserPickerDialog.vue';
@@ -42,7 +40,6 @@ import { usePermissionsAdmin } from './composables/usePermissionsAdmin';
const vLoading = ElLoading.directive;
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const csvInputRef = ref<HTMLInputElement | null>(null);
const {
@@ -134,7 +131,6 @@ onMounted(() => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage :loading="isLoading">
<template #title>
<h2 class="section-title">{{ t('admin.perm.title') }}</h2>
@@ -400,7 +396,6 @@ onMounted(() => {
@cancel="cancelMembersConfirm"
@confirm="applyMembers"
/>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,7 +1,7 @@
/**
* features/admin/modules/platform-apps/PlatformAppsPage.vue
* 用途:平台应用说明(新手指南)管理。按应用筛选指南,维护上传、启停与排序。
* 依赖:AdminListPage、useElementProvider、element-plus、admin.api 指南 CRUD/上传、vue-i18n。
* 依赖:AdminListPage、element-plus、admin.api 指南 CRUD/上传、vue-i18n。
* 逻辑:Admin 路由挂载。选择应用后拉取指南列表。创建/编辑用对话框,删除用 Element 确认框。
*/
<script setup lang="ts">
@@ -11,7 +11,6 @@ import { Plus } from '@element-plus/icons-vue';
import {
ElAlert,
ElButton,
ElConfigProvider,
ElDialog,
ElForm,
ElFormItem,
@@ -30,7 +29,6 @@ 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 {
createAdminAgentGuide,
deleteAdminAgentGuide,
@@ -43,7 +41,6 @@ import {
const vLoading = ElLoading.directive;
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const agents = ref<any[]>([]);
const selectedAgentId = ref<number | ''>('');
@@ -333,7 +330,6 @@ const formatSize = (bytes: number) => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage>
<template #title>
<h2 class="section-title">{{ t('admin.nav.platformApps') }}</h2>
@@ -499,7 +495,6 @@ const formatSize = (bytes: number) => {
</ElButton>
</template>
</ElDialog>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,7 +1,7 @@
/**
* features/admin/modules/procurement-contract/ProcurementContractPage.vue
* 用途:采购合同审查管理。一张卡片里放模板库、风险规则、审查历史三个页签。
* 依赖:AdminListPage、AdminListTabs、useElementProvider、element-plus、procurement-contract.api、
* 依赖:AdminListPage、AdminListTabs、element-plus、procurement-contract.api、
* contract-ocr-match-tokens、ContractRiskRulesPanel、useMessage、vue-i18n。
* 逻辑:Admin 路由挂载。页签用 AdminListTabs,筛选和表格走 AdminListPage。上传、区域配置、详情用对话框。
* 删除用 Element 确认框。下载和保存仍走原有接口,参数不变。
@@ -15,7 +15,6 @@ import {
ElButton,
ElCheckbox,
ElCheckboxGroup,
ElConfigProvider,
ElDescriptions,
ElDescriptionsItem,
ElDialog,
@@ -37,7 +36,6 @@ import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import {
createAdminContractTemplate,
deleteAdminContractTemplate,
@@ -65,7 +63,6 @@ const vLoading = ElLoading.directive;
const { t } = useI18n();
const msg = useMessage();
const { elementLocale } = useElementProvider();
type ContractTab = 'templates' | 'rules' | 'reviews';
type TagType = 'primary' | 'success' | 'warning' | 'info' | 'danger';
@@ -701,7 +698,6 @@ function defaultLabel(isDefault: boolean): string {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage>
<template #title>
<h2 class="section-title">{{ t('admin.procurementContract.title') }}</h2>
@@ -1135,7 +1131,6 @@ function defaultLabel(isDefault: boolean): string {
</div>
</template>
</ElDialog>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,7 +1,7 @@
/**
* features/admin/modules/questions/QuestionsPage.vue
* 用途:常用问题管理页。一张卡片里放标题、添加按钮、页签、筛选和表格。
* 依赖:AdminListPage、AdminListTabs、useQuestionsAdmin、useElementProvider、element-plus、QuestionFormModal、HotFaqCandidatesPanel。
* 依赖:AdminListPage、AdminListTabs、useQuestionsAdmin、element-plus、QuestionFormModal、HotFaqCandidatesPanel。
* 逻辑:路由 /admin/questions。骨架用 AdminListPage,页签用 AdminListTabs。
* 筛选、表格留在本页;热点候选由页签内容区的面板自己渲染。删除在 composable 里用 Element 确认框。
*/
@@ -12,7 +12,6 @@ import { Plus } from '@element-plus/icons-vue';
import {
ElButton,
ElCheckbox,
ElConfigProvider,
ElInput,
ElLoading,
ElOption,
@@ -26,7 +25,6 @@ import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import AdminListTabs from '@/features/admin/components/AdminListTabs.vue';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import type { AdminQuickQuestionRow } from '@/features/admin/types/question.types';
import HotFaqCandidatesPanel from './components/HotFaqCandidatesPanel.vue';
import QuestionFormModal from './components/QuestionFormModal.vue';
@@ -35,7 +33,6 @@ import { useQuestionsAdmin } from './composables/useQuestionsAdmin';
const vLoading = ElLoading.directive;
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const activeTab = ref<'manual' | 'hot'>('manual');
const {
@@ -106,7 +103,6 @@ onMounted(() => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage>
<template #title>
<h2 class="section-title">{{ t('admin.question.title') }}</h2>
@@ -242,7 +238,6 @@ onMounted(() => {
@save="saveQuestion"
@review="saveReviewQuestion"
/>
</ElConfigProvider>
</template>
<style scoped>
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 前端按日期升序兜底;问题分析优先问题表前端分页;非表页切换时清空通用表状态防幽灵分页;
@@ -11,6 +11,7 @@
import { computed, reactive, 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,
@@ -742,30 +743,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)) {
@@ -1672,25 +1649,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 () => {
@@ -2016,8 +2009,6 @@ watch([reportPageSize, issueQuestionTotal], () => {
reportRangeStart,
reportRangeEnd,
reportPageButtons,
showDeleteConfirmDialog,
deleteConfirmMessage,
loadAll,
handleFilterChange,
resetChatLogsColumns,
@@ -2044,6 +2035,5 @@ watch([reportPageSize, issueQuestionTotal], () => {
goToReportPage,
prevReportPage,
nextReportPage,
confirmDelete,
};
}
@@ -2,15 +2,13 @@
* features/admin/modules/schedules/SchedulesPage.vue
* 用途:定时任务管理独立页面壳层。路由:/admin/schedules
* 依赖:useSchedulesAdmin、schedules.context、Element Plus、子 panel/overlays。
* 逻辑:reactive + provide admin;ElConfigProvider 包裹 admin-table-section;概览/工作台切换。
* 逻辑:reactive + provide admin;概览/工作台切换。
*/
<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,
@@ -22,7 +20,6 @@ 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);
@@ -36,12 +33,10 @@ onMounted(async () => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<section class="admin-table-section animate-fade-in-up">
<SchedulePageHeader />
<ScheduleOverviewPanel v-if="admin.scheduleViewMode === 'overview'" />
<ScheduleWorkbenchPanel v-else />
</section>
<SchedulesPageOverlays />
</ElConfigProvider>
</template>
File diff suppressed because it is too large. Load diff
@@ -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>
@@ -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,7 +1,7 @@
/**
* features/admin/modules/users/UsersPage.vue
* 用途:用户管理独立页面(服务端筛选分页、用户/部门列排序、批量操作)。
* 依赖:useUsersAdmin、useElementProvider、element-plus、用户相关 Modal、adminRoleLabel、getUserAvatarLabel。
* 依赖:useUsersAdmin、element-plus、用户相关 Modal、adminRoleLabel、getUserAvatarLabel。
* 逻辑:路由 /admin/users。列表骨架用 AdminListPage;筛选、表格、分页和三个业务弹窗仍由本页组装。
* 删除和改角色用 Element 确认框。列表经 listAdminUsersPage 按页拉取。
*/
@@ -11,7 +11,6 @@ import { useI18n } from 'vue-i18n';
import { Delete, Edit, Plus, User } from '@element-plus/icons-vue';
import {
ElButton,
ElConfigProvider,
ElInput,
ElLoading,
ElOption,
@@ -28,7 +27,6 @@ import '@/features/admin/styles/element-trial.css';
import { adminRoleLabel } from '@/features/admin/utils/roleLabel';
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
import type { AdminUserRow } from '@/features/admin/types/admin.types';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import BatchEditUserModal from './components/BatchEditUserModal.vue';
import BatchPermissionModal from './components/BatchPermissionModal.vue';
@@ -38,7 +36,6 @@ import { useUsersAdmin } from './composables/useUsersAdmin';
const vLoading = ElLoading.directive;
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const {
agents,
@@ -125,7 +122,6 @@ onMounted(() => {
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage :loading="isLoading">
<template #title>
<h2 class="section-title">{{ t('admin.user.title') }}</h2>
@@ -277,7 +273,6 @@ onMounted(() => {
@close="showBatchPermissionModal = false"
@save="submitBatchPermission"
/>
</ElConfigProvider>
</template>
<style scoped>
@@ -1,26 +1,22 @@
<script setup lang="ts">
/**
* features/admin/modules/wecom/WecomLayout.vue
* 企微管理壳层:二级 Tab、共享 composable、子路由出口。
* 用途:企微管理壳层。注入共享数据,并引入 Element 样式。
* 依赖:useWecomAdmin、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 { 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 { useWecomAdmin } from './composables/useWecomAdmin';
import { WECOM_ADMIN_KEY } from './wecom.context';
const { t } = useI18n();
const vLoading = ElLoading.directive;
const wecomAdmin = useWecomAdmin();
const { isLoading } = wecomAdmin;
provide(WECOM_ADMIN_KEY, wecomAdmin);
const {
isLoading,
showDeleteConfirmDialog,
deleteConfirmMessage,
confirmDelete,
refreshWecomData,
} = wecomAdmin;
onMounted(() => {
void wecomAdmin.loadAll();
@@ -28,33 +24,13 @@ 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>
<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>
</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,15 +1,31 @@
<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,
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 { 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();
@@ -20,83 +36,132 @@ 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>
<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>
</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,268 @@
<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,
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 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 {
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>
<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>
</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,13 +1,36 @@
<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,
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 type { WecomIntegrationManifest } from '@/features/admin/types/wecom.types';
import WecomSubNav from '../components/WecomSubNav.vue';
import { WECOM_ADMIN_KEY } from '../wecom.context';
const { t } = useI18n();
@@ -23,238 +46,424 @@ 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>
<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>
</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>
@@ -1,89 +1,11 @@
/**
* features/admin/styles/element-trial.css
* 用途:管理端 Element Plus 的字体、字号、颜色、圆角、控件高度,以及和 Tailwind 共存的修正。
* 依赖:tokens.css 的 --text-* / --bg-* / --border-*,element-plus 暗色变量,Tailwind preflight。
* 逻辑:由 UsersPage、AgentsPage、KbAdminPanel 在暗色 CSS 之后引入,所以 html.dark 能盖过 Element 默认暗色。
* 字号和颜色以本文变量为准。页面不要再用 text-sm / text-muted 改表格和按钮。
* 用途:管理端列表专用的表格内边距、分页条和表单补充说明。
* 依赖:shared/styles/element-theme.css 的 Element 变量。
* 逻辑:本文件先引入全站皮肤。管理页在暗色 CSS 之后引入本文件,变量才能盖过 Element 默认暗色。
* 列宽、筛选框宽度不要写进这里。对话等非列表页只引 element-theme.css,不引本文件。
*/
:root,
html.dark {
--el-color-primary: #0284c7;
--el-color-primary-light-3: #4da3d6;
--el-color-primary-light-5: #81c2e3;
--el-color-primary-light-7: #b4daf0;
--el-color-primary-light-8: #cde6f4;
--el-color-primary-light-9: #e6f3fa;
--el-color-primary-dark-2: #0269a0;
--el-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
--el-font-size-extra-large: 20px;
--el-font-size-large: 18px;
--el-font-size-medium: 16px;
--el-font-size-base: 14px;
--el-font-size-small: 13px;
--el-font-size-extra-small: 12px;
--el-text-color-primary: var(--text-primary);
--el-text-color-regular: var(--text-secondary);
--el-text-color-secondary: var(--text-muted);
--el-text-color-placeholder: var(--text-muted);
--el-text-color-disabled: var(--text-muted);
--el-border-color: var(--border-default);
--el-border-color-light: var(--border-subtle);
--el-border-color-lighter: var(--border-subtle);
--el-bg-color: var(--bg-surface);
--el-bg-color-overlay: var(--bg-surface);
--el-fill-color-blank: var(--bg-surface);
--el-fill-color-light: var(--bg-surface-soft);
--el-border-radius-base: 8px;
--el-component-size: 32px;
}
.el-button {
display: inline-flex;
align-items: center;
justify-content: center;
}
.el-button .el-icon,
.el-button svg {
display: inline-flex;
flex: none;
}
/* Tailwind forms 会给单行输入框内部的 input 加边框。聚焦时左右两边会多出两条蓝线。
多行输入框的边框就画在 .el-textarea__inner 上,不能一起清掉。 */
.el-input__inner,
.el-select__input,
.el-range-input,
.el-input__inner:hover,
.el-select__input:hover,
.el-range-input:hover,
.el-input__inner:focus,
.el-select__input:focus,
.el-range-input:focus {
border: 0;
outline: none;
background-color: transparent;
box-shadow: none;
--tw-ring-shadow: 0 0 #0000;
--tw-ring-offset-shadow: 0 0 #0000;
}
.el-textarea__inner {
background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
}
.el-textarea__inner:hover {
box-shadow: 0 0 0 1px var(--el-input-hover-border-color, var(--el-border-color-hover)) inset;
}
.el-textarea__inner:focus {
outline: none;
box-shadow: 0 0 0 1px var(--el-input-focus-border-color, var(--el-color-primary)) inset;
--tw-ring-shadow: 0 0 #0000;
--tw-ring-offset-shadow: 0 0 #0000;
}
@import "../../../shared/styles/element-theme.css";
/* 列表首尾列与页头 32px 对齐;分页贴在表格下方 */
.hx-admin-table .el-table__cell:first-child .cell {
@@ -1399,6 +1399,19 @@ export async function batchConfirmWorkspaceShippingNoticesUploaded(businessNos:
);
}
/**
* 手动刷新 Crane 分配状态。后端只排队一次状态回查,不重新上传 Excel。
* @param businessNo - 对外发货通知单号,同时是 Crane 的 Pull Request #
* @returns 已排队的回查结果
*/
export async function refreshWorkspaceCraneUploadStatus(businessNo: string) {
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
`/api/workspace/shipping-notices/${encodeURIComponent(businessNo)}/refresh-crane-upload`,
jsonPost({}),
);
return assertShippingOk(body);
}
/** 按多个发货通知单号批量受理货代 RPA 上传;RPA 成功仍以回调为准。 */
export async function batchStartWorkspaceShippingNoticeRpaUpload(businessNos: string[]) {
return requestJson<{ results: Array<Record<string, unknown>> }>(
@@ -34,6 +34,7 @@ import {
executeTransferItems,
listEvidenceFiles,
reparseCurrentFile,
downloadEvidenceFile,
retryTransferSourceRpa,
retryTransferSourcesRpaBatch,
getTransferBacklogSummary,
@@ -109,6 +110,13 @@ describe('transfer.api JSON request contract', () => {
expect(url).toBe('/api/in-transit-transfer/sources/DSV360/evidence-files?record_kind=outbound');
});
it('单文件下载走站点 evidence-files/{id},不打开 MinIO 地址', () => {
// [断言意图] HTTPS 页面不能直接打开 HTTP MinIO 预签名链接,下载必须走当前站点。
downloadEvidenceFile('DSV360', 25, 'outbound');
const [url] = requestBlob.mock.calls[0] as [string, RequestInit];
expect(url).toBe('/api/in-transit-transfer/sources/DSV360/evidence-files/25?record_kind=outbound');
});
it('当前文件重解析 POST reparse,body 只有 record_kind', () => {
reparseCurrentFile('DSV360_AWSDU', 'outbound');
const calls = requestJson.mock.calls as [string, RequestInit][];
@@ -5,6 +5,8 @@
* 逻辑:薄封装后端 /api/in-transit-transfer 全部端点;二进制下载走 requestBlob。
* 来源重试 body 带 record_kind;批量重试与证据打包在带来源类型时带 transfer_type;
* 证据清单走 GET sources/{code}/evidence-files;
* 单文件下载走 GET sources/{code}/evidence-files/{fileId},由站点回传,
* 不打开 HTTP MinIO 预签名地址;
* 当前归档重解析走 POST sources/{code}/reparse(body 仅 record_kind,不触发 RPA)。
*/
import { requestBlob, requestJson } from '@/shared/api/client';
@@ -327,6 +329,25 @@ export const listEvidenceFiles = (sourceCode: string, recordKind: TransferRecord
{ headers: getAuthHeaders() },
);
/**
* 经当前站点下载一份证据文件。
* 核心逻辑:GET /sources/{code}/evidence-files/{fileId},带 record_kind。
* 页面是 HTTPS,MinIO 公网地址是 HTTP,直接打开预签名链接会被浏览器拦截。
* @param sourceCode - 来源实例编码
* @param fileId - 归档文件主键
* @param recordKind - inbound 或 outbound
* @returns 文件内容和 Content-Disposition 中的保存名
*/
export const downloadEvidenceFile = (
sourceCode: string,
fileId: number,
recordKind: TransferRecordKind,
) =>
requestBlob(
`${BASE}/sources/${encodeURIComponent(sourceCode)}/evidence-files/${fileId}?record_kind=${encodeURIComponent(recordKind)}`,
{ headers: getAuthHeaders() },
);
/**
* 对来源当前最新归档文件重新解析(不触发 RPA)。
* 核心逻辑:POST /sources/{code}/reparse,body 只带 record_kind,后端重放最新归档 Excel。
@@ -320,7 +320,7 @@ function resultLabelKey(item: TransferBacklogItem): string {
</div>
</div>
<!-- EP 表格壳:数据=服务端返回的当前页切片;横向滚动由 el-table 内建(列 min-width 撑开) -->
<!-- EP 表格:show-overflow-tooltip;左固定勾选,右固定结果+操作;单号/老化可滚 -->
<el-table
v-if="items.length"
:data="items"
@@ -330,7 +330,7 @@ function resultLabelKey(item: TransferBacklogItem): string {
class="text-xs"
data-testid="transfer-backlog-table"
>
<el-table-column width="48" class-name="whitespace-nowrap">
<el-table-column fixed width="48">
<template #header>
<el-checkbox
size="small"
@@ -349,40 +349,61 @@ function resultLabelKey(item: TransferBacklogItem): string {
/>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" show-overflow-tooltip>
<template #default="{ row }">
<span :data-testid="`transfer-backlog-type-${row.invoice_no}`">{{ typeLabel(row.transfer_type) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="130" class-name="whitespace-nowrap">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
prop="invoice_no"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span class="font-semibold">{{ row.invoice_no }}</span>
<span class="font-semibold">{{ row.invoice_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="100" class-name="whitespace-nowrap">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span data-testid="transfer-backlog-external-doc">{{ row.external_doc_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colName')" min-width="140">
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip>
<template #default="{ row }">{{ row.material_name || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" min-width="110" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" min-width="110" show-overflow-tooltip>
<template #default="{ row }">{{ row.from_warehouse || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="110" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
<template #default="{ row }">{{ deriveBatchNo(row.lot_no ?? '') || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="90" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ formatQuantity(row.external_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToWarehouse')" min-width="110" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colToWarehouse')" min-width="110" show-overflow-tooltip>
<template #default="{ row }">{{ row.to_warehouse || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ formatQuantity(row.movement_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colResult')" min-width="110">
<el-table-column :label="$t('chat.transfer.colAging')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ $t(agingLabel(row.aging_level)) }}</template>
</el-table-column>
<el-table-column
fixed="right"
:label="$t('chat.transfer.colResult')"
width="100"
>
<template #default="{ row }">
<el-tag
size="small"
@@ -395,10 +416,11 @@ function resultLabelKey(item: TransferBacklogItem): string {
</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colAging')" min-width="90" class-name="whitespace-nowrap">
<template #default="{ row }">{{ $t(agingLabel(row.aging_level)) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colAction')" min-width="150" class-name="whitespace-nowrap">
<el-table-column
fixed="right"
:label="$t('chat.transfer.colAction')"
width="150"
>
<template #default="{ row }">
<template v-if="isActionable(row as TransferBacklogItem)">
<!-- 失效行(文件已移除)只留关闭:重查会被后端拒绝(TRANSFER.RETRY_NOT_ALLOWED)。 -->
@@ -2,20 +2,18 @@
features/chat/components/messages/TransferExecutableCard.vue
用途:可调拨明细卡——全局可执行行队列(跨匹配范围):勾选明细行后按行生成调拨单。
依赖:Element Plus ElTable/ElTableColumn/ElInput/ElButton/ElTag/ElPagination/
ElCheckbox(2026-10-20:勾选列一并 EP;testid 挂 el-checkbox,规格经内层
input 读写)、props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo。
逻辑:行由后端按业务稳定键排序(异动日期→Invoice→创建时间);勾选为卡片本地态;
stale/file_current 行置灰提示(执行门禁在后端,失败经 BusinessError 展示);
无 item_id 的历史回放行禁选。
客户端分页(2026-10-16):集合天然有界(仅当日成熟可执行行)但为防增长后
DOM 失控,50/页切片渲染;关键字筛选变更回第 1 页,勾选集合跨页保留。
行定位:el-table 经 row-class-name 注入 transfer-executable-<invoice_no>。
调拨类型列取行上 transfer_type,按启用类型配置显示当前语言名称。
ElCheckbox/ElAlert、props.items、i18n chat.transfer.*、transferBatch /
transferItemTable(明细表密度约定)。
逻辑:行由后端按业务稳定键排序;勾选本地态;无 item_id 历史行禁选;50/页分页。
表格遵循 transferItemTable:show-overflow-tooltip、左固定勾选、右固定结果+操作、
单号可滚、库存数量与查询时刻同行、过期用顶栏 el-alert 汇总批量重查。
行定位:row-class-name 注入 transfer-executable-<invoice_no>。
-->
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import {
ElAlert,
ElButton,
ElCheckbox,
ElInput,
@@ -27,8 +25,11 @@ import {
import type { CheckboxValueType } from 'element-plus';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import {
formatStockQuantityCell,
freshnessHint,
} from './transferItemTable';
import { transferTypeDisplay } from './transferTypeLabel';
import { parseApiUtcDate } from '@/shared/utils/dateTime';
import type { TransferMatchingItem, TransferTypeOption } from '../../types/transfer.types';
const props = withDefaults(defineProps<{
@@ -40,7 +41,7 @@ const props = withDefaults(defineProps<{
transferTypes: () => [],
});
const { locale } = useI18n();
const { locale, t } = useI18n();
/**
* 把可执行行的调拨类型 code 显示成名称。
@@ -70,7 +71,7 @@ const filtered = computed(() =>
props.items.filter((item) => {
const kw = keyword.value.trim().toLowerCase();
if (!kw) return true;
const haystack = [item.invoice_no, item.material_no, item.material_name, item.source_code, item.lot_no]
const haystack = [item.invoice_no, item.external_doc_no, item.material_no, item.material_name, item.source_code, item.lot_no]
.map((value) => String(value ?? '').toLowerCase());
return haystack.some((value) => value.includes(kw));
}),
@@ -80,7 +81,6 @@ const pagedItems = computed(() =>
filtered.value.slice((currentPage.value - 1) * PAGE_SIZE, currentPage.value * PAGE_SIZE),
);
// 筛选变更回第 1 页;刷新后行数减少时收拢当前页防空白页
watch(keyword, () => {
currentPage.value = 1;
});
@@ -97,6 +97,13 @@ const allFilteredSelected = computed(() =>
filtered.value.length > 0 && filtered.value.every((item) => item.item_id != null && selectedIds.value.has(item.item_id)),
);
/** 当前筛选下库存已过期且可重查的行 id。 */
const staleItemIds = computed(() =>
filtered.value
.filter((item) => item.stale === true && item.item_id != null)
.map((item) => item.item_id as number),
);
function toggleRow(item: TransferMatchingItem, checkedBox: boolean) {
if (item.item_id == null) return;
const next = new Set(selectedIds.value);
@@ -126,7 +133,7 @@ function rowKey(item: TransferMatchingItem): string {
/**
* el-table 行类:注入行定位类 + stale/文件过期置灰。
* @param row 可执行明细行
* @returns 空格分隔的 class 串(含 transfer-executable-<invoice_no>)
* @returns 空格分隔的 class 串
*/
function rowClassName({ row }: { row: TransferMatchingItem }): string {
return [
@@ -135,12 +142,21 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
].filter(Boolean).join(' ');
}
/** 查询时刻展示(HH:mm);后端 naive ISO 按 UTC 解析后转浏览器本地时区
* (仓库约定 parseApiUtcDate,2026-09-29 修复 UTC+8 展示异常);无 checked_at 不渲染。 */
function checkedTime(item: TransferMatchingItem): string {
if (!item.checked_at) return '';
const date = parseApiUtcDate(item.checked_at);
return Number.isNaN(date.getTime()) ? '' : date.toTimeString().slice(0, 5);
/**
* 库存数量单元格:数量与完整查询时刻同一行。
* @param item 可执行明细行
*/
function stockCell(item: TransferMatchingItem): string {
return formatStockQuantityCell(formatQuantity(item.from_quantity), item.checked_at);
}
/**
* 批量重查当前筛选下全部过期行。
* 核心逻辑:顶栏汇总入口,避免结果列刷长文案。
*/
function requeryStaleRows() {
if (!staleItemIds.value.length) return;
emit('requery', [...staleItemIds.value]);
}
</script>
@@ -157,6 +173,30 @@ function checkedTime(item: TransferMatchingItem): string {
</el-button>
</div>
<el-alert
v-if="staleItemIds.length"
type="warning"
:closable="false"
class="mb-2"
data-testid="transfer-executable-stale-banner"
>
<template #title>
<div class="flex flex-wrap items-center gap-2">
<span>{{ $t('chat.transfer.staleBanner', { count: staleItemIds.length }) }}</span>
<el-button
link
type="primary"
size="small"
:disabled="busy"
data-testid="transfer-executable-requery-stale"
@click="requeryStaleRows"
>
{{ $t('chat.transfer.staleBannerRequery') }}
</el-button>
</div>
</template>
</el-alert>
<div class="mb-2 flex flex-wrap items-center gap-2">
<div class="w-56 shrink-0">
<el-input
@@ -189,7 +229,7 @@ function checkedTime(item: TransferMatchingItem): string {
class="text-xs"
data-testid="transfer-executable-table"
>
<el-table-column width="48" class-name="whitespace-nowrap">
<el-table-column fixed width="48">
<template #header>
<el-checkbox
size="small"
@@ -208,52 +248,77 @@ function checkedTime(item: TransferMatchingItem): string {
/>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" show-overflow-tooltip>
<template #default="{ row }">
<span :data-testid="`transfer-executable-type-${row.invoice_no}`">{{ typeLabel(row.transfer_type) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="130" class-name="whitespace-nowrap">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
prop="invoice_no"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span class="font-semibold">{{ row.invoice_no }}</span>
<span class="font-semibold">{{ row.invoice_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="100" class-name="whitespace-nowrap">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span data-testid="transfer-executable-external-doc">{{ row.external_doc_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colName')" min-width="140">
<template #default="{ row }">{{ row.material_name }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" min-width="110" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.from_warehouse }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="110" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" prop="from_warehouse" min-width="110" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
<template #default="{ row }">{{ deriveBatchNo(row.lot_no ?? '') || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="90" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="168" show-overflow-tooltip>
<template #default="{ row }">
{{ formatQuantity(row.from_quantity) }}
<div v-if="checkedTime(row as TransferMatchingItem)" class="text-[10px] text-muted">{{ checkedTime(row as TransferMatchingItem) }}</div>
<span
:class="row.stale ? 'text-amber-700' : undefined"
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
:data-testid="`transfer-executable-stock-${row.invoice_no}`"
>
{{ stockCell(row as TransferMatchingItem) }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToWarehouse')" min-width="110" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.to_warehouse }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colToWarehouse')" prop="to_warehouse" min-width="110" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ formatQuantity(row.to_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colResult')" min-width="120">
<el-table-column
fixed="right"
:label="$t('chat.transfer.colResult')"
width="88"
>
<template #default="{ row }">
<el-tag size="small" type="success" effect="light" data-testid="transfer-executable-result">
<el-tag
size="small"
type="success"
effect="light"
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
data-testid="transfer-executable-result"
>
{{ $t('chat.transfer.resultExecutable') }}
</el-tag>
<div v-if="row.stale" class="mt-0.5 text-[10px] text-amber-600">{{ $t('chat.transfer.staleRow') }}</div>
<div v-else-if="row.file_current === false" class="mt-0.5 text-[10px] text-amber-600">{{ $t('chat.transfer.fileChangedRow') }}</div>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colAction')" min-width="90" class-name="whitespace-nowrap">
<el-table-column
fixed="right"
:label="$t('chat.transfer.colAction')"
width="72"
>
<template #default="{ row }">
<el-button
link
@@ -268,7 +333,6 @@ function checkedTime(item: TransferMatchingItem): string {
</template>
</el-table-column>
</el-table>
<!-- 客户端分页(单页时隐藏):文案走全局 ElConfigProvider 四语言 locale -->
<el-pagination
v-if="filtered.length > PAGE_SIZE"
v-model:current-page="currentPage"
@@ -362,7 +362,10 @@ onMounted(async () => {
:data-testid="`transfer-executed-items-${order.doc_no}`"
>
<el-table :data="order.items" size="small" class="text-xs">
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="120" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" prop="invoice_no" min-width="120" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.external_doc_no || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="140" />
<!-- 拨出批号展示外部形态(WTP→HOW 镜像转换,与匹配卡/可调拨明细/待办池同规则;
@@ -2,7 +2,7 @@
* features/chat/components/messages/TransferMatchCard.spec.ts
* 用途:匹配卡顶栏「来源失败」横幅过滤——路由未解析失败只行内展示,不进顶栏。
* 依赖:@vue/test-utils、i18n。
* 逻辑:来源失败顶栏(sources[].error_code/error_message)防止“安静全 0”;
* 逻辑:来源失败顶栏(sources[].error_code/error_message)防止“安静全 0”。
* 后端分层后路由失败保持行级(result=blocked_route_not_resolved),
* 顶栏需按 error_code 客户端排除(历史卡片回放同样生效)。
*/
@@ -7,20 +7,11 @@
busy)、i18n chat.transfer.*。
逻辑:明细表渲染 pagedItems(filtered 经客户端分页切片);阻断项 checkbox 禁用;
勾选键 = 明细行 item_id(历史回放行无 item_id 禁用防误选);
库存数量下方小字透出查询时刻(checked_at);stale 行置灰 + 重查提示;
file_current=false 行提示文件已更新(自动对齐语义);blocked_file_removed
徽标独立文案;pending_stock_check 行徽标「待查库存」(el-tag warning);
计数卡透出待查库存(pending_stock_check_count)/已失效(invalid_count),
历史回放缺省按 0 展示;blocked_file_removed 行退出主视图(表格不渲染),
表格下方折叠提示去待处理异常池处理——重查救不了已消失的行,主清单只留
可行动项;重查范围含可恢复阻断与可执行行(重查仍按 invoice_no 提交);
阻断原因经结果徽标 title 悬浮透出不占行高;无选择或 busy 时生成按钮禁用;
emit execute(itemIds);来源级解析/文件失败经 sources.error_code 透出
(防"安静全 0"),但路由未解析失败(TRANSFER.ROUTE_NOT_RESOLVED)不进顶栏
——路由失败保持行级(result=blocked_route_not_resolved 行内展示),
顶栏按 error_code 客户端排除,历史卡片回放同样生效;
行定位:el-table 行不支持逐行 attr,经 row-class-name 注入
transfer-item-<invoice_no>(spec/e2e 用类选择器等价定位);
明细表遵循 transferItemTable(EP show-overflow-tooltip、左固定勾选、
右固定结果/重查、单号可滚、库存数量与查询时刻同行、过期顶栏 el-alert 汇总);
blocked_file_removed 退出主视图;重查仍按 invoice_no;emit execute(itemIds);
来源失败顶栏排除 TRANSFER.ROUTE_NOT_RESOLVED;行定位经 row-class-name
注入 transfer-item-<invoice_no>;
[2026-10-12 单据数口径修正] 预计 ERP 单据数(计数卡=全部可执行行、
生成按钮旁=勾选可执行行)按执行建单五元组 (external_org, source_code,
movement_date, from_warehouse, to_warehouse) 去重实时计算(与后端
@@ -49,7 +40,10 @@ import {
import type { CheckboxValueType } from 'element-plus';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import { parseApiUtcDate } from '@/shared/utils/dateTime';
import {
formatStockQuantityCell,
freshnessHint,
} from './transferItemTable';
import type { TransferMatchingItem, TransferMatchingSummary, TransferSourceProgress } from '../../types/transfer.types';
const { t } = useI18n();
@@ -129,7 +123,7 @@ const filtered = computed(() =>
if (isFileRemoved(item)) return false;
const kw = keyword.value.trim().toLowerCase();
if (kw) {
const haystack = [item.material_no, item.material_name, item.invoice_no, item.lot_no]
const haystack = [item.material_no, item.material_name, item.invoice_no, item.external_doc_no, item.lot_no]
.map((value) => String(value ?? '').toLowerCase());
if (!haystack.some((value) => value.includes(kw))) return false;
}
@@ -179,6 +173,22 @@ function requerySelected(): void {
if (nos.length) emit('requery', nos);
}
/** 当前筛选下库存已过期且可重查的单号。 */
const staleInvoiceNos = computed(() =>
filtered.value
.filter((item) => item.stale === true && isRequeryable(item))
.map((item) => item.invoice_no),
);
/**
* 批量重查当前筛选下全部过期行。
* 核心逻辑:顶栏汇总入口,避免结果列刷长文案。
*/
function requeryStaleRows(): void {
if (!staleInvoiceNos.value.length) return;
emit('requery', [...staleInvoiceNos.value]);
}
function isChecked(item: TransferMatchingItem): boolean {
return item.item_id != null && props.selected.has(item.item_id);
}
@@ -217,18 +227,11 @@ const estimatedDocumentCountSelected = computed(
);
/**
* 库存查询时刻小字(HH:mm);后端 naive ISO 按 UTC 解析后转浏览器本地时区
* (仓库约定 parseApiUtcDate,2026-09-29 修复 UTC+8 展示异常);
* 无效/缺省 checked_at 返回 null 不渲染。
* @param item 匹配明细行;checked_at 为后端 ISO 时间
* 库存数量单元格:数量与完整查询时刻同一行。
* @param item 匹配明细行
*/
function checkedAtLabel(item: TransferMatchingItem): string | null {
if (!item.checked_at) return null;
const date = parseApiUtcDate(item.checked_at);
if (Number.isNaN(date.getTime())) return null;
const hh = String(date.getHours()).padStart(2, '0');
const mm = String(date.getMinutes()).padStart(2, '0');
return `${hh}:${mm}`;
function stockCell(item: TransferMatchingItem): string {
return formatStockQuantityCell(formatQuantity(item.from_quantity), item.checked_at);
}
function resultLabel(result: string): string {
@@ -348,6 +351,30 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
</div>
</el-alert>
<el-alert
v-if="staleInvoiceNos.length"
type="warning"
:closable="false"
class="mb-3"
data-testid="transfer-match-stale-banner"
>
<template #title>
<div class="flex flex-wrap items-center gap-2">
<span>{{ $t('chat.transfer.staleBanner', { count: staleInvoiceNos.length }) }}</span>
<el-button
link
type="primary"
size="small"
:disabled="props.requeryBusy"
data-testid="transfer-match-requery-stale"
@click="requeryStaleRows"
>
{{ $t('chat.transfer.staleBannerRequery') }}
</el-button>
</div>
</template>
</el-alert>
<div class="mb-2 flex flex-wrap items-center gap-2">
<div class="w-56 shrink-0">
<el-input
@@ -383,8 +410,7 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
</el-button>
</div>
<!-- EP 表格壳:横向滚动由 el-table 内建(列 min-width 撑开);无行动行时不挂表;
表体只挂当前页切片(pagedItems),全量集合仍在 filtered 供筛选/全选/计数 -->
<!-- EP 表格:show-overflow-tooltip + 左右固定列;表体仅当前页切片 -->
<el-table
v-if="filtered.length"
:data="pagedItems"
@@ -394,7 +420,7 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
class="text-xs"
data-testid="transfer-match-table"
>
<el-table-column width="48" class-name="whitespace-nowrap">
<el-table-column fixed width="48">
<template #header>
<el-checkbox
size="small"
@@ -413,49 +439,57 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
/>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colInvoice')" prop="invoice_no" min-width="130" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
prop="invoice_no"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span class="font-semibold">{{ row.invoice_no }}</span>
<span class="font-semibold">{{ row.invoice_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="100" class-name="whitespace-nowrap">
<el-table-column
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
min-width="130"
show-overflow-tooltip
>
<template #default="{ row }">
<span data-testid="transfer-match-external-doc">{{ row.external_doc_no || '—' }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" class-name="whitespace-nowrap" />
<el-table-column :label="$t('chat.transfer.colName')" min-width="140">
<template #default="{ row }">{{ row.material_name }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" min-width="110" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.from_warehouse }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="110" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" prop="from_warehouse" min-width="110" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
<template #default="{ row }">{{ deriveBatchNo(row.lot_no) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="90" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="168" show-overflow-tooltip>
<template #default="{ row }">
<div>{{ formatQuantity(row.from_quantity) }}</div>
<!-- 库存查询时刻小字:数据新鲜度溯源(stale 门禁的可见依据) -->
<div
v-if="checkedAtLabel(row as TransferMatchingItem)"
class="text-[10px] text-muted"
:title="$t('chat.transfer.stockCheckedAtTitle', { time: checkedAtLabel(row as TransferMatchingItem) })"
<span
:class="row.stale === true ? 'text-amber-700' : undefined"
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
:data-testid="`transfer-checked-at-${row.invoice_no}`"
>
{{ checkedAtLabel(row as TransferMatchingItem) }}
</div>
{{ stockCell(row as TransferMatchingItem) }}
</span>
</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToWarehouse')" min-width="110" class-name="whitespace-nowrap">
<template #default="{ row }">{{ row.to_warehouse }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" class-name="whitespace-nowrap">
<el-table-column :label="$t('chat.transfer.colToWarehouse')" prop="to_warehouse" min-width="110" show-overflow-tooltip />
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
<template #default="{ row }">{{ formatQuantity(row.to_quantity) }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colResult')" min-width="200">
<el-table-column
fixed="right"
:label="$t('chat.transfer.colResult')"
width="200"
>
<template #default="{ row }">
<div class="flex flex-wrap items-center gap-1">
<!-- 阻断原因经悬浮提示(title)透出:不占行高;可执行行也提供重查入口 -->
<div class="flex flex-nowrap items-center gap-1">
<el-tag
size="small"
effect="light"
@@ -465,24 +499,25 @@ function rowClassName({ row }: { row: TransferMatchingItem }): string {
>
{{ $t(resultLabel(row.result)) }}
</el-tag>
<!-- 行级警示小标:stale(仅展示提示,不拦截执行——2026-09-25 TTL 退役)/ 文件版本已过期 -->
<el-tag
v-if="row.stale === true"
size="small"
type="warning"
effect="plain"
:title="$t('chat.transfer.staleRow')"
data-testid="transfer-item-stale"
>
{{ $t('chat.transfer.staleRow') }}
{{ $t('chat.transfer.staleShort') }}
</el-tag>
<el-tag
v-if="row.file_current === false"
size="small"
type="warning"
effect="plain"
:title="$t('chat.transfer.fileChangedRow')"
data-testid="transfer-item-file-changed"
>
{{ $t('chat.transfer.fileChangedRow') }}
{{ $t('chat.transfer.fileChangedShort') }}
</el-tag>
<el-button
v-if="isRequeryable(row as TransferMatchingItem)"
@@ -403,9 +403,12 @@ async function confirmCloseOrder() {
<!-- 行明细常驻展开(物料 × 批号聚合行;Invoice 首列对齐可调拨明细列序) -->
<div class="border-t border-subtle px-3 py-2" :data-testid="`transfer-order-lines-${order.doc_no}`">
<el-table :data="order.lines" size="small" class="text-xs">
<el-table-column :label="$t('chat.transfer.colInvoice')" min-width="110">
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" min-width="110">
<template #default="{ row }">{{ row.invoice_no || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120">
<template #default="{ row }">{{ row.external_doc_no || '—' }}</template>
</el-table-column>
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" />
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="120" />
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="100">
@@ -9,6 +9,7 @@
* 确认门禁=所选类型每条流都是 ready 或 no_data;混合选择先披露未就绪流再确认;
* 抓取中与未配置不渲染重试,其余状态可重试(ready 亦可强制重抓);
* 证据清单默认只显示最新一份,更早点开后才列出;首行「重新解析」走 reparseCurrentFile,不 emit retry;
单文件下载走 downloadEvidenceFile,不再把预签名地址放进 href;
* 类型选项=props.transferTypes 接口真相(enabled 过滤与排序在后端契约内,
* 前端不过滤),名称 names[locale]→zh-CN→en→code 回退,空列表空态+确认禁用。
*/
@@ -18,6 +19,7 @@ import i18n from '@/i18n';
const transferApiMocks = vi.hoisted(() => ({
listEvidenceFiles: vi.fn(),
downloadEvidenceFile: vi.fn(),
reparseCurrentFile: vi.fn(),
}));
vi.mock('../../api/transfer.api', () => transferApiMocks);
@@ -452,7 +454,7 @@ describe('TransferSourceSelectCard', () => {
expect(list.text()).not.toContain('TRIG-BATCH');
expect(list.get('p').attributes('title')).toContain('outbound_TRIG-BATCH-A629464D_DBS-AWSBI_NA_20261021101739.xlsx');
expect(list.get('p').attributes('title')).toContain('2026-10-21 18:00');
expect(wrapper.get('[data-testid="transfer-evidence-download-25"]').attributes('href')).toBe('https://files.example/current?filename=DBS-AWSBI_20261021_1800.xlsx');
expect(wrapper.get('[data-testid="transfer-evidence-download-25"]').attributes('href')).toBeUndefined();
expect(wrapper.text()).not.toContain('older.xlsx');
expect(wrapper.text()).not.toContain('abc');
const buttons = wrapper.findAll('[data-testid="transfer-evidence-reparse-DBS-AWSBI-inbound"]');
@@ -468,6 +470,23 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.emitted('reparsed')).toBeTruthy();
});
it('点击下载走站点接口,不打开预签名地址', async () => {
// [断言意图] 下载按钮不再带 MinIO href;点击后按来源、文件和记录类型请求当前站点。
transferApiMocks.listEvidenceFiles.mockResolvedValue([
{ file_id: 25, original_filename: 'CRANE.xlsx', created_at: '2026-10-26T07:00:00', sha256: 'abc', file_size: 10, presigned_url: 'http://192.168.100.192:9000/file', download_url: 'http://192.168.100.192:9000/file?filename=CRANE.xlsx' },
]);
transferApiMocks.downloadEvidenceFile.mockResolvedValue({ blob: new Blob(['xlsx']), filename: 'DBS-AWSBI_20261026_1500.xlsx' });
const wrapper = mount(TransferSourceSelectCard, {
props: { sources: readySources, transferTypes: defaultTransferTypes },
global: { plugins: [i18n] },
});
await wrapper.find('[data-testid="transfer-source-status-DBS-AWSBI"]').trigger('click');
await flushPromises();
await wrapper.get('[data-testid="transfer-evidence-download-25"]').trigger('click');
await flushPromises();
expect(transferApiMocks.downloadEvidenceFile).toHaveBeenCalledWith('DBS-AWSBI', 25, 'inbound');
});
it('按所选类型的 record_kinds 绘制证据流芯片,抓取中无重试,下载按钮为证据文件', async () => {
// [断言意图] 方案 A:状态芯片与重试钮分离。hub_to_hub 两种流各一枚芯片;
// 出站抓取中无 ↻;入站 ↻ 的 aria-label 为「重试入站」。切回只含 inbound 时不出现「出站」。
@@ -6,7 +6,7 @@
ElCheckbox(2026-10-20:类型/日期/勾选一并 EP 化;规格改断言 is-active /
ElDatePicker modelValue / checkbox 内层 input)、
props.sources(含 streams)、props.transferTypes(含 record_kinds)、
listEvidenceFiles、reparseCurrentFile、i18n chat.transfer.*。
listEvidenceFiles、downloadEvidenceFile、reparseCurrentFile、i18n chat.transfer.*。
逻辑:匹配参数区(调拨类型 + 异动日期,确认时一并提交)→ 选择辅助/上下文操作条
(有选中时原位替换辅助区,承载一次批量重试/下载证据文件/清空选择)→
平台分组来源列表(只画当前类型 record_kinds 里的证据流)→
@@ -15,6 +15,7 @@
(来源编码 + 入站/出站 + 状态)再提交可匹配来源;
行态为方案 A:状态芯片(边框 + ▾/▴,点开当天证据清单)与独立描边 ↻ 钮分隔;
清单默认只显示最新一份,一行放下文件名、短时间和操作,更早的当天归档点开才列出;
单文件预览和下载都走站点接口再触发一次 blob 保存,不新开 HTTP MinIO 标签;
抓取中与未配置不渲染 ↻;调拨类型选项=接口下发数据,名称按
names[locale]→zh-CN→en→code 回退;配置为空渲染空态且确认禁用;缺省选中接口列表首项。
-->
@@ -31,7 +32,8 @@ import {
} from 'element-plus';
import type { CheckboxValueType } from 'element-plus';
import { useMessage } from '@/shared/composables/useMessage';
import { listEvidenceFiles, reparseCurrentFile } from '../../api/transfer.api';
import { triggerBlobDownload } from '@/shared/utils/download';
import { downloadEvidenceFile, listEvidenceFiles, reparseCurrentFile } from '../../api/transfer.api';
import { defaultMovementDate, formatShanghaiDateTime, formatShanghaiMonthDayTime } from './transferDate';
import type {
TransferEvidenceFile,
@@ -193,6 +195,7 @@ watch(openEvidenceKey, () => {
const evidenceByKey = ref<Record<string, TransferEvidenceFile[]>>({});
/** 正在执行当前文件重解析的证据流键(source:recordKind),用于禁用对应按钮 */
const reparsingKey = ref<string | null>(null);
const downloadingEvidenceId = ref<number | null>(null);
/** 清单未加载时复用同一空数组,避免模板里每次渲染 new [] 触发递归更新。 */
const NO_EVIDENCE_FILES: TransferEvidenceFile[] = [];
@@ -414,6 +417,31 @@ async function reparseEvidence(sourceCode: string, recordKind: TransferRecordKin
}
}
/**
* 下载或预览清单中的一份证据文件。
* 核心逻辑:向当前站点要文件字节,再用 a[download] 保存。
* xlsx 无法在浏览器里打开。页面是 HTTPS、MinIO 是 HTTP 时,新开标签会被立刻关掉。
* @param sourceCode - 来源实例编码
* @param recordKind - inbound 或 outbound
* @param file - 清单中的一条归档
* @returns 无;失败时弹出错误
*/
async function downloadEvidence(
sourceCode: string,
recordKind: TransferRecordKind,
file: TransferEvidenceFile,
): Promise<void> {
downloadingEvidenceId.value = file.file_id;
try {
const result = await downloadEvidenceFile(sourceCode, file.file_id, recordKind);
triggerBlobDownload(result.blob, result.filename || evidenceLabel(file, sourceCode));
} catch (err) {
notifyError(err instanceof Error ? err.message : String(err));
} finally {
downloadingEvidenceId.value = null;
}
}
/**
* 行内短文件名,对齐排程压缩包条目。
* 核心逻辑:包内条目是 `{序号}_{来源}.xlsx`,序号只保证同一压缩包不重名。
@@ -903,19 +931,19 @@ watch(selectedRecordKinds, () => {
:data-testid="`transfer-evidence-reparse-${source.source_code}-${stream.record_kind}`"
@click="reparseEvidence(source.source_code, stream.record_kind)"
>{{ t('chat.transfer.reparseCurrentFile') }}</button>
<a
:href="file.presigned_url"
target="_blank"
rel="noopener noreferrer"
class="font-bold text-brand-700"
>{{ t('chat.transfer.previewEvidence') }}</a>
<a
:href="file.download_url"
target="_blank"
rel="noopener noreferrer"
class="font-bold text-brand-700"
<button
type="button"
class="font-bold text-brand-700 disabled:opacity-50"
:disabled="downloadingEvidenceId === file.file_id"
@click="downloadEvidence(source.source_code, stream.record_kind, file)"
>{{ t('chat.transfer.previewEvidence') }}</button>
<button
type="button"
class="font-bold text-brand-700 disabled:opacity-50"
:disabled="downloadingEvidenceId === file.file_id"
:data-testid="`transfer-evidence-download-${file.file_id}`"
>{{ t('chat.transfer.downloadEvidence') }}</a>
@click="downloadEvidence(source.source_code, stream.record_kind, file)"
>{{ t('chat.transfer.downloadEvidence') }}</button>
</span>
</div>
<button
@@ -108,15 +108,17 @@ describe('TransferMatchCard', () => {
expect(wrapper.find('.transfer-item-INV-001').text()).toContain('HOW26082728');
});
it('库存数量下方小字展示查询时刻(HH:mm)', async () => {
it('库存数量与完整查询时刻同一行(数量 · YYYY-MM-DD HH:mm)', async () => {
// [断言意图] 数量与时刻同行,避免第二行撑高整表;完整日期才能判断新旧。
const wrapper = await mountMatchCard({ summary, items, selected: new Set<number>() });
const cell = wrapper.find('[data-testid="transfer-checked-at-INV-001"]');
expect(cell.exists()).toBe(true);
expect(cell.text()).toMatch(/^\d{2}:\d{2}$/);
expect(wrapper.find('[data-testid="transfer-checked-at-INV-041"]').exists()).toBe(false);
expect(cell.text()).toBe('1200 · 2026-09-23 09:05');
// [断言意图] 无查询时刻时仍单行只显示数量,不拆第二行。
expect(wrapper.find('[data-testid="transfer-checked-at-INV-041"]').text()).not.toContain('·');
});
it('stale 行置灰 + 重查小标;file_current=false 行展示文件更新小标', async () => {
it('stale 行置灰 + 短徽标;file_current=false 行展示文件更新短徽标;顶栏汇总过期', async () => {
const flaggedItems = [
{ ...items[0], stale: true, file_current: false },
];
@@ -124,8 +126,12 @@ describe('TransferMatchCard', () => {
// [断言意图] el-table 行类经 row-class-name 注入 opacity-60。
const row = wrapper.find('.transfer-item-INV-001');
expect(row.classes()).toContain('opacity-60');
expect(wrapper.find('[data-testid="transfer-item-stale"]').text()).toContain('重查');
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').text()).toContain('自动对齐');
// [断言意图] 长句只放悬停;行内只留短徽标;顶栏 el-alert 汇总可批量重查。
expect(wrapper.find('[data-testid="transfer-item-stale"]').text()).toContain('已过期');
expect(wrapper.find('[data-testid="transfer-item-stale"]').attributes('title')).toContain('重查');
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').text()).toContain('文件更新');
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').attributes('title')).toContain('自动对齐');
expect(wrapper.find('[data-testid="transfer-match-stale-banner"]').text()).toContain('1');
});
it('计数卡透出待查库存/已失效计数;历史 payload 缺省按 0 展示', async () => {
@@ -0,0 +1,32 @@
/**
* features/chat/components/messages/transferItemTable.spec.ts
* 用途:锁住明细表库存单元格与新鲜度提示的统一格式。
*/
import { describe, expect, it } from 'vitest';
import {
formatStockCheckedAt,
formatStockQuantityCell,
freshnessHint,
} from './transferItemTable';
describe('transferItemTable', () => {
it('完整查询时刻为上海时区 YYYY-MM-DD HH:mm', () => {
// [断言意图] +08:00 墙钟原样保留;无时区 naive 按 UTC 再转上海。
expect(formatStockCheckedAt('2026-09-23T09:05:00+08:00')).toBe('2026-09-23 09:05');
expect(formatStockCheckedAt('2026-10-22T02:57:00')).toBe('2026-10-22 10:57');
expect(formatStockCheckedAt('')).toBe('');
});
it('库存单元格数量与时刻同一行', () => {
// [断言意图] 禁止拆成两行撑高表格。
expect(formatStockQuantityCell('30', '2026-10-20T10:38:00+08:00')).toBe('30 · 2026-10-20 10:38');
expect(formatStockQuantityCell('30', null)).toBe('30');
});
it('新鲜度悬停过期优先于文件更新', () => {
const t = (key: string) => key;
expect(freshnessHint({ stale: true, file_current: false }, t)).toBe('chat.transfer.staleRow');
expect(freshnessHint({ stale: false, file_current: false }, t)).toBe('chat.transfer.fileChangedRow');
expect(freshnessHint({}, t)).toBe('');
});
});
@@ -0,0 +1,61 @@
/**
* features/chat/components/messages/transferItemTable.ts
* 用途:在途调拨明细表(可调拨 / 匹配 / 待恢复)的统一展示约定与单元格格式化。
* 依赖:transferDate.formatShanghaiDateTime、i18n chat.transfer.*。
* 逻辑:三卡共用 Element Plus 密度规则,禁止各卡各自叠第二行或放任折行。
*
* Element Plus 约定:
* 1. 长文本列 show-overflow-tooltip;不够宽就横向滚,不折行。
* 2. 左只固定勾选,右固定结果/操作;单号随表横滚(不钉死,避免挤窄中间区)。
* 3. 库存数量与查询时刻同一行:「数量 · YYYY-MM-DD HH:mm」。
* 4. 过期不占结果列长文;顶栏 el-alert 汇总 + 批量重查。
*/
import { formatShanghaiDateTime } from './transferDate';
const CHECKED_AT_RE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
/**
* 把后端库存查得时刻格式成上海时区完整墙钟。
* @param checkedAt - 后端 ISO(可空)
* @returns `YYYY-MM-DD HH:mm`;无法解析则空串
*/
export function formatStockCheckedAt(checkedAt: string | null | undefined): string {
if (!checkedAt) return '';
const label = formatShanghaiDateTime(checkedAt);
return CHECKED_AT_RE.test(label) ? label : '';
}
/**
* 库存数量单元格主文案:数量与查询时刻同一行。
* @param quantityLabel - 已格式化的数量文本
* @param checkedAt - 后端 ISO
* @returns 如 `30 · 2026-10-20 18:38`;无时刻则仅数量
*/
export function formatStockQuantityCell(
quantityLabel: string,
checkedAt: string | null | undefined,
): string {
const when = formatStockCheckedAt(checkedAt);
return when ? `${quantityLabel} · ${when}` : quantityLabel;
}
export interface TransferFreshnessRow {
stale?: boolean;
file_current?: boolean;
}
/**
* 行新鲜度悬停说明(过期优先于文件更新)。
* @param row - 带 stale / file_current 的明细行
* @param t - vue-i18n t
* @returns 悬停全文;无提示时空串
*/
export function freshnessHint(
row: TransferFreshnessRow,
t: (key: string) => string,
): string {
if (row.stale) return t('chat.transfer.staleRow');
if (row.file_current === false) return t('chat.transfer.fileChangedRow');
return '';
}
@@ -77,6 +77,8 @@ export interface TransferMatchingItem {
material_name: string;
specification: string;
invoice_no: string;
/** 档上的外部单号;没有则为空,列表显示占位 */
external_doc_no?: string;
/** 明细异动日期(Task 3 序列化键更名,明细 movement 语义;旧名见 git 历史) */
movement_date?: string | null;
from_warehouse: string;
@@ -164,8 +166,10 @@ export type TransferOrderStatus = 'pending' | 'executing' | 'success' | 'duplica
/** 单内行(ERP 写入行粒度聚合:物料+批号;quantity 为 6 位小数字符串,与 D14 快照口径一致) */
export interface TransferOrderLine {
/** 行级溯源入站通知号(2026-09-29 契约扩充;一行恒对应一张 invoice,旧 payload 缺省) */
/** 行级溯源单号(档 doc_no;旧 payload 缺省) */
invoice_no?: string;
/** 档上的外部单号;聚合行内多个单号以逗号连接,旧 payload 缺省 */
external_doc_no?: string;
material_no: string;
material_name: string;
lot_no: string;
@@ -218,6 +222,8 @@ export interface TransferBacklogItem {
item_id: number;
source_code: string;
invoice_no: string;
/** 档上的外部单号;没有则为空 */
external_doc_no?: string;
material_no: string;
status: string;
reason: string;
@@ -388,6 +394,8 @@ export interface TransferOrderGroups {
*/
export interface TransferExecutedOrderItem {
invoice_no: string;
/** 档上的外部单号;没有则为空 */
external_doc_no?: string;
material_no: string;
material_name: string;
lot_no: string;
@@ -2,14 +2,15 @@
/**
* features/chat/views/ChatView.vue
* 单个 Agent 对话页入口:provide 编排上下文,子组件 inject 消费。
* 依赖:useChatPage、ChatViewContent/ChatViewOverlays。
* 依赖:useChatPage、ChatViewContent/ChatViewOverlays、shared/styles/element-theme.css。
* 逻辑:在途调拨业务面板(Transfer* 组件)已 EP 组件化(el-dialog/el-table/el-select),
* EP 样式随本页入口全量引入(亮色 + 暗色变量,模式同 admin 页面内引入),
* 保证 chat 直达时样式就绪、不依赖 admin 路由先行加载。
* EP 官方样式和全站 element-theme.css 随本页入口引入,放在暗色变量之后。
* 不引管理端 element-trial.css。保证 chat 直达时样式就绪、不依赖 admin 路由先行加载。
*/
import { provide, reactive } from 'vue';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/shared/styles/element-theme.css';
import { useChatPage } from '@/features/chat/composables/useChatPage';
import { CHAT_PAGE_KEY, type ChatPageContextProvided } from '@/features/chat/composables/chat.context';
import ChatViewContent from '@/features/chat/components/ChatViewContent.vue';
@@ -35,6 +35,7 @@ import {
getWorkspaceShippingFreightNoticeGroups,
batchConfirmWorkspaceShippingNoticesUploaded,
batchStartWorkspaceShippingNoticeRpaUpload,
refreshWorkspaceCraneUploadStatus,
retryWorkspaceShippingOrderStpAutoCreate,
retryShippingNoticeIntake,
decideWorkspaceShippingOrderReviewLineFulfillment,
@@ -2542,7 +2543,7 @@ const freightNoticeGroupsLoadFailed = ref(false);
/** 货代上传分组请求在途守卫:独立于 loading,避免轮询 tick 与动作后刷新并发重载。 */
const freightGroupsInFlight = ref(false);
const selectedFreightBusinessNos = ref<string[]>([]);
const freightBatchBusy = ref<'download' | 'confirm' | 'rpa' | 'regenerate' | null>(null);
const freightBatchBusy = ref<'download' | 'confirm' | 'rpa' | 'regenerate' | 'refresh' | null>(null);
/**
* 判断货代通知聚合行是否已具备上传成功事实。
* 核心逻辑:聚合接口 upload_status 已经过后端 project_notice_upload_status 归一,
@@ -3459,7 +3460,7 @@ watch(
function hasFreightGroupsInFlightRpa(groups: ShippingFreightNoticeGroup[]): boolean {
return (groups || []).some((group) => {
const st = String(group.upload_status || '').trim().toLowerCase();
return st === 'uploading';
return st === 'uploading' || st === 'allocating';
});
}
@@ -3524,14 +3525,35 @@ function toggleFreightNoticeSelection(businessNo: string, checked: boolean) {
: selectedFreightBusinessNos.value.filter((item) => item !== businessNo);
}
/** 已选通知单中任一已上传时,批量写入动作必须 fail-closed,避免重复提交成功通知。 */
/** 已选通知单中任一已上传或仍在 Crane 分配中时,批量写入动作必须停住,避免重复上传。 */
const selectedFreightNoticesContainUploaded = computed(() => {
const selected = new Set(selectedFreightBusinessNos.value);
return freightNoticeGroups.value.some((group) => (
selected.has(group.business_no) && isFreightNoticeUploaded(group)
selected.has(group.business_no)
&& (isFreightNoticeUploaded(group) || String(group.upload_status || '').trim().toLowerCase() === 'allocating')
));
});
/**
* 手动刷新一张仍在分配中的 Crane 发货单。
* @param businessNo - 发货通知单号,即 Pull Request #
*/
async function refreshCraneUploadStatus(businessNo: string) {
if (freightBatchBusy.value) return;
freightBatchBusy.value = 'refresh';
try {
await refreshWorkspaceCraneUploadStatus(businessNo);
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
if (taskNo) await loadFreightNoticeGroups(taskNo);
freightNoticeGroupsFinalized = false;
startWorkflowProgressPolling();
} catch (error) {
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
} finally {
freightBatchBusy.value = null;
}
}
async function downloadFreightNotice(businessNo: string) {
try {
await downloadWorkspaceShippingNoticeExcelFile(businessNo);
@@ -3824,13 +3846,21 @@ function freightLineNoDisplay(line: { line_no?: string | number | null }): {
* @param group - 当前发货通知单聚合行(含 upload_status 与逐单错误字段)。
*/
function freightUploadStatusDisplay(group: ShippingFreightNoticeGroup): {
state: 'uploaded' | 'uploading' | 'failed' | 'needs_human' | 'pending';
state: 'uploaded' | 'uploading' | 'allocating' | 'failed' | 'needs_human' | 'pending';
label: string;
chipClass: string;
reason: string | null;
} {
const status = String(group.upload_status || '').trim().toLowerCase();
const reason = group.upload_error_message || group.upload_error_code || null;
if (status === 'allocating') {
return {
state: 'allocating',
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.allocating'),
chipClass: 'bg-amber-100 text-amber-800 dark:bg-amber-950/50 dark:text-amber-200',
reason: null,
};
}
if (status === 'uploaded') {
return {
state: 'uploaded',
@@ -5496,7 +5526,15 @@ watch(
<span :class="freightUploadStatusDisplay(group).chipClass" :title="freightUploadStatusDisplay(group).reason || undefined" class="rounded-full px-2 py-0.5 font-medium cursor-help" tabindex="0">{{ freightUploadStatusDisplay(group).label }}</span>
<button type="button" class="rounded border border-brand-200 px-2 py-1 font-medium text-brand-700 hover:bg-brand-50" data-testid="review-freight-upload-download" :disabled="saving" @click="void downloadFreightNotice(group.business_no)">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.download') }}</button>
<button
v-if="canRunFreightNoticeAction(group, 'retry_freight_upload_rpa')"
v-if="freightUploadStatusDisplay(group).state === 'allocating'"
type="button"
class="rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface-muted disabled:opacity-50"
data-testid="review-freight-upload-refresh"
:disabled="freightBatchBusy !== null"
@click="void refreshCraneUploadStatus(group.business_no)"
>{{ t('chat.shippingOrderReview.lifecycle.freightUpload.refreshStatus') }}</button>
<button
v-if="canRunFreightNoticeAction(group, 'retry_freight_upload_rpa') && freightUploadStatusDisplay(group).state !== 'allocating'"
type="button"
class="rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface-muted disabled:opacity-50"
data-testid="review-freight-upload-rpa"
@@ -5504,7 +5542,7 @@ watch(
@click="void runFreightNoticeAction(group, 'rpa')"
>{{ t('chat.shippingOrderReview.lifecycle.freightUpload.rpa') }}</button>
<button
v-if="canRunFreightNoticeAction(group, 'mark_manual_uploaded')"
v-if="canRunFreightNoticeAction(group, 'mark_manual_uploaded') && freightUploadStatusDisplay(group).state !== 'allocating'"
type="button"
class="rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface-muted disabled:opacity-50"
data-testid="review-freight-upload-confirm"
@@ -1,11 +1,14 @@
/**
* features/contract-payment/utils/paymentStatus.test.ts
* 用途:锁定台账阶段格子的逾期与缺日期判定,避免验收款有过期日期却不显示已逾期。
* 依赖:paymentStatus.classifyLedgerStageCell。
* 依赖:paymentStatus.classifyLedgerStageCell、firstRoundAlertDate、payableDate、isNothingToPay、aggregateContractNodeStatus。
* 逻辑:用固定业务日覆盖验收款已逾期、质保款未到期,以及零金额阶段显示为空格。
* 另断言详情页首轮预警日与第 1 次预警同一天,验收款不再把归档日当成预警日期。
* 质保款应付日是验收归档日加质保期,不能回退成验收日。
* 金额和比例都为 0 的阶段不参与合同逾期,也不再标已逾期。
*/
import { describe, expect, it } from 'vitest';
import { classifyLedgerStageCell } from './paymentStatus';
import { classifyLedgerStageCell, firstRoundAlertDate, aggregateContractNodeStatus, isNothingToPay, payableDate } from './paymentStatus';
const TODAY = '2026-10-07';
@@ -41,14 +44,15 @@ describe('classifyLedgerStageCell', () => {
}, 'acceptance', TODAY)).toBe('missing_date');
});
it('keeps paid prepayment as paid and a zero stage as an empty cell', () => {
it('keeps a paid acceptance as paid and a zero stage as an empty cell', () => {
// 验收款对上 ERP 付款后必须显示已付,不能因为归档日已过继续标已逾期。
expect(classifyLedgerStageCell({
status: 'paid',
percentage: '30',
amount: '6600.00',
due_date: '2026-08-12',
anchor_date: '2026-08-12',
}, 'prepayment', TODAY)).toBe('paid');
percentage: '20',
amount: '11160.00',
due_date: '2026-10-24',
anchor_date: '2026-10-24',
}, 'acceptance', TODAY)).toBe('paid');
expect(classifyLedgerStageCell({
status: 'active',
percentage: '0',
@@ -58,3 +62,116 @@ describe('classifyLedgerStageCell', () => {
}, 'acceptance', TODAY)).toBe('absent');
});
});
describe('firstRoundAlertDate', () => {
it('uses archive plus 30 days for acceptance so it matches the first alert', () => {
// 验收款 due_date 与归档日相同,预警日期必须取首轮而不是把 9 月 24 日再印一遍。
expect(firstRoundAlertDate({
node_type: 'acceptance',
anchor_date: '2026-09-24',
due_date: '2026-09-24',
})).toBe('2026-10-24');
});
it('keeps prepayment, shipment and warranty on their first-round offsets', () => {
expect(firstRoundAlertDate({
node_type: 'prepayment',
anchor_date: '2026-09-18',
due_date: '2026-09-18',
})).toBe('2026-09-25');
expect(firstRoundAlertDate({
node_type: 'shipment',
anchor_date: '2026-08-25',
due_date: '2026-08-25',
})).toBe('2026-08-18');
expect(firstRoundAlertDate({
node_type: 'warranty',
anchor_date: '2026-09-24',
due_date: '2027-09-24',
})).toBe('2027-09-17');
});
it('returns null when the stage has no date to count from', () => {
expect(firstRoundAlertDate({
node_type: 'acceptance',
anchor_date: null,
due_date: null,
})).toBeNull();
expect(firstRoundAlertDate({
node_type: 'warranty',
anchor_date: '2026-09-24',
due_date: null,
})).toBeNull();
});
});
describe('payableDate', () => {
it('uses acceptance plus the warranty term for warranty, not the acceptance date', () => {
// 质保款 anchor_date 是验收归档日,应付日必须取 due_date。
expect(payableDate({
node_type: 'warranty',
anchor_date: '2026-09-24',
due_date: '2027-03-23',
})).toBe('2027-03-23');
expect(payableDate({
node_type: 'warranty',
anchor_date: '2026-09-24',
due_date: null,
})).toBeNull();
});
it('keeps the existing due date for prepayment, shipment and acceptance', () => {
expect(payableDate({
node_type: 'prepayment',
anchor_date: '2026-09-02',
due_date: '2026-09-02',
})).toBe('2026-09-02');
expect(payableDate({
node_type: 'shipment',
anchor_date: '2026-08-25',
due_date: '2026-08-25',
})).toBe('2026-08-25');
expect(payableDate({
node_type: 'acceptance',
anchor_date: '2026-09-24',
due_date: '2026-09-24',
})).toBe('2026-09-24');
});
});
describe('isNothingToPay', () => {
it('does not treat a zero acceptance or warranty stage as overdue', () => {
// 金额和比例都是 0 时没有应付金额,合同状态不能被这个阶段拉成已逾期。
const acceptance = {
status: 'active',
percentage: '0',
amount: '0.00',
due_date: '2026-09-24',
anchor_date: '2026-09-24',
node_type: 'acceptance',
};
const warranty = {
status: 'active',
percentage: '0',
amount: '0.00',
due_date: '2027-03-23',
anchor_date: '2026-09-24',
node_type: 'warranty',
};
expect(isNothingToPay(acceptance)).toBe(true);
expect(classifyLedgerStageCell(acceptance, 'acceptance', TODAY)).toBe('absent');
expect(aggregateContractNodeStatus([
{ ...acceptance, id: 1 } as never,
{ ...warranty, id: 2 } as never,
{
id: 3,
status: 'paid',
percentage: '50',
amount: '4250.00',
due_date: '2026-09-02',
anchor_date: '2026-09-02',
node_type: 'prepayment',
} as never,
])).toBe('completed');
});
});
@@ -4,6 +4,8 @@
* 依赖:contract-payment.api 的 PaymentNode 类型、浏览器 Date。
* 逻辑:付款节点到期/逾期以节点 due_date 为准;台账状态按节点聚合,供列表页一行一眼看是否逾期。
* 阶段格子的已逾期/即将到期/未到期也走这里,验收款和质保款与预付款、出货款共用同一比较。
* 金额和比例都为 0 的阶段视为无需付款:详情不标已逾期,台账汇总也不把它算进逾期。
* 详情页「预警日期」用 firstRoundAlertDate,与下方第 1 次预警同一天,不直接展示 due_date。
*/
import type { PaymentNode } from '../api/contract-payment.api';
@@ -70,36 +72,92 @@ export function nodeDueReference(node: Pick<PaymentNode, 'due_date' | 'anchor_da
return node.due_date || node.anchor_date || null;
}
/**
* 返回详情页应展示的应付日期。
* 核心逻辑:质保款的应付日是验收归档日加上合同质保期,存在 due_date;没有质保期时不回退验收日。
* 预付款、出货款、验收款的 due_date 就是应付日,缺 due_date 时回退 anchor_date。
* @param node - 付款节点,至少含阶段类型和两个日期。
* @returns 应付日 YYYY-MM-DD;质保款未算出到期日时返回 null。
*/
export function payableDate(
node: Pick<PaymentNode, 'node_type' | 'anchor_date' | 'due_date'>,
): string | null {
const nodeType = String(node.node_type || '').trim().toLowerCase();
if (nodeType === 'warranty') return node.due_date || null;
return node.due_date || node.anchor_date || null;
}
/**
* 判断这一阶段是否没有应付金额。
* 核心逻辑:状态已是无此阶段,或比例和金额都是 0(含空金额)。已付节点不按 0 处理。
* @param node - 付款节点。
* @returns 无需付款时为 true。
*/
export function isNothingToPay(
node: Pick<PaymentNode, 'status' | 'percentage' | 'amount'>,
): boolean {
const status = String(node.status || '').trim().toLowerCase();
if (status === 'not_applicable') return true;
if (status === 'paid') return false;
const percentValue = Number(node.percentage);
const amountValue = Number(node.amount);
return Number.isFinite(percentValue)
&& percentValue === 0
&& (node.amount == null || node.amount === '' || amountValue === 0);
}
/** 各阶段首轮相对锚点的自然日偏移,与后端 alert_service._ALERT_RULES 第一轮一致。 */
const FIRST_ROUND_OFFSET_DAYS: Record<string, number> = {
prepayment: 7,
shipment: -7,
acceptance: 30,
warranty: -7,
};
/**
* 计算详情页应展示的首轮预警日期。
* 核心逻辑:预付款、验收款从 anchor_date 起算(+7 / +30 天);出货款、质保款从 due_date 起算(-7 天)。
* 验收款的 due_date 被写成归档日,不能拿来当预警日期,否则会和「第 1 次预警」相差 30 天。
* @param node - 付款节点,至少含阶段类型和两个日期。
* @returns 首轮计划日 YYYY-MM-DD;缺少对应锚点时返回 null。
*/
export function firstRoundAlertDate(
node: Pick<PaymentNode, 'node_type' | 'anchor_date' | 'due_date'>,
): string | null {
const nodeType = String(node.node_type || '').trim().toLowerCase();
const offset = FIRST_ROUND_OFFSET_DAYS[nodeType];
if (offset == null) return node.due_date || null;
const basis = nodeType === 'shipment' || nodeType === 'warranty'
? node.due_date
: (node.anchor_date || node.due_date);
if (!basis) return null;
const date = new Date(`${basis}T00:00:00Z`);
if (Number.isNaN(date.getTime())) return null;
date.setUTCDate(date.getUTCDate() + offset);
return date.toISOString().slice(0, 10);
}
/** 台账阶段格子的状态:空格、已付、缺日期、已逾期、即将到期、未到期。 */
export type LedgerStageCellKind = 'absent' | 'paid' | 'missing_date' | 'overdue' | 'due' | 'active';
/**
* 判断台账里一个付款阶段格子该显示哪种状态。
* 核心逻辑:无节点、不适用或金额比例都是 0 视为空格。只有预付款和出货款在已付时返回 paid。
* 核心逻辑:无节点、不适用或金额比例都是 0 视为空格。四个阶段在 ERP 对上付款后都返回 paid。
* 其余未付阶段没有日期依据则返回 missing_date;有日期则按业务日比较已逾期、7 日内即将到期或未到期。
* 验收款、质保款与预付款、出货款共用这套日期比较,不因没有付款回写而省略已逾期。
* @param node - 付款节点;该阶段不存在时传 null。
* @param nodeType - 阶段类型,用来区分能否标已付。
* @param _nodeType - 保留给列表调用;已付不再按阶段类型区分。
* @param todayIso - 可选业务日 YYYY-MM-DD。
* @returns 格子状态种类。
*/
export function classifyLedgerStageCell(
node: Pick<PaymentNode, 'status' | 'percentage' | 'amount' | 'due_date' | 'anchor_date'> | null | undefined,
nodeType: string,
_nodeType: string,
todayIso?: string,
): LedgerStageCellKind {
if (!node) return 'absent';
const status = String(node.status || '').trim().toLowerCase();
const percentValue = Number(node.percentage);
const amountValue = Number(node.amount);
const absent = status === 'not_applicable' || (
status !== 'paid'
&& Number.isFinite(percentValue)
&& percentValue === 0
&& (node.amount == null || node.amount === '' || amountValue === 0)
);
if (absent) return 'absent';
if ((nodeType === 'prepayment' || nodeType === 'shipment') && status === 'paid') return 'paid';
if (isNothingToPay(node)) return 'absent';
if (status === 'paid') return 'paid';
const basis = nodeDueReference(node);
if (!basis) return 'missing_date';
if (isNodeOverdue(basis, todayIso)) return 'overdue';
@@ -112,14 +170,17 @@ export type ContractNodeStatusCode = 'active' | 'due' | 'overdue' | 'completed'
/**
* 按付款节点聚合出合同台账的进度/逾期状态。
* 核心逻辑:先在合同层排除「待补充」(非激活或解析待确认);否则若存在未付且已过 due_date 的
* 节点 → 已逾期;存在 7 天内到期 → 即将到期;仍有未付且付款日在 7 日外 → 未到期;全部节点已付 → 已完成。
* 核心逻辑:金额和比例都为 0 的阶段不参与逾期判断。其余进行中节点已过 due_date → 已逾期;
* 存在 7 天内到期 → 即将到期;仍有未付且付款日在 7 日外 → 未到期;全部节点已付 → 已完成。
* @param nodes - 合同的付款节点列表。
* @returns 台账状态编码。
*/
export function aggregateContractNodeStatus(nodes: PaymentNode[]): ContractNodeStatusCode {
if (!nodes || nodes.length === 0) return 'needs_completion';
const active = nodes.filter((n) => String(n.status || '').trim().toLowerCase() === 'active');
const active = nodes.filter((n) => {
const status = String(n.status || '').trim().toLowerCase();
return status === 'active' && !isNothingToPay(n);
});
if (active.length === 0) {
// 无进行中的节点:存在已付则视为整个付款计划已完成,否则判为待补充。
const hasPaid = nodes.some((n) => String(n.status || '').trim().toLowerCase() === 'paid' || !!n.paid_at);
@@ -3,15 +3,18 @@
用途:展示单份采购合同的概览、原文附件、付款计划及企业微信预警审计。
依赖:contract-payment.api、统一消息提示;由 Chat 台账/待确认行点击在当前 Tab 内下钻。
逻辑:以合同 ID 调用已有详情接口,付款任务按节点和预警轮次聚合;原文附件可在线预览 PDF/图片,或继续下载。
待复核合同时,解析提示右侧用主按钮放「人工复核」,弹窗里填写阶段后再进入台账。合同概览和页头其余内容保持原样。
未付的预付款、出货款可在卡片上标为已付,只改这一阶段。
待复核合同时,解析提示右侧用主按钮放「人工复核」,弹窗里填写阶段后再进入台账。
页头主标题展示采购单号,摘要卡第二格展示合同号;采购跟单以采购单号为主标识。
未付的预付款、出货款、验收款、质保款可在卡片上标为已付,只改这一阶段。金额和比例都为 0 的不出现按钮。
付款计划上的应付日期:质保款为验收归档日加合同质保期,其余阶段为各自到期日。
付款计划上的预警日期展示该阶段首轮计划日,与下方第 1 次预警同一天。
-->
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { ArrowLeft, CircleHelp, Download, Eye, FileText, RefreshCw } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import { BusinessError } from '@/shared/api/client';
import { formatLocalDateTime, formatNaiveDate, formatNaiveDateTime } from '@/shared/utils/dateTime';
import { formatLocalDateTime, formatNaiveDate } from '@/shared/utils/dateTime';
import { useMessage } from '@/shared/composables/useMessage';
import {
downloadContractPaymentAttachment,
@@ -23,7 +26,7 @@ import {
type PaymentNode,
} from '../api/contract-payment.api';
import { displayCurrency } from '../utils/currency';
import { isNodeNearDue, isNodeOverdue, nodeDueReference } from '../utils/paymentStatus';
import { firstRoundAlertDate, isNodeNearDue, isNodeOverdue, isNothingToPay, nodeDueReference, payableDate } from '../utils/paymentStatus';
import ContractPaymentManualReviewPage from './ContractPaymentManualReviewPage.vue';
const props = withDefaults(defineProps<{
@@ -83,14 +86,14 @@ function displayNodeType(nodeType: string): string {
}
/**
* 格式化预警计划日期为原墙面时钟的 YYYY-MM-DD HH:mm:ss。
* 核心逻辑:scheduled_at 是业务日期(节点触发日)与零点组合的墙面时钟,不做时区换算,
* 避免把「8 月 22 日触发」误显示为次日;空值回退 '—',非法日期回退原值以便排障。
* 格式化预警计划日期为 YYYY-MM-DD。
* 核心逻辑:scheduled_at 是业务日期与零点拼成的墙面时钟,页面只展示日期,不带 00:00:00。
* 不做时区换算,避免把触发日显示成次日;空值回退 '—'。
* @param iso - 后端返回的 ISO 计划日期字符串。
* @returns 墙面时钟时间文本。
* @returns 日期文本。
*/
function displayScheduledAt(iso?: string | null): string {
return iso ? formatNaiveDateTime(iso) : '—';
return iso ? formatNaiveDate(iso) : '—';
}
/**
@@ -119,23 +122,25 @@ function displayContractState(state?: string | null): string {
/**
* 返回付款节点的展示预警日期。
* 核心逻辑:预付款为“归档日 +7/14/21 天”多轮规则,节点不存单一 due_date;
* 有 due_date 时原样展示,否则对预付款按首轮(归档日 +7 天)推算并标注“首轮”,避免空“预警日期”误导。
* 核心逻辑:四个阶段都展示首轮计划日并标注「首轮」,与卡片下方「第 1 次预警」同一天。
* 不用 due_date 原文:验收款的 due_date 等于归档日,直接展示会和首轮相差 30 天。
* @param node - 当前付款节点。
* @returns 用户可见的预警日期文本;无依据时返回 '—'。
*/
function displayAlertDate(node: PaymentNode): string {
// 预付款优先按「归档日 +7 天首轮」展示预警日期,与 due_date(仅用于到期/逾期判断)解耦。
// 预付款的 due_date = 合同归档日期,若直接走下面的 due_date 分支会丢失「首轮 +7」信息。
if (node.node_type === 'prepayment' && node.anchor_date) {
const anchor = new Date(`${node.anchor_date}T00:00:00Z`);
if (!Number.isNaN(anchor.getTime())) {
anchor.setUTCDate(anchor.getUTCDate() + 7);
return `${t('admin.contractPayment.alertFirstRound')} ${anchor.toISOString().slice(0, 10)}`;
}
}
if (node.due_date) return node.due_date;
return '—';
const firstRound = firstRoundAlertDate(node);
if (!firstRound) return '—';
return `${t('admin.contractPayment.alertFirstRound')} ${firstRound}`;
}
/**
* 返回付款节点的应付日期。
* 核心逻辑:质保款展示验收归档日加质保期;其余阶段展示到期日。没有算出质保到期日时显示横线。
* @param node - 当前付款节点。
* @returns 用户可见的应付日期;缺失时返回 '—'。
*/
function displayPayableDate(node: PaymentNode): string {
return payableDate(node) || '—';
}
/**
@@ -153,16 +158,18 @@ const currentActiveNodeId = computed(() => {
/**
* 推导付款节点的展示状态与时间线色调。
* 核心逻辑:已付/待复核/无此阶段沿用后端明确状态;未完成时按“无到期事实→待起算、临近到期→即将到期、
* 当前阶段→进行中、其余→待处理”分层,避免同页多阶段都误标为进行中。
* 核心逻辑:已付/待复核沿用后端状态;金额和比例都为 0 时显示无此阶段,不因日期已过标已逾期。
* 其余未完成阶段按无到期事实、临近到期、进行中、待处理分层。
* @param node - 当前付款节点。
* @returns 用户可见的状态文本与对应色调。
*/
function nodeStatusInfo(node: PaymentNode): { label: string; tone: 'paid' | 'current' | 'due' | 'overdue' | 'pending' | 'review' } {
const state = String(node.status || '').trim().toLowerCase();
if (state === 'paid') return { label: t('admin.contractPayment.nodeStatus.paid'), tone: 'paid' };
if (state === 'not_applicable') return { label: t('admin.contractPayment.nodeStatus.notApplicable'), tone: 'pending' };
if (state === 'needs_review') return { label: t('admin.contractPayment.nodeStatus.review'), tone: 'review' };
if (state === 'not_applicable' || isNothingToPay(node)) {
return { label: t('admin.contractPayment.nodeStatus.notApplicable'), tone: 'pending' };
}
const isCurrent = node.id === currentActiveNodeId.value;
if (!node.due_date && !node.anchor_date) return { label: t('admin.contractPayment.nodeStatus.notStarted'), tone: 'pending' };
// 到期/逾期判断:以「due_date || anchor_date」为基准;历史合同预付款可能只有 anchor_date(归档日),
@@ -190,14 +197,13 @@ function nodePayDateText(node: PaymentNode): string {
/**
* 判断这一阶段能否手动标为已付。
* 核心逻辑:只有未付的预付款、出货款出现按钮;验收款、质保款和已付阶段不出现。
* 核心逻辑:四个阶段只要还是未付且有应付金额,就出现按钮。已付、无此阶段、金额和比例都为 0 的不出现。
* @param node - 当前付款节点。
* @returns 是否显示「标为已付」。
*/
function canMarkPaid(node: PaymentNode): boolean {
const type = String(node.node_type || '').toLowerCase();
const state = String(node.status || '').toLowerCase();
return (type === 'prepayment' || type === 'shipment') && state === 'active';
return state === 'active' && !isNothingToPay(node);
}
/**
@@ -411,7 +417,7 @@ onBeforeUnmount(() => closeAttachmentPreview());
<section class="section-gap contract-detail animate-fade-in-up">
<header class="mb-5 flex items-start justify-between gap-3">
<div v-if="contract" class="min-w-0">
<h2 class="text-2xl font-bold text-primary">{{ contract.contract_no || t('admin.contractPayment.contractNoPending') }}</h2>
<h2 class="text-2xl font-bold text-primary">{{ contract.purchase_order_no || '—' }}</h2>
<p class="mt-1 text-sm text-muted">{{ contract.supplier_name || '—' }}</p>
</div>
<div class="flex shrink-0 gap-2"><button class="btn-secondary-ds" :disabled="reparsing" @click="reparseContract"><RefreshCw class="h-4 w-4" :class="{ 'animate-spin': reparsing }" />{{ t('admin.contractPaymentReparse.action') }}</button><button class="btn-secondary-ds" @click="backToLedger"><ArrowLeft class="h-4 w-4" />{{ t('admin.contractPayment.backToLedger') }}</button></div>
@@ -422,7 +428,7 @@ onBeforeUnmount(() => closeAttachmentPreview());
<div class="detail-summary-grid">
<div class="detail-summary-card"><span>{{ t('admin.contractPayment.amount') }}</span><strong>{{ contract.total_amount || '—' }}<template v-if="displayCurrency(contract.currency)"> {{ displayCurrency(contract.currency) }}</template></strong></div>
<div class="detail-summary-card"><span>{{ t('admin.contractPayment.purchaseOrder') }}</span><strong>{{ contract.purchase_order_no || '—' }}</strong></div>
<div class="detail-summary-card"><span>{{ t('admin.contractPayment.contractNo') }}</span><strong>{{ contract.contract_no || t('admin.contractPayment.contractNoPending') }}</strong></div>
<div class="detail-summary-card"><span>{{ t('admin.contractPayment.workflowNo') }}</span><strong>{{ contract.workflow_no || '—' }}</strong></div>
<div class="detail-summary-card"><span>{{ t('admin.contractPayment.applicant') }}</span><strong>{{ contract.applicant_name || '—' }}</strong></div>
</div>
@@ -472,9 +478,9 @@ onBeforeUnmount(() => closeAttachmentPreview());
<div class="flex flex-wrap items-center justify-between gap-2"><strong>{{ displayNodeType(node.node_type) }} · <template v-if="String(node.status || '').toLowerCase() === 'not_applicable'">—</template><template v-else>{{ node.amount || '—' }} / {{ displayPercentage(node.percentage) }}%</template></strong><span class="node-status" :class="`status-${nodeStatusInfo(node).tone}`">{{ nodeStatusInfo(node).label }}</span></div>
<p class="payment-node-pay-line">{{ t('admin.contractPayment.payDate') }}:{{ nodePayDateText(node) }}</p>
<p v-if="node.paid_source === 'manual'" class="payment-node-pay-line text-emerald-700">{{ t('admin.contractPayment.markPaidSource') }}</p>
<p>{{ t('admin.contractPayment.anchorDate') }}:{{ node.anchor_date || '—' }} · {{ t('admin.contractPayment.alertDate') }}:{{ displayAlertDate(node) }}</p>
<p>{{ t('admin.contractPayment.payableDate') }}:{{ displayPayableDate(node) }} · {{ t('admin.contractPayment.alertDate') }}:{{ displayAlertDate(node) }}</p>
<button v-if="canMarkPaid(node)" class="mt-2 text-sm font-bold text-[#2875d5]" type="button" @click="openMarkPaid(node)">{{ t('admin.contractPayment.markPaid') }}</button>
<div v-if="alertsForNode(node).length" class="node-alert-list"><span v-for="alert in alertsForNode(node)" :key="alert.id">{{ t('admin.contractPayment.alertRound', { round: alert.alert_round }) }} · {{ displayScheduledAt(alert.scheduled_at) }} · {{ displayAlertStatus(alert.status) }}</span></div>
<div v-if="alertsForNode(node).length && !isNothingToPay(node)" class="node-alert-list"><span v-for="alert in alertsForNode(node)" :key="alert.id">{{ t('admin.contractPayment.alertRound', { round: alert.alert_round }) }} · {{ displayScheduledAt(alert.scheduled_at) }} · {{ displayAlertStatus(alert.status) }}</span></div>
</div>
</div>
</section>
@@ -3,7 +3,8 @@
用途:合同付款预警台账列表、汇总卡与本周待发送摘要。
依赖:contract-payment.api、PaginationBar、统一消息提示。
逻辑:Chat Tab 以 embedded 嵌入时隐藏页头;点行通过 open-detail 交给父级下钻详情;关键词可搜合同号、流程号、采购单号、供应商和申请人。
四阶段列只显示阶段名。预付款、出货款按 ERP 付款事实标已付;未付时与验收款、质保款一样按日期依据标已逾期、即将到期或未到期。
台账标识列只展示采购单号和供应商,不展示合同号。
四阶段列只显示阶段名。四个阶段按 ERP 付款事实标已付;未付时按日期依据标已逾期、即将到期或未到期。
验收款、质保款没有付款回写,不标已付。没有日期依据时按阶段说明原因,例如验收单未归档、质保到期日未定。
嵌入布局为上半汇总卡/搜索与底部分页固定,仅表格区域双向滚动;汇总卡采用紧凑尺寸以留出小屏列表高度。
-->
@@ -64,7 +65,7 @@ type StagePayTone = '' | 'paid' | 'overdue' | 'due' | 'normal';
/**
* 组装一个付款阶段格子:金额比例、日期,以及这一格的状态。
* 核心逻辑:状态种类交给 classifyLedgerStageCell。预付款、出货款已付显示付款日。
* 未付的四个阶段都按日期依据标已逾期、即将到期或未到期。验收款、质保款不标已付。
* 未付的四个阶段都按日期依据标已逾期、即将到期或未到期。验收款、质保款对上 ERP 后也标已付。
* 没有日期依据时按阶段写明原因,悬停可看说明。无此阶段或金额比例都是 0 时显示横线。
* @param item - 合同台账行。
* @param name - 付款节点类型。
@@ -257,13 +258,13 @@ onMounted(() => void load());
<div class="surface-panel contract-ledger-panel contract-scroll-panel min-h-0 flex-1">
<table class="contract-ledger-table text-sm">
<thead><tr>
<th>{{ t('admin.contractPayment.contractSupplier') }}</th><th>{{ t('admin.contractPayment.amount') }}</th>
<th>{{ t('admin.contractPayment.purchaseOrderSupplier') }}</th><th>{{ t('admin.contractPayment.amount') }}</th>
<th v-for="nodeType in stageTypes" :key="nodeType">{{ t(`admin.contractPayment.nodeType.${nodeType}`) }}</th>
<th>{{ t('admin.contractPayment.applicant') }}</th><th>{{ t('admin.contractPayment.statusLabel') }}</th>
</tr></thead>
<tbody>
<tr v-for="item in contracts" :key="item.id" class="contract-ledger-row" @click="openContractDetail(item.id)">
<td class="contract-identify"><strong>{{ t('admin.contractPayment.contractPrefix') }}:{{ item.contract_no || t('admin.contractPayment.contractNoPending') }}</strong><span>{{ t('admin.contractPayment.purchaseOrder') }}:{{ item.purchase_order_no || '—' }}</span><span>{{ item.supplier_name || '—' }}</span></td>
<td class="contract-identify"><strong>{{ item.purchase_order_no || '—' }}</strong><span>{{ item.supplier_name || '—' }}</span></td>
<td class="contract-money">{{ item.total_amount || '—' }}<span v-if="displayCurrency(item.currency)"> {{ displayCurrency(item.currency) }}</span></td>
<td v-for="nodeType in stageTypes" :key="nodeType" class="contract-payment-cell"><template v-if="paymentCell(item, nodeType).amountRatio !== '—'"><strong>{{ paymentCell(item, nodeType).amountRatio }}</strong><span :class="{ 'contract-date-pending': paymentCell(item, nodeType).missingDate }" :title="paymentCell(item, nodeType).dateTitle || undefined">{{ paymentCell(item, nodeType).dateText }}</span><span v-if="paymentCell(item, nodeType).payLabel" class="stage-pay-tag" :class="paymentCell(item, nodeType).payTone">{{ paymentCell(item, nodeType).payLabel }}</span></template><span v-else>—</span></td>
<td class="contract-applicant">{{ item.applicant_name || '—' }}</td>
@@ -2,7 +2,9 @@
* features/equipment-acceptance/api/equipment-acceptance.api.ts
* 用途:设备验收预警同步列表、详情和手动同步。
* 依赖:统一 requestJson;后端 /api/equipment-acceptance。
* 逻辑:Chat 作业面调用。同步只读 E10。配置只保存天数和系统用户,不保存发送时刻。
* 逻辑:Chat 作业面调用。同步同时读 E10 和 E8,列表用来源字段区分。
* 停留列表的 keyword 同时查流程编号、验收单号、采购单号,applicant 只查申请人。
* 配置只保存天数和系统用户,不保存发送时刻。
* 保存配置自行声明 Content-Type: application/json,供 Flask get_json 解析。
* 发送记录只读已落库的行。每位收件人的 Excel 可再下载。
*/
@@ -23,7 +25,15 @@ export interface EquipmentAcceptanceOperator {
export interface EquipmentAcceptanceOrder {
id: number;
/** 来源。e10 或 e8。旧数据未返回时为空。 */
oa_system?: string | null;
acceptance_no?: string | null;
/** 流程编号。E10 为 requestmark,E8 为 lcbh。 */
flow_no?: string | null;
/** 流程标题。两边都是流程表 requestname。 */
request_title?: string | null;
/** 流程创建时间。E10 为 createdatetime,E8 为 createdate 加 createtime。 */
request_created_at?: string | null;
purchase_order_no?: string | null;
contract_no?: string | null;
timer_started_at?: string | null;
@@ -72,19 +82,27 @@ export interface EquipmentAcceptanceSyncResult {
/**
* 分页查询已同步的验收单。
* 核心逻辑:focus 对应原型分组。空或 all 不过滤。
* 核心逻辑:focus 对应状态分组。keyword 同时匹配流程编号、验收单号、采购单号。applicant 只匹配申请人。空值不传。
* @param params.focus - watching、overdue、stopped、not_started
* @param params.keyword - 三种单号的包含匹配
* @param params.applicant - 申请人姓名的包含匹配
* @param params.page - 页码,从 1 开始
* @param params.pageSize - 每页条数
* @returns 分页快照和全部单据汇总
* @returns 分页快照和汇总。汇总不看状态分组,但跟着单号和申请人走
*/
export function listEquipmentAcceptanceOrders(params?: {
focus?: string;
keyword?: string;
applicant?: string;
page?: number;
pageSize?: number;
}) {
const query = new URLSearchParams();
if (params?.focus && params.focus !== 'all') query.set('focus', params.focus);
const keyword = params?.keyword?.trim();
const applicant = params?.applicant?.trim();
if (keyword) query.set('keyword', keyword);
if (applicant) query.set('applicant', applicant);
if (params?.page) query.set('page', String(params.page));
if (params?.pageSize) query.set('page_size', String(params.pageSize));
const suffix = query.toString() ? `?${query.toString()}` : '';
@@ -1,19 +1,30 @@
<!--
features/equipment-acceptance/components/EquipmentAcceptanceChatPanel.vue
用途:设备验收预警 Chat 主区:停留列表、详情、发送记录、预警配置,以及管理员同步、扫描和发送。
依赖:停留列表、详情、发送记录、配置页、auth.store、equipment-acceptance.api、DeleteConfirmDialog、vue-router query。
依赖:停留列表、详情、发送记录、配置页、Element Plus、auth.store、equipment-acceptance.api、vue-router query。
逻辑:由 ChatViewContent 在 agent_code=equipment_acceptance 时替换消息列表与输入框。
本文件引入 Element 样式并包住 ElConfigProvider。标题和页签压到两行,下面整块留给当前页。
view=config 打开预警配置;view=sends 打开发送记录;orderId 只在停留列表下钻。
同步只在停留列表。扫描和发送只在发送记录,且仅平台管理员可见。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { RefreshCw } from 'lucide-vue-next';
import { Refresh } from '@element-plus/icons-vue';
import { useI18n } from 'vue-i18n';
import {
ElButton,
ElConfigProvider,
ElMessageBox,
ElTabPane,
ElTabs,
} from 'element-plus';
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import { BusinessError } from '@/shared/api/client';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import { useAuthStore } from '@/features/auth/stores/auth.store';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import { useMessage } from '@/shared/composables/useMessage';
import {
scanEquipmentAcceptanceAlerts,
@@ -32,9 +43,9 @@ const route = useRoute();
const router = useRouter();
const auth = useAuthStore();
const msg = useMessage();
const { elementLocale } = useElementProvider();
const syncing = ref(false);
const alertRunning = ref(false);
const pendingAlert = ref<'scan' | 'send' | null>(null);
const runningAction = ref<'scan' | 'send' | null>(null);
const listPage = ref<{ reload: () => Promise<void> } | null>(null);
const sendsPage = ref<{ reload: () => Promise<void> } | null>(null);
@@ -44,17 +55,6 @@ const activeView = computed<WorkspaceView>(() => {
if (route.query.view === 'sends') return 'sends';
return 'ledger';
});
const showAlertConfirm = computed({
get: () => pendingAlert.value !== null,
set: (open: boolean) => {
if (!open) pendingAlert.value = null;
},
});
const alertConfirmCopy = computed(() => (
pendingAlert.value === 'send'
? { title: t('admin.equipmentAcceptance.sendAlerts'), message: t('admin.equipmentAcceptance.sendConfirm') }
: { title: t('admin.equipmentAcceptance.scanAlerts'), message: t('admin.equipmentAcceptance.scanConfirm') }
));
const detailId = computed(() => {
if (activeView.value !== 'ledger') return null;
const raw = Number(route.query.orderId);
@@ -97,23 +97,33 @@ function selectView(view: WorkspaceView): void {
}
/**
* 管理员在发送记录页立即扫描或发送。
* 核心逻辑:公共确认框点确定后才调用。先取出动作再关掉弹窗,避免关闭时把待执行动作清掉。
* 只接受本页三个页签,避免 Element 回传任意字符串。
* @param name - 被点中的页签名
*/
function confirmAlertAction(): void {
const action = pendingAlert.value;
pendingAlert.value = null;
if (action) void runAlertAction(action);
function onTabChange(name: string | number): void {
if (name === 'ledger' || name === 'sends' || name === 'config') selectView(name);
}
/**
* 执行已经确认的扫描或发送。
* 核心逻辑:扫描会同步 E10;发送把待发送记录推到企业微信。
* 管理员在发送记录页确认后立即扫描或发送。
* 核心逻辑:确认框取消会拒绝,这里直接返回。扫描会同步 E10;发送把待发送记录推到企业微信。
* @param action - scan 或 send
*/
async function runAlertAction(action: 'scan' | 'send'): Promise<void> {
if (alertRunning.value) return;
alertRunning.value = true;
async function askAlert(action: 'scan' | 'send'): Promise<void> {
if (runningAction.value) return;
const copy = action === 'send'
? { title: t('admin.equipmentAcceptance.sendAlerts'), message: t('admin.equipmentAcceptance.sendConfirm') }
: { title: t('admin.equipmentAcceptance.scanAlerts'), message: t('admin.equipmentAcceptance.scanConfirm') };
try {
await ElMessageBox.confirm(copy.message, copy.title, {
type: 'warning',
confirmButtonText: t('common.deleteDialog.confirm'),
cancelButtonText: t('common.cancel'),
});
} catch {
return;
}
runningAction.value = action;
try {
if (action === 'scan') {
const result = await scanEquipmentAcceptanceAlerts();
@@ -133,12 +143,12 @@ async function runAlertAction(action: 'scan' | 'send'): Promise<void> {
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.syncFailed'));
} finally {
alertRunning.value = false;
runningAction.value = null;
}
}
/**
* 管理员从 E10 同步后刷新列表。
* 管理员从 OA 同步后刷新列表。
* 核心逻辑:成功提示写入、跳过和本次未见条数。失败展示业务错误。
*/
async function runSync(): Promise<void> {
@@ -161,65 +171,107 @@ async function runSync(): Promise<void> {
</script>
<template>
<section class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[var(--surface-muted,#f4f7fb)]">
<div class="flex flex-wrap items-center justify-between gap-2 px-5 pt-3">
<div class="min-w-0">
<h1 class="text-lg font-bold text-primary md:text-xl">{{ t('admin.equipmentAcceptance.title') }}</h1>
<ElConfigProvider :locale="elementLocale">
<section class="ea-workspace">
<header class="ea-workspace__bar">
<h1 class="section-title">{{ t('admin.equipmentAcceptance.title') }}</h1>
<div v-if="isAdmin && activeView === 'sends'" class="ea-workspace__actions">
<ElButton :loading="runningAction === 'scan'" :disabled="runningAction !== null" @click="askAlert('scan')">
{{ t('admin.equipmentAcceptance.scanAlerts') }}
</ElButton>
<ElButton :loading="runningAction === 'send'" :disabled="runningAction !== null" @click="askAlert('send')">
{{ t('admin.equipmentAcceptance.sendAlerts') }}
</ElButton>
</div>
<ElButton
v-else-if="isAdmin && activeView === 'ledger' && !detailId"
:icon="Refresh"
:loading="syncing"
@click="runSync"
>
{{ t('admin.equipmentAcceptance.sync') }}
</ElButton>
</header>
<ElTabs :model-value="activeView" class="ea-tabs" @tab-change="onTabChange">
<ElTabPane v-for="tab in tabs" :key="tab.key" :name="tab.key" :label="tab.label" />
</ElTabs>
<div class="ea-workspace__body">
<EquipmentAcceptanceDetailPage
v-if="detailId"
:order-id="detailId"
@back="syncQuery('ledger', null)"
/>
<EquipmentAcceptanceConfigPage
v-else-if="activeView === 'config'"
:editable="isAdmin"
/>
<EquipmentAcceptanceSendsPage v-else-if="activeView === 'sends'" ref="sendsPage" />
<EquipmentAcceptancePage
v-else
ref="listPage"
@open-detail="syncQuery('ledger', $event)"
/>
</div>
<div v-if="isAdmin && activeView === 'sends'" class="flex flex-wrap items-center gap-2">
<button class="btn-secondary-ds" type="button" :disabled="alertRunning" @click="pendingAlert = 'scan'">
{{ t('admin.equipmentAcceptance.scanAlerts') }}
</button>
<button class="btn-secondary-ds" type="button" :disabled="alertRunning" @click="pendingAlert = 'send'">
{{ t('admin.equipmentAcceptance.sendAlerts') }}
</button>
</div>
<button
v-if="isAdmin && activeView === 'ledger' && !detailId"
class="btn-secondary-ds"
type="button"
:disabled="syncing"
@click="runSync"
>
<RefreshCw class="h-4 w-4" aria-hidden="true" />{{ t('admin.equipmentAcceptance.sync') }}
</button>
</div>
<div class="mt-2 flex gap-0 border-b border-default px-5">
<button
v-for="tab in tabs"
:key="tab.key"
type="button"
class="mb-[-1px] border-b-2 px-3 py-2 text-sm font-bold"
:class="activeView === tab.key
? 'border-brand-500 text-brand-600'
: 'border-transparent text-muted hover:text-secondary'"
@click="selectView(tab.key)"
>
{{ tab.label }}
</button>
</div>
<EquipmentAcceptanceDetailPage
v-if="detailId"
:order-id="detailId"
@back="syncQuery('ledger', null)"
/>
<EquipmentAcceptanceConfigPage
v-else-if="activeView === 'config'"
:editable="isAdmin"
/>
<EquipmentAcceptanceSendsPage v-else-if="activeView === 'sends'" ref="sendsPage" />
<EquipmentAcceptancePage
v-else
ref="listPage"
@open-detail="syncQuery('ledger', $event)"
/>
<DeleteConfirmDialog
v-if="isAdmin"
v-model="showAlertConfirm"
:title="alertConfirmCopy.title"
:message="alertConfirmCopy.message"
confirm-tone="primary"
@confirm="confirmAlertAction"
/>
</section>
</section>
</ElConfigProvider>
</template>
<style scoped>
.ea-workspace {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-height: 0;
min-width: 0;
overflow: hidden;
background: var(--surface-muted, var(--el-fill-color-light));
}
.ea-workspace__bar {
display: flex;
flex: none;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 8px 16px 0;
}
.ea-workspace__actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.ea-tabs {
flex: none;
padding: 0 8px;
}
.ea-tabs :deep(.el-tabs__header) {
margin-bottom: 0;
}
.ea-tabs :deep(.el-tabs__nav-wrap::after) {
height: 1px;
background: var(--el-border-color-lighter);
}
.ea-tabs :deep(.el-tabs__content) {
display: none;
}
.ea-tabs :deep(.el-tabs__item) {
height: 36px;
padding: 0 12px;
font-size: var(--el-font-size-base);
line-height: 36px;
}
.ea-workspace__body {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-height: 0;
padding: 8px 12px 12px;
}
</style>
@@ -0,0 +1,41 @@
/**
* features/equipment-acceptance/composables/useFillHeight.ts
* 用途:把 Element 表格高度收成容器剩余像素,表头固定、表体在卡片内滚动。
* 依赖:vue。
* 逻辑:停留列表和发送记录把表格外包一层,本函数监听该层高度并回写给 ElTable 的 height。
*/
import { onBeforeUnmount, onMounted, ref, type Ref } from 'vue';
/**
* 读取容器当前高度,供 ElTable 占满剩余区域。
* 核心逻辑:容器由 flex 撑开,表格再用同样的像素高度内部滚动,避免整页把表头卷走。
* @param host - 表格外层,高度应等于剩余视口
* @returns height 为不小于 160 的像素高度
*/
export function useFillHeight(host: Ref<HTMLElement | null>): { height: Ref<number> } {
const height = ref(240);
let observer: ResizeObserver | null = null;
/**
* 用容器客户区高度更新表格。容器尚未挂上时跳过。
*/
function measure(): void {
const el = host.value;
if (!el) return;
height.value = Math.max(160, Math.floor(el.clientHeight));
}
onMounted(() => {
measure();
if (typeof ResizeObserver === 'undefined' || !host.value) return;
observer = new ResizeObserver(() => measure());
observer.observe(host.value);
});
onBeforeUnmount(() => {
observer?.disconnect();
observer = null;
});
return { height };
}
@@ -1,13 +1,20 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptanceConfigPage.vue
用途:设备验收预警配置页。按升级轮次编辑天数、第 4 轮开关和三个固定岗位。
依赖:equipment-acceptance.api、UserPickerDialog、userPicker.utils、vue-i18n。
逻辑:由 Chat 作业面的「预警配置」Tab 嵌入。同一岗位在多个轮次里共用一个人。
发送时刻不在本页,由排程 Cron 配置。非管理员只能查看。
依赖:equipment-acceptance.api、Element Plus、UserPickerDialog、userPicker.utils、vue-i18n。
逻辑:由 Chat 作业面的「预警配置」Tab 嵌入。样式和 ElConfigProvider 由作业面提供。
同一岗位在多个轮次里共用一个人。发送时刻不在本页,由排程 Cron 配置。非管理员只能查看。
-->
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import {
ElButton,
ElCard,
ElCheckbox,
ElInputNumber,
ElLoading,
} from 'element-plus';
import { BusinessError } from '@/shared/api/client';
import UserPickerDialog from '@/shared/components/UserPickerDialog.vue';
import { useMessage } from '@/shared/composables/useMessage';
@@ -60,6 +67,7 @@ const ROUNDS: Array<{ index: number; lines: RoundLine[] }> = [
const { t } = useI18n();
const msg = useMessage();
const vLoading = ElLoading.directive;
const loading = ref(false);
const saving = ref(false);
const days = ref<number[]>([30, 37, 44, 51]);
@@ -224,100 +232,74 @@ onMounted(() => {
</script>
<template>
<section class="min-h-0 flex-1 overflow-auto px-5 pb-6 pt-3">
<p class="mb-3 text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.configLead') }}</p>
<p v-if="loading" class="text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.loading') }}</p>
<template v-else>
<section class="overflow-hidden rounded-2xl border border-[#dce4ef] bg-white">
<div class="px-5 pb-2 pt-4">
<h2 class="text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.configSheetTitle') }}</h2>
<p class="mt-1 text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.configSheetLead') }}</p>
<section v-loading="loading" class="ea-scroll">
<p class="ea-lead">{{ t('admin.equipmentAcceptance.configLead') }}</p>
<ElCard v-if="!loading" shadow="never" class="ea-config-card">
<template #header>
<h2 class="ea-card-title">{{ t('admin.equipmentAcceptance.configSheetTitle') }}</h2>
<p class="ea-lead">{{ t('admin.equipmentAcceptance.configSheetLead') }}</p>
</template>
<article
v-for="round in ROUNDS"
:key="round.index"
class="ea-round"
:class="round.index === ROUNDS.length - 1 ? 'ea-round--last' : ''"
>
<div class="ea-round__when">
<b>{{ t('admin.equipmentAcceptance.roundName', { n: round.index + 1 }) }}</b>
<label class="ea-days">
{{ t('admin.equipmentAcceptance.overPrefix') }}
<ElInputNumber
v-model="days[round.index]"
:min="1"
:step="1"
:precision="0"
:disabled="!editable"
controls-position="right"
/>
{{ t('admin.equipmentAcceptance.dayUnit') }}
</label>
<template v-if="round.index === 3">
<ElCheckbox v-model="round4Enabled" :disabled="!editable">
{{ t('admin.equipmentAcceptance.round4Enabled') }}
</ElCheckbox>
<p class="ea-lead">{{ t('admin.equipmentAcceptance.round4ShortHint') }}</p>
</template>
</div>
<div class="px-3 pb-2">
<article
v-for="round in ROUNDS"
:key="round.index"
class="relative ml-4 grid grid-cols-1 gap-3 border-l-2 border-[#c9d4e3] py-4 pl-7 sm:grid-cols-[168px_minmax(0,1fr)] sm:gap-x-5"
:class="round.index === ROUNDS.length - 1 ? 'border-transparent' : ''"
>
<span class="absolute -left-[7px] top-6 h-3 w-3 rounded-full border-2 border-white bg-[#1d4e89] shadow-[0_0_0_1px_#c9d4e3]"></span>
<div class="flex flex-col gap-2">
<b class="text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.roundName', { n: round.index + 1 }) }}</b>
<label class="flex items-center gap-2 text-[13px] text-[#64748b]">
{{ t('admin.equipmentAcceptance.overPrefix') }}
<input
v-model.number="days[round.index]"
class="h-10 w-[72px] rounded-lg border border-[#d5dee8] bg-[#f8fafc] text-center text-[22px] font-semibold text-[#142033] disabled:opacity-70"
type="number"
min="1"
:disabled="!editable"
/>
{{ t('admin.equipmentAcceptance.dayUnit') }}
</label>
<template v-if="round.index === 3">
<label class="flex items-center gap-1.5 text-[13px] font-bold text-[#142033]">
<input v-model="round4Enabled" class="h-4 w-4 accent-[#1d4e89]" type="checkbox" :disabled="!editable" />
{{ t('admin.equipmentAcceptance.round4Enabled') }}
</label>
<small class="text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.round4ShortHint') }}</small>
<div class="ea-round__who" :class="round.index === 3 && !round4Enabled ? 'is-muted' : ''">
<div v-for="(line, lineIndex) in round.lines" :key="`${round.index}-${lineIndex}`" class="ea-line">
<span class="ea-line__tag">{{ t(`admin.equipmentAcceptance.${line.tag}`) }}</span>
<div class="ea-line__body">
<template v-if="line.kind === 'plain'">
<p class="ea-line__text">{{ t(`admin.equipmentAcceptance.${line.text}`) }}</p>
<p v-if="line.note" class="ea-lead">{{ t(`admin.equipmentAcceptance.${line.note}`) }}</p>
</template>
</div>
<div class="flex flex-col gap-2" :class="round.index === 3 && !round4Enabled ? 'opacity-45' : ''">
<div v-for="(line, lineIndex) in round.lines" :key="`${round.index}-${lineIndex}`" class="flex items-start gap-2.5">
<span class="mt-1.5 w-9 shrink-0 text-xs font-bold text-[#64748b]">{{ t(`admin.equipmentAcceptance.${line.tag}`) }}</span>
<div class="min-w-0">
<template v-if="line.kind === 'plain'">
<p class="mt-1 text-sm font-semibold text-[#142033]">{{ t(`admin.equipmentAcceptance.${line.text}`) }}</p>
<p v-if="line.note" class="mt-1 text-xs text-[#94a3b8]">{{ t(`admin.equipmentAcceptance.${line.note}`) }}</p>
</template>
<div v-else class="flex flex-wrap gap-2">
<div
v-for="role in line.roles"
:key="role"
class="flex min-h-8 items-center gap-2 rounded-full bg-[#eef3f8] py-1 pl-1 pr-2"
>
<span class="grid h-6 w-6 place-items-center rounded-full bg-[#d7e4f2] text-xs font-bold text-[#1d4e89]">{{ roleInitial(role) }}</span>
<span class="flex flex-col leading-tight">
<strong class="text-[13px] text-[#142033]">{{ roleName(role) || t('admin.equipmentAcceptance.roleEmpty') }}</strong>
<span class="text-[11px] text-[#64748b]">{{ roleMeta(role) }}</span>
</span>
<button
v-if="editable"
class="text-xs font-bold text-[#1d4e89]"
type="button"
@click="openPicker(role)"
>
{{ roleIds[role] ? t('admin.equipmentAcceptance.replaceUser') : t('admin.equipmentAcceptance.selectUser') }}
</button>
<button
v-if="editable && roleIds[role]"
class="text-xs text-[#64748b]"
type="button"
@click="clearRole(role)"
>
{{ t('admin.equipmentAcceptance.clearUser') }}
</button>
</div>
</div>
<div v-else class="ea-people">
<div v-for="role in line.roles" :key="role" class="ea-person">
<span class="ea-person__avatar">{{ roleInitial(role) }}</span>
<span class="ea-person__text">
<strong>{{ roleName(role) || t('admin.equipmentAcceptance.roleEmpty') }}</strong>
<span>{{ roleMeta(role) }}</span>
</span>
<ElButton v-if="editable" link type="primary" @click="openPicker(role)">
{{ roleIds[role] ? t('admin.equipmentAcceptance.replaceUser') : t('admin.equipmentAcceptance.selectUser') }}
</ElButton>
<ElButton v-if="editable && roleIds[role]" link @click="clearRole(role)">
{{ t('admin.equipmentAcceptance.clearUser') }}
</ElButton>
</div>
</div>
</div>
</article>
</div>
</div>
<div class="flex items-center justify-between gap-4 border-t border-[#dce4ef] bg-[#fafbfd] px-5 py-3.5">
<span class="text-xs text-[#64748b]">{{ editable ? t('admin.equipmentAcceptance.configSaveHint') : t('admin.equipmentAcceptance.configReadOnly') }}</span>
<button
v-if="editable"
class="h-9 rounded-lg bg-[#1d4e89] px-4 text-[13px] font-bold text-white disabled:opacity-50"
type="button"
:disabled="saving"
@click="save"
>
{{ t('admin.equipmentAcceptance.saveConfig') }}
</button>
</div>
</section>
</template>
</article>
<div class="ea-config-foot">
<span>{{ editable ? t('admin.equipmentAcceptance.configSaveHint') : t('admin.equipmentAcceptance.configReadOnly') }}</span>
<ElButton v-if="editable" type="primary" :loading="saving" @click="save">
{{ t('admin.equipmentAcceptance.saveConfig') }}
</ElButton>
</div>
</ElCard>
<UserPickerDialog
v-model="pickerOpen"
@@ -329,3 +311,166 @@ onMounted(() => {
/>
</section>
</template>
<style scoped>
.ea-scroll {
flex: 1 1 auto;
min-height: 240px;
overflow: auto;
}
.ea-lead {
margin: 0;
font-size: var(--el-font-size-extra-small);
line-height: 1.4;
color: var(--el-text-color-secondary);
}
.ea-scroll > .ea-lead {
margin-bottom: 8px;
}
.ea-config-card :deep(.el-card__header) {
padding: 12px 16px 8px;
}
.ea-config-card :deep(.el-card__body) {
padding: 0 16px 12px;
}
.ea-card-title {
margin: 0 0 4px;
font-size: var(--el-font-size-base);
font-weight: var(--el-font-weight-primary);
color: var(--el-text-color-primary);
}
.ea-round {
position: relative;
display: grid;
grid-template-columns: 200px minmax(0, 1fr);
gap: 12px 20px;
margin-left: 12px;
border-left: 2px solid var(--el-border-color);
padding: 12px 0 12px 20px;
}
.ea-round--last {
border-left-color: transparent;
}
.ea-round::before {
content: '';
position: absolute;
left: -7px;
top: 18px;
width: 12px;
height: 12px;
border: 2px solid var(--el-bg-color);
border-radius: 999px;
background: var(--el-color-primary);
box-shadow: 0 0 0 1px var(--el-border-color);
}
.ea-round__when {
display: flex;
flex-direction: column;
gap: 8px;
color: var(--el-text-color-secondary);
font-size: var(--el-font-size-small);
}
.ea-days {
display: flex;
align-items: center;
gap: 8px;
}
.ea-days :deep(.el-input-number) {
width: 120px;
}
.ea-round__who.is-muted {
opacity: 0.45;
}
.ea-line {
display: flex;
align-items: flex-start;
gap: 8px;
margin-bottom: 8px;
}
.ea-line__tag {
flex: none;
width: 36px;
margin-top: 6px;
font-size: var(--el-font-size-extra-small);
font-weight: var(--el-font-weight-primary);
color: var(--el-text-color-secondary);
}
.ea-line__text {
margin: 6px 0 0;
color: var(--el-text-color-primary);
font-weight: var(--el-font-weight-primary);
}
.ea-people {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.ea-person {
display: flex;
align-items: center;
gap: 8px;
min-height: 32px;
padding: 4px 8px 4px 4px;
border-radius: 999px;
background: var(--el-fill-color-light);
}
.ea-person__avatar {
display: grid;
width: 24px;
height: 24px;
place-items: center;
border-radius: 999px;
background: var(--el-color-primary-light-8);
color: var(--el-color-primary);
font-size: var(--el-font-size-extra-small);
font-weight: var(--el-font-weight-primary);
}
.ea-person__text {
display: flex;
flex-direction: column;
line-height: 1.2;
color: var(--el-text-color-primary);
}
.ea-person__text span {
color: var(--el-text-color-secondary);
font-size: var(--el-font-size-extra-small);
}
.ea-config-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin: 4px -16px 0;
padding: 12px 16px;
border-top: 1px solid var(--el-border-color-lighter);
color: var(--el-text-color-secondary);
font-size: var(--el-font-size-extra-small);
}
@media (max-width: 720px) {
.ea-round {
grid-template-columns: 1fr;
}
}
</style>
@@ -0,0 +1,75 @@
/**
* features/equipment-acceptance/views/EquipmentAcceptanceDetailPage.spec.ts
* 用途:确认详情在接口返回后能画出标题和当前节点表格,加载遮罩会关掉。
* 依赖:EquipmentAcceptanceDetailPage、vue-i18n、@vue/test-utils。
* 逻辑:只挂本页,接口用桩数据。不覆盖对话壳。
*/
import { flushPromises, mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import { describe, expect, it, vi } from 'vitest';
import { getEquipmentAcceptanceOrder } from '../api/equipment-acceptance.api';
import EquipmentAcceptanceDetailPage from './EquipmentAcceptanceDetailPage.vue';
vi.mock('../api/equipment-acceptance.api', () => ({
getEquipmentAcceptanceOrder: vi.fn(),
}));
const sample = {
id: 1,
request_title: '托威斯平台式自动拉钉机/1套资产验收单提交OA-20260718000003',
acceptance_no: '20260718000003',
flow_no: '20260718-1520',
request_created_at: '2026-07-18T16:51:47',
finished_at: null,
applicant_name: '柴晓红',
purchase_order_no: '5202-2606030008',
flow_status_raw: 1,
dwell_days: null,
timer_started_at: null,
can_accept: 1,
is_returned: 0,
cannot_accept_note: null,
monitor_status: 'not_started',
overdue: false,
nodes: [{ node_id: '1', node_name: '品质担当', node_type: null }],
operators: [{ node_id: '1', user_id: '9', handler_name: '温德佳', handler_job_num: '25060045' }],
};
describe('设备验收详情', () => {
it('接口返回后显示标题、当前节点、处理人和工号,并关掉加载遮罩', async () => {
const errors: unknown[] = [];
vi.mocked(getEquipmentAcceptanceOrder).mockResolvedValue(sample as never);
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
missing: (_locale, key) => key,
messages: { 'zh-CN': {} },
});
const wrapper = mount(EquipmentAcceptanceDetailPage, {
props: { orderId: 1 },
global: {
plugins: [i18n],
config: {
errorHandler(err) {
errors.push(err);
},
},
},
});
await flushPromises();
await new Promise((resolve) => setTimeout(resolve, 500));
const text = wrapper.text();
// 标题用流程标题,不再用验收单号占页眉。
expect(text).toContain(sample.request_title);
// 采购单号单独占字段表第一行。
expect(wrapper.find('.el-descriptions__label').text()).toBe('admin.equipmentAcceptance.purchaseOrderNo');
// 当前节点、处理人、工号只出现在下方表格。
expect(text).toContain('品质担当');
expect(text).toContain('温德佳');
expect(text).toContain('25060045');
// 加载结束不能留下可见遮罩,否则页面会一直转圈。
const mask = wrapper.find('.el-loading-mask');
expect(mask.exists() && mask.isVisible()).toBe(false);
expect(errors).toEqual([]);
});
});
@@ -1,13 +1,26 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptanceDetailPage.vue
用途:一张验收单的详情卡片,展示状态徽章、停留进度、当前节点和操作人。
依赖:equipment-acceptance.api、vue-i18n、统一消息提示。
逻辑:由 Chat 作业面在选中某行后展示。操作人只显示姓名和工号。
用途:一张验收单的详情卡片,展示状态标签、停留进度、当前节点和操作人。
依赖:equipment-acceptance.api、Element Plus、vue-i18n、统一消息提示。
逻辑:由 Chat 作业面在选中某行后展示。样式和 ElConfigProvider 由作业面提供。
页眉是流程标题。采购单号单独占第一行。流程编号与验收单单号、创建时间与结束时间各占一行。申请人单独占一行。
监控状态贴在标题下方。当前节点、处理人和工号只在下方表格出现一次。
进度条只按签核天数画到 30/37/44/51,不表示已经发送。
-->
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
import { ArrowLeft } from '@element-plus/icons-vue';
import { useI18n } from 'vue-i18n';
import {
ElButton,
ElDescriptions,
ElDescriptionsItem,
ElLoading,
ElProgress,
ElTable,
ElTableColumn,
ElTag,
} from 'element-plus';
import { BusinessError } from '@/shared/api/client';
import { useMessage } from '@/shared/composables/useMessage';
import {
@@ -23,7 +36,7 @@ const emit = defineEmits<{
back: [];
}>();
type BadgeTone = 'red' | 'green' | 'gray';
type TagType = 'danger' | 'success' | 'info';
const STOPPED_STATUSES = new Set([
'stopped_returned',
@@ -49,21 +62,68 @@ const FLOW_STATUS_KEYS: Record<number, string> = {
const REMINDER_DAYS = [30, 37, 44, 51];
interface OperatorRow {
rowKey: string;
nodeName: string;
handlerName: string;
jobNum: string;
}
const { t } = useI18n();
const msg = useMessage();
const vLoading = ElLoading.directive;
const loading = ref(false);
const order = ref<EquipmentAcceptanceOrder | null>(null);
const operatorRows = ref<OperatorRow[]>([]);
/**
* 把接口里的节点和操作人收成表格行。
* 核心逻辑:操作人的 node_id 对上节点名。没有操作人时仍列出节点,人和工号为空。
* 表格会改传入的数组,所以这里每次返回新的普通对象,不把计算属性直接交给表格。
* @param current - 当前验收单,空则没有行
* @returns 当前节点、处理人、工号各一列
*/
function buildOperatorRows(current: EquipmentAcceptanceOrder | null): OperatorRow[] {
if (!current) return [];
const nodes = Array.isArray(current.nodes) ? current.nodes.filter((node) => node) : [];
const people = Array.isArray(current.operators) ? current.operators.filter((item) => item) : [];
const nodeNameById = new Map(
nodes
.filter((node) => node.node_id)
.map((node) => [String(node.node_id), node.node_name || '—']),
);
const namedNodes = nodes.filter((node) => node.node_name);
const onlyNamed = namedNodes.length === 1 ? namedNodes[0] : undefined;
const fallbackNode = onlyNamed?.node_name || '—';
if (!people.length) {
return namedNodes.map((node, index) => ({
rowKey: `node-${node.node_id || index}`,
nodeName: node.node_name || '—',
handlerName: '—',
jobNum: '—',
}));
}
return people.map((item, index) => ({
rowKey: `${item.user_id || ''}-${item.node_id || ''}-${index}`,
nodeName: (item.node_id && nodeNameById.get(String(item.node_id))) || fallbackNode,
handlerName: item.handler_name || '—',
jobNum: item.handler_job_num || '—',
}));
}
/**
* 读取当前验收单详情。
* 核心逻辑:orderId 变化时重新请求。失败清空详情,避免上一张单残留。
* 核心逻辑:先算出表格行,再写入单据。失败时单据和表格一起清空,避免上一张单残留。
*/
async function load(): Promise<void> {
loading.value = true;
try {
order.value = await getEquipmentAcceptanceOrder(props.orderId);
const next = await getEquipmentAcceptanceOrder(props.orderId);
operatorRows.value = buildOperatorRows(next);
order.value = next;
} catch (error) {
order.value = null;
operatorRows.value = [];
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.detailLoadFailed'));
} finally {
loading.value = false;
@@ -80,6 +140,16 @@ function dateText(value?: string | null): string {
return value.slice(0, 10);
}
/**
* 展示流程创建时间,保留时分秒,不按浏览器时区再换算。
* @param value - 接口返回的 ISO 时间
* @returns 本地墙上时间或横线
*/
function dateTimeText(value?: string | null): string {
if (!value) return '—';
return value.replace('T', ' ').replace(/Z$/, '').slice(0, 19);
}
/**
* 把 0/1 写成否/是。可以验收为空时显示未标明,退回在同步时已把空收成否。
* @param value - 标准 0 否、1 是
@@ -114,55 +184,23 @@ function dwellText(item: EquipmentAcceptanceOrder): string {
}
/**
* 当前节点名称。没有节点时为空,模板改显示横线。
* 与列表相同的标签颜色。红是已逾期,绿是不再提醒,灰是未开始和未超时。
* @param item - 当前验收单
* @returns 节点名称列表
* @returns 文案和 Element 标签类型
*/
function nodeNames(item: EquipmentAcceptanceOrder): string[] {
return (item.nodes || []).map((node) => node.node_name).filter((name): name is string => Boolean(name));
}
/**
* 当前处理人去重后拼成一行。
* @param item - 当前验收单
* @returns 处理人姓名
*/
function handlerNames(item: EquipmentAcceptanceOrder): string {
const names = Array.from(new Set(
(item.operators || []).map((person) => person.handler_name).filter((name): name is string => Boolean(name)),
));
return names.length ? names.join('、') : '—';
}
/**
* 与列表相同的徽章颜色。红是已逾期,绿是不再提醒,灰是未开始和未超时。
* @param item - 当前验收单
* @returns 文案和颜色
*/
function statusBadge(item: EquipmentAcceptanceOrder): { label: string; tone: BadgeTone } {
function statusTag(item: EquipmentAcceptanceOrder): { label: string; type: TagType } {
if (item.monitor_status === 'watching' && item.overdue) {
return { label: t('admin.equipmentAcceptance.badgeOverdue'), tone: 'red' };
return { label: t('admin.equipmentAcceptance.badgeOverdue'), type: 'danger' };
}
if (item.monitor_status === 'watching') {
return { label: t('admin.equipmentAcceptance.badgeOnTime'), tone: 'gray' };
return { label: t('admin.equipmentAcceptance.badgeOnTime'), type: 'info' };
}
return {
label: t(`admin.equipmentAcceptance.statusLabel.${item.monitor_status}`),
tone: STOPPED_STATUSES.has(item.monitor_status) ? 'green' : 'gray',
type: STOPPED_STATUSES.has(item.monitor_status) ? 'success' : 'info',
};
}
/**
* 徽章底色。
* @param tone - 徽章颜色
* @returns Tailwind 类名
*/
function badgeClass(tone: BadgeTone): string {
if (tone === 'red') return 'bg-[#fff0ef] text-[#b42318]';
if (tone === 'green') return 'bg-[#eafaf1] text-[#067647]';
return 'bg-[#edf1f6] text-[#475569]';
}
/**
* 按签核天数在 0 到第 4 档之间画进度。没有天数时不画。
* 核心逻辑:刻度至少到 60 天,避免 51 天贴在条的尽头。
@@ -172,8 +210,9 @@ const track = computed(() => {
if (order.value?.monitor_status === 'not_started' || days == null) return null;
const lastMark = REMINDER_DAYS[REMINDER_DAYS.length - 1] ?? 51;
const scale = Math.max(60, lastMark + 9, days);
const percent = Math.min(100, Math.round((days / scale) * 100));
return {
width: `${Math.min(100, Math.round((days / scale) * 100))}%`,
percent,
marks: [0, ...REMINDER_DAYS, scale].map((day) => ({
day,
left: `${(day / scale) * 100}%`,
@@ -192,35 +231,22 @@ watch(() => props.orderId, () => {
</script>
<template>
<section class="min-h-0 flex-1 overflow-auto px-5 pb-6 pt-3">
<button
class="mb-3 rounded-lg border border-[#dce4ef] bg-white px-3 py-1.5 text-xs font-bold text-[#142033]"
type="button"
@click="emit('back')"
>
<section v-loading="loading" class="ea-scroll">
<ElButton class="ea-back" :icon="ArrowLeft" @click="emit('back')">
{{ t('admin.equipmentAcceptance.back') }}
</button>
<p v-if="loading && !order" class="text-sm text-[#64748b]">{{ t('admin.equipmentAcceptance.loading') }}</p>
<article v-else-if="order" class="overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
<div class="flex items-start justify-between gap-3 px-4 pt-4">
<h2 class="text-lg font-bold text-[#142033]">{{ order.acceptance_no || '—' }}</h2>
<span
class="inline-flex shrink-0 rounded-full px-2 py-0.5 text-[11px] font-extrabold"
:class="badgeClass(statusBadge(order).tone)"
>
{{ statusBadge(order).label }}
</span>
</div>
</ElButton>
<article v-if="order" class="ea-detail">
<header class="ea-detail__head">
<h2>{{ order.request_title || order.acceptance_no || '—' }}</h2>
<ElTag :type="statusTag(order).type" effect="light">{{ statusTag(order).label }}</ElTag>
</header>
<div v-if="track" class="px-7 pt-5">
<div class="h-2 overflow-hidden rounded-full bg-[#e7edf5]">
<i class="block h-full rounded-full bg-gradient-to-r from-[#93c5fd] to-[#2563eb]" :style="{ width: track.width }"></i>
</div>
<div class="relative mt-1 h-4 text-[11px] text-[#64748b]">
<div v-if="track" class="ea-track">
<ElProgress :percentage="track.percent" :show-text="false" :stroke-width="8" />
<div class="ea-track__marks">
<span
v-for="mark in track.marks"
:key="mark.day"
class="absolute -translate-x-1/2 whitespace-nowrap"
:style="{ left: mark.left }"
>
{{ mark.label }}
@@ -228,87 +254,130 @@ watch(() => props.orderId, () => {
</div>
</div>
<div class="flex flex-wrap gap-1.5 px-4 pb-1 pt-4">
<span
v-for="(name, index) in nodeNames(order)"
:key="`${name}-${index}`"
class="rounded-full bg-[#dbeafe] px-2 py-1 text-[11px] font-extrabold text-[#1d4ed8]"
>
{{ name }}
</span>
<span v-if="!nodeNames(order).length" class="text-sm text-[#64748b]">—</span>
</div>
<ElDescriptions :column="2" border>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.purchaseOrderNo')" :span="2">
{{ order.purchase_order_no || '—' }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.flowNo')">
{{ order.flow_no || '—' }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.acceptanceNo')">
{{ order.acceptance_no || '—' }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.createdAt')">
{{ dateTimeText(order.request_created_at) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.finishedAt')">
{{ dateText(order.finished_at) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.applicant')" :span="2">
{{ order.applicant_name || '—' }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.flowStatus')" :span="2">
{{ flowText(order.flow_status_raw) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.dwellDays')">
{{ dwellText(order) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.timerStart')">
{{ dateText(order.timer_started_at) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.canAccept')">
{{ yesNo(order.can_accept, t('admin.equipmentAcceptance.unspecified')) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.returnFlag')">
{{ yesNo(order.is_returned, t('common.no')) }}
</ElDescriptionsItem>
<ElDescriptionsItem :label="t('admin.equipmentAcceptance.cannotAcceptNote')" :span="2">
<span class="ea-pre">{{ order.cannot_accept_note || '—' }}</span>
</ElDescriptionsItem>
</ElDescriptions>
<dl class="mt-3 grid border-t border-[#dce4ef] px-4 sm:grid-cols-2">
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</dt>
<dd class="text-[#142033]">{{ order.purchase_order_no || '—' }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.applicant') }}</dt>
<dd class="text-[#142033]">{{ order.applicant_name || '—' }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.dwellDays') }}</dt>
<dd class="text-[#142033]">{{ dwellText(order) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.timerStart') }}</dt>
<dd class="text-[#142033]">{{ dateText(order.timer_started_at) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:col-span-2">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.currentHandlers') }}</dt>
<dd class="text-[#142033]">{{ handlerNames(order) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.canAccept') }}</dt>
<dd class="text-[#142033]">{{ yesNo(order.can_accept, t('admin.equipmentAcceptance.unspecified')) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:col-span-2">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.cannotAcceptNote') }}</dt>
<dd class="whitespace-pre-wrap text-[#142033]">{{ order.cannot_accept_note || '—' }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.returnFlag') }}</dt>
<dd class="text-[#142033]">{{ yesNo(order.is_returned, t('common.no')) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.flowStatus') }}</dt>
<dd class="text-[#142033]">{{ flowText(order.flow_status_raw) }}</dd>
</div>
<div class="grid grid-cols-[108px_minmax(0,1fr)] gap-2 border-b border-[#dce4ef] py-2.5 text-xs sm:pl-4">
<dt class="font-bold text-[#64748b]">{{ t('admin.equipmentAcceptance.finishedAt') }}</dt>
<dd class="text-[#142033]">{{ dateText(order.finished_at) }}</dd>
</div>
</dl>
<div class="px-4 pb-4 pt-4">
<h3 class="text-sm font-bold text-[#142033]">{{ t('admin.equipmentAcceptance.operators') }}</h3>
<p class="mt-1 text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.operatorsNote') }}</p>
<div class="mt-3 overflow-auto rounded-xl border border-[#dce4ef]">
<table class="w-full min-w-[640px] border-collapse text-left text-xs">
<thead class="bg-[#f8fbff] text-[#64748b]">
<tr>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.operatorName') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.jobNum') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="(item, index) in order.operators"
:key="`${item.user_id}-${item.node_id}-${index}`"
class="border-t border-[#dce4ef]"
>
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.handler_name || '—' }}</td>
<td class="px-3 py-2.5">{{ item.handler_job_num || '—' }}</td>
</tr>
<tr v-if="!order.operators.length">
<td colspan="2" class="px-3 py-6 text-center text-[#64748b]">—</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 class="ea-operators-title">{{ t('admin.equipmentAcceptance.operators') }}</h3>
<p class="ea-lead">{{ t('admin.equipmentAcceptance.operatorsNote') }}</p>
<ElTable class="ea-operators" :data="operatorRows" row-key="rowKey" :empty-text="'—'">
<ElTableColumn :label="t('admin.equipmentAcceptance.currentNodes')" min-width="160">
<template #default="{ row }">{{ row.nodeName }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.currentHandlers')" min-width="160">
<template #default="{ row }">{{ row.handlerName }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.jobNum')" min-width="140">
<template #default="{ row }">{{ row.jobNum }}</template>
</ElTableColumn>
</ElTable>
</article>
</section>
</template>
<style scoped>
.ea-scroll {
flex: 1 1 auto;
min-height: 0;
overflow: auto;
}
.ea-back {
margin-bottom: 8px;
}
.ea-detail {
padding: 16px;
background: var(--el-bg-color);
border: 1px solid var(--el-border-color);
border-radius: var(--el-border-radius-base);
}
.ea-detail__head {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 12px;
margin-bottom: 12px;
}
.ea-detail__head h2 {
margin: 0;
font-size: var(--el-font-size-large);
font-weight: var(--el-font-weight-primary);
line-height: 1.4;
color: var(--el-text-color-primary);
overflow-wrap: anywhere;
}
.ea-track {
padding: 16px 12px 0;
}
.ea-track__marks {
position: relative;
height: 18px;
margin-top: 4px;
color: var(--el-text-color-secondary);
font-size: var(--el-font-size-extra-small);
}
.ea-track__marks span {
position: absolute;
white-space: nowrap;
transform: translateX(-50%);
}
.ea-pre {
white-space: pre-wrap;
}
.ea-operators-title {
margin: 16px 0 4px;
font-size: var(--el-font-size-base);
font-weight: var(--el-font-weight-primary);
color: var(--el-text-color-primary);
}
.ea-lead {
margin: 0 0 8px;
font-size: var(--el-font-size-extra-small);
line-height: 1.4;
color: var(--el-text-color-secondary);
}
</style>
@@ -1,16 +1,30 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptancePage.vue
用途:设备验收预警停留列表,对齐原型的汇总卡、分组筛选和状态徽章。
依赖:equipment-acceptance.api、PaginationBar、统一消息提示、vue-i18n。
逻辑:由 Chat 作业面嵌入。点「查看详情」交给父级下钻。
已逾期只看接口给出的 overdue。发送结果在「发送记录」页,这里不显示第几档。
用途:设备验收预警停留列表。四张数字卡既是总览也是状态筛选。
依赖:equipment-acceptance.api、Element Plus、useFillHeight、统一消息提示、vue-i18n。
逻辑:由 Chat 作业面嵌入。样式和 ElConfigProvider 由 EquipmentAcceptanceChatPanel 提供。
点一张卡片只看该状态,再点一次回到全部。单号和申请人是另外两个输入框。
点「查看详情」交给父级下钻。已逾期只看接口给出的 overdue。
列表前五列是来源、标题、采购单号、验收单单号、流程编号,其余列接在后面。
发送结果在「发送记录」页,这里不显示第几档。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import {
ElButton,
ElCard,
ElInput,
ElLoading,
ElPagination,
ElStatistic,
ElTable,
ElTableColumn,
ElTag,
} from 'element-plus';
import { BusinessError } from '@/shared/api/client';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import { useMessage } from '@/shared/composables/useMessage';
import { useFillHeight } from '../composables/useFillHeight';
import {
listEquipmentAcceptanceOrders,
type EquipmentAcceptanceOrder,
@@ -22,7 +36,7 @@ const emit = defineEmits<{
}>();
type FocusKey = 'all' | 'watching' | 'overdue' | 'stopped' | 'not_started';
type BadgeTone = 'red' | 'green' | 'gray';
type TagType = 'danger' | 'success' | 'info';
const STOPPED_STATUSES = new Set([
'stopped_returned',
@@ -33,23 +47,23 @@ const STOPPED_STATUSES = new Set([
'stopped_revoked',
]);
const filters: Array<{ key: FocusKey; label: string }> = [
{ key: 'all', label: 'filterAll' },
{ key: 'watching', label: 'filterWatching' },
{ key: 'overdue', label: 'filterOverdue' },
{ key: 'stopped', label: 'filterStopped' },
{ key: 'not_started', label: 'filterNotStarted' },
];
const PAGE_SIZES = [10, 20, 50, 100];
const { t } = useI18n();
const msg = useMessage();
const vLoading = ElLoading.directive;
const tableHost = ref<HTMLElement | null>(null);
const { height: tableHeight } = useFillHeight(tableHost);
const loading = ref(false);
const orders = ref<EquipmentAcceptanceOrder[]>([]);
const focus = ref<FocusKey>('all');
const page = ref(1);
const pageSize = ref(20);
const total = ref(0);
const pages = ref(1);
const keyword = ref('');
const applicant = ref('');
let searchTimer: ReturnType<typeof setTimeout> | null = null;
let skipNextInput = false;
const summary = ref<EquipmentAcceptanceSummary>({
watching: 0,
overdue: 0,
@@ -57,10 +71,17 @@ const summary = ref<EquipmentAcceptanceSummary>({
not_started: 0,
});
const kpis = computed(() => [
{ key: 'watching' as const, label: 'kpiWatching', value: summary.value.watching },
{ key: 'overdue' as const, label: 'kpiOverdue', value: summary.value.overdue },
{ key: 'stopped' as const, label: 'kpiStopped', value: summary.value.stopped },
{ key: 'not_started' as const, label: 'filterNotStarted', value: summary.value.not_started },
]);
/**
* 加载当前分组的验收单,并刷新全部单据的汇总数字。
* 核心逻辑:汇总不受当前筛选影响,由接口的 summary 给出。
* @param resetPage - 为 true 时回到第一页,用于更换筛选。
* 核心逻辑:状态分组只影响表格。单号和申请人同时影响表格和分组数字。
* @param resetPage - 为 true 时回到第一页,用于更换筛选或每页条数。
*/
async function load(resetPage = false): Promise<void> {
if (resetPage) page.value = 1;
@@ -68,12 +89,13 @@ async function load(resetPage = false): Promise<void> {
try {
const result = await listEquipmentAcceptanceOrders({
focus: focus.value,
keyword: keyword.value,
applicant: applicant.value,
page: page.value,
pageSize: pageSize.value,
});
orders.value = result.items || [];
total.value = result.total || 0;
pages.value = result.pages || 1;
if (result.summary) summary.value = result.summary;
} catch (error) {
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.loadFailed'));
@@ -83,15 +105,93 @@ async function load(resetPage = false): Promise<void> {
}
/**
* 切换原型分组并回到第一页。
* @param next - all、watching、overdue、stopped、not_started
* 用数字卡切换停留分组,并回到第一页。
* 核心逻辑:再点当前卡片回到全部,避免卡片下面再放一排同样的标签。
* @param next - watching、overdue、stopped、not_started
*/
function selectFocus(next: FocusKey): void {
if (focus.value === next) return;
focus.value = next;
focus.value = focus.value === next ? 'all' : next;
void load(true);
}
/**
* 翻页后按当前分组重拉。
* @param next - 从 1 开始的页码
*/
function onPageChange(next: number): void {
if (page.value === next) return;
page.value = next;
void load();
}
/**
* 更换每页条数后回到第一页,避免停在已经不存在的页上。
* @param next - 每页条数
*/
function onSizeChange(next: number): void {
pageSize.value = next;
void load(true);
}
/**
* 停掉尚未发出的搜索,避免连续按键打出一串过期请求。
*/
function clearSearchTimer(): void {
if (searchTimer === null) return;
clearTimeout(searchTimer);
searchTimer = null;
}
/**
* 单号或申请人变化后稍等再查,并回到第一页。
* 核心逻辑:输入停 300 毫秒才请求。清空按钮紧接着还会发一次 input,那一次丢掉。
*/
function scheduleSearch(): void {
if (skipNextInput) {
skipNextInput = false;
return;
}
clearSearchTimer();
searchTimer = setTimeout(() => {
searchTimer = null;
void load(true);
}, 300);
}
/**
* 立刻按当前两个输入框查询。
* 核心逻辑:回车或点清空时不等待防抖。清空后的 input 由 skipNextInput 吃掉。
*/
function searchNow(): void {
clearSearchTimer();
skipNextInput = true;
queueMicrotask(() => {
skipNextInput = false;
});
void load(true);
}
/**
* 把来源代码显示成 E10 或 E8。
* @param order - 列表行
* @returns 来源名称,空值显示横线
*/
function sourceText(order: EquipmentAcceptanceOrder): string {
if (order.oa_system === 'e10') return t('admin.equipmentAcceptance.sourceE10');
if (order.oa_system === 'e8') return t('admin.equipmentAcceptance.sourceE8');
return '—';
}
/**
* 空单元格显示横线。
* @param value - 接口原值
* @returns 文本或横线
*/
function textOrDash(value?: string | null): string {
const text = String(value || '').trim();
return text || '—';
}
/**
* 把节点名称拼成一格。没有节点时显示横线。
* @param order - 列表行
@@ -124,6 +224,17 @@ function dateText(value?: string | null): string {
return value.slice(0, 10);
}
/**
* 展示流程创建时间,保留时分秒,不按浏览器时区再换算。
* @param value - 接口返回的 ISO 时间
* @returns 本地墙上时间或横线
*/
function dateTimeText(value?: string | null): string {
if (!value) return '—';
const text = value.replace('T', ' ').replace(/Z$/, '');
return text.slice(0, 19);
}
/**
* 未开始或没有天数时显示横线,其余显示「N 天」。
* @param order - 列表行
@@ -135,130 +246,270 @@ function dwellText(order: EquipmentAcceptanceOrder): string {
}
/**
* 按监控状态收成徽章。已逾期用红色,表示还要提醒。不再提醒用绿色,未开始和未超时用灰色。
* 按监控状态收成标签。已逾期用危险色,不再提醒用成功色,未开始和未超时用信息色。
* @param order - 列表行
* @returns 文案和颜色
* @returns 文案和 Element 标签类型
*/
function statusBadge(order: EquipmentAcceptanceOrder): { label: string; tone: BadgeTone } {
function statusTag(order: EquipmentAcceptanceOrder): { label: string; type: TagType } {
if (order.monitor_status === 'watching' && order.overdue) {
return { label: t('admin.equipmentAcceptance.badgeOverdue'), tone: 'red' };
return { label: t('admin.equipmentAcceptance.badgeOverdue'), type: 'danger' };
}
if (order.monitor_status === 'watching') {
return { label: t('admin.equipmentAcceptance.badgeOnTime'), tone: 'gray' };
return { label: t('admin.equipmentAcceptance.badgeOnTime'), type: 'info' };
}
return {
label: t(`admin.equipmentAcceptance.statusLabel.${order.monitor_status}`),
tone: STOPPED_STATUSES.has(order.monitor_status) ? 'green' : 'gray',
type: STOPPED_STATUSES.has(order.monitor_status) ? 'success' : 'info',
};
}
/**
* 徽章底色。红是已逾期,绿是不再提醒,灰是未超时、未开始和不在监控范围。
* @param tone - 徽章颜色
* @returns Tailwind 类名
*/
function badgeClass(tone: BadgeTone): string {
if (tone === 'red') return 'bg-[#fff0ef] text-[#b42318]';
if (tone === 'green') return 'bg-[#eafaf1] text-[#067647]';
return 'bg-[#edf1f6] text-[#475569]';
}
defineExpose({ reload: () => load(false) });
onMounted(() => {
void load();
});
onBeforeUnmount(() => {
clearSearchTimer();
});
</script>
<template>
<section class="flex min-h-0 flex-1 flex-col gap-3 px-5 pb-4 pt-3">
<div class="grid grid-cols-4 gap-3">
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.watching }}</b>
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiWatching') }}</span>
</article>
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.overdue }}</b>
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiOverdue') }}</span>
</article>
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.stopped }}</b>
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.kpiStopped') }}</span>
</article>
<article class="rounded-xl border border-[#dce4ef] bg-white px-4 py-3.5">
<b class="block text-[26px] font-bold leading-none text-[#142033]">{{ summary.not_started }}</b>
<span class="mt-1 block text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.filterNotStarted') }}</span>
</article>
<div class="ea-board">
<div class="ea-kpis">
<ElCard
v-for="item in kpis"
:key="item.key"
shadow="never"
class="ea-kpi"
:class="{ 'is-active': focus === item.key }"
role="button"
tabindex="0"
@click="selectFocus(item.key)"
@keyup.enter="selectFocus(item.key)"
>
<ElStatistic :title="t(`admin.equipmentAcceptance.${item.label}`)" :value="item.value" />
</ElCard>
</div>
<div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
<div class="flex flex-wrap gap-2 p-3">
<button
v-for="item in filters"
:key="item.key"
type="button"
class="rounded-full border px-2.5 py-1 text-xs font-bold"
:class="focus === item.key
? 'border-[#bfdbfe] bg-[#eaf2ff] text-[#1d4ed8]'
: 'border-[#dce4ef] bg-white text-[#475569]'"
@click="selectFocus(item.key)"
>
{{ t(`admin.equipmentAcceptance.${item.label}`) }}
</button>
</div>
<div class="min-h-0 flex-1 overflow-auto">
<table class="min-w-[960px] w-full border-collapse text-left text-xs">
<thead class="sticky top-0 bg-[#f8fbff] text-[#64748b]">
<tr>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.acceptanceNo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.applicant') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.currentNodes') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.currentHandlers') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.timerStart') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.dwellDays') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.status') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.actions') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="item in orders" :key="item.id" class="border-b border-[#dce4ef] hover:bg-[#f3f7ff]">
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.acceptance_no || '—' }}</td>
<td class="px-3 py-2.5">{{ item.purchase_order_no || '—' }}</td>
<td class="px-3 py-2.5">{{ item.applicant_name || '—' }}</td>
<td class="px-3 py-2.5">{{ nodeNames(item) }}</td>
<td class="px-3 py-2.5">{{ handlerNames(item) }}</td>
<td class="px-3 py-2.5">{{ dateText(item.timer_started_at) }}</td>
<td class="px-3 py-2.5">{{ dwellText(item) }}</td>
<td class="px-3 py-2.5">
<span
class="inline-flex rounded-full px-2 py-0.5 text-[11px] font-extrabold"
:class="badgeClass(statusBadge(item).tone)"
>
{{ statusBadge(item).label }}
</span>
</td>
<td class="px-3 py-2.5">
<button class="font-extrabold text-[#175cd3]" type="button" @click="emit('open-detail', item.id)">
{{ t('admin.equipmentAcceptance.detail') }}
</button>
</td>
</tr>
<tr v-if="!loading && !orders.length">
<td colspan="9" class="px-3 py-9 text-center text-[#64748b]">{{ t('admin.equipmentAcceptance.empty') }}</td>
</tr>
</tbody>
</table>
<section class="ea-pane">
<div class="ea-filters">
<div class="ea-searches">
<ElInput
v-model="keyword"
clearable
class="ea-filter-keyword"
:placeholder="t('admin.equipmentAcceptance.keywordPlaceholder')"
@input="scheduleSearch"
@clear="searchNow"
@keyup.enter="searchNow"
/>
<ElInput
v-model="applicant"
clearable
class="ea-filter-applicant"
:placeholder="t('admin.equipmentAcceptance.applicant')"
@input="scheduleSearch"
@clear="searchNow"
@keyup.enter="searchNow"
/>
</div>
</div>
<PaginationBar
class="shrink-0"
v-model:page="page"
v-model:page-size="pageSize"
:total="total"
:pages="pages"
@update:page="() => load()"
@update:page-size="() => load()"
/>
</section>
<div ref="tableHost" class="ea-table-host">
<ElTable
v-loading="loading"
class="ea-table"
:data="orders"
:height="tableHeight"
row-key="id"
:empty-text="t('admin.equipmentAcceptance.empty')"
>
<ElTableColumn :label="t('admin.equipmentAcceptance.source')" width="72" class-name="ea-ellipsis">
<template #default="{ row }">
<span class="ea-strong">{{ sourceText(row as EquipmentAcceptanceOrder) }}</span>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.requestTitle')" min-width="220" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ textOrDash((row as EquipmentAcceptanceOrder).request_title) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.purchaseOrderNo')" min-width="132" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ textOrDash((row as EquipmentAcceptanceOrder).purchase_order_no) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.acceptanceNo')" min-width="156" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">
<span class="ea-strong">{{ textOrDash((row as EquipmentAcceptanceOrder).acceptance_no) }}</span>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.flowNo')" min-width="132" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ textOrDash((row as EquipmentAcceptanceOrder).flow_no) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.createdAt')" min-width="168" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ dateTimeText((row as EquipmentAcceptanceOrder).request_created_at) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.applicant')" min-width="88" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ textOrDash((row as EquipmentAcceptanceOrder).applicant_name) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.currentNodes')" min-width="120" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ nodeNames(row as EquipmentAcceptanceOrder) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.currentHandlers')" min-width="120" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ handlerNames(row as EquipmentAcceptanceOrder) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.timerStart')" min-width="112" class-name="ea-ellipsis">
<template #default="{ row }">{{ dateText((row as EquipmentAcceptanceOrder).timer_started_at) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.dwellDays')" min-width="96" class-name="ea-ellipsis">
<template #default="{ row }">{{ dwellText(row as EquipmentAcceptanceOrder) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.status')" min-width="168">
<template #default="{ row }">
<ElTag :type="statusTag(row as EquipmentAcceptanceOrder).type" effect="light">
{{ statusTag(row as EquipmentAcceptanceOrder).label }}
</ElTag>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.actions')" width="96" fixed="right" align="right">
<template #default="{ row }">
<ElButton link type="primary" @click="emit('open-detail', (row as EquipmentAcceptanceOrder).id)">
{{ t('admin.equipmentAcceptance.detail') }}
</ElButton>
</template>
</ElTableColumn>
</ElTable>
</div>
<div class="ea-pager">
<ElPagination
background
layout="total, sizes, prev, pager, next"
:total="total"
:page-size="pageSize"
:current-page="page"
:page-sizes="PAGE_SIZES"
@current-change="onPageChange"
@size-change="onSizeChange"
/>
</div>
</section>
</div>
</template>
<style scoped>
.ea-board {
display: flex;
flex: 1 1 auto;
flex-direction: column;
gap: 8px;
min-height: 0;
min-width: 0;
}
.ea-kpis {
display: grid;
flex: none;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 12px;
}
.ea-kpi {
cursor: pointer;
border-radius: 12px;
}
.ea-kpi.is-active {
border-color: var(--el-color-primary);
}
.ea-kpi:focus-visible {
outline: 2px solid var(--el-color-primary);
outline-offset: 2px;
}
.ea-kpi :deep(.el-card__body) {
padding: 14px 16px;
}
.ea-kpi :deep(.el-statistic) {
display: flex;
flex-direction: column-reverse;
align-items: flex-start;
--el-statistic-content-font-size: 26px;
}
.ea-kpi :deep(.el-statistic__head) {
margin-top: 6px;
margin-bottom: 0;
color: var(--el-text-color-secondary);
font-size: var(--el-font-size-extra-small);
line-height: 1.2;
}
.ea-kpi :deep(.el-statistic__content) {
line-height: 1;
}
.ea-pane {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-height: 0;
min-width: 0;
overflow: hidden;
background: var(--el-bg-color);
border: 1px solid var(--el-border-color);
border-radius: var(--el-border-radius-base);
}
.ea-filters {
display: flex;
flex: none;
flex-wrap: wrap;
align-items: center;
gap: 12px;
padding: 10px 12px;
border-bottom: 1px solid var(--el-border-color-lighter);
}
.ea-searches {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.ea-filter-keyword {
width: 18rem;
flex: none;
}
.ea-filter-applicant {
width: 11rem;
flex: none;
}
.ea-table-host {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
.ea-table :deep(.el-table__cell) {
padding-top: 6px;
padding-bottom: 6px;
}
.ea-table :deep(.ea-ellipsis .cell) {
white-space: nowrap;
word-break: normal;
}
.ea-strong {
font-weight: var(--el-font-weight-primary);
color: var(--el-text-color-primary);
}
.ea-pager {
display: flex;
flex: none;
justify-content: flex-end;
padding: 8px 12px;
border-top: 1px solid var(--el-border-color-lighter);
}
</style>
@@ -1,55 +1,89 @@
<!--
features/equipment-acceptance/views/EquipmentAcceptanceSendsPage.vue
用途:设备验收预警发送记录页,列出每张验收单某一档的主送、抄送、Excel 附件和结果。
依赖:equipment-acceptance.api、PaginationBar、统一消息提示、vue-i18n、lucide 图标。
逻辑:由 Chat 作业面的「发送记录」Tab 嵌入。Excel 附件列点击文件名下载。发送失败时悬停图标看原因。
依赖:equipment-acceptance.api、Element Plus、useFillHeight、统一消息提示、vue-i18n。
逻辑:由 Chat 作业面的「发送记录」Tab 嵌入。样式和 ElConfigProvider 由作业面提供。
Excel 附件列点击文件名下载。发送失败时悬停图标看原因。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { CircleAlert, Download } from 'lucide-vue-next';
import { Download, Warning } from '@element-plus/icons-vue';
import { useI18n } from 'vue-i18n';
import {
ElButton,
ElLoading,
ElPagination,
ElTable,
ElTableColumn,
ElTag,
ElTooltip,
} from 'element-plus';
import { BusinessError } from '@/shared/api/client';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import { useMessage } from '@/shared/composables/useMessage';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import { useFillHeight } from '../composables/useFillHeight';
import {
downloadEquipmentAcceptanceSendFile,
listEquipmentAcceptanceSends,
type EquipmentAcceptanceSendRecord,
} from '../api/equipment-acceptance.api';
type TagType = 'success' | 'danger' | 'warning' | 'info';
const PAGE_SIZES = [10, 20, 50, 100];
const { t, te } = useI18n();
const msg = useMessage();
const vLoading = ElLoading.directive;
const tableHost = ref<HTMLElement | null>(null);
const { height: tableHeight } = useFillHeight(tableHost);
const records = ref<EquipmentAcceptanceSendRecord[]>([]);
const downloadingId = ref<number | null>(null);
const loading = ref(false);
const page = ref(1);
const pageSize = ref(20);
const total = ref(0);
const pages = ref(1);
const failureTip = ref<{ text: string; left: number; top: number } | null>(null);
/**
* 拉取当前页发送记录。
* 核心逻辑:失败时清空表格并提示。空列表留给模板显示「还没有发送记录」。
* 核心逻辑:失败时清空表格并提示。空列表留给表格显示「还没有发送记录」。
* @param resetPage - 为 true 时回到第一页,用于更换每页条数。
*/
async function load(): Promise<void> {
async function load(resetPage = false): Promise<void> {
if (resetPage) page.value = 1;
loading.value = true;
try {
const result = await listEquipmentAcceptanceSends({ page: page.value, pageSize: pageSize.value });
records.value = result.items || [];
total.value = result.total || 0;
pages.value = Math.max(1, Math.ceil(total.value / pageSize.value));
} catch (error) {
records.value = [];
total.value = 0;
pages.value = 1;
msg.error(error instanceof BusinessError ? error.message : t('admin.equipmentAcceptance.sendsFailed'));
} finally {
loading.value = false;
}
}
/**
* 翻页后重拉发送记录。
* @param next - 从 1 开始的页码
*/
function onPageChange(next: number): void {
if (page.value === next) return;
page.value = next;
void load();
}
/**
* 更换每页条数后回到第一页。
* @param next - 每页条数
*/
function onSizeChange(next: number): void {
pageSize.value = next;
void load(true);
}
/**
* 轮次列写成「超过 N 天」。
* @param item - 一条发送记录
@@ -69,6 +103,18 @@ function statusText(status: string): string {
return te(key) ? t(key) : status;
}
/**
* 发送结果对应的标签颜色。
* @param status - pending、sent、failed、cancelled
* @returns Element 标签类型
*/
function sendTagType(status: string): TagType {
if (status === 'sent') return 'success';
if (status === 'failed') return 'danger';
if (status === 'pending') return 'warning';
return 'info';
}
/**
* 已发送显示本地时间,待发送没有时间时显示横线。
* @param value - 接口返回的发送时间
@@ -81,27 +127,13 @@ function sentText(value?: string | null): string {
}
/**
* 在失败图标下方显示原因。用固定定位,避免被表格滚动容器裁掉。
* @param event - 悬停或聚焦事件
* @param message - 发送失败原因
* 空单元格显示横线。
* @param value - 接口原值
* @returns 文本或横线
*/
function openFailureTip(event: Event, message: string): void {
const target = event.currentTarget;
if (!(target instanceof HTMLElement)) return;
const rect = target.getBoundingClientRect();
const width = 280;
failureTip.value = {
text: message || t('admin.equipmentAcceptance.failureReasonEmpty'),
left: Math.max(8, Math.min(rect.left, window.innerWidth - width - 8)),
top: rect.bottom + 6,
};
}
/**
* 鼠标离开或失焦时关掉失败原因提示。
*/
function closeFailureTip(): void {
failureTip.value = null;
function textOrDash(value?: string | null): string {
const text = String(value || '').trim();
return text || '—';
}
/**
@@ -133,97 +165,159 @@ onMounted(() => {
void load();
});
defineExpose({ reload: load });
defineExpose({ reload: () => load(false) });
</script>
<template>
<section class="flex min-h-0 flex-1 flex-col gap-3 px-5 pb-4 pt-3">
<p class="text-xs text-[#64748b]">{{ t('admin.equipmentAcceptance.sendsLead') }}</p>
<div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-[#dce4ef] bg-white">
<div class="min-h-0 flex-1 overflow-auto">
<table class="min-w-[960px] w-full border-collapse text-left text-xs">
<thead class="sticky top-0 bg-[#f8fbff] text-[#64748b]">
<tr>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.acceptanceNo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.purchaseOrderNo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTier') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleTo') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.ruleCc') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.sendResult') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.excelColumn') }}</th>
<th class="px-3 py-2.5 font-bold">{{ t('admin.equipmentAcceptance.sentAt') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="item in records" :key="item.id" class="border-b border-[#dce4ef]">
<td class="px-3 py-2.5 font-bold text-[#142033]">{{ item.acceptance_no || '—' }}</td>
<td class="px-3 py-2.5">{{ item.purchase_order_no || '—' }}</td>
<td class="px-3 py-2.5">{{ tierText(item) }}</td>
<td class="px-3 py-2.5">{{ item.to_text || '—' }}</td>
<td class="px-3 py-2.5">{{ item.cc_text || '—' }}</td>
<td class="px-3 py-2.5">
<span class="inline-flex items-center gap-1" :class="item.status === 'failed' ? 'font-bold text-[#b42318]' : ''">
{{ statusText(item.status) }}
<button
v-if="item.status === 'failed'"
class="inline-flex h-[22px] w-[22px] items-center justify-center rounded-full text-[#b42318] hover:bg-[#fff1f2]"
type="button"
:aria-label="t('admin.equipmentAcceptance.failureReasonAria')"
@mouseenter="openFailureTip($event, item.error_message || '')"
@mouseleave="closeFailureTip"
@focus="openFailureTip($event, item.error_message || '')"
@blur="closeFailureTip"
>
<CircleAlert class="h-4 w-4" />
</button>
</span>
</td>
<td class="px-3 py-2.5">
<div v-if="item.files?.length" class="flex max-w-[280px] flex-col gap-1">
<button
v-for="file in item.files"
:key="file.id"
class="inline-flex min-w-0 items-center gap-1 font-semibold text-[#2563eb] disabled:opacity-50"
type="button"
:disabled="downloadingId === file.id"
:title="t('admin.equipmentAcceptance.excelColumn')"
@click="downloadFile(file)"
>
<Download class="h-3.5 w-3.5 shrink-0" />
<span class="truncate">{{ file.excel_file_name }}</span>
</button>
</div>
<span v-else>—</span>
</td>
<td class="px-3 py-2.5">{{ sentText(item.sent_at) }}</td>
</tr>
<tr v-if="!loading && !records.length">
<td colspan="8" class="px-3 py-10 text-center text-[#64748b]">
{{ t('admin.equipmentAcceptance.sendsEmpty') }}
</td>
</tr>
</tbody>
</table>
</div>
</div>
<PaginationBar
class="shrink-0"
v-model:page="page"
v-model:page-size="pageSize"
:total="total"
:pages="pages"
@update:page="() => load()"
@update:page-size="() => load()"
/>
<Teleport to="body">
<div
v-if="failureTip"
class="pointer-events-none fixed z-[80] max-w-[280px] whitespace-normal break-words rounded-lg bg-slate-900 px-2.5 py-1.5 text-xs leading-relaxed text-white shadow-lg"
role="tooltip"
:style="{ left: `${failureTip.left}px`, top: `${failureTip.top}px` }"
<section class="ea-pane">
<p class="ea-lead">{{ t('admin.equipmentAcceptance.sendsLead') }}</p>
<div ref="tableHost" class="ea-table-host">
<ElTable
v-loading="loading"
class="ea-table"
:data="records"
:height="tableHeight"
row-key="id"
:empty-text="t('admin.equipmentAcceptance.sendsEmpty')"
>
{{ failureTip.text }}
</div>
</Teleport>
<ElTableColumn :label="t('admin.equipmentAcceptance.acceptanceNo')" min-width="156" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">
<span class="ea-strong">{{ textOrDash((row as EquipmentAcceptanceSendRecord).acceptance_no) }}</span>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.purchaseOrderNo')" min-width="132" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ textOrDash((row as EquipmentAcceptanceSendRecord).purchase_order_no) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.ruleTier')" min-width="120" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ tierText(row as EquipmentAcceptanceSendRecord) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.ruleTo')" min-width="160" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ textOrDash((row as EquipmentAcceptanceSendRecord).to_text) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.ruleCc')" min-width="160" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ textOrDash((row as EquipmentAcceptanceSendRecord).cc_text) }}</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.sendResult')" min-width="140">
<template #default="{ row }">
<span class="ea-result">
<ElTag :type="sendTagType((row as EquipmentAcceptanceSendRecord).status)" effect="light">
{{ statusText((row as EquipmentAcceptanceSendRecord).status) }}
</ElTag>
<ElTooltip
v-if="(row as EquipmentAcceptanceSendRecord).status === 'failed'"
:content="(row as EquipmentAcceptanceSendRecord).error_message || t('admin.equipmentAcceptance.failureReasonEmpty')"
placement="top"
>
<ElButton
link
type="danger"
:icon="Warning"
:title="t('admin.equipmentAcceptance.failureReasonAria')"
/>
</ElTooltip>
</span>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.excelColumn')" min-width="220">
<template #default="{ row }">
<div v-if="(row as EquipmentAcceptanceSendRecord).files?.length" class="ea-files">
<ElButton
v-for="file in (row as EquipmentAcceptanceSendRecord).files"
:key="file.id"
link
type="primary"
:icon="Download"
:loading="downloadingId === file.id"
:title="t('admin.equipmentAcceptance.excelColumn')"
@click="downloadFile(file)"
>
{{ file.excel_file_name }}
</ElButton>
</div>
<span v-else>—</span>
</template>
</ElTableColumn>
<ElTableColumn :label="t('admin.equipmentAcceptance.sentAt')" min-width="168" class-name="ea-ellipsis" show-overflow-tooltip>
<template #default="{ row }">{{ sentText((row as EquipmentAcceptanceSendRecord).sent_at) }}</template>
</ElTableColumn>
</ElTable>
</div>
<div class="ea-pager">
<ElPagination
background
layout="total, sizes, prev, pager, next"
:total="total"
:page-size="pageSize"
:current-page="page"
:page-sizes="PAGE_SIZES"
@current-change="onPageChange"
@size-change="onSizeChange"
/>
</div>
</section>
</template>
<style scoped>
.ea-pane {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-height: 0;
min-width: 0;
overflow: hidden;
background: var(--el-bg-color);
border: 1px solid var(--el-border-color);
border-radius: var(--el-border-radius-base);
}
.ea-lead {
flex: none;
margin: 0;
padding: 8px 12px;
border-bottom: 1px solid var(--el-border-color-lighter);
font-size: var(--el-font-size-extra-small);
line-height: 1.4;
color: var(--el-text-color-secondary);
}
.ea-table-host {
flex: 1 1 auto;
min-height: 0;
overflow: hidden;
}
.ea-table :deep(.el-table__cell) {
padding-top: 6px;
padding-bottom: 6px;
}
.ea-table :deep(.ea-ellipsis .cell) {
white-space: nowrap;
word-break: normal;
}
.ea-strong {
font-weight: var(--el-font-weight-primary);
color: var(--el-text-color-primary);
}
.ea-result {
display: inline-flex;
align-items: center;
gap: 4px;
}
.ea-files {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.ea-pager {
display: flex;
flex: none;
justify-content: flex-end;
padding: 8px 12px;
border-top: 1px solid var(--el-border-color-lighter);
}
</style>
@@ -13,7 +13,6 @@ import { CircleCheck, Plus, Search, Setting, Tools } from '@element-plus/icons-v
import {
ElAlert,
ElButton,
ElConfigProvider,
ElInput,
ElLoading,
ElMessageBox,
@@ -25,7 +24,6 @@ import {
import 'element-plus/dist/index.css';
import 'element-plus/theme-chalk/dark/css-vars.css';
import '@/features/admin/styles/element-trial.css';
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
import KbGroupDrawer, { type KbGroupFormValue } from './KbGroupDrawer.vue';
import DifyHealthDialog from './DifyHealthDialog.vue';
@@ -45,7 +43,6 @@ type GroupSortKey = 'name' | 'document_count' | 'updated_at';
const router = useRouter();
const { t } = useI18n();
const { elementLocale } = useElementProvider();
const vLoading = ElLoading.directive;
const groups = ref<KbGroup[]>([]);
@@ -269,7 +266,6 @@ defineExpose({ loadData });
</script>
<template>
<ElConfigProvider :locale="elementLocale">
<AdminListPage>
<template #title>
<h2 class="section-title">{{ t('kbAdmin.groupsTitle') }}</h2>
@@ -372,7 +368,6 @@ defineExpose({ loadData });
<DifySettingsDialog :open="settingsDialogOpen" @close="settingsDialogOpen = false" @saved="(message) => { feedback = message; feedbackType = 'success'; void loadData(); }" @error="(message) => { feedback = message; feedbackType = 'error'; }" />
<DifyHealthDialog :open="healthDialogOpen" @close="healthDialogOpen = false" @error="(message) => { feedback = message; feedbackType = 'error'; }" />
</ElConfigProvider>
</template>
<style scoped>
@@ -3,7 +3,7 @@
* 用途:工作台立账凭证检核任务列表、最近一次检核、批次明细、企微发送记录、通知配置与强制重检 API 客户端。
* 依赖:@/shared/api/client、getAuthHeaders。
* 逻辑:AccountingVoucherCheckView / DetailView / VoucherCheckNotifyConfigPanel 调用;
* 对应 /api/workspace/accounting-voucher-check/* 与排程 Excel 下载。
* 对应 /api/workspace/accounting-voucher-check/*,企微记录 Excel 也走该前缀。
*/
import { requestJson } from '@/shared/api/client';
import { getAuthHeaders } from '@/shared/utils/auth';
@@ -133,11 +133,13 @@ export function listVoucherCheckRuns(params: {
}
/**
* 分页查询指定排程批次的 invoice 明细,可按 result 过滤状态;同时返回 by_file_type。
* 分页查询指定排程批次的 invoice 明细,可按 result 和 invoice 号过滤;同时返回 by_file_type。
* @param params.invoice_no - 包含匹配,忽略大小写;空表示不按号筛
*/
export function listVoucherCheckRunItems(runId: number, params?: { result?: string; page?: number; page_size?: number }) {
export function listVoucherCheckRunItems(runId: number, params?: { result?: string; invoice_no?: string; page?: number; page_size?: number }) {
const q = new URLSearchParams();
if (params?.result) q.set('result', params.result);
if (params?.invoice_no) q.set('invoice_no', params.invoice_no);
if (params?.page) q.set('page', String(params.page));
if (params?.page_size) q.set('page_size', String(params.page_size));
const qs = q.toString();
@@ -196,11 +198,15 @@ export function listVoucherCheckNotifications(params?: {
/**
* 下载该排程批次的检核结果 Excel。
* 核心逻辑:走立账凭证自己的下载接口,能看企微发送记录就能下,不要求是排程通知人。
* @param scheduleRunId - ScheduleRun.id
* @param filename - 回退文件名(无 Content-Disposition 时使用)
*/
export async function downloadVoucherCheckExcel(scheduleRunId: number, filename?: string | null) {
const res = await fetch(`/api/workspace/schedule-runs/${scheduleRunId}/excel`, { headers: getAuthHeaders() });
const res = await fetch(
`/api/workspace/accounting-voucher-check/schedule-runs/${scheduleRunId}/excel`,
{ headers: getAuthHeaders() },
);
if (!res.ok) {
throw new Error('excel');
}
@@ -3,7 +3,7 @@
* features/workspace/views/AccountingVoucherCheckDetailView.vue
* 用途:立账凭证检核批次明细独立页,支持按 invoice 或按文件类型汇总。
* 依赖:voucherCheck.api、PaginationBar、vue-router、vue-i18n、useMessage、voucherCheck.display。
* 逻辑:独立路由或 Chat 嵌入;标题下用下划线 Tab 切换汇总维度;状态筛选仅在按 invoice 时出现。
* 逻辑:独立路由或 Chat 嵌入;标题下用下划线 Tab 切换汇总维度;按 invoice 时可按状态和 invoice 号筛选。
* Chat 嵌入时 runId / runNo 由父级传入,返回列表通过 close 事件。
*/
import { computed, onMounted, ref, watch } from 'vue';
@@ -51,6 +51,7 @@ const total = ref(0);
const page = ref(1);
const pageSize = ref(50);
const statusFilter = ref('');
const invoiceFilter = ref('');
const runNo = ref('');
const viewMode = ref<'invoice' | 'fileType'>('invoice');
@@ -81,7 +82,7 @@ const statusOptions = computed(() => [
const pages = computed(() => Math.max(1, Math.ceil((total.value || 0) / Math.max(1, pageSize.value))));
/**
* 加载当前排程批次明细;invoice 行分页,文件类型汇总为整批快照。
* 加载当前排程批次明细;invoice 行按状态和单号分页,文件类型汇总为整批快照。
*/
async function loadItems() {
if (!scheduleRunId.value) {
@@ -92,8 +93,10 @@ async function loadItems() {
}
loading.value = true;
try {
const invoiceNo = invoiceFilter.value.trim();
const data = await listVoucherCheckRunItems(scheduleRunId.value, {
result: statusFilter.value || undefined,
invoice_no: invoiceNo || undefined,
page: page.value,
page_size: pageSize.value,
});
@@ -112,7 +115,7 @@ async function loadItems() {
}
/**
* 状态筛选变更时回到第一页再查询。
* 状态或 invoice 号变更时回到第一页再查询。
*/
function applyStatusFilter() {
page.value = 1;
@@ -158,6 +161,7 @@ onMounted(() => {
watch(scheduleRunId, () => {
page.value = 1;
statusFilter.value = '';
invoiceFilter.value = '';
viewMode.value = 'invoice';
void loadItems();
});
@@ -215,6 +219,16 @@ watch(scheduleRunId, () => {
<option v-for="opt in statusOptions" :key="opt.value || 'all'" :value="opt.value">{{ opt.label }}</option>
</select>
</label>
<label class="flex min-w-[12rem] flex-col gap-1 text-xs font-medium text-muted">
{{ $t('workspace.voucherCheck.invoiceNo') }}
<input
v-model="invoiceFilter"
type="text"
class="rounded-xl border border-default bg-surface px-3 py-1.5 text-sm text-primary"
:placeholder="$t('workspace.voucherCheck.invoicePlaceholder')"
@keyup.enter="applyStatusFilter"
/>
</label>
<button
type="button"
class="inline-flex items-center gap-1 rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-brand-700"
@@ -297,7 +311,7 @@ watch(scheduleRunId, () => {
v-model:page-size="pageSize"
:total="total"
:pages="pages"
:visible="total > 0 || !!statusFilter"
:visible="total > 0 || !!statusFilter || !!invoiceFilter.trim()"
@update:page="() => loadItems()"
@update:page-size="() => loadItems()"
/>
+25 -17
View File
@@ -1026,8 +1026,8 @@
},
"connectionBoundary": "Enter only the login information here. The system handles the required page actions, downloads, and waiting for the selected freight platform.",
"uploadConfigTitle": "Shipping Excel Auto Upload",
"uploadConfigHint": "Edited from this System Connection and stored as a restricted JSON. No free JavaScript, scripts, URL templates, cookies, or arbitrary browser actions are allowed.",
"uploadAutoEnabled": "Enable auto-upload (admin has reviewed this connection's upload behavior)",
"uploadConfigHint": "This switch only enables auto-upload. The page, buttons, and success checks are fixed in the freight connector.",
"uploadAutoEnabled": "Auto-upload",
"uploadEntryUrl": "Upload entry URL",
"uploadFileSelector": "File input selector",
"uploadSubmitMode": "Submit mode",
@@ -1041,7 +1041,7 @@
"uploadSuccessTexts": "Success texts (one per line)",
"uploadSuccessTextsHint": "Matching any success text marks success",
"uploadTimeout": "Timeout (seconds)",
"uploadConfigBoundary": "Upload config changes do not increment the inventory RPA config_version; used only for this connection's freight upload, not propagated to inventory/receipt RPA.",
"uploadConfigBoundary": "The upload page, buttons, and success checks are fixed in the connector. This switch only turns auto-upload on or off.",
"platform": {
"dbs": "DBS",
"crane": "Crane"
@@ -2636,6 +2636,7 @@
"platformJobFreightRpaOnhand": "Freight onhand inventory RPA",
"platformJobFaqHotAggregate": "FAQ hot aggregate",
"platformJobFileAssetCleanup": "Temporary file asset cleanup",
"transferTypeCodes": "Transfer types",
"transferSourceCodes": "Source instances",
"transferRecoverHistory": "Recover retryable history",
"transferReceiptDateFrom": "Movement date from (T-N)",
@@ -5227,6 +5228,7 @@
"items": "items",
"empty": "No contract data",
"purchaseOrder": "Purchase order",
"contractNo": "Contract no.",
"supplier": "Supplier",
"amount": "Contract amount",
"deliveryDate": "Delivery due date",
@@ -5278,7 +5280,6 @@
"company": "Company",
"erpSchema": "Payment ledger",
"statusLabel": "Status",
"contractPrefix": "Contract",
"datePending": "Date pending",
"dateMissing": {
"prepayment": "Archive date missing",
@@ -5299,7 +5300,7 @@
"statusActive": "Not yet due",
"statusCompleted": "Completed",
"totalPrefix": "Total",
"contractSupplier": "Contract / supplier",
"purchaseOrderSupplier": "Purchase order / supplier",
"nextAlert": "Next alert",
"triggerBasis": "Trigger basis",
"alertDate": "Alert date",
@@ -5401,7 +5402,7 @@
"attachmentPreviewUnsupported": "This format cannot be previewed online. Download the file to view it.",
"attachmentDownloadFailed": "Failed to download contract attachment",
"paymentPlanEmpty": "No payment plan to display",
"anchorDate": "Date basis",
"payableDate": "Payable date",
"nodeStatus": {
"pending": "Pending",
"active": "Active",
@@ -5612,7 +5613,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",
@@ -5663,6 +5664,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.",
@@ -5681,6 +5683,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",
@@ -5797,12 +5804,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": {
@@ -6101,7 +6102,7 @@
"configSheetLead": "Set the day threshold on the left. The right side lists who is notified. COO, purchasing deputy manager, and general manager are each chosen once and shown on every round that uses them.",
"overPrefix": "Over",
"roundName": "Round {n}",
"roundFixedNote": "Follows the current order. No one is picked here.",
"roundFixedNote": "Taken from the order's using-department representative. No one is picked here.",
"replaceUser": "Change",
"round4ShortHint": "Off by default. The general manager is not notified.",
"tier1": "Tier 1",
@@ -6132,9 +6133,9 @@
"ruleTo": "To",
"ruleCc": "Cc",
"ruleOver": "Over {days} days",
"ruleTo1": "Current handler",
"ruleCc1": "Their supervisor and the applicant",
"ruleTo2": "The handler's deputy manager",
"ruleTo1": "Using-department representative",
"ruleCc1": "Their direct supervisor and the procurement owner",
"ruleTo2": "That representative's deputy manager",
"ruleCc2": "COO and procurement deputy manager",
"ruleTo3": "COO",
"ruleCc3": "Procurement deputy manager",
@@ -6159,12 +6160,19 @@
"filterOverdue": "Overdue",
"filterStopped": "No further reminders",
"filterNotStarted": "Not started",
"keywordPlaceholder": "Flow no., acceptance no., or PO no.",
"badgeOverdue": "Overdue",
"badgeOnTime": "Not yet due",
"currentHandlers": "Current handlers",
"daysValue": "{days} days",
"statusAll": "All statuses",
"status": "Status",
"source": "Source",
"sourceE10": "E10",
"sourceE8": "E8",
"flowNo": "Process no.",
"requestTitle": "Title",
"createdAt": "Created at",
"acceptanceNo": "Acceptance no.",
"purchaseOrderNo": "Purchase order no.",
"applicant": "Applicant",
+7 -2
View File
@@ -1746,6 +1746,7 @@
"download": "Download Excel",
"rpa": "RPA upload",
"confirm": "Confirm uploaded",
"refreshStatus": "Refresh upload status",
"lineNo": "Line",
"lineNoSourceCustomerPo": "Customer PO line no.",
"lineNoSourceSequence": "System sequence (internal line no. not recognized)",
@@ -1758,6 +1759,7 @@
"uploadStatus": {
"pending": "Pending upload",
"uploading": "Uploading",
"allocating": "Accepted, allocating",
"failed": "Upload failed",
"uploaded": "Uploaded",
"needsHuman": "Manual upload needed"
@@ -3805,14 +3807,13 @@
"colMaterial": "Material",
"colName": "Name",
"colSpec": "Spec",
"colInvoice": "Invoice",
"colMovementDate": "Movement Date",
"colFromWarehouse": "From warehouse",
"colFromQty": "Stock qty",
"stockCheckedAtTitle": "Stock checked at {time}",
"colToWarehouse": "To warehouse",
"colFromBatch": "Outbound Batch",
"filterPlaceholder": "Filter by material / name / Invoice / batch",
"filterPlaceholder": "Filter by material / name / doc no. / external doc / batch",
"filterAll": "All results",
"requerySelected": "Requery selected",
"movementDateLabel": "Movement date",
@@ -3828,7 +3829,11 @@
"resultFileRemoved": "Removed from file",
"resultPendingStockCheck": "Pending stock check",
"staleRow": "Stale — requery",
"staleShort": "Stale",
"staleBanner": "{count} rows have stale inventory",
"staleBannerRequery": "Requery stale rows",
"fileChangedRow": "File updated; data will realign",
"fileChangedShort": "File updated",
"fileRemovedQuarantined": "{count} more rows were invalidated (removed from the inbound file) and are hidden from this list; handle them under Pending Exceptions (mark as no further action).",
"runProgress": "Transfer run progress",
"runExecuting": "Executing",
+3
View File
@@ -17,6 +17,9 @@
"ORDER_DELIVERY_REPLY.BATCH_INVALID": "Invalid batch format. Check the date, quantity, or remark.",
"ORDER_DELIVERY_REPLY.BATCH_QTY_TOTAL_MISMATCH": "The total of all batch quantities must equal the order quantity. Please adjust and save again.",
"SHIPPING.NOTICE_ODM_CHOICE_INVALID": "The selected ODM ID is not among the feasible candidates. Please choose again.",
"SHIPPING.UPLOAD_CRANE_ALLOCATING": "The forwarder accepted the file and is still allocating it. Refresh the status instead of uploading again.",
"SHIPPING.UPLOAD_CRANE_REFRESH_INFLIGHT": "A status refresh is already queued. Try again shortly.",
"SHIPPING.UPLOAD_TRIGGER_UNAVAILABLE": "The upload status-check directory is unavailable. Check the RPA shared folder.",
"SHIPPING.FULFILLMENT_POLICY_INVALID": "The fulfillment policy or field capability binding is invalid.",
"SHIPPING.FULFILLMENT_POLICY_NOT_FOUND": "The fulfillment policy was not found.",
"SHIPPING.FULFILLMENT_POLICY_CONFLICT": "The fulfillment policy was changed by another administrator. Refresh and try again.",
+25 -17
View File
@@ -1026,8 +1026,8 @@
},
"connectionBoundary": "กรอกเฉพาะข้อมูลเข้าสู่ระบบ ระบบจะดำเนินการหน้าเว็บ ดาวน์โหลด และรอตามแพลตฟอร์มผู้ให้บริการที่เลือกโดยอัตโนมัติ",
"uploadConfigTitle": "อัปโหลด Excel การจัดส่งอัตโนมัติ",
"uploadConfigHint": "แก้ไขจากหน้าการเชื่อมต่อระบบนี้และบันทึกเป็น JSON แบบจำกัด; ห้ามใช้ JavaScript/สคริปต์/URL template/Cookie หรือการกระทำเบราว์เซอร์โดยอิสระ",
"uploadAutoEnabled": "เปิดใช้งานอัปโหลดอัตโนมัติ (ผู้ดูแลตรวจสอบพฤติกรรมการอัปโหลดของการเชื่อมต่อนี้แล้ว)",
"uploadConfigHint": "สวิตช์นี้เปิดเฉพาะการอัปโหลดอัตโนมัติ หน้า ปุ่ม และเงื่อนไขสำเร็จถูกกำหนดไว้ในตัวเชื่อมต่อ",
"uploadAutoEnabled": "อัปโหลดอัตโนมัติ",
"uploadEntryUrl": "URL หน้าอัปโหลด",
"uploadFileSelector": "ตัวเลือกไฟล์ (selector)",
"uploadSubmitMode": "โหมดส่ง",
@@ -1041,7 +1041,7 @@
"uploadSuccessTexts": "ข้อความสำเร็จ (หนึ่งรายการต่อบรรทัด)",
"uploadSuccessTextsHint": "หากตรงกับข้อความสำเร็จข้อใดข้อหนึ่งถือว่าสำเร็จ",
"uploadTimeout": "ระยะเวลารอ (วินาที)",
"uploadConfigBoundary": "การเปลี่ยนค่าอัปโหลดไม่เพิ่ม config_version ของ RPA คลัง; ใช้เฉพาะการอัปโหลดของสายการขนส่งนี้เท่านั้น ไม่แพร่ไปยัง RPA คลัง/รับของ",
"uploadConfigBoundary": "หน้า ปุ่ม และเงื่อนไขสำเร็จถูกกำหนดในโปรแกรม สวิตช์นี้เปิดหรือปิดการอัปโหลดอัตโนมัติเท่านั้น",
"platform": {
"dbs": "DBS",
"crane": "Crane"
@@ -2516,6 +2516,7 @@
"platformJobFreightRpaOnhand": "Freight onhand inventory RPA",
"platformJobFaqHotAggregate": "FAQ hot aggregate",
"platformJobFileAssetCleanup": "Temporary file asset cleanup",
"transferTypeCodes": "ประเภทการโอนย้าย",
"transferSourceCodes": "Source instances",
"transferRecoverHistory": "Recover retryable history",
"transferReceiptDateFrom": "วันที่เคลื่อนไหวเริ่ม (T-N)",
@@ -5227,6 +5228,7 @@
"items": "รายการ",
"empty": "ไม่มีข้อมูลสัญญา",
"purchaseOrder": "ใบสั่งซื้อ",
"contractNo": "เลขที่สัญญา",
"supplier": "ผู้ขาย",
"amount": "มูลค่าสัญญา",
"deliveryDate": "กำหนดส่งมอบ",
@@ -5278,7 +5280,6 @@
"company": "บริษัท",
"erpSchema": "ชุดบัญชี",
"statusLabel": "สถานะ",
"contractPrefix": "สัญญา",
"datePending": "รอระบุวันที่",
"dateMissing": {
"prepayment": "ยังไม่มีวันจัดเก็บสัญญา",
@@ -5299,7 +5300,7 @@
"statusActive": "ยังไม่ถึงกำหนด",
"statusCompleted": "เสร็จสิ้น",
"totalPrefix": "รวม",
"contractSupplier": "สัญญา / ผู้ขาย",
"purchaseOrderSupplier": "ใบสั่งซื้อ / ผู้ขาย",
"nextAlert": "แจ้งเตือนถัดไป",
"triggerBasis": "เกณฑ์เริ่ม",
"alertDate": "วันที่แจ้งเตือน",
@@ -5401,7 +5402,7 @@
"attachmentPreviewUnsupported": "รูปแบบนี้ยังไม่รองรับการดูออนไลน์ กรุณาดาวน์โหลดเพื่อเปิดดู",
"attachmentDownloadFailed": "ดาวน์โหลดไฟล์แนบสัญญาไม่สำเร็จ",
"paymentPlanEmpty": "ไม่มีแผนการชำระเงินที่แสดงได้",
"anchorDate": "เกณฑ์วันที่",
"payableDate": "วันครบกำหนดชำระ",
"nodeStatus": {
"pending": "รอดำเนินการ",
"active": "กำลังดำเนินการ",
@@ -5612,7 +5613,7 @@
"types": "ประเภทการฝึกอบรม",
"typeCount": "ทั้งหมด {count} การกำหนดค่า",
"detail": "รายละเอียดการกำหนดค่า",
"headerMeta": "ประเภท: {type} · เวอร์ชันปัจจุบัน: {version}",
"headerMeta": "รหัสประเภท: {type}",
"addType": "เพิ่มประเภทการฝึกอบรม",
"editType": "แก้ไขประเภทการฝึกอบรม",
"empty": "ยังไม่มีการกำหนดค่า",
@@ -5663,6 +5664,7 @@
},
"placeholders": {
"onePerLine": "กรอกหนึ่งรายการต่อบรรทัด",
"typeCode": "ตัวอย่าง: onboarding",
"oneQuestionPerLine": "กรอกหนึ่งคำถามต่อบรรทัด",
"progressItemLabel": "ตัวอย่าง: ดูวิดีโอ",
"progressHintText": "ตัวอย่าง: จะถือว่าเสร็จสิ้นเมื่อทำวิดีโอ ทบทวนความรู้ และข้อสอบครบแล้ว",
@@ -5681,6 +5683,11 @@
"progressHintText": "คำอธิบายความคืบหน้าการฝึกอบรม",
"stepIntroText": "ข้อความแนะนำขั้นตอนการฝึกอบรม",
"requiredDuration": "เวลาที่ต้องใช้ (นาที)",
"requiredDurationPlaceholder": "0 หมายถึงไม่จำกัด",
"stageSummaryTitle": "สรุปตามระดับ (หนึ่งรายการต่อบรรทัด)",
"stageSummaryCompany": "สรุประดับบริษัท",
"stageSummaryDepartment": "สรุประดับแผนก",
"stageSummaryTeam": "สรุประดับทีม",
"summaryPoints": "ประเด็นทบทวน",
"summaryChecklist": "รายการก่อนสอบ",
"employeeQuestions": "คำถามที่พบบ่อยของพนักงาน",
@@ -5797,12 +5804,6 @@
"eyebrow": "培训运营中心",
"pageHint": "配置变更将在保存后生效",
"footerHint": "所有配置项均支持保存后继续调整",
"stats": {
"total": "配置总数",
"published": "已发布",
"resources": "当前资料",
"levels": "已配置级别"
},
"questionBankTitle": "入职培训题库"
},
"integrationConnector": {
@@ -6101,7 +6102,7 @@
"configSheetLead": "ด้านซ้ายกำหนดจำนวนวันที่เกิน ด้านขวาคือผู้รับในรอบนี้ COO รองผู้จัดการจัดซื้อ และผู้จัดการทั่วไปเลือกครั้งเดียว แล้วแสดงคนเดียวกันในทุกรอบที่ใช้",
"overPrefix": "เกิน",
"roundName": "รอบที่ {n}",
"roundFixedNote": "ตามเอกสารปัจจุบัน ไม่ต้องเลือกคนที่นี่",
"roundFixedNote": "ตามผู้รับผิดชอบฝ่ายใช้งานบนเอกสาร ไม่ต้องเลือกคนที่นี่",
"replaceUser": "เปลี่ยน",
"round4ShortHint": "ค่าเริ่มต้นคือปิด จะไม่แจ้งผู้จัดการทั่วไป",
"tier1": "ขั้นที่ 1",
@@ -6132,9 +6133,9 @@
"ruleTo": "ผู้รับหลัก",
"ruleCc": "สำเนา",
"ruleOver": "เกิน {days} วัน",
"ruleTo1": "ผู้ดำเนินการปัจจุบัน",
"ruleCc1": "หัวหน้าตรงและผู้ขอ",
"ruleTo2": "รองผู้จัดการของผู้ดำเนินการ",
"ruleTo1": "ผู้รับผิดชอบฝ่ายใช้งาน",
"ruleCc1": "หัวหน้าตรงของผู้นั้นและผู้ขอจัดซื้อ",
"ruleTo2": "รองผู้จัดการของผู้รับผิดชอบฝ่ายใช้งาน",
"ruleCc2": "COO และรองผู้จัดการจัดซื้อ",
"ruleTo3": "COO",
"ruleCc3": "รองผู้จัดการจัดซื้อ",
@@ -6159,12 +6160,19 @@
"filterOverdue": "เกินกำหนด",
"filterStopped": "ไม่แจ้งเตือนอีก",
"filterNotStarted": "ยังไม่เริ่ม",
"keywordPlaceholder": "เลขที่กระบวนการ เลขที่ตรวจรับ หรือเลขที่ใบสั่งซื้อ",
"badgeOverdue": "เกินกำหนด",
"badgeOnTime": "ยังไม่เกินกำหนด",
"currentHandlers": "ผู้ดำเนินการปัจจุบัน",
"daysValue": "{days} วัน",
"statusAll": "ทุกสถานะ",
"status": "สถานะ",
"source": "แหล่งที่มา",
"sourceE10": "E10",
"sourceE8": "E8",
"flowNo": "เลขที่กระบวนการ",
"requestTitle": "ชื่อเรื่อง",
"createdAt": "เวลาที่สร้าง",
"acceptanceNo": "เลขที่ใบตรวจรับ",
"purchaseOrderNo": "เลขที่ใบสั่งซื้อ",
"applicant": "ผู้ขอ",
+7 -2
View File
@@ -1746,6 +1746,7 @@
"download": "ดาวน์โหลด Excel",
"rpa": "อัปโหลด RPA",
"confirm": "ยืนยันอัปโหลด",
"refreshStatus": "รีเฟรชสถานะอัปโหลด",
"lineNo": "รายการ",
"lineNoSourceCustomerPo": "เลขบรรทัด PO ของลูกค้า",
"lineNoSourceSequence": "ลำดับระบบ (ไม่พบเลขรายการภายใน)",
@@ -1758,6 +1759,7 @@
"uploadStatus": {
"pending": "รออัปโหลด",
"uploading": "กำลังอัปโหลด",
"allocating": "รับไฟล์แล้ว กำลังจัดสรร",
"failed": "อัปโหลดล้มเหลว",
"uploaded": "อัปโหลดแล้ว",
"needsHuman": "ต้องอัปโหลดด้วยตนเอง"
@@ -3805,14 +3807,13 @@
"colMaterial": "รหัสวัสดุ",
"colName": "ชื่อ",
"colSpec": "สเปก",
"colInvoice": "Invoice",
"colMovementDate": "วันที่เคลื่อนไหว",
"colFromWarehouse": "คลังต้นทาง",
"colFromQty": "จำนวนสต๊อก",
"stockCheckedAtTitle": "เวลาตรวจสอบสต๊อก: {time}",
"colToWarehouse": "คลังปลายทาง",
"colFromBatch": "ล็อตต้นทาง",
"filterPlaceholder": "กรองตามรหัสวัสดุ / ชื่อ / Invoice / ล็อต",
"filterPlaceholder": "กรองตามรหัสวัสดุ / ชื่อ / เลขที่เอกสาร / เลขที่เอกสารภายนอก / ล็อต",
"filterAll": "ทุกผลลัพธ์",
"requerySelected": "ตรวจซ้ำที่เลือก",
"movementDateLabel": "วันที่เคลื่อนไหว",
@@ -3828,7 +3829,11 @@
"resultFileRemoved": "ถูกลบออกจากไฟล์",
"resultPendingStockCheck": "รอตรวจสอบสต๊อก",
"staleRow": "ข้อมูลหมดอายุ กรุณาตรวจซ้ำ",
"staleShort": "หมดอายุ",
"staleBanner": "มี {count} แถวที่สต๊อกหมดอายุ",
"staleBannerRequery": "ตรวจซ้ำแถวที่หมดอายุ",
"fileChangedRow": "ไฟล์อัปเดตแล้ว ข้อมูลจะจัดตำแหน่งใหม่อัตโนมัติ",
"fileChangedShort": "ไฟล์อัปเดต",
"fileRemovedQuarantined": "อีก {count} รายการถือเป็นยกเลิกเนื่องจากถูกลบออกจากไฟล์รับเข้า และถูกซ่อนจากรายการนี้ โปรดดำเนินการใน「ข้อยกเว้นที่รอดำเนินการ」โดยสามารถทำเครื่องหมายว่าไม่จำเป็นต้องดำเนินการต่อ",
"runProgress": "ความคืบหน้าการโอน",
"runExecuting": "กำลังดำเนินการ",
+3
View File
@@ -17,6 +17,9 @@
"ORDER_DELIVERY_REPLY.BATCH_INVALID": "รูปแบบงวดไม่ถูกต้อง โปรดตรวจสอบวันที่ จำนวน หรือหมายเหตุ",
"ORDER_DELIVERY_REPLY.BATCH_QTY_TOTAL_MISMATCH": "ผลรวมจำนวนทุกงวดต้องเท่ากับจำนวนของคำสั่งซื้อ โปรดปรับแล้วบันทึกอีกครั้ง",
"SHIPPING.NOTICE_ODM_CHOICE_INVALID": "ODM ID ที่เลือกไม่อยู่ในตัวเลือกที่ทำได้ โปรดเลือกใหม่",
"SHIPPING.UPLOAD_CRANE_ALLOCATING": "ผู้รับขนรับไฟล์แล้วและกำลังจัดสรร โปรดรีเฟรชสถานะ อย่าอัปโหลดซ้ำ",
"SHIPPING.UPLOAD_CRANE_REFRESH_INFLIGHT": "มีการรีเฟรชสถานะค้างอยู่ในคิว โปรดลองอีกครั้งในอีกสักครู่",
"SHIPPING.UPLOAD_TRIGGER_UNAVAILABLE": "โฟลเดอร์ตรวจสถานะการอัปโหลดไม่พร้อม โปรดตรวจโฟลเดอร์ที่ใช้ร่วมกันของ RPA",
"SHIPPING.FULFILLMENT_POLICY_INVALID": "นโยบายการปฏิบัติตามหรือการผูกความสามารถของฟิลด์ไม่ถูกต้อง",
"SHIPPING.FULFILLMENT_POLICY_NOT_FOUND": "ไม่พบนโยบายการปฏิบัติตาม",
"SHIPPING.FULFILLMENT_POLICY_CONFLICT": "นโยบายการปฏิบัติตามถูกแก้ไขโดยผู้ดูแลรายอื่น โปรดรีเฟรชแล้วลองใหม่",
+24 -16
View File
@@ -1157,8 +1157,8 @@
},
"connectionBoundary": "连接配置只填写登录所需信息;系统会按货代平台自动执行页面操作、下载和等待。",
"uploadConfigTitle": "发货 Excel 自动上传",
"uploadConfigHint": "该配置由系统连接管理端编辑,后端保存为受限 JSON;禁止自由 JavaScript、脚本、URL 模板、Cookie 或任意浏览器动作。",
"uploadAutoEnabled": "启用自动上传(代表管理员已审核该连接的上传行为)",
"uploadConfigHint": "只控制这条连接是否自动上传。上传页面、按钮和成功判断由对应货代平台的程序固定。",
"uploadAutoEnabled": "自动上传",
"uploadEntryUrl": "上传入口 URL",
"uploadFileSelector": "文件选择器",
"uploadSubmitMode": "提交方式",
@@ -1172,7 +1172,7 @@
"uploadSuccessTexts": "成功文本(每行一条)",
"uploadSuccessTextsHint": "命中任一条成功文本即判定成功",
"uploadTimeout": "超时时间(秒)",
"uploadConfigBoundary": "上传配置变更不递增库存 RPA config_version;仅该连接的货代上传使用,不向库存/收料 RPA 扩散。",
"uploadConfigBoundary": "上传页面、按钮和成功判断由货代平台程序固定。这里只开关自动上传,变更不递增库存 RPA config_version。",
"platform": {
"dbs": "DBS 平台",
"crane": "Crane 平台"
@@ -2767,6 +2767,7 @@
"platformJobFreightRpaOnhand": "货代库存 RPA",
"platformJobFaqHotAggregate": "FAQ 热点聚合",
"platformJobFileAssetCleanup": "临时文件资产清理",
"transferTypeCodes": "调拨类型",
"transferSourceCodes": "来源实例",
"transferRecoverHistory": "历史可恢复异常复核",
"transferReceiptDateFrom": "异动日期起(T-N)",
@@ -5230,6 +5231,7 @@
"items": "条",
"empty": "暂无合同数据",
"purchaseOrder": "采购单号",
"contractNo": "合同号",
"supplier": "供应商",
"amount": "合同金额",
"deliveryDate": "交货期限",
@@ -5281,7 +5283,6 @@
"company": "公司",
"erpSchema": "付款账套",
"statusLabel": "状态",
"contractPrefix": "合同",
"datePending": "待补充日期",
"dateMissing": {
"prepayment": "合同归档日未填",
@@ -5302,7 +5303,7 @@
"statusActive": "未到期",
"statusCompleted": "已完成",
"totalPrefix": "共",
"contractSupplier": "合同号 / 供应商",
"purchaseOrderSupplier": "采购单号 / 供应商",
"nextAlert": "下一预警",
"triggerBasis": "触发依据",
"alertDate": "预警日期",
@@ -5404,7 +5405,7 @@
"attachmentPreviewUnsupported": "该格式暂不支持在线预览,请下载后查看",
"attachmentDownloadFailed": "下载合同附件失败",
"paymentPlanEmpty": "暂无可展示的付款计划",
"anchorDate": "日期依据",
"payableDate": "应付日期",
"nodeStatus": {
"pending": "待处理",
"active": "进行中",
@@ -5626,16 +5627,10 @@
"subtitle": "按培训类型管理版本、考试规则、资源与题目",
"pageHint": "配置变更将在保存后生效",
"footerHint": "所有配置项均支持保存后继续调整",
"stats": {
"total": "配置总数",
"published": "已发布",
"resources": "当前资料",
"levels": "已配置级别"
},
"types": "培训类型",
"typeCount": "共 {count} 个配置",
"detail": "配置详情",
"headerMeta": "类型编码:{type} · 当前版本:{version}",
"headerMeta": "类型编码:{type}",
"addType": "新增培训类型",
"editType": "编辑培训类型",
"empty": "暂无培训配置",
@@ -5687,6 +5682,7 @@
},
"placeholders": {
"onePerLine": "每行填写一项",
"typeCode": "例如 onboarding,小写字母开头",
"oneQuestionPerLine": "每行填写一个问题",
"progressItemLabel": "例如:观看视频",
"progressHintText": "例如:按 HR 要求完成视频、知识点、考试三个环节后才能视为完成。",
@@ -5705,6 +5701,11 @@
"progressHintText": "培训进度说明",
"stepIntroText": "培训步骤引导文案",
"requiredDuration": "所需时间(分钟)",
"requiredDurationPlaceholder": "0 表示不限制",
"stageSummaryTitle": "分级培训总结(按行分隔)",
"stageSummaryCompany": "公司级总结",
"stageSummaryDepartment": "部门级总结",
"stageSummaryTeam": "班组级总结",
"summaryPoints": "复盘要点",
"summaryChecklist": "考前清单",
"employeeQuestions": "员工常见问题",
@@ -6115,7 +6116,7 @@
"configSheetLead": "左边改超过多少天。右边是这一轮的主送和抄送。COO、采购经副理、总经理各选一次,用到的轮次都显示同一个人。",
"overPrefix": "超过",
"roundName": "第 {n} 轮",
"roundFixedNote": "随当前单据变化,这里不选人",
"roundFixedNote": "随单据上的使用部门担当变化,这里不选人",
"replaceUser": "更换",
"round4ShortHint": "默认关闭,不通知总经理",
"tier1": "第 1 档",
@@ -6146,9 +6147,9 @@
"ruleTo": "主送",
"ruleCc": "抄送",
"ruleOver": "超过 {days} 天",
"ruleTo1": "当前节点处理人",
"ruleTo1": "使用部门担当",
"ruleCc1": "其直接主管、采购担当",
"ruleTo2": "当前节点处理人的经副理",
"ruleTo2": "使用部门担当的经副理",
"ruleCc2": "COO、采购经副理",
"ruleTo3": "COO",
"ruleCc3": "采购经副理",
@@ -6173,12 +6174,19 @@
"filterOverdue": "已逾期",
"filterStopped": "不再提醒",
"filterNotStarted": "未开始",
"keywordPlaceholder": "流程编号、验收单号或采购单号",
"badgeOverdue": "已逾期",
"badgeOnTime": "未超时",
"currentHandlers": "当前处理人",
"daysValue": "{days} 天",
"statusAll": "全部状态",
"status": "状态",
"source": "来源",
"sourceE10": "E10",
"sourceE8": "E8",
"flowNo": "流程编号",
"requestTitle": "标题",
"createdAt": "创建时间",
"acceptanceNo": "验收单单号",
"purchaseOrderNo": "采购单号",
"applicant": "申请人",
+7 -2
View File
@@ -1780,6 +1780,7 @@
"download": "下载 Excel",
"rpa": "RPA 上传",
"confirm": "确认上传",
"refreshStatus": "刷新上传状态",
"lineNo": "项次",
"lineNoSourceCustomerPo": "客户 PO 行号",
"lineNoSourceSequence": "系统行序(未识别到内部项次)",
@@ -1792,6 +1793,7 @@
"uploadStatus": {
"pending": "待上传",
"uploading": "上传中",
"allocating": "已接收,分配中",
"failed": "上传失败",
"uploaded": "已上传",
"needsHuman": "需人工上传"
@@ -3805,14 +3807,13 @@
"colMaterial": "料号",
"colName": "品名",
"colSpec": "规格",
"colInvoice": "Invoice",
"colMovementDate": "异动日期",
"colFromWarehouse": "拨出仓库",
"colFromQty": "库存数量",
"stockCheckedAtTitle": "库存查询时刻:{time}",
"colToWarehouse": "拨入仓库",
"colFromBatch": "拨出批号",
"filterPlaceholder": "按料号 / 品名 / Invoice / 批号筛选",
"filterPlaceholder": "按料号 / 品名 / 单号 / 外部单号 / 批号筛选",
"filterAll": "全部结果",
"requerySelected": "重查选中",
"movementDateLabel": "异动日期",
@@ -3828,7 +3829,11 @@
"resultFileRemoved": "文件已移除",
"resultPendingStockCheck": "待查库存",
"staleRow": "数据已过期,请重查",
"staleShort": "已过期",
"staleBanner": "{count} 行库存已过期",
"staleBannerRequery": "重查过期行",
"fileChangedRow": "文件已更新,将自动对齐",
"fileChangedShort": "文件更新",
"fileRemovedQuarantined": "另有 {count} 行已随入站文件移除而失效,已移出本清单;请到「待处理异常」处理,可标记无需继续处理。",
"runProgress": "调拨执行进度",
"runExecuting": "执行中",
+3
View File
@@ -17,6 +17,9 @@
"ORDER_DELIVERY_REPLY.BATCH_INVALID": "批次格式不合法,请检查交期、数量或备注。",
"ORDER_DELIVERY_REPLY.BATCH_QTY_TOTAL_MISMATCH": "各批次数量合计必须等于订单数量,请调整后重新保存。",
"SHIPPING.NOTICE_ODM_CHOICE_INVALID": "所选 ODM ID 不在当前可行候选内,请重新选择。",
"SHIPPING.UPLOAD_CRANE_ALLOCATING": "货代已接收文件并正在分配,请刷新状态,不要再次上传。",
"SHIPPING.UPLOAD_CRANE_REFRESH_INFLIGHT": "上一次状态刷新还在排队,请稍后再试。",
"SHIPPING.UPLOAD_TRIGGER_UNAVAILABLE": "上传回查目录不可用,请检查 RPA 共享目录。",
"SHIPPING.FULFILLMENT_POLICY_INVALID": "货代履约策略或字段能力绑定无效。",
"SHIPPING.FULFILLMENT_POLICY_NOT_FOUND": "未找到货代履约策略。",
"SHIPPING.FULFILLMENT_POLICY_CONFLICT": "货代履约策略已被其他管理员修改,请刷新后重试。",
+24 -16
View File
@@ -1026,8 +1026,8 @@
},
"connectionBoundary": "連線設定只填寫登入所需資訊;系統會依貨代平台自動執行頁面操作、下載與等待。",
"uploadConfigTitle": "發貨 Excel 自動上傳",
"uploadConfigHint": "本設定由系統連線管理端編輯,後端儲存為受限 JSON;禁止自由 JavaScript、腳本、URL 範本、Cookie 或任意瀏覽器動作。",
"uploadAutoEnabled": "啟用自動上傳(代表管理員已審核該連線的上傳行為)",
"uploadConfigHint": "只控制這條連線是否自動上傳。上傳頁面、按鈕和成功判斷由對應貨代平台的程式固定。",
"uploadAutoEnabled": "自動上傳",
"uploadEntryUrl": "上傳入口 URL",
"uploadFileSelector": "檔案選擇器",
"uploadSubmitMode": "提交方式",
@@ -1041,7 +1041,7 @@
"uploadSuccessTexts": "成功文字(每行一條)",
"uploadSuccessTextsHint": "命中任一條成功文字即判定成功",
"uploadTimeout": "逾時時間(秒)",
"uploadConfigBoundary": "上傳設定變更不遞增庫存 RPA config_version;僅該連線的貨代上傳使用,不擴散至庫存/收料 RPA。",
"uploadConfigBoundary": "上傳頁面、按鈕和成功判斷由貨代平台程式固定。這裡只開關自動上傳,變更不遞增庫存 RPA config_version。",
"platform": {
"dbs": "DBS 平台",
"crane": "Crane 平台"
@@ -2516,6 +2516,7 @@
"platformJobFreightRpaOnhand": "貨代庫存 RPA",
"platformJobFaqHotAggregate": "FAQ 熱點聚合",
"platformJobFileAssetCleanup": "暫存檔案資產清理",
"transferTypeCodes": "調撥類型",
"transferSourceCodes": "來源實例",
"transferRecoverHistory": "歷史可復原異常複核",
"transferReceiptDateFrom": "異動日期起(T-N)",
@@ -5227,6 +5228,7 @@
"items": "筆",
"empty": "暫無合約資料",
"purchaseOrder": "採購單號",
"contractNo": "合約號",
"supplier": "供應商",
"amount": "合約金額",
"deliveryDate": "交貨期限",
@@ -5278,7 +5280,6 @@
"company": "公司",
"erpSchema": "付款帳套",
"statusLabel": "狀態",
"contractPrefix": "合約",
"datePending": "待補充日期",
"dateMissing": {
"prepayment": "合約歸檔日未填",
@@ -5299,7 +5300,7 @@
"statusActive": "未到期",
"statusCompleted": "已完成",
"totalPrefix": "共",
"contractSupplier": "合約號 / 供應商",
"purchaseOrderSupplier": "採購單號 / 供應商",
"nextAlert": "下一預警",
"triggerBasis": "觸發依據",
"alertDate": "預警日期",
@@ -5401,7 +5402,7 @@
"attachmentPreviewUnsupported": "此格式暫不支援線上預覽,請下載後查看",
"attachmentDownloadFailed": "下載合約附件失敗",
"paymentPlanEmpty": "暫無可展示的付款計畫",
"anchorDate": "日期依據",
"payableDate": "應付日期",
"nodeStatus": {
"pending": "待處理",
"active": "進行中",
@@ -5612,7 +5613,7 @@
"types": "培訓類型",
"typeCount": "共 {count} 個配置",
"detail": "配置詳情",
"headerMeta": "類型編碼:{type} · 目前版本:{version}",
"headerMeta": "類型編碼:{type}",
"addType": "新增培訓類型",
"editType": "編輯培訓類型",
"empty": "暫無培訓配置",
@@ -5663,6 +5664,7 @@
},
"placeholders": {
"onePerLine": "每行填寫一項",
"typeCode": "例如 onboarding,小寫字母開頭",
"oneQuestionPerLine": "每行填寫一個問題",
"progressItemLabel": "例如:觀看影片",
"progressHintText": "例如:按 HR 要求完成影片、知識點、考試三個環節後才算完成。",
@@ -5681,6 +5683,11 @@
"progressHintText": "培訓進度說明",
"stepIntroText": "培訓步驟引導文案",
"requiredDuration": "所需時間(分鐘)",
"requiredDurationPlaceholder": "0 表示不限制",
"stageSummaryTitle": "分級培訓總結(按行分隔)",
"stageSummaryCompany": "公司級總結",
"stageSummaryDepartment": "部門級總結",
"stageSummaryTeam": "班組級總結",
"summaryPoints": "複盤要點",
"summaryChecklist": "考前清單",
"employeeQuestions": "員工常見問題",
@@ -5797,12 +5804,6 @@
"eyebrow": "培训运营中心",
"pageHint": "配置变更将在保存后生效",
"footerHint": "所有配置项均支持保存后继续调整",
"stats": {
"total": "配置总数",
"published": "已发布",
"resources": "当前资料",
"levels": "已配置级别"
},
"questionBankTitle": "入职培训题库"
},
"integrationConnector": {
@@ -6101,7 +6102,7 @@
"configSheetLead": "左邊改超過多少天。右邊是這一輪的主送和抄送。COO、採購經副理、總經理各選一次,用到的輪次都顯示同一個人。",
"overPrefix": "超過",
"roundName": "第 {n} 輪",
"roundFixedNote": "隨目前單據變化,這裡不選人",
"roundFixedNote": "隨單據上的使用部門擔當變化,這裡不選人",
"replaceUser": "更換",
"round4ShortHint": "預設關閉,不通知總經理",
"tier1": "第 1 檔",
@@ -6132,9 +6133,9 @@
"ruleTo": "主送",
"ruleCc": "抄送",
"ruleOver": "超過 {days} 天",
"ruleTo1": "目前節點處理人",
"ruleTo1": "使用部門擔當",
"ruleCc1": "其直接主管、採購擔當",
"ruleTo2": "目前節點處理人的經副理",
"ruleTo2": "使用部門擔當的經副理",
"ruleCc2": "COO、採購經副理",
"ruleTo3": "COO",
"ruleCc3": "採購經副理",
@@ -6159,12 +6160,19 @@
"filterOverdue": "已逾期",
"filterStopped": "不再提醒",
"filterNotStarted": "未開始",
"keywordPlaceholder": "流程編號、驗收單號或採購單號",
"badgeOverdue": "已逾期",
"badgeOnTime": "未超時",
"currentHandlers": "目前處理人",
"daysValue": "{days} 天",
"statusAll": "全部狀態",
"status": "狀態",
"source": "來源",
"sourceE10": "E10",
"sourceE8": "E8",
"flowNo": "流程編號",
"requestTitle": "標題",
"createdAt": "建立時間",
"acceptanceNo": "驗收單單號",
"purchaseOrderNo": "採購單號",
"applicant": "申請人",
+7 -2
View File
@@ -1746,6 +1746,7 @@
"download": "下載 Excel",
"rpa": "RPA 上傳",
"confirm": "確認上傳",
"refreshStatus": "重新整理上傳狀態",
"lineNo": "項次",
"lineNoSourceCustomerPo": "客戶 PO 行號",
"lineNoSourceSequence": "系統行序(未識別到內部項次)",
@@ -1758,6 +1759,7 @@
"uploadStatus": {
"pending": "待上傳",
"uploading": "上傳中",
"allocating": "已接收,分配中",
"failed": "上傳失敗",
"uploaded": "已上傳",
"needsHuman": "需人工上傳"
@@ -3805,14 +3807,13 @@
"colMaterial": "料號",
"colName": "品名",
"colSpec": "規格",
"colInvoice": "Invoice",
"colMovementDate": "異動日期",
"colFromWarehouse": "撥出倉庫",
"colFromQty": "庫存數量",
"stockCheckedAtTitle": "庫存查詢時刻:{time}",
"colToWarehouse": "撥入倉庫",
"colFromBatch": "撥出批號",
"filterPlaceholder": "按料號 / 品名 / Invoice / 批號篩選",
"filterPlaceholder": "按料號 / 品名 / 單號 / 外部單號 / 批號篩選",
"filterAll": "全部結果",
"requerySelected": "重查選中",
"movementDateLabel": "異動日期",
@@ -3828,7 +3829,11 @@
"resultFileRemoved": "檔案已移除",
"resultPendingStockCheck": "待查庫存",
"staleRow": "資料已過期,請重查",
"staleShort": "已過期",
"staleBanner": "{count} 行庫存已過期",
"staleBannerRequery": "重查過期行",
"fileChangedRow": "檔案已更新,將自動對齊",
"fileChangedShort": "檔案更新",
"fileRemovedQuarantined": "另有 {count} 筆已隨入站檔案移除而失效,已移出本清單;請到「待處理異常」處理,可標記無需繼續處理。",
"runProgress": "調撥執行進度",
"runExecuting": "執行中",
+3
View File
@@ -17,6 +17,9 @@
"ORDER_DELIVERY_REPLY.BATCH_INVALID": "批次格式不合法,請檢查交期、數量或備註。",
"ORDER_DELIVERY_REPLY.BATCH_QTY_TOTAL_MISMATCH": "各批次數量合計必須等於訂單數量,請調整後重新保存。",
"SHIPPING.NOTICE_ODM_CHOICE_INVALID": "所選 ODM ID 不在當前可行候選內,請重新選擇。",
"SHIPPING.UPLOAD_CRANE_ALLOCATING": "貨代已接收檔案並正在分配,請重新整理狀態,不要再次上傳。",
"SHIPPING.UPLOAD_CRANE_REFRESH_INFLIGHT": "上一次狀態重新整理還在排隊,請稍後再試。",
"SHIPPING.UPLOAD_TRIGGER_UNAVAILABLE": "上傳回查目錄不可用,請檢查 RPA 共用目錄。",
"SHIPPING.FULFILLMENT_POLICY_INVALID": "貨代履約策略或欄位能力綁定無效。",
"SHIPPING.FULFILLMENT_POLICY_NOT_FOUND": "找不到貨代履約策略。",
"SHIPPING.FULFILLMENT_POLICY_CONFLICT": "貨代履約策略已被其他管理員修改,請重新整理後再試。",
@@ -0,0 +1,87 @@
/**
* shared/styles/element-theme.css
* 用途:全站 Element Plus 的字体、字号、颜色、圆角、控件高度,以及和 Tailwind 共存的修正。
* 依赖:tokens.css 的 --text-* / --bg-* / --border-*,element-plus 暗色变量,Tailwind preflight。
* 逻辑:用到 Element 的页面在 element-plus/theme-chalk/dark/css-vars.css 之后引入,html.dark 才能盖过 Element 默认暗色。
* 管理列表的列内边距和分页条不在这里,见 features/admin/styles/element-trial.css。
* 字号和颜色以本文变量为准。页面不要再用 text-sm / text-muted 改表格和按钮。
*/
:root,
html.dark {
--el-color-primary: #0284c7;
--el-color-primary-light-3: #4da3d6;
--el-color-primary-light-5: #81c2e3;
--el-color-primary-light-7: #b4daf0;
--el-color-primary-light-8: #cde6f4;
--el-color-primary-light-9: #e6f3fa;
--el-color-primary-dark-2: #0269a0;
--el-font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
--el-font-size-extra-large: 20px;
--el-font-size-large: 18px;
--el-font-size-medium: 16px;
--el-font-size-base: 14px;
--el-font-size-small: 13px;
--el-font-size-extra-small: 12px;
--el-text-color-primary: var(--text-primary);
--el-text-color-regular: var(--text-secondary);
--el-text-color-secondary: var(--text-muted);
--el-text-color-placeholder: var(--text-muted);
--el-text-color-disabled: var(--text-muted);
--el-border-color: var(--border-default);
--el-border-color-light: var(--border-subtle);
--el-border-color-lighter: var(--border-subtle);
--el-bg-color: var(--bg-surface);
--el-bg-color-overlay: var(--bg-surface);
--el-fill-color-blank: var(--bg-surface);
--el-fill-color-light: var(--bg-surface-soft);
--el-border-radius-base: 8px;
--el-component-size: 32px;
}
.el-button {
display: inline-flex;
align-items: center;
justify-content: center;
}
.el-button .el-icon,
.el-button svg {
display: inline-flex;
flex: none;
}
/* Tailwind forms 会给单行输入框内部的 input 加边框。聚焦时左右两边会多出两条蓝线。
多行输入框的边框就画在 .el-textarea__inner 上,不能一起清掉。 */
.el-input__inner,
.el-select__input,
.el-range-input,
.el-input__inner:hover,
.el-select__input:hover,
.el-range-input:hover,
.el-input__inner:focus,
.el-select__input:focus,
.el-range-input:focus {
border: 0;
outline: none;
background-color: transparent;
box-shadow: none;
--tw-ring-shadow: 0 0 #0000;
--tw-ring-offset-shadow: 0 0 #0000;
}
.el-textarea__inner {
background-color: var(--el-input-bg-color, var(--el-fill-color-blank));
box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color)) inset;
}
.el-textarea__inner:hover {
box-shadow: 0 0 0 1px var(--el-input-hover-border-color, var(--el-border-color-hover)) inset;
}
.el-textarea__inner:focus {
outline: none;
box-shadow: 0 0 0 1px var(--el-input-focus-border-color, var(--el-color-primary)) inset;
--tw-ring-shadow: 0 0 #0000;
--tw-ring-offset-shadow: 0 0 #0000;
}