| | |
| | | </view> |
| | | <!-- 日历 --> |
| | | <view class="time-tools">{{calendar}}</view> |
| | | <view class="version">V:{{version}}</view> |
| | | <view class="button-left" @click="ejected()"></view> |
| | | <view class="button-right" @click="ejected()"></view> |
| | | <!-- 主视图 --> |
| | |
| | | </y-box> |
| | | </view> |
| | | <view style="height: 2%;"></view> |
| | | <view style="height: 18%;"> |
| | | <y-box> |
| | | <view class="flex-col" style="width: 100%;height: 100%;font-size: 4vh;justify-content: center;letter-spacing: 1vh;"> |
| | | 智能大屏显示系统 |
| | | </view> |
| | | </y-box> |
| | | <view style="height: 18%;display: flex;justify-content: space-around;align-items: center;"> |
| | | <!-- <view style="font-size: 4vh"> |
| | | 自动仓库WCS监控平台 |
| | | </view> --> |
| | | <view style="height: 50%;"> |
| | | <image style="height: 100%;" src="../../static/img/logo-bai.png" mode="aspectFit"></image> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | </view> |
| | | </view> |
| | | <view class="item"> |
| | | <view class="desc">port:</view> |
| | | <view class="desc">Wcsport:</view> |
| | | <view class="input"> |
| | | <input type="text" v-model="basePort"> |
| | | </view> |
| | | </view> |
| | | <view class="item"> |
| | | <view class="desc">WcsUrl:</view> |
| | | <view class="input"> |
| | | <input type="text" v-model="baseUrl"> |
| | | </view> |
| | | </view> |
| | | <view class="item"> |
| | | <view class="desc">Wmsport:</view> |
| | | <view class="input"> |
| | | <input type="text" v-model="wmsPort"> |
| | | </view> |
| | | </view> |
| | | <view class="item"> |
| | | <view class="desc">WmsUrl:</view> |
| | | <view class="input"> |
| | | <input type="text" v-model="wmsUrl"> |
| | | </view> |
| | | </view> |
| | | <view class="item"> |
| | | <view class="desc">ledId:</view> |
| | | <view class="input"> |
| | | <input type="text" v-model="baseLedId"> |
| | | </view> |
| | | </view> |
| | | <view class="item"> |
| | | <view class="desc">CrnId:</view> |
| | | <view class="input"> |
| | | <input type="text" v-model="baseCrnId"> |
| | | </view> |
| | | </view> |
| | | <view class="item"> |
| | | <view class="desc">Url:</view> |
| | | <view class="input"> |
| | | <input type="text" v-model="baseUrl"> |
| | | </view> |
| | | </view> |
| | | </scroll-view> |
| | |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view> |
| | | <!-- 提示窗示例 --> |
| | | <uni-popup ref="upVersion" type="dialog"> |
| | | <uni-popup-dialog :type="msgType" title="通知" :content="dialogContent" @confirm="dialogConfirm" |
| | | @close="dialogClose"></uni-popup-dialog> |
| | | </uni-popup> |
| | | </view> |
| | | <view style="color: #FFF;position: fixed;bottom: 10px;left: 10px;" v-show="timeOut"> |
| | | 连接超时: {{times}} s |
| | | 连接超时,正在重新建立链接:: {{times}} |
| | | </view> |
| | | </view> |
| | | </template> |
| | |
| | | import demodata from '@/mockdata/demodata.json'; |
| | | import ycqdata from '@/pages/index/data.json'; |
| | | import {WebSocketClient} from "@/static/js/WebSocketClient" |
| | | import WebSocketUtil from './uniWebSocket'; |
| | | let socket; |
| | | export default { |
| | | data() { |
| | |
| | | currDate: '', |
| | | locList:[], |
| | | oldHours:'', |
| | | oldMin:'' |
| | | |
| | | oldMin:'', |
| | | socketClient: null, |
| | | messages: [], |
| | | version:'', |
| | | socketUrl:'', |
| | | msgType: 'success', |
| | | filename: '', |
| | | dialogContent: '', |
| | | wmsUrl:'', |
| | | wmsPort:'' |
| | | |
| | | } |
| | | }, |
| | |
| | | // #ifdef APP-PLUS |
| | | plus.navigator.setFullscreen(true) |
| | | // #endif |
| | | this.getVersion() |
| | | }, |
| | | mounted() { |
| | | let that = this |
| | |
| | | const BasePort = uni.getStorageSync('BasePort'); |
| | | const BaseCrnId = uni.getStorageSync('BaseCrnId'); |
| | | const PROJ = uni.getStorageSync('UPROJ'); |
| | | const WMSURL = uni.getStorageSync('wmsUrl'); |
| | | const WMSPORT = uni.getStorageSync('wmsPort'); |
| | | that.baseUrl = PROJ |
| | | that.baseIP = BaseIP |
| | | that.baseLedId = BaseLedId |
| | | that.basePort = BasePort |
| | | that.baseCrnId = BaseCrnId |
| | | that.wmsUrl = WMSURL |
| | | that.wmsPort = WMSPORT |
| | | // this.getUrl() |
| | | }, |
| | | created() { |
| | |
| | | const BasePort = uni.getStorageSync('BasePort'); |
| | | const BaseCrnId = uni.getStorageSync('BaseCrnId'); |
| | | const PROJ = uni.getStorageSync('UPROJ'); |
| | | const WMSURL = uni.getStorageSync('wmsUrl'); |
| | | const WMSPORT = uni.getStorageSync('wmsPort'); |
| | | that.baseUrl = PROJ |
| | | that.baseIP = BaseIP |
| | | that.baseLedId = BaseLedId |
| | | that.basePort = BasePort |
| | | that.baseCrnId = BaseCrnId |
| | | that.webSockerInit(); |
| | | that.wmsUrl = WMSURL |
| | | that.wmsPort = WMSPORT |
| | | that.uniWebSocket(); |
| | | // that.webSockerInit() |
| | | }, |
| | | onLoad() { |
| | | setInterval(()=>{ |
| | |
| | | // },1000*30) |
| | | }, |
| | | methods: { |
| | | uniWebSocket(){ |
| | | let that = this; |
| | | that.commonUrl = that.baseIP + ':' +that.basePort + "/" +that.baseUrl |
| | | that.socketUrl = "ws://"+that.commonUrl+"/led/"+that.baseLedId |
| | | // 创建WebSocket实例 |
| | | that.socketClient = new WebSocketUtil(that.socketUrl, { |
| | | // 心跳间隔,默认30秒 |
| | | heartbeatInterval: 30000, |
| | | // 重连间隔,默认3秒 |
| | | reconnectInterval: 3000, |
| | | // 最大重连次数,-1表示无限重连 |
| | | maxReconnectAttempts: -1, |
| | | // 消息回调 |
| | | onMessage: (res) => { |
| | | try { |
| | | const data = JSON.parse(res.data); |
| | | that.showDate(data) |
| | | // 处理消息... |
| | | } catch (e) { |
| | | console.error('解析消息失败', e); |
| | | } |
| | | }, |
| | | // 连接打开回调 |
| | | onOpen: (res) => { |
| | | that.timeOut = false |
| | | that.times = 0 |
| | | console.log('WebSocket已连接', res); |
| | | }, |
| | | // 连接错误回调 |
| | | onError: (error) => { |
| | | console.error('WebSocket错误', error); |
| | | }, |
| | | // 连接关闭回调 |
| | | onClose: (res) => { |
| | | that.timeOut = true |
| | | that.times = that.times+1 |
| | | that.infoType = 0 |
| | | console.log('WebSocket已关闭', res); |
| | | }, |
| | | // 重连回调 |
| | | onReconnect: (info) => { |
| | | console.log(`WebSocket重连(${info.attempts}/${info.maxAttempts})`); |
| | | } |
| | | }); |
| | | |
| | | // 建立连接 |
| | | that.socketClient.connect(); |
| | | }, |
| | | // 发送消息 |
| | | sendMessage(content) { |
| | | const message = { |
| | | type: 'chat', |
| | | content: content, |
| | | timestamp: Date.now() |
| | | }; |
| | | |
| | | this.socketClient.send(message) |
| | | .then(() => { |
| | | console.log('消息发送成功'); |
| | | }) |
| | | .catch(error => { |
| | | console.error('消息发送失败', error); |
| | | }); |
| | | }, |
| | | webSockerInit(){ |
| | | let that = this; |
| | | |
| | | if(that.baseIP === '' && that.basePort === '' && that.baseUrl ==='' ){ |
| | | that.timeOut = true |
| | | that.times = that.times+1 |
| | | that.infoType = 0 |
| | | return ; |
| | | } |
| | | |
| | | that.commonUrl = that.baseIP + ':' +that.basePort + "/" +that.baseUrl |
| | | let socketUrl = "ws://"+that.commonUrl+"/led/"+that.baseLedId |
| | | // socketUrl = "ws://10.0.100.150:8080/gtctu/led/113" |
| | | const ws = new WebSocketClient(socketUrl); |
| | | ws.connect() |
| | | ws.onmessage((msg)=>{ |
| | | |
| | | console.log(ws) |
| | | |
| | | ws.onclose(() =>{ |
| | | |
| | | }) |
| | | |
| | | ws.onmessage((msg)=>{ |
| | | that.timeOut = false |
| | | let data = JSON.parse(msg.data) |
| | | if(data.type === "default"){ |
| | | that.chartsData.Pie.series[0].data = data.pie |
| | | that.baseInfo.stockCount = data.stockCunt |
| | | that.baseInfo.emptyCount = data.emptyCount |
| | | that.baseInfo.noneCount =data.noneCount |
| | | that.baseInfo.used = data.used |
| | | that.baseInfo.usedPr = data.usedPr |
| | | |
| | | that.chartsData.Line.categories = [ |
| | | that.getDateFormat(-11),that.getDateFormat(-10),that.getDateFormat(-9),that.getDateFormat(-8), |
| | | that.getDateFormat(-7),that.getDateFormat(-6),that.getDateFormat(-5),that.getDateFormat(-4), |
| | | that.getDateFormat(-3),that.getDateFormat(-2),that.getDateFormat(-1),that.getDateFormat(0),] |
| | | that.chartsData.Line.series = data.rows |
| | | that.calendar = data.year + "年" + data.month + "月" + data.day + "日 " + data.hour + ":" + data.minute + ":" + data.second + " " + data.week |
| | | that.currDate = data.year + "/" + data.month + "/" + data.day |
| | | that.locList = data.inventoryData |
| | | that.oldHours = data.hour |
| | | that.oldMin = data.minute |
| | | }else if(data.type === "error"){ |
| | | if (data.errMsg && data.errMsg !== "") { |
| | | var errorInfo = data.errMsg |
| | | if (that.infoType == 1) { |
| | | that.infoType = 3 |
| | | that.infoText.title = "其他信息" |
| | | // that.infoText.title = "异常" |
| | | that.infoText.error = errorInfo |
| | | return |
| | | } |
| | | that.infoType = 2 |
| | | that.infoText.title = "其他信息" |
| | | // that.infoText.title = "异常" |
| | | that.infoText.error = errorInfo |
| | | } else { |
| | | if (that.infoType == 1) { |
| | | return |
| | | } |
| | | that.infoType = 0 |
| | | } |
| | | }else if(data.type === "task"){ |
| | | if (data.taskList && data.taskList !== "" && data.taskList.length !=0) { |
| | | if (that.infoType == 2 || that.infoType == 3) { |
| | | return; |
| | | } |
| | | // infoType1:只有拣料等信息 |
| | | that.infoType = 1 |
| | | if (data.taskList[0].ioType === 101) { |
| | | that.infoText.title = '全板出库' |
| | | } else if(data.taskList[0].ioType === 103) { |
| | | that.infoText.title = '拣料出库' |
| | | } else if(data.taskList[0].ioType === 107) { |
| | | that.infoText.title = '盘点出库' |
| | | } else if(data.taskList[0].ioType === 1) { |
| | | that.infoText.title = '入库' |
| | | } else if(data.taskList[0].ioType === 10) { |
| | | that.infoText.title = '空托入库' |
| | | } else if(data.taskList[0].ioType === 110) { |
| | | that.infoText.title = '空托出库' |
| | | } else if(data.taskList[0].ioType === 104) { |
| | | that.infoText.title = '并板出库' |
| | | }else if(data.taskList[0].ioType === 54) { |
| | | that.infoText.title = '并板入库' |
| | | } |
| | | that.infoText.barcode = data.taskList[0].barcode |
| | | that.infoText.workNo = data.taskList[0].workNo |
| | | that.infoText.sourceLocNo = data.taskList[0].sourceLocNo |
| | | that.infoText.staNo = data.taskList[0].staNo |
| | | that.swiperList = data.taskList[0].matDtos |
| | | // that.infoText.matnr = res.data[0].matDtos[0].matnr |
| | | // that.infoText.specs = res.data[0].matDtos[0].specs |
| | | // that.infoText.maknx = res.data[0].matDtos[0].maknx |
| | | // that.infoText.count = res.data[0].matDtos[0].count |
| | | } else { |
| | | if (that.infoType == 2 || that.infoType == 3) { |
| | | return; |
| | | } |
| | | that.infoType = 0 |
| | | } |
| | | } |
| | | that.showDate(data) |
| | | |
| | | }) |
| | | |
| | | }, |
| | | showDate(data){ |
| | | const that = this |
| | | if(data.type === "default"){ |
| | | that.chartsData.Pie.series[0].data = data.pie |
| | | that.baseInfo.stockCount = data.stockCunt |
| | | that.baseInfo.emptyCount = data.emptyCount |
| | | that.baseInfo.noneCount =data.noneCount |
| | | that.baseInfo.used = data.used |
| | | that.baseInfo.usedPr = data.usedPr |
| | | |
| | | that.chartsData.Line.categories = [ |
| | | that.getDateFormat(-11),that.getDateFormat(-10),that.getDateFormat(-9),that.getDateFormat(-8), |
| | | that.getDateFormat(-7),that.getDateFormat(-6),that.getDateFormat(-5),that.getDateFormat(-4), |
| | | that.getDateFormat(-3),that.getDateFormat(-2),that.getDateFormat(-1),that.getDateFormat(0),] |
| | | that.chartsData.Line.series = data.rows |
| | | that.calendar = data.year + "年" + data.month + "月" + data.day + "日 " + data.hour + ":" + data.minute + ":" + data.second + " " + data.week |
| | | that.currDate = data.year + "/" + data.month + "/" + data.day |
| | | that.locList = data.inventoryData |
| | | that.oldHours = data.hour |
| | | that.oldMin = data.minute |
| | | }else if(data.type === "error"){ |
| | | if (data.errMsg && data.errMsg !== "") { |
| | | var errorInfo = data.errMsg |
| | | if (that.infoType == 1) { |
| | | that.infoType = 3 |
| | | that.infoText.title = "其他信息" |
| | | // that.infoText.title = "异常" |
| | | that.infoText.error = errorInfo |
| | | return |
| | | } |
| | | that.infoType = 2 |
| | | that.infoText.title = "其他信息" |
| | | // that.infoText.title = "异常" |
| | | that.infoText.error = errorInfo |
| | | } else { |
| | | if (that.infoType == 1) { |
| | | return |
| | | } |
| | | that.infoType = 0 |
| | | } |
| | | }else if(data.type === "task"){ |
| | | if (data.taskList && data.taskList !== "" && data.taskList.length !=0) { |
| | | if (that.infoType == 2 || that.infoType == 3) { |
| | | return; |
| | | } |
| | | // infoType1:只有拣料等信息 |
| | | that.infoType = 1 |
| | | if (data.taskList[0].ioType === 101) { |
| | | that.infoText.title = '全板出库' |
| | | } else if(data.taskList[0].ioType === 103) { |
| | | that.infoText.title = '拣料出库' |
| | | } else if(data.taskList[0].ioType === 107) { |
| | | that.infoText.title = '盘点出库' |
| | | } else if(data.taskList[0].ioType === 1) { |
| | | that.infoText.title = '入库' |
| | | } else if(data.taskList[0].ioType === 10) { |
| | | that.infoText.title = '空托入库' |
| | | } else if(data.taskList[0].ioType === 110) { |
| | | that.infoText.title = '空托出库' |
| | | } else if(data.taskList[0].ioType === 104) { |
| | | that.infoText.title = '并板出库' |
| | | }else if(data.taskList[0].ioType === 54) { |
| | | that.infoText.title = '并板入库' |
| | | } |
| | | that.infoText.barcode = data.taskList[0].barcode |
| | | that.infoText.workNo = data.taskList[0].workNo |
| | | that.infoText.sourceLocNo = data.taskList[0].sourceLocNo |
| | | that.infoText.staNo = data.taskList[0].staNo |
| | | that.swiperList = data.taskList[0].matDtos |
| | | // that.infoText.matnr = res.data[0].matDtos[0].matnr |
| | | // that.infoText.specs = res.data[0].matDtos[0].specs |
| | | // that.infoText.maknx = res.data[0].matDtos[0].maknx |
| | | // that.infoText.count = res.data[0].matDtos[0].count |
| | | } else { |
| | | if (that.infoType == 2 || that.infoType == 3) { |
| | | return; |
| | | } |
| | | that.infoType = 0 |
| | | } |
| | | } |
| | | }, |
| | | statisticalModel() { |
| | | let that = this |
| | |
| | | } |
| | | }) |
| | | }, |
| | | timeOut() { |
| | | console.log(this.times); |
| | | }, |
| | | getUrl() { |
| | | this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePort + "/" +this.baseUrl |
| | | this.commonUrl = this.baseHttp + this.baseIP + ':' +this.basePort + "/" +this.baseUrl |
| | | }, |
| | | getServerData() { |
| | | this.chartsDataLine1=JSON.parse(JSON.stringify(this.chartsData.Line)) |
| | |
| | | uni.setStorageSync('BasePort',this.basePort); |
| | | uni.setStorageSync('BaseCrnId',this.baseCrnId); |
| | | uni.setStorageSync('UPROJ',this.baseUrl); |
| | | uni.setStorageSync('wmsUrl',this.wmsUrl); |
| | | uni.setStorageSync('wmsPort',this.wmsPort); |
| | | this.getUrl() |
| | | this.ejectShow = false |
| | | }, |
| | |
| | | } |
| | | } |
| | | }) |
| | | }, |
| | | //检测当前平台,如果是安卓则启动安卓更新 |
| | | getVersion() { |
| | | let that = this; |
| | | uni.getSystemInfo({ |
| | | success: (res) => { |
| | | if (res.platform == "android") { |
| | | that.AndroidCheckUpdate(); |
| | | } |
| | | // that.AndroidCheckUpdate(); |
| | | |
| | | } |
| | | }) |
| | | }, |
| | | // 获取当前版本号 |
| | | AndroidCheckUpdate() { |
| | | let that = this; |
| | | plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { |
| | | that.version = wgtinfo.version //客户端版本号 |
| | | }) |
| | | setTimeout(()=>{ |
| | | that.getUpdateVersion() |
| | | },100) |
| | | }, |
| | | // 校验版本 |
| | | getUpdateVersion() { |
| | | let that = this |
| | | let type = 1 |
| | | if (that.baseUrl == 'http://undefined:undefined/undefined') { |
| | | return |
| | | } |
| | | const wms = 'http://'+ that.baseIP + ':' +that.wmsPort + "/" +that.wmsUrl |
| | | console.log(wms) |
| | | let url = wms + '/appVersion/checkUpdate/' + that.version + '/' + type |
| | | uni.request({ |
| | | url: url, |
| | | method: 'GET', |
| | | success(res) { |
| | | console.log(res); |
| | | var res = res.data |
| | | if (res.data) { |
| | | that.filename = res.data.path |
| | | that.dialogContent = '发现新版本:' + res.data.version + ', 是否立即更新' |
| | | that.$refs.upVersion.open() |
| | | } else { |
| | | uni.showToast({ |
| | | title: res.msg, |
| | | icon: "none", |
| | | position: 'top' |
| | | }) |
| | | } |
| | | |
| | | } |
| | | }) |
| | | }, |
| | | dialogConfirm() { |
| | | this.$refs.upVersion.close() |
| | | this.downWgt() |
| | | }, |
| | | dialogClose() { |
| | | this.$refs.upVersion.close() |
| | | }, |
| | | downWgt() { |
| | | let that = this; |
| | | const wms = 'http://'+ that.baseIP + ':' +that.wmsPort + "/" +that.wmsUrl |
| | | const downloadUrl = wms + "/appVersion/downloadApp/" + that.filename |
| | | uni.showLoading({ |
| | | title: '更新中……' |
| | | }) |
| | | const downloadTask = uni.downloadFile({ //执行下载 |
| | | url: downloadUrl, //下载地址 |
| | | timeout: 1000 * 30, //30秒超时时间 |
| | | success: downloadResult => { //下载成功 |
| | | console.log(downloadResult); |
| | | that.showdownLine = false |
| | | uni.hideLoading(); |
| | | if (downloadResult.statusCode == 200) { |
| | | uni.showModal({ |
| | | title: '', |
| | | content: '更新成功,确定现在重启吗?', |
| | | confirmText: '重启', |
| | | confirmColor: '#EE8F57', |
| | | success: function(res) { |
| | | if (res.confirm == true) { |
| | | plus.runtime.install( //安装 |
| | | downloadResult.tempFilePath, { |
| | | force: true |
| | | }, |
| | | function(res) { |
| | | utils.showToast('更新成功,重启中'); |
| | | plus.runtime.restart(); |
| | | } |
| | | ); |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | uni.hideLoading(); |
| | | that.showdownLine = false |
| | | uni.showToast({ |
| | | title:'请先上传安装包', |
| | | icon: 'error' |
| | | }) |
| | | } |
| | | }, |
| | | fail: err => { |
| | | uni.hideLoading(); |
| | | that.showdownLine = false |
| | | that.$u.toast(downloadResult.errMsg) |
| | | }, |
| | | complete: com => { |
| | | |
| | | console.log(com) |
| | | } |
| | | }); |
| | | |
| | | // 下载进度 |
| | | downloadTask.onProgressUpdate(res => { |
| | | that.downloadNum = res.progress |
| | | console.log('下载进度' + that.downloadNum); |
| | | }); |
| | | }, |
| | | } |
| | | |
| | |
| | | font-size:1.5vw; |
| | | font-weight: 700; |
| | | } |
| | | .version{ |
| | | position: absolute; |
| | | left: 1%; |
| | | top: 1%; |
| | | font-size:1vw; |
| | | transform: scale(0.8); |
| | | } |
| | | .item-subTitle { |
| | | font-size:0.5vw; |
| | | text-indent: 0em; |
| | |
| | | } |
| | | .eject{ |
| | | position: relative; |
| | | width: 40vw; |
| | | height: 40vh; |
| | | width: 45vw; |
| | | height: 45vh; |
| | | background-color: #fff; |
| | | border-radius: 2rem; |
| | | } |