costShareParams.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-08-04 18:43:08
  4. * @LastEditTime: 2021-08-04 18:44:57
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /CostAccountManaSys/mock/costShareParams.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. calcType:1,
  20. shareParamCode:index,
  21. shareParamName:`分摊参数名${i}`,
  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 bindList(req, res, u, b) {
  70. const { method, body } = req;
  71. const { roleId, userIds } = body;
  72. const result = {
  73. status: 200,
  74. msg: '',
  75. };
  76. res.json(result);
  77. }
  78. export default {
  79. 'GET /api/costAccount/costshareparam/list': getList,
  80. // 'POST /api/costAccount/costincomegroupset/addCostIncomeGroupSet': postList,
  81. // 'POST /api/costAccount/role/delete': delList,
  82. // 'POST /api/costAccount/role/editUserRole': bindList,
  83. };