change Table event @on-cell-click position

This commit is contained in:
梁灏 2021-05-24 14:54:45 +08:00
parent 9d6b5f0381
commit 03e6c07622
2 changed files with 16 additions and 6 deletions

View file

@ -1,5 +1,5 @@
<template> <template>
<div :class="classes" ref="cell" @click="handleCellClick"> <div :class="classes" ref="cell">
<template v-if="renderType === 'index'"><span>{{ column.indexMethod ? column.indexMethod(row) : (naturalIndex + 1) }}</span></template> <template v-if="renderType === 'index'"><span>{{ column.indexMethod ? column.indexMethod(row) : (naturalIndex + 1) }}</span></template>
<template v-if="renderType === 'selection'"> <template v-if="renderType === 'selection'">
<Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox> <Checkbox :value="checked" @click.native.stop="handleClick" @on-change="toggleSelect" :disabled="disabled"></Checkbox>
@ -162,9 +162,10 @@
handleToggleTree () { handleToggleTree () {
this.$parent.$parent.$parent.toggleTree(this.row._rowKey); this.$parent.$parent.$parent.toggleTree(this.row._rowKey);
}, },
handleCellClick (event) { // table-body cell padding
this.$parent.$parent.$parent.$emit('on-cell-click', this.row, this.column, this.row[this.column.key], event); // handleCellClick (event) {
} // this.$parent.$parent.$parent.$emit('on-cell-click', this.row, this.column, this.row[this.column.key], event);
// }
}, },
created () { created () {
if (this.column.type === 'index') { if (this.column.type === 'index') {

View file

@ -114,6 +114,9 @@
event.stopPropagation(); event.stopPropagation();
this.$parent.dblclickCurrentRow(_index, rowKey); this.$parent.dblclickCurrentRow(_index, rowKey);
}, },
clickCell (row, column, key, event) {
this.$parent.$emit('on-cell-click', row, column, row[key], event);
},
contextmenuCurrentRow (_index, event, rowKey) { contextmenuCurrentRow (_index, event, rowKey) {
event.stopPropagation(); event.stopPropagation();
if (this.$parent.contextMenu) event.preventDefault(); if (this.$parent.contextMenu) event.preventDefault();
@ -257,7 +260,10 @@
const $td = h('td', { const $td = h('td', {
class: this.alignCls(column, row), class: this.alignCls(column, row),
attrs: this.getSpan(row, column, index, colIndex) attrs: this.getSpan(row, column, index, colIndex),
on: {
click: (e) => this.clickCell(row, column, column.key, e)
}
}, [$tableCell]); }, [$tableCell]);
$tds.push($td); $tds.push($td);
} }
@ -333,7 +339,10 @@
const $td = h('td', { const $td = h('td', {
class: this.alignCls(column, row), class: this.alignCls(column, row),
attrs: this.getSpan(row, column, index, colIndex) attrs: this.getSpan(row, column, index, colIndex),
on: {
click: (e) => this.clickCell(row, column, column.key, e)
}
}, [$tableCell]); }, [$tableCell]);
$tds.push($td); $tds.push($td);
} }