From 150accdfac03ba122fb140a37cb0649271f2c816 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Tue, 1 Aug 2023 10:07:38 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=20input-kv=20?= =?UTF-8?q?=E5=9C=A8=E7=BC=96=E8=BE=91=E8=BF=87=E7=A8=8B=E4=B8=AD=E4=B8=8D?= =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E9=A1=BA=E5=BA=8F=20Close:=20#7201=20(#7642)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/renderers/wrapControl.tsx | 6 +++--- packages/amis/src/schemaExtend.ts | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/amis-core/src/renderers/wrapControl.tsx b/packages/amis-core/src/renderers/wrapControl.tsx index abd75541b..5af977e23 100644 --- a/packages/amis-core/src/renderers/wrapControl.tsx +++ b/packages/amis-core/src/renderers/wrapControl.tsx @@ -648,7 +648,7 @@ export function wrapControl< if (pipeOut) { const oldValue = this.model.value; - value = pipeOut(value, oldValue, data); + value = pipeOut.call(this, value, oldValue, data); } this.model.changeTmpValue(value, 'input'); @@ -767,7 +767,7 @@ export function wrapControl< } = this.props; if (pipeOut) { - value = pipeOut(value, oldValue, data); + value = pipeOut.call(this, value, oldValue, data); } if (model.extraName) { @@ -784,7 +784,7 @@ export function wrapControl< let value: any = this.model ? this.model.tmpValue : control.value; if (control.pipeIn) { - value = control.pipeIn(value, data); + value = control.pipeIn.call(this, value, data); } return value; diff --git a/packages/amis/src/schemaExtend.ts b/packages/amis/src/schemaExtend.ts index 7821eacd3..5eeebb9bd 100644 --- a/packages/amis/src/schemaExtend.ts +++ b/packages/amis/src/schemaExtend.ts @@ -14,10 +14,13 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) { draggable: true, ...schema, multiple: true, - pipeIn: (value: any) => { + pipeIn: function (this: any, value: any) { if (!isObject(value)) { return []; } + if (isEqual(value, this.cachedValue)) { + return this.cachedValueArray; + } const arr: Array = []; Object.keys(value).forEach(key => { const valueType = typeof value[key]; @@ -33,7 +36,7 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) { }); return arr; }, - pipeOut: (value: any) => { + pipeOut: function (this: any, value: any) { if (!Array.isArray(value)) { return value; } @@ -53,6 +56,8 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) { obj[key] = value; }); + this.cachedValue = obj; + this.cachedValueArray = value; return obj; }, items: [