<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='巡检记录'></cus-header>
		<div class="query">
			<div class="pre" @tap="selectQuery(1)">
				<span>{{statusText}}</span>
				<u-icon name="arrow-down-fill" color="#C0C4CC" size="20rpx"></u-icon>
			</div>
			<div class="pre" @tap="selectQuery(2)">
				<span>{{timeText}}</span>
				<u-icon name="arrow-down-fill" color="#C0C4CC" size="20rpx"></u-icon>
			</div>
			<div class="pre" @tap="selectQuery(3)">
				<span>{{placeText}}</span>
				<u-icon name="arrow-down-fill" color="#C0C4CC" size="20rpx"></u-icon>
			</div>
		</div>
		<div class="boxs" v-if="list.length">
			<div class="box" v-for="(item,index) in list" :key="index" @tap="toDetail(item)">
				<div class="top">
					<div class="left">{{'长鑫科技集团股份有限公司'}}</div>
					<div class="right">
						<div class="status" :class="{'zc':index===0,'yc':index===1}">{{index===0?'正常':'异常'}}</div>
						<image :src="imgBase+'operation/arrow_right.png'" mode="widthFix"></image>
					</div>
				</div>
				<div class="text">
					<div class="left">巡检时间</div>
					<p>{{'2025-03-28'}}</p>
				</div>
				<div class="text">
					<div class="left">巡检负责人</div>
					<p>{{'王安宇'}}</p>
				</div>
			</div>
		</div>
		<template v-else>
			<page-empty :height="'calc(100vh - 200px)'"></page-empty>
		</template>
		<div class="bottom">
			<div class="btn" @tap="addRecord">添加巡检记录</div>
		</div>
		<u-picker :itemHeight="88" :show="show1" :columns="columns1" keyName="label" title="巡检状态"
			@cancel="show1=false" @confirm="e=>confirm(e,1)" :immediateChange="true"></u-picker>
		<u-datetime-picker :itemHeight="88" :show="show2" v-model="queryParams.month" mode="year-month" title="巡检时间"
			@cancel="show2=false" @confirm="e=>confirm(e,2)" :immediateChange="true" :minDate="minDate" :maxDate="maxDate"></u-datetime-picker>
		<u-picker :itemHeight="88" :show="show3" :columns="columns3" keyName="label" title="巡检地点"
			@cancel="show3=false" @confirm="e=>confirm(e,3)" :immediateChange="true"></u-picker>
	</view>
</template>

<script>
	import pageEmpty from '@/components/pageEmpty/index.vue'
	export default {
		components:{
			pageEmpty
		},
		data(){
			return {
				statusText:'巡检状态',
				timeText:'巡检时间',
				placeText:'巡检地点',
				queryParams:{
					status:'',
					month:'',
					place:''
				},
				show1:false,
				show2:false,
				show3:false,
				columns1:[[
					{value:0,label:'正常'},
					{value:1,label:'异常'}
				]],
				columns3:[[
					{value:1,label:'长鑫科技集团股份有限公司'},
					{value:2,label:'峻凌电子(合肥)有限公司'}
				]],
				minDate:'',
				maxDate:'',
				page:1,
				limit:10,
				isOver:false,
				list:[]
			}
		},
		onReachBottom() {
			if(this.isOver) return
			this.getList();
		},
		onLoad() {
			let d = new Date();
			this.minDate = new Date(d.getFullYear()-3,d.getMonth()+1,d.getDate()).getTime();
			this.maxDate = new Date().getTime();
			this.getList();
		},
		methods:{
			getList(){
				this.list = [1,2]
			},
			selectQuery(type){
				if(type==1) this.show1 = true;
				else if(type==2) this.show2 = true;
				else if(type==3) this.show3 = true;
			},
			confirm(e,type){
				if(type==1){
					this.statusText = e.value[0].label;
					this.queryParams.status = e.value[0].value;
					this.show1 = false;
				}else if(type==2){
					this.timeText = new Date(e.value).Format('yyyy-MM');
					this.queryParams.month = new Date(e.value).Format('yyyy-MM');
					this.show2 = false;
				}else if(type==3){
					this.placeText = e.value[0].label;
					this.queryParams.place = e.value[0].value;
					this.show3 = false;
				}
			},
			addRecord(){
				uni.navigateTo({
					url:'/pagesOperation/record/add'
				})
			},
			toDetail(item){
				uni.navigateTo({
					url:'/pagesOperation/record/detail'
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		padding-bottom: 168rpx;
		background: #F4F8FB;
		
		.query{
			width: 100%;
			height: 88rpx;
			background: #FFFFFF;
			display: flex;
			.pre{
				width: calc(100% / 3);
				height: 88rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				span{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 26rpx;
					color: #86909C;
					line-height: 26rpx;
					margin-right: 12rpx;
				}
			}
		}
	
		.boxs{
			padding: 0 24rpx;
			.box{
				background: #FFFFFF;
				border-radius: 16rpx;
				margin-top: 20rpx;
				padding: 36rpx 24rpx;
				.top{
					display: flex;
					align-items: center;
					justify-content: space-between;
					.left{
						width: calc(100% - 146rpx);
						padding-right: 20rpx;
						font-family: PingFang-SC, PingFang-SC;
						font-weight: bold;
						font-size: 30rpx;
						color: #1D2129;
						line-height: 30rpx;
						overflow: hidden;
						white-space: nowrap;
						text-overflow: ellipsis;
					}
					.right{
						display: flex;
						align-items: center;
						.status{
							width: 88rpx;
							height: 42rpx;
							border-radius: 6rpx;
							font-family: PingFang-SC, PingFang-SC;
							font-weight: bold;
							font-size: 26rpx;
							color: #FFFFFF;
							line-height: 42rpx;
							text-align: center;
							&.zc{
								background: #14CC8C;
							}
							&.yc{
								background: #FF4141;
							}
						}
						image{
							width: 24rpx;
							height: 24rpx;
							margin-left: 10rpx;
						}
					}
				}
				.text{
					margin-top: 36rpx;
					display: flex;
					align-items: center;
					.left{
						width: 168rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 26rpx;
						color: #86909C;
						line-height: 26rpx;
					}
					p{
						font-family: PingFangSC, PingFang SC;
						font-weight: 400;
						font-size: 26rpx;
						color: #1D2129;
						line-height: 26rpx;
					}
				}
			}
		}
			
		.bottom{
			width: 100%;
			height: 148rpx;
			padding: 20rpx 48rpx;
			box-sizing: border-box;
			background: #FFFFFF;
			position: fixed;
			bottom: 0;
			left: 0;
			z-index: 9;
			.btn{
				width: 100%;
				height: 88rpx;
				background: #2E69EB;
				border-radius: 16rpx;
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 88rpx;
				text-align: center;
			}
		}
	}
</style>