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

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

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

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

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

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

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

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

/**
 * export file
 * parameter: { }
 * @param parameter :
 * @returns {*}
 */
export function exportPurchasePlan (parameter) {
  return axios({
    url: '/purchase/purchase-plans/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-plans/' + id + '/submit',
    method: 'PUT'
  })
}

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