Skip to content

Commit 9e58315

Browse files
committed
博客专栏支持排序
1 parent d1d3770 commit 9e58315

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/service/column.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ export const apiColumnArticleAllList = (paramsData) => {
5959
}
6060
})
6161
}
62+
63+
export const apiColumnChangeSort = (paramsData) => {
64+
return Vue.axios.post('/column/changeSort', {
65+
...paramsData
66+
},
67+
{
68+
showLoading: true
69+
})
70+
}

src/views/AdminColumn.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
<el-page-header @back="$router.back()" content="专栏列表"></el-page-header>
44
<div class="row">
55
<el-button plain @click="addColumn">添加专栏</el-button>
6+
<el-button plain @click="changeSort">更新排序</el-button>
67
</div>
8+
<div class="row">提示:排序值尽量填不同的数值,以免排列顺序有误。</div>
79
<el-table
810
v-if="tableData.length"
911
:data="tableData"
@@ -26,6 +28,20 @@
2628
label="创建时间"
2729
width="240">
2830
</el-table-column>
31+
<el-table-column
32+
label="排序"
33+
width="155">
34+
<template slot-scope="scope">
35+
<el-input-number
36+
v-model="scope.row.columnSort"
37+
:min="1"
38+
size="mini"
39+
:step="1"
40+
placeholder="排序数值"
41+
step-strictly>
42+
</el-input-number>
43+
</template>
44+
</el-table-column>
2945
<el-table-column
3046
label="操作"
3147
width="220">
@@ -48,7 +64,7 @@
4864

4965
<script>
5066
import { mapState } from 'vuex'
51-
import { apiColumnList, apiColumnDelete } from './../service/column'
67+
import { apiColumnList, apiColumnDelete, apiColumnChangeSort } from './../service/column'
5268
export default {
5369
name: 'AdminColumn',
5470
data () {
@@ -126,6 +142,14 @@ export default {
126142
})
127143
this.apiColumnListMethod()
128144
}
145+
},
146+
async changeSort () {
147+
let result = await apiColumnChangeSort({
148+
list: this.tableData
149+
})
150+
if (result.isok) {
151+
this.apiColumnListMethod()
152+
}
129153
}
130154
}
131155
}

0 commit comments

Comments
 (0)