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

@@ -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 {