56 lines
1.2 KiB
Vue
Raw Normal View History

2025-06-05 09:42:18 +08:00
<template>
<el-radio-group v-model="radioValue" @change="change" v-bind="$props">
<el-radio-button v-for="dict in dictList" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio-button>
</el-radio-group>
</template>
<script>
import { getDicts } from '@/api/system/dict/data';
export default {
props: ['radioData', 'size', 'value', 'showAll', 'filter'],
data() {
return {
dictList: []
};
},
computed: {
radioValue: {
get() {
return this.value;
},
set(v) {
this.$emit('input', v);
}
}
},
created() {
if (this.radioData) {
this.getEmuList();
}
},
methods: {
change(val) {
this.$emit('change', val);
},
getEmuList() {
getDicts(this.radioData)
.then((res) => {
const { code, data = [] } = res || {};
if (code == 200) {
const dicArr = data.map((p) => {
return { label: p.dictLabel, value: p.dictValue, elTagType: p.listClass, elTagClass: p.cssClass };
});
this.dictList = dicArr || [];
} else {
this.dictList = [];
}
})
.catch(() => {
this.dictList = [];
});
}
}
};
</script>