visitsAndBedDayCostSetting.js 3.4 KB

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