From e7f922c5a9a5543be7e6a52b85cb6fdb1b8140dd Mon Sep 17 00:00:00 2001
From: BlInYo <blinyo@163.com>
Date: Sat, 5 Apr 2025 20:01:19 +0800
Subject: [PATCH 1/2] feat: listTable added tiggerEvent parameter to
 changeCellValue

---
 docs/assets/api/en/methods.md             |  4 ++--
 docs/assets/api/zh/methods.md             | 14 +++++++++++---
 packages/vtable/src/ListTable.ts          | 22 ++++++++++++++++++----
 packages/vtable/src/core/record-helper.ts |  8 ++++++--
 4 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/docs/assets/api/en/methods.md b/docs/assets/api/en/methods.md
index 3974e4fda7..c2ac4a6125 100644
--- a/docs/assets/api/en/methods.md
+++ b/docs/assets/api/en/methods.md
@@ -1060,7 +1060,7 @@ Change the value of a cell:
 ```
 
 /\*_ Set the value of the cell. Note that it corresponds to the original value of the source data, and the vtable instance records will be modified accordingly _/
-changeCellValue: (col: number, row: number, value: string | number | null, workOnEditableCell = false) => void;
+changeCellValue: (col: number, row: number, value: string | number | null, workOnEditableCell = false, triggerEvent = true) => void;
 
 ```
 
@@ -1077,7 +1077,7 @@ Change the value of cells in batches:
 - @param row The starting row number of pasted data
 - @param values Data array of multiple cells
   \*/
-  changeCellValues(startCol: number, startRow: number, values: string[][])
+  changeCellValues(startCol: number, startRow: number, values: string[][], workOnEditableCell = false, triggerEvent=true) => void;
 
 ```
 
diff --git a/docs/assets/api/zh/methods.md b/docs/assets/api/zh/methods.md
index 94e58cc911..7bf508a0a1 100644
--- a/docs/assets/api/zh/methods.md
+++ b/docs/assets/api/zh/methods.md
@@ -956,8 +956,15 @@ use case: 对于透视图的场景上，点击图例项后 更新过滤规则 
 更改单元格的 value 值：
 
 ```
-  /** 设置单元格的value值，注意对应的是源数据的原始值，vtable实例records会做对应修改 */
-  changeCellValue: (col: number, row: number, value: string | number | null, workOnEditableCell = false) => void;
+  /**
+   * 设置单元格的value值，注意对应的是源数据的原始值，vtable实例records会做对应修改
+   * @param col 单元格的起始列号
+   * @param row 单元格的起始行号
+   * @param value 更改后的值
+   * @param workOnEditableCell 是否仅更改可编辑单元格
+   * @param triggerEvent 是否在值发生改变的时候触发change_cell_value事件
+   */
+  changeCellValue: (col: number, row: number, value: string | number | null, workOnEditableCell = false, triggerEvent = true) => void;
 ```
 
 ## changeCellValues(Function)
@@ -971,8 +978,9 @@ use case: 对于透视图的场景上，点击图例项后 更新过滤规则 
    * @param row 粘贴数据的起始行号
    * @param values 多个单元格的数据数组
    * @param workOnEditableCell 是否仅更改可编辑单元格
+   * @param triggerEvent 是否在值发生改变的时候触发change_cell_value事件
    */
-  changeCellValues(startCol: number, startRow: number, values: string[][], workOnEditableCell = false)
+  changeCellValues(startCol: number, startRow: number, values: string[][], workOnEditableCell = false, triggerEvent=true) => void;
 ```
 
 ## getEditor(Function)
diff --git a/packages/vtable/src/ListTable.ts b/packages/vtable/src/ListTable.ts
index fc45ffa453..5b980faf2b 100644
--- a/packages/vtable/src/ListTable.ts
+++ b/packages/vtable/src/ListTable.ts
@@ -1326,9 +1326,16 @@ export class ListTable extends BaseTable implements ListTableAPI {
    * @param row
    * @param value 更改后的值
    * @param workOnEditableCell 限制只能更改配置了编辑器的单元格值。快捷键paste这里配置的true，限制只能修改可编辑单元格值
+   * @param triggerEvent 是否在值发生改变的时候触发change_cell_value事件
    */
-  changeCellValue(col: number, row: number, value: string | number | null, workOnEditableCell = false) {
-    return listTableChangeCellValue(col, row, value, workOnEditableCell, this);
+  changeCellValue(
+    col: number,
+    row: number,
+    value: string | number | null,
+    workOnEditableCell = false,
+    triggerEvent = true
+  ) {
+    return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this);
   }
   /**
    * 批量更新多个单元格的数据
@@ -1336,9 +1343,16 @@ export class ListTable extends BaseTable implements ListTableAPI {
    * @param row 粘贴数据的起始行号
    * @param values 多个单元格的数据数组
    * @param workOnEditableCell 是否仅更改可编辑单元格
+   * @param triggerEvent 是否在值发生改变的时候触发change_cell_value事件
    */
-  changeCellValues(startCol: number, startRow: number, values: (string | number)[][], workOnEditableCell = false) {
-    return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, this);
+  changeCellValues(
+    startCol: number,
+    startRow: number,
+    values: (string | number)[][],
+    workOnEditableCell = false,
+    triggerEvent = true
+  ) {
+    return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this);
   }
   /**
    * 添加数据 单条数据
diff --git a/packages/vtable/src/core/record-helper.ts b/packages/vtable/src/core/record-helper.ts
index eed1083f77..062e2cac93 100644
--- a/packages/vtable/src/core/record-helper.ts
+++ b/packages/vtable/src/core/record-helper.ts
@@ -14,12 +14,14 @@ import { TABLE_EVENT_TYPE } from './TABLE_EVENT_TYPE';
  * @param row
  * @param value 更改后的值
  * @param workOnEditableCell 限制只能更改配置了编辑器的单元格值。快捷键paste这里配置的true，限制只能修改可编辑单元格值
+ * @param triggerEvent 是否在值发生改变的时候触发change_cell_value事件
  */
 export function listTableChangeCellValue(
   col: number,
   row: number,
   value: string | number | null,
   workOnEditableCell: boolean,
+  triggerEvent: boolean,
   table: ListTable
 ) {
   if ((workOnEditableCell && table.isHasEditorDefine(col, row)) || workOnEditableCell === false) {
@@ -91,7 +93,7 @@ export function listTableChangeCellValue(
       table.scenegraph.updateRowHeight(row, newHeight - oldHeight);
     }
     const changedValue = table.getCellOriginValue(col, row);
-    if (oldValue !== changedValue) {
+    if (oldValue !== changedValue && triggerEvent) {
       table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
         col,
         row,
@@ -109,12 +111,14 @@ export function listTableChangeCellValue(
  * @param row 粘贴数据的起始行号
  * @param values 多个单元格的数据数组
  * @param workOnEditableCell 是否仅更改可编辑单元格
+ * @param triggerEvent 是否在值发生改变的时候触发change_cell_value事件
  */
 export function listTableChangeCellValues(
   startCol: number,
   startRow: number,
   values: (string | number)[][],
   workOnEditableCell: boolean,
+  triggerEvent: boolean,
   table: ListTable
 ) {
   let pasteColEnd = startCol;
@@ -193,7 +197,7 @@ export function listTableChangeCellValues(
           table.dataSource.changeFieldValue(value, recordIndex, field, startCol + j, startRow + i, table);
         }
         const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
-        if (oldValue !== changedValue) {
+        if (oldValue !== changedValue && triggerEvent) {
           table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
             col: startCol + j,
             row: startRow + i,

From 5de71ec8a62b7f527565bef31619d30a827036d0 Mon Sep 17 00:00:00 2001
From: BlInYo <blinyo@163.com>
Date: Tue, 8 Apr 2025 21:35:58 +0800
Subject: [PATCH 2/2] docs: update changlog of rush

---
 .../vtable/feat-changeCellValue_2025-04-08-13-35.json | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 common/changes/@visactor/vtable/feat-changeCellValue_2025-04-08-13-35.json

diff --git a/common/changes/@visactor/vtable/feat-changeCellValue_2025-04-08-13-35.json b/common/changes/@visactor/vtable/feat-changeCellValue_2025-04-08-13-35.json
new file mode 100644
index 0000000000..3b99a3abf0
--- /dev/null
+++ b/common/changes/@visactor/vtable/feat-changeCellValue_2025-04-08-13-35.json
@@ -0,0 +1,11 @@
+{
+  "changes": [
+    {
+      "comment": "feat: listTable added tiggerEvent parameter to changeCellValue\n\n",
+      "type": "none",
+      "packageName": "@visactor/vtable"
+    }
+  ],
+  "packageName": "@visactor/vtable",
+  "email": "blinyo@163.com"
+}
\ No newline at end of file
