代码生成编辑表格新增排序

This commit is contained in:
不做码农 2022-04-26 08:55:11 +08:00
parent 506f9446b2
commit 158cd02e5c

View File

@ -125,7 +125,7 @@ import { listType } from '@/api/system/dict/type'
import basicInfoForm from './basicInfoForm' import basicInfoForm from './basicInfoForm'
import genInfoForm from './genInfoForm' import genInfoForm from './genInfoForm'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
// import Sortable from 'sortablejs' import Sortable from 'sortablejs'
// name // name
const activeName = ref('cloum') const activeName = ref('cloum')
@ -240,5 +240,27 @@ function nextFocus(row, index, e) {
} }
/*************** table column 回车代码 end *************/ /*************** table column 回车代码 end *************/
//
const tableSort = () => {
const tbody = document.querySelector('.el-table__body > tbody')
Sortable.create(tbody, {
onEnd: (evt) => {
const targetRow = columns.value.splice(evt.oldIndex, 1)[0]
columns.value.splice(evt.newIndex, 0, targetRow)
for (const index in columns.value) {
columns.value[index].sort = parseInt(index) + 1
}
nextTick(() => {
console.log(columns.value)
})
},
})
}
onMounted(() => {
tableSort()
})
handleQuery() handleQuery()
</script> </script>