Files
UNION_HUTB/target/classes/static/components/plugins/DictSelect.vue
T
2026-09-09 09:14:28 +08:00

87 lines
1.4 KiB
Vue

<template>
<el-select v-model="value" :placeholder="placeholder" @change="onChange" :clearable="clearable" :style="style"
:multiple="multiple"
:size="size">
<el-option
v-for="item in options"
:key="item[option_value]"
:label="item[option_label]"
:value="item[option_value]">
</el-option>
</el-select>
</template>
<script>
module.exports = {
props: {
value: {type: String},
code: {
type: String,
default: ""
},
option_value: {
type: String,
default: "code"
},
option_label: {
type: String,
default: "name"
},
style: {
type: String,
default: ""
},
size: {
type: String,
default: ""
},
placeholder: {
type: String,
default: "请选择"
},
clearable: {
type: Boolean,
default: true
},
multiple: {
type: Boolean,
default: false
},
},
model: {
prop: 'value',
event: 'change'
},
data() {
return {
options: []
}
},
watch: {
code(val) {
this.flushOptions()
}
},
methods: {
onChange(val) {
this.$emit("change", val)
},
async flushOptions() {
if (!this.code) {
this.options = []
return
}
this.options = await getDictOptions(this.code)
},
},
created() {
this.flushOptions()
}
}
</script>
<style>
</style>