import { axios } from '@/utils/request'
import { stringify } from 'qs'

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getRepairFormPage (parameter) {
  return axios({
    url: '/repair/forms/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * add func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function addRepairForm (parameter) {
  return axios({
    url: '/repair/forms',
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateRepairForm (parameter) {
  return axios({
    url: '/repair/forms/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function dispatchModelByDTO (parameter) {
  return axios({
    url: '/repair/forms/dispatch/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

/**
 * fetch single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchRepairForm (parameter) {
  return axios({
    url: '/repair/forms/' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * query list func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function queryRepairForm (parameter) {
  return axios({
    url: '/repair/forms?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * query list func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function queryNum (parameter) {
  return axios({
    url: '/repair/forms/num?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteRepairForms (parameter) {
  return axios({
    url: '/repair/forms',
    method: 'DELETE',
    data: parameter
  })
}

/**
 * delete single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteRepairForm (parameter) {
  return axios({
    url: '/repair/forms/' + parameter.id,
    method: 'DELETE',
    data: parameter
  })
}

/**
 * export file
 * parameter: { }
 * @param parameter :
 * @returns {*}
 */
export function exportRepairForm (parameter) {
  return axios({
    url: '/repair/forms/export?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    responseType: 'blob'
  })
}

/**
 * finish func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function finish (parameter) {
  return axios({
    url: '/repair/forms/finish/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

/**
 * finish func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function repairFormDeal (parameter) {
  return axios({
    url: '/repair/forms/deal/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function statisticsByGroupBySbPage (parameter) {
  return axios({
    url: '/repair/forms/statistics-sb/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function statisticsByGroupByMonthPage (parameter) {
  return axios({
    url: '/repair/forms/statistics-month/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function statisticsByGroupByErrorTypePage (parameter) {
  return axios({
    url: '/repair/forms/statistics-error-type/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function statisticsByGroupByUserPage (parameter) {
  return axios({
    url: '/repair/forms/statistics-user/page?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function statisticsResultSbGroupBySbMonth (parameter) {
  return axios({
    url: '/repair/forms/statistics-result-sb?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function statisticsResultMonthGroupByMonth (parameter) {
  return axios({
    url: '/repair/forms/statistics-result-month?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function statisticsResultErrorTypeByGroupByErrorType (parameter) {
  return axios({
    url: '/repair/forms/statistics-result-error-type?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function statisticsResultUserByGroupByUser (parameter) {
  return axios({
    url: '/repair/forms/statistics-result-user?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
