audit-permission-tree-service.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import axios from '@/common/services/axios-instance'
  2. class AuditPermissionTreeService {
  3. getParentOrgInfo(params) {
  4. return axios({
  5. url: 'api/xcoa-mobile/v1/iamorg/getManagedHierarchyOrg',
  6. method: 'post',
  7. params,
  8. }).then((res) => {
  9. res.data.forEach((item) => {
  10. item.isLeaf = item.leaf
  11. if (item.props.orgId === null) {
  12. item.props = { ORG_ID: null, BELONGED_ORG_ID: -1 }
  13. } else {
  14. item.props = { ORG_ID: item.props.orgId, BELONGED_ORG_ID: -1 }
  15. }
  16. })
  17. return res
  18. })
  19. }
  20. getPcParentOrgInfo() {
  21. return axios({
  22. url: 'api/xcoa-mobile/v1/iamorg/getCurrentUserGroup',
  23. method: 'get',
  24. }).then((res) => {
  25. res.data.isLeaf = true
  26. res.data.props = { ORG_ID: res.data.id, BELONGED_ORG_ID: -1 }
  27. res.data.text = res.data.name
  28. const result = { data: [] }
  29. result.data.push(res.data)
  30. return result
  31. })
  32. }
  33. // 业务类型分类树
  34. getCategoryTree(parentId, params) {
  35. // url: `api/xcoa-mobile/v1/iam-tree/findTreeNodeById/${params.configId}/${parentId}`,
  36. return axios({
  37. url: `api/xcoa-mobile/v1/iamorg/getAuditOrgTreeNodeById/${parentId}`,
  38. method: 'post',
  39. params,
  40. }).then((res) => {
  41. res.data.forEach((item) => {
  42. item.isLeaf = item.leaf
  43. if (item.props.orgId === null) {
  44. item.props = {}
  45. } else {
  46. item.props = { ORG_ID: Number(item.props.orgId), BELONGED_ORG_ID: -1 }
  47. }
  48. })
  49. return res
  50. })
  51. }
  52. // 拖拽功能
  53. dragNode(params) {
  54. return axios({
  55. url: `api/xcoa-mobile/v1/iam-tree/moveTreeNode/${params.configId}/${params.id}/${params.targetId}/${params.position}`,
  56. method: 'post',
  57. data: null,
  58. }).then((res) => {
  59. res.data.forEach((item) => (item.isLeaf = item.leaf))
  60. return res
  61. })
  62. }
  63. // 地址树搜索功能
  64. groupsQuery(data) {
  65. return axios({
  66. url: `api/xcoa-mobile/v1/iamorg/groups_query`,
  67. method: 'post',
  68. params: data,
  69. }).then((res) => {
  70. res.data.forEach((item) => {
  71. item.isLeaf = item.leaf
  72. item.name = item.text
  73. item.oldId = item.id
  74. item.props.ORG_ID = item.props.orgId
  75. if (item.props.ORG_ID !== null) {
  76. item.code = item.props.ORG_ID.toString()
  77. item.id = item.props.ORG_ID
  78. } else {
  79. item.code = item.id.toString()
  80. }
  81. item.type = 'Group'
  82. item.checkable = true
  83. })
  84. return res.data
  85. })
  86. }
  87. }
  88. export default new AuditPermissionTreeService()