commit
71ce0cdd93
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,58 @@ |
||||
<template> |
||||
<span v-if='dictValue' class="v-dict" :class="'type'+dictValue.dictValue"> |
||||
{{ dictValue.dictLabel }} |
||||
</span> |
||||
</template> |
||||
|
||||
<script> |
||||
export default { |
||||
name: "vDict", |
||||
props: { |
||||
options: { |
||||
type: Array, |
||||
default: null, |
||||
}, |
||||
value: [Number, String, Array], |
||||
}, |
||||
data() { |
||||
return { |
||||
dictValue: [] |
||||
} |
||||
}, |
||||
watch: { |
||||
options: { |
||||
handler(newVal, oldVal) { |
||||
console.log('aaa',this.value) |
||||
if (this.value !== null && typeof this.value !== 'undefined') { |
||||
let newOptions=[] |
||||
newOptions = newVal.filter((currentValue) => { |
||||
return currentValue.dictValue == this.value; |
||||
}); |
||||
this.dictValue = newOptions[0] |
||||
} else { |
||||
this.values = [] |
||||
} |
||||
}, |
||||
immediate: true |
||||
}, |
||||
value: { |
||||
handler(newVal, oldVal) { |
||||
if (this.value !== null && typeof this.value !== 'undefined') { |
||||
let newValue=[] |
||||
newValue = this.options.filter((currentValue) => { |
||||
return currentValue.dictValue == newVal; |
||||
}); |
||||
this.dictValue = newValue[0] |
||||
} else { |
||||
this.values = [] |
||||
} |
||||
}, |
||||
immediate: true |
||||
}, |
||||
}, |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
|
||||
</style> |
Loading…
Reference in new issue