import axios from '@/common/services/axios-instance'

class AuditMattersService {
  // 获取审计事项列表信息
  findIamAuditMatters(id) {
    return axios
      .get('api/xcoa-mobile/v1/iam-audit-matters/findIamAuditMatters?id=', id)
      .then(function(res) {
        return res.data
      })
  }

  // 获取审计事项分类树
  findIamAuditMattersCategoryTree(parentId, orgId) {
    const url =
      'api/xcoa-mobile/v1/iam-audit-matters-catalog/findIamAuditMattersCategoryTree?parentId=' +
      parentId +
      '&orgId=' +
      orgId
    return axios.post(url).then(function(res) {
      return res
    })
  }

  // 删除时检查分类
  deleteCheckCategory(ids) {
    return axios
      .get('api/xcoa-mobile/v1/iam-audit-matters-catalog/delete-check-category?ids=' + ids)
      .then(function(res) {
        return res.data
      })
  }

  // 删除时分类
  deleteCategory(ids) {
    return axios
      .delete('api/xcoa-mobile/v1/iam-audit-matters-catalog/delete-category?ids=' + ids)
      .then(function(res) {
        return res.data
      })
  }

  // 删除事项
  deleteIamAuditMatters(ids) {
    return axios
      .delete('api/xcoa-mobile/v1/iam-audit-matters/delete-iamAuditMatters?ids=' + ids)
      .then(function(res) {
        return res.data
      })
  }

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

  // 导出审计事项
  exportItem(id, rootId) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iam-audit-matters/exportItem',
      params: { id: Number(id), rootId: Number(rootId) },
      responseType: 'blob',
    })
  }

  // 导出模板
  exportItemTemplate(level) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iam-audit-matters/exportItemTemplate',
      params: { level: Number(level) },
      responseType: 'blob',
    })
  }

  // 导入数据
  importItemTemplate(importType, groupId, orgId) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iam-audit-matters/importItemTemplate',
      params: { importType: importType, groupId: groupId, orgId: orgId },
    })
  }

  // 拖拽功能
  dragNode(data) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iam-audit-matters-catalog/drage',
      data: data,
    }).then((res) => {
      return res.data
    })
  }
}

export default new AuditMattersService()
