diff --git a/src/components/Form/src/components/ApiTreeSelect.vue b/src/components/Form/src/components/ApiTreeSelect.vue index 707edbefe..2fa310f88 100644 --- a/src/components/Form/src/components/ApiTreeSelect.vue +++ b/src/components/Form/src/components/ApiTreeSelect.vue @@ -38,6 +38,7 @@ const treeData = ref([]); const isFirstLoaded = ref(false); const loading = ref(false); + const getAttrs = computed(() => { return { ...(props.api ? { treeData: unref(treeData) } : {}), @@ -92,8 +93,10 @@ labelField: props.labelField, defaultValue: props.defaultValue, }); - isFirstLoaded.value = true; + emit('options-change', treeData.value); + + isFirstLoaded.value = true; } return { getAttrs, loading, handleChange, fetch }; }, diff --git a/src/components/Form/src/hooks/useFormValues.ts b/src/components/Form/src/hooks/useFormValues.ts index 299afdaad..b50049ca4 100644 --- a/src/components/Form/src/hooks/useFormValues.ts +++ b/src/components/Form/src/hooks/useFormValues.ts @@ -157,6 +157,7 @@ export function useFormValues({ if (formModel[item.field] === undefined) { formModel[item.field] = defaultValue; } + return; } if (!isNullish(componentProps?.defaultValue)) { obj[item.field] = componentProps?.defaultValue; diff --git a/src/views/sys/department/department.data.ts b/src/views/sys/department/department.data.ts index 367448a6d..50f149cc3 100644 --- a/src/views/sys/department/department.data.ts +++ b/src/views/sys/department/department.data.ts @@ -111,6 +111,7 @@ export const formSchema: FormSchema[] = [ value: ParentIdEnum.DEFAULT, }, }, + defaultValue: ParentIdEnum.DEFAULT, }, { field: 'ancestors', diff --git a/src/views/sys/menu/menu.data.ts b/src/views/sys/menu/menu.data.ts index ef7792655..eab4106ba 100644 --- a/src/views/sys/menu/menu.data.ts +++ b/src/views/sys/menu/menu.data.ts @@ -161,6 +161,7 @@ export const formSchema: FormSchema[] = [ value: ParentIdEnum.DEFAULT, }, }, + defaultValue: ParentIdEnum.DEFAULT, colProps: { lg: 12, md: 12, sm: 12 }, }, {