Przeglądaj źródła

[Mod 0000]修改质量管理页面跳转逻辑

wangkeyi 3 miesięcy temu
rodzic
commit
f89068f12d

+ 37 - 36
src/views/dashboard/basicInfo/dataQuality/dataQuality.data.ts

@@ -21,6 +21,12 @@ export const productionStatusMap: Record<string | number, { label: string; value
   // 15: { label: '已关闭矿井', value: 15, color: 'green' },
 };
 
+// 基于productionStatusMap生成下拉选项
+export const productionStatusOptions = Object.entries(productionStatusMap).map(([key, item]) => ({
+  label: item.label, // 状态名称
+  value: key,        // 状态值(转字符串,和原硬编码格式一致)
+}));
+
 // 颜色映射
 const colorHexMap: Record<string, string> = {
   blue: '#1890ff',
@@ -59,7 +65,6 @@ export const columns: BasicColumn[] = [
     dataIndex: 'mineLinkStatus',
     width: 100,
     customRender: ({ record }) => {
-      console.log(record.mineLinkStatus);
       const status = record.mineLinkStatus;
       if (status === undefined || status === null) {
         return h('span', { style: { color: colorHexMap.black } }, '/');
@@ -105,42 +110,38 @@ export const searchFormSchema: FormSchema[] = [
     colProps: { span: 6 },
     groupName: '常规查询',
   },
-  {
-    field: 'mineNameAbbr',
-    label: '煤矿简称',
-    component: 'Input',
-    colProps: { span: 6 },
-    groupName: '常规查询',
-  },
-  {
-    field: 'productionStatus',
-    label: '生产状态',
-    component: 'Select',
-    componentProps: {
-      options: [
-        { label: '拟建矿井', value: '0' },
-        { label: '正常生产矿井', value: '1' },
-        { label: '长期停产矿井', value: '1' },
-      ],
-    },
-    colProps: { span: 6 },
-    groupName: '常规查询',
-  },
+  // {
+  //   field: 'mineNameAbbr',
+  //   label: '煤矿简称',
+  //   component: 'Input',
+  //   colProps: { span: 6 },
+  //   groupName: '常规查询',
+  // },
+  // {
+  //   field: 'productionStatus',
+  //   label: '生产状态',
+  //   component: 'Select',
+  //   componentProps: {
+  //     options: productionStatusOptions
+  //   },
+  //   colProps: { span: 6 },
+  //   groupName: '常规查询',
+  // },
 
-  {
-    field: 'mineLinkStatus',
-    label: '在线状态',
-    component: 'Select',
-    componentProps: {
-      options: [
-        { label: '离线', value: '0' },
-        { label: '在线', value: '1' },
-        { label: '未连接', value: '2' },
-      ],
-    },
-    colProps: { span: 6 },
-    groupName: '常规查询',
-  },
+  // {
+  //   field: 'mineLinkStatus',
+  //   label: '在线状态',
+  //   component: 'Select',
+  //   componentProps: {
+  //     options: [
+  //       { label: '离线', value: '0' },
+  //       { label: '在线', value: '1' },
+  //       { label: '未连接', value: '2' },
+  //     ],
+  //   },
+  //   colProps: { span: 6 },
+  //   groupName: '常规查询',
+  // },
 ];
 
 // 模拟煤矿在线状态选项数据

+ 35 - 12
src/views/dashboard/basicInfo/dataQuality/index.vue

@@ -56,7 +56,7 @@
               <SvgIcon name="resolved" />
             </button>
           </Popconfirm>
-          <button @click="handleGoToPage(record, '/basicInfo/accessStatistics')" class="action-btn">
+          <button @click="handleGoToPage(record)" class="action-btn">
             <SvgIcon name="details" />
           </button>
         </template>
@@ -108,10 +108,14 @@
   import { SvgIcon } from '/@/components/Icon';
   import { columns, searchFormSchema, productionStatusMap } from './dataQuality.data';
   import { getDataQuaQueList, addDataQuaQue, deleteDataQuaQue, editDataQuaQue } from '../basicInfo.api';
+  import { findNode, findPath, listToTree } from '/@/utils/helper/treeHelper';
+  import { useMineStore } from '/@/store/modules/mine';
   import dayjs from 'dayjs'; 
   import * as XLSX from 'xlsx';
   // 路由实例
   const router = useRouter();
+  // 实例化矿井Store
+  const mineStore = useMineStore();
   // 响应式数据
   const activeKey = ref('unresolved'); // 激活的Tab键
   const pageMode = ref('add');
@@ -232,20 +236,39 @@
     }
   }
   /**
-   * 通用页面跳转方法
-   * @param record 当前行数据
-   * @param path 目标路径
-   */
-  function handleGoToPage(record: any, path: string) {
-    // 跳转时携带当前煤矿的编号作为参数(根据实际需求调整携带的参数)
+ * 通用页面跳转方法
+ * @param record 当前行数据
+ * @param path 目标路径(树形结构所在页面的路由地址)
+ */
+async function handleGoToPage(record: any) {
+  try {
+    const mineCode = record.mineCode;
+    const targetNode = findNode(
+      mineStore.getMineTree,
+      (item) => item.id === mineCode,
+      { id: 'id', pid: 'parentId', children: 'childDepart' }
+    );
+
+    let minePath = '';
+    if (targetNode) {
+      minePath = targetNode.parentId; // 取parentId作为minePath
+      console.log('minePath(当前节点的parentId):', minePath);
+    } else {
+      message.warning(`未找到矿码【${mineCode}】对应的矿井节点`);
+      return;
+    }
+
+    // 跳转页面(可携带拼接后的矿名/路径等参数)
     router.push({
-      path,
-      // query: {
-      //   orderNo: record.orderNo, // 煤矿编号
-      //   mineName: record.mineName // 煤矿名称
-      // }
+      path: `/sealed/${minePath}`,
+      query: {},
     });
+
+  } catch (error) {
+    console.error('矿节点定位失败:', error);
+    message.error('矿节点定位失败,请稍后重试');
   }
+}
 
   /**
    * 气泡取消按钮通用回调