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

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

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

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

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

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

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

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

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

/**
 * submit func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function submit (id) {
  return axios({
    url: '/purchase/purchase-applies/' + id + '/submit',
    method: 'PUT'
  })
}

/**
 * finish func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function finish (id) {
  return axios({
    url: '/purchase/purchase-applies/' + id + '/finish',
    method: 'PUT'
  })
}

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