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

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

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

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

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

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

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

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

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

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

/**
 * submit func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function getMoney (id) {
  return axios({
    url: '/purchase/purchase-demand-plans/' + id + '/money',
    method: 'GET'
  })
}

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