system.ts 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import { MockMethod } from 'vite-plugin-mock';
  2. import { resultPageSuccess, resultSuccess } from '../_util';
  3. const accountList = (() => {
  4. const result: any[] = [];
  5. for (let index = 0; index < 20; index++) {
  6. result.push({
  7. id: `${index}`,
  8. account: '@first',
  9. email: '@email',
  10. nickname: '@cname()',
  11. role: '@first',
  12. createTime: '@datetime',
  13. remark: '@cword(10,20)',
  14. 'status|1': ['0', '1'],
  15. });
  16. }
  17. return result;
  18. })();
  19. const roleList = (() => {
  20. const result: any[] = [];
  21. for (let index = 0; index < 4; index++) {
  22. result.push({
  23. id: `${index}`,
  24. orderNo: `${index + 1}`,
  25. roleName: ['超级管理员', '管理员', '文章管理员', '普通用户'][index],
  26. roleValue: '@first',
  27. createTime: '@datetime',
  28. remark: '@cword(10,20)',
  29. 'status|1': ['0', '1'],
  30. });
  31. }
  32. return result;
  33. })();
  34. const deptList = (() => {
  35. const result: any[] = [];
  36. for (let index = 0; index < 3; index++) {
  37. result.push({
  38. id: `${index}`,
  39. deptName: ['华东分部', '华南分部', '西北分部'][index],
  40. orderNo: index + 1,
  41. createTime: '@datetime',
  42. remark: '@cword(10,20)',
  43. 'status|1': ['0', '0', '1'],
  44. children: (() => {
  45. const children: any[] = [];
  46. for (let j = 0; j < 4; j++) {
  47. children.push({
  48. id: `${index}-${j}`,
  49. deptName: ['研发部', '市场部', '商务部', '财务部'][j],
  50. orderNo: j + 1,
  51. createTime: '@datetime',
  52. remark: '@cword(10,20)',
  53. 'status|1': ['0', '1'],
  54. parentDept: `${index}`,
  55. children: undefined,
  56. });
  57. }
  58. return children;
  59. })(),
  60. });
  61. }
  62. return result;
  63. })();
  64. const menuList = (() => {
  65. const result: any[] = [];
  66. for (let index = 0; index < 3; index++) {
  67. result.push({
  68. id: `${index}`,
  69. icon: ['ion:layers-outline', 'ion:git-compare-outline', 'ion:tv-outline'][index],
  70. component: 'LAYOUT',
  71. menuName: ['Dashboard', '权限管理', '功能'][index],
  72. permission: '',
  73. orderNo: index + 1,
  74. createTime: '@datetime',
  75. 'status|1': ['0', '0', '1'],
  76. children: (() => {
  77. const children: any[] = [];
  78. for (let j = 0; j < 4; j++) {
  79. children.push({
  80. id: `${index}-${j}`,
  81. menuName: ['菜单1', '菜单2', '菜单3', '菜单4'][j],
  82. icon: 'ion:document',
  83. permission: ['menu1:view', 'menu2:add', 'menu3:update', 'menu4:del'][index],
  84. component: [
  85. '/dashboard/welcome/index',
  86. '/dashboard/analysis/index',
  87. '/dashboard/workbench/index',
  88. '/dashboard/test/index',
  89. ][j],
  90. orderNo: j + 1,
  91. createTime: '@datetime',
  92. 'status|1': ['0', '1'],
  93. parentMenu: `${index}`,
  94. children: undefined,
  95. });
  96. }
  97. return children;
  98. })(),
  99. });
  100. }
  101. return result;
  102. })();
  103. export default [
  104. {
  105. url: '/basic-api/system/getAccountList',
  106. timeout: 100,
  107. method: 'get',
  108. response: ({ query }) => {
  109. const { page = 1, pageSize = 20 } = query;
  110. return resultPageSuccess(page, pageSize, accountList);
  111. },
  112. },
  113. {
  114. url: '/basic-api/system/getRoleListByPage',
  115. timeout: 100,
  116. method: 'get',
  117. response: ({ query }) => {
  118. const { page = 1, pageSize = 20 } = query;
  119. return resultPageSuccess(page, pageSize, roleList);
  120. },
  121. },
  122. {
  123. url: '/basic-api/system/getAllRoleList',
  124. timeout: 100,
  125. method: 'get',
  126. response: () => {
  127. return resultSuccess(roleList);
  128. },
  129. },
  130. {
  131. url: '/basic-api/system/getDeptList',
  132. timeout: 100,
  133. method: 'get',
  134. response: () => {
  135. return resultSuccess(deptList);
  136. },
  137. },
  138. {
  139. url: '/basic-api/system/getMenuList',
  140. timeout: 100,
  141. method: 'get',
  142. response: () => {
  143. return resultSuccess(menuList);
  144. },
  145. },
  146. ] as MockMethod[];