import axios from '@/common/services/axios-instance'
class AuditTreeService {
  // 业务类型分类树
  getCategoryTree(parentId, treeparams, params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-tree/findTreeNodeById/${treeparams.configId}/${parentId}`,
      method: 'post',
      params,
    }).then((res) => {
      res.data.forEach((item) => (item.isLeaf = item.leaf))
      return res
    })
  }

  // 拖拽功能
  dragNode(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-tree/moveTreeNode/${params.configId}/${params.id}/${params.targetId}/${params.position}`,
      method: 'post',
      data: null,
    }).then((res) => {
      return res.data
    })
  }

  // 获取分级授权下拉列表
  getManagedHierarchyOrg(formId) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-page/getHavePermissionOrg/${formId}`,
      method: 'post',
    }).then((res) => {
      return res
    })
  }

  // 获取分级授权下拉列表(子项)
  getChildPermissionOrg(formId) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-page/getChildPermissionOrg/${formId}`,
      method: 'post',
    }).then((res) => {
      return res
    })
  }
}
export default new AuditTreeService()
