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

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

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

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

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateStatus(parameter) {
  return axios({
    url: '/status/stores/status/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

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

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

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

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


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

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function joinForm (parameter) {
  return axios({
    url: '/purchase/store-forms/joinForm',
    method: 'PUT',
    data: parameter
  })
}

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function applyInStore (parameter) {
  return axios({
    url: '/purchase/store-forms/apply/inStore/' + parameter.id,
    method: 'PUT'
  })
}
