Bladeren bron

[Feat 0000] 接入统计添加跳转功能,跳转参数修改

houzekong 1 week geleden
bovenliggende
commit
fdd720f79c

+ 2 - 2
src/views/analysis/warningAnalysis/connectAnalysis/hooks/form.ts

@@ -10,8 +10,8 @@ export function useInitForm() {
   // 默认填充的矿码
   const innerValue = ref<string>('');
 
-  if (route.query.id) {
-    innerValue.value = route.query.id as string;
+  if (route.query.deptId) {
+    innerValue.value = route.query.deptId as string;
   } else {
     const leaf = mineStore.findDepart((e) => e.isLeaf, mineStore.getRoot);
     innerValue.value = leaf?.id as string;

+ 30 - 1
src/views/dashboard/basicInfo/accessStatistics/index.vue

@@ -1,7 +1,13 @@
 <!-- eslint-disable vue/multi-word-component-names -->
 <template>
   <div class="p-4">
-    <BasicTable @register="registerTable" />
+    <BasicTable @register="registerTable">
+      <template #action="{ record }">
+        <button v-if="!record.isTotal" @click="handleGoToPageQuery(record, '/basicinfo/mines-info')" class="action-btn" title="矿山基础信息">
+          <SvgIcon name="info" />
+        </button>
+      </template>
+    </BasicTable>
   </div>
 </template>
 <script setup lang="ts">
@@ -9,6 +15,10 @@
   import { accessStatisticsColumns } from './access.data';
   import { getGoafAccessCount } from '../basicInfo.api';
   import type { BasicColumn } from '/@/components/Table/src/types/table';
+  import { useRouter } from 'vue-router';
+  import SvgIcon from '/@/components/Icon/src/SvgIcon.vue';
+
+  const router = useRouter();
 
   // 封装接口调用,获取数据后手动添加「总计」行
   const fetchTableData = async (params: any) => {
@@ -70,8 +80,27 @@
     useSearchForm: false,
     bordered: true,
     showIndexColumn: false,
+    actionColumn: {
+      width: 80,
+      title: '操作',
+      dataIndex: 'action',
+      slots: { customRender: 'action' },
+    },
     scroll: { x: 'max-content' },
   });
+
+  /**
+   * 通用页面跳转方法
+   * @param record 当前行数据
+   * @param path 目标路径
+   */
+  function handleGoToPageQuery(record: any, path: string) {
+    const deptId = record.deptId;
+    router.push({
+      path,
+      query: { deptId },
+    });
+  }
 </script>
 <style lang="less" scoped>
   :deep(.ant-table-thead th:nth-child(1)) {

+ 17 - 74
src/views/dashboard/basicInfo/minesInfo/index.vue

@@ -8,76 +8,40 @@
       <button @click="handleGoToPageQuery(record, `/sealed/${record.parentId}`)" class="action-btn" title="老空区永久密闭监测数据">
         <SvgIcon name="data" />
       </button>
-      <button @click="handleGoToPage(record, '/basicinfo/access-statistics')" class="action-btn" title="接入统计数据">
+      <button @click="handleGoToPageQuery(record, '/basicinfo/access-statistics')" class="action-btn" title="接入统计数据">
         <SvgIcon name="info" />
       </button>
       <button @click="handleGoToPageQuery(record, '/warningAnalysis/connectAnalysis')" class="action-btn" title="智能分析数据">
         <SvgIcon name="chart" />
       </button>
     </template>
+    <template #expandedRowRender="{ record }">
+      <BasicTable :dataSource="record.coalSeamList" :columns="coalSeamColumns" :pagination="false">
+        <!-- <template #action="{ record }">
+            <button @click="handleEdit(record, 'goaf')" class="action-btn" title="编辑">
+              <SvgIcon name="edit" />
+            </button>
+          </template> -->
+      </BasicTable>
+    </template>
   </BasicTable>
 </template>
 
 <script setup lang="ts">
-  import { ref, nextTick, onMounted } from 'vue';
-  import { useRouter } from 'vue-router';
+  import { useRouter, useRoute } from 'vue-router';
   import { BasicTable } from '/@/components/Table';
   import { SvgIcon } from '/@/components/Icon';
-  import { message } from 'ant-design-vue';
   // 引入动态列/表单配置函数 + 类型
-  import { columns, searchFormSchema, type ProductionStatusMap } from './minesInfo.data';
+  import { coalSeamColumns, columns, searchFormSchema } from './minesInfo.data';
   import { getMineData } from '../basicInfo.api';
   // 引入字典获取方法
-  import { getDictItemsByCode } from '/@/utils/dict';
   import { useListPage } from '/@/hooks/system/useListPage';
   // import { useIntervalFn } from '@vueuse/core';
   // import { useModal } from '/@/components/Modal';
 
   // 路由实例
   const router = useRouter();
-
-  // ========== 动态生产状态配置 ==========
-  // 1. 响应式存储动态状态映射(key: 状态值,value: 配置)
-  const dynamicProductionStatusMap = ref<ProductionStatusMap>({});
-  // 2. 响应式存储动态下拉选项(供搜索表单使用)
-  const dynamicProductionStatusOptions = ref<{ label: string; value: string | number }[]>([]);
-
-  // 3. 生产状态颜色分配规则(和dataQuality保持一致)
-  const getStatusColor = (statusText: string) => {
-    if (statusText.includes('正常生产')) return 'green';
-    if (statusText.includes('拟建矿井')) return 'blue';
-    return 'red'; // 其他状态统一红色
-  };
-
-  // 4. 从接口获取生产状态字典,生成动态映射/选项
-  const fetchProductionStatus = async () => {
-    try {
-      const statusList = await getDictItemsByCode('mineProStatus');
-      if (!Array.isArray(statusList)) return;
-
-      const statusMap: ProductionStatusMap = {};
-      const statusOptions: { label: string; value: string | number }[] = [];
-
-      statusList.forEach((item) => {
-        const value = item.value;
-        const label = item.text || item.label;
-        const color = getStatusColor(label);
-
-        statusMap[value] = { label, value, color };
-        statusOptions.push({ label, value });
-      });
-
-      // 赋值到响应式变量
-      dynamicProductionStatusMap.value = statusMap;
-      dynamicProductionStatusOptions.value = statusOptions;
-
-      // 刷新表格(使用最新的状态映射)
-      await safeReloadTable();
-    } catch (error) {
-      console.error('获取生产状态字典失败:', error);
-      message.error('生产状态数据加载失败');
-    }
-  };
+  const route = useRoute();
 
   // ========== 表格注册 ==========
   const { tableContext: ctxRealtime, onExportXls } = useListPage({
@@ -85,6 +49,7 @@
       api: getMineData, // 数据统计接口
       columns, // 绑定动态列
       formConfig: {
+        model: { deptId: route.query.deptId },
         labelWidth: 120,
         schemas: searchFormSchema, // 绑定动态搜索表单
         showAdvancedButton: false,
@@ -99,36 +64,19 @@
       params: {},
     },
   });
-  const [registerRealtimeTable, realtimeTable] = ctxRealtime;
+  const [registerRealtimeTable] = ctxRealtime;
   // useIntervalFn(() => realtimeTable.reload({ silence: true }), 10000);
 
-  // ========== 辅助方法 ==========
-  // 安全刷新表格(避免表格未初始化导致的报错)
-  async function safeReloadTable() {
-    await nextTick();
-    try {
-      await realtimeTable.reload();
-    } catch (e) {
-      console.warn('矿山信息表格重载失败:', e);
-    }
-  }
-
   /**
    * 通用页面跳转方法
    * @param record 当前行数据
    * @param path 目标路径
    */
-  function handleGoToPage(__: any, path: string) {
-    router.push({
-      path,
-    });
-  }
-
   function handleGoToPageQuery(record: any, path: string) {
-    const id = record.deptId;
+    const deptId = record.deptId;
     router.push({
       path,
-      query: { id },
+      query: { deptId },
     });
   }
   // const [registerRealtimeModal, { openModal: openRealtimeModal }] = useModal();
@@ -143,11 +91,6 @@
   //   // }
   //   pause();
   // };
-  // ========== 初始化 ==========
-  onMounted(async () => {
-    // 先获取生产状态字典,再加载表格
-    await fetchProductionStatus();
-  });
 </script>
 
 <style lang="less" scoped>

+ 1 - 1
src/views/monitor/sealedMonitor/hooks/form.ts

@@ -13,7 +13,7 @@ export function useInitForm() {
   // 获取到路由携带的id后进行过滤
   const dep = mineStore.findDepartById(departId);
   // 获取到query携带的矿id,如有就默认选中该矿
-  const rawcode = route.query.id as string;
+  const rawcode = route.query.deptId as string;
   // 给历史数据默认填充的矿码
   const hiscode = rawcode
     ? rawcode