Skip to content

Commit

Permalink
fix(Form): default value process logic
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan32 committed Jun 12, 2024
1 parent 24ed4f3 commit 6ae9881
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Form/src/components/ApiTreeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
const treeData = ref<Recordable[]>([]);
const isFirstLoaded = ref<Boolean>(false);
const loading = ref(false);
const getAttrs = computed(() => {
return {
...(props.api ? { treeData: unref(treeData) } : {}),
Expand Down Expand Up @@ -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 };
},
Expand Down
1 change: 1 addition & 0 deletions src/components/Form/src/hooks/useFormValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/views/sys/department/department.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const formSchema: FormSchema[] = [
value: ParentIdEnum.DEFAULT,
},
},
defaultValue: ParentIdEnum.DEFAULT,
},
{
field: 'ancestors',
Expand Down
1 change: 1 addition & 0 deletions src/views/sys/menu/menu.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export const formSchema: FormSchema[] = [
value: ParentIdEnum.DEFAULT,
},
},
defaultValue: ParentIdEnum.DEFAULT,
colProps: { lg: 12, md: 12, sm: 12 },
},
{
Expand Down

0 comments on commit 6ae9881

Please sign in to comment.