vue
复制代码
<template>
<el-select clearable
:collapse-tags="collapseTags"
:multiple="multiple"
v-bind="$attrs"
:placeholder="placeholder"
:spellcheck="false"
style="width: 100%"
v-on="$listeners"
>
<el-option v-for="item in options" :key="item.itemCode" :label="item.label" :value="item.value"/>
</el-select>
</template>
<script>
import {getDictItemByDictCode} from "@/api/dictItemManagement";
export default {
name: 'HmSelectCode',
props: {
codeid: {
type: String,
required: false,
default: '',
},
multiple: {
type: Boolean,
required: false,
default: false,
},
collapseTags: {
type: Boolean,
required: false,
default: true,
},
placeholder: {
type: String,
required: false,
default: '',
}
},
data() {
return {
title: '组件标题',
currentDesc: '',
// 组件内输入框的值
currentValue: '',
options: [],
}
},
mounted() {
if (!this.codeid) return
//调用后端接口
getDictItemByDictCode(this.codeid).then(res => {
this.options = []
res.data.forEach((value1,) => {
const option = {value: value1.itemCode, label: value1.itemName}
this.options.push(option)
})
})
},
methods: {
init() {
},
},
}
</script>