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

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

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

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

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

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

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

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

/**
 * export file
 * parameter: { }
 * @param parameter :
 * @returns {*}
 */
export function exportSpareType (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-type/export?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    },
    responseType: 'blob'
  })
}
/**
 * 获取类别树
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchSpareTypeTree (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-type/tree?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 获取类别树
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function fetchSpareTypeAndSbModelTree (parameter) {
  return axios({
    url: '/sqarepartmanage/spare-type/tree/sbModel?' + stringify(parameter),
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}