<!-- 隐患记录 -->
<template>
	<view class="hiddenDangerRecord">
		<scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
			<view class="tip">此检查项在当前实验室累计出现 {{total}} 次隐患</view>
			<view class="list">
				<view class="list-li" v-for="(item,index) in dataList" @click="clickInfo(item)">
					<view>{{item.flagType==1?'检查时间':'上报时间'}}</view>
					<view>{{item.checkTime}}
						<img :src="imagesUrl('commonality/icon_wd_gd@1x.png')">
					</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 {} from '@/pages/api/index.js'
	import {
		securityAppCheckDangerGetCheckDangerBySub
	} from '@/pages_safetyCheck/api/index.js'
	export default {
		name: "hiddenDangerRecord",
		components: {

		},
		data() {
			return {
				baseUrl: config.base_url,
				pageType: 0,
				// 查询参数
				queryParams: {
					page: 1,
					pageSize: 20,
				},
				total:0,
				getDataType: false,
				optionData:null,
				dataList: [{
						name: '检查时间',
						time: '2024-09-06',
					},
					{
						name: '检查时间',
						time: '2024-09-06',
					},
					{
						name: '检查时间',
						time: '2024-09-06',
					},
				]

			}
		},
		onLoad(option) {
			let optionData = JSON.parse(decodeURIComponent(option.infoData));
			uni.setNavigationBarTitle({
				title: optionData.subName + '(' + (optionData.pageType == 0 ? (optionData.roomNum?optionData.roomNum:'-') : (optionData
					.subRoom?optionData
					.subRoom:'-')) + ')'
			})
			this.$set(this, 'optionData', optionData);
		},
		onShow() {

		},
		mounted() {
			this.getList();
		},
		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();
					})
				}
			},
			clickInfo(row){
				let infoData = this.optionData;
				
				if(row.flagType==1){
					//检查时间
					infoData.checkPlanSetVoList.planId=row.planId;
					infoData.checkPlanSetVoList.planSetId=row.planSetId;
					infoData.manageId=row.manageId;
					infoData.setOptionId=row.setOptionId;
					infoData.subId=row.subId;
					infoData.hazardCheckPro=row.hazardCheckPro;
					uni.navigateTo({
						url: '/pages_safetyCheck/views/itemsManage/hiddenDangerItemsDetail?infoData=' +
							encodeURIComponent(JSON
								.stringify(infoData))
					});
				}else if(row.flagType==2){
					//上报时间
					let infoData=this.optionData;
					uni.redirectTo({
						url: '/pages_safetyCheck/views/snapshotManage/snapshotDetail?infoData=' + encodeURIComponent(JSON.stringify(infoData))
					});
				}
			},
			async getList() {
				let self = this;
				let obj = JSON.parse(JSON.stringify(this.queryParams))
				obj.hazardCheckPro = this.optionData.hazardCheckPro;
				obj.subId = this.optionData.subId;
				const {
					data
				} = await securityAppCheckDangerGetCheckDangerBySub(obj);
				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>
	.hiddenDangerRecord {
		height: 100%;
		display flex;

		.tip {
			width: 750rpx;
			height: 80rpx;
			background: rgba(255, 140, 0, 0.2);
			border-radius: 0rpx 0rpx 0rpx 0rpx;
			font-size: 30rpx;
			color: #FF8C00;
			line-height: 80rpx;
			text-align: center;
		}

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

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

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

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

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

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

		.get-data-null-p {
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
		}
	}
</style>
