Commit 0cc53558fb55e61cd90a1d467a1f1a74fb2ace70

Authored by Wit〆苗大
Committed by GitHub
1 parent 7e77177e

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

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

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

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

Co-authored-by: 苗大 <caoshengmiao@hypergryph.com>
src/components/Table/src/components/editable/EditableCell.vue
... ... @@ -77,6 +77,11 @@
77 77 if (isFunction(compProps)) {
78 78 compProps = compProps({ text: val, record, column, index }) ?? {};
79 79 }
  80 +
  81 + // 用临时变量存储 onChange方法 用于 handleChange方法 获取,并删除原始onChange, 防止存在两个 onChange
  82 + compProps.onChangeTemp = compProps.onChange;
  83 + delete compProps.onChange;
  84 +
80 85 const component = unref(getComponent);
81 86 const apiSelectProps: Recordable = {};
82 87 if (component === 'ApiSelect') {
... ... @@ -187,7 +192,7 @@
187 192 } else if (isString(e) || isBoolean(e) || isNumber(e) || isArray(e)) {
188 193 currentValueRef.value = e;
189 194 }
190   - const onChange = unref(getComponentProps)?.onChange;
  195 + const onChange = unref(getComponentProps)?.onChangeTemp;
191 196 if (onChange && isFunction(onChange)) onChange(...arguments);
192 197  
193 198 table.emit?.('edit-change', {
... ... @@ -404,8 +409,7 @@
404 409 column: this.column,
405 410 index: this.index,
406 411 })
407   - : (this.getValues ?? "\u00A0")
408   - }
  412 + : this.getValues ?? '\u00A0'}
409 413 </div>
410 414 {!this.column.editRow && <FormOutlined class={`${this.prefixCls}__normal-icon`} />}
411 415 </div>
... ...