From 9854ed381eaf10a06b5fe65891642fe7419d0574 Mon Sep 17 00:00:00 2001 From: liaoxuezhi <2betop.cn@gmail.com> Date: Fri, 2 Sep 2022 21:20:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=89=E4=B8=AD=E5=85=B3=E8=81=94?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=9B=B8=E5=85=B3=E5=BC=B9=E7=AA=97=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=98=A0=E5=B0=84=E4=B8=8D=E7=BB=9F=E4=B8=80=20(#5296?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 选中关联编辑相关弹窗数据映射不统一 * 有可能需要有个初始化接口,因为选项的数据可能不全 --- packages/amis-core/src/renderers/Options.tsx | 3 +++ packages/amis-core/src/store/formItem.ts | 14 ++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/amis-core/src/renderers/Options.tsx b/packages/amis-core/src/renderers/Options.tsx index 53f30f208..df8f86452 100644 --- a/packages/amis-core/src/renderers/Options.tsx +++ b/packages/amis-core/src/renderers/Options.tsx @@ -248,6 +248,7 @@ export interface OptionsProps creatable?: boolean; addApi?: Api; addControls?: Array; + editInitApi?: Api; editApi?: Api; editControls?: Array; deleteApi?: Api; @@ -1110,6 +1111,7 @@ export function registerOptionsControl(config: OptionsConfig) { labelField, onOpenDialog, editApi, + editInitApi, env, source, data, @@ -1144,6 +1146,7 @@ export function registerOptionsControl(config: OptionsConfig) { ...editDialog, body: { type: 'form', + initApi: editInitApi, api: editApi, controls: editControls } diff --git a/packages/amis-core/src/store/formItem.ts b/packages/amis-core/src/store/formItem.ts index 54a833700..13f9772f7 100644 --- a/packages/amis-core/src/store/formItem.ts +++ b/packages/amis-core/src/store/formItem.ts @@ -31,6 +31,7 @@ import {StoreNode} from './node'; import {getStoreById} from './manager'; import {normalizeOptions} from '../utils/normalizeOptions'; import {optionValueCompare} from '../utils/optionValueCompare'; +import {dataMapping} from '../utils/dataMapping'; interface IOption { value?: string | number | null; @@ -1179,13 +1180,14 @@ export const FormItemStore = StoreNode.named('FormItemStore') clearError(); } - function openDialog( - schema: any, - data: any, - callback?: (ret?: any) => void - ) { + function openDialog(schema: any, ctx: any, callback?: (ret?: any) => void) { + if (schema.data) { + self.dialogData = dataMapping(schema.data, ctx); + } else { + self.dialogData = ctx; + } + self.dialogSchema = schema; - self.dialogData = data; self.dialogOpen = true; callback && dialogCallbacks.set(self.dialogData, callback); }