diff --git a/src/api/iot/device.js b/src/api/iot/device.js index 13f7bd87..dfec29db 100644 --- a/src/api/iot/device.js +++ b/src/api/iot/device.js @@ -133,6 +133,15 @@ export function setSwitchControl(data) { }); } +// 开关控制 最新接口 +export function setSwitchAllControl(data) { + return request({ + url: "/iot/dev/opt/switchAll", + method: "post", + data: data + }); +} + // 开关控制 最新接口 export function searchDevControl(data) { return request({ diff --git a/src/main.js b/src/main.js index 9bb9eba5..46c0c96b 100644 --- a/src/main.js +++ b/src/main.js @@ -27,8 +27,8 @@ import dataV from '@jiaminghi/data-view' // import VueCron from 'vue-cron'; // 自定义表格工具扩展 import RightToolbar from "@/components/RightToolbar" -// import iView from 'iview' -// import 'iview/dist/styles/iview.css' +import iView from 'iview' +import 'iview/dist/styles/iview.css' import VueAMap from 'vue-amap'; @@ -61,7 +61,7 @@ Vue.prototype.msgInfo = function (msg) { // 全局组件挂载 Vue.component('Pagination', Pagination) Vue.component('RightToolbar', RightToolbar) -// Vue.use(iView) +Vue.use(iView) Vue.use(dataV) Vue.use(VueClipboard) Vue.use(VueAMap); diff --git a/src/views/iot/project/profileV2/DeviceManage/EDeviceChildren.vue b/src/views/iot/project/profileV2/DeviceManage/EDeviceChildren.vue index 1fdc3175..f6af73db 100644 --- a/src/views/iot/project/profileV2/DeviceManage/EDeviceChildren.vue +++ b/src/views/iot/project/profileV2/DeviceManage/EDeviceChildren.vue @@ -148,7 +148,7 @@ import { listProjectModel, listProjectTableFilter, } from "@/api/iot/project_new"; -import { setSwitchControl,searchDevControl } from "@/api/iot/device"; +import { setSwitchControl, searchDevControl, setSwitchAllControl } from "@/api/iot/device"; import { webSocketProjectGatewayUrl } from "@/config/env"; import moment from "moment"; export default { @@ -358,9 +358,46 @@ export default { }, handleChildStatus(type) { if (this.tableSelectList && this.tableSelectList.length > 0) { - this.handleSendSwitchDirect(type, this.tableSelectList.toString()); + this.handleChildAllStatus(type); } }, + // 点击子设备 线路开关 + handleChildAllStatus(type) { + this.$prompt("请输入登录密码", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + inputPattern: /^[a-z A-z 0-9 $.]+/, + inputType: "password", + inputErrorMessage: "登录密码不能为空", + }).then(({ value }) => { + let params = { + data: { + // cmd: "set_switch", + params: { + switch: 1, + }, + }, + deviceId: "", + verifyKey: value, + }; + + switch (type) { + case "true": + params.data.params.switch = 1; + params.deviceId = this.gatewayDevice.deviceId; + break; + + case "false": + params.data.params.switch = 0; + params.deviceId = this.gatewayDevice.deviceId; + break; + } + + setSwitchAllControl(params).then((res) => { + this.msgSuccess("修改成功"); + }); + }); + }, handleDevSearch() { if (this.tableSelectList && this.tableSelectList.length > 0) { this.handleSearchDevDirect( this.tableSelectList.toString()); diff --git a/src/views/profile/DeviceDetailsView/deviceSelectNav.vue b/src/views/profile/DeviceDetailsView/deviceSelectNav.vue index 7b949a01..60d8b1ef 100644 --- a/src/views/profile/DeviceDetailsView/deviceSelectNav.vue +++ b/src/views/profile/DeviceDetailsView/deviceSelectNav.vue @@ -351,7 +351,7 @@ import { listChildrenDevice, setSwitchControl, setLivetimeControl, - searchDevControl + searchDevControl, setSwitchAllControl } from "@/api/iot/device"; import { devLiveWebSocketBaseUrl, @@ -489,15 +489,54 @@ export default { }, handleAllStatus(type) { if (this.childDeviceList.length > 0) { - this.childDeviceList.forEach(v => { - if (this.tSelectList.indexOf(v.deviceId) < 0) { - this.tSelectList.push(v.deviceId); - this.tSelectLabelList.push(v.deviceName); - } - }); - this.handleChildStatus(type); + // this.childDeviceList.forEach(v => { + // if (this.tSelectList.indexOf(v.deviceId) < 0) { + // this.tSelectList.push(v.deviceId); + // this.tSelectLabelList.push(v.deviceName); + // } + // }); + this.handleChildAllStatus(type); } }, + // 点击子设备 线路开关 + handleChildAllStatus(type) { + // if (this.tSelectLabelList.legnth > 0) { + this.$prompt("请输入登录密码", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + inputPattern: /^[a-z A-z 0-9 $.]+/, + inputType: "password", + inputErrorMessage: "登录密码不能为空" + }).then(({ value }) => { + let params = { + data: { + // cmd: "set_switch", + params: { + switch: 1 + } + }, + deviceId: "", + verifyKey: value + }; + + switch (type) { + case "true": + params.data.params.switch = 1; + params.deviceId = this.deviceInfo.deviceId; + break; + + case "false": + params.data.params.switch = 0; + params.deviceId = this.deviceInfo.deviceId; + break; + } + + setSwitchAllControl(params).then(res => { + this.msgSuccess("修改成功"); + }); + }); + // } + }, handleDevSearch() { this.$prompt("请输入登录密码", "提示", { confirmButtonText: "确定",