<template>
|
<el-radio-group
|
v-model="currentValue"
|
class="product-type-switch"
|
@change="handleChange"
|
>
|
<el-radio-button :label="1">原材料</el-radio-button>
|
<el-radio-button :label="3">半成品</el-radio-button>
|
<el-radio-button :label="2">成品</el-radio-button>
|
</el-radio-group>
|
</template>
|
|
<script setup>
|
import { ref, watch } from 'vue'
|
|
const props = defineProps({
|
modelValue: {
|
type: Number,
|
default: 1, // 默认选中"原材料"
|
},
|
})
|
|
const emit = defineEmits(['update:modelValue', 'change'])
|
|
const currentValue = ref(props.modelValue)
|
|
watch(
|
() => props.modelValue,
|
(newVal) => {
|
currentValue.value = newVal
|
}
|
)
|
|
const handleChange = (value) => {
|
emit('update:modelValue', value)
|
emit('change', value)
|
}
|
</script>
|
|
<style scoped>
|
.product-type-switch {
|
display: inline-flex;
|
}
|
|
.product-type-switch :deep(.el-radio-button__inner) {
|
background-color: rgba(20, 32, 66, 0.55);
|
color: #8fa3c8;
|
border-color: #1e3160;
|
border-radius: 0;
|
padding: 6px 20px;
|
font-size: 14px;
|
transition: color 0.2s ease, background-color 0.2s ease;
|
}
|
|
.product-type-switch :deep(.el-radio-button:first-child .el-radio-button__inner) {
|
border-top-left-radius: 6px;
|
border-bottom-left-radius: 6px;
|
}
|
|
.product-type-switch :deep(.el-radio-button:last-child .el-radio-button__inner) {
|
border-top-right-radius: 6px;
|
border-bottom-right-radius: 6px;
|
}
|
|
.product-type-switch :deep(.el-radio-button:not(:last-child) .el-radio-button__inner) {
|
border-right: 1px solid #1e3160;
|
}
|
|
.product-type-switch :deep(.el-radio-button__original-radio:checked + .el-radio-button__inner) {
|
background: #2c51d9;
|
color: #ffffff;
|
border-color: #2c51d9;
|
box-shadow: none;
|
}
|
|
.product-type-switch :deep(.el-radio-button__inner:hover) {
|
color: #eaf1ff;
|
}
|
|
.product-type-switch :deep(.el-radio-button__original-radio:checked + .el-radio-button__inner:hover) {
|
background: #4a6cf0;
|
border-color: #4a6cf0;
|
color: #ffffff;
|
}
|
</style>
|