From 16eb4bd55a4fd61ddd7a171b1a07378c45d1665b Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期四, 05 六月 2025 13:59:28 +0800 Subject: [PATCH] 动态溯源(待完成) --- src/components/monitor/FactorRadio.vue | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/components/monitor/FactorRadio.vue b/src/components/monitor/FactorRadio.vue index a5ebb94..e95e72d 100644 --- a/src/components/monitor/FactorRadio.vue +++ b/src/components/monitor/FactorRadio.vue @@ -1,5 +1,5 @@ <template> - <BaseCard class="map-factor-selector"> + <BaseCard> <template #content> <el-radio-group v-model="radio" size="default" @change="handleChange"> <el-radio v-for="(item, i) in options" :key="i" :value="item.value">{{ @@ -12,18 +12,50 @@ <script> // 鐩戞祴鍥犲瓙鍗曢�夋 -import { radioOptions } from '@/constant/radio-options'; +import { radioOptions, defaultOptions } from '@/constant/radio-options'; +import { TYPE0 } from '@/constant/device-type'; + export default { - emits:['change'], + props: { + modelValue: { + type: String, + default: defaultOptions(TYPE0).value + }, + deviceType: { + type: String, + // type0: 杞﹁浇鎴栨棤浜烘満; type1:鏃犱汉鑸� + default: TYPE0 + } + }, + emits: ['change', 'update:modelValue'], data() { return { - radio: radioOptions.type0[0].value, - options: radioOptions.type0 + radio: defaultOptions(TYPE0).value }; }, - method:{ + computed: { + options() { + return radioOptions(this.deviceType); + } + }, + watch: { + deviceType(nV, oV) { + if (nV != oV) { + this.radio = this.options[0].value; + this.$emit('update:modelValue', this.radio) + } + }, + modelValue(nV, oV){ + if (nV != oV) { + this.radio = nV + } + } + }, + methods: { handleChange(value) { - this.$emit('change', value) + const item = this.options.find((v) => v.value == value); + this.$emit('change', item.value, item); + this.$emit('update:modelValue', item.value) // todo 鍦板浘3d鍥惧儚鍒囨崲灞曠ず鐩戞祴鍥犲瓙 } } @@ -32,6 +64,7 @@ <style scoped> .el-radio { --el-radio-text-color: white; + --el-color-primary: #23dad1; margin-right: 10px; height: initial; } -- Gitblit v1.9.3