From 84b90d1e66ba297ce0d4b812f60b3656ba0bf3dc Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 23 十月 2026 17:01:18 +0800
Subject: [PATCH] feat(ai): 更新AI功能配置和数据补录界面

---
 src/views/ai/model/model/index.vue |   64 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/src/views/ai/model/model/index.vue b/src/views/ai/model/model/index.vue
index 350dd0a..54e8ac5 100644
--- a/src/views/ai/model/model/index.vue
+++ b/src/views/ai/model/model/index.vue
@@ -2,12 +2,15 @@
 import type { VxeTableGridOptions } from '#/adapter/vxe-table';
 import type { AiModelModelApi } from '#/api/ai/model/model';
 
-import { Page, useVbenModal } from '@vben/common-ui';
+import { ref } from 'vue';
+
+import { confirm, Page, useVbenModal } from '@vben/common-ui';
+import { CommonStatusEnum } from '@vben/constants';
 
 import { message } from 'ant-design-vue';
 
 import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
-import { deleteModel, getModelPage } from '#/api/ai/model/model';
+import { deleteModel, getModelPage, updateModelStatus } from '#/api/ai/model/model';
 import { $t } from '#/locales';
 
 import { useGridColumns, useGridFormSchema } from './data';
@@ -17,6 +20,9 @@
   connectedComponent: Form,
   destroyOnClose: true,
 });
+
+/** 褰撳墠椤垫暟鎹紝spanMethod 渚濊禆瀹冭绠楃被鍨嬪垪鍚堝苟琛屾暟 */
+const currentRows = ref<AiModelModelApi.Model[]>([]);
 
 /** 鍒锋柊琛ㄦ牸 */
 function handleRefresh() {
@@ -48,22 +54,71 @@
   }
 }
 
+/** 鏇存柊妯″瀷鍚敤鐘舵�侊細鍚敤浼氳嚜鍔ㄥ叧闂悓绫诲瀷鍚岃兘鍔涚殑鍏朵粬妯″瀷 */
+async function handleStatusChange(
+  newStatus: number,
+  row: AiModelModelApi.Model,
+): Promise<boolean | undefined> {
+  try {
+    await confirm(
+      newStatus === CommonStatusEnum.ENABLE
+        ? `鍚敤銆�${row.name}銆嶅悗锛屽悓绫诲瀷鍚岃兘鍔涗笅宸插惎鐢ㄧ殑鍏朵粬妯″瀷浼氳嚜鍔ㄥ叧闂紝纭畾缁х画鍚楋紵`
+        : `浣犺鍋滅敤銆�${row.name}銆嶅悧锛熷仠鐢ㄥ悗璇ョ被鍨嬭鑳藉姏灏嗘病鏈夊彲鐢ㄦā鍨嬨�俙,
+    );
+  } catch {
+    return false;
+  }
+  await updateModelStatus(row.id!, newStatus);
+  message.success($t('ui.actionMessage.operationSuccess'));
+  // 鍚岀粍鍏朵粬妯″瀷鐨勫惎鐢ㄧ姸鎬佸凡琚悗绔敼鍐欙紝蹇呴』鏁撮〉鍒锋柊
+  handleRefresh();
+  return true;
+}
+
+/** 妯″瀷绫诲瀷鍒楁寜绫诲瀷绾靛悜鍚堝苟锛屽舰鎴愬垎绫诲睍绀� */
+function handleSpanMethod({
+  column,
+  rowIndex,
+}: {
+  column: { field?: string; property?: string };
+  rowIndex: number;
+}) {
+  const field = column.field || column.property;
+  if (field !== 'type') {
+    return { colspan: 1, rowspan: 1 };
+  }
+  const row = currentRows.value[rowIndex];
+  if (rowIndex > 0 && currentRows.value[rowIndex - 1]?.type === row?.type) {
+    return { colspan: 0, rowspan: 0 };
+  }
+  let rowspan = 1;
+  for (let index = rowIndex + 1; index < currentRows.value.length; index += 1) {
+    if (currentRows.value[index]?.type !== row?.type) {
+      break;
+    }
+    rowspan += 1;
+  }
+  return { colspan: 1, rowspan };
+}
+
 const [Grid, gridApi] = useVbenVxeGrid({
   formOptions: {
     schema: useGridFormSchema(),
   },
   gridOptions: {
-    columns: useGridColumns(),
+    columns: useGridColumns(handleStatusChange),
     height: 'auto',
     keepSource: true,
     proxyConfig: {
       ajax: {
         query: async ({ page }, formValues) => {
-          return await getModelPage({
+          const data = await getModelPage({
             pageNo: page.currentPage,
             pageSize: page.pageSize,
             ...formValues,
           });
+          currentRows.value = data.list || [];
+          return data;
         },
       },
     },
@@ -71,6 +126,7 @@
       keyField: 'id',
       isHover: true,
     },
+    spanMethod: handleSpanMethod,
     toolbarConfig: {
       refresh: true,
       search: true,

--
Gitblit v1.9.3