mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-03 04:39:09 +08:00
Table: Add handleEvent. (#3305)
This commit is contained in:
parent
4aabc95a6d
commit
5e796ca33b
@ -219,37 +219,29 @@ export default {
|
||||
},
|
||||
|
||||
handleContextMenu(event, row) {
|
||||
const table = this.table;
|
||||
const cell = getCell(event);
|
||||
let column;
|
||||
if (cell) {
|
||||
column = getColumnByCell(table, cell);
|
||||
if (column) {
|
||||
table.$emit('cell-dblclick', row, column, cell, event);
|
||||
}
|
||||
}
|
||||
table.$emit('row-contextmenu', row, event);
|
||||
this.handleEvent(event, row, 'contextmenu');
|
||||
},
|
||||
|
||||
handleDoubleClick(event, row) {
|
||||
const table = this.table;
|
||||
table.$emit('row-dblclick', row, event);
|
||||
this.handleEvent(event, row, 'dblclick');
|
||||
},
|
||||
|
||||
handleClick(event, row) {
|
||||
this.store.commit('setCurrentRow', row);
|
||||
this.handleEvent(event, row, 'click');
|
||||
},
|
||||
|
||||
handleEvent(event, row, name) {
|
||||
const table = this.table;
|
||||
const cell = getCell(event);
|
||||
let column;
|
||||
if (cell) {
|
||||
column = getColumnByCell(table, cell);
|
||||
if (column) {
|
||||
table.$emit('cell-click', row, column, cell, event);
|
||||
table.$emit(`cell-${name}`, row, column, cell, event);
|
||||
}
|
||||
}
|
||||
|
||||
this.store.commit('setCurrentRow', row);
|
||||
|
||||
table.$emit('row-click', row, event, column);
|
||||
table.$emit(`row-${name}`, row, event, column);
|
||||
},
|
||||
|
||||
handleExpandClick(row) {
|
||||
|
@ -459,7 +459,7 @@ describe('Table', () => {
|
||||
const cell = vm.$el.querySelectorAll('.el-table__body .cell')[2]; // first row
|
||||
|
||||
triggerEvent(cell.parentNode.parentNode, 'dblclick');
|
||||
expect(vm.result).to.length(2); // row, event
|
||||
expect(vm.result).to.length(3); // row, event, column
|
||||
expect(vm.result[0]).to.have.property('name').to.equal(getTestData()[0].name);
|
||||
destroyVM(vm);
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user