Kaynağa Gözat

[Fix 0000] 修复了智能分析页面数据不能初始化的问题

houzekong 3 ay önce
ebeveyn
işleme
2ba592948c

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

@@ -1,18 +1,20 @@
 import { ref } from 'vue';
 import { useRoute } from 'vue-router';
 import { getGoafSelectOption } from '/@/views/monitor/sealedMonitor/monitor.api';
+import { first } from 'lodash';
+import { useMineDepartmentStore } from '/@/store/modules/mine';
 
 export function useInitForm() {
-  // const mineStore = useMineDepartmentStore();
+  const mineStore = useMineDepartmentStore();
   const route = useRoute();
   const loading = ref(false);
-  const innerValue = ref<string>((route.query.mineCode as string) || '');
-  // 给历史数据默认填充的矿码
+  // 默认填充的矿码
+  const innerValue = ref<string>((route.query.mineCode as string) || (first(mineStore.getMineCode.split(',')) as string));
 
-  if (innerValue.value) {
-    // mineStore.setDepartById(code as string);
-    initGoafOptions(innerValue);
-  }
+  // if (innerValue.value) {
+  //   // mineStore.setDepartById(code as string);
+  //   initGoafOptions(innerValue);
+  // }
 
   // 采空区选择器
   const goafId = ref('');

+ 13 - 16
src/views/analysis/warningAnalysis/connectAnalysis/index.vue

@@ -74,7 +74,7 @@
 </template>
 
 <script setup lang="ts">
-  import { ref, onMounted, reactive } from 'vue';
+  import { ref, reactive } from 'vue';
   import dayjs from 'dayjs';
   import { Select, SelectOption, Row, Col, DatePicker, Button } from 'ant-design-vue';
   import MineCascader from '@/components/Form/src/jeecg/components/MineCascader/MineCascader.vue';
@@ -83,8 +83,8 @@
   import echartContent from './components/echart-content.vue';
   import echartDivder from './components/echart-divder.vue';
   import { getGoafHistory } from './connectAnalysis.api';
-  import { useRouter } from 'vue-router';
-  import { useMineDepartmentStore } from '/@/store/modules/mine';
+  // import { useRouter } from 'vue-router';
+  // import { useMineDepartmentStore } from '/@/store/modules/mine';
   import { SvgIcon } from '/@/components/Icon';
   import { useInitForm } from './hooks/form';
 
@@ -92,20 +92,25 @@
 
   // 组件注册
   const RangePicker: any = DatePicker.RangePicker;
-  const { currentRoute } = useRouter();
+  // const { currentRoute } = useRouter();
   // 筛选相关响应式数据
   const dateRange = ref([dayjs().add(-30, 'day'), dayjs()]); // 默认时间范围(近1天)
-  const mineStore = useMineDepartmentStore();
+  // const mineStore = useMineDepartmentStore();
   const checkList = ref<any[]>(['coVal', 'ch4Val', 'c2h4Val', 'c2h2Val', 'co2Val', 'o2Val', 'sourcePressure', 'temperature']); //当前选中要进行显示的选项
   const echartData = reactive({
     xData: [] as any,
     yData: [] as any,
+    flag: true,
   });
 
   //煤矿选项切换
   function changeCascader(val) {
     innerValue.value = val;
-    initGoafOptions(val);
+    initGoafOptions(val).then(() => {
+      if (echartData.flag) {
+        generateChart();
+      }
+    });
   }
   //时间选择选项切换
   function changeTime(val) {
@@ -121,6 +126,7 @@
   // 生成折线图核心逻辑
   async function generateChart() {
     echartData.yData.length = 0;
+    echartData.flag = false;
     let startTime = dateRange.value[0].format('YYYY-MM-DD HH:mm:ss');
     let endTime = dateRange.value[1].format('YYYY-MM-DD HH:mm:ss');
     let res = await getGoafHistory({ pageNo: 1, pageSize: 1000, startTime: startTime, endTime: endTime, goafId: goafId.value });
@@ -154,16 +160,7 @@
   //   goafId.value = goafOption.value.length ? (goafId.value ? goafId.value : goafOption.value[0]['value']) : '';
   // }
 
-  onMounted(async () => {
-    const mineCode = currentRoute.value['query']['mineCode']; //传递过来的矿ID
-    if (mineCode) {
-      innerValue.value = mineCode as any;
-    } else {
-      innerValue.value = mineStore.getMineCode.split(',')[0];
-      console.log(innerValue.value, 'innerValue.value');
-      await generateChart();
-    }
-  });
+  generateChart();
 </script>
 
 <style lang="less" scoped>