role.mock.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. import { defineMock } from './base'
  2. export default defineMock([
  3. {
  4. url: 'roles/options',
  5. method: ['GET'],
  6. body: {
  7. code: '200',
  8. data: [
  9. {
  10. value: 2,
  11. label: '系统管理员'
  12. },
  13. {
  14. value: 4,
  15. label: '系统管理员1'
  16. },
  17. {
  18. value: 5,
  19. label: '系统管理员2'
  20. },
  21. {
  22. value: 6,
  23. label: '系统管理员3'
  24. },
  25. {
  26. value: 7,
  27. label: '系统管理员4'
  28. },
  29. {
  30. value: 8,
  31. label: '系统管理员5'
  32. },
  33. {
  34. value: 9,
  35. label: '系统管理员6'
  36. },
  37. {
  38. value: 10,
  39. label: '系统管理员7'
  40. },
  41. {
  42. value: 11,
  43. label: '系统管理员8'
  44. },
  45. {
  46. value: 12,
  47. label: '系统管理员9'
  48. },
  49. {
  50. value: 3,
  51. label: '访问游客'
  52. }
  53. ],
  54. message: '一切ok'
  55. }
  56. },
  57. {
  58. url: 'roles/page',
  59. method: ['GET'],
  60. body: {
  61. code: '200',
  62. data: {
  63. list: [
  64. {
  65. id: 2,
  66. name: '系统管理员',
  67. code: 'ADMIN',
  68. status: 1,
  69. sort: 2,
  70. createTime: '2021-03-25 12:39:54',
  71. updateTime: null
  72. },
  73. {
  74. id: 3,
  75. name: '访问游客',
  76. code: 'GUEST',
  77. status: 1,
  78. sort: 3,
  79. createTime: '2021-05-26 15:49:05',
  80. updateTime: '2019-05-05 16:00:00'
  81. },
  82. {
  83. id: 4,
  84. name: '系统管理员1',
  85. code: 'ADMIN1',
  86. status: 1,
  87. sort: 2,
  88. createTime: '2021-03-25 12:39:54',
  89. updateTime: null
  90. },
  91. {
  92. id: 5,
  93. name: '系统管理员2',
  94. code: 'ADMIN2',
  95. status: 1,
  96. sort: 2,
  97. createTime: '2021-03-25 12:39:54',
  98. updateTime: null
  99. },
  100. {
  101. id: 6,
  102. name: '系统管理员3',
  103. code: 'ADMIN3',
  104. status: 1,
  105. sort: 2,
  106. createTime: '2021-03-25 12:39:54',
  107. updateTime: null
  108. },
  109. {
  110. id: 7,
  111. name: '系统管理员4',
  112. code: 'ADMIN4',
  113. status: 1,
  114. sort: 2,
  115. createTime: '2021-03-25 12:39:54',
  116. updateTime: null
  117. },
  118. {
  119. id: 8,
  120. name: '系统管理员5',
  121. code: 'ADMIN5',
  122. status: 1,
  123. sort: 2,
  124. createTime: '2021-03-25 12:39:54',
  125. updateTime: null
  126. },
  127. {
  128. id: 9,
  129. name: '系统管理员6',
  130. code: 'ADMIN6',
  131. status: 1,
  132. sort: 2,
  133. createTime: '2021-03-25 12:39:54',
  134. updateTime: '2023-12-04 11:43:15'
  135. },
  136. {
  137. id: 10,
  138. name: '系统管理员7',
  139. code: 'ADMIN7',
  140. status: 1,
  141. sort: 2,
  142. createTime: '2021-03-25 12:39:54',
  143. updateTime: null
  144. },
  145. {
  146. id: 11,
  147. name: '系统管理员8',
  148. code: 'ADMIN8',
  149. status: 1,
  150. sort: 2,
  151. createTime: '2021-03-25 12:39:54',
  152. updateTime: null
  153. }
  154. ],
  155. total: 10
  156. },
  157. message: '一切ok'
  158. }
  159. },
  160. // 新增角色
  161. {
  162. url: 'roles',
  163. method: ['POST'],
  164. body({ body }) {
  165. return {
  166. code: '200',
  167. data: null,
  168. message: '新增角色' + body.name + '成功'
  169. }
  170. }
  171. },
  172. // 获取角色表单数据
  173. {
  174. url: 'roles/:id/form',
  175. method: ['GET'],
  176. body: ({ params }) => {
  177. return {
  178. code: '200',
  179. data: roleMap[params.id],
  180. message: '一切ok'
  181. }
  182. }
  183. },
  184. // 修改角色
  185. {
  186. url: 'roles/:id',
  187. method: ['PUT'],
  188. body({ body }) {
  189. return {
  190. code: '200',
  191. data: null,
  192. message: '修改角色' + body.name + '成功'
  193. }
  194. }
  195. },
  196. // 删除角色
  197. {
  198. url: 'roles/:id',
  199. method: ['DELETE'],
  200. body({ params }) {
  201. return {
  202. code: '200',
  203. data: null,
  204. message: '删除角色' + params.id + '成功'
  205. }
  206. }
  207. },
  208. // 获取角色拥有的菜单ID
  209. {
  210. url: 'roles/:id/menuIds',
  211. method: ['GET'],
  212. body: ({ params }) => {
  213. return {
  214. code: '200',
  215. data: [
  216. 1, 2, 31, 32, 33, 88, 3, 70, 71, 72, 4, 73, 75, 74, 5, 76, 77, 78, 6, 79, 81, 84, 85, 86, 87, 40, 41, 26, 30, 20, 21, 22, 23, 24, 89, 90, 91, 36, 37,
  217. 38, 39, 93, 94, 95, 97, 102, 89, 90, 91, 93, 94, 95, 97, 102, 103, 104
  218. ],
  219. message: '一切ok'
  220. }
  221. }
  222. },
  223. // 保存角色菜单
  224. {
  225. url: 'roles/:id/menus',
  226. method: ['PUT'],
  227. body: {
  228. code: '200',
  229. data: null,
  230. message: '一切ok'
  231. }
  232. }
  233. ])
  234. // 角色映射表数据
  235. const roleMap: Record<string, any> = {
  236. 2: {
  237. id: 2,
  238. name: '系统管理员',
  239. code: 'ADMIN',
  240. status: 1,
  241. sort: 2,
  242. createTime: '2021-03-25 12:39:54',
  243. updateTime: null
  244. },
  245. 3: {
  246. id: 3,
  247. name: '访问游客',
  248. code: 'GUEST',
  249. status: 1,
  250. sort: 3,
  251. createTime: '2021-05-26 15:49:05',
  252. updateTime: '2019-05-05 16:00:00'
  253. },
  254. 4: {
  255. id: 4,
  256. name: '系统管理员1',
  257. code: 'ADMIN1',
  258. status: 1,
  259. sort: 2,
  260. createTime: '2021-03-25 12:39:54',
  261. updateTime: null
  262. },
  263. 5: {
  264. id: 5,
  265. name: '系统管理员2',
  266. code: 'ADMIN2',
  267. status: 1,
  268. sort: 2,
  269. createTime: '2021-03-25 12:39:54',
  270. updateTime: null
  271. },
  272. 6: {
  273. id: 6,
  274. name: '系统管理员3',
  275. code: 'ADMIN3',
  276. status: 1,
  277. sort: 2,
  278. createTime: '2021-03-25 12:39:54',
  279. updateTime: null
  280. },
  281. 7: {
  282. id: 7,
  283. name: '系统管理员4',
  284. code: 'ADMIN4',
  285. status: 1,
  286. sort: 2,
  287. createTime: '2021-03-25 12:39:54',
  288. updateTime: null
  289. },
  290. 8: {
  291. id: 8,
  292. name: '系统管理员5',
  293. code: 'ADMIN5',
  294. status: 1,
  295. sort: 2,
  296. createTime: '2021-03-25 12:39:54',
  297. updateTime: null
  298. },
  299. 9: {
  300. id: 9,
  301. name: '系统管理员6',
  302. code: 'ADMIN6',
  303. status: 1,
  304. sort: 2,
  305. createTime: '2021-03-25 12:39:54',
  306. updateTime: '2023-12-04 11:43:15'
  307. },
  308. 10: {
  309. id: 10,
  310. name: '系统管理员7',
  311. code: 'ADMIN7',
  312. status: 1,
  313. sort: 2,
  314. createTime: '2021-03-25 12:39:54',
  315. updateTime: null
  316. },
  317. 11: {
  318. id: 11,
  319. name: '系统管理员8',
  320. code: 'ADMIN8',
  321. status: 1,
  322. sort: 2,
  323. createTime: '2021-03-25 12:39:54',
  324. updateTime: null
  325. }
  326. }