12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- import {
- reqDictionary
- } from "@/request/api.js";
- import cloneDeep from 'lodash/cloneDeep'
- const stateReset = {
- dictionaryInfo: {},
- };
- const state = cloneDeep(stateReset);
- const getters = {};
- const mutations = {
-
- resetVxDictionary(state) {
- Object.assign(state, cloneDeep(stateReset))
- },
-
- vxDictionary(state, args) {
- state.dictionaryInfo[args.key] = args.data;
- },
- };
- const actions = {
-
- async vxDictionary({
- commit,
- state
- }, args) {
- if (state.dictionaryInfo[args.key]) {
-
- return await Promise.resolve(state.dictionaryInfo[args.key]);
- } else {
- let result = await reqDictionary(args);
- commit("vxDictionary", {
- key: args.key,
- data: result
- });
- return result;
- }
- },
- };
- export default {
- namespaced: true,
- state,
- getters,
- mutations,
- actions,
- };
|