From cb99768a728002372bcb80885de2b4b2cd52e303 Mon Sep 17 00:00:00 2001 From: riku <risaku@163.com> Date: 星期一, 09 九月 2024 14:10:32 +0800 Subject: [PATCH] 1. 修复轨迹动画无法运行的问题 --- src/components/search/OptionDevice.vue | 35 ++++++++++++++++++++++++++++++++--- 1 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/components/search/OptionDevice.vue b/src/components/search/OptionDevice.vue index 2ba1468..d5a4d43 100644 --- a/src/components/search/OptionDevice.vue +++ b/src/components/search/OptionDevice.vue @@ -19,6 +19,8 @@ <script> import { deviceList } from '@/constant/device-type'; +import { mapStores } from 'pinia'; +import { useDeviceStore } from '@/stores/device'; export default { props: { @@ -30,24 +32,51 @@ return {}; }, computed: { + ...mapStores(useDeviceStore), deviceOptions() { - return deviceList(this.type); + return this.deviceStore.getDevice(this.type).map((v) => { + return { + label: v.deviceName, + value: v.deviceCode + }; + }); } }, watch: { + // type(nV, oV) { + // if (nV != oV) { + // this.refreshOptions(); + // } + // } deviceOptions(nV, oV) { if (nV != oV) { - this.handleChange(nV[0].value); + if (nV.length > 0) { + this.handleChange(nV[0].value); + } } } }, methods: { + fetchDevice() { + this.deviceStore.fetchDevice().then((res) => { + if (res.success && res.data.length > 0) { + this.handleChange(this.deviceOptions[0].value); + } + }); + }, + // refreshOptions() { + // this.deviceOptions = + // }, handleChange(value) { this.$emit('update:modelValue', value); } }, mounted() { - this.handleChange(this.deviceOptions[0].value); + if (this.deviceStore.deviceList.length == 0) { + this.fetchDevice(); + } else { + this.handleChange(this.deviceOptions[0].value); + } } }; </script> -- Gitblit v1.9.3