<template>
	<view class="container">
		<uni-navbar title="新增运输" path="/pages/home/index"></uni-navbar>
		<view class="box" style="overflow: hidden;">
			<u-button class="commonMt custom-style" shape="circle" @click="addLine"
				color="linear-gradient(to top, #F59A02, #FFD334)">
				<view class="button-class">
					<image style="width: 29rpx;height: 29rpx;" src="../../static/images/transport/plus.png"
						mode="widthFix">
					</image>
					<text style="margin-left: 19rpx;">新增运输</text>
				</view>
			</u-button>
			<view class="box2">
				<view class="commonMb">
					<view @tap="goToDetial(item)" class="small-box commonBj" v-for="(item,index) 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="item.auditState===0? '../../static/images/transport/state1.png': item.auditState===-1? '../../static/images/transport/state2.png':'../../static/images/transport/state3.png'"
									mode="widthFix">
								</image>
								<text>{{ item.transportName }}</text>
							</view>
							<view :class="changeStateClass(item.auditState)" class="small-box-top-right">
								<text>{{item.auditState===0? '待审核':item.auditState===-1?'驳 回':'通 过'}}</text>
							</view>
						</view>
						<view class="small-box-middle">
							<view class="small-box-middle-startAndEnd" style="margin-bottom: -6rpx;">
								<view>
									<view class="circle-green circle-style">
										起
									</view>
								</view>

								<!-- <text class="deepGreen bold">起点:</text> -->
								<text class="green" style="width: 70%;">{{item.startName}}</text>
							</view>
							<view class="small-box-middle-line">
								<view class="small-box-middle-line-left">
								</view>
								<!-- <view class="small-box-middle-line-right commonLine">
								</view> -->
							</view>
							<view class="small-box-middle-startAndEnd" style="margin-top: -6rpx;">
								<view class="circle-red circle-style">
									终
								</view>
								<!-- <text class="deepRed bold">终点:</text> -->
								<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">
								日期：{{changeDate(item.startDate)}} — {{changeDate(item.endDate)}}
							</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">
									时间：{{changeTime(item.startTime)}} — {{changeTime(item.endTime)}}
								</text>
							</view>
							<view class="small-box-bottom-left">
								<image style="width: 25rpx;height: 25rpx;" src="../../static/images/transport/lb_01.png"
									mode="">
								</image>
								<text class="mr15 ml19 font-size-style">计划使用车辆数：{{item.expectCar}} 辆</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getTransport
	} from "../../api/company/transport.js"
	export default {
		data() {
			return {
				list: [
					// {
					// 	id: '1',
					// 	name: '蓝天建筑 0819023',
					// 	state: '0',
					// 	start: '宽城区光机路新星宇·之悦工地现场',
					// 	end: '米沙子渣土处理垃圾站',
					// 	startDate: '20220829',
					// 	endDate: '20220901',
					// 	startTime: '15:00',
					// 	endTime: '18:00',
					// 	count: '3'
					// },
					// {
					// 	id: '2',
					// 	name: '蓝天建筑 0819023',
					// 	state: '1',
					// 	start: '汽开区32街区',
					// 	end: '上城碧水华庭',
					// 	startDate: '20220829',
					// 	endDate: '20220901',
					// 	startTime: '09:00',
					// 	endTime: '12:00',
					// 	count: '10'
					// },
					// {
					// 	id: '3',
					// 	name: '蓝天建筑 0819023',
					// 	state: '2',
					// 	start: '北湖区中海尚学府',
					// 	end: '朝阳区欧亚卖场',
					// 	startDate: '20220701',
					// 	endDate: '20220702',
					// 	startTime: '12:00',
					// 	endTime: '19:00',
					// 	count: '5'
					// },
					// {
					// 	id: '4',
					// 	name: '蓝天建筑 0819023',
					// 	state: '2',
					// 	start: '北湖区中海尚学府',
					// 	end: '朝阳区欧亚卖场',
					// 	startDate: '20220701',
					// 	endDate: '20220702',
					// 	startTime: '12:00',
					// 	endTime: '19:00',
					// 	count: '5'
					// },
					// {
					// 	id: '5',
					// 	name: '蓝天建筑 0819023',
					// 	state: '2',
					// 	start: '北湖区中海尚学府',
					// 	end: '朝阳区欧亚卖场',
					// 	startDate: '20220701',
					// 	endDate: '20220702',
					// 	startTime: '12:00',
					// 	endTime: '19:00',
					// 	count: '5'
					// }
				],
				queryParams: {
					pageSize: 1000,
					pageNum: 1
				},
				total: 0
			}
		},
		methods: {
			// 跳转 
			// 通过和驳回跳转，待审核不跳
			goToDetial(item) {
				if (item.auditState === -1) {
					this.$tab.navigateTo(`/pages/addTransport/index?id=${item.id}&state=${item.auditState}`)
				}
				if (item.auditState === 1) {
					this.$tab.navigateTo(`/pages/transportInfo/index?id=${item.id}`)
				}
			},
			addLine() {
				this.$tab.navigateTo('/pages/addTransport/index')
			},
			changeStateClass(state) {
				switch (state) {
					case 0:
						return 'state-class1'
					case -1:
						return 'state-class2'
					case 1:
						return 'state-class3'
				}
			},
			changeDate(date) {
				return date.substring(0, 4) + '年' + date.substring(5, 7) + '月' + date.substring(8, 10)
			},
			changeTime(time) {
				return time.slice(0, 5)
			},
			// 获取运输列表
			async getList() {
				const res = await getTransport(this.queryParams)
				console.log('运输列表', res);
				this.total = res.total
				this.list = res.rows
				console.log(this.list);
			}
		},
		onLoad() {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.deepRed {
		color: #E54504
	}

	.deepGreen {
		color: #088243
	}

	.red {
		color: #FF6424;
	}

	.green {
		color: #45AC77;


	}

	.circle-style {
		width: 40rpx;
		height: 40rpx;
		line-height: 40rpx;
		text-align: center;
		border-radius: 50%;
		font-size: 20rpx;
		font-weight: bold;
		color: #FFFFFF;
		// padding: 7px;
	}

	.circle-green {
		background: #45AC77;
	}

	.circle-red {
		background: #FF6424;
	}

	.bold {
		font-weight: bold;
	}

	.custom-style {
		font-size: 28rpx;
		height: 66rpx;
		line-height: 66rpx;
		font-size: 28rpx;
		font-weight: bold;
		color: #FFFFFF;
		margin-bottom: 25rpx;

		.button-class {
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}

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

		.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-top-right {
				text-align: center;
				width: 103rpx;
				height: 45rpx;
				border-radius: 15rpx;
				font-size: 26rpx;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 45rpx;
			}
		}

		.small-box-middle {
			// width: 631rpx;
			// height: 144rpx;
			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 {
				display: flex;
				justify-content: space-between;
				align-items: center;

				.small-box-middle-line-left {
					width: 2rpx;
					height: 20rpx;
					background: rgba(238, 238, 238, 0.5);
					border-radius: 1rpx;
					// margin-left: 20rpx;
					// margin-top: 2rpx;
					// margin-bottom: 2rpx;
					margin: 10rpx 20rpx;
				}

				.small-box-middle-line-right {
					width: 552rpx;
					margin-left: 15rpx;
				}
			}
		}

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


	.ml19 {
		margin-left: 10rpx;
	}

	.mt23 {
		margin-top: 23rpx;
	}

	.mr15 {
		margin-right: 15rpx;
	}

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

	.state-class1 {
		background: linear-gradient(90deg, #F59A02 0%, #FFD334 100%);
	}

	.state-class2 {

		background: linear-gradient(90deg, #FF2D04 0%, #FFA53E 100%);
	}

	.state-class3 {

		background: linear-gradient(90deg, #3FC377 0%, #83D992 100%);
	}
</style>
