Browse Source

feat(case): 数据页工具栏增加刷新按钮并调整设置图标顺序

- 新增「刷新」:左侧治理树与右侧列表同时重拉,保留当前选中节点、页码与
  自定义查询条件;节点已不存在时退回首节点
- 设置图标移到工具栏最后
- 移除数据页冗余的「查看结果」按钮(顶部页签本身可切换)
cc 4 days ago
parent
commit
30b9c8b005
1 changed files with 53 additions and 13 deletions
  1. 53 13
      ai-electron/frontend/src/case/views/data/index.vue

+ 53 - 13
ai-electron/frontend/src/case/views/data/index.vue

@@ -25,9 +25,6 @@
           </button>
         </div>
         <div class="header-actions">
-          <Button v-if="cleanMode === 'manual'" class="header-actions__result" @click="activeTab = 'import'">
-            查看结果
-          </Button>
           <Button type="primary" class="header-actions__upload" @click="handleUploadNavigate('single')"
             >清洗数据</Button
           >
@@ -62,11 +59,6 @@
               <div class="panel-title">数据结果列表</div>
             </div>
             <div class="table-actions">
-              <TableSetting
-                :key="resultTableSettingKey"
-                class="table-setting-trigger"
-                :setting="{ setting: true, size: true, redo: false, fullScreen: false }"
-              />
               <Popover
                 v-if="showCustomQueryButton"
                 v-model:open="customQueryPopoverOpen"
@@ -79,6 +71,15 @@
                 </template>
                 <Button type="primary">自定义查询</Button>
               </Popover>
+              <Button class="table-actions__refresh" :loading="refreshing" @click="handleRefreshData">
+                <template #icon><ReloadOutlined /></template>
+                刷新
+              </Button>
+              <TableSetting
+                :key="resultTableSettingKey"
+                class="table-setting-trigger"
+                :setting="{ setting: true, size: true, redo: false, fullScreen: false }"
+              />
             </div>
           </div>
 
@@ -215,6 +216,7 @@
 <script lang="ts" setup name="ViewsDataIndex">
   import { computed, h, ref, nextTick, onActivated, onBeforeUnmount, onDeactivated, onMounted } from 'vue';
   import { Button, Select, Pagination, Input, Modal, Radio, Tooltip, Popover, Form, RadioGroup } from 'ant-design-vue';
+  import { ReloadOutlined } from '@ant-design/icons-vue';
   import { BasicTable, type BasicColumn } from '@/core/components/Table';
   import TableSetting from '@/core/components/Table/src/components/settings/index.vue';
   import { createTableContext } from '@/core/components/Table/src/hooks/useTableContext';
@@ -309,7 +311,7 @@
   // 支持 ?tab=files 直达「导入文件」页签(仅作 URL 直连兜底;正常流程由清洗进度页经 sessionStorage 切换)
   const initialTab = new URLSearchParams(window.location.search).get('tab') === 'files' ? 'files' : 'import';
   const activeTab = ref<DataPageTabKey>(initialTab as DataPageTabKey);
-  /** 完成出口标记(?mode=manual,仅作 URL 直连兜底):决定展示「查看结果」 */
+  /** 完成出口标记(?mode=manual,仅作 URL 直连兜底):从清洗完成跳转而来时保留页签,不强切回导入数据 */
   const readCleanMode = (): '' | 'manual' => {
     const mode = new URLSearchParams(window.location.search).get('mode');
     return mode === 'manual' ? mode : '';
@@ -505,6 +507,8 @@
   const resultTableAction = ref<any>(null);
   const totalCount = ref(0);
   const loading = ref(false);
+  /** 工具栏「刷新」进行中:树与列表同时在重拉,按钮转圈并防重复点击 */
+  const refreshing = ref(false);
 
   const pageSize = ref(componentSetting.table.defaultPageSize);
   const lastPageSize = ref(pageSize.value);
@@ -1532,6 +1536,44 @@
     );
   };
 
+  /**
+   * 工具栏「刷新」:左侧治理树与右侧列表一起重拉,并保留当前选中节点、页码与自定义查询条件。
+   *
+   * 不复用 fetchTreeData({ preserveActive: true }):那条分支会把 activeNodeLevel 清 0,
+   * 刷新完「自定义查询」按钮和「打开文件」列会跟着消失。
+   * 节点已不在新树里(被删除/重建)时,退回默认的首节点选中逻辑。
+   */
+  const handleRefreshData = async () => {
+    if (refreshing.value) return;
+    refreshing.value = true;
+    try {
+      const data = await getTree();
+      treeData.value = mapGovernTree(data);
+      updateTemplateCategories(data);
+      if (!treeData.value.length) {
+        clearTableState();
+        return;
+      }
+      const current = findGovernNodeByCurrent(data);
+      if (!current) {
+        initTreeSelection(treeData.value);
+        const firstNode = treeData.value[0]?.dataRef as GovernTree | undefined;
+        if (firstNode) {
+          fetchByNode(firstNode);
+        }
+        return;
+      }
+      activeNode.value = current;
+      const currentKey = resolveGovernTreeKey(current, treeData.value);
+      selectedKeys.value = currentKey ? [currentKey] : [];
+      fetchByActiveNode();
+    } catch (error) {
+      console.error('刷新数据失败', error);
+    } finally {
+      refreshing.value = false;
+    }
+  };
+
   const handlePageChange = (page: number) => {
     currentPage.value = page;
     jumpPage.value = page.toString(); // 同步跳转页码输入框
@@ -2959,8 +3001,7 @@
       &__upload,
       &__govern,
       &__config,
-      &__smart,
-      &__result {
+      &__smart {
         min-width: 0;
         height: 30px;
         padding: 0 14px;
@@ -2969,8 +3010,7 @@
         box-shadow: none;
       }
 
-      &__config,
-      &__result {
+      &__config {
         border: 1px solid #e7ebf3;
         background: #fff;
         color: #5b6577;