diff --git a/src/mock/article_table.js b/src/mock/article_table.js index a85f74a3..8320fe0c 100644 --- a/src/mock/article_table.js +++ b/src/mock/article_table.js @@ -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, { diff --git a/src/views/example/table.vue b/src/views/example/table.vue index 8631df1f..69e53179 100644 --- a/src/views/example/table.vue +++ b/src/views/example/table.vue @@ -14,6 +14,11 @@ + + + + + 搜索 添加 导出 @@ -174,7 +179,8 @@ limit: 20, importance: undefined, title: undefined, - type: undefined + type: undefined, + sort: '+id' }, temp: { id: undefined, @@ -187,6 +193,7 @@ }, importanceOptions: [1, 2, 3], calendarTypeOptions, + sortOptions: [{ label: '按ID升序列', key: '+id' }, { label: '按ID降序', key: '-id' }], statusOptions: ['published', 'draft', 'deleted'], dialogFormVisible: false, dialogStatus: '',