mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-03 20:58: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) {
|
handleContextMenu(event, row) {
|
||||||
const table = this.table;
|
this.handleEvent(event, row, 'contextmenu');
|
||||||
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);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDoubleClick(event, row) {
|
handleDoubleClick(event, row) {
|
||||||
const table = this.table;
|
this.handleEvent(event, row, 'dblclick');
|
||||||
table.$emit('row-dblclick', row, event);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleClick(event, row) {
|
handleClick(event, row) {
|
||||||
|
this.store.commit('setCurrentRow', row);
|
||||||
|
this.handleEvent(event, row, 'click');
|
||||||
|
},
|
||||||
|
|
||||||
|
handleEvent(event, row, name) {
|
||||||
const table = this.table;
|
const table = this.table;
|
||||||
const cell = getCell(event);
|
const cell = getCell(event);
|
||||||
let column;
|
let column;
|
||||||
if (cell) {
|
if (cell) {
|
||||||
column = getColumnByCell(table, cell);
|
column = getColumnByCell(table, cell);
|
||||||
if (column) {
|
if (column) {
|
||||||
table.$emit('cell-click', row, column, cell, event);
|
table.$emit(`cell-${name}`, row, column, cell, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
table.$emit(`row-${name}`, row, event, column);
|
||||||
this.store.commit('setCurrentRow', row);
|
|
||||||
|
|
||||||
table.$emit('row-click', row, event, column);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleExpandClick(row) {
|
handleExpandClick(row) {
|
||||||
|
@ -459,7 +459,7 @@ describe('Table', () => {
|
|||||||
const cell = vm.$el.querySelectorAll('.el-table__body .cell')[2]; // first row
|
const cell = vm.$el.querySelectorAll('.el-table__body .cell')[2]; // first row
|
||||||
|
|
||||||
triggerEvent(cell.parentNode.parentNode, 'dblclick');
|
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);
|
expect(vm.result[0]).to.have.property('name').to.equal(getTestData()[0].name);
|
||||||
destroyVM(vm);
|
destroyVM(vm);
|
||||||
done();
|
done();
|
||||||
|
Loading…
Reference in New Issue
Block a user