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

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

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

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateSparePartUsed (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-part-used/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

/**
 * add batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function addSparePartUsedBatch (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-part-used/batch',
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json;charset=UTF-8'
    },
    data: parameter
  })
}

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

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

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteSparePartUseds (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-part-used',
    method: 'DELETE',
    data: parameter
  })
}

/**
 * page func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function selectSparePartUsedListByRepairId (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-part-used/repair/' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * delete single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteSparePartUsed (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-part-used/' + parameter.id,
    method: 'DELETE',
    data: parameter
  })
}

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

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