Merge branch 'dev' into hugo
This commit is contained in:
commit
29a7704d46
55 files changed
+2852
-546
No files matched your search
@@ -40,7 +40,10 @@ const SchedulesPage = () =>
|
||||
const KnowledgeBasePage = () =>
|
||||
import("@/features/admin/modules/knowledge-base/KnowledgeBasePage.vue");
|
||||
|
||||
const WecomPage = () => import("@/features/admin/modules/wecom/WecomPage.vue");
|
||||
const WecomLayout = () => import("@/features/admin/modules/wecom/WecomLayout.vue");
|
||||
const WecomSettingsPage = () => import("@/features/admin/modules/wecom/pages/WecomSettingsPage.vue");
|
||||
const WecomBindingsPage = () => import("@/features/admin/modules/wecom/pages/WecomBindingsPage.vue");
|
||||
const WecomAuditsPage = () => import("@/features/admin/modules/wecom/pages/WecomAuditsPage.vue");
|
||||
|
||||
const ReportsPage = () =>
|
||||
import("@/features/admin/modules/reports/ReportsPage.vue");
|
||||
@@ -83,8 +86,29 @@ export const adminRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: "wecom",
|
||||
name: "AdminWecom",
|
||||
component: WecomPage,
|
||||
component: WecomLayout,
|
||||
redirect: { name: "AdminWecomSettings" },
|
||||
meta: { requiresAdmin: true, adminModule: "wecom", title: "企业微信" },
|
||||
children: [
|
||||
{
|
||||
path: "settings",
|
||||
name: "AdminWecomSettings",
|
||||
component: WecomSettingsPage,
|
||||
meta: { requiresAdmin: true, adminModule: "wecom", title: "企业微信配置" },
|
||||
},
|
||||
{
|
||||
path: "bindings",
|
||||
name: "AdminWecomBindings",
|
||||
component: WecomBindingsPage,
|
||||
meta: { requiresAdmin: true, adminModule: "wecom", title: "企业微信绑定" },
|
||||
},
|
||||
{
|
||||
path: "audits",
|
||||
name: "AdminWecomAudits",
|
||||
component: WecomAuditsPage,
|
||||
meta: { requiresAdmin: true, adminModule: "wecom", title: "企业微信审计" },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "approvals",
|
||||
|
||||
@@ -130,8 +130,26 @@ export const batchDeleteAdminChatLogs = (ids: number[]) =>
|
||||
});
|
||||
|
||||
// WeCom admin
|
||||
export const listAdminWecomBindings = (boundOnly: boolean) =>
|
||||
requestJson<any[]>(`/api/admin/wecom/bindings?bound_only=${boundOnly ? 'true' : 'false'}`, auth());
|
||||
export interface ListAdminWecomBindingsParams {
|
||||
boundOnly?: boolean;
|
||||
keyword?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}
|
||||
|
||||
export const listAdminWecomBindings = (params: ListAdminWecomBindingsParams = {}) => {
|
||||
const qs = new URLSearchParams();
|
||||
if (params.boundOnly) qs.set('bound_only', 'true');
|
||||
const keyword = params.keyword?.trim();
|
||||
if (keyword) qs.set('keyword', keyword);
|
||||
if (params.page) qs.set('page', String(params.page));
|
||||
if (params.pageSize) qs.set('page_size', String(params.pageSize));
|
||||
const query = qs.toString();
|
||||
const suffix = query ? `?${query}` : '';
|
||||
return requestJson<import('@/shared/types/pagination.types').PaginatedResult<
|
||||
import('@/features/admin/types/wecom.types').WecomBindingRow
|
||||
>>(`/api/admin/wecom/bindings${suffix}`, auth());
|
||||
};
|
||||
export const listAdminWecomLoginAudits = (query: string) =>
|
||||
requestJson<any[]>(`/api/admin/wecom/login-audits?${query}`, auth());
|
||||
export const getAdminWecomSystemSettings = () =>
|
||||
@@ -154,6 +172,14 @@ export const saveAdminWecomNotifySettings = (payload: Record<string, unknown>) =
|
||||
});
|
||||
export const getAdminWecomNotifyMetrics = () =>
|
||||
requestJson<any>('/api/admin/wecom/notify-metrics', auth());
|
||||
export const getAdminWecomBindingStats = () =>
|
||||
requestJson<import('@/features/admin/types/wecom.types').WecomBindingStats>('/api/admin/wecom/binding-stats', auth());
|
||||
export const syncAdminWecomUserids = (payload: { apply: boolean; department_id?: number | null }) =>
|
||||
requestJson<import('@/features/admin/types/wecom.types').WecomSyncSummary>('/api/admin/wecom/sync-userids', {
|
||||
method: 'POST',
|
||||
...jsonAuth(),
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
export const bindAdminWecomUser = (payload: Record<string, unknown>) =>
|
||||
requestJson('/api/admin/wecom/bind', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const unbindAdminWecomUser = (userId: number) =>
|
||||
|
||||
@@ -42,10 +42,25 @@ const visibleModules = computed(() =>
|
||||
ADMIN_MODULE_METAS.filter((item) => config.admin.modules[item.configKey] !== false),
|
||||
);
|
||||
|
||||
const standardModules = computed(() =>
|
||||
visibleModules.value.filter((item) => item.id !== 'wecom'),
|
||||
);
|
||||
|
||||
const isModuleActive = (moduleId: AdminModuleId): boolean =>
|
||||
route.meta.adminModule === moduleId;
|
||||
|
||||
const isReportsActive = computed(() => route.meta.adminModule === 'reports');
|
||||
const isWecomActive = computed(() => route.meta.adminModule === 'wecom');
|
||||
|
||||
const wecomSubRoutes = [
|
||||
{ name: 'AdminWecomSettings', labelKey: 'admin.wecom.nav.settings' },
|
||||
{ name: 'AdminWecomBindings', labelKey: 'admin.wecom.nav.bindings' },
|
||||
{ name: 'AdminWecomAudits', labelKey: 'admin.wecom.nav.audits' },
|
||||
] as const;
|
||||
|
||||
const navigateWecom = (routeName: string): void => {
|
||||
router.push({ name: routeName });
|
||||
};
|
||||
|
||||
const getReportTableLabel = (table: string): string => {
|
||||
const i18nKey = `admin.report.tables.${table}`;
|
||||
@@ -70,7 +85,7 @@ const navigateReport = (table: string): void => {
|
||||
>
|
||||
<nav class="flex md:flex-col p-3 gap-1 overflow-x-auto md:overflow-visible no-scrollbar">
|
||||
<button
|
||||
v-for="item in visibleModules"
|
||||
v-for="item in standardModules"
|
||||
:key="item.id"
|
||||
type="button"
|
||||
class="admin-nav-btn group"
|
||||
@@ -96,6 +111,35 @@ const navigateReport = (table: string): void => {
|
||||
/>
|
||||
</button>
|
||||
|
||||
<div v-if="config.admin.modules.wecom !== false" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
class="admin-nav-btn group justify-between"
|
||||
:class="{ 'admin-nav-btn--active': isWecomActive }"
|
||||
@click="navStore.wecomExpanded = !navStore.wecomExpanded"
|
||||
>
|
||||
<div class="flex items-center gap-3">
|
||||
<Link2 class="w-5 h-5 flex-shrink-0" :class="isWecomActive ? 'text-brand-600' : 'text-muted'" />
|
||||
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t('admin.nav.wecom') }}</span>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
v-if="navStore.wecomExpanded && !navStore.sidebarCollapsed"
|
||||
class="pl-4 space-y-1 mt-1 border-l-2 border-subtle ml-6"
|
||||
>
|
||||
<button
|
||||
v-for="sub in wecomSubRoutes"
|
||||
:key="sub.name"
|
||||
type="button"
|
||||
class="admin-nav-subitem"
|
||||
:class="{ 'admin-nav-subitem--active': route.name === sub.name }"
|
||||
@click="navigateWecom(sub.name)"
|
||||
>
|
||||
{{ t(sub.labelKey) }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="config.admin.modules.reports !== false" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
getAdminUsageReport,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import { loadReportLayoutPref, saveReportLayoutPref } from '@/shared/composables/useReportLayoutStorage';
|
||||
import { buildOffsetPageButtons } from '@/shared/composables/useOffsetPagination';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { ADMIN_REPORT_TABLES } from '@/features/admin/constants/modules';
|
||||
import type {
|
||||
@@ -635,10 +636,7 @@ const nextReportPage = () => goToReportPage(reportCurrentPage.value + 1);
|
||||
const reportPageButtons = computed(() => {
|
||||
const total = reportTotalPages.value;
|
||||
const current = Math.min(Math.max(1, reportCurrentPage.value), total);
|
||||
if (total <= 7) return Array.from({ length: total }, (_, i) => i + 1);
|
||||
if (current <= 4) return [1, 2, 3, 4, 5, -1, total];
|
||||
if (current >= total - 3) return [1, -1, total - 4, total - 3, total - 2, total - 1, total];
|
||||
return [1, -1, current - 1, current, current + 1, -1, total];
|
||||
return buildOffsetPageButtons(current, total);
|
||||
});
|
||||
|
||||
const onReportHeaderClick = (key: string) => {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/WecomLayout.vue
|
||||
* 企微管理壳层:二级 Tab、共享 composable、子路由出口。
|
||||
*/
|
||||
import { onMounted, provide } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { RefreshCw } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import WecomSubNav from './components/WecomSubNav.vue';
|
||||
import { useWecomAdmin } from './composables/useWecomAdmin';
|
||||
import { WECOM_ADMIN_KEY } from './wecom.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const wecomAdmin = useWecomAdmin();
|
||||
provide(WECOM_ADMIN_KEY, wecomAdmin);
|
||||
const {
|
||||
isLoading,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
confirmDelete,
|
||||
refreshWecomData,
|
||||
} = wecomAdmin;
|
||||
|
||||
onMounted(() => {
|
||||
void wecomAdmin.loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<section v-else class="section-gap animate-fade-in-up space-y-6">
|
||||
<div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.wecom.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-secondary inline-flex items-center gap-2 px-4 py-2 text-secondary rounded-xl hover-surface-soft transition-all shadow-sm"
|
||||
@click="refreshWecomData()"
|
||||
>
|
||||
<RefreshCw class="w-4 h-4" />
|
||||
{{ t('admin.wecom.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<WecomSubNav />
|
||||
<router-view />
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,456 +0,0 @@
|
||||
/**
|
||||
* features/admin/modules/wecom/WecomPage.vue
|
||||
* 企业微信管理独立页面。路由:/admin/wecom
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { CircleHelp, Download, Link2, RefreshCw, Unlink2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { useWecomAdmin } from './composables/useWecomAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
isLoading,
|
||||
isSaving,
|
||||
wecomBindings,
|
||||
wecomBindForm,
|
||||
wecomBindUserQuery,
|
||||
wecomBindUserDropdownOpen,
|
||||
wecomBindUserOptions,
|
||||
wecomBoundOnly,
|
||||
wecomAuditSourceFilter,
|
||||
wecomAuditStatusFilter,
|
||||
filteredWecomLoginAudits,
|
||||
wecomNotifySettings,
|
||||
wecomNotifyEventsText,
|
||||
wecomNotifyMetrics,
|
||||
wecomSystemSettings,
|
||||
wecomIntegrationManifest,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
refreshWecomData,
|
||||
selectWecomBindUser,
|
||||
scheduleCloseWecomBindUserDropdown,
|
||||
copyText,
|
||||
getWecomAuditReasonText,
|
||||
getWecomAuditMetaText,
|
||||
generateWecomAddressesFromPublicBase,
|
||||
generateWecomCallbackToken,
|
||||
generateWecomEncodingAesKey,
|
||||
saveWecomSystemSettings,
|
||||
saveWecomNotifySettings,
|
||||
bindWecomUser,
|
||||
unbindWecomUserByAdmin,
|
||||
exportWecomAudits,
|
||||
confirmDelete,
|
||||
} = useWecomAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<section v-else class="section-gap animate-fade-in-up">
|
||||
<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
|
||||
@click="refreshWecomData"
|
||||
class="btn-secondary inline-flex items-center gap-2 px-4 py-2 text-secondary rounded-xl hover-surface-soft transition-all shadow-sm"
|
||||
>
|
||||
<RefreshCw class="w-4 h-4" />
|
||||
{{ t('admin.wecom.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.quickBind') }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-3">
|
||||
<div class="relative md:col-span-1">
|
||||
<input
|
||||
v-model="wecomBindUserQuery"
|
||||
type="text"
|
||||
class="input-field"
|
||||
:placeholder="t('admin.wecom.fields.userSelect')"
|
||||
@focus="wecomBindUserDropdownOpen = true"
|
||||
@input="wecomBindUserDropdownOpen = true"
|
||||
@blur="scheduleCloseWecomBindUserDropdown"
|
||||
/>
|
||||
<div
|
||||
v-if="wecomBindUserDropdownOpen"
|
||||
class="admin-dropdown w-72"
|
||||
>
|
||||
<button
|
||||
v-for="u in wecomBindUserOptions"
|
||||
:key="u.id"
|
||||
type="button"
|
||||
class="flex w-full items-center justify-between gap-3 px-3 py-2 text-left hover:bg-blue-50"
|
||||
@mousedown.prevent="selectWecomBindUser(u.id, u.label)"
|
||||
>
|
||||
<span class="text-sm text-primary">{{ u.label }}</span>
|
||||
<span class="text-xs text-muted">{{ u.employeeId || '' }}</span>
|
||||
</button>
|
||||
<div v-if="wecomBindUserOptions.length === 0" class="px-3 py-2 text-sm text-muted">
|
||||
{{ t('admin.wecom.noData') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input v-model="wecomBindForm.wecom_userid" :placeholder="t('admin.wecom.fields.wecomUserId')" class="input-field md:col-span-2" />
|
||||
<input v-model="wecomBindForm.wecom_unionid" :placeholder="t('admin.wecom.fields.wecomUnionId')" class="input-field" />
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button @click="bindWecomUser" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60">
|
||||
<Link2 class="w-4 h-4" /> {{ t('admin.wecom.bind') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.systemSettings') }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomSystemSettings.enabled" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.enabled') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.enabled')" />
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomSystemSettings.auto_create_user" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.autoCreateUser') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.autoCreateUser')" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.corpId') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.corpId')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.corp_id" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.agentId') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.agentId')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.agent_id" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.secret') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.secret')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.secret" type="password" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.redirectUri') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.redirectUri')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.redirect_uri" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.publicBaseUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.publicBaseUrl')" />
|
||||
</label>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<input
|
||||
v-model="wecomSystemSettings.public_base_url"
|
||||
:placeholder="t('admin.wecom.publicBasePlaceholder')"
|
||||
class="input-field flex-1 min-w-[200px]"
|
||||
/>
|
||||
<button type="button" class="btn-secondary px-4 shrink-0" @click="generateWecomAddressesFromPublicBase">
|
||||
{{ t('admin.wecom.generateAddresses') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.callbackToken') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.callbackToken')" />
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<input v-model="wecomSystemSettings.callback_token" class="input-field flex-1 min-w-0" />
|
||||
<button type="button" class="btn-secondary px-3 shrink-0 text-xs" @click="generateWecomCallbackToken">
|
||||
{{ t('admin.wecom.generateToken') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.encodingAesKey') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.encodingAesKey')" />
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<input v-model="wecomSystemSettings.encoding_aes_key" class="input-field flex-1 min-w-0 font-mono text-xs" />
|
||||
<button type="button" class="btn-secondary px-3 shrink-0 text-xs" @click="generateWecomEncodingAesKey">
|
||||
{{ t('admin.wecom.generateEncodingKey') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.callbackUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.callbackUrl')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.callback_url" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.homepageUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.homepageUrl')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.homepage_url" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.trustedDomain') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.trustedDomain')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.trusted_domain" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.matchRules') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.matchRules')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.match_rules" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.matchOperator') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.matchOperator')" />
|
||||
</label>
|
||||
<select v-model="wecomSystemSettings.match_operator" class="input-field">
|
||||
<option value="AND">AND</option>
|
||||
<option value="OR">OR</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.firstLoginBindMode') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.firstLoginBindMode')" />
|
||||
</label>
|
||||
<select v-model="wecomSystemSettings.first_login_bind_mode" class="input-field">
|
||||
<option value="match_rules">{{ t('admin.wecom.bindModes.match_rules') }}</option>
|
||||
<option value="input_verify">{{ t('admin.wecom.bindModes.input_verify') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.firstLoginInputFields') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.firstLoginInputFields')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.first_login_input_fields" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.employeeIdSource') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.employeeIdSource')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.employee_id_source" class="input-field" />
|
||||
</div>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary pt-7">
|
||||
<input v-model="wecomSystemSettings.mobile_normalize" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.mobileNormalize') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.mobileNormalize')" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button @click="saveWecomSystemSettings" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60">
|
||||
{{ t('admin.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.notifySettings') }}</h3>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomNotifySettings.enabled" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.notifyEnabled') }}
|
||||
</label>
|
||||
<input v-model="wecomNotifySettings.base_url" :placeholder="t('admin.wecom.notifyBaseUrl')" class="input-field" />
|
||||
<input v-model="wecomNotifyEventsText" :placeholder="t('admin.wecom.notifyEvents')" class="input-field" />
|
||||
<div class="flex justify-end">
|
||||
<button @click="saveWecomNotifySettings" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60">
|
||||
{{ t('admin.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.notifyMetrics') }}</h3>
|
||||
<div v-if="wecomNotifyMetrics" class="grid grid-cols-2 gap-3 text-sm">
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricTotal') }}</div>
|
||||
<div class="text-lg font-semibold text-primary">{{ wecomNotifyMetrics.total }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricSuccessRate') }}</div>
|
||||
<div class="text-lg font-semibold text-emerald-700">{{ wecomNotifyMetrics.send_success_rate }}%</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricOpenedRate') }}</div>
|
||||
<div class="text-lg font-semibold text-blue-700">{{ wecomNotifyMetrics.opened_24h_rate }}%</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricWindowDays') }}</div>
|
||||
<div class="text-lg font-semibold text-primary">{{ wecomNotifyMetrics.window_days }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.integrationCopyTitle') }}</h3>
|
||||
<p class="text-xs text-muted">{{ t('admin.wecom.integrationCopyDesc') }}</p>
|
||||
<p class="text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded-lg px-3 py-2">{{ t('admin.wecom.integrationCopySecretsNote') }}</p>
|
||||
<div v-if="wecomIntegrationManifest" class="grid grid-cols-1 gap-3">
|
||||
<div v-for="item in [
|
||||
{ key: 'public_base_url', label: t('admin.wecom.copyFields.publicBaseUrl') },
|
||||
{ key: 'callback_url', label: t('admin.wecom.copyFields.callbackUrl') },
|
||||
{ key: 'callback_token', label: t('admin.wecom.copyFields.callbackToken') },
|
||||
{ key: 'encoding_aes_key', label: t('admin.wecom.copyFields.encodingAesKey') },
|
||||
{ key: 'oauth_redirect_uri', label: t('admin.wecom.copyFields.oauthRedirectUri') },
|
||||
{ key: 'homepage_url', label: t('admin.wecom.copyFields.homepageUrl') },
|
||||
{ key: 'trusted_domain', label: t('admin.wecom.copyFields.trustedDomain') },
|
||||
{ key: 'authorize_api', label: t('admin.wecom.copyFields.authorizeApi') },
|
||||
{ key: 'login_api', label: t('admin.wecom.copyFields.loginApi') },
|
||||
]" :key="item.key">
|
||||
<label class="mb-1.5 block text-xs text-muted">{{ item.label }}</label>
|
||||
<div class="flex gap-2">
|
||||
<input :value="(wecomIntegrationManifest as any)[item.key] || ''" readonly class="input-field flex-1 bg-surface-soft font-mono text-xs" />
|
||||
<button class="btn-secondary px-3" @click="copyText(String((wecomIntegrationManifest as any)[item.key] || ''))">{{ t('admin.wecom.copy') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-section">
|
||||
<div class="admin-table-header px-5 py-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.bindingList') }}</h3>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input type="checkbox" v-model="wecomBoundOnly" class="w-4 h-4 rounded text-brand-600 border-default" />
|
||||
{{ t('admin.wecom.boundOnly') }}
|
||||
</label>
|
||||
</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.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="5" 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">{{ 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"
|
||||
@click="unbindWecomUserByAdmin(u.id)"
|
||||
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"
|
||||
>
|
||||
<Unlink2 class="w-3.5 h-3.5" />
|
||||
{{ t('admin.wecom.unbind') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-section">
|
||||
<div class="admin-table-header admin-table-header--stacked px-5 py-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.auditTitle') }}</h3>
|
||||
<div class="flex w-full md:w-auto flex-wrap md:flex-nowrap items-center justify-start md:justify-end gap-2">
|
||||
<select v-model="wecomAuditSourceFilter" class="admin-table-filter-input h-11 min-w-[112px] shrink-0">
|
||||
<option value="all">{{ t('admin.wecom.filters.allSources') }}</option>
|
||||
<option value="wecom">{{ t('admin.wecom.sources.wecom') }}</option>
|
||||
<option value="password">{{ t('admin.wecom.sources.password') }}</option>
|
||||
</select>
|
||||
<select v-model="wecomAuditStatusFilter" class="admin-table-filter-input h-11 min-w-[112px] shrink-0">
|
||||
<option value="all">{{ t('admin.wecom.filters.allStatus') }}</option>
|
||||
<option value="success">{{ t('admin.wecom.auditStatus.success') }}</option>
|
||||
<option value="failed">{{ t('admin.wecom.auditStatus.failed') }}</option>
|
||||
</select>
|
||||
<button
|
||||
@click="exportWecomAudits"
|
||||
class="btn-secondary h-11 shrink-0 text-sm"
|
||||
>
|
||||
<Download class="w-4 h-4" />
|
||||
{{ t('admin.wecom.exportAudit') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-table-wrap max-h-[420px]">
|
||||
<table class="admin-table">
|
||||
<thead class="sticky top-0 z-10 admin-table-sticky-head">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.time') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.source') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.user') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.status') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.reason') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.ip') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="filteredWecomLoginAudits.length === 0">
|
||||
<td colspan="6" class="px-4 admin-table-empty">{{ t('admin.wecom.noAuditData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in filteredWecomLoginAudits" :key="row.id">
|
||||
<td class="px-4 py-3 text-xs text-muted whitespace-nowrap">{{ row.created_at || '-' }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary">{{ t('admin.wecom.sources.' + row.source) }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary">{{ row.username || '-' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span class="inline-flex px-2 py-0.5 rounded-full text-[11px] font-medium" :class="row.status === 'success' ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700'">
|
||||
{{ t('admin.wecom.auditStatus.' + row.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-muted max-w-[360px] align-top">
|
||||
<div class="max-w-[360px] whitespace-normal break-words">
|
||||
<div class="text-xs text-secondary leading-5">{{ getWecomAuditReasonText(row) }}</div>
|
||||
<div v-if="getWecomAuditMetaText(row)" class="mt-1 text-[11px] text-muted leading-5" :title="getWecomAuditMetaText(row)">
|
||||
{{ getWecomAuditMetaText(row) }}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-muted font-mono">{{ row.ip || '-' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/components/WecomOverviewCards.vue
|
||||
* 企微 userid 绑定概览统计卡片。
|
||||
*/
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { getAdminWecomBindingStats } from '@/features/admin/api/admin.api';
|
||||
import type { WecomBindingStats } from '@/features/admin/types/wecom.types';
|
||||
|
||||
const props = defineProps<{
|
||||
refreshKey?: number;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const stats = ref<WecomBindingStats | null>(null);
|
||||
|
||||
/**
|
||||
* 拉取绑定统计,供设置页概览卡片展示。
|
||||
*/
|
||||
const loadStats = async (): Promise<void> => {
|
||||
try {
|
||||
stats.value = await getAdminWecomBindingStats();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
stats.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
void loadStats();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.refreshKey,
|
||||
() => {
|
||||
void loadStats();
|
||||
},
|
||||
);
|
||||
|
||||
defineExpose({ reload: loadStats });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="stats" class="grid grid-cols-2 xl:grid-cols-4 gap-3">
|
||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.bound') }}</div>
|
||||
<div class="mt-1 text-xl font-semibold text-primary">{{ stats.bound }} / {{ stats.total_active }}</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.unbound') }}</div>
|
||||
<div class="mt-1 text-xl font-semibold text-amber-700">{{ stats.unbound }}</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.boundRate') }}</div>
|
||||
<div class="mt-1 text-xl font-semibold text-emerald-700">{{ stats.bound_rate }}%</div>
|
||||
</div>
|
||||
<div class="rounded-xl bg-surface-soft px-4 py-3">
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.overview.hint') }}</div>
|
||||
<div class="mt-1 text-sm text-secondary leading-5">{{ t('admin.wecom.overview.hintDesc') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/components/WecomSubNav.vue
|
||||
* 企微管理二级 Tab 导航。
|
||||
*/
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const tabs = [
|
||||
{ name: 'AdminWecomSettings', labelKey: 'admin.wecom.nav.settings' },
|
||||
{ name: 'AdminWecomBindings', labelKey: 'admin.wecom.nav.bindings' },
|
||||
{ name: 'AdminWecomAudits', labelKey: 'admin.wecom.nav.audits' },
|
||||
] as const;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-wrap gap-2 border-b border-subtle pb-3">
|
||||
<router-link
|
||||
v-for="tab in tabs"
|
||||
:key="tab.name"
|
||||
:to="{ name: tab.name }"
|
||||
class="rounded-xl px-4 py-2 text-sm font-medium transition-colors"
|
||||
:class="route.name === tab.name
|
||||
? 'bg-brand-50 text-brand-700 ring-1 ring-brand-200'
|
||||
: 'text-secondary hover:bg-surface-soft hover:text-primary'"
|
||||
>
|
||||
{{ t(tab.labelKey) }}
|
||||
</router-link>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,144 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/components/WecomSyncPanel.vue
|
||||
* 企微通讯录 userid 一键同步面板(预览 + 确认写入)。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { RefreshCw } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||
import { useWecomSync } from '../composables/useWecomSync';
|
||||
|
||||
const emit = defineEmits<{
|
||||
applied: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const { wecomSystemSettings, refreshWecomData } = inject(WECOM_ADMIN_KEY)!;
|
||||
|
||||
const {
|
||||
departmentId,
|
||||
isSyncing,
|
||||
previewSummary,
|
||||
showApplyConfirm,
|
||||
previewSync,
|
||||
requestApplySync,
|
||||
confirmApplySync,
|
||||
} = useWecomSync({
|
||||
onApplied: async () => {
|
||||
await refreshWecomData();
|
||||
emit('applied');
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<div>
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.sync.title') }}</h3>
|
||||
<p class="mt-1 text-sm text-muted">{{ t('admin.wecom.sync.desc') }}</p>
|
||||
<p class="mt-2 text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded-lg px-3 py-2">
|
||||
{{ t('admin.wecom.sync.permissionNote') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1.5 block text-xs text-muted">{{ t('admin.wecom.sync.employeeIdSource') }}</label>
|
||||
<input
|
||||
:value="wecomSystemSettings.employee_id_source"
|
||||
readonly
|
||||
class="input-field bg-surface-soft"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 block text-xs text-muted">{{ t('admin.wecom.sync.departmentId') }}</label>
|
||||
<input
|
||||
v-model="departmentId"
|
||||
:placeholder="t('admin.wecom.sync.departmentIdPlaceholder')"
|
||||
class="input-field"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" class="btn-secondary inline-flex items-center gap-2" :disabled="isSyncing" @click="previewSync">
|
||||
<RefreshCw class="w-4 h-4" :class="{ 'animate-spin': isSyncing }" />
|
||||
{{ t('admin.wecom.sync.preview') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="isSyncing || !previewSummary || (previewSummary.conflicts?.length || 0) > 0 || (previewSummary.would_update || 0) <= 0"
|
||||
@click="requestApplySync"
|
||||
>
|
||||
{{ t('admin.wecom.sync.apply') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="previewSummary" class="rounded-xl border border-subtle bg-surface-soft p-4 space-y-3 text-sm">
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-3">
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.stats.wecomUsers') }}</div>
|
||||
<div class="font-semibold text-primary">{{ previewSummary.wecom_users }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs text-muted">{{ t('admin.wecom.sync.stats.localMatched') }}</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 v-if="previewSummary.pending_updates?.length" class="overflow-x-auto">
|
||||
<table class="admin-table min-w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.employeeId') }}</th>
|
||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.user') }}</th>
|
||||
<th class="px-3 py-2 text-xs">{{ t('admin.wecom.headers.wecomUserId') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="row in previewSummary.pending_updates" :key="`${row.employee_id}-${row.wecom_userid}`">
|
||||
<td class="px-3 py-2 text-xs">{{ row.employee_id }}</td>
|
||||
<td class="px-3 py-2 text-xs">{{ row.username }}</td>
|
||||
<td class="px-3 py-2 text-xs font-mono">{{ row.wecom_userid }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p v-if="previewSummary.would_update > previewSummary.pending_updates.length" class="mt-2 text-xs text-muted">
|
||||
{{ t('admin.wecom.sync.previewTruncated', { total: previewSummary.would_update }) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="previewSummary.conflicts?.length" class="space-y-2">
|
||||
<div class="text-xs font-medium text-red-700">{{ t('admin.wecom.sync.conflictsTitle') }}</div>
|
||||
<div
|
||||
v-for="(conflict, idx) in previewSummary.conflicts"
|
||||
:key="idx"
|
||||
class="rounded-lg border border-red-100 bg-red-50 px-3 py-2 text-xs text-red-800"
|
||||
>
|
||||
{{ conflict.employee_id }} / {{ conflict.username }}
|
||||
<span v-if="conflict.old_wecom_userid"> · {{ conflict.old_wecom_userid }} → {{ conflict.new_wecom_userid }}</span>
|
||||
<span v-else-if="conflict.occupied_by_username"> · {{ t('admin.wecom.sync.occupiedBy', { user: conflict.occupied_by_username }) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showApplyConfirm"
|
||||
:message="t('admin.wecom.sync.applyConfirm', { count: previewSummary?.would_update || 0 })"
|
||||
@confirm="confirmApplySync"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -40,6 +40,13 @@ export function useWecomAdmin() {
|
||||
const isSaving = ref(false);
|
||||
|
||||
const wecomBindings = ref<WecomBindingRow[]>([]);
|
||||
const wecomBindingsKeyword = ref('');
|
||||
const wecomBindingsPage = ref(1);
|
||||
const wecomBindingsPageSize = ref(20);
|
||||
const wecomBindingsTotal = ref(0);
|
||||
const wecomBindingsPages = ref(1);
|
||||
const wecomBindingsPageSizeOptions = [10, 20, 50, 100] as const;
|
||||
let wecomBindingsSearchTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
const wecomLoginAudits = ref<WecomLoginAuditRow[]>([]);
|
||||
const wecomBindForm = ref({
|
||||
user_id: '' as string | number,
|
||||
@@ -112,14 +119,44 @@ export function useWecomAdmin() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 拉取绑定列表(服务端分页 + keyword 搜索)。
|
||||
* 核心逻辑:调用 listAdminWecomBindings,写回 items 与分页元数据。
|
||||
*/
|
||||
const loadWecomBindings = async (): Promise<void> => {
|
||||
try {
|
||||
wecomBindings.value = await listAdminWecomBindings(wecomBoundOnly.value);
|
||||
const data = await listAdminWecomBindings({
|
||||
boundOnly: wecomBoundOnly.value,
|
||||
keyword: wecomBindingsKeyword.value,
|
||||
page: wecomBindingsPage.value,
|
||||
pageSize: wecomBindingsPageSize.value,
|
||||
});
|
||||
wecomBindings.value = data.items;
|
||||
wecomBindingsTotal.value = data.total;
|
||||
wecomBindingsPage.value = data.page;
|
||||
wecomBindingsPages.value = data.pages;
|
||||
} catch (e) {
|
||||
console.error('Error loading WeCom bindings:', e);
|
||||
wecomBindings.value = [];
|
||||
wecomBindingsTotal.value = 0;
|
||||
wecomBindingsPages.value = 1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 重置页码并刷新绑定列表;若页码已是 1 则直接请求。
|
||||
* @param resetPage - 为 true 时将 page 置 1
|
||||
*/
|
||||
const scheduleLoadWecomBindings = (resetPage = false): void => {
|
||||
if (resetPage) {
|
||||
if (wecomBindingsPage.value !== 1) {
|
||||
wecomBindingsPage.value = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
void loadWecomBindings();
|
||||
};
|
||||
|
||||
const loadWecomAudits = async (): Promise<void> => {
|
||||
try {
|
||||
const params = new URLSearchParams({ limit: '200' });
|
||||
@@ -409,9 +446,24 @@ export function useWecomAdmin() {
|
||||
};
|
||||
|
||||
watch(wecomBoundOnly, () => {
|
||||
scheduleLoadWecomBindings(true);
|
||||
});
|
||||
|
||||
watch(wecomBindingsPage, () => {
|
||||
void loadWecomBindings();
|
||||
});
|
||||
|
||||
watch(wecomBindingsPageSize, () => {
|
||||
scheduleLoadWecomBindings(true);
|
||||
});
|
||||
|
||||
watch(wecomBindingsKeyword, () => {
|
||||
if (wecomBindingsSearchTimer) clearTimeout(wecomBindingsSearchTimer);
|
||||
wecomBindingsSearchTimer = setTimeout(() => {
|
||||
scheduleLoadWecomBindings(true);
|
||||
}, 300);
|
||||
});
|
||||
|
||||
watch([wecomAuditSourceFilter, wecomAuditStatusFilter], () => {
|
||||
void loadWecomAudits();
|
||||
});
|
||||
@@ -420,6 +472,12 @@ export function useWecomAdmin() {
|
||||
isLoading,
|
||||
isSaving,
|
||||
wecomBindings,
|
||||
wecomBindingsKeyword,
|
||||
wecomBindingsPage,
|
||||
wecomBindingsPageSize,
|
||||
wecomBindingsTotal,
|
||||
wecomBindingsPages,
|
||||
wecomBindingsPageSizeOptions,
|
||||
wecomLoginAudits,
|
||||
wecomBindForm,
|
||||
wecomBindUserQuery,
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* features/admin/modules/wecom/composables/useWecomSync.ts
|
||||
* 企微通讯录 userid 同步:预览 dry-run 与确认写入。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { syncAdminWecomUserids } from '@/features/admin/api/admin.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { WecomSyncSummary } from '@/features/admin/types/wecom.types';
|
||||
|
||||
export function useWecomSync(options?: { onApplied?: () => void | Promise<void> }) {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const departmentId = ref('');
|
||||
const isSyncing = ref(false);
|
||||
const previewSummary = ref<WecomSyncSummary | null>(null);
|
||||
const showApplyConfirm = ref(false);
|
||||
|
||||
/**
|
||||
* 解析可选部门 ID;空字符串表示同步全部部门。
|
||||
* @returns number | null 合法值;false 表示格式非法
|
||||
*/
|
||||
const parseDepartmentId = (): number | null | false => {
|
||||
const raw = departmentId.value.trim();
|
||||
if (!raw) return null;
|
||||
const parsed = Number(raw);
|
||||
if (!Number.isInteger(parsed) || parsed <= 0) {
|
||||
return false;
|
||||
}
|
||||
return parsed;
|
||||
};
|
||||
|
||||
/**
|
||||
* 预览同步结果(dry-run,不写库)。
|
||||
*/
|
||||
const previewSync = async (): Promise<void> => {
|
||||
const deptId = parseDepartmentId();
|
||||
if (deptId === false) {
|
||||
msg.warning(t('admin.wecom.sync.invalidDepartmentId'));
|
||||
return;
|
||||
}
|
||||
isSyncing.value = true;
|
||||
try {
|
||||
previewSummary.value = await syncAdminWecomUserids({ apply: false, department_id: deptId });
|
||||
msg.success(t('admin.wecom.sync.previewDone'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.wecom.sync.previewFailed'));
|
||||
} finally {
|
||||
isSyncing.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开确认写入对话框;需先预览且无冲突。
|
||||
*/
|
||||
const requestApplySync = (): void => {
|
||||
if (!previewSummary.value) {
|
||||
msg.warning(t('admin.wecom.sync.previewFirst'));
|
||||
return;
|
||||
}
|
||||
if ((previewSummary.value.conflicts || []).length > 0) {
|
||||
msg.warning(t('admin.wecom.sync.conflictsBlockApply'));
|
||||
return;
|
||||
}
|
||||
if ((previewSummary.value.would_update || 0) <= 0) {
|
||||
msg.info(t('admin.wecom.sync.nothingToUpdate'));
|
||||
return;
|
||||
}
|
||||
showApplyConfirm.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 确认后将预览结果写入数据库。
|
||||
*/
|
||||
const confirmApplySync = async (): Promise<void> => {
|
||||
const deptId = parseDepartmentId();
|
||||
if (deptId === false) {
|
||||
msg.warning(t('admin.wecom.sync.invalidDepartmentId'));
|
||||
return;
|
||||
}
|
||||
isSyncing.value = true;
|
||||
try {
|
||||
const summary = await syncAdminWecomUserids({ apply: true, department_id: deptId });
|
||||
previewSummary.value = summary;
|
||||
showApplyConfirm.value = false;
|
||||
msg.success(t('admin.wecom.sync.applyDone', { count: summary.updated || 0 }));
|
||||
await options?.onApplied?.();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.wecom.sync.applyFailed'));
|
||||
} finally {
|
||||
isSyncing.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
departmentId,
|
||||
isSyncing,
|
||||
previewSummary,
|
||||
showApplyConfirm,
|
||||
previewSync,
|
||||
requestApplySync,
|
||||
confirmApplySync,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/pages/WecomAuditsPage.vue
|
||||
* 企微与密码登录审计列表。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download } from 'lucide-vue-next';
|
||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const {
|
||||
wecomAuditSourceFilter,
|
||||
wecomAuditStatusFilter,
|
||||
filteredWecomLoginAudits,
|
||||
exportWecomAudits,
|
||||
getWecomAuditReasonText,
|
||||
getWecomAuditMetaText,
|
||||
} = inject(WECOM_ADMIN_KEY)!;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="admin-table-section">
|
||||
<div class="admin-table-header admin-table-header--stacked px-5 py-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.auditTitle') }}</h3>
|
||||
<div class="flex w-full md:w-auto flex-wrap md:flex-nowrap items-center justify-start md:justify-end gap-2">
|
||||
<select v-model="wecomAuditSourceFilter" class="admin-table-filter-input h-11 min-w-[112px] shrink-0">
|
||||
<option value="all">{{ t('admin.wecom.filters.allSources') }}</option>
|
||||
<option value="wecom">{{ t('admin.wecom.sources.wecom') }}</option>
|
||||
<option value="password">{{ t('admin.wecom.sources.password') }}</option>
|
||||
</select>
|
||||
<select v-model="wecomAuditStatusFilter" class="admin-table-filter-input h-11 min-w-[112px] shrink-0">
|
||||
<option value="all">{{ t('admin.wecom.filters.allStatus') }}</option>
|
||||
<option value="success">{{ t('admin.wecom.auditStatus.success') }}</option>
|
||||
<option value="failed">{{ t('admin.wecom.auditStatus.failed') }}</option>
|
||||
</select>
|
||||
<button type="button" class="btn-secondary h-11 shrink-0 text-sm" @click="exportWecomAudits()">
|
||||
<Download class="w-4 h-4" />
|
||||
{{ t('admin.wecom.exportAudit') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-table-wrap max-h-[560px]">
|
||||
<table class="admin-table">
|
||||
<thead class="sticky top-0 z-10 admin-table-sticky-head">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.time') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.source') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.user') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.status') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.reason') }}</th>
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.auditHeaders.ip') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="filteredWecomLoginAudits.length === 0">
|
||||
<td colspan="6" class="px-4 admin-table-empty">{{ t('admin.wecom.noAuditData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in filteredWecomLoginAudits" :key="row.id">
|
||||
<td class="px-4 py-3 text-xs text-muted whitespace-nowrap">{{ row.created_at || '-' }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary">{{ t('admin.wecom.sources.' + row.source) }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary">{{ row.username || '-' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span
|
||||
class="inline-flex px-2 py-0.5 rounded-full text-[11px] font-medium"
|
||||
:class="row.status === 'success' ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700'"
|
||||
>
|
||||
{{ t('admin.wecom.auditStatus.' + row.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-muted max-w-[360px] align-top">
|
||||
<div class="max-w-[360px] whitespace-normal break-words">
|
||||
<div class="text-xs text-secondary leading-5">{{ getWecomAuditReasonText(row) }}</div>
|
||||
<div v-if="getWecomAuditMetaText(row)" class="mt-1 text-[11px] text-muted leading-5" :title="getWecomAuditMetaText(row)">
|
||||
{{ getWecomAuditMetaText(row) }}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-muted font-mono">{{ row.ip || '-' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,300 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
/**
|
||||
|
||||
* features/admin/modules/wecom/pages/WecomBindingsPage.vue
|
||||
|
||||
* 企微快速绑定与绑定列表(搜索 + 服务端分页)。
|
||||
|
||||
* 依赖:WECOM_ADMIN_KEY、PaginationBar、lucide-vue-next。
|
||||
|
||||
* 逻辑:inject 父级 useWecomAdmin 状态;列表区复用 PaginationBar。
|
||||
|
||||
*/
|
||||
|
||||
import { inject } from 'vue';
|
||||
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { Link2, Search, Unlink2 } from 'lucide-vue-next';
|
||||
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
|
||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||
|
||||
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
|
||||
wecomBindUserQuery,
|
||||
|
||||
wecomBindUserDropdownOpen,
|
||||
|
||||
wecomBindUserOptions,
|
||||
|
||||
wecomBindForm,
|
||||
|
||||
isSaving,
|
||||
|
||||
wecomBoundOnly,
|
||||
|
||||
wecomBindings,
|
||||
|
||||
wecomBindingsKeyword,
|
||||
|
||||
wecomBindingsPage,
|
||||
|
||||
wecomBindingsPageSize,
|
||||
|
||||
wecomBindingsTotal,
|
||||
|
||||
wecomBindingsPages,
|
||||
|
||||
wecomBindingsPageSizeOptions,
|
||||
|
||||
selectWecomBindUser,
|
||||
|
||||
scheduleCloseWecomBindUserDropdown,
|
||||
|
||||
bindWecomUser,
|
||||
|
||||
unbindWecomUserByAdmin,
|
||||
|
||||
} = inject(WECOM_ADMIN_KEY)!;
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<div class="space-y-6">
|
||||
|
||||
<p class="text-sm text-muted">{{ t('admin.wecom.bindingsHint') }}</p>
|
||||
|
||||
|
||||
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.quickBind') }}</h3>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-3">
|
||||
|
||||
<div class="relative md:col-span-1">
|
||||
|
||||
<input
|
||||
|
||||
v-model="wecomBindUserQuery"
|
||||
|
||||
type="text"
|
||||
|
||||
class="input-field"
|
||||
|
||||
:placeholder="t('admin.wecom.fields.userSelect')"
|
||||
|
||||
@focus="wecomBindUserDropdownOpen = true"
|
||||
|
||||
@input="wecomBindUserDropdownOpen = true"
|
||||
|
||||
@blur="scheduleCloseWecomBindUserDropdown()"
|
||||
|
||||
/>
|
||||
|
||||
<div v-if="wecomBindUserDropdownOpen" class="admin-dropdown w-72">
|
||||
|
||||
<button
|
||||
|
||||
v-for="u in wecomBindUserOptions"
|
||||
|
||||
:key="u.id"
|
||||
|
||||
type="button"
|
||||
|
||||
class="flex w-full items-center justify-between gap-3 px-3 py-2 text-left hover:bg-blue-50"
|
||||
|
||||
@mousedown.prevent="selectWecomBindUser(u.id, u.label)"
|
||||
|
||||
>
|
||||
|
||||
<span class="text-sm text-primary">{{ u.label }}</span>
|
||||
|
||||
<span class="text-xs text-muted">{{ u.employeeId || '' }}</span>
|
||||
|
||||
</button>
|
||||
|
||||
<div v-if="wecomBindUserOptions.length === 0" class="px-3 py-2 text-sm text-muted">
|
||||
|
||||
{{ t('admin.wecom.noData') }}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<input v-model="wecomBindForm.wecom_userid" :placeholder="t('admin.wecom.fields.wecomUserId')" class="input-field md:col-span-2" />
|
||||
|
||||
<input v-model="wecomBindForm.wecom_unionid" :placeholder="t('admin.wecom.fields.wecomUnionId')" class="input-field" />
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end">
|
||||
|
||||
<button type="button" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60" @click="bindWecomUser()">
|
||||
|
||||
<Link2 class="w-4 h-4" /> {{ t('admin.wecom.bind') }}
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="admin-table-section space-y-0">
|
||||
|
||||
<div class="admin-table-header px-5 py-4 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.bindingList') }}</h3>
|
||||
|
||||
<div class="flex flex-col gap-3 sm:flex-row sm:items-center">
|
||||
|
||||
<div class="relative min-w-[240px]">
|
||||
|
||||
<Search class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted" />
|
||||
|
||||
<input
|
||||
|
||||
v-model="wecomBindingsKeyword"
|
||||
|
||||
type="search"
|
||||
|
||||
class="input-field pl-9"
|
||||
|
||||
:placeholder="t('admin.wecom.searchBindings')"
|
||||
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary whitespace-nowrap">
|
||||
|
||||
<input v-model="wecomBoundOnly" type="checkbox" class="w-4 h-4 rounded text-brand-600 border-default" />
|
||||
|
||||
{{ t('admin.wecom.boundOnly') }}
|
||||
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
|
||||
<table class="admin-table">
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.user') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.employeeId') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.roleStatus') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.wecomUserId') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs">{{ t('admin.wecom.headers.unionId') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-xs text-right">{{ t('admin.wecom.headers.actions') }}</th>
|
||||
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
<tr v-if="wecomBindings.length === 0">
|
||||
|
||||
<td colspan="6" class="px-4 admin-table-empty">{{ t('admin.wecom.noData') }}</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr v-for="u in wecomBindings" :key="u.id">
|
||||
|
||||
<td class="px-4 py-3">
|
||||
|
||||
<div class="text-sm font-medium text-primary">{{ u.username }} <span class="text-muted">(#{{ u.id }})</span></div>
|
||||
|
||||
<div class="text-xs text-muted">{{ u.real_name || '-' }} · {{ u.email }}</div>
|
||||
|
||||
</td>
|
||||
|
||||
<td class="px-4 py-3 text-sm text-secondary font-mono">{{ u.employee_id || '-' }}</td>
|
||||
|
||||
<td class="px-4 py-3 text-sm text-secondary">{{ t('admin.role.' + u.role) }} / {{ t('admin.status.' + u.status) }}</td>
|
||||
|
||||
<td class="px-4 py-3 text-sm text-secondary font-mono">{{ u.wecom_userid || '-' }}</td>
|
||||
|
||||
<td class="px-4 py-3 text-sm text-secondary font-mono">{{ u.wecom_unionid || '-' }}</td>
|
||||
|
||||
<td class="px-4 py-3 text-right">
|
||||
|
||||
<button
|
||||
|
||||
v-if="u.wecom_userid"
|
||||
|
||||
type="button"
|
||||
|
||||
class="inline-flex items-center gap-1 px-3 py-1.5 text-xs text-red-600 bg-red-50 rounded-lg hover:bg-red-100"
|
||||
|
||||
@click="unbindWecomUserByAdmin(u.id)"
|
||||
|
||||
>
|
||||
|
||||
<Unlink2 class="w-3.5 h-3.5" />
|
||||
|
||||
{{ t('admin.wecom.unbind') }}
|
||||
|
||||
</button>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="px-4 pb-4 pt-2">
|
||||
|
||||
<PaginationBar
|
||||
|
||||
v-model:page="wecomBindingsPage"
|
||||
|
||||
v-model:page-size="wecomBindingsPageSize"
|
||||
|
||||
:total="wecomBindingsTotal"
|
||||
|
||||
:pages="wecomBindingsPages"
|
||||
|
||||
:page-size-options="[...wecomBindingsPageSizeOptions]"
|
||||
|
||||
:visible="wecomBindingsTotal > 0 || !!wecomBindingsKeyword.trim()"
|
||||
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/admin/modules/wecom/pages/WecomSettingsPage.vue
|
||||
* 企微系统配置、通讯录同步、通知与集成复制。
|
||||
*/
|
||||
import { inject, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { CircleHelp } from 'lucide-vue-next';
|
||||
import WecomOverviewCards from '../components/WecomOverviewCards.vue';
|
||||
import WecomSyncPanel from '../components/WecomSyncPanel.vue';
|
||||
import { WECOM_ADMIN_KEY } from '../wecom.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const {
|
||||
wecomSystemSettings,
|
||||
isSaving,
|
||||
wecomNotifySettings,
|
||||
wecomNotifyEventsText,
|
||||
wecomNotifyMetrics,
|
||||
wecomIntegrationManifest,
|
||||
generateWecomAddressesFromPublicBase,
|
||||
generateWecomCallbackToken,
|
||||
generateWecomEncodingAesKey,
|
||||
saveWecomSystemSettings,
|
||||
saveWecomNotifySettings,
|
||||
copyText,
|
||||
} = inject(WECOM_ADMIN_KEY)!;
|
||||
const overviewRefreshKey = ref(0);
|
||||
|
||||
const onSyncApplied = (): void => {
|
||||
overviewRefreshKey.value += 1;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-6">
|
||||
<WecomOverviewCards :refresh-key="overviewRefreshKey" />
|
||||
<WecomSyncPanel @applied="onSyncApplied" />
|
||||
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.systemSettings') }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomSystemSettings.enabled" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.enabled') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.enabled')" />
|
||||
</label>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomSystemSettings.auto_create_user" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.autoCreateUser') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.autoCreateUser')" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.corpId') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.corpId')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.corp_id" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.agentId') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.agentId')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.agent_id" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.secret') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.secret')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.secret" type="password" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.redirectUri') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.redirectUri')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.redirect_uri" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.publicBaseUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.publicBaseUrl')" />
|
||||
</label>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<input
|
||||
v-model="wecomSystemSettings.public_base_url"
|
||||
:placeholder="t('admin.wecom.publicBasePlaceholder')"
|
||||
class="input-field flex-1 min-w-[200px]"
|
||||
/>
|
||||
<button type="button" class="btn-secondary px-4 shrink-0" @click="generateWecomAddressesFromPublicBase()">
|
||||
{{ t('admin.wecom.generateAddresses') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.callbackToken') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.callbackToken')" />
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<input v-model="wecomSystemSettings.callback_token" class="input-field flex-1 min-w-0" />
|
||||
<button type="button" class="btn-secondary px-3 shrink-0 text-xs" @click="generateWecomCallbackToken()">
|
||||
{{ t('admin.wecom.generateToken') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.encodingAesKey') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.encodingAesKey')" />
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<input v-model="wecomSystemSettings.encoding_aes_key" class="input-field flex-1 min-w-0 font-mono text-xs" />
|
||||
<button type="button" class="btn-secondary px-3 shrink-0 text-xs" @click="generateWecomEncodingAesKey()">
|
||||
{{ t('admin.wecom.generateEncodingKey') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.callbackUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.callbackUrl')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.callback_url" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.homepageUrl') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.homepageUrl')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.homepage_url" class="input-field" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.trustedDomain') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.trustedDomain')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.trusted_domain" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.matchRules') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.matchRules')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.match_rules" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.matchOperator') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.matchOperator')" />
|
||||
</label>
|
||||
<select v-model="wecomSystemSettings.match_operator" class="input-field">
|
||||
<option value="AND">AND</option>
|
||||
<option value="OR">OR</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.firstLoginBindMode') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.firstLoginBindMode')" />
|
||||
</label>
|
||||
<select v-model="wecomSystemSettings.first_login_bind_mode" class="input-field">
|
||||
<option value="match_rules">{{ t('admin.wecom.bindModes.match_rules') }}</option>
|
||||
<option value="input_verify">{{ t('admin.wecom.bindModes.input_verify') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.firstLoginInputFields') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.firstLoginInputFields')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.first_login_input_fields" class="input-field" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1.5 inline-flex items-center gap-1 text-xs text-muted">
|
||||
{{ t('admin.wecom.fields.employeeIdSource') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.employeeIdSource')" />
|
||||
</label>
|
||||
<input v-model="wecomSystemSettings.employee_id_source" class="input-field" />
|
||||
</div>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary pt-7">
|
||||
<input v-model="wecomSystemSettings.mobile_normalize" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.fields.mobileNormalize') }}
|
||||
<CircleHelp class="w-3.5 h-3.5 text-muted" :title="t('admin.wecom.tips.mobileNormalize')" />
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="button" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60" @click="saveWecomSystemSettings()">
|
||||
{{ t('admin.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.notifySettings') }}</h3>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary">
|
||||
<input v-model="wecomNotifySettings.enabled" type="checkbox" class="admin-checkbox" />
|
||||
{{ t('admin.wecom.notifyEnabled') }}
|
||||
</label>
|
||||
<input v-model="wecomNotifySettings.base_url" :placeholder="t('admin.wecom.notifyBaseUrl')" class="input-field" />
|
||||
<input v-model="wecomNotifyEventsText" :placeholder="t('admin.wecom.notifyEvents')" class="input-field" />
|
||||
<div class="flex justify-end">
|
||||
<button type="button" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60" @click="saveWecomNotifySettings()">
|
||||
{{ t('admin.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-primary">{{ t('admin.wecom.notifyMetrics') }}</h3>
|
||||
<div v-if="wecomNotifyMetrics" class="grid grid-cols-2 gap-3 text-sm">
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricTotal') }}</div>
|
||||
<div class="text-lg font-semibold text-primary">{{ wecomNotifyMetrics.total }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricSuccessRate') }}</div>
|
||||
<div class="text-lg font-semibold text-emerald-700">{{ wecomNotifyMetrics.send_success_rate }}%</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricOpenedRate') }}</div>
|
||||
<div class="text-lg font-semibold text-blue-700">{{ wecomNotifyMetrics.opened_24h_rate }}%</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft px-3 py-2">
|
||||
<div class="text-muted">{{ t('admin.wecom.metricWindowDays') }}</div>
|
||||
<div class="text-lg font-semibold text-primary">{{ wecomNotifyMetrics.window_days }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<details class="card shadow-sm p-5">
|
||||
<summary class="cursor-pointer font-semibold text-primary">{{ t('admin.wecom.integrationCopyTitle') }}</summary>
|
||||
<div class="mt-4 space-y-4">
|
||||
<p class="text-xs text-muted">{{ t('admin.wecom.integrationCopyDesc') }}</p>
|
||||
<p class="text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded-lg px-3 py-2">{{ t('admin.wecom.integrationCopySecretsNote') }}</p>
|
||||
<div v-if="wecomIntegrationManifest" class="grid grid-cols-1 gap-3">
|
||||
<div
|
||||
v-for="item in [
|
||||
{ key: 'public_base_url', label: t('admin.wecom.copyFields.publicBaseUrl') },
|
||||
{ key: 'callback_url', label: t('admin.wecom.copyFields.callbackUrl') },
|
||||
{ key: 'callback_token', label: t('admin.wecom.copyFields.callbackToken') },
|
||||
{ key: 'encoding_aes_key', label: t('admin.wecom.copyFields.encodingAesKey') },
|
||||
{ key: 'oauth_redirect_uri', label: t('admin.wecom.copyFields.oauthRedirectUri') },
|
||||
{ key: 'homepage_url', label: t('admin.wecom.copyFields.homepageUrl') },
|
||||
{ key: 'trusted_domain', label: t('admin.wecom.copyFields.trustedDomain') },
|
||||
{ key: 'authorize_api', label: t('admin.wecom.copyFields.authorizeApi') },
|
||||
{ key: 'login_api', label: t('admin.wecom.copyFields.loginApi') },
|
||||
]"
|
||||
:key="item.key"
|
||||
>
|
||||
<label class="mb-1.5 block text-xs text-muted">{{ item.label }}</label>
|
||||
<div class="flex gap-2">
|
||||
<input :value="(wecomIntegrationManifest as any)[item.key] || ''" readonly class="input-field flex-1 bg-surface-soft font-mono text-xs" />
|
||||
<button type="button" class="btn-secondary px-3" @click="copyText(String((wecomIntegrationManifest as any)[item.key] || ''))">
|
||||
{{ t('admin.wecom.copy') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* features/admin/modules/wecom/wecom.context.ts
|
||||
* 企微管理子页面共享 context key。
|
||||
*/
|
||||
import type { InjectionKey } from 'vue';
|
||||
import type { useWecomAdmin } from './composables/useWecomAdmin';
|
||||
|
||||
export type WecomAdminContext = ReturnType<typeof useWecomAdmin>;
|
||||
|
||||
export const WECOM_ADMIN_KEY: InjectionKey<WecomAdminContext> = Symbol('wecomAdmin');
|
||||
@@ -16,6 +16,7 @@ const BADGE_CACHE_TTL_MS = 60_000;
|
||||
export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
const sidebarCollapsed = ref(false);
|
||||
const reportsExpanded = ref(true);
|
||||
const wecomExpanded = ref(true);
|
||||
/** 「用户审批」导航角标:pending 注册用户数 */
|
||||
const pendingApprovalsCount = ref(0);
|
||||
/** 「权限申请」导航角标:pending 权限申请数 */
|
||||
@@ -83,6 +84,7 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
return {
|
||||
sidebarCollapsed,
|
||||
reportsExpanded,
|
||||
wecomExpanded,
|
||||
pendingApprovalsCount,
|
||||
pendingRequestsCount,
|
||||
toggleSidebar,
|
||||
|
||||
@@ -7,6 +7,7 @@ export interface WecomBindingRow {
|
||||
id: number;
|
||||
username: string;
|
||||
real_name?: string;
|
||||
employee_id?: string | null;
|
||||
email: string;
|
||||
role: string;
|
||||
status: string;
|
||||
@@ -82,6 +83,45 @@ export interface WecomIntegrationManifest {
|
||||
login_api: string;
|
||||
}
|
||||
|
||||
export interface WecomBindingStats {
|
||||
total_active: number;
|
||||
bound: number;
|
||||
unbound: number;
|
||||
bound_rate: number;
|
||||
}
|
||||
|
||||
export interface WecomSyncConflict {
|
||||
employee_id?: string;
|
||||
username?: string;
|
||||
old_wecom_userid?: string;
|
||||
new_wecom_userid?: string;
|
||||
occupied_by_user_id?: number;
|
||||
occupied_by_username?: string;
|
||||
}
|
||||
|
||||
export interface WecomSyncPendingUpdate {
|
||||
employee_id: string;
|
||||
username: string;
|
||||
wecom_userid: string;
|
||||
name?: string | null;
|
||||
}
|
||||
|
||||
export interface WecomSyncSummary {
|
||||
apply: boolean;
|
||||
employee_id_source: string;
|
||||
department_ids: number[];
|
||||
wecom_users: number;
|
||||
wecom_without_employee_id: number;
|
||||
local_matched: number;
|
||||
would_update: number;
|
||||
updated: number;
|
||||
already_bound: number;
|
||||
local_missing: number;
|
||||
conflicts: WecomSyncConflict[];
|
||||
missing_samples: Array<{ wecom_userid?: string | null; name?: string | null }>;
|
||||
pending_updates: WecomSyncPendingUpdate[];
|
||||
}
|
||||
|
||||
export const createDefaultWecomSystemSettings = (): WecomSystemSettings => ({
|
||||
enabled: true,
|
||||
corp_id: '',
|
||||
|
||||
@@ -35,6 +35,13 @@ export const submitLeaveWorkflow = (form: Record<string, any>) =>
|
||||
body: JSON.stringify(form),
|
||||
});
|
||||
|
||||
export const resetPasswordByWecom = (employeeId: string, username: string) =>
|
||||
requestJson('/api/user/reset-password-by-wecom', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ employee_id: employeeId, username }),
|
||||
});
|
||||
|
||||
export const resetPasswordConfirm = (token: string, newPassword: string) =>
|
||||
requestJson('/api/user/reset-password-confirm', {
|
||||
method: 'POST',
|
||||
|
||||
@@ -1,24 +1,45 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/auth/components/LoginModals.vue
|
||||
* 登录相关弹窗:找回密码、公告详情、企微登录/绑定提示、注册。
|
||||
* 用途:登录相关弹窗(找回密码、公告、企微提示、注册)。
|
||||
* 依赖:login.context、useDialogBackdropClose、wecom 工具函数。
|
||||
* 逻辑:LoginPage 注入 LOGIN_KEY;遮罩关闭用 pointer 判定避免拖选误关。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Lock, User, X } from 'lucide-vue-next';
|
||||
import { formatWecomFieldLabel } from '@/shared/utils/wecom';
|
||||
import { createDialogBackdropCloseHandler } from '@/shared/composables/useDialogBackdropClose';
|
||||
import { LOGIN_KEY } from '../composables/login.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
const lk = inject(LOGIN_KEY)! as any;
|
||||
|
||||
const forgotPasswordBackdrop = createDialogBackdropCloseHandler(() => {
|
||||
lk.showForgotPasswordModal = false;
|
||||
});
|
||||
const announcementBackdrop = createDialogBackdropCloseHandler(() => {
|
||||
lk.showAnnouncementModal = false;
|
||||
});
|
||||
const wecomLoginBackdrop = createDialogBackdropCloseHandler(() => {
|
||||
lk.wecomLoginDialog = null;
|
||||
});
|
||||
const wecomBindBackdrop = createDialogBackdropCloseHandler(() => {
|
||||
lk.wecomBindPrompt = null;
|
||||
});
|
||||
const registerBackdrop = createDialogBackdropCloseHandler(() => {
|
||||
lk.showRegisterModal = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div
|
||||
v-if="lk.showForgotPasswordModal"
|
||||
class="dialog-overlay z-50 items-center animate-fade-in"
|
||||
@click.self="lk.showForgotPasswordModal = false"
|
||||
@pointerdown.self="forgotPasswordBackdrop.onBackdropPointerDown"
|
||||
@pointerup.self="forgotPasswordBackdrop.onBackdropPointerUp"
|
||||
>
|
||||
<div class="dialog-panel max-w-md animate-slide-up">
|
||||
<div class="dialog-header dialog-header--compact relative border-0 pb-0">
|
||||
@@ -33,9 +54,15 @@ const lk = inject(LOGIN_KEY)! as any;
|
||||
</div>
|
||||
<h3 class="text-xl font-bold text-primary">{{ $t('login.forgotPassword') }}</h3>
|
||||
<p class="mt-2 text-sm text-muted">{{ $t('login.forgotPasswordDesc') }}</p>
|
||||
<div class="mt-6 space-y-2 text-left">
|
||||
<label class="label-field ml-1">{{ $t('register.email') }}</label>
|
||||
<input v-model="lk.forgotPasswordForm.email" :placeholder="$t('register.email')" class="input-field" @keyup.enter="lk.handleForgotPassword" />
|
||||
<div class="mt-6 space-y-4 text-left">
|
||||
<div class="space-y-2">
|
||||
<label class="label-field ml-1">{{ $t('register.fields.employeeId') }}</label>
|
||||
<input v-model="lk.forgotPasswordForm.employee_id" :placeholder="$t('register.fields.employeeId')" class="input-field" @keyup.enter="lk.handleForgotPassword" />
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="label-field ml-1">{{ $t('login.username') }}</label>
|
||||
<input v-model="lk.forgotPasswordForm.username" :placeholder="$t('login.placeholder.username')" class="input-field" @keyup.enter="lk.handleForgotPassword" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
@@ -48,7 +75,8 @@ const lk = inject(LOGIN_KEY)! as any;
|
||||
<div
|
||||
v-if="lk.showAnnouncementModal && lk.selectedAnnouncement"
|
||||
class="dialog-overlay z-50 items-center animate-fade-in"
|
||||
@click.self="lk.showAnnouncementModal = false"
|
||||
@pointerdown.self="announcementBackdrop.onBackdropPointerDown"
|
||||
@pointerup.self="announcementBackdrop.onBackdropPointerUp"
|
||||
>
|
||||
<div class="dialog-panel max-w-2xl max-h-[85vh] animate-slide-up">
|
||||
<div class="dialog-header">
|
||||
@@ -74,7 +102,8 @@ const lk = inject(LOGIN_KEY)! as any;
|
||||
<div
|
||||
v-if="lk.wecomLoginDialog"
|
||||
class="dialog-overlay z-50 items-center animate-fade-in"
|
||||
@click.self="lk.wecomLoginDialog = null"
|
||||
@pointerdown.self="wecomLoginBackdrop.onBackdropPointerDown"
|
||||
@pointerup.self="wecomLoginBackdrop.onBackdropPointerUp"
|
||||
>
|
||||
<div class="dialog-panel max-w-lg animate-slide-up">
|
||||
<div class="dialog-header dialog-header--compact">
|
||||
@@ -116,7 +145,8 @@ const lk = inject(LOGIN_KEY)! as any;
|
||||
<div
|
||||
v-if="lk.wecomBindPrompt"
|
||||
class="dialog-overlay z-50 items-center animate-fade-in"
|
||||
@click.self="lk.wecomBindPrompt = null"
|
||||
@pointerdown.self="wecomBindBackdrop.onBackdropPointerDown"
|
||||
@pointerup.self="wecomBindBackdrop.onBackdropPointerUp"
|
||||
>
|
||||
<div class="dialog-panel max-w-lg animate-slide-up">
|
||||
<div class="dialog-header dialog-header--compact">
|
||||
@@ -168,7 +198,8 @@ const lk = inject(LOGIN_KEY)! as any;
|
||||
<div
|
||||
v-if="lk.showRegisterModal"
|
||||
class="dialog-overlay z-50 items-center animate-fade-in"
|
||||
@click.self="lk.showRegisterModal = false"
|
||||
@pointerdown.self="registerBackdrop.onBackdropPointerDown"
|
||||
@pointerup.self="registerBackdrop.onBackdropPointerUp"
|
||||
>
|
||||
<div class="dialog-panel max-w-md animate-slide-up">
|
||||
<div class="dialog-header">
|
||||
|
||||
@@ -90,7 +90,7 @@ const lk = inject(LOGIN_KEY)! as any;
|
||||
</button>
|
||||
|
||||
<div class="flex justify-between items-center pt-4 mt-2 border-t border-subtle/50">
|
||||
<button type="button" @click="lk.showForgotPasswordModal = true" class="text-sm text-secondary hover:text-brand-700 transition-colors">
|
||||
<button type="button" @click="lk.openForgotPasswordModal" class="text-sm text-secondary hover:text-brand-700 transition-colors">
|
||||
{{ $t('login.forgotPassword') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -45,7 +45,7 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
employee_id: '',
|
||||
phone_number: '',
|
||||
});
|
||||
const forgotPasswordForm = ref({ email: '' });
|
||||
const forgotPasswordForm = ref({ employee_id: '', username: '' });
|
||||
const isWecomLoggingIn = ref(false);
|
||||
const wecomLoginDialog = ref<WecomLoginDialogContent | null>(null);
|
||||
const wecomBindPrompt = ref<WecomBindPromptState | null>(null);
|
||||
@@ -59,22 +59,43 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
saveAuthUser({ ...(user || {}) }, rememberMe.value);
|
||||
};
|
||||
|
||||
const openForgotPasswordModal = () => {
|
||||
forgotPasswordForm.value = {
|
||||
employee_id: '',
|
||||
username: loginUsername.value.trim(),
|
||||
};
|
||||
showForgotPasswordModal.value = true;
|
||||
};
|
||||
|
||||
const handleForgotPassword = async () => {
|
||||
if (!forgotPasswordForm.value.email) {
|
||||
msg.warning(t('register.emailRequired'));
|
||||
const employeeId = forgotPasswordForm.value.employee_id.trim();
|
||||
const username = forgotPasswordForm.value.username.trim();
|
||||
if (!employeeId) {
|
||||
msg.warning(t('login.employeeIdRequired'));
|
||||
return;
|
||||
}
|
||||
if (!username) {
|
||||
msg.warning(t('login.usernameRequired'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await requestJson('/api/user/reset-password-by-email', {
|
||||
await requestJson('/api/user/reset-password-by-wecom', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(forgotPasswordForm.value),
|
||||
body: JSON.stringify({ employee_id: employeeId, username }),
|
||||
});
|
||||
msg.success(t('login.passwordResetEmailSent'));
|
||||
msg.success(t('login.passwordResetWecomSent'));
|
||||
showForgotPasswordModal.value = false;
|
||||
forgotPasswordForm.value = { email: '' };
|
||||
forgotPasswordForm.value = { employee_id: '', username: '' };
|
||||
} catch (e) {
|
||||
console.error('Password reset error', e);
|
||||
if (e instanceof BusinessError && e.code === 'AUTH.PASSWORD_RESET_RATE_LIMITED') {
|
||||
const minutes =
|
||||
Number(e.details?.retry_after_minutes)
|
||||
|| Math.max(1, Math.ceil(Number(e.details?.retry_after_seconds || 300) / 60));
|
||||
msg.error(t('login.passwordResetRateLimited', { minutes }));
|
||||
return;
|
||||
}
|
||||
msg.error((e as Error)?.message || t('login.passwordResetRequestFailed'));
|
||||
}
|
||||
};
|
||||
@@ -375,6 +396,7 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
rememberMe,
|
||||
showRegisterModal,
|
||||
showForgotPasswordModal,
|
||||
openForgotPasswordModal,
|
||||
registerForm,
|
||||
forgotPasswordForm,
|
||||
isWecomLoggingIn,
|
||||
|
||||
@@ -8,6 +8,7 @@ export {
|
||||
getUserProfile,
|
||||
getLeaveBalance,
|
||||
submitLeaveWorkflow,
|
||||
resetPasswordByWecom,
|
||||
resetPasswordConfirm,
|
||||
getUserAgent,
|
||||
listUserAgents,
|
||||
|
||||
@@ -1,33 +1,87 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/auth/views/ResetPasswordView.vue
|
||||
* 邮件链接重置密码页(/reset-password?token=...)。
|
||||
* 企微 textcard / 邮件链接重置密码页(/reset-password?token=...)。
|
||||
* 依赖:user.api resetPasswordConfirm、vue-i18n、MinimalShell。
|
||||
* 逻辑:校验 token 与两次密码一致后调 confirm 接口,成功后跳转 /login。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Lock, AlertCircle, CheckCircle } from 'lucide-vue-next';
|
||||
import MinimalShell from '@/shared/layouts/MinimalShell.vue';
|
||||
import { resetPasswordConfirm } from '@/features/auth/api/user.api';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { resolveCasdoorErrorMessage } from '@/shared/utils/casdoor';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const token = ref(route.query.token as string || '');
|
||||
/**
|
||||
* 从路由 query 解析 reset token,兼容重复参数与首尾空白。
|
||||
* @returns 明文 token;缺失时返回空字符串
|
||||
*/
|
||||
function readResetTokenFromRoute(): string {
|
||||
const raw = route.query.token;
|
||||
const value = Array.isArray(raw) ? raw[0] : raw;
|
||||
return String(value || '').trim();
|
||||
}
|
||||
|
||||
const token = ref(readResetTokenFromRoute());
|
||||
const password = ref('');
|
||||
const confirmPassword = ref('');
|
||||
const isLoading = ref(false);
|
||||
const status = ref<'idle' | 'success' | 'error'>('idle');
|
||||
const message = ref('');
|
||||
|
||||
/**
|
||||
* 将后端/网络错误映射为页面可读文案。
|
||||
* @param err - 捕获的异常
|
||||
*/
|
||||
function resolveResetErrorMessage(err: unknown): string {
|
||||
if (err instanceof BusinessError) {
|
||||
if (err.code === 'AUTH.RESET_TOKEN_INVALID') {
|
||||
return t('resetPassword.tokenInvalid');
|
||||
}
|
||||
const raw = String(err.message || '').toLowerCase();
|
||||
if (
|
||||
err.code === 'VALIDATION.INVALID_PARAM'
|
||||
&& (raw.includes('invalid or expired token') || raw.includes('reset_token_invalid'))
|
||||
) {
|
||||
return t('resetPassword.tokenInvalid');
|
||||
}
|
||||
return resolveCasdoorErrorMessage(err, t) || err.message || t('resetPassword.failed');
|
||||
}
|
||||
return (err as Error)?.message || t('resetPassword.failed');
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (!token.value) {
|
||||
status.value = 'error';
|
||||
message.value = t('resetPassword.invalidLink');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 提交新密码并重置 token。
|
||||
* 核心逻辑:前端校验 → resetPasswordConfirm → 成功 3 秒后跳转登录页。
|
||||
*/
|
||||
const handleReset = async () => {
|
||||
if (!token.value) {
|
||||
status.value = 'error';
|
||||
message.value = t('resetPassword.invalidLink');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!password.value || !confirmPassword.value) {
|
||||
message.value = 'Please fill in all fields';
|
||||
message.value = t('resetPassword.fillAllFields');
|
||||
status.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.value !== confirmPassword.value) {
|
||||
message.value = 'Passwords do not match';
|
||||
message.value = t('resetPassword.passwordMismatch');
|
||||
status.value = 'error';
|
||||
return;
|
||||
}
|
||||
@@ -39,13 +93,13 @@ const handleReset = async () => {
|
||||
try {
|
||||
await resetPasswordConfirm(token.value, password.value);
|
||||
status.value = 'success';
|
||||
message.value = 'Password reset successfully! Redirecting to login...';
|
||||
message.value = t('resetPassword.successRedirect');
|
||||
setTimeout(() => {
|
||||
router.push('/');
|
||||
router.push('/login');
|
||||
}, 3000);
|
||||
} catch (e) {
|
||||
status.value = 'error';
|
||||
message.value = (e as Error).message || 'Failed to reset password';
|
||||
message.value = resolveResetErrorMessage(e);
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
@@ -58,8 +112,8 @@ const handleReset = async () => {
|
||||
<div class="w-12 h-12 bg-brand-100 rounded-xl mx-auto flex items-center justify-center text-brand-600 mb-4">
|
||||
<Lock class="w-6 h-6" />
|
||||
</div>
|
||||
<h2 class="page-title">Reset Password</h2>
|
||||
<p class="section-desc mt-2">Enter your new password below</p>
|
||||
<h2 class="page-title">{{ $t('resetPassword.title') }}</h2>
|
||||
<p class="section-desc mt-2">{{ $t('resetPassword.desc') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="status === 'success'" class="alert-ds alert-success mb-6">
|
||||
@@ -72,25 +126,37 @@ const handleReset = async () => {
|
||||
<div>{{ message }}</div>
|
||||
</div>
|
||||
|
||||
<form v-if="status !== 'success'" @submit.prevent="handleReset" class="space-y-5">
|
||||
<form v-if="status !== 'success' && token" @submit.prevent="handleReset" class="space-y-5">
|
||||
<div>
|
||||
<label class="label-field mb-1.5 block">New Password</label>
|
||||
<input v-model="password" type="password" class="input-field" placeholder="Enter new password" required />
|
||||
<label class="label-field mb-1.5 block">{{ $t('resetPassword.newPassword') }}</label>
|
||||
<input
|
||||
v-model="password"
|
||||
type="password"
|
||||
class="input-field"
|
||||
:placeholder="$t('resetPassword.newPasswordPlaceholder')"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="label-field mb-1.5 block">Confirm Password</label>
|
||||
<input v-model="confirmPassword" type="password" class="input-field" placeholder="Confirm new password" required />
|
||||
<label class="label-field mb-1.5 block">{{ $t('resetPassword.confirmPassword') }}</label>
|
||||
<input
|
||||
v-model="confirmPassword"
|
||||
type="password"
|
||||
class="input-field"
|
||||
:placeholder="$t('resetPassword.confirmPasswordPlaceholder')"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button type="submit" :disabled="isLoading" class="btn-primary w-full py-3 flex justify-center items-center gap-2">
|
||||
<div v-if="isLoading" class="animate-spin rounded-full h-4 w-4 border-2 border-white/30 border-t-white"></div>
|
||||
<span>{{ isLoading ? 'Resetting...' : 'Reset Password' }}</span>
|
||||
<span>{{ isLoading ? $t('resetPassword.submitting') : $t('resetPassword.submit') }}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="mt-6 text-center">
|
||||
<router-link to="/" class="text-sm font-medium text-muted hover:text-secondary">Back to Login</router-link>
|
||||
<router-link to="/login" class="text-sm font-medium text-muted hover:text-secondary">{{ $t('resetPassword.backToLogin') }}</router-link>
|
||||
</div>
|
||||
</MinimalShell>
|
||||
</template>
|
||||
@@ -237,8 +237,50 @@
|
||||
}
|
||||
},
|
||||
"wecom": {
|
||||
"title": "WeCom Binding Management",
|
||||
"subtitle": "Manually bind/unbind WeCom accounts and review login audit records",
|
||||
"title": "WeCom",
|
||||
"subtitle": "Configure WeCom integration, sync userids, manage bindings and login audits",
|
||||
"nav": {
|
||||
"settings": "Settings",
|
||||
"bindings": "Bindings",
|
||||
"audits": "Login Audits"
|
||||
},
|
||||
"overview": {
|
||||
"bound": "Bound userids",
|
||||
"unbound": "Unbound",
|
||||
"boundRate": "Bound rate",
|
||||
"hint": "Password reset",
|
||||
"hintDesc": "Users without wecom_userid cannot receive WeCom reset links"
|
||||
},
|
||||
"sync": {
|
||||
"title": "Directory Sync",
|
||||
"desc": "Pull WeCom members and backfill users.wecom_userid by employee ID for reset and notifications.",
|
||||
"permissionNote": "Requires contact read and message send permissions on the WeCom app.",
|
||||
"employeeIdSource": "Employee ID source",
|
||||
"departmentId": "Root department ID (optional)",
|
||||
"departmentIdPlaceholder": "Leave empty for all departments",
|
||||
"preview": "Preview sync",
|
||||
"apply": "Apply changes",
|
||||
"previewDone": "Preview completed. Review results before applying.",
|
||||
"previewFailed": "Preview sync failed",
|
||||
"previewFirst": "Please preview sync results first",
|
||||
"conflictsBlockApply": "Conflicts detected. Resolve them before applying.",
|
||||
"nothingToUpdate": "Nothing to update",
|
||||
"applyConfirm": "Write {count} userid bindings to the database?",
|
||||
"applyDone": "Successfully updated {count} bindings",
|
||||
"applyFailed": "Failed to apply sync results",
|
||||
"invalidDepartmentId": "Department ID must be a positive integer",
|
||||
"previewTruncated": "Showing first 20 of {total} pending updates",
|
||||
"conflictsTitle": "Conflicts",
|
||||
"occupiedBy": "userid already used by {user}",
|
||||
"stats": {
|
||||
"wecomUsers": "WeCom members",
|
||||
"localMatched": "Local matched",
|
||||
"wouldUpdate": "Would update",
|
||||
"conflicts": "Conflicts"
|
||||
}
|
||||
},
|
||||
"bindingsHint": "Users without wecom_userid cannot use WeCom password reset. Run directory sync or bind manually.",
|
||||
"searchBindings": "Search username, name, employee ID or wecom_userid",
|
||||
"systemSettings": "WeCom System Settings",
|
||||
"integrationCopyTitle": "WeCom Console Copy Helper",
|
||||
"integrationCopyDesc": "Copy these values directly into WeCom console fields.",
|
||||
@@ -323,6 +365,7 @@
|
||||
},
|
||||
"headers": {
|
||||
"user": "User",
|
||||
"employeeId": "Employee ID",
|
||||
"roleStatus": "Role / Status",
|
||||
"wecomUserId": "WeCom UserId",
|
||||
"unionId": "UnionId",
|
||||
|
||||
@@ -30,11 +30,14 @@
|
||||
"dbConnectionFailed": "Database connection failed. Please check if the database service is running.",
|
||||
"internalError": "Internal server error. Please try again later.",
|
||||
"rememberMe": "Remember me for 30 days",
|
||||
"forgotPasswordDesc": "Enter your email to reset your password",
|
||||
"forgotPasswordDesc": "Enter your employee ID and username; a reset link will be sent to your WeCom",
|
||||
"findPassword": "Find Password",
|
||||
"employeeIdRequired": "Please enter employee ID",
|
||||
"passwordResetWecomSent": "If the account exists and WeCom is bound, a reset link has been sent to your WeCom.",
|
||||
"passwordResetEmailSent": "If the account exists, a reset link has been sent to your email.",
|
||||
"passwordResetRequestFailed": "Failed to request password reset",
|
||||
"passwordResetRateLimited": "Too many attempts. Please try again in {minutes} minute(s).",
|
||||
"announcements": "Announcements",
|
||||
"passwordResetEmailSent": "如果账号存在,重置链接已发送到您的邮箱。",
|
||||
"passwordResetRequestFailed": "请求密码重置失败",
|
||||
"casdoorLogin": "Login with Casdoor",
|
||||
"casdoorErrors": {
|
||||
"invalidCredentials": "Incorrect username or password",
|
||||
@@ -161,5 +164,22 @@
|
||||
"employeeId": "Employee ID",
|
||||
"phone": "Phone Number"
|
||||
}
|
||||
},
|
||||
"resetPassword": {
|
||||
"title": "Reset Password",
|
||||
"desc": "Enter your new password below",
|
||||
"newPassword": "New Password",
|
||||
"confirmPassword": "Confirm Password",
|
||||
"newPasswordPlaceholder": "Enter new password",
|
||||
"confirmPasswordPlaceholder": "Confirm new password",
|
||||
"submit": "Reset Password",
|
||||
"submitting": "Resetting...",
|
||||
"backToLogin": "Back to Login",
|
||||
"fillAllFields": "Please fill in all fields",
|
||||
"passwordMismatch": "Passwords do not match",
|
||||
"successRedirect": "Password reset successfully. Redirecting to login...",
|
||||
"failed": "Failed to reset password",
|
||||
"invalidLink": "Invalid reset link. Please request password reset again.",
|
||||
"tokenInvalid": "This link has expired or was already used. Please request a new reset link from the login page."
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,12 @@
|
||||
"info": "Notice",
|
||||
"warning": "Warning",
|
||||
"error": "Error"
|
||||
},
|
||||
"pagination": {
|
||||
"summary": "Total {total} rows, page {page} / {pages}",
|
||||
"perPage": "Per page",
|
||||
"itemsUnit": "rows",
|
||||
"prevPage": "Previous",
|
||||
"nextPage": "Next"
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,11 @@
|
||||
"USER_PHONE_EXISTS": "Phone number already exists.",
|
||||
"USER_UNIQUENESS_CONFLICT": "Data uniqueness conflict.",
|
||||
"SYSTEM_INTERNAL_ERROR": "Internal server error. Please try again later.",
|
||||
"SYSTEM_HTTP_ERROR": "Request failed."
|
||||
"SYSTEM_HTTP_ERROR": "Request failed.",
|
||||
"WECOM_RESET_NOT_CONFIGURED": "WeCom password reset is not configured. Enable WeCom under Admin → WeCom → System Settings and fill Corp ID, Agent ID, and Secret.",
|
||||
"WECOM_NOTIFY_DISABLED": "WeCom notifications are disabled. Enable them under Admin → WeCom → Notify Settings.",
|
||||
"WECOM_RESET_URL_NOT_CONFIGURED": "Public base URL is not configured. Set WECOM_PUBLIC_BASE_URL in system settings.",
|
||||
"AUTH_PASSWORD_RESET_RATE_LIMITED": "Too many requests. Please try again later.",
|
||||
"AUTH_RESET_TOKEN_INVALID": "Reset link is invalid or expired. Please request password reset again."
|
||||
}
|
||||
}
|
||||
@@ -237,8 +237,50 @@
|
||||
}
|
||||
},
|
||||
"wecom": {
|
||||
"title": "การจัดการการผูกบัญชี WeCom",
|
||||
"subtitle": "ผูก/ยกเลิกการผูกบัญชี WeCom แบบแมนนวล และตรวจสอบบันทึกการเข้าสู่ระบบ",
|
||||
"title": "WeCom",
|
||||
"subtitle": "ตั้งค่า WeCom ซิงค์ userid จัดการการผูกบัญชีและตรวจสอบการเข้าสู่ระบบ",
|
||||
"nav": {
|
||||
"settings": "การตั้งค่า",
|
||||
"bindings": "การผูกบัญชี",
|
||||
"audits": "ตรวจสอบการเข้าสู่ระบบ"
|
||||
},
|
||||
"overview": {
|
||||
"bound": "ผูก userid แล้ว",
|
||||
"unbound": "ยังไม่ผูก",
|
||||
"boundRate": "อัตราการผูก",
|
||||
"hint": "รีเซ็ตรหัสผ่าน",
|
||||
"hintDesc": "ผู้ใช้ที่ไม่มี wecom_userid จะไม่ได้รับลิงก์รีเซ็ตผ่าน WeCom"
|
||||
},
|
||||
"sync": {
|
||||
"title": "ซิงค์สมุดรายชื่อ",
|
||||
"desc": "ดึงสมาชิก WeCom และเติม users.wecom_userid ตามรหัสพนักงาน",
|
||||
"permissionNote": "แอป WeCom ต้องมีสิทธิ์อ่านสมุดรายชื่อและส่งข้อความ",
|
||||
"employeeIdSource": "แหล่งรหัสพนักงาน",
|
||||
"departmentId": "รหัสแผนกราก (ไม่บังคับ)",
|
||||
"departmentIdPlaceholder": "เว้นว่างเพื่อซิงค์ทุกแผนก",
|
||||
"preview": "ดูตัวอย่าง",
|
||||
"apply": "ยืนยันเขียน",
|
||||
"previewDone": "ดูตัวอย่างเสร็จแล้ว โปรดตรวจสอบก่อนยืนยัน",
|
||||
"previewFailed": "ดูตัวอย่างล้มเหลว",
|
||||
"previewFirst": "โปรดดูตัวอย่างก่อน",
|
||||
"conflictsBlockApply": "พบความขัดแย้ง โปรดแก้ไขก่อนยืนยัน",
|
||||
"nothingToUpdate": "ไม่มีรายการที่ต้องอัปเดต",
|
||||
"applyConfirm": "ยืนยันเขียน {count} รายการลงฐานข้อมูล?",
|
||||
"applyDone": "อัปเดต {count} รายการสำเร็จ",
|
||||
"applyFailed": "ยืนยันการซิงค์ล้มเหลว",
|
||||
"invalidDepartmentId": "รหัสแผนกต้องเป็นจำนวนเต็มบวก",
|
||||
"previewTruncated": "แสดง 20 รายการแรกจากทั้งหมด {total} รายการ",
|
||||
"conflictsTitle": "รายการขัดแย้ง",
|
||||
"occupiedBy": "userid ถูกใช้โดย {user} แล้ว",
|
||||
"stats": {
|
||||
"wecomUsers": "สมาชิก WeCom",
|
||||
"localMatched": "จับคู่ในระบบ",
|
||||
"wouldUpdate": "จะอัปเดต",
|
||||
"conflicts": "ขัดแย้ง"
|
||||
}
|
||||
},
|
||||
"bindingsHint": "ผู้ใช้ที่ไม่มี wecom_userid ใช้การรีเซ็ตรหัสผ่านผ่าน WeCom ไม่ได้ โปรดซิงค์หรือผูกด้วยตนเอง",
|
||||
"searchBindings": "ค้นหาชื่อผู้ใช้ ชื่อ รหัสพนักงาน หรือ wecom_userid",
|
||||
"systemSettings": "การตั้งค่าระบบ WeCom",
|
||||
"integrationCopyTitle": "ตัวช่วยคัดลอกค่าไปยังคอนโซล WeCom",
|
||||
"integrationCopyDesc": "คัดลอกค่าด้านล่างไปใส่ในช่องที่ตรงกันในคอนโซลผู้ดูแล WeCom ได้โดยตรง",
|
||||
@@ -328,6 +370,7 @@
|
||||
},
|
||||
"headers": {
|
||||
"user": "ผู้ใช้",
|
||||
"employeeId": "รหัสพนักงาน",
|
||||
"roleStatus": "บทบาท / สถานะ",
|
||||
"wecomUserId": "WeCom UserId",
|
||||
"unionId": "UnionId",
|
||||
|
||||
@@ -22,8 +22,12 @@
|
||||
"forgotPassword": "ลืมรหัสผ่าน?",
|
||||
"rememberMe": "จดจำการเข้าสู่ระบบ 30 วัน",
|
||||
"announcements": "ประกาศ",
|
||||
"forgotPasswordDesc": "กรอกอีเมลเพื่อรีเซ็ตรหัสผ่าน",
|
||||
"forgotPasswordDesc": "กรอกรหัสพนักงานและชื่อผู้ใช้ ลิงก์รีเซ็ตจะถูกส่งไปยัง WeCom ของคุณ",
|
||||
"findPassword": "ค้นหารหัสผ่าน",
|
||||
"employeeIdRequired": "กรุณากรอกรหัสพนักงาน",
|
||||
"passwordResetWecomSent": "หากบัญชีมีอยู่และผูก WeCom แล้ว ลิงก์รีเซ็ตถูกส่งไปยัง WeCom ของคุณแล้ว",
|
||||
"passwordResetRequestFailed": "คำขอรีเซ็ตรหัสผ่านล้มเหลว",
|
||||
"passwordResetRateLimited": "คำขอถี่เกินไป โปรดลองอีกครั้งใน {minutes} นาที",
|
||||
"casdoorLogin": "เข้าสู่ระบบด้วย Casdoor",
|
||||
"casdoorErrors": {
|
||||
"invalidCredentials": "ชื่อผู้ใช้หรือรหัสผ่านไม่ถูกต้อง",
|
||||
@@ -143,6 +147,28 @@
|
||||
"success": "ส่งคำขอลงทะเบียนแล้ว โปรดรอการอนุมัติ",
|
||||
"failed": "การลงทะเบียนล้มเหลว",
|
||||
"inputError": "กรุณากรอกชื่อผู้ใช้และรหัสผ่าน",
|
||||
"requestFailed": "คำขอล้มเหลว"
|
||||
"requestFailed": "คำขอล้มเหลว",
|
||||
"fields": {
|
||||
"realName": "ชื่อจริง",
|
||||
"employeeId": "รหัสพนักงาน",
|
||||
"phone": "หมายเลขโทรศัพท์"
|
||||
}
|
||||
},
|
||||
"resetPassword": {
|
||||
"title": "รีเซ็ตรหัสผ่าน",
|
||||
"desc": "กรอกรหัสผ่านใหม่ด้านล่าง",
|
||||
"newPassword": "รหัสผ่านใหม่",
|
||||
"confirmPassword": "ยืนยันรหัสผ่าน",
|
||||
"newPasswordPlaceholder": "กรอกรหัสผ่านใหม่",
|
||||
"confirmPasswordPlaceholder": "กรอกรหัสผ่านใหม่อีกครั้ง",
|
||||
"submit": "รีเซ็ตรหัสผ่าน",
|
||||
"submitting": "กำลังรีเซ็ต...",
|
||||
"backToLogin": "กลับไปหน้าเข้าสู่ระบบ",
|
||||
"fillAllFields": "กรุณากรอกข้อมูลให้ครบ",
|
||||
"passwordMismatch": "รหัสผ่านไม่ตรงกัน",
|
||||
"successRedirect": "รีเซ็ตรหัสผ่านสำเร็จ กำลังไปหน้าเข้าสู่ระบบ...",
|
||||
"failed": "รีเซ็ตรหัสผ่านล้มเหลว",
|
||||
"invalidLink": "ลิงก์รีเซ็ตไม่ถูกต้อง โปรดขอรีเซ็ตรหัสผ่านใหม่",
|
||||
"tokenInvalid": "ลิงก์หมดอายุหรือถูกใช้แล้ว โปรดขอลิงก์ใหม่จากหน้าเข้าสู่ระบบ"
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,12 @@
|
||||
"info": "แจ้งเตือน",
|
||||
"warning": "คำเตือน",
|
||||
"error": "ข้อผิดพลาด"
|
||||
},
|
||||
"pagination": {
|
||||
"summary": "ทั้งหมด {total} รายการ, หน้า {page} / {pages}",
|
||||
"perPage": "ต่อหน้า",
|
||||
"itemsUnit": "รายการ",
|
||||
"prevPage": "ก่อนหน้า",
|
||||
"nextPage": "ถัดไป"
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,11 @@
|
||||
"USER_PHONE_EXISTS": "หมายเลขโทรศัพท์นี้มีอยู่แล้ว",
|
||||
"USER_UNIQUENESS_CONFLICT": "ข้อมูลซ้ำกัน",
|
||||
"SYSTEM_INTERNAL_ERROR": "เซิร์ฟเวอร์ขัดข้อง กรุณาลองใหม่ภายหลัง",
|
||||
"SYSTEM_HTTP_ERROR": "คำขอล้มเหลว"
|
||||
"SYSTEM_HTTP_ERROR": "คำขอล้มเหลว",
|
||||
"WECOM_RESET_NOT_CONFIGURED": "ยังไม่ได้ตั้งค่าการรีเซ็ตรหัสผ่านผ่าน WeCom โปรดเปิดใช้งานและกรอก Corp ID, Agent ID, Secret ใน Admin → WeCom → System Settings",
|
||||
"WECOM_NOTIFY_DISABLED": "การแจ้งเตือน WeCom ถูกปิด โปรดเปิดใน Admin → WeCom → Notify Settings",
|
||||
"WECOM_RESET_URL_NOT_CONFIGURED": "ยังไม่ได้ตั้งค่า Public Base URL โปรดกรอก WECOM_PUBLIC_BASE_URL ในการตั้งค่าระบบ",
|
||||
"AUTH_PASSWORD_RESET_RATE_LIMITED": "คำขอถี่เกินไป โปรดลองอีกครั้งในภายหลัง",
|
||||
"AUTH_RESET_TOKEN_INVALID": "ลิงก์รีเซ็ตหมดอายุหรือใช้แล้ว โปรดขอรีเซ็ตรหัสผ่านใหม่"
|
||||
}
|
||||
}
|
||||
@@ -238,8 +238,50 @@
|
||||
}
|
||||
},
|
||||
"wecom": {
|
||||
"title": "企业微信绑定管理",
|
||||
"subtitle": "手动绑定/解绑企业微信账号,并查看登录审计记录",
|
||||
"title": "企业微信",
|
||||
"subtitle": "配置企微集成、同步 userid、管理绑定与登录审计",
|
||||
"nav": {
|
||||
"settings": "系统配置",
|
||||
"bindings": "绑定管理",
|
||||
"audits": "登录审计"
|
||||
},
|
||||
"overview": {
|
||||
"bound": "已绑定 userid",
|
||||
"unbound": "未绑定",
|
||||
"boundRate": "绑定率",
|
||||
"hint": "找回密码",
|
||||
"hintDesc": "未绑定 wecom_userid 的用户无法接收企微重置链接"
|
||||
},
|
||||
"sync": {
|
||||
"title": "通讯录同步",
|
||||
"desc": "从企业微信通讯录按工号回填 users.wecom_userid,用于找回密码与通知触达。",
|
||||
"permissionNote": "需在企微后台为自建应用开通「通讯录读」与「发送应用消息」权限。",
|
||||
"employeeIdSource": "当前工号来源",
|
||||
"departmentId": "根部门 ID(可选)",
|
||||
"departmentIdPlaceholder": "留空表示全部部门",
|
||||
"preview": "预览同步",
|
||||
"apply": "确认写入",
|
||||
"previewDone": "预览完成,请确认结果后再写入",
|
||||
"previewFailed": "预览同步失败",
|
||||
"previewFirst": "请先预览同步结果",
|
||||
"conflictsBlockApply": "存在冲突,请先人工处理后再写入",
|
||||
"nothingToUpdate": "没有需要更新的绑定",
|
||||
"applyConfirm": "确认将 {count} 条 userid 绑定写入数据库?",
|
||||
"applyDone": "已成功更新 {count} 条绑定",
|
||||
"applyFailed": "写入同步结果失败",
|
||||
"invalidDepartmentId": "部门 ID 必须为正整数",
|
||||
"previewTruncated": "仅展示前 20 条,共 {total} 条待更新",
|
||||
"conflictsTitle": "冲突明细",
|
||||
"occupiedBy": "userid 已被用户 {user} 占用",
|
||||
"stats": {
|
||||
"wecomUsers": "企微成员",
|
||||
"localMatched": "本地匹配",
|
||||
"wouldUpdate": "待更新",
|
||||
"conflicts": "冲突"
|
||||
}
|
||||
},
|
||||
"bindingsHint": "未绑定 wecom_userid 的用户无法使用企微找回密码;可先运行通讯录同步或手动绑定。",
|
||||
"searchBindings": "搜索用户名、姓名、工号或 wecom_userid",
|
||||
"systemSettings": "企业微信系统配置",
|
||||
"integrationCopyTitle": "企微后台复制助手",
|
||||
"integrationCopyDesc": "以下字段可直接复制到企业微信管理后台对应配置项。",
|
||||
@@ -324,6 +366,7 @@
|
||||
},
|
||||
"headers": {
|
||||
"user": "用户",
|
||||
"employeeId": "工号",
|
||||
"roleStatus": "角色/状态",
|
||||
"wecomUserId": "WeCom UserId",
|
||||
"unionId": "UnionId",
|
||||
|
||||
@@ -30,11 +30,14 @@
|
||||
"dbConnectionFailed": "数据库连接失败,请检查数据库服务是否运行。",
|
||||
"internalError": "服务器内部错误,请稍后重试。",
|
||||
"rememberMe": "30天内免登录",
|
||||
"forgotPasswordDesc": "输入您的邮箱以重置密码",
|
||||
"forgotPasswordDesc": "输入工号和用户名,重置链接将发送到您的企业微信",
|
||||
"findPassword": "找回密码",
|
||||
"announcements": "公告",
|
||||
"passwordResetEmailSent": "如果账号存在,重置链接已发送到您的邮箱。",
|
||||
"employeeIdRequired": "请输入工号",
|
||||
"passwordResetWecomSent": "若账号存在且已绑定企业微信,重置链接已发送到您的企业微信。",
|
||||
"passwordResetEmailSent": "若账号存在,重置链接已发送到您的邮箱。",
|
||||
"passwordResetRequestFailed": "请求密码重置失败",
|
||||
"passwordResetRateLimited": "操作过于频繁,请 {minutes} 分钟后再试",
|
||||
"announcements": "公告",
|
||||
"casdoorLogin": "Casdoor 登录",
|
||||
"casdoorErrors": {
|
||||
"invalidCredentials": "用户名或密码错误",
|
||||
@@ -160,5 +163,22 @@
|
||||
"employeeId": "工号",
|
||||
"phone": "手机号"
|
||||
}
|
||||
},
|
||||
"resetPassword": {
|
||||
"title": "重置密码",
|
||||
"desc": "请在下方输入新密码",
|
||||
"newPassword": "新密码",
|
||||
"confirmPassword": "确认密码",
|
||||
"newPasswordPlaceholder": "请输入新密码",
|
||||
"confirmPasswordPlaceholder": "请再次输入新密码",
|
||||
"submit": "重置密码",
|
||||
"submitting": "正在重置...",
|
||||
"backToLogin": "返回登录",
|
||||
"fillAllFields": "请填写所有字段",
|
||||
"passwordMismatch": "两次输入的密码不一致",
|
||||
"successRedirect": "密码重置成功,即将跳转到登录页...",
|
||||
"failed": "密码重置失败",
|
||||
"invalidLink": "重置链接无效或缺少 token,请重新申请找回密码",
|
||||
"tokenInvalid": "链接已失效或已过期(可能已使用过或重新申请过),请回到登录页重新发起找回密码"
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,12 @@
|
||||
"info": "提示",
|
||||
"warning": "警告",
|
||||
"error": "错误"
|
||||
},
|
||||
"pagination": {
|
||||
"summary": "共 {total} 条,当前第 {page} / {pages} 页",
|
||||
"perPage": "每页",
|
||||
"itemsUnit": "条",
|
||||
"prevPage": "上一页",
|
||||
"nextPage": "下一页"
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,11 @@
|
||||
"USER_PHONE_EXISTS": "手机号已存在。",
|
||||
"USER_UNIQUENESS_CONFLICT": "数据唯一性冲突。",
|
||||
"SYSTEM_INTERNAL_ERROR": "服务器内部错误,请稍后重试。",
|
||||
"SYSTEM_HTTP_ERROR": "请求失败。"
|
||||
"SYSTEM_HTTP_ERROR": "请求失败。",
|
||||
"WECOM_RESET_NOT_CONFIGURED": "企微找回密码未配置,请在管理端「企业微信 → 系统配置」开启企微并填写 Corp ID、Agent ID、Secret。",
|
||||
"WECOM_NOTIFY_DISABLED": "企微通知已关闭,请在管理端「企业微信 → 通知设置」开启。",
|
||||
"WECOM_RESET_URL_NOT_CONFIGURED": "未配置公网访问地址,请在系统配置中填写公网基地址(WECOM_PUBLIC_BASE_URL)。",
|
||||
"AUTH_PASSWORD_RESET_RATE_LIMITED": "操作过于频繁,请稍后再试。",
|
||||
"AUTH_RESET_TOKEN_INVALID": "重置链接已失效或已过期,请重新申请找回密码"
|
||||
}
|
||||
}
|
||||
@@ -237,8 +237,50 @@
|
||||
}
|
||||
},
|
||||
"wecom": {
|
||||
"title": "企業微信綁定管理",
|
||||
"subtitle": "手動綁定/解綁企業微信帳號,並查看登入審計記錄",
|
||||
"title": "企業微信",
|
||||
"subtitle": "配置企微整合、同步 userid、管理綁定與登入審計",
|
||||
"nav": {
|
||||
"settings": "系統配置",
|
||||
"bindings": "綁定管理",
|
||||
"audits": "登入審計"
|
||||
},
|
||||
"overview": {
|
||||
"bound": "已綁定 userid",
|
||||
"unbound": "未綁定",
|
||||
"boundRate": "綁定率",
|
||||
"hint": "找回密碼",
|
||||
"hintDesc": "未綁定 wecom_userid 的用戶無法接收企微重設連結"
|
||||
},
|
||||
"sync": {
|
||||
"title": "通訊錄同步",
|
||||
"desc": "從企業微信通訊錄按工號回填 users.wecom_userid。",
|
||||
"permissionNote": "需在企微後台開通「通訊錄讀」與「發送應用消息」權限。",
|
||||
"employeeIdSource": "當前工號來源",
|
||||
"departmentId": "根部門 ID(可選)",
|
||||
"departmentIdPlaceholder": "留空表示全部部門",
|
||||
"preview": "預覽同步",
|
||||
"apply": "確認寫入",
|
||||
"previewDone": "預覽完成,請確認結果後再寫入",
|
||||
"previewFailed": "預覽同步失敗",
|
||||
"previewFirst": "請先預覽同步結果",
|
||||
"conflictsBlockApply": "存在衝突,請先人工處理後再寫入",
|
||||
"nothingToUpdate": "沒有需要更新的綁定",
|
||||
"applyConfirm": "確認將 {count} 條 userid 綁定寫入資料庫?",
|
||||
"applyDone": "已成功更新 {count} 條綁定",
|
||||
"applyFailed": "寫入同步結果失敗",
|
||||
"invalidDepartmentId": "部門 ID 必須為正整數",
|
||||
"previewTruncated": "僅展示前 20 條,共 {total} 條待更新",
|
||||
"conflictsTitle": "衝突明細",
|
||||
"occupiedBy": "userid 已被用戶 {user} 占用",
|
||||
"stats": {
|
||||
"wecomUsers": "企微成員",
|
||||
"localMatched": "本地匹配",
|
||||
"wouldUpdate": "待更新",
|
||||
"conflicts": "衝突"
|
||||
}
|
||||
},
|
||||
"bindingsHint": "未綁定 wecom_userid 的用戶無法使用企微找回密碼;可先執行通訊錄同步或手動綁定。",
|
||||
"searchBindings": "搜尋用戶名、姓名、工號或 wecom_userid",
|
||||
"systemSettings": "企業微信系統配置",
|
||||
"integrationCopyTitle": "企微後台複製助手",
|
||||
"integrationCopyDesc": "以下字段可直接複製到企業微信管理後台對應配置項。",
|
||||
@@ -328,6 +370,7 @@
|
||||
},
|
||||
"headers": {
|
||||
"user": "用戶",
|
||||
"employeeId": "工號",
|
||||
"roleStatus": "角色/狀態",
|
||||
"wecomUserId": "WeCom UserId",
|
||||
"unionId": "UnionId",
|
||||
|
||||
@@ -22,8 +22,12 @@
|
||||
"forgotPassword": "忘記密碼?",
|
||||
"rememberMe": "30天內免登入",
|
||||
"announcements": "公告",
|
||||
"forgotPasswordDesc": "輸入您的郵箱以重設密碼",
|
||||
"forgotPasswordDesc": "輸入工號與用戶名,重設連結將發送到您的企業微信",
|
||||
"findPassword": "找回密碼",
|
||||
"employeeIdRequired": "請輸入工號",
|
||||
"passwordResetWecomSent": "若帳號存在且已綁定企業微信,重設連結已發送到您的企業微信。",
|
||||
"passwordResetRequestFailed": "請求密碼重設失敗",
|
||||
"passwordResetRateLimited": "操作過於頻繁,請 {minutes} 分鐘後再試",
|
||||
"casdoorLogin": "Casdoor 登入",
|
||||
"casdoorErrors": {
|
||||
"invalidCredentials": "用戶名或密碼錯誤",
|
||||
@@ -143,6 +147,28 @@
|
||||
"success": "註冊申請已提交,請等待管理員審批",
|
||||
"failed": "註冊失敗",
|
||||
"inputError": "請輸入用戶名和密碼",
|
||||
"requestFailed": "請求失敗"
|
||||
"requestFailed": "請求失敗",
|
||||
"fields": {
|
||||
"realName": "真實姓名",
|
||||
"employeeId": "工號",
|
||||
"phone": "手機號"
|
||||
}
|
||||
},
|
||||
"resetPassword": {
|
||||
"title": "重設密碼",
|
||||
"desc": "請在下方輸入新密碼",
|
||||
"newPassword": "新密碼",
|
||||
"confirmPassword": "確認密碼",
|
||||
"newPasswordPlaceholder": "請輸入新密碼",
|
||||
"confirmPasswordPlaceholder": "請再次輸入新密碼",
|
||||
"submit": "重設密碼",
|
||||
"submitting": "正在重設...",
|
||||
"backToLogin": "返回登入",
|
||||
"fillAllFields": "請填寫所有欄位",
|
||||
"passwordMismatch": "兩次輸入的密碼不一致",
|
||||
"successRedirect": "密碼重設成功,即將跳轉到登入頁...",
|
||||
"failed": "密碼重設失敗",
|
||||
"invalidLink": "重設連結無效或缺少 token,請重新申請找回密碼",
|
||||
"tokenInvalid": "連結已失效或已過期(可能已使用過或重新申請過),請回到登入頁重新發起找回密碼"
|
||||
}
|
||||
}
|
||||
@@ -17,5 +17,12 @@
|
||||
"info": "提示",
|
||||
"warning": "警告",
|
||||
"error": "錯誤"
|
||||
},
|
||||
"pagination": {
|
||||
"summary": "共 {total} 條,當前第 {page} / {pages} 頁",
|
||||
"perPage": "每頁",
|
||||
"itemsUnit": "條",
|
||||
"prevPage": "上一頁",
|
||||
"nextPage": "下一頁"
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,11 @@
|
||||
"USER_PHONE_EXISTS": "手機號已存在。",
|
||||
"USER_UNIQUENESS_CONFLICT": "數據唯一性衝突。",
|
||||
"SYSTEM_INTERNAL_ERROR": "伺服器內部錯誤,請稍後重試。",
|
||||
"SYSTEM_HTTP_ERROR": "請求失敗。"
|
||||
"SYSTEM_HTTP_ERROR": "請求失敗。",
|
||||
"WECOM_RESET_NOT_CONFIGURED": "企微找回密碼未配置,請在管理端「企業微信 → 系統配置」開啟企微並填寫 Corp ID、Agent ID、Secret。",
|
||||
"WECOM_NOTIFY_DISABLED": "企微通知已關閉,請在管理端「企業微信 → 通知設定」開啟。",
|
||||
"WECOM_RESET_URL_NOT_CONFIGURED": "未配置公網訪問地址,請在系統配置中填寫公網基地址(WECOM_PUBLIC_BASE_URL)。",
|
||||
"AUTH_PASSWORD_RESET_RATE_LIMITED": "操作過於頻繁,請稍後再試。",
|
||||
"AUTH_RESET_TOKEN_INVALID": "重設連結已失效或已過期,請重新申請找回密碼"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* shared/components/PaginationBar.vue
|
||||
* 用途:通用偏移分页条(摘要、每页条数、页码按钮)。
|
||||
* 依赖:buildOffsetPageButtons、common.pagination i18n、components-ds 样式类。
|
||||
* 逻辑:父组件 v-model:page / v-model:page-size,服务端或客户端分页均可复用。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { buildOffsetPageButtons } from '@/shared/composables/useOffsetPagination';
|
||||
|
||||
interface Props {
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
/** 服务端已算好的总页数;不传则按 total/pageSize 推算 */
|
||||
pages?: number;
|
||||
pageSizeOptions?: number[];
|
||||
/** 为 false 时强制隐藏;默认 total > 0 时显示 */
|
||||
visible?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
pages: 0,
|
||||
pageSizeOptions: () => [10, 20, 50, 100],
|
||||
visible: undefined,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:page', value: number): void;
|
||||
(e: 'update:pageSize', value: number): void;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const totalPages = computed(() => {
|
||||
if (props.pages > 0) return props.pages;
|
||||
const size = Math.max(1, Number(props.pageSize) || 20);
|
||||
const total = Math.max(0, Number(props.total) || 0);
|
||||
return Math.max(1, Math.ceil(total / size));
|
||||
});
|
||||
|
||||
const safePage = computed(() =>
|
||||
Math.min(Math.max(1, Number(props.page) || 1), totalPages.value),
|
||||
);
|
||||
|
||||
const pageButtons = computed(() => buildOffsetPageButtons(safePage.value, totalPages.value));
|
||||
|
||||
const showBar = computed(() => {
|
||||
if (props.visible !== undefined) return props.visible;
|
||||
return props.total > 0;
|
||||
});
|
||||
|
||||
/**
|
||||
* 跳转到指定页并通知父组件。
|
||||
* @param target - 目标页码(1-based)
|
||||
*/
|
||||
const onGoToPage = (target: number): void => {
|
||||
const next = Math.min(Math.max(1, target), totalPages.value);
|
||||
emit('update:page', next);
|
||||
};
|
||||
|
||||
/**
|
||||
* 上一页并通知父组件。
|
||||
*/
|
||||
const onPrevPage = (): void => {
|
||||
onGoToPage(safePage.value - 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* 下一页并通知父组件。
|
||||
*/
|
||||
const onNextPage = (): void => {
|
||||
onGoToPage(safePage.value + 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* 每页条数变更时重置到第 1 页。
|
||||
* @param size - 新的 pageSize
|
||||
*/
|
||||
const onPageSizeChange = (size: number): void => {
|
||||
emit('update:pageSize', size);
|
||||
emit('update:page', 1);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="showBar"
|
||||
class="flex flex-col gap-3 rounded-2xl border border-default bg-surface px-4 py-3 md:flex-row md:items-center md:justify-between"
|
||||
>
|
||||
<div class="text-sm text-secondary">
|
||||
{{ t('common.pagination.summary', { total, page: safePage, pages: totalPages }) }}
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<label class="flex items-center gap-2 text-xs text-secondary">
|
||||
<span>{{ t('common.pagination.perPage') }}</span>
|
||||
<span class="relative inline-flex items-center">
|
||||
<select
|
||||
:value="pageSize"
|
||||
class="admin-table-filter-input appearance-none pl-2 pr-7 py-1 text-xs leading-5"
|
||||
@change="onPageSizeChange(Number(($event.target as HTMLSelectElement).value))"
|
||||
>
|
||||
<option v-for="size in pageSizeOptions" :key="`page-size-${size}`" :value="size">
|
||||
{{ size }}
|
||||
</option>
|
||||
</select>
|
||||
<svg
|
||||
class="pointer-events-none absolute right-2 h-3.5 w-3.5 text-muted"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.168l3.71-3.938a.75.75 0 1 1 1.08 1.04l-4.25 4.5a.75.75 0 0 1-1.08 0l-4.25-4.5a.75.75 0 0 1 .02-1.06Z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
<span>{{ t('common.pagination.itemsUnit') }}</span>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="safePage <= 1"
|
||||
class="admin-report-page-btn"
|
||||
@click="onPrevPage"
|
||||
>
|
||||
{{ t('common.pagination.prevPage') }}
|
||||
</button>
|
||||
<button
|
||||
v-for="btn in pageButtons"
|
||||
:key="`page-btn-${btn}`"
|
||||
type="button"
|
||||
:disabled="btn === -1"
|
||||
class="admin-report-page-btn"
|
||||
:class="btn === -1
|
||||
? 'border-transparent text-muted cursor-default opacity-100'
|
||||
: btn === safePage
|
||||
? 'admin-report-page-btn--active'
|
||||
: ''"
|
||||
@click="btn !== -1 && onGoToPage(btn)"
|
||||
>
|
||||
{{ btn === -1 ? '...' : btn }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="safePage >= totalPages"
|
||||
class="admin-report-page-btn"
|
||||
@click="onNextPage"
|
||||
>
|
||||
{{ t('common.pagination.nextPage') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* shared/composables/useDialogBackdropClose.ts
|
||||
* 用途:弹窗遮罩点击关闭,避免输入框拖选文字时误触关闭。
|
||||
* 依赖:无。
|
||||
* 逻辑:仅当 pointerdown 与 pointerup 均发生在遮罩自身时才触发 onClose。
|
||||
*/
|
||||
|
||||
export interface DialogBackdropCloseHandlers {
|
||||
onBackdropPointerDown: (event: PointerEvent) => void;
|
||||
onBackdropPointerUp: (event: PointerEvent) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建遮罩关闭处理器,防止从输入框拖选到遮罩外时误关弹窗。
|
||||
* @param onClose - 遮罩有效点击时的关闭回调
|
||||
* @returns pointerdown / pointerup 处理器
|
||||
*/
|
||||
export function createDialogBackdropCloseHandler(onClose: () => void): DialogBackdropCloseHandlers {
|
||||
let pointerDownOnBackdrop = false;
|
||||
|
||||
/**
|
||||
* 记录是否在遮罩上按下指针。
|
||||
* @param event - pointerdown 事件
|
||||
*/
|
||||
const onBackdropPointerDown = (event: PointerEvent): void => {
|
||||
pointerDownOnBackdrop = event.target === event.currentTarget;
|
||||
};
|
||||
|
||||
/**
|
||||
* 仅在遮罩上完成按下+抬起时关闭弹窗。
|
||||
* @param event - pointerup 事件
|
||||
*/
|
||||
const onBackdropPointerUp = (event: PointerEvent): void => {
|
||||
if (pointerDownOnBackdrop && event.target === event.currentTarget) {
|
||||
onClose();
|
||||
}
|
||||
pointerDownOnBackdrop = false;
|
||||
};
|
||||
|
||||
return { onBackdropPointerDown, onBackdropPointerUp };
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* shared/composables/useOffsetPagination.ts
|
||||
* 用途:管理端偏移分页的页码计算与导航辅助。
|
||||
* 依赖:vue computed/ref/unref。
|
||||
* 逻辑:PaginationBar、报表页等复用 pageButtons 与翻页方法。
|
||||
*/
|
||||
import { computed, unref, type ComputedRef, type Ref } from 'vue';
|
||||
|
||||
export interface UseOffsetPaginationOptions {
|
||||
page: Ref<number>;
|
||||
pageSize: Ref<number>;
|
||||
total: Ref<number> | ComputedRef<number>;
|
||||
/** 服务端已计算总页数时传入,优先于 total/pageSize 推算 */
|
||||
pages?: Ref<number> | ComputedRef<number>;
|
||||
}
|
||||
|
||||
const DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100] as const;
|
||||
|
||||
/**
|
||||
* 根据当前页与总页数生成带省略号的页码按钮序列(-1 表示 ...)。
|
||||
* 核心逻辑:页数较多时开头仅展示 1–3 页,末尾仅展示最后 3 页,中间展示当前页邻域。
|
||||
* @param current - 当前页(1-based)
|
||||
* @param totalPages - 总页数
|
||||
*/
|
||||
export function buildOffsetPageButtons(current: number, totalPages: number): number[] {
|
||||
const total = Math.max(1, totalPages);
|
||||
const page = Math.min(Math.max(1, current), total);
|
||||
if (total <= 5) return Array.from({ length: total }, (_, i) => i + 1);
|
||||
if (page <= 3) return [1, 2, 3, -1, total];
|
||||
if (page >= total - 2) return [1, -1, total - 2, total - 1, total];
|
||||
return [1, -1, page - 1, page, page + 1, -1, total];
|
||||
}
|
||||
|
||||
/**
|
||||
* 提供偏移分页的 totalPages、range 与翻页辅助。
|
||||
* @param options.page - 当前页码 ref
|
||||
* @param options.pageSize - 每页条数 ref
|
||||
* @param options.total - 总条数 ref/computed
|
||||
* @param options.pages - 可选,服务端返回的总页数
|
||||
*/
|
||||
export function useOffsetPagination(options: UseOffsetPaginationOptions) {
|
||||
const totalPages = computed(() => {
|
||||
const explicit = options.pages ? Math.max(1, Number(unref(options.pages)) || 1) : 0;
|
||||
if (explicit > 0) return explicit;
|
||||
const size = Math.max(1, Number(unref(options.pageSize)) || 20);
|
||||
const total = Math.max(0, Number(unref(options.total)) || 0);
|
||||
return Math.max(1, Math.ceil(total / size));
|
||||
});
|
||||
|
||||
const safePage = computed(() =>
|
||||
Math.min(Math.max(1, Number(unref(options.page)) || 1), totalPages.value),
|
||||
);
|
||||
|
||||
const rangeStart = computed(() => {
|
||||
const total = Math.max(0, Number(unref(options.total)) || 0);
|
||||
if (total === 0) return 0;
|
||||
const size = Math.max(1, Number(unref(options.pageSize)) || 20);
|
||||
return (safePage.value - 1) * size + 1;
|
||||
});
|
||||
|
||||
const rangeEnd = computed(() => {
|
||||
const total = Math.max(0, Number(unref(options.total)) || 0);
|
||||
if (total === 0) return 0;
|
||||
const size = Math.max(1, Number(unref(options.pageSize)) || 20);
|
||||
return Math.min(rangeStart.value + size - 1, total);
|
||||
});
|
||||
|
||||
const pageButtons = computed(() => buildOffsetPageButtons(safePage.value, totalPages.value));
|
||||
|
||||
/**
|
||||
* 跳转到指定页,自动 clamp 到合法范围。
|
||||
* @param page - 目标页码
|
||||
*/
|
||||
const goToPage = (page: number): void => {
|
||||
options.page.value = Math.min(Math.max(1, page), totalPages.value);
|
||||
};
|
||||
|
||||
/** 上一页 */
|
||||
const prevPage = (): void => {
|
||||
goToPage(safePage.value - 1);
|
||||
};
|
||||
|
||||
/** 下一页 */
|
||||
const nextPage = (): void => {
|
||||
goToPage(safePage.value + 1);
|
||||
};
|
||||
|
||||
return {
|
||||
totalPages,
|
||||
safePage,
|
||||
rangeStart,
|
||||
rangeEnd,
|
||||
pageButtons,
|
||||
goToPage,
|
||||
prevPage,
|
||||
nextPage,
|
||||
pageSizeOptions: DEFAULT_PAGE_SIZE_OPTIONS,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* shared/types/pagination.types.ts
|
||||
* 用途:前后端通用的偏移分页响应结构。
|
||||
* 依赖:无。
|
||||
* 逻辑:分页 API 与 PaginationBar 等组件共享本类型。
|
||||
*/
|
||||
|
||||
export interface PaginatedResult<T> {
|
||||
items: T[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
pages: number;
|
||||
}
|
||||
Reference in new issue
Block a user