dict-data.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * @Author: qianlishi
  3. * @Date: 2020-07-13 15:13:17
  4. * @Last Modified by: qianlishi
  5. * @Last Modified time: 2020-12-15 15:34:34
  6. */
  7. import request from '@/utils/request'
  8. import { setStorageItem } from '@/utils/storage'
  9. // 数据字典和基础数据查询的相关接口
  10. /**
  11. * 数据字典多类型编码查询接口
  12. * type参数 类型 String
  13. * type参数 格式 'type'
  14. */
  15. export function getDictList (type) {
  16. return request({
  17. url: `/gaeaDict/select/${type}`,
  18. method: 'get',
  19. })
  20. }
  21. export function getDictCodes (project) {
  22. return request({
  23. url: `/gaeaDict/selectAll/${project}`,
  24. method: 'get',
  25. })
  26. }
  27. /**
  28. * 数据字典多类型编码查询接口
  29. * typeList参数 类型 Array
  30. * typeList参数 格式 ['type1','type2',...]
  31. */
  32. export function getMultipleDictList (typeList) {
  33. const types = typeList + ''
  34. return request({
  35. url: `/v1/dict/types`,
  36. method: 'get',
  37. params: { types },
  38. })
  39. }
  40. /**
  41. * 主数据编码查询接口
  42. * typeList参数 类型 Array
  43. * typeList参数 格式 ['type1','type2',...]
  44. */
  45. export function getBaseDataList (typeList) {
  46. const types = typeList + ''
  47. return request({
  48. url: `/v1/master/types`,
  49. method: 'get',
  50. params: { types },
  51. })
  52. }
  53. // 查询所有数据字典接口
  54. export function getAllDict() {
  55. return request({
  56. url: '/gaeaDict/all',
  57. method: 'GET',
  58. })
  59. }
  60. // 将所有接口初始化到浏览器本地缓存
  61. export function initDictToLocalstorage(callback) {
  62. getAllDict().then((res) => {
  63. if (res.code != 200) {
  64. console.error('初始化数据字典到local storage失败: ' + res.message)
  65. return
  66. }
  67. // 保存数据字典到localStorage
  68. setStorageItem('AJReportDict', res.data)
  69. if (callback != null) {
  70. callback()
  71. }
  72. })
  73. }