Browse Source

✨ feat: 绑定解绑审计来源与详情支持中文展示

将管理端审计列表中的来源字段改为中文映射展示,并将详情中的常用键值与触发方式转换为中文文案,提升客服和运营排查效率。

Made-with: Cursor
Pchen0 1 month ago
parent
commit
90b35e91d7

+ 34 - 2
src/pages/admin/lepaoAccount/accountList.vue

@@ -267,6 +267,9 @@
             <template #action="{ record }">
                 <a-tag>{{ actionLabel(record.action) }}</a-tag>
             </template>
+            <template #source="{ record }">
+                {{ sourceLabel(record.source) }}
+            </template>
             <template #operator_user="{ record }">
                 <a-space>
                     <a-avatar :size="26">
@@ -450,7 +453,7 @@ const bindAuditColumns = [
     { title: '乐跑账号', slotName: 'lepao_user', width: 180 },
     { title: '所属用户', slotName: 'owner_user', width: 180 },
     { title: '动作', slotName: 'action', width: 120 },
-    { title: '来源', dataIndex: 'source', width: 140 },
+    { title: '来源', slotName: 'source', width: 140 },
     { title: '操作者', slotName: 'operator_user', width: 180 },
     { title: '详情', slotName: 'detail_json', width: 220, ellipsis: true, tooltip: true },
     { title: '时间', slotName: 'created_at', width: 180 }
@@ -690,10 +693,39 @@ const actionLabel = (action) => {
     return map[action] || action
 }
 
+const sourceLabel = (source) => {
+    const map = {
+        user_api: '用户接口',
+        admin_api: '管理员接口',
+        service_api: '客服接口',
+        mcp_qq: '机器人MCP',
+        mcp_work_order: '工单MCP'
+    }
+    return map[source] || source
+}
+
 const formatDetail = (detail) => {
     if (!detail) return '-'
     if (typeof detail === 'string') return detail
-    return Object.keys(detail).map(key => `${key}:${detail[key]}`).join(' ; ')
+    const keyMap = {
+        via: '触发方式',
+        sender: '发送者',
+        old_owner_uuid: '原所属用户UUID',
+        new_owner_uuid: '新所属用户UUID'
+    }
+    const valueMap = {
+        AddAccount: '用户新增账号',
+        DeleteAccount: '账号解绑接口',
+        'AddAccount:auto_unbind_rebind': '新增账号自动解绑并重绑'
+    }
+    return Object.keys(detail)
+        .map((key) => {
+            const label = keyMap[key] || key
+            const rawValue = detail[key]
+            const value = (typeof rawValue === 'string' && valueMap[rawValue]) ? valueMap[rawValue] : rawValue
+            return `${label}:${value}`
+        })
+        .join(';')
 }
 
 const openBindAudit = async (record) => {

+ 35 - 2
src/pages/admin/lepaoBindAudit/index.vue

@@ -103,7 +103,11 @@
               <a-tag>{{ actionLabel(record.action) }}</a-tag>
             </template>
           </a-table-column>
-          <a-table-column title="来源" data-index="source" :width="150" />
+          <a-table-column title="来源" :width="150">
+            <template #cell="{ record }">
+              {{ sourceLabel(record.source) }}
+            </template>
+          </a-table-column>
           <a-table-column title="操作者" :width="180">
             <template #cell="{ record }">
               <a-space>
@@ -157,10 +161,39 @@ const actionLabel = (action) => {
   return map[action] || action
 }
 
+const sourceLabel = (source) => {
+  const map = {
+    user_api: '用户接口',
+    admin_api: '管理员接口',
+    service_api: '客服接口',
+    mcp_qq: '机器人MCP',
+    mcp_work_order: '工单MCP'
+  }
+  return map[source] || source
+}
+
 const formatDetail = (detail) => {
   if (!detail) return '-'
   if (typeof detail === 'string') return detail
-  return Object.keys(detail).map(key => `${key}:${detail[key]}`).join(' ; ')
+  const keyMap = {
+    via: '触发方式',
+    sender: '发送者',
+    old_owner_uuid: '原所属用户UUID',
+    new_owner_uuid: '新所属用户UUID'
+  }
+  const valueMap = {
+    AddAccount: '用户新增账号',
+    DeleteAccount: '账号解绑接口',
+    'AddAccount:auto_unbind_rebind': '新增账号自动解绑并重绑'
+  }
+  return Object.keys(detail)
+    .map((key) => {
+      const label = keyMap[key] || key
+      const rawValue = detail[key]
+      const value = (typeof rawValue === 'string' && valueMap[rawValue]) ? valueMap[rawValue] : rawValue
+      return `${label}:${value}`
+    })
+    .join(';')
 }
 
 const formatTime = (time) => new Date(time).toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })