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

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

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

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

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

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

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

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

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

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

/**
 * add func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function importPurchaseDispatchOrderList (parameter) {
  return axios({
    url: '/purchase/purchase-dispatch-order-lists/import',
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: parameter
  })
}
