Commit 853d9ab7fbb8d21855bdb3cb6dd1e7f3f25d7c0a
Merge branch 'fix/data-board-control-send-issue' into 'main_dev'
fix: 修改看板控制组件 See merge request yunteng/thingskit-front!717
Showing
1 changed file
with
19 additions
and
5 deletions
... | ... | @@ -15,8 +15,10 @@ |
15 | 15 | |
16 | 16 | const sliderValue = ref<number>(33); |
17 | 17 | const oldSliderValue = ref<number>(33); |
18 | + const noSendValue = ref<number>(0); | |
18 | 19 | const sMin = ref<number>(0); |
19 | 20 | const sMax = ref<number>(100); |
21 | + const sliderEl = ref<Nullable<InstanceType<typeof Slider>>>(null); | |
20 | 22 | |
21 | 23 | const { loading, sendCommand } = useSendCommand(); |
22 | 24 | |
... | ... | @@ -43,11 +45,20 @@ |
43 | 45 | sliderValue.value = e; |
44 | 46 | }; |
45 | 47 | |
46 | - const handleAfterChange = async (e) => { | |
47 | - const flag = await sendCommand(props.config.option, unref(sliderValue)); | |
48 | - flag | |
49 | - ? ((sliderValue.value = e), (oldSliderValue.value = sliderValue.value), (index.value = 0)) | |
50 | - : (sliderValue.value = unref(oldSliderValue)); | |
48 | + const handleAfterChange = async () => { | |
49 | + unref(sliderEl)?.blur(); | |
50 | + }; | |
51 | + | |
52 | + const handleBlur = async () => { | |
53 | + if (unref(oldSliderValue) !== unref(sliderValue)) { | |
54 | + console.log('effect'); | |
55 | + const flag = await sendCommand(props.config.option, unref(sliderValue)); | |
56 | + flag | |
57 | + ? ((sliderValue.value = unref(sliderValue)), | |
58 | + (oldSliderValue.value = sliderValue.value), | |
59 | + (index.value = 0)) | |
60 | + : (sliderValue.value = unref(oldSliderValue)); | |
61 | + } | |
51 | 62 | }; |
52 | 63 | |
53 | 64 | const { getNumberValue } = useReceiveValue(); |
... | ... | @@ -55,6 +66,7 @@ |
55 | 66 | const { data = {} } = message; |
56 | 67 | const [latest] = data[attribute] || []; |
57 | 68 | const [_, value] = latest; |
69 | + noSendValue.value = getNumberValue(value); | |
58 | 70 | sliderValue.value = getNumberValue(value); |
59 | 71 | }; |
60 | 72 | |
... | ... | @@ -74,6 +86,7 @@ |
74 | 86 | >{{ sliderValue }}</span |
75 | 87 | > |
76 | 88 | <Slider |
89 | + ref="sliderEl" | |
77 | 90 | :style="{ '--slider-color': getDesign.controlBarColor }" |
78 | 91 | class="no-drag" |
79 | 92 | :value="sliderValue" |
... | ... | @@ -81,6 +94,7 @@ |
81 | 94 | :max="sMax" |
82 | 95 | @change="handleChange" |
83 | 96 | @afterChange="handleAfterChange" |
97 | + @blur="handleBlur" | |
84 | 98 | /> |
85 | 99 | |
86 | 100 | <span | ... | ... |