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

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

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

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

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updatePurchaseDispatchOrderInfo (parameter) {
  return axios({
    url: '/purchase/purchase-dispatch-orders/' + parameter.id + '/info',
    method: 'PUT',
    data: parameter
  })
}

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function confirmUpdateQuantityForInStore (parameter) {
  return axios({
    url: '/purchase/purchase-dispatch-orders/' + parameter.id + '/quantity/error',
    method: 'PUT',
    data: parameter
  })
}

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

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

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deletePurchaseDispatchOrders (parameter) {
  return axios({
    url: '/purchase/purchase-dispatch-orders',
    method: 'DELETE',
    data: parameter
  })
}

/**
 * delete single func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deletePurchaseDispatchOrder (parameter) {
  return axios({
    url: '/purchase/purchase-dispatch-orders/' + parameter.id,
    method: 'DELETE',
    data: parameter
  })
}

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