feat: Radio改造
This commit is contained in:
parent
6f1a94809e
commit
deeee73bcb
|
@ -281,8 +281,11 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 单选框组
|
// 单选框组和按钮样式
|
||||||
if (item.component === ComponentNameEnum.RADIO_GROUP) {
|
if (
|
||||||
|
item.component === ComponentNameEnum.RADIO_GROUP ||
|
||||||
|
item.component === ComponentNameEnum.RADIO_BUTTON
|
||||||
|
) {
|
||||||
slotsMap.default = !componentSlots.default
|
slotsMap.default = !componentSlots.default
|
||||||
? () => renderRadioOptions(item)
|
? () => renderRadioOptions(item)
|
||||||
: () => {
|
: () => {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import { ComponentName } from '@/types/components'
|
||||||
const componentMap: Recordable<Component, ComponentName> = {
|
const componentMap: Recordable<Component, ComponentName> = {
|
||||||
Radio: ElRadio,
|
Radio: ElRadio,
|
||||||
RadioGroup: ElRadioGroup,
|
RadioGroup: ElRadioGroup,
|
||||||
|
RadioButton: ElRadioGroup,
|
||||||
Checkbox: ElCheckboxGroup,
|
Checkbox: ElCheckboxGroup,
|
||||||
CheckboxButton: ElCheckboxGroup,
|
CheckboxButton: ElCheckboxGroup,
|
||||||
Input: ElInput,
|
Input: ElInput,
|
||||||
|
@ -43,7 +44,6 @@ const componentMap: Recordable<Component, ComponentName> = {
|
||||||
Divider: ElDivider,
|
Divider: ElDivider,
|
||||||
TimeSelect: ElTimeSelect,
|
TimeSelect: ElTimeSelect,
|
||||||
SelectV2: ElSelectV2,
|
SelectV2: ElSelectV2,
|
||||||
RadioButton: ElRadioGroup,
|
|
||||||
InputPassword: InputPassword,
|
InputPassword: InputPassword,
|
||||||
Editor: Editor
|
Editor: Editor
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,6 +485,34 @@ export interface RadioGroupComponentProps {
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RadioButtonComponentProps {
|
||||||
|
value?: string | number | boolean
|
||||||
|
size?: ElementPlusSize
|
||||||
|
disabled?: boolean
|
||||||
|
textColor?: string
|
||||||
|
fill?: string
|
||||||
|
validateEvent?: boolean
|
||||||
|
label?: string
|
||||||
|
name?: string
|
||||||
|
id?: string
|
||||||
|
options?: RadioOption[]
|
||||||
|
/**
|
||||||
|
* 数据源的字段别名
|
||||||
|
*/
|
||||||
|
props: {
|
||||||
|
label?: string
|
||||||
|
value?: string
|
||||||
|
disabled?: string
|
||||||
|
}
|
||||||
|
on?: {
|
||||||
|
change?: (value: string | number | boolean) => void
|
||||||
|
}
|
||||||
|
slots?: {
|
||||||
|
default?: (...args: any[]) => JSX.Element | null
|
||||||
|
}
|
||||||
|
style?: CSSProperties
|
||||||
|
}
|
||||||
|
|
||||||
export interface ColProps {
|
export interface ColProps {
|
||||||
span?: number
|
span?: number
|
||||||
xs?: number
|
xs?: number
|
||||||
|
|
|
@ -14,7 +14,8 @@ import {
|
||||||
ColorPickerComponentProps,
|
ColorPickerComponentProps,
|
||||||
TransferComponentProps,
|
TransferComponentProps,
|
||||||
RadioComponentProps,
|
RadioComponentProps,
|
||||||
RadioGroupComponentProps
|
RadioGroupComponentProps,
|
||||||
|
RadioButtonComponentProps
|
||||||
} from '@/types/components'
|
} from '@/types/components'
|
||||||
import { FormValueType, FormValueType } from '@/types/form'
|
import { FormValueType, FormValueType } from '@/types/form'
|
||||||
import type { AxiosPromise } from 'axios'
|
import type { AxiosPromise } from 'axios'
|
||||||
|
@ -74,6 +75,7 @@ export interface FormSchema {
|
||||||
| TransferComponentProps
|
| TransferComponentProps
|
||||||
| RadioComponentProps
|
| RadioComponentProps
|
||||||
| RadioGroupComponentProps
|
| RadioGroupComponentProps
|
||||||
|
| RadioButtonComponentProps
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* formItem组件属性,具体可以查看element-plus文档
|
* formItem组件属性,具体可以查看element-plus文档
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
RadioOption
|
RadioOption
|
||||||
} from '@/types/components'
|
} from '@/types/components'
|
||||||
import { useForm } from '@/hooks/web/useForm'
|
import { useForm } from '@/hooks/web/useForm'
|
||||||
import { ElOption, ElOptionGroup, ElButton, ElRadio } from 'element-plus'
|
import { ElOption, ElOptionGroup, ElButton, ElRadio, ElRadioButton } from 'element-plus'
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
|
||||||
|
@ -1029,31 +1029,58 @@ const schema = reactive<FormSchema[]>([
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field40',
|
||||||
|
label: t('formDemo.button'),
|
||||||
|
component: 'RadioButton',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'option-1',
|
||||||
|
value: '1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'option-2',
|
||||||
|
value: '2'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field40',
|
||||||
|
label: `${t('formDemo.button')}${t('formDemo.slot')}`,
|
||||||
|
component: 'RadioButton',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'option-1',
|
||||||
|
value: '1'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'option-2',
|
||||||
|
value: '2'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
slots: {
|
||||||
|
default: (options: RadioOption[]) => {
|
||||||
|
return options?.map((v) => {
|
||||||
|
return (
|
||||||
|
<ElRadioButton label={v.value}>
|
||||||
|
{v.label}({v.value})
|
||||||
|
</ElRadioButton>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'field41',
|
||||||
|
label: t('formDemo.checkbox'),
|
||||||
|
component: 'Divider'
|
||||||
}
|
}
|
||||||
// {
|
// {
|
||||||
// field: 'field40',
|
|
||||||
// label: t('formDemo.button'),
|
|
||||||
// component: 'RadioButton',
|
|
||||||
// componentProps: {
|
|
||||||
// options: [
|
|
||||||
// {
|
|
||||||
// disabled: true,
|
|
||||||
// label: 'option-1',
|
|
||||||
// value: '1'
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// label: 'option-2',
|
|
||||||
// value: '2'
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// field: 'field41',
|
|
||||||
// label: t('formDemo.checkbox'),
|
|
||||||
// component: 'Divider'
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// field: 'field42',
|
// field: 'field42',
|
||||||
// label: t('formDemo.default'),
|
// label: t('formDemo.default'),
|
||||||
// component: 'Checkbox',
|
// component: 'Checkbox',
|
||||||
|
|
Loading…
Reference in New Issue