From 59e2283a10aee45e6a98e34b432ba345095116db Mon Sep 17 00:00:00 2001 From: wujian <14790700720@163.com> Date: 星期三, 10 七月 2024 16:36:42 +0800 Subject: [PATCH] add 选瓦 --- jcdm-ui/src/views/main/cfkb/crankshaftUp/index.vue | 115 +++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 71 insertions(+), 44 deletions(-) diff --git a/jcdm-ui/src/views/main/cfkb/crankshaftUp/index.vue b/jcdm-ui/src/views/main/cfkb/crankshaftUp/index.vue index e8fb564..e46a44c 100644 --- a/jcdm-ui/src/views/main/cfkb/crankshaftUp/index.vue +++ b/jcdm-ui/src/views/main/cfkb/crankshaftUp/index.vue @@ -8,26 +8,7 @@ </div> </template> </el-card> - <el-row :gutter="3"> - <el-col :span="6"> - <el-card shadow="always" class="boxSize"> - <div class="centerImg"> - <img style="width: 140px;height: 30px;" src="@/assets/logo/jcdm2.png" alt="dark"> - </div> - </el-card> - </el-col> - <el-col :span="3"> - <el-card shadow="always" class="boxSize"> - <span class="centerText" style="height: 60px">{{locationCode}}</span> - </el-card> - </el-col> - <el-col :span="15"> - <el-card shadow="always" class="boxSize"> - <span class="centerText" >{{locationName}}</span> - </el-card> - </el-col> - </el-row> <el-card class="box-card" > <el-form :model="from" size="large" :inline="true" label-width="68px" @submit.native.prevent> <el-form-item label-width="200" label="鏇茶酱鐮�" :prop="from.scanObject2" style="align-content: center"> @@ -71,6 +52,8 @@ import { listTileMatchRules, getTileMatchRules, delTileMatchRules, addTileMatchRules, updateTileMatchRules } from "@/api/main/bs/tileMatchRules/tileMatchRules"; import {listStationConf,getIp} from "@/api/main/sc/stationConf"; import {setBarcode1} from "@/api/main/da/opcuaconfig/opcuaconfig"; +import WebSocketReconnect from "@/utils/WebsocketTool"; +import {getUrl} from "@/api/main/bs/orderScheduling/orderScheduling"; export default { name: "index", dicts: ['colour_hex','productseries','axisname','neckname','tilename'], @@ -81,7 +64,7 @@ return{ scannerFlag: false, loading: true, - locationCode: "鏈厤缃�", + locationCode: "OP030", locationName: "鏈厤缃伐浣�", tileMatchKbList: [], qrCode: '', @@ -130,8 +113,8 @@ } }, mounted() { + this.getWebUrl() this.setFocus() - this.getStationConf() //this.getNowTime() this.$refs.inputdata.addEventListener('keydown',this.handleScannerInput) }, @@ -139,6 +122,65 @@ this.$refs.inputdata.removeEventListener('keydown',this.handleScannerInput) }, methods:{ + getWebUrl(){ + getUrl().then(res=>{ + this.websocketUrl = res+"OP030" + console.log('websocketUrl锛�',this.websocketUrl) + this.initWebSocket() + }) + }, + initWebSocket: function (){ + //鍒ゆ柇褰撳墠娴忚鍣ㄦ槸鍚︽敮鎸乄ebSocket + if ('WebSocket' in window) { + //杩炴帴WebSocket鑺傜偣 + this.websocket = new WebSocketReconnect(this.websocketUrl); + //鎺ユ敹鍒版秷鎭殑鍥炶皟鏂规硶 + this.websocket.socket.onmessage = (event) => { + let data = event.data; + if (data != null && data !== ''){ + this.result = JSON.parse(data); + if (this.result.server_message === 'clean'){ + this.$refs.inputdata1.focus(); + this.from.scanObject1 = '' + this.from.scanObjectCopy = '' + this.from.scanObject2 = '' + this.from.scanObject3 = '' + this.from.scanObject4 = '' + this.from.scanObject5 = '' + this.queryParams.productSeries = '' + this.queryParams.scanObject1 = '' + this.queryParams.scanObjectCopy = '' + this.queryParams.scanObject2 = '' + this.queryParams.scanObject3 = '' + this.queryParams.scanObject4 = '' + this.queryParams.scanObject5 = '' + this.queryParams.checkResult = '' + this.queryParams.checkResultColor = '' + this.queryParams.tileColor = '' + this.queryParams.words = '' + } else if (this.result.server_message.indexOf("*") !== -1){ + const parts1 = this.result.server_message.split("*"); + if (parts1.length >= 2) { + console.log("44",parts1) + //const axisValueextracted = parts1[2].substring(3,4); + this.queryParams.productSeries = parts1[0] + this.queryParams.scanObject1 = parts1[1] + } + } + } + } + //鐩戝惉绐楀彛鍏抽棴浜嬩欢锛屽綋绐楀彛鍏抽棴鏃讹紝涓诲姩鍘诲叧闂瓀ebsocket杩炴帴锛岄槻姝㈣繛鎺ヨ繕娌℃柇寮�灏卞叧闂獥鍙o紝server绔細鎶涘紓甯搞�� + window.onbeforeunload = function () { + this.websocket.close() + } + //鍏抽棴杩炴帴 + function closeWebSocket() { + this.websocket.close() + } + } else { + alert('娴忚鍣ㄤ笉鏀寔webSocket') + } + }, refresh() { location.reload(); }, @@ -160,26 +202,23 @@ this.scannerFlag = true this.from.scanObject2 = inputValue //console.log('鏉$爜锛�',this.from.scanObject2,this.locationCode) - if (typeof this.from.scanObject2 !== 'undefined'&& typeof this.locationCode !== 'undefined' ) { + if (this.from.scanObject2 !== null && this.from.scanObject2 !== '' && this.locationCode !== '' ) { console.log('鏉$爜锛�',this.from.scanObject2,this.locationCode) setBarcode1({barcode:this.from.scanObject2,locationCode:this.locationCode}).then(res => { - if (res.data===500){ - this.$message({ - message:res.msg, - type:'warning' - }) - }else { + if (res.code === 200){ this.$message({ message:'鎿嶄綔鎴愬姛', type:'success' }) console.log('杩斿洖锛�',res) - this.queryParams.productSeries=res.sfcCode - this.queryParams.scanObject1=res.paramValue - this.queryParams.scanObject2=this.from.scanObject2 + this.queryParams.scanObject2 = this.from.scanObject2 this.queryParams.words="鎵爜鎴愬姛"; this.queryParams.tileColor='#00FF00'; - + }else { + this.$message({ + message:res.msg, + type:'warning' + }) } }) @@ -193,18 +232,6 @@ } }, - /** 鏌ヨ宸ヤ綅缁堢閰嶇疆鍒楄〃 */ - getStationConf() { - getIp().then(response => { - let queryParams = { - ipAddress: response.msg, - } - listStationConf(queryParams).then(response => { - this.locationName = response.rows[0].processesName - this.locationCode = response.rows[0].processesCode - }); - }); - }, /** 鎼滅储鎸夐挳鎿嶄綔 */ handleQuery() { this.clear(); -- Gitblit v1.9.3