cc hai 3 días
pai
achega
e2f16a56ff

+ 6 - 6
ai-electron/frontend/src/workbench/api/audit.ts

@@ -1,16 +1,16 @@
-import { aiDownload, aiGet, aiPost, aiPut, PageResult } from './http';
+import { aiDownload, aiGet, aiPage, aiPost, aiPut, PageResult } from './http';
 
 export type Id = string | number;
 
 // ---- 会话/消息审计 ----
 export function listMessageAudit(query?: any): Promise<PageResult<any>> {
-  return aiGet<PageResult<any>>('/ai/audit/message/list', query);
+  return aiPage<any>('/ai/audit/message/list', query);
 }
 export function exportMessageAudit(query: any, filename: string): Promise<void> {
   return aiDownload('/ai/audit/message/export', query, filename, 'POST');
 }
 export function listToolCallAudit(query?: any): Promise<PageResult<any>> {
-  return aiGet<PageResult<any>>('/ai/audit/toolCall/list', query);
+  return aiPage<any>('/ai/audit/toolCall/list', query);
 }
 export function toolCallStats(query?: any): Promise<any[]> {
   return aiGet<any[]>('/ai/audit/toolCall/stats', query);
@@ -30,7 +30,7 @@ export function purgeAuditRetention(): Promise<any> {
 
 // ---- 链路追踪 ----
 export function listTrace(query?: any): Promise<PageResult<any>> {
-  return aiGet<PageResult<any>>('/ai/trace/list', query);
+  return aiPage<any>('/ai/trace/list', query);
 }
 export function getTrace(id: Id): Promise<any> {
   return aiGet<any>(`/ai/trace/${id}`);
@@ -38,7 +38,7 @@ export function getTrace(id: Id): Promise<any> {
 
 // ---- 编排运行 ----
 export function listRouteRuns(query?: any): Promise<PageResult<any>> {
-  return aiGet<PageResult<any>>('/ai/route/run/list', query);
+  return aiPage<any>('/ai/route/run/list', query);
 }
 export function routeRunStats(query?: any): Promise<any> {
   return aiGet<any>('/ai/route/run/stats', query);
@@ -49,7 +49,7 @@ export function getRouteRun(id: Id): Promise<any> {
 
 // ---- 用量 ----
 export function listUsageStat(query?: any): Promise<PageResult<any>> {
-  return aiGet<PageResult<any>>('/ai/usage/list', query);
+  return aiPage<any>('/ai/usage/list', query);
 }
 export function usageOverview(query?: any): Promise<any> {
   return aiGet<any>('/ai/usage/overview', query);

+ 6 - 0
ai-electron/frontend/src/workbench/api/http.ts

@@ -51,6 +51,12 @@ export function aiGet<T = any>(path: string, params?: Record<string, any>, optio
   return defHttp.get<T>({ url: aiUrl(path), params: cleanParams(params) }, options);
 }
 
+/** 分页列表接口:后端 total 可能序列化为字符串,统一归一为 number 供 BasicTable 分页消费 */
+export async function aiPage<T = any>(path: string, params?: Record<string, any>): Promise<PageResult<T>> {
+  const res = await aiGet<PageResult<T>>(path, params);
+  return { total: Number(res?.total ?? 0), rows: res?.rows ?? [] };
+}
+
 export function aiPost<T = any>(path: string, data?: any): Promise<T> {
   return defHttp.postJson<T>({ url: aiUrl(path), data });
 }

+ 3 - 3
ai-electron/frontend/src/workbench/api/kb.ts

@@ -1,4 +1,4 @@
-import { aiDelete, aiGet, aiPost, aiPut, PageResult } from './http';
+import { aiDelete, aiGet, aiPage, aiPost, aiPut, PageResult } from './http';
 
 export type Id = string | number;
 
@@ -91,13 +91,13 @@ export function delKnowledgeBase(ids: Id | Id[]): Promise<void> {
 
 // ---- 文档 ----
 export function listDocument(query?: any): Promise<PageResult<DocumentVO>> {
-  return aiGet<PageResult<DocumentVO>>('/ai/kb/doc/list', query);
+  return aiPage<DocumentVO>('/ai/kb/doc/list', query);
 }
 export function getDocumentContent(id: Id): Promise<string> {
   return aiGet<string>(`/ai/kb/doc/${id}/content`);
 }
 export function listDocumentChunk(id: Id, query?: any): Promise<PageResult<ChunkVO>> {
-  return aiGet<PageResult<ChunkVO>>(`/ai/kb/doc/${id}/chunks`, query);
+  return aiPage<ChunkVO>(`/ai/kb/doc/${id}/chunks`, query);
 }
 export function getDocumentChunkContext(id: Id, chunkIndex: number, radius = 1): Promise<any> {
   return aiGet<any>(`/ai/kb/doc/${id}/chunks/${chunkIndex}`, { radius });

+ 2 - 2
ai-electron/frontend/src/workbench/api/mcp.ts

@@ -1,9 +1,9 @@
-import { aiDelete, aiGet, aiPost, aiPut, PageResult } from './http';
+import { aiDelete, aiGet, aiPage, aiPost, aiPut, PageResult } from './http';
 
 export type Id = string | number;
 
 export function listMcpClient(query?: any): Promise<PageResult<any>> {
-  return aiGet<PageResult<any>>('/ai/mcp/client/list', query);
+  return aiPage<any>('/ai/mcp/client/list', query);
 }
 export function getMcpClient(id: Id): Promise<any> {
   return aiGet<any>(`/ai/mcp/client/${id}`);

+ 2 - 2
ai-electron/frontend/src/workbench/api/session.ts

@@ -1,9 +1,9 @@
-import { aiDelete, aiDownload, aiGet, aiPut, PageResult } from './http';
+import { aiDelete, aiDownload, aiGet, aiPage, aiPut, PageResult } from './http';
 
 export type Id = string | number;
 
 export function listChatSessions(query?: any): Promise<PageResult<any>> {
-  return aiGet<PageResult<any>>('/ai/session/list', query);
+  return aiPage<any>('/ai/session/list', query);
 }
 export function optionSessionAgent(): Promise<any[]> {
   return aiGet<any[]>('/ai/session/agent/options');

+ 3 - 3
ai-electron/frontend/src/workbench/api/tool.ts

@@ -1,4 +1,4 @@
-import { aiDelete, aiGet, aiPost, aiPut, PageResult } from './http';
+import { aiDelete, aiGet, aiPage, aiPost, aiPut, PageResult } from './http';
 
 export type Id = string | number;
 
@@ -17,7 +17,7 @@ export interface ToolVO {
 }
 
 export function listTool(query?: any): Promise<PageResult<ToolVO>> {
-  return aiGet<PageResult<ToolVO>>('/ai/tool/list', query);
+  return aiPage<ToolVO>('/ai/tool/list', query);
 }
 export function getTool(id: Id): Promise<ToolVO> {
   return aiGet<ToolVO>(`/ai/tool/${id}`);
@@ -32,7 +32,7 @@ export function delTool(ids: Id | Id[]): Promise<void> {
   return aiDelete<void>(`/ai/tool/${Array.isArray(ids) ? ids.join(',') : ids}`);
 }
 export function listToolTag(query?: any): Promise<PageResult<any>> {
-  return aiGet<PageResult<any>>('/ai/tool/tag/list', query);
+  return aiPage<any>('/ai/tool/tag/list', query);
 }
 export function optionToolTag(): Promise<any[]> {
   return aiGet<any[]>('/ai/tool/tag/options');

+ 2 - 3
ai-electron/frontend/src/workbench/components/ant.ts

@@ -2,7 +2,8 @@
  * 智能工作台 Ant Design Vue 组件别名。
  *
  * 目标项目未全局注册 AntDV(仅全局注册 Input/Button),页面需显式导入组件;
- * 这里统一以 `A*` 别名导出,模板中继续使用 `a-card` / `a-table` 等 kebab-case 写法。
+ * 这里统一以 `A*` 别名导出,模板中继续使用 `a-card` / `a-tag` 等 kebab-case 写法。
+ * 表格与分页不在此列:统一使用系统封装的 BasicTable(内置统一分页)与 AnalysisPagination。
  */
 export {
   Alert as AAlert,
@@ -31,7 +32,6 @@ export {
   MenuDivider as AMenuDivider,
   MenuItem as AMenuItem,
   Modal as AModal,
-  Pagination as APagination,
   Popover as APopover,
   Progress as AProgress,
   Radio as ARadio,
@@ -45,7 +45,6 @@ export {
   Spin as ASpin,
   Statistic as AStatistic,
   Switch as ASwitch,
-  Table as ATable,
   Tabs as ATabs,
   TabPane as ATabPane,
   Tag as ATag,

+ 113 - 18
ai-electron/frontend/src/workbench/styles/workbench.less

@@ -146,6 +146,61 @@
   margin-top: 12px;
 }
 
+// BasicTable 嵌入 flex 卡片:逐层传递高度,表体内部滚动、统一分页固定在卡片底部。
+// 与 canResize + isCanResizeParent 搭配使用(同 call/continuous 等分析页结构)。
+.wb-table-fill {
+  display: flex;
+  flex: 1 1 auto;
+  flex-direction: column;
+  height: 100%;
+  min-height: 0;
+  overflow: hidden;
+
+  .ant-table-wrapper,
+  .ant-spin-nested-loading,
+  .ant-spin-container,
+  .ant-table,
+  .ant-table-container {
+    display: flex;
+    flex: 1 1 auto;
+    flex-direction: column;
+    height: 100%;
+    min-height: 0;
+  }
+
+  .ant-table-header {
+    flex: 0 0 auto;
+  }
+
+  .ant-table-body {
+    flex: 1 1 auto;
+    min-height: 0;
+    // 用容器高度兜底,避免 BasicTable 写入的 max-height 偏小在表格下方留下空白
+    max-height: 100% !important;
+    overflow-y: auto;
+  }
+}
+
+// BasicTable 核心样式默认隐藏分页(仅 canResize 算高时内联恢复 display),
+// 工作台的自然高度表格与弹窗内表格在此以更高优先级恢复显示与外边距
+.jeesite-basic-table.wb-table,
+.jeesite-basic-table.wb-table-fill {
+  .ant-table-wrapper .ant-pagination.ant-table-pagination {
+    display: flex;
+    margin: 12px 0 0;
+  }
+}
+
+.jeesite-basic-table.wb-table-fill {
+  .ant-table-wrapper .ant-pagination.ant-table-pagination {
+    flex: 0 0 auto;
+    justify-content: flex-end;
+    margin: 0;
+    padding: 8px 14px 10px;
+    border-top: 1px solid #eff2f7;
+  }
+}
+
 .wb-mono,
 .wb-pre {
   font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
@@ -568,24 +623,6 @@
     }
   }
 
-  .wb-table-scroll {
-    flex: 1 1 auto;
-    min-height: 0;
-    overflow: auto;
-  }
-
-  .wb-pagination {
-    flex: 0 0 auto;
-    justify-content: flex-end;
-    margin-top: 0;
-    padding: 8px 14px 10px;
-    border-top: 1px solid #eff2f7;
-
-    .ant-pagination {
-      margin: 0;
-    }
-  }
-
   .detail-card {
     background: #fff;
     border: 1px solid #e7ebf3;
@@ -654,6 +691,64 @@
   border-top: 1px solid #eff2f7;
 }
 
+// 抽屉自定义关闭按钮(参考设置侧滑栏:Tooltip + pointer + 明确悬浮反馈):
+// 命中区 40px,负 margin 抵消扩大量,使图标视觉位置与原生 closable 按钮保持一致
+.wb-detail-drawer {
+  .wb-drawer-title {
+    display: inline-flex;
+    align-items: center;
+    gap: 8px;
+    min-width: 0;
+  }
+
+  .wb-drawer-title__text {
+    overflow: hidden;
+    color: #111827;
+    font-size: 15px;
+    font-weight: 600;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+  }
+
+  .wb-drawer-close {
+    display: inline-flex;
+    align-items: center;
+    justify-content: center;
+    flex: 0 0 auto;
+    width: 40px;
+    height: 40px;
+    margin: -4px;
+    padding: 0;
+    border: 0;
+    border-radius: 8px;
+    background: transparent;
+    color: #64748b;
+    cursor: pointer;
+    transition:
+      background 0.15s,
+      color 0.15s,
+      transform 0.1s;
+
+    .anticon {
+      font-size: 16px;
+    }
+
+    &:hover {
+      background: #eef2f7;
+      color: #111827;
+    }
+
+    &:active {
+      transform: scale(0.92);
+    }
+
+    &:focus-visible {
+      outline: 2px solid #2a50ec;
+      outline-offset: 1px;
+    }
+  }
+}
+
 /* ------------------------------------------------------------------ *
  * 抽屉 / 侧边栏通用加固:
  * 1) 关闭按钮扩大命中区域并给明确悬浮反馈,避免「点不到 / 点了没反应」;

+ 55 - 67
ai-electron/frontend/src/workbench/views/agent/memory/index.vue

@@ -260,29 +260,26 @@
                 <span class="memory-panel-meta">{{ files.length }} 个</span>
               </div>
               <div class="memory-panel-body">
-                <a-table
+                <BasicTable
                   :columns="fileColumns"
                   :data-source="files"
                   :loading="fileLoading"
                   row-key="path"
                   :pagination="false"
-                  :custom-row="customRow"
                   :row-class-name="rowClassName"
-                  size="small"
                   class="memory-file-table"
                   :locale="{ emptyText: '暂无记忆文件' }"
+                  @row-click="handleSelectFile"
                 >
-                  <template #bodyCell="{ column, record }">
-                    <template v-if="column.key === 'name'">
-                      <span>{{ record.name }}</span>
-                    </template>
-                    <template v-else-if="column.key === 'type'">
-                      <a-tag :color="record.type === 'MEMORY' ? 'success' : 'default'">
-                        {{ record.type === 'MEMORY' ? '长期' : '流水' }}
-                      </a-tag>
-                    </template>
+                  <template #fileName="{ record }">
+                    <span>{{ record.name }}</span>
                   </template>
-                </a-table>
+                  <template #fileType="{ record }">
+                    <a-tag :color="record.type === 'MEMORY' ? 'success' : 'default'">
+                      {{ record.type === 'MEMORY' ? '长期' : '流水' }}
+                    </a-tag>
+                  </template>
+                </BasicTable>
               </div>
             </div>
 
@@ -333,36 +330,33 @@
             </div>
           </template>
 
-          <a-table
+          <BasicTable
             :columns="declaredColumns"
             :data-source="declared"
             :loading="declaredLoading"
             row-key="id"
             :pagination="false"
-            size="small"
             class="memory-declared-table"
             :locale="{ emptyText: '暂无显式记忆' }"
           >
-            <template #bodyCell="{ column, record }">
-              <template v-if="column.key === 'status'">
-                <a-tag :color="record.revoked ? 'default' : 'success'">
-                  {{ record.revoked ? '已撤销' : '生效中' }}
-                </a-tag>
-              </template>
-              <template v-else-if="column.key === 'action'">
-                <a-button
-                  v-auth="'ai:memory:remove'"
-                  type="link"
-                  danger
-                  size="small"
-                  :disabled="record.revoked"
-                  @click="handleRevokeDeclared(record)"
-                >
-                  撤销
-                </a-button>
-              </template>
+            <template #declaredStatus="{ record }">
+              <a-tag :color="record.revoked ? 'default' : 'success'">
+                {{ record.revoked ? '已撤销' : '生效中' }}
+              </a-tag>
+            </template>
+            <template #declaredAction="{ record }">
+              <a-button
+                v-auth="'ai:memory:remove'"
+                type="link"
+                danger
+                size="small"
+                :disabled="record.revoked"
+                @click="handleRevokeDeclared(record)"
+              >
+                撤销
+              </a-button>
             </template>
-          </a-table>
+          </BasicTable>
         </a-card>
       </a-tab-pane>
 
@@ -468,38 +462,35 @@
       wrap-class-name="memory-modal"
       destroy-on-close
     >
-      <a-table
+      <BasicTable
         :columns="versionColumns"
         :data-source="versions"
         :loading="versionLoading"
         row-key="versionId"
         :pagination="false"
-        size="small"
         class="version-table"
         :locale="{ emptyText: '暂无历史版本' }"
       >
-        <template #bodyCell="{ column, record }">
-          <template v-if="column.key === 'source'">
-            <a-tag :color="record.current ? 'success' : 'default'">
-              {{ sourceLabel(record.source) }}
-            </a-tag>
-            <a-tag v-if="record.current" color="success" class="version-current-tag">当前</a-tag>
-          </template>
-          <template v-else-if="column.key === 'action'">
-            <a-button type="link" size="small" @click="handleViewVersion(record)">查看</a-button>
-            <a-button
-              v-auth="'ai:memory:edit'"
-              type="link"
-              size="small"
-              class="wb-link-warning"
-              :disabled="record.current"
-              @click="handleRestoreVersion(record)"
-            >
-              恢复
-            </a-button>
-          </template>
+        <template #versionSource="{ record }">
+          <a-tag :color="record.current ? 'success' : 'default'">
+            {{ sourceLabel(record.source) }}
+          </a-tag>
+          <a-tag v-if="record.current" color="success" class="version-current-tag">当前</a-tag>
         </template>
-      </a-table>
+        <template #versionAction="{ record }">
+          <a-button type="link" size="small" @click="handleViewVersion(record)">查看</a-button>
+          <a-button
+            v-auth="'ai:memory:edit'"
+            type="link"
+            size="small"
+            class="wb-link-warning"
+            :disabled="record.current"
+            @click="handleRestoreVersion(record)"
+          >
+            恢复
+          </a-button>
+        </template>
+      </BasicTable>
     </BasicModal>
 
     <BasicModal
@@ -576,7 +567,6 @@
     ASpin,
     ASwitch,
     ATabPane,
-    ATable,
     ATabs,
     ATag,
     ATextarea,
@@ -586,6 +576,7 @@
   } from '@/workbench/components/ant';
   import { Icon } from '@/core/components/Icon';
   import { BasicModal } from '@/core/components/Modal';
+  import { BasicTable } from '@/core/components/Table';
   import { useUserStore } from '@/core/store/modules/case';
   import { optionAgent } from '@/workbench/api/agent';
   import {
@@ -696,30 +687,27 @@
   }>({ versionId: '', mode: 'CONTENT', note: '' });
 
   const fileColumns: any[] = [
-    { title: '文件', dataIndex: 'name', key: 'name', ellipsis: true },
-    { title: '类型', key: 'type', width: 90, align: 'center' },
+    { title: '文件', dataIndex: 'name', key: 'name', ellipsis: true, slot: 'fileName' },
+    { title: '类型', key: 'type', width: 90, align: 'center', slot: 'fileType' },
     { title: '字符数', dataIndex: 'chars', key: 'chars', width: 90, align: 'center' },
   ];
 
   const declaredColumns: any[] = [
-    { title: '状态', key: 'status', width: 90, align: 'center' },
+    { title: '状态', key: 'status', width: 90, align: 'center', slot: 'declaredStatus' },
     { title: '记忆内容', dataIndex: 'fact', key: 'fact', minWidth: 220, ellipsis: true },
     { title: '用户原话', dataIndex: 'evidence', key: 'evidence', minWidth: 220, ellipsis: true },
     { title: '创建时间', dataIndex: 'createdAt', key: 'createdAt', width: 200, ellipsis: true },
-    { title: '操作', key: 'action', width: 100, align: 'center' },
+    { title: '操作', key: 'action', width: 100, align: 'center', ellipsis: false, slot: 'declaredAction' },
   ];
 
   const versionColumns: any[] = [
     { title: '时间', dataIndex: 'createdAt', key: 'createdAt', width: 210, ellipsis: true },
-    { title: '来源', key: 'source', width: 150 },
+    { title: '来源', key: 'source', width: 150, slot: 'versionSource' },
     { title: '字符数', dataIndex: 'chars', key: 'chars', width: 90, align: 'center' },
     { title: '备注', dataIndex: 'note', key: 'note', ellipsis: true },
-    { title: '操作', key: 'action', width: 150, align: 'center' },
+    { title: '操作', key: 'action', width: 150, align: 'center', ellipsis: false, slot: 'versionAction' },
   ];
 
-  const customRow = (record: any) => ({
-    onClick: () => handleSelectFile(record),
-  });
   const rowClassName = (record: any) => (record.path === current.value.path ? 'memory-row-active' : '');
 
   /** 版本来源中文标签 */

+ 81 - 128
ai-electron/frontend/src/workbench/views/agent/session/index.vue

@@ -70,81 +70,56 @@
             <a-button v-auth="'ai:session:edit'" class="wb-btn-warning" :disabled="multiple" @click="handleClose()"> 终止 </a-button>
             <a-button v-auth="'ai:session:remove'" danger :disabled="multiple" @click="handleDelete()"> 删除 </a-button>
             <a-button v-auth="'ai:session:export'" @click="handleExport"> 导出 </a-button>
-            <a-button @click="getList">刷新</a-button>
+            <a-button @click="reload()">刷新</a-button>
           </div>
         </div>
       </template>
 
-      <div class="session-table-scroll">
-        <a-table
-          :columns="columns"
-          :data-source="sessionList"
-          :loading="loading"
-          row-key="id"
-          :row-selection="{ selectedRowKeys: ids, onChange: handleSelectionChange }"
-          :pagination="false"
-          :scroll="{ x: 1400 }"
-          size="middle"
-          class="session-table"
-        >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'sessionTitle'">
-              <a-tag v-if="record.topFlag === '1'" color="warning" class="pin-tag">置顶</a-tag>
-              <span>{{ record.sessionTitle }}</span>
-            </template>
-            <template v-else-if="column.key === 'source'">
-              <a-tag :color="sourceTagColor(record.source)">
-                {{ sourceLabel(record.source) }}
-              </a-tag>
-            </template>
-            <template v-else-if="column.key === 'user'">
-              <span v-if="record.userName">{{ record.userName }}</span>
-              <span v-else class="wb-muted">{{ record.userId ?? '-' }}</span>
-            </template>
-            <template v-else-if="column.key === 'status'">
-              <a-tag :color="record.status === '0' ? 'success' : 'default'">
-                {{ record.status === '0' ? '进行中' : '已结束' }}
-              </a-tag>
-            </template>
-            <template v-else-if="column.key === 'action'">
-              <div class="session-actions">
-                <a-tooltip title="消息明细">
-                  <a-button type="link" size="small" aria-label="消息明细" @click="handleDetail(record)">详情</a-button>
-                </a-tooltip>
-                <a-tooltip title="终止任务">
-                  <a-button
-                    v-auth="'ai:session:edit'"
-                    type="link"
-                    size="small"
-                    class="wb-link-warning"
-                    aria-label="终止任务"
-                    :disabled="record.status === '1'"
-                    @click="handleClose(record)"
-                  >
-                    终止
-                  </a-button>
-                </a-tooltip>
-                <a-tooltip title="删除任务">
-                  <a-button v-auth="'ai:session:remove'" type="link" danger size="small" aria-label="删除任务" @click="handleDelete(record)">
-                    删除
-                  </a-button>
-                </a-tooltip>
-              </div>
-            </template>
-          </template>
-        </a-table>
-      </div>
-
-      <div v-show="total > 0" class="session-pagination">
-        <a-pagination
-          v-model:current="queryParams.pageNum"
-          v-model:page-size="queryParams.pageSize"
-          :total="total"
-          show-size-changer
-          :page-size-options="['10', '20', '50', '100']"
-          @change="getList"
-        />
-      </div>
+      <BasicTable @register="registerTable" class="session-table wb-table-fill" @fetch-success="handleFetchSuccess">
+        <template #sessionTitle="{ record }">
+          <a-tag v-if="record.topFlag === '1'" color="warning" class="pin-tag">置顶</a-tag>
+          <span>{{ record.sessionTitle }}</span>
+        </template>
+        <template #source="{ record }">
+          <a-tag :color="sourceTagColor(record.source)">
+            {{ sourceLabel(record.source) }}
+          </a-tag>
+        </template>
+        <template #user="{ record }">
+          <span v-if="record.userName">{{ record.userName }}</span>
+          <span v-else class="wb-muted">{{ record.userId ?? '-' }}</span>
+        </template>
+        <template #status="{ record }">
+          <a-tag :color="record.status === '0' ? 'success' : 'default'">
+            {{ record.status === '0' ? '进行中' : '已结束' }}
+          </a-tag>
+        </template>
+        <template #action="{ record }">
+          <div class="session-actions">
+            <a-tooltip title="消息明细">
+              <a-button type="link" size="small" aria-label="消息明细" @click="handleDetail(record)">详情</a-button>
+            </a-tooltip>
+            <a-tooltip title="终止任务">
+              <a-button
+                v-auth="'ai:session:edit'"
+                type="link"
+                size="small"
+                class="wb-link-warning"
+                aria-label="终止任务"
+                :disabled="record.status === '1'"
+                @click="handleClose(record)"
+              >
+                终止
+              </a-button>
+            </a-tooltip>
+            <a-tooltip title="删除任务">
+              <a-button v-auth="'ai:session:remove'" type="link" danger size="small" aria-label="删除任务" @click="handleDelete(record)">
+                删除
+              </a-button>
+            </a-tooltip>
+          </div>
+        </template>
+      </BasicTable>
     </a-card>
 
     <BasicModal
@@ -240,18 +215,16 @@
     ADescriptionsItem,
     AEmpty,
     AInput,
-    APagination,
     ASelect,
     ASelectOption,
     ASpin,
-    ASwitch,
-    ATable,
     ATag,
     ATooltip,
     Modal,
     message,
   } from '@/workbench/components/ant';
   import { BasicModal } from '@/core/components/Modal';
+  import { BasicTable, useTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import {
     closeChatSessionById,
@@ -268,9 +241,7 @@
 
   const route = useRoute();
 
-  const sessionList = ref<any[]>([]);
   const agentOptions = ref<any[]>([]);
-  const loading = ref(true);
   /** 查询条件展开态(默认展开,点击标题收起) */
   const showSearch = ref(true);
   const total = ref(0);
@@ -279,8 +250,6 @@
   const pendingSessionId = ref<string | undefined>();
 
   const queryParams = reactive({
-    pageNum: 1,
-    pageSize: 10,
     sessionTitle: '',
     agentId: undefined as any,
     status: undefined as any,
@@ -305,42 +274,49 @@
   const multiple = ref(true);
 
   const columns: any[] = [
-    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', ellipsis: true },
-    { title: '来源', key: 'source', width: 110, align: 'center' },
+    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', width: 260, ellipsis: true, slot: 'sessionTitle' },
+    { title: '来源', key: 'source', width: 110, align: 'center', slot: 'source' },
     { title: '智能体', dataIndex: 'agentName', key: 'agentName', width: 150, ellipsis: true },
-    { title: '归属用户', key: 'user', width: 120 },
+    { title: '归属用户', key: 'user', width: 120, slot: 'user' },
     { title: '消息数', dataIndex: 'messageCount', key: 'messageCount', width: 90, align: 'center' },
-    { title: '状态', key: 'status', width: 100, align: 'center' },
+    { title: '状态', key: 'status', width: 100, align: 'center', slot: 'status' },
     { title: '最后活跃时间', dataIndex: 'lastActiveTime', key: 'lastActiveTime', width: 170, align: 'center' },
     { title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 170, align: 'center' },
-    { title: '操作', key: 'action', width: 200, align: 'center', fixed: 'right' },
+    { title: '操作', key: 'action', width: 200, align: 'center', fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 
-  /** 查询会话列表 */
-  const getList = async () => {
-    loading.value = true;
-    try {
-      const params: any = { ...queryParams };
+  const [registerTable, { reload }] = useTable({
+    api: listChatSessions,
+    columns,
+    rowKey: 'id',
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => {
+      const p: any = {
+        ...params,
+        sessionTitle: queryParams.sessionTitle,
+        agentId: queryParams.agentId,
+        status: queryParams.status,
+        sessionId: queryParams.sessionId,
+      };
       if (dateRange.value && dateRange.value.length === 2) {
-        params.beginTime = `${dateRange.value[0]}T00:00:00`;
-        params.endTime = `${dateRange.value[1]}T23:59:59`;
+        p.beginTime = `${dateRange.value[0]}T00:00:00`;
+        p.endTime = `${dateRange.value[1]}T23:59:59`;
       }
-      const res = await listChatSessions(params);
-      sessionList.value = res?.rows ?? [];
-      total.value = Number(res?.total ?? 0);
-      openPendingSession();
-    } finally {
-      loading.value = false;
-    }
-  };
+      return p;
+    },
+    rowSelection: { type: 'checkbox', onChange: (keys: any) => handleSelectionChange(keys) },
+    canResize: true,
+    isCanResizeParent: true,
+  });
 
-  /** 地址栏带入会话主键时,定位并直接展开该会话明细 */
-  const openPendingSession = () => {
+  /** 列表返回后更新总数;地址栏带入会话主键时定位并直接展开明细 */
+  const handleFetchSuccess = ({ items, total: t }: any) => {
+    total.value = Number(t ?? 0);
     const target = pendingSessionId.value;
     if (!target) {
       return;
     }
-    const row = sessionList.value.find((item) => String(item.id) === String(target));
+    const row = (items ?? []).find((item: any) => String(item.id) === String(target));
     if (row) {
       pendingSessionId.value = undefined;
       handleDetail(row);
@@ -363,8 +339,7 @@
   };
 
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   const resetQuery = () => {
@@ -372,10 +347,9 @@
     queryParams.agentId = undefined;
     queryParams.status = undefined;
     queryParams.sessionId = undefined;
-    queryParams.pageNum = 1;
     dateRange.value = [];
     pendingSessionId.value = undefined;
-    getList();
+    reload({ page: 1 });
   };
 
   const handleSelectionChange = (keys: Array<string | number>) => {
@@ -407,7 +381,7 @@
     }
     await closeChatSessionById(targetIds.join(','));
     message.success('已终止');
-    await getList();
+    await reload();
   };
 
   /** 删除会话 */
@@ -424,7 +398,7 @@
     }
     await delChatSession(targetIds.join(','));
     message.success('删除成功');
-    await getList();
+    await reload();
   };
 
   /** 导出留档 */
@@ -434,8 +408,6 @@
       params.beginTime = `${dateRange.value[0]}T00:00:00`;
       params.endTime = `${dateRange.value[1]}T23:59:59`;
     }
-    delete params.pageNum;
-    delete params.pageSize;
     await exportSession(params, `任务数据_${new Date().getTime()}.xlsx`);
   };
 
@@ -488,7 +460,6 @@
   onMounted(() => {
     applyRouteQuery();
     getAgentOptions();
-    getList();
   });
 </script>
 
@@ -710,12 +681,6 @@
     overflow: hidden;
   }
 
-  .session-table-scroll {
-    flex: 1 1 auto;
-    min-height: 0;
-    overflow: auto;
-  }
-
   .session-table-card :deep(.ant-table) {
     font-size: 12px;
   }
@@ -769,18 +734,6 @@
     }
   }
 
-  .session-pagination {
-    display: flex;
-    align-items: center;
-    justify-content: flex-end;
-    padding: 8px 14px 10px;
-    border-top: 1px solid #eff2f7;
-  }
-
-  .session-pagination :deep(.ant-pagination) {
-    margin: 0;
-  }
-
   @media (max-width: 992px) {
     .session-card-head--table {
       flex-direction: column;

+ 33 - 37
ai-electron/frontend/src/workbench/views/audit/health/index.vue

@@ -38,39 +38,35 @@
         </div>
       </div>
 
-      <div class="wb-table-scroll">
-        <a-table
-          :columns="columns"
-          :data-source="visibleItems"
-          :loading="loading"
-          :pagination="false"
-          :locale="{ emptyText: '没有符合筛选的检查项' }"
-          :scroll="{ x: 1100 }"
-          row-key="key"
-          size="small"
-          class="wb-table"
-        >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'status'">
-              <a-tag :color="statusTagColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
-            </template>
-            <template v-else-if="column.key === 'suggestion'">{{ record.suggestion || '-' }}</template>
-            <template v-else-if="column.key === 'action'">
-              <a-button
-                v-if="record.probeSupported"
-                v-auth="'ai:health:execute'"
-                type="link"
-                size="small"
-                :loading="probingKey === record.key"
-                @click="handleProbe(record)"
-              >
-                测试
-              </a-button>
-              <span v-else class="health-empty">-</span>
-            </template>
-          </template>
-        </a-table>
-      </div>
+      <BasicTable
+        :columns="columns"
+        :data-source="visibleItems"
+        :loading="loading"
+        :pagination="false"
+        :locale="{ emptyText: '没有符合筛选的检查项' }"
+        row-key="key"
+        class="wb-table wb-table-fill"
+        can-resize
+        is-can-resize-parent
+      >
+        <template #status="{ record }">
+          <a-tag :color="statusTagColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
+        </template>
+        <template #suggestion="{ record }">{{ record.suggestion || '-' }}</template>
+        <template #action="{ record }">
+          <a-button
+            v-if="record.probeSupported"
+            v-auth="'ai:health:execute'"
+            type="link"
+            size="small"
+            :loading="probingKey === record.key"
+            @click="handleProbe(record)"
+          >
+            测试
+          </a-button>
+          <span v-else class="health-empty">-</span>
+        </template>
+      </BasicTable>
     </a-card>
 
     <!-- 首登清单:与任务工作台的卡片同源(GET /ai/onboarding/checklist),不受「已完成」隐藏限制 -->
@@ -123,10 +119,10 @@
     ARadioButton,
     ARadioGroup,
     ASpin,
-    ATable,
     ATag,
     message,
   } from '@/workbench/components/ant';
+  import { BasicTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import { getHealthReport, getOnboardingChecklist, probeHealthItem } from '@/workbench/api/audit';
 
@@ -315,10 +311,10 @@
   const columns: any[] = [
     { title: '检查项', dataIndex: 'name', key: 'name', width: 180, ellipsis: true },
     { title: '分类', dataIndex: 'category', key: 'category', width: 120 },
-    { title: '状态', key: 'status', width: 100 },
+    { title: '状态', key: 'status', width: 100, slot: 'status' },
     { title: '说明', dataIndex: 'detail', key: 'detail', ellipsis: true },
-    { title: '修复建议', key: 'suggestion', width: 300, ellipsis: true },
-    { title: '操作', key: 'action', width: 120, fixed: 'right' },
+    { title: '修复建议', key: 'suggestion', width: 300, ellipsis: true, slot: 'suggestion' },
+    { title: '操作', key: 'action', width: 120, fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 
   onMounted(loadReport);

+ 39 - 81
ai-electron/frontend/src/workbench/views/audit/message/index.vue

@@ -73,55 +73,29 @@
           </div>
           <div class="wb-toolbar__actions">
             <a-button v-auth="'ai:audit:export'" type="primary" ghost @click="handleExport">导出</a-button>
-            <a-button @click="getList">刷新</a-button>
+            <a-button @click="reload()">刷新</a-button>
           </div>
         </div>
       </template>
 
-      <div class="wb-table-scroll">
-        <a-table
-          :columns="columns"
-          :data-source="messageList"
-          :loading="loading"
-          :pagination="false"
-          :locale="{ emptyText: '暂无数据' }"
-          :scroll="{ x: 1500 }"
-          row-key="id"
-          size="small"
-          class="wb-table"
-        >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'user'">
-              <span v-if="record.userName">{{ record.userName }}</span>
-              <span v-else class="wb-muted">{{ record.userId ?? '-' }}</span>
-            </template>
-            <template v-else-if="column.key === 'role'">
-              <a-tag :color="roleTagColor(record.role)">{{ roleLabel(record.role) }}</a-tag>
-            </template>
-            <template v-else-if="column.key === 'status'">
-              <a-tag :color="statusTagColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
-            </template>
-            <template v-else-if="column.key === 'totalTokens'">{{ record.totalTokens ?? '-' }}</template>
-            <template v-else-if="column.key === 'action'">
-              <a-tooltip title="查看详情">
-                <a-button type="link" size="small" aria-label="查看详情" @click="handleDetail(record)">查看</a-button>
-              </a-tooltip>
-            </template>
-          </template>
-        </a-table>
-      </div>
-
-      <div v-show="total > 0" class="wb-pagination">
-        <a-pagination
-          v-model:current="queryParams.pageNum"
-          v-model:page-size="queryParams.pageSize"
-          :total="total"
-          show-size-changer
-          :show-total="showTotal"
-          :page-size-options="['10', '20', '50', '100']"
-          @change="getList"
-        />
-      </div>
+      <BasicTable @register="registerTable" class="wb-table wb-table-fill">
+        <template #user="{ record }">
+          <span v-if="record.userName">{{ record.userName }}</span>
+          <span v-else class="wb-muted">{{ record.userId ?? '-' }}</span>
+        </template>
+        <template #role="{ record }">
+          <a-tag :color="roleTagColor(record.role)">{{ roleLabel(record.role) }}</a-tag>
+        </template>
+        <template #status="{ record }">
+          <a-tag :color="statusTagColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
+        </template>
+        <template #totalTokens="{ record }">{{ record.totalTokens ?? '-' }}</template>
+        <template #action="{ record }">
+          <a-tooltip title="查看详情">
+            <a-button type="link" size="small" aria-label="查看详情" @click="handleDetail(record)">查看</a-button>
+          </a-tooltip>
+        </template>
+      </BasicTable>
     </a-card>
 
     <BasicModal
@@ -192,14 +166,13 @@
     AForm,
     AFormItem,
     AInput,
-    APagination,
     ASelect,
     ASelectOption,
-    ATable,
     ATag,
     ATooltip,
   } from '@/workbench/components/ant';
   import BasicModal from '@/core/components/Modal/src/BasicModal.vue';
+  import { BasicTable, useTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import AiMarkdown from '@/workbench/components/AiMarkdown.vue';
   import { exportMessageAudit, listMessageAudit, optionAuditAgents } from '@/workbench/api/audit';
@@ -207,16 +180,11 @@
   // AntDV 的 RangePicker 挂在 DatePicker 上,别名模块未单独导出
   const ARangePicker = ADatePicker.RangePicker;
 
-  const messageList = ref<any[]>([]);
   const agentOptions = ref<any[]>([]);
-  const loading = ref(true);
   const showSearch = ref(true);
-  const total = ref(0);
   const dateRange = ref<any>(null);
 
   const queryParams = reactive<any>({
-    pageNum: 1,
-    pageSize: 10,
     keyword: '',
     role: undefined,
     status: undefined,
@@ -232,20 +200,18 @@
     record: undefined,
   });
 
-  const showTotal = (count: number) => `共 ${count} 条`;
-
   const columns: any[] = [
     { title: '时间', dataIndex: 'createTime', key: 'createTime', align: 'center', width: 170 },
-    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', align: 'left', ellipsis: true },
+    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', align: 'left', width: 220, ellipsis: true },
     { title: '智能体', dataIndex: 'agentName', key: 'agentName', align: 'center', width: 150, ellipsis: true },
-    { title: '归属用户', key: 'user', align: 'center', width: 120 },
-    { title: '角色', key: 'role', align: 'center', width: 90 },
-    { title: '正文', dataIndex: 'content', key: 'content', align: 'left', ellipsis: true },
-    { title: '状态', key: 'status', align: 'center', width: 90 },
+    { title: '归属用户', key: 'user', align: 'center', width: 120, slot: 'user' },
+    { title: '角色', key: 'role', align: 'center', width: 90, slot: 'role' },
+    { title: '正文', dataIndex: 'content', key: 'content', align: 'left', width: 260, ellipsis: true },
+    { title: '状态', key: 'status', align: 'center', width: 90, slot: 'status' },
     { title: '工具调用次数', dataIndex: 'toolCallCount', key: 'toolCallCount', align: 'center', width: 110 },
-    { title: 'Token', key: 'totalTokens', align: 'center', width: 90 },
+    { title: 'Token', key: 'totalTokens', align: 'center', width: 90, slot: 'totalTokens' },
     { title: '耗时(ms)', dataIndex: 'durationMs', key: 'durationMs', align: 'center', width: 100 },
-    { title: '操作', key: 'action', align: 'center', width: 100, fixed: 'right' },
+    { title: '操作', key: 'action', align: 'center', width: 100, fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 
   /** 组装含时间范围的查询参数 */
@@ -258,17 +224,15 @@
     return params;
   };
 
-  /** 查询消息审计列表 */
-  const getList = async () => {
-    loading.value = true;
-    try {
-      const res: any = await listMessageAudit(buildParams());
-      messageList.value = res?.rows ?? [];
-      total.value = Number(res?.total ?? 0);
-    } finally {
-      loading.value = false;
-    }
-  };
+  const [registerTable, { reload }] = useTable({
+    api: listMessageAudit,
+    columns,
+    rowKey: 'id',
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => ({ ...params, ...buildParams() }),
+    canResize: true,
+    isCanResizeParent: true,
+  });
 
   /** 查询出现的智能体选项(含已停用) */
   const getAgentOptions = async () => {
@@ -277,8 +241,7 @@
   };
 
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   const resetQuery = () => {
@@ -287,9 +250,8 @@
     queryParams.status = undefined;
     queryParams.sessionTitle = '';
     queryParams.agentId = undefined;
-    queryParams.pageNum = 1;
     dateRange.value = null;
-    getList();
+    reload({ page: 1 });
   };
 
   const roleLabel = (role?: string) => {
@@ -341,10 +303,7 @@
   /** 导出留档 */
   const handleExport = async () => {
     try {
-      const params: any = { ...buildParams() };
-      delete params.pageNum;
-      delete params.pageSize;
-      await exportMessageAudit(params, `消息审计_${new Date().getTime()}.xlsx`);
+      await exportMessageAudit(buildParams(), `消息审计_${new Date().getTime()}.xlsx`);
     } catch {
       // 失败提示由请求层统一处理
     }
@@ -352,7 +311,6 @@
 
   onMounted(() => {
     getAgentOptions();
-    getList();
   });
 </script>
 

+ 75 - 105
ai-electron/frontend/src/workbench/views/audit/routeRun/index.vue

@@ -136,63 +136,39 @@
             </p>
           </div>
           <div class="wb-toolbar__actions">
-            <a-button @click="getList">刷新</a-button>
+            <a-button @click="handleRefresh">刷新</a-button>
           </div>
         </div>
       </template>
 
-      <a-table
-        :columns="columns"
-        :data-source="runList"
-        :loading="loading"
-        :pagination="false"
-        :locale="{ emptyText: '暂无编排运行数据' }"
-        :scroll="{ x: 1665 }"
-        row-key="id"
-        size="small"
-        class="wb-table"
-      >
-        <template #bodyCell="{ column, record }">
-          <template v-if="column.key === 'user'">
-            <span v-if="record.userName">{{ record.userName }}</span>
-            <span v-else class="wb-muted">{{ record.userId ?? '-' }}</span>
-          </template>
-          <template v-else-if="column.key === 'action'">
-            <a-tag :color="actionTagColor(record.action)">{{ actionLabel(record.action) }}</a-tag>
-          </template>
-          <template v-else-if="column.key === 'status'">
-            <a-tag :color="statusTagColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
-            <a-tooltip v-if="record.degradeReason" :title="record.degradeReason">
-              <Icon icon="i-mdi:alert-circle-outline" class="status-tip-icon" />
-            </a-tooltip>
-          </template>
-          <template v-else-if="column.key === 'expertAgentNames'">{{ record.expertAgentNames || '-' }}</template>
-          <template v-else-if="column.key === 'expertCallCount'">{{ record.expertCallCount ?? 0 }}</template>
-          <template v-else-if="column.key === 'duration'">{{ formatDuration(record.durationMs) }}</template>
-          <template v-else-if="column.key === 'totalTokens'">{{ formatNumber(record.totalTokens) }}</template>
-          <template v-else-if="column.key === 'totalCost'">
-            <span>{{ formatCost(record.totalCost) }}</span>
-            <a-tooltip v-if="record.priceConfigured === false" title="涉及模型未配置单价,费用按 0 估算">
-              <a-tag color="default" class="cost-tip-tag">未配置单价</a-tag>
-            </a-tooltip>
-          </template>
-          <template v-else-if="column.key === 'rowAction'">
-            <a-button type="link" size="small" @click="handleDetail(record)">详情</a-button>
-          </template>
+      <BasicTable @register="registerTable" class="wb-table" :locale="{ emptyText: '暂无编排运行数据' }">
+        <template #user="{ record }">
+          <span v-if="record.userName">{{ record.userName }}</span>
+          <span v-else class="wb-muted">{{ record.userId ?? '-' }}</span>
         </template>
-      </a-table>
-
-      <div v-show="total > 0" class="wb-pagination">
-        <a-pagination
-          v-model:current="queryParams.pageNum"
-          v-model:page-size="queryParams.pageSize"
-          :total="total"
-          show-size-changer
-          :show-total="showTotal"
-          :page-size-options="['10', '20', '50', '100']"
-          @change="getList"
-        />
-      </div>
+        <template #action="{ record }">
+          <a-tag :color="actionTagColor(record.action)">{{ actionLabel(record.action) }}</a-tag>
+        </template>
+        <template #status="{ record }">
+          <a-tag :color="statusTagColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
+          <a-tooltip v-if="record.degradeReason" :title="record.degradeReason">
+            <Icon icon="i-mdi:alert-circle-outline" class="status-tip-icon" />
+          </a-tooltip>
+        </template>
+        <template #expertAgentNames="{ record }">{{ record.expertAgentNames || '-' }}</template>
+        <template #expertCallCount="{ record }">{{ record.expertCallCount ?? 0 }}</template>
+        <template #duration="{ record }">{{ formatDuration(record.durationMs) }}</template>
+        <template #totalTokens="{ record }">{{ formatNumber(record.totalTokens) }}</template>
+        <template #totalCost="{ record }">
+          <span>{{ formatCost(record.totalCost) }}</span>
+          <a-tooltip v-if="record.priceConfigured === false" title="涉及模型未配置单价,费用按 0 估算">
+            <a-tag color="default" class="cost-tip-tag">未配置单价</a-tag>
+          </a-tooltip>
+        </template>
+        <template #rowAction="{ record }">
+          <a-button type="link" size="small" @click="handleDetail(record)">详情</a-button>
+        </template>
+      </BasicTable>
     </a-card>
 
     <a-drawer v-model:open="detail.visible" title="编排运行详情" width="65%" root-class-name="wb-detail-drawer">
@@ -268,14 +244,13 @@
             </a-card>
 
             <a-card :bordered="false" class="detail-card" title="专家调用明细">
-              <a-table
+              <BasicTable
                 v-if="expertCalls.length"
                 :columns="expertColumns"
                 :data-source="expertCalls"
                 :pagination="false"
                 row-key="id"
                 bordered
-                size="small"
               >
                 <template #expandedRowRender="{ record }">
                   <div class="expand-block">
@@ -283,18 +258,16 @@
                     <pre class="detail-pre">{{ record.rawOutput || '-' }}</pre>
                   </div>
                 </template>
-                <template #bodyCell="{ column, record }">
-                  <template v-if="column.key === 'callKind'">{{ callKindLabel(record.callKind) }}</template>
-                  <template v-else-if="column.key === 'status'">
-                    <a-tag :color="callStatusTagColor(record.status)">{{ callStatusLabel(record.status) }}</a-tag>
-                  </template>
-                  <template v-else-if="column.key === 'tokens'">
-                    {{ formatNumber(sumTokens(record.promptTokens, record.completionTokens)) }}
-                  </template>
-                  <template v-else-if="column.key === 'cost'">{{ formatCost(record.cost) }}</template>
-                  <template v-else-if="column.key === 'duration'">{{ formatDuration(record.durationMs) }}</template>
+                <template #expertCallKind="{ record }">{{ callKindLabel(record.callKind) }}</template>
+                <template #expertStatus="{ record }">
+                  <a-tag :color="callStatusTagColor(record.status)">{{ callStatusLabel(record.status) }}</a-tag>
                 </template>
-              </a-table>
+                <template #expertTokens="{ record }">
+                  {{ formatNumber(sumTokens(record.promptTokens, record.completionTokens)) }}
+                </template>
+                <template #expertCost="{ record }">{{ formatCost(record.cost) }}</template>
+                <template #expertDuration="{ record }">{{ formatDuration(record.durationMs) }}</template>
+              </BasicTable>
               <span v-else class="wb-muted">本轮未调用专家(自己回答)</span>
             </a-card>
           </template>
@@ -319,16 +292,15 @@
     AForm,
     AFormItem,
     AInputNumber,
-    APagination,
     ASelect,
     ASelectOption,
     ASpin,
-    ATable,
     ATag,
     ATooltip,
     Modal,
     message,
   } from '@/workbench/components/ant';
+  import { BasicTable, useTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import {
     getAuditRetention,
@@ -345,13 +317,10 @@
 
   const route = useRoute();
 
-  const runList = ref<any[]>([]);
   const agentOptions = ref<any[]>([]);
   const stat = ref<any>({});
-  const loading = ref(true);
   const statLoading = ref(true);
   const showSearch = ref(true);
-  const total = ref(0);
   const dateRange = ref<any>(null);
 
   /** 审计数据保留:保留天数(0=不清理)与各表超期行数 */
@@ -380,8 +349,6 @@
   });
 
   const queryParams = reactive<any>({
-    pageNum: 1,
-    pageSize: 10,
     sessionId: undefined,
     expertAgentId: undefined,
     action: undefined,
@@ -398,11 +365,9 @@
     record: undefined,
   });
 
-  const showTotal = (count: number) => `共 ${count} 条`;
-
   const columns: any[] = [
     { title: '创建时间', dataIndex: 'createTime', key: 'createTime', align: 'center', width: 170 },
-    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', align: 'left', ellipsis: true },
+    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', align: 'left', width: 240, ellipsis: true },
     {
       title: '入口智能体',
       dataIndex: 'entryAgentName',
@@ -411,26 +376,26 @@
       width: 140,
       ellipsis: true,
     },
-    { title: '提问用户', key: 'user', align: 'center', width: 110 },
-    { title: '动作', key: 'action', align: 'center', width: 110 },
-    { title: '状态', key: 'status', align: 'center', width: 150 },
-    { title: '专家', key: 'expertAgentNames', align: 'center', width: 180, ellipsis: true },
-    { title: '专家次数', key: 'expertCallCount', align: 'center', width: 100 },
-    { title: '耗时', key: 'duration', align: 'center', width: 100 },
-    { title: 'Token', key: 'totalTokens', align: 'center', width: 110 },
-    { title: '费用(元)', key: 'totalCost', align: 'center', width: 140 },
-    { title: '操作', key: 'rowAction', align: 'center', width: 100, fixed: 'right' },
+    { title: '提问用户', key: 'user', align: 'center', width: 110, slot: 'user' },
+    { title: '动作', key: 'action', align: 'center', width: 110, slot: 'action' },
+    { title: '状态', key: 'status', align: 'center', width: 150, slot: 'status' },
+    { title: '专家', key: 'expertAgentNames', align: 'center', width: 180, ellipsis: true, slot: 'expertAgentNames' },
+    { title: '专家次数', key: 'expertCallCount', align: 'center', width: 100, slot: 'expertCallCount' },
+    { title: '耗时', key: 'duration', align: 'center', width: 100, slot: 'duration' },
+    { title: 'Token', key: 'totalTokens', align: 'center', width: 110, slot: 'totalTokens' },
+    { title: '费用(元)', key: 'totalCost', align: 'center', width: 140, slot: 'totalCost' },
+    { title: '操作', key: 'rowAction', align: 'center', width: 100, fixed: 'right', ellipsis: false, slot: 'rowAction' },
   ];
 
   const expertColumns: any[] = [
     { title: '第 N 次', dataIndex: 'attemptNo', key: 'attemptNo', align: 'center', width: 80 },
-    { title: '类型', key: 'callKind', align: 'center', width: 110 },
+    { title: '类型', key: 'callKind', align: 'center', width: 110, slot: 'expertCallKind' },
     { title: '专家', dataIndex: 'expertAgentName', key: 'expertAgentName', align: 'left', width: 140, ellipsis: true },
-    { title: '状态', key: 'status', align: 'center', width: 130 },
+    { title: '状态', key: 'status', align: 'center', width: 130, slot: 'expertStatus' },
     { title: '失败原因', dataIndex: 'validationError', key: 'validationError', align: 'left', ellipsis: true },
-    { title: 'Token', key: 'tokens', align: 'center', width: 110 },
-    { title: '费用(元)', key: 'cost', align: 'center', width: 100 },
-    { title: '耗时', key: 'duration', align: 'center', width: 100 },
+    { title: 'Token', key: 'tokens', align: 'center', width: 110, slot: 'expertTokens' },
+    { title: '费用(元)', key: 'cost', align: 'center', width: 100, slot: 'expertCost' },
+    { title: '耗时', key: 'duration', align: 'center', width: 100, slot: 'expertDuration' },
   ];
 
   /** 专家调用明细(缺失时兜底为空数组) */
@@ -668,25 +633,30 @@
     return params;
   };
 
-  /** 查询列表与统计(同一筛选条件) */
-  const getList = async () => {
-    const params = buildParams();
-    const statParams: any = { ...params };
-    delete statParams.pageNum;
-    delete statParams.pageSize;
-    loading.value = true;
+  const [registerTable, { reload }] = useTable({
+    api: listRouteRuns,
+    columns,
+    rowKey: 'id',
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => ({ ...params, ...buildParams() }),
+  });
+
+  /** 编排统计(与列表同一筛选条件,不随分页变化) */
+  const loadStats = async () => {
     statLoading.value = true;
     try {
-      const [statRes, listRes]: any[] = await Promise.all([routeRunStats(statParams), listRouteRuns(params)]);
+      const statRes: any = await routeRunStats(buildParams());
       stat.value = statRes ?? {};
-      runList.value = listRes?.rows ?? [];
-      total.value = Number(listRes?.total ?? 0);
     } finally {
-      loading.value = false;
       statLoading.value = false;
     }
   };
 
+  const handleRefresh = () => {
+    reload();
+    loadStats();
+  };
+
   /** 查询专家选项(含已停用:历史数据里的专家可能已停用) */
   const getAgentOptions = async () => {
     const res = await optionAuditAgents();
@@ -702,8 +672,8 @@
   };
 
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
+    loadStats();
   };
 
   const resetQuery = () => {
@@ -711,9 +681,9 @@
     queryParams.expertAgentId = undefined;
     queryParams.action = undefined;
     queryParams.status = undefined;
-    queryParams.pageNum = 1;
     dateRange.value = defaultDateRange();
-    getList();
+    reload({ page: 1 });
+    loadStats();
   };
 
   /** 查看详情(先展示列表行,再拉取含决策原文与专家明细的详情) */
@@ -739,7 +709,7 @@
     dateRange.value = defaultDateRange();
     applyRouteQuery();
     getAgentOptions();
-    getList();
+    loadStats();
     getRetention();
   });
 </script>

+ 70 - 87
ai-electron/frontend/src/workbench/views/audit/toolCall/index.vue

@@ -94,7 +94,7 @@
             </div>
           </div>
           <div class="wb-toolbar__actions">
-            <a-button @click="getList">刷新</a-button>
+            <a-button @click="handleRefresh">刷新</a-button>
           </div>
         </div>
       </template>
@@ -102,65 +102,37 @@
       <div class="tool-call-content">
         <div class="section-block">
           <div class="section-title">按工具统计</div>
-          <a-table
+          <BasicTable
             :columns="statColumns"
             :data-source="statList"
             :loading="statLoading"
             :pagination="false"
-            :locale="{ emptyText: '暂无数据' }"
             row-key="toolName"
-            size="small"
-            class="wb-table"
+            class="wb-table stats-table"
           >
-            <template #bodyCell="{ column, record }">
-              <template v-if="column.key === 'failRate'">
-                <span :class="{ 'text-danger': (record.failRate ?? 0) > 0 }">
-                  {{ formatRate(record.failRate) }}
-                </span>
-              </template>
-              <template v-else-if="column.key === 'avgDurationMs'">{{ record.avgDurationMs ?? '-' }}</template>
+            <template #failRate="{ record }">
+              <span :class="{ 'text-danger': (record.failRate ?? 0) > 0 }">
+                {{ formatRate(record.failRate) }}
+              </span>
             </template>
-          </a-table>
+            <template #avgDurationMs="{ record }">{{ record.avgDurationMs ?? '-' }}</template>
+          </BasicTable>
         </div>
 
         <div class="section-block">
           <div class="section-title">调用明细</div>
-          <a-table
-            :columns="columns"
-            :data-source="toolCallList"
-            :loading="loading"
-            :pagination="false"
-            :locale="{ emptyText: '暂无数据' }"
-            :scroll="{ x: 1250 }"
-            row-key="id"
-            size="small"
-            class="wb-table"
-          >
-            <template #bodyCell="{ column, record }">
-              <template v-if="column.key === 'state'">
-                <a-tag :color="stateTagColor(record.state)">{{ stateLabel(record.state) }}</a-tag>
-              </template>
-              <template v-else-if="column.key === 'user'">
-                <span v-if="record.userName">{{ record.userName }}</span>
-                <span v-else class="wb-muted">{{ record.userId ?? '-' }}</span>
-              </template>
-              <template v-else-if="column.key === 'action'">
-                <a-button type="link" size="small" @click="handleDetail(record)">查看入参/出参</a-button>
-              </template>
+          <BasicTable @register="registerTable" class="wb-table wb-table-fill">
+            <template #state="{ record }">
+              <a-tag :color="stateTagColor(record.state)">{{ stateLabel(record.state) }}</a-tag>
             </template>
-          </a-table>
-
-          <div v-show="total > 0" class="wb-pagination">
-            <a-pagination
-              v-model:current="queryParams.pageNum"
-              v-model:page-size="queryParams.pageSize"
-              :total="total"
-              show-size-changer
-              :show-total="showTotal"
-              :page-size-options="['10', '20', '50', '100']"
-              @change="getList"
-            />
-          </div>
+            <template #user="{ record }">
+              <span v-if="record.userName">{{ record.userName }}</span>
+              <span v-else class="wb-muted">{{ record.userId ?? '-' }}</span>
+            </template>
+            <template #action="{ record }">
+              <a-button type="link" size="small" @click="handleDetail(record)">查看入参/出参</a-button>
+            </template>
+          </BasicTable>
         </div>
       </div>
     </a-card>
@@ -222,14 +194,13 @@
     AForm,
     AFormItem,
     AInput,
-    APagination,
     ASelect,
     ASelectOption,
-    ATable,
     ATag,
     ATooltip,
   } from '@/workbench/components/ant';
   import BasicModal from '@/core/components/Modal/src/BasicModal.vue';
+  import { BasicTable, useTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import { listToolCallAudit, optionAuditAgents, toolCallStats } from '@/workbench/api/audit';
   import { listChatSessions } from '@/workbench/api/session';
@@ -237,19 +208,14 @@
   // AntDV 的 RangePicker 挂在 DatePicker 上,别名模块未单独导出
   const ARangePicker = ADatePicker.RangePicker;
 
-  const toolCallList = ref<any[]>([]);
   const statList = ref<any[]>([]);
   const agentOptions = ref<any[]>([]);
   const sessionOptions = ref<any[]>([]);
-  const loading = ref(true);
   const statLoading = ref(true);
   const showSearch = ref(true);
-  const total = ref(0);
   const dateRange = ref<any>(null);
 
   const queryParams = reactive<any>({
-    pageNum: 1,
-    pageSize: 10,
     keyword: '',
     toolName: '',
     state: undefined,
@@ -265,8 +231,6 @@
     record: undefined,
   });
 
-  const showTotal = (count: number) => `共 ${count} 条`;
-
   /** 任务筛选:tags 模式等价于 Element 的 allow-create,可直接输入任务 ID 后回车生效 */
   const sessionSelectValue = computed<any[]>({
     get: () => {
@@ -290,19 +254,19 @@
     { title: '调用次数', dataIndex: 'totalCount', key: 'totalCount', align: 'center', width: 110 },
     { title: '成功', dataIndex: 'successCount', key: 'successCount', align: 'center', width: 100 },
     { title: '失败', dataIndex: 'failCount', key: 'failCount', align: 'center', width: 100 },
-    { title: '失败率(%)', key: 'failRate', align: 'center', width: 120 },
-    { title: '平均耗时(ms)', key: 'avgDurationMs', align: 'center', width: 130 },
+    { title: '失败率(%)', key: 'failRate', align: 'center', width: 120, slot: 'failRate' },
+    { title: '平均耗时(ms)', key: 'avgDurationMs', align: 'center', width: 130, slot: 'avgDurationMs' },
   ];
 
   const columns: any[] = [
     { title: '时间', dataIndex: 'createTime', key: 'createTime', align: 'center', width: 170 },
-    { title: '工具名', dataIndex: 'toolName', key: 'toolName', align: 'left', ellipsis: true },
-    { title: '状态', key: 'state', align: 'center', width: 100 },
-    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', align: 'left', ellipsis: true },
+    { title: '工具名', dataIndex: 'toolName', key: 'toolName', align: 'left', width: 180, ellipsis: true },
+    { title: '状态', key: 'state', align: 'center', width: 100, slot: 'state' },
+    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', align: 'left', width: 240, ellipsis: true },
     { title: '发起智能体', dataIndex: 'agentName', key: 'agentName', align: 'center', width: 140, ellipsis: true },
-    { title: '触发用户', key: 'user', align: 'center', width: 120 },
+    { title: '触发用户', key: 'user', align: 'center', width: 120, slot: 'user' },
     { title: '耗时(ms)', dataIndex: 'durationMs', key: 'durationMs', align: 'center', width: 100 },
-    { title: '操作', key: 'action', align: 'center', width: 120, fixed: 'right' },
+    { title: '操作', key: 'action', align: 'center', width: 120, fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 
   /** 组装含时间范围的查询参数 */
@@ -315,28 +279,35 @@
     return params;
   };
 
-  /** 查询明细与统计(同一份筛选条件) */
-  const getList = async () => {
-    const params = buildParams();
-    const statParams: any = { ...params };
-    delete statParams.pageNum;
-    delete statParams.pageSize;
-    loading.value = true;
+  const [registerTable, { reload }] = useTable({
+    api: listToolCallAudit,
+    columns,
+    rowKey: 'id',
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => ({ ...params, ...buildParams() }),
+    canResize: true,
+    isCanResizeParent: true,
+  });
+
+  /** 按工具统计(与明细同一份筛选条件,不随分页变化) */
+  const loadStats = async () => {
     statLoading.value = true;
     try {
-      const [statRes, listRes]: any[] = await Promise.all([toolCallStats(statParams), listToolCallAudit(params)]);
+      const statRes: any = await toolCallStats(buildParams());
       statList.value = statRes ?? [];
-      toolCallList.value = listRes?.rows ?? [];
-      total.value = Number(listRes?.total ?? 0);
     } finally {
-      loading.value = false;
       statLoading.value = false;
     }
   };
 
+  const handleRefresh = () => {
+    reload();
+    loadStats();
+  };
+
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
+    loadStats();
   };
 
   const resetQuery = () => {
@@ -345,9 +316,9 @@
     queryParams.state = undefined;
     queryParams.agentId = undefined;
     queryParams.sessionId = '';
-    queryParams.pageNum = 1;
     dateRange.value = null;
-    getList();
+    reload({ page: 1 });
+    loadStats();
   };
 
   /** 状态标签颜色 */
@@ -396,7 +367,7 @@
   onMounted(() => {
     getAgentOptions();
     getFilterOptions();
-    getList();
+    loadStats();
   });
 </script>
 
@@ -447,22 +418,34 @@
     margin-bottom: 20px;
 
     &:first-child {
-      flex: 0 0 auto;
-    }
-
-    &:last-child {
+      // 统计表限高并内部滚动,避免数据增多时撑满容器、把下方明细表挤成 0 高度
       display: flex;
-      flex: 1 1 auto;
+      flex: 0 1 auto;
       flex-direction: column;
       min-height: 0;
-      margin-bottom: 0;
+      max-height: 32%;
+
+      .stats-table {
+        display: flex;
+        flex: 0 1 auto;
+        flex-direction: column;
+        min-height: 0;
+      }
 
       :deep(.ant-table-wrapper) {
-        flex: 1 1 auto;
+        flex: 0 1 auto;
         min-height: 0;
         overflow: auto;
       }
     }
+
+    &:last-child {
+      display: flex;
+      flex: 1 1 auto;
+      flex-direction: column;
+      min-height: 220px;
+      margin-bottom: 0;
+    }
   }
 
   .section-title {

+ 60 - 86
ai-electron/frontend/src/workbench/views/audit/trace/index.vue

@@ -66,58 +66,47 @@
             </p>
           </div>
           <div class="wb-toolbar__actions">
-            <a-button @click="getList">刷新</a-button>
+            <a-button @click="reload()">刷新</a-button>
           </div>
         </div>
       </template>
 
-      <div class="wb-table-scroll">
-        <a-table
-          :columns="columns"
-          :data-source="traceList"
-          :loading="loading"
-          :pagination="false"
-          :locale="{ emptyText: '暂无链路数据' }"
-          :scroll="{ x: 1300 }"
-          row-key="id"
-          size="small"
-          class="wb-table"
-        >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'source'">
-              <a-tag :color="sourceTagColor(record.source)">{{ sourceLabel(record.source) }}</a-tag>
-            </template>
-            <template v-else-if="column.key === 'status'">
-              <a-tag :color="statusTagColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
-              <a-tooltip v-if="record.errorMsg" :title="record.errorMsg">
-                <Icon icon="i-mdi:alert-circle-outline" class="status-error-icon" />
-              </a-tooltip>
-            </template>
-            <template v-else-if="column.key === 'model'">{{ record.modelCode || '-' }}</template>
-            <template v-else-if="column.key === 'duration'">{{ formatDuration(record.durationMs) }}</template>
-            <template v-else-if="column.key === 'toolCallCount'">{{ record.toolCallCount ?? '-' }}</template>
-            <template v-else-if="column.key === 'totalTokens'">{{ record.totalTokens ?? '-' }}</template>
-            <template v-else-if="column.key === 'action'">
-              <a-button type="link" size="small" @click="handleDetail(record)">详情</a-button>
-            </template>
-          </template>
-        </a-table>
-      </div>
-
-      <div v-show="total > 0" class="wb-pagination">
-        <a-pagination
-          v-model:current="queryParams.pageNum"
-          v-model:page-size="queryParams.pageSize"
-          :total="total"
-          show-size-changer
-          :show-total="showTotal"
-          :page-size-options="['10', '20', '50', '100']"
-          @change="getList"
-        />
-      </div>
+      <BasicTable @register="registerTable" class="wb-table wb-table-fill" :locale="{ emptyText: '暂无链路数据' }">
+        <template #source="{ record }">
+          <a-tag :color="sourceTagColor(record.source)">{{ sourceLabel(record.source) }}</a-tag>
+        </template>
+        <template #status="{ record }">
+          <a-tag :color="statusTagColor(record.status)">{{ statusLabel(record.status) }}</a-tag>
+          <a-tooltip v-if="record.errorMsg" :title="record.errorMsg">
+            <Icon icon="i-mdi:alert-circle-outline" class="status-error-icon" />
+          </a-tooltip>
+        </template>
+        <template #model="{ record }">{{ record.modelCode || '-' }}</template>
+        <template #duration="{ record }">{{ formatDuration(record.durationMs) }}</template>
+        <template #toolCallCount="{ record }">{{ record.toolCallCount ?? '-' }}</template>
+        <template #totalTokens="{ record }">{{ record.totalTokens ?? '-' }}</template>
+        <template #action="{ record }">
+          <a-button type="link" size="small" @click="handleDetail(record)">详情</a-button>
+        </template>
+      </BasicTable>
     </a-card>
 
-    <a-drawer v-model:open="detail.visible" title="链路详情" width="60%" root-class-name="wb-detail-drawer">
+    <a-drawer
+      v-model:open="detail.visible"
+      width="60%"
+      root-class-name="wb-detail-drawer"
+      :closable="false"
+    >
+      <template #title>
+        <span class="wb-drawer-title">
+          <a-tooltip title="关闭" placement="bottom">
+            <button type="button" class="wb-drawer-close" aria-label="关闭" @click="detail.visible = false">
+              <Icon icon="i-ant-design:close-outlined" />
+            </button>
+          </a-tooltip>
+          <span class="wb-drawer-title__text">链路详情</span>
+        </span>
+      </template>
       <a-spin :spinning="detail.loading">
         <div class="trace-detail">
           <template v-if="detail.record">
@@ -201,21 +190,18 @@
 
               <div class="context-block">
                 <div class="context-title">工具决策(工具编码 → 决策)</div>
-                <a-table
+                <BasicTable
                   v-if="toolDecisionList.length"
                   :columns="decisionColumns"
                   :data-source="toolDecisionList"
                   :pagination="false"
                   row-key="code"
                   bordered
-                  size="small"
                 >
-                  <template #bodyCell="{ column, record }">
-                    <template v-if="column.key === 'decision'">
-                      <a-tag :color="decisionTagColor(record.decision)">{{ decisionLabel(record.decision) }}</a-tag>
-                    </template>
+                  <template #decision="{ record }">
+                    <a-tag :color="decisionTagColor(record.decision)">{{ decisionLabel(record.decision) }}</a-tag>
                   </template>
-                </a-table>
+                </BasicTable>
                 <span v-else class="wb-muted">-</span>
               </div>
 
@@ -264,16 +250,15 @@
     AForm,
     AFormItem,
     AInput,
-    APagination,
     ASelect,
     ASelectOption,
     ASpin,
-    ATable,
     ATag,
     ATimeline,
     ATimelineItem,
     ATooltip,
   } from '@/workbench/components/ant';
+  import { BasicTable, useTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import { getTrace, listTrace, optionAuditAgents } from '@/workbench/api/audit';
 
@@ -342,16 +327,11 @@
 
   const route = useRoute();
 
-  const traceList = ref<any[]>([]);
   const agentOptions = ref<any[]>([]);
-  const loading = ref(true);
   const showSearch = ref(true);
-  const total = ref(0);
   const dateRange = ref<any>(null);
 
   const queryParams = reactive<any>({
-    pageNum: 1,
-    pageSize: 10,
     sessionId: undefined,
     agentId: undefined,
     source: undefined,
@@ -369,24 +349,22 @@
     record: undefined,
   });
 
-  const showTotal = (count: number) => `共 ${count} 条`;
-
   const columns: any[] = [
     { title: '创建时间', dataIndex: 'createTime', key: 'createTime', align: 'center', width: 170 },
     { title: '智能体', dataIndex: 'agentName', key: 'agentName', align: 'center', width: 140, ellipsis: true },
-    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', align: 'left', ellipsis: true },
-    { title: '来源', key: 'source', align: 'center', width: 110 },
-    { title: '状态', key: 'status', align: 'center', width: 160 },
-    { title: '模型', key: 'model', align: 'center', width: 150, ellipsis: true },
-    { title: '耗时', key: 'duration', align: 'center', width: 110 },
-    { title: '工具次数', key: 'toolCallCount', align: 'center', width: 100 },
-    { title: 'Token', key: 'totalTokens', align: 'center', width: 100 },
-    { title: '操作', key: 'action', align: 'center', width: 100, fixed: 'right' },
+    { title: '任务标题', dataIndex: 'sessionTitle', key: 'sessionTitle', align: 'left', width: 200, ellipsis: true },
+    { title: '来源', key: 'source', align: 'center', width: 110, slot: 'source' },
+    { title: '状态', key: 'status', align: 'center', width: 160, slot: 'status' },
+    { title: '模型', key: 'model', align: 'center', width: 150, ellipsis: true, slot: 'model' },
+    { title: '耗时', key: 'duration', align: 'center', width: 110, slot: 'duration' },
+    { title: '工具次数', key: 'toolCallCount', align: 'center', width: 100, slot: 'toolCallCount' },
+    { title: 'Token', key: 'totalTokens', align: 'center', width: 100, slot: 'totalTokens' },
+    { title: '操作', key: 'action', align: 'center', width: 100, fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 
   const decisionColumns: any[] = [
     { title: '工具编码', dataIndex: 'code', key: 'code', align: 'left', ellipsis: true },
-    { title: '决策', key: 'decision', align: 'center', width: 140 },
+    { title: '决策', key: 'decision', align: 'center', width: 140, slot: 'decision' },
   ];
 
   /** 上下文对象(后端可能为 null 或历史未采集,统一兜底为空对象) */
@@ -517,16 +495,15 @@
   };
 
   /** 查询链路追踪列表 */
-  const getList = async () => {
-    loading.value = true;
-    try {
-      const res: any = await listTrace(buildParams());
-      traceList.value = res?.rows ?? [];
-      total.value = Number(res?.total ?? 0);
-    } finally {
-      loading.value = false;
-    }
-  };
+  const [registerTable, { reload }] = useTable({
+    api: listTrace,
+    columns,
+    rowKey: 'id',
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => ({ ...params, ...buildParams() }),
+    canResize: true,
+    isCanResizeParent: true,
+  });
 
   /** 查询出现的智能体选项(含已停用) */
   const getAgentOptions = async () => {
@@ -543,8 +520,7 @@
   };
 
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   const resetQuery = () => {
@@ -553,9 +529,8 @@
     queryParams.source = undefined;
     queryParams.status = undefined;
     queryParams.modelCode = '';
-    queryParams.pageNum = 1;
     dateRange.value = null;
-    getList();
+    reload({ page: 1 });
   };
 
   /** 查看链路详情(先展示列表行数据,再拉取含上下文与时间线的详情) */
@@ -580,7 +555,6 @@
   onMounted(() => {
     applyRouteQuery();
     getAgentOptions();
-    getList();
   });
 </script>
 

+ 55 - 99
ai-electron/frontend/src/workbench/views/integration/mcpClient/index.vue

@@ -56,70 +56,44 @@
               删除
             </a-button>
             <a-button @click="showSearch = !showSearch">{{ showSearch ? '隐藏搜索' : '显示搜索' }}</a-button>
-            <a-button @click="getList">刷新</a-button>
+            <a-button @click="reload()">刷新</a-button>
           </div>
         </div>
       </template>
 
-      <div class="wb-table-scroll">
-        <a-table
-          :columns="columns"
-          :data-source="clientList"
-          :loading="loading"
-          row-key="id"
-          :row-selection="{ selectedRowKeys, onChange: handleSelectionChange }"
-          :pagination="false"
-          :scroll="{ x: 1202 }"
-          size="small"
-          class="wb-table"
-        >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'transport'">
-              <a-tag>{{ record.transport === 'sse' ? 'sse' : 'http(streamable)' }}</a-tag>
-            </template>
-            <template v-else-if="column.key === 'enableTools'">
-              <span v-if="record.enableTools">{{ record.enableTools }}</span>
-              <span v-else class="wb-muted">全部工具</span>
-            </template>
-            <template v-else-if="column.key === 'headers'">
-              <a-tag :color="record.headersConfigured ? 'success' : 'default'">
-                {{ record.headersConfigured ? '已配置' : '无' }}
-              </a-tag>
-            </template>
-            <template v-else-if="column.key === 'status'">
-              <a-tag :color="record.status === '0' ? 'success' : 'default'">
-                {{ record.status === '0' ? '启用' : '停用' }}
-              </a-tag>
-            </template>
-            <template v-else-if="column.key === 'action'">
-              <a-tooltip title="查看">
-                <a-button type="link" size="small" @click="handleView(record)">查看</a-button>
-              </a-tooltip>
-              <a-tooltip title="测试连接">
-                <a-button v-auth="'ai:mcpClient:edit'" type="link" size="small" @click="handleTest(record)">测试</a-button>
-              </a-tooltip>
-              <a-tooltip title="修改">
-                <a-button v-auth="'ai:mcpClient:edit'" type="link" size="small" @click="handleUpdate(record)">修改</a-button>
-              </a-tooltip>
-              <a-tooltip title="删除">
-                <a-button v-auth="'ai:mcpClient:remove'" danger type="link" size="small" @click="handleDelete(record)">删除</a-button>
-              </a-tooltip>
-            </template>
-          </template>
-        </a-table>
-      </div>
-
-      <div class="wb-pagination">
-        <a-pagination
-          v-model:current="queryParams.pageNum"
-          v-model:page-size="queryParams.pageSize"
-          :total="total"
-          :show-size-changer="true"
-          :page-size-options="['10', '20', '50', '100']"
-          :show-total="showTotal"
-          @change="getList"
-        />
-      </div>
+      <BasicTable @register="registerTable" class="wb-table wb-table-fill">
+        <template #transport="{ record }">
+          <a-tag>{{ record.transport === 'sse' ? 'sse' : 'http(streamable)' }}</a-tag>
+        </template>
+        <template #enableTools="{ record }">
+          <span v-if="record.enableTools">{{ record.enableTools }}</span>
+          <span v-else class="wb-muted">全部工具</span>
+        </template>
+        <template #headers="{ record }">
+          <a-tag :color="record.headersConfigured ? 'success' : 'default'">
+            {{ record.headersConfigured ? '已配置' : '无' }}
+          </a-tag>
+        </template>
+        <template #status="{ record }">
+          <a-tag :color="record.status === '0' ? 'success' : 'default'">
+            {{ record.status === '0' ? '启用' : '停用' }}
+          </a-tag>
+        </template>
+        <template #action="{ record }">
+          <a-tooltip title="查看">
+            <a-button type="link" size="small" @click="handleView(record)">查看</a-button>
+          </a-tooltip>
+          <a-tooltip title="测试连接">
+            <a-button v-auth="'ai:mcpClient:edit'" type="link" size="small" @click="handleTest(record)">测试</a-button>
+          </a-tooltip>
+          <a-tooltip title="修改">
+            <a-button v-auth="'ai:mcpClient:edit'" type="link" size="small" @click="handleUpdate(record)">修改</a-button>
+          </a-tooltip>
+          <a-tooltip title="删除">
+            <a-button v-auth="'ai:mcpClient:remove'" danger type="link" size="small" @click="handleDelete(record)">删除</a-button>
+          </a-tooltip>
+        </template>
+      </BasicTable>
     </a-card>
 
     <BasicModal
@@ -314,7 +288,7 @@
 </template>
 
 <script lang="ts" setup name="WorkbenchIntegrationMcpClient">
-  import { computed, onMounted, reactive, ref } from 'vue';
+  import { computed, reactive, ref } from 'vue';
   import {
     AAlert,
     AButton,
@@ -325,12 +299,10 @@
     AFormItem,
     AInput,
     AInputNumber,
-    APagination,
     ARadio,
     ARadioGroup,
     ASelect,
     ASelectOption,
-    ATable,
     ATag,
     ATextarea,
     ATooltip,
@@ -338,6 +310,7 @@
     Modal,
   } from '@/workbench/components/ant';
   import BasicModal from '@/core/components/Modal/src/BasicModal.vue';
+  import { BasicTable, useTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import {
     addMcpClient,
@@ -368,17 +341,12 @@
   "Authorization": "Bearer <token>"
 }`;
 
-  const clientList = ref<any[]>([]);
-  const loading = ref(true);
   const showSearch = ref(true);
-  const total = ref(0);
   const buttonLoading = ref(false);
   const testing = ref(false);
   const clientFormRef = ref<any>();
 
   const queryParams = reactive({
-    pageNum: 1,
-    pageSize: 10,
     keyword: '',
     transport: undefined as string | undefined,
     status: undefined as string | undefined,
@@ -440,45 +408,35 @@
 
   const columns: any[] = [
     { title: 'Server 名称', dataIndex: 'serverName', key: 'serverName', width: 150, align: 'center', ellipsis: true },
-    { title: '传输', key: 'transport', width: 140, align: 'center' },
+    { title: '传输', key: 'transport', width: 140, align: 'center', slot: 'transport' },
     { title: '地址', dataIndex: 'url', key: 'url', width: 180, ellipsis: true },
-    { title: '工具白名单', key: 'enableTools', width: 160, ellipsis: true },
-    { title: '请求头', key: 'headers', width: 80, align: 'center' },
-    { title: '状态', key: 'status', width: 70, align: 'center' },
+    { title: '工具白名单', key: 'enableTools', width: 160, ellipsis: true, slot: 'enableTools' },
+    { title: '请求头', key: 'headers', width: 80, align: 'center', slot: 'headers' },
+    { title: '状态', key: 'status', width: 70, align: 'center', slot: 'status' },
     { title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', width: 150, align: 'center' },
-    { title: '操作', key: 'action', width: 240, align: 'center', fixed: 'right' },
+    { title: '操作', key: 'action', width: 240, align: 'center', fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 
-  const showTotal = (value: number) => `共 ${value} 条`;
-
-  const clearSelection = () => {
-    selectedRowKeys.value = [];
-  };
-
-  /** 查询外部 MCP 连接列表 */
-  const getList = async () => {
-    loading.value = true;
-    try {
-      const res = await listMcpClient(queryParams);
-      clientList.value = res?.rows ?? [];
-      total.value = Number(res?.total ?? 0);
-      clearSelection();
-    } finally {
-      loading.value = false;
-    }
-  };
+  const [registerTable, { reload }] = useTable({
+    api: listMcpClient,
+    columns,
+    rowKey: 'id',
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => ({ ...params, ...queryParams }),
+    rowSelection: { type: 'checkbox', onChange: (keys: any) => handleSelectionChange(keys) },
+    canResize: true,
+    isCanResizeParent: true,
+  });
 
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   const resetQuery = () => {
     queryParams.keyword = '';
     queryParams.transport = undefined;
     queryParams.status = undefined;
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   const handleSelectionChange = (keys: Id[]) => {
@@ -581,7 +539,7 @@
         message.success('新增成功,下一次对话即按新配置装配');
       }
       dialog.visible = false;
-      await getList();
+      await reload();
     } finally {
       buttonLoading.value = false;
     }
@@ -601,7 +559,7 @@
     }
     await delMcpClient(target);
     message.success('删除成功');
-    await getList();
+    await reload();
   };
 
   /** 表格行内「测试连接」:直接落结果提示 */
@@ -636,8 +594,6 @@
       testing.value = false;
     }
   };
-
-  onMounted(getList);
 </script>
 
 <style scoped lang="less">

+ 13 - 21
ai-electron/frontend/src/workbench/views/integration/mcpServer/index.vue

@@ -88,31 +88,24 @@
         </div>
       </template>
 
-      <a-table
+      <BasicTable
         :columns="columns"
         :data-source="toolList"
         :loading="toolsLoading"
         row-key="id"
         :pagination="false"
-        :scroll="{ x: 900 }"
-        size="small"
+        :locale="{ emptyText: '暂无启用中的只读工具,请先到「业务工具注册」新增' }"
         class="wb-table"
       >
-        <template #bodyCell="{ column, record }">
-          <template v-if="column.key === 'exposed'">
-            <a-switch v-model:checked="record.exposed" :disabled="!record.registered" />
-          </template>
-          <template v-else-if="column.key === 'registered'">
-            <a-tag :color="record.registered ? 'success' : 'error'">
-              {{ record.registered ? '已登记' : '未登记' }}
-            </a-tag>
-          </template>
+        <template #exposed="{ record }">
+          <a-switch v-model:checked="record.exposed" :disabled="!record.registered" />
         </template>
-      </a-table>
-      <a-empty
-        v-if="!toolsLoading && !toolList.length"
-        description="暂无启用中的只读工具,请先到「业务工具注册」新增"
-      />
+        <template #registered="{ record }">
+          <a-tag :color="record.registered ? 'success' : 'error'">
+            {{ record.registered ? '已登记' : '未登记' }}
+          </a-tag>
+        </template>
+      </BasicTable>
     </a-card>
 
     <a-card :bordered="false" class="wb-card example-panel">
@@ -191,17 +184,16 @@
     ACard,
     ADescriptions,
     ADescriptionsItem,
-    AEmpty,
     AForm,
     AFormItem,
     AInputPassword,
     ASpin,
     ASwitch,
-    ATable,
     ATag,
     ATooltip,
     message,
   } from '@/workbench/components/ant';
+  import { BasicTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import { useGlobSetting } from '@/core/hooks/setting';
   import { getMcpServer, listMcpServerTools, updateMcpServer, updateMcpServerTools } from '@/workbench/api/mcp';
@@ -233,10 +225,10 @@
   const toolList = ref<any[]>([]);
 
   const columns: any[] = [
-    { title: '对外暴露', key: 'exposed', width: 110, align: 'center' },
+    { title: '对外暴露', key: 'exposed', width: 110, align: 'center', slot: 'exposed' },
     { title: '工具编码', dataIndex: 'toolCode', key: 'toolCode', width: 220, align: 'center', ellipsis: true },
     { title: '工具名称', dataIndex: 'toolName', key: 'toolName', width: 160, align: 'center', ellipsis: true },
-    { title: '实现登记', key: 'registered', width: 110, align: 'center' },
+    { title: '实现登记', key: 'registered', width: 110, align: 'center', slot: 'registered' },
     { title: '说明', dataIndex: 'description', key: 'description', ellipsis: true },
   ];
 

+ 79 - 128
ai-electron/frontend/src/workbench/views/integration/registry/index.vue

@@ -72,60 +72,34 @@
               批量打标签
             </a-button>
             <a-button v-auth="'ai:tool:remove'" :disabled="multiple" @click="openBatchTagDialog('remove')"> 移除标签 </a-button>
-            <a-button @click="getList">刷新</a-button>
+            <a-button @click="reload()">刷新</a-button>
           </div>
         </div>
       </template>
 
-      <div class="wb-table-scroll">
-        <a-table
-          :columns="columns"
-          :data-source="toolList"
-          :loading="loading"
-          row-key="id"
-          :row-selection="{ selectedRowKeys, onChange: handleSelectionChange }"
-          :pagination="false"
-          :scroll="{ x: 1180 }"
-          size="small"
-          class="wb-table"
-        >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'toolType'">
-              <a-tag :color="record.toolType === '1' ? 'orange' : 'blue'">
-                {{ record.toolType === '1' ? '写入' : '只读' }}
-              </a-tag>
-            </template>
-            <template v-else-if="column.key === 'tags'">
-              <template v-if="record.tags && record.tags.length">
-                <a-tag v-for="tag in record.tags" :key="String(tag.id)" class="tag-item">{{ tag.tagName }}</a-tag>
-              </template>
-              <span v-else class="wb-muted">未打标签</span>
-            </template>
-            <template v-else-if="column.key === 'status'">
-              <a-tag :color="record.status === '0' ? 'success' : 'default'">
-                {{ record.status === '0' ? '启用' : '停用' }}
-              </a-tag>
-            </template>
-            <template v-else-if="column.key === 'action'">
-              <a-tooltip title="查看">
-                <a-button type="link" size="small" @click="handleView(record)">查看</a-button>
-              </a-tooltip>
-            </template>
+      <BasicTable @register="registerTable" class="wb-table wb-table-fill">
+        <template #toolType="{ record }">
+          <a-tag :color="record.toolType === '1' ? 'orange' : 'blue'">
+            {{ record.toolType === '1' ? '写入' : '只读' }}
+          </a-tag>
+        </template>
+        <template #tags="{ record }">
+          <template v-if="record.tags && record.tags.length">
+            <a-tag v-for="tag in record.tags" :key="String(tag.id)" class="tag-item">{{ tag.tagName }}</a-tag>
           </template>
-        </a-table>
-      </div>
-
-      <div class="wb-pagination">
-        <a-pagination
-          v-model:current="queryParams.pageNum"
-          v-model:page-size="queryParams.pageSize"
-          :total="total"
-          :show-size-changer="true"
-          :page-size-options="['10', '20', '50', '100']"
-          :show-total="showTotal"
-          @change="getList"
-        />
-      </div>
+          <span v-else class="wb-muted">未打标签</span>
+        </template>
+        <template #status="{ record }">
+          <a-tag :color="record.status === '0' ? 'success' : 'default'">
+            {{ record.status === '0' ? '启用' : '停用' }}
+          </a-tag>
+        </template>
+        <template #action="{ record }">
+          <a-tooltip title="查看">
+            <a-button type="link" size="small" @click="handleView(record)">查看</a-button>
+          </a-tooltip>
+        </template>
+      </BasicTable>
     </a-card>
 
     <BasicModal
@@ -264,46 +238,33 @@
         </a-form-item>
       </a-form>
 
-      <a-table
+      <BasicTable
         :columns="tagColumns"
         :data-source="tagList"
         :loading="tagLoading"
         row-key="id"
-        :pagination="false"
-        :scroll="{ y: 360 }"
-        size="small"
+        :pagination="{ current: tagQuery.pageNum, pageSize: tagQuery.pageSize, total: tagTotal }"
+        :scroll="({ y: 360 } as any)"
         :row-class-name="tagRowClass"
-        class="tag-table"
+        class="tag-table wb-table"
+        @change="handleTagTableChange"
       >
-        <template #bodyCell="{ column, record }">
-          <template v-if="column.key === 'tagName'">
-            <a-tag>{{ record.tagName }}</a-tag>
-          </template>
-          <template v-else-if="column.key === 'useCount'">
-            <a-tag :color="(record.useCount ?? 0) > 0 ? 'blue' : 'default'">{{ record.useCount ?? 0 }}</a-tag>
-          </template>
-          <template v-else-if="column.key === 'action'">
-            <a-tooltip title="编辑">
-              <a-button v-auth="'ai:tool:edit'" type="link" size="small" @click="editTag(record)">编辑</a-button>
-            </a-tooltip>
-            <a-tooltip title="删除">
-              <a-button v-auth="'ai:tool:remove'" danger type="link" size="small" @click="handleDeleteTag(record)">删除</a-button>
-            </a-tooltip>
-          </template>
+        <template #tagName="{ record }">
+          <a-tag>{{ record.tagName }}</a-tag>
         </template>
-      </a-table>
-
-      <div v-show="tagTotal > 0" class="wb-pagination">
-        <a-pagination
-          v-model:current="tagQuery.pageNum"
-          v-model:page-size="tagQuery.pageSize"
-          :total="tagTotal"
-          :show-size-changer="true"
-          :page-size-options="['10', '20', '50', '100']"
-          :show-total="showTotal"
-          @change="getTagList"
-        />
-      </div>
+        <template #useCount="{ record }">
+          <a-tag :color="(record.useCount ?? 0) > 0 ? 'blue' : 'default'">{{ record.useCount ?? 0 }}</a-tag>
+        </template>
+        <template #tagAction="{ record }">
+          <a-tooltip title="编辑">
+            <a-button v-auth="'ai:tool:edit'" type="link" size="small" @click="editTag(record)">编辑</a-button>
+          </a-tooltip>
+          <a-tooltip title="删除">
+            <a-button v-auth="'ai:tool:remove'" danger type="link" size="small" @click="handleDeleteTag(record)">删除</a-button>
+          </a-tooltip>
+        </template>
+      </BasicTable>
+
       <div class="form-tip">
         标签仅作分类标记:删除标签会一并解除它与全部工具的关联;「使用工具数」便于发现未使用的标签。
       </div>
@@ -422,12 +383,10 @@
     AForm,
     AFormItem,
     AInput,
-    APagination,
     ARadio,
     ARadioGroup,
     ASelect,
     ASelectOption,
-    ATable,
     ATag,
     ATextarea,
     ATooltip,
@@ -435,6 +394,7 @@
     Modal,
   } from '@/workbench/components/ant';
   import BasicModal from '@/core/components/Modal/src/BasicModal.vue';
+  import { BasicTable, useTable } from '@/core/components/Table';
   import { Icon } from '@/core/components/Icon';
   import {
     addTool,
@@ -464,8 +424,6 @@
   }
 
   interface ToolQueryData {
-    pageNum: number;
-    pageSize: number;
     keyword?: string;
     toolType?: string;
     status?: string;
@@ -506,16 +464,11 @@
   "required": ["query"]
 }`;
 
-  const toolList = ref<ToolVO[]>([]);
-  const loading = ref(true);
   const showSearch = ref(true);
-  const total = ref(0);
   const buttonLoading = ref(false);
   const toolFormRef = ref<any>();
 
   const queryParams = reactive<ToolQueryData>({
-    pageNum: 1,
-    pageSize: 10,
     keyword: '',
     toolType: undefined,
     status: undefined,
@@ -608,42 +561,36 @@
   const columns: any[] = [
     { title: '工具编码', dataIndex: 'toolCode', key: 'toolCode', width: 130, align: 'center', ellipsis: true },
     { title: '工具名称', dataIndex: 'toolName', key: 'toolName', width: 130, align: 'center', ellipsis: true },
-    { title: '类型', key: 'toolType', width: 64, align: 'center' },
-    { title: '标签', key: 'tags', width: 120 },
+    { title: '类型', key: 'toolType', width: 64, align: 'center', slot: 'toolType' },
+    { title: '标签', key: 'tags', width: 120, slot: 'tags' },
     { title: '实现标识', dataIndex: 'implName', key: 'implName', width: 120, align: 'center', ellipsis: true },
-    { title: '状态', key: 'status', width: 64, align: 'center' },
+    { title: '状态', key: 'status', width: 64, align: 'center', slot: 'status' },
     { title: '说明', dataIndex: 'description', key: 'description', width: 300, ellipsis: true },
     { title: '更新时间', dataIndex: 'updateTime', key: 'updateTime', width: 140, align: 'center' },
-    { title: '操作', key: 'action', width: 80, align: 'center', fixed: 'right' },
+    { title: '操作', key: 'action', width: 80, align: 'center', fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 
   const tagColumns: any[] = [
-    { title: '标签名称', key: 'tagName', width: 240, ellipsis: true },
-    { title: '使用工具数', key: 'useCount', width: 110, align: 'center' },
+    { title: '标签名称', key: 'tagName', width: 240, ellipsis: true, slot: 'tagName' },
+    { title: '使用工具数', key: 'useCount', width: 110, align: 'center', slot: 'useCount' },
     { title: '备注', dataIndex: 'remark', key: 'remark', ellipsis: true },
-    { title: '操作', key: 'action', width: 130, align: 'center' },
+    { title: '操作', key: 'action', width: 130, align: 'center', ellipsis: false, slot: 'tagAction' },
   ];
 
-  const showTotal = (value: number) => `共 ${value} 条`;
-
-  const clearSelection = () => {
-    selectedRowKeys.value = [];
-    selectedTools.value = [];
-  };
-
-  /** 查询工具注册列表 */
-  const getList = async () => {
-    loading.value = true;
-    try {
-      queryParams.tagIds = tagFilter.value.length ? tagFilter.value.join(',') : undefined;
-      const res = await listTool(queryParams);
-      toolList.value = res?.rows ?? [];
-      total.value = Number(res?.total ?? 0);
-      clearSelection();
-    } finally {
-      loading.value = false;
-    }
-  };
+  const [registerTable, { reload }] = useTable({
+    api: listTool,
+    columns,
+    rowKey: 'id',
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => ({
+      ...params,
+      ...queryParams,
+      tagIds: tagFilter.value.length ? tagFilter.value.join(',') : undefined,
+    }),
+    rowSelection: { type: 'checkbox', onChange: (keys: any, rows: any) => handleSelectionChange(keys, rows) },
+    canResize: true,
+    isCanResizeParent: true,
+  });
 
   /** 查询全部标签选项 */
   const getTagOptions = async () => {
@@ -652,8 +599,7 @@
   };
 
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   const resetQuery = () => {
@@ -663,8 +609,7 @@
     queryParams.status = undefined;
     queryParams.tagIds = undefined;
     queryParams.noTag = false;
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   const handleSelectionChange = (keys: Id[], rows: ToolVO[]) => {
@@ -757,7 +702,7 @@
         message.success('新增成功');
       }
       dialog.visible = false;
-      await getList();
+      await reload();
       // 标签使用计数会随打标变化,一并刷新
       await getTagOptions();
     } finally {
@@ -778,7 +723,7 @@
     }
     await delTool(target as Id | Id[]);
     message.success('删除成功');
-    await getList();
+    await reload();
     await getTagOptions();
   };
 
@@ -807,6 +752,13 @@
     }
   };
 
+  /** 标签表分页切换(系统统一分页由 BasicTable 内置渲染) */
+  const handleTagTableChange = (pagination: any) => {
+    tagQuery.pageNum = pagination.current;
+    tagQuery.pageSize = pagination.pageSize;
+    getTagList();
+  };
+
   const handleTagQuery = () => {
     tagQuery.pageNum = 1;
     getTagList();
@@ -846,7 +798,7 @@
       await getTagList();
       await getTagOptions();
       // 工具列表的标签列同步刷新
-      await getList();
+      await reload();
     } finally {
       buttonLoading.value = false;
     }
@@ -866,7 +818,7 @@
     message.success('删除成功');
     await getTagList();
     await getTagOptions();
-    await getList();
+    await reload();
   };
 
   // ------------------------------------------------------------------
@@ -951,7 +903,7 @@
       batchDialog.visible = false;
       await getTagOptions();
       // 刷新列表:标签列随之后端返回同步
-      await getList();
+      await reload();
     } finally {
       buttonLoading.value = false;
     }
@@ -959,7 +911,6 @@
 
   onMounted(() => {
     getTagOptions();
-    getList();
   });
 </script>
 

+ 104 - 152
ai-electron/frontend/src/workbench/views/kb/doc/index.vue

@@ -118,87 +118,62 @@
         </div>
       </template>
 
-      <div class="kb-doc-table-scroll">
-        <a-table
-          :columns="columns"
-          :data-source="docList"
-          :loading="loading"
-          :row-selection="rowSelection"
-          :pagination="false"
-          :scroll="{ x: 1210 }"
-          row-key="id"
-          size="small"
-          class="kb-doc-table"
-        >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'fileSuffix'">{{ record.fileSuffix || '-' }}</template>
-            <template v-else-if="column.key === 'fileSize'">{{ formatSize(record.fileSize) }}</template>
-            <template v-else-if="column.key === 'chunkCount'">
-              <a-button type="link" size="small" :disabled="!record.chunkCount" @click="handleChunks(record)">
-                {{ record.chunkCount ?? 0 }}
+      <BasicTable @register="registerTable" class="kb-doc-table wb-table-fill" @fetch-success="handleFetchSuccess">
+        <template #fileSuffix="{ record }">{{ record.fileSuffix || '-' }}</template>
+        <template #fileSize="{ record }">{{ formatSize(record.fileSize) }}</template>
+        <template #chunkCount="{ record }">
+          <a-button type="link" size="small" :disabled="!record.chunkCount" @click="handleChunks(record)">
+            {{ record.chunkCount ?? 0 }}
+          </a-button>
+        </template>
+        <template #parseStatus="{ record }">
+          <a-tooltip :title="record.errorMsg || statusLabel(record.parseStatus)">
+            <a-tag :color="statusType(record.parseStatus)">{{ statusLabel(record.parseStatus) }}</a-tag>
+          </a-tooltip>
+        </template>
+        <template #vectorStatus="{ record }">
+          <a-tooltip :title="record.vectorErrorMsg || vectorStatusLabel(record.vectorStatus)">
+            <a-tag :color="statusType(record.vectorStatus)">{{ vectorStatusLabel(record.vectorStatus) }}</a-tag>
+          </a-tooltip>
+        </template>
+        <template #action="{ record }">
+          <div class="kb-doc-actions">
+            <a-tooltip title="预览">
+              <a-button type="link" size="small" @click="handlePreview(record)">预览</a-button>
+            </a-tooltip>
+            <a-tooltip title="解析(提取文本并重建切片)">
+              <a-button
+                v-auth="'ai:doc:edit'"
+                type="link"
+                size="small"
+                :disabled="record.parseStatus === '1'"
+                @click="handleParse(record)"
+              >
+                解析
               </a-button>
-            </template>
-            <template v-else-if="column.key === 'parseStatus'">
-              <a-tooltip :title="record.errorMsg || statusLabel(record.parseStatus)">
-                <a-tag :color="statusType(record.parseStatus)">{{ statusLabel(record.parseStatus) }}</a-tag>
-              </a-tooltip>
-            </template>
-            <template v-else-if="column.key === 'vectorStatus'">
-              <a-tooltip :title="record.vectorErrorMsg || vectorStatusLabel(record.vectorStatus)">
-                <a-tag :color="statusType(record.vectorStatus)">{{ vectorStatusLabel(record.vectorStatus) }}</a-tag>
-              </a-tooltip>
-            </template>
-            <template v-else-if="column.key === 'action'">
-              <div class="kb-doc-actions">
-                <a-tooltip title="预览">
-                  <a-button type="link" size="small" @click="handlePreview(record)">预览</a-button>
-                </a-tooltip>
-                <a-tooltip title="解析(提取文本并重建切片)">
-                  <a-button
-                    v-auth="'ai:doc:edit'"
-                    type="link"
-                    size="small"
-                    :disabled="record.parseStatus === '1'"
-                    @click="handleParse(record)"
-                  >
-                    解析
-                  </a-button>
-                </a-tooltip>
-                <a-tooltip :title="record.vectorStatus === '2' ? '重建索引(重新向量化)' : '向量化(写入向量库)'">
-                  <a-button
-                    v-auth="'ai:doc:edit'"
-                    type="link"
-                    size="small"
-                    :disabled="record.parseStatus !== '2' || record.vectorStatus === '1'"
-                    @click="handleVectorize(record)"
-                  >
-                    向量化
-                  </a-button>
-                </a-tooltip>
-                <a-tooltip title="下载原文件">
-                  <a-button type="link" size="small" :disabled="!record.fileUrl" @click="openFile(record)">
-                    下载
-                  </a-button>
-                </a-tooltip>
-                <a-tooltip title="删除">
-                  <a-button v-auth="'ai:doc:remove'" danger type="link" size="small" @click="handleDelete(record)"> 删除 </a-button>
-                </a-tooltip>
-              </div>
-            </template>
-          </template>
-        </a-table>
-      </div>
-
-      <div v-show="total > 0" class="kb-doc-pagination">
-        <a-pagination
-          v-model:current="queryParams.pageNum"
-          v-model:page-size="queryParams.pageSize"
-          :total="total"
-          :show-size-changer="true"
-          :page-size-options="['10', '20', '50', '100']"
-          @change="getList"
-        />
-      </div>
+            </a-tooltip>
+            <a-tooltip :title="record.vectorStatus === '2' ? '重建索引(重新向量化)' : '向量化(写入向量库)'">
+              <a-button
+                v-auth="'ai:doc:edit'"
+                type="link"
+                size="small"
+                :disabled="record.parseStatus !== '2' || record.vectorStatus === '1'"
+                @click="handleVectorize(record)"
+              >
+                向量化
+              </a-button>
+            </a-tooltip>
+            <a-tooltip title="下载原文件">
+              <a-button type="link" size="small" :disabled="!record.fileUrl" @click="openFile(record)">
+                下载
+              </a-button>
+            </a-tooltip>
+            <a-tooltip title="删除">
+              <a-button v-auth="'ai:doc:remove'" danger type="link" size="small" @click="handleDelete(record)"> 删除 </a-button>
+            </a-tooltip>
+          </div>
+        </template>
+      </BasicTable>
     </a-card>
 
     <!-- 在线预览 -->
@@ -258,14 +233,13 @@
         </div>
       </a-spin>
       <div v-show="chunkDialog.total > 0" class="wb-pagination">
-        <a-pagination
-          v-model:current="chunkDialog.query.pageNum"
-          v-model:page-size="chunkDialog.query.pageSize"
+        <AnalysisPagination
           :total="chunkDialog.total"
-          :show-size-changer="true"
+          :current="chunkDialog.query.pageNum"
+          :page-size="chunkDialog.query.pageSize"
           :page-size-options="['5', '10', '20', '50']"
-          :show-total="showTotal"
-          @change="loadChunks"
+          :loading="chunkDialog.loading"
+          @change="handleChunkPageChange"
         />
       </div>
       <template #footer>
@@ -312,12 +286,10 @@
     AInput,
     AMenu,
     AMenuItem,
-    APagination,
     ASelect,
     ASelectOption,
     ASpin,
     ASwitch,
-    ATable,
     ATabPane,
     ATabs,
     ATag,
@@ -328,6 +300,8 @@
   } from '@/workbench/components/ant';
   import { Icon } from '@/core/components/Icon';
   import { BasicModal } from '@/core/components/Modal';
+  import { BasicTable, useTable } from '@/core/components/Table';
+  import AnalysisPagination from '@/core/components/AnalysisPagination/src/AnalysisPagination.vue';
   import {
     addDocument,
     batchIngestDocument,
@@ -425,9 +399,7 @@
 
   const route = useRoute();
 
-  const docList = ref<DocumentVO[]>([]);
   const kbOptions = ref<KnowledgeBaseVO[]>([]);
-  const loading = ref(true);
   /** 查询条件展开态(默认展开,点击标题收起) */
   const showSearch = ref(true);
   const total = ref(0);
@@ -439,8 +411,6 @@
   const uploadPending = ref(0);
 
   const queryParams = reactive<any>({
-    pageNum: 1,
-    pageSize: 10,
     kbId: undefined,
     docName: undefined,
     parseStatus: undefined,
@@ -485,23 +455,34 @@
 
   const columns: any[] = [
     { title: '文档名称', dataIndex: 'docName', key: 'docName', width: 198, align: 'center', ellipsis: true },
-    { title: '格式', key: 'fileSuffix', align: 'center', width: 72 },
-    { title: '大小', key: 'fileSize', align: 'center', width: 72 },
+    { title: '格式', key: 'fileSuffix', align: 'center', width: 72, slot: 'fileSuffix' },
+    { title: '大小', key: 'fileSize', align: 'center', width: 72, slot: 'fileSize' },
     { title: '字符数', dataIndex: 'charCount', key: 'charCount', align: 'center', width: 84 },
-    { title: '切片数', key: 'chunkCount', align: 'center', width: 72 },
-    { title: '解析状态', key: 'parseStatus', align: 'center', width: 110 },
-    { title: '向量化状态', key: 'vectorStatus', align: 'center', width: 120 },
+    { title: '切片数', key: 'chunkCount', align: 'center', width: 72, slot: 'chunkCount' },
+    { title: '解析状态', key: 'parseStatus', align: 'center', width: 110, slot: 'parseStatus' },
+    { title: '向量化状态', key: 'vectorStatus', align: 'center', width: 120, slot: 'vectorStatus' },
     { title: '创建时间', dataIndex: 'createTime', key: 'createTime', align: 'center', width: 150 },
-    { title: '操作', key: 'action', align: 'center', width: 300, fixed: 'right' },
+    { title: '操作', key: 'action', align: 'center', width: 300, fixed: 'right', ellipsis: false, slot: 'action' },
   ];
 
-  const rowSelection = computed(() => ({
-    selectedRowKeys: selectedRowKeys.value,
-    preserveSelectedRowKeys: true,
-    onChange: (keys: Id[]) => {
-      selectedRowKeys.value = keys;
-    },
-  }));
+  const [registerTable, { reload, clearSelectedRowKeys }] = useTable({
+    api: listDocument,
+    columns,
+    rowKey: 'id',
+    // 首屏需先载入知识库选项(可能深链带入 kbId)再查询,故不立即请求
+    immediate: false,
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => ({ ...params, ...queryParams }),
+    // 批量处理允许跨页勾选:翻页 / 刷新保留选择,批量完成后显式清空
+    clearSelectedOnReload: false,
+    rowSelection: { type: 'checkbox', onChange: (keys: any) => (selectedRowKeys.value = keys) },
+    canResize: true,
+    isCanResizeParent: true,
+  });
+
+  const handleFetchSuccess = ({ total: t }: any) => {
+    total.value = Number(t ?? 0);
+  };
 
   const isPdf = computed(() => preview.suffix === 'pdf');
   const isImage = computed(() => ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp'].includes(preview.suffix));
@@ -541,8 +522,6 @@
     return (size / 1024 / 1024).toFixed(2) + ' MB';
   };
 
-  const showTotal = (count: number) => `共 ${count} 条`;
-
   const confirm = (content: string) =>
     new Promise<boolean>((resolve) => {
       Modal.confirm({
@@ -567,28 +546,14 @@
     }
   };
 
-  /** 查询文档列表(未选知识库时查询全部:后端 kbId 为条件过滤,不传即全量) */
-  const getList = async () => {
-    loading.value = true;
-    try {
-      const res = await listDocument(queryParams);
-      docList.value = res?.rows ?? [];
-      total.value = Number(res?.total ?? 0);
-    } finally {
-      loading.value = false;
-    }
-  };
-
   /** 切换知识库 */
   const handleKbChange = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   /** 搜索按钮操作 */
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
   };
 
   const resetQuery = async () => {
@@ -596,9 +561,8 @@
     queryParams.docName = undefined;
     queryParams.parseStatus = undefined;
     queryParams.vectorStatus = undefined;
-    queryParams.pageNum = 1;
     await loadKbOptions();
-    handleQuery();
+    reload({ page: 1 });
   };
 
   /** 上传前校验(多文件时每个文件各触发一次) */
@@ -682,7 +646,7 @@
       await submitBatch('ingest', targetIds);
     } else {
       message.success(`已登记 ${targetIds.length} 个文档,请点击「解析」提取文本与切片`);
-      await getList();
+      await reload();
     }
   };
 
@@ -734,7 +698,7 @@
     if (!accepted.length && !skipped.length) {
       message.warning('没有可处理的文档');
     }
-    await getList();
+    await reload();
   };
 
   /** 打开进度面板并开始轮询 */
@@ -767,8 +731,8 @@
       return;
     }
     // 全部进入终态:刷新列表并清空选择,避免「已完成」的文档仍处于勾选态
-    await getList();
-    selectedRowKeys.value = [];
+    await reload();
+    clearSelectedRowKeys();
   };
 
   /** 页面卸载时清理定时器(避免离开后仍持续请求) */
@@ -793,7 +757,7 @@
     } catch {
       hide();
     }
-    await getList();
+    await reload();
   };
 
   /** 向量化文档(已向量化时为重建索引) */
@@ -810,7 +774,7 @@
     } catch {
       hide();
     }
-    await getList();
+    await reload();
   };
 
   /** 预览 */
@@ -859,6 +823,13 @@
     }
   };
 
+  /** 切片分页切换(系统统一分页组件回调) */
+  const handleChunkPageChange = (page: number, pageSize: number) => {
+    chunkDialog.query.pageNum = page;
+    chunkDialog.query.pageSize = pageSize;
+    loadChunks();
+  };
+
   /** 删除按钮操作 */
   const handleDelete = async (row?: Partial<DocumentVO>) => {
     const target = row?.id ?? selectedRowKeys.value;
@@ -867,12 +838,12 @@
     }
     await delDocument(target);
     message.success('删除成功');
-    await getList();
+    await reload();
   };
 
   onMounted(async () => {
     await loadKbOptions();
-    await getList();
+    await reload();
   });
 </script>
 
@@ -1073,12 +1044,6 @@
     line-height: 30px;
   }
 
-  .kb-doc-table-scroll {
-    flex: 1 1 auto;
-    min-height: 0;
-    overflow: auto;
-  }
-
   .kb-doc-table :deep(.ant-table) {
     font-size: 12px;
   }
@@ -1132,19 +1097,6 @@
     }
   }
 
-  .kb-doc-pagination {
-    display: flex;
-    flex: 0 0 auto;
-    align-items: center;
-    justify-content: flex-end;
-    padding: 8px 14px 10px;
-    border-top: 1px solid #eff2f7;
-  }
-
-  .kb-doc-pagination :deep(.ant-pagination) {
-    margin: 0;
-  }
-
   .auto-ingest-switch {
     margin-right: 2px;
   }

+ 50 - 96
ai-electron/frontend/src/workbench/views/model/usage/index.vue

@@ -99,99 +99,64 @@
 
       <div class="section-block">
         <div class="section-title">按日期</div>
-        <a-table
+        <BasicTable
           :columns="byDateColumns"
           :data-source="overview.byDate"
           :loading="overviewLoading"
           :pagination="false"
-          :locale="{ emptyText: '暂无数据' }"
           row-key="label"
-          size="middle"
           class="wb-table"
         >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'cost'">{{ formatCost(record.cost) }}</template>
-          </template>
-        </a-table>
+          <template #cost="{ record }">{{ formatCost(record.cost) }}</template>
+        </BasicTable>
       </div>
 
       <div class="section-block">
         <div class="section-title">按智能体 / 模型</div>
         <a-row :gutter="16">
           <a-col :span="12">
-            <a-table
+            <BasicTable
               :columns="byAgentColumns"
               :data-source="overview.byAgent"
               :pagination="false"
-              :locale="{ emptyText: '暂无数据' }"
               row-key="label"
-              size="middle"
               class="wb-table"
             >
-              <template #bodyCell="{ column, record }">
-                <template v-if="column.key === 'cost'">{{ formatCost(record.cost) }}</template>
-              </template>
-            </a-table>
+              <template #cost="{ record }">{{ formatCost(record.cost) }}</template>
+            </BasicTable>
           </a-col>
           <a-col :span="12">
-            <a-table
+            <BasicTable
               :columns="byModelColumns"
               :data-source="overview.byModel"
               :pagination="false"
-              :locale="{ emptyText: '暂无数据' }"
               row-key="label"
-              size="middle"
               class="wb-table"
             >
-              <template #bodyCell="{ column, record }">
-                <template v-if="column.key === 'cost'">{{ formatCost(record.cost) }}</template>
-              </template>
-            </a-table>
+              <template #cost="{ record }">{{ formatCost(record.cost) }}</template>
+            </BasicTable>
           </a-col>
         </a-row>
       </div>
 
       <div class="section-block">
         <div class="section-title">用量明细</div>
-        <a-table
-          :columns="detailColumns"
-          :data-source="usageList"
-          :loading="loading"
-          :pagination="false"
-          :locale="{ emptyText: '暂无数据' }"
-          row-key="id"
-          size="middle"
-          class="wb-table"
-        >
-          <template #bodyCell="{ column, record }">
-            <template v-if="column.key === 'usageType'">
-              <a-tag :color="record.usageType === '1' ? 'default' : 'blue'">
-                {{ record.usageType === '1' ? '知识库入库' : '对话' }}
-              </a-tag>
-            </template>
-            <template v-else-if="column.key === 'model'">
-              <span>{{ record.modelName || record.modelId || '-' }}</span>
-              <a-tag v-if="record.priceConfigured === false" class="price-tag" color="warning">未配置单价</a-tag>
-            </template>
-            <template v-else-if="column.key === 'user'">
-              <span v-if="record.userName">{{ record.userName }}</span>
-              <span v-else class="text-muted">{{ record.userId ?? '-' }}</span>
-            </template>
-            <template v-else-if="column.key === 'cost'">{{ formatCost(record.cost) }}</template>
+        <BasicTable @register="registerTable" class="wb-table">
+          <template #usageType="{ record }">
+            <a-tag :color="record.usageType === '1' ? 'default' : 'blue'">
+              {{ record.usageType === '1' ? '知识库入库' : '对话' }}
+            </a-tag>
           </template>
-        </a-table>
-
-        <div v-show="total > 0" class="wb-pagination">
-          <a-pagination
-            v-model:current="queryParams.pageNum"
-            v-model:page-size="queryParams.pageSize"
-            :total="total"
-            :show-size-changer="true"
-            :page-size-options="['10', '20', '50', '100']"
-            :show-total="showTotal"
-            @change="getList"
-          />
-        </div>
+          <template #model="{ record }">
+            <span>{{ record.modelName || record.modelId || '-' }}</span>
+            <a-tag v-if="record.priceConfigured === false" class="price-tag" color="warning">未配置单价</a-tag>
+          </template>
+          <template #user="{ record }">
+            <span v-if="record.userName">{{ record.userName }}</span>
+            <span v-else class="text-muted">{{ record.userId ?? '-' }}</span>
+          </template>
+          <template #cost="{ record }">{{ formatCost(record.cost) }}</template>
+        </BasicTable>
       </div>
     </a-card>
   </div>
@@ -206,13 +171,12 @@
     ADatePicker,
     AForm,
     AFormItem,
-    APagination,
     ARow,
     ASelect,
     ASelectOption,
-    ATable,
     ATag,
   } from '@/workbench/components/ant';
+  import { BasicTable, useTable } from '@/core/components/Table';
   import { exportUsage, listUsageStat, optionAuditAgents, usageOverview } from '@/workbench/api/audit';
   import { listUser } from '@/workbench/api/user';
   import type { UserVO } from '@/workbench/api/user';
@@ -227,48 +191,43 @@
     { title: '总 Token', dataIndex: 'totalTokens', key: 'totalTokens', align: 'center', width: 130 },
     { title: '请求数', dataIndex: 'requestCount', key: 'requestCount', align: 'center', width: 100 },
     { title: '工具调用', dataIndex: 'toolCallCount', key: 'toolCallCount', align: 'center', width: 100 },
-    { title: '费用(元)', key: 'cost', align: 'center', width: 130 },
+    { title: '费用(元)', key: 'cost', align: 'center', width: 130, slot: 'cost' },
   ];
 
   const byAgentColumns: any[] = [
     { title: '智能体', dataIndex: 'label', key: 'label', align: 'left', ellipsis: true },
     { title: '总 Token', dataIndex: 'totalTokens', key: 'totalTokens', align: 'center', width: 120 },
-    { title: '费用(元)', key: 'cost', align: 'center', width: 120 },
+    { title: '费用(元)', key: 'cost', align: 'center', width: 120, slot: 'cost' },
   ];
 
   const byModelColumns: any[] = [
     { title: '模型', dataIndex: 'label', key: 'label', align: 'left', ellipsis: true },
     { title: '总 Token', dataIndex: 'totalTokens', key: 'totalTokens', align: 'center', width: 120 },
-    { title: '费用(元)', key: 'cost', align: 'center', width: 120 },
+    { title: '费用(元)', key: 'cost', align: 'center', width: 120, slot: 'cost' },
   ];
 
   const detailColumns: any[] = [
     { title: '日期', dataIndex: 'statDate', key: 'statDate', align: 'center', width: 120 },
-    { title: '类型', key: 'usageType', align: 'center', width: 110 },
-    { title: '智能体', dataIndex: 'agentName', key: 'agentName', align: 'left', ellipsis: true },
-    { title: '模型', key: 'model', align: 'left', width: 160, ellipsis: true },
-    { title: '用户', key: 'user', align: 'center', width: 120 },
+    { title: '类型', key: 'usageType', align: 'center', width: 110, slot: 'usageType' },
+    { title: '智能体', dataIndex: 'agentName', key: 'agentName', align: 'left', width: 160, ellipsis: true },
+    { title: '模型', key: 'model', align: 'left', width: 160, ellipsis: true, slot: 'model' },
+    { title: '用户', key: 'user', align: 'center', width: 120, slot: 'user' },
     { title: '输入 Token', dataIndex: 'promptTokens', key: 'promptTokens', align: 'center', width: 120 },
     { title: '输出 Token', dataIndex: 'completionTokens', key: 'completionTokens', align: 'center', width: 120 },
     { title: '总 Token', dataIndex: 'totalTokens', key: 'totalTokens', align: 'center', width: 120 },
     { title: '请求数', dataIndex: 'requestCount', key: 'requestCount', align: 'center', width: 90 },
     { title: '工具调用', dataIndex: 'toolCallCount', key: 'toolCallCount', align: 'center', width: 100 },
-    { title: '费用(元)', key: 'cost', align: 'center', width: 120 },
+    { title: '费用(元)', key: 'cost', align: 'center', width: 120, slot: 'cost' },
   ];
 
-  const usageList = ref<any[]>([]);
   const agentOptions = ref<any[]>([]);
   const userOptions = ref<UserVO[]>([]);
   const overview = ref<any>({ byDate: [], byAgent: [], byModel: [] });
-  const loading = ref(true);
   const overviewLoading = ref(true);
   const showSearch = ref(true);
-  const total = ref(0);
   const dateRange = ref<any>(null);
 
   const queryParams = reactive<any>({
-    pageNum: 1,
-    pageSize: 10,
     beginDate: undefined,
     endDate: undefined,
     agentId: undefined,
@@ -305,16 +264,19 @@
     return params;
   };
 
-  /** 查询明细与总览(同一份筛选条件) */
-  const getList = async () => {
-    const params = buildParams();
-    const overviewParams: any = { ...params };
-    delete overviewParams.pageNum;
-    delete overviewParams.pageSize;
-    loading.value = true;
+  const [registerTable, { reload }] = useTable({
+    api: listUsageStat,
+    columns: detailColumns,
+    rowKey: 'id',
+    fetchSetting: { pageField: 'pageNum', sizeField: 'pageSize', listField: 'rows', totalField: 'total' },
+    beforeFetch: (params) => ({ ...params, ...buildParams() }),
+  });
+
+  /** 用量总览(与明细同一份筛选条件,不随分页变化) */
+  const loadOverview = async () => {
     overviewLoading.value = true;
     try {
-      const [overviewRes, listRes] = await Promise.all([usageOverview(overviewParams), listUsageStat(params)]);
+      const overviewRes: any = await usageOverview(buildParams());
       const overviewData = overviewRes ?? {};
       overview.value = {
         ...overviewData,
@@ -322,10 +284,7 @@
         byAgent: overviewData.byAgent ?? [],
         byModel: overviewData.byModel ?? [],
       };
-      usageList.value = listRes?.rows ?? [];
-      total.value = Number(listRes?.total ?? 0);
     } finally {
-      loading.value = false;
       overviewLoading.value = false;
     }
   };
@@ -347,8 +306,8 @@
   };
 
   const handleQuery = () => {
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
+    loadOverview();
   };
 
   const resetQuery = () => {
@@ -356,12 +315,10 @@
     queryParams.usageType = undefined;
     queryParams.userId = undefined;
     dateRange.value = null;
-    queryParams.pageNum = 1;
-    getList();
+    reload({ page: 1 });
+    loadOverview();
   };
 
-  const showTotal = (count: number) => `共 ${count} 条`;
-
   /** 费用展示(保留 6 位小数,去尾零) */
   const formatCost = (cost?: number) => {
     if (cost === undefined || cost === null) {
@@ -376,11 +333,8 @@
 
   /** 导出用量明细 */
   const handleExport = async () => {
-    const params: any = { ...buildParams() };
-    delete params.pageNum;
-    delete params.pageSize;
     try {
-      await exportUsage(params, `用量统计_${new Date().getTime()}.xlsx`);
+      await exportUsage(buildParams(), `用量统计_${new Date().getTime()}.xlsx`);
     } catch {
       // 失败提示由请求层统一处理
     }
@@ -389,7 +343,7 @@
   onMounted(() => {
     getAgentOptions();
     getUserOptions();
-    getList();
+    loadOverview();
   });
 </script>