diff --git a/src/basedata/physicalModel.js b/src/basedata/physicalModel.js index 70e3bbd4..24d8c4d6 100644 --- a/src/basedata/physicalModel.js +++ b/src/basedata/physicalModel.js @@ -18,3 +18,13 @@ export const eventLevel = { warn:'警告', urgent:'紧急', } +export const preCheckTypeList = [ + { + value: '', + label: '无校验' + }, + { + value: 'userPassword', + label: '用户密码校验' + } +] diff --git a/src/views/iot/device/profile/details.vue b/src/views/iot/device/profile/details.vue index a7878d48..e6c5d879 100644 --- a/src/views/iot/device/profile/details.vue +++ b/src/views/iot/device/profile/details.vue @@ -5,6 +5,22 @@ 设备名称:{{infoData.deviceName}} 设备key:{{infoData.deviceKey}} 所属型号:{{infoData.modelName}} +
在线状态: + + + {{ + infoData["deviceState"] == "ONLINE" ? "在线" : "离线" + }} +
@@ -108,6 +125,7 @@ import { iotWebSocketBaseUrl } from "@/config/env"; import TriggerWrap from "@/views/profile/DeviceTrigger/index"; import EDeviceScene from '@/views/profile/EDeviceScene/indexView' import functionWrap from "@/views/iot/device/profile/functionWrap" +import { setFunctionControl } from '../../../../api/iot/device' export default { name: "DetailsWrap", props: ["sourceId"], @@ -129,7 +147,8 @@ export default { breadcrumbList: [], tempType: "bs", deviceId: "", - devudeRunState: false + devudeRunState: false, + timingPingWs_flag: null, }; }, created() { @@ -153,6 +172,10 @@ export default { this.devudeRunState = false; this.deviceInfo(); }, + changeDeviceState(e){ + console.log("更新设备状态",e) + this.infoData.deviceState = e.state; + }, // 设备详情 deviceInfo() { getDevice(this.deviceId).then(response => { @@ -160,6 +183,9 @@ export default { // response.data.deviceLabel.shift(); // } this.infoData = response.data; + if(response.data && response.data.deviceKey && (response.data.deviceType === '10001' || response.data.deviceType === '10002' || response.data.deviceType === '10013')){ + this.timingPingWs(response.data) + } if (this.breadcrumbList.length <= 0) { this.breadcrumbList.push(this.infoData); } @@ -175,6 +201,31 @@ export default { this.devudeRunState = true; }); }, + // 定时 ping ws + timingPingWs(row) { + this.extenSubmit(row); + clearInterval(this.timingPingWs_flag); + const _this = this; + this.timingPingWs_flag = setInterval(function() { + _this.extenSubmit(row); + }, 110000); + }, + //开启 + extenSubmit(row) { + let params = { + input: { + ltime: 15, // 上报间隔(0.1秒) + dtime: 1200 //上报时长(0.1秒) + }, + deviceKey: row.deviceKey, + funcId: "set_live_time" + }; + + //使用新版功能 + setFunctionControl(params).then(res => { + console.log(res); + }); + }, toNewDevice(data) { this.tempType = "children"; this.deviceId = data.deviceId; @@ -211,10 +262,33 @@ export default { justify-content: space-between; align-items: center; .device-info-left{ + display: flex; + align-items: center; + font-size: 14px; span{ margin-right: 20px; - font-size: 14px; } + .dev-info-state { + display: flex; + align-items: center; + justify-content: flex-start; + .iconfont{ + color: #00c805; + margin-right: 2px; + } + .dev-info-state-txt{ + color: #00c805; + } + &.off-line { + .iconfont{ + color: #da2710; + } + .dev-info-state-txt{ + color: #da2710; + } + } + } + } } diff --git a/src/views/profile/DeviceDetailsView/deviceSelectNav.vue b/src/views/profile/DeviceDetailsView/deviceSelectNav.vue index dfb2327e..00454832 100644 --- a/src/views/profile/DeviceDetailsView/deviceSelectNav.vue +++ b/src/views/profile/DeviceDetailsView/deviceSelectNav.vue @@ -360,6 +360,7 @@ import { } from "@/config/env"; import SignalIntensity from "./signalIntensity"; import EWebSocket from "@/components/EWebSocket/src/basic/index"; +import { setFunctionControl } from '../../../api/iot/device' export default { name: "DeviceSelectNav", components: { @@ -458,29 +459,42 @@ export default { },${str}`; }, wsMessage(e) { - if ( - e["deviceState"] || - (e["switch"] !== null && e["switch"] !== undefined) - ) { - if(e["switch"] == "1"){ - e["switch"] = 1 - }else if(e["switch"] == "0"){ - e["switch"] = 0 - } - this.handleDeviceInfo(e); - } + console.log("wsMessage", e); + // if ( + // e["deviceState"] || + // (e["switch"] !== null && e["switch"] !== undefined) + // ) { + // if(e["switch"] == "1"){ + // e["switch"] = 1 + // }else if(e["switch"] == "0"){ + // e["switch"] = 0 + // } + // this.handleDeviceInfo(e); + // } + this.handleDeviceInfo(e); }, // 处理 socket 数据返回 赋值问题 handleDeviceInfo(param) { - if (param.deviceKey === this.deviceInfo.deviceKey) { - this.deviceInfo = Object.assign(this.deviceInfo, param); + if (param.tags.device_key === this.deviceInfo.deviceKey) { + if(param.type === "state"){ + this.$nextTick(() => { + this.$set(this.deviceInfo, 'deviceState',param.state); + }); + } + // this.deviceInfo = Object.assign(this.deviceInfo, param); } else { if (this.childDeviceList && this.childDeviceList.length > 0) { - this.childDeviceList = this.childDeviceList.map(v => { - if (v["deviceKey"] === param["deviceKey"]) { - return Object.assign(v, param); + this.childDeviceList = this.childDeviceList.map(item => { + if (item["deviceKey"] === param.tags.device_key) { + if(param.type === "state"){ + item.deviceState = param.state; + } + if(param.type === "extra" && param.extra.type === "switch"){ + item.switch = param.extra.switch; + } + return item; } else { - return v; + return item; } }); this.$forceUpdate(); @@ -740,20 +754,35 @@ export default { }, 110000); }, extenSubmit(row) { - let params = { - data: { - params: { - ltime: 15, // 上报间隔(0.1秒) - dtime: 1200 //上报时长(0.1秒) - } - }, - deviceId: row.deviceId - }; + // let params = { + // data: { + // params: { + // ltime: 15, // 上报间隔(0.1秒) + // dtime: 1200 //上报时长(0.1秒) + // } + // }, + // deviceId: row.deviceId + // }; //先屏蔽设备主动拉取功能 // setLivetimeControl(params).then(res => { // console.log(res); // // this.msgSuccess("成功"); // }); + + let params = { + input: { + ltime: 15, // 上报间隔(0.1秒) + dtime: 1200 //上报时长(0.1秒) + }, + deviceKey: row.deviceKey, + funcId: "set_live_time" + }; + + //使用新版功能 + setFunctionControl(params).then(res => { + console.log(res); + // this.msgSuccess("成功"); + }); }, // 点击子设备 线路开关 submitChildStatus(type, row) { diff --git a/src/views/profile/DeviceRunStarts/index.vue b/src/views/profile/DeviceRunStarts/index.vue index 48e8f394..00a6bbda 100644 --- a/src/views/profile/DeviceRunStarts/index.vue +++ b/src/views/profile/DeviceRunStarts/index.vue @@ -262,6 +262,13 @@ export default { ); } } + if(result.type === "state"){ + this.$emit("updateDeviceState",{ + deviceKey: this.deviceInfo.deviceKey, + state: result.state + }); + } + // for (var i = 0; i < list.length; i++) { // // if (this.firstWsMassage) { diff --git a/src/views/profile/attribute/functionFormModel.vue b/src/views/profile/attribute/functionFormModel.vue index c631a53f..ef8c30e9 100644 --- a/src/views/profile/attribute/functionFormModel.vue +++ b/src/views/profile/attribute/functionFormModel.vue @@ -95,10 +95,33 @@ >新增输入参数 + + + + + + + + + + + + + + - - - + + +