common.js 903 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import request from '@/utils/request'
  2. // 公用接口
  3. // 公用导出
  4. export function exportApi(url, data, method) {
  5. let option = {
  6. url: url,
  7. method: method,
  8. responseType: 'blob'
  9. }
  10. if (method == 'get') {
  11. option.params = data
  12. } else {
  13. option.data = data
  14. }
  15. return request(option)
  16. }
  17. // 公用导入
  18. export function importApi(url, data, method) {
  19. let option = {
  20. url: url,
  21. method: method ? method : 'get'
  22. }
  23. if (method == 'get') {
  24. option.params = data
  25. } else {
  26. option.data = data
  27. }
  28. return request(option)
  29. }
  30. // 获取Excel导入模板
  31. export function getExcelTemplate(type) {
  32. return request({
  33. url: '/file/exportExcel/' + type,
  34. method: 'get',
  35. responseType: 'blob'
  36. })
  37. }
  38. // 根据登录信息获取用户权限
  39. export function getResources(params) {
  40. return request({
  41. url: '/getResources',
  42. method: 'get',
  43. params
  44. })
  45. }