fix: dict
parent
30065de533
commit
f33e8788f8
|
@ -3,6 +3,7 @@ import { defineComponent, PropType, ref } from 'vue'
|
||||||
import { isHexColor } from '@/utils/color'
|
import { isHexColor } from '@/utils/color'
|
||||||
import { Tag } from 'ant-design-vue'
|
import { Tag } from 'ant-design-vue'
|
||||||
import { DictDataType, getBoolDictOptions, getDictOptions, getStrDictOptions } from '@/utils/dict'
|
import { DictDataType, getBoolDictOptions, getDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||||
|
import { propTypes } from '@/utils/propTypes'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'DictTag',
|
name: 'DictTag',
|
||||||
|
@ -11,15 +12,8 @@ export default defineComponent({
|
||||||
type: String as PropType<string>,
|
type: String as PropType<string>,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
value: {
|
value: propTypes.oneOfType([propTypes.string, propTypes.number, propTypes.bool]),
|
||||||
type: [String, Number, Boolean] as PropType<string | number | boolean>,
|
dictType: propTypes.oneOf(['string', 'boolean', 'number']).def('number'),
|
||||||
required: true
|
|
||||||
},
|
|
||||||
dictType: {
|
|
||||||
type: String as PropType<string>,
|
|
||||||
required: false,
|
|
||||||
default: () => 'number'
|
|
||||||
},
|
|
||||||
icon: { type: String }
|
icon: { type: String }
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
@ -51,7 +45,7 @@ export default defineComponent({
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
// 解决自定义字典标签值为零时标签不渲染的问题
|
// 解决自定义字典标签值为零时标签不渲染的问题
|
||||||
if (props.value === undefined && props.value !== null) {
|
if (props.value === undefined || props.value === null) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
getDictObj(props.type, props.value.toString())
|
getDictObj(props.type, props.value.toString())
|
||||||
|
|
Loading…
Reference in New Issue