Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8c48329d4e | ||
|
|
a10ecc8073 | ||
|
|
70c7f03a5a | ||
|
|
b032bb6729 | ||
|
|
627da80e65 | ||
|
|
47ff0107bd | ||
|
|
8cd8012632 |
No files matched your search
@@ -1,27 +1,32 @@
|
|||||||
/**
|
/**
|
||||||
* features/admin/modules/approvals/ApprovalsPage.vue
|
* features/admin/modules/approvals/ApprovalsPage.vue
|
||||||
* 用户注册审批独立页面。路由:/admin/approvals
|
* 用途:用户注册审批列表。一张卡片里放标题和待审表格。
|
||||||
|
* 依赖:AdminListPage、useApprovalsAdmin、useElementProvider、element-plus、roleLabel。
|
||||||
|
* 逻辑:路由未挂进当前菜单。通过和拒绝由 composable 弹出 Element 确认框后调接口。
|
||||||
*/
|
*/
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { ShieldCheck, Trash2 } from 'lucide-vue-next';
|
import { CircleCheck, Delete } from '@element-plus/icons-vue';
|
||||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
import { ElButton, ElConfigProvider, ElTable, ElTableColumn, ElTag } from 'element-plus';
|
||||||
|
import 'element-plus/dist/index.css';
|
||||||
|
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||||
|
import '@/features/admin/styles/element-trial.css';
|
||||||
|
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||||
|
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||||
import { adminRoleLabel } from '@/features/admin/utils/roleLabel';
|
import { adminRoleLabel } from '@/features/admin/utils/roleLabel';
|
||||||
|
import type { AdminUserRow } from '@/features/admin/types/admin.types';
|
||||||
import { useApprovalsAdmin } from './composables/useApprovalsAdmin';
|
import { useApprovalsAdmin } from './composables/useApprovalsAdmin';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const { elementLocale } = useElementProvider();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
pendingUsers,
|
pendingUsers,
|
||||||
isLoading,
|
isLoading,
|
||||||
showConfirmDialog,
|
|
||||||
confirmMessage,
|
|
||||||
loadAll,
|
loadAll,
|
||||||
approveUser,
|
approveUser,
|
||||||
rejectUser,
|
rejectUser,
|
||||||
closeConfirm,
|
|
||||||
confirmActionHandler,
|
|
||||||
} = useApprovalsAdmin();
|
} = useApprovalsAdmin();
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -30,80 +35,60 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<section class="admin-table-section">
|
<ElConfigProvider :locale="elementLocale">
|
||||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
<AdminListPage :loading="isLoading">
|
||||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
<template #title>
|
||||||
</div>
|
<h2 class="section-title">{{ t('admin.approval.title') }}</h2>
|
||||||
|
<p class="section-desc">{{ t('admin.approval.subtitle') }}</p>
|
||||||
|
</template>
|
||||||
|
|
||||||
<template v-else>
|
<ElTable
|
||||||
<div class="admin-table-header">
|
class="hx-admin-table"
|
||||||
<div>
|
:data="pendingUsers"
|
||||||
<h2 class="section-title">{{ t('admin.approval.title') }}</h2>
|
row-key="id"
|
||||||
<p class="section-desc mt-1">{{ t('admin.approval.subtitle') }}</p>
|
:empty-text="t('admin.approval.noPending')"
|
||||||
</div>
|
>
|
||||||
</div>
|
<ElTableColumn :label="t('admin.approval.headers.username')" min-width="200">
|
||||||
|
<template #default="{ row }">
|
||||||
<div class="admin-table-wrap">
|
<div>{{ (row as AdminUserRow).username }}</div>
|
||||||
<table class="admin-table">
|
<p class="hx-element-hint">{{ (row as AdminUserRow).email }}</p>
|
||||||
<thead>
|
</template>
|
||||||
<tr>
|
</ElTableColumn>
|
||||||
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.username') }}</th>
|
<ElTableColumn :label="t('admin.approval.headers.nameId')" min-width="160">
|
||||||
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.nameId') }}</th>
|
<template #default="{ row }">
|
||||||
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.contact') }}</th>
|
<div>{{ (row as AdminUserRow).real_name || '-' }}</div>
|
||||||
<th class="px-8 py-4 text-left text-xs">{{ t('admin.approval.headers.role') }}</th>
|
<p class="hx-element-hint">{{ (row as AdminUserRow).employee_id || '-' }}</p>
|
||||||
<th class="px-8 py-4 text-right text-xs">{{ t('admin.approval.headers.actions') }}</th>
|
</template>
|
||||||
</tr>
|
</ElTableColumn>
|
||||||
</thead>
|
<ElTableColumn :label="t('admin.approval.headers.contact')" min-width="140">
|
||||||
<tbody>
|
<template #default="{ row }">{{ (row as AdminUserRow).phone_number || '-' }}</template>
|
||||||
<tr v-if="pendingUsers.length === 0">
|
</ElTableColumn>
|
||||||
<td colspan="5" class="px-8 admin-table-empty">{{ t('admin.approval.noPending') }}</td>
|
<ElTableColumn :label="t('admin.approval.headers.role')" min-width="120">
|
||||||
</tr>
|
<template #default="{ row }">
|
||||||
<tr v-for="user in pendingUsers" :key="user.id">
|
<ElTag effect="light" type="warning">
|
||||||
<td class="px-8 py-5 text-sm font-medium text-primary">
|
{{ adminRoleLabel(t, (row as AdminUserRow).role, (row as AdminUserRow).role_name) }}
|
||||||
<div>{{ user.username }}</div>
|
</ElTag>
|
||||||
<div class="text-xs text-muted font-normal">{{ user.email }}</div>
|
</template>
|
||||||
</td>
|
</ElTableColumn>
|
||||||
<td class="px-8 py-5 text-sm text-muted">
|
<ElTableColumn :label="t('admin.approval.headers.actions')" width="120" align="right">
|
||||||
<div>{{ user.real_name || '-' }}</div>
|
<template #default="{ row }">
|
||||||
<div class="text-xs text-muted font-mono">{{ user.employee_id || '-' }}</div>
|
<ElButton
|
||||||
</td>
|
link
|
||||||
<td class="px-8 py-5 text-sm text-muted">{{ user.phone_number || '-' }}</td>
|
type="primary"
|
||||||
<td class="px-8 py-5">
|
:icon="CircleCheck"
|
||||||
<span
|
:title="t('admin.approval.confirmApprove')"
|
||||||
class="px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-100 text-yellow-800 border border-yellow-200"
|
@click="approveUser((row as AdminUserRow).id)"
|
||||||
>
|
/>
|
||||||
{{ adminRoleLabel(t, user.role, user.role_name) }}
|
<ElButton
|
||||||
</span>
|
link
|
||||||
</td>
|
type="danger"
|
||||||
<td class="px-8 py-5 text-right flex items-center justify-end gap-2">
|
:icon="Delete"
|
||||||
<button
|
:title="t('admin.approval.confirmReject')"
|
||||||
type="button"
|
@click="rejectUser((row as AdminUserRow).id)"
|
||||||
class="p-2 text-green-600 bg-green-50 rounded-lg hover:bg-green-100 transition-colors"
|
/>
|
||||||
:title="t('admin.approval.confirmApprove')"
|
</template>
|
||||||
@click="approveUser(user.id)"
|
</ElTableColumn>
|
||||||
>
|
</ElTable>
|
||||||
<ShieldCheck class="w-4 h-4" />
|
</AdminListPage>
|
||||||
</button>
|
</ElConfigProvider>
|
||||||
<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>
|
|
||||||
</template>
|
</template>
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* features/admin/modules/approvals/composables/useApprovalsAdmin.ts
|
* features/admin/modules/approvals/composables/useApprovalsAdmin.ts
|
||||||
* 用户注册审批:待审列表、通过、拒绝。
|
* 用途:用户注册审批的待审列表、通过和拒绝。
|
||||||
|
* 依赖:admin.api、useMessage、useAdminNavBadges、element-plus 的确认框。
|
||||||
|
* 逻辑:ApprovalsPage 调用本模块;通过和拒绝都先弹出 Element 确认框,成功后刷新列表和导航角标。
|
||||||
*/
|
*/
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { ElMessageBox } from 'element-plus';
|
||||||
import { approveAdminUser, listAdminUsers, rejectAdminUser } from '@/features/admin/api/admin.api';
|
import { approveAdminUser, listAdminUsers, rejectAdminUser } from '@/features/admin/api/admin.api';
|
||||||
import { useMessage } from '@/shared/composables/useMessage';
|
import { useMessage } from '@/shared/composables/useMessage';
|
||||||
import { useAdminNavBadges } from '@/features/admin/composables/useAdminNavBadges';
|
import { useAdminNavBadges } from '@/features/admin/composables/useAdminNavBadges';
|
||||||
@@ -17,10 +20,6 @@ export function useApprovalsAdmin() {
|
|||||||
const users = ref<AdminUserRow[]>([]);
|
const users = ref<AdminUserRow[]>([]);
|
||||||
const isLoading = ref(true);
|
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 pendingUsers = computed(() => users.value.filter((u) => u.status === 'pending'));
|
||||||
|
|
||||||
const loadUsers = async (): Promise<void> => {
|
const loadUsers = async (): Promise<void> => {
|
||||||
@@ -38,61 +37,61 @@ export function useApprovalsAdmin() {
|
|||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const openConfirm = (message: string, action: () => Promise<void> | void): void => {
|
/**
|
||||||
confirmMessage.value = message;
|
* 弹出确认框。点取消时 Element 会拒绝 Promise,这里吞掉,不当成失败。
|
||||||
confirmAction = action;
|
* @param message - 确认正文
|
||||||
showConfirmDialog.value = true;
|
* @returns 用户是否点了确定
|
||||||
};
|
*/
|
||||||
|
async function confirmAction(message: string): Promise<boolean> {
|
||||||
const closeConfirm = (): void => {
|
|
||||||
showConfirmDialog.value = false;
|
|
||||||
confirmAction = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const confirmActionHandler = async (): Promise<void> => {
|
|
||||||
if (!confirmAction) return;
|
|
||||||
try {
|
try {
|
||||||
await confirmAction();
|
await ElMessageBox.confirm(message, t('common.deleteDialog.defaultTitle'), {
|
||||||
} finally {
|
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||||
closeConfirm();
|
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||||
|
type: 'warning',
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const approveUser = (userId: number): void => {
|
/**
|
||||||
openConfirm(t('admin.approval.confirmApprove'), async () => {
|
* 通过一条待审注册。先确认,再调审批接口并刷新角标。
|
||||||
try {
|
* @param userId - 待审用户主键
|
||||||
await approveAdminUser(userId);
|
*/
|
||||||
await loadUsers();
|
async function approveUser(userId: number): Promise<void> {
|
||||||
await refreshBadges();
|
if (!(await confirmAction(t('admin.approval.confirmApprove')))) return;
|
||||||
} catch (e) {
|
try {
|
||||||
console.error(e);
|
await approveAdminUser(userId);
|
||||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
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 {
|
* @param userId - 待审用户主键
|
||||||
await rejectAdminUser(userId);
|
*/
|
||||||
await loadUsers();
|
async function rejectUser(userId: number): Promise<void> {
|
||||||
await refreshBadges();
|
if (!(await confirmAction(t('admin.approval.confirmReject')))) return;
|
||||||
} catch (e) {
|
try {
|
||||||
console.error(e);
|
await rejectAdminUser(userId);
|
||||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
await loadUsers();
|
||||||
}
|
await refreshBadges();
|
||||||
});
|
} catch (e) {
|
||||||
};
|
console.error(e);
|
||||||
|
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pendingUsers,
|
pendingUsers,
|
||||||
isLoading,
|
isLoading,
|
||||||
showConfirmDialog,
|
|
||||||
confirmMessage,
|
|
||||||
loadAll,
|
loadAll,
|
||||||
approveUser,
|
approveUser,
|
||||||
rejectUser,
|
rejectUser,
|
||||||
closeConfirm,
|
|
||||||
confirmActionHandler,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
/**
|
/**
|
||||||
* features/admin/modules/departments/DepartmentsPage.vue
|
* features/admin/modules/departments/DepartmentsPage.vue
|
||||||
* 用途:部门管理列表。一张卡片里放标题、添加按钮、搜索、表格。
|
* 用途:部门管理列表。一张卡片里放标题、添加按钮、搜索、表格。
|
||||||
* 依赖:AdminListPage、useDepartmentsAdmin、useElementProvider、element-plus、lucide-vue-next、部门表单和员工名单弹窗。
|
* 依赖:AdminListPage、useDepartmentsAdmin、useElementProvider、element-plus、部门表单和员工名单弹窗。
|
||||||
* 逻辑:路由 /admin/departments。骨架用 AdminListPage。筛选、列和两个弹窗留在本页。
|
* 逻辑:路由 /admin/departments。骨架用 AdminListPage。筛选、列和两个弹窗留在本页。
|
||||||
* 名称、编码、公司用表头排序,排的是当前过滤结果。删除用 Element 确认框。
|
* 名称、编码、公司用表头排序,排的是当前过滤结果。删除用 Element 确认框。
|
||||||
* 表格用 Element stripe 斑马纹。员工、编辑、删除保持图标按钮,悬停文案走 i18n title。
|
* 表格用 Element stripe 斑马纹。员工数、编辑、删除用 Element 链接按钮,悬停文案走 i18n title。
|
||||||
*/
|
*/
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, onMounted, ref } from 'vue';
|
import { computed, onMounted, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { Plus } from '@element-plus/icons-vue';
|
import { Delete, Edit, Plus, User } from '@element-plus/icons-vue';
|
||||||
import { Edit, Trash2, Users } from 'lucide-vue-next';
|
|
||||||
import {
|
import {
|
||||||
ElButton,
|
ElButton,
|
||||||
ElConfigProvider,
|
ElConfigProvider,
|
||||||
@@ -157,36 +156,34 @@ onMounted(() => {
|
|||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
<ElTableColumn :label="t('admin.dept.headers.members')" width="120" align="center">
|
<ElTableColumn :label="t('admin.dept.headers.members')" width="120" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<button
|
<ElButton
|
||||||
type="button"
|
link
|
||||||
class="dept-member-btn"
|
type="primary"
|
||||||
|
:icon="User"
|
||||||
:title="t('admin.dept.actions.viewMembers')"
|
:title="t('admin.dept.actions.viewMembers')"
|
||||||
@click="openDepartmentMembers((row as AdminDepartmentRow).id)"
|
@click="openDepartmentMembers((row as AdminDepartmentRow).id)"
|
||||||
>
|
>
|
||||||
<Users class="dept-member-icon" />
|
{{ row.member_count || 0 }}
|
||||||
<span>{{ row.member_count || 0 }}</span>
|
</ElButton>
|
||||||
</button>
|
|
||||||
</template>
|
</template>
|
||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
<ElTableColumn :label="t('admin.dept.headers.actions')" width="120" align="right">
|
<ElTableColumn :label="t('admin.dept.headers.actions')" width="120" align="right">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div class="dept-row-actions">
|
<div class="dept-row-actions">
|
||||||
<button
|
<ElButton
|
||||||
type="button"
|
link
|
||||||
class="dept-icon-btn dept-icon-btn--edit"
|
type="primary"
|
||||||
|
:icon="Edit"
|
||||||
:title="t('admin.dept.actions.edit')"
|
:title="t('admin.dept.actions.edit')"
|
||||||
@click="editDepartment(row as AdminDepartmentRow)"
|
@click="editDepartment(row as AdminDepartmentRow)"
|
||||||
>
|
/>
|
||||||
<Edit class="dept-action-icon" />
|
<ElButton
|
||||||
</button>
|
link
|
||||||
<button
|
type="danger"
|
||||||
type="button"
|
:icon="Delete"
|
||||||
class="dept-icon-btn dept-icon-btn--delete"
|
|
||||||
:title="t('admin.dept.actions.delete')"
|
:title="t('admin.dept.actions.delete')"
|
||||||
@click="deleteDepartment((row as AdminDepartmentRow).id)"
|
@click="deleteDepartment((row as AdminDepartmentRow).id)"
|
||||||
>
|
/>
|
||||||
<Trash2 class="dept-action-icon" />
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</ElTableColumn>
|
</ElTableColumn>
|
||||||
@@ -219,69 +216,9 @@ onMounted(() => {
|
|||||||
white-space: nowrap;
|
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 {
|
.dept-row-actions {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
gap: 4px;
|
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>
|
</style>
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* features/admin/modules/reports/composables/useReportsAdmin.ts
|
* features/admin/modules/reports/composables/useReportsAdmin.ts
|
||||||
* 用途:管理后台报表(多表浏览、筛选、排序、chat_logs 批量删除、使用分析与应用运营看板)。
|
* 用途:管理后台报表(多表浏览、筛选、排序、chat_logs 批量删除、使用分析与应用运营看板)。
|
||||||
* 依赖:admin.api、useReportLayoutStorage、useOffsetPagination、useMessage、dateTime、vue-router。
|
* 依赖:admin.api、useReportLayoutStorage、useOffsetPagination、useMessage、dateTime、vue-router、element-plus(ElMessageBox)。
|
||||||
* 逻辑:ReportsPage 调用本 composable;使用分析按用户服务端分页、按应用前端分页,均复用 PaginationBar;
|
* 逻辑:ReportsPage 调用本 composable;使用分析按用户服务端分页、按应用前端分页,页码状态交给页面的 ElPagination;
|
||||||
* 低使用应用优先消费后端 low_agents(含零使用启用应用),与应用运营口径对齐;
|
* 低使用应用优先消费后端 low_agents(含零使用启用应用),与应用运营口径对齐;
|
||||||
* 统计范围统一为开始/结束日期(默认近 30 天),经 start_date/end_date 传给后端,聊天日志走 created_from/created_to;
|
* 统计范围统一为开始/结束日期(默认近 30 天),经 start_date/end_date 传给后端,聊天日志走 created_from/created_to;
|
||||||
* 趋势 by_day 前端按日期升序兜底;问题分析优先问题表前端分页;非表页切换时清空通用表状态防幽灵分页。
|
* 趋势 by_day 前端按日期升序兜底;问题分析优先问题表前端分页;非表页切换时清空通用表状态防幽灵分页。
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
import { ElMessageBox } from 'element-plus';
|
||||||
import * as XLSX from 'xlsx';
|
import * as XLSX from 'xlsx';
|
||||||
import {
|
import {
|
||||||
batchDeleteAdminChatLogs,
|
batchDeleteAdminChatLogs,
|
||||||
@@ -655,30 +656,6 @@ export function useReportsAdmin() {
|
|||||||
};
|
};
|
||||||
const isLoading = ref(true);
|
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 resolveTableFromRoute = (): AdminReportTableId => {
|
||||||
const table = route.params.table;
|
const table = route.params.table;
|
||||||
if (typeof table === 'string' && (ADMIN_REPORT_TABLES as readonly string[]).includes(table)) {
|
if (typeof table === 'string' && (ADMIN_REPORT_TABLES as readonly string[]).includes(table)) {
|
||||||
@@ -1575,25 +1552,41 @@ const toggleAllReportRows = () => {
|
|||||||
selectedReportRowIds.value = Array.from(merged);
|
selectedReportRowIds.value = Array.from(merged);
|
||||||
};
|
};
|
||||||
|
|
||||||
const batchDeleteChatLogs = async () => {
|
/**
|
||||||
|
* 批量删除已勾选的聊天日志。
|
||||||
|
* 核心逻辑:先弹出 Element 确认框;取消则直接返回。确认后按当前选中 id 调用原批量删除接口并刷新列表与总数。
|
||||||
|
* @returns 无。取消确认时不请求接口。
|
||||||
|
*/
|
||||||
|
const batchDeleteChatLogs = async (): Promise<void> => {
|
||||||
if (!isChatLogsTable.value) return;
|
if (!isChatLogsTable.value) return;
|
||||||
if (selectedReportRowIds.value.length === 0) return;
|
if (selectedReportRowIds.value.length === 0) return;
|
||||||
const targetRowIds = [...selectedReportRowIds.value];
|
const targetRowIds = [...selectedReportRowIds.value];
|
||||||
openDeleteConfirm(`Delete ${targetRowIds.length} selected chat logs?`, async () => {
|
try {
|
||||||
isDeletingChatLogs.value = true;
|
await ElMessageBox.confirm(
|
||||||
try {
|
t('admin.report.deleteSelected', { count: targetRowIds.length }),
|
||||||
const data = await batchDeleteAdminChatLogs(targetRowIds);
|
t('common.deleteDialog.defaultTitle'),
|
||||||
msg.success(`Deleted ${data.deleted_count ?? 0} chat logs.`);
|
{
|
||||||
selectedReportRowIds.value = [];
|
type: 'warning',
|
||||||
await loadTableData();
|
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||||
chatLogsTotal.value = await loadTableCount('chat_logs');
|
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||||
} catch (e) {
|
},
|
||||||
console.error(e);
|
);
|
||||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
} catch {
|
||||||
} finally {
|
return;
|
||||||
isDeletingChatLogs.value = false;
|
}
|
||||||
}
|
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 () => {
|
watch(currentTable, async () => {
|
||||||
@@ -1913,8 +1906,6 @@ watch([reportPageSize, issueQuestionTotal], () => {
|
|||||||
reportRangeStart,
|
reportRangeStart,
|
||||||
reportRangeEnd,
|
reportRangeEnd,
|
||||||
reportPageButtons,
|
reportPageButtons,
|
||||||
showDeleteConfirmDialog,
|
|
||||||
deleteConfirmMessage,
|
|
||||||
loadAll,
|
loadAll,
|
||||||
handleFilterChange,
|
handleFilterChange,
|
||||||
resetChatLogsColumns,
|
resetChatLogsColumns,
|
||||||
@@ -1941,6 +1932,5 @@ watch([reportPageSize, issueQuestionTotal], () => {
|
|||||||
goToReportPage,
|
goToReportPage,
|
||||||
prevReportPage,
|
prevReportPage,
|
||||||
nextReportPage,
|
nextReportPage,
|
||||||
confirmDelete,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
+123
-71
@@ -1,14 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/training-config/components/LeanTargetModal.vue
|
* features/admin/modules/training-config/components/LeanTargetModal.vue
|
||||||
* 用途:精益周任务"受训对象"选择弹窗,支持按角色、按员工两个维度多选(两个范围取并集生效)。
|
* 用途:精益周任务受训对象选择对话框,按角色和员工两个维度多选。
|
||||||
* 依赖:vue-i18n、lucide 图标与父级培训配置页面传入的目标状态(角色/用户 ID/用户列表)。
|
* 依赖:element-plus 对话框、复选框和搜索框、vue-i18n、父级传入的用户列表。
|
||||||
* 逻辑:弹窗打开时从 props 快照到本地草稿(取消不污染外部状态);员工支持关键字搜索;
|
* 逻辑:打开时把父级选择快照到本地草稿,取消不回写。确认后 emit save,由父级随保存任务提交。
|
||||||
* 确认后 emit save({ roles, userIds }),由父级写回表单并随"保存任务"统一落库。
|
|
||||||
*/
|
*/
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
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';
|
import type { AdminUserRow } from '../../../types/admin.types';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
@@ -48,91 +47,144 @@ const summaryLabel = computed(() => t('admin.trainingConfig.lean.targetSelectedC
|
|||||||
users: draftUserIds.value.length,
|
users: draftUserIds.value.length,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切换一个角色是否进入本次草稿。
|
||||||
|
* @param role - 角色名
|
||||||
|
*/
|
||||||
const toggleRole = (role: string) => {
|
const toggleRole = (role: string) => {
|
||||||
draftRoles.value = draftRoles.value.includes(role)
|
draftRoles.value = draftRoles.value.includes(role)
|
||||||
? draftRoles.value.filter((item) => item !== role)
|
? draftRoles.value.filter((item) => item !== role)
|
||||||
: [...draftRoles.value, role];
|
: [...draftRoles.value, role];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 切换一名员工是否进入本次草稿。
|
||||||
|
* @param userId - 用户主键
|
||||||
|
*/
|
||||||
const toggleUser = (userId: number) => {
|
const toggleUser = (userId: number) => {
|
||||||
draftUserIds.value = draftUserIds.value.includes(userId)
|
draftUserIds.value = draftUserIds.value.includes(userId)
|
||||||
? draftUserIds.value.filter((item) => item !== userId)
|
? draftUserIds.value.filter((item) => item !== userId)
|
||||||
: [...draftUserIds.value, userId];
|
: [...draftUserIds.value, userId];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 把草稿交回父级。落库仍等父级保存周任务。
|
||||||
|
*/
|
||||||
const handleSave = () => {
|
const handleSave = () => {
|
||||||
emit('save', { roles: [...draftRoles.value], userIds: [...draftUserIds.value] });
|
emit('save', { roles: [...draftRoles.value], userIds: [...draftUserIds.value] });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话框关闭时通知页面收起。
|
||||||
|
* @param open - Element 对话框的打开状态
|
||||||
|
*/
|
||||||
|
function onVisibleChange(open: boolean): void {
|
||||||
|
if (!open) emit('close');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="props.visible" class="admin-modal-overlay animate-fade-in items-center" @click.self="emit('close')">
|
<ElDialog
|
||||||
<div class="admin-modal-panel max-w-2xl max-h-[92vh] scale-100">
|
:model-value="props.visible"
|
||||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
:title="t('admin.trainingConfig.lean.targetModalTitle')"
|
||||||
<h3 class="section-title">{{ t('admin.trainingConfig.lean.targetModalTitle') }}</h3>
|
width="680px"
|
||||||
<p class="mt-1 text-xs text-muted">{{ t('admin.trainingConfig.lean.targetsHint') }}</p>
|
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>
|
||||||
<div class="px-5 sm:px-8 py-5 overflow-y-auto">
|
</ElForm>
|
||||||
<div class="grid gap-5 md:grid-cols-2">
|
<template #footer>
|
||||||
<!-- 按角色选择 -->
|
<div class="lean-target-footer">
|
||||||
<div class="space-y-2">
|
<ElText type="info">{{ summaryLabel }}</ElText>
|
||||||
<label class="label-field">{{ t('admin.trainingConfig.lean.targetRoles') }}</label>
|
<div>
|
||||||
<div class="space-y-2 rounded-xl border border-default bg-surface p-3">
|
<ElButton @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||||
<label
|
<ElButton type="primary" @click="handleSave">{{ t('admin.trainingConfig.lean.targetConfirm') }}</ElButton>
|
||||||
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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="admin-modal-footer">
|
</template>
|
||||||
<p class="mr-auto text-xs text-muted">{{ summaryLabel }}</p>
|
</ElDialog>
|
||||||
<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>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.lean-target-form {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lean-target-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lean-target-list {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid var(--el-border-color);
|
||||||
|
border-radius: var(--el-border-radius-base);
|
||||||
|
}
|
||||||
|
|
||||||
|
.lean-target-list--scroll {
|
||||||
|
max-height: 16rem;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.lean-target-search) {
|
||||||
|
width: 16rem;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lean-target-footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.lean-target-grid {
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+42
-33
@@ -1,11 +1,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/training-config/components/TrainingTypeFormModal.vue
|
* features/admin/modules/training-config/components/TrainingTypeFormModal.vue
|
||||||
* 用途:提供培训类型 code 与名称的新增、编辑弹窗。
|
* 用途:培训类型编码和名称的新增、编辑对话框。
|
||||||
* 依赖:vue-i18n 与父级培训配置页面的表单状态。
|
* 依赖:element-plus 对话框和表单、vue-i18n、父级传入的类型表单。
|
||||||
* 逻辑:允许管理员输入符合编码规范的自定义类型 code,并将保存动作交由父级处理。
|
* 逻辑:TrainingConfigPage 打开本组件。字段仍写回父级 form 对象,保存由父级校验并调接口。样式跟页面已引入的 Element 皮肤走。
|
||||||
*/
|
*/
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { ElButton, ElDialog, ElForm, ElFormItem, ElInput } from 'element-plus';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
@@ -16,37 +17,45 @@ const props = defineProps<{
|
|||||||
|
|
||||||
const emit = defineEmits<{ close: []; save: [] }>();
|
const emit = defineEmits<{ close: []; save: [] }>();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对话框关闭时通知页面收起。提交中不响应关闭。
|
||||||
|
* @param open - Element 对话框的打开状态
|
||||||
|
*/
|
||||||
|
function onVisibleChange(open: boolean): void {
|
||||||
|
if (!open && !props.isSaving) emit('close');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="props.visible" class="admin-modal-overlay animate-fade-in items-center" @click.self="emit('close')">
|
<ElDialog
|
||||||
<div class="admin-modal-panel max-w-lg max-h-[92vh] scale-100">
|
:model-value="visible"
|
||||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
:title="editing ? t('admin.trainingConfig.editType') : t('admin.trainingConfig.addType')"
|
||||||
<h3 class="section-title">{{ props.editing ? t('admin.trainingConfig.editType') : t('admin.trainingConfig.addType') }}</h3>
|
width="480px"
|
||||||
</div>
|
align-center
|
||||||
<div class="px-5 sm:px-8 py-5 space-y-4 overflow-y-auto">
|
append-to-body
|
||||||
<div class="space-y-1.5">
|
:close-on-click-modal="false"
|
||||||
<label class="label-field">{{ t('admin.trainingConfig.fields.type') }}</label>
|
:close-on-press-escape="!isSaving"
|
||||||
<input
|
:show-close="!isSaving"
|
||||||
v-model="props.form.training_type"
|
@update:model-value="onVisibleChange"
|
||||||
type="text"
|
>
|
||||||
class="input-field text-sm"
|
<ElForm label-position="top" :model="form" @submit.prevent="emit('save')">
|
||||||
maxlength="50"
|
<ElFormItem :label="t('admin.trainingConfig.fields.type')">
|
||||||
pattern="[a-z][a-z0-9_-]*"
|
<ElInput
|
||||||
:placeholder="t('admin.trainingConfig.placeholders.typeCode')"
|
v-model="form.training_type"
|
||||||
/>
|
maxlength="50"
|
||||||
</div>
|
:placeholder="t('admin.trainingConfig.placeholders.typeCode')"
|
||||||
<div class="space-y-1.5">
|
/>
|
||||||
<label class="label-field">{{ t('admin.trainingConfig.fields.name') }}</label>
|
</ElFormItem>
|
||||||
<input v-model="props.form.name" type="text" class="input-field text-sm" :placeholder="t('admin.trainingConfig.fields.name')" />
|
<ElFormItem :label="t('admin.trainingConfig.fields.name')">
|
||||||
</div>
|
<ElInput v-model="form.name" :placeholder="t('admin.trainingConfig.fields.name')" />
|
||||||
</div>
|
</ElFormItem>
|
||||||
<div class="admin-modal-footer">
|
</ElForm>
|
||||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
<template #footer>
|
||||||
<button type="button" class="btn-primary disabled:opacity-70" :disabled="props.isSaving" @click="emit('save')">
|
<ElButton :disabled="isSaving" @click="emit('close')">{{ t('admin.cancel') }}</ElButton>
|
||||||
{{ props.isSaving ? `${t('admin.save')}...` : props.editing ? t('admin.update') : t('admin.add') }}
|
<ElButton type="primary" :loading="isSaving" @click="emit('save')">
|
||||||
</button>
|
{{ editing ? t('admin.update') : t('admin.add') }}
|
||||||
</div>
|
</ElButton>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
</ElDialog>
|
||||||
</template>
|
</template>
|
||||||
@@ -1,26 +1,24 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/wecom/WecomLayout.vue
|
* features/admin/modules/wecom/WecomLayout.vue
|
||||||
* 企微管理壳层:二级 Tab、共享 composable、子路由出口。
|
* 用途:企微管理壳层。注入共享数据,并提供 Element 语言与样式。
|
||||||
|
* 依赖:useWecomAdmin、useElementProvider、element-plus、WECOM_ADMIN_KEY。
|
||||||
|
* 逻辑:路由 /admin/wecom 的父级。首屏等 loadAll 结束后再渲染子页。子页自己放页签和列表,解绑确认在 composable 里完成。
|
||||||
*/
|
*/
|
||||||
import { onMounted, provide } from 'vue';
|
import { onMounted, provide } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { ElConfigProvider, ElLoading } from 'element-plus';
|
||||||
import { RefreshCw } from 'lucide-vue-next';
|
import 'element-plus/dist/index.css';
|
||||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||||
import WecomSubNav from './components/WecomSubNav.vue';
|
import '@/features/admin/styles/element-trial.css';
|
||||||
|
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||||
import { useWecomAdmin } from './composables/useWecomAdmin';
|
import { useWecomAdmin } from './composables/useWecomAdmin';
|
||||||
import { WECOM_ADMIN_KEY } from './wecom.context';
|
import { WECOM_ADMIN_KEY } from './wecom.context';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const vLoading = ElLoading.directive;
|
||||||
|
const { elementLocale } = useElementProvider();
|
||||||
const wecomAdmin = useWecomAdmin();
|
const wecomAdmin = useWecomAdmin();
|
||||||
|
const { isLoading } = wecomAdmin;
|
||||||
provide(WECOM_ADMIN_KEY, wecomAdmin);
|
provide(WECOM_ADMIN_KEY, wecomAdmin);
|
||||||
const {
|
|
||||||
isLoading,
|
|
||||||
showDeleteConfirmDialog,
|
|
||||||
deleteConfirmMessage,
|
|
||||||
confirmDelete,
|
|
||||||
refreshWecomData,
|
|
||||||
} = wecomAdmin;
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
void wecomAdmin.loadAll();
|
void wecomAdmin.loadAll();
|
||||||
@@ -28,33 +26,15 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
<ElConfigProvider :locale="elementLocale">
|
||||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
<div v-loading="isLoading" class="wecom-layout">
|
||||||
</div>
|
<router-view v-if="!isLoading" />
|
||||||
|
|
||||||
<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>
|
</div>
|
||||||
|
</ElConfigProvider>
|
||||||
<WecomSubNav />
|
|
||||||
<router-view />
|
|
||||||
|
|
||||||
<DeleteConfirmDialog
|
|
||||||
v-model="showDeleteConfirmDialog"
|
|
||||||
:message="deleteConfirmMessage"
|
|
||||||
@confirm="confirmDelete"
|
|
||||||
/>
|
|
||||||
</section>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.wecom-layout {
|
||||||
|
min-height: 16rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/wecom/components/WecomOverviewCards.vue
|
* features/admin/modules/wecom/components/WecomOverviewCards.vue
|
||||||
* 企微 userid 绑定概览统计卡片。
|
* 用途:企微 userid 绑定概览。四张统计卡,不是列表。
|
||||||
|
* 依赖:getAdminWecomBindingStats、element-plus 的卡片和统计。
|
||||||
|
* 逻辑:绑定管理页放在列表卡片正文里。数字用 ElStatistic;说明句用文字块。refreshKey 变化时重拉。
|
||||||
*/
|
*/
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { onMounted, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { ElCard, ElStatistic, ElText } from 'element-plus';
|
||||||
import { getAdminWecomBindingStats } from '@/features/admin/api/admin.api';
|
import { getAdminWecomBindingStats } from '@/features/admin/api/admin.api';
|
||||||
import type { WecomBindingStats } from '@/features/admin/types/wecom.types';
|
import type { WecomBindingStats } from '@/features/admin/types/wecom.types';
|
||||||
|
|
||||||
@@ -16,7 +19,8 @@ const { t } = useI18n();
|
|||||||
const stats = ref<WecomBindingStats | null>(null);
|
const stats = ref<WecomBindingStats | null>(null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拉取绑定统计,供设置页概览卡片展示。
|
* 拉取绑定统计,供概览卡片展示。
|
||||||
|
* 核心逻辑:请求失败时清空卡片,避免留下过期数字。
|
||||||
*/
|
*/
|
||||||
const loadStats = async (): Promise<void> => {
|
const loadStats = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
@@ -42,22 +46,43 @@ defineExpose({ reload: loadStats });
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="stats" class="grid grid-cols-2 xl:grid-cols-4 gap-3">
|
<div v-if="stats" class="wecom-overview">
|
||||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
<ElCard shadow="never">
|
||||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.bound') }}</div>
|
<ElStatistic
|
||||||
<div class="mt-1 text-xl font-semibold text-primary">{{ stats.bound }} / {{ stats.total_active }}</div>
|
:title="t('admin.wecom.overview.bound')"
|
||||||
</div>
|
:value="stats.bound"
|
||||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
:suffix="` / ${stats.total_active}`"
|
||||||
<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>
|
</ElCard>
|
||||||
</div>
|
<ElCard shadow="never">
|
||||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
<ElStatistic :title="t('admin.wecom.overview.unbound')" :value="stats.unbound" />
|
||||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.boundRate') }}</div>
|
</ElCard>
|
||||||
<div class="mt-1 text-xl font-semibold text-emerald-700">{{ stats.bound_rate }}%</div>
|
<ElCard shadow="never">
|
||||||
</div>
|
<ElStatistic :title="t('admin.wecom.overview.boundRate')" :value="stats.bound_rate" suffix="%" />
|
||||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
</ElCard>
|
||||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.hint') }}</div>
|
<ElCard shadow="never">
|
||||||
<div class="mt-1 text-sm text-secondary leading-5">{{ t('admin.wecom.overview.hintDesc') }}</div>
|
<div class="wecom-overview__hint-title">{{ t('admin.wecom.overview.hint') }}</div>
|
||||||
</div>
|
<ElText type="info">{{ t('admin.wecom.overview.hintDesc') }}</ElText>
|
||||||
|
</ElCard>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</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">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/wecom/components/WecomSubNav.vue
|
* 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 { 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 { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{ name: 'AdminWecomSettings', labelKey: 'admin.wecom.nav.settings' },
|
{ name: 'AdminWecomSettings', labelKey: 'admin.wecom.nav.settings' },
|
||||||
{ name: 'AdminWecomBindings', labelKey: 'admin.wecom.nav.bindings' },
|
{ name: 'AdminWecomBindings', labelKey: 'admin.wecom.nav.bindings' },
|
||||||
{ name: 'AdminWecomAudits', labelKey: 'admin.wecom.nav.audits' },
|
{ name: 'AdminWecomAudits', labelKey: 'admin.wecom.nav.audits' },
|
||||||
] as const;
|
] 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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-wrap gap-2 border-b border-subtle pb-3">
|
<AdminListTabs :model-value="activeTab" :items="tabItems" @update:model-value="onTabChange" />
|
||||||
<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>
|
|
||||||
</template>
|
</template>
|
||||||
@@ -1,14 +1,23 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/wecom/components/WecomSyncPanel.vue
|
* features/admin/modules/wecom/components/WecomSyncPanel.vue
|
||||||
* OA userInfo_view 工号→wecom_userid 同步面板(预览 + 确认写入)。
|
* 用途:OA userInfo_view 工号到 wecom_userid 的预览和确认写入面板。
|
||||||
* 依赖:useWecomSync、WECOM_ADMIN_KEY.refreshWecomData。
|
* 依赖:useWecomSync、WECOM_ADMIN_KEY.refreshWecomData、element-plus。
|
||||||
* 逻辑:绑定管理页调用;先扫本地工号,再按 IN 查 OA userInfo_view 匹配写入。
|
* 逻辑:绑定管理页调用。先扫本地工号,再按 IN 查 OA 匹配。确认写入在 composable 里弹 Element 确认框。
|
||||||
*/
|
*/
|
||||||
import { inject } from 'vue';
|
import { inject } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { RefreshCw } from 'lucide-vue-next';
|
import { Refresh } from '@element-plus/icons-vue';
|
||||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.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 { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||||
import { useWecomSync } from '../composables/useWecomSync';
|
import { useWecomSync } from '../composables/useWecomSync';
|
||||||
|
|
||||||
@@ -16,146 +25,190 @@ const emit = defineEmits<{
|
|||||||
applied: [];
|
applied: [];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const vLoading = ElLoading.directive;
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { refreshWecomData } = inject(WECOM_ADMIN_KEY)!;
|
const { refreshWecomData } = inject(WECOM_ADMIN_KEY)!;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isSyncing,
|
isSyncing,
|
||||||
previewSummary,
|
previewSummary,
|
||||||
showApplyConfirm,
|
|
||||||
canApplySync,
|
canApplySync,
|
||||||
applyBlockHint,
|
applyBlockHint,
|
||||||
previewSync,
|
previewSync,
|
||||||
requestApplySync,
|
requestApplySync,
|
||||||
confirmApplySync,
|
|
||||||
} = useWecomSync({
|
} = useWecomSync({
|
||||||
onApplied: async () => {
|
onApplied: async () => {
|
||||||
await refreshWecomData();
|
await refreshWecomData();
|
||||||
emit('applied');
|
emit('applied');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预览表的行键。同一工号待写入的 userid 唯一。
|
||||||
|
* @param row - 待更新行
|
||||||
|
* @returns 工号与 userid 拼成的键
|
||||||
|
*/
|
||||||
|
function pendingRowKey(row: WecomSyncPendingUpdate): string {
|
||||||
|
return `${row.employee_id}-${row.wecom_userid}`;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="card shadow-sm p-5 space-y-4">
|
<div class="wecom-sync">
|
||||||
<div>
|
<h3 class="wecom-sync__title">{{ t('admin.wecom.sync.title') }}</h3>
|
||||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.sync.title') }}</h3>
|
<ElText type="info">{{ t('admin.wecom.sync.desc') }}</ElText>
|
||||||
<p class="mt-1 text-sm text-muted">{{ t('admin.wecom.sync.desc') }}</p>
|
<ElAlert
|
||||||
<p class="mt-2 text-xs text-sky-900 bg-sky-50 border border-sky-100 rounded-lg px-3 py-2">
|
class="wecom-sync__note"
|
||||||
{{ t('admin.wecom.sync.oaSourceNote') }}
|
type="info"
|
||||||
</p>
|
:closable="false"
|
||||||
</div>
|
: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>
|
||||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.oaWorkcodeField') }}</div>
|
<div class="wecom-sync__label">{{ t('admin.wecom.sync.oaWorkcodeField') }}</div>
|
||||||
<div class="mt-1 font-mono text-primary">userInfo_view.workcode</div>
|
<div class="wecom-sync__mono">userInfo_view.workcode</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.oaWecomIdField') }}</div>
|
<div class="wecom-sync__label">{{ t('admin.wecom.sync.oaWecomIdField') }}</div>
|
||||||
<div class="mt-1 font-mono text-primary">userInfo_view.id</div>
|
<div class="wecom-sync__mono">userInfo_view.id</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-2">
|
<div class="wecom-sync__actions">
|
||||||
<div class="flex flex-wrap gap-2">
|
<ElButton type="primary" :icon="Refresh" :loading="isSyncing" @click="previewSync">
|
||||||
<button
|
{{ t('admin.wecom.sync.preview') }}
|
||||||
type="button"
|
</ElButton>
|
||||||
class="inline-flex items-center gap-2"
|
<ElButton
|
||||||
:class="isSyncing ? 'btn-secondary opacity-60' : 'btn-primary'"
|
:type="canApplySync ? 'primary' : 'default'"
|
||||||
:disabled="isSyncing"
|
:disabled="isSyncing"
|
||||||
@click="previewSync"
|
:title="applyBlockHint || undefined"
|
||||||
>
|
@click="requestApplySync"
|
||||||
<RefreshCw class="w-4 h-4" :class="{ 'animate-spin': isSyncing }" />
|
>
|
||||||
{{ t('admin.wecom.sync.preview') }}
|
{{ t('admin.wecom.sync.apply') }}
|
||||||
</button>
|
</ElButton>
|
||||||
<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>
|
</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 v-if="previewSummary" v-loading="isSyncing" class="wecom-sync__result">
|
||||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-3">
|
<div class="wecom-sync__stats">
|
||||||
<div>
|
<ElStatistic :title="t('admin.wecom.sync.stats.localCandidates')" :value="previewSummary.local_candidates" />
|
||||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.stats.localCandidates') }}</div>
|
<ElStatistic :title="t('admin.wecom.sync.stats.oaMatched')" :value="previewSummary.local_matched" />
|
||||||
<div class="font-semibold text-primary">{{ previewSummary.local_candidates }}</div>
|
<ElStatistic :title="t('admin.wecom.sync.stats.wouldUpdate')" :value="previewSummary.would_update" />
|
||||||
</div>
|
<ElStatistic :title="t('admin.wecom.sync.stats.conflicts')" :value="previewSummary.conflicts?.length || 0" />
|
||||||
<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>
|
</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 }) }}
|
{{ t('admin.wecom.sync.localMissingHint', { count: previewSummary.local_missing }) }}
|
||||||
</div>
|
</ElText>
|
||||||
|
|
||||||
<div v-if="previewSummary.pending_updates?.length" class="overflow-x-auto">
|
<ElTable
|
||||||
<table class="admin-table min-w-full">
|
v-if="previewSummary.pending_updates?.length"
|
||||||
<thead>
|
class="hx-admin-table"
|
||||||
<tr>
|
:data="previewSummary.pending_updates"
|
||||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.employeeId') }}</th>
|
:row-key="pendingRowKey"
|
||||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.user') }}</th>
|
:empty-text="t('admin.wecom.noData')"
|
||||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.wecomUserId') }}</th>
|
>
|
||||||
</tr>
|
<ElTableColumn :label="t('admin.wecom.headers.employeeId')" min-width="140">
|
||||||
</thead>
|
<template #default="{ row }">{{ (row as WecomSyncPendingUpdate).employee_id }}</template>
|
||||||
<tbody>
|
</ElTableColumn>
|
||||||
<tr v-for="row in previewSummary.pending_updates" :key="`${row.employee_id}-${row.wecom_userid}`">
|
<ElTableColumn :label="t('admin.wecom.headers.user')" min-width="180">
|
||||||
<td class="px-3 py-2 text-xs">{{ row.employee_id }}</td>
|
<template #default="{ row }">
|
||||||
<td class="px-3 py-2 text-xs">
|
{{ (row as WecomSyncPendingUpdate).username }}
|
||||||
{{ row.username }}
|
<ElText v-if="(row as WecomSyncPendingUpdate).name" type="info">
|
||||||
<span v-if="row.name" class="text-muted"> · {{ row.name }}</span>
|
· {{ (row as WecomSyncPendingUpdate).name }}
|
||||||
</td>
|
</ElText>
|
||||||
<td class="px-3 py-2 text-xs font-mono">{{ row.wecom_userid }}</td>
|
</template>
|
||||||
</tr>
|
</ElTableColumn>
|
||||||
</tbody>
|
<ElTableColumn :label="t('admin.wecom.headers.wecomUserId')" min-width="180">
|
||||||
</table>
|
<template #default="{ row }">
|
||||||
<p v-if="previewSummary.would_update > previewSummary.pending_updates.length" class="mt-2 text-xs text-muted">
|
<span class="wecom-sync__mono">{{ (row as WecomSyncPendingUpdate).wecom_userid }}</span>
|
||||||
{{ t('admin.wecom.sync.previewTruncated', { total: previewSummary.would_update }) }}
|
</template>
|
||||||
</p>
|
</ElTableColumn>
|
||||||
</div>
|
</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 v-if="previewSummary.conflicts?.length" class="wecom-sync__conflicts">
|
||||||
<div class="text-xs font-medium text-red-700">{{ t('admin.wecom.sync.conflictsTitle') }}</div>
|
<ElText type="danger">{{ t('admin.wecom.sync.conflictsTitle') }}</ElText>
|
||||||
<div
|
<ElAlert
|
||||||
v-for="(conflict, idx) in previewSummary.conflicts"
|
v-for="(conflict, idx) in previewSummary.conflicts"
|
||||||
:key="idx"
|
: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-if="conflict.old_wecom_userid"> · {{ conflict.old_wecom_userid }} → {{ conflict.new_wecom_userid }}</span>
|
<span v-else-if="conflict.occupied_by_username">
|
||||||
<span v-else-if="conflict.occupied_by_username"> · {{ t('admin.wecom.sync.occupiedBy', { user: conflict.occupied_by_username }) }}</span>
|
{{ t('admin.wecom.sync.occupiedBy', { user: conflict.occupied_by_username }) }}
|
||||||
</div>
|
</span>
|
||||||
|
</ElAlert>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</div>
|
||||||
</template>
|
</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
|
* features/admin/modules/wecom/composables/useWecomAdmin.ts
|
||||||
* 企业微信:绑定、系统配置、通知、登录审计。
|
* 企业微信:绑定、系统配置、通知、登录审计。
|
||||||
* 依赖:admin.api、useMessage、wecom 展示工具、PaginationBar 所需的审计分页状态。
|
* 依赖:admin.api、useMessage、wecom 展示工具、element-plus 确认框。
|
||||||
* 逻辑:绑定走服务端分页;登录审计仍一次拉取最近 200 条,由前端切片分页。
|
* 逻辑:绑定走服务端分页;登录审计仍一次拉取最近 200 条,由前端切片分页。解绑用 ElMessageBox。
|
||||||
*/
|
*/
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { ElMessageBox } from 'element-plus';
|
||||||
import * as XLSX from 'xlsx';
|
import * as XLSX from 'xlsx';
|
||||||
import {
|
import {
|
||||||
bindAdminWecomUser,
|
bindAdminWecomUser,
|
||||||
@@ -90,10 +91,6 @@ export function useWecomAdmin() {
|
|||||||
const wecomSystemSettings = ref<WecomSystemSettings>(createDefaultWecomSystemSettings());
|
const wecomSystemSettings = ref<WecomSystemSettings>(createDefaultWecomSystemSettings());
|
||||||
const wecomIntegrationManifest = ref<WecomIntegrationManifest | null>(null);
|
const wecomIntegrationManifest = ref<WecomIntegrationManifest | null>(null);
|
||||||
|
|
||||||
const showDeleteConfirmDialog = ref(false);
|
|
||||||
const deleteConfirmMessage = ref('');
|
|
||||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
|
||||||
|
|
||||||
const wecomBindUserOptions = computed(() => {
|
const wecomBindUserOptions = computed(() => {
|
||||||
const keyword = wecomBindUserQuery.value.trim().toLowerCase();
|
const keyword = wecomBindUserQuery.value.trim().toLowerCase();
|
||||||
return users.value
|
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> => {
|
const loadUsers = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
users.value = await listAdminUsers();
|
users.value = await listAdminUsers();
|
||||||
@@ -428,19 +405,31 @@ export function useWecomAdmin() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理员解绑企微 userid。取消确认则不请求。
|
||||||
|
* 核心逻辑:Element 确认框使用通用删除标题和按钮;确定后仍调用既有解绑接口并刷新列表。
|
||||||
|
* @param userId - 本地用户主键
|
||||||
|
*/
|
||||||
const unbindWecomUserByAdmin = async (userId: number): Promise<void> => {
|
const unbindWecomUserByAdmin = async (userId: number): Promise<void> => {
|
||||||
openDeleteConfirm(t('admin.wecom.confirmUnbind'), async () => {
|
try {
|
||||||
isSaving.value = true;
|
await ElMessageBox.confirm(t('admin.wecom.confirmUnbind'), t('common.deleteDialog.defaultTitle'), {
|
||||||
try {
|
type: 'warning',
|
||||||
await unbindAdminWecomUser(userId);
|
confirmButtonText: t('common.deleteDialog.confirm'),
|
||||||
await refreshWecomData();
|
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||||
} catch (e) {
|
});
|
||||||
console.error(e);
|
} catch {
|
||||||
msg.error((e as Error).message || t('admin.wecom.msg.unbindFailed'));
|
return;
|
||||||
} finally {
|
}
|
||||||
isSaving.value = false;
|
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 => {
|
const exportWecomAudits = (): void => {
|
||||||
@@ -522,8 +511,6 @@ export function useWecomAdmin() {
|
|||||||
wecomNotifyMetrics,
|
wecomNotifyMetrics,
|
||||||
wecomSystemSettings,
|
wecomSystemSettings,
|
||||||
wecomIntegrationManifest,
|
wecomIntegrationManifest,
|
||||||
showDeleteConfirmDialog,
|
|
||||||
deleteConfirmMessage,
|
|
||||||
loadAll,
|
loadAll,
|
||||||
refreshWecomData,
|
refreshWecomData,
|
||||||
selectWecomBindUser,
|
selectWecomBindUser,
|
||||||
@@ -539,6 +526,5 @@ export function useWecomAdmin() {
|
|||||||
bindWecomUser,
|
bindWecomUser,
|
||||||
unbindWecomUserByAdmin,
|
unbindWecomUserByAdmin,
|
||||||
exportWecomAudits,
|
exportWecomAudits,
|
||||||
confirmDelete,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* features/admin/modules/wecom/composables/useWecomSync.ts
|
* 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 { computed, ref } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { ElMessageBox } from 'element-plus';
|
||||||
import { syncAdminWecomUserids } from '@/features/admin/api/admin.api';
|
import { syncAdminWecomUserids } from '@/features/admin/api/admin.api';
|
||||||
import { useMessage } from '@/shared/composables/useMessage';
|
import { useMessage } from '@/shared/composables/useMessage';
|
||||||
import type { WecomSyncSummary } from '@/features/admin/types/wecom.types';
|
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 isSyncing = ref(false);
|
||||||
const previewSummary = ref<WecomSyncSummary | null>(null);
|
const previewSummary = ref<WecomSyncSummary | null>(null);
|
||||||
const showApplyConfirm = ref(false);
|
|
||||||
const previewAttempted = ref(false);
|
const previewAttempted = ref(false);
|
||||||
const previewFailed = 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 (isSyncing.value) return;
|
||||||
if (previewFailed.value || (previewAttempted.value && !previewSummary.value)) {
|
if (previewFailed.value || (previewAttempted.value && !previewSummary.value)) {
|
||||||
msg.warning(t('admin.wecom.sync.previewFirstAfterFail'));
|
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'));
|
msg.info(t('admin.wecom.sync.nothingToUpdate'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showApplyConfirm.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 确认后将预览结果写入数据库。
|
|
||||||
*/
|
|
||||||
const confirmApplySync = async (): Promise<void> => {
|
|
||||||
isSyncing.value = true;
|
|
||||||
try {
|
try {
|
||||||
const summary = await syncAdminWecomUserids({ apply: true });
|
await ElMessageBox.confirm(
|
||||||
previewSummary.value = summary;
|
t('admin.wecom.sync.applyConfirm', { count: previewSummary.value.would_update || 0 }),
|
||||||
showApplyConfirm.value = false;
|
t('admin.wecom.sync.applyConfirmTitle'),
|
||||||
msg.success(t('admin.wecom.sync.applyDone', { count: summary.updated || 0 }));
|
{
|
||||||
await options?.onApplied?.();
|
type: 'warning',
|
||||||
} catch (e) {
|
confirmButtonText: t('admin.wecom.sync.applyConfirmButton'),
|
||||||
console.error(e);
|
cancelButtonText: t('common.deleteDialog.cancel'),
|
||||||
msg.error((e as Error).message || t('admin.wecom.sync.applyFailed'));
|
},
|
||||||
} finally {
|
);
|
||||||
isSyncing.value = false;
|
} catch {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
await confirmApplySync();
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isSyncing,
|
isSyncing,
|
||||||
previewSummary,
|
previewSummary,
|
||||||
showApplyConfirm,
|
|
||||||
canApplySync,
|
canApplySync,
|
||||||
applyBlockHint,
|
applyBlockHint,
|
||||||
previewSync,
|
previewSync,
|
||||||
requestApplySync,
|
requestApplySync,
|
||||||
confirmApplySync,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,37 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/wecom/pages/WecomAuditsPage.vue
|
* features/admin/modules/wecom/pages/WecomAuditsPage.vue
|
||||||
* 企微与密码登录审计列表。
|
* 用途:企微与密码登录审计列表。
|
||||||
* 依赖:WECOM_ADMIN_KEY、PaginationBar、formatLocalDateTime。
|
* 依赖:AdminListPage、AdminListTabs、WECOM_ADMIN_KEY、element-plus、formatLocalDateTime。
|
||||||
* 逻辑:表格渲染当前页切片;分页条对已拉取的最近 200 条做前端翻页。
|
* 逻辑:路由 AdminWecomAudits。页签仍跳原来的三个子路由。表格渲染当前页切片;分页对已拉取的最近 200 条做前端翻页。
|
||||||
*/
|
*/
|
||||||
import { inject } from 'vue';
|
import { inject } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { Download } from 'lucide-vue-next';
|
import { Download, Refresh } from '@element-plus/icons-vue';
|
||||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
import {
|
||||||
|
ElButton,
|
||||||
|
ElConfigProvider,
|
||||||
|
ElOption,
|
||||||
|
ElPagination,
|
||||||
|
ElSelect,
|
||||||
|
ElSpace,
|
||||||
|
ElTable,
|
||||||
|
ElTableColumn,
|
||||||
|
ElTag,
|
||||||
|
ElText,
|
||||||
|
} from 'element-plus';
|
||||||
|
import 'element-plus/dist/index.css';
|
||||||
|
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||||
|
import '@/features/admin/styles/element-trial.css';
|
||||||
|
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||||
|
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
import { 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';
|
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const { elementLocale } = useElementProvider();
|
||||||
const {
|
const {
|
||||||
wecomAuditSourceFilter,
|
wecomAuditSourceFilter,
|
||||||
wecomAuditStatusFilter,
|
wecomAuditStatusFilter,
|
||||||
@@ -20,83 +39,134 @@ const {
|
|||||||
wecomAuditsPageSize,
|
wecomAuditsPageSize,
|
||||||
wecomAuditsPageSizeOptions,
|
wecomAuditsPageSizeOptions,
|
||||||
wecomAuditsTotal,
|
wecomAuditsTotal,
|
||||||
filteredWecomLoginAudits,
|
|
||||||
pagedWecomLoginAudits,
|
pagedWecomLoginAudits,
|
||||||
exportWecomAudits,
|
exportWecomAudits,
|
||||||
|
refreshWecomData,
|
||||||
getWecomAuditReasonText,
|
getWecomAuditReasonText,
|
||||||
getWecomAuditMetaText,
|
getWecomAuditMetaText,
|
||||||
} = inject(WECOM_ADMIN_KEY)!;
|
} = 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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="admin-table-section">
|
<ElConfigProvider :locale="elementLocale">
|
||||||
<div class="admin-table-header admin-table-header--stacked px-5 py-4">
|
<AdminListPage>
|
||||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.auditTitle') }}</h3>
|
<template #title>
|
||||||
<div class="flex w-full md:w-auto flex-wrap md:flex-nowrap items-center justify-start md:justify-end gap-2">
|
<h2 class="section-title">{{ t('admin.wecom.title') }}</h2>
|
||||||
<select v-model="wecomAuditSourceFilter" class="admin-table-filter-input h-11 min-w-[112px] shrink-0">
|
<p class="section-desc mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||||
<option value="all">{{ t('admin.wecom.filters.allSources') }}</option>
|
</template>
|
||||||
<option value="wecom">{{ t('admin.wecom.sources.wecom') }}</option>
|
<template #actions>
|
||||||
<option value="password">{{ t('admin.wecom.sources.password') }}</option>
|
<ElSpace>
|
||||||
</select>
|
<ElButton :icon="Refresh" @click="refreshWecomData()">{{ t('admin.wecom.refresh') }}</ElButton>
|
||||||
<select v-model="wecomAuditStatusFilter" class="admin-table-filter-input h-11 min-w-[112px] shrink-0">
|
<ElButton :icon="Download" @click="exportWecomAudits()">{{ t('admin.wecom.exportAudit') }}</ElButton>
|
||||||
<option value="all">{{ t('admin.wecom.filters.allStatus') }}</option>
|
</ElSpace>
|
||||||
<option value="success">{{ t('admin.wecom.auditStatus.success') }}</option>
|
</template>
|
||||||
<option value="failed">{{ t('admin.wecom.auditStatus.failed') }}</option>
|
<template #tabs>
|
||||||
</select>
|
<WecomSubNav />
|
||||||
<button type="button" class="btn-secondary h-11 shrink-0 text-sm" @click="exportWecomAudits()">
|
</template>
|
||||||
<Download class="w-4 h-4" />
|
<template #filters>
|
||||||
{{ t('admin.wecom.exportAudit') }}
|
<ElSelect
|
||||||
</button>
|
class="wecom-filter-select"
|
||||||
</div>
|
:model-value="wecomAuditSourceFilter === 'all' ? undefined : wecomAuditSourceFilter"
|
||||||
</div>
|
clearable
|
||||||
<div class="admin-table-wrap">
|
:placeholder="t('admin.wecom.filters.allSources')"
|
||||||
<table class="admin-table">
|
@update:model-value="onAuditSourceChange"
|
||||||
<thead>
|
>
|
||||||
<tr>
|
<ElOption :label="t('admin.wecom.sources.wecom')" value="wecom" />
|
||||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.time') }}</th>
|
<ElOption :label="t('admin.wecom.sources.password')" value="password" />
|
||||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.source') }}</th>
|
</ElSelect>
|
||||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.user') }}</th>
|
<ElSelect
|
||||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.status') }}</th>
|
class="wecom-filter-select"
|
||||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.reason') }}</th>
|
:model-value="wecomAuditStatusFilter === 'all' ? undefined : wecomAuditStatusFilter"
|
||||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.ip') }}</th>
|
clearable
|
||||||
</tr>
|
:placeholder="t('admin.wecom.filters.allStatus')"
|
||||||
</thead>
|
@update:model-value="onAuditStatusChange"
|
||||||
<tbody>
|
>
|
||||||
<tr v-if="filteredWecomLoginAudits.length === 0">
|
<ElOption :label="t('admin.wecom.auditStatus.success')" value="success" />
|
||||||
<td colspan="6" class="px-4 admin-table-empty">{{ t('admin.wecom.noAuditData') }}</td>
|
<ElOption :label="t('admin.wecom.auditStatus.failed')" value="failed" />
|
||||||
</tr>
|
</ElSelect>
|
||||||
<tr v-for="row in pagedWecomLoginAudits" :key="row.id">
|
</template>
|
||||||
<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>
|
<ElTable
|
||||||
<td class="px-4 py-3 text-xs text-secondary">{{ row.username || '-' }}</td>
|
class="hx-admin-table"
|
||||||
<td class="px-4 py-3">
|
:data="pagedWecomLoginAudits"
|
||||||
<span
|
row-key="id"
|
||||||
class="inline-flex px-2 py-0.5 rounded-full text-[11px] font-medium"
|
:empty-text="t('admin.wecom.noAuditData')"
|
||||||
:class="row.status === 'success' ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700'"
|
>
|
||||||
>
|
<ElTableColumn :label="t('admin.wecom.auditHeaders.time')" min-width="180">
|
||||||
{{ t('admin.wecom.auditStatus.' + row.status) }}
|
<template #default="{ row }">
|
||||||
</span>
|
{{ formatLocalDateTime((row as WecomLoginAuditRow).created_at) }}
|
||||||
</td>
|
</template>
|
||||||
<td class="px-4 py-3 text-xs text-muted max-w-[360px] align-top">
|
</ElTableColumn>
|
||||||
<div class="max-w-[360px] whitespace-normal break-words">
|
<ElTableColumn :label="t('admin.wecom.auditHeaders.source')" min-width="120">
|
||||||
<div class="text-xs text-secondary leading-5">{{ getWecomAuditReasonText(row) }}</div>
|
<template #default="{ row }">
|
||||||
<div v-if="getWecomAuditMetaText(row)" class="mt-1 text-[11px] text-muted leading-5" :title="getWecomAuditMetaText(row)">
|
{{ t('admin.wecom.sources.' + (row as WecomLoginAuditRow).source) }}
|
||||||
{{ getWecomAuditMetaText(row) }}
|
</template>
|
||||||
</div>
|
</ElTableColumn>
|
||||||
</div>
|
<ElTableColumn :label="t('admin.wecom.auditHeaders.user')" min-width="140">
|
||||||
</td>
|
<template #default="{ row }">{{ (row as WecomLoginAuditRow).username || '-' }}</template>
|
||||||
<td class="px-4 py-3 text-xs text-muted font-mono">{{ row.ip || '-' }}</td>
|
</ElTableColumn>
|
||||||
</tr>
|
<ElTableColumn :label="t('admin.wecom.auditHeaders.status')" min-width="110">
|
||||||
</tbody>
|
<template #default="{ row }">
|
||||||
</table>
|
<ElTag
|
||||||
</div>
|
effect="light"
|
||||||
<div class="px-4 pb-4 pt-2">
|
:type="(row as WecomLoginAuditRow).status === 'success' ? 'success' : 'danger'"
|
||||||
<PaginationBar
|
>
|
||||||
v-model:page="wecomAuditsPage"
|
{{ t('admin.wecom.auditStatus.' + (row as WecomLoginAuditRow).status) }}
|
||||||
v-model:page-size="wecomAuditsPageSize"
|
</ElTag>
|
||||||
:total="wecomAuditsTotal"
|
</template>
|
||||||
:page-size-options="[...wecomAuditsPageSizeOptions]"
|
</ElTableColumn>
|
||||||
/>
|
<ElTableColumn :label="t('admin.wecom.auditHeaders.reason')" min-width="240">
|
||||||
</div>
|
<template #default="{ row }">
|
||||||
</div>
|
<div>{{ getWecomAuditReasonText(row as WecomLoginAuditRow) }}</div>
|
||||||
|
<ElText v-if="getWecomAuditMetaText(row as WecomLoginAuditRow)" type="info">
|
||||||
|
{{ getWecomAuditMetaText(row as WecomLoginAuditRow) }}
|
||||||
|
</ElText>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
<ElTableColumn :label="t('admin.wecom.auditHeaders.ip')" min-width="140">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="wecom-audit-mono">{{ (row as WecomLoginAuditRow).ip || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
</ElTable>
|
||||||
|
|
||||||
|
<template #pagination>
|
||||||
|
<ElPagination
|
||||||
|
v-model:current-page="wecomAuditsPage"
|
||||||
|
v-model:page-size="wecomAuditsPageSize"
|
||||||
|
:total="wecomAuditsTotal"
|
||||||
|
:page-sizes="[...wecomAuditsPageSizeOptions]"
|
||||||
|
layout="total, sizes, prev, pager, next"
|
||||||
|
background
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</AdminListPage>
|
||||||
|
</ElConfigProvider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
:deep(.wecom-filter-select) {
|
||||||
|
width: 11rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wecom-audit-mono {
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,291 +1,273 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/wecom/pages/WecomBindingsPage.vue
|
* features/admin/modules/wecom/pages/WecomBindingsPage.vue
|
||||||
* 企微 OA 同步、快速绑定与绑定列表(搜索 + 服务端分页)。
|
* 用途:企微绑定概览、OA 同步、快速绑定和绑定列表。
|
||||||
* 依赖:WECOM_ADMIN_KEY、WecomSyncPanel、PaginationBar。
|
* 依赖:AdminListPage、AdminListTabs、WecomOverviewCards、WecomSyncPanel、WECOM_ADMIN_KEY、element-plus。
|
||||||
|
* 逻辑:路由 AdminWecomBindings。概览和同步在页签卡片里;绑定列表单独一张 AdminListPage,搜索和分页只服务这张表。
|
||||||
*/
|
*/
|
||||||
import { inject } from 'vue';
|
import { inject } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { Link2, Search, Unlink2 } from 'lucide-vue-next';
|
import { Link, Refresh } from '@element-plus/icons-vue';
|
||||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
import {
|
||||||
|
ElButton,
|
||||||
|
ElCheckbox,
|
||||||
|
ElConfigProvider,
|
||||||
|
ElForm,
|
||||||
|
ElFormItem,
|
||||||
|
ElInput,
|
||||||
|
ElOption,
|
||||||
|
ElPagination,
|
||||||
|
ElSelect,
|
||||||
|
ElTable,
|
||||||
|
ElTableColumn,
|
||||||
|
ElTag,
|
||||||
|
ElText,
|
||||||
|
} from 'element-plus';
|
||||||
|
import 'element-plus/dist/index.css';
|
||||||
|
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||||
|
import '@/features/admin/styles/element-trial.css';
|
||||||
|
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||||
|
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||||
|
import type { WecomBindingRow } from '@/features/admin/types/wecom.types';
|
||||||
import WecomOverviewCards from '../components/WecomOverviewCards.vue';
|
import WecomOverviewCards from '../components/WecomOverviewCards.vue';
|
||||||
import WecomSyncPanel from '../components/WecomSyncPanel.vue';
|
import WecomSyncPanel from '../components/WecomSyncPanel.vue';
|
||||||
|
import WecomSubNav from '../components/WecomSubNav.vue';
|
||||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const { elementLocale } = useElementProvider();
|
||||||
const {
|
const {
|
||||||
|
|
||||||
wecomBindUserQuery,
|
|
||||||
|
|
||||||
wecomBindUserDropdownOpen,
|
|
||||||
|
|
||||||
wecomBindUserOptions,
|
wecomBindUserOptions,
|
||||||
|
wecomBindUserQuery,
|
||||||
wecomBindForm,
|
wecomBindForm,
|
||||||
|
|
||||||
isSaving,
|
isSaving,
|
||||||
|
|
||||||
wecomBoundOnly,
|
wecomBoundOnly,
|
||||||
|
|
||||||
wecomBindings,
|
wecomBindings,
|
||||||
|
|
||||||
wecomBindingsKeyword,
|
wecomBindingsKeyword,
|
||||||
|
|
||||||
wecomBindingsPage,
|
wecomBindingsPage,
|
||||||
|
|
||||||
wecomBindingsPageSize,
|
wecomBindingsPageSize,
|
||||||
|
|
||||||
wecomBindingsTotal,
|
wecomBindingsTotal,
|
||||||
|
|
||||||
wecomBindingsPages,
|
|
||||||
|
|
||||||
wecomBindingsPageSizeOptions,
|
wecomBindingsPageSizeOptions,
|
||||||
|
|
||||||
selectWecomBindUser,
|
|
||||||
|
|
||||||
scheduleCloseWecomBindUserDropdown,
|
|
||||||
|
|
||||||
bindWecomUser,
|
bindWecomUser,
|
||||||
|
|
||||||
unbindWecomUserByAdmin,
|
unbindWecomUserByAdmin,
|
||||||
|
|
||||||
refreshWecomData,
|
refreshWecomData,
|
||||||
|
|
||||||
} = inject(WECOM_ADMIN_KEY)!;
|
} = inject(WECOM_ADMIN_KEY)!;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步写入成功后刷新绑定列表和配置。
|
||||||
|
* 核心逻辑:面板内部已经刷新过一次,这里再拉一次,保持原来的 applied 回调。
|
||||||
|
*/
|
||||||
const onSyncApplied = async (): Promise<void> => {
|
const onSyncApplied = async (): Promise<void> => {
|
||||||
await refreshWecomData();
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="space-y-6">
|
<ElConfigProvider :locale="elementLocale">
|
||||||
<WecomOverviewCards />
|
<div class="wecom-bindings">
|
||||||
<WecomSyncPanel @applied="onSyncApplied" />
|
<AdminListPage>
|
||||||
|
<template #title>
|
||||||
<p class="text-sm text-muted">{{ t('admin.wecom.bindingsHint') }}</p>
|
<h2 class="section-title">{{ t('admin.wecom.title') }}</h2>
|
||||||
|
<p class="section-desc mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||||
|
</template>
|
||||||
|
<template #actions>
|
||||||
<div class="card shadow-sm p-5 space-y-4">
|
<ElButton :icon="Refresh" @click="refreshWecomData()">{{ t('admin.wecom.refresh') }}</ElButton>
|
||||||
|
</template>
|
||||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.quickBind') }}</h3>
|
<template #tabs>
|
||||||
|
<WecomSubNav />
|
||||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-3">
|
</template>
|
||||||
|
|
||||||
<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__block">
|
||||||
|
<WecomOverviewCards />
|
||||||
</div>
|
</div>
|
||||||
|
<WecomSyncPanel @applied="onSyncApplied" />
|
||||||
<input v-model="wecomBindForm.wecom_userid" :placeholder="t('admin.wecom.fields.wecomUserId')" class="input-field md:col-span-2" />
|
<div class="wecom-bindings__block">
|
||||||
|
<ElText type="info">{{ t('admin.wecom.bindingsHint') }}</ElText>
|
||||||
<input v-model="wecomBindForm.wecom_unionid" :placeholder="t('admin.wecom.fields.wecomUnionId')" class="input-field" />
|
<h3 class="wecom-bindings__heading">{{ t('admin.wecom.quickBind') }}</h3>
|
||||||
|
<ElForm label-position="top" :model="wecomBindForm" @submit.prevent="bindWecomUser()">
|
||||||
</div>
|
<div class="wecom-bindings__form">
|
||||||
|
<ElFormItem :label="t('admin.wecom.fields.userSelect')">
|
||||||
<div class="flex justify-end">
|
<ElSelect
|
||||||
|
:model-value="wecomBindForm.user_id === '' ? undefined : wecomBindForm.user_id"
|
||||||
<button type="button" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60" @click="bindWecomUser()">
|
filterable
|
||||||
|
clearable
|
||||||
<Link2 class="w-4 h-4" /> {{ t('admin.wecom.bind') }}
|
:placeholder="t('admin.wecom.fields.userSelect')"
|
||||||
|
@update:model-value="onBindUserChange"
|
||||||
</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)"
|
|
||||||
|
|
||||||
>
|
>
|
||||||
|
<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') }}
|
<ElTable
|
||||||
|
class="hx-admin-table"
|
||||||
</button>
|
:data="wecomBindings"
|
||||||
|
row-key="id"
|
||||||
</td>
|
:empty-text="t('admin.wecom.noData')"
|
||||||
|
>
|
||||||
</tr>
|
<ElTableColumn :label="t('admin.wecom.headers.user')" min-width="220">
|
||||||
|
<template #default="{ row }">
|
||||||
</tbody>
|
<div>
|
||||||
|
{{ (row as WecomBindingRow).username }}
|
||||||
</table>
|
<ElText type="info">(#{{ (row as WecomBindingRow).id }})</ElText>
|
||||||
|
</div>
|
||||||
</div>
|
<ElText type="info">
|
||||||
|
{{ (row as WecomBindingRow).real_name || '-' }} · {{ (row as WecomBindingRow).email }}
|
||||||
<div class="px-4 pb-4 pt-2">
|
</ElText>
|
||||||
|
</template>
|
||||||
<PaginationBar
|
</ElTableColumn>
|
||||||
|
<ElTableColumn :label="t('admin.wecom.headers.employeeId')" min-width="140">
|
||||||
v-model:page="wecomBindingsPage"
|
<template #default="{ row }">
|
||||||
|
<span class="wecom-bindings__mono">{{ (row as WecomBindingRow).employee_id || '-' }}</span>
|
||||||
v-model:page-size="wecomBindingsPageSize"
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
:total="wecomBindingsTotal"
|
<ElTableColumn :label="t('admin.wecom.headers.roleStatus')" min-width="180">
|
||||||
|
<template #default="{ row }">
|
||||||
:pages="wecomBindingsPages"
|
<span>{{ t('admin.role.' + (row as WecomBindingRow).role) }}</span>
|
||||||
|
<ElTag
|
||||||
:page-size-options="[...wecomBindingsPageSizeOptions]"
|
class="wecom-bindings__status"
|
||||||
|
effect="light"
|
||||||
:visible="wecomBindingsTotal > 0 || !!wecomBindingsKeyword.trim()"
|
:type="(row as WecomBindingRow).status === 'active' ? 'success' : 'info'"
|
||||||
|
>
|
||||||
/>
|
{{ t('admin.status.' + (row as WecomBindingRow).status) }}
|
||||||
|
</ElTag>
|
||||||
</div>
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
<ElTableColumn :label="t('admin.wecom.headers.wecomUserId')" min-width="160">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="wecom-bindings__mono">{{ (row as WecomBindingRow).wecom_userid || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
<ElTableColumn :label="t('admin.wecom.headers.unionId')" min-width="160">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span class="wecom-bindings__mono">{{ (row as WecomBindingRow).wecom_unionid || '-' }}</span>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
<ElTableColumn :label="t('admin.wecom.headers.actions')" width="120" align="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<ElButton
|
||||||
|
v-if="(row as WecomBindingRow).wecom_userid"
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="unbindWecomUserByAdmin((row as WecomBindingRow).id)"
|
||||||
|
>
|
||||||
|
{{ t('admin.wecom.unbind') }}
|
||||||
|
</ElButton>
|
||||||
|
</template>
|
||||||
|
</ElTableColumn>
|
||||||
|
</ElTable>
|
||||||
|
|
||||||
|
<template #pagination v-if="wecomBindingsTotal > 0 || !!wecomBindingsKeyword.trim()">
|
||||||
|
<ElPagination
|
||||||
|
v-model:current-page="wecomBindingsPage"
|
||||||
|
v-model:page-size="wecomBindingsPageSize"
|
||||||
|
:total="wecomBindingsTotal"
|
||||||
|
:page-sizes="[...wecomBindingsPageSizeOptions]"
|
||||||
|
layout="total, sizes, prev, pager, next"
|
||||||
|
background
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</AdminListPage>
|
||||||
</div>
|
</div>
|
||||||
|
</ElConfigProvider>
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.wecom-bindings {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wecom-bindings__block {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 16px 32px 24px;
|
||||||
|
border-top: 1px solid var(--el-border-color-lighter);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wecom-bindings__heading {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--el-text-color-primary);
|
||||||
|
font-size: var(--el-font-size-large);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wecom-bindings__form {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
column-gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wecom-bindings__submit {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wecom-bindings__mono {
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wecom-bindings__status {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.wecom-filter-search) {
|
||||||
|
width: 16rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.wecom-bindings__form {
|
||||||
|
grid-template-columns: 1fr 2fr 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,16 +1,42 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
/**
|
/**
|
||||||
* features/admin/modules/wecom/pages/WecomSettingsPage.vue
|
* 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 { useI18n } from 'vue-i18n';
|
||||||
import { CircleHelp } from 'lucide-vue-next';
|
import { QuestionFilled, Refresh } from '@element-plus/icons-vue';
|
||||||
|
import {
|
||||||
|
ElAlert,
|
||||||
|
ElButton,
|
||||||
|
ElCard,
|
||||||
|
ElCollapse,
|
||||||
|
ElCollapseItem,
|
||||||
|
ElConfigProvider,
|
||||||
|
ElForm,
|
||||||
|
ElFormItem,
|
||||||
|
ElIcon,
|
||||||
|
ElInput,
|
||||||
|
ElOption,
|
||||||
|
ElSelect,
|
||||||
|
ElStatistic,
|
||||||
|
ElSwitch,
|
||||||
|
ElText,
|
||||||
|
ElTooltip,
|
||||||
|
} from 'element-plus';
|
||||||
|
import 'element-plus/dist/index.css';
|
||||||
|
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||||
|
import '@/features/admin/styles/element-trial.css';
|
||||||
|
import AdminListPage from '@/features/admin/components/AdminListPage.vue';
|
||||||
|
import { useElementProvider } from '@/features/admin/composables/useElementProvider';
|
||||||
|
import type { WecomIntegrationManifest } from '@/features/admin/types/wecom.types';
|
||||||
|
import WecomSubNav from '../components/WecomSubNav.vue';
|
||||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const { elementLocale } = useElementProvider();
|
||||||
const {
|
const {
|
||||||
wecomSystemSettings,
|
wecomSystemSettings,
|
||||||
isSaving,
|
isSaving,
|
||||||
@@ -23,238 +49,426 @@ const {
|
|||||||
generateWecomEncodingAesKey,
|
generateWecomEncodingAesKey,
|
||||||
saveWecomSystemSettings,
|
saveWecomSystemSettings,
|
||||||
saveWecomNotifySettings,
|
saveWecomNotifySettings,
|
||||||
|
refreshWecomData,
|
||||||
copyText,
|
copyText,
|
||||||
} = inject(WECOM_ADMIN_KEY)!;
|
} = 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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="space-y-6">
|
<ElConfigProvider :locale="elementLocale">
|
||||||
<div class="card shadow-sm p-5 space-y-4">
|
<AdminListPage>
|
||||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.systemSettings') }}</h3>
|
<template #title>
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
<h2 class="section-title">{{ t('admin.wecom.title') }}</h2>
|
||||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
<p class="section-desc mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||||
<input v-model="wecomSystemSettings.enabled" type="checkbox" class="admin-checkbox" />
|
</template>
|
||||||
{{ t('admin.wecom.fields.enabled') }}
|
<template #actions>
|
||||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.enabled')" />
|
<ElButton :icon="Refresh" @click="refreshWecomData()">{{ t('admin.wecom.refresh') }}</ElButton>
|
||||||
</label>
|
</template>
|
||||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
<template #tabs>
|
||||||
<input v-model="wecomSystemSettings.auto_create_user" type="checkbox" class="admin-checkbox" />
|
<WecomSubNav />
|
||||||
{{ t('admin.wecom.fields.autoCreateUser') }}
|
</template>
|
||||||
<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>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
|
<div class="wecom-settings">
|
||||||
<div class="card shadow-sm p-5 space-y-4">
|
<section class="wecom-settings__section">
|
||||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.notifySettings') }}</h3>
|
<h3 class="wecom-settings__heading">{{ t('admin.wecom.systemSettings') }}</h3>
|
||||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
<ElForm label-position="top" :model="wecomSystemSettings" @submit.prevent="saveWecomSystemSettings()">
|
||||||
<input v-model="wecomNotifySettings.enabled" type="checkbox" class="admin-checkbox" />
|
<div class="wecom-settings__grid">
|
||||||
{{ t('admin.wecom.notifyEnabled') }}
|
<ElFormItem>
|
||||||
</label>
|
<template #label>
|
||||||
<input v-model="wecomNotifySettings.base_url" :placeholder="t('admin.wecom.notifyBaseUrl')" class="input-field" />
|
<span class="wecom-settings__label">
|
||||||
<input v-model="wecomNotifyEventsText" :placeholder="t('admin.wecom.notifyEvents')" class="input-field" />
|
{{ t('admin.wecom.fields.enabled') }}
|
||||||
<div class="flex justify-end">
|
<ElTooltip :content="t('admin.wecom.tips.enabled')" placement="top">
|
||||||
<button type="button" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60" @click="saveWecomNotifySettings()">
|
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||||
{{ t('admin.save') }}
|
</ElTooltip>
|
||||||
</button>
|
</span>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
<ElSwitch v-model="wecomSystemSettings.enabled" />
|
||||||
<div class="card shadow-sm p-5 space-y-4">
|
</ElFormItem>
|
||||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.notifyMetrics') }}</h3>
|
<ElFormItem>
|
||||||
<div v-if="wecomNotifyMetrics" class="grid grid-cols-2 gap-3 text-sm">
|
<template #label>
|
||||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
<span class="wecom-settings__label">
|
||||||
<div class="text-muted">{{ t('admin.wecom.metricTotal') }}</div>
|
{{ t('admin.wecom.fields.autoCreateUser') }}
|
||||||
<div class="text-lg font-semibold text-primary">{{ wecomNotifyMetrics.total }}</div>
|
<ElTooltip :content="t('admin.wecom.tips.autoCreateUser')" placement="top">
|
||||||
</div>
|
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
</ElTooltip>
|
||||||
<div class="text-muted">{{ t('admin.wecom.metricSuccessRate') }}</div>
|
</span>
|
||||||
<div class="text-lg font-semibold text-emerald-700">{{ wecomNotifyMetrics.send_success_rate }}%</div>
|
</template>
|
||||||
</div>
|
<ElSwitch v-model="wecomSystemSettings.auto_create_user" />
|
||||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
</ElFormItem>
|
||||||
<div class="text-muted">{{ t('admin.wecom.metricOpenedRate') }}</div>
|
<ElFormItem>
|
||||||
<div class="text-lg font-semibold text-blue-700">{{ wecomNotifyMetrics.opened_24h_rate }}%</div>
|
<template #label>
|
||||||
</div>
|
<span class="wecom-settings__label">
|
||||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
{{ t('admin.wecom.fields.corpId') }}
|
||||||
<div class="text-muted">{{ t('admin.wecom.metricWindowDays') }}</div>
|
<ElTooltip :content="t('admin.wecom.tips.corpId')" placement="top">
|
||||||
<div class="text-lg font-semibold text-primary">{{ wecomNotifyMetrics.window_days }}</div>
|
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||||
</div>
|
</ElTooltip>
|
||||||
</div>
|
</span>
|
||||||
</div>
|
</template>
|
||||||
</div>
|
<ElInput v-model="wecomSystemSettings.corp_id" />
|
||||||
|
</ElFormItem>
|
||||||
<details class="card shadow-sm p-5">
|
<ElFormItem>
|
||||||
<summary class="cursor-pointer font-semibold text-primary">{{ t('admin.wecom.integrationCopyTitle') }}</summary>
|
<template #label>
|
||||||
<div class="mt-4 space-y-4">
|
<span class="wecom-settings__label">
|
||||||
<p class="text-xs text-muted">{{ t('admin.wecom.integrationCopyDesc') }}</p>
|
{{ t('admin.wecom.fields.agentId') }}
|
||||||
<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>
|
<ElTooltip :content="t('admin.wecom.tips.agentId')" placement="top">
|
||||||
<div v-if="wecomIntegrationManifest" class="grid grid-cols-1 gap-3">
|
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||||
<div
|
</ElTooltip>
|
||||||
v-for="item in [
|
</span>
|
||||||
{ key: 'public_base_url', label: t('admin.wecom.copyFields.publicBaseUrl') },
|
</template>
|
||||||
{ key: 'callback_url', label: t('admin.wecom.copyFields.callbackUrl') },
|
<ElInput v-model="wecomSystemSettings.agent_id" />
|
||||||
{ key: 'callback_token', label: t('admin.wecom.copyFields.callbackToken') },
|
</ElFormItem>
|
||||||
{ key: 'encoding_aes_key', label: t('admin.wecom.copyFields.encodingAesKey') },
|
<ElFormItem class="wecom-settings__span">
|
||||||
{ key: 'oauth_redirect_uri', label: t('admin.wecom.copyFields.oauthRedirectUri') },
|
<template #label>
|
||||||
{ key: 'homepage_url', label: t('admin.wecom.copyFields.homepageUrl') },
|
<span class="wecom-settings__label">
|
||||||
{ key: 'trusted_domain', label: t('admin.wecom.copyFields.trustedDomain') },
|
{{ t('admin.wecom.fields.secret') }}
|
||||||
{ key: 'authorize_api', label: t('admin.wecom.copyFields.authorizeApi') },
|
<ElTooltip :content="t('admin.wecom.tips.secret')" placement="top">
|
||||||
{ key: 'login_api', label: t('admin.wecom.copyFields.loginApi') },
|
<ElIcon class="wecom-settings__help"><QuestionFilled /></ElIcon>
|
||||||
]"
|
</ElTooltip>
|
||||||
:key="item.key"
|
</span>
|
||||||
>
|
</template>
|
||||||
<label class="mb-1.5 block text-xs text-muted">{{ item.label }}</label>
|
<ElInput v-model="wecomSystemSettings.secret" type="password" show-password />
|
||||||
<div class="flex gap-2">
|
</ElFormItem>
|
||||||
<input :value="(wecomIntegrationManifest as any)[item.key] || ''" readonly class="input-field flex-1 bg-surface-soft font-mono text-xs" />
|
<ElFormItem class="wecom-settings__span">
|
||||||
<button type="button" class="btn-secondary px-3" @click="copyText(String((wecomIntegrationManifest as any)[item.key] || ''))">
|
<template #label>
|
||||||
{{ t('admin.wecom.copy') }}
|
<span class="wecom-settings__label">
|
||||||
</button>
|
{{ 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>
|
<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>
|
</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>
|
</div>
|
||||||
</details>
|
</AdminListPage>
|
||||||
</div>
|
</ElConfigProvider>
|
||||||
</template>
|
</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>
|
||||||
@@ -5612,7 +5612,7 @@
|
|||||||
"types": "Training Types",
|
"types": "Training Types",
|
||||||
"typeCount": "{count} configurations",
|
"typeCount": "{count} configurations",
|
||||||
"detail": "Configuration Details",
|
"detail": "Configuration Details",
|
||||||
"headerMeta": "Type: {type} · Current version: {version}",
|
"headerMeta": "Type code: {type}",
|
||||||
"addType": "Add Training Type",
|
"addType": "Add Training Type",
|
||||||
"editType": "Edit Training Type",
|
"editType": "Edit Training Type",
|
||||||
"empty": "No training configurations",
|
"empty": "No training configurations",
|
||||||
@@ -5663,6 +5663,7 @@
|
|||||||
},
|
},
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"onePerLine": "Enter one item per line",
|
"onePerLine": "Enter one item per line",
|
||||||
|
"typeCode": "Example: onboarding",
|
||||||
"oneQuestionPerLine": "Enter one question per line",
|
"oneQuestionPerLine": "Enter one question per line",
|
||||||
"progressItemLabel": "Example: Watch video",
|
"progressItemLabel": "Example: Watch video",
|
||||||
"progressHintText": "Example: Training is complete only after the video, knowledge review, and exam are all finished.",
|
"progressHintText": "Example: Training is complete only after the video, knowledge review, and exam are all finished.",
|
||||||
@@ -5681,6 +5682,11 @@
|
|||||||
"progressHintText": "Training progress note",
|
"progressHintText": "Training progress note",
|
||||||
"stepIntroText": "Training step guide copy",
|
"stepIntroText": "Training step guide copy",
|
||||||
"requiredDuration": "Required time (minutes)",
|
"requiredDuration": "Required time (minutes)",
|
||||||
|
"requiredDurationPlaceholder": "0 means no limit",
|
||||||
|
"stageSummaryTitle": "Level summaries (one item per line)",
|
||||||
|
"stageSummaryCompany": "Company summary",
|
||||||
|
"stageSummaryDepartment": "Department summary",
|
||||||
|
"stageSummaryTeam": "Team summary",
|
||||||
"summaryPoints": "Review points",
|
"summaryPoints": "Review points",
|
||||||
"summaryChecklist": "Pre-exam checklist",
|
"summaryChecklist": "Pre-exam checklist",
|
||||||
"employeeQuestions": "Employee FAQs",
|
"employeeQuestions": "Employee FAQs",
|
||||||
@@ -5797,12 +5803,6 @@
|
|||||||
"eyebrow": "Training Operations Center",
|
"eyebrow": "Training Operations Center",
|
||||||
"pageHint": "Configuration changes take effect after saving",
|
"pageHint": "Configuration changes take effect after saving",
|
||||||
"footerHint": "All configuration items can be adjusted after saving",
|
"footerHint": "All configuration items can be adjusted after saving",
|
||||||
"stats": {
|
|
||||||
"total": "Total Configs",
|
|
||||||
"published": "Published",
|
|
||||||
"resources": "Current Materials",
|
|
||||||
"levels": "Configured Levels"
|
|
||||||
},
|
|
||||||
"questionBankTitle": "Onboarding Question Bank"
|
"questionBankTitle": "Onboarding Question Bank"
|
||||||
},
|
},
|
||||||
"integrationConnector": {
|
"integrationConnector": {
|
||||||
|
|||||||
@@ -5612,7 +5612,7 @@
|
|||||||
"types": "ประเภทการฝึกอบรม",
|
"types": "ประเภทการฝึกอบรม",
|
||||||
"typeCount": "ทั้งหมด {count} การกำหนดค่า",
|
"typeCount": "ทั้งหมด {count} การกำหนดค่า",
|
||||||
"detail": "รายละเอียดการกำหนดค่า",
|
"detail": "รายละเอียดการกำหนดค่า",
|
||||||
"headerMeta": "ประเภท: {type} · เวอร์ชันปัจจุบัน: {version}",
|
"headerMeta": "รหัสประเภท: {type}",
|
||||||
"addType": "เพิ่มประเภทการฝึกอบรม",
|
"addType": "เพิ่มประเภทการฝึกอบรม",
|
||||||
"editType": "แก้ไขประเภทการฝึกอบรม",
|
"editType": "แก้ไขประเภทการฝึกอบรม",
|
||||||
"empty": "ยังไม่มีการกำหนดค่า",
|
"empty": "ยังไม่มีการกำหนดค่า",
|
||||||
@@ -5663,6 +5663,7 @@
|
|||||||
},
|
},
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"onePerLine": "กรอกหนึ่งรายการต่อบรรทัด",
|
"onePerLine": "กรอกหนึ่งรายการต่อบรรทัด",
|
||||||
|
"typeCode": "ตัวอย่าง: onboarding",
|
||||||
"oneQuestionPerLine": "กรอกหนึ่งคำถามต่อบรรทัด",
|
"oneQuestionPerLine": "กรอกหนึ่งคำถามต่อบรรทัด",
|
||||||
"progressItemLabel": "ตัวอย่าง: ดูวิดีโอ",
|
"progressItemLabel": "ตัวอย่าง: ดูวิดีโอ",
|
||||||
"progressHintText": "ตัวอย่าง: จะถือว่าเสร็จสิ้นเมื่อทำวิดีโอ ทบทวนความรู้ และข้อสอบครบแล้ว",
|
"progressHintText": "ตัวอย่าง: จะถือว่าเสร็จสิ้นเมื่อทำวิดีโอ ทบทวนความรู้ และข้อสอบครบแล้ว",
|
||||||
@@ -5681,6 +5682,11 @@
|
|||||||
"progressHintText": "คำอธิบายความคืบหน้าการฝึกอบรม",
|
"progressHintText": "คำอธิบายความคืบหน้าการฝึกอบรม",
|
||||||
"stepIntroText": "ข้อความแนะนำขั้นตอนการฝึกอบรม",
|
"stepIntroText": "ข้อความแนะนำขั้นตอนการฝึกอบรม",
|
||||||
"requiredDuration": "เวลาที่ต้องใช้ (นาที)",
|
"requiredDuration": "เวลาที่ต้องใช้ (นาที)",
|
||||||
|
"requiredDurationPlaceholder": "0 หมายถึงไม่จำกัด",
|
||||||
|
"stageSummaryTitle": "สรุปตามระดับ (หนึ่งรายการต่อบรรทัด)",
|
||||||
|
"stageSummaryCompany": "สรุประดับบริษัท",
|
||||||
|
"stageSummaryDepartment": "สรุประดับแผนก",
|
||||||
|
"stageSummaryTeam": "สรุประดับทีม",
|
||||||
"summaryPoints": "ประเด็นทบทวน",
|
"summaryPoints": "ประเด็นทบทวน",
|
||||||
"summaryChecklist": "รายการก่อนสอบ",
|
"summaryChecklist": "รายการก่อนสอบ",
|
||||||
"employeeQuestions": "คำถามที่พบบ่อยของพนักงาน",
|
"employeeQuestions": "คำถามที่พบบ่อยของพนักงาน",
|
||||||
@@ -5797,12 +5803,6 @@
|
|||||||
"eyebrow": "培训运营中心",
|
"eyebrow": "培训运营中心",
|
||||||
"pageHint": "配置变更将在保存后生效",
|
"pageHint": "配置变更将在保存后生效",
|
||||||
"footerHint": "所有配置项均支持保存后继续调整",
|
"footerHint": "所有配置项均支持保存后继续调整",
|
||||||
"stats": {
|
|
||||||
"total": "配置总数",
|
|
||||||
"published": "已发布",
|
|
||||||
"resources": "当前资料",
|
|
||||||
"levels": "已配置级别"
|
|
||||||
},
|
|
||||||
"questionBankTitle": "入职培训题库"
|
"questionBankTitle": "入职培训题库"
|
||||||
},
|
},
|
||||||
"integrationConnector": {
|
"integrationConnector": {
|
||||||
|
|||||||
@@ -5626,16 +5626,10 @@
|
|||||||
"subtitle": "按培训类型管理版本、考试规则、资源与题目",
|
"subtitle": "按培训类型管理版本、考试规则、资源与题目",
|
||||||
"pageHint": "配置变更将在保存后生效",
|
"pageHint": "配置变更将在保存后生效",
|
||||||
"footerHint": "所有配置项均支持保存后继续调整",
|
"footerHint": "所有配置项均支持保存后继续调整",
|
||||||
"stats": {
|
|
||||||
"total": "配置总数",
|
|
||||||
"published": "已发布",
|
|
||||||
"resources": "当前资料",
|
|
||||||
"levels": "已配置级别"
|
|
||||||
},
|
|
||||||
"types": "培训类型",
|
"types": "培训类型",
|
||||||
"typeCount": "共 {count} 个配置",
|
"typeCount": "共 {count} 个配置",
|
||||||
"detail": "配置详情",
|
"detail": "配置详情",
|
||||||
"headerMeta": "类型编码:{type} · 当前版本:{version}",
|
"headerMeta": "类型编码:{type}",
|
||||||
"addType": "新增培训类型",
|
"addType": "新增培训类型",
|
||||||
"editType": "编辑培训类型",
|
"editType": "编辑培训类型",
|
||||||
"empty": "暂无培训配置",
|
"empty": "暂无培训配置",
|
||||||
@@ -5687,6 +5681,7 @@
|
|||||||
},
|
},
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"onePerLine": "每行填写一项",
|
"onePerLine": "每行填写一项",
|
||||||
|
"typeCode": "例如 onboarding,小写字母开头",
|
||||||
"oneQuestionPerLine": "每行填写一个问题",
|
"oneQuestionPerLine": "每行填写一个问题",
|
||||||
"progressItemLabel": "例如:观看视频",
|
"progressItemLabel": "例如:观看视频",
|
||||||
"progressHintText": "例如:按 HR 要求完成视频、知识点、考试三个环节后才能视为完成。",
|
"progressHintText": "例如:按 HR 要求完成视频、知识点、考试三个环节后才能视为完成。",
|
||||||
@@ -5705,6 +5700,11 @@
|
|||||||
"progressHintText": "培训进度说明",
|
"progressHintText": "培训进度说明",
|
||||||
"stepIntroText": "培训步骤引导文案",
|
"stepIntroText": "培训步骤引导文案",
|
||||||
"requiredDuration": "所需时间(分钟)",
|
"requiredDuration": "所需时间(分钟)",
|
||||||
|
"requiredDurationPlaceholder": "0 表示不限制",
|
||||||
|
"stageSummaryTitle": "分级培训总结(按行分隔)",
|
||||||
|
"stageSummaryCompany": "公司级总结",
|
||||||
|
"stageSummaryDepartment": "部门级总结",
|
||||||
|
"stageSummaryTeam": "班组级总结",
|
||||||
"summaryPoints": "复盘要点",
|
"summaryPoints": "复盘要点",
|
||||||
"summaryChecklist": "考前清单",
|
"summaryChecklist": "考前清单",
|
||||||
"employeeQuestions": "员工常见问题",
|
"employeeQuestions": "员工常见问题",
|
||||||
|
|||||||
@@ -5612,7 +5612,7 @@
|
|||||||
"types": "培訓類型",
|
"types": "培訓類型",
|
||||||
"typeCount": "共 {count} 個配置",
|
"typeCount": "共 {count} 個配置",
|
||||||
"detail": "配置詳情",
|
"detail": "配置詳情",
|
||||||
"headerMeta": "類型編碼:{type} · 目前版本:{version}",
|
"headerMeta": "類型編碼:{type}",
|
||||||
"addType": "新增培訓類型",
|
"addType": "新增培訓類型",
|
||||||
"editType": "編輯培訓類型",
|
"editType": "編輯培訓類型",
|
||||||
"empty": "暫無培訓配置",
|
"empty": "暫無培訓配置",
|
||||||
@@ -5663,6 +5663,7 @@
|
|||||||
},
|
},
|
||||||
"placeholders": {
|
"placeholders": {
|
||||||
"onePerLine": "每行填寫一項",
|
"onePerLine": "每行填寫一項",
|
||||||
|
"typeCode": "例如 onboarding,小寫字母開頭",
|
||||||
"oneQuestionPerLine": "每行填寫一個問題",
|
"oneQuestionPerLine": "每行填寫一個問題",
|
||||||
"progressItemLabel": "例如:觀看影片",
|
"progressItemLabel": "例如:觀看影片",
|
||||||
"progressHintText": "例如:按 HR 要求完成影片、知識點、考試三個環節後才算完成。",
|
"progressHintText": "例如:按 HR 要求完成影片、知識點、考試三個環節後才算完成。",
|
||||||
@@ -5681,6 +5682,11 @@
|
|||||||
"progressHintText": "培訓進度說明",
|
"progressHintText": "培訓進度說明",
|
||||||
"stepIntroText": "培訓步驟引導文案",
|
"stepIntroText": "培訓步驟引導文案",
|
||||||
"requiredDuration": "所需時間(分鐘)",
|
"requiredDuration": "所需時間(分鐘)",
|
||||||
|
"requiredDurationPlaceholder": "0 表示不限制",
|
||||||
|
"stageSummaryTitle": "分級培訓總結(按行分隔)",
|
||||||
|
"stageSummaryCompany": "公司級總結",
|
||||||
|
"stageSummaryDepartment": "部門級總結",
|
||||||
|
"stageSummaryTeam": "班組級總結",
|
||||||
"summaryPoints": "複盤要點",
|
"summaryPoints": "複盤要點",
|
||||||
"summaryChecklist": "考前清單",
|
"summaryChecklist": "考前清單",
|
||||||
"employeeQuestions": "員工常見問題",
|
"employeeQuestions": "員工常見問題",
|
||||||
@@ -5797,12 +5803,6 @@
|
|||||||
"eyebrow": "培训运营中心",
|
"eyebrow": "培训运营中心",
|
||||||
"pageHint": "配置变更将在保存后生效",
|
"pageHint": "配置变更将在保存后生效",
|
||||||
"footerHint": "所有配置项均支持保存后继续调整",
|
"footerHint": "所有配置项均支持保存后继续调整",
|
||||||
"stats": {
|
|
||||||
"total": "配置总数",
|
|
||||||
"published": "已发布",
|
|
||||||
"resources": "当前资料",
|
|
||||||
"levels": "已配置级别"
|
|
||||||
},
|
|
||||||
"questionBankTitle": "入职培训题库"
|
"questionBankTitle": "入职培训题库"
|
||||||
},
|
},
|
||||||
"integrationConnector": {
|
"integrationConnector": {
|
||||||
|
|||||||
Reference in new issue
Block a user