<template>
	<view class="shade" v-if="pageType == 1">
		<view class="null-box" @click="dialogClose()"></view>
		<view class="shade_n">
			<view class="title">
				<view>请选择实验室</view>
			</view>
			<view class="batch">
				<view class="batch-li" @click="batchClick(item)" v-for="(item,index) in batchList">
					<view class="batch-li-l">
						<text>{{item.planTitle}}-{{item.checkName}}</text>
						<text>{{item.subName}}{{item.roomNum?'('+item.roomNum+')':''}}</text>
					</view>
					<view class="batch-li-r">
						<img :src="imagesUrl('commonality/icon_wd_gd@1x.png')">
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		securityAppCheckManageList,
		securityAppCheckSetOptionList,
		securityAppCheckPlanScanCode,
	} from '@/pages_safetyCheck/api/index.js'
	import {
		config
	} from '@/api/request/config.js'
	export default {
		name: "iotControl",
		props: {
			subjectData: {},
		},
		data() {
			return {
				pageType:0,
				newData:{},
				batchList: [],
				checkCategory: null,
			}
		},
		created() {
			
		},
		mounted() {
			if(uni.getStorageSync('identityData')){
				if(uni.getStorageSync('identityData').type=='collegeAdmin'){
					this.checkCategory=2
				}else if(uni.getStorageSync('identityData').type=='schoolAdmin'){
					this.checkCategory=1
				}
			}
			this.$set(this, 'newData', this.subjectData);
			this.securityAppCheckPlanScanCode();
		},
		methods: {
			dialogClose() {
				this.$parent.goPage('securityCheck',false);
			},
			batchClick(row) {
				let infoData = row;
				infoData.pageType = 0;
				uni.navigateTo({
					url: '/pages_safetyCheck/views/itemsManage/hiddenDangerItems?infoData=' + encodeURIComponent(
						JSON.stringify(infoData))
				});
			},
			//查询计划
			async securityAppCheckPlanScanCode() {
				console.log('planSetId',this.newData)
				let obj = {
					subId:this.newData.subId,
					checkCategory:this.checkCategory,
				};
				if(this.newData.planSetId){
					obj.planSetId = this.newData.planSetId;
				}
				const {
					data
				} = await securityAppCheckPlanScanCode(obj);
				if (data.code == 200) {
					if(data.data[0]){
						if(data.data[1]){
							//多个
							this.$set(this,'batchList',data.data);
							this.$set(this,'pageType',1);
						}else{
							//单个
							let infoData = data.data[0];
							infoData.pageType = 0;
							uni.navigateTo({
								url: '/pages_safetyCheck/views/itemsManage/hiddenDangerItems?infoData=' + encodeURIComponent(
									JSON.stringify(infoData))
							});
						}
					}else{
						//没有
						uni.showToast({
							title: '该实验室暂无检查计划!',
							icon: "none",
							mask: true,
							duration: 2000
						});
						this.dialogClose();
					}
				}
			},
		},
		onHide() {
		
		},
		beforeDestroy() {
			
		},
	}
</script>

<style lang="stylus" scoped>
	.shade {
		height: 100%;
		width: 100%;
		position: fixed;
		display: flex;
		flex-direction: column;
		z-index: 200;
		background: rgba(0, 0, 0, 0.2);
		top: 0;
	
		.null-box {
			flex: 1;
		}
	
		.shade_n {
			position: absolute;
			bottom: 0;
			left: 0;
			width: 750rpx;
			height: 466rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 0rpx 0rpx;
			overflow-y: auto;
	
			.title {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 50rpx 0 284rpx;
				box-sizing: border-box;
				border-bottom: 1rpx solid #E0E0E0;
	
				>view {
					font-size: 30rpx;
					color: #3D3D3D;
					line-height: 90rpx;
					text-align: left;
				}
	
				>img {
					width: 24rpx;
					height: 12rpx;
				}
			}
	
			.batch {
				padding: 0 30rpx;
				box-sizing: border-box;
	
				.batch-li {
					display: flex;
					justify-content: space-between;
					align-items: center;
					border-bottom: 1rpx solid #E0E0E0;
					padding: 20rpx 0 16rpx 0rpx;
					box-sizing: border-box;
	
					.batch-li-l {
						>text:nth-of-type(1) {
							display: block;
							font-size: 30rpx;
							color: #333333;
							line-height: 42rpx;
							text-align: left;
						}
	
						>text:nth-of-type(2) {
							display: block;
							font-size: 28rpx;
							color: #666666;
							line-height: 39rpx;
							text-align: left;
							margin-top: 6rpx;
						}
					}
	
					.batch-li-r {
						font-size: 28rpx;
						color: #666666;
						line-height: 39rpx;
						text-align: left;
						display: flex;
						justify-content: flex-start;
						align-items: center;
	
						>img {
							width: 24rpx;
							height: 24rpx;
							margin-left: 9rpx;
						}
					}
				}
			}
		}
	}
</style>
