分组新增排序

This commit is contained in:
gyq
2024-06-06 17:44:30 +08:00
parent 192c37c946
commit 7266dd9309
12 changed files with 226 additions and 39 deletions

View File

@@ -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);
}