瀏覽代碼

[Pref 0000] 优化各个页面的历史数据请求逻辑

houzekong 1 月之前
父節點
當前提交
462a28f30f

+ 1 - 1
src/components/Table/src/props.ts

@@ -55,7 +55,7 @@ export const basicProps = {
     },
   },
   // 立即请求接口
-  immediate: propTypes.bool.def(true),
+  immediate: propTypes.bool.def(false),
   emptyDataIsShowTable: propTypes.bool.def(true),
   // 额外的请求参数
   searchInfo: {

+ 1 - 1
src/views/analysis/common/analysis.ts

@@ -24,7 +24,7 @@ export function useInitForm(ctx?: TableActionType) {
   function initGoafOptions(deptId) {
     return getGoafSelectOption({ deptId }).then(({ options, defaultValue }) => {
       goafOptions.value = options;
-      if (options.some((e) => e.id === goafId.value)) return;
+      if (options.some((e) => e.value === goafId.value)) return;
       goafId.value = defaultValue;
     });
   }

+ 10 - 9
src/views/analysis/warningAnalysis/airLeakStatus/index.vue

@@ -45,7 +45,7 @@
           <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
         </template>
         <template #form-goaf-select>
-          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="historyTable.reload" />
         </template>
       </BasicTable>
     </TabPane>
@@ -132,8 +132,9 @@
     tableProps: {
       columns,
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(params.deptId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getProvinceAlarmHistory(params);
@@ -173,15 +174,15 @@
             field: 'deptId',
             component: 'MineCascader', // 自定义组件名
             componentProps: {
-              initFromStore: true,
+              initFromStore: false,
               syncToStore: false,
               changeOnSelect: false,
-              onChange: (e) => {
-                historyTable.setLoading(true);
-                initGoafOptions(e).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange: (e) => {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(e).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
             colProps: { span: 6 },
             rules: [],

+ 10 - 9
src/views/analysis/warningAnalysis/autoFireAnalysis/index.vue

@@ -48,7 +48,7 @@
             <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
           </template>
           <template #form-goaf-select>
-            <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+            <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="historyTable.reload" />
           </template>
         </BasicTable>
       </TabPane>
@@ -155,8 +155,9 @@
       columns,
       // columns: historyColumns,
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(params.deptId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getProvinceAlarmHistory(params);
@@ -196,15 +197,15 @@
             field: 'deptId',
             component: 'MineCascader', // 自定义组件名
             componentProps: {
-              initFromStore: true,
+              initFromStore: false,
               syncToStore: false,
               changeOnSelect: false,
-              onChange: (e) => {
-                historyTable.setLoading(true);
-                initGoafOptions(e).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange: (e) => {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(e).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
             colProps: { span: 6 },
             rules: [],

+ 10 - 9
src/views/analysis/warningAnalysis/autoFireOutAnalysis/index.vue

@@ -48,7 +48,7 @@
             <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
           </template>
           <template #form-goaf-select>
-            <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+            <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="historyTable.reload" />
           </template>
         </BasicTable>
       </TabPane>
@@ -155,8 +155,9 @@
       columns,
       // columns: historyColumns,
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(params.deptId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getProvinceAlarmHistory(params);
@@ -196,15 +197,15 @@
             field: 'deptId',
             component: 'MineCascader', // 自定义组件名
             componentProps: {
-              initFromStore: true,
+              initFromStore: false,
               syncToStore: false,
               changeOnSelect: false,
-              onChange: (e) => {
-                historyTable.setLoading(true);
-                initGoafOptions(e).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange: (e) => {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(e).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
             colProps: { span: 6 },
             rules: [],

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

@@ -38,7 +38,7 @@ export function useInitForm({ unlink }: { unlink?: boolean } = {}) {
       .then(({ options, defaultValue }) => {
         goafOptions.value = options;
         if (unlink) return;
-        if (options.some((e) => e.id === goafId.value)) return;
+        if (options.some((e) => e.value === goafId.value)) return;
 
         goafId.value = defaultValue;
       })

+ 10 - 9
src/views/analysis/warningAnalysis/fireAreaJudgeAnalysis/index.vue

@@ -47,7 +47,7 @@
           <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
         </template>
         <template #form-goaf-select>
-          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="historyTable.reload" />
         </template>
       </BasicTable>
     </TabPane>
@@ -146,8 +146,9 @@
       columns,
       // columns: historyColumns,
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(params.deptId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getProvinceAlarmHistory(params);
@@ -187,15 +188,15 @@
             field: 'deptId',
             component: 'MineCascader', // 自定义组件名
             componentProps: {
-              initFromStore: true,
+              initFromStore: false,
               syncToStore: false,
               changeOnSelect: false,
-              onChange: (e) => {
-                historyTable.setLoading(true);
-                initGoafOptions(e).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange: (e) => {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(e).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
             colProps: { span: 6 },
             rules: [],

+ 10 - 9
src/views/analysis/warningAnalysis/overlimitAlarm/index.vue

@@ -47,7 +47,7 @@
           <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
         </template>
         <template #form-goaf-select>
-          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="historyTable.reload" />
         </template>
       </BasicTable>
     </TabPane>
@@ -149,8 +149,9 @@
       columns,
       // columns: historyColumns,
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(params.deptId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getProvinceAlarmHistory(params);
@@ -190,15 +191,15 @@
             field: 'deptId',
             component: 'MineCascader', // 自定义组件名
             componentProps: {
-              initFromStore: true,
+              initFromStore: false,
               syncToStore: false,
               changeOnSelect: false,
-              onChange: (e) => {
-                historyTable.setLoading(true);
-                initGoafOptions(e).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange: (e) => {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(e).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
             colProps: { span: 6 },
             rules: [],

+ 10 - 9
src/views/analysis/warningAnalysis/overlimitAlarmOut/index.vue

@@ -47,7 +47,7 @@
           <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
         </template>
         <template #form-goaf-select>
-          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="historyTable.reload" />
         </template>
       </BasicTable>
     </TabPane>
@@ -146,8 +146,9 @@
       columns,
       // columns: historyColumns,
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(params.deptId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getProvinceAlarmHistory(params);
@@ -187,15 +188,15 @@
             field: 'deptId',
             component: 'MineCascader', // 自定义组件名
             componentProps: {
-              initFromStore: true,
+              initFromStore: false,
               syncToStore: false,
               changeOnSelect: false,
-              onChange: (e) => {
-                historyTable.setLoading(true);
-                initGoafOptions(e).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange: (e) => {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(e).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
             colProps: { span: 6 },
             rules: [],

+ 10 - 9
src/views/analysis/warningAnalysis/pressureDiffAnalysis/index.vue

@@ -51,7 +51,7 @@
           <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
         </template>
         <template #form-goaf-select>
-          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="historyTable.reload" />
         </template>
       </BasicTable>
     </TabPane>
@@ -169,8 +169,9 @@
       columns,
       // columns: historyColumns,
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(params.deptId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getProvinceAlarmHistory(params);
@@ -210,15 +211,15 @@
             field: 'deptId',
             component: 'MineCascader', // 自定义组件名
             componentProps: {
-              initFromStore: true,
+              initFromStore: false,
               syncToStore: false,
               changeOnSelect: false,
-              onChange: (e) => {
-                historyTable.setLoading(true);
-                initGoafOptions(e).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange: (e) => {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(e).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
             colProps: { span: 6 },
             rules: [],

+ 10 - 9
src/views/analysis/warningAnalysis/sealRiskJudgeAnalysis/index.vue

@@ -48,7 +48,7 @@
           <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
         </template>
         <template #form-goaf-select>
-          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="historyTable.reload" />
         </template>
       </BasicTable>
     </TabPane>
@@ -145,8 +145,9 @@
       columns,
       // columns: historyColumns,
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(params.deptId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getProvinceAlarmHistory(params);
@@ -186,15 +187,15 @@
             field: 'deptId',
             component: 'MineCascader', // 自定义组件名
             componentProps: {
-              initFromStore: true,
+              initFromStore: false,
               syncToStore: false,
               changeOnSelect: false,
-              onChange: (e) => {
-                historyTable.setLoading(true);
-                initGoafOptions(e).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange: (e) => {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(e).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
             colProps: { span: 6 },
             rules: [],

+ 4 - 6
src/views/dashboard/basicInfo/accessStatistics/index.vue

@@ -20,7 +20,8 @@
   import { useMineDepartmentStore } from '/@/store/modules/mine';
   import { advancedRoutePush } from '/@/utils';
 
-  const deptId = ref();
+  const mineStore = useMineDepartmentStore();
+  const deptId = ref(mineStore.getDepartId);
 
   // 封装接口调用,获取数据后手动添加「总计」行
   const fetchTableData = async (params: any) => {
@@ -95,6 +96,7 @@
       slots: { customRender: 'action' },
     },
     scroll: { x: 'max-content' },
+    immediate: true,
   });
 
   /**
@@ -109,15 +111,11 @@
     });
   }
 
-  const mineStore = useMineDepartmentStore();
   watch(
     () => mineStore.getDepartId,
     (v) => {
-      deptId.value = v || mineStore.getRootId;
+      deptId.value = v;
       reload();
-    },
-    {
-      immediate: true,
     }
   );
 </script>

+ 2 - 4
src/views/dashboard/basicInfo/closedStatistics/index.vue

@@ -22,7 +22,7 @@
 
   // 路由实例
   const mineStore = useMineDepartmentStore();
-  const deptId = ref();
+  const deptId = ref(mineStore.getDepartId);
 
   // 注册表格并获取相关方法
   const [registerTable, { reload, setLoading }] = useTable({
@@ -46,6 +46,7 @@
       dataIndex: 'action',
       slots: { customRender: 'action' },
     },
+    immediate: true,
   });
 
   /**
@@ -69,9 +70,6 @@
     (v) => {
       deptId.value = v || mineStore.getRootId;
       reload();
-    },
-    {
-      immediate: true,
     }
   );
 </script>

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

@@ -29,7 +29,7 @@ export function useInitForm() {
   function initGoafOptions(deptId) {
     return getGoafSelectOption({ deptId }).then(({ options, defaultValue }) => {
       goafOptions.value = options;
-      if (options.some((e) => e.id === goafId.value)) return;
+      if (options.some((e) => e.value === goafId.value)) return;
       goafId.value = defaultValue;
     });
   }

+ 10 - 9
src/views/monitor/sealedMonitor/index.vue

@@ -28,7 +28,7 @@
           <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 导出 </a-button>
         </template>
         <template #form-goaf-select>
-          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" />
+          <a-select v-model:value="goafId" :options="goafOptions" placeholder="请选择" @change="reloadHistory" />
         </template>
         <template #action="{ record }">
           <div class="action-buttons">
@@ -120,8 +120,9 @@
   const { tableContext: ctxHistory, onExportXls } = useListPage({
     tableProps: {
       api: async (params) => {
+        await initGoafOptions(params.deptId);
         if (!goafId.value) {
-          await initGoafOptions(departId);
+          return Promise.resolve([]);
         }
         params.goafId = goafId.value;
         return getGoafHistory(params);
@@ -142,12 +143,12 @@
               initFromStore: false,
               syncToStore: false,
               rootId: departId,
-              onChange(v) {
-                historyTable.setLoading(true);
-                initGoafOptions(v).finally(() => {
-                  historyTable.setLoading(false);
-                });
-              },
+              // onChange(v) {
+              //   historyTable.setLoading(true);
+              //   initGoafOptions(v).finally(() => {
+              //     historyTable.setLoading(false);
+              //   });
+              // },
             },
           },
           ...historicalFormSchema,
@@ -169,7 +170,7 @@
     },
     pagination: true,
   });
-  const [registerHistoryTable, historyTable] = ctxHistory;
+  const [registerHistoryTable, { reload: reloadHistory }] = ctxHistory;
 
   // 弹窗引用
   const [registerRealtimeModal, { openModal: openRealtimeModal }] = useModal();