91 lines
1.5 KiB
Vue
91 lines
1.5 KiB
Vue
<template>
|
|
<el-select v-model="value" :placeholder="placeholder" @change="onChange" :disabled="disabled" :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
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
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> |