add table demo
This commit is contained in:
45
src/mock/article_table.js
Normal file
45
src/mock/article_table.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import Mock from 'mockjs';
|
||||
|
||||
|
||||
const List = [];
|
||||
const count = 50;
|
||||
|
||||
for (let i = 0; i < count; i++) {
|
||||
List.push(Mock.mock({
|
||||
id: '@increment',
|
||||
timestamp: +Mock.Random.date('T'),
|
||||
author: '@cname',
|
||||
title: '@ctitle(10, 20)',
|
||||
forecast: '@float(0, 100, 2, 2)',
|
||||
importance: '@integer(1, 3)',
|
||||
'calendar_type|1': ['FD', 'FE', 'BI', 'VN'],
|
||||
'status|1': ['published', 'draft', 'deleted']
|
||||
}));
|
||||
}
|
||||
|
||||
export default {
|
||||
getList: config =>
|
||||
// let {page, sortWay, startTime, endTime, userName, age} = config.params;
|
||||
// let mockUsers = _Users.filter(user => {
|
||||
// if (startTime && user.date < startTime) return false;
|
||||
// if (endTime && user.date > endTime) return false;
|
||||
// if (userName && user.name !== userName) return false;
|
||||
// if (age && user.age !== age) return false;
|
||||
// return true;
|
||||
// });
|
||||
// if (sortWay) {
|
||||
// let {order, prop} = sortWay;
|
||||
// mockUsers = mockUsers.sort((u1, u2) => order === 'ascending' ? u1[prop] - u2[prop] : u2[prop] - u1[prop]);
|
||||
// }
|
||||
// if (page === 0) page++;
|
||||
// mockUsers = mockUsers.filter((u, index) => index < 20 * page && index >= 20 * (page - 1));
|
||||
new Promise(resolve => {
|
||||
setTimeout(() => {
|
||||
resolve([200, {
|
||||
total: List.length,
|
||||
items: List
|
||||
}]);
|
||||
}, 100);
|
||||
})
|
||||
|
||||
};
|
@@ -1,6 +1,7 @@
|
||||
import axios from 'axios';
|
||||
import Mock from 'mockjs';
|
||||
import MockAdapter from 'axios-mock-adapter';
|
||||
import article_tableAPI from './article_table'
|
||||
const mock = new MockAdapter(axios);
|
||||
|
||||
const articleList = {
|
||||
@@ -15,4 +16,10 @@ const articleList = {
|
||||
}
|
||||
const data = JSON.stringify(Mock.mock(articleList))
|
||||
mock.onGet('/article/list').reply(200, data);
|
||||
|
||||
|
||||
mock.onGet('/article_table/list').reply(article_tableAPI.getList);
|
||||
|
||||
|
||||
|
||||
export default mock;
|
||||
|
Reference in New Issue
Block a user