<!-- 检查和自查列表 -->
<template>
	<view class="snapshotList">
		<scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
			<view class="title" @click="planClick()">
				<view class="title-l" >
					<view class="title-l-t">{{newData.data10}}</view>
					<view class="title-l-b">
						<view v-for="(item,index) in newData.data11" :key="index">{{item}}</view>
					</view>
				</view>
				<img class="title-r" src="@/pages_safetyCheck/images/icon_wd_gd@1x.png">
			</view>
			<view class="tabTitleTow">
				<view :class="tabIndexTow==index?'tab-C':'tab-D'" v-for="(item,index) in tabListTow"
					@click="tabClickTow(index)">{{item}}</view>
			</view>
			<view>
				<view class="srearch">
					<view class="college">学院
						<img src="@/pages_safetyCheck/images/icon_06.png">
					</view>
					<view class="srearch-n">
						<view class="srearch-l" @click="popupClick(1)">
							<img src="@/pages_safetyCheck/images/icon_aqjc_ss.png">
						</view>
						<input class="srearch-c" type="text" v-model="form.searchValue" placeholder="实验室/房间号" />
						<view class="srearch-r" @click="saoCode()">
							<img src="@/pages_safetyCheck/images/icon_aqjc_sm.png">
						</view>
					</view>
				</view>
				<view class="level">
					<view class="level-li" :id="levelIndex==index?'levelColor-A':'levelColor-B'"
						@click="levelClick(index)" v-for="(item,index) in levelList">{{item}}</view>
				</view>
			</view>
			<view class="hidden">
				<view class="hidden-li" @click="listClick(item)" v-for="(item,index) in hiddenList">
					<img class="hidden-li-l" src="@/pages_safetyCheck/images/icon_sys_xz@1x.png">
					<view class="hidden-li-c">{{item.subName}}</view>
					<view class="hidden-li-r">待检查{{item.num}}项
						<img src="@/pages_safetyCheck/images/icon_ssp_gd@1x.png">
					</view>
				</view>
			</view>

		</scroll-view>
		<view class="popup-max-box" v-if="popupType">
			<view class="popup-null" @click="popupClick(2)"></view>
			<view class="popup-big-box">
				<view class="popup-input-box">
					<input type="text" maxlength="10" v-model="room" placeholder="请输入关键字">
					<view @click="buildBySub">搜索</view>
				</view>
				<view class="popup-for-max-box">
					<view class="popup-for-null" v-if="!roomList[0]">暂无数据</view>
					<view class="popup-for-box" v-for="(item,index) in roomList" :key="index">
						<view class="name-p">{{item.subName}} ({{item.roomNum?item.roomNum:'-'}})</view>
						<view class="button-p" @click="popupClickItem(item)">确定</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		config
	} from '@/api/request/config.js'
	import {} from '@/pages/api/index.js'
	import {
		laboratorySubRelInfoGetRelList,
		checkOptionListNew,
	} from '@/pages_safetyCheck/api/index.js'
	export default {
		name: "snapshotList",
		components: {

		},
		data() {
			return {
				baseUrl: config.base_url,
				pageType: 0,
				userType: 1,
				tabListTow: ['自查任务', '复查验证', '隐患整改'],
				tabIndexTow: 0,
				newData: {
					data10: '计划标题计划标题计划标题计划标题计划标题计标题计划标题计划标题',
					data11: ['校级检查', '全面检查', '交叉检查'],
				},
				form: {
					rectifyDescribe: '',
					imgDtoList: [],
					hazardCheckName: '',
				},
				popupType: false,
				roomList: [],
				checkOptionList: [],
				hiddenList: [{
						subName: '实验室名称实验室名称实验室名称实验室名称',
						num: 3,
					},
					{
						subName: '实验室名称实验室名称实验室名称实验室名称',
						num: 3,
					},
					{
						subName: '实验室名称实验室名称实验室名称实验室名称',
						num: 3,
					},
				],
				levelList: ['一级', '二级', '三级', '四级'],
				levelIndex: 0,
			}
		},
		onLoad(option) {
			//this.$set(this, 'newData', JSON.parse(decodeURIComponent(option.infoData)));
			this.pageType = option.infoData.pageType;
			console.log( this.newData)
			uni.setNavigationBarTitle({
				title: '第1次检查'
			})
			if (this.pageType == 0) {
				//检查
				this.tabListTow = ['检查任务', '复查验证', '隐患整改'];
			} else if (this.pageType == 1) {
				//复查
				this.tabListTow = ['自查任务', '复查验证', '隐患整改'];
			}

		},
		onShow() {

		},
		mounted() {

		},
		methods: {
			//滚动事件
			scrollGet() {},
			levelClick(index) {
				this.levelIndex = index;
			},
			tabClickTow(index) {
				this.tabIndexTow = index;
				this.pageType = index;
			},
			planClick(){
				let infoData='';
				uni.navigateTo({
					url: '/pages_safetyCheck/views/planDetail?infoData=' + encodeURIComponent(JSON.stringify(infoData))
				});
			},
			listClick(row){
				let infoData=row;
				infoData.pageType=this.tabIndexTow;
				uni.navigateTo({
					url: '/pages_safetyCheck/views/itemsManage/hiddenDangerItems?infoData=' + encodeURIComponent(JSON.stringify(infoData))
				});
			},
			/******搜索房间弹层开关******/
			popupClick(type) {
				if (type == 1) {
					this.room = "";
					this.roomList = [];
					this.popupType = true;
					this.buildBySub();
				} else if (type == 2) {
					this.popupType = false;
				}
			},
			//搜索房间接口
			async buildBySub() {
				let self = this;
				const {
					data
				} = await laboratorySubRelInfoGetRelList({
					'searchValue': this.form.searchValue,
				});
				if (data.code == 200) {
					if (data.data[0]) {
						this.roomList = data.data;
					} else {
						uni.showToast({
							title: '未找到相关实验室',
							icon: "none",
							mask: true,
							duration: 2000
						});
					}
				}
			},
			//确认搜索房间
			popupClickItem(item) {
				console.log(item)
				this.$set(this.form, "subId", item.subId)
				this.$set(this.form, "subName", item.subName)
				this.$set(this.form, "deptId", item.deptId)
				for (let i = 0; i < this.collegeList.length; i++) {
					if (item.deptId == this.collegeList[i].deptId) {
						this.$set(this.form, "deptName", this.collegeList[i].deptName)
					}
				}
				this.popupType = false;
			},
			/******调用摄像头******/
			saoCode() {
				let self = this;
				uni.scanCode({
					onlyFromCamera: true,
					success: function(res) {
						let list = res.result.split("?")[1].split("&");
						let codeData = {};
						list.forEach((item) => {
							codeData[item.split("=")[0]] = item.split("=")[1];
						})
						console.log('二维码', codeData)
						if (codeData.code) {
							self.laboratoryAppletGetSubDetailInfo(codeData.code);
						} else {
							uni.showToast({
								title: '请扫描正确的二维码',
								icon: "none",
								mask: true,
								duration: 2000
							});
						}
					}
				});
			},


		}
	}
</script>

<style lang="stylus" scoped>
	.snapshotList {
		height: 100%;
		display flex;

		.title {
			width: 750rpx;
			height: 150rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 30rpx;
			box-sizing: border-box;

			.title-l {
				width: 594rpx;

				.title-l-t {
					font-size: 30rpx;
					color: #333333;
					line-height: 42rpx;
					text-align: left;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}

				.title-l-b {
					display: flex;
					justify-content: flex-start;
					margin-top: 16rpx;

					>view {
						width: 130rpx;
						height: 50rpx;
						background: rgba(1, 131, 250, 0.2);
						border-radius: 6rpx 6rpx 6rpx 6rpx;
						font-size: 24rpx;
						color: #0183FA;
						line-height: 50rpx;
						text-align: center;
						margin-right: 14rpx;
					}
				}
			}

			.title-r {
				width: 24rpx;
				height: 24rpx;
			}
		}

		.tabTitleTow {
			width: 690rpx;
			height: 80rpx;
			display: flex;
			justify-content: center;
			margin: 20rpx 0 0 30rpx;

			>view:nth-of-type(1) {
				width: 230rpx;
				height: 80rpx;
				border-radius: 50rpx 0rpx 0rpx 50rpx;
			}

			>view:nth-of-type(2) {
				width: 230rpx;
				height: 80rpx;
				border-radius: 0rpx 0rpx 0rpx 0rpx;
			}

			>view:nth-of-type(3) {
				width: 230rpx;
				height: 80rpx;
				border-radius: 0rpx 50rpx 50rpx 0rpx;
			}

			.tab-C {
				font-size: 30rpx;
				color: #FFFFFF;
				line-height: 80rpx;
				text-align: center;
				background: #0183FA;
			}

			.tab-D {
				font-size: 30rpx;
				color: #333333;
				line-height: 80rpx;
				text-align: center;
				background: #FFFFFF;
			}
		}

		.srearch {
			width: 750rpx;
			height: 100rpx;
			background: #FFFFFF;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			overflow: hidden;
			margin-top: 20rpx;
			display: flex;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 30rpx;
			box-sizing: border-box;

			.college {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx 50rpx 50rpx 50rpx;
				border: 1rpx solid #E0E0E0;
				font-size: 24rpx;
				color: #333333;
				line-height: 60rpx;
				text-align: left;
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 26rpx;
				box-sizing: border-box;

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

			.srearch-n {
				width: 480rpx;
				height: 60rpx;
				border-radius: 50rpx 50rpx 50rpx 50rpx;
				border: 1rpx solid #E0E0E0;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.srearch-l {
					width: 60rpx;
					height: 60rpx;

					>img {
						width: 20rpx;
						height: 20rpx;
						margin: 20rpx 0 0 26rpx;
					}
				}

				.srearch-c {
					flex: 1;
					height: 58rpx;
					font-size: 24rpx;
					color: #999999;
					line-height: 30rpx;
					text-align: left;
				}

				.srearch-r {
					width: 60rpx;
					height: 60rpx;

					>img {
						width: 30rpx;
						height: 30rpx;
						margin: 14rpx 22rpx 0 0;
					}


				}
			}
		}

		.level {
			width: 750rpx;
			height: 80rpx;
			background: #FFFFFF;
			display: flex;
			justify-content: flex-start;
			padding: 0 30rpx;
			box-sizing: border-box;

			.level-li {
				width: 100rpx;
				height: 50rpx;
				background: #F5F5F5;
				border-radius: 50rpx 50rpx 50rpx 50rpx;
				border: 1rpx solid #E0E0E0;
				margin-right: 10rpx;
				font-size: 24rpx;
				color: #333333;
				line-height: 50rpx;
				text-align: center;
			}

			#levelColor-A {
				background: rgba(255, 0, 0, 0.2);
				color: #FF0000;
				border: 1rpx solid #FF0000;
			}

			#levelColor-B {
				background: #F5F5F5;
				color: #333333;
				border: 1rpx solid #E0E0E0;
			}

		}

		.list {
			width: 690rpx;
			min-height: 765rpx;
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			margin: 20rpx 0 0 30rpx;

			.list-li {
				display: flex;
				justify-content: space-between;
				border-bottom: 1rpx solid #E0E0E0;
				padding: 0 22rpx 0 28rpx;
				box-sizing: border-box;

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

				>view:nth-of-type(2) {
					font-size: 28rpx;
					color: #666666;
					line-height: 80rpx;
					text-align: left;
					display: flex;
					justify-content: flex-start;
					align-items: center;

					>img {
						width: 24rpx;
						height: 24rpx;
						margin-left: 8rpx;
					}
				}

				.project_r {
					width: 510rpx;
					min-height: 80rpx;
					display: flex;
					justify-content: flex-end;
					align-items: center;
					padding-left: 20rpx;
					box-sizing: border-box;
					color: #666;
				}

			}

			.describe {
				width: 636rpx;
				height: 120rpx;
				border-radius: 10rpx 10rpx 10rpx 10rpx;
				border: 1rpx solid #E0E0E0;
				margin: 20rpx 0 0 28rpx;
				padding: 12rpx 16rpx;
				box-sizing: border-box;
			}

			.check-for-img-max-box {
				margin: 20px 28rpx;

				.left-title-p {
					width: 100%;
					text-align: left;
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 80rpx;
				}

				.right-img-box {
					.img-box {
						display inline-block;
						height: 150rpx;
						width: 150rpx;
						position relative;
						margin: 0 14rpx 20rpx 0;
						border-radius 10rpx;
						overflow hidden;

						.img-data {
							height: 150rpx;
							width: 150rpx;
						}

						.position-img {
							position absolute;
							right: 0;
							top: 0;
							width: 36rpx;
							height: 36rpx;
						}
					}

					.img-box:nth-of-type(3n+3) {
						margin-right: 0rpx;
					}

					.add-button {
						margin: 0 0rpx 20rpx 0;
						border-radius 10rpx;
						overflow hidden;
						display inline-block;
						height: 150rpx;
						width: 150rpx;
					}
				}
			}
		}

		/* 实验室弹框 */
		.popup-max-box {
			z-index: 10;
			height: 100%;
			width: 100%;
			position fixed;
			background rgba(0, 0, 0, 0.2);
			display flex;

			flex-direction column;

			.popup-null {
				flex: 1;
			}

			.popup-big-box {
				border-top-left-radius: 20rpx;
				border-top-right-radius: 20rpx;

				background #fff;

				.popup-input-box {
					padding: 30rpx 20rpx;
					display: flex;

					input {
						flex: 1;
						height: 70rpx;
						border: 1rpx solid #e0e0e0;
						border-radius: 10rpx;
						margin-right: 20rpx;
						padding: 0 20rpx;
					}

					view {
						background #0183FA;
						color: #fff;
						border-radius: 10rpx;
						width: 140rpx;
						line-height: 70rpx;
						text-align center;
						font-size: 28rpx;
					}
				}

				.popup-for-max-box {
					margin: 0 20rpx 30rpx;
					height: 600rpx;
					overflow-y scroll;

					.popup-for-null {
						line-height: 100rpx;
						text-align center;
						color: #999;
					}

					.popup-for-box {
						display: flex;
						padding: 10px 0;

						.name-p {
							flex: 1;
							line-height: 60rpx;
						}

						.button-p {
							background #0183FA;
							color: #fff;
							text-align center;
							width: 100rpx;
							line-height: 60rpx;
							height: 60rpx;
							border-radius: 10rpx;
						}
					}
				}
			}
		}

		.subBtn {
			width: 690rpx;
			height: 100rpx;
			background: #0183FA;
			border-radius: 50rpx 50rpx 50rpx 50rpx;
			font-weight: 400;
			font-size: 30rpx;
			color: #FFFFFF;
			line-height: 100rpx;
			text-align: center;
			position: fixed;
			left: 30rpx;
			bottom: 10rpx;
		}

		/* 上报记录 */
		.escalation {

			.escalation-li {
				width: 690rpx;
				height: 162rpx;
				background: #FFFFFF;
				border-radius: 20rpx 20rpx 20rpx 20rpx;
				margin: 20rpx 30rpx;
				padding: 0 30rpx;
				box-sizing: border-box;

				.escalation-li-t {
					display: flex;
					justify-content: space-between;
					align-items: center;
					border-bottom: 1rpx solid #E0E0E0;

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

					>view:nth-of-type(2) {
						font-weight: 400;
						font-size: 28rpx;
						color: #0183FA;
						line-height: 80rpx;
						text-align: left;
						display: flex;
						justify-content: flex-start;
						align-items: center;

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

				.escalation-li-b {
					display: flex;
					justify-content: space-between;
					align-items: center;

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

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

			}
		}

		/* 隐患整改 */
		.hidden {
			width: 690rpx;
			border-radius: 20rpx 20rpx 20rpx 20rpx;
			background: #FFFFFF;
			padding: 0 30rpx;
			box-sizing: border-box;
			margin: 20rpx 30rpx;

			.hidden-li {
				height: 80rpx;
				border-bottom: 1rpx solid #E0E0E0;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.hidden-li-l {
					width: 34rpx;
					height: 34rpx;
				}

				.hidden-li-c {
					font-size: 28rpx;
					color: #333333;
					line-height: 30rpx;
					text-align: left;
					flex: 1;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					margin: 0 84rpx 0 12rpx;
				}

				.hidden-li-r {
					font-size: 28rpx;
					color: #0183FA;
					line-height: 80rpx;
					text-align: left;
					display: flex;
					justify-content: flex-start;
					align-items: center;

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

			.hidden-li:last-of-type {
				border: none;
			}
		}

		#color-A {
			color: #0183FA;
		}

		#color-B {
			color: #FF8C00;
		}

		#color-C {
			color: #16B531;
		}
	}
</style>
