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

class LawService {
  // 获取案由配置下级节点
  findCaseCatelogtree(parentId) {
    const url = 'api/framework/v1/law-case-action/findLawCaseActionTree?parentCode=' + parentId
    return axios.post(url).then(function (res) {
      return res
    })
  }

  // 获取案由配置节点最大数值
  findActionCode(parentId) {
    const url = 'api/framework/v1/law-case-action/findActionCode?parentCode=' + parentId
    return axios.get(url).then(function (res) {
      return res
    })
  }

  getAlljfStage() {
    const url = 'api/xcoa-mobile/v1/iam-page/businessList'
    const params = {
      buttonExpressions: [],
      columns: 'STAGE_CODE,text0,STAGE_NAME,CREATOR_NAME,CREATION_TIME',
      expressions: [],
      formId: 'onlhead:7d24a24cc49641d8a5477dd1f73bf515',
      maxResults: 10,
      orderBy: 'CREATION_TIME ASC',
      startPosition: 0,
    }
    return axios.post(url, params).then(function (res) {
      return res
    })
  }

  // 根据纠纷projectId获取纠纷进展信息
  getProgressData(id) {
    return axios.get(`api/framework/v1/law-work-step/step-tree?lawId=${id}`).then(function (res) {
      return res
    })
  }

  // 获取案件阶段树代码 api/framework/v1/lawcasestage/findLawCaseStageTree
  getCaseTree(caseType, caseStage) {
    const url = 'api/framework/v1/lawcasestage/findLawCaseStageTree'
    const params = {
      caseType: caseType,
      caseStage: caseStage,
    }
    return axios
      .get(
        `api/framework/v1/lawcasestage/findLawCaseStageTree?caseType=${caseType}&caseStage=${caseStage}`
      )
      .then(function (res) {
        return res
      })
  }

  getAllCaseTree() {
    return axios.get(`api/framework/v1/lawcasestage/findAll`).then(function (res) {
      return res
    })
  }

  getAllcaseproStage() {
    const url = 'api/framework/v1/lawexecuteproceure/findExecuteProceureList'
    return axios.post(url).then(function (res) {
      return res
    })
  }

  // 获取案件信息
  getCaseData(caseId) {
    return axios
      .get(`api/framework/v1/law-case-finish/getCaseInfoByCaseId?caseId=${caseId}`)
      .then(function (res) {
        return res
      })
  }

  getdict(id) {
    return axios
      .get(`api/framework/v1/app-dict/select-item/${id}?parentId=${id}`)
      .then(function (res) {
        return res
      })
    // const url = 'api/xcoa-mobile/v1/iam-page/businessList'
    // return axios.post(url, params).then(function(res) {
    //   return res
    // })
    // http://localhost:8888/xcoa/api/framework/v1/app-dict/select-item/280447518411472896?parentId=280447518411472896
  }

  // 创建案件接口
  createCase(disputeId, type) {
    return axios
      .get(
        `api/xcoa-mobile/v1/law-dispute-finish/createLawCase?disputeId=${disputeId}&disputeResult=${type}`
      )
      .then(function (res) {
        return res
      })
  }

  // 根据案件id获取案件大事记信息
  getMemoir(id) {
    return axios
      .get(`api/xcoa-mobile/v1/law-work-step/law-memoir?lawId=${id}`)
      .then(function (res) {
        return res
      })
  }

  // 统计接口-案件数量统计
  getCaseStatistics(params) {
    const url = 'api/xcoa-mobile/v1/law-statistics/getCaseAmount'
    return axios.post(url, params).then(function (res) {
      return res
    })
  }

  // 统计接口-诉讼地位统计
  getSsdwStatistics(params) {
    const url = 'api/framework/v1/law-case-statistics/getLawCaseResult'
    return axios.post(url, params).then(function (res) {
      return res
    })
  }

  // 统计接口-案件阶段统计
  getCasestageStatistics(params) {
    const url = 'api/framework/v1/law-case-statistics/getLawCaseResult'
    return axios.post(url, params).then(function (res) {
      return res
    })
  }

  getBeanByFormId(id, formId) {
    const url = 'api/framework/v1/page/wp/' + formId
    return axios.post(url, { id: id }).then(function (res) {
      return res
    })
  }

  getBeanByInstId(instId) {
    return axios
      .get('api/framework/v1/task-form-process/done-pages/' + instId)
      .then(function (res) {
        return res
      })
  }

  // 获取业务类型id
  getTypeBusId(id) {
    return axios({
      url: 'api/framework/v1/businesstype-manage/auth-businesstypes/moduleid?appModuleId=' + id,
      method: 'get',
    })
  }

  // 根据案件上报id 查询所需值
  findByCase(caseId) {
    return axios
      .get(`api/framework/v1/law-case-reporting/findByCase?caseId=${caseId}`)
      .then(function (res) {
        return res
      })
  }

  // 执行程序唯一校验
  getCaseExecuteCode(code, id) {
    return axios
      .get(`api/framework/v1/lawexecuteproceure/validate/code?code=${code}&id=${id}`)
      .then(function (res) {
        return res
      })
  }

  // 判断用户是否拥有角色
  isUserHasRole(account, roleCode) {
    return axios
      .get(
        `api/xcoa-mobile/v1/iam-common/common/user-hasRole?account=${account}&roleCode=${roleCode}`
      )
      .then(function (res) {
        return res
      })
  }

  // 获取用户
  getUser(account) {
    return axios
      .get(`api/xcoa-mobile/v1/lawLawYerController/getUser?account=${account}`)
      .then(function (res) {
        return res
      })
  }
}

export default new LawService()
