Files
2026-09-08 19:49:21 +08:00

81 lines
1.3 KiB
Vue

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