audit-operate-tree-service.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import axios from '@/common/services/axios-instance'
  2. class AuditOperateTreeService {
  3. // 获取年度树
  4. getYearTree(account) {
  5. return axios({
  6. url: 'api/xcoa-mobile/v1/iam-work-paper/projectTree',
  7. method: 'get',
  8. }).then((res) => {
  9. res.data.forEach((item) => {
  10. item.id = item.planId + item.year
  11. item.text = item.year
  12. item.isLeaf = false
  13. item.props = { ORG_ID: item.id, BELONGED_ORG_ID: -1 }
  14. var child = []
  15. item.projectList.forEach((o) => {
  16. var obj = {
  17. id: o.projectId,
  18. text: o.projectName,
  19. leaf: false,
  20. props: { ORG_ID: item.id, BELONGED_ORG_ID: -1, projectId: o.projectId },
  21. children: [],
  22. key: Number(o.projectId),
  23. }
  24. child.push(obj)
  25. })
  26. item.children = child
  27. item.key = Number(item.planId)
  28. })
  29. res.data.sort(function(a, b) {
  30. return a.year - b.year
  31. })
  32. return res
  33. })
  34. }
  35. // 拖拽功能
  36. dragNode(params) {
  37. return axios({
  38. url: `api/xcoa-mobile/v1/iam-tree/moveTreeNode/${params.configId}/${params.id}/${params.targetId}/${params.position}`,
  39. method: 'post',
  40. data: null,
  41. }).then((res) => {
  42. res.data.forEach((item) => (item.isLeaf = item.leaf))
  43. return res
  44. })
  45. }
  46. }
  47. export default new AuditOperateTreeService()