Quellcode durchsuchen

fix(EditableCell): 修复可编辑表格 组件onChange重复问题 (#2495)

* fix: props 初始化拼写错误 defualt => default

* fix: props 定义默认值拼写错误 defualt => default

* fix(EditableCell): 修复可编辑表格select组件onChange重复问题

Co-authored-by: 苗大 <caoshengmiao@hypergryph.com>
Wit〆苗大 vor 2 Jahren
Ursprung
Commit
0cc53558fb
1 geänderte Dateien mit 7 neuen und 3 gelöschten Zeilen
  1. 7 3
      src/components/Table/src/components/editable/EditableCell.vue

+ 7 - 3
src/components/Table/src/components/editable/EditableCell.vue

@@ -77,6 +77,11 @@
         if (isFunction(compProps)) {
           compProps = compProps({ text: val, record, column, index }) ?? {};
         }
+
+        // 用临时变量存储 onChange方法 用于 handleChange方法 获取,并删除原始onChange, 防止存在两个 onChange
+        compProps.onChangeTemp = compProps.onChange;
+        delete compProps.onChange;
+
         const component = unref(getComponent);
         const apiSelectProps: Recordable = {};
         if (component === 'ApiSelect') {
@@ -187,7 +192,7 @@
         } else if (isString(e) || isBoolean(e) || isNumber(e) || isArray(e)) {
           currentValueRef.value = e;
         }
-        const onChange = unref(getComponentProps)?.onChange;
+        const onChange = unref(getComponentProps)?.onChangeTemp;
         if (onChange && isFunction(onChange)) onChange(...arguments);
 
         table.emit?.('edit-change', {
@@ -404,8 +409,7 @@
                     column: this.column,
                     index: this.index,
                   })
-                : (this.getValues ?? "\u00A0")
-                }
+                : this.getValues ?? '\u00A0'}
             </div>
             {!this.column.editRow && <FormOutlined class={`${this.prefixCls}__normal-icon`} />}
           </div>