fix(admin): 删除用户审批功能并更新图标
This commit is contained in:
1 parent
55c6467d83
commit
07e83132c0
11 files changed
+141
-153
No files matched your search
@@ -1,82 +1,70 @@
|
|||||||
"""
|
"""
|
||||||
backend/app/api/admin/users.py
|
backend/app/api/admin/users.py
|
||||||
|
|
||||||
用途:管理后台用户 CRUD API(薄路由层)。
|
鐢ㄩ€旓細绠$悊鍚庡彴鐢ㄦ埛 CRUD API锛堣杽璺敱灞傦級銆?
|
||||||
依赖:admin.blueprint、services/admin/user_service、core.auth.jwt。
|
渚濊禆锛歛dmin.blueprint銆乻ervices/admin/user_service銆乧ore.auth.jwt銆?
|
||||||
逻辑:/users* 路由。
|
閫昏緫锛?users* 璺敱銆?
|
||||||
"""
|
"""
|
||||||
from flask import jsonify, request
|
from flask import jsonify, request
|
||||||
|
|
||||||
from app.api.admin.blueprint import admin_bp
|
from app.api.admin.blueprint import admin_bp
|
||||||
from app.core.auth.jwt import get_current_user as _get_auth_user
|
from app.core.auth.jwt import get_current_user as _get_auth_user
|
||||||
from app.core.decorators import require_admin
|
from app.core.decorators import require_admin
|
||||||
from app.services.admin import user_service
|
from app.services.admin import user_service
|
||||||
|
|
||||||
|
|
||||||
def _query_params() -> dict[str, str]:
|
def _query_params() -> dict[str, str]:
|
||||||
return {k: str(v) for k, v in request.args.items()}
|
return {k: str(v) for k, v in request.args.items()}
|
||||||
|
|
||||||
|
|
||||||
@admin_bp.route('/users', methods=['GET'])
|
@admin_bp.route('/users', methods=['GET'])
|
||||||
@require_admin
|
@require_admin
|
||||||
def list_users():
|
def list_users():
|
||||||
"""列出管理端用户(支持分页与筛选)。"""
|
"""鍒楀嚭绠$悊绔敤鎴凤紙鏀寔鍒嗛〉涓庣瓫閫夛級銆?""
|
||||||
result = user_service.list_users(_query_params())
|
result = user_service.list_users(_query_params())
|
||||||
return jsonify(result)
|
return jsonify(result)
|
||||||
|
|
||||||
|
|
||||||
@admin_bp.route('/users', methods=['POST'])
|
@admin_bp.route('/users', methods=['POST'])
|
||||||
@require_admin
|
@require_admin
|
||||||
def create_user():
|
def create_user():
|
||||||
"""创建用户并同步 Casdoor。"""
|
"""鍒涘缓鐢ㄦ埛骞跺悓姝?Casdoor銆?""
|
||||||
data = request.get_json() or {}
|
data = request.get_json() or {}
|
||||||
payload = user_service.create_user(data)
|
payload = user_service.create_user(data)
|
||||||
return jsonify(payload), 201
|
return jsonify(payload), 201
|
||||||
|
|
||||||
|
|
||||||
@admin_bp.route('/users/<int:id>', methods=['PUT'])
|
@admin_bp.route('/users/<int:id>', methods=['PUT'])
|
||||||
@require_admin
|
@require_admin
|
||||||
def update_user(id: int):
|
def update_user(id: int):
|
||||||
"""更新用户资料;有 password 时同步 Casdoor 改密。"""
|
"""鏇存柊鐢ㄦ埛璧勬枡锛涙湁 password 鏃跺悓姝?Casdoor 鏀瑰瘑銆?""
|
||||||
data = request.get_json() or {}
|
data = request.get_json() or {}
|
||||||
return jsonify(user_service.update_user(id, data))
|
return jsonify(user_service.update_user(id, data))
|
||||||
|
|
||||||
|
|
||||||
@admin_bp.route('/users/cleanup-rejected', methods=['POST'])
|
@admin_bp.route('/users/cleanup-rejected', methods=['POST'])
|
||||||
@require_admin
|
@require_admin
|
||||||
def cleanup_rejected_users():
|
def cleanup_rejected_users():
|
||||||
"""批量删除 status=rejected 的用户。"""
|
"""鎵归噺鍒犻櫎 status=rejected 鐨勭敤鎴枫€?""
|
||||||
return jsonify(user_service.cleanup_rejected_users())
|
return jsonify(user_service.cleanup_rejected_users())
|
||||||
|
|
||||||
|
|
||||||
@admin_bp.route('/users/batch-delete', methods=['POST'])
|
@admin_bp.route('/users/batch-delete', methods=['POST'])
|
||||||
@require_admin
|
@require_admin
|
||||||
def batch_delete_users():
|
def batch_delete_users():
|
||||||
"""批量删除用户(排除当前登录管理员)。"""
|
"""鎵归噺鍒犻櫎鐢ㄦ埛锛堟帓闄ゅ綋鍓嶇櫥褰曠鐞嗗憳锛夈€?""
|
||||||
data = request.get_json() or {}
|
data = request.get_json() or {}
|
||||||
current_user = _get_auth_user()
|
current_user = _get_auth_user()
|
||||||
current_user_id = current_user.id if current_user else None
|
current_user_id = current_user.id if current_user else None
|
||||||
return jsonify(user_service.batch_delete_users(data.get('user_ids', []), current_user_id=current_user_id))
|
return jsonify(user_service.batch_delete_users(data.get('user_ids', []), current_user_id=current_user_id))
|
||||||
|
|
||||||
|
|
||||||
@admin_bp.route('/users/<int:id>', methods=['DELETE'])
|
@admin_bp.route('/users/<int:id>', methods=['DELETE'])
|
||||||
@require_admin
|
@require_admin
|
||||||
def delete_user(id: int):
|
def delete_user(id: int):
|
||||||
"""删除单个用户。"""
|
"""鍒犻櫎鍗曚釜鐢ㄦ埛銆?""
|
||||||
current_user = _get_auth_user()
|
current_user = _get_auth_user()
|
||||||
current_user_id = current_user.id if current_user else None
|
current_user_id = current_user.id if current_user else None
|
||||||
return jsonify(user_service.delete_user(id, current_user_id=current_user_id))
|
return jsonify(user_service.delete_user(id, current_user_id=current_user_id))
|
||||||
|
|
||||||
|
␍`n
|
||||||
@admin_bp.route('/users/<int:id>/approve', methods=['POST'])
|
|
||||||
@require_admin
|
|
||||||
def approve_user(id: int):
|
|
||||||
"""审批通过用户。"""
|
|
||||||
return jsonify(user_service.approve_user(id))
|
|
||||||
|
|
||||||
|
|
||||||
@admin_bp.route('/users/<int:id>/reject', methods=['POST'])
|
|
||||||
@require_admin
|
|
||||||
def reject_user(id: int):
|
|
||||||
"""拒绝用户注册。"""
|
|
||||||
return jsonify(user_service.reject_user(id))
|
|
||||||
@@ -38,10 +38,8 @@ def compute_dashboard_badges() -> dict:
|
|||||||
Returns:
|
Returns:
|
||||||
pending_approvals、pending_requests。
|
pending_approvals、pending_requests。
|
||||||
"""
|
"""
|
||||||
pending_approvals = db.session.query(func.count(User.id)).filter_by(status='pending').scalar() or 0
|
|
||||||
pending_requests = db.session.query(func.count(PermissionRequest.id)).filter_by(status='pending').scalar() or 0
|
pending_requests = db.session.query(func.count(PermissionRequest.id)).filter_by(status='pending').scalar() or 0
|
||||||
return {
|
return {
|
||||||
'pending_approvals': pending_approvals,
|
|
||||||
'pending_requests': pending_requests,
|
'pending_requests': pending_requests,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +53,5 @@ def compute_legacy_dashboard_stats() -> dict:
|
|||||||
'active_agents': summary['agent_count'],
|
'active_agents': summary['agent_count'],
|
||||||
'total_conversations': summary['total_conversations'],
|
'total_conversations': summary['total_conversations'],
|
||||||
'avg_score': summary['avg_score'],
|
'avg_score': summary['avg_score'],
|
||||||
'pending_approvals': badges['pending_approvals'],
|
|
||||||
'pending_requests': badges['pending_requests'],
|
'pending_requests': badges['pending_requests'],
|
||||||
}
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 198 KiB |
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* app/router/routes/admin.routes.ts
|
* app/router/routes/admin.routes.ts
|
||||||
* 管理后台嵌套路由;全部 admin 模块已独立拆分。
|
* 绠$悊鍚庡彴宓屽璺敱锛涘叏閮?admin 妯″潡宸茬嫭绔嬫媶鍒嗐€?
|
||||||
* 依赖:vue-router;meta.title 存 i18n key(如 admin.nav.*),由 guards 解析为 document.title。
|
* 渚濊禆锛歷ue-router锛沵eta.title 瀛?i18n key锛堝 admin.nav.*锛夛紝鐢?guards 瑙f瀽涓?document.title銆?
|
||||||
* 逻辑:AdminLayout 嵌套各管理页;企微为三级子路由。
|
* 閫昏緫锛欰dminLayout 宓屽鍚勭鐞嗛〉锛涗紒寰负涓夌骇瀛愯矾鐢便€?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { RouteRecordRaw } from "vue-router";
|
import type { RouteRecordRaw } from "vue-router";
|
||||||
@@ -17,9 +17,6 @@ const UsersPage = () => import("@/features/admin/modules/users/UsersPage.vue");
|
|||||||
const DepartmentsPage = () =>
|
const DepartmentsPage = () =>
|
||||||
import("@/features/admin/modules/departments/DepartmentsPage.vue");
|
import("@/features/admin/modules/departments/DepartmentsPage.vue");
|
||||||
|
|
||||||
const ApprovalsPage = () =>
|
|
||||||
import("@/features/admin/modules/approvals/ApprovalsPage.vue");
|
|
||||||
|
|
||||||
const AnnouncementsPage = () =>
|
const AnnouncementsPage = () =>
|
||||||
import("@/features/admin/modules/announcements/AnnouncementsPage.vue");
|
import("@/features/admin/modules/announcements/AnnouncementsPage.vue");
|
||||||
|
|
||||||
@@ -116,17 +113,7 @@ export const adminRoutes: RouteRecordRaw[] = [
|
|||||||
component: WecomAuditsPage,
|
component: WecomAuditsPage,
|
||||||
meta: { requiresAdmin: true, adminModule: "wecom", title: "admin.wecom.nav.auditsPage" },
|
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",
|
path: "agents",
|
||||||
@@ -233,3 +220,7 @@ export const adminRoutes: RouteRecordRaw[] = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+28
-26
@@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* config.ts
|
* config.ts
|
||||||
* 用途:前端应用级开关与默认配置(登录模式、工作台模块、管理模块可见性)。
|
* 鐢ㄩ€旓細鍓嶇搴旂敤绾у紑鍏充笌榛樿閰嶇疆锛堢櫥褰曟ā寮忋€佸伐浣滃彴妯″潡銆佺鐞嗘ā鍧楀彲瑙佹€э級銆?
|
||||||
* 依赖:无运行时依赖;应用标题通过 common.app.title i18n key 解析。
|
* 渚濊禆锛氭棤杩愯鏃朵緷璧栵紱搴旂敤鏍囬閫氳繃 common.app.title i18n key 瑙f瀽銆?
|
||||||
* 逻辑:main.ts / router guards 使用 i18n.t(config.appTitleKey) 设置 document.title。
|
* 閫昏緫锛歮ain.ts / router guards 浣跨敤 i18n.t(config.appTitleKey) 璁剧疆 document.title銆?
|
||||||
*/
|
*/
|
||||||
export const config = {
|
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',
|
appTitleKey: 'common.app.title',
|
||||||
auth: {
|
auth: {
|
||||||
// Login mode switch:
|
// Login mode switch:
|
||||||
@@ -19,7 +19,7 @@ export const config = {
|
|||||||
passwordLoginApi: '/api/user/casdoor/password-login',
|
passwordLoginApi: '/api/user/casdoor/password-login',
|
||||||
refreshApi: '/api/user/casdoor/refresh',
|
refreshApi: '/api/user/casdoor/refresh',
|
||||||
callbackPath: '/casdoor-callback',
|
callbackPath: '/casdoor-callback',
|
||||||
// Casdoor Provider「Name」字段须一致(当前 IdP:wecom)。留空则仅用后端 CASDOOR_WECOM_PROVIDER_HINT。
|
// Casdoor Provider銆孨ame銆嶅瓧娈甸』涓€鑷达紙褰撳墠 IdP锛歸ecom锛夈€傜暀绌哄垯浠呯敤鍚庣 CASDOOR_WECOM_PROVIDER_HINT銆?
|
||||||
wecomProviderHint: 'wecom',
|
wecomProviderHint: 'wecom',
|
||||||
},
|
},
|
||||||
wecom: {
|
wecom: {
|
||||||
@@ -35,15 +35,15 @@ export const config = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
workspace: {
|
workspace: {
|
||||||
// true 显示评分区;false 隐藏评分区
|
// true 鏄剧ず璇勫垎鍖猴紱false 闅愯棌璇勫垎鍖?
|
||||||
showChatRating: true,
|
showChatRating: true,
|
||||||
// 聊天窗口“源文件展示”开关配置
|
// 鑱婂ぉ绐楀彛鈥滄簮鏂囦欢灞曠ず鈥濆紑鍏抽厤缃?
|
||||||
sourceFiles: {
|
sourceFiles: {
|
||||||
// 是否显示源文件区域(包含上方文件按钮 + 下方“源文档”详情)
|
// 鏄惁鏄剧ず婧愭枃浠跺尯鍩燂紙鍖呭惈涓婃柟鏂囦欢鎸夐挳 + 涓嬫柟鈥滄簮鏂囨。鈥濊鎯咃級
|
||||||
showSourceFiles: true,
|
showSourceFiles: true,
|
||||||
// 是否显示 MD 源文件(文件名后缀为 .md/.markdown)
|
// 鏄惁鏄剧ず MD 婧愭枃浠讹紙鏂囦欢鍚嶅悗缂€涓?.md/.markdown锛?
|
||||||
showMdFiles: false,
|
showMdFiles: false,
|
||||||
// 当 showMdFiles=true 时,MD 源文件是否默认展开“源文档”详情
|
// 褰?showMdFiles=true 鏃讹紝MD 婧愭枃浠舵槸鍚﹂粯璁ゅ睍寮€鈥滄簮鏂囨。鈥濊鎯?
|
||||||
expandMdByDefault: false,
|
expandMdByDefault: false,
|
||||||
},
|
},
|
||||||
modules: {
|
modules: {
|
||||||
@@ -57,21 +57,23 @@ export const config = {
|
|||||||
admin: {
|
admin: {
|
||||||
modules: {
|
modules: {
|
||||||
dashboard: true, // 仪表盘
|
dashboard: true, // 仪表盘
|
||||||
approvals: true, // 用户审批
|
users: true, // 鐢ㄦ埛绠$悊
|
||||||
users: true, // 用户管理
|
departments: true, // 閮ㄩ棬绠$悊
|
||||||
departments: true, // 部门管理
|
agents: true, // 搴旂敤绠$悊
|
||||||
agents: true, // 应用管理
|
knowledge_base: true, // 鐭ヨ瘑搴撶鐞?
|
||||||
knowledge_base: true, // 知识库管理
|
announcements: true, // 鍏憡绠$悊
|
||||||
announcements: true, // 公告管理
|
questions: true, // 甯哥敤闂
|
||||||
questions: true, // 常用问题
|
wecom: true, // 浼佷笟寰俊
|
||||||
wecom: true, // 企业微信
|
linked_services: true, // 鍏宠仈鏈嶅姟锛堜晶鏍忚烦杞叆鍙o級
|
||||||
linked_services: true, // 关联服务(侧栏跳转入口)
|
permissions: true, // 搴旂敤鏉冮檺
|
||||||
permissions: true, // 应用权限
|
platform_apps: true, // 骞冲彴搴旂敤璇存槑
|
||||||
platform_apps: true, // 平台应用说明
|
requests: true, // 瀹℃壒鏉冮檺
|
||||||
requests: true, // 审批权限
|
reports: true, // 鏁版嵁鎶ヨ〃
|
||||||
reports: true, // 数据报表
|
schedules: true, // 瀹氭椂浠诲姟
|
||||||
schedules: true, // 定时任务
|
procurement_contract: true, // 閲囪喘鍚堝悓瀹℃煡锛堟ā鏉垮簱 + 鍘嗗彶锛?
|
||||||
procurement_contract: true, // 采购合同审查(模板库 + 历史)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
/**
|
/**
|
||||||
* features/admin/components/AdminNav.vue
|
* features/admin/components/AdminNav.vue
|
||||||
* 管理后台左侧导航,使用子路由跳转。
|
* 绠$悊鍚庡彴宸︿晶瀵艰埅锛屼娇鐢ㄥ瓙璺敱璺宠浆銆?
|
||||||
* 依赖:admin-nav.store、modules 常量、vue-router。
|
* 渚濊禆锛歛dmin-nav.store銆乵odules 甯搁噺銆乿ue-router銆?
|
||||||
* 逻辑:报表/企微子菜单默认折叠;当前路由落在对应模块时自动展开以便看到激活项。
|
* 閫昏緫锛氭姤琛?浼佸井瀛愯彍鍗曢粯璁ゆ姌鍙狅紱褰撳墠璺敱钀藉湪瀵瑰簲妯″潡鏃惰嚜鍔ㄥ睍寮€浠ヤ究鐪嬪埌婵€娲婚」銆?
|
||||||
*/
|
*/
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, watch } from 'vue';
|
import { computed, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import {
|
import { LayoutDashboard, UserCog, Building, Bot, FileText,
|
||||||
LayoutDashboard, UserPlus, UserCog, Building, Bot, FileText,
|
|
||||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, ShieldCheck, BarChart2, AppWindow,
|
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, ShieldCheck, BarChart2, AppWindow,
|
||||||
ScrollText, ExternalLink,
|
ScrollText, ExternalLink,
|
||||||
} from 'lucide-vue-next';
|
} from 'lucide-vue-next';
|
||||||
@@ -26,7 +25,6 @@ const navStore = useAdminNavStore();
|
|||||||
|
|
||||||
const iconMap: Record<AdminModuleId, Component> = {
|
const iconMap: Record<AdminModuleId, Component> = {
|
||||||
dashboard: LayoutDashboard,
|
dashboard: LayoutDashboard,
|
||||||
approvals: UserPlus,
|
|
||||||
users: UserCog,
|
users: UserCog,
|
||||||
departments: Building,
|
departments: Building,
|
||||||
agents: Bot,
|
agents: Bot,
|
||||||
@@ -83,7 +81,7 @@ const navigateReport = (table: string): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进入报表/企微模块时自动展开子菜单,避免当前页在折叠状态下不可见。
|
* 杩涘叆鎶ヨ〃/浼佸井妯″潡鏃惰嚜鍔ㄥ睍寮€瀛愯彍鍗曪紝閬垮厤褰撳墠椤靛湪鎶樺彔鐘舵€佷笅涓嶅彲瑙併€?
|
||||||
*/
|
*/
|
||||||
watch(
|
watch(
|
||||||
isReportsActive,
|
isReportsActive,
|
||||||
@@ -195,3 +193,4 @@ watch(
|
|||||||
</nav>
|
</nav>
|
||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* features/admin/constants/modules.ts
|
* features/admin/constants/modules.ts
|
||||||
* 管理后台模块元数据,AdminNav 与子路由共用。
|
* 绠$悊鍚庡彴妯″潡鍏冩暟鎹紝AdminNav 涓庡瓙璺敱鍏辩敤銆?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { AdminModuleId, AdminReportTableId } from '../types/admin.types';
|
import type { AdminModuleId, AdminReportTableId } from '../types/admin.types';
|
||||||
@@ -13,14 +13,13 @@ export interface AdminModuleMeta {
|
|||||||
configKey: keyof typeof import('@/config').config.admin.modules;
|
configKey: keyof typeof import('@/config').config.admin.modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 已独立拆分的模块(全部 admin 模块均已拆分) */
|
/** 宸茬嫭绔嬫媶鍒嗙殑妯″潡锛堝叏閮?admin 妯″潡鍧囧凡鎷嗗垎锛?*/
|
||||||
export const STANDALONE_ADMIN_MODULES = new Set<AdminModuleId>([
|
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', 'procurement_contract', 'reports',
|
'dashboard', 'agents', 'users', 'departments', 'announcements', 'questions', 'requests', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'procurement_contract', 'reports',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||||
{ id: 'dashboard', routeName: 'AdminDashboard', path: 'dashboard', labelKey: 'admin.nav.dashboard', configKey: 'dashboard' },
|
{ 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: 'users', routeName: 'AdminUsers', path: 'users', labelKey: 'admin.nav.users', configKey: 'users' },
|
||||||
{ id: 'departments', routeName: 'AdminDepartments', path: 'departments', labelKey: 'admin.nav.departments', configKey: 'departments' },
|
{ id: 'departments', routeName: 'AdminDepartments', path: 'departments', labelKey: 'admin.nav.departments', configKey: 'departments' },
|
||||||
{ id: 'agents', routeName: 'AdminAgents', path: 'agents', labelKey: 'admin.nav.agents', configKey: 'agents' },
|
{ id: 'agents', routeName: 'AdminAgents', path: 'agents', labelKey: 'admin.nav.agents', configKey: 'agents' },
|
||||||
@@ -53,3 +52,4 @@ export const adminModulePath = (moduleId: AdminModuleId | string): string => {
|
|||||||
if (meta) return `/admin/${meta.path}`;
|
if (meta) return `/admin/${meta.path}`;
|
||||||
return `/admin/${LEGACY_MODULE_QUERY_TO_PATH[moduleId] || moduleId}`;
|
return `/admin/${LEGACY_MODULE_QUERY_TO_PATH[moduleId] || moduleId}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -21,7 +21,6 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
|||||||
/** 企业微信子菜单:默认折叠 */
|
/** 企业微信子菜单:默认折叠 */
|
||||||
const wecomExpanded = ref(false);
|
const wecomExpanded = ref(false);
|
||||||
/** 「用户审批」导航角标:pending 注册用户数 */
|
/** 「用户审批」导航角标:pending 注册用户数 */
|
||||||
const pendingApprovalsCount = ref(0);
|
|
||||||
/** 「权限申请」导航角标:pending 权限申请数 */
|
/** 「权限申请」导航角标:pending 权限申请数 */
|
||||||
const pendingRequestsCount = ref(0);
|
const pendingRequestsCount = ref(0);
|
||||||
|
|
||||||
@@ -34,13 +33,11 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
|||||||
sidebarCollapsed.value = !sidebarCollapsed.value;
|
sidebarCollapsed.value = !sidebarCollapsed.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const setBadgeCounts = (approvals: number, requests: number): void => {
|
const setBadgeCounts = (_approvals: number, requests: number): void => {
|
||||||
pendingApprovalsCount.value = approvals;
|
|
||||||
pendingRequestsCount.value = requests;
|
pendingRequestsCount.value = requests;
|
||||||
};
|
};
|
||||||
|
|
||||||
const badgeForModule = (moduleId: AdminModuleId): number | undefined => {
|
const badgeForModule = (moduleId: AdminModuleId): number | undefined => {
|
||||||
if (moduleId === 'approvals' && pendingApprovalsCount.value > 0) return pendingApprovalsCount.value;
|
|
||||||
if (moduleId === 'requests' && pendingRequestsCount.value > 0) return pendingRequestsCount.value;
|
if (moduleId === 'requests' && pendingRequestsCount.value > 0) return pendingRequestsCount.value;
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
@@ -66,7 +63,7 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
|||||||
badgesInFlight = (async () => {
|
badgesInFlight = (async () => {
|
||||||
try {
|
try {
|
||||||
const data = await getAdminDashboardBadges();
|
const data = await getAdminDashboardBadges();
|
||||||
setBadgeCounts(data.pending_approvals, data.pending_requests);
|
setBadgeCounts(0, data.pending_requests);
|
||||||
badgesFetchedAt = Date.now();
|
badgesFetchedAt = Date.now();
|
||||||
} catch {
|
} catch {
|
||||||
setBadgeCounts(0, 0);
|
setBadgeCounts(0, 0);
|
||||||
@@ -88,7 +85,6 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
|||||||
sidebarCollapsed,
|
sidebarCollapsed,
|
||||||
reportsExpanded,
|
reportsExpanded,
|
||||||
wecomExpanded,
|
wecomExpanded,
|
||||||
pendingApprovalsCount,
|
|
||||||
pendingRequestsCount,
|
pendingRequestsCount,
|
||||||
toggleSidebar,
|
toggleSidebar,
|
||||||
setBadgeCounts,
|
setBadgeCounts,
|
||||||
@@ -97,3 +93,4 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
|||||||
refreshBadges,
|
refreshBadges,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* features/admin/types/admin.types.ts
|
* features/admin/types/admin.types.ts
|
||||||
* 管理后台域公共类型。
|
* 绠$悊鍚庡彴鍩熷叕鍏辩被鍨嬨€?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export type AdminModuleId =
|
export type AdminModuleId =
|
||||||
| 'dashboard'
|
| 'dashboard'
|
||||||
| 'approvals'
|
|
||||||
| 'users'
|
| 'users'
|
||||||
| 'departments'
|
| 'departments'
|
||||||
| 'agents'
|
| 'agents'
|
||||||
@@ -67,3 +66,4 @@ export interface AdminAnnouncementRow {
|
|||||||
content: string;
|
content: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,7 +13,6 @@ export interface AdminDashboardSummary {
|
|||||||
|
|
||||||
/** GET /api/admin/dashboard/badges — 侧栏「用户审批」「权限申请」角标 */
|
/** GET /api/admin/dashboard/badges — 侧栏「用户审批」「权限申请」角标 */
|
||||||
export interface AdminDashboardBadges {
|
export interface AdminDashboardBadges {
|
||||||
pending_approvals: number;
|
|
||||||
pending_requests: number;
|
pending_requests: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,15 @@ import { storeToRefs } from 'pinia';
|
|||||||
import { ExternalLink } from 'lucide-vue-next';
|
import { ExternalLink } from 'lucide-vue-next';
|
||||||
import { useLinkedNavStore } from '../stores/linked-nav.store';
|
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<{
|
const props = withDefaults(defineProps<{
|
||||||
compact?: boolean;
|
compact?: boolean;
|
||||||
showLabel?: boolean;
|
showLabel?: boolean;
|
||||||
@@ -56,7 +65,13 @@ onMounted(() => {
|
|||||||
:title="entry.display_name"
|
:title="entry.display_name"
|
||||||
@click="linkedNav.openItem(entry)"
|
@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>
|
<span v-if="showLabel && !compact" class="truncate">{{ entry.display_name }}</span>
|
||||||
</button>
|
</button>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in new issue
Block a user