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

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

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

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

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

/**
 * fetch single func 查找备件仓库信息列表
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchStoreList (parameter) {
  return axios({
    url: '/store/spare-stores/page?spareId=' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * fetch single func 查找备件入库信息列表
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchInStoreList (parameter) {
  return axios({
    url: '/store/in-store-details/page?spareId=' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * fetch single func 查找备件出库信息列表
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchOutStoreList (parameter) {
  return axios({
    url: '/store/out-store-details/page?spareId=' + parameter.id,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

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

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

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateSpareIdsBatch (spareId, parameter) {
  return axios({
    url: '/sqarepartmanage/spare-part-info/adjust/' + spareId,
    method: 'PUT',
    data: parameter
  })
}

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

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

/**
 * 查询下拉框
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchSparePartInfoOptions (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-part-info/options?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

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

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