Merge branch 'dev' into hugo
This commit is contained in:
commit
29a7704d46
55 files changed
+2852
-546
No files matched your search
@@ -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');
|
||||
Reference in new issue
Block a user