mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(form): 函数配置中添加config参数
This commit is contained in:
parent
7c5c4cb4ae
commit
eae9725ccb
@ -217,6 +217,7 @@ export default defineComponent({
|
||||
values: mForm?.initValues,
|
||||
formValue: mForm?.values,
|
||||
prop: itemProp.value,
|
||||
config: props.config,
|
||||
});
|
||||
}
|
||||
|
||||
@ -234,6 +235,7 @@ export default defineComponent({
|
||||
values: mForm?.initValues,
|
||||
formValue: mForm?.values,
|
||||
prop: itemProp.value,
|
||||
config: props.config,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -136,7 +136,11 @@ const Tab = defineComponent({
|
||||
if (!props.config.name) throw new Error('dynamic tab 必须配置name');
|
||||
|
||||
if (typeof props.config.onTabAdd === 'function') {
|
||||
props.config.onTabAdd(mForm, { model: props.model });
|
||||
props.config.onTabAdd(mForm, {
|
||||
model: props.model,
|
||||
prop: props.prop,
|
||||
config: props.config,
|
||||
});
|
||||
} else if (tabs.value.length > 0) {
|
||||
const newObj = cloneDeep(tabs.value[0]);
|
||||
newObj.title = `标签${tabs.value.length + 1}`;
|
||||
@ -150,7 +154,11 @@ const Tab = defineComponent({
|
||||
if (!props.config.name) throw new Error('dynamic tab 必须配置name');
|
||||
|
||||
if (typeof props.config.onTabRemove === 'function') {
|
||||
props.config.onTabRemove(mForm, tabName, { model: props.model });
|
||||
props.config.onTabRemove(mForm, tabName, {
|
||||
model: props.model,
|
||||
prop: props.prop,
|
||||
config: props.config,
|
||||
});
|
||||
} else {
|
||||
props.model[props.config.name].splice(+tabName, 1);
|
||||
|
||||
@ -169,7 +177,7 @@ const Tab = defineComponent({
|
||||
changeHandler: () => {
|
||||
emit('change', props.model);
|
||||
if (typeof props.config.onChange === 'function') {
|
||||
props.config.onChange(mForm, { model: props.model });
|
||||
props.config.onChange(mForm, { model: props.model, prop: props.prop, config: props.config });
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -134,6 +134,7 @@ export default defineComponent({
|
||||
model: props.model,
|
||||
formValue: mForm?.values,
|
||||
formValues: mForm?.values,
|
||||
config: props.config,
|
||||
}) as Record<string, any>;
|
||||
}
|
||||
|
||||
@ -163,6 +164,7 @@ export default defineComponent({
|
||||
model: props.model,
|
||||
formValue: mForm?.values,
|
||||
formValues: mForm?.values,
|
||||
config: props.config,
|
||||
});
|
||||
}
|
||||
|
||||
@ -287,6 +289,7 @@ export default defineComponent({
|
||||
prop: props.prop,
|
||||
formValues: mForm?.values,
|
||||
formValue: mForm?.values,
|
||||
config: props.config,
|
||||
}),
|
||||
).then((data) => {
|
||||
options.value = data;
|
||||
|
@ -120,6 +120,7 @@ export interface Rule {
|
||||
/** 整个表单的值 */
|
||||
formValue: FormValue;
|
||||
prop: string;
|
||||
config: any;
|
||||
},
|
||||
mForm: FormState | undefined,
|
||||
) => void;
|
||||
@ -145,6 +146,7 @@ type FilterFunction = (
|
||||
parent?: Record<any, any>;
|
||||
formValue: Record<any, any>;
|
||||
prop: string;
|
||||
config: any;
|
||||
},
|
||||
) => boolean;
|
||||
|
||||
@ -156,6 +158,7 @@ type OnChangeHandler = (
|
||||
values: Record<any, any>;
|
||||
parent?: Record<any, any>;
|
||||
formValue: Record<any, any>;
|
||||
config: any;
|
||||
},
|
||||
) => any;
|
||||
|
||||
@ -191,6 +194,7 @@ type SelectOptionFunction = (
|
||||
prop?: string;
|
||||
formValues: any;
|
||||
formValue: any;
|
||||
config: any;
|
||||
},
|
||||
) => SelectOption[] | SelectGroupOption[];
|
||||
|
||||
@ -200,6 +204,7 @@ type RemoteSelectOptionBodyFunction = (
|
||||
model: any;
|
||||
formValue: any;
|
||||
formValues: any;
|
||||
config: any;
|
||||
},
|
||||
) => Record<string, any>;
|
||||
|
||||
@ -210,6 +215,7 @@ type RemoteSelectOptionRequestFunction = (
|
||||
model: any;
|
||||
formValue: any;
|
||||
formValues: any;
|
||||
config: any;
|
||||
},
|
||||
) => any;
|
||||
|
||||
@ -500,6 +506,7 @@ export interface TabPaneConfig {
|
||||
lazy?: boolean;
|
||||
labelWidth?: string;
|
||||
items: FormConfig;
|
||||
[key: string]: any;
|
||||
}
|
||||
export interface TabConfig extends FormItem, ContainerCommonConfig {
|
||||
type: 'tab' | 'dynamic-tab';
|
||||
|
@ -201,6 +201,7 @@ export const filterFunction = (mForm: FormState | undefined, config: any, props:
|
||||
parent: mForm?.parentValues || {},
|
||||
formValue: mForm?.values || props.model,
|
||||
prop: props.prop,
|
||||
config: props.config,
|
||||
});
|
||||
};
|
||||
|
||||
@ -242,6 +243,7 @@ export const getRules = function (mForm: FormState | undefined, rules: Rule[] |
|
||||
parent: mForm?.parentValues || {},
|
||||
formValue: mForm?.values || props.model,
|
||||
prop: props.prop,
|
||||
config: props.config,
|
||||
},
|
||||
mForm,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user