accountingSubject.js 2.7 KB

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