分组新增排序
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
</el-row>
|
||||
</div>
|
||||
<div class="head-container" id="table_drag">
|
||||
<el-table ref="table" :data="tableData.data" v-loading="tableData.loading">
|
||||
<el-table ref="table" :data="tableData.data" v-loading="tableData.loading" row-key="id">
|
||||
<el-table-column prop="id" label="ID" width="50px"></el-table-column>
|
||||
<el-table-column label="商品信息">
|
||||
<template v-slot="scope">
|
||||
@@ -133,30 +133,24 @@ export default {
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
//表格拖炸
|
||||
//表格拖拽
|
||||
tableDrag() {
|
||||
const el = document.querySelector('#table_drag .el-table__body-wrapper tbody')
|
||||
new Sortable(el, {
|
||||
animation: 150,
|
||||
onEnd: async e => {
|
||||
console.log('拖拽结束===', e);
|
||||
// console.log('拖拽结束===', e);
|
||||
if (e.oldIndex == e.newIndex) return
|
||||
let oid = this.tableData.data[e.oldIndex].id
|
||||
let nid = this.tableData.data[e.newIndex].id
|
||||
let ids = this.tableData.data.map(item => item.id)
|
||||
// let arr = [...this.tableData.data] // 获取表数据
|
||||
// arr.splice(e.oldIndex, 1, ...arr.splice(e.newIndex, 1, arr[e.oldIndex])); // 数据处理
|
||||
// this.$nextTick(() => {
|
||||
// this.tableData.data = [...arr]
|
||||
// })
|
||||
try {
|
||||
await upProSort({
|
||||
strId: oid,
|
||||
endId: nid,
|
||||
ids: ids
|
||||
})
|
||||
// await this.getTableData()
|
||||
window.location.reload();
|
||||
await this.getTableData()
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user