From 9efc07aa84d4302e048d8741137ce66793a61319 Mon Sep 17 00:00:00 2001 From: chuguofei <1633295391@qq.com> Date: Fri, 26 May 2023 21:25:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=A7=BB=E5=8A=A8=E7=AB=AF=E7=BB=84?= =?UTF-8?q?=E6=80=81=E5=B7=A5=E5=85=B7=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/webapp/page/visual/show.html | 459 +++++++++++++------------- 1 file changed, 232 insertions(+), 227 deletions(-) diff --git a/src/main/webapp/page/visual/show.html b/src/main/webapp/page/visual/show.html index d18e0ae..00117ab 100644 --- a/src/main/webapp/page/visual/show.html +++ b/src/main/webapp/page/visual/show.html @@ -1,239 +1,244 @@ - - - - - 物联网可视化平台 - - - - - - - - - - - - - - - - - + + + + + 物联网可视化平台 + - - - - -
-
-
- - - - + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + 取 消 确 定 - - -
-
- - - -
- - + }, + downdata() { + // 数据下发 + commonAjax('PUT', baseurl + "/service/sensor/param/down.json", { + id: app.downSensorId, + sdata: app.inputData + }, function (data) { + if (isOK(data)) { + app.$message({ + message: '成功', + type: 'success' + }); + setTimeout(function () { + // 关闭 + app.dialogVisible = false; + app.inputData = ''; + }, 1000); + } else { + app.$message.error(data.statusMsg); + setTimeout(function () { + app.inputData = ''; + app.dialogVisible = false; + }, 2000); + } + }); + }, + //初始化样式 + initCanvasStyle() { + var xr = 1; + // 屏幕宽度 + var win_width = $(window).width(); + var win_height = $(window).height(); + + // 组态高度 + var content_width = $(".edit-container").width(); + var content_height = $(".edit-container").height(); + + this.orginWidth = content_width; + this.orginHeight = content_height; + + r = win_width / content_width; +// h = win_height / content_height ; + + var translatewidth = 0; + var translateheight = 0; + + xr = r; + + this.scaler = xr; + this.changescaler = xr; + $(".edit-container").css({ + "-webkit-transform": "scale(" + xr + ", " + xr + " ) translate(" + translatewidth + "px," + translateheight + "px)", + "transform": "scale(" + xr + ", " + xr + " ) translate(" + translatewidth + "px," + translateheight + "px)", + "position": "relative", + "transform-origin": "0 0", + "margin-left": "0" + }); + + // 这里把背景色或者背景图片,更换下 + var bg = $(".edit-container").attr("bg"); + if (isNotEmpty(bg)) { + $("body").css("background-color", bg); + } + + var url = $(".edit-container").attr("bgurl"); + if (isNotEmpty(url)) { + $("body").css("background", "url(" + url + ") no-repeat "); + $("body").css("background-position", "center top"); + } + }, + mqttInit() { + var that = this; + // 连接选项 + var client = this.client; + const options = { + connectTimeout: 4000, // 超时时间 + // 认证信息 + clientId: 'brower_' + parseInt(Math.random() / 31.1 * 10000000000), + username: 'yinzy', + password: 'yzy123456', + } + client = mqtt.connect('wss://' + document.domain + '/mqtt', options); + // client = mqtt.connect(mqttUrl, options) ; + client.on('reconnect', function (error) { + console.log("reconnect"); + }) + client.on('error', function (error) { + console.log('连接失败:', error) + }) + client.on('message', function (topic, message, s) { + console.log('mqtt reflush with [%o],[%o],[%o] now', topic, message, s); + if (message.toString() == '1') { + if (that.lastTime + 2 * 1000 < new Date().getTime()) { + that.lastTime = new Date().getTime(); + + udpChartValue(); + initSensorData(); + initControlNode(); + initStateNode(); + initDeviceStatus(); + } + } + }) + client.subscribe("/scene/update/" + that.scene_id); + client.publish('/sys/update/scene', that.scene_id + ''); + } + }, created() { + + }, mounted() { + // 初始化组态信息 + this.initVisualInfo(); + $(window).resize(function () { + app.initCanvasStyle(); + }); + } + }) +