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

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

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

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateFillProjectQuantity (parameter) {
  return axios({
    url: '/fill/project-quantities/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

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

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

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

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteFillProjectQuantitys (parameter) {
  return axios({
    url: '/fill/project-quantities',
    method: 'DELETE',
    data: parameter
  })
}

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

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

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

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

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateCloseProject (parameter) {
  return axios({
    url: '/fill/project-quantities/update/close-project/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

/**
 * add func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function importProject (file) {
  return axios({
    url: '/fill/project-quantities/import',
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: file
  })
}
