瀏覽代碼

Merge branch 'master' of http://182.92.126.35:3000/hrx/mky-vent-base

lxh 11 小時之前
父節點
當前提交
b45ba1e8af

+ 64 - 5
src/views/vent/internalManager/index.vue

@@ -35,14 +35,16 @@
 <script setup lang="ts">
   import { Select, message } from 'ant-design-vue';
   import { ref, reactive, onMounted } from 'vue';
+  import { BasicColumn } from '/@/components/Table';
   import { getDictItemsByCode } from '/@/utils/dict';
   import { deleteById, getList, autoLinkReg } from './internalManager.api';
-  import { columnsMap } from './internalManager.data';
+  // import { columnsMap } from './internalManager.data';
   import proceduresModal from './procedures-modal.vue';
 
   const dataSource = ref<any[]>([]);
   const deviceKind = ref<string>('');
   const deviceKindOption = ref([]);
+  const regTypeOption = ref([]);
   //分页参数配置
   const pagination = reactive({
     current: 1, // 当前页码
@@ -60,10 +62,62 @@
     regName: '',
     regType: '',
     deviceKind: '',
+    dataId: '',
     monitorDataName: '',
     regRoute: '',
   });
-
+  const columnsMap: BasicColumn[] = [
+    {
+      title: '序号',
+      width: 60,
+      align: 'center',
+      customRender: ({ index }: { index: number }) => `${index + 1}`,
+    },
+    {
+      title: '规程名称',
+      dataIndex: 'regName',
+      align: 'center',
+    },
+    {
+      title: '规程类型',
+      dataIndex: 'regType',
+      align: 'center',
+      // 新增:通过规程类型字典映射中文
+      customRender: ({ text }) => {
+        // 从规程类型字典中找到匹配的中文label
+        const matchItem = regTypeOption.value.find((item) => item.value === text);
+        return matchItem ? matchItem.label : text; // 未匹配到则显示原字段
+      },
+    },
+    {
+      title: '设备种类',
+      dataIndex: 'deviceKind',
+      align: 'center',
+      // 新增:通过设备种类字典映射中文
+      customRender: ({ text }) => {
+        // 从设备种类字典中找到匹配的中文label
+        const matchItem = deviceKindOption.value.find((item) => item.value === text);
+        return matchItem ? matchItem.label : text; // 未匹配到则显示原字段
+      },
+    },
+    {
+      title: '关联监测数据名称',
+      dataIndex: 'monitorDataName',
+      align: 'center',
+    },
+    {
+      title: '规则路由',
+      dataIndex: 'regRoute',
+      align: 'center',
+    },
+    {
+      title: '操作',
+      dataIndex: 'action',
+      width: 200,
+      align: 'center',
+      slots: { customRender: 'action' },
+    },
+  ];
   //关闭弹窗
   function handleClose() {
     visibleMap.value = false;
@@ -79,6 +133,7 @@
       regName: '',
       regType: '',
       deviceKind: '',
+      dataId: '',
       monitorDataName: '',
       regRoute: '',
     });
@@ -94,6 +149,7 @@
       regName: record.regName,
       regType: record.regType,
       deviceKind: record.deviceKind,
+      dataId: record.dataId,
       monitorDataName: record.monitorDataName,
       regRoute: record.regRoute,
     });
@@ -148,9 +204,12 @@
     }
   }
   onMounted(() => {
-    let dictName = 'devicekind';
-    const res = getDictItemsByCode(dictName);
-    deviceKindOption.value = res;
+    const deviceKindRes = getDictItemsByCode('devicekind');
+    deviceKindOption.value = deviceKindRes;
+    console.log('deviceKindOption', deviceKindOption.value);
+    const regTypeRes = getDictItemsByCode('regType');
+    regTypeOption.value = regTypeRes;
+    console.log('regTypeOption', regTypeOption.value);
     getListMap();
   });
 </script>

+ 7 - 0
src/views/vent/internalManager/internalManager.api.ts

@@ -9,6 +9,7 @@ enum Api {
   getList = '/ventanaly-device/safety/rdl/list',
   queryById = '/ventanaly-device/safety/rdl/queryById',
   autoLinkReg = '/ventanaly-device/safety/rdl/autoMonitorLinkReg',
+  getRegDataList = '/modelreq/safety/ventanalyShowColum/list',
 }
 /**
  * 新增规程关联表
@@ -64,3 +65,9 @@ export const queryById = (params) => defHttp.get({ headers: { 'Content-Type': 'a
  * @param params
  */
 export const autoLinkReg = (params) => defHttp.post({ url: Api.autoLinkReg, params });
+
+/**
+ * 获取设备类型及页面类型下数据
+ * @param params
+ */
+export const getRegDataList = (params) => defHttp.get({ url: Api.getRegDataList, params });

+ 82 - 7
src/views/vent/internalManager/procedures-modal.vue

@@ -5,13 +5,29 @@
         <a-input v-model:value="formStates.regName" placeholder="请输入规程名称" />
       </a-form-item>
       <a-form-item label="规程类型:">
-        <a-input v-model:value="formStates.regType" placeholder="请输入规程类型" />
+        <a-select
+          v-model:value="formStates.regType"
+          placeholder="请选择规程类型"
+          :options="regTypeOption"
+          :fieldNames="{ label: 'label', value: 'value' }"
+        />
       </a-form-item>
       <a-form-item label="设备种类:">
-        <a-input v-model:value="formStates.deviceKind" placeholder="请输入设备种类" />
+        <a-select
+          v-model:value="formStates.deviceKind"
+          placeholder="请选择设备种类"
+          :options="deviceKindOption"
+          :fieldNames="{ label: 'label', value: 'value' }"
+        />
       </a-form-item>
       <a-form-item label="关联监测数据名称:">
-        <a-input v-model:value="formStates.monitorDataName" placeholder="请输入关联监测数据名称" />
+        <a-select
+          v-model:value="formStates.dataId"
+          placeholder="请选择关联监测数据名称"
+          :options="monitorDataOptions"
+          :fieldNames="{ label: 'des', value: 'id' }"
+          :disabled="!formStates.deviceKind"
+        />
       </a-form-item>
       <a-form-item label="规则路由:">
         <a-input v-model:value="formStates.regRoute" placeholder="请输入规则路由" />
@@ -26,7 +42,8 @@
 
 <script setup lang="ts">
   import { ref, reactive, onMounted, watch } from 'vue';
-  import { addList, editList } from './internalManager.api';
+  import { addList, editList, getRegDataList } from './internalManager.api';
+  import { getDictItemsByCode } from '/@/utils/dict';
 
   let props = defineProps({
     formState: {
@@ -46,20 +63,60 @@
     regName: '',
     regType: '',
     deviceKind: '',
+    dataId: '',
     monitorDataName: '',
     regRoute: '',
   });
+
+  // 下拉选项
+  const deviceKindOption = ref([]); // 设备类型选项
+  const regTypeOption = ref([]); // 规程类型选项
+  const monitorDataOptions = ref([]); // 关联监测数据名称选项
+
   let emit = defineEmits<{
     (e: 'close'): void;
   }>();
 
+  // 获取关联监测数据名称选项
+  const fetchMonitorDataOptions = async () => {
+    if (!formStates.deviceKind) return;
+
+    try {
+      // 调用接口获取关联监测数据
+      const res = await getRegDataList({
+        pagetype: 'left',
+        pageSize: 500,
+        deviceKind: formStates.deviceKind,
+      });
+      monitorDataOptions.value = res.records;
+    } catch (error) {
+      console.error('获取关联监测数据失败:', error);
+      monitorDataOptions.value = [];
+    }
+  };
+
+  // 监听设备种类变化,获取关联监测数据
+  watch(
+    () => formStates.deviceKind,
+    async ([newDeviceKind], [oldDeviceKind]) => {
+      // 只有当两个值都存在时才请求
+      if (newDeviceKind) {
+        await fetchMonitorDataOptions();
+      } else if (newDeviceKind !== oldDeviceKind) {
+        // 当任一值清空时,重置关联监测数据
+        monitorDataOptions.value = [];
+        formStates.monitorDataName = '';
+      }
+    }
+  );
+
   async function getConfirm() {
     const params = {
       id: formStates.id,
       regName: formStates.regName,
       regType: formStates.regType,
       deviceKind: formStates.deviceKind,
-      monitorDataName: formStates.monitorDataName,
+      dataId: formStates.dataId,
       regRoute: formStates.regRoute,
     };
     if (props.isToggle == 'add') {
@@ -69,21 +126,39 @@
     }
     emit('close');
   }
+
   function getCancel() {
     emit('close');
   }
+
   // 监听formState变化,同步到表单
   watch(
     () => props.formState,
-    (newVal) => {
+    async (newVal) => {
       if (newVal) {
         Object.assign(formStates, newVal);
+        // 当编辑时,同步获取关联监测数据
+        if (formStates.deviceKind) {
+          await fetchMonitorDataOptions();
+        }
       }
     },
     { immediate: true }
   );
 
-  onMounted(() => {});
+  onMounted(async () => {
+    // 获取设备类型字典
+    const deviceRes = getDictItemsByCode('devicekind');
+    deviceKindOption.value = deviceRes;
+    // 获取规程类型字典
+    const regRes = getDictItemsByCode('regType');
+    regTypeOption.value = regRes;
+
+    // 如果有初始值,获取关联监测数据
+    if (formStates.deviceKind) {
+      await fetchMonitorDataOptions();
+    }
+  });
 </script>
 
 <style lang="less" scoped>

+ 2 - 1
src/views/vent/performance/fileDetail/commen/treeList.vue

@@ -114,7 +114,8 @@
   // 是否拖拽文件
   const isDragFile = ref(false);
   // 是否展开
-  const expanded = ref(true);
+  // const expanded = ref(true);
+  const expanded = ref(!props.model.pid || props.model.pid === 'root'); // 默认只展开一级菜单
   // inputRef
   const nodeInput = ref(null);
   // 是否是文件夹