afterCollectionSearch.js 3.5 KB

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