mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-06 06:40:27 +08:00
实现重写规则管理
This commit is contained in:
25
web/public/js/components/common/sortable.js
Normal file
25
web/public/js/components/common/sortable.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// 给Table增加排序功能
|
||||
function sortTable(callback) {
|
||||
// 引入js
|
||||
let jsFile = document.createElement("script")
|
||||
jsFile.setAttribute("src", "/js/sortable.min.js")
|
||||
jsFile.addEventListener("load", function () {
|
||||
// 初始化
|
||||
let box = document.querySelector("#sortable-table")
|
||||
Sortable.create(box, {
|
||||
draggable: "tbody",
|
||||
handle: ".icon.handle",
|
||||
onStart: function () {
|
||||
},
|
||||
onUpdate: function (event) {
|
||||
let rows = box.querySelectorAll("tbody")
|
||||
let rowIds = []
|
||||
rows.forEach(function (row) {
|
||||
rowIds.push(parseInt(row.getAttribute("v-id")))
|
||||
})
|
||||
callback(rowIds)
|
||||
}
|
||||
})
|
||||
})
|
||||
document.head.appendChild(jsFile)
|
||||
}
|
||||
Reference in New Issue
Block a user