提交 b90e0512 编写于 作者: RedPig97's avatar RedPig97

update: 代办列表支持排序

上级 4e443d1d
<template> <template>
<div class='app-todo-list'> <div class='app-todo-list'>
<i-input v-model="query" search enter-button @on-search="handleSearch" class='app-todo-list__search' placeHolder="标题"/> <i-input v-model="query" search enter-button @on-search="handleSearch" class='app-todo-list__search' placeHolder="标题"/>
<el-table :data="myTasks" :border="true"> <el-table :data="myTasks" :border="true" @sort-change="handleSortChange">
<el-table-column prop="" sortable label="标题"> <el-table-column prop="" sortable label="标题">
<template slot-scope="scope"> <template slot-scope="scope">
<span class="title" @click="handleClick(scope.row)">{{ scope.row.description }}</span> <span class="title" @click="handleClick(scope.row)">{{ scope.row.description }}</span>
...@@ -61,6 +61,11 @@ export default class AppTodoList extends Vue { ...@@ -61,6 +61,11 @@ export default class AppTodoList extends Vue {
*/ */
public total: number = 0; public total: number = 0;
/**
* 排序字段
*/
public sort: string = '';
/** /**
* vue创建 * vue创建
*/ */
...@@ -80,6 +85,9 @@ export default class AppTodoList extends Vue { ...@@ -80,6 +85,9 @@ export default class AppTodoList extends Vue {
if (this.query) { if (this.query) {
Object.assign(params, {query: this.query}); Object.assign(params, {query: this.query});
} }
if (this.sort) {
Object.assign(params, {sort: this.sort});
}
Http.getInstance().get(url, params).then((response: any) => { Http.getInstance().get(url, params).then((response: any) => {
if (response && response.status == 200) { if (response && response.status == 200) {
if(response.headers['x-total']){ if(response.headers['x-total']){
...@@ -144,6 +152,16 @@ export default class AppTodoList extends Vue { ...@@ -144,6 +152,16 @@ export default class AppTodoList extends Vue {
this.getMyTasks(); this.getMyTasks();
} }
/**
* 处理排序改变
*/
public handleSortChange($event: any) {
const { prop, order } = $event;
const dir = Object.is(order, 'ascending') ? 'asc' : Object.is(order, 'descending') ? 'desc' : '';
this.sort = `${prop},${dir}`;
this.getMyTasks();
}
} }
</script> </script>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册