mirror of
https://github.com/cuiocean/ZY-Player.git
synced 2026-05-07 22:24:44 +08:00
重新排序后更新数据库
This commit is contained in:
@@ -20,7 +20,8 @@
|
||||
ref="editSitesTable"
|
||||
size="mini" fit height="100%" row-key="id"
|
||||
:data="sites"
|
||||
@selection-change="handleSelectionChange">
|
||||
@selection-change="handleSelectionChange"
|
||||
@sort-change="handleSortChange">
|
||||
<el-table-column
|
||||
type="selection"
|
||||
v-if="enableBatchEdit">
|
||||
@@ -174,6 +175,9 @@ export default {
|
||||
handleSelectionChange (rows) {
|
||||
this.multipleSelection = rows
|
||||
},
|
||||
handleSortChange (column, prop, order) {
|
||||
this.updateDatabase()
|
||||
},
|
||||
saveBatchEdit () {
|
||||
this.multipleSelection.forEach(ele => {
|
||||
if (this.batchGroupName) {
|
||||
@@ -334,13 +338,16 @@ export default {
|
||||
})
|
||||
},
|
||||
updateDatabase () {
|
||||
if (this.$refs.editSitesTable.tableData && this.$refs.editSitesTable.tableData.length === this.sites.length) {
|
||||
this.sites = this.$refs.editSitesTable.tableData
|
||||
}
|
||||
sites.clear().then(res => {
|
||||
var id = 1
|
||||
this.sites.forEach(ele => {
|
||||
ele.id = id
|
||||
id += 1
|
||||
})
|
||||
sites.bulkAdd(this.sites).then(this.getSites())
|
||||
sites.bulkAdd(this.sites)
|
||||
})
|
||||
},
|
||||
removeAllSites () {
|
||||
|
||||
@@ -19,12 +19,14 @@
|
||||
size="mini" fit height="100%" row-key="id"
|
||||
:data="filteredTableData"
|
||||
@row-click="playEvent"
|
||||
@selection-change="handleSelectionChange">
|
||||
@selection-change="handleSelectionChange"
|
||||
@sort-change="handleSortChange">>
|
||||
<el-table-column
|
||||
type="selection"
|
||||
v-if="enableBatchEdit">
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
default-sort="ascending"
|
||||
prop="name"
|
||||
label="频道名">
|
||||
<template #header>
|
||||
@@ -37,6 +39,9 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
sort-by="['group', 'name']"
|
||||
sortable
|
||||
:sort-method="sortByGroup"
|
||||
prop="group"
|
||||
label="分组"
|
||||
:filters="getFilters"
|
||||
@@ -134,9 +139,15 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE']),
|
||||
sortByGroup (a, b) {
|
||||
return a.group.localeCompare(b.group, 'zh')
|
||||
},
|
||||
handleSelectionChange (rows) {
|
||||
this.multipleSelection = rows
|
||||
},
|
||||
handleSortChange (column, prop, order) {
|
||||
this.updateDatabase()
|
||||
},
|
||||
saveBatchEdit () {
|
||||
if (this.multipleSelection && this.batchGroupName) {
|
||||
this.multipleSelection.forEach(ele => {
|
||||
@@ -227,7 +238,7 @@ export default {
|
||||
id: id,
|
||||
name: ele.name,
|
||||
url: ele.url,
|
||||
group: this.determineGroup(ele.group, ele.name)
|
||||
group: this.determineGroup(ele.name)
|
||||
}
|
||||
id += 1
|
||||
docs.push(doc)
|
||||
@@ -243,7 +254,7 @@ export default {
|
||||
id: id,
|
||||
name: ele.name,
|
||||
url: ele.url,
|
||||
group: ele.group === undefined ? this.determineGroup(ele.group, ele.name) : ele.group
|
||||
group: this.determineGroup(ele.name)
|
||||
}
|
||||
id += 1
|
||||
docs.push(doc)
|
||||
@@ -262,13 +273,17 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
determineGroup (group, name) {
|
||||
if (!group) {
|
||||
return group
|
||||
determineGroup (name) {
|
||||
if (name.toLowerCase().includes('cctv') && (name.includes('蓝光') || name.includes('高清'))) {
|
||||
return '央视高清'
|
||||
} else if (name.toLowerCase().includes('cctv')) {
|
||||
return '央视'
|
||||
} else if (name.includes('卫视')) {
|
||||
return '卫视'
|
||||
} else if (name.includes('香港') || name.includes('澳门') || name.includes('台湾') || name.includes('凤凰')) {
|
||||
return '港澳台'
|
||||
} else if (name.includes('高清') || name.includes('蓝光') || name.includes('1080P')) {
|
||||
return '高清'
|
||||
} else {
|
||||
return '其他'
|
||||
}
|
||||
@@ -317,9 +332,12 @@ export default {
|
||||
this.updateDatabase()
|
||||
},
|
||||
updateDatabase () {
|
||||
if (this.$refs.iptvTable.tableData && this.$refs.iptvTable.tableData.length === this.iptvList.length) {
|
||||
this.iptvList = this.$refs.iptvTable.tableData
|
||||
}
|
||||
iptv.clear().then(res => {
|
||||
this.resetId(this.iptvList)
|
||||
iptv.bulkAdd(this.iptvList).then(this.getChannels())
|
||||
iptv.bulkAdd(this.iptvList)
|
||||
})
|
||||
},
|
||||
resetId (inArray) {
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
<el-button @click.stop="updateAllEvent" icon="el-icon-refresh">同步所有收藏</el-button>
|
||||
</div>
|
||||
<div class="listpage-body" id="star-table">
|
||||
<el-table size="mini" fit height="100%" row-key="id" :data="list" :cell-class-name="checkUpdate" @row-click="detailEvent">
|
||||
<el-table size="mini" fit height="100%" row-key="id"
|
||||
ref="starTable"
|
||||
:data="list"
|
||||
:cell-class-name="checkUpdate"
|
||||
@row-click="detailEvent"
|
||||
@sort-change="handleSortChange">
|
||||
<el-table-column
|
||||
sortable
|
||||
:sort-method="sortByName"
|
||||
@@ -129,6 +134,9 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapMutations(['SET_VIEW', 'SET_DETAIL', 'SET_VIDEO', 'SET_SHARE']),
|
||||
handleSortChange (column, prop, order) {
|
||||
this.updateDatabase()
|
||||
},
|
||||
sortByName (a, b) {
|
||||
return a.name.localeCompare(b.name, 'zh')
|
||||
},
|
||||
@@ -377,14 +385,17 @@ export default {
|
||||
this.getFavorites()
|
||||
})
|
||||
},
|
||||
updateDatabase (data) {
|
||||
updateDatabase () {
|
||||
if (this.$refs.starTable.tableData.length === this.list.length) {
|
||||
this.list = this.$refs.starTable.tableData
|
||||
}
|
||||
star.clear().then(res => {
|
||||
var id = length
|
||||
data.forEach(ele => {
|
||||
var id = this.list.length
|
||||
this.list.forEach(ele => {
|
||||
ele.id = id
|
||||
id -= 1
|
||||
})
|
||||
star.bulkAdd(data)
|
||||
star.bulkAdd(this.list)
|
||||
})
|
||||
},
|
||||
rowDrop () {
|
||||
@@ -394,7 +405,7 @@ export default {
|
||||
onEnd ({ newIndex, oldIndex }) {
|
||||
const currRow = _this.list.splice(oldIndex, 1)[0]
|
||||
_this.list.splice(newIndex, 0, currRow)
|
||||
_this.updateDatabase(_this.list)
|
||||
_this.updateDatabase()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user