fix: 选中关联编辑相关弹窗数据映射不统一 (#5296)

* fix: 选中关联编辑相关弹窗数据映射不统一

* 有可能需要有个初始化接口,因为选项的数据可能不全
This commit is contained in:
liaoxuezhi 2022-09-02 21:20:19 +08:00 committed by RUNZE LU
parent 1f853d78cd
commit 9854ed381e
2 changed files with 11 additions and 6 deletions

View File

@ -248,6 +248,7 @@ export interface OptionsProps
creatable?: boolean; creatable?: boolean;
addApi?: Api; addApi?: Api;
addControls?: Array<any>; addControls?: Array<any>;
editInitApi?: Api;
editApi?: Api; editApi?: Api;
editControls?: Array<any>; editControls?: Array<any>;
deleteApi?: Api; deleteApi?: Api;
@ -1110,6 +1111,7 @@ export function registerOptionsControl(config: OptionsConfig) {
labelField, labelField,
onOpenDialog, onOpenDialog,
editApi, editApi,
editInitApi,
env, env,
source, source,
data, data,
@ -1144,6 +1146,7 @@ export function registerOptionsControl(config: OptionsConfig) {
...editDialog, ...editDialog,
body: { body: {
type: 'form', type: 'form',
initApi: editInitApi,
api: editApi, api: editApi,
controls: editControls controls: editControls
} }

View File

@ -31,6 +31,7 @@ import {StoreNode} from './node';
import {getStoreById} from './manager'; import {getStoreById} from './manager';
import {normalizeOptions} from '../utils/normalizeOptions'; import {normalizeOptions} from '../utils/normalizeOptions';
import {optionValueCompare} from '../utils/optionValueCompare'; import {optionValueCompare} from '../utils/optionValueCompare';
import {dataMapping} from '../utils/dataMapping';
interface IOption { interface IOption {
value?: string | number | null; value?: string | number | null;
@ -1179,13 +1180,14 @@ export const FormItemStore = StoreNode.named('FormItemStore')
clearError(); clearError();
} }
function openDialog( function openDialog(schema: any, ctx: any, callback?: (ret?: any) => void) {
schema: any, if (schema.data) {
data: any, self.dialogData = dataMapping(schema.data, ctx);
callback?: (ret?: any) => void } else {
) { self.dialogData = ctx;
}
self.dialogSchema = schema; self.dialogSchema = schema;
self.dialogData = data;
self.dialogOpen = true; self.dialogOpen = true;
callback && dialogCallbacks.set(self.dialogData, callback); callback && dialogCallbacks.set(self.dialogData, callback);
} }