system.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 deptList = (() => {
  20. const result: any[] = [];
  21. for (let index = 0; index < 3; index++) {
  22. result.push({
  23. id: `${index}`,
  24. deptName: ['华东分部', '华南分部', '西北分部'][index],
  25. orderNo: index + 1,
  26. createTime: '@datetime',
  27. remark: '@cword(10,20)',
  28. 'status|1': ['0', '0', '1'],
  29. children: (() => {
  30. const children: any[] = [];
  31. for (let j = 0; j < 4; j++) {
  32. children.push({
  33. id: `${index}-${j}`,
  34. deptName: ['研发部', '市场部', '商务部', '财务部'][j],
  35. orderNo: j + 1,
  36. createTime: '@datetime',
  37. remark: '@cword(10,20)',
  38. 'status|1': ['0', '1'],
  39. parentDept: `${index}`,
  40. children: undefined,
  41. });
  42. }
  43. return children;
  44. })(),
  45. });
  46. }
  47. return result;
  48. })();
  49. export default [
  50. {
  51. url: '/api/system/getAccountList',
  52. timeout: 100,
  53. method: 'get',
  54. response: ({ query }) => {
  55. const { page = 1, pageSize = 20 } = query;
  56. return resultPageSuccess(page, pageSize, accountList);
  57. },
  58. },
  59. {
  60. url: '/api/system/getDeptList',
  61. timeout: 100,
  62. method: 'get',
  63. response: () => {
  64. return resultSuccess(deptList);
  65. },
  66. },
  67. ] as MockMethod[];