reportProjectSetting.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * @Author: your name
  3. * @Date: 2021-08-04 15:09:41
  4. * @LastEditTime: 2021-08-04 18:23:17
  5. * @LastEditors: Please set LastEditors
  6. * @Description: In User Settings Edit
  7. * @FilePath: /CostAccountManaSys/mock/reportProjectSetting.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. num: `编号${i}`,
  20. reportName: `报表名${i}`,
  21. calcType:0,
  22. parentId:0,
  23. reportType:1,
  24. calcFormula:'[0]+[1]',
  25. sort:0,
  26. ratioBase:'100%',
  27. showAddRelation:1,
  28. children:[
  29. {
  30. key: index+i,
  31. id: index+i,
  32. num: `编号${i}`,
  33. reportName: `报表名${i}`,
  34. calcType:0,
  35. parentId:0,
  36. reportType:1,
  37. calcFormula:'[0]+[1]',
  38. sort:0,
  39. ratioBase:'100%',
  40. showAddRelation:2
  41. }
  42. ]
  43. });
  44. }
  45. // console.log({tableListDataSource});
  46. tableListDataSource.reverse();
  47. return tableListDataSource;
  48. };
  49. let tableListDataSource = genList(1, 100);
  50. function getList(req, res, u) {
  51. let realUrl = u;
  52. if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
  53. realUrl = req.url;
  54. }
  55. const { current = 1, pageSize = 10 } = req.query;
  56. let dataSource = [...tableListDataSource].slice((current - 1) * pageSize, current * pageSize);
  57. const result = {
  58. data: {
  59. list: dataSource,
  60. totalCount: tableListDataSource.length,
  61. pageSize: pageSize,
  62. },
  63. status: 200,
  64. success: true,
  65. };
  66. return res.json(result);
  67. }
  68. function postList(req, res, u, b) {
  69. let realUrl = u;
  70. if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
  71. realUrl = req.url;
  72. }
  73. const { method, body } = req;
  74. tableListDataSource.push({ ...body });
  75. const result = {
  76. status: 200,
  77. msg: '',
  78. };
  79. res.json(result);
  80. }
  81. function delList(req, res, u, b) {
  82. const { method, body } = req;
  83. tableListDataSource = tableListDataSource.filter((item) => !body.includes(item.roleId));
  84. const result = {
  85. status: 200,
  86. msg: '',
  87. };
  88. res.json(result);
  89. }
  90. function editList(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. function getRelationList(req, res, u, b){
  100. const data = [
  101. {
  102. code:97,
  103. name:'97name'
  104. },
  105. {
  106. code:92,
  107. name:'92name'
  108. }
  109. ];
  110. const result = {
  111. data:data,
  112. status: 200,
  113. msg: '',
  114. };
  115. res.json(result);
  116. }
  117. export default {
  118. 'GET /api/costAccount/reportForm/list': getList,
  119. 'POST /api/costAccount/reportForm/save': postList,
  120. 'POST /api/costAccount/reportForm/delete': delList,
  121. 'POST /api/costAccount/reportForm/edit': editList,
  122. 'GET /api/costAccount/reportForm/getRelationList': getRelationList,
  123. };