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

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

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

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

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

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

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

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

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

/**
 * export file
 * parameter: { }
 * @param parameter :
 * @returns {*}
 */
export function exportRepairApplicationForm (parameter) {
  return axios({
    url: '/repair/application-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/application-forms/finish/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

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

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

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

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