zhengkaixin 1 年之前
父節點
當前提交
70ad03644d
共有 2 個文件被更改,包括 86 次插入6 次删除
  1. 51 6
      pages/equipmentDataMonitoring/electronicMonitoring.vue
  2. 35 0
      pages/statistics/statistics.vue

+ 51 - 6
pages/equipmentDataMonitoring/electronicMonitoring.vue

@@ -59,12 +59,18 @@
 			</view>
 		</view>
 		<!-- 远程控制电源开关 -->
-		<view class="control">
+		<view class="control" v-if="codes.indexOf('switch')!=-1">
 			<view class="text">
 				远程控制电源开关
 			</view>
 			<view class="icon">
-				<img src="@/assets/img/control.png" alt="" />
+				<img src="@/assets/img/control.png"
+				 @click="switchBtnApi(meterDetail,0)"
+				 v-if="meterDetail.switchStatus"
+				 alt="" />
+				<img   @click="switchBtnApi(meterDetail,1)"
+				v-else
+				src="@/assets/img/switchClose.png" alt="" />
 			</view>
 		</view>
 		<!-- 各时段用电量 -->
@@ -96,7 +102,7 @@
 			</view>
 		</view>
 		<!-- 异常告警 -->
-		<view class="abnormal" >
+		<view class="abnormal" v-if="abnormalRecordsList.length" >
 			<view class="headline">
 				<view class="title">
 					<view class="icon">
@@ -366,7 +372,9 @@
 		getWeek
 	} from '@/apis/utils'
 	import * as echarts from 'echarts';
-	import * as API from '@/apis/pagejs/index.js'
+	import * as API from '@/apis/pagejs/index.js'
+	import * as API_energyManage from '@/apis/pagejs/energyManage.js'
+	
 	import * as API_electricityMeter from '@/apis/pagejs/electricityMeter.js'
 	import * as WxJsApi from '@/apis/utils/wxJsApi.js'
 
@@ -392,6 +400,7 @@
 					meterId: '',
 					type: 0
 				},
+				codes:"",
 				FormData2: {
 					queryDate: '',
 					meterId: ''
@@ -495,7 +504,41 @@
 			this.intervalReady = false;
 			console.log("组件销毁前清除定时器")
 		},
-		methods: {
+		methods: {
+			switchBtnApiMethod(node,key){
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				API_energyManage.remoteSwitch({
+					meterId:node.id,
+					enabled:key
+				}).then((res) => {
+					uni.hideLoading();
+					node.switchStatus=key
+					
+				}).catch(error => {
+					
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
+			},
+			switchBtnApi(node,key){
+				uni.showModal({
+					confirmColor:`${key?'#3CC51F':'red'}`,
+					confirmText:`${key?'开启':'关闭'}`,
+					content: `确认是否要"${key?'开启':'关闭'}"${node.name}`,
+					title: "提示",
+					success:res=> {
+						if(res.confirm){
+							this.switchBtnApiMethod(node,key);
+						}
+					}
+				})
+				console.log(node,key)
+			},
 			toMeterLocation() {
 				// WxJsApi.openLocation({
 				// 	latitude: parseFloat(this.meterDetail.latitude), //目的地latitude
@@ -520,7 +563,9 @@
 					meterId: meterId
 				}).then((res) => {
 					uni.hideLoading();
-					this.meterDetail = res.data.meter;
+					this.meterDetail = res.data.meter;
+					this.codes =this.carhelp.getPersonInfo().codes;
+					
 				}).catch(error => {
 					uni.showToast({
 						title: error,

+ 35 - 0
pages/statistics/statistics.vue

@@ -129,6 +129,7 @@
 				 @query="getHomePageManageChildMeter"
 				 v-if="getHomePageManageReady"
 				 :role="codes.indexOf('switch')!=-1"
+				  @switchBtn="switchBtnApi"
 				 ></Tree-Body>
 				 
 				
@@ -457,6 +458,40 @@
 			console.log("组件销毁前清除定时器")
 		},
 		methods: {
+			switchBtnApiMethod(node,key){
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				API.remoteSwitch({
+					meterId:node.id,
+					enabled:key
+				}).then((res) => {
+					uni.hideLoading();
+					node.switchStatus=key
+					
+				}).catch(error => {
+					
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
+			},
+			switchBtnApi(node,key){
+				uni.showModal({
+					confirmColor:`${key?'#3CC51F':'red'}`,
+					confirmText:`${key?'开启':'关闭'}`,
+					content: `确认是否要"${key?'开启':'关闭'}"${node.name}`,
+					title: "提示",
+					success:res=> {
+						if(res.confirm){
+							this.switchBtnApiMethod(node,key);
+						}
+					}
+				})
+				console.log(node,key)
+			},
 			// 设备数据监测
 			getHomePageManageChildMeter(item,bl) {
 				if(!bl){