课程列表取消全选
This commit is contained in:
parent
ebfd3ce4ec
commit
7ba667f657
|
@ -25,7 +25,7 @@
|
||||||
</a-form>
|
</a-form>
|
||||||
<!-- onChange: onSelectChange, -->
|
<!-- onChange: onSelectChange, -->
|
||||||
<s-table ref="table" :columns="columns" :data="loadData" :rowKey="(record) => record.id"
|
<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">
|
<span slot="serial" slot-scope="text, record, index">
|
||||||
{{ index + 1 }}
|
{{ index + 1 }}
|
||||||
</span>
|
</span>
|
||||||
|
@ -145,14 +145,9 @@ export default {
|
||||||
this.selectedRows = this.unique([...this.selectedRows, ...selectedRows])
|
this.selectedRows = this.unique([...this.selectedRows, ...selectedRows])
|
||||||
},
|
},
|
||||||
|
|
||||||
/** 用户手动选择/取消选择某列的回调 */
|
/** table取消勾选 */
|
||||||
tableOnSelect(record, selected, selectedRows, nativeEvent){
|
tableOnSelect(record, selected, selectedRows, nativeEvent){
|
||||||
if(!selected) { //取消勾选操作
|
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 keys = this.selectedRowKeys.filter(item => item != record.id);
|
||||||
let rows = this.selectedRows.filter(item => item.id != record.id);
|
let rows = this.selectedRows.filter(item => item.id != record.id);
|
||||||
|
|
||||||
|
@ -160,6 +155,17 @@ export default {
|
||||||
this.selectedRowKeys = keys;
|
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) {
|
unique(arr) {
|
||||||
|
|
Loading…
Reference in New Issue