Browse Source

1.字典逻辑修改。

jiaxiaoqiang 11 months ago
parent
commit
83fccb1a34
2 changed files with 10 additions and 13 deletions
  1. 7 1
      src/plugins/permission.ts
  2. 3 12
      src/store/modules/dictionary.ts

+ 7 - 1
src/plugins/permission.ts

@@ -4,6 +4,7 @@ import { usePermissionStore } from "@/store/modules/permission";
 import { useDictionaryStore } from "@/store/modules/dictionary";
 import { useDictionaryStore } from "@/store/modules/dictionary";
 
 
 import NProgress from "@/utils/nprogress";
 import NProgress from "@/utils/nprogress";
+import { getUserDicts } from "@/api/auth";
 
 
 export function setupPermission() {
 export function setupPermission() {
   // 白名单路由
   // 白名单路由
@@ -19,7 +20,12 @@ export function setupPermission() {
         NProgress.done();
         NProgress.done();
       } else {
       } else {
         const dictStore = useDictionaryStore();
         const dictStore = useDictionaryStore();
-        dictStore.checkDicts();
+        if (JSON.stringify(dictStore.dicts.value) === "{}") {
+          const res = await getUserDicts(dictStore.types);
+          if (res.data) {
+            dictStore.dicts.value = res?.data ?? [];
+          }
+        }
 
 
         const userStore = useUserStore();
         const userStore = useUserStore();
         // const hasRoles =
         // const hasRoles =

+ 3 - 12
src/store/modules/dictionary.ts

@@ -24,26 +24,17 @@ export const useDictionaryStore = defineStore("dictionaryStore", () => {
     "skill_type",
     "skill_type",
     "drawing_type",
     "drawing_type",
     "vehicle_level",
     "vehicle_level",
-	  "fault_current_state",
+    "fault_current_state",
     "escalation_fault_state",
     "escalation_fault_state",
     "defect_mana",
     "defect_mana",
     "disposal_measures_type",
     "disposal_measures_type",
-	"process_check_result",  ];
+    "process_check_result",
+  ];
   const dicts = ref<{ [key: string]: any[] }>({});
   const dicts = ref<{ [key: string]: any[] }>({});
-  function checkDicts() {
-    if (JSON.stringify(dicts.value) === "{}") {
-      getUserDicts(types).then((res) => {
-        if (res.data) {
-          dicts.value = res?.data ?? [];
-        }
-      });
-    }
-  }
 
 
   return {
   return {
     types,
     types,
     dicts,
     dicts,
-    checkDicts,
   };
   };
 });
 });