menu.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-08-03 14:39:54
  4. * @LastEditTime: 2021-08-03 16:36:21
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /CostAccountManaSys/mock/menu.js
  8. */
  9. // eslint-disable-next-line import/no-extraneous-dependencies
  10. import moment from 'moment';
  11. import { parse } from 'url'; // mock tableListDataSource
  12. const genList = (current, pageSize) => {
  13. const tableListDataSource = [];
  14. for (let i = 0; i < pageSize; i += 1) {
  15. const index = (current - 1) * 10 + i;
  16. tableListDataSource.push({
  17. key: index,
  18. menuId: index,
  19. parentId:index,
  20. name: `菜单名 ${i}`,
  21. path: `path路径 ${i}`,
  22. url:`url路径 ${i}`,
  23. perms:`授权 ${i}`,
  24. type:0,
  25. icon:`图标 ${i}`,
  26. orderNum:`排序 ${i}`,
  27. modifyUserName:`修改人 ${i}`,
  28. children:[
  29. {
  30. key:`${i}${index}`,
  31. menuId:`${i}${index}`,
  32. parentId:index+1,
  33. name: `菜单名 ${i}`,
  34. path: `path路径 ${i}`,
  35. url:`url路径 ${i}`,
  36. perms:`授权 ${i}`,
  37. type:0,
  38. icon:`图标 ${i}`,
  39. orderNum:`排序 ${i}`,
  40. modifyUserName:`修改人 ${i}`,
  41. }
  42. ],
  43. modifyTime: moment().format('YYYY-MM-DD'),
  44. });
  45. }
  46. // console.log({tableListDataSource});
  47. tableListDataSource.reverse();
  48. return tableListDataSource;
  49. };
  50. let tableListDataSource = genList(1, 100);
  51. function getList(req, res, u) {
  52. let realUrl = u;
  53. if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
  54. realUrl = req.url;
  55. }
  56. const { current = 1, pageSize = 10 } = req.query;
  57. let dataSource = [...tableListDataSource].slice((current - 1) * pageSize, current * pageSize);
  58. const result = {
  59. data: {
  60. list: dataSource,
  61. totalCount: tableListDataSource.length,
  62. pageSize: pageSize,
  63. },
  64. status: 200,
  65. success: true,
  66. };
  67. return res.json(result);
  68. }
  69. function postList(req, res, u, b) {
  70. const result = {
  71. status: 200,
  72. msg: '',
  73. };
  74. res.json(result);
  75. }
  76. function delList(req, res, u, b) {
  77. const { method, body } = req;
  78. tableListDataSource = tableListDataSource.filter((item) => !body.includes(item.roleId));
  79. const result = {
  80. status: 200,
  81. msg: '',
  82. };
  83. res.json(result);
  84. }
  85. function editList(req, res, u, b) {
  86. const { method, body } = req;
  87. const { roleId, userIds } = body;
  88. const result = {
  89. status: 200,
  90. msg: '',
  91. };
  92. res.json(result);
  93. }
  94. export default {
  95. 'GET /api/costAccount/menu/list': getList,
  96. 'POST /api/costAccount/menu/save': postList,
  97. 'POST /api/costAccount/menu/edit': editList,
  98. };