feat: improve vbenCheckButtonGroup (#6329)
* 按钮组支持单选清除和多选限制最大选项数 * 按钮组支持icon插槽来定制图标
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
VbenButtonGroup,
|
||||
VbenCheckButtonGroup,
|
||||
} from '@vben/common-ui';
|
||||
import { LoaderCircle, Square, SquareCheckBig } from '@vben/icons';
|
||||
|
||||
import { Button, Card, message } from 'ant-design-vue';
|
||||
|
||||
@@ -51,6 +52,7 @@ const compProps = reactive({
|
||||
gap: 0,
|
||||
showIcon: true,
|
||||
size: 'middle',
|
||||
allowClear: false,
|
||||
} as Recordable<any>);
|
||||
|
||||
const [Form] = useVbenForm({
|
||||
@@ -63,6 +65,9 @@ const [Form] = useVbenForm({
|
||||
}
|
||||
});
|
||||
},
|
||||
commonConfig: {
|
||||
labelWidth: 150,
|
||||
},
|
||||
schema: [
|
||||
{
|
||||
component: 'RadioGroup',
|
||||
@@ -109,6 +114,20 @@ const [Form] = useVbenForm({
|
||||
fieldName: 'beforeChange',
|
||||
label: '前置回调',
|
||||
},
|
||||
{
|
||||
component: 'Switch',
|
||||
defaultValue: false,
|
||||
fieldName: 'allowClear',
|
||||
label: '允许清除',
|
||||
help: '单选时是否允许取消选中(值为undefined)',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
defaultValue: 0,
|
||||
fieldName: 'maxCount',
|
||||
label: '最大选中数量',
|
||||
help: '多选时有效,0表示不限制',
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
submitOnChange: true,
|
||||
@@ -186,6 +205,21 @@ function onBtnClick(value: any) {
|
||||
v-bind="compProps"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-4">自定义图标{{ checkValue }}</p>
|
||||
<div class="mt-2 flex flex-col gap-2">
|
||||
<VbenCheckButtonGroup
|
||||
v-model="checkValue"
|
||||
multiple
|
||||
:options="options"
|
||||
v-bind="compProps"
|
||||
>
|
||||
<template #icon="{ loading, checked }">
|
||||
<LoaderCircle class="animate-spin" v-if="loading" />
|
||||
<SquareCheckBig v-else-if="checked" />
|
||||
<Square v-else />
|
||||
</template>
|
||||
</VbenCheckButtonGroup>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card title="设置" class="mt-4">
|
||||
|
Reference in New Issue
Block a user