mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-05-11 11:05:56 +08:00
支持sites页面拖曳排序
This commit is contained in:
@@ -6,13 +6,12 @@
|
|||||||
<span class="btn" @click="exportSites">导出</span>
|
<span class="btn" @click="exportSites">导出</span>
|
||||||
<span class="btn" @click="importSites">导入</span>
|
<span class="btn" @click="importSites">导入</span>
|
||||||
<span class="btn" @click="removeAllSites">清空</span>
|
<span class="btn" @click="removeAllSites">清空</span>
|
||||||
<span class="btn" @click="resetSites">重置</span>
|
<span class="btn" @click="resetSitesEvent">重置</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="listpage-body" id="editSites-table">
|
<div class="listpage-body" id="sites-table">
|
||||||
<el-table
|
<el-table
|
||||||
:data="sites"
|
:data="sites"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
@row-click="detailEvent"
|
|
||||||
style="width: 100%">
|
style="width: 100%">
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="name"
|
prop="name"
|
||||||
@@ -229,12 +228,12 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
resetSitesEvent () {
|
resetSitesEvent () {
|
||||||
this.resetSites(defaultSites)
|
sites.clear().then(sites.bulkAdd(defaultSites).then(this.getSites()))
|
||||||
this.$message.success('重置源成功')
|
this.$message.success('重置源成功')
|
||||||
},
|
},
|
||||||
moveSiteToTop (i) {
|
moveSiteToTop (i) {
|
||||||
this.sites.sort(function (x, y) { return x.key === i.key ? -1 : y.key === i.key ? 1 : 0 })
|
this.sites.sort(function (x, y) { return x.key === i.key ? -1 : y.key === i.key ? 1 : 0 })
|
||||||
this.resetSites(this.sites)
|
this.updateDatabase(this.sites)
|
||||||
},
|
},
|
||||||
resetId (inArray) {
|
resetId (inArray) {
|
||||||
var id = 1
|
var id = 1
|
||||||
@@ -243,28 +242,27 @@ export default {
|
|||||||
id += 1
|
id += 1
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
resetSites (newSites) {
|
updateDatabase (data) {
|
||||||
this.resetId(newSites)
|
sites.clear().then(res => {
|
||||||
sites.clear().then(sites.bulkAdd(newSites).then(this.getSites()))
|
var id = 1
|
||||||
|
data.forEach(ele => {
|
||||||
|
ele.id = id
|
||||||
|
id += 1
|
||||||
|
})
|
||||||
|
sites.bulkAdd(data)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
removeAllSites () {
|
removeAllSites () {
|
||||||
sites.clear().then(this.getSites())
|
sites.clear().then(this.getSites())
|
||||||
},
|
},
|
||||||
rowDrop () {
|
rowDrop () {
|
||||||
const tbody = document.getElementById('editSites-table').querySelector('.el-table__body-wrapper tbody')
|
const tbody = document.getElementById('sites-table').querySelector('.el-table__body-wrapper tbody')
|
||||||
var data = this.sites
|
const _this = this
|
||||||
Sortable.create(tbody, {
|
Sortable.create(tbody, {
|
||||||
onEnd ({ newIndex, oldIndex }) {
|
onEnd ({ newIndex, oldIndex }) {
|
||||||
const currRow = data.splice(oldIndex, 1)[0]
|
const currRow = _this.sites.splice(oldIndex, 1)[0]
|
||||||
data.splice(newIndex, 0, currRow)
|
_this.sites.splice(newIndex, 0, currRow)
|
||||||
sites.clear().then(res => {
|
_this.updateDatabase(_this.sites)
|
||||||
var id = data.length
|
|
||||||
data.forEach(element => {
|
|
||||||
element.id = id
|
|
||||||
sites.add(element)
|
|
||||||
id -= 1
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<span class="btn"></span>
|
<span class="btn"></span>
|
||||||
<span class="btn" @click="clearAllHistory">清空</span>
|
<span class="btn" @click="clearAllHistory">清空</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="listpage-body" id="list-table">
|
<div class="listpage-body" id="history-table">
|
||||||
<el-table
|
<el-table
|
||||||
:data="history"
|
:data="history"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
@@ -213,7 +213,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
rowDrop () {
|
rowDrop () {
|
||||||
const tbody = document.getElementById('list-table').querySelector('.el-table__body-wrapper tbody')
|
const tbody = document.getElementById('history-table').querySelector('.el-table__body-wrapper tbody')
|
||||||
const _this = this
|
const _this = this
|
||||||
Sortable.create(tbody, {
|
Sortable.create(tbody, {
|
||||||
onEnd ({ newIndex, oldIndex }) {
|
onEnd ({ newIndex, oldIndex }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user