Selaa lähdekoodia

fix(import): 树表叶子行隐藏序号/圆点,电子数据包展示提取状态

- 叶子节点(sheet 行)不显示序号,文件行按根节点连续编号
- 自定义 expandIcon:仅可展开的文件行渲染箭头,去掉叶子占位圆点
- 治理状态列对电子数据包展示提取中/完成/失败,失败标红并悬停提示原因
cc 2 viikkoa sitten
vanhempi
commit
6c1b69d515
1 muutettua tiedostoa jossa 57 lisäystä ja 12 poistoa
  1. 57 12
      ai-electron/frontend/src/case/views/data/importList.vue

+ 57 - 12
ai-electron/frontend/src/case/views/data/importList.vue

@@ -1,6 +1,15 @@
 <template>
   <div :class="prefixCls" class="case-import-list">
     <BasicTable class="import-list-table" @register="registerTable" @fetch-success="handleFetchSuccess">
+      <!-- 叶子节点(sheet 行、无子表的文件行)不再渲染占位圆点,只有可展开的文件行显示箭头 -->
+      <template #expandIcon="{ record, expanded, onExpand }">
+        <BasicArrow
+          v-if="hasExpandableChildren(record)"
+          style="margin-right: 8px"
+          :expand="expanded"
+          @click="onExpand(record, $event)"
+        />
+      </template>
       <template #toolbar>
         <div class="table-toolbar">
           <div class="table-title-meta">
@@ -67,6 +76,7 @@
   import type { PropType } from 'vue';
   import { Input, Pagination, Popconfirm, Select } from 'ant-design-vue';
   import { Icon } from '@/core/components/Icon';
+  import { BasicArrow } from '@/core/components/Basic';
   import { BasicTable, BasicColumn, useTable } from '@/core/components/Table';
   import { useDesign } from '@/core/hooks/web/useDesign';
   import { useGo } from '@/core/hooks/web/usePage';
@@ -187,6 +197,10 @@
   /** sheet 子行判断:文件行的 pid 为空/0,sheet 行的 pid 指向所属文件 */
   const isSheetRecord = (record: Partial<FileInfo>) => !(record.pid == null || String(record.pid) === '0');
 
+  /** 是否还有可展开的子行:只有文件行(可能挂 sheet)才显示展开箭头,叶子节点不渲染占位圆点 */
+  const hasExpandableChildren = (record?: Partial<FileInfo>) =>
+    Array.isArray(record?.children) && record.children.length > 0;
+
   /** 电子数据包:fileType=eds,不是表格文件,列表按专用口径展示(不显示导入数/治理状态/清洗方式) */
   const isEdsPackage = (record?: Partial<FileInfo> | null) =>
     String(record?.fileType ?? '')
@@ -210,13 +224,21 @@
   const getErrorMessage = (error: any, fallback = '操作失败') =>
     error?.response?.data?.message || error?.message || fallback;
 
+  /** 序号按文件行(树的根节点)连续编号:sheet 子行不占号,避免文件序号被明细行顶出空号 */
+  const rootRowNoMap = ref<Map<string, number>>(new Map());
+
   const tableColumns: BasicColumn<FileInfo>[] = [
     {
       title: '序号',
       key: 'sort',
       width: 76,
       align: 'center',
-      customRender: ({ index }: { index: number }) => h('span', { class: 'table-cell-center' }, String(index + 1)),
+      customRender: ({ record }: { record: FileInfo }) => {
+        // 叶子节点(sheet 行)只作为文件明细展示,不显示序号
+        if (isSheetRecord(record)) return '';
+        const no = rootRowNoMap.value.get(String(record.id ?? ''));
+        return h('span', { class: 'table-cell-center' }, no == null ? '' : String(no));
+      },
     },
     {
       title: '文件名称',
@@ -266,18 +288,30 @@
       title: '治理状态',
       dataIndex: 'fileStatus',
       key: 'fileStatus',
-      width: 120,
+      width: 140,
       align: 'center',
-      customRender: ({ value, record }: { value?: string | null; record?: any }) =>
-        // 电子数据包不参与治理,不展示治理状态
-        isEdsPackage(record)
-          ? ''
-          : // 未解析的文件悬停可看原因(已保留原件 / 仅登记、未保存源文件)
-            h(
-              'span',
-              { class: 'govern-status-text', title: record?.unsupportedReason || undefined },
-              getGovernStatusLabel(value),
-            ),
+      customRender: ({ value, record }: { value?: string | null; record?: any }) => {
+        // 电子数据包不参与治理,但这列是文件状态唯一的展示位:
+        // 提取中 / 提取完成 / 提取失败都要看得到,失败标红并悬停展示原因
+        if (isEdsPackage(record)) {
+          const label = getGovernStatusLabel(value);
+          return h(
+            'span',
+            {
+              // FileStatusEnum 的值是中文标签,value 是后端枚举名,统一用 label 判断失败态
+              class: ['govern-status-text', { 'is-error': label === FileStatusEnum.FILE_EDS_FAIL }],
+              title: record?.cleanNote || record?.unsupportedReason || undefined,
+            },
+            label,
+          );
+        }
+        // 未解析的文件悬停可看原因(已保留原件 / 仅登记、未保存源文件)
+        return h(
+          'span',
+          { class: 'govern-status-text', title: record?.unsupportedReason || undefined },
+          getGovernStatusLabel(value),
+        );
+      },
     },
     {
       // 仅 sheet 行有意义:文件行留空。值由后端 getFiles 按 AI 任务记录回填
@@ -391,6 +425,11 @@
       };
       collectSheetIds(items ?? []);
       sheetRowIdSet.value = sheetIds;
+      const noMap = new Map<string, number>();
+      (items ?? []).forEach((row, i) => {
+        if (row?.id != null) noMap.set(String(row.id), i + 1);
+      });
+      rootRowNoMap.value = noMap;
       return items;
     },
     immediate: false,
@@ -801,6 +840,12 @@
       vertical-align: middle;
     }
 
+    /* 电子数据包提取失败:状态列标红,和「备注」里的原因一起形成明确提示 */
+    .govern-status-text.is-error {
+      color: #dc2626;
+      font-weight: 500;
+    }
+
     .fail-link {
       color: #315efb;
       font-size: 12px;