update
This commit is contained in:
@@ -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 |
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 事件
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
},
|
||||
// 获取所有的列,排除分组
|
||||
|
||||
Reference in New Issue
Block a user