auth.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { queryCheckedList, queryVersionByNode } from '@/services/bomAuth';
  2. import { queryClassify } from '@/services/boom';
  3. export default {
  4. namespace: 'auth',
  5. state: {
  6. checkedList: { list: [], pagination: {} },
  7. },
  8. effects: {
  9. *queryCheckedList({ payload }, { call, put }) {
  10. const responce = yield call(queryCheckedList, payload);
  11. if (responce) {
  12. let data = responce.data.list;
  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. id: e.id,
  34. });
  35. });
  36. yield put({
  37. type: 'save',
  38. payload: { checkedList: { list: ret, pagination: responce.data.pagination } },
  39. });
  40. }
  41. },
  42. *queryClassify({ payload, callback }, { call, put }) {
  43. const data = yield call(queryClassify, payload);
  44. if (data) {
  45. yield put({
  46. type: 'save',
  47. payload: {
  48. typeOptions: data?.map(item => {
  49. return { ...item, label: item.name, value: item.id };
  50. }),
  51. },
  52. });
  53. }
  54. },
  55. *queryVersionByNode({ payload, callback }, { call, put }) {
  56. const data = yield call(queryVersionByNode, payload);
  57. if (data) {
  58. callback && callback(data.data.excel_version_tree);
  59. }
  60. },
  61. },
  62. reducers: {
  63. save(state, action) {
  64. return {
  65. ...state,
  66. ...action.payload,
  67. };
  68. },
  69. },
  70. };