| | |
| | | const filmsId = ref(''); |
| | | const patternThickness = ref(''); |
| | | const number = ref(''); |
| | | const canSelectProject = ref(true); // 假设开始时可以选择项目 |
| | | const canStartLoading = ref(false); |
| | | import { WebSocketHost ,host} from '@/utils/constants' |
| | | import request from "@/utils/request" |
| | | const ida = ref(null); |
| | |
| | | const socketUrl = `ws://${WebSocketHost}:${host}/api/loadGlass/api/talk/loadGlass`; |
| | | // 定义消息处理函数,更新 receivedData 变量 |
| | | const handleMessage = (data) => { |
| | | // 更新 tableData 的数据 |
| | | if(data.prioritylist!=null){ |
| | | tableData.splice(0, tableData.length, ...data.prioritylist[0]); |
| | | } |
| | | if(data.list!=null){ |
| | | tableDataa.value = data.list[0] |
| | | } |
| | | if(data.engineering ){ |
| | | if ( Array.isArray(data.engineering) && data.engineering.length !== 0) { |
| | | canSelectProject.value = false; |
| | | canStartLoading.value = true; |
| | | }else{ |
| | | canSelectProject.value = true; |
| | | canStartLoading.value = false; |
| | | } |
| | | } |
| | | if (data.InkageStatus) { |
| | | if(data.InkageStatus!=null){ |
| | | const status = data.InkageStatus[0]; |
| | | cuttingMachine.value = status; |
| | | upstatus.value = status === '1' ? t('basicData.machine') : t('basicData.machineaa'); |
| | | cuttingMachineStatusColor.value = status === '1' ? 'green' : '#911005'; |
| | | inKageWord.value = status === '1' ? 0 : 1; |
| | | } |
| | | } |
| | | }; |
| | | const requestData = { |
| | | state: 100 |
| | |
| | | ElMessage.error(t('basicData.glassnull')); |
| | | } |
| | | }; |
| | | const wsUrl = `ws://${WebSocketHost}:${host}/api/loadGlass/api/talk/loadGlass`; |
| | | const ws = new WebSocket(wsUrl); |
| | | ws.onopen = () => { |
| | | console.log('WebSocket连接已打开'); |
| | | }; |
| | | // 上片机联机状态 |
| | | // const wsUrl = `ws://${WebSocketHost}:${host}/api/loadGlass/api/talk/loadGlass`; |
| | | // const ws = new WebSocket(wsUrl); |
| | | // ws.onopen = () => { |
| | | // console.log('WebSocket连接已打开'); |
| | | // }; |
| | | |
| | | // 监听WebSocket的错误事件 |
| | | ws.onerror = (error) => { |
| | | console.error('WebSocket发生错误:', error); |
| | | }; |
| | | // // 监听WebSocket的错误事件 |
| | | // ws.onerror = (error) => { |
| | | // console.error('WebSocket发生错误:', error); |
| | | // }; |
| | | |
| | | // 监听WebSocket的关闭事件 |
| | | ws.onclose = (event) => { |
| | | if (event.wasClean) { |
| | | console.log('WebSocket连接已正常关闭'); |
| | | } else { |
| | | console.error('WebSocket连接异常关闭'); |
| | | } |
| | | }; |
| | | // 监听WebSocket的消息事件 |
| | | ws.onmessage = (event) => { |
| | | try { |
| | | |
| | | const data = JSON.parse(event.data.replace('<END>', '')); // 解析消息为JSON |
| | | |
| | | if (data && Array.isArray(data.InkageStatus) && data.InkageStatus.length > 0) { |
| | | if(data.InkageStatus!=null){ |
| | | const status = data.InkageStatus[0]; |
| | | cuttingMachine.value = status; |
| | | upstatus.value = status === '1' ? t('basicData.machine') : t('basicData.machineaa'); |
| | | cuttingMachineStatusColor.value = status === '1' ? 'green' : '#911005'; |
| | | inKageWord.value = status === '1' ? 0 : 1; |
| | | } |
| | | } else { |
| | | // 处理错误情况或无效数据 |
| | | // console.error('接收到的数据无效', data); |
| | | } |
| | | } catch (error) { |
| | | // console.error('解析WebSocket消息时发生错误', error); |
| | | } |
| | | }; |
| | | // // 监听WebSocket的关闭事件 |
| | | // ws.onclose = (event) => { |
| | | // if (event.wasClean) { |
| | | // console.log('WebSocket连接已正常关闭'); |
| | | // } else { |
| | | // console.error('WebSocket连接异常关闭'); |
| | | // } |
| | | // }; |
| | | // // 监听WebSocket的消息事件 |
| | | // ws.onmessage = (event) => { |
| | | // try { |
| | | // const data = JSON.parse(event.data.replace('<END>', '')); // 解析消息为JSON |
| | | // if (data && Array.isArray(data.InkageStatus) && data.InkageStatus.length > 0) { |
| | | // if(data.InkageStatus!=null){ |
| | | // const status = data.InkageStatus[0]; |
| | | // cuttingMachine.value = status; |
| | | // upstatus.value = status === '1' ? t('basicData.machine') : t('basicData.machineaa'); |
| | | // cuttingMachineStatusColor.value = status === '1' ? 'green' : '#911005'; |
| | | // inKageWord.value = status === '1' ? 0 : 1; |
| | | // } |
| | | // } else { |
| | | // // 处理错误情况或无效数据 |
| | | // // console.error('接收到的数据无效', data); |
| | | // } |
| | | // } catch (error) { |
| | | // // console.error('解析WebSocket消息时发生错误', error); |
| | | // } |
| | | // }; |
| | | const confirmCutting = async () => { |
| | | try { |
| | | const response = await request.post('/loadGlass/LoadGlass/updateMesInkageLoad', |
| | |
| | | <el-button @click="confirmCutting" style="margin-left: 30px;margin-top: -3px;" >{{ $t('basicData.change') }}</el-button> |
| | | |
| | | </div> |
| | | <el-button style="margin-top: 5px;margin-left: 15px;" id="searchButton" type="primary" @click="dialogFormVisible = true">{{ $t('basicData.selectproject') }}</el-button> |
| | | <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="primary" @click="handleBind">{{ $t('basicData.startloading') }}</el-button> |
| | | <el-button :disabled="!canSelectProject" style="margin-top: 5px;margin-left: 15px;" type="primary" @click="dialogFormVisible = true">{{ $t('basicData.selectproject') }}</el-button> |
| | | <el-button :style="{ backgroundColor: canStartLoading ? 'green' : 'initial',color: canStartLoading ? 'white' : 'black', }" style="margin-top: 5px;margin-left: 20px;" @click="handleBind">{{ $t('basicData.startloading') }}</el-button> |
| | | <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="warning" @click="handleBinda">{{ $t('basicData.stop') }}</el-button> |
| | | <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="info" @click="handlezhiban">{{ $t('searchOrder.dutyinformation') }}</el-button> |
| | | <!-- <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="danger" @click="handleBindb">停止任务</el-button> --> |