1
0
mirror of synced 2025-12-07 14:18:31 +08:00
This commit is contained in:
xuliangzhan
2019-04-28 11:44:00 +08:00
parent 44f480701a
commit bb8d5adf28
4 changed files with 22 additions and 11 deletions

View File

@@ -116,7 +116,8 @@ Vue.use(VXETable)
| 事件名 | 说明 | 参数 |
|------|------|-----|
| select-all | 只对 type=selection 有效,当手动勾选全选时触发的事件 | selection |
| select-all | 只对 type=selection 有效,当手动勾选全选时触发的事件 | selection,checked |
| select-change | 只对 type=selection/radio 有效,当手动勾选时触发的事件 | row,selection,checked |
| cell-click | 当某个单元格被点击时会触发该事件 | {row,rowIndex,column,columnIndex,cell},event |
| cell-dblclick | 当某个单元格被双击时会触发该事件 | {row,rowIndex,column,columnIndex,cell},event |

View File

@@ -35,7 +35,8 @@
height="300"
border
:data.sync="tableData"
:customs.sync="customColumns">
:customs.sync="customColumns"
@select-change="selectChangeEvent">
<vxe-table-column type="index" width="60"></vxe-table-column>
<vxe-table-column type="selection" prop="checked" width="60"></vxe-table-column>
<vxe-table-column prop="name" label="名称" min-width="200"></vxe-table-column>
@@ -133,6 +134,9 @@ export default {
return 'col-orange'
}
}
},
selectChangeEvent (row, selection, checked) {
console.log(selection)
}
}
}

View File

@@ -611,20 +611,25 @@ export default {
* 多选,行选中事件
*/
triggerCheckRowEvent (evnt, value, { row, column }) {
let { $listeners, selection, tableData } = this
let { property } = column
if (property) {
XEUtils.set(row, property, value)
this.isAllSelected = this.tableData.every(item => XEUtils.get(item, property))
this.isIndeterminate = !this.isAllSelected && this.tableData.some(item => XEUtils.get(item, property))
this.isAllSelected = tableData.every(item => XEUtils.get(item, property))
this.isIndeterminate = !this.isAllSelected && tableData.some(item => XEUtils.get(item, property))
if ($listeners['select-change']) {
selection = tableData.filter(item => XEUtils.get(item, property))
}
} else {
if (value) {
this.selection.push(row)
selection.push(row)
} else {
XEUtils.remove(this.selection, item => item === row)
XEUtils.remove(selection, item => item === row)
}
this.isAllSelected = this.tableData.length === this.selection.length
this.isIndeterminate = !this.isAllSelected && this.selection.length
this.isAllSelected = tableData.length === selection.length
this.isIndeterminate = !this.isAllSelected && selection.length
}
Tools.emitEvent(this, 'select-change', [row, selection, value])
},
/**
* 多选,选中所有事件
@@ -640,13 +645,14 @@ export default {
this.selection = value ? Array.from(this.tableData) : []
this.isAllSelected = value
this.isIndeterminate = false
Tools.emitEvent(this, 'select-all', [this.selection])
Tools.emitEvent(this, 'select-all', [this.selection, value])
},
/**
* 单选,行选中事件
*/
triggerRowEvent (evnt, { row, column }) {
triggerRowEvent (evnt, { row }) {
this.selectRow = row
Tools.emitEvent(this, 'select-change', [row])
},
/**
* 行 hover 事件

View File

@@ -11,7 +11,7 @@ const Tools = {
// 触发事件
emitEvent (_vm, type, args) {
if (_vm.$listeners[type]) {
_vm.$emit.apply(_vm, [].concat.apply([type], args))
_vm.$emit.apply(_vm, [type].concat(args))
}
},
// 获取所有的列,排除分组