/* * @Author: your name * @Date: 2021-08-04 09:08:39 * @LastEditTime: 2021-08-11 17:58:29 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: /CostAccountManaSys/mock/incomeCollection.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, fileId: index, year:`year ${index}`, month:`month ${index}`, amount:1000, isCollection:true }); } // 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 getHasBindList(req, res, u, b){ const data = [ { id:98, accountingName:'会计科目98', accountingCode:98 }, { id:97, accountingName:'会计科目97', accountingCode:97 } ]; const result = { status: 200, msg: '', data:data }; res.json(result); } function bindList(req, res, u, b) { const { method, body } = req; const { roleId, userIds } = body; const result = { status: 200, msg: '', }; res.json(result); } export default { 'GET /api/costAccount/incomeCollection/getCollections': getList, 'POST /api/costAccount/costincomegroupset/addCostIncomeGroupSet': postList, 'GET /api/costAccount/costincomegroupset/getIncomeAccountStatus': getHasBindList, 'POST /api/costAccount/role/editUserRole': bindList, };