import { IQueryCommon, IRes, IResult } from '@/api/common'
import axios from '@/utils/request'
import { base, IAssessmentBase, IAssessmentFlaw, IAssessmentHealth, IAssessmentAssessment, IAssessment } from './common'
export interface IQueryParam {
  checkCode: string
  siteId: number
  beginDate: string
  endDate: string
}

const uris = {
  base: `${base}/assessmentReport/getAssessConclusion`,
  flaw: `${base}/assessmentReport/getDataByFlawTypeCount`,
  health: `${base}/assessmentReport/getHealthLevel`,
  assessment: `${base}/assessmentReport/getReportCondision`,
  page: `${base}/assessmentReport/page`,
  download: `${base}/assessmentReport/exportExcel`
}

export const fetchBaseReport = () => axios.request<IResult<IAssessmentBase>>({ url: uris.base, method: 'get' })

export const fetchFlawReport = () => axios.request<IResult<IAssessmentFlaw>>({ url: uris.flaw, method: 'get' })

export const fetchHealthReport = () => axios.request<IResult<IAssessmentHealth[]>>({ url: uris.health, method: 'get' })

export const fetchAssessmentReport = () =>
  axios.request<IResult<IAssessmentAssessment[]>>({ url: uris.assessment, method: 'get' })

export const fetchReportPage = (params: Partial<IQueryCommon>) =>
  axios.request<IRes<IAssessment[]>>({ url: uris.page, method: 'get', params })

export const downloadAssessment = () => axios.request<IResult<any>>({ url: uris.download, method: 'get' })
