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;
addApi?: Api;
addControls?: Array<any>;
editInitApi?: Api;
editApi?: Api;
editControls?: Array<any>;
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
}

View File

@ -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);
}