fix: 修复表单初始化触发change事件缺少的自定义参数
fix: select组件以api加载时将选项回写scheme,以便change事件调用
This commit is contained in:
@ -180,8 +180,6 @@
|
|||||||
selectedValue.value = ((typeof props.value === 'string' && !!props.value ? props.value?.split(',') : props.value) || undefined) as any;
|
selectedValue.value = ((typeof props.value === 'string' && !!props.value ? props.value?.split(',') : props.value) || undefined) as any;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function _fetch() {
|
async function _fetch() {
|
||||||
const { sepTextField } = props;
|
const { sepTextField } = props;
|
||||||
if (!valChanged.value && sepTextField) {
|
if (!valChanged.value && sepTextField) {
|
||||||
@ -202,6 +200,7 @@
|
|||||||
}
|
}
|
||||||
if (props.datasourceType === 'api') {
|
if (props.datasourceType === 'api') {
|
||||||
options.value = await apiConfigFunc(props.apiConfig, isCamelCase, formModel, props.index);
|
options.value = await apiConfigFunc(props.apiConfig, isCamelCase, formModel, props.index);
|
||||||
|
props.staticOptions.splice(0, props.staticOptions.length, options.value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
api = props.api;
|
api = props.api;
|
||||||
|
|||||||
@ -51,6 +51,7 @@
|
|||||||
const formRef = ref<FormInstance>();
|
const formRef = ref<FormInstance>();
|
||||||
const formWrap = ref<HTMLElement>();
|
const formWrap = ref<HTMLElement>();
|
||||||
const wrapWidth = ref(960);
|
const wrapWidth = ref(960);
|
||||||
|
const formData = inject('formData', { noInject: true });
|
||||||
|
|
||||||
const propsRef = ref<Partial<FormProps>>({});
|
const propsRef = ref<Partial<FormProps>>({});
|
||||||
|
|
||||||
@ -437,8 +438,8 @@
|
|||||||
for (const eventKey in schema.componentProps['events']) {
|
for (const eventKey in schema.componentProps['events']) {
|
||||||
if (eventKey !== 'change') return;
|
if (eventKey !== 'change') return;
|
||||||
try {
|
try {
|
||||||
const event = new Function('schema', 'formModel', 'formActionType', `${schema.componentProps['events'][eventKey]}`);
|
const event = new Function('schema', 'formModel', 'formActionType', 'extParams', `${schema.componentProps['events'][eventKey]}`);
|
||||||
event(schema, formModel, formApi);
|
event(schema, formModel, formApi, { formData });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('error', error);
|
console.log('error', error);
|
||||||
notification.error({
|
notification.error({
|
||||||
|
|||||||
@ -83,6 +83,7 @@
|
|||||||
const wrapWidth = ref(960);
|
const wrapWidth = ref(960);
|
||||||
const propsRef = ref<Partial<FormProps>>({});
|
const propsRef = ref<Partial<FormProps>>({});
|
||||||
const schemaRef = ref<Nullable<FormSchema[]>>(null);
|
const schemaRef = ref<Nullable<FormSchema[]>>(null);
|
||||||
|
const formData = inject('formData', { noInject: true });
|
||||||
|
|
||||||
const getSchemas = computed<FormSchema[]>(() => {
|
const getSchemas = computed<FormSchema[]>(() => {
|
||||||
return (unref(getProps).schemas as any) || unref(schemaRef);
|
return (unref(getProps).schemas as any) || unref(schemaRef);
|
||||||
@ -438,8 +439,8 @@
|
|||||||
for (const eventKey in schema.componentProps['events']) {
|
for (const eventKey in schema.componentProps['events']) {
|
||||||
if (eventKey !== 'change') return;
|
if (eventKey !== 'change') return;
|
||||||
try {
|
try {
|
||||||
const event = new Function('schema', 'formModel', 'formActionType', `${schema.componentProps['events'][eventKey]}`);
|
const event = new Function('schema', 'formModel', 'formActionType', 'extParams', `${schema.componentProps['events'][eventKey]}`);
|
||||||
event(schema, formModel, formApi);
|
event(schema, formModel, formApi, { formData });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('error', error);
|
console.log('error', error);
|
||||||
notification.error({
|
notification.error({
|
||||||
|
|||||||
Reference in New Issue
Block a user