From 9611946d95fde34be4d54cf8d8972c55272ce77c Mon Sep 17 00:00:00 2001 From: taiiiyang <781547101@qq.com> Date: Sat, 21 Dec 2024 12:21:47 +0800 Subject: [PATCH] feat: pivot table change cells value when real update --- packages/vtable/examples/editor/date-editor.ts | 3 +++ packages/vtable/src/PivotTable.ts | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/vtable/examples/editor/date-editor.ts b/packages/vtable/examples/editor/date-editor.ts index ac5ff3ce7..f7561fd89 100644 --- a/packages/vtable/examples/editor/date-editor.ts +++ b/packages/vtable/examples/editor/date-editor.ts @@ -190,5 +190,8 @@ export function createTable() { tableInstance.on('initialized', args => { console.log('initialized'); }); + tableInstance.on('change_cell_value', arg => { + console.log(arg); + }); window.tableInstance = tableInstance; } diff --git a/packages/vtable/src/PivotTable.ts b/packages/vtable/src/PivotTable.ts index 96cc8c641..cb7142f20 100644 --- a/packages/vtable/src/PivotTable.ts +++ b/packages/vtable/src/PivotTable.ts @@ -1799,14 +1799,16 @@ export class PivotTable extends BaseTable implements PivotTableAPI { newValue = parseFloat(value); } this._changeCellValueToDataSet(startCol + j, startRow + i, oldValue, newValue); - - this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, { - col: startCol + j, - row: startRow + i, - rawValue, - currentValue: oldValue, - changedValue: this.getCellOriginValue(startCol + j, startRow + i) - }); + const changedValue = this.getCellOriginValue(startCol + j, startRow + i); + if (changedValue !== oldValue) { + this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, { + col: startCol + j, + row: startRow + i, + rawValue, + currentValue: oldValue, + changedValue + }); + } } } pasteColEnd = Math.max(pasteColEnd, thisRowPasteColEnd);