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

class AuditMaintainService {
  // 获取单个授权模型信息
  findIamAuditMaintain(id) {
    return axios({
      url: `api/xcoa-mobile/v1/iammodelmaintain/findIamModelMaintain?id=${id}`,
      method: 'post',
    }).then((res) => {
      return res.data
    })
  }

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

  // 保存授权模型 iamModelMaintainSqSave
  saveIamAuditMaintain(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iammodelmaintain/iamModelMaintainSqSave`,
      method: 'post',
      data: params,
    }).then((res) => {
      return res.data
    })
  }

  // 获取模型授权申请数据接口
  getmaintainsqdata(id) {
    return axios({
      url: `api/xcoa-mobile/v1/iammodelmaintain/getIamModelMaintains?id=${id}`,
      method: 'post',
    }).then((res) => {
      return res.data
    })
  }

  // 保存数据授权 saveIamModelMaintainSqDte
  saveIamModelMaintain(params) {
    return axios({
      url: `api/xcoa-mobile/v1/iammodelmaintain/saveIamModelMaintainSqDte`,
      method: 'post',
      data: params,
    }).then((res) => {
      return res.data
    })
  }

  // 获取数据授权 getIamModelMaintainSqDte
  getIamModelMaintain(id) {
    return axios({
      url: `api/xcoa-mobile/v1/iammodelmaintain/getIamModelMaintainSqDte?selectOrgId=${id}`,
      method: 'post',
    }).then((res) => {
      return res.data
    })
  }

  // 生成查看日志接口
  saveModelmaintainlogInfo(id) {
    return axios({
      url: `api/xcoa-mobile/v1/iammodelmaintainlog/saveModelmaintainlogInfo?maintainId=${id}&operateType=01`,
      method: 'get',
    }).then((res) => {
      return res.data
    })
  }

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

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

  // 删除事项
  deleteIamAuditMaintain(ids) {
    return axios
      .delete('api/xcoa-mobile/v1/iam-audit-maintain/delete-iamAuditMaintain?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-maintain/exportItem',
      params: { id: Number(id), rootId: Number(rootId) },
      responseType: 'blob',
    })
  }

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

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

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

  // 获取分类树形图
  getFindModelCategoryTreeAll() {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iammodelcategory/findModelCategoryTreeAll',
    })
  }

  setShareStatus(data) {
    return axios({
      method: 'post',
      url:
        'api/xcoa-mobile/v1/iammodelmaintain/editIamModelSharedSetting?sharedSetting=' +
        data.sharedSetting +
        '&id=' +
        data.id,
    })
  }

  // 事件标签列表
  getEventTagList() {
    return axios({
      method: 'get',
      url: 'api/xcoa-mobile/v1/iamincidenttag/findIncidentTagListAll',
    })
  }

  // 删除事件标签
  deleteEventTag(ids) {
    return axios({
      method: 'delete',
      url: 'api/xcoa-mobile/v1/iam-page/iamIncidentTag?ids=' + ids,
    })
  }

  // 校验事件标签
  checkEventTag(ids) {
    return axios({
      method: 'get',
      url: 'api/xcoa-mobile/v1/iamincidenttag/deleteIncidentTagCheck?ids=' + ids,
    })
  }

  // 申请共享
  applyShareLog(data) {
    return axios({
      method: 'post',
      url: 'api/xcoa-mobile/v1/iamdetailformmodifylog/saveDetailFormModifyLog',
      data: data,
    })
  }

  applyShare(data) {
    return axios({
      method: 'post',
      url: 'api/framework/v1/page/handleData',
      data: data,
    })
  }

  // 请求申请共享新增模板
  getApplyShareModel(id) {
    return axios({
      method: 'post',
      url: 'api/framework/v1/page/wp/audit/maintain/iamModelShare',
    })
  }

  // 修改申请状态
  updateApplyStatus(data) {
    return axios({
      method: 'post',
      url: `api/xcoa-mobile/v1/iammodelshare/editIamModelApplyStatus?applyStatus=${data.applyStatus}&id=${data.id}`,
    })
  }

  // 获取分类授权申请数据接口
  getclassdata(id) {
    return axios({
      url: `api/xcoa-mobile/v1/iamdatacategory/getIamDataCategorys?id=${id}`,
      method: 'post',
    }).then((res) => {
      return res.data
    })
  }

  // 修改模型上下线
  // iammodelmaintain/modelOnline这是post方法
  // iammodelmaintain/modelOnline?status=1这样传参
  updateModelStatus(data) {
    return axios({
      method: 'post',
      url: `api/xcoa-mobile/v1/iammodelmaintain/modelOnline?status=${data.status}&id=${data.id}`,
    })
  }

  // 全量查询模型领域列表
  getAreaListAll() {
    return axios({
      url: 'api/xcoa-mobile/v1/model-domain/all',
      method: 'get',
    })
  }

  // 全量查询模型阶段列表
  getStageListAll() {
    return axios({
      url: 'api/xcoa-mobile/v1/model-phase/all',
      method: 'get',
    })
  }

  // 查询模型领域详情
  getAreaDetail(id) {
    return axios({
      url: `api/framework/v1/page/wp/audit/maintain/iamModelDomain?id=${id}`,
      method: 'post',
    })
  }

  // iammodelmaintain/modelSave  固化模型保存
  modelSaveGH(data) {
    return axios({
      url: `api/xcoa-mobile/v1/iammodelmaintain/modelSave`,
      method: 'post',
      data: data,
    })
  }

  // 多选绑定model-domain-user/butchBindPeople
  butchBindPeople(data) {
    return axios({
      url: `api/xcoa-mobile/v1/model-domain-user/butchBindPeople`,
      method: 'post',
      data: data,
    })
  }
}

export default new AuditMaintainService()
