table example add sort

This commit is contained in:
Pan
2017-05-08 22:55:09 +08:00
parent f1c807ab12
commit 7225333018
2 changed files with 15 additions and 3 deletions

View File

@@ -21,14 +21,19 @@ for (let i = 0; i < count; i++) {
export default {
getList: config => {
const { importance, type, title, page, limit } = config.params;
const mockList = List.filter(item => {
const { importance, type, title, page, limit, sort } = config.params;
let mockList = List.filter(item => {
if (importance && item.importance !== importance) return false;
if (type && item.type !== type) return false;
if (title && item.title.indexOf(title) < 0) return false;
return true;
});
if (sort === '-id') {
mockList = mockList.reverse()
}
const pageList = mockList.filter((item, index) => index < limit * page && index >= limit * (page - 1));
return new Promise(resolve => {
setTimeout(() => {
resolve([200, {