userManagement.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const totalCount = 3
  2. const List = [
  3. {
  4. id: '@id',
  5. username: 'admin',
  6. password: 'admin',
  7. email: '@email',
  8. permissions: ['admin'],
  9. datatime: '@datetime',
  10. },
  11. {
  12. id: '@id',
  13. username: 'editor',
  14. password: 'editor',
  15. email: '@email',
  16. permissions: ['editor'],
  17. datatime: '@datetime',
  18. },
  19. {
  20. id: '@id',
  21. username: 'test',
  22. password: 'test',
  23. email: '@email',
  24. permissions: ['admin', 'editor'],
  25. datatime: '@datetime',
  26. },
  27. ]
  28. module.exports = [
  29. {
  30. url: '/userManagement/getList',
  31. type: 'post',
  32. response(config) {
  33. const { title = '', pageNo = 1, pageSize = 20 } = config.body
  34. let mockList = List.filter((item) => {
  35. if (title && item.title.indexOf(title) < 0) return false
  36. return true
  37. })
  38. const pageList = mockList.filter(
  39. (item, index) =>
  40. index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
  41. )
  42. return {
  43. code: 200,
  44. msg: 'success',
  45. totalCount,
  46. data: pageList,
  47. }
  48. },
  49. },
  50. {
  51. url: '/userManagement/doEdit',
  52. type: 'post',
  53. response() {
  54. return {
  55. code: 200,
  56. msg: '模拟保存成功',
  57. }
  58. },
  59. },
  60. {
  61. url: '/userManagement/doDelete',
  62. type: 'post',
  63. response() {
  64. return {
  65. code: 200,
  66. msg: '模拟删除成功',
  67. }
  68. },
  69. },
  70. ]