<template>
	<view class="container">
		<view class="tabar">
			<view class="flex pad-40 fs-36" style="align-items: center;font-weight: bold;">
				<image class="wh-36" src="../../static/hoem/icon_back.png" @click="$wskj.goBack(1)"></image>
				<view>公厕巡查记录</view>
			</view>
			<view class="flex h-90">
				<view class="flex-center-center" style="flex: 1;" @click="onCz">全部</view>
				<view class="flex-center-center" style="flex: 1;" @click="show=true">
					<text>筛选</text>
					<image class="wh-18 ml-10" src="../../static/icon_sx.png"></image>
				</view>
			</view>
		</view>
		<view class="bgList">
			<scroll-view scroll-y style="height: 100%;">
				<view class="patrolRecordItem" v-for="(item,index) in list" :key="index">
					<view class="item">
						<view class="info">
							<image class="hread" src="../../static/hoem/ic_hread.png"></image>
							<view class="title">
								<view class="toiletName">{{item.toiletId}}公厕</view>
								<view class="devicesName">设备：{{item.equipmentBinding}}</view>
							</view>
						</view>
						<view class="toInspected"> 已巡查</view>
						<view class="patrolTime"> 巡查时间：{{item.inspectionTime}}</view>
						<view class="patrolTime"> 巡查人员：{{item.inspector}}</view>
						<view class="patrolTime"> 巡查区域：{{item.inspectionArea}}</view>
						<view class="patrolPicture">
							<view>巡查照片：</view>
							<view v-for="(otem,ondex) in item.inspectionFileS" :key="index">
								<image class="picture" :src="otem"></image>
							</view>
						</view>
					</view>
				</view>
			</scroll-view>
			<u-popup :show="show" mode="top" @close="show=false" @open="open">
				<view class="pad-20" style="background-color: white;">
					<view class="flex" style="align-items: center;">
						<view @click="showTimeStart=true" class="flex br-10 flex-between-center pad-20"
							style="background-color: #F8F4F4;flex: 1;color: #999;">
							<text>{{ timeStartValue==''?'起始日期':timeStartValue }}</text>
							<image class="wh-36" src="../../static/icon_time.png"></image>
						</view>
						<view class="mlr-20">
							至
						</view>
						<view @click="showTimeEnd=true" class="flex br-10 flex-between-center pad-20"
							style="background-color: #F8F4F4;flex: 1;color: #999;">
							<text>{{ timeEndValue==''?'结束日期':timeEndValue }}</text>
							<image class="wh-36" src="../../static/icon_time.png"></image>
						</view>
					</view>
					<input class=" br-36 mt-20  pad-20 fs-24" style="background: #F8F4F4;color: #999;"
						placeholder="请输入巡查人员姓名搜索" v-model="name" />
					<input class=" br-36 mt-20  pad-20 fs-24" style="background: #F8F4F4;color: #999;"
						placeholder="请输入公厕编号搜索" v-model="number" />
					<view class="flex mt-20" style="align-items: center;">
						<view @click="onCz" class="flex br-40 flex-center-center ptb-20 fs-28"
							style="background-color: #F8F4F4;flex: 1;color: #999;">
							<text>重置</text>
						</view>
						<view @click="onSx" class="flex br-40 flex-center-center ptb-20 fs-28 ml-20"
							style="background: linear-gradient( 90deg, #FCD4D2 0%, #FB262A 100%);;flex: 1;color: white;">
							<text>筛选</text>
						</view>
					</view>
				</view>
			</u-popup>
			<u-datetime-picker :show="showTimeStart" v-model="timeStart" mode="date" @close="showTimeStart=false"
				@cancel="showTimeStart=false" @confirm="onTimeStart"></u-datetime-picker>
			<u-datetime-picker :show="showTimeEnd" v-model="timeEnd" mode="date" @close="showTimeEnd=false"
				@cancel="showTimeEnd=false" @confirm="onTimeEnd"></u-datetime-picker>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showTimeStart: false,
				showTimeEnd: false,
				timeStart: Number(new Date()),
				timeEnd: Number(new Date()),
				timeStartValue: '',
				timeEndValue: '',
				name: '',
				number: '',
				show: false,
				list:[]
			}

		},
		onLoad() {
			
		},
		onShow() {
			this.getCheckList()
		},
		methods: {
			//巡查记录列表
			getCheckList(){
				const params = {
					url: '/system/inspections/list',
					data: {
						inspectorId:uni.getStorageSync("userId"),
						status:'1',
						inspector: this.name,//巡查人员姓名
						toiletId: this.number,//公厕编号
						startTime: this.timeStartValue,//开始时间  
						endTime: this.timeEndValue,//结束时间
					},
				}
				this.$request(params).then(res => {
					this.list=res.rows
				})
			},
			onTimeStart(e) {
				this.showTimeStart = false
				this.timeStartValue = this.$wskj.timeFormat(e.value, 'yyyy-mm-dd')
				console.log(this.timeStartValue)
			},
			onTimeEnd(e) {
				this.showTimeEnd = false
				this.timeEndValue = this.$wskj.timeFormat(e.value, 'yyyy-mm-dd')
				console.log(this.timeEndValue)
			},
			onCz() {
				this.timeStartValue = ''
				this.timeEndValue = ''
				this.name = ''
				this.number = ''
				this.getCheckList()
				this.show = false;
			},
			onSx() {
				this.getCheckList()
				this.show = false;
			}
		}
	}
</script>

<style lang="scss">
	/deep/ .u-fade-enter-active {
		margin-top: 180rpx;
	}

	/deep/ .u-slide-down-enter-active {
		margin-top: 180rpx;
	}

	.container {
		background: linear-gradient(91deg, #FDEDEE 0%, #FFFFFF 100%);
		height: 100%;
		width: 100%;
		display: flex;
		flex-direction: column;
		padding-top: 60rpx;

		.bgList {
			flex: 1;
			overflow-y: auto;
			padding: 0 24rpx;
			background-color: #F8F4F4;
	.patrolRecordItem {
					position: relative;
					padding: 20rpx;
					margin-top: 20rpx;
					background: #FFFFFF;
					border-radius: 14rpx 14rpx 14rpx 14rpx;

					.item {
						margin-top: 20rpx;
						justify-content: space-between;

						.patrolPicture {
							margin-top: 10rpx;
							display: flex;
							font-size: 24rpx;
							color: #666666;

							.picture {

								width: 168rpx;
								height: 126rpx;
								border-radius: 5rpx 5rpx 5rpx 5rpx;
							}
						}

						.patrolTime {
							margin-top: 10rpx;
							font-size: 24rpx;
							color: #666666;
						}

						.toInspected {
							width: 125rpx;
							height: 54rpx;
							text-align: center;
							color: #999999;
							font-size: 24rpx;
							align-items: center;
							line-height: 54rpx;
							position: absolute;
							top: 0%;
							right: 0%;
							background: #E3E3E3;
							border-radius: 0rpx 14rpx 0rpx 0rpx;
						}

						.info {
							display: flex;

							.title {
								padding-left: 10rpx;

								.toiletName {
									color: #333333;
									font-size: 28rpx;
									font-weight: 700;
								}

								.devicesName {
									color: #999999;
									font-size: 24rpx;
								}

							}

							.hread {
								width: 75rpx;
								height: 75rpx;
							}
						}
					}

				}

				

		}

		.tabar {
			display: flex;
			flex-direction: column;
			background: linear-gradient(91deg, #FDEDEE 0%, #FFFFFF 100%);
		}


	}
</style>