<template>
	<view class="container">
		<uni-navbar title="路线申请"></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 class="small-box commonBj" @click="changeState(item)" v-for="(item,index) in list"
						:key="item.id">
						<view class="small-box-middle">
							<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 class="middle-right">
								<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-startAndEnd" style="margin-bottom: -6rpx;">
								<view class="circle-green circle-style">
									起
								</view>
								<text class="green textStyle" style="width: 70%;">{{item.startName}}</text>
							</view>
							<view class="small-box-middle-line">
								<view class="small-box-middle-line-left">
								</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-startAndEnd" style="margin-top: -6rpx;">
								<view class="circle-red circle-style">
									终
								</view>
								<text class="red textStyle" style="width: 70%;">{{item.endName}}</text>
							</view> -->
						</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/path/enterprise.png" mode="widthFix"></image>
								<text class="ml19 font-size-style">发起部门：{{item.startDept}}</text>
							</view>
							<view class="small-box-bottom-left">
								<image style="width: 25rpx;height: 25rpx;" src="../../static/images/transport/time.png"
									mode="widthFix">
								</image>

								<text class="mr15 ml19 font-size-style">发起时间：{{changeTime(item.createTime)}}</text>
							</view>
							<!-- <text class="mr15 ml19 font-size-style">发起时间：2022/8/24 16:46</text> -->
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		routeList
	} from "../../api/company/path.js"
	export default {
		data() {
			return {
				list: []
			}
		},
		methods: {
			changeTime(time) {
				if (time) {
					return time.slice(0, time.length - 3).replace(/-/g, "/")
				} else {
					return '无'
				}
			},
			routeList() {
				routeList().then(res => {
					console.log(res, 'res');
					this.list = res.rows;
				})
			},
			addLine() {
				this.$tab.navigateTo('/pages/addPath/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(4, 6) + '月' + date.substring(6)
			},
			changeState(item) {
				console.log('item', item);
				if (item.auditState == '-1') {
					this.$tab.navigateTo('/pages/addPath/index?id=' + item.id)
				} else if (item.auditState == '1') {
					this.$tab.navigateTo('/pages/pathInfo/index?id=' + item.id)
				}
			}
		},
		onShow() {
			console.log('初始化了', '111');
			this.routeList()
		}
	}
</script>

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

	.deepGreen {
		color: #088243
	}



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

	.small-box {
		margin-bottom: 30rpx;
		margin-top: 20rpx;
		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-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>
