refactor: change the form button field from text to content to prevent conflicts with the frame (#4586)

* refactor: change the form button field from text to content to prevent conflicts with the frame
pull/48/MERGE
Vben 2024-10-07 16:30:41 +08:00 committed by GitHub
parent ab44926ec8
commit 2d019b3c8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 13 additions and 17 deletions

View File

@ -62,15 +62,11 @@ setupVbenForm<FormComponentType>({
DatePicker: NDatePicker, DatePicker: NDatePicker,
// 自定义默认的重置按钮 // 自定义默认的重置按钮
DefaultResetActionButton: (props, { attrs, slots }) => { DefaultResetActionButton: (props, { attrs, slots }) => {
return h(NButton, { ...props, attrs, text: false, type: 'info' }, slots); return h(NButton, { ...props, attrs, type: 'info' }, slots);
}, },
// 自定义默认的提交按钮 // 自定义默认的提交按钮
DefaultSubmitActionButton: (props, { attrs, slots }) => { DefaultSubmitActionButton: (props, { attrs, slots }) => {
return h( return h(NButton, { ...props, attrs, type: 'primary' }, slots);
NButton,
{ ...props, attrs, text: false, type: 'primary' },
slots,
);
}, },
Divider: NDivider, Divider: NDivider,
Input: withDefaultPlaceholder(NInput, 'input'), Input: withDefaultPlaceholder(NInput, 'input'),

View File

@ -78,7 +78,7 @@ const [QueryForm] = useVbenForm({
// //
showCollapseButton: true, showCollapseButton: true,
submitButtonOptions: { submitButtonOptions: {
text: '查询', content: '查询',
}, },
wrapperClass: 'grid-cols-1 md:grid-cols-2', wrapperClass: 'grid-cols-1 md:grid-cols-2',
}); });

View File

@ -16,16 +16,16 @@ const collapsed = defineModel({ default: false });
const resetButtonOptions = computed(() => { const resetButtonOptions = computed(() => {
return { return {
content: `${$t.value('reset')}`,
show: true, show: true,
text: `${$t.value('reset')}`,
...unref(rootProps).resetButtonOptions, ...unref(rootProps).resetButtonOptions,
}; };
}); });
const submitButtonOptions = computed(() => { const submitButtonOptions = computed(() => {
return { return {
content: `${$t.value('submit')}`,
show: true, show: true,
text: `${$t.value('submit')}`,
...unref(rootProps).submitButtonOptions, ...unref(rootProps).submitButtonOptions,
}; };
}); });
@ -91,7 +91,7 @@ watch(
@click="handleReset" @click="handleReset"
v-bind="resetButtonOptions" v-bind="resetButtonOptions"
> >
{{ resetButtonOptions.text }} {{ resetButtonOptions.content }}
</component> </component>
<component <component
@ -101,7 +101,7 @@ watch(
@click="handleSubmit" @click="handleSubmit"
v-bind="submitButtonOptions" v-bind="submitButtonOptions"
> >
{{ submitButtonOptions.text }} {{ submitButtonOptions.content }}
</component> </component>
<VbenExpandableArrow <VbenExpandableArrow

View File

@ -289,8 +289,8 @@ export interface FormRenderProps<
} }
export interface ActionButtonOptions extends VbenButtonProps { export interface ActionButtonOptions extends VbenButtonProps {
content?: string;
show?: boolean; show?: boolean;
text?: string;
} }
export interface VbenFormProps< export interface VbenFormProps<

View File

@ -154,7 +154,7 @@ const vbenFormOptions = computed(() => {
}, },
showCollapseButton: true, showCollapseButton: true,
submitButtonOptions: { submitButtonOptions: {
text: $t('common.query'), content: $t('common.query'),
}, },
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3', wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',
}; };

View File

@ -46,7 +46,7 @@ const [FirstForm, firstFormApi] = useVbenForm({
}, },
], ],
submitButtonOptions: { submitButtonOptions: {
text: '下一步', content: '下一步',
}, },
wrapperClass: 'grid-cols-1 md:grid-cols-1 lg:grid-cols-1', wrapperClass: 'grid-cols-1 md:grid-cols-1 lg:grid-cols-1',
}); });
@ -60,7 +60,7 @@ const [SecondForm, secondFormApi] = useVbenForm({
handleSubmit: onSecondSubmit, handleSubmit: onSecondSubmit,
layout: 'horizontal', layout: 'horizontal',
resetButtonOptions: { resetButtonOptions: {
text: '上一步', content: '上一步',
}, },
schema: [ schema: [
{ {

View File

@ -80,7 +80,7 @@ const [QueryForm] = useVbenForm({
// //
showCollapseButton: true, showCollapseButton: true,
submitButtonOptions: { submitButtonOptions: {
text: '查询', content: '查询',
}, },
// 321 // 321
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3', wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',
@ -119,7 +119,7 @@ const [QueryForm1] = useVbenForm({
// //
showCollapseButton: true, showCollapseButton: true,
submitButtonOptions: { submitButtonOptions: {
text: '查询', content: '查询',
}, },
// 321 // 321
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3', wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',