| | |
| | | active-class="blue-button" |
| | | >{{ $t("State") }}</router-link |
| | | > |
| | | <router-link |
| | | <!-- <router-link |
| | | to="/Electrical/Action" |
| | | tag="el-button" |
| | | type="text" |
| | | active-class="blue-button" |
| | | >{{ $t("Action") }}</router-link |
| | | > |
| | | > --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link |
| | |
| | | active-class="blue-button" |
| | | >{{ $t("Automatic State") }}</router-link |
| | | > |
| | | <router-link |
| | | <!-- <router-link |
| | | to="/Electrical/ManualJog" |
| | | tag="el-button" |
| | | type="text" |
| | | active-class="blue-button" |
| | | >{{ $t("ManualJog") }}</router-link |
| | | > |
| | | > --> |
| | | |
| | | <router-link |
| | | to="/Electrical/ManualonePosition" |
| | |
| | | active-class="blue-button" |
| | | >{{ $t("Speed parameter settings") }}</router-link |
| | | > |
| | | |
| | | <router-link |
| | | to="/Electrical/InteractionState" |
| | | tag="el-button" |
| | | type="text" |
| | | active-class="blue-button" |
| | | >{{ $t("InteractionState") }}</router-link |
| | | > |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="18" class="card"> |
| | |
| | | <el-input |
| | | v-if="item.type === '0'" |
| | | v-model="item.value" |
| | | class="input-box" |
| | | @keyup.enter.native="submitDataToBackend" |
| | | class="input-box" :oninput="`value=value.replace(/^0|[^0-9]/g,'');if(value<`+item.min+`){value=`+item.value+`}else if(value>`+item.max+`){value=`+item.value+`}`" |
| | | @keyup.enter.native="submitDataToBackend($event)" |
| | | ></el-input> |
| | | <span v-if="item.unit" :name="item.unit">{{ item.unit }}</span> |
| | | |
| | |
| | | this.$set(dataGroup[itemIndex].button, "value", 1); // 点击按钮后将值改为1 |
| | | }, |
| | | //提交数据到后端 |
| | | submitDataToBackend() { |
| | | submitDataToBackend(event) { |
| | | const inputData = this.jsonData.map((dataGroup) => { |
| | | return dataGroup.map((item) => { |
| | | if (item.type === "0") { |
| | |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | // console.log('提交以下数据到后端:', jsonString); |
| | | console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | event.target.blur(); // 取消输入框焦点 |
| | | }, |
| | | initWebSocket() { |
| | | let viewname = "Positioning1"; |
| | |
| | | }; |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | // let isMouseInInputBox = false; // 标记鼠标是否在输入框内 |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | document.addEventListener("mouseover", function (event) { |
| | | const inputBox = document.querySelectorAll(".input-box"); |
| | | const target = event.target; |
| | | const parms = obj.params; |
| | | if ( |
| | | parms && |
| | | inputBox && |
| | | Array.from(inputBox).every((box) => !box.contains(target)) |
| | | ) { |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | // const inputBox = document.querySelectorAll('.input-box'); |
| | | // inputBox.forEach(box => { |
| | | // box.addEventListener('mouseenter', () => { |
| | | // isMouseInInputBox = true; |
| | | // }); |
| | | // box.addEventListener('mouseleave', () => { |
| | | // isMouseInInputBox = false; |
| | | // }); |
| | | // }); |
| | | |
| | | // console.log(parms) |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | if (document.activeElement.tagName.toLowerCase() === 'input') { |
| | | return; |
| | | } |
| | | |
| | | let index = 0; |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if ( |
| | | obj.type === "0" && |
| | | Object.prototype.hasOwnProperty.call(obj, "value") |
| | | ) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | // console.log(jsonData2); |
| | | } |
| | | }); |
| | | }; |
| | | const parms = obj.params; |
| | | |
| | | if(parms ){ // 只有在鼠标不在输入框内时才更新数据 |
| | | // console.log(parms) |
| | | |
| | | let index = 0; |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if ( |
| | | obj.type === "0" && |
| | | Object.prototype.hasOwnProperty.call(obj, "value") |
| | | ) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | |
| | | // 关闭事件 |
| | | socket.onclose = function () { |