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

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

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

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

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

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

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

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

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

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

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