|
|
@@ -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);
|
|
|
+}
|