<template>
	<view class="container">
		<uni-navbar title="运输记录"></uni-navbar>
		<view class="box " style="overflow: hidden;">
			<!-- 按钮区域 -->
			<view class="button-box commonMt">
				<view :class="'car-box ' + (isCarInfo==='0'?'active':'')" @click="carbButtonClick">
					<image style="width: 28rpx;height: 28rpx;" src="../../static/images/record/state1.png"
						mode="widthFix"></image>
					<text>合规记录</text>
				</view>
				<view :class="'car-box ' + (isCarInfo==='1'?'active':'')" @click="personbButtonClick">
					<image style="width: 28rpx;height: 28rpx;" src="../../static/images/record/state2.png"
						mode="widthFix"></image>
					<text>不合规记录</text>
				</view>
			</view>
			<view class="box2">
				<!-- 通过记录 -->
				<view class="commonMb" v-if="isCarInfo==='0'">
					<view @click="goTo(item.id,item.auditState)" class="small-box commonBj " v-for="item in tongguoList"
						:key="item.id">
						<view class="small-box-top">
							<view class="small-box-top-left">
								<image style="width: 35rpx;height: 35rpx;margin-left: 11rpx;"
									src="../../static/images/record/right.png" mode="widthFix">
								</image>
								<text>{{ item.transportName }}</text>
							</view>
							<view class="small-box-right">
								<text>合&nbsp;规</text>
							</view>
						</view>
						<view class="small-box-middle">
							<view class="small-box-middle-startAndEnd" style="margin-top: -6rpx;">
								<view class="start-green">
									起
								</view>
								<text class="green" style="width: 70%;">{{item.startName}}</text>
							</view>
							<view class="small-box-middle-line-right">
							</view>
							<view class="small-box-middle-startAndEnd" style="margin-top: -6rpx;">
								<view class="start-green bgRed">
									终
								</view>
								<text class="red" style="width: 70%;">{{item.endName}}</text>
							</view>
						</view>
						<view class="small-box-date">
							<image style="width: 24rpx;height: 24rpx;margin-left: 10rpx;"
								src="../../static/images/transport/rili.png" mode="widthFix">
							</image>
							<text class="ml19 font-size-style">
								时间： {{item.startTime+' - '+item.endTime}}
							</text>
						</view>
						<view class="small-box-bottom mt23">
							<view class="small-box-bottom-left">
								<image style="width: 25rpx;height: 25rpx;margin-left: 10rpx;"
									src="../../static/images/transport/time.png" mode="widthFix"></image>
								<text class="ml19 font-size-style">车牌号：{{item.carNumber}} </text>
							</view>
							<view class="small-box-bottom-left">
								<image style="width: 25rpx;height: 25rpx;" src="../../static/images/record/duoren.png"
									mode="widthFix">
								</image>
								<text class="mr15 ml19 font-size-style">车辆司机：{{item.driverName}}</text>
							</view>
						</view>
					</view>
				</view>
				<!-- 驳回记录 -->
				<view class="commonMb" v-if="isCarInfo==='1'">
					<view @click="goTo(item.id,item.auditState)" class="small-box commonBj" v-for="item in bohuiList"
						:key="item.id">
						<view class="small-box-top">
							<view class="small-box-top-left">
								<image style="width: 35rpx;height: 35rpx;margin-left: 11rpx;"
									src="../../static/images/record/wrong.png" mode="widthFix">
								</image>
								<text>{{ item.transportName }}</text>
							</view>
							<view class="small-box-right box-linear">
								<text>不合规</text>
							</view>
						</view>
						<view class="small-box-middle">
							<view class="small-box-middle-startAndEnd" style="margin-top: -6rpx;">
								<view class="start-green">
									起
								</view>
								<text class="green" style="width: 70%;">{{item.startName}}</text>
							</view>
							<view class="small-box-middle-line-right">
							</view>
							<view class="small-box-middle-startAndEnd" style="margin-top: -6rpx;">
								<view class="start-green bgRed">
									终
								</view>
								<text class="red" style="width: 70%;">{{item.endName}}</text>
							</view>
						</view>
						<view class="small-box-date">
							<image style="width: 24rpx;height: 24rpx;margin-left: 10rpx;"
								src="../../static/images/transport/rili.png" mode="widthFix">
							</image>
							<text class="ml19 font-size-style">
								时间： {{item.startTime+' - '+item.endTime}}
							</text>
						</view>
						<view class="small-box-bottom mt23">
							<view class="small-box-bottom-left">
								<image style="width: 25rpx;height: 25rpx;margin-left: 10rpx;"
									src="../../static/images/transport/time.png" mode="widthFix"></image>
								<text class="ml19 font-size-style">车牌号：{{item.carNumber}} </text>
							</view>
							<view class="small-box-bottom-left">
								<image style="width: 25rpx;height: 25rpx;" src="../../static/images/record/duoren.png"
									mode="widthFix">
								</image>
								<text class="mr15 ml19 font-size-style">车辆司机：{{item.driverName}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		selectHistoryData
	} from "@/api/company/record.js"
	export default {
		data() {
			return {
				queryParams: {
					userId:this.$store.state.user.userId,
				},
				// 通过记录或者驳回记录0是通过，1是驳回
				isCarInfo: '0',
				tongguoList: [],
				bohuiList: []
			}
		},
		methods: {
			goTo(id, state) {
				this.$tab.navigateTo(`/pages/recordDetail/index?id=${id}&state=${state}`)
			},
			// 运输记录和驳回就的点击事件
			carbButtonClick() {
				this.isCarInfo = '0'
			},
			personbButtonClick() {
				this.isCarInfo = '1'
			},
			// 获得记录列表
			async getRecordList() {
				const res = await selectHistoryData(this.queryParams)
				console.log('记录列表', res);
				this.tongguoList = res.rows.filter(item => item.auditState === 1)
				this.bohuiList = res.rows.filter(item => item.auditState === -1)
				this.tongguoList.forEach(item => {
					item.startTime = item.startTime.slice(0, 16)
					item.endTime = item.endTime.slice(0, 16)
				})
				this.bohuiList.forEach(item => {
					item.startTime = item.startTime.slice(0, 16)
					item.endTime = item.endTime.slice(0, 16)
				})
			}
		},
		onLoad() {
			this.getRecordList()
		}
	}
</script>

<style lang="scss" scoped>
	.active {
		background: linear-gradient(0deg, #F59A02 0%, #FFD334 100%) !important;
		box-shadow: 0px 2rpx 13rpx 0px rgba(27, 43, 95, 0.25) !important;
	}

	.start-green {
		width: 34rpx;
		height: 34rpx;
		background: #45AC77;
		border-radius: 50%;
		text-align: center;
		line-height: 34rpx;
		font-size: 20rpx;
		font-weight: bold;
		color: #FFFFFF;
	}

	.red {
		color: #FF6424;
	}

	.green {
		color: #45AC77;
	}

	.button-box {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 24rpx;


		.car-box {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 330rpx;
			height: 66rpx;
			background: rgba(255, 255, 255, 0.6);
			border: 0;
			// box-shadow: 0px 0px 24rpx 6rpx rgba(109, 160, 251, 0.6);
			border-radius: 33rpx;

			uni-text {
				margin-left: 18rpx;
				font-size: 28rpx;
				font-weight: bold;
				color: #FFFFFF;
			}
		}
	}

	.bgRed {
		background: #FF6424;
	}

	.small-box {
		padding: 22rpx;
		box-sizing: border-box;
		margin-bottom: 31rpx;

		.small-box-top {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.small-box-top-left {
				display: flex;
				align-items: center;

				uni-text {
					font-size: 28rpx;
					font-weight: bold;
					color: #333333;
					margin-left: 18rpx;
				}

			}

			.small-box-right {
				text-align: center;
				width: 103rpx;
				height: 45rpx;
				border-radius: 15rpx;
				font-size: 26rpx;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 45rpx;
				background: linear-gradient(90deg, #3FC377 0%, #83D992 100%);
			}
		}

		.small-box-middle {
			background: rgba(245, 246, 250, 0.5);
			border: 1rpx solid rgba(235, 235, 235, 0.5);
			border-radius: 20rpx;
			margin-top: 20rpx;
			padding: 20rpx 28rpx;
			box-sizing: border-box;

			.small-box-middle-startAndEnd {
				display: flex;
				align-items: center;
				font-size: 24rpx;
				font-weight: bold;

				uni-text {
					margin-left: 22rpx;
				}
			}

			.small-box-middle-line-right {
				width: 2rpx;
				height: 26rpx;
				background: #eeeeee;
				border-radius: 1rpx;
				// margin: 6rpx 16rpx;
				margin: 10rpx 16rpx;

			}
		}

		.small-box-date {
			display: flex;
			align-items: center;
			margin-top: 24rpx;
		}

		.small-box-bottom {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.small-box-bottom-left {
				display: flex;
				align-items: center;
			}
		}
	}

	.font-size-style {
		font-size: 24rpx;
		font-weight: 400;
		color: #485B93;
	}

	.ml19 {
		margin-left: 10rpx;
	}

	.mt23 {
		margin-top: 23rpx;
	}

	.mr15 {
		margin-right: 15rpx;
	}

	.box-linear {
		background: linear-gradient(90deg, #FF2D04 0%, #FFA53E 100%) !important;
	}
</style>
