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

class RiskTasksService {
  // 获取风险准则
  getRiskCriteria(depId) {
    return axios({
      method: 'get',
      url: `api/xcoa-mobile/v1/riskdutie/getRiskCriteria?inspectUnitId=${depId}`,
    })
  }

  // 获取风险任务信息
  getRiskTaskInfo(id) {
    return axios({
      method: 'get',
      url: `api/xcoa-mobile/v1/page/wp/risk/task/dutie/riskDutie?id=${id}`,
    })
  }

  // 获取准则信息
  getRiskCriteriaInfo(id) {
    return axios({
      method: 'get',
      url: `api/xcoa-mobile/v1/page/wp/risk/criteria/riskCriteria?id=${id}`,
    })
  }

  getUserChangeLogInfo(id) {
    return axios({
      url: `api/xcoa-mobile/v1/taskuser/getTaskUserChangeInfo?taskId=` + id,
    })
  }

  // 获取任务信息
  // getTaskInfo(taskId) {
  //   return axios({
  //     url: `api/framework/v1/page/wp/risk/dutie/riskDutie?id=` + taskId,
  //   })
  // }

  // 获取当前用户风控机构
  findIamOrgId(deptId, moduleId = 'riskLibraryVersion') {
    const params = {
      orgId: deptId,
      moduleId,
    }
    return axios({
      method: 'post',
      url: `api/xcoa-mobile/v1/iamorg/findIamOrgId`,
      params,
    })
  }

  // 设置控制测试人员
  setAssessmentTestor(accout, ids) {
    return axios
      .get(
        'api/xcoa-mobile/v1/riskassessment/riskAssessmentEntityIssued?userAccount=' +
          accout +
          '&ids=' +
          ids
      )
      .then(function(res) {
        return res.data
      })
  }

  // 所有已选ids
  getAllids(taskId) {
    return axios
      .get('api/xcoa-mobile/v1/riskassessment/getAlllistids?taskId=' + taskId)
      .then(function(res) {
        return res.data
      })
  }

  // 控制节点生成评估
  saveAssessment(taskId, ids) {
    return axios
      .get(
        'api/xcoa-mobile/v1/riskassessment/riskAssessmentEntitySave?riskDutiesId=' +
          taskId +
          '&ids=' +
          ids
      )
      .then(function(res) {
        return res.data
      })
  }

  // 删除工作底稿列表数据
  deleteassess(params, formId) {
    return axios({
      url: `api/xcoa-mobile/v1/riskassessment/${formId}`,
      method: 'delete',
      params,
    })
  }

  // 评估应对

  // 设置控制测试人员
  setResponseTestor(accout, ids) {
    return axios
      .get(
        'api/xcoa-mobile/v1/riskresponse/riskAssessmentEntityIssued?userAccount=' +
          accout +
          '&ids=' +
          ids
      )
      .then(function(res) {
        return res.data
      })
  }

  // 所有已选ids
  getAllResponseids(taskId) {
    return axios
      .get('api/xcoa-mobile/v1/riskresponse/getAlllistids?taskId=' + taskId)
      .then(function(res) {
        return res.data
      })
  }

  // 控制节点生成评估
  saveResponse(taskId, ids) {
    return axios
      .get(
        'api/xcoa-mobile/v1/riskresponse/riskAssessmentEntitySave?riskDutiesId=' +
          taskId +
          '&ids=' +
          ids
      )
      .then(function(res) {
        return res.data
      })
  }

  // 删除工作底稿列表数据
  deleteresponse(params, formId) {
    return axios({
      url: `api/xcoa-mobile/v1/riskresponse/${formId}`,
      method: 'delete',
      params,
    })
  }

  //  获取下一个报告编号
  getNextNumber(params) {
    return axios({
      url: 'api/xcoa-mobile/v1/riskTaskReport/get-next-number',
      params,
      method: 'get',
    })
  }
}

export default new RiskTasksService()
