Просмотр исходного кода

[Feat 0000] 密闭监测页面历史数据部分设置默认表单值

houzekong 4 месяцев назад
Родитель
Сommit
c4b80806ed

+ 9 - 5
src/views/monitor/sealedMonitor/hooks/form.ts

@@ -1,4 +1,4 @@
-import { last } from 'lodash';
+import { first, get, last } from 'lodash';
 import { ref } from 'vue';
 import { useRoute } from 'vue-router';
 import { getGoafSelectOption } from '../monitor.api';
@@ -8,11 +8,14 @@ export function useInitForm() {
   const mineStore = useMineDepartmentStore();
   const route = useRoute();
   const departId = last(route.fullPath.split('/'));
-  const code = route.params.mineCode;
+  const dep = mineStore.findDepartById(departId, mineStore.departTree);
+  const code = route.params.mineCode as string;
+  // 给历史数据默认填充的矿码
+  const historyMineCode = !code ? first(get(dep, 'id', '').split(',')) : code;
 
-  if (code) {
-    mineStore.setDepartById(code as string);
-    initGoafOptions(code);
+  if (historyMineCode) {
+    // mineStore.setDepartById(code as string);
+    initGoafOptions(historyMineCode);
   }
 
   // 采空区选择器
@@ -30,6 +33,7 @@ export function useInitForm() {
     departId,
     goafOptions,
     goafId,
+    historyMineCode,
     initGoafOptions,
   };
 }

+ 6 - 1
src/views/monitor/sealedMonitor/index.vue

@@ -56,7 +56,7 @@
   // 激活的Tab页签
 
   // 处理矿名选择器相关的逻辑
-  const { departId, goafOptions, goafId, initGoafOptions } = useInitForm();
+  const { departId, goafOptions, goafId, historyMineCode, initGoafOptions } = useInitForm();
   const activeTab = ref('realtime');
 
   // 注册实时数据表格
@@ -72,6 +72,7 @@
             component: 'MineCascader',
             colProps: { span: 6 },
             componentProps: {
+              initFromStore: false,
               syncToStore: false,
               rootId: departId,
             },
@@ -102,6 +103,9 @@
       },
       columns: historicalColumns,
       formConfig: {
+        model: {
+          mineCodeList: historyMineCode,
+        },
         schemas: [
           {
             field: 'mineCodeList',
@@ -110,6 +114,7 @@
             colProps: { span: 6 },
             required: true,
             componentProps: {
+              initFromStore: false,
               syncToStore: false,
               rootId: departId,
               onChange(v) {