lucw 8 месяцев назад
Родитель
Сommit
9d9d5516e1
1 измененных файлов с 10 добавлено и 4 удалено
  1. 10 4
      src/store/modules/dict.js

+ 10 - 4
src/store/modules/dict.js

@@ -21,6 +21,12 @@ const mutations = {
   //根据字典code 添加字典
   //根据字典code 添加字典
   ADD_DICT: (state, { code, dict }) => {
   ADD_DICT: (state, { code, dict }) => {
     Vue.set(state, code, dict);
     Vue.set(state, code, dict);
+  },
+  dictLoadingAdd: (state, code) => {
+    state.dictLoading.push(code);
+  },
+  dictLoadingRemove: (state, code) => {
+    state.dictLoading = state.dictLoading.filter((item) => item !== code);
   }
   }
 };
 };
 
 
@@ -31,7 +37,7 @@ const actions = {
     // 如果字典正在加载中,则不重复请求
     // 如果字典正在加载中,则不重复请求
     if (state.dictLoading.includes(code)) return;
     if (state.dictLoading.includes(code)) return;
 
 
-    state.dictLoading.push(code);
+    commit('dictLoadingAdd', code);
 
 
     if (state[code]?.length) return state[code];
     if (state[code]?.length) return state[code];
 
 
@@ -50,14 +56,14 @@ const actions = {
             };
             };
           })
           })
         });
         });
-        state.dictLoading = state.dictLoading.filter((item) => item !== code);
+        commit('dictLoadingRemove', code);
         return res.data;
         return res.data;
       }
       }
 
 
-      state.dictLoading = state.dictLoading.filter((item) => item !== code);
+      commit('dictLoadingRemove', code);
       return [];
       return [];
     } catch (error) {
     } catch (error) {
-      state.dictLoading = state.dictLoading.filter((item) => item !== code);
+      commit('dictLoadingRemove', code);
       return [];
       return [];
     }
     }
   },
   },