123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- /*
- * @Author: your name
- * @Date: 2021-08-04 15:09:41
- * @LastEditTime: 2021-08-04 18:23:17
- * @LastEditors: Please set LastEditors
- * @Description: In User Settings Edit
- * @FilePath: /CostAccountManaSys/mock/reportProjectSetting.js
- */
- // eslint-disable-next-line import/no-extraneous-dependencies
- import moment from 'moment';
- import { parse } from 'url'; // mock tableListDataSource
- const genList = (current, pageSize) => {
- const tableListDataSource = [];
- for (let i = 0; i < pageSize; i += 1) {
- const index = (current - 1) * 10 + i;
- tableListDataSource.push({
- key: index,
- id: index,
- num: `编号${i}`,
- reportName: `报表名${i}`,
- calcType:0,
- parentId:0,
- reportType:1,
- calcFormula:'[0]+[1]',
- sort:0,
- ratioBase:'100%',
- showAddRelation:1,
- children:[
- {
- key: index+i,
- id: index+i,
- num: `编号${i}`,
- reportName: `报表名${i}`,
- calcType:0,
- parentId:0,
- reportType:1,
- calcFormula:'[0]+[1]',
- sort:0,
- ratioBase:'100%',
- showAddRelation:2
- }
- ]
- });
- }
- // console.log({tableListDataSource});
- tableListDataSource.reverse();
- return tableListDataSource;
- };
- let tableListDataSource = genList(1, 100);
- function getList(req, res, u) {
- let realUrl = u;
- if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
- realUrl = req.url;
- }
- const { current = 1, pageSize = 10 } = req.query;
- let dataSource = [...tableListDataSource].slice((current - 1) * pageSize, current * pageSize);
- const result = {
- data: {
- list: dataSource,
- totalCount: tableListDataSource.length,
- pageSize: pageSize,
- },
- status: 200,
- success: true,
- };
- return res.json(result);
- }
- function postList(req, res, u, b) {
- let realUrl = u;
- if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
- realUrl = req.url;
- }
- const { method, body } = req;
- tableListDataSource.push({ ...body });
- const result = {
- status: 200,
- msg: '',
- };
- res.json(result);
- }
- function delList(req, res, u, b) {
- const { method, body } = req;
- tableListDataSource = tableListDataSource.filter((item) => !body.includes(item.roleId));
- const result = {
- status: 200,
- msg: '',
- };
- res.json(result);
- }
- function editList(req, res, u, b) {
- const { method, body } = req;
- const { roleId, userIds } = body;
- const result = {
- status: 200,
- msg: '',
- };
- res.json(result);
- }
- function getRelationList(req, res, u, b){
- const data = [
- {
- code:97,
- name:'97name'
- },
- {
- code:92,
- name:'92name'
- }
- ];
- const result = {
- data:data,
- status: 200,
- msg: '',
- };
- res.json(result);
- }
- export default {
- 'GET /api/costAccount/reportForm/list': getList,
- 'POST /api/costAccount/reportForm/save': postList,
- 'POST /api/costAccount/reportForm/delete': delList,
- 'POST /api/costAccount/reportForm/edit': editList,
- 'GET /api/costAccount/reportForm/getRelationList': getRelationList,
- };
|