| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <template>
- <el-select
- :value="value"
- @input="$emit('input', $event)"
- v-bind="$attrs"
- @change="changeData"
- >
- <el-option
- v-for="item in dict"
- :key="item.id || item.dictValue"
- :label="item.dictName"
- :value="item.dictValue"
- />
- </el-select>
- </template>
- <script>
- export default {
- name: 'VabDictSelect',
- props: {
- dictCode:{
- required:true,
- type:String
- },
- value:[String,Number],
- },
- emits: ['change', 'update:value'],
- watch:{
- value(newVal){
- if(typeof newVal == 'number'){
- // eslint-disable-next-line vue/no-mutating-props
- this.value = newVal+'';
- this.$forceUpdate();
- }
- console.log(this.dict[0].dictValue ,this.value)
- }
- },
- data(){
- return {
- dict:[],
- }
- },
- computed: {
- localModelValue: {
- get() {
- return this.modelValue;
- },
- set(newValue) {
- this.$emit('update:value', newValue);
- }
- }
- },
- methods:{
- changeData(){
- this.$emit('change',this.value)
- }
- },
- created() {
- this.dict = this.$getDictList(this.dictCode);
- }
- }
- </script>
|