| | |
| | | }}</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 to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
|
| | | }}</router-link> -->
|
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ |
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <!-- <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> --> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | }}</router-link> |
| | |
| | | |
| | | <el-row :gutter="10"> |
| | | <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block" style="width:485px;"> |
| | | <el-card class="json-block" style="width:585px;">
|
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container"> |
| | | <div class="item-row"> |
| | | <span class="name" style="width:100px;">{{ item.name }}</span> |
| | | <span class="name" style="width:300px;">{{ item.name }}</span>
|
| | | <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0'" v-model="item.value" |
| | | class="input-box"></el-input> |
| | | </div> |
| | | </div> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <el-button v-if="item.button && item.button.state != 0" :name="item.button.name" v-model="item.button.value" |
| | | :class="{ 'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1 }" |
| | | <el-button v-if="item.button && language === 'en-US' && item.state != 0" :name="item.button.name"
|
| | | v-model="item.button.value"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === 'Fault' && item.button.value === 1, 'error-button2': item.button.name === 'NotZero' && item.button.value === 0 }"
|
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
|
| | | item.button.name }}</el-button>
|
| | | <el-button v-if="item.button && language === 'zh-CN' && item.state != 0" :name="item.button.name"
|
| | | v-model="item.button.value"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1, 'error-button2': item.button.name === '未回零' && item.button.value === 0 }"
|
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ |
| | | item.button.name }}</el-button> |
| | | </div> |
| | |
| | | data () { |
| | | return { |
| | | jsonData: data, |
| | | language: this.$i18n.locale,
|
| | | |
| | | // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, |
| | | created () { |
| | | activated () {
|
| | |
|
| | | this.initWebSocket(); |
| | | // console.log('jsonData:', this.jsonData); |
| | | const language = this.$i18n.locale;
|
| | | //console.log(language);
|
| | | if (language === 'en-US') {
|
| | | this.replaceChineseWithEnglish();
|
| | | }
|
| | | this.$forceUpdate();
|
| | |
|
| | | |
| | | }, |
| | | methods: { |
| | | closeSocket () {
|
| | | // 关闭 WebSocket 连接
|
| | | socket.close();
|
| | | },
|
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | |
| | |
| | | |
| | | }, |
| | | submitDataToBackend (currentButtonName) { |
| | | if (currentButtonName === 'A01启动') { |
| | | if (currentButtonName === 'A01启动' || currentButtonName === 'A01 Start') {
|
| | | const data = []; |
| | | |
| | | for (let i = 0; i < 1; i++) { |
| | |
| | | |
| | | data.push(values); |
| | | } |
| | | data.push([], [], [],[],[],[]);
|
| | | |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === 'A02启动') { |
| | | if (currentButtonName === 'A02启动' || currentButtonName === 'A02 Start') {
|
| | | const data = []; |
| | | |
| | | for (let i = 1; i < 2; i++) { |
| | |
| | | data.unshift([]); |
| | | data.push(values); |
| | | } |
| | | data.push([], [], [],[],[]);
|
| | | |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === 'B01启动') { |
| | | if (currentButtonName === 'B01启动' || currentButtonName === 'B01 Start') {
|
| | | const data = []; |
| | | |
| | | for (let i = 2; i < 3; i++) { |
| | |
| | | data.unshift([], []); |
| | | data.push(values); |
| | | } |
| | | //data.unshift([]);
|
| | | |
| | | data.push([], [], [],[]);
|
| | | |
| | | |
| | | const jsonObject = { data }; |
| | |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === 'B02启动') { |
| | | if (currentButtonName === 'B02启动' || currentButtonName === 'B02 Start') {
|
| | | const data = []; |
| | | |
| | | for (let i = 3; i < 4; i++) { |
| | |
| | | data.push(values); |
| | | } |
| | | |
| | | data.push([], [],[]);
|
| | |
|
| | | |
| | | |
| | | const jsonObject = { data }; |
| | |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === '故障') { |
| | | if (currentButtonName === '故障' || currentButtonName === 'Fault') {
|
| | | |
| | | const data2 = []; |
| | | const resetButtonValues = this.jsonData.map(item => { |
| | | const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '故障'); |
| | | // const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '故障' || subItem.button.name === 'Fault');
|
| | | const buttonItem = item.find(subItem => subItem.button && ['故障', 'Fault'].includes(subItem.button.name));
|
| | | return buttonItem ? buttonItem.button.value : null; |
| | | }).filter(value => value !== null); |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data2.push(...resetButtonValues); |
| | | data2.unshift([], [], [], []); |
| | | const jsonObject2 = { data2 }; |
| | | const jsonObject2 = { data:data2 };
|
| | | data.push([],[]);
|
| | | |
| | | // 提交数据到后端 |
| | | const jsonString2 = JSON.stringify(jsonObject2); |
| | |
| | | |
| | | } |
| | | |
| | | if (currentButtonName === '复位') { |
| | | if (currentButtonName === '复位' || currentButtonName === 'Reset') {
|
| | | |
| | | const data2 = []; |
| | | const resetButtonValues = this.jsonData.map(item => { |
| | | const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '复位'); |
| | | const buttonItem = item.find(subItem => subItem.button && ['复位', 'Reset'].includes(subItem.button.name));
|
| | |
|
| | | return buttonItem ? buttonItem.button.value : null; |
| | | }).filter(value => value !== null); |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data2.push(...resetButtonValues); |
| | | data2.push(resetButtonValues.flat());
|
| | | data2.unshift([], [], [], [], []); |
| | | const jsonObject2 = { data2 }; |
| | | const jsonObject2 = { data:data2 };
|
| | | data2.push([]);
|
| | | |
| | | // 提交数据到后端 |
| | | const jsonString2 = JSON.stringify(jsonObject2); |
| | | console.log('所有复位的value:', jsonString2); |
| | | socket?.send(jsonString2); |
| | | |
| | | // setTimeout(() =>
|
| | | // window.location.reload(), 2000
|
| | | // )
|
| | | |
| | | } |
| | | |
| | | if (currentButtonName === '回零') { |
| | | if (currentButtonName === '回零' || currentButtonName === 'Zero') {
|
| | | |
| | | const data2 = []; |
| | | const resetButtonValues = this.jsonData.map(item => { |
| | | const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '回零'); |
| | | const buttonItem = item.find(subItem => subItem.button && ['回零', 'Zero'].includes(subItem.button.name));
|
| | |
|
| | | return buttonItem ? buttonItem.button.value : null; |
| | | }).filter(value => value !== null); |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data2.push(...resetButtonValues); |
| | | data2.push(resetButtonValues.flat());
|
| | | data2.unshift([], [], [], [], [], []); |
| | | const jsonObject2 = { data2 }; |
| | | const jsonObject2 = { data:data2 };
|
| | | |
| | | // 提交数据到后端 |
| | | const jsonString2 = JSON.stringify(jsonObject2); |
| | | console.log('所有回零的value:', jsonString2); |
| | | socket?.send(jsonString2); |
| | | |
| | | // setTimeout(() =>
|
| | | // window.location.reload(), 2000
|
| | | // )
|
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | // console.log(obj) |
| | | // console.log(obj);
|
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const weihuiling = obj.weihuiling;
|
| | | const handleMouseMove = throttle(function (event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | |
| | | }); |
| | | |
| | | // 遍历guzhang数组 |
| | | for (let i = 0; i < obj.guzhang[0].length; i++) { |
| | | const guzhangValue = obj.guzhang[0][i]; |
| | | |
| | | // 查找jsonData2中带有"button"的对象,并且name等于"故障" |
| | | for (let j = 0; j < jsonData2.length; j++) { |
| | | const section = jsonData2[j]; |
| | | |
| | | for (let k = 0; k < section.length; k++) { |
| | | const item = section[k]; |
| | | |
| | | if (item.button && item.button.name === "故障") { |
| | | // 更新value属性 |
| | | item.button.value = guzhangValue; |
| | | break; |
| | | for (let i = 0; i < jsonData2.length; i++) {
|
| | | let arr = jsonData2[i];
|
| | | for (let j = 0; j < arr.length; j++) {
|
| | | let obj2 = arr[j];
|
| | | if (obj2.button && (obj2.button.name === "故障" || obj2.button.name === "Fault")) {
|
| | | obj2.button.value = obj.guzhang[0][i];
|
| | | // console.log(obj2.button.value)
|
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
|
| | | for (let i = 2; i < jsonData2.length; i++) {
|
| | | let arr2 = jsonData2[i];
|
| | | for (let j = 2; j < arr2.length; j++) {
|
| | | let obj3 = arr2[j];
|
| | | if (obj3.button) {
|
| | | if (obj3.button && (obj3.button.name === "未回零" || obj3.button.name === "NotZero")) {
|
| | | obj3.button.value = weihuiling[0][i];
|
| | | console.log(obj3.button.value)
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | } |
| | | |
| | | |
| | |
| | | socket.onerror = function () { |
| | | console.log("websocket发生了错误"); |
| | | }; |
| | | this.$router.afterEach(function () {
|
| | | socket.close();
|
| | | })
|
| | | |
| | | } |
| | | }, |
| | |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | },
|
| | | replaceChineseWithEnglish () {
|
| | |
|
| | |
|
| | | const nameMap = this.$t('ManualonePositionlang')
|
| | | this.jsonData = this.jsonData.map((item) => {
|
| | | return item.map((obj) => {
|
| | | if (obj.name) {
|
| | | const newName = nameMap[obj.name] || obj.name;
|
| | | return { ...obj, name: newName };
|
| | | } else if (obj.button && obj.button.name) {
|
| | | const newName = nameMap[obj.button.name] || obj.button.name;
|
| | | return { ...obj, button: { ...obj.button, name: newName } };
|
| | | } else if (obj.title && obj.title.name) {
|
| | | const newName = nameMap[obj.title.name] || obj.title.name;
|
| | | return { ...obj, title: { ...obj.title, name: newName } };
|
| | | } else {
|
| | | return obj;
|
| | | }
|
| | | });
|
| | | });
|
| | |
|
| | |
|
| | |
|
| | | } |
| | | |
| | | } |
| | |
| | | .error-button { |
| | | background-color: red; |
| | | } |
| | |
|
| | | .error-button2 {
|
| | | background-color: red;
|
| | | }
|
| | | </style> |