批处理多选时支持shift快捷键

This commit is contained in:
buvta
2020-11-07 14:24:04 +08:00
parent c6a39591d5
commit 8f94a5604d
2 changed files with 40 additions and 0 deletions

View File

@@ -21,6 +21,7 @@
<el-table size="mini" fit height="100%" row-key="id"
ref="editSitesTable"
:data="sites"
@select="selectionCellClick"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange">
<el-table-column
@@ -148,6 +149,9 @@ export default {
enableBatchEdit: false,
batchGroupName: '',
batchIsActive: 1,
shiftDown: false,
selectionBegin: '',
selectionEnd: '',
multipleSelection: [],
checkAllSitesLoading: false,
checkProgress: 0,
@@ -193,6 +197,20 @@ export default {
setting.update(res)
})
},
selectionCellClick (selection, row) {
if (this.shiftDown && this.selectionBegin !== '') {
this.selectionEnd = row.id
const start = Math.min(this.selectionBegin, this.selectionEnd) - 1
const end = Math.max(this.selectionBegin, this.selectionEnd)
const selections = this.sites.slice(start, end)
this.$nextTick(() => {
selections.forEach(e => this.$refs.editSitesTable.toggleRowSelection(e, true))
})
this.selectionBegin = this.selectionEnd = ''
return
}
this.selectionBegin = row.id
},
handleSelectionChange (rows) {
this.multipleSelection = rows
},
@@ -473,6 +491,8 @@ export default {
},
mounted () {
this.rowDrop()
addEventListener('keydown', code => { if (code.keyCode === 16) this.shiftDown = true })
addEventListener('keyup', code => { if (code.keyCode === 16) this.shiftDown = false })
},
created () {
this.getSites()

View File

@@ -21,6 +21,7 @@
size="mini" fit height="100%" row-key="id"
:data="filteredTableData"
@row-click="playEvent"
@select="selectionCellClick"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange">>
<el-table-column
@@ -119,6 +120,9 @@ export default {
enableBatchEdit: false,
batchGroupName: '',
batchIsActive: 1,
shiftDown: false,
selectionBegin: '',
selectionEnd: '',
multipleSelection: [],
checkAllChannelsLoading: false,
checkProgress: 0,
@@ -186,6 +190,20 @@ export default {
sortByGroup (a, b) {
return a.group.localeCompare(b.group, 'zh')
},
selectionCellClick (selection, row) {
if (this.shiftDown && this.selectionBegin !== '') {
this.selectionEnd = row.id
const start = Math.min(this.selectionBegin, this.selectionEnd) - 1
const end = Math.max(this.selectionBegin, this.selectionEnd)
const selections = this.iptvList.slice(start, end)
this.$nextTick(() => {
selections.forEach(e => this.$refs.iptvTable.toggleRowSelection(e, true))
})
this.selectionBegin = this.selectionEnd = ''
return
}
this.selectionBegin = row.id
},
handleSelectionChange (rows) {
this.multipleSelection = rows
},
@@ -476,6 +494,8 @@ export default {
},
mounted () {
this.rowDrop()
addEventListener('keydown', code => { if (code.keyCode === 16) this.shiftDown = true })
addEventListener('keyup', code => { if (code.keyCode === 16) this.shiftDown = false })
},
created () {
this.getChannels()