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

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

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

/**
 * update func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function updateSysExcelImport (parameter) {
  return axios({
    url: '/upms/excel-imports/' + parameter.id,
    method: 'PUT',
    data: parameter
  })
}

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

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

/**
 * delete batch func
 * parameter: { }
 * @param parameter
 * @returns {*}
 */
export function deleteSysExcelImports (parameter) {
  return axios({
    url: '/upms/excel-imports',
    method: 'DELETE',
    data: parameter
  })
}

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

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

export function uploadFile (parameter) {
  return axios({
    url: `/upms/excel-imports/import`,
    method: 'POST',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: parameter
  })
}
