diff --git a/src/components/info/AirSwitchConfig.vue b/src/components/info/AirSwitchConfig.vue index dd56338..9e46485 100644 --- a/src/components/info/AirSwitchConfig.vue +++ b/src/components/info/AirSwitchConfig.vue @@ -73,7 +73,7 @@ import { airInletProportionalValve_getStateJSON, AirOutletProportionalValve_getStateJSON, } from '@/mock/command' -import { ref, onMounted } from 'vue' +import { ref, onMounted, watch } from 'vue' const activeTab = ref('1') const sealStore = useSealStore() @@ -87,39 +87,59 @@ const bottomText = ref('0%') const topChange = ({ selectedOptions, selectedValues }) => { topText.value = selectedOptions[0].text webSocketStore.sendCommandMsg( - AirInletProportionalValve_setStateJSON([parseInt(selectedValues[0]) * 10]), + AirInletProportionalValve_setStateJSON([parseInt(selectedValues[0])]), ) - sealStore.updateAirInletProportionalValue(parseInt(selectedValues[0]) * 10) + sealStore.updateAirInletProportionalValue(parseInt(selectedValues[0])) } const bottomChange = ({ selectedOptions, selectedValues }) => { bottomText.value = selectedOptions[0].text webSocketStore.sendCommandMsg( - AirOutletProportionalValve_setStateJSON([parseInt(selectedValues[0]) * 10]), + AirOutletProportionalValve_setStateJSON([parseInt(selectedValues[0])]), ) - sealStore.updateAirOutletProportionalValue(parseInt(selectedValues[0]) * 10) + sealStore.updateAirOutletProportionalValue(parseInt(selectedValues[0])) } const columns = ref([ { text: '0%', value: '0' }, - { text: '10%', value: '1' }, - { text: '20%', value: '2' }, - { text: '30%', value: '3' }, - { text: '40%', value: '4' }, - { text: '50%', value: '5' }, - { text: '60%', value: '6' }, - { text: '70%', value: '7' }, - { text: '80%', value: '8' }, - { text: '90%', value: '9' }, - { text: '100%', value: '10' }, + { text: '10%', value: '10' }, + { text: '20%', value: '20' }, + { text: '30%', value: '30' }, + { text: '40%', value: '40' }, + { text: '50%', value: '50' }, + { text: '60%', value: '60' }, + { text: '70%', value: '70' }, + { text: '80%', value: '80' }, + { text: '90%', value: '90' }, + { text: '100%', value: '100' }, ]) const selectedValuesTop = ref(['0']) const selectedValuesBottom = ref(['0']) onMounted(() => { - webSocketStore.sendCommandMsg(airInletProportionalValve_getStateJSON) - webSocketStore.sendCommandMsg(AirOutletProportionalValve_getStateJSON) + setTimeout(() => { + webSocketStore.sendCommandMsg(airInletProportionalValve_getStateJSON) + webSocketStore.sendCommandMsg(AirOutletProportionalValve_getStateJSON) + }, 1000) }) + +watch( + () => sealStore.airInletProportionalInitVal, + (newVal, oldVal) => { + console.log('airInletProportionalInitVal', newVal) + selectedValuesTop.value = [newVal + ''] + topText.value = `${newVal}%` + }, +) + +watch( + () => sealStore.airOutletProportionalInitVal, + (newVal, oldVal) => { + console.log('airOutletProportionalInitVal', newVal) + selectedValuesBottom.value = [newVal + ''] + bottomText.value = `${newVal}%` + }, +)