Просмотр исходного кода

fix(dm): 导入文件列表按文件勾选,sheet 不参与计数删除

- sheet 子行禁用复选框,全选只选择文件行
- 已选/删除数量只统计文件 id,并过滤历史选择中的 sheet id
- “当前页”条数按文件行分页计算,不再把 sheet 计入
cc 3 недель назад
Родитель
Сommit
c12139f56c
1 измененных файлов с 25 добавлено и 2 удалено
  1. 25 2
      ai-electron/frontend/src/case/views/data/importList.vue

+ 25 - 2
ai-electron/frontend/src/case/views/data/importList.vue

@@ -79,6 +79,8 @@
   const PRE_FILE_EMPTY_MESSAGE = '未识别到可处理文件,可能是文件重复、所有文件不存在,或文件格式不正确';
   const PRE_FILE_EMPTY_MESSAGE = '未识别到可处理文件,可能是文件重复、所有文件不存在,或文件格式不正确';
   const ctrlPermi = ref('');
   const ctrlPermi = ref('');
   const currentPageFileCount = ref(0);
   const currentPageFileCount = ref(0);
+  /** 本次 fetch 返回的文件行总数(不含 sheet 子行),用于计算当前页展示条数 */
+  const currentPageRootCount = ref(0);
   const logModalOpen = ref(false);
   const logModalOpen = ref(false);
   const currentLogFileInfos = ref<FileInfo[]>([]);
   const currentLogFileInfos = ref<FileInfo[]>([]);
   const currentLogSheetId = ref<string>('');
   const currentLogSheetId = ref<string>('');
@@ -327,11 +329,15 @@
   };
   };
 
 
   const selectedRowKeysRef = ref<string[]>([]);
   const selectedRowKeysRef = ref<string[]>([]);
+  /** sheet 子行 id:全选/历史选择里即使带了 sheet id,也不计入按文件删除 */
+  const sheetRowIdSet = ref<Set<string>>(new Set());
   const rowSelection = {
   const rowSelection = {
     type: 'checkbox',
     type: 'checkbox',
     columnWidth: 48,
     columnWidth: 48,
+    // sheet 只是文件的明细行,删除按文件粒度,sheet 不参与勾选和计数
+    getCheckboxProps: (record: FileInfo) => ({ disabled: isSheetRecord(record) }),
     onChange: (selectedRowKeys: string[]) => {
     onChange: (selectedRowKeys: string[]) => {
-      selectedRowKeysRef.value = selectedRowKeys;
+      selectedRowKeysRef.value = selectedRowKeys.filter((key) => !sheetRowIdSet.value.has(String(key)));
     },
     },
   };
   };
   const [registerTable, tableAction] = useTable<FileInfo>({
   const [registerTable, tableAction] = useTable<FileInfo>({
@@ -342,7 +348,18 @@
       return nextParams;
       return nextParams;
     },
     },
     afterFetch: (items: FileInfo[]) => {
     afterFetch: (items: FileInfo[]) => {
-      currentPageFileCount.value = Array.isArray(items) ? items.length : 0;
+      currentPageRootCount.value = Array.isArray(items) ? items.length : 0;
+      const sheetIds = new Set<string>();
+      const collectSheetIds = (rows: FileInfo[]) => {
+        rows.forEach((row) => {
+          (row.children ?? []).forEach((child) => {
+            if (child?.id != null) sheetIds.add(String(child.id));
+            collectSheetIds([child]);
+          });
+        });
+      };
+      collectSheetIds(items ?? []);
+      sheetRowIdSet.value = sheetIds;
       return items;
       return items;
     },
     },
     immediate: false,
     immediate: false,
@@ -374,6 +391,12 @@
     pagination.value.current = Number(tablePagination.current) || 1;
     pagination.value.current = Number(tablePagination.current) || 1;
     pagination.value.pageSize = Number(tablePagination.pageSize || tablePagination.defaultPageSize) || 1;
     pagination.value.pageSize = Number(tablePagination.pageSize || tablePagination.defaultPageSize) || 1;
     pagination.value.total = Number(total ?? tablePagination.total) || 0;
     pagination.value.total = Number(total ?? tablePagination.total) || 0;
+    // “当前页”只统计本页的文件行;sheet 是文件明细,不计入文件条数/删除数量
+    const pageStart = (pagination.value.current - 1) * pagination.value.pageSize;
+    currentPageFileCount.value = Math.max(
+      0,
+      Math.min(pagination.value.pageSize, currentPageRootCount.value - pageStart),
+    );
   };
   };
 
 
   const handlePaginationChange = async (page: number, pageSize: number) => {
   const handlePaginationChange = async (page: number, pageSize: number) => {