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

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

/**
 * add func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function addPurchaseOrderList (parameter) {
  return axios({
    url: '/purchase/purchase-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 updatePurchaseOrderList (parameter) {
  return axios({
    url: '/purchase/purchase-order-lists/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

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

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

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

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

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

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

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

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