incomeCollection.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-08-04 09:08:39
  4. * @LastEditTime: 2021-08-11 17:58:29
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /CostAccountManaSys/mock/incomeCollection.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. fileId: index,
  19. year:`year ${index}`,
  20. month:`month ${index}`,
  21. amount:1000,
  22. isCollection:true
  23. });
  24. }
  25. // console.log({tableListDataSource});
  26. tableListDataSource.reverse();
  27. return tableListDataSource;
  28. };
  29. let tableListDataSource = genList(1, 100);
  30. function getList(req, res, u) {
  31. let realUrl = u;
  32. if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
  33. realUrl = req.url;
  34. }
  35. const { current = 1, pageSize = 10 } = req.query;
  36. let dataSource = [...tableListDataSource].slice((current - 1) * pageSize, current * pageSize);
  37. const result = {
  38. data: {
  39. list: dataSource,
  40. totalCount: tableListDataSource.length,
  41. pageSize: pageSize,
  42. },
  43. status: 200,
  44. success: true,
  45. };
  46. return res.json(result);
  47. }
  48. function postList(req, res, u, b) {
  49. let realUrl = u;
  50. if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
  51. realUrl = req.url;
  52. }
  53. const { method, body } = req;
  54. tableListDataSource.push({ ...body });
  55. const result = {
  56. status: 200,
  57. msg: '',
  58. };
  59. res.json(result);
  60. }
  61. function delList(req, res, u, b) {
  62. const { method, body } = req;
  63. tableListDataSource = tableListDataSource.filter((item) => !body.includes(item.roleId));
  64. const result = {
  65. status: 200,
  66. msg: '',
  67. };
  68. res.json(result);
  69. }
  70. function getHasBindList(req, res, u, b){
  71. const data = [
  72. {
  73. id:98,
  74. accountingName:'会计科目98',
  75. accountingCode:98
  76. },
  77. {
  78. id:97,
  79. accountingName:'会计科目97',
  80. accountingCode:97
  81. }
  82. ];
  83. const result = {
  84. status: 200,
  85. msg: '',
  86. data:data
  87. };
  88. res.json(result);
  89. }
  90. function bindList(req, res, u, b) {
  91. const { method, body } = req;
  92. const { roleId, userIds } = body;
  93. const result = {
  94. status: 200,
  95. msg: '',
  96. };
  97. res.json(result);
  98. }
  99. export default {
  100. 'GET /api/costAccount/incomeCollection/getCollections': getList,
  101. 'POST /api/costAccount/costincomegroupset/addCostIncomeGroupSet': postList,
  102. 'GET /api/costAccount/costincomegroupset/getIncomeAccountStatus': getHasBindList,
  103. 'POST /api/costAccount/role/editUserRole': bindList,
  104. };