Commit 31f79bf0d90d0a2bdcd158054d09c90e65c3b2bc
Merge branch 'fix/DEFECT-2124' into 'main_dev'
fix: 属性下发拖动时 slider值应该跟随移动 See merge request yunteng/thingskit-front!1382
Showing
1 changed file
with
13 additions
and
10 deletions
| ... | ... | @@ -62,29 +62,31 @@ |
| 62 | 62 | }; |
| 63 | 63 | }); |
| 64 | 64 | |
| 65 | - const sendValue = ref(0); | |
| 66 | - const handleChange = async (value: number) => { | |
| 67 | - sendValue.value = value; | |
| 68 | - }; | |
| 65 | + // const sendValue = ref(0); | |
| 66 | + const isChangeValue = ref<number | string>(); //保留以前的值 报错的时候要取以前的值 | |
| 67 | + const handleChange = async () => {}; | |
| 69 | 68 | |
| 70 | 69 | const { loading, doControlSendCommand } = useControlComand(); |
| 71 | 70 | |
| 72 | - const handleAfterChange = () => { | |
| 71 | + const handleAfterChange = (value) => { | |
| 73 | 72 | if (unref(getDesign).password) { |
| 74 | 73 | openModal(true, { password: unref(getDesign).password }); |
| 75 | 74 | unref(sliderElRef)?.blur(); |
| 76 | 75 | return; |
| 77 | 76 | } |
| 78 | - handleSendCommand(); | |
| 77 | + handleSendCommand(value); | |
| 79 | 78 | }; |
| 80 | 79 | |
| 81 | - const handleSendCommand = async () => { | |
| 80 | + const handleSendCommand = async (value) => { | |
| 82 | 81 | if (props.config.option.mode === ComponentMode.SELECT_PREVIEW) return; |
| 83 | - const value = unref(sendValue); | |
| 84 | 82 | const { option } = props.config || {}; |
| 85 | 83 | const result = await doControlSendCommand(option, value); |
| 86 | 84 | unref(sliderElRef)?.blur(); |
| 87 | - sliderValue.value = result ? value : unref(sliderValue); | |
| 85 | + sliderValue.value = result ? value : unref(isChangeValue); | |
| 86 | + | |
| 87 | + if (result) { | |
| 88 | + isChangeValue.value = sliderValue.value; | |
| 89 | + } | |
| 88 | 90 | }; |
| 89 | 91 | |
| 90 | 92 | const { getNumberValue } = useReceiveValue(); |
| ... | ... | @@ -94,6 +96,7 @@ |
| 94 | 96 | const [name, value] = latest; |
| 95 | 97 | if (!name && !value) return; |
| 96 | 98 | sliderValue.value = getNumberValue(value); |
| 99 | + isChangeValue.value = getNumberValue(value); | |
| 97 | 100 | }; |
| 98 | 101 | |
| 99 | 102 | useDataFetch(props, updateFn); |
| ... | ... | @@ -125,7 +128,7 @@ |
| 125 | 128 | '--slider-top': -(getRatio ? getRatio * 5 : 5) + 'px', |
| 126 | 129 | }" |
| 127 | 130 | class="no-drag" |
| 128 | - :value="sliderValue" | |
| 131 | + v-model:value="sliderValue" | |
| 129 | 132 | :min="getDesign.minNumber" |
| 130 | 133 | :max="getDesign.maxNumber" |
| 131 | 134 | @change="handleChange" | ... | ... |