From 703c9fa6d4c4d8d9092b2d83426e1dfa646e715c Mon Sep 17 00:00:00 2001 From: kangwei Date: Mon, 15 Jun 2020 22:24:41 +0800 Subject: [PATCH] fix listsetter bugs --- .../src/designer/setting/setting-field.ts | 22 +++++++++++++++---- .../designer/setting/setting-prop-entry.ts | 7 ++++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/packages/designer/src/designer/setting/setting-field.ts b/packages/designer/src/designer/setting/setting-field.ts index 3f092b753..f15969b75 100644 --- a/packages/designer/src/designer/setting/setting-field.ts +++ b/packages/designer/src/designer/setting/setting-field.ts @@ -91,8 +91,16 @@ export class SettingField extends SettingPropEntry implements SettingEntry { } private hotValue: any; - + // ======= compatibles for vision ====== + setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: any) { + if (isHotValue) { + this.setHotValue(val, extraOptions); + return; + } + super.setValue(val, false, false, extraOptions); + } + getHotValue(): any { if (this.hotValue) { return this.hotValue; @@ -105,7 +113,7 @@ export class SettingField extends SettingPropEntry implements SettingEntry { return this.transducer.toHot(v); } - setHotValue(data: any) { + setHotValue(data: any, options?: any) { this.hotValue = data; const v = this.transducer.toNative(data); if (this.isUseVariable()) { @@ -114,10 +122,16 @@ export class SettingField extends SettingPropEntry implements SettingEntry { type: 'JSExpression', value: ov.value, mock: v, - }); + }, false, false, options); } else { - this.setValue(v); + this.setValue(v, false, false, options); } + + // dirty fix list setter + if (Array.isArray(data) && data[0] && data[0].__sid__) { + return; + } + this.valueChange(); } diff --git a/packages/designer/src/designer/setting/setting-prop-entry.ts b/packages/designer/src/designer/setting/setting-prop-entry.ts index cae691219..d6988543e 100644 --- a/packages/designer/src/designer/setting/setting-prop-entry.ts +++ b/packages/designer/src/designer/setting/setting-prop-entry.ts @@ -144,12 +144,15 @@ export class SettingPropEntry implements SettingEntry { /** * 设置当前属性值 */ - setValue(val: any) { + setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: any) { if (this.type === 'field') { this.parent.setPropValue(this.name, val); } + if (!extraOptions) { + extraOptions = {}; + } const { setValue } = this.extraProps; - if (setValue) { + if (setValue && !extraOptions.disableMutator) { setValue(this, val); } }