departmentManagement.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const { mock } = require("mockjs");
  2. const List = [
  3. {
  4. id: "root",
  5. createTime: "@datetime",
  6. name: "根节点",
  7. order: 0,
  8. children: [
  9. {
  10. id: "1",
  11. parentId: "root",
  12. parentName: "根节点",
  13. createTime: "@datetime",
  14. name: "桃花坞",
  15. order: 0,
  16. },
  17. {
  18. id: "2",
  19. parentId: "root",
  20. parentName: "根节点",
  21. createTime: "@datetime",
  22. name: "少林寺",
  23. order: 1,
  24. children: [
  25. {
  26. id: "@uuid",
  27. parentId: "2",
  28. parentName: "少林寺",
  29. createTime: "@datetime",
  30. name: "达摩院",
  31. order: 0,
  32. },
  33. {
  34. id: "@uuid",
  35. parentId: "2",
  36. parentName: "少林寺",
  37. createTime: "@datetime",
  38. name: "戒律堂",
  39. order: 1,
  40. },
  41. ],
  42. },
  43. ],
  44. },
  45. ];
  46. module.exports = [
  47. {
  48. url: "/departmentManagement/getList",
  49. type: "get",
  50. response: (config) => {
  51. const { name, pageNo = 1, pageSize = 20 } = config.query;
  52. let mockList = List.filter((item) => {
  53. if (name && item.name.indexOf(name) < 0) return false;
  54. return true;
  55. });
  56. const pageList = mockList.filter(
  57. (item, index) =>
  58. index < pageSize * pageNo && index >= pageSize * (pageNo - 1)
  59. );
  60. return {
  61. code: 200,
  62. msg: "success",
  63. totalCount: mockList.length,
  64. data: pageList,
  65. };
  66. },
  67. },
  68. {
  69. url: "/departmentManagement/doEdit",
  70. type: "post",
  71. response: () => {
  72. return {
  73. code: 200,
  74. msg: "模拟保存成功",
  75. };
  76. },
  77. },
  78. {
  79. url: "/departmentManagement/doDelete",
  80. type: "post",
  81. response: () => {
  82. return {
  83. code: 200,
  84. msg: "模拟删除成功",
  85. };
  86. },
  87. },
  88. ];