smart-admin/smart-app/src/components/smart-enum-radio/index.vue
2024-03-10 22:26:32 +08:00

43 lines
1.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--
* 枚举 radio
*
* @Author: 1024创新实验室-主任卓大
* @Date: 2022-08-08 20:32:30
* @Wechat: zhuda1024
* @Email: lab1024@163.com
* @Copyright 1024创新实验室 https://1024lab.net Since 2012
*
-->
<template>
<radio-group @change="handleChange">
<label v-for="item in $smartEnumPlugin.getValueDescList(props.enumName)" :key="item.value" class="smart-margin-right10">
<radio :value="item.value + ''" :checked="item.value === modelValue">{{ item.desc }}</radio>
</label>
</radio-group>
</template>
<script setup>
import { ref, watch } from 'vue';
const props = defineProps({
enumName: String,
modelValue: [Number, String],
});
const emit = defineEmits(['update:modelValue', 'change']);
const selectValue = ref(props.modelValue);
watch(
() => props.modelValue,
(newValue) => {
selectValue.value = newValue;
}
);
function handleChange(e) {
emit('update:modelValue', e.detail.value);
emit('change', e.detail.value);
}
</script>