diff --git a/ruoyi-ui/src/store/modules/dict.js b/ruoyi-ui/src/store/modules/dict.js index f48df4228105903ede6182b7383aedf35ca19a60..9ad054668caf6e39677e56d2420e8f345c5c394b 100644 --- a/ruoyi-ui/src/store/modules/dict.js +++ b/ruoyi-ui/src/store/modules/dict.js @@ -1,50 +1,51 @@ -const state = { - dict: new Array() -} -const mutations = { - SET_DICT: (state, { key, value }) => { - if (key !== null && key !== "") { - state.dict.push({ - key: key, - value: value - }) - } - }, - REMOVE_DICT: (state, key) => { - try { - for (let i = 0; i < state.dict.length; i++) { - if (state.dict[i].key == key) { - state.dict.splice(i, i) - return true - } - } - } catch (e) { - } - }, - CLEAN_DICT: (state) => { - state.dict = new Array() - } -} - -const actions = { - // 设置字典 - setDict({ commit }, data) { - commit('SET_DICT', data) - }, - // 删除字典 - removeDict({ commit }, key) { - commit('REMOVE_DICT', key) - }, - // 清空字典 - cleanDict({ commit }) { - commit('CLEAN_DICT') - } -} - -export default { - namespaced: true, - state, - mutations, - actions -} - +const state = { + dict: new Array() +} +const mutations = { + SET_DICT: (state, { key, value }) => { + if (key !== null && key !== "") { + state.dict.push({ + key: key, + value: value + }) + } + }, + REMOVE_DICT: (state, key) => { + try { + for (let i = 0; i < state.dict.length; i++) { + if (state.dict[i].key == key) { + //修复bug:修改数据字典后,此处可能误删已经通过Vuex缓存的其它字典数据 + state.dict.splice(i, 1) + return true + } + } + } catch (e) { + } + }, + CLEAN_DICT: (state) => { + state.dict = new Array() + } +} + +const actions = { + // 设置字典 + setDict({ commit }, data) { + commit('SET_DICT', data) + }, + // 删除字典 + removeDict({ commit }, key) { + commit('REMOVE_DICT', key) + }, + // 清空字典 + cleanDict({ commit }) { + commit('CLEAN_DICT') + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} +