<!-- 隐患项 -->
<template>
	<view class="hiddenDangerItems">
		<view class="header">
			<view class="tabTitle_tow">
				<view class="tabTitle_tow_li" @tap="tabClickTow(index)" :key="index" v-for="(item,index) in tabTextTow">
					<view :class="{on:curTabTow==index}" class="tabTitle_tow_text">{{item}}</view>
					<view :class="{on:curTabTow==index}" class="tabTitle_tow_across"></view>
				</view>
			</view>
			<view class="line"></view>
			<view class="search">
				<view class="search-l">
					<view>符合</view>
					<view>不符合</view>
				</view>
				<view class="search-r" @click="inspectionItemsClick()">
					<img src="@/pages_safetyCheck/images/icon_aqjc_ss.png">
					{{newData.hazardCheckCode?newData.hazardCheckCode:''}}{{newData.hazardCheckName?newData.hazardCheckName:'模糊搜索检查项'}}
				</view>
			</view>
		</view>
		<scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
			<view class="list">
				<view class="total">待整改共{{total}}项</view>
				<view class="list-li" v-for="(item,index) in dataList" :key="index">
					<view class="list-li-t" @click="itemsClick(item)">
						<img v-if="item.rectifyStatus==0" src="@/pages_safetyCheck/images/icon_zg_zh@1x.png">
						<img v-if="item.rectifyStatus==1" src="@/pages_safetyCheck/images/icon_xz_fc@1x.png">
						<img v-if="item.rectifyStatus==2" src="@/pages_safetyCheck/images/icon_xz_zg@1x.png">
						<view v-if="item.hazardCheckId">{{item.hazardCheckCode}}{{item.hazardCheckName}}</view>
						<view v-if="!item.hazardCheckId">{{item.hazardDescribe}}</view>
					</view>
					<view v-if="item.hazardCheckId" class="list-li-b" @click="hiddenDangerClick(item)">
						此检查项在当前实验室累计出现<text>{{item.hazardCheckNum}}</text>次隐患
					</view>
				</view>
			</view>
			<view class="get-data-null-p" v-if="getDataType">- 没有更多数据 -</view>
		</scroll-view>
	</view>

</template>

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

		},
		data() {
			return {
				baseUrl: config.base_url,
				pageType: 1,
				tabTextTow: ['待整改', '已整改', '暂无法整改'],
				curTabTow: 0,
				form: {
					imgDtoList: [],
				},
				newData: {

				},
				dialogVisible: false,
				// 查询参数
				queryParams: {
					page: 1,
					pageSize: 10,
					subId: '',
					rectifyStatus: 0,
					hazardCheckId: '',
					searchValue: '',
				},
				total: 0,
				dataList: [],
				getDataType: false,

			}
		},
		onLoad(option) {
			this.$set(this, 'newData', JSON.parse(decodeURIComponent(option.infoData)));
			this.pageType = this.newData.pageType;
			this.queryParams.subId = this.newData.subId ? this.newData.subId : ''
			this.queryParams.hazardCheckId = this.newData.hazardCheckId ? this.newData.hazardCheckId : ''
			uni.setNavigationBarTitle({
				title: '实验室名称(房间号)'
			})
			if (this.pageType == 0) {
				//检查
				this.tabTextTow = ['待检查', '检查中', '已检查']
			} else if (this.pageType == 1) {
				//复查
				this.tabTextTow = ['待复查', '复查完毕', '退回整改']
			} else if (this.pageType == 2) {
				//整改
				this.tabTextTow = ['待整改', '已整改', '暂无法整改']
				this.getList()
			}
		},
		onShow() {

		},
		mounted() {
			
		},
		methods: {
			//滚动事件
			scrollGet() {
				let self = this;
				if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
					this.$set(this, 'getDataType', true);
				} else {
					this.queryParams.page += 1;
					this.$nextTick(() => {
						this.getList();
					})
				}
			},
			//顶部tab点击
			tabClickTow(index) {
				this.curTabTow = index;
				this.queryParams.rectifyStatus = index;
				this.getList()
			},
			dialogOpen() {
				this.dialogVisible = true;
			},
			dialogClose() {
				this.dialogVisible = false;
			},
			//搜索项跳转
			inspectionItemsClick() {
				this.newData.pageType = 2; //1随手拍检查项
				uni.redirectTo({
					url: '/pages_safetyCheck/views/itemsManage/hiddenDangerItemsSearch?form=' + encodeURIComponent(
						JSON.stringify(this.newData))
				});
			},
			itemsClick(row) {
				let infoData = row;
				infoData.pageType = this.pageType;
				uni.redirectTo({
					url: '/pages_safetyCheck/views/inspectManage/inspectAdd?infoData=' + encodeURIComponent(JSON
						.stringify(infoData))
				});
			},
			hiddenDangerClick(row) {
				let infoData = row;
				infoData.pageType = this.pageType;
				uni.redirectTo({
					url: '/pages_safetyCheck/views/inspectManage/hiddenDangerRecord?infoData=' +
						encodeURIComponent(JSON.stringify(infoData))
				});
			},
			//
			async getList() {
				let self = this;
				const {
					data
				} = await securityAppCheckPhotoList(this.queryParams);
				if (data.code == 200) {
					if (self.queryParams.page == 1) {
						this.dataList = data.data.records;
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					} else {
						this.dataList = [...this.dataList, ...data.data.records]
						this.total = data.data.total;
						if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
							this.$set(this, 'getDataType', true);
						}
					}
				}
			},
			

		}
	}
</script>

<style lang="stylus" scoped>
	.hiddenDangerItems {
		height: 100%;
		display flex;
		box-sizing: border-box;

		#totalColor-A {
			color: #0183FA;
			background: rgba(1, 131, 250, 0.2);
		}

		#totalColor-B {
			color: #16B531;
			background: rgba(22, 181, 49, 0.2);
		}

		#totalColor-C {
			color: #FF8C00;
			background: rgba(255, 140, 0, 0.2);
		}

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

			.tabTitle_tow {
				width: 520rpx;
				height: 80rpx;

				display flex;
				justify-content: flex-start;
				align-items: center;

				.tabTitle_tow_li {
					flex: 1;
					position: relative;
					text-align center;

					.tabTitle_tow_text {
						display: inline-block;
						font-size: 30rpx;
						font-family: PingFang SC;
						font-weight: 500;
						color: #333333;
						line-height: 46rpx;
						position: relative;

						&.on {
							color: #0183FA;
						}
					}

					.tabTitle_tow_across {
						width: 50rpx;
						height: 4rpx;
						background: #0183FA;
						border-radius: 2rpx;
						margin-left: 38%;
						display none;

						&.on {
							display block;
						}
					}

				}
			}

			.line {
				width: 100%;
				height: 20rpx;
				background: #F5F5F5;
			}

			.search {
				width: 750rpx;
				height: 80rpx;
				background: #FFFFFF;
				border-radius: 0rpx 0rpx 0rpx 0rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;

				.search-l {
					display: flex;
					justify-content: flex-start;
					align-items: center;
					margin: 0 30rpx;
					.search-A{
						border-radius: 50rpx 50rpx 50rpx 50rpx;
						border: 1rpx solid #E0E0E0;
						width: 100rpx;
						height: 60rpx;
						background: #E0E0E0;
						border-radius: 50rpx 50rpx 50rpx 50rpx;
						font-weight: normal;
						font-size: 24rpx;
						color: #333333;
						line-height: 60rpx;
						text-align: center;
						margin-right: 10rpx;
					}
					.search-B{
						border-radius: 50rpx 50rpx 50rpx 50rpx;
						border: 1rpx solid #E0E0E0;
						width: 100rpx;
						height: 60rpx;
						background: #0183FA;
						border-radius: 50rpx 50rpx 50rpx 50rpx;
						font-weight: normal;
						font-size: 24rpx;
						color: #FFFFFF;
						line-height: 60rpx;
						text-align: center;
						margin-right: 10rpx;
					}
				}

				.search-r {
					width: 470rpx;
					height: 60rpx;
					background: #FFFFFF;
					border-radius: 50rpx 50rpx 50rpx 50rpx;
					border: 1rpx solid #E0E0E0;
					font-size: 24rpx;
					color: #999999;
					line-height: 60rpx;
					text-align: left;
					display: flex;
					justify-content: flex-start;
					align-items: center;
					padding: 0 20rpx;
					box-sizing: border-box;

					>img {
						width: 30rpx;
						height: 30rpx;
						margin-right: 20rpx;
					}
				}
			}
		}

		.list {
			width: 750rpx;
			background: #FFFFFF;
			margin-top: 200rpx;
			padding-bottom: 20rpx;
			box-sizing: border-box;

			.total {
				width: 180rpx;
				height: 50rpx;
				background: rgba(1, 131, 250, 0.2);
				border-radius: 0rpx 0rpx 20rpx 0rpx;
				font-size: 24rpx;
				color: #0183FA;
				line-height: 50rpx;
				text-align: left;
				padding: 0rpx 22rpx;
				box-sizing: border-box;
				margin-bottom: 20rpx;
			}

			.list-li {
				margin: 0 30rpx;

				.list-li-t {
					width: 690rpx;
					background: #F5F5F5;
					border-radius: 10rpx 10rpx 10rpx 10rpx;
					display: flex;
					justify-content: flex-start;
					padding: 12rpx 20rpx 14rpx 14rpx;
					box-sizing: border-box;
					margin: 20rpx 0;

					>img {
						width: 24rpx;
						height: 24rpx;
						margin-right: 30rpx;
					}

					>view {
						flex: 1;
						font-size: 24rpx;
						color: #3D3D3D;
						line-height: 34rpx;
						text-align: left;
					}
				}

				.list-li-b {
					font-size: 24rpx;
					color: #3D3D3D;
					line-height: 24rpx;
					text-align: right;

					>text {
						color: #FF0000;
					}
				}

			}
		}

		.get-data-null-p {
			text-align: center;
			height: 100rpx;
			line-height: 100rpx;
			color: #999;
			padding-bottom: 200rpx;
		}
	}
</style>
