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

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

  fngetsortNum(id) {
    return axios
      .post('api/xcoa-mobile/v1/icmtxmeasure/getsortNum?catalogId=' + id)
      .then(function(res) {
        return res.data
      })
  }

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

  // 获取措施节点
  findIcIcmeasureCategoryTree(parentId, orgId, versionId) {
    const url =
      'api/xcoa-mobile/v1/icmtxprocess/findIcIcmeasureCategoryTree?parentId=' +
      parentId +
      '&auditOrgId=' +
      orgId +
      '&versionId=' +
      versionId
    return axios.post(url).then(function(res) {
      return res
    })
  }

  // 获取分类path
  findupcatinfo(categoryId) {
    const url = 'api/xcoa-mobile/v1/icmtxprocess/findupcatinfo?categoryId=' + categoryId
    return axios.post(url).then(function(res) {
      return res
    })
  }

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

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

  // 删除事项
  deleteIcIcmatrix(ids) {
    return axios
      .delete('api/xcoa-mobile/v1/icmtxprocess/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, versionId) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/icmtxmeasure/exportItem',
      params: { id: Number(id), versionId: Number(versionId) },
      responseType: 'blob',
    })
  }

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

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

  // 拖拽功能
  dragNode(data) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/icmtxprocess/drage',
      data: data,
    })
  }

  // 获取版本ID
  getversion(belongUnitId) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/icmtxversion/getMtxVersion',
      params: { belongUnitId: belongUnitId },
    })
  }

  // 检查分类
  CheckCategory(ids) {
    return axios
      .get('api/xcoa-mobile/v1/icmtxprocess/check-category?ids=' + ids)
      .then(function(res) {
        return res.data
      })
  }
}

export default new IcService()
