课程列表取消全选

This commit is contained in:
Yjhon 2022-02-24 19:31:02 +08:00
parent ebfd3ce4ec
commit 7ba667f657
1 changed files with 13 additions and 7 deletions

View File

@ -25,7 +25,7 @@
</a-form>
<!-- onChange: onSelectChange, -->
<s-table ref="table" :columns="columns" :data="loadData" :rowKey="(record) => record.id"
:rowSelection="{ selectedRowKeys: selectedRowKeys, selectedRows: selectedRows,onChange: onSelectChange, onSelect: tableOnSelect }">
:rowSelection="{ selectedRowKeys: selectedRowKeys, selectedRows: selectedRows,onChange: onSelectChange, onSelect: tableOnSelect ,onSelectAll: tableAllSelected }">
<span slot="serial" slot-scope="text, record, index">
{{ index + 1 }}
</span>
@ -145,14 +145,9 @@ export default {
this.selectedRows = this.unique([...this.selectedRows, ...selectedRows])
},
/** 用户手动选择/取消选择某列的回调 */
/** table取消勾选 */
tableOnSelect(record, selected, selectedRows, nativeEvent){
if(!selected) { //
console.log('tableOnSelect - record:{}', record)
console.log('tableOnSelect - selected:{}', selected)
console.log('tableOnSelect - selectedRows:{}', selectedRows)
console.log('tableOnSelect - nativeEvent:{}', nativeEvent)
let keys = this.selectedRowKeys.filter(item => item != record.id);
let rows = this.selectedRows.filter(item => item.id != record.id);
@ -160,6 +155,17 @@ export default {
this.selectedRowKeys = keys;
}
},
/** table取消全选 */
tableAllSelected(selected, selectedRows, changeRows){
if(!selected){ //
let exKeys = changeRows.map(value => {return value.id})
let keys = this.selectedRowKeys.filter(item => {return !exKeys.includes(item)});
let rows = this.selectedRows.filter(item => {return !exKeys.includes(item.id)});
this.selectedRows = rows;
this.selectedRowKeys = keys;
}
},
//
unique(arr) {