Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 优化、修复不合理问题 #283

Open
wants to merge 9 commits into
base: next
Choose a base branch
from
Open
6 changes: 4 additions & 2 deletions packages/pro-form/examples/layouts/BasicLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<!-- custom right-content -->
<template #rightContentRender>
<div style="margin-right: 12px">
<a-avatar shape="square" size="small">
<Avatar shape="square" size="small">
<template #icon>
<UserOutlined />
</template>
</a-avatar>
</Avatar>
</div>
</template>
<!-- custom breadcrumb itemRender -->
Expand Down Expand Up @@ -72,6 +72,8 @@
import { computed, reactive, ref, watchEffect, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { getMenuData, clearMenuItem, type RouteContextProps } from '@ant-design-vue/pro-layout';
import { Avatar } from 'ant-design-vue';


const watermarkContent = ref('Pro Layout');
const loading = ref(false);
Expand Down
8 changes: 6 additions & 2 deletions packages/pro-form/examples/views/QueryFilter.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<QueryFilter :model="formModel" @finish="handleSubmit" @collapsed="onCollapsed">
<QueryFilter :model="formModel" @finish="handleSubmit" @collapsed="onCollapsed" @reset="onReset">
<ProFormText
name="name"
label="应用名称"
Expand Down Expand Up @@ -109,7 +109,7 @@ const fetchUser = async () => {

const formModel = reactive({
name: '456',
country: undefined,
country: [],
expirationTime: ref<Dayjs>(dayjs('2015/01/01', dateFormat)),
rangeTimes: ref<RangeValue>(),
weakTime: ref<Dayjs>(),
Expand All @@ -135,4 +135,8 @@ function handleSubmit(params: any) {
function onCollapsed(collapsed: boolean) {
console.log(collapsed);
}

function onReset(params: any) {
console.log(params);
}
</script>
2 changes: 1 addition & 1 deletion packages/pro-form/src/BaseForm/BaseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const BaseForm = defineComponent({
...formEvents,
...formMethods
} as BaseFormType;

createFromInstance(instance);

expose(instance);
Expand Down
2 changes: 1 addition & 1 deletion packages/pro-form/src/BaseForm/hooks/useFormEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const useFromEvents = (params: EventsParams) => {
const resetFields = (name?: NamePath) => {
unref(formInstanceRef)?.resetFields(name);

props.onReset?.(model.value);
props.onReset?.(handleFormValues(model.value));
submitOnReset && handleSubmit();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export const Action = defineComponent({
},
emits: ['collapsed'],
setup(props, { emit }) {

const { submit, resetForm } = useFormInstance();

const onCollapsed = () => {
emit('collapsed', !props.collapsed);
};
Expand Down
6 changes: 0 additions & 6 deletions packages/pro-form/src/helpers/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,8 @@ export const gridHelpers: (config: ProFormGridConfig & CommonProps) => GridHelpe
});

export const useGridHelpers = (props?: (ProFormGridConfig & CommonProps) | boolean) => {
const formInstance = useFormInstance();
const _grid = ref<boolean>();
const _colProps = ref<ColProps>();
if (formInstance) {
const { grid, colProps } = unref(formInstance.getFormProps);
_grid.value = grid;
_colProps.value = colProps;
}

const config = computed(() => {
if (typeof props === 'object') {
Expand Down