incomeCostDataImport.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-08-12 09:44:05
  4. * @LastEditTime: 2021-08-12 09:49:58
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /CostAccountManaSys/mock/incomeCostDataImport.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. id: index,
  19. allocation: 1,
  20. incomeType: 1,
  21. errStatus: 1,
  22. });
  23. }
  24. // console.log({tableListDataSource});
  25. tableListDataSource.reverse();
  26. return tableListDataSource;
  27. };
  28. let tableListDataSource = genList(1, 100);
  29. function getList(req, res, u) {
  30. let realUrl = u;
  31. if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
  32. realUrl = req.url;
  33. }
  34. const { current = 1, pageSize = 10 } = req.query;
  35. let dataSource = [...tableListDataSource].slice((current - 1) * pageSize, current * pageSize);
  36. const result = {
  37. data: {
  38. list: dataSource,
  39. totalCount: tableListDataSource.length,
  40. pageSize: pageSize,
  41. },
  42. status: 200,
  43. success: true,
  44. };
  45. return res.json(result);
  46. }
  47. function postList(req, res, u, b) {
  48. let realUrl = u;
  49. if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
  50. realUrl = req.url;
  51. }
  52. const { method, body } = req;
  53. tableListDataSource.push({ ...body });
  54. const result = {
  55. status: 200,
  56. msg: '',
  57. };
  58. res.json(result);
  59. }
  60. function delList(req, res, u, b) {
  61. const { method, body } = req;
  62. tableListDataSource = tableListDataSource.filter((item) => !body.includes(item.roleId));
  63. const result = {
  64. status: 200,
  65. msg: '',
  66. };
  67. res.json(result);
  68. }
  69. function getHasBindList(req, res, u, b) {
  70. const data = [
  71. {
  72. total: 123,
  73. errMessage: '错误信息',
  74. },
  75. {
  76. total: 123,
  77. errMessage: '错误信息',
  78. },
  79. {
  80. total: 123,
  81. errMessage: '错误信息',
  82. },
  83. ];
  84. const result = {
  85. status: 200,
  86. msg: '',
  87. data: data,
  88. };
  89. res.json(result);
  90. }
  91. function getHasBindMenuList(req, res, u, b) {
  92. const data = [
  93. {
  94. id: 98,
  95. name: '菜单98',
  96. },
  97. {
  98. id: 92,
  99. name: '菜单92',
  100. },
  101. ];
  102. const result = {
  103. status: 200,
  104. msg: '',
  105. data: data,
  106. };
  107. res.json(result);
  108. }
  109. function bindList(req, res, u, b) {
  110. const { method, body } = req;
  111. const { roleId, userIds } = body;
  112. const result = {
  113. status: 200,
  114. msg: '',
  115. };
  116. res.json(result);
  117. }
  118. export default {
  119. 'GET /api/costAccount/costincomefile/list': getList,
  120. 'GET /api/costAccount/costincomefile/getErrorList': getHasBindList,
  121. 'GET /api/costAccount/role/roleMenus': getHasBindMenuList,
  122. 'POST /api/costAccount/role/save': postList,
  123. 'POST /api/costAccount/role/delete': delList,
  124. 'POST /api/costAccount/role/editUserRole': bindList,
  125. };