Переглянути джерело

[Wip 0000] 通用矿号、采空区编号级联选择器开发

houzekong 4 місяців тому
батько
коміт
3f985d0218
1 змінених файлів з 56 додано та 0 видалено
  1. 56 0
      src/store/modules/mine.ts

+ 56 - 0
src/store/modules/mine.ts

@@ -0,0 +1,56 @@
+import type { ErrorLogInfo } from '/#/store';
+
+import { defineStore } from 'pinia';
+import { store } from '/@/store';
+
+import { flatMap } from 'lodash-es';
+
+import { formatToDateTime } from '/@/utils/dateUtil';
+import projectSetting from '/@/settings/projectSetting';
+
+import { ErrorTypeEnum } from '/@/enums/exceptionEnum';
+import { getEnfMineTree } from '/@/api/sys/menu';
+
+export interface MineState {
+  errorLogInfoList: Nullable<ErrorLogInfo[]>;
+  errorLogListCount: number;
+}
+
+export const useErrorLogStore = defineStore({
+  id: 'mine-store',
+  state: (): MineState => ({
+    defaultCode: null,
+    mineTree: [],
+  }),
+  getters: {
+    getMineTree(): any {
+      return this.mineTree;
+    },
+    getDefaultCode(): any {
+      return this.defaultCode;
+    },
+  },
+  actions: {
+    async fetchMineTree() {
+      const topLevelData = getEnfMineTree().then((r) => {
+        // const transkey =
+        return r.reduce((arr, ele) => {
+          if (ele.childDepart) {
+            arr.push(...ele.childDepart);
+            delete ele.childDepart;
+            arr.push(ele);
+          } else {
+            arr.push(ele);
+          }
+
+          return arr;
+        }, []);
+      });
+    },
+  },
+});
+
+// Need to be used outside the setup
+export function useErrorLogStoreWithOut() {
+  return useErrorLogStore(store);
+}