管理系统PC前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dm-manage-web/src/store/modules/dict.js

51 lines
870 B

2 years ago
const state = {
2 years ago
dict: []
};
2 years ago
const mutations = {
SET_DICT: (state, { key, value }) => {
2 years ago
if (key !== null && key !== '') {
2 years ago
state.dict.push({
key: key,
value: value
2 years ago
});
2 years ago
}
},
REMOVE_DICT: (state, key) => {
try {
for (let i = 0; i < state.dict.length; i++) {
2 years ago
if (state.dict[i].key === key) {
state.dict.splice(i, i);
return true;
2 years ago
}
}
} catch (e) {
2 years ago
console.log(e);
2 years ago
}
},
CLEAN_DICT: (state) => {
2 years ago
state.dict = [];
2 years ago
}
2 years ago
};
2 years ago
const actions = {
// 设置字典
setDict({ commit }, data) {
2 years ago
commit('SET_DICT', data);
2 years ago
},
// 删除字典
removeDict({ commit }, key) {
2 years ago
commit('REMOVE_DICT', key);
2 years ago
},
// 清空字典
cleanDict({ commit }) {
2 years ago
commit('CLEAN_DICT');
2 years ago
}
2 years ago
};
2 years ago
export default {
namespaced: true,
state,
mutations,
actions
2 years ago
};