import { queryCheckedList, queryVersionByNode } from '@/services/bomAuth'; import { queryClassify } from '@/services/boom'; export default { namespace: 'auth', state: { checkedList: { list: [], pagination: {} }, }, effects: { *queryCheckedList({ payload }, { call, put }) { const responce = yield call(queryCheckedList, payload); if (responce) { let data = responce.data.list; let ret = []; data.forEach(e => { let item = ret.find(item => item.key == `${e.template_id}_${e.project_id}`); if (!item) { item = { key: `${e.template_id}_${e.project_id}`, name: e.name, project_name: e.ding_schema, nodes: [], }; ret.push(item); } item.nodes.push({ template_id: e.template_id, project_id: e.project_id, version_name: e.version_name, node_name: e.TemplateNodeInfo?.label, node_id: e.TemplateNodeInfo?.Id, author: e.AuthorInfo?.CName, classify_id: e.classify_id, id: e.id, }); }); yield put({ type: 'save', payload: { checkedList: { list: ret, pagination: responce.data.pagination } }, }); } }, *queryClassify({ payload, callback }, { call, put }) { const data = yield call(queryClassify, payload); if (data) { yield put({ type: 'save', payload: { typeOptions: data?.map(item => { return { ...item, label: item.name, value: item.id }; }), }, }); } }, *queryVersionByNode({ payload, callback }, { call, put }) { const data = yield call(queryVersionByNode, payload); if (data) { callback && callback(data.data.excel_version_tree); } }, }, reducers: { save(state, action) { return { ...state, ...action.payload, }; }, }, };