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

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

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

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

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

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

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

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

/**
 * export file
 * parameter: { }
 * @param parameter :
 * @returns {*}
 */
export function exportRepairCheck (parameter) {
  return axios({
    url: '/repair/checks/export?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    responseType: 'blob'
  })
}
/**
 * approve func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function approve (parameter) {
  return axios({
    url: '/repair/checks/approve/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

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