feat: 优化dict tag 颜色

pull/5/MERGE
xingyu 2023-04-24 20:13:08 +08:00
parent 2f284d31c3
commit 2111e14e31
2 changed files with 50 additions and 12 deletions

View File

@ -19,7 +19,8 @@ export default defineComponent({
type: String as PropType<string>, type: String as PropType<string>,
required: false, required: false,
default: () => 'number' default: () => 'number'
} },
icon: { type: String }
}, },
setup(props) { setup(props) {
const dictData = ref<DictDataType>() const dictData = ref<DictDataType>()
@ -34,8 +35,8 @@ export default defineComponent({
} }
dictOptions.forEach((dict: DictDataType) => { dictOptions.forEach((dict: DictDataType) => {
if (dict.value === value) { if (dict.value === value) {
if (dict.colorType + '' === 'primary' || dict.colorType + '' === 'default') { if (dict.colorType + '' === 'primary' || dict.colorType + '' === 'info') {
dict.colorType = '' dict.colorType = 'processing'
} }
dictData.value = dict dictData.value = dict
} }
@ -50,9 +51,17 @@ export default defineComponent({
return null return null
} }
getDictObj(props.type, props.value.toString()) getDictObj(props.type, props.value.toString())
// // && isHexColor(dictData.value?.cssClass)
return ( return (
<Tag color={dictData.value?.cssClass && isHexColor(dictData.value?.cssClass) ? dictData.value?.cssClass : ''}> <Tag
color={
dictData.value?.colorType
? dictData.value?.colorType
: dictData.value?.cssClass && isHexColor(dictData.value?.cssClass)
? dictData.value?.cssClass
: ''
}
>
{dictData.value?.label} {dictData.value?.label}
</Tag> </Tag>
) )

View File

@ -121,11 +121,11 @@ export const dataFormSchema: FormSchema[] = [
componentProps: { componentProps: {
options: [ options: [
{ {
value: 'default', value: '',
label: '默认' label: ''
}, },
{ {
value: 'primary', value: 'processing',
label: '主要' label: '主要'
}, },
{ {
@ -133,16 +133,44 @@ export const dataFormSchema: FormSchema[] = [
label: '成功' label: '成功'
}, },
{ {
value: 'info', value: 'default',
label: '信息' label: '默认'
}, },
{ {
value: 'warning', value: 'warning',
label: '警告' label: '警告'
}, },
{ {
value: 'danger', value: 'error',
label: '危险' label: '危险'
},
{
value: 'pink',
label: 'pink'
},
{
value: 'red',
label: 'red'
},
{
value: 'orange',
label: 'orange'
},
{
value: 'green',
label: 'green'
},
{
value: 'cyan',
label: 'cyan'
},
{
value: 'blue',
label: 'blue'
},
{
value: 'purple',
label: 'purple'
} }
] ]
} }
@ -150,7 +178,8 @@ export const dataFormSchema: FormSchema[] = [
{ {
label: 'CSS Class', label: 'CSS Class',
field: 'cssClass', field: 'cssClass',
component: 'Input' component: 'Input',
helpMessage: '输入hex模式的颜色例如#108ee9'
}, },
{ {
label: '备注', label: '备注',