authList.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { queryAuthList } from '@/services/bomAuth';
  2. export default {
  3. namespace: 'authList',
  4. state: {
  5. authList: [],
  6. authVersionList: [],
  7. },
  8. effects: {
  9. *queryAuthList({ payload }, { call, put }) {
  10. const responce = yield call(queryAuthList, payload);
  11. if (responce) {
  12. let data = responce.data;
  13. let ret = [];
  14. data.forEach(e => {
  15. let item = ret.find(item => item.key == `${e.template_id}_${e.project_id}`);
  16. if (!item) {
  17. item = {
  18. key: `${e.template_id}_${e.project_id}`,
  19. name: e.name,
  20. project_name: e.ding_schema,
  21. nodes: [],
  22. };
  23. ret.push(item);
  24. }
  25. item.nodes.push({
  26. template_id: e.template_id,
  27. project_id: e.project_id,
  28. version_name: e.version_name,
  29. node_name: e.TemplateNodeInfo?.label,
  30. node_id: e.TemplateNodeInfo?.Id,
  31. author: e.AuthorInfo?.CName,
  32. classify_id: e.classify_id,
  33. version_id: e.version_id,
  34. id: e.id,
  35. type: 'auth',
  36. });
  37. });
  38. yield put({
  39. type: 'save',
  40. payload: { authList: ret, authVersionList: data },
  41. });
  42. }
  43. },
  44. },
  45. reducers: {
  46. save(state, action) {
  47. return {
  48. ...state,
  49. ...action.payload,
  50. };
  51. },
  52. },
  53. };