|
| 1 | +import Mock from 'mockjs'; |
| 2 | + |
| 3 | + |
| 4 | +const List = []; |
| 5 | +const count = 50; |
| 6 | + |
| 7 | +for (let i = 0; i < count; i++) { |
| 8 | + List.push(Mock.mock({ |
| 9 | + id: '@increment', |
| 10 | + timestamp: +Mock.Random.date('T'), |
| 11 | + author: '@cname', |
| 12 | + title: '@ctitle(10, 20)', |
| 13 | + forecast: '@float(0, 100, 2, 2)', |
| 14 | + importance: '@integer(1, 3)', |
| 15 | + 'calendar_type|1': ['FD', 'FE', 'BI', 'VN'], |
| 16 | + 'status|1': ['published', 'draft', 'deleted'] |
| 17 | + })); |
| 18 | +} |
| 19 | + |
| 20 | +export default { |
| 21 | + getList: config => |
| 22 | + // let {page, sortWay, startTime, endTime, userName, age} = config.params; |
| 23 | + // let mockUsers = _Users.filter(user => { |
| 24 | + // if (startTime && user.date < startTime) return false; |
| 25 | + // if (endTime && user.date > endTime) return false; |
| 26 | + // if (userName && user.name !== userName) return false; |
| 27 | + // if (age && user.age !== age) return false; |
| 28 | + // return true; |
| 29 | + // }); |
| 30 | + // if (sortWay) { |
| 31 | + // let {order, prop} = sortWay; |
| 32 | + // mockUsers = mockUsers.sort((u1, u2) => order === 'ascending' ? u1[prop] - u2[prop] : u2[prop] - u1[prop]); |
| 33 | + // } |
| 34 | + // if (page === 0) page++; |
| 35 | + // mockUsers = mockUsers.filter((u, index) => index < 20 * page && index >= 20 * (page - 1)); |
| 36 | + new Promise(resolve => { |
| 37 | + setTimeout(() => { |
| 38 | + resolve([200, { |
| 39 | + total: List.length, |
| 40 | + items: List |
| 41 | + }]); |
| 42 | + }, 100); |
| 43 | + }) |
| 44 | + |
| 45 | +}; |
0 commit comments