<template>
	<view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='工单待办'></cus-header>
		<div class="tab">
			<div class="pre" :class="{'active':tIdx===0}" @tap="changeType(0)">待指派</div>
			<div class="pre" :class="{'active':tIdx===1}" @tap="changeType(1)">已指派(待维修)</div>
			<div class="pre" :class="{'active':tIdx===2}" @tap="changeType(2)">已维修</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="place">{{item.place}}</div>
				<div class="pre">报修类型<span>{{item.typename}}</span></div>
				<div class="pre">报修时间<span>{{item.time}}</span></div>
				<div class="type" :class="colorCfg[item.type]||'mr'">{{typeCfg[item.type]||'未知'}}</div>
			</div>
		</div>
		<template v-else>
			<page-empty :height="'calc(100vh - '+(mt+60)+'px)'" marginTop="60px"></page-empty>
		</template>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				typeCfg:{
					1:'普通',
					2:'紧急',
					3:'非常紧急'
				},
				colorCfg:{
					1:'pt',
					2:'jj',
					3:'fcjj'
				},
				tIdx:0,
				source:[
					{
						place:'B座13楼1301',
						typename:'水龙头漏水',
						time:'2024-12-28 10:32:35',
						type:3,//1普通 2紧急 3非常紧急
						status:1//1待指派 2已指派待维修 3已维修
					},
					{
						place:'B座13楼1301',
						typename:'水龙头漏水',
						time:'2024-12-28 10:32:35',
						type:2,//1普通 2紧急 3非常紧急
						status:2//1待指派 2已指派待维修 3已维修
					},
					{
						place:'B座13楼1301',
						typename:'水龙头漏水',
						time:'2024-12-28 10:32:35',
						type:1,//1普通 2紧急 3非常紧急
						status:3//1待指派 2已指派待维修 3已维修
					}
				],
				list:[]
			}
		},
		onShow() {
			let pages = getCurrentPages();
			let last = pages[pages.length-1];
			let status = last.options?.status;
			this.tIdx = status ? (status-1) : 0;
			this.list = this.source.filter(l=>l.status==(status||1))
		},
		methods:{
			changeType(type){
				this.tIdx = type;
				this.list = this.source.filter(l=>l.status===(type+1))
			},
			toDetail(item){
				uni.navigateTo({
					url:'/pagesInspection/waitOrder/detail?order='+JSON.stringify(item)
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.page{
		background: #F4F8FB;
		padding-bottom: 20rpx;
		box-sizing: border-box;
		.tab{
			width: 100%;
			height: 102rpx;
			background: #FFFFFF;
			display: flex;
			.pre{
				width: calc(100% / 3);
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #1D2129;
				line-height: 40rpx;
				position: relative;
				&.active{
					font-weight: bold;
					font-size: 32rpx;
					color: #198CFF;
					line-height: 45rpx;
					&::after{
						content: '';
						width: 36rpx;
						height: 8rpx;
						background: #198CFF;
						border-radius: 4rpx;
						position: absolute;
						left: 50%;
						margin-left: -18rpx;
						bottom: 8rpx;
					}
				}
			}
		}
		
		.boxs{
			width: 100%;
			padding: 0 24rpx;
			box-sizing: border-box;
			.box{
				margin-top: 20rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				padding: 36rpx 24rpx;
				position: relative;
				.place{
					font-family: PingFang-SC, PingFang-SC;
					font-weight: bold;
					font-size: 32rpx;
					color: #1D2129;
					line-height: 36rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}
				.pre{
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #86909C;
					line-height: 24rpx;
					margin-top: 24rpx;
					span{
						font-size: 26rpx;
						color: #1D2129;
						margin-left: 40rpx;
					}
				}
				.type{
					height: 48rpx;
					padding: 0 19rpx;
					border-radius: 0rpx 16rpx 0rpx 16rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 26rpx;
					line-height: 48rpx;
					position: absolute;
					top: 0;
					right: 0;
					&.pt{
						background: rgba(20,204,140,.14);
						color: #14CC8C;
					}
					&.jj{
						background: rgba(254,164,0,.14);
						color: #FEA400;
					}
					&.fcjj{
						background: rgba(249,80,80,.14);
						color: #F95050;
					}
					&.mr{
						background: rgba(153,153,153,.14);
						color: #999999;
					}
				}
			}
		}
	}
</style>