<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 list"
						: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 mt20">
							<view class="middle-left">
								<view class="circle-green circle-style">
									起
								</view>
								<view class="small-box-middle-line-left">
								</view>
								<view class="circle-red circle-style">
									终
								</view>
							</view>
							<view class="middle-middle">
								<view class="position-start">
									<view class="green bold size24 textStyle">{{item.startName}}</view>
								</view>
								<view class="position-end">
									<text class="red bold size24 textStyle ">{{item.endName}}</text>
								</view>
							</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 list"
						: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"
								:class="item.isInterrupt === 1?'box-isInterrupt':'box-linear'">
								<text>{{item.isInterrupt === 1?'脱 离':'不合规'}}</text>
							</view>
						</view>
						<view class="small-box-middle mt20">
							<view class="middle-left">
								<view class="circle-green circle-style">
									起
								</view>
								<view class="small-box-middle-line-left">
								</view>
								<view class="circle-red circle-style">
									终
								</view>
							</view>
							<view class="middle-middle">
								<view class="position-start">
									<view class="green bold size24 textStyle">{{item.startName}}</view>
								</view>
								<view class="position-end">
									<text class="red bold size24 textStyle ">{{item.endName}}</text>
								</view>
							</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 {
		recordList
	} from "@/api/company/record.js"
	export default {
		data() {
			return {
				// 通过记录或者驳回记录0是通过，1是驳回
				isCarInfo: '0',
				list: [],
				// tongguoList: [],
				// bohuiList: [],
			}
		},
		methods: {
			goTo(id, state) {
				this.$tab.navigateTo(`/pages/recordDetail/index?id=${id}&state=${state}`)
			},
			// 运输记录和驳回就的点击事件
			carbButtonClick() {
				this.isCarInfo = '0'
				this.getRecordList('1')
			},
			personbButtonClick() {
				this.isCarInfo = '1'
				this.getRecordList('-1')
			},
			// 获得记录列表
			async getRecordList(auditState) {
				const res = await recordList(auditState)
				console.log('记录列表', res);
				// this.tongguoList = res.rows.filter(item => item.auditState === 1)
				// this.bohuiList = res.rows.filter(item => item.auditState === -1)
				this.list = res.rows
				this.list.forEach(item => {
					item.startTime = item.startTime.replace(/-/g, '/').slice(0, -3)
					item.endTime = item.endTime.replace(/-/g, '/').slice(0, -3)
				})
				// this.bohuiList.forEach(item => {
				// 	item.startTime = item.startTime.slice(0, 16)
				// 	item.endTime = item.endTime.slice(0, 16)
				// })
			}
		},
		onLoad() {
			// 参数1默认合规
			this.getRecordList('1')
		}
	}
</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;
	}

	.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;
			}
		}
	}

	.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%);
			}
		}

		.mt20 {
			margin-top: 20rpx;
		}

		.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;
	}

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