dictionaryManagement.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. module.exports = [
  2. {
  3. url: '/dictionaryManagement/getTree',
  4. type: 'get',
  5. response() {
  6. return {
  7. code: 200,
  8. msg: 'success',
  9. data: {
  10. total: 999,
  11. list: [
  12. {
  13. id: 'root',
  14. key: 'root',
  15. label: '全部字典',
  16. children: [
  17. {
  18. id: '@id',
  19. key: 'sex',
  20. label: '性别',
  21. },
  22. {
  23. id: '@id',
  24. key: 'type',
  25. label: '类型',
  26. },
  27. ],
  28. },
  29. ],
  30. },
  31. }
  32. },
  33. },
  34. {
  35. url: '/dictionaryManagement/getList',
  36. type: 'get',
  37. response: (config) => {
  38. const { key, parentKey } = config.query
  39. const list1 = [
  40. {
  41. parentKey: 'sex',
  42. id: '@id',
  43. lable: '性别',
  44. key: '1',
  45. value: '男',
  46. },
  47. {
  48. parentKey: 'sex',
  49. id: '@id',
  50. lable: '性别',
  51. key: '2',
  52. value: '女',
  53. },
  54. ]
  55. const list2 = [
  56. {
  57. parentKey: 'type',
  58. id: '@id',
  59. lable: '类型',
  60. key: '1',
  61. value: '新闻',
  62. },
  63. {
  64. parentKey: 'type',
  65. id: '@id',
  66. lable: '类型',
  67. key: '2',
  68. value: '知识',
  69. },
  70. ]
  71. if (parentKey) {
  72. return {
  73. code: 200,
  74. msg: 'success',
  75. data: {
  76. list: parentKey === 'sex' ? list1 : list2,
  77. },
  78. }
  79. }
  80. return {
  81. code: 200,
  82. msg: 'success',
  83. data: {
  84. list: !key || key === 'root' ? [] : key === 'sex' ? list1 : list2,
  85. },
  86. }
  87. },
  88. },
  89. {
  90. url: '/dictionaryManagement/doEdit',
  91. type: 'post',
  92. response: () => {
  93. return {
  94. code: 200,
  95. msg: '模拟保存成功',
  96. }
  97. },
  98. },
  99. {
  100. url: '/dictionaryManagement/doDelete',
  101. type: 'post',
  102. response: () => {
  103. return {
  104. code: 200,
  105. msg: '模拟删除成功',
  106. }
  107. },
  108. },
  109. ]