import { CheckboxGroup } from '@/common/components/_auto-import/antd-map'
import axios from '@/common/services/axios-instance'

class IamAuditFrameService {
  // 获取审计框架左侧树
  getFrameTreeNodeInfo(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-category/findIamAuditFrameCategoryTree`,
      params: params,
      method: 'post',
    })
  }

  // 获取审计框架下拉框
  getFrameListInfo(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame/getIamAuditFrameEntitys`,
      params: { projectId: params },
      method: 'post',
    })
  }

  // 从审计模板库拷贝事项
  copyIamAuditFrameFromTemplate(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame/copyIamAuditFrameFromTemplate`,
      params: params,
      method: 'post',
    })
  }

  // 从审计模板库拷贝事项
  copyIamAuditFrameFromItem(iamAuditFrameParam) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame/copyIamAuditFrameFromItem`,
      data: iamAuditFrameParam,
      method: 'post',
    })
  }

  // 获取项目人员列表
  getProjectUsers(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-user/get-project-users`,
      params: params,
      method: 'post',
    })
  }

  // 获取事项列表
  findIamAuditFrameItems(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-item/findIamAuditFrameItems`,
      params: params,
      method: 'post',
    })
  }

  // 分配审计事项
  saveIamAuditFrameUserRel(iamAuditFrameUserRelParam) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-user/saveIamAuditFrameUserRel`,
      data: iamAuditFrameUserRelParam,
      method: 'post',
    })
  }

  // 删除审计事项分配
  deleteIamAuditFrameUserRel(iamAuditFrameUserRelParam) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-user/deleteIamAuditFrameUserRel`,
      data: iamAuditFrameUserRelParam,
      method: 'post',
    })
  }

  // 删除审计框架
  deleteframe(id) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame/deleteIamAuditFrame?id=${id}`,
      method: 'DELETE',
    })
  }

  // 删除事项分类
  deleteCategory(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-category/delete-category?ids=${params}`,
      method: 'DELETE',
    })
  }

  // 判断事项是否可以删除
  checkDeleteMatters(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-item/check-delete-iamAuditFrameItems?ids=${params}`,
      method: 'post',
    })
  }

  // 删除事项
  deleteMatters(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-item/deleteIamAuditFrameItems?ids=${params}`,
      method: 'POST',
    })
  }

  // 删除事项所分配的人员
  deleteUserRels(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iam-audit-frame-user/deleteUserRels`,
      data: params,
      method: 'POST',
    })
  }

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

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

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

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

export default new IamAuditFrameService()
