56 files changed
+4501
-1110
No files matched your search
@@ -7,7 +7,7 @@
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import type { AdminUserRow } from '../types/admin.types';
|
||||
import type { AdminDashboardBadges, AdminDashboardSummary } from '../types/dashboard.types';
|
||||
import type { AdminDashboardSummary } from '../types/dashboard.types';
|
||||
import type { PaginatedResult } from '@/shared/types/pagination.types';
|
||||
import type { AdminLinkedServiceRow } from '../types/linked-service.types';
|
||||
import type {
|
||||
@@ -15,6 +15,7 @@ import type {
|
||||
ApplicationSortKey,
|
||||
ApplicationStatusFilter,
|
||||
ApplicationUsageFilter,
|
||||
OpsOverviewReport,
|
||||
UsageReport,
|
||||
UsageRangeKey,
|
||||
} from '../types/report.types';
|
||||
@@ -571,6 +572,8 @@ export const updateAdminUserPermissions = (userId: number, agentIds: number[]) =
|
||||
|
||||
// Departments
|
||||
export const listAdminDepartments = () => requestJson<any[]>('/api/admin/departments', auth());
|
||||
export const listAdminDepartmentMembers = (id: number) =>
|
||||
requestJson(`/api/admin/departments/${id}/members`, auth());
|
||||
export const createAdminDepartment = (payload: Record<string, unknown>) =>
|
||||
requestJson('/api/admin/departments', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const updateAdminDepartment = (id: number, payload: Record<string, unknown>) =>
|
||||
@@ -714,13 +717,6 @@ export const saveAdminAgentPermissions = (agentId: number, userIds: number[]) =>
|
||||
body: JSON.stringify({ user_ids: userIds }),
|
||||
});
|
||||
|
||||
// Permission requests
|
||||
export const listAdminPermissionRequests = () =>
|
||||
requestJson<any[]>('/api/admin/permission-requests', auth());
|
||||
export const approveAdminPermissionRequest = (id: number) =>
|
||||
requestJson(`/api/admin/permission-requests/${id}/approve`, { method: 'POST', ...auth() });
|
||||
export const rejectAdminPermissionRequest = (id: number) =>
|
||||
requestJson(`/api/admin/permission-requests/${id}/reject`, { method: 'POST', ...auth() });
|
||||
export const batchUpdateAdminPermissions = (payload: Record<string, unknown>) =>
|
||||
requestJson('/api/admin/permissions/batch', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const importAdminPermissions = (formData: FormData) =>
|
||||
@@ -731,23 +727,25 @@ export const importAdminPermissions = (formData: FormData) =>
|
||||
export const getAdminDashboardSummary = () =>
|
||||
requestJson<AdminDashboardSummary>('/api/admin/dashboard/summary', auth());
|
||||
|
||||
/** 侧栏角标:待审批用户数、待处理权限申请数 */
|
||||
export const getAdminDashboardBadges = () =>
|
||||
requestJson<AdminDashboardBadges>('/api/admin/dashboard/badges', auth());
|
||||
|
||||
// Reports
|
||||
export interface AdminUsageReportParams {
|
||||
user_page?: number;
|
||||
user_page_size?: number;
|
||||
/** 时间范围:7d | 30d | 90d | 180d | 365d */
|
||||
/** 时间范围:7d | 30d | 90d | 180d | 365d(与 start_date/end_date 互斥,自定义日期优先) */
|
||||
range?: UsageRangeKey;
|
||||
/** 自定义开始日期 YYYY-MM-DD */
|
||||
start_date?: string;
|
||||
/** 自定义结束日期 YYYY-MM-DD */
|
||||
end_date?: string;
|
||||
}
|
||||
|
||||
export const getAdminUsageReport = (params: AdminUsageReportParams = {}) => {
|
||||
const qs = new URLSearchParams();
|
||||
if (params.user_page != null) qs.set('user_page', String(params.user_page));
|
||||
if (params.user_page_size != null) qs.set('user_page_size', String(params.user_page_size));
|
||||
if (params.range) qs.set('range', params.range);
|
||||
if (params.start_date) qs.set('start_date', params.start_date);
|
||||
if (params.end_date) qs.set('end_date', params.end_date);
|
||||
if (!params.start_date && !params.end_date && params.range) qs.set('range', params.range);
|
||||
const query = qs.toString();
|
||||
return requestJson<UsageReport>(
|
||||
`/api/admin/reports/usage${query ? `?${query}` : ''}`,
|
||||
@@ -757,6 +755,10 @@ export const getAdminUsageReport = (params: AdminUsageReportParams = {}) => {
|
||||
|
||||
export interface AdminApplicationReportParams {
|
||||
range?: UsageRangeKey;
|
||||
/** 自定义开始日期 YYYY-MM-DD(优先于 range) */
|
||||
start_date?: string;
|
||||
/** 自定义结束日期 YYYY-MM-DD(优先于 range) */
|
||||
end_date?: string;
|
||||
status?: ApplicationStatusFilter;
|
||||
usage?: ApplicationUsageFilter;
|
||||
q?: string;
|
||||
@@ -772,7 +774,9 @@ export interface AdminApplicationReportParams {
|
||||
*/
|
||||
export const getAdminApplicationReport = (params: AdminApplicationReportParams = {}) => {
|
||||
const qs = new URLSearchParams();
|
||||
if (params.range) qs.set('range', params.range);
|
||||
if (params.start_date) qs.set('start_date', params.start_date);
|
||||
if (params.end_date) qs.set('end_date', params.end_date);
|
||||
if (!params.start_date && !params.end_date && params.range) qs.set('range', params.range);
|
||||
if (params.status && params.status !== 'all') qs.set('status', params.status);
|
||||
if (params.usage && params.usage !== 'all') qs.set('usage', params.usage);
|
||||
if (params.q?.trim()) qs.set('q', params.q.trim());
|
||||
@@ -788,8 +792,64 @@ export const getAdminApplicationReport = (params: AdminApplicationReportParams =
|
||||
};
|
||||
|
||||
export const getAdminFeedbackReport = () => requestJson<any>('/api/admin/reports/feedback', auth());
|
||||
|
||||
/**
|
||||
* 拉取运营总览报表:对话量 / 活跃用户 / 活跃应用 / 趋势环比 / Top 与低使用应用 / 未处理反馈。
|
||||
* @param params - 统计范围:自定义起止日期(优先)或预设 range key
|
||||
*/
|
||||
export const getAdminOpsOverview = (params: { range?: UsageRangeKey; start_date?: string; end_date?: string } = {}) => {
|
||||
const qs = new URLSearchParams();
|
||||
if (params.start_date) qs.set('start_date', params.start_date);
|
||||
if (params.end_date) qs.set('end_date', params.end_date);
|
||||
if (!params.start_date && !params.end_date && params.range) qs.set('range', params.range);
|
||||
const query = qs.toString();
|
||||
return requestJson<OpsOverviewReport>(
|
||||
`/api/admin/reports/overview${query ? `?${query}` : ''}`,
|
||||
auth(),
|
||||
);
|
||||
};
|
||||
|
||||
export const getAdminReportTable = (url: string) => requestJson<any[]>(url, auth());
|
||||
export const getAdminReportTableCount = (url: string) => requestJson<{ total: number }>(url, auth());
|
||||
|
||||
/**
|
||||
* 拉取聊天日志「Top 提问内容 / Top 回答内容」(直接按 ChatLog 明细统计)。
|
||||
* @param query - 可选的查询串(时间范围/应用/用户等识别条件)
|
||||
*/
|
||||
export const getAdminChatLogTops = (query = '') =>
|
||||
requestJson<{ questions: Array<{ label: string; count: number }>; answers: Array<{ label: string; count: number }> }>(
|
||||
`/api/admin/reports/chat-log-tops${query}`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
/** 反馈概览:待处理 / 本月已关闭 / 最多反馈应用 */
|
||||
export const getAdminFeedbackSummary = (query = '') =>
|
||||
requestJson<{ pending_count: number; closed_this_month: number; top_app: { name: string; count: number } }>(
|
||||
`/api/admin/reports/feedback-summary${query}`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
/** 问题分析:高频问题簇 KPI + 优先处理问题(复用聊天日志风险规则) */
|
||||
export const getAdminIssueAnalysis = (query = '') =>
|
||||
requestJson<{
|
||||
kpi: {
|
||||
high_freq_clusters: number;
|
||||
attention_signals: number;
|
||||
review_signals: number;
|
||||
empty_answers: number;
|
||||
top10_ratio: number;
|
||||
top_risk_app: { name: string; signal_count: number; attention_ratio: number };
|
||||
};
|
||||
total_questions: number;
|
||||
questions: Array<{ topic: string; count: number; apps: string; attention_count: number; reasons: string[]; checks: string[] }>;
|
||||
}>(`/api/admin/reports/issue-analysis${query}`, auth());
|
||||
|
||||
/** 将一条意见反馈标记为已关闭 */
|
||||
export const closeAdminGeneralFeedback = (feedbackId: number) =>
|
||||
requestJson<{ id: number; status: string; closed_at: string }>(
|
||||
`/api/admin/reports/general-feedbacks/${feedbackId}/close`,
|
||||
{ method: 'POST', ...auth() },
|
||||
);
|
||||
export const batchDeleteAdminChatLogs = (ids: number[]) =>
|
||||
requestJson<{ deleted_count: number }>('/api/admin/database/chat_logs/batch-delete', {
|
||||
method: 'POST',
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
/**
|
||||
* features/admin/components/AdminNav.vue
|
||||
* 管理后台左侧导航,使用子路由跳转。
|
||||
* 依赖:admin-nav.store、modules 常量、vue-router。
|
||||
* 逻辑:报表/企微子菜单默认折叠;当前路由落在对应模块时自动展开以便看到激活项。
|
||||
* 绠$悊鍚庡彴宸︿晶瀵艰埅锛屼娇鐢ㄥ瓙璺敱璺宠浆銆?
|
||||
* 渚濊禆锛歛dmin-nav.store銆乵odules 甯搁噺銆乿ue-router銆?
|
||||
* 閫昏緫锛氭姤琛?浼佸井瀛愯彍鍗曢粯璁ゆ姌鍙狅紱褰撳墠璺敱钀藉湪瀵瑰簲妯″潡鏃惰嚜鍔ㄥ睍寮€浠ヤ究鐪嬪埌婵€娲婚」銆?
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
LayoutDashboard, UserPlus, UserCog, Building, Bot, FileText,
|
||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, ShieldCheck, BarChart2, AppWindow,
|
||||
LayoutDashboard, UserCog, Building, Bot, FileText,
|
||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, BarChart2, AppWindow,
|
||||
ScrollText, ExternalLink, PackageSearch, GraduationCap, Cable,
|
||||
} from 'lucide-vue-next';
|
||||
import type { Component } from 'vue';
|
||||
@@ -30,7 +30,6 @@ const navStore = useAdminNavStore();
|
||||
|
||||
const iconMap: Record<AdminModuleId, Component> = {
|
||||
dashboard: LayoutDashboard,
|
||||
approvals: UserPlus,
|
||||
users: UserCog,
|
||||
departments: Building,
|
||||
agents: Bot,
|
||||
@@ -45,7 +44,6 @@ const iconMap: Record<AdminModuleId, Component> = {
|
||||
procurement_contract: ScrollText,
|
||||
training_config: GraduationCap,
|
||||
integration_connector: Cable,
|
||||
requests: ShieldCheck,
|
||||
reports: BarChart2,
|
||||
shipping_inventory: PackageSearch,
|
||||
};
|
||||
@@ -108,7 +106,7 @@ const navigateReport = (table: string): void => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 进入报表/企微模块时自动展开子菜单,避免当前页在折叠状态下不可见。
|
||||
* 杩涘叆鎶ヨ〃/浼佸井妯″潡鏃惰嚜鍔ㄥ睍寮€瀛愯彍鍗曪紝閬垮厤褰撳墠椤靛湪鎶樺彔鐘舵€佷笅涓嶅彲瑙併€?
|
||||
*/
|
||||
watch(
|
||||
isReportsActive,
|
||||
@@ -167,12 +165,6 @@ watch(
|
||||
:class="isModuleActive(item.id) ? 'text-brand-600' : 'text-muted group-hover:text-secondary'"
|
||||
/>
|
||||
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t(item.labelKey) }}</span>
|
||||
<span
|
||||
v-if="navStore.badgeForModule(item.id) && !navStore.sidebarCollapsed"
|
||||
class="ml-auto bg-red-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full shadow-sm"
|
||||
>
|
||||
{{ navStore.badgeForModule(item.id) }}
|
||||
</span>
|
||||
<div
|
||||
v-if="isModuleActive(item.id)"
|
||||
class="absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 bg-brand-600 rounded-r-full"
|
||||
@@ -276,3 +268,4 @@ watch(
|
||||
</nav>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
* features/admin/composables/useAdminNavBadges.ts
|
||||
* 暴露角标刷新入口;拉取与缓存放 admin-nav.store(不在此 composable 内 onMounted,避免子页面重复请求)。
|
||||
*/
|
||||
import { useAdminNavStore } from '../stores/admin-nav.store';
|
||||
|
||||
export function useAdminNavBadges() {
|
||||
const navStore = useAdminNavStore();
|
||||
return {
|
||||
refreshBadges: () => navStore.refreshBadges(),
|
||||
};
|
||||
return { refreshBadges: async (): Promise<void> => undefined };
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/constants/modules.ts
|
||||
* 管理后台模块元数据,AdminNav 与子路由共用。
|
||||
* 绠$悊鍚庡彴妯″潡鍏冩暟鎹紝AdminNav 涓庡瓙璺敱鍏辩敤銆?
|
||||
*/
|
||||
|
||||
import type { AdminModuleId, AdminReportTableId, ShippingConfigSubModuleId } from '../types/admin.types';
|
||||
@@ -40,12 +40,11 @@ export interface ShippingConfigSubModuleMeta {
|
||||
|
||||
/** 已独立拆分的模块(全部 admin 模块均已拆分) */
|
||||
export const STANDALONE_ADMIN_MODULES = new Set<AdminModuleId>([
|
||||
'dashboard', 'agents', 'users', 'departments', 'approvals', 'announcements', 'questions', 'requests', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'shipping_inventory', 'procurement_contract', 'reports','training_config', 'integration_connector'
|
||||
'dashboard', 'agents', 'users', 'departments', 'announcements', 'questions', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'shipping_inventory', 'procurement_contract', 'reports', 'training_config', 'integration_connector'
|
||||
]);
|
||||
|
||||
export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'dashboard', routeName: 'AdminDashboard', path: 'dashboard', labelKey: 'admin.nav.dashboard', configKey: 'dashboard' },
|
||||
{ id: 'approvals', routeName: 'AdminApprovals', path: 'approvals', labelKey: 'admin.nav.approvals', configKey: 'approvals' },
|
||||
{ id: 'users', routeName: 'AdminUsers', path: 'users', labelKey: 'admin.nav.users', configKey: 'users' },
|
||||
{ id: 'departments', routeName: 'AdminDepartments', path: 'departments', labelKey: 'admin.nav.departments', configKey: 'departments' },
|
||||
{ id: 'agents', routeName: 'AdminAgents', path: 'agents', labelKey: 'admin.nav.agents', configKey: 'agents' },
|
||||
@@ -61,9 +60,15 @@ export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'procurement_contract', routeName: 'AdminProcurementContract', path: 'procurement-contract', labelKey: 'admin.nav.procurementContract', configKey: 'procurement_contract' },
|
||||
{ id: 'training_config', routeName: 'AdminTrainingConfig', path: 'training-config', labelKey: 'admin.nav.trainingConfig', configKey: 'training_config' },
|
||||
{ id: 'integration_connector', routeName: 'AdminIntegrationConnector', path: 'integration-connector', labelKey: 'admin.nav.integrationConnector', configKey: 'integration_connector' },
|
||||
{ id: 'requests', routeName: 'AdminRequests', path: 'requests', labelKey: 'admin.nav.requests', configKey: 'requests' },
|
||||
];
|
||||
|
||||
/**
|
||||
* 数据报表导航子项:
|
||||
* - 保留:使用分析、聊天日志、应用运营
|
||||
* - 合并:意见反馈(general_feedbacks) + 回答评价(feedbacks) → 用户反馈与回答评价(feedbacks)
|
||||
* - 新增:运营总览(ops_overview)、问题分析(issue_analysis) 第一版为骨架/空状态
|
||||
* - 说明:general_feedbacks 仅作为「用户反馈与回答评价」页内 Tab 的数据源,不再作为独立导航项。
|
||||
*/
|
||||
/** 货代管理的业务导航唯一真相源;按基础定义、适配规则、运行任务的依赖顺序排列。 */
|
||||
export const SHIPPING_CONFIG_SUB_MODULE_METAS: ShippingConfigSubModuleMeta[] = [
|
||||
{ id: 'field_assets', routeName: 'AdminShippingFieldAssets', path: 'shipping-field-assets', labelKey: 'admin.nav.shippingFieldAssets', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
@@ -84,12 +89,12 @@ export const SHIPPING_CONFIG_SUB_MODULE_METAS: ShippingConfigSubModuleMeta[] = [
|
||||
];
|
||||
|
||||
export const ADMIN_REPORT_TABLES: AdminReportTableId[] = [
|
||||
'ops_overview',
|
||||
'usage_analysis',
|
||||
'chat_logs',
|
||||
'agents',
|
||||
'permission_requests',
|
||||
'general_feedbacks',
|
||||
'feedbacks',
|
||||
'issue_analysis',
|
||||
];
|
||||
|
||||
export const LEGACY_MODULE_QUERY_TO_PATH: Record<string, string> = {};
|
||||
@@ -100,3 +105,4 @@ export const adminModulePath = (moduleId: AdminModuleId | string): string => {
|
||||
if (meta) return `/admin/${meta.path}`;
|
||||
return `/admin/${LEGACY_MODULE_QUERY_TO_PATH[moduleId] || moduleId}`;
|
||||
};
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Bot, Plus, SquarePen, Trash2, Users } from 'lucide-vue-next';
|
||||
import { Bot, Plus, SquarePen, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import AgentFormModal from './components/AgentFormModal.vue';
|
||||
import AgentPermissionModal from './components/AgentPermissionModal.vue';
|
||||
import AgentTestModal from './components/AgentTestModal.vue';
|
||||
import { useAgentsAdmin } from './composables/useAgentsAdmin';
|
||||
import { useAgentsTableColumnResize } from './composables/useAgentsTableColumnResize';
|
||||
@@ -29,7 +28,6 @@ const {
|
||||
contentProfileOptions,
|
||||
scheduleTasks,
|
||||
trainingExamPdfGuides,
|
||||
activeUsers,
|
||||
isLoading,
|
||||
isSaving,
|
||||
isImportingTrainingPdf,
|
||||
@@ -40,9 +38,6 @@ const {
|
||||
isTesting,
|
||||
testingAgent,
|
||||
testResult,
|
||||
showPermissionModal,
|
||||
permissionAgent,
|
||||
permissionUserIds,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
@@ -59,9 +54,6 @@ const {
|
||||
deleteAgent,
|
||||
openTestModal,
|
||||
runAgentTest,
|
||||
openPermissionModal,
|
||||
togglePermissionUser,
|
||||
savePermissions,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
} = useAgentsAdmin();
|
||||
@@ -75,13 +67,11 @@ const {
|
||||
|
||||
const tableHeaderColumns = computed(() => [
|
||||
{ key: 'name', label: t('admin.agent.headers.name'), align: 'left' as const },
|
||||
{ key: 'type', label: t('admin.agent.headers.type'), align: 'left' as const },
|
||||
{ key: 'aggregation', label: t('admin.agent.headers.aggregation'), align: 'left' as const },
|
||||
{ key: 'config', label: t('admin.agent.headers.config'), align: 'left' as const },
|
||||
{ key: 'status', label: t('admin.agent.headers.status'), align: 'left' as const },
|
||||
{ key: 'actions', label: t('admin.agent.headers.actions'), align: 'right' as const },
|
||||
]);
|
||||
|
||||
/* 列表仅展示名称、状态和操作;类型/聚合/配置仍由编辑弹窗维护。 */
|
||||
const formatAgentCode = (agent: AgentRow) => agent.agent_code || 'generic';
|
||||
|
||||
const formatAgentAggregationPrimary = (agent: AgentRow) => (
|
||||
@@ -131,6 +121,8 @@ const formatRuntimeProviderLabel = (agent: AgentRow) => {
|
||||
const translated = t(key);
|
||||
return translated === key ? provider : translated;
|
||||
};
|
||||
void [formatAgentAggregationPrimary, formatAgentAggregationSecondary, formatAgentConfigPrimary,
|
||||
formatAgentConfigSecondary, formatAgentTypeLabel, formatRuntimeProviderLabel];
|
||||
|
||||
const showFormDialog = ref(false);
|
||||
|
||||
@@ -241,43 +233,6 @@ onMounted(() => {
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<p class="truncate text-sm text-primary" :title="formatAgentTypeLabel(agent)">
|
||||
{{ formatAgentTypeLabel(agent) }}
|
||||
</p>
|
||||
<p class="truncate text-xs text-muted" :title="formatRuntimeProviderLabel(agent)">
|
||||
{{ formatRuntimeProviderLabel(agent) }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<p
|
||||
class="truncate text-sm font-medium"
|
||||
:class="agent.is_aggregate ? 'text-brand-700' : 'text-secondary'"
|
||||
:title="formatAgentAggregationPrimary(agent)"
|
||||
>
|
||||
{{ formatAgentAggregationPrimary(agent) }}
|
||||
</p>
|
||||
<p class="truncate text-xs text-muted" :title="formatAgentAggregationSecondary(agent)">
|
||||
{{ formatAgentAggregationSecondary(agent) }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<p
|
||||
class="truncate font-mono text-sm text-primary"
|
||||
:title="formatAgentConfigPrimary(agent)"
|
||||
>
|
||||
{{ formatAgentConfigPrimary(agent) }}
|
||||
</p>
|
||||
<p class="truncate text-xs text-muted">
|
||||
{{ formatAgentConfigSecondary(agent) }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<span
|
||||
@@ -300,14 +255,6 @@ onMounted(() => {
|
||||
<SquarePen class="w-4 h-4 shrink-0" />
|
||||
{{ t('admin.edit') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center justify-center p-2 text-blue-600 bg-blue-50 hover:bg-blue-100 rounded-lg transition-all"
|
||||
:title="t('admin.agent.manageAccess')"
|
||||
@click.stop="openPermissionModal(agent)"
|
||||
>
|
||||
<Users class="w-5 h-5 shrink-0" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center whitespace-nowrap p-2 text-emerald-600 bg-emerald-50 hover:bg-emerald-100 rounded-lg transition-all"
|
||||
@@ -367,17 +314,6 @@ onMounted(() => {
|
||||
@import-training-pdf="importTrainingQuestionBankFromPdf"
|
||||
/>
|
||||
|
||||
<AgentPermissionModal
|
||||
:visible="showPermissionModal"
|
||||
:agent="permissionAgent"
|
||||
:users="activeUsers()"
|
||||
:selected-user-ids="permissionUserIds"
|
||||
:is-saving="isSaving"
|
||||
@close="showPermissionModal = false"
|
||||
@save="savePermissions"
|
||||
@toggle-user="togglePermissionUser"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
|
||||
+5
-3
@@ -8,12 +8,14 @@
|
||||
|
||||
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||
|
||||
const STORAGE_KEY = 'hxops.admin.agents.tableColumnWidths';
|
||||
// 列结构已移除权限操作,升级缓存键以废弃旧的拖拽宽度,避免旧值继续撑出横向滚动。
|
||||
const STORAGE_KEY = 'hxops.admin.agents.tableColumnWidths.v4';
|
||||
|
||||
/** 名称 / 类型 / 分类 / 配置 / 状态 / 操作 */
|
||||
const DEFAULT_WIDTHS = [220, 168, 128, 140, 96, 220] as const;
|
||||
// 列宽只根据字段和操作控件确定;描述始终在名称单元格内截断,不参与宽度计算。
|
||||
const DEFAULT_WIDTHS = [400, 140, 240] as const;
|
||||
|
||||
const MIN_WIDTHS = [140, 120, 100, 120, 80, 200] as const;
|
||||
const MIN_WIDTHS = [220, 110, 220] as const;
|
||||
|
||||
const COLUMN_COUNT = DEFAULT_WIDTHS.length;
|
||||
|
||||
|
||||
@@ -5,15 +5,22 @@
|
||||
* 逻辑:路由 /admin/departments;表头排序复用 shared SortableTableHeader + useTableSort。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Plus, Search, Trash2 } from 'lucide-vue-next';
|
||||
import { Edit, Plus, Search, Trash2, Users } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import SortableTableHeader from '@/shared/components/SortableTableHeader.vue';
|
||||
import DepartmentFormModal from './components/DepartmentFormModal.vue';
|
||||
import DepartmentMembersModal from './components/DepartmentMembersModal.vue';
|
||||
import { useDepartmentsAdmin } from './composables/useDepartmentsAdmin';
|
||||
import { listAdminDepartmentMembers } from '@/features/admin/api/admin.api';
|
||||
import type { AdminDepartmentMembersResponse } from '@/features/admin/types/admin.types';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const showMembersModal = ref(false);
|
||||
const departmentMembers = ref<AdminDepartmentMembersResponse | null>(null);
|
||||
|
||||
const {
|
||||
filteredDepartments,
|
||||
@@ -40,6 +47,16 @@ const {
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
|
||||
/** 加载并展示指定部门的员工名单。 */
|
||||
const openDepartmentMembers = async (departmentId: number): Promise<void> => {
|
||||
try {
|
||||
departmentMembers.value = await listAdminDepartmentMembers(departmentId) as AdminDepartmentMembersResponse;
|
||||
showMembersModal.value = true;
|
||||
} catch (error) {
|
||||
msg.error((error as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -77,13 +94,14 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<!-- 列宽:名称 / 编码 / 公司 / 操作 -->
|
||||
<!-- 列宽:名称 / 编码 / 公司 / 员工 / 操作 -->
|
||||
<table class="admin-table table-fixed">
|
||||
<colgroup>
|
||||
<col class="w-[25%]" />
|
||||
<col class="w-[20%]" />
|
||||
<col class="w-[35%]" />
|
||||
<col class="w-[15%]" />
|
||||
<col class="w-[30%]" />
|
||||
<col class="w-[12%]" />
|
||||
<col class="w-[13%]" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -114,12 +132,13 @@ onMounted(() => {
|
||||
@sort="toggleSort"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-center text-xs">{{ t('admin.dept.headers.members') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs">{{ t('admin.dept.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="filteredDepartments.length === 0">
|
||||
<td colspan="4" class="px-6 admin-table-empty">
|
||||
<td colspan="5" class="px-6 admin-table-empty">
|
||||
{{ searchQuery.trim() ? t('admin.dept.noSearchResults') : t('admin.dept.noDepts') }}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -140,6 +159,14 @@ onMounted(() => {
|
||||
<td class="px-6 py-4 text-sm text-muted truncate" :title="d.company || '-'">
|
||||
{{ d.company || '-' }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-center">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center rounded-lg bg-blue-50 p-2 text-blue-600 hover:bg-blue-100"
|
||||
:title="t('admin.dept.actions.viewMembers')"
|
||||
@click="openDepartmentMembers(d.id)"
|
||||
><Users class="w-5 h-5" /><span class="ml-1 text-xs">{{ d.member_count || 0 }}</span></button>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-end gap-1">
|
||||
<button
|
||||
@@ -173,6 +200,11 @@ onMounted(() => {
|
||||
@close="closeFormModal"
|
||||
@save="saveDepartment"
|
||||
/>
|
||||
<DepartmentMembersModal
|
||||
:visible="showMembersModal"
|
||||
:data="departmentMembers"
|
||||
@close="showMembersModal = false"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* features/admin/modules/departments/components/DepartmentMembersModal.vue
|
||||
* 用途:展示部门对应的员工数量和名单。
|
||||
* 依赖:部门成员只读 API 响应与 Vue 事件。
|
||||
* 逻辑:DepartmentsPage 点击员工图标后传入数据,本组件只负责呈现与关闭。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Users, X } from 'lucide-vue-next';
|
||||
import type { AdminDepartmentMembersResponse } from '@/features/admin/types/admin.types';
|
||||
|
||||
defineProps<{ visible: boolean; data: AdminDepartmentMembersResponse | null }>();
|
||||
const emit = defineEmits<{ close: [] }>();
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible && data" class="admin-modal-overlay items-center" @click.self="emit('close')">
|
||||
<section class="admin-modal-panel max-w-2xl max-h-[90vh] animate-fade-in-up">
|
||||
<header class="px-8 py-6 border-b border-subtle flex items-center justify-between">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-primary">{{ t('admin.dept.members.title', { name: data.department.name }) }}</h3>
|
||||
<p class="text-sm text-muted mt-1">{{ t('admin.dept.members.count', { count: data.count }) }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds rounded-full" :title="t('admin.close')" @click="emit('close')"><X class="w-5 h-5" /></button>
|
||||
</header>
|
||||
<div class="max-h-[60vh] overflow-y-auto p-6">
|
||||
<div v-if="data.members.length === 0" class="py-12 text-center text-muted">
|
||||
<Users class="w-9 h-9 mx-auto mb-3 opacity-60" />
|
||||
{{ t('admin.dept.members.empty') }}
|
||||
</div>
|
||||
<ul v-else class="divide-y divide-subtle">
|
||||
<li v-for="member in data.members" :key="member.id" class="py-3 flex items-center justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<p class="font-medium text-primary">{{ member.real_name || member.username }}</p>
|
||||
<p class="text-xs text-muted truncate">{{ member.employee_id || member.username }} · {{ member.email || '-' }}</p>
|
||||
</div>
|
||||
<span class="text-xs text-muted whitespace-nowrap">{{ member.status }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -5,17 +5,20 @@
|
||||
* 逻辑:路由 /admin/permissions;左侧用户相关列 sticky,右侧为各应用权限列。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download, FileText, Users } from 'lucide-vue-next';
|
||||
import BatchPermissionModal from '@/features/admin/modules/users/components/BatchPermissionModal.vue';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import { usePermissionsAdmin } from './composables/usePermissionsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
agents,
|
||||
users,
|
||||
appRows,
|
||||
permissionFilters,
|
||||
selectedUserIds,
|
||||
paginatedUsers,
|
||||
@@ -40,6 +43,45 @@ const { t } = useI18n();
|
||||
importPermissions,
|
||||
} = usePermissionsAdmin();
|
||||
|
||||
const permissionView = ref<'apps' | 'members'>('apps');
|
||||
const selectedApp = ref<(typeof agents.value)[number] | null>(null);
|
||||
const appMemberSearch = ref('');
|
||||
const appMemberPage = ref(1);
|
||||
const appMemberPageSize = ref(10);
|
||||
const appMemberPageSizeOptions = [10, 20, 50, 100];
|
||||
|
||||
/** 应用成员弹窗:已授权人员优先展示,同时可搜索全部有效人员以便增删权限。 */
|
||||
const appMembers = computed(() => {
|
||||
const appId = selectedApp.value?.id;
|
||||
const keyword = appMemberSearch.value.trim().toLowerCase();
|
||||
if (!appId) return [];
|
||||
return users.value
|
||||
.filter((user) => user.status !== 'pending')
|
||||
.filter((user) => !keyword || [user.username, user.real_name, user.department, user.employee_id]
|
||||
.filter(Boolean)
|
||||
.some((value) => String(value).toLowerCase().includes(keyword)))
|
||||
.sort((a, b) => Number(b.agent_ids.includes(appId)) - Number(a.agent_ids.includes(appId)));
|
||||
});
|
||||
|
||||
const appMemberTotalPages = computed(() => Math.max(1, Math.ceil(appMembers.value.length / appMemberPageSize.value)));
|
||||
const paginatedAppMembers = computed(() => {
|
||||
const page = Math.min(Math.max(1, appMemberPage.value), appMemberTotalPages.value);
|
||||
const start = (page - 1) * appMemberPageSize.value;
|
||||
return appMembers.value.slice(start, start + appMemberPageSize.value);
|
||||
});
|
||||
watch(appMemberSearch, () => { appMemberPage.value = 1; });
|
||||
|
||||
const openAppMembers = (app: (typeof agents.value)[number]): void => {
|
||||
selectedApp.value = app;
|
||||
appMemberSearch.value = '';
|
||||
appMemberPage.value = 1;
|
||||
};
|
||||
|
||||
const closeAppMembers = (): void => {
|
||||
selectedApp.value = null;
|
||||
appMemberSearch.value = '';
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
@@ -85,7 +127,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-filters--inline">
|
||||
<div v-if="permissionView === 'members'" class="admin-table-filters--inline">
|
||||
<input
|
||||
v-model="permissionFilters.username"
|
||||
:placeholder="t('admin.perm.filterName')"
|
||||
@@ -104,11 +146,37 @@ onMounted(() => {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<div class="flex gap-6 border-b border-default">
|
||||
<button type="button" class="border-b-2 px-1 py-3 text-sm font-medium transition-colors" :class="permissionView === 'apps' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-primary'" @click="permissionView = 'apps'">
|
||||
{{ t('admin.perm.views.apps') }}
|
||||
</button>
|
||||
<button type="button" class="border-b-2 px-1 py-3 text-sm font-medium transition-colors" :class="permissionView === 'members' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-primary'" @click="permissionView = 'members'">
|
||||
{{ t('admin.perm.views.members') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="permissionView === 'apps'" class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table min-w-[680px]">
|
||||
<thead><tr>
|
||||
<th class="px-6 py-4 text-left text-sm">{{ t('admin.perm.appHeaders.app') }}</th>
|
||||
<th class="px-4 py-4 text-center text-sm">{{ t('admin.perm.appHeaders.type') }}</th>
|
||||
<th class="px-4 py-4 text-center text-sm">{{ t('admin.perm.appHeaders.authorized') }}</th>
|
||||
<th class="px-6 py-4 text-right text-sm">{{ t('admin.perm.appHeaders.actions') }}</th>
|
||||
</tr></thead>
|
||||
<tbody><tr v-for="app in appRows" :key="app.id">
|
||||
<td class="px-6 py-4"><div class="font-medium text-primary">{{ app.name }}</div><div class="mt-1 text-xs text-muted">{{ t('admin.perm.appHeaders.accessHint') }}</div></td>
|
||||
<td class="px-4 py-4 text-center text-sm text-muted">{{ app.type || 'API' }}</td>
|
||||
<td class="px-4 py-4 text-center text-sm font-medium text-primary">{{ app.authorizedCount }}</td>
|
||||
<td class="px-6 py-4 text-right"><button type="button" class="text-sm font-medium text-brand-600 hover:text-brand-700" @click="openAppMembers(app)">{{ t('admin.perm.appHeaders.viewMembers') }}</button></td>
|
||||
</tr></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-else class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table min-w-max">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-4 w-12 text-center sticky left-0 admin-table-sticky-head z-20">
|
||||
<th class="w-[3rem] px-2 py-4 text-center sticky left-0 admin-table-sticky-head z-20">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500"
|
||||
@@ -117,27 +185,17 @@ onMounted(() => {
|
||||
/>
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-12 admin-table-sticky-head z-20 w-56"
|
||||
class="w-[18rem] min-w-[18rem] px-4 py-4 text-left text-sm sticky left-[3rem] admin-table-sticky-head z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]"
|
||||
>
|
||||
{{ t('admin.perm.headers.user') }}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-[17rem] admin-table-sticky-head z-20 w-36"
|
||||
>
|
||||
{{ t('admin.perm.headers.realName') }}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-[26rem] admin-table-sticky-head z-20 w-40 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]"
|
||||
>
|
||||
{{ t('admin.perm.headers.dept') }}
|
||||
</th>
|
||||
<th
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="px-4 py-4 text-center text-sm min-w-[100px]"
|
||||
class="w-[7.5rem] min-w-[7.5rem] px-3 py-4 text-center text-sm"
|
||||
>
|
||||
<div class="flex flex-col items-center gap-1">
|
||||
<span>{{ agent.name }}</span>
|
||||
<div class="flex min-h-14 flex-col items-center justify-center gap-1">
|
||||
<span class="line-clamp-2 max-w-[6.5rem] break-words leading-tight" :title="agent.name">{{ agent.name }}</span>
|
||||
<span class="text-[10px] text-muted font-normal border border-default px-1 rounded">
|
||||
{{ agent.type }}
|
||||
</span>
|
||||
@@ -147,7 +205,7 @@ onMounted(() => {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="user in paginatedUsers" :key="user.id">
|
||||
<td class="px-4 py-4 text-center sticky left-0 admin-table-sticky-cell z-20">
|
||||
<td class="w-[3rem] px-2 py-4 text-center sticky left-0 admin-table-sticky-cell z-20">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500"
|
||||
@@ -155,34 +213,29 @@ onMounted(() => {
|
||||
@change="toggleUserSelection(user.id)"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-6 py-4 sticky left-12 admin-table-sticky-cell z-20">
|
||||
<td class="w-[18rem] min-w-[18rem] px-4 py-3 sticky left-[3rem] admin-table-sticky-cell z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.05)]">
|
||||
<div class="flex items-center gap-3">
|
||||
<div
|
||||
class="w-8 h-8 rounded-full bg-gradient-to-br from-brand-100 to-indigo-100 text-brand-600 flex items-center justify-center font-bold text-sm"
|
||||
>
|
||||
{{ user.username.charAt(0).toUpperCase() }}
|
||||
{{ getUserAvatarLabel(user) }}
|
||||
</div>
|
||||
<div class="font-medium text-primary text-sm truncate max-w-[120px]" :title="user.username">
|
||||
{{ user.username }}
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-medium text-primary" :title="user.real_name || user.username">
|
||||
{{ user.real_name || user.username }}
|
||||
</div>
|
||||
<div class="mt-1 flex min-w-0 items-center gap-2 text-xs text-muted">
|
||||
<span class="max-w-[7rem] truncate" :title="user.username">{{ user.username }}</span>
|
||||
<span class="h-3 w-px shrink-0 bg-border" />
|
||||
<span class="max-w-[8rem] truncate" :title="user.department || '-'">{{ user.department || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 sticky left-[17rem] admin-table-sticky-cell z-20">
|
||||
<div class="text-sm text-primary truncate" :title="user.real_name || '-'">
|
||||
{{ user.real_name || '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="px-6 py-4 sticky left-[26rem] admin-table-sticky-cell z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.05)]"
|
||||
>
|
||||
<div class="text-sm text-muted truncate" :title="user.department">
|
||||
{{ user.department || '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="px-4 py-4 text-center border-l border-dashed border-subtle"
|
||||
class="w-[7.5rem] min-w-[7.5rem] px-3 py-3 text-center border-l border-dashed border-subtle"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -215,5 +268,33 @@ onMounted(() => {
|
||||
@close="closeBatchPermissionModal"
|
||||
@save="submitBatchPermission"
|
||||
/>
|
||||
|
||||
<div v-if="selectedApp" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/30 p-4" @click.self="closeAppMembers">
|
||||
<section class="flex max-h-[min(720px,calc(100vh-2rem))] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-default bg-surface shadow-2xl">
|
||||
<header class="flex items-start justify-between border-b border-default px-6 py-5"><div><h3 class="text-lg font-semibold text-primary">{{ selectedApp.name }}</h3><p class="mt-1 text-sm text-muted">{{ t('admin.perm.appHeaders.memberHint') }}</p></div><button type="button" class="text-sm text-muted hover:text-primary" @click="closeAppMembers">{{ t('admin.close') }}</button></header>
|
||||
<div class="border-b border-subtle bg-surface-soft px-6 py-4"><input v-model="appMemberSearch" :placeholder="t('admin.perm.appHeaders.memberSearch')" class="admin-table-filter-input w-full" /></div>
|
||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||
<div v-for="member in paginatedAppMembers" :key="member.id" class="flex items-center justify-between gap-4 border-b border-subtle px-6 py-3 last:border-b-0"><div class="flex min-w-0 items-center gap-3"><div class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-brand-100 text-sm font-bold text-brand-600">{{ getUserAvatarLabel(member) }}</div><div class="min-w-0"><div class="truncate text-sm font-medium text-primary">{{ member.real_name || member.username }}</div><div class="truncate text-xs text-muted">{{ member.username }} · {{ member.department || '-' }}</div></div></div><button type="button" class="shrink-0 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors" :class="member.agent_ids.includes(selectedApp.id) ? 'text-red-600 hover:bg-red-50' : 'text-brand-600 hover:bg-brand-50'" @click="toggleUserAgentPermission(member, selectedApp.id)">{{ member.agent_ids.includes(selectedApp.id) ? t('admin.perm.appHeaders.removeMember') : t('admin.perm.appHeaders.addMember') }}</button></div>
|
||||
<p v-if="appMembers.length === 0" class="px-6 py-12 text-center text-sm text-muted">{{ t('admin.perm.appHeaders.noMembers') }}</p>
|
||||
</div>
|
||||
<PaginationBar v-if="appMembers.length > 0" v-model:page="appMemberPage" v-model:page-size="appMemberPageSize" :total="appMembers.length" :pages="appMemberTotalPages" :page-size-options="appMemberPageSizeOptions" class="app-member-pagination rounded-none border-x-0 border-b-0" />
|
||||
</section>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 查看成员弹窗宽度固定,分页摘要与翻页操作保持在同一行。 */
|
||||
:deep(.app-member-pagination) {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
:deep(.app-member-pagination > div) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:deep(.app-member-pagination > div:last-child) {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
</style>
|
||||
@@ -39,6 +39,12 @@ export function usePermissionsAdmin() {
|
||||
|
||||
const activeUsers = computed(() => users.value.filter((u) => u.status !== 'pending'));
|
||||
|
||||
/** 按应用视图行:复用已加载用户权限,统计每个应用的有效授权人数。 */
|
||||
const appRows = computed(() => agents.value.map((agent) => ({
|
||||
...agent,
|
||||
authorizedCount: activeUsers.value.filter((user) => user.agent_ids.includes(agent.id)).length,
|
||||
})));
|
||||
|
||||
const filteredUsers = computed(() =>
|
||||
activeUsers.value.filter((u) => {
|
||||
const matchName =
|
||||
@@ -216,6 +222,7 @@ export function usePermissionsAdmin() {
|
||||
return {
|
||||
users,
|
||||
agents,
|
||||
appRows,
|
||||
permissionFilters,
|
||||
selectedUserIds,
|
||||
filteredUsers,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,100 +0,0 @@
|
||||
/**
|
||||
* features/admin/modules/requests/RequestsPage.vue
|
||||
* 权限申请管理独立页面。路由:/admin/requests
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ShieldCheck } from 'lucide-vue-next';
|
||||
import { useRequestsAdmin } from './composables/useRequestsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
requests,
|
||||
isLoading,
|
||||
loadAll,
|
||||
approveRequest,
|
||||
rejectRequest,
|
||||
} = useRequestsAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.request.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.request.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="requests.length === 0"
|
||||
class="flex flex-col items-center justify-center py-16 text-muted"
|
||||
>
|
||||
<div class="w-16 h-16 bg-surface-soft rounded-full flex items-center justify-center mb-4">
|
||||
<ShieldCheck class="w-8 h-8 text-muted" />
|
||||
</div>
|
||||
<p>{{ t('admin.request.noPending') }}</p>
|
||||
</div>
|
||||
|
||||
<table v-else class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.userId') }}</th>
|
||||
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.targetAgent') }}</th>
|
||||
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.reason') }}</th>
|
||||
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.status') }}</th>
|
||||
<th class="px-8 py-4 text-xs text-right">{{ t('admin.request.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="req in requests" :key="req.id">
|
||||
<td class="px-8 py-4 text-sm font-medium text-primary">{{ req.user_id }}</td>
|
||||
<td class="px-8 py-4 text-sm text-secondary">{{ req.agent_id }}</td>
|
||||
<td
|
||||
class="px-8 py-4 text-sm text-muted max-w-xs truncate"
|
||||
:title="req.reason"
|
||||
>
|
||||
{{ req.reason || '-' }}
|
||||
</td>
|
||||
<td class="px-8 py-4">
|
||||
<span
|
||||
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-50 text-yellow-700 border border-yellow-100"
|
||||
>
|
||||
{{ t('admin.status.' + req.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-8 py-4 text-right">
|
||||
<div class="flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
class="text-green-600 hover:text-green-800 text-sm font-medium hover:underline"
|
||||
@click="approveRequest(req.id)"
|
||||
>
|
||||
{{ t('admin.request.approve') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-red-500 hover:text-red-700 text-sm font-medium hover:underline"
|
||||
@click="rejectRequest(req.id)"
|
||||
>
|
||||
{{ t('admin.request.reject') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,68 +0,0 @@
|
||||
/**
|
||||
* features/admin/modules/requests/composables/useRequestsAdmin.ts
|
||||
* 权限申请管理:列表、通过、拒绝。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
approveAdminPermissionRequest,
|
||||
listAdminPermissionRequests,
|
||||
rejectAdminPermissionRequest,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { useAdminNavBadges } from '@/features/admin/composables/useAdminNavBadges';
|
||||
import type { AdminPermissionRequestRow } from '@/features/admin/types/request.types';
|
||||
|
||||
export function useRequestsAdmin() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const { refreshBadges } = useAdminNavBadges();
|
||||
|
||||
const requests = ref<AdminPermissionRequestRow[]>([]);
|
||||
const isLoading = ref(true);
|
||||
|
||||
const loadRequests = async (): Promise<void> => {
|
||||
try {
|
||||
requests.value = await listAdminPermissionRequests();
|
||||
} catch (e) {
|
||||
console.error('Error loading permission requests:', e);
|
||||
requests.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const loadAll = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
await loadRequests();
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
const approveRequest = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await approveAdminPermissionRequest(id);
|
||||
await loadRequests();
|
||||
await refreshBadges();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
||||
}
|
||||
};
|
||||
|
||||
const rejectRequest = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await rejectAdminPermissionRequest(id);
|
||||
await loadRequests();
|
||||
await refreshBadges();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
requests,
|
||||
isLoading,
|
||||
loadAll,
|
||||
approveRequest,
|
||||
rejectRequest,
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { Edit, Plus, Trash2, Users } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import SortableTableHeader from '@/shared/components/SortableTableHeader.vue';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import BatchEditUserModal from './components/BatchEditUserModal.vue';
|
||||
import BatchPermissionModal from './components/BatchPermissionModal.vue';
|
||||
import UserFormModal from './components/UserFormModal.vue';
|
||||
@@ -199,7 +200,7 @@ onMounted(() => {
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-center">
|
||||
<div class="h-9 w-9 rounded-full bg-gradient-to-br from-brand-500 to-indigo-600 text-white flex items-center justify-center text-xs font-bold shadow-sm">
|
||||
{{ user.username.charAt(0).toUpperCase() }}
|
||||
{{ getUserAvatarLabel(user) }}
|
||||
</div>
|
||||
<div class="ml-3 text-sm font-medium text-primary">{{ user.username }}</div>
|
||||
</div>
|
||||
|
||||
@@ -2,17 +2,10 @@
|
||||
* features/admin/stores/admin-nav.store.ts
|
||||
* 管理后台导航 UI 状态(侧栏折叠、报表/企微子菜单展开、角标)。
|
||||
*
|
||||
* 角标数据来自 GET /api/admin/dashboard/badges,在 store 内做 TTL 缓存与 in-flight 去重,
|
||||
* 避免切换 admin 子路由时重复请求(AdminLayout 挂载一次即可)。
|
||||
* 报表与企业微信子菜单默认折叠,进入对应模块时由 AdminNav 展开。
|
||||
*/
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { getAdminDashboardBadges } from '@/features/admin/api/admin.api';
|
||||
import type { AdminModuleId } from '../types/admin.types';
|
||||
|
||||
/** 角标缓存有效期(毫秒):此时间内 ensureBadges 直接复用内存中的计数 */
|
||||
const BADGE_CACHE_TTL_MS = 60_000;
|
||||
|
||||
export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
const sidebarCollapsed = ref(false);
|
||||
@@ -27,65 +20,10 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
/** 「权限申请」导航角标:pending 权限申请数 */
|
||||
const pendingRequestsCount = ref(0);
|
||||
|
||||
/** 上次成功拉取 badges 的时间戳;0 表示尚未拉取 */
|
||||
let badgesFetchedAt = 0;
|
||||
/** 进行中的 badges 请求 Promise,用于并发调用合并为单次 HTTP */
|
||||
let badgesInFlight: Promise<void> | null = null;
|
||||
|
||||
const toggleSidebar = (): void => {
|
||||
sidebarCollapsed.value = !sidebarCollapsed.value;
|
||||
};
|
||||
|
||||
const setBadgeCounts = (approvals: number, requests: number): void => {
|
||||
pendingApprovalsCount.value = approvals;
|
||||
pendingRequestsCount.value = requests;
|
||||
};
|
||||
|
||||
const badgeForModule = (moduleId: AdminModuleId): number | undefined => {
|
||||
if (moduleId === 'approvals' && pendingApprovalsCount.value > 0) return pendingApprovalsCount.value;
|
||||
if (moduleId === 'requests' && pendingRequestsCount.value > 0) return pendingRequestsCount.value;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* 拉取侧栏角标。force=false 时命中 TTL 缓存则跳过网络请求;
|
||||
* 多个组件同时调用时会共享同一 inFlight,避免重复打 /dashboard/badges。
|
||||
*/
|
||||
const fetchBadges = async (options?: { force?: boolean }): Promise<void> => {
|
||||
const force = options?.force ?? false;
|
||||
const now = Date.now();
|
||||
|
||||
// 非强制刷新且缓存未过期:直接返回 store 中已有计数
|
||||
if (!force && badgesFetchedAt > 0 && now - badgesFetchedAt < BADGE_CACHE_TTL_MS) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 已有请求在飞:等待同一 Promise,不再发起第二次请求
|
||||
if (badgesInFlight) {
|
||||
return badgesInFlight;
|
||||
}
|
||||
|
||||
badgesInFlight = (async () => {
|
||||
try {
|
||||
const data = await getAdminDashboardBadges();
|
||||
setBadgeCounts(data.pending_approvals, data.pending_requests);
|
||||
badgesFetchedAt = Date.now();
|
||||
} catch {
|
||||
setBadgeCounts(0, 0);
|
||||
} finally {
|
||||
badgesInFlight = null;
|
||||
}
|
||||
})();
|
||||
|
||||
return badgesInFlight;
|
||||
};
|
||||
|
||||
/** AdminLayout onMounted:有有效缓存则跳过请求 */
|
||||
const ensureBadges = (): Promise<void> => fetchBadges({ force: false });
|
||||
|
||||
/** 审批/驳回操作后:忽略缓存,立即重新拉取角标 */
|
||||
const refreshBadges = (): Promise<void> => fetchBadges({ force: true });
|
||||
|
||||
return {
|
||||
sidebarCollapsed,
|
||||
reportsExpanded,
|
||||
@@ -94,9 +32,6 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
pendingApprovalsCount,
|
||||
pendingRequestsCount,
|
||||
toggleSidebar,
|
||||
setBadgeCounts,
|
||||
badgeForModule,
|
||||
ensureBadges,
|
||||
refreshBadges,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
/**
|
||||
* features/admin/types/admin.types.ts
|
||||
* 管理后台域公共类型。
|
||||
* 绠$悊鍚庡彴鍩熷叕鍏辩被鍨嬨€?
|
||||
*/
|
||||
import type { FeaturePermissions } from '@/shared/utils/auth';
|
||||
|
||||
export type AdminModuleId =
|
||||
| 'dashboard'
|
||||
| 'approvals'
|
||||
| 'users'
|
||||
| 'departments'
|
||||
| 'agents'
|
||||
@@ -17,7 +16,6 @@ export type AdminModuleId =
|
||||
| 'wecom'
|
||||
| 'linked_services'
|
||||
| 'permissions'
|
||||
| 'requests'
|
||||
| 'platform_apps'
|
||||
| 'shipping_inventory'
|
||||
| 'procurement_contract'
|
||||
@@ -48,9 +46,10 @@ export type AdminReportTableId =
|
||||
| 'users'
|
||||
| 'agents'
|
||||
| 'chat_logs'
|
||||
| 'permission_requests'
|
||||
| 'general_feedbacks'
|
||||
| 'feedbacks';
|
||||
| 'feedbacks'
|
||||
| 'ops_overview'
|
||||
| 'issue_analysis';
|
||||
|
||||
export interface AdminUserRow {
|
||||
id: number;
|
||||
@@ -72,6 +71,22 @@ export interface AdminDepartmentRow {
|
||||
code?: string;
|
||||
company?: string;
|
||||
description?: string;
|
||||
member_count?: number;
|
||||
}
|
||||
|
||||
export interface AdminDepartmentMember {
|
||||
id: number;
|
||||
username: string;
|
||||
real_name?: string;
|
||||
employee_id?: string;
|
||||
email?: string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface AdminDepartmentMembersResponse {
|
||||
department: AdminDepartmentRow;
|
||||
count: number;
|
||||
members: AdminDepartmentMember[];
|
||||
}
|
||||
|
||||
export interface AdminAgentOption {
|
||||
@@ -87,3 +102,4 @@ export interface AdminAnnouncementRow {
|
||||
content: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,6 @@ export interface AdminDashboardSummary {
|
||||
avg_score: number;
|
||||
}
|
||||
|
||||
/** GET /api/admin/dashboard/badges — 侧栏「用户审批」「权限申请」角标 */
|
||||
export interface AdminDashboardBadges {
|
||||
pending_approvals: number;
|
||||
pending_requests: number;
|
||||
}
|
||||
|
||||
export interface AdminUsageReport {
|
||||
total: number;
|
||||
by_user: { username: string; count: number }[];
|
||||
|
||||
@@ -8,6 +8,19 @@
|
||||
/** 使用分析时间范围(与后端 USAGE_RANGE_DAYS 一致) */
|
||||
export type UsageRangeKey = '7d' | '30d' | '90d' | '180d' | '365d';
|
||||
|
||||
/** 「用户反馈与回答评价」页内 Tab:general=意见反馈(general_feedbacks),rating=回答评价(feedbacks) */
|
||||
export type ReportFeedbackTab = 'general' | 'rating';
|
||||
|
||||
/** 工作日 x 时段热力图数据 */
|
||||
export interface UsageHourHeatmap {
|
||||
/** 纵轴一周日序号(ISO:1=周一 .. 7=周日) */
|
||||
weekdays: number[];
|
||||
/** 横轴小时(0-23) */
|
||||
hours: number[];
|
||||
/** 单元格矩阵:cells[weekdayIndex][hourIndex] = 该日该时段对话量 */
|
||||
cells: number[][];
|
||||
}
|
||||
|
||||
export interface UsageReport {
|
||||
total: number;
|
||||
/** 当前统计时间范围 */
|
||||
@@ -16,6 +29,10 @@ export interface UsageReport {
|
||||
by_agent: { agent: string; count: number }[];
|
||||
/** 当前范围内按自然日聚合的对话趋势,用于使用分析柱状图。 */
|
||||
by_day?: { date: string; count: number }[];
|
||||
/** 人员/部门排行:按部门聚合对话量与去重用户数 */
|
||||
by_department?: { department: string; chat_count: number; user_count: number }[];
|
||||
/** 工作日 x 时段热力图:横轴=小时,纵轴=工作日(周一..周五),格子颜色深浅=该日该时段对话量 */
|
||||
hour_heatmap?: UsageHourHeatmap;
|
||||
/**
|
||||
* 运营提醒:启用应用中范围内对话次数 ≤ low_agent_max_chats 的列表(含零使用)。
|
||||
* 由后端以 Agent 主表左连接统计,与应用运营「零使用」口径对齐。
|
||||
@@ -35,8 +52,8 @@ export interface UsageReport {
|
||||
/** 应用运营报表:启用状态筛选 */
|
||||
export type ApplicationStatusFilter = 'all' | 'active' | 'inactive';
|
||||
|
||||
/** 应用运营报表:是否有使用筛选 */
|
||||
export type ApplicationUsageFilter = 'all' | 'used' | 'unused';
|
||||
/** 应用运营报表:是否有使用筛选(unused_authorized=已授权未使用) */
|
||||
export type ApplicationUsageFilter = 'all' | 'used' | 'unused' | 'unused_authorized';
|
||||
|
||||
/** 应用运营报表可排序字段 */
|
||||
export type ApplicationSortKey =
|
||||
@@ -58,11 +75,12 @@ export interface ApplicationReportItem {
|
||||
last_active_at: string | null;
|
||||
authorized_users: number;
|
||||
/** 后端仍返回;应用运营页已不再展示待审列 */
|
||||
pending_requests?: number;
|
||||
avg_score: number | null;
|
||||
feedback_count: number;
|
||||
tokens_used: number;
|
||||
avg_latency_ms: number | null;
|
||||
/** 「已授权未使用」:已授权给用户但范围内无对话 */
|
||||
authorized_unused?: boolean;
|
||||
}
|
||||
|
||||
export interface ApplicationReportSummary {
|
||||
@@ -72,6 +90,8 @@ export interface ApplicationReportSummary {
|
||||
unused_agents: number;
|
||||
/** 后端仍返回;应用运营页已不再展示待审摘要卡 */
|
||||
pending_permission_total?: number;
|
||||
/** 「已授权未使用」应用数量 */
|
||||
authorized_unused_count?: number;
|
||||
}
|
||||
|
||||
export interface ApplicationReport {
|
||||
@@ -108,3 +128,40 @@ export interface SortRule {
|
||||
key: string;
|
||||
direction: SortDirection;
|
||||
}
|
||||
|
||||
/** 运营总览 KPI 卡片指标 */
|
||||
export interface OpsOverviewKpi {
|
||||
total_chats: number;
|
||||
active_users: number;
|
||||
active_agents: number;
|
||||
/** 待跟进反馈数量(status=pending 的通用意见反馈,与反馈页「待处理」一致) */
|
||||
pending_feedback: number;
|
||||
}
|
||||
|
||||
/** 运营总览:对话趋势与环比 */
|
||||
export interface OpsOverviewTrend {
|
||||
by_day: { date: string; count: number }[];
|
||||
total: number;
|
||||
prev_total: number;
|
||||
/** 环比变化百分数;无上一周期数据时为 null */
|
||||
change_pct: number | null;
|
||||
range_days: number;
|
||||
}
|
||||
|
||||
/** 运营总览:Top / 低使用应用项 */
|
||||
export interface OpsOverviewApp {
|
||||
agent_id: number;
|
||||
name: string;
|
||||
chat_count: number;
|
||||
unique_users: number;
|
||||
avg_score: number | null;
|
||||
authorized_users?: number;
|
||||
}
|
||||
|
||||
export interface OpsOverviewReport {
|
||||
range: UsageRangeKey;
|
||||
kpi: OpsOverviewKpi;
|
||||
trend: OpsOverviewTrend;
|
||||
top_apps: OpsOverviewApp[];
|
||||
low_use_apps: OpsOverviewApp[];
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* features/admin/types/request.types.ts
|
||||
* 权限申请管理类型。
|
||||
*/
|
||||
|
||||
export interface AdminPermissionRequestRow {
|
||||
id: number;
|
||||
user_id: number;
|
||||
agent_id: number;
|
||||
reason: string;
|
||||
status: string;
|
||||
created_at: string;
|
||||
reviewed_at?: string | null;
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
/**
|
||||
* features/admin/views/AdminLayout.vue
|
||||
* 管理后台壳层:顶栏 + AdminNav + 子路由出口。
|
||||
* 角标仅在 Layout 首次挂载时 ensureBadges(store 内 60s TTL 缓存)。
|
||||
* 逻辑:桌面端将导航与业务内容拆成独立纵向滚动区,任一侧滚动不会带动另一侧。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { ArrowLeft } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
@@ -16,15 +15,11 @@ const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const navStore = useAdminNavStore();
|
||||
|
||||
// 进入 /admin 时拉一次角标;切换子路由不重复挂载 Layout,故不会重复请求
|
||||
onMounted(() => {
|
||||
void navStore.ensureBadges();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-shell min-h-screen font-sans flex flex-col">
|
||||
<header class="app-header px-6">
|
||||
<div class="page-shell flex h-dvh min-h-screen flex-col overflow-hidden font-sans">
|
||||
<header class="app-header shrink-0 px-6">
|
||||
<div class="flex items-center gap-4">
|
||||
<button type="button" class="btn-icon-ds md:block hidden" @click="navStore.toggleSidebar()">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/></svg>
|
||||
@@ -42,9 +37,11 @@ onMounted(() => {
|
||||
<AppHeaderTools />
|
||||
</header>
|
||||
|
||||
<main class="flex-1 w-full mx-auto px-4 md:px-8 py-6 md:py-8 flex flex-col md:flex-row gap-8 items-start">
|
||||
<AdminNav />
|
||||
<section class="flex-1 min-w-0 space-y-8 w-full">
|
||||
<main class="flex min-h-0 flex-1 w-full mx-auto flex-col gap-8 overflow-hidden px-4 py-6 md:flex-row md:items-stretch md:px-8 md:py-8">
|
||||
<aside class="min-h-0 shrink-0 overflow-y-auto md:pr-1">
|
||||
<AdminNav />
|
||||
</aside>
|
||||
<section class="min-h-0 w-full flex-1 space-y-8 overflow-y-auto md:pr-1">
|
||||
<router-view />
|
||||
</section>
|
||||
</main>
|
||||
|
||||
@@ -41,8 +41,13 @@ export function useChatScroll(options: UseChatScrollOptions) {
|
||||
|
||||
const stopContainerWatch = watch(container, syncScrollListener, { immediate: true });
|
||||
|
||||
/**
|
||||
* 判断是否显示“回到最新消息”按钮。
|
||||
* 核心逻辑:只要用户离开底部就提供入口;流式回复只有两条消息时同样需要可恢复跟随。
|
||||
* @returns 用户是否正在查看历史内容。
|
||||
*/
|
||||
const showScrollToBottom = computed(() =>
|
||||
messages.value.length >= 4 && !isNearBottom.value,
|
||||
messages.value.length > 0 && !isNearBottom.value,
|
||||
);
|
||||
|
||||
const scrollToBottom = async () => {
|
||||
@@ -118,9 +123,15 @@ export function useChatScroll(options: UseChatScrollOptions) {
|
||||
stopContainerWatch();
|
||||
};
|
||||
|
||||
/** 消息/思考态变化时自动滚动(思考结束滚到用户问题,否则贴底) */
|
||||
/**
|
||||
* 监听流式消息与会话状态,决定是否继续贴底跟随。
|
||||
* 核心逻辑:用户在底部时显示最新生成内容;用户手动向上阅读后停止自动滚动,
|
||||
* 直到其主动点击“回到最新消息”。
|
||||
* @param isThinking - 当前回复是否仍在生成,用于纳入监听依赖。
|
||||
* @param conversationId - 当前会话标识,用于在切换会话后重新评估滚动状态。
|
||||
* @returns 无返回值;监听会在 composable 卸载时自动清理。
|
||||
*/
|
||||
const setupThinkingScrollWatch = (isThinking: Ref<boolean>, conversationId?: Ref<string | null>) => {
|
||||
let wasThinking = false;
|
||||
watch(
|
||||
() => ({
|
||||
messageCount: messages.value.length,
|
||||
@@ -130,14 +141,14 @@ export function useChatScroll(options: UseChatScrollOptions) {
|
||||
conversationId: conversationId?.value || '',
|
||||
}),
|
||||
() => {
|
||||
if (wasThinking && !isThinking.value) {
|
||||
wasThinking = false;
|
||||
void scrollToUserQuestion();
|
||||
} else {
|
||||
if (isThinking.value) wasThinking = true;
|
||||
if (isNearBottom.value) scheduleScrollToBottom();
|
||||
else window.requestAnimationFrame(updateNearBottomState);
|
||||
// [STEP 1] 用户停留在底部时随新内容向下滚动;离开底部后保留阅读位置。
|
||||
if (isNearBottom.value) {
|
||||
scheduleScrollToBottom();
|
||||
return;
|
||||
}
|
||||
|
||||
// [STEP 2] 内容高度变化可能使“接近底部”状态恢复,重新计算但不主动移动视口。
|
||||
window.requestAnimationFrame(updateNearBottomState);
|
||||
},
|
||||
{ deep: false },
|
||||
);
|
||||
|
||||
@@ -12,6 +12,12 @@ describe('isStrongLeaveIntent', () => {
|
||||
// 断言:规则咨询不应触发本地请假表单,应继续走 Dify 问答。
|
||||
expect(isStrongLeaveIntent('年假可以按照小时请假吗?')).toBe(false);
|
||||
expect(isStrongLeaveIntent('怎么请年假?年假可以按照小时请假吗?')).toBe(false);
|
||||
// 断言:扣薪/薪资计算属于知识库制度问答,不应弹出请假申请表单。
|
||||
expect(isStrongLeaveIntent('请假扣多少薪资')).toBe(false);
|
||||
expect(isStrongLeaveIntent('请假如何扣除薪资')).toBe(false);
|
||||
expect(isStrongLeaveIntent('请病假怎么扣钱')).toBe(false);
|
||||
expect(isStrongLeaveIntent('请假扣多少钱,计算公式是什么')).toBe(false);
|
||||
expect(isStrongLeaveIntent('薪资福利中的请假扣款怎么算')).toBe(false);
|
||||
});
|
||||
|
||||
it('保留强请假意图触发表单', () => {
|
||||
|
||||
@@ -140,6 +140,10 @@ export function getLeaveIntentNormalized(content: string): string {
|
||||
/** 区分「真请假」与「咨询流程/材料」类弱意图 */
|
||||
export function isStrongLeaveIntent(content: string): boolean {
|
||||
const normalized = getLeaveIntentNormalized(content);
|
||||
// [STEP 1] 薪资/扣薪属于制度计算问答,必须交给 Dify/FAQ,不能被“请假”关键词抢先拦截为申请表单。
|
||||
// [PROMPT_UPDATE] 保留知识库中的计算公式、适用条件和口径,由知识库回答而非前端自行生成。
|
||||
const leaveSalaryConsultationIntent = /(请假|休假|年假|事假|病假).{0,12}(薪资|工资|薪酬|扣薪|扣钱|扣款|扣除|多少钱|福利|计算|公式)|(?:薪资|工资|薪酬|扣薪|扣钱|扣款|扣除|多少钱|福利|计算公式).{0,12}(请假|休假|年假|事假|病假)/;
|
||||
if (leaveSalaryConsultationIntent.test(normalized)) return false;
|
||||
const weakConsultationIntent = /(请假流程|请假怎么走|请假步骤|请假如何申请|请假如何走流程|请假怎么办|请假需要什么|请假规定|请假管理办法|请假制度)/;
|
||||
const weakLeaveQuestionIntent = /((怎么|如何).{0,8}(请假|请年假|休假|休年假|年假)|(请假|年假|休假).{0,12}(可以|可否|能否|是否|支持).{0,8}(按小时|按照小时|小时请|小时休))/;
|
||||
const materialConsultationIntent = /(提交哪些|提交什么|需要哪些|需要什么|要提交哪些|要提交什么|哪些资料|哪些材料|什么资料|什么材料|申请材料|所需资料|所需材料)/;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/kb/components/KbAdminPanel.vue
|
||||
* 知识库配置面板(治理面:分组、Dify、任务队列)。
|
||||
* 知识库配置面板(治理面:分组、Dify)。
|
||||
* 依赖:kb.api、DifySettingsDialog、DifyHealthDialog、DeleteConfirmDialog、Vue I18n。
|
||||
* 逻辑:管理控制台加载知识库分组与任务队列;分组列表在主表格过滤排序,新增/编辑通过右侧抽屉提交。
|
||||
* 逻辑:管理控制台加载知识库分组;分组列表在主表格过滤排序,新增/编辑通过右侧抽屉提交。
|
||||
*/
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
Wrench,
|
||||
} from 'lucide-vue-next';
|
||||
import KbGroupDrawer, { type KbGroupFormValue } from './KbGroupDrawer.vue';
|
||||
import KbJobQueuePanel from './KbJobQueuePanel.vue';
|
||||
import DifyHealthDialog from './DifyHealthDialog.vue';
|
||||
import DifySettingsDialog from './DifySettingsDialog.vue';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
@@ -30,11 +29,8 @@ import {
|
||||
createKbGroup,
|
||||
deleteKbGroup,
|
||||
getKbGroupsSafe,
|
||||
getKbJobsSafe,
|
||||
runKbJob,
|
||||
updateKbGroup,
|
||||
type KbGroup,
|
||||
type KbJob,
|
||||
} from '../api/kb.api';
|
||||
import { formatDateTime } from '../utils/kb-display.utils';
|
||||
|
||||
@@ -45,7 +41,6 @@ const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
|
||||
const groups = ref<KbGroup[]>([]);
|
||||
const jobs = ref<KbJob[]>([]);
|
||||
const isSubmitting = ref(false);
|
||||
const isDeleting = ref(false);
|
||||
const isRefreshing = ref(false);
|
||||
@@ -53,7 +48,6 @@ const editingGroupId = ref<number | null>(null);
|
||||
const form = ref<KbGroupFormValue>({ name: '', description: '' });
|
||||
const feedback = ref('');
|
||||
const feedbackType = ref<'success' | 'error' | ''>('');
|
||||
const runningJobId = ref<number | string | null>(null);
|
||||
const settingsDialogOpen = ref(false);
|
||||
const healthDialogOpen = ref(false);
|
||||
const deleteDialogOpen = ref(false);
|
||||
@@ -103,20 +97,15 @@ const pagedGroups = computed(() => {
|
||||
/** 格式化分组更新时间,避免管理台表格直接暴露后端 ISO 时间字符串。 */
|
||||
const formatGroupUpdatedAt = (value?: string | null) => formatDateTime(value);
|
||||
|
||||
/** 加载知识库治理页的分组与任务队列,供页面初始渲染和操作后刷新复用。 */
|
||||
/** 加载知识库治理页的分组数据,供页面初始渲染和操作后刷新复用。 */
|
||||
const loadData = async () => {
|
||||
isRefreshing.value = true;
|
||||
const [groupsResult, jobsResult] = await Promise.all([getKbGroupsSafe(), getKbJobsSafe()]);
|
||||
const groupsResult = await getKbGroupsSafe();
|
||||
if (groupsResult.ok) groups.value = groupsResult.data;
|
||||
else {
|
||||
feedback.value = groupsResult.error || t('kbAdmin.msg.loadGroupsFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
if (jobsResult.ok) jobs.value = jobsResult.data;
|
||||
else {
|
||||
feedback.value = jobsResult.error || t('kbAdmin.msg.loadJobsFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
isRefreshing.value = false;
|
||||
};
|
||||
|
||||
@@ -199,23 +188,6 @@ const handleDeleteGroupConfirm = async () => {
|
||||
await loadData();
|
||||
};
|
||||
|
||||
/** 手动执行可重试的知识库任务,并将后端执行结果反馈到页面提示区。 */
|
||||
const handleRunJob = async (job: KbJob) => {
|
||||
runningJobId.value = job.id;
|
||||
const result = await runKbJob(job.id);
|
||||
runningJobId.value = null;
|
||||
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || t('kbAdmin.msg.runFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = result.run_result || t('kbAdmin.msg.runDone');
|
||||
feedbackType.value = 'success';
|
||||
await loadData();
|
||||
};
|
||||
|
||||
watch([searchKeyword, filterMode, sortMode, pageSize], () => {
|
||||
currentPage.value = 1;
|
||||
});
|
||||
@@ -362,11 +334,6 @@ defineExpose({ loadData });
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<KbJobQueuePanel
|
||||
:jobs="jobs"
|
||||
:running-job-id="runningJobId"
|
||||
@run-job="handleRunJob"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -10,6 +10,15 @@ import { storeToRefs } from 'pinia';
|
||||
import { ExternalLink } from 'lucide-vue-next';
|
||||
import { useLinkedNavStore } from '../stores/linked-nav.store';
|
||||
|
||||
/**
|
||||
* 判断关联入口是否为图纸标注。
|
||||
* 图纸标注入口使用产品提供的尺规图标,其余入口继续使用统一的外链图标。
|
||||
*/
|
||||
function isDrawingAnnotationEntry(displayName: string): boolean {
|
||||
const normalized = String(displayName || '').trim();
|
||||
return normalized.includes('图纸标注') || normalized.includes('标注');
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
compact?: boolean;
|
||||
showLabel?: boolean;
|
||||
@@ -56,7 +65,13 @@ onMounted(() => {
|
||||
:title="entry.display_name"
|
||||
@click="linkedNav.openItem(entry)"
|
||||
>
|
||||
<ExternalLink :class="resolvedIconClass" />
|
||||
<img
|
||||
v-if="isDrawingAnnotationEntry(entry.display_name)"
|
||||
src="/icons/drawing-annotation.png"
|
||||
alt=""
|
||||
:class="[resolvedIconClass, 'object-contain']"
|
||||
/>
|
||||
<ExternalLink v-else :class="resolvedIconClass" />
|
||||
<span v-if="showLabel && !compact" class="truncate">{{ entry.display_name }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
User, Mail, Building, CreditCard, Globe, Save, Palette,
|
||||
} from 'lucide-vue-next';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import { WORKSPACE_KEY } from '@/features/workspace/composables/workspace.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -20,14 +21,6 @@ const fieldValueClass = 'flex min-h-11 items-center rounded-xl border border-def
|
||||
/** 表单标签:与分区标题区分层级,全页统一 14px。 */
|
||||
const fieldLabelClass = 'mb-1.5 flex items-center gap-1.5 text-sm font-medium text-muted';
|
||||
|
||||
/**
|
||||
* 头像字母:取姓名或用户名首字,供身份卡展示。
|
||||
*/
|
||||
const avatarLetter = computed(() => {
|
||||
const source = userProfile.profileUser.real_name || userProfile.profileUser.username || 'U';
|
||||
return source.charAt(0).toUpperCase();
|
||||
});
|
||||
|
||||
/**
|
||||
* 身份主标题:优先真实姓名,缺失时回退用户名。
|
||||
*/
|
||||
@@ -66,7 +59,7 @@ const identityMeta = computed(() => {
|
||||
<div
|
||||
class="flex h-14 w-14 shrink-0 items-center justify-center rounded-full bg-brand-100 text-xl font-semibold text-brand-600 md:h-16 md:w-16 md:text-2xl"
|
||||
>
|
||||
{{ avatarLetter }}
|
||||
{{ getUserAvatarLabel(userProfile.profileUser) }}
|
||||
</div>
|
||||
<div class="min-w-0 space-y-0.5">
|
||||
<div class="truncate text-lg font-semibold text-primary">{{ displayName }}</div>
|
||||
|
||||
Reference in new issue
Block a user