From cc72fe81e57735ae930a4377104468509a46ad83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E7=86=A0?= Date: Thu, 14 Jan 2021 15:05:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=98=E9=87=8F=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E6=9C=AA=E8=A7=A6=E5=8F=91=E4=BA=8B=E4=BB=B6,=20http:?= =?UTF-8?q?//gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/issues/?= =?UTF-8?q?100851?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/src/designer/setting/setting-field.ts | 12 +++++------- .../src/designer/setting/setting-prop-entry.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/designer/src/designer/setting/setting-field.ts b/packages/designer/src/designer/setting/setting-field.ts index 4bb8ea1ee..9a18e4fc1 100644 --- a/packages/designer/src/designer/setting/setting-field.ts +++ b/packages/designer/src/designer/setting/setting-field.ts @@ -154,20 +154,18 @@ export class SettingField extends SettingPropEntry implements SettingEntry { setHotValue(data: any, options?: any) { this.hotValue = data; - const v = this.transducer.toNative(data); + const value = this.transducer.toNative(data); if (this.isUseVariable()) { - const ov = this.getValue(); + const oldValue = this.getValue(); this.setValue({ type: 'JSExpression', - value: ov.value, - mock: v, + value: oldValue.value, + mock: value, }, false, false, options); } else { - this.setValue(v, false, false, options); + this.setValue(value, false, false, options); } - this.notifyValueChange(); - // dirty fix list setter if (Array.isArray(data) && data[0] && data[0].__sid__) { return; diff --git a/packages/designer/src/designer/setting/setting-prop-entry.ts b/packages/designer/src/designer/setting/setting-prop-entry.ts index 805042440..3ec65bd4e 100644 --- a/packages/designer/src/designer/setting/setting-prop-entry.ts +++ b/packages/designer/src/designer/setting/setting-prop-entry.ts @@ -163,14 +163,13 @@ export class SettingPropEntry implements SettingEntry { * 设置当前属性值 */ setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: any) { + const oldValue = this.getValue(); if (this.type === 'field') { this.parent.setPropValue(this.name, val); } - if (!extraOptions) { - extraOptions = {}; - } + const { setValue } = this.extraProps; - if (setValue && !extraOptions.disableMutator) { + if (setValue && !extraOptions?.disableMutator) { try { setValue(this, val); } catch (e) { @@ -178,6 +177,7 @@ export class SettingPropEntry implements SettingEntry { console.warn(e); } } + this.notifyValueChange(oldValue, val); } /** @@ -276,8 +276,8 @@ export class SettingPropEntry implements SettingEntry { this.emitter.emit('valuechange'); } - notifyValueChange() { - this.editor.emit('node.prop.change', { node: this.getNode(), prop: this }); + notifyValueChange(oldValue: any, newValue:any) { + this.editor.emit('node.prop.change', { node: this.getNode(), prop: this, oldValue, newValue }); } getDefaultValue() {