From 9c1f36d460cac104b6fb14d91b0b4c3542bf2a98 Mon Sep 17 00:00:00 2001 From: juzi <819872918@qq.com> Date: Tue, 29 Apr 2025 15:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=B7=E7=AB=AF=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.prod | 2 +- .../coldDashboard/components/dataBox.vue | 20 +++--- src/views/dashboard/coldDashboard/index.vue | 66 ++++++++----------- 3 files changed, 40 insertions(+), 48 deletions(-) diff --git a/.env.prod b/.env.prod index 1c1f7a14..94c37a72 100644 --- a/.env.prod +++ b/.env.prod @@ -21,7 +21,7 @@ VUE_APP_BASE_API = '' PUBLIC_PATH = '' # ws地址 -WSURL = '100.64.0.45:48080' +VUE_APP_WS_API = 'ws://100.64.0.45:48080' # 二级部署路径 VUE_APP_APP_NAME ='yudao-admin' diff --git a/src/views/dashboard/coldDashboard/components/dataBox.vue b/src/views/dashboard/coldDashboard/components/dataBox.vue index 5dfdf9e7..d582de3f 100644 --- a/src/views/dashboard/coldDashboard/components/dataBox.vue +++ b/src/views/dashboard/coldDashboard/components/dataBox.vue @@ -16,36 +16,36 @@
- 213,452片 + {{msgData?.cut || '-'}}片 - 预计切割片数 -
- 95.32% + {{msgData?.allRatio ? msgData?.allRatio*100:'-'}}% - 综合面积良品率 -
掰边后片数: - 23,452片 + {{msgData?.bai || '-'}}片
掰边后良品率: - 98% + {{msgData?.baiRatio ? msgData?.baiRatio*100 : '-'}}%
顶板后片数: - 23,452片 + {{msgData?.ding || '-'}}片
顶板后良品率: - 98% + {{msgData?.dingRatio ? msgData?.dingRatio*100 : '-'}}%
下片片数: - 23,452片 + {{msgData?.xia || '-'}}片
下片良品率: - 98% + {{msgData?.xiaRatio ? msgData?.xiaRatio*100 : '-'}}%
@@ -61,6 +61,10 @@ export default { position:{ type: String, default: '' + }, + msgData: { + type: Object, + default: () => {} } }, data() { diff --git a/src/views/dashboard/coldDashboard/index.vue b/src/views/dashboard/coldDashboard/index.vue index 814f9299..2a8cd01a 100644 --- a/src/views/dashboard/coldDashboard/index.vue +++ b/src/views/dashboard/coldDashboard/index.vue @@ -5,10 +5,10 @@ :isFullScreen="isFullScreen" @screenfullChange="screenfullChange" topTitle="自贡冷端数据看板" /> - - - - + + + + @@ -31,6 +31,10 @@ export default { permission: false, url: process.env.VUE_APP_WS_API, websock: '', + line1:{}, + line2:{}, + line3:{}, + line4:{} } }, created() { @@ -52,6 +56,7 @@ export default { }, destroyed() { window.removeEventListener('resize', this.boxReset); + this.websocketclose(); }, methods: { boxReset() { @@ -126,42 +131,24 @@ export default { this.initWebSocket(); }, websocketonmessage(e) { - let dataJson = JSON.parse(e.data); - console.log(dataJson); - // 数据接收 - if ('DeepState' in dataJson) { - this.topData = dataJson.DeepState; - if(!this.permission){ - this.topData.yestodaySum = '***' - this.topData.monthSum = '***' - this.topData.monthAreaCost = '***' - } - } - if ('DeepEnergyTableList' in dataJson) { - this.tableData1 = dataJson.DeepEnergyTableList; - if(!this.permission){ - this.tableData1.forEach(item=>{ - item.elecPrice = null - }) - } - } - if ('DeepCostTableList' in dataJson) { - this.tableData2 = dataJson.DeepCostTableList; - if(!this.permission){ - this.tableData2.forEach(item=>{ - item.priceD = null - }) - } - } - if ('DeepPdTables' in dataJson) { - this.tableData3 = dataJson.DeepPdTables; - } - if ('DeepCostTrendList' in dataJson) { - this.echartData = dataJson.DeepCostTrendList; - this.$nextTick(() => { - this.$refs.chartRef.initChart(!this.permission); - }); + let msgData = e.data + try { + msgData = JSON.parse(e.data); + } catch (error) { + console.log("websocket: [unable to msgData] : ", e.data); } + if (!Object.prototype.toString.call(msgData).includes('Object')) return; + if (!this.permission) return + msgData.originRatioTables && msgData.originRatioTables.forEach((item) => { + item.lineName.includes('1') && (this.line1 = item); + item.lineName.includes('2') && (this.line2 = item); + item.lineName.includes('3') && (this.line3 = item); + item.lineName.includes('4') && (this.line4 = item); + }) + }, + websocketsend() { + // 数据发送 + this.websock.send(''); }, websocketsend(val) { // 数据发送 @@ -169,6 +156,7 @@ export default { }, websocketclose(e) { // 关闭 + this.websock.close(); console.log('断开连接', e); }, }