Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5faf86b184 | ||
|
|
de9db2ea77 | ||
|
|
590a21515a | ||
|
|
ed4a47ffba | ||
|
|
09603b334b | ||
|
|
ca9c174f29 | ||
|
|
cc41f8fe25 | ||
|
|
4445ff68d4 | ||
|
|
07e83132c0 | ||
|
|
55c6467d83 |
No files matched your search
@@ -22,21 +22,11 @@ def dashboard_summary():
|
||||
return jsonify(dashboard_service.compute_dashboard_summary())
|
||||
|
||||
|
||||
@admin_bp.route('/dashboard/badges', methods=['GET'])
|
||||
@require_admin
|
||||
def dashboard_badges():
|
||||
"""
|
||||
管理后台侧栏待办角标(供 AdminLayout 轻量轮询/缓存刷新)。
|
||||
GET /api/admin/dashboard/badges
|
||||
"""
|
||||
return jsonify(dashboard_service.compute_dashboard_badges())
|
||||
|
||||
|
||||
@admin_bp.route('/dashboard', methods=['GET'])
|
||||
@require_admin
|
||||
def dashboard_stats():
|
||||
"""
|
||||
仪表盘统计(遗留接口;新代码请用 /dashboard/summary 与 /dashboard/badges)。
|
||||
仪表盘统计(遗留接口;新代码请用 /dashboard/summary)。
|
||||
GET /api/admin/dashboard
|
||||
"""
|
||||
return jsonify(dashboard_service.compute_legacy_dashboard_stats())
|
||||
@@ -28,6 +28,13 @@ def create_department():
|
||||
return jsonify(payload), 201
|
||||
|
||||
|
||||
@admin_bp.route('/departments/<int:id>/members', methods=['GET'])
|
||||
@require_admin
|
||||
def list_department_members(id: int):
|
||||
"""返回部门员工数量与名单。"""
|
||||
return jsonify(department_service.list_department_members(id))
|
||||
|
||||
|
||||
@admin_bp.route('/departments/<int:id>', methods=['PUT'])
|
||||
@require_admin
|
||||
def update_department(id: int):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
backend/app/api/admin/permissions.py
|
||||
|
||||
用途:管理后台权限批量更新与权限申请审批 API(薄路由层)。
|
||||
用途:管理后台应用权限批量更新 API(薄路由层)。
|
||||
依赖:admin.blueprint、services/admin/permission_service。
|
||||
逻辑:/permissions/*、/permission-requests/*、/users/<id>/permissions 路由。
|
||||
逻辑:/permissions/*、/users/<id>/permissions 路由。
|
||||
"""
|
||||
from flask import jsonify, request
|
||||
|
||||
@@ -28,22 +28,3 @@ def update_user_permissions(id: int):
|
||||
return jsonify(permission_service.update_user_permissions(id, data))
|
||||
|
||||
|
||||
@admin_bp.route('/permission-requests', methods=['GET'])
|
||||
@require_admin
|
||||
def list_permission_requests():
|
||||
"""列出全部权限申请。"""
|
||||
return jsonify(permission_service.list_permission_requests())
|
||||
|
||||
|
||||
@admin_bp.route('/permission-requests/<int:id>/approve', methods=['POST'])
|
||||
@require_admin
|
||||
def approve_request(id: int):
|
||||
"""批准权限申请。"""
|
||||
return jsonify(permission_service.approve_permission_request(id))
|
||||
|
||||
|
||||
@admin_bp.route('/permission-requests/<int:id>/reject', methods=['POST'])
|
||||
@require_admin
|
||||
def reject_request(id: int):
|
||||
"""拒绝权限申请。"""
|
||||
return jsonify(permission_service.reject_permission_request(id))
|
||||
@@ -19,7 +19,7 @@ def _query_params() -> dict[str, str]:
|
||||
@admin_bp.route('/reports/usage', methods=['GET'])
|
||||
@require_admin
|
||||
def usage_report():
|
||||
"""聊天使用分析报表(支持时间范围 range=7d|30d|90d|180d|365d)。"""
|
||||
"""聊天使用分析报表(统计范围:start_date/end_date 自定义日期优先,否则 range=7d|30d|90d|180d|365d)。"""
|
||||
try:
|
||||
user_page = int(request.args.get('user_page', 1))
|
||||
except (TypeError, ValueError):
|
||||
@@ -34,6 +34,8 @@ def usage_report():
|
||||
user_page=user_page,
|
||||
user_page_size=user_page_size,
|
||||
range_key=range_key,
|
||||
start_date=request.args.get('start_date'),
|
||||
end_date=request.args.get('end_date'),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -43,7 +45,7 @@ def usage_report():
|
||||
def applications_report():
|
||||
"""
|
||||
应用运营报表:按应用聚合使用 / 权限 / 评分。
|
||||
Query: range, status, usage, q, sort, order, page, page_size。
|
||||
Query: start_date, end_date(自定义日期优先), range, status, usage, q, sort, order, page, page_size。
|
||||
"""
|
||||
try:
|
||||
page = int(request.args.get('page', 1))
|
||||
@@ -56,6 +58,8 @@ def applications_report():
|
||||
return jsonify(
|
||||
report_service.build_application_report(
|
||||
range_key=request.args.get('range'),
|
||||
start_date=request.args.get('start_date'),
|
||||
end_date=request.args.get('end_date'),
|
||||
status=request.args.get('status'),
|
||||
usage=request.args.get('usage'),
|
||||
q=request.args.get('q'),
|
||||
@@ -67,6 +71,22 @@ def applications_report():
|
||||
)
|
||||
|
||||
|
||||
@admin_bp.route('/reports/overview', methods=['GET'])
|
||||
@require_admin
|
||||
def ops_overview_report():
|
||||
"""
|
||||
运营总览报表:对话量 / 活跃用户 / 活跃应用 / 趋势环比 / Top 与低使用应用 / 未处理反馈。
|
||||
Query: start_date, end_date(自定义日期优先),否则 range(7d/30d/90d/180d/365d)。
|
||||
"""
|
||||
return jsonify(
|
||||
report_service.build_ops_overview_report(
|
||||
range_key=request.args.get('range'),
|
||||
start_date=request.args.get('start_date'),
|
||||
end_date=request.args.get('end_date'),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@admin_bp.route('/reports/feedback', methods=['GET'])
|
||||
@require_admin
|
||||
def feedback_report():
|
||||
@@ -86,3 +106,31 @@ def list_general_feedbacks_report():
|
||||
def count_general_feedbacks_report():
|
||||
"""通用反馈计数。"""
|
||||
return jsonify(report_service.count_general_feedbacks_report(_query_params()))
|
||||
|
||||
|
||||
@admin_bp.route('/reports/chat-log-tops', methods=['GET'])
|
||||
@require_admin
|
||||
def chat_log_tops():
|
||||
"""聊天日志 Top 提问/回答内容(直接按 ChatLog 明细统计,复用 FAQ 问句归一化)。"""
|
||||
return jsonify(report_service.build_chat_log_top_content(_query_params()))
|
||||
|
||||
|
||||
@admin_bp.route('/reports/feedback-summary', methods=['GET'])
|
||||
@require_admin
|
||||
def feedback_summary():
|
||||
"""用户反馈概览:待处理 / 本月已关闭 / 最多反馈应用(三张概览卡)。"""
|
||||
return jsonify(report_service.build_feedback_summary(_query_params()))
|
||||
|
||||
|
||||
@admin_bp.route('/reports/issue-analysis', methods=['GET'])
|
||||
@require_admin
|
||||
def issue_analysis():
|
||||
"""问题分析:高频问题簇 KPI + 优先处理问题(复用聊天日志风险规则)。"""
|
||||
return jsonify(report_service.build_issue_analysis_report(_query_params()))
|
||||
|
||||
|
||||
@admin_bp.route('/reports/general-feedbacks/<int:feedback_id>/close', methods=['POST'])
|
||||
@require_admin
|
||||
def close_general_feedback(feedback_id: int):
|
||||
"""将一条意见反馈标记为已关闭(status='closed')。"""
|
||||
return jsonify(report_service.mark_general_feedback_closed(feedback_id))
|
||||
@@ -1,9 +1,9 @@
|
||||
"""
|
||||
"""
|
||||
backend/app/api/admin/users.py
|
||||
|
||||
用途:管理后台用户 CRUD API(薄路由层)。
|
||||
依赖:admin.blueprint、services/admin/user_service、core.auth.jwt。
|
||||
逻辑:/users* 路由。
|
||||
鐢ㄩ€旓細绠$悊鍚庡彴鐢ㄦ埛 CRUD API锛堣杽璺敱灞傦級銆?
|
||||
渚濊禆锛歛dmin.blueprint銆乻ervices/admin/user_service銆乧ore.auth.jwt銆?
|
||||
閫昏緫锛?users* 璺敱銆?
|
||||
"""
|
||||
from flask import jsonify, request
|
||||
|
||||
@@ -20,7 +20,7 @@ def _query_params() -> dict[str, str]:
|
||||
@admin_bp.route('/users', methods=['GET'])
|
||||
@require_admin
|
||||
def list_users():
|
||||
"""列出管理端用户(支持分页与筛选)。"""
|
||||
"""Admin user operation."""
|
||||
result = user_service.list_users(_query_params())
|
||||
return jsonify(result)
|
||||
|
||||
@@ -28,7 +28,7 @@ def list_users():
|
||||
@admin_bp.route('/users', methods=['POST'])
|
||||
@require_admin
|
||||
def create_user():
|
||||
"""创建用户并同步 Casdoor。"""
|
||||
"""Admin user operation."""
|
||||
data = request.get_json() or {}
|
||||
payload = user_service.create_user(data)
|
||||
return jsonify(payload), 201
|
||||
@@ -37,7 +37,7 @@ def create_user():
|
||||
@admin_bp.route('/users/<int:id>', methods=['PUT'])
|
||||
@require_admin
|
||||
def update_user(id: int):
|
||||
"""更新用户资料;有 password 时同步 Casdoor 改密。"""
|
||||
"""Admin user operation."""
|
||||
data = request.get_json() or {}
|
||||
return jsonify(user_service.update_user(id, data))
|
||||
|
||||
@@ -45,14 +45,14 @@ def update_user(id: int):
|
||||
@admin_bp.route('/users/cleanup-rejected', methods=['POST'])
|
||||
@require_admin
|
||||
def cleanup_rejected_users():
|
||||
"""批量删除 status=rejected 的用户。"""
|
||||
"""Admin user operation."""
|
||||
return jsonify(user_service.cleanup_rejected_users())
|
||||
|
||||
|
||||
@admin_bp.route('/users/batch-delete', methods=['POST'])
|
||||
@require_admin
|
||||
def batch_delete_users():
|
||||
"""批量删除用户(排除当前登录管理员)。"""
|
||||
"""Admin user operation."""
|
||||
data = request.get_json() or {}
|
||||
current_user = _get_auth_user()
|
||||
current_user_id = current_user.id if current_user else None
|
||||
@@ -62,21 +62,7 @@ def batch_delete_users():
|
||||
@admin_bp.route('/users/<int:id>', methods=['DELETE'])
|
||||
@require_admin
|
||||
def delete_user(id: int):
|
||||
"""删除单个用户。"""
|
||||
"""Admin user operation."""
|
||||
current_user = _get_auth_user()
|
||||
current_user_id = current_user.id if current_user else None
|
||||
return jsonify(user_service.delete_user(id, current_user_id=current_user_id))
|
||||
|
||||
|
||||
@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))
|
||||
@@ -130,4 +130,8 @@ class GeneralFeedback(Base):
|
||||
feedback_module: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
content: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
source_page: Mapped[Optional[str]] = mapped_column(String(32))
|
||||
# 处理状态:pending=待处理,closed=已关闭(数据分析卡片用;默认待处理)
|
||||
status: Mapped[str] = mapped_column(String(20), default='pending', nullable=False, index=True)
|
||||
# 关闭时间:记录何时被处理/关闭,用于「本月已关闭」统计
|
||||
closed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, index=True)
|
||||
@@ -15,7 +15,13 @@ import requests
|
||||
from app import db
|
||||
from app.core.config.settings import Config
|
||||
from app.core.errors import NotFoundError, ValidationError
|
||||
from app.models import Agent, User
|
||||
from app.models import (
|
||||
Agent, AgentDirectoryMember, ChatLog, ChatSession, ChatToolRun,
|
||||
ContractReview, FaqHotCandidate, Feedback, GeneralFeedback,
|
||||
PermissionRequest, QuickQuestion, ScheduleTask, User,
|
||||
UserDefaultAgent, UserFavoriteAgent, user_agent_permissions,
|
||||
)
|
||||
from sqlalchemy import delete, select, update
|
||||
from app.services.agent_directory import normalize_directory_member_ids, replace_directory_members
|
||||
from app.services.admin.training_exam_pdf_service import parse_training_question_bank_from_guide
|
||||
from app.services.agent_registry.admin_payload import apply_agent_payload, validate_agent_payload
|
||||
@@ -112,11 +118,40 @@ def update_agent(agent_id: int, data: dict[str, Any]) -> None:
|
||||
|
||||
|
||||
def delete_agent(agent_id: int) -> None:
|
||||
"""删除 Agent(不存在时静默成功)。"""
|
||||
"""
|
||||
删除 Agent 及其数据库引用,避免 chat_logs 外键导致管理端删除失败。
|
||||
|
||||
[STEP 1] 清理权限、目录、收藏、默认入口及业务直接引用。
|
||||
[STEP 2] 先清理 chat_log 子表,再删除会话日志。
|
||||
[STEP 3] 最后删除 Agent,整段操作使用当前事务保证原子性。
|
||||
"""
|
||||
agent = db.session.get(Agent, agent_id)
|
||||
if agent:
|
||||
db.session.delete(agent)
|
||||
db.session.commit()
|
||||
if not agent:
|
||||
return
|
||||
chat_log_ids = select(ChatLog.id).where(ChatLog.agent_id == agent_id)
|
||||
db.session.execute(delete(user_agent_permissions).where(user_agent_permissions.c.agent_id == agent_id))
|
||||
db.session.execute(delete(AgentDirectoryMember).where(
|
||||
(AgentDirectoryMember.directory_agent_id == agent_id)
|
||||
| (AgentDirectoryMember.member_agent_id == agent_id)
|
||||
))
|
||||
db.session.execute(delete(UserFavoriteAgent).where(UserFavoriteAgent.agent_id == agent_id))
|
||||
db.session.execute(delete(UserDefaultAgent).where(UserDefaultAgent.agent_id == agent_id))
|
||||
db.session.execute(update(User).where(User.default_agent_id == agent_id).values(default_agent_id=None))
|
||||
db.session.execute(update(ScheduleTask).where(ScheduleTask.dify_agent_id == agent_id).values(dify_agent_id=None))
|
||||
db.session.execute(delete(PermissionRequest).where(PermissionRequest.agent_id == agent_id))
|
||||
db.session.execute(delete(ContractReview).where(ContractReview.agent_id == agent_id))
|
||||
db.session.execute(delete(QuickQuestion).where(QuickQuestion.agent_id == agent_id))
|
||||
db.session.execute(delete(FaqHotCandidate).where(FaqHotCandidate.agent_id == agent_id))
|
||||
db.session.execute(delete(ChatSession).where(ChatSession.agent_id == agent_id))
|
||||
db.session.execute(delete(ChatToolRun).where(
|
||||
(ChatToolRun.agent_id == agent_id) | ChatToolRun.chat_log_id.in_(chat_log_ids)
|
||||
))
|
||||
db.session.execute(delete(Feedback).where(Feedback.chat_log_id.in_(chat_log_ids)))
|
||||
db.session.execute(delete(GeneralFeedback).where(GeneralFeedback.chat_log_id.in_(chat_log_ids)))
|
||||
db.session.execute(delete(ContractReview).where(ContractReview.chat_log_id.in_(chat_log_ids)))
|
||||
db.session.execute(delete(ChatLog).where(ChatLog.agent_id == agent_id))
|
||||
db.session.delete(agent)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def test_agent_connectivity(agent_id: int) -> dict[str, Any]:
|
||||
@@ -170,68 +205,65 @@ def _test_iframe_agent(agent: Agent, tested_at: str) -> dict[str, Any]:
|
||||
|
||||
|
||||
def _test_dify_agent(agent: Agent, tested_at: str) -> dict[str, Any]:
|
||||
"""
|
||||
Test Dify endpoint reachability without executing the configured application flow.
|
||||
|
||||
The test calls Dify's read-only ``/v1/parameters`` endpoint so a business
|
||||
Chatflow/Workflow never receives synthetic text such as ``OK`` that could be
|
||||
passed into a database or other external tool.
|
||||
"""
|
||||
if not agent.dify_api_key:
|
||||
return {
|
||||
'passed': False,
|
||||
'request_url': '',
|
||||
'output_info': 'Missing dify_api_key.',
|
||||
'analysis': '测试失败:未配置 API Key。',
|
||||
'analysis': '\u6d4b\u8bd5\u5931\u8d25\uff1a\u672a\u914d\u7f6e API Key\u3002',
|
||||
'http_status': 0,
|
||||
'tested_at': tested_at,
|
||||
}
|
||||
|
||||
base_url = (agent.api_base_url or Config.DIFY_API_BASE or '').rstrip('/')
|
||||
if not base_url:
|
||||
return {
|
||||
'passed': False,
|
||||
'request_url': '',
|
||||
'output_info': 'Missing api_base_url.',
|
||||
'analysis': '测试失败:未配置 API Base URL。',
|
||||
'analysis': '\u6d4b\u8bd5\u5931\u8d25\uff1a\u672a\u914d\u7f6e API Base URL\u3002',
|
||||
'http_status': 0,
|
||||
'tested_at': tested_at,
|
||||
}
|
||||
|
||||
dify_app_type = str(agent.dify_app_type or 'chatflow').strip().lower()
|
||||
if dify_app_type not in ('chatflow', 'workflow'):
|
||||
dify_app_type = 'chatflow'
|
||||
if dify_app_type == 'workflow':
|
||||
request_url = DifyService._build_workflow_url(base_url)
|
||||
payload = {
|
||||
'inputs': {'query': '系统连通性测试,请简短回复OK。'},
|
||||
'response_mode': 'blocking',
|
||||
'user': 'admin_test',
|
||||
}
|
||||
else:
|
||||
request_url = DifyService._build_chat_messages_url(base_url)
|
||||
payload = {
|
||||
'inputs': {},
|
||||
'query': '系统连通性测试,请简短回复OK。',
|
||||
'response_mode': 'blocking',
|
||||
'user': 'admin_test',
|
||||
}
|
||||
headers = {'Authorization': f'Bearer {agent.dify_api_key}', 'Content-Type': 'application/json'}
|
||||
|
||||
# [STEP 1] Read-only endpoint: never run a business Chatflow/Workflow in an admin connectivity test.
|
||||
request_url = DifyService._build_parameters_url(base_url)
|
||||
headers = {'Authorization': f'Bearer {agent.dify_api_key}'}
|
||||
try:
|
||||
resp = requests.post(request_url, headers=headers, json=payload, timeout=(5, 25))
|
||||
raw_text = (resp.text or '')[:4000]
|
||||
response = requests.get(request_url, headers=headers, timeout=(5, 15))
|
||||
raw_text = (response.text or '')[:4000]
|
||||
output_info = raw_text
|
||||
passed = False
|
||||
analysis = f'测试失败:HTTP {resp.status_code}。'
|
||||
if dify_app_type == 'workflow' and 200 <= resp.status_code < 300:
|
||||
if response.ok:
|
||||
passed = True
|
||||
analysis = '测试通过:Workflow 接口可访问且认证通过。'
|
||||
try:
|
||||
data = resp.json()
|
||||
if dify_app_type == 'workflow':
|
||||
passed, output_info, analysis = _parse_workflow_test_response(resp, data, output_info, analysis)
|
||||
else:
|
||||
passed, output_info, analysis = _parse_chatflow_test_response(resp, data, output_info, analysis, passed)
|
||||
except ValueError:
|
||||
if resp.ok and raw_text.strip():
|
||||
passed = True
|
||||
analysis = (
|
||||
'测试通过:Workflow 接口可访问并返回了文本内容。'
|
||||
if dify_app_type == 'workflow'
|
||||
else '测试通过:Chatflow 接口可访问并返回了文本内容。'
|
||||
)
|
||||
if passed and (not agent.is_active):
|
||||
analysis = '\u6d4b\u8bd5\u901a\u8fc7\uff1aDify \u53c2\u6570\u63a5\u53e3\u53ef\u8bbf\u95ee\u4e14 API Key \u8ba4\u8bc1\u901a\u8fc7\u3002'
|
||||
try:
|
||||
body = response.json()
|
||||
if isinstance(body, dict):
|
||||
output_info = str(body)[:4000]
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
passed = False
|
||||
analysis = f'\u6d4b\u8bd5\u5931\u8d25\uff1aHTTP {response.status_code}\u3002'
|
||||
try:
|
||||
body = response.json()
|
||||
if isinstance(body, dict) and body.get('message'):
|
||||
output_info = str(body['message'])[:4000]
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if passed and not agent.is_active:
|
||||
agent.is_active = True
|
||||
db.session.commit()
|
||||
return {
|
||||
@@ -240,7 +272,7 @@ def _test_dify_agent(agent: Agent, tested_at: str) -> dict[str, Any]:
|
||||
'request_url': request_url,
|
||||
'output_info': output_info,
|
||||
'analysis': analysis,
|
||||
'http_status': resp.status_code,
|
||||
'http_status': response.status_code,
|
||||
'tested_at': tested_at,
|
||||
}
|
||||
except requests.RequestException as exc:
|
||||
@@ -249,12 +281,11 @@ def _test_dify_agent(agent: Agent, tested_at: str) -> dict[str, Any]:
|
||||
'dify_app_type': dify_app_type,
|
||||
'request_url': request_url,
|
||||
'output_info': str(exc),
|
||||
'analysis': '测试失败:请求异常(网络、超时或认证问题)。',
|
||||
'analysis': '\u6d4b\u8bd5\u5931\u8d25\uff1a\u8bf7\u6c42\u5f02\u5e38\uff08\u7f51\u7edc\u3001\u8d85\u65f6\u6216\u8ba4\u8bc1\u95ee\u9898\uff09\u3002',
|
||||
'http_status': 0,
|
||||
'tested_at': tested_at,
|
||||
}
|
||||
|
||||
|
||||
def _parse_workflow_test_response(resp, data, output_info: str, analysis: str) -> tuple[bool, str, str]:
|
||||
passed = 200 <= resp.status_code < 300
|
||||
workflow_data = data.get('data') if isinstance(data, dict) else None
|
||||
|
||||
@@ -10,7 +10,7 @@ from __future__ import annotations
|
||||
from sqlalchemy import func
|
||||
|
||||
from app import db
|
||||
from app.models import Agent, ChatLog, Feedback, PermissionRequest, User
|
||||
from app.models import Agent, ChatLog, Feedback, User
|
||||
|
||||
|
||||
def compute_dashboard_summary() -> dict:
|
||||
@@ -32,29 +32,12 @@ def compute_dashboard_summary() -> dict:
|
||||
}
|
||||
|
||||
|
||||
def compute_dashboard_badges() -> dict:
|
||||
"""
|
||||
聚合侧栏角标所需的待办数量。
|
||||
Returns:
|
||||
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
|
||||
return {
|
||||
'pending_approvals': pending_approvals,
|
||||
'pending_requests': pending_requests,
|
||||
}
|
||||
|
||||
|
||||
def compute_legacy_dashboard_stats() -> dict:
|
||||
"""遗留 /dashboard 接口响应(summary + badges 字段名兼容早期前端)。"""
|
||||
summary = compute_dashboard_summary()
|
||||
badges = compute_dashboard_badges()
|
||||
return {
|
||||
'total_users': summary['user_count'],
|
||||
'active_agents': summary['agent_count'],
|
||||
'total_conversations': summary['total_conversations'],
|
||||
'avg_score': summary['avg_score'],
|
||||
'pending_approvals': badges['pending_approvals'],
|
||||
'pending_requests': badges['pending_requests'],
|
||||
}
|
||||
@@ -19,7 +19,6 @@ from app.models import (
|
||||
ChatLog,
|
||||
Department,
|
||||
Feedback,
|
||||
PermissionRequest,
|
||||
QuickQuestion,
|
||||
User,
|
||||
UserDefaultAgent,
|
||||
@@ -33,7 +32,6 @@ ADMIN_TABLE_MODEL_MAP = {
|
||||
'agents': Agent,
|
||||
'chat_logs': ChatLog,
|
||||
'feedbacks': Feedback,
|
||||
'permission_requests': PermissionRequest,
|
||||
'departments': Department,
|
||||
'quick_questions': QuickQuestion,
|
||||
'user_homepage_configs': UserHomepageConfig,
|
||||
@@ -52,6 +50,35 @@ def _serialize_model_row(item) -> dict:
|
||||
return row
|
||||
|
||||
|
||||
def _apply_generic_table_filters(query, model, query_params: dict[str, str]):
|
||||
"""通用表筛选:created_at 时间范围(created_from/created_to)+ 各列 ILIKE/等值过滤。"""
|
||||
reserved = {'created_from', 'created_to'}
|
||||
# 时间范围(支持有 created_at 列的通用表,如 feedbacks 回答评价)
|
||||
created_from = (query_params.get('created_from') or '').strip()
|
||||
created_to = (query_params.get('created_to') or '').strip()
|
||||
if created_from and hasattr(model, 'created_at'):
|
||||
dt = report_service._parse_datetime(created_from, end_of_day=False)
|
||||
if dt:
|
||||
query = query.filter(model.created_at >= dt)
|
||||
if created_to and hasattr(model, 'created_at'):
|
||||
dt = report_service._parse_datetime(created_to, end_of_day=True)
|
||||
if dt:
|
||||
query = query.filter(model.created_at <= dt)
|
||||
|
||||
for key, value in query_params.items():
|
||||
if key in reserved or not value:
|
||||
continue
|
||||
if hasattr(model, key):
|
||||
col = getattr(model, key)
|
||||
col_type = getattr(col, 'type', None)
|
||||
# 整型外键(如 agent_id)用等值过滤,避免 ILIKE '%16%' 误匹配 160
|
||||
if value.isdigit() and col_type is not None and getattr(col_type, 'python_type', None) is int:
|
||||
query = query.filter(col == int(value))
|
||||
else:
|
||||
query = query.filter(col.cast(db.String).ilike(f'%{value}%'))
|
||||
return query
|
||||
|
||||
|
||||
def get_table_data(table: str, query_params: dict[str, str]) -> list[dict]:
|
||||
"""
|
||||
返回管理报表表数据(最多 100 行)。
|
||||
@@ -62,28 +89,20 @@ def get_table_data(table: str, query_params: dict[str, str]) -> list[dict]:
|
||||
model = ADMIN_TABLE_MODEL_MAP.get(table)
|
||||
if not model:
|
||||
raise ValidationError('Invalid table')
|
||||
query = db.session.query(model)
|
||||
for key, value in query_params.items():
|
||||
if hasattr(model, key) and value:
|
||||
col = getattr(model, key)
|
||||
col_type = getattr(col, 'type', None)
|
||||
# 整型外键(如 agent_id)用等值过滤,避免 ILIKE '%16%' 误匹配 160
|
||||
if value.isdigit() and col_type is not None and getattr(col_type, 'python_type', None) is int:
|
||||
query = query.filter(col == int(value))
|
||||
else:
|
||||
query = query.filter(col.cast(db.String).ilike(f'%{value}%'))
|
||||
query = _apply_generic_table_filters(db.session.query(model), model, query_params)
|
||||
items = query.limit(100).all()
|
||||
return [_serialize_model_row(item) for item in items]
|
||||
|
||||
|
||||
def get_table_count(table: str, query_params: dict[str, str]) -> dict:
|
||||
"""返回表行数;chat_logs 使用报表筛选。"""
|
||||
"""返回表行数(应用当前筛选);chat_logs 使用报表筛选。"""
|
||||
if table == 'chat_logs':
|
||||
return report_service.count_chat_logs_report(query_params)
|
||||
model = ADMIN_TABLE_MODEL_MAP.get(table)
|
||||
if not model:
|
||||
raise ValidationError('Invalid table')
|
||||
total = db.session.query(func.count(model.id)).scalar()
|
||||
query = _apply_generic_table_filters(db.session.query(model), model, query_params)
|
||||
total = query.count()
|
||||
return {'table': table, 'total': int(total or 0)}
|
||||
|
||||
|
||||
|
||||
@@ -9,9 +9,11 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import func
|
||||
|
||||
from app import db
|
||||
from app.core.errors import NotFoundError, ValidationError
|
||||
from app.models import Department
|
||||
from app.models import Department, User
|
||||
|
||||
|
||||
def serialize_department(dept: Department) -> dict:
|
||||
@@ -27,8 +29,43 @@ def serialize_department(dept: Department) -> dict:
|
||||
|
||||
def list_departments() -> list[dict]:
|
||||
"""返回全部部门(按 name 升序)。"""
|
||||
depts = db.session.query(Department).order_by(Department.name.asc()).all()
|
||||
return [serialize_department(d) for d in depts]
|
||||
rows = (
|
||||
db.session.query(Department, func.count(User.id).label('member_count'))
|
||||
.outerjoin(User, User.department == Department.name)
|
||||
.group_by(Department.id)
|
||||
.order_by(Department.name.asc())
|
||||
.all()
|
||||
)
|
||||
return [{**serialize_department(dept), 'member_count': int(member_count or 0)} for dept, member_count in rows]
|
||||
|
||||
|
||||
def list_department_members(dept_id: int) -> dict:
|
||||
"""
|
||||
查询指定部门的员工名单。
|
||||
|
||||
[STEP 1] 通过部门主键读取部门名称。
|
||||
[STEP 2] 复用现有 users.department 文本关联查询成员。
|
||||
[STEP 3] 返回人数与脱敏后的管理端成员资料。
|
||||
"""
|
||||
dept = db.session.get(Department, dept_id)
|
||||
if not dept:
|
||||
raise NotFoundError('Not found')
|
||||
users = db.session.query(User).filter(User.department == dept.name).order_by(User.real_name.asc(), User.username.asc()).all()
|
||||
return {
|
||||
'department': serialize_department(dept),
|
||||
'count': len(users),
|
||||
'members': [
|
||||
{
|
||||
'id': user.id,
|
||||
'username': user.username,
|
||||
'real_name': user.real_name,
|
||||
'employee_id': user.employee_id,
|
||||
'email': user.email,
|
||||
'status': user.status,
|
||||
}
|
||||
for user in users
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def create_department(data: dict[str, Any]) -> dict:
|
||||
|
||||
@@ -1,35 +1,22 @@
|
||||
"""
|
||||
backend/app/services/admin/permission_service.py
|
||||
|
||||
用途:用户 Agent 权限批量/单用户更新,以及权限申请审批业务逻辑。
|
||||
依赖:models、wecom_notify.send_wecom_event_message。
|
||||
用途:用户 Agent 权限批量/单用户更新业务逻辑。
|
||||
依赖:models、integrations.wecom.notify.send_wecom_event_message。
|
||||
逻辑:由 api/admin/permissions.py 调用;users 路由 /users/<id>/permissions 亦委托本模块。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from app import db
|
||||
from app.core.errors import NotFoundError, ValidationError
|
||||
from app.models import Agent, PermissionRequest, User
|
||||
from app.models import Agent, User
|
||||
from app.services.integrations.wecom.notify import send_wecom_event_message
|
||||
|
||||
_BATCH_ACTION_LABELS = {'add': '新增', 'remove': '移除', 'set': '重置为'}
|
||||
|
||||
|
||||
def serialize_permission_request(req: PermissionRequest) -> dict:
|
||||
"""PermissionRequest ORM → 管理端列表 JSON。"""
|
||||
return {
|
||||
'id': req.id,
|
||||
'user_id': req.user_id,
|
||||
'agent_id': req.agent_id,
|
||||
'reason': req.reason,
|
||||
'status': req.status,
|
||||
'created_at': req.created_at.isoformat(),
|
||||
}
|
||||
|
||||
|
||||
def _load_users_and_agents(user_ids: list[Any], agent_ids: list[Any]) -> tuple[list[User], list[Agent]]:
|
||||
users = db.session.query(User).filter(User.id.in_(user_ids)).all()
|
||||
agents = db.session.query(Agent).filter(Agent.id.in_(agent_ids)).all()
|
||||
@@ -108,67 +95,3 @@ def update_user_permissions(user_id: int, data: dict[str, Any]) -> dict:
|
||||
user.agents = agents
|
||||
db.session.commit()
|
||||
return {'status': 'ok'}
|
||||
|
||||
|
||||
def list_permission_requests() -> list[dict]:
|
||||
"""返回全部权限申请(按 created_at 降序)。"""
|
||||
reqs = (
|
||||
db.session.query(PermissionRequest)
|
||||
.order_by(PermissionRequest.created_at.desc())
|
||||
.all()
|
||||
)
|
||||
return [serialize_permission_request(r) for r in reqs]
|
||||
|
||||
|
||||
def approve_permission_request(request_id: int) -> dict:
|
||||
"""
|
||||
批准权限申请:更新状态并将 Agent 加入用户权限。
|
||||
Raises:
|
||||
NotFoundError: 申请不存在。
|
||||
"""
|
||||
req = db.session.get(PermissionRequest, request_id)
|
||||
if not req:
|
||||
raise NotFoundError('Not found')
|
||||
|
||||
user = db.session.get(User, req.user_id)
|
||||
agent = db.session.get(Agent, req.agent_id)
|
||||
req.status = 'approved'
|
||||
req.reviewed_at = datetime.utcnow()
|
||||
if user and agent and (agent not in user.agents):
|
||||
user.agents.append(agent)
|
||||
if user and user.wecom_userid:
|
||||
send_wecom_event_message(
|
||||
event_type='permission_request_approved',
|
||||
user=user,
|
||||
title='权限申请已通过',
|
||||
content=f'你申请的应用权限已通过:{(agent.name if agent else req.agent_id)}',
|
||||
jump_path='/workspace',
|
||||
)
|
||||
db.session.commit()
|
||||
return {'status': 'ok'}
|
||||
|
||||
|
||||
def reject_permission_request(request_id: int) -> dict:
|
||||
"""
|
||||
拒绝权限申请并通知用户(若已绑定企微)。
|
||||
Raises:
|
||||
NotFoundError: 申请不存在。
|
||||
"""
|
||||
req = db.session.get(PermissionRequest, request_id)
|
||||
if not req:
|
||||
raise NotFoundError('Not found')
|
||||
|
||||
req.status = 'rejected'
|
||||
req.reviewed_at = datetime.utcnow()
|
||||
user = db.session.get(User, req.user_id)
|
||||
agent = db.session.get(Agent, req.agent_id)
|
||||
if user and user.wecom_userid:
|
||||
send_wecom_event_message(
|
||||
event_type='permission_request_rejected',
|
||||
user=user,
|
||||
title='权限申请未通过',
|
||||
content=f'你申请的应用权限未通过:{(agent.name if agent else req.agent_id)}',
|
||||
jump_path='/workspace',
|
||||
)
|
||||
db.session.commit()
|
||||
return {'status': 'ok'}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
backend/migrations/versions/0f1e2d3c4b5a_add_general_feedback_status.py
|
||||
|
||||
用途:给 general_feedbacks 增加处理状态字段,支撑「用户反馈与回答评价」的三张概览卡
|
||||
(待处理 / 本月已关闭 / 最多反馈应用)。
|
||||
依赖:Alembic revision a0b1c2d3e4f5(当前唯一 head)。
|
||||
逻辑:新增 status(默认 pending)与 closed_at(可空)两列;仅 DDL,不回填历史数据。
|
||||
|
||||
Revision ID: 0f1e2d3c4b5a
|
||||
Revises: a0b1c2d3e4f5
|
||||
Create Date: 2026-08-28 09:00:00.000000
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "0f1e2d3c4b5a"
|
||||
down_revision = "a0b1c2d3e4f5"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.add_column(
|
||||
'general_feedbacks',
|
||||
sa.Column('status', sa.String(20), nullable=False, server_default='pending'),
|
||||
)
|
||||
op.create_index('ix_general_feedbacks_status', 'general_feedbacks', ['status'])
|
||||
op.add_column(
|
||||
'general_feedbacks',
|
||||
sa.Column('closed_at', sa.DateTime(), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_column('general_feedbacks', 'closed_at')
|
||||
op.drop_index('ix_general_feedbacks_status', table_name='general_feedbacks')
|
||||
op.drop_column('general_feedbacks', 'status')
|
||||
@@ -0,0 +1,24 @@
|
||||
"""merge feedback status and lean training heads
|
||||
|
||||
Revision ID: 353ebb6187ce
|
||||
Revises: 0f1e2d3c4b5a, fb26bc033d27
|
||||
Create Date: 2026-09-14 08:29:33.122865
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '353ebb6187ce'
|
||||
down_revision = ('0f1e2d3c4b5a', 'fb26bc033d27')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -0,0 +1,24 @@
|
||||
"""merge snow feedback status and dev transfer naming heads
|
||||
|
||||
Revision ID: 6d7b0d04ac25
|
||||
Revises: 353ebb6187ce, 43a8179cdd88
|
||||
Create Date: 2026-09-23 13:45:05.502424
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '6d7b0d04ac25'
|
||||
down_revision = ('353ebb6187ce', '43a8179cdd88')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
||||
@@ -10,7 +10,7 @@ import json
|
||||
from unittest.mock import MagicMock, patch
|
||||
from flask import g
|
||||
from app import create_app, db
|
||||
from app.models import User, Agent, ChatLog, Feedback, PermissionRequest, QuickQuestion
|
||||
from app.models import User, Agent, ChatLog, Feedback, QuickQuestion
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Fixtures (Setup & Teardown)
|
||||
@@ -65,11 +65,6 @@ def mock_chat_log_query(mocker):
|
||||
"""Mock ChatLog.query"""
|
||||
return mocker.patch('app.models.ChatLog.query')
|
||||
|
||||
@pytest.fixture
|
||||
def mock_permission_request_query(mocker):
|
||||
"""Mock PermissionRequest.query"""
|
||||
return mocker.patch('app.models.PermissionRequest.query')
|
||||
|
||||
@pytest.fixture
|
||||
def mock_quick_question_query(mocker):
|
||||
"""Mock QuickQuestion.query"""
|
||||
@@ -332,44 +327,6 @@ def test_admin_delete_agent(client, admin_headers, mock_agent_query, mock_db_ses
|
||||
mock_db_session.delete.assert_called_once_with(mock_agent)
|
||||
mock_db_session.commit.assert_called_once()
|
||||
|
||||
def test_admin_approve_user(client, admin_headers, mock_user_query, mock_db_session, mocker):
|
||||
"""
|
||||
[Admin] 审批用户 (Happy Path)
|
||||
"""
|
||||
# Arrange
|
||||
mock_user = User(id=2, status="pending")
|
||||
mock_user_query.get.return_value = mock_user
|
||||
|
||||
admin_user = User(role='admin', username='admin')
|
||||
mocker.patch('app.core.decorators._get_current_user', return_value=admin_user)
|
||||
|
||||
# Act
|
||||
response = client.post('/api/admin/users/2/approve', headers=admin_headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
assert mock_user.status == 'active'
|
||||
mock_db_session.commit.assert_called_once()
|
||||
|
||||
def test_admin_reject_user(client, admin_headers, mock_user_query, mock_db_session, mocker):
|
||||
"""
|
||||
[Admin] 拒绝用户 (Happy Path)
|
||||
"""
|
||||
# Arrange
|
||||
mock_user = User(id=3, status="pending")
|
||||
mock_user_query.get.return_value = mock_user
|
||||
|
||||
admin_user = User(role='admin', username='admin')
|
||||
mocker.patch('app.core.decorators._get_current_user', return_value=admin_user)
|
||||
|
||||
# Act
|
||||
response = client.post('/api/admin/users/3/reject', headers=admin_headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
assert mock_user.status == 'rejected'
|
||||
mock_db_session.commit.assert_called_once()
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# 3. Chat System Tests (Mocking External API)
|
||||
# -----------------------------------------------------------------------------
|
||||
@@ -502,84 +459,7 @@ def test_submit_feedback_invalid_score(client, mocker, mock_agent_query):
|
||||
assert "between 1 and 5" in response.get_json()['error']
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# 4. Permission Request Tests
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def test_create_permission_request(client, mocker, mock_db_session, mock_agent_query, mock_permission_request_query):
|
||||
"""
|
||||
[Permission] 用户申请权限 (Happy Path)
|
||||
"""
|
||||
# Arrange
|
||||
mock_user = User(id=1, agents=[])
|
||||
mock_agent = Agent(id=5)
|
||||
|
||||
mocker.patch('app.api.user._get_current_user', return_value=mock_user)
|
||||
mock_agent_query.get.return_value = mock_agent
|
||||
|
||||
# Ensure no existing pending request
|
||||
mock_permission_request_query.filter_by.return_value.first.return_value = None
|
||||
|
||||
# Act
|
||||
payload = {"agent_id": 5, "reason": "Need access"}
|
||||
response = client.post('/api/user/permission-requests', json=payload)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 201
|
||||
mock_db_session.add.assert_called_once()
|
||||
mock_db_session.commit.assert_called_once()
|
||||
|
||||
def test_create_permission_request_already_exists(client, mocker, mock_agent_query, mock_permission_request_query):
|
||||
"""
|
||||
[Permission] 用户重复申请权限 (Error)
|
||||
"""
|
||||
# Arrange
|
||||
mock_user = User(id=1, agents=[])
|
||||
mock_agent = Agent(id=5)
|
||||
|
||||
mocker.patch('app.api.user._get_current_user', return_value=mock_user)
|
||||
mock_agent_query.get.return_value = mock_agent
|
||||
|
||||
# Mock existing pending request
|
||||
mock_permission_request_query.filter_by.return_value.first.return_value = PermissionRequest(id=1)
|
||||
|
||||
# Act
|
||||
payload = {"agent_id": 5}
|
||||
response = client.post('/api/user/permission-requests', json=payload)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 400
|
||||
assert "Request already pending" in response.get_json()['error']
|
||||
|
||||
def test_admin_approve_permission_request(client, admin_headers, mock_permission_request_query, mock_user_query, mock_agent_query, mock_db_session, mocker):
|
||||
"""
|
||||
[Admin] 同意权限申请 (Happy Path)
|
||||
"""
|
||||
# Arrange
|
||||
mock_pr = PermissionRequest(id=1, user_id=2, agent_id=5, status='pending')
|
||||
mock_user = User(id=2, agents=[])
|
||||
mock_agent = Agent(id=5)
|
||||
|
||||
# Mock PermissionRequest.query.get
|
||||
mock_permission_request_query.get.return_value = mock_pr
|
||||
# Mock User.query.get
|
||||
mock_user_query.get.return_value = mock_user
|
||||
# Mock Agent.query.get
|
||||
mock_agent_query.get.return_value = mock_agent
|
||||
|
||||
admin_user = User(role='admin', username='admin')
|
||||
mocker.patch('app.core.decorators._get_current_user', return_value=admin_user)
|
||||
|
||||
# Act
|
||||
response = client.post('/api/admin/permission-requests/1/approve', headers=admin_headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
assert mock_pr.status == 'approved'
|
||||
assert mock_agent in mock_user.agents
|
||||
mock_db_session.commit.assert_called_once()
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# 5. Quick Question Tests
|
||||
# 4. Quick Question Tests
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
def test_add_quick_question(client, mocker, mock_db_session):
|
||||
|
||||
+1
-2
@@ -45,7 +45,6 @@ services:
|
||||
- KB_WORKER_POLL_SECONDS=${KB_WORKER_POLL_SECONDS:-2}
|
||||
# kb-worker 自动回收长时间 running 的任务(秒)
|
||||
- KB_JOB_RUNNING_TIMEOUT_SECONDS=${KB_JOB_RUNNING_TIMEOUT_SECONDS:-1200}
|
||||
|
||||
# 采购合同异步审核:清洗产物与任务/模型输入保护
|
||||
- PROCUREMENT_CONTRACT_STORAGE_ROOT=${PROCUREMENT_CONTRACT_STORAGE_ROOT:-/app/data/procurement_contract}
|
||||
- PROCUREMENT_CONTRACT_JOB_TIMEOUT_SECONDS=${PROCUREMENT_CONTRACT_JOB_TIMEOUT_SECONDS:-600}
|
||||
@@ -118,7 +117,7 @@ services:
|
||||
- KB_WORKER_POLL_SECONDS=${KB_WORKER_POLL_SECONDS:-2}
|
||||
# kb-worker 自动回收长时间 running 的任务(秒)
|
||||
- KB_JOB_RUNNING_TIMEOUT_SECONDS=${KB_JOB_RUNNING_TIMEOUT_SECONDS:-1200}
|
||||
|
||||
|
||||
# 采购合同异步审核:Worker 与后端必须指向同一持久化目录
|
||||
- PROCUREMENT_CONTRACT_STORAGE_ROOT=${PROCUREMENT_CONTRACT_STORAGE_ROOT:-/app/data/procurement_contract}
|
||||
- PROCUREMENT_CONTRACT_JOB_TIMEOUT_SECONDS=${PROCUREMENT_CONTRACT_JOB_TIMEOUT_SECONDS:-600}
|
||||
|
||||
+8
-4
@@ -614,10 +614,14 @@
|
||||
|
||||
## 7. 管理端功能清单
|
||||
|
||||
| 功能项 | 说明 | 状态 | 优先级 |
|
||||
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ | ------ |
|
||||
| 管理端使用分析 | 管理控制台「数据报表」首项由原始用户表替换为「使用分析」,展示对话总量、活跃用户/应用、按日趋势、应用/用户排行、低使用应用与异常高峰提醒,并保留聊天明细追溯与导出 | 已实现 | P1 |
|
||||
| 管理端应用运营报表 | 「数据报表 > 应用」由 agents 配置表替换为应用运营看板:按应用聚合对话/用户/最近活跃/授权/均分,支持时间范围与状态筛选、Excel 导出,并可下钻聊天日志 | 已实现 | P1 |
|
||||
| 功能项 | 说明 | 状态 | 优先级 |
|
||||
| --- | --- | --- | --- |
|
||||
| 管理端使用分析 | 管理控制台「数据报表」首项为「使用分析」,展示对话总量、活跃用户/应用、人员/部门排行、应用排行、按日趋势、时段热力图、低使用应用与异常高峰提醒;严格不展示聊天原文 | 已实现 | P1 |
|
||||
| 管理端应用运营报表 | 「数据报表 > 应用」为应用运营看板:按应用聚合调用次数/用户数/最近活跃/授权人数/评分,支持时间范围与状态筛选、Excel 导出;识别「已授权未使用」应用,可由应用行下钻对应聊天日志筛选结果 | 已实现 | P1 |
|
||||
| 管理端用户反馈与回答评价 | 「数据报表」将原「意见反馈、回答评价」两个入口合并为「用户反馈与回答评价」,页内以「意见反馈 / 回答评价」两个 Tab 切换数据源,意见反馈 Tab 展示实时计数角标 | 已实现 | P1 |
|
||||
| 管理端运营总览 | 「数据报表」新增「运营总览」入口:展示对话量/活跃用户/活跃应用/好评率、对话趋势与环比、Top 应用与低使用应用、低评分回答与未处理反馈,复用 chat_logs/feedbacks/general_feedbacks/agents/应用授权数据 | 已实现(数据处理) | P1 |
|
||||
| 管理端问题分析 | 「数据报表」新增「问题分析」入口,第一版为页面骨架与空状态,不伪造数据 | 已实现(骨架) | P2 |
|
||||
| 管理端时间范围统一 | 「数据报表」各数据页时间范围筛选器统一为「近 7 天 / 30 天 / 90 天」,并同步四语言文案 | 已实现 | P1 |
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
# 知识库 Excel/CSV 切块与 Dify 同步
|
||||
|
||||
> 说明 Excel/CSV 清洗成 Markdown 后如何与 Dify custom 分段配合,以及版本目录下调试产物路径。
|
||||
|
||||
---
|
||||
|
||||
## 1. 问题背景
|
||||
|
||||
知识库 Excel(如 RoHS/供应商排程宽表)经 edkb 清洗成 Markdown 后,同步 Dify 时若使用默认 `process_rule.mode=automatic`,宽表 pipe 行或长段落会被 Dify 按 token/标点切散,导致**同一数据行字段落入不同 segment**,Hit testing 检索时上下文不完整。
|
||||
|
||||
典型症状:
|
||||
|
||||
- 问「某供应商编码 + 物料」命中片段只有半行字段;
|
||||
- Dify 文档分段数远大于 Excel 数据行数,或一行被拆成多段。
|
||||
|
||||
---
|
||||
|
||||
## 2. 改造后数据流
|
||||
|
||||
```text
|
||||
上传 xlsx/csv
|
||||
→ edkb loader_excel / loader_csv
|
||||
→ table_linearize(宽表行文本化 / 窄表 pipe 行 \n\n 分隔)
|
||||
→ document.md(写入 KB 版本目录)
|
||||
→ [可选] 04_chunks.jsonl / chunks/(调试,不传 Dify)
|
||||
→ sync_dify:create-by-text / update-by-text
|
||||
→ Dify process_rule.mode=custom(Excel/CSV 专用,separator=\n\n)
|
||||
```
|
||||
|
||||
### table_linearize 输出规则(摘要)
|
||||
|
||||
| 表类型 | 条件 | 输出格式 |
|
||||
| --- | --- | --- |
|
||||
| 条件/处理/责任表 | 表头含「条件」「处理」等关键词 | 每条 bullet 之间 `\n\n` |
|
||||
| 窄表 | 列数 ≤ 8 | 表头块 + 每个数据行单独 `\| ... \|` 块,行间 `\n\n` |
|
||||
| 宽表 | 列数 > 8 | `- 【行】列1=值1;列2=值2;...`,行间 `\n\n` |
|
||||
|
||||
示例(宽表,与 RoHS 排程类文件一致):
|
||||
|
||||
```markdown
|
||||
## Sheet: result
|
||||
|
||||
- 【行】供应商编码=VCCD00027;供应商名称=沃顿;物料编码=121040033400;...
|
||||
|
||||
- 【行】供应商编码=VCCD00027;供应商名称=沃顿;...
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. 配置项(KB_DIFY_*)
|
||||
|
||||
可通过 **环境变量** 或管理台 **AppSetting** 覆盖;读取入口:`get_kb_dify_settings()`。
|
||||
|
||||
| 键 | 默认值 | 含义 |
|
||||
| --- | --- | --- |
|
||||
| `KB_DIFY_PROCESS_MODE` | `custom` | 非 Excel/CSV 文档的 Dify 分段模式;按空行保留标题、规则和例外条件组成的完整知识单元 |
|
||||
| `KB_DIFY_PROCESS_MODE_EXCEL` | `custom` | xlsx / xls / csv 专用分段模式 |
|
||||
| `KB_DIFY_SEGMENT_SEPARATOR` | `\n\n`(env 写 `\\n\\n`) | custom 模式通用分隔符 |
|
||||
| `KB_DIFY_SEGMENT_SEPARATOR_EXCEL` | `\n\n` | Excel/CSV custom 分隔符,与 table_linearize 对齐 |
|
||||
| `KB_DIFY_SEGMENT_MAX_TOKENS` | `600` | custom 模式 max_tokens |
|
||||
| `KB_DIFY_SEGMENT_CHUNK_OVERLAP` | `100` | custom 模式 chunk_overlap,保留相邻段落的必要上下文 |
|
||||
| `KB_DIFY_REMOVE_URLS` | `false` | 映射 Dify `remove_urls_emails`;RoHS 等表含 PDF 链接,默认关闭 |
|
||||
|
||||
`.env` 示例:
|
||||
|
||||
```bash
|
||||
KB_DIFY_PROCESS_MODE=automatic
|
||||
KB_DIFY_PROCESS_MODE_EXCEL=custom
|
||||
KB_DIFY_SEGMENT_SEPARATOR_EXCEL=\n\n
|
||||
KB_DIFY_SEGMENT_MAX_TOKENS=800
|
||||
KB_DIFY_SEGMENT_CHUNK_OVERLAP=50
|
||||
KB_DIFY_REMOVE_URLS=false
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. 版本目录与调试文件
|
||||
|
||||
清洗完成后,单版本目录结构(相对 `backend/data/kb/` 或部署挂载路径):
|
||||
|
||||
```text
|
||||
group_XXXX/document_XXXXXX/vXXX/
|
||||
su_schedule_5.xlsx # 原始上传
|
||||
document.md # 清洗结果(sync_dify 读取此文件)
|
||||
document_preview.md # 可选,含图片预览时
|
||||
04_chunks.jsonl # 可选,edkb 切块调试(不传 Dify)
|
||||
chunks/
|
||||
chunk_0000.md
|
||||
chunk_0001.md
|
||||
...
|
||||
```
|
||||
|
||||
- `document.md`:权威同步文本;
|
||||
- `04_chunks.jsonl`:edkb export 阶段产物,一行一个 chunk JSON,便于与 Dify segment 列表对照;
|
||||
- 若清洗失败回退占位,会出现 `*.preview.txt`(含 `clean_status=placeholder_success`),**不应**作为 Dify 同步源。
|
||||
|
||||
---
|
||||
|
||||
## 5. 手动验收(curl)
|
||||
|
||||
对已有 dataset 创建文本文档,模拟 Excel custom 分段(需替换 `DATASET_ID`、`API_KEY`):
|
||||
|
||||
```bash
|
||||
curl -X POST "http://<DIFY_HOST>/v1/datasets/<DATASET_ID>/document/create-by-text" \
|
||||
-H "Authorization: Bearer <API_KEY>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"name": "excel-chunk-test.md",
|
||||
"text": "## Sheet: result\n\n- 【行】列1=a;列2=b。\n\n- 【行】列1=c;列2=d。",
|
||||
"indexing_technique": "high_quality",
|
||||
"doc_form": "text_model",
|
||||
"process_rule": {
|
||||
"mode": "custom",
|
||||
"rules": {
|
||||
"pre_processing_rules": [
|
||||
{"id": "remove_extra_spaces", "enabled": true},
|
||||
{"id": "remove_urls_emails", "enabled": false}
|
||||
],
|
||||
"segmentation": {
|
||||
"separator": "\n\n",
|
||||
"max_tokens": 800,
|
||||
"chunk_overlap": 50
|
||||
}
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 6. 对比 Dify 分段与本地 jsonl
|
||||
|
||||
1. 打开 Dify 知识库 → 该文档 → **分段列表**,记录 segment 数量与首段内容;
|
||||
2. 打开版本目录 `04_chunks.jsonl`,统计非空行数:`wc -l 04_chunks.jsonl`;
|
||||
3. 宽表场景:segment 数应接近 **数据行数**(每行一条 `【行】` bullet,经 `\n\n` 切开);
|
||||
4. 在 Dify **Hit testing** 用表中存在的「供应商编码 + 物料名称」提问,应命中包含完整行字段的片段。
|
||||
|
||||
---
|
||||
|
||||
## 7. 回滚
|
||||
|
||||
| 层级 | 做法 |
|
||||
| --- | --- |
|
||||
| Dify 分段 | 设 `KB_DIFY_PROCESS_MODE_EXCEL=automatic`,并对已有 Excel 文档 **重新 sync_dify** |
|
||||
| 清洗格式 | git revert `table_linearize` 相关提交(document.md 格式恢复旧行为) |
|
||||
| 调试文件 | 忽略 `04_chunks.jsonl`,不影响线上同步 |
|
||||
|
||||
> **发版说明**:环境变量变更后,**已有 Excel 文档需触发重新 sync_dify** 才会应用新的 `process_rule`;仅重新清洗不会更新 Dify 远端分段规则。
|
||||
|
||||
---
|
||||
|
||||
## 8. 本地开发注意
|
||||
|
||||
- API 与 KB worker 须使用同一虚拟环境:
|
||||
|
||||
```bash
|
||||
cd backend && source .venv/bin/activate
|
||||
python run.py # 终端 1
|
||||
python worker_kb.py # 终端 2
|
||||
```
|
||||
|
||||
- `.env.shared` 中 `EDKB_FILE_TIMEOUT_SEC` 对 Word 等慢格式启用 spawn 超时;**Excel/CSV 已在代码中豁免**,避免 macOS 本地 `Operation not permitted`。
|
||||
- 相关代码:`edkb_system/skills/table_linearize.py`、`app/services/knowledge_cleaning/dify_sync_service.py`、`edkb_adapter.py`。
|
||||
|
||||
---
|
||||
|
||||
## 9. 相关测试
|
||||
|
||||
```bash
|
||||
cd backend && source .venv/bin/activate
|
||||
python -m pytest tests/test_dify_sync_process_rule.py \
|
||||
tests/test_table_linearize.py \
|
||||
tests/test_kb_excel_cleaning.py \
|
||||
tests/test_edkb_adapter_chunks.py \
|
||||
tests/test_edkb_file_timeout.py -q
|
||||
```
|
||||
@@ -0,0 +1,175 @@
|
||||
# 主平台知识库运行时部署说明
|
||||
|
||||
## 目标
|
||||
|
||||
将知识库上传、清洗、Dify 同步运行时统一收敛到主平台 `hxops&xinxin`,不再依赖 `xinxin2` 独立运行 `api + worker + redis`。
|
||||
|
||||
当前主平台 `docker-compose.yml` 已接入:
|
||||
|
||||
- `kb-redis`
|
||||
- `hxops-backend`
|
||||
- `hxops-kb-worker`
|
||||
- `hxops-frontend`
|
||||
- 共享卷 `hxops_runtime_data`
|
||||
|
||||
## 容器职责
|
||||
|
||||
### `hxops-backend`
|
||||
|
||||
- 提供主平台 API
|
||||
- 提供知识库 API:`/api/kb/*`
|
||||
- 提供集成 API:`/api/integration/*`
|
||||
- 挂载知识库存储根目录到 `/app/data`
|
||||
|
||||
### `hxops-kb-worker`
|
||||
|
||||
- 轮询执行知识库 `clean` 任务
|
||||
- 复用后端镜像,避免维护第二套依赖
|
||||
- 与后端共享数据库、Redis、知识库存储卷
|
||||
|
||||
### `kb-redis`
|
||||
|
||||
- 提供知识库异步任务所需 Redis
|
||||
- 当前主要用于主平台知识库运行时接入与后续队列化扩展
|
||||
|
||||
## 关键环境变量
|
||||
|
||||
部署主平台知识库运行时时,至少确认以下变量:
|
||||
|
||||
| 变量名 | 用途 | 建议值/说明 |
|
||||
| --- | --- | --- |
|
||||
| `DATABASE_URL` | 主平台数据库连接 | 指向当前主平台生产库 |
|
||||
| `SECRET_KEY` | Flask/JWT 密钥 | 使用足够长的随机字符串 |
|
||||
| `REDIS_URL` | 知识库 Redis 连接 | 默认可用 `redis://kb-redis:6379/0` |
|
||||
| `KB_STORAGE_ROOT` | 知识库文件根目录 | 容器内建议保持 `/app/data/kb` |
|
||||
| `KB_TASK_EXECUTION_MODE` | 任务执行模式 | 生产建议 `worker` |
|
||||
| `KB_WORKER_POLL_SECONDS` | worker 轮询间隔 | 默认 `2` 即可 |
|
||||
| `KB_JOB_RUNNING_TIMEOUT_SECONDS` | running 任务超时回收 | 图文 PDF 建议 `1200`,必须大于 `EDKB_PDF_FILE_TIMEOUT_SEC` |
|
||||
| `EDKB_SOFFICE_TIMEOUT_SEC` | LibreOffice 转换超时 | 默认 `120` |
|
||||
| `EDKB_PDF_FILE_TIMEOUT_SEC` | 图文 PDF 清洗总超时 | 建议 `900`;应小于 `KB_JOB_RUNNING_TIMEOUT_SECONDS`,避免 PDF OCR/版面恢复被通用时限提前中止 |
|
||||
| `INTEGRATION_API_MODE` | 聊天侧集成调用模式 | 主平台自承载时建议 `local` |
|
||||
| `WECOM_PUBLIC_BASE_URL` | 对外可访问主平台地址 | 供聊天/企业微信/文件回链生成绝对地址 |
|
||||
| `DIFY_API_BASE` | Dify API 地址 | 按现网环境填写 |
|
||||
| `DIFY_API_KEY` | Dify API Key | 由管理端保存后可持久化到 `.env`/数据库 |
|
||||
| `KB_REDIS_IMAGE` | Redis 镜像来源 | 默认 `redis:7-alpine`,内网可改为私有仓库地址 |
|
||||
| `PYTHON_BASE_IMAGE` | 后端基础镜像 | 默认 `python:3.12-slim`,内网可改为私有仓库地址 |
|
||||
| `NODE_BASE_IMAGE` | 前端构建基础镜像 | 默认 `node:22-alpine` |
|
||||
| `NGINX_BASE_IMAGE` | 前端运行基础镜像 | 默认 `nginx:alpine` |
|
||||
| `PIP_INDEX_URL` | 后端 pip 主镜像源 | 可指向国内或内网 PyPI 镜像 |
|
||||
| `PIP_EXTRA_INDEX_URL` | 后端 pip 额外镜像源 | 用于补充私有或备用源 |
|
||||
|
||||
补充说明:
|
||||
|
||||
- 宿主机应先创建 `backend/.env` 文件,再执行 `docker compose up`,避免 Docker 将目标当作目录挂载。
|
||||
- 当前 `docker-compose.yml` 不再从宿主机 shell 强依赖 `DATABASE_URL`,而是由容器内挂载的 `backend/.env` 提供数据库连接与密钥。
|
||||
- 若当前环境无法访问 Docker Hub,可在执行前设置 `KB_REDIS_IMAGE`,例如改为企业私有仓库中的 Redis 镜像。
|
||||
- 若当前环境无法访问 Docker Hub,也可同时设置 `PYTHON_BASE_IMAGE`、`NODE_BASE_IMAGE`、`NGINX_BASE_IMAGE`,把后端/前端基础镜像切到企业私有仓库。
|
||||
- 若后端 `pip install -r requirements.txt` 速度过慢或不稳定,可设置 `PIP_INDEX_URL` / `PIP_EXTRA_INDEX_URL`。
|
||||
- OCR 依赖(OpenCV/RapidOCR)在 `backend/requirements-ocr.txt`,由 `backend/Dockerfile` 分步安装,避免同时下载 `opencv-python` 与 `opencv-python-headless` 两个大 wheel。
|
||||
- 若要沿用旧 `xinxin2` 文件目录,切换前需先把历史知识库文件迁入主平台卷,并保证 `KB_STORAGE_ROOT` 指向迁移后的新路径。
|
||||
- 若仍要调用外部 integration API,才需要配置 `INTEGRATION_API_BASE` 与 `INTEGRATION_API_KEY`,此时 `INTEGRATION_API_MODE` 设为 `external`。
|
||||
- 当前知识库主链路的 `worker_kb` 轮询数据库即可工作,`kb-redis` 以 profile 方式保留,用于后续异步队列扩展或外接 Redis 场景。
|
||||
|
||||
## 启动步骤
|
||||
|
||||
### 1. 构建并启动
|
||||
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
若使用私有镜像仓库,可先设置:
|
||||
|
||||
```bash
|
||||
$env:KB_REDIS_IMAGE = "your-registry.example.com/library/redis:7-alpine"
|
||||
$env:PYTHON_BASE_IMAGE = "your-registry.example.com/library/python:3.12-slim"
|
||||
$env:NODE_BASE_IMAGE = "your-registry.example.com/library/node:22-alpine"
|
||||
$env:NGINX_BASE_IMAGE = "your-registry.example.com/library/nginx:alpine"
|
||||
$env:PIP_INDEX_URL = "https://pypi.tuna.tsinghua.edu.cn/simple"
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
若需要同时启用内置 Redis,再改为:
|
||||
|
||||
```bash
|
||||
docker compose --profile kb-redis up -d --build
|
||||
```
|
||||
|
||||
### 2. 执行数据库迁移
|
||||
|
||||
```bash
|
||||
docker compose exec hxops-backend flask db upgrade
|
||||
```
|
||||
|
||||
### 3. 检查服务状态
|
||||
|
||||
```bash
|
||||
docker compose ps
|
||||
```
|
||||
|
||||
预期:
|
||||
|
||||
- `hxops-backend` 为 `Up`
|
||||
- `hxops-kb-worker` 为 `Up`(与 backend 共用镜像;Jenkins/`deploy_compose.sh` 在后端变更时会一并重建)
|
||||
- `hxops-frontend` 为 `Up`
|
||||
|
||||
若启用了 `kb-redis` profile,则额外确认:
|
||||
|
||||
- `kb-redis` 为 `Up`
|
||||
|
||||
### 4. 检查 worker 日志
|
||||
|
||||
```bash
|
||||
docker compose logs -f hxops-kb-worker
|
||||
```
|
||||
|
||||
预期可见:
|
||||
|
||||
```text
|
||||
[kb-worker] started, poll_seconds=2.0
|
||||
```
|
||||
|
||||
## 端口与卷
|
||||
|
||||
当前主平台容器端口关系:
|
||||
|
||||
- 宿主机 `5002` -> `hxops-backend:5000`
|
||||
- 宿主机 `8890` -> `hxops-frontend:80`
|
||||
|
||||
当前关键卷:
|
||||
|
||||
- `hxops_runtime_data`:主平台运行时可写数据,包含知识库存储目录
|
||||
- `hxops_redis_data`:Redis 持久化数据
|
||||
|
||||
## 切换前检查
|
||||
|
||||
切换 `xinxin2` 运行时前,至少确认:
|
||||
|
||||
1. 主平台已完成数据库迁移
|
||||
2. 主平台后台可正常打开知识库管理页
|
||||
3. 上传文件后会生成 `upload/clean` 任务
|
||||
4. `hxops-kb-worker` 能持续消费待执行任务
|
||||
5. Dify 设置已在主平台管理端保存并通过健康检查
|
||||
6. 聊天侧 `INTEGRATION_API_MODE=local`
|
||||
7. `WECOM_PUBLIC_BASE_URL` 对应外部真实可访问域名
|
||||
|
||||
## 切换后冒烟清单
|
||||
|
||||
建议按顺序验证:
|
||||
|
||||
1. 登录主平台并进入知识库工作台
|
||||
2. 新建一个分组和一个文档条目
|
||||
3. 上传一个 `txt` 或 `md` 文件
|
||||
4. 确认任务状态从 `pending/running` 进入 `success`
|
||||
5. 在文档详情里触发一次 Dify 同步
|
||||
6. 调用主平台 `/api/integration/dify-file` 或 `/api/integration/dify-files/resolve` 验证映射
|
||||
7. 从聊天侧点击源文件链接,确认下载地址仍指向主平台
|
||||
|
||||
## 常见注意事项
|
||||
|
||||
- `hxops-backend` 容器内部监听 `5000`,宿主机映射使用 `5002:5000`;若改端口,需同步更新网关/探针配置。
|
||||
- `worker_kb.py` 已按 `FLASK_ENV` 或 `APP_CONFIG` 选择配置;生产环境不要再用 `development` 配置启动 worker。
|
||||
- `KB_TASK_EXECUTION_MODE=worker` 时,需要确保 `hxops-kb-worker` 运行;若临时排障切到 `sync`,应评估接口耗时影响。
|
||||
- `kb-redis` 已改为可选 profile,不执行 `docker compose --profile kb-redis ...` 时不会默认拉起。
|
||||
- `backend/.env` 与数据库配置存在持久化联动,重建容器前不要误删该文件。
|
||||
- `SECRET_KEY` 过短会导致 JWT/HMAC 安全性不足,生产必须替换为长随机值。
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 198 KiB |
@@ -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
@@ -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 = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import type { AdminUserRow } from '../types/admin.types';
|
||||
import type { AdminDashboardBadges, AdminDashboardSummary } from '../types/dashboard.types';
|
||||
import type { AdminDashboardSummary } from '../types/dashboard.types';
|
||||
import type { PaginatedResult } from '@/shared/types/pagination.types';
|
||||
import type { AdminLinkedServiceRow } from '../types/linked-service.types';
|
||||
import type {
|
||||
@@ -15,6 +15,7 @@ import type {
|
||||
ApplicationSortKey,
|
||||
ApplicationStatusFilter,
|
||||
ApplicationUsageFilter,
|
||||
OpsOverviewReport,
|
||||
UsageReport,
|
||||
UsageRangeKey,
|
||||
} from '../types/report.types';
|
||||
@@ -571,6 +572,8 @@ export const updateAdminUserPermissions = (userId: number, agentIds: number[]) =
|
||||
|
||||
// Departments
|
||||
export const listAdminDepartments = () => requestJson<any[]>('/api/admin/departments', auth());
|
||||
export const listAdminDepartmentMembers = (id: number) =>
|
||||
requestJson(`/api/admin/departments/${id}/members`, auth());
|
||||
export const createAdminDepartment = (payload: Record<string, unknown>) =>
|
||||
requestJson('/api/admin/departments', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const updateAdminDepartment = (id: number, payload: Record<string, unknown>) =>
|
||||
@@ -714,13 +717,6 @@ export const saveAdminAgentPermissions = (agentId: number, userIds: number[]) =>
|
||||
body: JSON.stringify({ user_ids: userIds }),
|
||||
});
|
||||
|
||||
// Permission requests
|
||||
export const listAdminPermissionRequests = () =>
|
||||
requestJson<any[]>('/api/admin/permission-requests', auth());
|
||||
export const approveAdminPermissionRequest = (id: number) =>
|
||||
requestJson(`/api/admin/permission-requests/${id}/approve`, { method: 'POST', ...auth() });
|
||||
export const rejectAdminPermissionRequest = (id: number) =>
|
||||
requestJson(`/api/admin/permission-requests/${id}/reject`, { method: 'POST', ...auth() });
|
||||
export const batchUpdateAdminPermissions = (payload: Record<string, unknown>) =>
|
||||
requestJson('/api/admin/permissions/batch', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const importAdminPermissions = (formData: FormData) =>
|
||||
@@ -731,23 +727,25 @@ export const importAdminPermissions = (formData: FormData) =>
|
||||
export const getAdminDashboardSummary = () =>
|
||||
requestJson<AdminDashboardSummary>('/api/admin/dashboard/summary', auth());
|
||||
|
||||
/** 侧栏角标:待审批用户数、待处理权限申请数 */
|
||||
export const getAdminDashboardBadges = () =>
|
||||
requestJson<AdminDashboardBadges>('/api/admin/dashboard/badges', auth());
|
||||
|
||||
// Reports
|
||||
export interface AdminUsageReportParams {
|
||||
user_page?: number;
|
||||
user_page_size?: number;
|
||||
/** 时间范围:7d | 30d | 90d | 180d | 365d */
|
||||
/** 时间范围:7d | 30d | 90d | 180d | 365d(与 start_date/end_date 互斥,自定义日期优先) */
|
||||
range?: UsageRangeKey;
|
||||
/** 自定义开始日期 YYYY-MM-DD */
|
||||
start_date?: string;
|
||||
/** 自定义结束日期 YYYY-MM-DD */
|
||||
end_date?: string;
|
||||
}
|
||||
|
||||
export const getAdminUsageReport = (params: AdminUsageReportParams = {}) => {
|
||||
const qs = new URLSearchParams();
|
||||
if (params.user_page != null) qs.set('user_page', String(params.user_page));
|
||||
if (params.user_page_size != null) qs.set('user_page_size', String(params.user_page_size));
|
||||
if (params.range) qs.set('range', params.range);
|
||||
if (params.start_date) qs.set('start_date', params.start_date);
|
||||
if (params.end_date) qs.set('end_date', params.end_date);
|
||||
if (!params.start_date && !params.end_date && params.range) qs.set('range', params.range);
|
||||
const query = qs.toString();
|
||||
return requestJson<UsageReport>(
|
||||
`/api/admin/reports/usage${query ? `?${query}` : ''}`,
|
||||
@@ -757,6 +755,10 @@ export const getAdminUsageReport = (params: AdminUsageReportParams = {}) => {
|
||||
|
||||
export interface AdminApplicationReportParams {
|
||||
range?: UsageRangeKey;
|
||||
/** 自定义开始日期 YYYY-MM-DD(优先于 range) */
|
||||
start_date?: string;
|
||||
/** 自定义结束日期 YYYY-MM-DD(优先于 range) */
|
||||
end_date?: string;
|
||||
status?: ApplicationStatusFilter;
|
||||
usage?: ApplicationUsageFilter;
|
||||
q?: string;
|
||||
@@ -772,7 +774,9 @@ export interface AdminApplicationReportParams {
|
||||
*/
|
||||
export const getAdminApplicationReport = (params: AdminApplicationReportParams = {}) => {
|
||||
const qs = new URLSearchParams();
|
||||
if (params.range) qs.set('range', params.range);
|
||||
if (params.start_date) qs.set('start_date', params.start_date);
|
||||
if (params.end_date) qs.set('end_date', params.end_date);
|
||||
if (!params.start_date && !params.end_date && params.range) qs.set('range', params.range);
|
||||
if (params.status && params.status !== 'all') qs.set('status', params.status);
|
||||
if (params.usage && params.usage !== 'all') qs.set('usage', params.usage);
|
||||
if (params.q?.trim()) qs.set('q', params.q.trim());
|
||||
@@ -788,8 +792,64 @@ export const getAdminApplicationReport = (params: AdminApplicationReportParams =
|
||||
};
|
||||
|
||||
export const getAdminFeedbackReport = () => requestJson<any>('/api/admin/reports/feedback', auth());
|
||||
|
||||
/**
|
||||
* 拉取运营总览报表:对话量 / 活跃用户 / 活跃应用 / 趋势环比 / Top 与低使用应用 / 未处理反馈。
|
||||
* @param params - 统计范围:自定义起止日期(优先)或预设 range key
|
||||
*/
|
||||
export const getAdminOpsOverview = (params: { range?: UsageRangeKey; start_date?: string; end_date?: string } = {}) => {
|
||||
const qs = new URLSearchParams();
|
||||
if (params.start_date) qs.set('start_date', params.start_date);
|
||||
if (params.end_date) qs.set('end_date', params.end_date);
|
||||
if (!params.start_date && !params.end_date && params.range) qs.set('range', params.range);
|
||||
const query = qs.toString();
|
||||
return requestJson<OpsOverviewReport>(
|
||||
`/api/admin/reports/overview${query ? `?${query}` : ''}`,
|
||||
auth(),
|
||||
);
|
||||
};
|
||||
|
||||
export const getAdminReportTable = (url: string) => requestJson<any[]>(url, auth());
|
||||
export const getAdminReportTableCount = (url: string) => requestJson<{ total: number }>(url, auth());
|
||||
|
||||
/**
|
||||
* 拉取聊天日志「Top 提问内容 / Top 回答内容」(直接按 ChatLog 明细统计)。
|
||||
* @param query - 可选的查询串(时间范围/应用/用户等识别条件)
|
||||
*/
|
||||
export const getAdminChatLogTops = (query = '') =>
|
||||
requestJson<{ questions: Array<{ label: string; count: number }>; answers: Array<{ label: string; count: number }> }>(
|
||||
`/api/admin/reports/chat-log-tops${query}`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
/** 反馈概览:待处理 / 本月已关闭 / 最多反馈应用 */
|
||||
export const getAdminFeedbackSummary = (query = '') =>
|
||||
requestJson<{ pending_count: number; closed_this_month: number; top_app: { name: string; count: number } }>(
|
||||
`/api/admin/reports/feedback-summary${query}`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
/** 问题分析:高频问题簇 KPI + 优先处理问题(复用聊天日志风险规则) */
|
||||
export const getAdminIssueAnalysis = (query = '') =>
|
||||
requestJson<{
|
||||
kpi: {
|
||||
high_freq_clusters: number;
|
||||
attention_signals: number;
|
||||
review_signals: number;
|
||||
empty_answers: number;
|
||||
top10_ratio: number;
|
||||
top_risk_app: { name: string; signal_count: number; attention_ratio: number };
|
||||
};
|
||||
total_questions: number;
|
||||
questions: Array<{ topic: string; count: number; apps: string; attention_count: number; reasons: string[]; checks: string[] }>;
|
||||
}>(`/api/admin/reports/issue-analysis${query}`, auth());
|
||||
|
||||
/** 将一条意见反馈标记为已关闭 */
|
||||
export const closeAdminGeneralFeedback = (feedbackId: number) =>
|
||||
requestJson<{ id: number; status: string; closed_at: string }>(
|
||||
`/api/admin/reports/general-feedbacks/${feedbackId}/close`,
|
||||
{ method: 'POST', ...auth() },
|
||||
);
|
||||
export const batchDeleteAdminChatLogs = (ids: number[]) =>
|
||||
requestJson<{ deleted_count: number }>('/api/admin/database/chat_logs/batch-delete', {
|
||||
method: 'POST',
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/**
|
||||
/**
|
||||
* features/admin/components/AdminNav.vue
|
||||
* 管理后台左侧导航,使用子路由跳转。
|
||||
* 依赖:admin-nav.store、modules 常量、vue-router。
|
||||
* 逻辑:报表/企微子菜单默认折叠;当前路由落在对应模块时自动展开以便看到激活项。
|
||||
* 绠$悊鍚庡彴宸︿晶瀵艰埅锛屼娇鐢ㄥ瓙璺敱璺宠浆銆?
|
||||
* 渚濊禆锛歛dmin-nav.store銆乵odules 甯搁噺銆乿ue-router銆?
|
||||
* 閫昏緫锛氭姤琛?浼佸井瀛愯彍鍗曢粯璁ゆ姌鍙狅紱褰撳墠璺敱钀藉湪瀵瑰簲妯″潡鏃惰嚜鍔ㄥ睍寮€浠ヤ究鐪嬪埌婵€娲婚」銆?
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
LayoutDashboard, UserPlus, UserCog, Building, Bot, FileText,
|
||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, ShieldCheck, BarChart2, AppWindow,
|
||||
LayoutDashboard, UserCog, Building, Bot, FileText,
|
||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, BarChart2, AppWindow,
|
||||
ScrollText, ExternalLink, PackageSearch, GraduationCap, Cable,
|
||||
} from 'lucide-vue-next';
|
||||
import type { Component } from 'vue';
|
||||
@@ -30,7 +30,6 @@ const navStore = useAdminNavStore();
|
||||
|
||||
const iconMap: Record<AdminModuleId, Component> = {
|
||||
dashboard: LayoutDashboard,
|
||||
approvals: UserPlus,
|
||||
users: UserCog,
|
||||
departments: Building,
|
||||
agents: Bot,
|
||||
@@ -45,7 +44,6 @@ const iconMap: Record<AdminModuleId, Component> = {
|
||||
procurement_contract: ScrollText,
|
||||
training_config: GraduationCap,
|
||||
integration_connector: Cable,
|
||||
requests: ShieldCheck,
|
||||
reports: BarChart2,
|
||||
shipping_inventory: PackageSearch,
|
||||
};
|
||||
@@ -108,7 +106,7 @@ const navigateReport = (table: string): void => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 进入报表/企微模块时自动展开子菜单,避免当前页在折叠状态下不可见。
|
||||
* 杩涘叆鎶ヨ〃/浼佸井妯″潡鏃惰嚜鍔ㄥ睍寮€瀛愯彍鍗曪紝閬垮厤褰撳墠椤靛湪鎶樺彔鐘舵€佷笅涓嶅彲瑙併€?
|
||||
*/
|
||||
watch(
|
||||
isReportsActive,
|
||||
@@ -167,12 +165,6 @@ watch(
|
||||
:class="isModuleActive(item.id) ? 'text-brand-600' : 'text-muted group-hover:text-secondary'"
|
||||
/>
|
||||
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t(item.labelKey) }}</span>
|
||||
<span
|
||||
v-if="navStore.badgeForModule(item.id) && !navStore.sidebarCollapsed"
|
||||
class="ml-auto bg-red-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full shadow-sm"
|
||||
>
|
||||
{{ navStore.badgeForModule(item.id) }}
|
||||
</span>
|
||||
<div
|
||||
v-if="isModuleActive(item.id)"
|
||||
class="absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 bg-brand-600 rounded-r-full"
|
||||
@@ -276,3 +268,4 @@ watch(
|
||||
</nav>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
@@ -2,11 +2,6 @@
|
||||
* features/admin/composables/useAdminNavBadges.ts
|
||||
* 暴露角标刷新入口;拉取与缓存放 admin-nav.store(不在此 composable 内 onMounted,避免子页面重复请求)。
|
||||
*/
|
||||
import { useAdminNavStore } from '../stores/admin-nav.store';
|
||||
|
||||
export function useAdminNavBadges() {
|
||||
const navStore = useAdminNavStore();
|
||||
return {
|
||||
refreshBadges: () => navStore.refreshBadges(),
|
||||
};
|
||||
return { refreshBadges: async (): Promise<void> => undefined };
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/constants/modules.ts
|
||||
* 管理后台模块元数据,AdminNav 与子路由共用。
|
||||
* 绠$悊鍚庡彴妯″潡鍏冩暟鎹紝AdminNav 涓庡瓙璺敱鍏辩敤銆?
|
||||
*/
|
||||
|
||||
import type { AdminModuleId, AdminReportTableId, ShippingConfigSubModuleId } from '../types/admin.types';
|
||||
@@ -40,12 +40,11 @@ export interface ShippingConfigSubModuleMeta {
|
||||
|
||||
/** 已独立拆分的模块(全部 admin 模块均已拆分) */
|
||||
export const STANDALONE_ADMIN_MODULES = new Set<AdminModuleId>([
|
||||
'dashboard', 'agents', 'users', 'departments', 'approvals', 'announcements', 'questions', 'requests', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'shipping_inventory', 'procurement_contract', 'reports','training_config', 'integration_connector'
|
||||
'dashboard', 'agents', 'users', 'departments', 'announcements', 'questions', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'shipping_inventory', 'procurement_contract', 'reports', 'training_config', 'integration_connector'
|
||||
]);
|
||||
|
||||
export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'dashboard', routeName: 'AdminDashboard', path: 'dashboard', labelKey: 'admin.nav.dashboard', configKey: 'dashboard' },
|
||||
{ id: 'approvals', routeName: 'AdminApprovals', path: 'approvals', labelKey: 'admin.nav.approvals', configKey: 'approvals' },
|
||||
{ id: 'users', routeName: 'AdminUsers', path: 'users', labelKey: 'admin.nav.users', configKey: 'users' },
|
||||
{ id: 'departments', routeName: 'AdminDepartments', path: 'departments', labelKey: 'admin.nav.departments', configKey: 'departments' },
|
||||
{ id: 'agents', routeName: 'AdminAgents', path: 'agents', labelKey: 'admin.nav.agents', configKey: 'agents' },
|
||||
@@ -61,9 +60,15 @@ export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'procurement_contract', routeName: 'AdminProcurementContract', path: 'procurement-contract', labelKey: 'admin.nav.procurementContract', configKey: 'procurement_contract' },
|
||||
{ id: 'training_config', routeName: 'AdminTrainingConfig', path: 'training-config', labelKey: 'admin.nav.trainingConfig', configKey: 'training_config' },
|
||||
{ id: 'integration_connector', routeName: 'AdminIntegrationConnector', path: 'integration-connector', labelKey: 'admin.nav.integrationConnector', configKey: 'integration_connector' },
|
||||
{ id: 'requests', routeName: 'AdminRequests', path: 'requests', labelKey: 'admin.nav.requests', configKey: 'requests' },
|
||||
];
|
||||
|
||||
/**
|
||||
* 数据报表导航子项:
|
||||
* - 保留:使用分析、聊天日志、应用运营
|
||||
* - 合并:意见反馈(general_feedbacks) + 回答评价(feedbacks) → 用户反馈与回答评价(feedbacks)
|
||||
* - 新增:运营总览(ops_overview)、问题分析(issue_analysis) 第一版为骨架/空状态
|
||||
* - 说明:general_feedbacks 仅作为「用户反馈与回答评价」页内 Tab 的数据源,不再作为独立导航项。
|
||||
*/
|
||||
/** 货代管理的业务导航唯一真相源;按基础定义、适配规则、运行任务的依赖顺序排列。 */
|
||||
export const SHIPPING_CONFIG_SUB_MODULE_METAS: ShippingConfigSubModuleMeta[] = [
|
||||
{ id: 'field_assets', routeName: 'AdminShippingFieldAssets', path: 'shipping-field-assets', labelKey: 'admin.nav.shippingFieldAssets', groupKey: 'admin.nav.shippingOrderRecognition' },
|
||||
@@ -84,12 +89,12 @@ export const SHIPPING_CONFIG_SUB_MODULE_METAS: ShippingConfigSubModuleMeta[] = [
|
||||
];
|
||||
|
||||
export const ADMIN_REPORT_TABLES: AdminReportTableId[] = [
|
||||
'ops_overview',
|
||||
'usage_analysis',
|
||||
'chat_logs',
|
||||
'agents',
|
||||
'permission_requests',
|
||||
'general_feedbacks',
|
||||
'feedbacks',
|
||||
'issue_analysis',
|
||||
];
|
||||
|
||||
export const LEGACY_MODULE_QUERY_TO_PATH: Record<string, string> = {};
|
||||
@@ -100,3 +105,4 @@ export const adminModulePath = (moduleId: AdminModuleId | string): string => {
|
||||
if (meta) return `/admin/${meta.path}`;
|
||||
return `/admin/${LEGACY_MODULE_QUERY_TO_PATH[moduleId] || moduleId}`;
|
||||
};
|
||||
|
||||
@@ -8,10 +8,9 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Bot, Plus, SquarePen, Trash2, Users } from 'lucide-vue-next';
|
||||
import { Bot, Plus, SquarePen, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import AgentFormModal from './components/AgentFormModal.vue';
|
||||
import AgentPermissionModal from './components/AgentPermissionModal.vue';
|
||||
import AgentTestModal from './components/AgentTestModal.vue';
|
||||
import { useAgentsAdmin } from './composables/useAgentsAdmin';
|
||||
import { useAgentsTableColumnResize } from './composables/useAgentsTableColumnResize';
|
||||
@@ -29,7 +28,6 @@ const {
|
||||
contentProfileOptions,
|
||||
scheduleTasks,
|
||||
trainingExamPdfGuides,
|
||||
activeUsers,
|
||||
isLoading,
|
||||
isSaving,
|
||||
isImportingTrainingPdf,
|
||||
@@ -40,9 +38,6 @@ const {
|
||||
isTesting,
|
||||
testingAgent,
|
||||
testResult,
|
||||
showPermissionModal,
|
||||
permissionAgent,
|
||||
permissionUserIds,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
@@ -59,9 +54,6 @@ const {
|
||||
deleteAgent,
|
||||
openTestModal,
|
||||
runAgentTest,
|
||||
openPermissionModal,
|
||||
togglePermissionUser,
|
||||
savePermissions,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
} = useAgentsAdmin();
|
||||
@@ -75,13 +67,11 @@ const {
|
||||
|
||||
const tableHeaderColumns = computed(() => [
|
||||
{ key: 'name', label: t('admin.agent.headers.name'), align: 'left' as const },
|
||||
{ key: 'type', label: t('admin.agent.headers.type'), align: 'left' as const },
|
||||
{ key: 'aggregation', label: t('admin.agent.headers.aggregation'), align: 'left' as const },
|
||||
{ key: 'config', label: t('admin.agent.headers.config'), align: 'left' as const },
|
||||
{ key: 'status', label: t('admin.agent.headers.status'), align: 'left' as const },
|
||||
{ key: 'actions', label: t('admin.agent.headers.actions'), align: 'right' as const },
|
||||
]);
|
||||
|
||||
/* 列表仅展示名称、状态和操作;类型/聚合/配置仍由编辑弹窗维护。 */
|
||||
const formatAgentCode = (agent: AgentRow) => agent.agent_code || 'generic';
|
||||
|
||||
const formatAgentAggregationPrimary = (agent: AgentRow) => (
|
||||
@@ -131,6 +121,8 @@ const formatRuntimeProviderLabel = (agent: AgentRow) => {
|
||||
const translated = t(key);
|
||||
return translated === key ? provider : translated;
|
||||
};
|
||||
void [formatAgentAggregationPrimary, formatAgentAggregationSecondary, formatAgentConfigPrimary,
|
||||
formatAgentConfigSecondary, formatAgentTypeLabel, formatRuntimeProviderLabel];
|
||||
|
||||
const showFormDialog = ref(false);
|
||||
|
||||
@@ -241,43 +233,6 @@ onMounted(() => {
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<p class="truncate text-sm text-primary" :title="formatAgentTypeLabel(agent)">
|
||||
{{ formatAgentTypeLabel(agent) }}
|
||||
</p>
|
||||
<p class="truncate text-xs text-muted" :title="formatRuntimeProviderLabel(agent)">
|
||||
{{ formatRuntimeProviderLabel(agent) }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<p
|
||||
class="truncate text-sm font-medium"
|
||||
:class="agent.is_aggregate ? 'text-brand-700' : 'text-secondary'"
|
||||
:title="formatAgentAggregationPrimary(agent)"
|
||||
>
|
||||
{{ formatAgentAggregationPrimary(agent) }}
|
||||
</p>
|
||||
<p class="truncate text-xs text-muted" :title="formatAgentAggregationSecondary(agent)">
|
||||
{{ formatAgentAggregationSecondary(agent) }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<p
|
||||
class="truncate font-mono text-sm text-primary"
|
||||
:title="formatAgentConfigPrimary(agent)"
|
||||
>
|
||||
{{ formatAgentConfigPrimary(agent) }}
|
||||
</p>
|
||||
<p class="truncate text-xs text-muted">
|
||||
{{ formatAgentConfigSecondary(agent) }}
|
||||
</p>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-4 align-middle">
|
||||
<div class="agent-list-cell">
|
||||
<span
|
||||
@@ -300,14 +255,6 @@ onMounted(() => {
|
||||
<SquarePen class="w-4 h-4 shrink-0" />
|
||||
{{ t('admin.edit') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center justify-center p-2 text-blue-600 bg-blue-50 hover:bg-blue-100 rounded-lg transition-all"
|
||||
:title="t('admin.agent.manageAccess')"
|
||||
@click.stop="openPermissionModal(agent)"
|
||||
>
|
||||
<Users class="w-5 h-5 shrink-0" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center whitespace-nowrap p-2 text-emerald-600 bg-emerald-50 hover:bg-emerald-100 rounded-lg transition-all"
|
||||
@@ -367,17 +314,6 @@ onMounted(() => {
|
||||
@import-training-pdf="importTrainingQuestionBankFromPdf"
|
||||
/>
|
||||
|
||||
<AgentPermissionModal
|
||||
:visible="showPermissionModal"
|
||||
:agent="permissionAgent"
|
||||
:users="activeUsers()"
|
||||
:selected-user-ids="permissionUserIds"
|
||||
:is-saving="isSaving"
|
||||
@close="showPermissionModal = false"
|
||||
@save="savePermissions"
|
||||
@toggle-user="togglePermissionUser"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
|
||||
+5
-3
@@ -8,12 +8,14 @@
|
||||
|
||||
import { computed, onBeforeUnmount, ref } from 'vue';
|
||||
|
||||
const STORAGE_KEY = 'hxops.admin.agents.tableColumnWidths';
|
||||
// 列结构已移除权限操作,升级缓存键以废弃旧的拖拽宽度,避免旧值继续撑出横向滚动。
|
||||
const STORAGE_KEY = 'hxops.admin.agents.tableColumnWidths.v4';
|
||||
|
||||
/** 名称 / 类型 / 分类 / 配置 / 状态 / 操作 */
|
||||
const DEFAULT_WIDTHS = [220, 168, 128, 140, 96, 220] as const;
|
||||
// 列宽只根据字段和操作控件确定;描述始终在名称单元格内截断,不参与宽度计算。
|
||||
const DEFAULT_WIDTHS = [400, 140, 240] as const;
|
||||
|
||||
const MIN_WIDTHS = [140, 120, 100, 120, 80, 200] as const;
|
||||
const MIN_WIDTHS = [220, 110, 220] as const;
|
||||
|
||||
const COLUMN_COUNT = DEFAULT_WIDTHS.length;
|
||||
|
||||
|
||||
@@ -5,15 +5,22 @@
|
||||
* 逻辑:路由 /admin/departments;表头排序复用 shared SortableTableHeader + useTableSort。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Plus, Search, Trash2 } from 'lucide-vue-next';
|
||||
import { Edit, Plus, Search, Trash2, Users } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import SortableTableHeader from '@/shared/components/SortableTableHeader.vue';
|
||||
import DepartmentFormModal from './components/DepartmentFormModal.vue';
|
||||
import DepartmentMembersModal from './components/DepartmentMembersModal.vue';
|
||||
import { useDepartmentsAdmin } from './composables/useDepartmentsAdmin';
|
||||
import { listAdminDepartmentMembers } from '@/features/admin/api/admin.api';
|
||||
import type { AdminDepartmentMembersResponse } from '@/features/admin/types/admin.types';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const showMembersModal = ref(false);
|
||||
const departmentMembers = ref<AdminDepartmentMembersResponse | null>(null);
|
||||
|
||||
const {
|
||||
filteredDepartments,
|
||||
@@ -40,6 +47,16 @@ const {
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
|
||||
/** 加载并展示指定部门的员工名单。 */
|
||||
const openDepartmentMembers = async (departmentId: number): Promise<void> => {
|
||||
try {
|
||||
departmentMembers.value = await listAdminDepartmentMembers(departmentId) as AdminDepartmentMembersResponse;
|
||||
showMembersModal.value = true;
|
||||
} catch (error) {
|
||||
msg.error((error as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -77,13 +94,14 @@ onMounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<!-- 列宽:名称 / 编码 / 公司 / 操作 -->
|
||||
<!-- 列宽:名称 / 编码 / 公司 / 员工 / 操作 -->
|
||||
<table class="admin-table table-fixed">
|
||||
<colgroup>
|
||||
<col class="w-[25%]" />
|
||||
<col class="w-[20%]" />
|
||||
<col class="w-[35%]" />
|
||||
<col class="w-[15%]" />
|
||||
<col class="w-[30%]" />
|
||||
<col class="w-[12%]" />
|
||||
<col class="w-[13%]" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -114,12 +132,13 @@ onMounted(() => {
|
||||
@sort="toggleSort"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-center text-xs">{{ t('admin.dept.headers.members') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs">{{ t('admin.dept.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="filteredDepartments.length === 0">
|
||||
<td colspan="4" class="px-6 admin-table-empty">
|
||||
<td colspan="5" class="px-6 admin-table-empty">
|
||||
{{ searchQuery.trim() ? t('admin.dept.noSearchResults') : t('admin.dept.noDepts') }}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -140,6 +159,14 @@ onMounted(() => {
|
||||
<td class="px-6 py-4 text-sm text-muted truncate" :title="d.company || '-'">
|
||||
{{ d.company || '-' }}
|
||||
</td>
|
||||
<td class="px-6 py-4 text-center">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center rounded-lg bg-blue-50 p-2 text-blue-600 hover:bg-blue-100"
|
||||
:title="t('admin.dept.actions.viewMembers')"
|
||||
@click="openDepartmentMembers(d.id)"
|
||||
><Users class="w-5 h-5" /><span class="ml-1 text-xs">{{ d.member_count || 0 }}</span></button>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex justify-end gap-1">
|
||||
<button
|
||||
@@ -173,6 +200,11 @@ onMounted(() => {
|
||||
@close="closeFormModal"
|
||||
@save="saveDepartment"
|
||||
/>
|
||||
<DepartmentMembersModal
|
||||
:visible="showMembersModal"
|
||||
:data="departmentMembers"
|
||||
@close="showMembersModal = false"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* features/admin/modules/departments/components/DepartmentMembersModal.vue
|
||||
* 用途:展示部门对应的员工数量和名单。
|
||||
* 依赖:部门成员只读 API 响应与 Vue 事件。
|
||||
* 逻辑:DepartmentsPage 点击员工图标后传入数据,本组件只负责呈现与关闭。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Users, X } from 'lucide-vue-next';
|
||||
import type { AdminDepartmentMembersResponse } from '@/features/admin/types/admin.types';
|
||||
|
||||
defineProps<{ visible: boolean; data: AdminDepartmentMembersResponse | null }>();
|
||||
const emit = defineEmits<{ close: [] }>();
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible && data" class="admin-modal-overlay items-center" @click.self="emit('close')">
|
||||
<section class="admin-modal-panel max-w-2xl max-h-[90vh] animate-fade-in-up">
|
||||
<header class="px-8 py-6 border-b border-subtle flex items-center justify-between">
|
||||
<div>
|
||||
<h3 class="text-lg font-bold text-primary">{{ t('admin.dept.members.title', { name: data.department.name }) }}</h3>
|
||||
<p class="text-sm text-muted mt-1">{{ t('admin.dept.members.count', { count: data.count }) }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-icon-ds rounded-full" :title="t('admin.close')" @click="emit('close')"><X class="w-5 h-5" /></button>
|
||||
</header>
|
||||
<div class="max-h-[60vh] overflow-y-auto p-6">
|
||||
<div v-if="data.members.length === 0" class="py-12 text-center text-muted">
|
||||
<Users class="w-9 h-9 mx-auto mb-3 opacity-60" />
|
||||
{{ t('admin.dept.members.empty') }}
|
||||
</div>
|
||||
<ul v-else class="divide-y divide-subtle">
|
||||
<li v-for="member in data.members" :key="member.id" class="py-3 flex items-center justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<p class="font-medium text-primary">{{ member.real_name || member.username }}</p>
|
||||
<p class="text-xs text-muted truncate">{{ member.employee_id || member.username }} · {{ member.email || '-' }}</p>
|
||||
</div>
|
||||
<span class="text-xs text-muted whitespace-nowrap">{{ member.status }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -5,17 +5,20 @@
|
||||
* 逻辑:路由 /admin/permissions;左侧用户相关列 sticky,右侧为各应用权限列。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download, FileText, Users } from 'lucide-vue-next';
|
||||
import BatchPermissionModal from '@/features/admin/modules/users/components/BatchPermissionModal.vue';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import { usePermissionsAdmin } from './composables/usePermissionsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
agents,
|
||||
users,
|
||||
appRows,
|
||||
permissionFilters,
|
||||
selectedUserIds,
|
||||
paginatedUsers,
|
||||
@@ -40,6 +43,45 @@ const { t } = useI18n();
|
||||
importPermissions,
|
||||
} = usePermissionsAdmin();
|
||||
|
||||
const permissionView = ref<'apps' | 'members'>('apps');
|
||||
const selectedApp = ref<(typeof agents.value)[number] | null>(null);
|
||||
const appMemberSearch = ref('');
|
||||
const appMemberPage = ref(1);
|
||||
const appMemberPageSize = ref(10);
|
||||
const appMemberPageSizeOptions = [10, 20, 50, 100];
|
||||
|
||||
/** 应用成员弹窗:已授权人员优先展示,同时可搜索全部有效人员以便增删权限。 */
|
||||
const appMembers = computed(() => {
|
||||
const appId = selectedApp.value?.id;
|
||||
const keyword = appMemberSearch.value.trim().toLowerCase();
|
||||
if (!appId) return [];
|
||||
return users.value
|
||||
.filter((user) => user.status !== 'pending')
|
||||
.filter((user) => !keyword || [user.username, user.real_name, user.department, user.employee_id]
|
||||
.filter(Boolean)
|
||||
.some((value) => String(value).toLowerCase().includes(keyword)))
|
||||
.sort((a, b) => Number(b.agent_ids.includes(appId)) - Number(a.agent_ids.includes(appId)));
|
||||
});
|
||||
|
||||
const appMemberTotalPages = computed(() => Math.max(1, Math.ceil(appMembers.value.length / appMemberPageSize.value)));
|
||||
const paginatedAppMembers = computed(() => {
|
||||
const page = Math.min(Math.max(1, appMemberPage.value), appMemberTotalPages.value);
|
||||
const start = (page - 1) * appMemberPageSize.value;
|
||||
return appMembers.value.slice(start, start + appMemberPageSize.value);
|
||||
});
|
||||
watch(appMemberSearch, () => { appMemberPage.value = 1; });
|
||||
|
||||
const openAppMembers = (app: (typeof agents.value)[number]): void => {
|
||||
selectedApp.value = app;
|
||||
appMemberSearch.value = '';
|
||||
appMemberPage.value = 1;
|
||||
};
|
||||
|
||||
const closeAppMembers = (): void => {
|
||||
selectedApp.value = null;
|
||||
appMemberSearch.value = '';
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
@@ -85,7 +127,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-filters--inline">
|
||||
<div v-if="permissionView === 'members'" class="admin-table-filters--inline">
|
||||
<input
|
||||
v-model="permissionFilters.username"
|
||||
:placeholder="t('admin.perm.filterName')"
|
||||
@@ -104,11 +146,37 @@ onMounted(() => {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<div class="flex gap-6 border-b border-default">
|
||||
<button type="button" class="border-b-2 px-1 py-3 text-sm font-medium transition-colors" :class="permissionView === 'apps' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-primary'" @click="permissionView = 'apps'">
|
||||
{{ t('admin.perm.views.apps') }}
|
||||
</button>
|
||||
<button type="button" class="border-b-2 px-1 py-3 text-sm font-medium transition-colors" :class="permissionView === 'members' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-primary'" @click="permissionView = 'members'">
|
||||
{{ t('admin.perm.views.members') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="permissionView === 'apps'" class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table min-w-[680px]">
|
||||
<thead><tr>
|
||||
<th class="px-6 py-4 text-left text-sm">{{ t('admin.perm.appHeaders.app') }}</th>
|
||||
<th class="px-4 py-4 text-center text-sm">{{ t('admin.perm.appHeaders.type') }}</th>
|
||||
<th class="px-4 py-4 text-center text-sm">{{ t('admin.perm.appHeaders.authorized') }}</th>
|
||||
<th class="px-6 py-4 text-right text-sm">{{ t('admin.perm.appHeaders.actions') }}</th>
|
||||
</tr></thead>
|
||||
<tbody><tr v-for="app in appRows" :key="app.id">
|
||||
<td class="px-6 py-4"><div class="font-medium text-primary">{{ app.name }}</div><div class="mt-1 text-xs text-muted">{{ t('admin.perm.appHeaders.accessHint') }}</div></td>
|
||||
<td class="px-4 py-4 text-center text-sm text-muted">{{ app.type || 'API' }}</td>
|
||||
<td class="px-4 py-4 text-center text-sm font-medium text-primary">{{ app.authorizedCount }}</td>
|
||||
<td class="px-6 py-4 text-right"><button type="button" class="text-sm font-medium text-brand-600 hover:text-brand-700" @click="openAppMembers(app)">{{ t('admin.perm.appHeaders.viewMembers') }}</button></td>
|
||||
</tr></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-else class="admin-table-section admin-table-wrap">
|
||||
<table class="admin-table min-w-max">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-4 w-12 text-center sticky left-0 admin-table-sticky-head z-20">
|
||||
<th class="w-[3rem] px-2 py-4 text-center sticky left-0 admin-table-sticky-head z-20">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500"
|
||||
@@ -117,27 +185,17 @@ onMounted(() => {
|
||||
/>
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-12 admin-table-sticky-head z-20 w-56"
|
||||
class="w-[18rem] min-w-[18rem] px-4 py-4 text-left text-sm sticky left-[3rem] admin-table-sticky-head z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]"
|
||||
>
|
||||
{{ t('admin.perm.headers.user') }}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-[17rem] admin-table-sticky-head z-20 w-36"
|
||||
>
|
||||
{{ t('admin.perm.headers.realName') }}
|
||||
</th>
|
||||
<th
|
||||
class="px-6 py-4 text-left text-sm sticky left-[26rem] admin-table-sticky-head z-20 w-40 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.1)]"
|
||||
>
|
||||
{{ t('admin.perm.headers.dept') }}
|
||||
</th>
|
||||
<th
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="px-4 py-4 text-center text-sm min-w-[100px]"
|
||||
class="w-[7.5rem] min-w-[7.5rem] px-3 py-4 text-center text-sm"
|
||||
>
|
||||
<div class="flex flex-col items-center gap-1">
|
||||
<span>{{ agent.name }}</span>
|
||||
<div class="flex min-h-14 flex-col items-center justify-center gap-1">
|
||||
<span class="line-clamp-2 max-w-[6.5rem] break-words leading-tight" :title="agent.name">{{ agent.name }}</span>
|
||||
<span class="text-[10px] text-muted font-normal border border-default px-1 rounded">
|
||||
{{ agent.type }}
|
||||
</span>
|
||||
@@ -147,7 +205,7 @@ onMounted(() => {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="user in paginatedUsers" :key="user.id">
|
||||
<td class="px-4 py-4 text-center sticky left-0 admin-table-sticky-cell z-20">
|
||||
<td class="w-[3rem] px-2 py-4 text-center sticky left-0 admin-table-sticky-cell z-20">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="w-4 h-4 rounded text-brand-600 focus:ring-brand-500"
|
||||
@@ -155,34 +213,29 @@ onMounted(() => {
|
||||
@change="toggleUserSelection(user.id)"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-6 py-4 sticky left-12 admin-table-sticky-cell z-20">
|
||||
<td class="w-[18rem] min-w-[18rem] px-4 py-3 sticky left-[3rem] admin-table-sticky-cell z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.05)]">
|
||||
<div class="flex items-center gap-3">
|
||||
<div
|
||||
class="w-8 h-8 rounded-full bg-gradient-to-br from-brand-100 to-indigo-100 text-brand-600 flex items-center justify-center font-bold text-sm"
|
||||
>
|
||||
{{ user.username.charAt(0).toUpperCase() }}
|
||||
{{ getUserAvatarLabel(user) }}
|
||||
</div>
|
||||
<div class="font-medium text-primary text-sm truncate max-w-[120px]" :title="user.username">
|
||||
{{ user.username }}
|
||||
<div class="min-w-0">
|
||||
<div class="truncate text-sm font-medium text-primary" :title="user.real_name || user.username">
|
||||
{{ user.real_name || user.username }}
|
||||
</div>
|
||||
<div class="mt-1 flex min-w-0 items-center gap-2 text-xs text-muted">
|
||||
<span class="max-w-[7rem] truncate" :title="user.username">{{ user.username }}</span>
|
||||
<span class="h-3 w-px shrink-0 bg-border" />
|
||||
<span class="max-w-[8rem] truncate" :title="user.department || '-'">{{ user.department || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 sticky left-[17rem] admin-table-sticky-cell z-20">
|
||||
<div class="text-sm text-primary truncate" :title="user.real_name || '-'">
|
||||
{{ user.real_name || '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
class="px-6 py-4 sticky left-[26rem] admin-table-sticky-cell z-20 border-r border-subtle shadow-[2px_0_5px_-2px_rgba(0,0,0,0.05)]"
|
||||
>
|
||||
<div class="text-sm text-muted truncate" :title="user.department">
|
||||
{{ user.department || '-' }}
|
||||
</div>
|
||||
</td>
|
||||
<td
|
||||
v-for="agent in agents"
|
||||
:key="agent.id"
|
||||
class="px-4 py-4 text-center border-l border-dashed border-subtle"
|
||||
class="w-[7.5rem] min-w-[7.5rem] px-3 py-3 text-center border-l border-dashed border-subtle"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -215,5 +268,33 @@ onMounted(() => {
|
||||
@close="closeBatchPermissionModal"
|
||||
@save="submitBatchPermission"
|
||||
/>
|
||||
|
||||
<div v-if="selectedApp" class="fixed inset-0 z-50 flex items-center justify-center bg-slate-950/30 p-4" @click.self="closeAppMembers">
|
||||
<section class="flex max-h-[min(720px,calc(100vh-2rem))] w-full max-w-2xl flex-col overflow-hidden rounded-2xl border border-default bg-surface shadow-2xl">
|
||||
<header class="flex items-start justify-between border-b border-default px-6 py-5"><div><h3 class="text-lg font-semibold text-primary">{{ selectedApp.name }}</h3><p class="mt-1 text-sm text-muted">{{ t('admin.perm.appHeaders.memberHint') }}</p></div><button type="button" class="text-sm text-muted hover:text-primary" @click="closeAppMembers">{{ t('admin.close') }}</button></header>
|
||||
<div class="border-b border-subtle bg-surface-soft px-6 py-4"><input v-model="appMemberSearch" :placeholder="t('admin.perm.appHeaders.memberSearch')" class="admin-table-filter-input w-full" /></div>
|
||||
<div class="min-h-0 flex-1 overflow-y-auto">
|
||||
<div v-for="member in paginatedAppMembers" :key="member.id" class="flex items-center justify-between gap-4 border-b border-subtle px-6 py-3 last:border-b-0"><div class="flex min-w-0 items-center gap-3"><div class="flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-brand-100 text-sm font-bold text-brand-600">{{ getUserAvatarLabel(member) }}</div><div class="min-w-0"><div class="truncate text-sm font-medium text-primary">{{ member.real_name || member.username }}</div><div class="truncate text-xs text-muted">{{ member.username }} · {{ member.department || '-' }}</div></div></div><button type="button" class="shrink-0 rounded-lg px-3 py-1.5 text-sm font-medium transition-colors" :class="member.agent_ids.includes(selectedApp.id) ? 'text-red-600 hover:bg-red-50' : 'text-brand-600 hover:bg-brand-50'" @click="toggleUserAgentPermission(member, selectedApp.id)">{{ member.agent_ids.includes(selectedApp.id) ? t('admin.perm.appHeaders.removeMember') : t('admin.perm.appHeaders.addMember') }}</button></div>
|
||||
<p v-if="appMembers.length === 0" class="px-6 py-12 text-center text-sm text-muted">{{ t('admin.perm.appHeaders.noMembers') }}</p>
|
||||
</div>
|
||||
<PaginationBar v-if="appMembers.length > 0" v-model:page="appMemberPage" v-model:page-size="appMemberPageSize" :total="appMembers.length" :pages="appMemberTotalPages" :page-size-options="appMemberPageSizeOptions" class="app-member-pagination rounded-none border-x-0 border-b-0" />
|
||||
</section>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 查看成员弹窗宽度固定,分页摘要与翻页操作保持在同一行。 */
|
||||
:deep(.app-member-pagination) {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
:deep(.app-member-pagination > div) {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:deep(.app-member-pagination > div:last-child) {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
</style>
|
||||
@@ -39,6 +39,12 @@ export function usePermissionsAdmin() {
|
||||
|
||||
const activeUsers = computed(() => users.value.filter((u) => u.status !== 'pending'));
|
||||
|
||||
/** 按应用视图行:复用已加载用户权限,统计每个应用的有效授权人数。 */
|
||||
const appRows = computed(() => agents.value.map((agent) => ({
|
||||
...agent,
|
||||
authorizedCount: activeUsers.value.filter((user) => user.agent_ids.includes(agent.id)).length,
|
||||
})));
|
||||
|
||||
const filteredUsers = computed(() =>
|
||||
activeUsers.value.filter((u) => {
|
||||
const matchName =
|
||||
@@ -216,6 +222,7 @@ export function usePermissionsAdmin() {
|
||||
return {
|
||||
users,
|
||||
agents,
|
||||
appRows,
|
||||
permissionFilters,
|
||||
selectedUserIds,
|
||||
filteredUsers,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1,100 +0,0 @@
|
||||
/**
|
||||
* features/admin/modules/requests/RequestsPage.vue
|
||||
* 权限申请管理独立页面。路由:/admin/requests
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ShieldCheck } from 'lucide-vue-next';
|
||||
import { useRequestsAdmin } from './composables/useRequestsAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
requests,
|
||||
isLoading,
|
||||
loadAll,
|
||||
approveRequest,
|
||||
rejectRequest,
|
||||
} = useRequestsAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.request.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.request.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="requests.length === 0"
|
||||
class="flex flex-col items-center justify-center py-16 text-muted"
|
||||
>
|
||||
<div class="w-16 h-16 bg-surface-soft rounded-full flex items-center justify-center mb-4">
|
||||
<ShieldCheck class="w-8 h-8 text-muted" />
|
||||
</div>
|
||||
<p>{{ t('admin.request.noPending') }}</p>
|
||||
</div>
|
||||
|
||||
<table v-else class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.userId') }}</th>
|
||||
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.targetAgent') }}</th>
|
||||
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.reason') }}</th>
|
||||
<th class="px-8 py-4 text-xs">{{ t('admin.request.headers.status') }}</th>
|
||||
<th class="px-8 py-4 text-xs text-right">{{ t('admin.request.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="req in requests" :key="req.id">
|
||||
<td class="px-8 py-4 text-sm font-medium text-primary">{{ req.user_id }}</td>
|
||||
<td class="px-8 py-4 text-sm text-secondary">{{ req.agent_id }}</td>
|
||||
<td
|
||||
class="px-8 py-4 text-sm text-muted max-w-xs truncate"
|
||||
:title="req.reason"
|
||||
>
|
||||
{{ req.reason || '-' }}
|
||||
</td>
|
||||
<td class="px-8 py-4">
|
||||
<span
|
||||
class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-yellow-50 text-yellow-700 border border-yellow-100"
|
||||
>
|
||||
{{ t('admin.status.' + req.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-8 py-4 text-right">
|
||||
<div class="flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
class="text-green-600 hover:text-green-800 text-sm font-medium hover:underline"
|
||||
@click="approveRequest(req.id)"
|
||||
>
|
||||
{{ t('admin.request.approve') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="text-red-500 hover:text-red-700 text-sm font-medium hover:underline"
|
||||
@click="rejectRequest(req.id)"
|
||||
>
|
||||
{{ t('admin.request.reject') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,68 +0,0 @@
|
||||
/**
|
||||
* features/admin/modules/requests/composables/useRequestsAdmin.ts
|
||||
* 权限申请管理:列表、通过、拒绝。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
approveAdminPermissionRequest,
|
||||
listAdminPermissionRequests,
|
||||
rejectAdminPermissionRequest,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { useAdminNavBadges } from '@/features/admin/composables/useAdminNavBadges';
|
||||
import type { AdminPermissionRequestRow } from '@/features/admin/types/request.types';
|
||||
|
||||
export function useRequestsAdmin() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const { refreshBadges } = useAdminNavBadges();
|
||||
|
||||
const requests = ref<AdminPermissionRequestRow[]>([]);
|
||||
const isLoading = ref(true);
|
||||
|
||||
const loadRequests = async (): Promise<void> => {
|
||||
try {
|
||||
requests.value = await listAdminPermissionRequests();
|
||||
} catch (e) {
|
||||
console.error('Error loading permission requests:', e);
|
||||
requests.value = [];
|
||||
}
|
||||
};
|
||||
|
||||
const loadAll = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
await loadRequests();
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
const approveRequest = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await approveAdminPermissionRequest(id);
|
||||
await loadRequests();
|
||||
await refreshBadges();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
||||
}
|
||||
};
|
||||
|
||||
const rejectRequest = async (id: number): Promise<void> => {
|
||||
try {
|
||||
await rejectAdminPermissionRequest(id);
|
||||
await loadRequests();
|
||||
await refreshBadges();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.failed'));
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
requests,
|
||||
isLoading,
|
||||
loadAll,
|
||||
approveRequest,
|
||||
rejectRequest,
|
||||
};
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import { Edit, Plus, Trash2, Users } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import PaginationBar from '@/shared/components/PaginationBar.vue';
|
||||
import SortableTableHeader from '@/shared/components/SortableTableHeader.vue';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import BatchEditUserModal from './components/BatchEditUserModal.vue';
|
||||
import BatchPermissionModal from './components/BatchPermissionModal.vue';
|
||||
import UserFormModal from './components/UserFormModal.vue';
|
||||
@@ -199,7 +200,7 @@ onMounted(() => {
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-center">
|
||||
<div class="h-9 w-9 rounded-full bg-gradient-to-br from-brand-500 to-indigo-600 text-white flex items-center justify-center text-xs font-bold shadow-sm">
|
||||
{{ user.username.charAt(0).toUpperCase() }}
|
||||
{{ getUserAvatarLabel(user) }}
|
||||
</div>
|
||||
<div class="ml-3 text-sm font-medium text-primary">{{ user.username }}</div>
|
||||
</div>
|
||||
|
||||
@@ -2,17 +2,10 @@
|
||||
* features/admin/stores/admin-nav.store.ts
|
||||
* 管理后台导航 UI 状态(侧栏折叠、报表/企微子菜单展开、角标)。
|
||||
*
|
||||
* 角标数据来自 GET /api/admin/dashboard/badges,在 store 内做 TTL 缓存与 in-flight 去重,
|
||||
* 避免切换 admin 子路由时重复请求(AdminLayout 挂载一次即可)。
|
||||
* 报表与企业微信子菜单默认折叠,进入对应模块时由 AdminNav 展开。
|
||||
*/
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref } from 'vue';
|
||||
import { getAdminDashboardBadges } from '@/features/admin/api/admin.api';
|
||||
import type { AdminModuleId } from '../types/admin.types';
|
||||
|
||||
/** 角标缓存有效期(毫秒):此时间内 ensureBadges 直接复用内存中的计数 */
|
||||
const BADGE_CACHE_TTL_MS = 60_000;
|
||||
|
||||
export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
const sidebarCollapsed = ref(false);
|
||||
@@ -27,65 +20,10 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
/** 「权限申请」导航角标:pending 权限申请数 */
|
||||
const pendingRequestsCount = ref(0);
|
||||
|
||||
/** 上次成功拉取 badges 的时间戳;0 表示尚未拉取 */
|
||||
let badgesFetchedAt = 0;
|
||||
/** 进行中的 badges 请求 Promise,用于并发调用合并为单次 HTTP */
|
||||
let badgesInFlight: Promise<void> | null = null;
|
||||
|
||||
const toggleSidebar = (): void => {
|
||||
sidebarCollapsed.value = !sidebarCollapsed.value;
|
||||
};
|
||||
|
||||
const setBadgeCounts = (approvals: number, requests: number): void => {
|
||||
pendingApprovalsCount.value = approvals;
|
||||
pendingRequestsCount.value = requests;
|
||||
};
|
||||
|
||||
const badgeForModule = (moduleId: AdminModuleId): number | undefined => {
|
||||
if (moduleId === 'approvals' && pendingApprovalsCount.value > 0) return pendingApprovalsCount.value;
|
||||
if (moduleId === 'requests' && pendingRequestsCount.value > 0) return pendingRequestsCount.value;
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* 拉取侧栏角标。force=false 时命中 TTL 缓存则跳过网络请求;
|
||||
* 多个组件同时调用时会共享同一 inFlight,避免重复打 /dashboard/badges。
|
||||
*/
|
||||
const fetchBadges = async (options?: { force?: boolean }): Promise<void> => {
|
||||
const force = options?.force ?? false;
|
||||
const now = Date.now();
|
||||
|
||||
// 非强制刷新且缓存未过期:直接返回 store 中已有计数
|
||||
if (!force && badgesFetchedAt > 0 && now - badgesFetchedAt < BADGE_CACHE_TTL_MS) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 已有请求在飞:等待同一 Promise,不再发起第二次请求
|
||||
if (badgesInFlight) {
|
||||
return badgesInFlight;
|
||||
}
|
||||
|
||||
badgesInFlight = (async () => {
|
||||
try {
|
||||
const data = await getAdminDashboardBadges();
|
||||
setBadgeCounts(data.pending_approvals, data.pending_requests);
|
||||
badgesFetchedAt = Date.now();
|
||||
} catch {
|
||||
setBadgeCounts(0, 0);
|
||||
} finally {
|
||||
badgesInFlight = null;
|
||||
}
|
||||
})();
|
||||
|
||||
return badgesInFlight;
|
||||
};
|
||||
|
||||
/** AdminLayout onMounted:有有效缓存则跳过请求 */
|
||||
const ensureBadges = (): Promise<void> => fetchBadges({ force: false });
|
||||
|
||||
/** 审批/驳回操作后:忽略缓存,立即重新拉取角标 */
|
||||
const refreshBadges = (): Promise<void> => fetchBadges({ force: true });
|
||||
|
||||
return {
|
||||
sidebarCollapsed,
|
||||
reportsExpanded,
|
||||
@@ -94,9 +32,6 @@ export const useAdminNavStore = defineStore('adminNav', () => {
|
||||
pendingApprovalsCount,
|
||||
pendingRequestsCount,
|
||||
toggleSidebar,
|
||||
setBadgeCounts,
|
||||
badgeForModule,
|
||||
ensureBadges,
|
||||
refreshBadges,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
/**
|
||||
* features/admin/types/admin.types.ts
|
||||
* 管理后台域公共类型。
|
||||
* 绠$悊鍚庡彴鍩熷叕鍏辩被鍨嬨€?
|
||||
*/
|
||||
import type { FeaturePermissions } from '@/shared/utils/auth';
|
||||
|
||||
export type AdminModuleId =
|
||||
| 'dashboard'
|
||||
| 'approvals'
|
||||
| 'users'
|
||||
| 'departments'
|
||||
| 'agents'
|
||||
@@ -17,7 +16,6 @@ export type AdminModuleId =
|
||||
| 'wecom'
|
||||
| 'linked_services'
|
||||
| 'permissions'
|
||||
| 'requests'
|
||||
| 'platform_apps'
|
||||
| 'shipping_inventory'
|
||||
| 'procurement_contract'
|
||||
@@ -48,9 +46,10 @@ export type AdminReportTableId =
|
||||
| 'users'
|
||||
| 'agents'
|
||||
| 'chat_logs'
|
||||
| 'permission_requests'
|
||||
| 'general_feedbacks'
|
||||
| 'feedbacks';
|
||||
| 'feedbacks'
|
||||
| 'ops_overview'
|
||||
| 'issue_analysis';
|
||||
|
||||
export interface AdminUserRow {
|
||||
id: number;
|
||||
@@ -72,6 +71,22 @@ export interface AdminDepartmentRow {
|
||||
code?: string;
|
||||
company?: string;
|
||||
description?: string;
|
||||
member_count?: number;
|
||||
}
|
||||
|
||||
export interface AdminDepartmentMember {
|
||||
id: number;
|
||||
username: string;
|
||||
real_name?: string;
|
||||
employee_id?: string;
|
||||
email?: string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export interface AdminDepartmentMembersResponse {
|
||||
department: AdminDepartmentRow;
|
||||
count: number;
|
||||
members: AdminDepartmentMember[];
|
||||
}
|
||||
|
||||
export interface AdminAgentOption {
|
||||
@@ -87,3 +102,4 @@ export interface AdminAnnouncementRow {
|
||||
content: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,6 @@ export interface AdminDashboardSummary {
|
||||
avg_score: number;
|
||||
}
|
||||
|
||||
/** GET /api/admin/dashboard/badges — 侧栏「用户审批」「权限申请」角标 */
|
||||
export interface AdminDashboardBadges {
|
||||
pending_approvals: number;
|
||||
pending_requests: number;
|
||||
}
|
||||
|
||||
export interface AdminUsageReport {
|
||||
total: number;
|
||||
by_user: { username: string; count: number }[];
|
||||
|
||||
@@ -8,6 +8,19 @@
|
||||
/** 使用分析时间范围(与后端 USAGE_RANGE_DAYS 一致) */
|
||||
export type UsageRangeKey = '7d' | '30d' | '90d' | '180d' | '365d';
|
||||
|
||||
/** 「用户反馈与回答评价」页内 Tab:general=意见反馈(general_feedbacks),rating=回答评价(feedbacks) */
|
||||
export type ReportFeedbackTab = 'general' | 'rating';
|
||||
|
||||
/** 工作日 x 时段热力图数据 */
|
||||
export interface UsageHourHeatmap {
|
||||
/** 纵轴一周日序号(ISO:1=周一 .. 7=周日) */
|
||||
weekdays: number[];
|
||||
/** 横轴小时(0-23) */
|
||||
hours: number[];
|
||||
/** 单元格矩阵:cells[weekdayIndex][hourIndex] = 该日该时段对话量 */
|
||||
cells: number[][];
|
||||
}
|
||||
|
||||
export interface UsageReport {
|
||||
total: number;
|
||||
/** 当前统计时间范围 */
|
||||
@@ -16,6 +29,10 @@ export interface UsageReport {
|
||||
by_agent: { agent: string; count: number }[];
|
||||
/** 当前范围内按自然日聚合的对话趋势,用于使用分析柱状图。 */
|
||||
by_day?: { date: string; count: number }[];
|
||||
/** 人员/部门排行:按部门聚合对话量与去重用户数 */
|
||||
by_department?: { department: string; chat_count: number; user_count: number }[];
|
||||
/** 工作日 x 时段热力图:横轴=小时,纵轴=工作日(周一..周五),格子颜色深浅=该日该时段对话量 */
|
||||
hour_heatmap?: UsageHourHeatmap;
|
||||
/**
|
||||
* 运营提醒:启用应用中范围内对话次数 ≤ low_agent_max_chats 的列表(含零使用)。
|
||||
* 由后端以 Agent 主表左连接统计,与应用运营「零使用」口径对齐。
|
||||
@@ -35,8 +52,8 @@ export interface UsageReport {
|
||||
/** 应用运营报表:启用状态筛选 */
|
||||
export type ApplicationStatusFilter = 'all' | 'active' | 'inactive';
|
||||
|
||||
/** 应用运营报表:是否有使用筛选 */
|
||||
export type ApplicationUsageFilter = 'all' | 'used' | 'unused';
|
||||
/** 应用运营报表:是否有使用筛选(unused_authorized=已授权未使用) */
|
||||
export type ApplicationUsageFilter = 'all' | 'used' | 'unused' | 'unused_authorized';
|
||||
|
||||
/** 应用运营报表可排序字段 */
|
||||
export type ApplicationSortKey =
|
||||
@@ -58,11 +75,12 @@ export interface ApplicationReportItem {
|
||||
last_active_at: string | null;
|
||||
authorized_users: number;
|
||||
/** 后端仍返回;应用运营页已不再展示待审列 */
|
||||
pending_requests?: number;
|
||||
avg_score: number | null;
|
||||
feedback_count: number;
|
||||
tokens_used: number;
|
||||
avg_latency_ms: number | null;
|
||||
/** 「已授权未使用」:已授权给用户但范围内无对话 */
|
||||
authorized_unused?: boolean;
|
||||
}
|
||||
|
||||
export interface ApplicationReportSummary {
|
||||
@@ -72,6 +90,8 @@ export interface ApplicationReportSummary {
|
||||
unused_agents: number;
|
||||
/** 后端仍返回;应用运营页已不再展示待审摘要卡 */
|
||||
pending_permission_total?: number;
|
||||
/** 「已授权未使用」应用数量 */
|
||||
authorized_unused_count?: number;
|
||||
}
|
||||
|
||||
export interface ApplicationReport {
|
||||
@@ -108,3 +128,40 @@ export interface SortRule {
|
||||
key: string;
|
||||
direction: SortDirection;
|
||||
}
|
||||
|
||||
/** 运营总览 KPI 卡片指标 */
|
||||
export interface OpsOverviewKpi {
|
||||
total_chats: number;
|
||||
active_users: number;
|
||||
active_agents: number;
|
||||
/** 待跟进反馈数量(status=pending 的通用意见反馈,与反馈页「待处理」一致) */
|
||||
pending_feedback: number;
|
||||
}
|
||||
|
||||
/** 运营总览:对话趋势与环比 */
|
||||
export interface OpsOverviewTrend {
|
||||
by_day: { date: string; count: number }[];
|
||||
total: number;
|
||||
prev_total: number;
|
||||
/** 环比变化百分数;无上一周期数据时为 null */
|
||||
change_pct: number | null;
|
||||
range_days: number;
|
||||
}
|
||||
|
||||
/** 运营总览:Top / 低使用应用项 */
|
||||
export interface OpsOverviewApp {
|
||||
agent_id: number;
|
||||
name: string;
|
||||
chat_count: number;
|
||||
unique_users: number;
|
||||
avg_score: number | null;
|
||||
authorized_users?: number;
|
||||
}
|
||||
|
||||
export interface OpsOverviewReport {
|
||||
range: UsageRangeKey;
|
||||
kpi: OpsOverviewKpi;
|
||||
trend: OpsOverviewTrend;
|
||||
top_apps: OpsOverviewApp[];
|
||||
low_use_apps: OpsOverviewApp[];
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/**
|
||||
* features/admin/types/request.types.ts
|
||||
* 权限申请管理类型。
|
||||
*/
|
||||
|
||||
export interface AdminPermissionRequestRow {
|
||||
id: number;
|
||||
user_id: number;
|
||||
agent_id: number;
|
||||
reason: string;
|
||||
status: string;
|
||||
created_at: string;
|
||||
reviewed_at?: string | null;
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
/**
|
||||
* features/admin/views/AdminLayout.vue
|
||||
* 管理后台壳层:顶栏 + AdminNav + 子路由出口。
|
||||
* 角标仅在 Layout 首次挂载时 ensureBadges(store 内 60s TTL 缓存)。
|
||||
* 逻辑:桌面端将导航与业务内容拆成独立纵向滚动区,任一侧滚动不会带动另一侧。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { ArrowLeft } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
@@ -16,15 +15,11 @@ const { t } = useI18n();
|
||||
const router = useRouter();
|
||||
const navStore = useAdminNavStore();
|
||||
|
||||
// 进入 /admin 时拉一次角标;切换子路由不重复挂载 Layout,故不会重复请求
|
||||
onMounted(() => {
|
||||
void navStore.ensureBadges();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page-shell min-h-screen font-sans flex flex-col">
|
||||
<header class="app-header px-6">
|
||||
<div class="page-shell flex h-dvh min-h-screen flex-col overflow-hidden font-sans">
|
||||
<header class="app-header shrink-0 px-6">
|
||||
<div class="flex items-center gap-4">
|
||||
<button type="button" class="btn-icon-ds md:block hidden" @click="navStore.toggleSidebar()">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/></svg>
|
||||
@@ -42,9 +37,11 @@ onMounted(() => {
|
||||
<AppHeaderTools />
|
||||
</header>
|
||||
|
||||
<main class="flex-1 w-full mx-auto px-4 md:px-8 py-6 md:py-8 flex flex-col md:flex-row gap-8 items-start">
|
||||
<AdminNav />
|
||||
<section class="flex-1 min-w-0 space-y-8 w-full">
|
||||
<main class="flex min-h-0 flex-1 w-full mx-auto flex-col gap-8 overflow-hidden px-4 py-6 md:flex-row md:items-stretch md:px-8 md:py-8">
|
||||
<aside class="min-h-0 shrink-0 overflow-y-auto md:pr-1">
|
||||
<AdminNav />
|
||||
</aside>
|
||||
<section class="min-h-0 w-full flex-1 space-y-8 overflow-y-auto md:pr-1">
|
||||
<router-view />
|
||||
</section>
|
||||
</main>
|
||||
|
||||
@@ -41,8 +41,13 @@ export function useChatScroll(options: UseChatScrollOptions) {
|
||||
|
||||
const stopContainerWatch = watch(container, syncScrollListener, { immediate: true });
|
||||
|
||||
/**
|
||||
* 判断是否显示“回到最新消息”按钮。
|
||||
* 核心逻辑:只要用户离开底部就提供入口;流式回复只有两条消息时同样需要可恢复跟随。
|
||||
* @returns 用户是否正在查看历史内容。
|
||||
*/
|
||||
const showScrollToBottom = computed(() =>
|
||||
messages.value.length >= 4 && !isNearBottom.value,
|
||||
messages.value.length > 0 && !isNearBottom.value,
|
||||
);
|
||||
|
||||
const scrollToBottom = async () => {
|
||||
@@ -118,9 +123,15 @@ export function useChatScroll(options: UseChatScrollOptions) {
|
||||
stopContainerWatch();
|
||||
};
|
||||
|
||||
/** 消息/思考态变化时自动滚动(思考结束滚到用户问题,否则贴底) */
|
||||
/**
|
||||
* 监听流式消息与会话状态,决定是否继续贴底跟随。
|
||||
* 核心逻辑:用户在底部时显示最新生成内容;用户手动向上阅读后停止自动滚动,
|
||||
* 直到其主动点击“回到最新消息”。
|
||||
* @param isThinking - 当前回复是否仍在生成,用于纳入监听依赖。
|
||||
* @param conversationId - 当前会话标识,用于在切换会话后重新评估滚动状态。
|
||||
* @returns 无返回值;监听会在 composable 卸载时自动清理。
|
||||
*/
|
||||
const setupThinkingScrollWatch = (isThinking: Ref<boolean>, conversationId?: Ref<string | null>) => {
|
||||
let wasThinking = false;
|
||||
watch(
|
||||
() => ({
|
||||
messageCount: messages.value.length,
|
||||
@@ -130,14 +141,14 @@ export function useChatScroll(options: UseChatScrollOptions) {
|
||||
conversationId: conversationId?.value || '',
|
||||
}),
|
||||
() => {
|
||||
if (wasThinking && !isThinking.value) {
|
||||
wasThinking = false;
|
||||
void scrollToUserQuestion();
|
||||
} else {
|
||||
if (isThinking.value) wasThinking = true;
|
||||
if (isNearBottom.value) scheduleScrollToBottom();
|
||||
else window.requestAnimationFrame(updateNearBottomState);
|
||||
// [STEP 1] 用户停留在底部时随新内容向下滚动;离开底部后保留阅读位置。
|
||||
if (isNearBottom.value) {
|
||||
scheduleScrollToBottom();
|
||||
return;
|
||||
}
|
||||
|
||||
// [STEP 2] 内容高度变化可能使“接近底部”状态恢复,重新计算但不主动移动视口。
|
||||
window.requestAnimationFrame(updateNearBottomState);
|
||||
},
|
||||
{ deep: false },
|
||||
);
|
||||
|
||||
@@ -12,6 +12,12 @@ describe('isStrongLeaveIntent', () => {
|
||||
// 断言:规则咨询不应触发本地请假表单,应继续走 Dify 问答。
|
||||
expect(isStrongLeaveIntent('年假可以按照小时请假吗?')).toBe(false);
|
||||
expect(isStrongLeaveIntent('怎么请年假?年假可以按照小时请假吗?')).toBe(false);
|
||||
// 断言:扣薪/薪资计算属于知识库制度问答,不应弹出请假申请表单。
|
||||
expect(isStrongLeaveIntent('请假扣多少薪资')).toBe(false);
|
||||
expect(isStrongLeaveIntent('请假如何扣除薪资')).toBe(false);
|
||||
expect(isStrongLeaveIntent('请病假怎么扣钱')).toBe(false);
|
||||
expect(isStrongLeaveIntent('请假扣多少钱,计算公式是什么')).toBe(false);
|
||||
expect(isStrongLeaveIntent('薪资福利中的请假扣款怎么算')).toBe(false);
|
||||
});
|
||||
|
||||
it('保留强请假意图触发表单', () => {
|
||||
|
||||
@@ -140,6 +140,10 @@ export function getLeaveIntentNormalized(content: string): string {
|
||||
/** 区分「真请假」与「咨询流程/材料」类弱意图 */
|
||||
export function isStrongLeaveIntent(content: string): boolean {
|
||||
const normalized = getLeaveIntentNormalized(content);
|
||||
// [STEP 1] 薪资/扣薪属于制度计算问答,必须交给 Dify/FAQ,不能被“请假”关键词抢先拦截为申请表单。
|
||||
// [PROMPT_UPDATE] 保留知识库中的计算公式、适用条件和口径,由知识库回答而非前端自行生成。
|
||||
const leaveSalaryConsultationIntent = /(请假|休假|年假|事假|病假).{0,12}(薪资|工资|薪酬|扣薪|扣钱|扣款|扣除|多少钱|福利|计算|公式)|(?:薪资|工资|薪酬|扣薪|扣钱|扣款|扣除|多少钱|福利|计算公式).{0,12}(请假|休假|年假|事假|病假)/;
|
||||
if (leaveSalaryConsultationIntent.test(normalized)) return false;
|
||||
const weakConsultationIntent = /(请假流程|请假怎么走|请假步骤|请假如何申请|请假如何走流程|请假怎么办|请假需要什么|请假规定|请假管理办法|请假制度)/;
|
||||
const weakLeaveQuestionIntent = /((怎么|如何).{0,8}(请假|请年假|休假|休年假|年假)|(请假|年假|休假).{0,12}(可以|可否|能否|是否|支持).{0,8}(按小时|按照小时|小时请|小时休))/;
|
||||
const materialConsultationIntent = /(提交哪些|提交什么|需要哪些|需要什么|要提交哪些|要提交什么|哪些资料|哪些材料|什么资料|什么材料|申请材料|所需资料|所需材料)/;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/kb/components/KbAdminPanel.vue
|
||||
* 知识库配置面板(治理面:分组、Dify、任务队列)。
|
||||
* 知识库配置面板(治理面:分组、Dify)。
|
||||
* 依赖:kb.api、DifySettingsDialog、DifyHealthDialog、DeleteConfirmDialog、Vue I18n。
|
||||
* 逻辑:管理控制台加载知识库分组与任务队列;分组列表在主表格过滤排序,新增/编辑通过右侧抽屉提交。
|
||||
* 逻辑:管理控制台加载知识库分组;分组列表在主表格过滤排序,新增/编辑通过右侧抽屉提交。
|
||||
*/
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
Wrench,
|
||||
} from 'lucide-vue-next';
|
||||
import KbGroupDrawer, { type KbGroupFormValue } from './KbGroupDrawer.vue';
|
||||
import KbJobQueuePanel from './KbJobQueuePanel.vue';
|
||||
import DifyHealthDialog from './DifyHealthDialog.vue';
|
||||
import DifySettingsDialog from './DifySettingsDialog.vue';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
@@ -30,11 +29,8 @@ import {
|
||||
createKbGroup,
|
||||
deleteKbGroup,
|
||||
getKbGroupsSafe,
|
||||
getKbJobsSafe,
|
||||
runKbJob,
|
||||
updateKbGroup,
|
||||
type KbGroup,
|
||||
type KbJob,
|
||||
} from '../api/kb.api';
|
||||
import { formatDateTime } from '../utils/kb-display.utils';
|
||||
|
||||
@@ -45,7 +41,6 @@ const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
|
||||
const groups = ref<KbGroup[]>([]);
|
||||
const jobs = ref<KbJob[]>([]);
|
||||
const isSubmitting = ref(false);
|
||||
const isDeleting = ref(false);
|
||||
const isRefreshing = ref(false);
|
||||
@@ -53,7 +48,6 @@ const editingGroupId = ref<number | null>(null);
|
||||
const form = ref<KbGroupFormValue>({ name: '', description: '' });
|
||||
const feedback = ref('');
|
||||
const feedbackType = ref<'success' | 'error' | ''>('');
|
||||
const runningJobId = ref<number | string | null>(null);
|
||||
const settingsDialogOpen = ref(false);
|
||||
const healthDialogOpen = ref(false);
|
||||
const deleteDialogOpen = ref(false);
|
||||
@@ -103,20 +97,15 @@ const pagedGroups = computed(() => {
|
||||
/** 格式化分组更新时间,避免管理台表格直接暴露后端 ISO 时间字符串。 */
|
||||
const formatGroupUpdatedAt = (value?: string | null) => formatDateTime(value);
|
||||
|
||||
/** 加载知识库治理页的分组与任务队列,供页面初始渲染和操作后刷新复用。 */
|
||||
/** 加载知识库治理页的分组数据,供页面初始渲染和操作后刷新复用。 */
|
||||
const loadData = async () => {
|
||||
isRefreshing.value = true;
|
||||
const [groupsResult, jobsResult] = await Promise.all([getKbGroupsSafe(), getKbJobsSafe()]);
|
||||
const groupsResult = await getKbGroupsSafe();
|
||||
if (groupsResult.ok) groups.value = groupsResult.data;
|
||||
else {
|
||||
feedback.value = groupsResult.error || t('kbAdmin.msg.loadGroupsFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
if (jobsResult.ok) jobs.value = jobsResult.data;
|
||||
else {
|
||||
feedback.value = jobsResult.error || t('kbAdmin.msg.loadJobsFailed');
|
||||
feedbackType.value = 'error';
|
||||
}
|
||||
isRefreshing.value = false;
|
||||
};
|
||||
|
||||
@@ -199,23 +188,6 @@ const handleDeleteGroupConfirm = async () => {
|
||||
await loadData();
|
||||
};
|
||||
|
||||
/** 手动执行可重试的知识库任务,并将后端执行结果反馈到页面提示区。 */
|
||||
const handleRunJob = async (job: KbJob) => {
|
||||
runningJobId.value = job.id;
|
||||
const result = await runKbJob(job.id);
|
||||
runningJobId.value = null;
|
||||
|
||||
if (!result.ok) {
|
||||
feedback.value = result.error || t('kbAdmin.msg.runFailed');
|
||||
feedbackType.value = 'error';
|
||||
return;
|
||||
}
|
||||
|
||||
feedback.value = result.run_result || t('kbAdmin.msg.runDone');
|
||||
feedbackType.value = 'success';
|
||||
await loadData();
|
||||
};
|
||||
|
||||
watch([searchKeyword, filterMode, sortMode, pageSize], () => {
|
||||
currentPage.value = 1;
|
||||
});
|
||||
@@ -362,11 +334,6 @@ defineExpose({ loadData });
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<KbJobQueuePanel
|
||||
:jobs="jobs"
|
||||
:running-job-id="runningJobId"
|
||||
@run-job="handleRunJob"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -10,6 +10,15 @@ import { storeToRefs } from 'pinia';
|
||||
import { ExternalLink } from 'lucide-vue-next';
|
||||
import { useLinkedNavStore } from '../stores/linked-nav.store';
|
||||
|
||||
/**
|
||||
* 判断关联入口是否为图纸标注。
|
||||
* 图纸标注入口使用产品提供的尺规图标,其余入口继续使用统一的外链图标。
|
||||
*/
|
||||
function isDrawingAnnotationEntry(displayName: string): boolean {
|
||||
const normalized = String(displayName || '').trim();
|
||||
return normalized.includes('图纸标注') || normalized.includes('标注');
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
compact?: boolean;
|
||||
showLabel?: boolean;
|
||||
@@ -56,7 +65,13 @@ onMounted(() => {
|
||||
:title="entry.display_name"
|
||||
@click="linkedNav.openItem(entry)"
|
||||
>
|
||||
<ExternalLink :class="resolvedIconClass" />
|
||||
<img
|
||||
v-if="isDrawingAnnotationEntry(entry.display_name)"
|
||||
src="/icons/drawing-annotation.png"
|
||||
alt=""
|
||||
:class="[resolvedIconClass, 'object-contain']"
|
||||
/>
|
||||
<ExternalLink v-else :class="resolvedIconClass" />
|
||||
<span v-if="showLabel && !compact" class="truncate">{{ entry.display_name }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
User, Mail, Building, CreditCard, Globe, Save, Palette,
|
||||
} from 'lucide-vue-next';
|
||||
import { getUserAvatarLabel } from '@/shared/utils/user-avatar';
|
||||
import { WORKSPACE_KEY } from '@/features/workspace/composables/workspace.context';
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -20,14 +21,6 @@ const fieldValueClass = 'flex min-h-11 items-center rounded-xl border border-def
|
||||
/** 表单标签:与分区标题区分层级,全页统一 14px。 */
|
||||
const fieldLabelClass = 'mb-1.5 flex items-center gap-1.5 text-sm font-medium text-muted';
|
||||
|
||||
/**
|
||||
* 头像字母:取姓名或用户名首字,供身份卡展示。
|
||||
*/
|
||||
const avatarLetter = computed(() => {
|
||||
const source = userProfile.profileUser.real_name || userProfile.profileUser.username || 'U';
|
||||
return source.charAt(0).toUpperCase();
|
||||
});
|
||||
|
||||
/**
|
||||
* 身份主标题:优先真实姓名,缺失时回退用户名。
|
||||
*/
|
||||
@@ -66,7 +59,7 @@ const identityMeta = computed(() => {
|
||||
<div
|
||||
class="flex h-14 w-14 shrink-0 items-center justify-center rounded-full bg-brand-100 text-xl font-semibold text-brand-600 md:h-16 md:w-16 md:text-2xl"
|
||||
>
|
||||
{{ avatarLetter }}
|
||||
{{ getUserAvatarLabel(userProfile.profileUser) }}
|
||||
</div>
|
||||
<div class="min-w-0 space-y-0.5">
|
||||
<div class="truncate text-lg font-semibold text-primary">{{ displayName }}</div>
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user