Browse Source

fix: dict

main
xingyu 2 years ago
parent
commit
f33e8788f8
  1. 14
      src/components/DictTag/src/DictTag.vue

14
src/components/DictTag/src/DictTag.vue

@ -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())