<!-- 安全检查扫一扫 实验室详情 -->
<template>
	<view class="safetyCardScan">
		<view class="header">
			<view class="tabTitle">
				<view class="tabTitle_li" @tap="tabClick(index)" :key="index" v-for="(item,index) in tabText">
					<view class="tabTitle_text">
						<img :src="item.img">
						<view
							:id="pageType==index&&index==0?'fontColor-A':(pageType==1&&index==1?'fontColor-B':(pageType==2&&index==2?'fontColor-C':''))">
							{{item.name}}
						</view>
					</view>
					<view :class="{on:pageType==index}" class="tabTitle_across">
						<img src="@/pages_safetyCheck/images/img_xyzc_bg@1x.png">
					</view>
					<view class="line"></view>
				</view>
			</view>
		</view>
		<view class="safetyCard" v-if="pageType==0">
			<view class="lab-info">
				<view class="lab-info-t">
					<view>{{newData.levelName}}</view>
					<view>{{newData.labClassTypeList[0].typeName}}</view>
					<view>{{newData.subName}}（{{newData.roomNum}}）</view>
				</view>
				<view class="lab-info-b">
					<img src="@/pages_safetyCheck/images/icon_sys_xz@1x.png">
					{{newData.buildName}}{{newData.floorName}}
				</view>
			</view>
			<view class="liability-unit">
				<view>学院单位</view>
				<view>{{newData.deptName}}</view>
			</view>
			<view class="small-title-new" @click="unfoldPackUp('subAdminShowType')">
				<view>实验室负责人</view>
				<uni-icons :type="newData.subAdminShowType?'up':'down'" size="12" color='#A2A2A2'></uni-icons>
			</view>
			<view class="sub-head" v-if="newData.subAdminShowType">
				<view>{{newData.adminName}}</view>
				<view @click="callPhone(newData.adminPhone)">
					<img src="@/pages_manage/images/icon_aqxxp_dh.png">
					<view>{{newData.adminPhone}}</view>
				</view>
			</view>
			<view class="small-title-new" @click="unfoldPackUp('adminShowType')">
				<view>安全员</view>
				<uni-icons :type="newData.adminShowType?'up':'down'" size="12" color='#A2A2A2'></uni-icons>
			</view>
			<view v-if="newData.adminShowType">
				<view class="sub-head" v-for="(item,index) in newData.safeUserList" :key="index">
					<view>{{item.safeUserName}}</view>
					<view @click="callPhone(item.safeUserPhone)">
						<img src="@/pages_manage/images/icon_aqxxp_dh.png">
						<view>{{item.safeUserPhone}}</view>
					</view>
				</view>
			</view>
			<view class="classify" v-for="(item,index) in newData.labInfoBrandModels" :key="index">
				<view v-if="item.privateList.length>0" class="small-title-new" @click="unfoldPackUp('list',index)">
					<view>{{item.brandName}}</view>
					<uni-icons :type="item.showType?'up':'down'" size="12" color='#A2A2A2'></uni-icons>
				</view>
				<view v-if="item.privateList.length>0 && item.brandType==1 && !item.isSpecial&&item.showType">
					<view class="small-items-new" v-for="(item2,index2) in item.privateList" :key="index2">
						<view>{{index2+1}}. </view>
						<view>{{item2.infoName}}</view>
					</view>
				</view>
				<view v-if="item.privateList.length>0 && item.brandType==1 && item.isSpecial&&item.showType">
					<view class="small-items-new" v-for="(item2,index2) in item.privateList" :key="index2">
						<view></view>
						<view>{{item2.infoName}}</view>
					</view>
				</view>
				<view v-if="item.privateList.length>0 && item.brandType==2&&item.showType">
					<view class="logotype-img-new">
						<img v-for="(item3,index3) in item.privateList" :key="index3" :src="baseUrl+item3.infoContent">
					</view>
				</view>
			</view>
		</view>
		<view class="position-button-box">
			<view class="position-button-p-null"></view>
			<view class="position-button-p-1" @click="goPage('securityCheck')">安全检查</view>
			<view class="position-button-p-4" @click="goPage('snapshot')">随手拍</view>
			<view class="position-button-p-null"></view>
		</view>
		<!-- 物联控制 -->
		<iotControl ref="iotControl" v-if="pageType == 1" :subjectData="subjectData"></iotControl>
		<!-- 进出记录 -->
		<accessRecord v-if="pageType == 2" :subjectData="subjectData"></accessRecord>
	</view>

</template>

<script>
	import {
		pageRestrictVerify
	} from '@/utils/index'
	import {
		iotControl
	} from '@/pages_manage/views/laboratory/iotControl.vue'
	import {
		accessRecord
	} from '@/pages_manage/views/laboratory/accessRecord.vue'
	import {
		config
	} from '@/api/request/config.js'
	import {

	} from '@/pages/api/index.js'
	export default {
		name: "safetyCardScan",
		components: {
			iotControl,
			accessRecord,
		},
		data() {
			return {
				baseUrl: config.base_url,
				pageType: 1,
				tabText: [{
						name: '安全信息牌',
						img: require('@/pages_safetyCheck/images/icon_sys_aqxxp@1x.png'),
					},
					{
						name: '监测控制',
						img: require('@/pages_safetyCheck/images/icon_sys_jckz@1x.png'),
					},
					{
						name: '进出记录',
						img: require('@/pages_safetyCheck/images/icon_sys_jcjl@1x.png'),
					},
				],
				pageType: 0,
				newData: {
					adminName: '',
					adminPhone: '',
					safeUserList: [],
					labInfoBrandModels: [],
				},
				subjectData: null,
				identityData: uni.getStorageSync('identityData'),

			}
		},
		// 父页面
		onReachBottom() {
			uni.$emit('onReachBottom') // 设置监听事件
		},
		onPullDownRefresh() {
			uni.$emit('onPullDownRefresh') // 设置监听事件
		},
		onLoad(option) {
			let newData = JSON.parse(decodeURIComponent(option.infoData));
			newData.subAdminShowType = true;
			newData.adminShowType = true;
			if (newData.labInfoBrandModels) {
				for (let i = 0; i < newData.labInfoBrandModels.length; i++) {
					newData.labInfoBrandModels[i].showType = true;
				}
			}
			this.$nextTick(() => {
				this.$set(this, 'newData', newData);
				this.$set(this, 'subjectData', newData);
				this.$set(this, 'pageType', 0);
			})

		},
		onShow() {

		},
		mounted() {

		},
		methods: {
			//展开/收起操作
			unfoldPackUp(type, index) {
				if (type == 'subAdminShowType') {
					this.$set(this.newData, 'subAdminShowType', !this.newData.subAdminShowType);
				} else if (type == 'adminShowType') {
					this.$set(this.newData, 'adminShowType', !this.newData.adminShowType);
				} else if (type == 'list') {
					this.$set(this.newData.labInfoBrandModels[index], 'showType', !this.newData.labInfoBrandModels[index].showType);
				}
			},
			//顶部tab点击
			tabClick(index) {
				if (this.pageType != index) {
					this.$set(this, 'pageType', index);
				}
			},
			goPage(type){
				if (!pageRestrictVerify(type)) {
					uni.showToast({
						title: '没有相关权限,请联系管理员',
						icon: "none",
						mask: true,
						duration: 2000
					});
					return
				}
				if (type == 'securityCheck') {
					//安全检查
					if(this.identityData){
						uni.navigateTo({
							url: "/pages_safetyCheck/views/safetyCheck",
						});
					}else{
						uni.showToast({
							mask: true,
							icon: "none",
							position: "center",
							title: '您不是校/院级管理员或督导组成员,无法使用该功能.',
							duration: 2000
						});
					}
				} else if (type == 'snapshot') {
					//随手拍
					uni.navigateTo({
						url: "/pages_safetyCheck/views/snapshotManage/snapshotList",
					});
				}
			},
		}
	}
</script>

<style lang="stylus" scoped>
	.safetyCardScan {
		height: 100%;
		display: flex;
		flex-direction: column;
		overflow: hidden;

		#fontColor-A {
			color: #00DEDE;
		}

		#fontColor-B {
			color: #FF8C00;
		}

		#fontColor-C {
			color: #0083FD;
		}

		.header {
			width: 100%;
			// position: fixed;
			// top: 0rpx;
			// z-index: 100;
			background: #fff;

			.tabTitle {
				width: 750rpx;
				height: 188rpx;
				display flex;
				justify-content: flex-start;
				align-items: center;
				border-bottom: 4rpx solid #F5F5F5;

				.tabTitle_li {
					height: 188rpx;
					flex: 1;
					position: relative;
					text-align center;

					.tabTitle_text {
						display: flex;
						justify-content: center;
						flex-direction: column;
						align-items: center;

						>img {
							width: 80rpx;
							height: 80rpx;
							margin-top: 20rpx;
						}

						>view:nth-of-type(1) {
							font-size: 30rpx;
							color: #333333;
							line-height: 42rpx;
							text-align: left;
							margin-top: 10rpx;
						}

						>view:nth-of-type(2) {
							font-size: 24rpx;
							color: #666666;
							line-height: 34rpx;
							text-align: left;
						}


						position: relative;

						&.on {}
					}

					.line {
						width: 2rpx;
						height: 40rpx;
						background: #D8D8D8;
						position: absolute;
						top: 40%;
					}

					.tabTitle_across {
						/* width: 50rpx;
						height: 4rpx;
						background: #0183FA;
						border-radius: 2rpx; */
						margin-left: 38%;
						margin-top: 12rpx;
						display none;

						>img {
							width: 40rpx;
							height: 26rpx;
						}

						&.on {
							display block;
						}
					}

				}
			}
		}

		/* 安全信息牌 */
		.safetyCard {
			flex: 1;
			overflow-y: scroll;
			padding-bottom: 150rpx;

			.lab-info {
				background: #FFFFFF;

				.lab-info-t {
					width: 750rpx;
					height: 80rpx;
					border-bottom: 2rpx dashed #E0E0E0;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					padding: 0 30rpx;
					box-sizing: border-box;

					>view:nth-of-type(1) {
						width: 100rpx;
						height: 60rpx;
						background: #FF0000;
						border-radius: 50rpx 50rpx 50rpx 50rpx;
						font-size: 30rpx;
						color: #FFFFFF;
						line-height: 60rpx;
						text-align: center;
					}

					>view:nth-of-type(2) {
						width: 130rpx;
						height: 60rpx;
						border-radius: 50rpx 50rpx 50rpx 50rpx;
						border: 2rpx solid #FF8C00;
						font-size: 30rpx;
						color: #FF8C00;
						line-height: 60rpx;
						text-align: center;
						margin: 0 30rpx 0 10rpx;
					}

					>view:nth-of-type(3) {
						font-size: 30rpx;
						color: #333333;
						line-height: 42rpx;
						text-align: left;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
				}

				.lab-info-b {
					height: 80rpx;
					padding: 0 30rpx;
					box-sizing: border-box;
					display: flex;
					justify-content: flex-start;
					align-items: center;

					>img {
						width: 34rpx;
						height: 34rpx;
						margin-right: 12rpx;
					}

					font-size: 30rpx;
					color: #333333;
					line-height: 42rpx;
					text-align: left;
				}
			}

			.liability-unit {
				width: 750rpx;
				height: 80rpx;
				background: #FFFFFF;
				border-bottom: 1rpx solid #E0E0E0;
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				margin-top: 14rpx;

				>view:nth-of-type(1) {
					font-size: 30rpx;
					color: #333333;
					line-height: 80rpx;
					text-align: left;
				}

				>view:nth-of-type(2) {
					font-size: 30rpx;
					color: #666666;
					line-height: 80rpx;
					text-align: left;
				}
			}

			.small-title {
				width: 750rpx;
				height: 80rpx;
				background: #FFFFFF;
				border-bottom: 1rpx solid #E0E0E0;
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;

				>view {
					font-size: 30rpx;
					color: #333333;
					line-height: 80rpx;
					text-align: left;
				}

				>img {
					width: 24rpx;
					height: 12rpx;
				}
			}

			.sub-head {
				width: 750rpx;
				height: 80rpx;
				background: #fff;
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1rpx solid #E0E0E0;

				>view:nth-of-type(1) {
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 30rpx;
					color: #666666;
					line-height: 30rpx;
				}

				>view:nth-of-type(2) {
					display: flex;
					justify-content: flex-end;
					align-items: center;

					>img {
						width: 34rpx;
						height: 34rpx;
						margin-right: 14rpx;
					}

					>view {
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 30rpx;
						color: #0183FA;
						line-height: 30rpx;
					}
				}
			}

			.sub-head:last-child {
				border-bottom: none;
			}


			.small-title-new {
				width: 750rpx;
				height: 80rpx;
				background: #FFFFFF;
				border-bottom: 1rpx solid #E0E0E0;
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;

				>view {
					font-size: 30rpx;
					color: #333333;
					line-height: 80rpx;
					text-align: left;
				}

				>img {
					width: 24rpx;
					height: 12rpx;
				}
			}

			.classify {
				.small-items-new {
					padding-left: 20rpx;
					box-sizing: border-box;
					background: #fff;
					display: flex;
					justify-content: flex-start;
					padding: 30rpx;
					box-sizing: border-box;
					border-bottom: 1rpx solid #E0E0E0;

					>view:nth-of-type(1) {
						color: #999999;
						font-weight: 500;
						font-size: 28rpx;
						margin-right: 12rpx;
						line-height: 34rpx;
					}

					>view:nth-of-type(2) {
						display: block;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						line-height: 34rpx;
						color: #999999;
					}
				}

				.logotype-img-new {
					padding: 26rpx 0 34rpx 0;
					box-sizing: border-box;
					background: #fff;

					>img {
						display: inline-block;
						width: 86rpx;
						height: 114rpx;
						margin-left: 30rpx;
						margin-bottom: 20rpx;
					}
				}

				.small-items {
					padding-left: 20rpx;
					box-sizing: border-box;
					background: #fff;
					display: flex;
					justify-content: flex-start;
					padding: 20rpx;
					box-sizing: border-box;

					>view:nth-of-type(1) {
						color: #999999;
						font-weight: 500;
						font-size: 28rpx;
						margin-right: 12rpx;
						line-height: 34rpx;
					}

					>view:nth-of-type(2) {
						display: block;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						line-height: 34rpx;
						color: #999999;
					}

				}

				.logotype {
					width: 750rpx;
					height: 100rpx;
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 32rpx;
					color: #333333;
					line-height: 100rpx;
					padding-left: 20rpx;
					box-sizing: border-box;
					background: #0183FA;
					color: #fff;
				}

				.logotype-img {
					padding: 26rpx 0 34rpx 0;
					box-sizing: border-box;
					background: #fff;

					>img {
						display: inline-block;
						width: 86rpx;
						height: 114rpx;
						margin-left: 30rpx;
						margin-bottom: 20rpx;
					}
				}
			}
		}

		.position-button-box {
			position: absolute;
			bottom: 25rpx;
			left: 60rpx;
			width: 640rpx;
			height: 100rpx;
			display: flex;
			color: #fff;
			overflow: hidden;

			view:nth-child(2) {
				border-top-left-radius: 10rpx;
				border-bottom-left-radius: 10rpx;
			}

			view:nth-last-child(2) {
				border-top-right-radius: 10rpx;
				border-bottom-right-radius: 10rpx;
			}

			.position-button-p-null {
				flex: 1;
			}

			.position-button-p-1 {
				width: 160rpx;
				line-height: 100rpx;
				font-size: 30rpx;
				text-align: center;
				background-color: #0183FA;
			}

			.position-button-p-2 {
				width: 160rpx;
				line-height: 100rpx;
				font-size: 30rpx;
				text-align: center;
				background-color: #16B531;
			}

			.position-button-p-3 {
				width: 160rpx;
				line-height: 100rpx;
				font-size: 30rpx;
				text-align: center;
				background-color: #00DEDE;
			}

			.position-button-p-4 {
				width: 160rpx;
				line-height: 100rpx;
				font-size: 30rpx;
				text-align: center;
				background-color: #FF8C00;
			}
		}
	}
</style>