From 06968cddbd4cfbd9845a343243ec5513883d213d Mon Sep 17 00:00:00 2001 From: Netfan Date: Wed, 11 Dec 2024 15:07:31 +0800 Subject: [PATCH 1/2] feat: form support reverse action buttons --- docs/src/components/common-ui/vben-form.md | 1 + .../form-ui/src/components/form-actions.vue | 44 +++++++++++++------ packages/@core/ui-kit/form-ui/src/types.ts | 4 ++ playground/src/views/examples/form/api.vue | 16 +++++++ 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/docs/src/components/common-ui/vben-form.md b/docs/src/components/common-ui/vben-form.md index 44abe1921ff..618e3d3a50d 100644 --- a/docs/src/components/common-ui/vben-form.md +++ b/docs/src/components/common-ui/vben-form.md @@ -307,6 +307,7 @@ useVbenForm 返回的第二个参数,是一个对象,包含了一些表单 | handleReset | 表单重置回调 | `(values: Record,) => Promise \| void` | - | | handleSubmit | 表单提交回调 | `(values: Record,) => Promise \| void` | - | | handleValuesChange | 表单值变化回调 | `(values: Record,) => void` | - | +| actionButtonsReverse | 调换操作按钮位置 | `boolean` | `false` | | resetButtonOptions | 重置按钮组件参数 | `ActionButtonOptions` | - | | submitButtonOptions | 提交按钮组件参数 | `ActionButtonOptions` | - | | showDefaultActions | 是否显示默认操作按钮 | `boolean` | `true` | diff --git a/packages/@core/ui-kit/form-ui/src/components/form-actions.vue b/packages/@core/ui-kit/form-ui/src/components/form-actions.vue index 26e426fe55f..4ab193f6c06 100644 --- a/packages/@core/ui-kit/form-ui/src/components/form-actions.vue +++ b/packages/@core/ui-kit/form-ui/src/components/form-actions.vue @@ -142,13 +142,28 @@ defineExpose({ " :style="queryFormStyle" > + + - - - - - {{ submitButtonOptions.content }} - + diff --git a/packages/@core/ui-kit/form-ui/src/types.ts b/packages/@core/ui-kit/form-ui/src/types.ts index 30daaee2eef..2f8a7be7f7a 100644 --- a/packages/@core/ui-kit/form-ui/src/types.ts +++ b/packages/@core/ui-kit/form-ui/src/types.ts @@ -307,6 +307,10 @@ export interface VbenFormProps< FormRenderProps, 'componentBindEventMap' | 'componentMap' | 'form' > { + /** + * 操作按钮是否反转(提交按钮前置) + */ + actionButtonsReverse?: boolean; /** * 表单操作区域class */ diff --git a/playground/src/views/examples/form/api.vue b/playground/src/views/examples/form/api.vue index eceeea3ef16..02abfce3f18 100644 --- a/playground/src/views/examples/form/api.vue +++ b/playground/src/views/examples/form/api.vue @@ -1,11 +1,17 @@