dict.js 805 B

1234567891011121314151617181920212223242526272829303132333435
  1. import {getStore, setStore} from '@/util/store'
  2. import {getDictionary} from '@/api/system/dict'
  3. const dict = {
  4. state: {
  5. flowRoutes: getStore({name: 'flowRoutes'}) || {},
  6. },
  7. actions: {
  8. FlowRoutes({commit}) {
  9. return new Promise((resolve, reject) => {
  10. getDictionary({code: 'flow'}).then(res => {
  11. commit('SET_FLOW_ROUTES', res.data.data);
  12. resolve();
  13. }).catch(error => {
  14. reject(error)
  15. })
  16. })
  17. },
  18. },
  19. mutations: {
  20. SET_FLOW_ROUTES: (state, data) => {
  21. state.flowRoutes = data.map(item => {
  22. return {
  23. routeKey: `${item.code}_${item.dictKey}`,
  24. routeValue: item.remark,
  25. };
  26. });
  27. setStore({name: 'flowRoutes', content: state.flowRoutes})
  28. },
  29. }
  30. };
  31. export default dict;