| | |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" style="margin: 10px;"> |
| | | <el-button v-if="item.button" v-model="item.button.value" :name="item.button.name" style='width:200px;' |
| | | :class="{ 'dow': item.button.value === 0, 'op': item.button.value === 1 }" class="action-button" |
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend();">{{ |
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ |
| | | item.button.name |
| | | }}</el-button> |
| | | </div> |
| | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/ManualJog' |
| | | import {SelectPassword} from "../../api/home"; |
| | | let socket; |
| | | export default { |
| | | name: "ManualJog", |
| | | mixins: [LanguageMixin], |
| | | data () { |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | jsonData: data, // 加载整个data.json文件作为jsonData |
| | | password: 1, |
| | | } |
| | | }, |
| | | activated () { |
| | | |
| | | |
| | | this.initWebSocket(); |
| | | const language = this.$i18n.locale; |
| | |
| | | } |
| | | // this.$forceUpdate(); |
| | | |
| | | |
| | | SelectPassword().then(res => { |
| | | this.password = res.data.password; |
| | | console.log(this.password) |
| | | }); |
| | | }, |
| | | methods: { |
| | | closeSocket () { |
| | |
| | | this.$set(dataGroup[itemIndex].button, 'value2', 0); |
| | | } |
| | | }, |
| | | submitDataToBackend () { |
| | | submitDataToBackend (currentButtonName) { |
| | | |
| | | if (currentButtonName === 'A01 SERVE TRAVEL Home' || currentButtonName === 'A02 SERVE TRAVEL Home' || currentButtonName === 'A01行走伺服回零' || currentButtonName === 'A02行走伺服回零') { |
| | | this.$prompt( |
| | | this.$t('Are you sure to perform this operation?'), |
| | | this.$t('prompt'), |
| | | { |
| | | inputType: 'password', |
| | | inputPlaceholder: this.$t('Please enter the password'), |
| | | confirmButtonText: this.$t('Yes'), |
| | | cancelButtonText: this.$t('No'), |
| | | type: 'warning', |
| | | } |
| | | ).then(({ value }) => { |
| | | // 验证密码是否正确 |
| | | if (value !== this.password) { |
| | | this.$message.error(this.$t('Incorrect password')); |
| | | return; |
| | | } |
| | | |
| | | // 密码正确,继续提交数据到后端 |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | |
| | | console.log('Type为3的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | }).catch(() => { |
| | | // 取消操作 |
| | | console.log('取消'); |
| | | }); |
| | | } else { |
| | | // 如果不是 A01 SERVE TRAVEL Home 按钮,继续提交数据到后端 |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | | return { value: item.button.value2 }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | const values = inputData.flat().filter(item => item !== null).map(item => item.value); |
| | | |
| | | const jsonObject = { data: values }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('Type为3的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | } |
| | | }, |
| | | //根据读取PLC的值,根据名称改变颜色1打开,0关闭 |
| | | // getStatusClass (zhuangtai) { |
| | |
| | | |
| | | const jsonData2 = this.jsonData; |
| | | const parms = obj.params; |
| | | console.log(obj) |
| | | // console.log(obj) |
| | | //console.log(this.jsonData) |
| | | if(parms){ |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | obj.button.value = parms[0][j]; |
| | | obj.button.value2 =obj.button.value; |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |