dedsudiyu 10 meses atrás
pai
commit
95b6f88d41

+ 90 - 20
pages_manage/views/laboratory/airConditioning.vue

@@ -5,48 +5,76 @@
 		<!-- 空调按钮 -->
 		<view class="panel">
 			<view class="panel-t">
-				<view>{{switchStatus==0?'空调未开启':'空调已开启'}}</view>
-				<view @click="switchFun()" :class="switchStatus==0?'color-A':'color-B'">{{switchStatus==0?'开启':'关闭'}}</view>
+				<view>{{infraredControllerForm.name}}</view>
+				<view @click="switchFun()" :class="infraredControllerForm.switchType==1?'color-A':'color-B'">{{infraredControllerForm.switchType==1?'开启':'关闭'}}</view>
 			</view>
 			<view class="panel-m" >
-				<view @click="temperatureFun(index)" :class="keystrokeIndex==index?'color-C':''" v-for="(item,index) in keystrokeData" :key="index">{{item}}</view>
+				<view @click="temperatureFun(index)" :class="infraredControllerForm.functionType==item.value?'color-C':''" v-for="(item,index) in infraredControllerData.functionList" :key="index">{{item.label}}</view>
 			</view>
 			<view class="panel-b">
 				<view @click="subtract">-</view>
-				<view>{{result}}℃</view>
+				<view v-for="(item,index) in infraredControllerData.orderList" :key="index" v-if="item.value == infraredControllerForm.orderType">{{item.value}}</view>
 				<view @click="add">+</view>
 			</view>
+			<view class="panel-button" @click="mangerControl">确定</view>
 		</view>
 	</view>
 </template>
 <script>
-	import {} from '@/pages_manage/api/index.js'
+	import {
+		iotAppHardwareOperatingHardware,
+	} from '@/pages_manage/api/index.js'
 	import { config } from '@/api/request/config.js'
 	export default {
 		name: "airConditioning",
 		props: {
-			subjectData: {},
+			airConditioningData: {},
 		},
 		data() {
 			return {
 				baseUrl:config.base_url,
-				//开关状态
-				switchStatus:0,
-				keystrokeData:['制热	','制冷','送风'],
-				keystrokeIndex:0,
-				num1: 0,	
+        /****************** 红外控制器相关 ******************/
+        infraredControllerType:false,
+        infraredControllerTitle:"",
+        infraredControllerForm:{
+          name:null,//设备名称
+          switchType:null,//0.关 1.开
+          functionType:null, //1.制冷 2.制热 3.通风
+          orderType:null, //温度指令
+          hardwareNo:null, //设备编号
+        },
+        infraredControllerData:{
+          functionList:[
+            {label:'制冷',value:'1'},
+            {label:'制热',value:'2'},
+            {label:'通风',value:'3'},
+          ],
+          orderList:[
+            {label:"18°C",value:18},
+            {label:"19°C",value:19},
+            {label:"20°C",value:20},
+            {label:"21°C",value:21},
+            {label:"22°C",value:22},
+            {label:"23°C",value:23},
+            {label:"24°C",value:24},
+            {label:"25°C",value:25},
+            {label:"26°C",value:26},
+            {label:"27°C",value:27},
+          ],
+        }
 			}
 		},
-		computed: {
-		    result() {
-		      return this.num1;
-		    },
-		},
 		created() {
 
 		},
 		mounted() {
-			
+			this.$set(this,'infraredControllerForm',{
+				name:this.airConditioningData.hardwareName,
+				switchType:parseInt(this.airConditioningData.switchType),
+				functionType:this.airConditioningData.switchType == 0 ? 1 : parseInt(this.airConditioningData.functionType),
+				orderType:this.airConditioningData.switchType == 1 && this.airConditioningData.functionType !=3 ? parseInt(this.airConditioningData.orderType):18,
+				hardwareNo:this.airConditioningData.hardwareNo,
+			});
 		},
 		methods: {
 			// 返回按钮
@@ -64,12 +92,45 @@
 				this.$set(this, 'keystrokeIndex',index);
 			},
 			add() {
-			  this.num1 += 1;
+        if(this.infraredControllerForm.orderType<27){
+          this.infraredControllerForm.orderType++
+        }
 			},
 			subtract() {
-			  this.num1 -= 1;
+        if(this.infraredControllerForm.orderType>18){
+          this.infraredControllerForm.orderType--
+        }
 			},	  
 			
+			//设备开关
+			async mangerControl() {
+        let text = '';
+        if(this.infraredControllerForm.switchType == 1){
+          if(this.infraredControllerForm.functionType != 3){
+            text = '1-' + this.infraredControllerForm.functionType + '-' + this.infraredControllerForm.orderType;
+          }else {
+            text = '1-3';
+          }
+        }else if(this.infraredControllerForm.switchType == 0){
+          text = '0';
+        }
+        let switchData = {
+          hardwareNo:this.infraredControllerForm.hardwareNo,
+          command:text
+        };
+				const {
+					data
+				} = await iotAppHardwareOperatingHardware(switchData);
+				if (data.code == 200) {
+					uni.showToast({
+						title: '操作成功',
+						icon: "none",
+						mask: true,
+						duration: 2000
+					});
+					this.backPage();
+				}
+			},
 			
 		},
 	}
@@ -91,7 +152,7 @@
 		/* 空调面板 */
 		.panel{
 			width: 710rpx;
-			height: 430rpx;
+			height: 530rpx;
 			background: #FFFFFF;
 			border-radius: 20rpx;
 			padding:34rpx 30rpx 0rpx;
@@ -200,6 +261,15 @@
 					text-align: center;
 				}
 			}
+			.panel-button{
+				text-align: center;
+				line-height: 80rpx;
+				font-size: 32rpx;
+				background: #0183fa;
+				border-radius: 10rpx;
+				color: #fff;
+				margin-top: 40rpx;
+			}
 		}
 		
 		

+ 4 - 1
pages_manage/views/laboratory/infoPage.vue

@@ -33,7 +33,7 @@
 		<!-- 语音广播弹窗 -->
 		<voiceBroadcast v-if="broadcastPage" :subjectData="subjectData"></voiceBroadcast>
 		<!-- 空调弹窗 -->
-		<airConditioning v-if="conditioningPage" :subjectData="subjectData"></airConditioning>
+		<airConditioning v-if="conditioningPage" :airConditioningData="airConditioningData"></airConditioning>
 	</view>
 </template>
 <script>
@@ -77,6 +77,8 @@
 					pageSize: 20,
 				},
 				subjectData: null,
+				// 空调弹窗
+				airConditioningData:null,
 			}
 		},
 		onLoad(option) {
@@ -117,6 +119,7 @@
 					this.$set(this, 'broadcastPage', false);
 				} else if (type == 'conditioningOpen') {
 					//空调弹窗开启
+					this.$set(this,'airConditioningData',row);
 					this.$set(this, 'conditioningPage', true);
 				} else if (type == 'conditioningClose') {
 					//空调弹窗关闭

+ 24 - 5
pages_manage/views/laboratory/iotControl.vue

@@ -138,7 +138,7 @@
 						this.$parent.buttonClick('broadcastOpen', '');
 					} else if (item.type == 'conditioning') {
 						//空调弹窗开启
-						this.$parent.buttonClick('conditioningOpen', '');
+						this.$parent.buttonClick('conditioningOpen', item);
 					}
 				}
 			},
@@ -214,6 +214,20 @@
 					subjectId: this.subId
 				});
 				if (data.code == 200) {
+					data.data.forEach((item)=>{
+						if(item.hardwareTypeKey == 'airConditioner'){
+							if(item.reservedThree.indexOf('-') != -1){
+								let list = item.reservedThree.split('-');
+								item.switchType = list[0]?list[0]:'';
+								item.functionType = list[1]?list[1]:'';
+								item.orderType = list[2]?list[2]:'';
+							}else{
+								item.switchType = '';
+								item.functionType = '';
+								item.orderType = '';
+							}
+						}
+					})
 					this.$set(this, 'labHardwareVOList', data.data);
 					for (let i = 0; i < data.data.length; i++) {
 						if (data.data[i].hardwareTypeKey == 'airConditioner') {
@@ -282,8 +296,15 @@
 							let list = JSON.parse(JSON.stringify(this.labHardwareVOList))
 							list.forEach((item) => {
 								if (item.hardwareNo == data.hardwareNo) {
-									item.operatingState = data.operatingState;
-									item.online = data.online;
+									if(item.hardwareTypeKey == 'airConditioner'){
+										let list = data.command.split('-');
+										item.switchType = list[0]?list[0]:'';
+										item.functionType = list[1]?list[1]:'';
+										item.orderType = list[2]?list[2]:'';
+									}else{
+										item.operatingState = data.operatingState;
+										item.online = data.online;
+									}
 								}
 							})
 							this.$set(this, 'labHardwareVOList', list);
@@ -338,8 +359,6 @@
 				display: flex;
 				justify-content: flex-start;
 				align-items: center;
-				border-right: 1px dashed #E0E0E0;
-				border-bottom: 1px dashed #E0E0E0;
 				padding-left: 10rpx;
 				padding-right: 10rpx;
 				box-sizing: border-box;