dict.js 717 B

1234567891011121314151617181920212223242526272829303132
  1. export default {
  2. namespaced: true,
  3. state: {},
  4. mutations: {
  5. SET_DICT: (state, data) => {
  6. state[data.dictType] = data.data
  7. },
  8. },
  9. actions: {
  10. getDicts(store, { dictType , customFlag }) {
  11. if (store.rootGetters.ccbModel && customFlag) {
  12. // 建行催收
  13. if (["debt_contact_relation", "debt_phone_type","debt_negotiation_type"].includes(dictType)) {
  14. dictType = dictType + "_ccb";
  15. }
  16. }
  17. return new Promise((resolve) => {
  18. if (store.state[dictType]) {
  19. resolve(store.state[dictType])
  20. } else {
  21. uni.$u.api.getDicts(dictType).then(res => {
  22. store.commit('SET_DICT', {
  23. dictType,
  24. data: res.data
  25. });
  26. resolve(res.data)
  27. })
  28. }
  29. });
  30. },
  31. }
  32. }