forked from AkkomaGang/admin-fe
add sort table
This commit is contained in:
parent
42f365535d
commit
0a489e7ac5
4 changed files with 138 additions and 218 deletions
|
@ -27,13 +27,14 @@
|
||||||
"nprogress": "0.2.0",
|
"nprogress": "0.2.0",
|
||||||
"showdown": "1.6.4",
|
"showdown": "1.6.4",
|
||||||
"simplemde": "1.11.2",
|
"simplemde": "1.11.2",
|
||||||
|
"sortablejs": "^1.5.1",
|
||||||
"vue": "2.2.6",
|
"vue": "2.2.6",
|
||||||
|
"vue-count-to": "1.0.5",
|
||||||
"vue-multiselect": "2.0.0-beta.14",
|
"vue-multiselect": "2.0.0-beta.14",
|
||||||
"vue-router": "2.3.0",
|
"vue-router": "2.3.0",
|
||||||
"vuedraggable": "2.8.4",
|
"vuedraggable": "2.8.4",
|
||||||
"vuex": "2.2.1",
|
"vuex": "2.2.1",
|
||||||
"xlsx": "0.8.1",
|
"xlsx": "0.8.1"
|
||||||
"vue-count-to":"1.0.5"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"autoprefixer": "6.7.2",
|
"autoprefixer": "6.7.2",
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -53,6 +53,7 @@ const Theme = resolve => require(['../views/theme/index'], resolve);
|
||||||
/* example*/
|
/* example*/
|
||||||
const DynamicTable = resolve => require(['../views/example/dynamictable'], resolve);
|
const DynamicTable = resolve => require(['../views/example/dynamictable'], resolve);
|
||||||
const Table = resolve => require(['../views/example/table'], resolve);
|
const Table = resolve => require(['../views/example/table'], resolve);
|
||||||
|
const DragTable = resolve => require(['../views/example/dragTable'], resolve);
|
||||||
const Form1 = resolve => require(['../views/example/form1'], resolve);
|
const Form1 = resolve => require(['../views/example/form1'], resolve);
|
||||||
// const Form2 = resolve => require(['../views/example/form2'], resolve);
|
// const Form2 = resolve => require(['../views/example/form2'], resolve);
|
||||||
|
|
||||||
|
@ -178,6 +179,7 @@ export default new Router({
|
||||||
icon: 'zonghe',
|
icon: 'zonghe',
|
||||||
children: [
|
children: [
|
||||||
{ path: 'dynamictable', component: DynamicTable, name: '动态table' },
|
{ path: 'dynamictable', component: DynamicTable, name: '动态table' },
|
||||||
|
{ path: 'dragtable', component: DragTable, name: '拖拽table' },
|
||||||
{ path: 'table', component: Table, name: '综合table' },
|
{ path: 'table', component: Table, name: '综合table' },
|
||||||
{ path: 'form1', component: Form1, name: '综合form1' }
|
{ path: 'form1', component: Form1, name: '综合form1' }
|
||||||
// { path: 'form2', component: Form2, name: '综合form2' }
|
// { path: 'form2', component: Form2, name: '综合form2' }
|
||||||
|
|
132
src/views/example/dragTable.vue
Normal file
132
src/views/example/dragTable.vue
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container calendar-list-container">
|
||||||
|
|
||||||
|
<el-table :data="list" v-loading.body="listLoading" border fit highlight-current-row style="width: 100%">
|
||||||
|
|
||||||
|
<el-table-column align="center" label="序号" width="65">
|
||||||
|
<template scope="scope">
|
||||||
|
<span>{{scope.row.id}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column width="180px" align="center" label="时间">
|
||||||
|
<template scope="scope">
|
||||||
|
<span>{{scope.row.timestamp | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column min-width="300px" label="标题">
|
||||||
|
<template scope="scope">
|
||||||
|
<span class="link-type" @click="handleUpdate(scope.row)">{{scope.row.title}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column width="110px" align="center" label="作者">
|
||||||
|
<template scope="scope">
|
||||||
|
<span>{{scope.row.author}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column width="80px" label="重要性">
|
||||||
|
<template scope="scope">
|
||||||
|
<wscn-icon-svg v-for="n in +scope.row.importance" icon-class="wujiaoxing" class="meta-item__icon" :key="n" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column align="center" label="阅读数" width="95">
|
||||||
|
<template scope="scope">
|
||||||
|
<span class="link-type" @click='handleFetchPv(scope.row.pageviews)'>{{scope.row.pageviews}}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column class-name="status-col" label="状态" width="90">
|
||||||
|
<template scope="scope">
|
||||||
|
<el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column align="center" label="拖拽" width="95">
|
||||||
|
<template scope="scope">
|
||||||
|
<wscn-icon-svg class='drag-handler' icon-class="tuozhuai" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<div class='show-d'>默认顺序{{olderList}}</div>
|
||||||
|
<div class='show-d'>拖拽后顺序{{newList}}</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { fetchList } from 'api/article_table';
|
||||||
|
import Sortable from 'sortablejs'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'drag-table_demo',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
list: null,
|
||||||
|
total: null,
|
||||||
|
listLoading: true,
|
||||||
|
listQuery: {
|
||||||
|
page: 1,
|
||||||
|
limit: 10
|
||||||
|
},
|
||||||
|
sortable: null,
|
||||||
|
olderList: [],
|
||||||
|
newList: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
filters: {
|
||||||
|
statusFilter(status) {
|
||||||
|
const statusMap = {
|
||||||
|
published: 'success',
|
||||||
|
draft: 'gray',
|
||||||
|
deleted: 'danger'
|
||||||
|
};
|
||||||
|
return statusMap[status]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getList() {
|
||||||
|
this.listLoading = true;
|
||||||
|
fetchList(this.listQuery).then(response => {
|
||||||
|
this.list = response.items;
|
||||||
|
this.total = response.total;
|
||||||
|
this.listLoading = false;
|
||||||
|
this.olderList = this.list.map(v => v.id);
|
||||||
|
this.newList = this.olderList.slice();
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.setSort()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
setSort() {
|
||||||
|
const el = document.querySelectorAll('.el-table__body-wrapper > table > tbody')[0];
|
||||||
|
this.sortable = Sortable.create(el, {
|
||||||
|
// handle: '.drag-handler',
|
||||||
|
onEnd: evt => {
|
||||||
|
const tempIndex = this.newList.splice(evt.oldIndex, 1)[0];
|
||||||
|
this.newList.splice(evt.newIndex, 1, tempIndex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style >
|
||||||
|
.drag-handler{
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
.show-d{
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in a new issue