!20 Merge branch 'dev' into snow

Merge pull request !20 from 王瑞雪/snow
This commit is contained in:
sophie authored and Gitee committed 2026-09-29 05:13:46 +00:00
commit 2065b73610
56 files changed
+4501 -1110

No files matched your search

+9 -31
View File
@@ -1,8 +1,8 @@
/**
/**
* app/router/routes/admin.routes.ts
* 管理后台嵌套路由;全部 admin 模块已独立拆分。
* 依赖:vue-router;meta.title 存 i18n key(如 admin.nav.*),由 guards 解析为 document.title。
* 逻辑:AdminLayout 嵌套各管理页;企微为三级子路由。
* 绠$悊鍚庡彴宓屽璺敱锛涘叏閮?admin 妯″潡宸茬嫭绔嬫媶鍒嗐€?
* 渚濊禆锛歷ue-router锛沵eta.title 瀛?i18n key锛堝 admin.nav.*锛夛紝鐢?guards 瑙f瀽涓?document.title銆?
* 閫昏緫锛欰dminLayout 宓屽鍚勭鐞嗛〉锛涗紒寰负涓夌骇瀛愯矾鐢便€?
*/
import type { RouteRecordRaw } from "vue-router";
@@ -17,18 +17,12 @@ const UsersPage = () => import("@/features/admin/modules/users/UsersPage.vue");
const DepartmentsPage = () =>
import("@/features/admin/modules/departments/DepartmentsPage.vue");
const ApprovalsPage = () =>
import("@/features/admin/modules/approvals/ApprovalsPage.vue");
const AnnouncementsPage = () =>
import("@/features/admin/modules/announcements/AnnouncementsPage.vue");
const QuestionsPage = () =>
import("@/features/admin/modules/questions/QuestionsPage.vue");
const RequestsPage = () =>
import("@/features/admin/modules/requests/RequestsPage.vue");
const PermissionsPage = () =>
import("@/features/admin/modules/permissions/PermissionsPage.vue");
const PlatformAppsPage = () =>
@@ -148,17 +142,7 @@ export const adminRoutes: RouteRecordRaw[] = [
component: WecomAuditsPage,
meta: { requiresAdmin: true, adminModule: "wecom", title: "admin.wecom.nav.auditsPage" },
},
],
},
{
path: "approvals",
name: "AdminApprovals",
component: ApprovalsPage,
meta: {
requiresAdmin: true,
adminModule: "approvals",
title: "admin.nav.approvals",
},
],
},
{
path: "agents",
@@ -307,16 +291,6 @@ export const adminRoutes: RouteRecordRaw[] = [
title: "admin.nav.linkedServices",
},
},
{
path: "requests",
name: "AdminRequests",
component: RequestsPage,
meta: {
requiresAdmin: true,
adminModule: "requests",
title: "admin.nav.requests",
},
},
{
path: "permissions",
name: "AdminPermissions",
@@ -376,3 +350,7 @@ export const adminRoutes: RouteRecordRaw[] = [
],
},
];
+17 -15
View File
@@ -1,11 +1,11 @@
/**
* config.ts
* 用途:前端应用级开关与默认配置(登录模式、工作台模块、管理模块可见性)。
* 依赖:无运行时依赖;应用标题通过 common.app.title i18n key 解析。
* 逻辑:main.ts / router guards 使用 i18n.t(config.appTitleKey) 设置 document.title。
* 鐢ㄩ€旓細鍓嶇搴旂敤绾у紑鍏充笌榛樿閰嶇疆锛堢櫥褰曟ā寮忋€佸伐浣滃彴妯″潡銆佺鐞嗘ā鍧楀彲瑙佹€э級銆?
* 渚濊禆锛氭棤杩愯鏃朵緷璧栵紱搴旂敤鏍囬閫氳繃 common.app.title i18n key 瑙f瀽銆?
* 閫昏緫锛歮ain.ts / router guards 浣跨敤 i18n.t(config.appTitleKey) 璁剧疆 document.title銆?
*/
export const config = {
/** Browser title base name — resolve via i18n `t(config.appTitleKey)`. */
/** Browser title base name 鈥?resolve via i18n `t(config.appTitleKey)`. */
appTitleKey: 'common.app.title',
auth: {
// Login mode switch:
@@ -19,7 +19,7 @@ export const config = {
passwordLoginApi: '/api/user/casdoor/password-login',
refreshApi: '/api/user/casdoor/refresh',
callbackPath: '/casdoor-callback',
// Casdoor Provider「Name」字段须一致(当前 IdP:wecom)。留空则仅用后端 CASDOOR_WECOM_PROVIDER_HINT。
// Casdoor Provider銆孨ame銆嶅瓧娈甸』涓€鑷达紙褰撳墠 IdP锛歸ecom锛夈€傜暀绌哄垯浠呯敤鍚庣 CASDOOR_WECOM_PROVIDER_HINT銆?
wecomProviderHint: 'wecom',
},
wecom: {
@@ -35,15 +35,15 @@ export const config = {
}
},
workspace: {
// true 显示评分区;false 隐藏评分区
// true 鏄剧ず璇勫垎鍖猴紱false 闅愯棌璇勫垎鍖?
showChatRating: true,
// 聊天窗口“源文件展示”开关配置
// 鑱婂ぉ绐楀彛鈥滄簮鏂囦欢灞曠ず鈥濆紑鍏抽厤缃?
sourceFiles: {
// 是否显示源文件区域(包含上方文件按钮 + 下方“源文档”详情)
// 鏄惁鏄剧ず婧愭枃浠跺尯鍩燂紙鍖呭惈涓婃柟鏂囦欢鎸夐挳 + 涓嬫柟鈥滄簮鏂囨。鈥濊鎯咃級
showSourceFiles: true,
// 是否显示 MD 源文件(文件名后缀为 .md/.markdown)
// 鏄惁鏄剧ず MD 婧愭枃浠讹紙鏂囦欢鍚嶅悗缂€涓?.md/.markdown锛?
showMdFiles: false,
// 当 showMdFiles=true 时,MD 源文件是否默认展开“源文档”详情
// 褰?showMdFiles=true 鏃讹紝MD 婧愭枃浠舵槸鍚﹂粯璁ゅ睍寮€鈥滄簮鏂囨。鈥濊鎯?
expandMdByDefault: false,
},
modules: {
@@ -57,20 +57,19 @@ export const config = {
admin: {
modules: {
dashboard: true, // 仪表盘
approvals: true, // 用户审批
users: true, // 用户管理
departments: true, // 部门管理
agents: true, // 应用管理
knowledge_base: true, // 知识库管理
announcements: true, // 公告管理
questions: true, // 常用问题
wecom: true, // 企业微信
linked_services: true, // 关联服务(侧栏跳转入口)
permissions: true, // 应用权限
platform_apps: true, // 平台应用说明
requests: true, // 审批权限
reports: true, // 数据报表
requests: false, // 权限审批功能已移除
reports: true, //数据报表
schedules: true, // 定时任务
wecom: true, // 企业微信
linked_services: true, // 关联服务(侧栏跳转入口)
shipping_inventory: true, // 货代配置
procurement_contract: true, // 采购合同审查(模板库 + 历史)
training_config: true,
@@ -78,3 +77,6 @@ export const config = {
}
}
};
+75 -15
View File
@@ -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"
@@ -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>
+174 -12
View File
@@ -1239,12 +1239,15 @@
"name": "Name",
"code": "Code",
"company": "Company",
"members": "Members",
"actions": "Actions"
},
"actions": {
"edit": "Edit",
"delete": "Delete"
"delete": "Delete",
"viewMembers": "View department members"
},
"members": { "title": "{name} Members", "count": "{count} members", "empty": "No members" },
"fields": {
"name": "Name",
"namePlaceholder": "e.g. IT Department",
@@ -1904,6 +1907,8 @@
"filterName": "Filter by Name/Username",
"filterDept": "Filter by Department",
"allRoles": "All Roles",
"views": { "apps": "By Application", "members": "By Member" },
"appHeaders": { "app": "Application", "type": "Type", "authorized": "Authorized", "actions": "Actions", "viewMembers": "View members", "accessHint": "Open member permissions", "memberHint": "Add or remove access to this application", "memberSearch": "Search name, username, employee ID, or department", "addMember": "Grant access", "removeMember": "Remove access", "noMembers": "No matching members" },
"headers": {
"user": "User",
"realName": "Real Name",
@@ -1946,6 +1951,7 @@
"report": {
"title": "Data Reports: {table}",
"subtitle": "Operational analytics and detail tracing",
"currentFilterResults": "Current filter results: {total}",
"export": "Export Excel",
"columnSettings": "Column Settings",
"showSelection": "Show Selection",
@@ -1977,16 +1983,26 @@
"noData": "No data available for {table}",
"noFilterResults": "No matching rows. Adjust your filters.",
"usage": "Usage Analytics",
"usageRangeLabel": "Time range",
"usageRanges": {
"7d": "Last 7 days",
"30d": "Last 30 days",
"90d": "Last 3 months",
"180d": "Last 6 months",
"365d": "Last 12 months"
},
"dateFrom": "Start date",
"dateTo": "End date",
"byUser": "Requests by User",
"byAgent": "Requests by Agent",
"byDepartment": "Requests by Department",
"usageByDepartmentHint": "Chat volume and participating users aggregated by department",
"unknownDepartment": "Unassigned",
"usageByDepartmentEmpty": "No department chat activity yet",
"usageHourHeatmap": "Weekday × time-slot heatmap",
"usageHourHeatmapHint": "X-axis = time slot, Y-axis = weekday; cell shade = chat volume for that day and slot",
"usageHourHeatmapEmpty": "No time-slot heatmap data yet",
"weekdays": {
"Mon": "Mon",
"Tue": "Tue",
"Wed": "Wed",
"Thu": "Thu",
"Fri": "Fri",
"Sat": "Sat",
"Sun": "Sun"
},
"usageByUserTopHint": "Top {limit} users by chat volume",
"usageByUserEmpty": "No user chat activity yet",
"columns": {
@@ -2054,16 +2070,26 @@
"reset_token_expiry": "Reset Token Expiry",
"feedback_module": "Feedback Module",
"feedback_type": "Feedback Type",
"source_page": "Source Page"
"source_page": "Source Page",
"risk_status": "Risk Status",
"risk_score": "Risk Score",
"latency": "Latency (ms)",
"is_empty_answer": "Empty Answer",
"is_system_failure": "System Failure",
"feedback_score": "Rating",
"feedback_comment": "Rating Comment",
"negative_feedback_count": "Negative Feedback",
"actions": "Actions"
},
"tables": {
"users": "Users",
"chat_logs": "Chat Logs",
"general_feedbacks": "Feedback",
"feedbacks": "Answer Rating",
"feedbacks": "User Feedback & Answer Rating",
"departments": "Departments",
"agents": "App Ops",
"permission_requests": "Permission Requests",
"ops_overview": "Ops Overview",
"issue_analysis": "Issue Analysis",
"usage_analysis": "Usage Analytics"
},
"feedbackValues": {
@@ -2113,11 +2139,15 @@
"usageAll": "All",
"usageUsed": "Used",
"usageUnused": "Unused",
"usageAuthorizedUnused": "Authorized, unused",
"searchPlaceholder": "Search app name…",
"summaryActive": "Active apps",
"summaryTotal": "{total} total",
"summaryUsed": "Used",
"summaryUnused": "Unused",
"summaryAuthorizedUnused": "Authorized, unused",
"summaryAuthorizedUnusedHint": "Authorized but no chat in range",
"authorizedUnused": "Authorized, unused",
"summaryPending": "Pending permissions",
"empty": "No application ops data. Try adjusting filters.",
"actionLogs": "Logs",
@@ -2136,6 +2166,138 @@
"tokens_used": "Tokens",
"actions": "Actions"
}
},
"placeholder": "This module is under construction. Stay tuned.",
"feedback": {
"title": "User Feedback & Answer Rating",
"intro": "Review user-submitted feedback and answer-rating details, with filtering, export, and tracing.",
"tabs": {
"general": "General Feedback",
"rating": "Answer Rating"
},
"timeFrom": "From",
"timeTo": "To",
"typeLabel": "Feedback Type",
"sourceLabel": "Source Page",
"moduleLabel": "Feedback Module",
"allOption": "All",
"notLinked": "Not linked",
"viewChatLog": "View chat log",
"expand": "Expand",
"collapse": "Collapse",
"viewFullContent": "View full feedback content",
"markClosed": "Mark closed",
"closed": "Closed",
"closedOk": "Marked as closed",
"summary": {
"pending": "Pending",
"pendingHint": "Feedback to follow up",
"closed": "Closed this month",
"closedHint": "Closed in this month",
"topApp": "Most feedback app",
"topAppHint": "{count} related feedback"
}
},
"chatLog": {
"title": "Chat Log Detail",
"detail": "Detail",
"meta": {
"app": "Application",
"user": "User",
"createdAt": "Created at",
"chatLogId": "Chat Log ID",
"rating": "Rating",
"negativeFeedback": "Negative feedback"
},
"tops": {
"questions": "Top Questions",
"answers": "Top Answers",
"empty": "No stats yet"
},
"question": "User Question",
"answer": "Agent Answer",
"riskStatus": "Risk Status",
"riskScore": "Risk Score",
"reasons": "Triggered Reasons",
"checks": "Suggested Checks",
"noReason": "No risk rule triggered",
"noCheck": "No suggested check",
"close": "Close",
"risk": {
"attention": "Needs attention",
"review": "Pending manual review",
"responded": "Responded"
},
"reason": {
"empty_answer": "Empty answer",
"system_failure": "System failure",
"low_score": "Low rating",
"negative_feedback": "Negative feedback",
"duplicate": "Repeated question"
},
"check": {
"check_chain": "Check model, API, and tool chain",
"check_answer": "Manually spot-check the answer",
"check_kb": "Check knowledge base and material validity",
"check_key_info": "Check whether the answer missed key info",
"priority_review": "Prioritize manual review of this question"
},
"filters": {
"title": "Risk Filters",
"timeFrom": "From",
"timeTo": "To",
"appLabel": "Application",
"userLabel": "User",
"emptyAnswerLabel": "Empty answer",
"systemFailureLabel": "System failure",
"riskStatusLabel": "Risk status",
"scoreRangeLabel": "Rating range",
"minScore": "Min",
"maxScore": "Max",
"reset": "Reset filters",
"yes": "Yes",
"no": "No"
},
"detailPlaceholder": "No data"
},
"opsOverview": {
"title": "Ops Overview",
"intro": "Aggregate key operational metrics and app health for a holistic platform view.",
"empty": "No ops overview data yet",
"kpi": {
"totalChats": "Total chats",
"activeUsers": "Active users",
"activeAgents": "Active apps",
"pendingFollowup": "Feedback to follow up"
},
"trendTitle": "Chat trend & period-over-period",
"trendEmpty": "No trend data yet",
"topApps": "Top apps",
"lowUseApps": "Low-usage apps"
},
"issueAnalysis": {
"title": "Issue Analysis",
"intro": "Cluster high-frequency questions and attention/review signals from chat-log risk rules to spot areas to optimize.",
"empty": "No issue analysis data yet",
"priorityTitle": "Priority Issues",
"colTopic": "Question Topic",
"colCount": "Count",
"colApps": "Application",
"colAttention": "Needs attention",
"colReasons": "Reasons",
"colChecks": "Suggested Checks",
"kpi": {
"highFreq": "High-frequency clusters",
"highFreqHint": "Top 10 = {ratio}% of all questions",
"attention": "Needs attention",
"attentionHint": "Empty/system failure +3; low rating +3; negative feedback +2; repeated question +1",
"review": "Pending review",
"reviewHint": "Low-risk signal, suggest manual check",
"emptyAnswer": "Empty answers",
"emptyAnswerHint": "Check model output and API chain",
"topApp": "App to optimize",
"topAppHint": "Attention signal share {ratio}%"
}
}
},
"batchEdit": {
+170 -11
View File
@@ -1908,6 +1908,8 @@
"filterName": "กรองตามชื่อ/ชื่อผู้ใช้",
"filterDept": "กรองตามแผนก",
"allRoles": "ทุกบทบาท",
"views": { "apps": "ตามแอปพลิเคชัน", "members": "ตามสมาชิก" },
"appHeaders": { "app": "แอปพลิเคชัน", "type": "ประเภท", "authorized": "ผู้ได้รับอนุญาต", "actions": "การดำเนินการ", "viewMembers": "ดูสมาชิก", "accessHint": "เปิดสิทธิ์ของสมาชิก", "memberHint": "เพิ่มหรือลบสิทธิ์ของแอปนี้", "memberSearch": "ค้นหาชื่อ ชื่อผู้ใช้ รหัสพนักงาน หรือแผนก", "addMember": "มอบสิทธิ์", "removeMember": "ยกเลิกสิทธิ์", "noMembers": "ไม่พบสมาชิกที่ตรงกัน" },
"headers": {
"user": "ผู้ใช้",
"realName": "ชื่อจริง",
@@ -1950,6 +1952,7 @@
"report": {
"title": "รายงานข้อมูล: {table}",
"subtitle": "การวิเคราะห์การใช้งานและรายละเอียดย้อนหลัง",
"currentFilterResults": "ผลการกรองปัจจุบัน: {total}",
"export": "ส่งออก Excel",
"columnSettings": "ตั้งค่าคอลัมน์",
"showSelection": "แสดงการเลือก",
@@ -1981,16 +1984,26 @@
"noData": "ไม่มีข้อมูลสำหรับ {table}",
"noFilterResults": "ไม่พบข้อมูลที่ตรงกับเงื่อนไข โปรดปรับตัวกรอง",
"usage": "วิเคราะห์การใช้งาน",
"usageRangeLabel": "ช่วงเวลา",
"usageRanges": {
"7d": "7 วันล่าสุด",
"30d": "30 วันล่าสุด",
"90d": "3 เดือนล่าสุด",
"180d": "6 เดือนล่าสุด",
"365d": "12 เดือนล่าสุด"
},
"dateFrom": "วันเริ่มต้น",
"dateTo": "วันสิ้นสุด",
"byUser": "ตามผู้ใช้",
"byAgent": "ตามตัวแทน",
"byDepartment": "ตามแผนก",
"usageByDepartmentHint": "ปริมาณการสนทนาและจำนวนผู้ใช้ตามแผนก",
"unknownDepartment": "ไม่ระบุแผนก",
"usageByDepartmentEmpty": "ยังไม่มีบันทึกการสนทนาตามแผนก",
"usageHourHeatmap": "ฮีตแมปวันทำงาน ตามช่วงเวลา",
"usageHourHeatmapHint": "แกนนอน=ช่วงเวลา แกนตั้ง=วันทำงาน สีเข้มของช่อง=ปริมาณการสนทนาของวันและช่วงนั้น",
"usageHourHeatmapEmpty": "ยังไม่มีข้อมูลฮีตแมปตามช่วงเวลา",
"weekdays": {
"Mon": "จ.",
"Tue": "อ.",
"Wed": "พ.",
"Thu": "พฤ.",
"Fri": "ศ.",
"Sat": "ส.",
"Sun": "อา."
},
"usageByUserTopHint": "แสดงผู้ใช้ {limit} อันดับแรกตามปริมาณการสนทนา",
"usageByUserEmpty": "ยังไม่มีบันทึกการสนทนาของผู้ใช้",
"columns": {
@@ -2055,16 +2068,26 @@
"theme_preference": "ค่ากำหนดธีม",
"password_hash": "แฮชรหัสผ่าน",
"reset_token": "โทเค็นรีเซ็ต",
"reset_token_expiry": "เวลาหมดอายุโทเค็นรีเซ็ต"
"reset_token_expiry": "เวลาหมดอายุโทเค็นรีเซ็ต",
"risk_status": "สถานะความเสี่ยง",
"risk_score": "คะแนนความเสี่ยง",
"latency": "เวลาแฝง (ms)",
"is_empty_answer": "คำตอบว่าง",
"is_system_failure": "ระบบล้มเหลว",
"feedback_score": "คะแนน",
"feedback_comment": "หมายเหตุคะแนน",
"negative_feedback_count": "จำนวนข้อเสนอแนะเชิงลบ",
"actions": "การทำงาน"
},
"tables": {
"users": "ผู้ใช้",
"chat_logs": "บันทึกแชท",
"general_feedbacks": "ข้อเสนอแนะทั่วไป",
"feedbacks": "การประเมินคำตอบ",
"feedbacks": "ข้อเสนอแนะผู้ใช้และการประเมินคำตอบ",
"departments": "แผนก",
"agents": "แอปปฏิบัติการ",
"permission_requests": "คำขอสิทธิ์",
"ops_overview": "ภาพรวมการดำเนินงาน",
"issue_analysis": "การวิเคราะห์ปัญหา",
"usage_analysis": "วิเคราะห์การใช้งาน"
},
"usageIntro": "ดูแนวโน้มการเรียกใช้แอป AI ผู้ใช้ที่ใช้งาน แอปที่ใช้น้อย และช่วงพีคผิดปกติ",
@@ -2096,11 +2119,15 @@
"usageAll": "ทั้งหมด",
"usageUsed": "มีการใช้",
"usageUnused": "ไม่มีการใช้",
"usageAuthorizedUnused": "ได้รับสิทธิ์แต่ไม่ใช้งาน",
"searchPlaceholder": "ค้นหาชื่อแอป…",
"summaryActive": "แอปที่เปิดใช้",
"summaryTotal": "ทั้งหมด {total}",
"summaryUsed": "มีการใช้",
"summaryUnused": "ไม่มีการใช้",
"summaryAuthorizedUnused": "ได้รับสิทธิ์แต่ไม่ใช้งาน",
"summaryAuthorizedUnusedHint": "ได้รับสิทธิ์แต่ไม่มีแชทในช่วงที่เลือก",
"authorizedUnused": "ได้รับสิทธิ์แต่ไม่ใช้งาน",
"summaryPending": "สิทธิ์รอดำเนินการ",
"empty": "ไม่มีข้อมูลแอปปฏิบัติการ ลองปรับตัวกรอง",
"actionLogs": "บันทึก",
@@ -2119,6 +2146,138 @@
"tokens_used": "Token",
"actions": "การทำงาน"
}
},
"placeholder": "โมดูลนี้อยู่ระหว่างการพัฒนา โปรดรอติดตาม",
"feedback": {
"title": "ข้อเสนอแนะผู้ใช้และการประเมินคำตอบ",
"intro": "ดูรายละเอียดข้อเสนอแนะและการประเมินคำตอบจากผู้ใช้ รองรับการกรอง การส่งออก และการติดตามย้อนหลัง",
"tabs": {
"general": "ข้อเสนอแนะทั่วไป",
"rating": "การประเมินคำตอบ"
},
"timeFrom": "ตั้งแต่วันที่",
"timeTo": "ถึงวันที่",
"typeLabel": "ประเภทข้อเสนอแนะ",
"sourceLabel": "หน้าที่มา",
"moduleLabel": "โมดูลข้อเสนอแนะ",
"allOption": "ทั้งหมด",
"notLinked": "ไม่เชื่อมโยง",
"viewChatLog": "ดูบันทึกแชท",
"expand": "ขยาย",
"collapse": "ย่อ",
"viewFullContent": "ดูเนื้อหาข้อเสนอแนะทั้งหมด",
"markClosed": "ทำเครื่องหมายว่าปิดแล้ว",
"closed": "ปิดแล้ว",
"closedOk": "ทำเครื่องหมายว่าปิดแล้ว",
"summary": {
"pending": "รอดำเนินการ",
"pendingHint": "ข้อเสนอแนะรอติดตาม",
"closed": "ปิดแล้วเดือนนี้",
"closedHint": "จำนวนที่ปิดเดือนนี้",
"topApp": "แอปที่ได้รับข้อเสนอแนะมากสุด",
"topAppHint": "ข้อเสนอแนะที่เกี่ยวข้อง {count} รายการ"
}
},
"chatLog": {
"title": "รายละเอียดบันทึกแชท",
"detail": "รายละเอียด",
"meta": {
"app": "แอปพลิเคชัน",
"user": "ผู้ใช้",
"createdAt": "สร้างเมื่อ",
"chatLogId": "ID บันทึกแชท",
"rating": "คะแนน",
"negativeFeedback": "ข้อเสนอแนะเชิงลบ"
},
"tops": {
"questions": "คำถามยอดนิยม",
"answers": "คำตอบยอดนิยม",
"empty": "ยังไม่มีสถิติ"
},
"question": "คำถามผู้ใช้",
"answer": "คำตอบแอเจนต์",
"riskStatus": "สถานะความเสี่ยง",
"riskScore": "คะแนนความเสี่ยง",
"reasons": "เหตุผลที่ตัดสิน",
"checks": "รายการตรวจสอบที่แนะนำ",
"noReason": "ไม่พบกฎความเสี่ยง",
"noCheck": "ไม่มีรายการตรวจสอบที่แนะนำ",
"close": "ปิด",
"risk": {
"attention": "ต้องให้ความสนใจ",
"review": "รอตรวจสอบด้วยตนเอง",
"responded": "ตอบแล้ว"
},
"reason": {
"empty_answer": "คำตอบว่าง",
"system_failure": "ระบบล้มเหลว",
"low_score": "คะแนนต่ำ",
"negative_feedback": "ข้อเสนอแนะเชิงลบ",
"duplicate": "ถามซ้ำทั้งหมด"
},
"check": {
"check_chain": "ตรวจสอบโมเดล API และเครื่องมือ",
"check_answer": "สุ่มตรวจเนื้อหาคำตอบ",
"check_kb": "ตรวจสอบฐานความรู้และอายุเอกสาร",
"check_key_info": "ตรวจสอบว่าคำตอบขาดข้อมูลสำคัญ",
"priority_review": "ให้ตรวจสอบคำถามนี้ก่อน"
},
"filters": {
"title": "ตัวกรองความเสี่ยง",
"timeFrom": "ตั้งแต่วันที่",
"timeTo": "ถึงวันที่",
"appLabel": "แอปพลิเคชัน",
"userLabel": "ผู้ใช้",
"emptyAnswerLabel": "คำตอบว่าง",
"systemFailureLabel": "ระบบล้มเหลว",
"riskStatusLabel": "สถานะความเสี่ยง",
"scoreRangeLabel": "ช่วงคะแนน",
"minScore": "ขั้นต่ำ",
"maxScore": "สูงสุด",
"reset": "ล้างตัวกรอง",
"yes": "ใช่",
"no": "ไม่"
},
"detailPlaceholder": "ไม่มีข้อมูล"
},
"opsOverview": {
"title": "ภาพรวมการดำเนินงาน",
"intro": "รวบรวมเมตริกการดำเนินงานที่สำคัญและสุขภาพแอปพลิเคชันเพื่อภาพรวมของแพลตฟอร์ม",
"empty": "ยังไม่มีข้อมูลภาพรวมการดำเนินงาน",
"kpi": {
"totalChats": "จำนวนแชท",
"activeUsers": "ผู้ใช้ที่ใช้งาน",
"activeAgents": "แอปที่ใช้งาน",
"pendingFollowup": "ข้อเสนอแนะที่รอติดตาม"
},
"trendTitle": "แนวโน้มแชทและเทียบช่วงเวลา",
"trendEmpty": "ยังไม่มีข้อมูลแนวโน้ม",
"topApps": "แอปยอดนิยม",
"lowUseApps": "แอปที่ใช้น้อย"
},
"issueAnalysis": {
"title": "การวิเคราะห์ปัญหา",
"intro": "จัดกลุ่มคำถามยอดนิยมและสัญญาณที่ต้องให้ความสนใจ/รอตรวจสอบจากกฎความเสี่ยงของบันทึกแชท เพื่อหาพื้นที่ที่ควรปรับปรุง",
"empty": "ยังไม่มีข้อมูลการวิเคราะห์ปัญหา",
"priorityTitle": "ปัญหาที่ควรจัดการก่อน",
"colTopic": "หัวข้อคำถาม",
"colCount": "จำนวนครั้ง",
"colApps": "แอปพลิเคชันที่เกี่ยวข้อง",
"colAttention": "ต้องให้ความสนใจ",
"colReasons": "เหตุผล",
"colChecks": "รายการตรวจสอบที่แนะนำ",
"kpi": {
"highFreq": "กลุ่มคำถามยอดนิยม",
"highFreqHint": "Top 10 = {ratio}% ของคำถามทั้งหมด",
"attention": "ต้องให้ความสนใจ",
"attentionHint": "คำตอบว่าง/ระบบล้มเหลว +3; คะแนนต่ำ +3; ข้อเสนอแนะเชิงลบ +2; ถามซ้ำ +1",
"review": "รอตรวจสอบด้วยตนเอง",
"reviewHint": "สัญญาณความเสี่ยงต่ำ แนะนำตรวจด้วยตนเอง",
"emptyAnswer": "คำตอบว่าง",
"emptyAnswerHint": "ตรวจสอบผลลัพธ์โมเดลและ API",
"topApp": "แอปที่ควรปรับปรุง",
"topAppHint": "สัดส่วนสัญญาณที่ต้องให้ความสนใจ {ratio}%"
}
}
},
"batchEdit": {
+175 -13
View File
@@ -1373,12 +1373,15 @@
"name": "名称",
"code": "编码",
"company": "公司",
"members": "员工",
"actions": "操作"
},
"actions": {
"edit": "编辑",
"delete": "删除"
"delete": "删除",
"viewMembers": "查看部门员工"
},
"members": { "title": "{name}员工", "count": "共 {count} 人", "empty": "暂无员工" },
"fields": {
"name": "名称",
"namePlaceholder": "例如:信息技术部",
@@ -2037,6 +2040,8 @@
"filterName": "筛选 姓名/用户名",
"filterDept": "筛选 部门",
"allRoles": "所有角色",
"views": { "apps": "按应用查看", "members": "按成员查看" },
"appHeaders": { "app": "应用", "type": "类型", "authorized": "已授权人数", "actions": "操作", "viewMembers": "查看成员", "accessHint": "点击查看成员权限", "memberHint": "可添加或取消此应用的访问权限", "memberSearch": "搜索姓名、用户名、工号或部门", "addMember": "添加权限", "removeMember": "取消权限", "noMembers": "没有匹配的人员" },
"headers": {
"user": "用户",
"realName": "真实姓名",
@@ -2077,8 +2082,9 @@
"reject": "拒绝"
},
"report": {
"title": "数据报表: {table}",
"title": "数据报表:{table}",
"subtitle": "运营分析与明细追溯",
"currentFilterResults": "当前筛选结果:{total} 条",
"export": "导出 Excel",
"columnSettings": "列设置",
"showSelection": "显示选择",
@@ -2110,16 +2116,26 @@
"noData": "暂无数据: {table}",
"noFilterResults": "没有匹配的数据,请调整筛选条件",
"usage": "使用分析",
"usageRangeLabel": "统计范围",
"usageRanges": {
"7d": "近一周",
"30d": "近一月",
"90d": "近三月",
"180d": "近半年",
"365d": "近一年"
},
"dateFrom": "开始日期",
"dateTo": "结束日期",
"byUser": "按用户统计",
"byAgent": "按应用统计",
"byDepartment": "按部门统计",
"usageByDepartmentHint": "按部门聚合对话量与参与用户数",
"unknownDepartment": "未分组",
"usageByDepartmentEmpty": "暂无部门对话记录",
"usageHourHeatmap": "工作日与时段热力图",
"usageHourHeatmapHint": "横轴=时段,纵轴=工作日,格子颜色深浅=该日该时段对话量",
"usageHourHeatmapEmpty": "暂无时段热力图数据",
"weekdays": {
"Mon": "周一",
"Tue": "周二",
"Wed": "周三",
"Thu": "周四",
"Fri": "周五",
"Sat": "周六",
"Sun": "周日"
},
"usageByUserTopHint": "仅显示对话量前 {limit} 名用户",
"usageByUserEmpty": "暂无用户对话记录",
"columns": {
@@ -2184,16 +2200,26 @@
"theme_preference": "主题偏好",
"password_hash": "密码哈希",
"reset_token": "重置令牌",
"reset_token_expiry": "重置令牌过期时间"
"reset_token_expiry": "重置令牌过期时间",
"risk_status": "风险状态",
"risk_score": "风险分",
"latency": "耗时(毫秒)",
"is_empty_answer": "空回答",
"is_system_failure": "系统失败",
"feedback_score": "评分",
"feedback_comment": "评分备注",
"negative_feedback_count": "负面反馈数",
"actions": "操作"
},
"tables": {
"users": "用户",
"chat_logs": "聊天日志",
"general_feedbacks": "意见反馈",
"feedbacks": "回答评价",
"feedbacks": "用户反馈与回答评价",
"departments": "部门",
"agents": "应用运营",
"permission_requests": "权限申请",
"ops_overview": "运营总览",
"issue_analysis": "问题分析",
"usage_analysis": "使用分析"
},
"usageIntro": "查看 AI 应用调用趋势、活跃用户、低使用应用与异常高峰。",
@@ -2225,11 +2251,15 @@
"usageAll": "全部",
"usageUsed": "有使用",
"usageUnused": "零使用",
"usageAuthorizedUnused": "已授权未使用",
"searchPlaceholder": "搜索应用名称…",
"summaryActive": "启用应用",
"summaryTotal": "共 {total} 个",
"summaryUsed": "有使用",
"summaryUnused": "零使用",
"summaryAuthorizedUnused": "已授权未使用",
"summaryAuthorizedUnusedHint": "已授权但范围内无对话",
"authorizedUnused": "已授权未使用",
"summaryPending": "待审权限",
"empty": "暂无应用运营数据,请调整筛选条件",
"actionLogs": "日志",
@@ -2248,6 +2278,138 @@
"tokens_used": "Token",
"actions": "操作"
}
},
"placeholder": "该模块正在建设中,敬请期待",
"feedback": {
"title": "用户反馈与回答评价",
"intro": "查看用户提交的意见反馈与回答评分明细,支持筛选、导出和追溯。",
"tabs": {
"general": "意见反馈",
"rating": "回答评价"
},
"timeFrom": "开始日期",
"timeTo": "结束日期",
"typeLabel": "反馈类型",
"sourceLabel": "来源页面",
"moduleLabel": "反馈模块",
"allOption": "全部",
"notLinked": "未关联",
"viewChatLog": "查看聊天记录",
"expand": "展开",
"collapse": "收起",
"viewFullContent": "查看完整反馈内容",
"markClosed": "标记已关闭",
"closed": "已关闭",
"closedOk": "已标记关闭",
"summary": {
"pending": "待处理",
"pendingHint": "待跟进反馈",
"closed": "本月已关闭",
"closedHint": "本月关闭量",
"topApp": "最多反馈应用",
"topAppHint": "共 {count} 条相关反馈"
}
},
"chatLog": {
"title": "聊天日志详情",
"detail": "详情",
"meta": {
"app": "应用",
"user": "用户",
"createdAt": "创建时间",
"chatLogId": "聊天日志 ID",
"rating": "评分",
"negativeFeedback": "负面反馈"
},
"tops": {
"questions": "Top 提问内容",
"answers": "Top 回答内容",
"empty": "暂无统计"
},
"question": "用户提问",
"answer": "智能体回答",
"riskStatus": "风险状态",
"riskScore": "风险分数",
"reasons": "判定原因",
"checks": "建议检查项",
"noReason": "无命中风险规则",
"noCheck": "无建议检查项",
"close": "关闭",
"risk": {
"attention": "需要关注",
"review": "待人工抽查",
"responded": "已响应"
},
"reason": {
"empty_answer": "空回答",
"system_failure": "系统失败",
"low_score": "低评分",
"negative_feedback": "负面反馈",
"duplicate": "完全重复提问"
},
"check": {
"check_chain": "检查模型、接口、工具链路",
"check_answer": "人工抽查回答内容",
"check_kb": "检查知识库和资料有效期",
"check_key_info": "检查回答是否遗漏关键信息",
"priority_review": "优先人工复核该问题"
},
"filters": {
"title": "风险筛选",
"timeFrom": "开始日期",
"timeTo": "结束日期",
"appLabel": "应用",
"userLabel": "用户",
"emptyAnswerLabel": "是否空回答",
"systemFailureLabel": "是否系统失败",
"riskStatusLabel": "风险状态",
"scoreRangeLabel": "评分区间",
"minScore": "最低分",
"maxScore": "最高分",
"reset": "重置筛选",
"yes": "是",
"no": "否"
},
"detailPlaceholder": "暂无数据"
},
"opsOverview": {
"title": "运营总览",
"intro": "汇总关键运营指标与应用健康度,整体把握平台运行情况。",
"empty": "暂无运营总览数据",
"kpi": {
"totalChats": "对话量",
"activeUsers": "活跃用户",
"activeAgents": "活跃应用",
"pendingFollowup": "待跟进反馈"
},
"trendTitle": "对话趋势与环比",
"trendEmpty": "暂无趋势数据",
"topApps": "Top 应用",
"lowUseApps": "低使用应用"
},
"issueAnalysis": {
"title": "问题分析",
"intro": "基于聊天日志风险规则聚合高频问题与需要关注/待抽查信号,定位待优化问题。",
"empty": "暂无问题分析数据",
"priorityTitle": "优先处理问题",
"colTopic": "问题主题",
"colCount": "出现次数",
"colApps": "涉及应用",
"colAttention": "需要关注",
"colReasons": "判定原因",
"colChecks": "建议检查项",
"kpi": {
"highFreq": "高频问题簇",
"highFreqHint": "Top 10 占全部提问 {ratio}%",
"attention": "需要关注",
"attentionHint": "空回答/系统失败 +3;低评分 +3;负面反馈 +2;完全重复提问 +1",
"review": "待人工抽查",
"reviewHint": "低风险信号,建议人工抽查",
"emptyAnswer": "空回答",
"emptyAnswerHint": "检查模型返回和接口链路",
"topApp": "优先优化应用",
"topAppHint": "需要关注信号占比 {ratio}%"
}
}
},
"batchEdit": {
+171 -12
View File
@@ -1913,6 +1913,8 @@
"filterName": "篩選 姓名/用戶名",
"filterDept": "篩選 部門",
"allRoles": "所有角色",
"views": { "apps": "按應用查看", "members": "按成員查看" },
"appHeaders": { "app": "應用", "type": "類型", "authorized": "已授權人數", "actions": "操作", "viewMembers": "查看成員", "accessHint": "點擊查看成員權限", "memberHint": "可新增或取消此應用的存取權限", "memberSearch": "搜尋姓名、用戶名、工號或部門", "addMember": "新增權限", "removeMember": "取消權限", "noMembers": "沒有符合的成員" },
"headers": {
"user": "用戶",
"realName": "真實姓名",
@@ -1953,8 +1955,9 @@
"reject": "拒絕"
},
"report": {
"title": "資料報表: {table}",
"title": "資料報表:{table}",
"subtitle": "營運分析與明細追溯",
"currentFilterResults": "當前篩選結果:{total} 條",
"export": "導出 Excel",
"columnSettings": "列設置",
"showSelection": "顯示選擇",
@@ -1986,16 +1989,26 @@
"noData": "暫無數據: {table}",
"noFilterResults": "沒有匹配的數據,請調整篩選條件",
"usage": "使用分析",
"usageRangeLabel": "統計範圍",
"usageRanges": {
"7d": "近一週",
"30d": "近一月",
"90d": "近三月",
"180d": "近半年",
"365d": "近一年"
},
"dateFrom": "開始日期",
"dateTo": "結束日期",
"byUser": "按用戶統計",
"byAgent": "按應用統計",
"byDepartment": "按部門統計",
"usageByDepartmentHint": "按部門聚合對話量與參與用戶數",
"unknownDepartment": "未分組",
"usageByDepartmentEmpty": "暫無部門對話記錄",
"usageHourHeatmap": "工作日與時段熱力圖",
"usageHourHeatmapHint": "橫軸=時段,縱軸=工作日,格子顏色深淺=該日該時段對話量",
"usageHourHeatmapEmpty": "暫無時段熱力圖資料",
"weekdays": {
"Mon": "週一",
"Tue": "週二",
"Wed": "週三",
"Thu": "週四",
"Fri": "週五",
"Sat": "週六",
"Sun": "週日"
},
"usageByUserTopHint": "僅顯示對話量前 {limit} 名用戶",
"usageByUserEmpty": "暫無用戶對話記錄",
"columns": {
@@ -2060,16 +2073,26 @@
"theme_preference": "主題偏好",
"password_hash": "密碼雜湊",
"reset_token": "重置令牌",
"reset_token_expiry": "重置令牌過期時間"
"reset_token_expiry": "重置令牌過期時間",
"risk_status": "風險狀態",
"risk_score": "風險分",
"latency": "耗時(毫秒)",
"is_empty_answer": "空回答",
"is_system_failure": "系統失敗",
"feedback_score": "評分",
"feedback_comment": "評分備註",
"negative_feedback_count": "負面反饋數",
"actions": "操作"
},
"tables": {
"users": "用戶",
"chat_logs": "聊天日誌",
"general_feedbacks": "意見反饋",
"feedbacks": "回答評價",
"feedbacks": "用戶反饋與回答評價",
"departments": "部門",
"agents": "應用運營",
"permission_requests": "權限申請",
"ops_overview": "營運總覽",
"issue_analysis": "問題分析",
"usage_analysis": "使用分析"
},
"usageIntro": "查看 AI 應用呼叫趨勢、活躍使用者、低使用應用與異常高峰。",
@@ -2101,11 +2124,15 @@
"usageAll": "全部",
"usageUsed": "有使用",
"usageUnused": "零使用",
"usageAuthorizedUnused": "已授權未使用",
"searchPlaceholder": "搜尋應用名稱…",
"summaryActive": "啟用應用",
"summaryTotal": "共 {total} 個",
"summaryUsed": "有使用",
"summaryUnused": "零使用",
"summaryAuthorizedUnused": "已授權未使用",
"summaryAuthorizedUnusedHint": "已授權但範圍內無對話",
"authorizedUnused": "已授權未使用",
"summaryPending": "待審權限",
"empty": "暫無應用運營資料,請調整篩選條件",
"actionLogs": "日誌",
@@ -2124,6 +2151,138 @@
"tokens_used": "Token",
"actions": "操作"
}
},
"placeholder": "該模塊正在建設中,敬請期待",
"feedback": {
"title": "用戶反饋與回答評價",
"intro": "查看用戶提交的意見反饋與回答評分明細,支持篩選、導出和追溯。",
"tabs": {
"general": "意見反饋",
"rating": "回答評價"
},
"timeFrom": "開始日期",
"timeTo": "結束日期",
"typeLabel": "反饋類型",
"sourceLabel": "來源頁面",
"moduleLabel": "反饋模塊",
"allOption": "全部",
"notLinked": "未關聯",
"viewChatLog": "查看聊天記錄",
"expand": "展開",
"collapse": "收起",
"viewFullContent": "查看完整反饋內容",
"markClosed": "標記已關閉",
"closed": "已關閉",
"closedOk": "已標記關閉",
"summary": {
"pending": "待處理",
"pendingHint": "待跟進反饋",
"closed": "本月已關閉",
"closedHint": "本月關閉量",
"topApp": "最多反饋應用",
"topAppHint": "共 {count} 條相關反饋"
}
},
"chatLog": {
"title": "聊天日誌詳情",
"detail": "詳情",
"meta": {
"app": "應用",
"user": "用戶",
"createdAt": "創建時間",
"chatLogId": "聊天日誌 ID",
"rating": "評分",
"negativeFeedback": "負面反饋"
},
"tops": {
"questions": "Top 提問內容",
"answers": "Top 回答內容",
"empty": "暫無統計"
},
"question": "用戶提問",
"answer": "智能體回答",
"riskStatus": "風險狀態",
"riskScore": "風險分數",
"reasons": "判定原因",
"checks": "建議檢查項",
"noReason": "無命中風險規則",
"noCheck": "無建議檢查項",
"close": "關閉",
"risk": {
"attention": "需要關注",
"review": "待人工抽查",
"responded": "已響應"
},
"reason": {
"empty_answer": "空回答",
"system_failure": "系統失敗",
"low_score": "低評分",
"negative_feedback": "負面反饋",
"duplicate": "完全重複提問"
},
"check": {
"check_chain": "檢查模型、接口、工具鏈路",
"check_answer": "人工抽查回答內容",
"check_kb": "檢查知識庫和資料有效期",
"check_key_info": "檢查回答是否遺漏關鍵信息",
"priority_review": "優先人工複核該問題"
},
"filters": {
"title": "風險篩選",
"timeFrom": "開始日期",
"timeTo": "結束日期",
"appLabel": "應用",
"userLabel": "用戶",
"emptyAnswerLabel": "是否空回答",
"systemFailureLabel": "是否系統失敗",
"riskStatusLabel": "風險狀態",
"scoreRangeLabel": "評分區間",
"minScore": "最低分",
"maxScore": "最高分",
"reset": "重設篩選",
"yes": "是",
"no": "否"
},
"detailPlaceholder": "暫無數據"
},
"opsOverview": {
"title": "營運總覽",
"intro": "彙總關鍵營運指標與應用健康度,整體掌握平台運行情況。",
"empty": "暫無營運總覽資料",
"kpi": {
"totalChats": "對話量",
"activeUsers": "活躍使用者",
"activeAgents": "活躍應用",
"pendingFollowup": "待跟進反饋"
},
"trendTitle": "對話趨勢與環比",
"trendEmpty": "暫無趨勢資料",
"topApps": "Top 應用",
"lowUseApps": "低使用應用"
},
"issueAnalysis": {
"title": "問題分析",
"intro": "基於聊天日誌風險規則聚合高頻問題與需要關注/待抽查信號,定位待優化問題。",
"empty": "暫無問題分析資料",
"priorityTitle": "優先處理問題",
"colTopic": "問題主題",
"colCount": "出現次數",
"colApps": "涉及應用",
"colAttention": "需要關注",
"colReasons": "判定原因",
"colChecks": "建議檢查項",
"kpi": {
"highFreq": "高頻問題簇",
"highFreqHint": "Top 10 占全部提問 {ratio}%",
"attention": "需要關注",
"attentionHint": "空回答/系統失敗 +3;低評分 +3;負面反饋 +2;完全重複提問 +1",
"review": "待人工抽查",
"reviewHint": "低風險信號,建議人工抽查",
"emptyAnswer": "空回答",
"emptyAnswerHint": "檢查模型返回和接口鏈路",
"topApp": "優先優化應用",
"topAppHint": "需要關注信號占比 {ratio}%"
}
}
},
"batchEdit": {
+47 -1
View File
@@ -1,4 +1,4 @@
/**
/**
* shared/styles/components-ds.css
* 设计系统组件样式(按钮、表格、表单等)。
*/
@@ -394,6 +394,42 @@
color: var(--text-secondary);
}
.admin-report-table--compact tbody td {
@apply align-middle py-2;
line-height: 1.25rem;
}
/* 反馈表必须为操作列保留横向按钮空间;内容详情始终由浮层承载,避免撑高数据行。 */
.admin-report-table--feedback {
min-width: 58rem;
}
.admin-report-table--feedback th:last-child,
.admin-report-table--feedback td:last-child {
min-width: 7rem;
white-space: nowrap;
}
.admin-report-feedback-action {
@apply inline-flex items-center justify-center whitespace-nowrap px-2.5 py-1;
min-width: 6rem;
}
.admin-report-feedback-content-trigger {
@apply w-full max-w-full truncate rounded px-0.5 py-0.5 text-left text-sm text-secondary transition-colors;
}
.admin-report-feedback-content-trigger:hover,
.admin-report-feedback-content-trigger:focus-visible {
@apply text-brand-700 outline-none;
background-color: color-mix(in srgb, #0ea5e9 8%, transparent);
}
.admin-report-feedback-content-popover {
@apply absolute left-0 top-full z-30 mt-1 max-h-48 w-72 overflow-auto whitespace-pre-wrap break-words rounded-xl border border-default p-3 text-sm text-secondary shadow-elevated;
background-color: var(--bg-surface);
}
.admin-report-filter-input {
@apply w-full max-w-full min-w-0 box-border px-1.5 py-1 text-xs border rounded outline-none font-normal normal-case;
border-color: var(--border-default);
@@ -442,6 +478,16 @@
color: var(--text-secondary);
}
/* 应用运营汇总卡:激活(被点击)时更深蓝高亮 */
.app-ops-summary-card {
@apply cursor-pointer;
}
.app-ops-summary-card--active {
border-color: color-mix(in srgb, #2563eb 45%, var(--border-default));
background-color: color-mix(in srgb, #2563eb 14%, var(--bg-surface));
box-shadow: 0 0 0 1px color-mix(in srgb, #2563eb 35%, transparent);
}
.admin-report-panel {
@apply p-4 md:p-5 rounded-2xl border border-default shadow-sm;
background-color: var(--bg-surface);
+17
View File
@@ -0,0 +1,17 @@
/**
* shared/utils/user-avatar.ts
* 用途:统一生成用户头像中的姓名缩写。
* 依赖:用户对象的 real_name 与 username 字段。
* 逻辑:优先显示真实姓名最后两个 Unicode 字符;无真实姓名时回退到账号首字母。
*/
/**
* 生成用户头像文字,供用户管理和个人中心等用户头像展示位置复用。
* @param user 用户信息,必须包含 username,可选 real_name。
* @returns 真实姓名后两个字符;姓名不足两字时返回全部姓名;无姓名时返回账号首字母。
*/
export function getUserAvatarLabel(user: { real_name?: string | null; username?: string | null }): string {
const realName = String(user.real_name || '').trim();
if (realName) return Array.from(realName).slice(-2).join('');
return String(user.username || 'U').charAt(0).toUpperCase();
}