<template>
	<!-- 查看详情页面 -->
	<view class="detail_con">
		<view class="detail_box">
			<view class="top_box">
				<view class="top_item">
					<view class="unit_left">
						<view class="unit">管理单位</view>
						<view class="unit_name">{{ roadData.organizationName }}</view>
					</view>
					<view class="unit_time">{{ roadData.statDate || '' }} {{ roadData.statPeriodValue || '' }}</view>
				</view>
				<view class="all_item first">
					<view class="all_left">高速开闭情况：</view>
					<view class="all_right">{{ roadData.isOpen == 1 ? '开放' : '关闭' }}</view>
				</view>
				<view class="all_item">
					<view class="all_left">已处理事故数量：</view>
					<view class="all_right">
						{{roadData.count1}}
					</view>
				</view>
				<view class="all_item">
					<view class="all_left">正在处理事故数量：</view>
					<view class="all_right">
						{{roadData.count2}}
					</view>
				</view>
				<view class="all_item">
					<view class="all_left">事故数量：</view>
					<view class="all_right">
						{{ roadData.accidentCount === 0 ? roadData.accidentCount : roadData.accidentCount || '' }}
					</view>
				</view>
				<view class="all_item">
					<view class="all_left">拥堵数量：</view>
					<view class="all_right">
						{{ roadData.congestionCount === 0 ? roadData.congestionCount : roadData.congestionCount || '' }}
					</view>
				</view>
				<view class="all_item">
					<view class="all_left">伤者人数：</view>
					<view class="all_right">
						{{ roadData.injuredCount === 0 ? roadData.injuredCount : roadData.injuredCount || '' }}
					</view>
				</view>
				<view class="all_item last">
					<view class="all_left">亡者人数：</view>
					<view class="all_right">
						{{ roadData.deceasedCount === 0 ? roadData.deceasedCount : roadData.deceasedCount || '' }}
					</view>
				</view>

			</view>
		</view>

		<view class="detail_box">
			<view class="top_box">
				<!-- tab 切换 -->
				<view class="tab_box">
					<view class="tab_nav" :class="tabType == 1 ? 'active' : ''" @click="tabType = 1">拥堵信息详情</view>
					<view class="tab_nav" :class="tabType == 2 ? 'active' : ''" @click="tabType = 2">事故信息详情</view>
				</view>
				<!-- 拥堵 -->
				<view class="con_item" v-if="tabType == 1" v-for="(item, index) in roadData.highwayCongestionDetailVOS"
					:key="index">
					<view class="spread_box" v-if="item.isSpread">
						<view class="item_con first">
							<view class="left">拥堵信息-{{index+1}}</view>
						</view>
						<view class="item_con">
							<view class="left">高速公路名称：</view>
							<view class="right">{{ item.highwayName || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">拥堵发生时间：</view>
							<view class="right">
								<uni-dateformat v-if="item.congestionStartTime" format="yyyy-MM-dd hh:mm:ss" :date="item.congestionStartTime"></uni-dateformat>
								<text v-else></text>
							</view>
						</view>
						<view class="item_con">
							<view class="left">拥堵处理结束时间：</view>
							<view class="right">
								<uni-dateformat v-if="item.congestionEndTime" format="yyyy-MM-dd hh:mm:ss" :date="item.congestionEndTime"></uni-dateformat>
								<text v-else></text>
							</view>
						</view>
						<view class="item_con">
							<view class="left">发生位置：</view>
							<view class="right">{{ item.location || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">拥堵内容：</view>
							<view class="right">{{ item.congestionContent || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">阻断/拥堵持续时间：</view>
							<view class="right">{{ item.duration || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">截至当前拥堵空间范围(桩号及方向)：</view>
							<view class="right">{{ item.congestionRange || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">处置工作开展情况：</view>
							<view class="right">{{ item.disposalStatus || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">补充：</view>
							<view class="right">{{ item.additionalNotes || '' }}</view>
						</view>
						<view class="expand_box" @click="clickPack(item)">
							<image class="img" src="../../../static/image/spread.png" mode=""></image>
							<view class="tit">收起</view>
						</view>
					</view>
					<view class="no_spread" v-if="!item.isSpread" @click="handleSpread(item)">
						<view class="item_con first">
							<view class="left">拥堵信息-{{index+1}}</view>
						</view>
						<view class="item_con">
							<view class="left">高速公路名称：</view>
							<view class="right">{{ item.highwayName || '' }}</view>
						</view>
					</view>
				</view>
				<!-- 事故 -->
				<view class="con_item" v-if="tabType == 2" v-for="(item, index) in roadData.highwayAccidentDetailVOS"
					:key="item.id">
					<view class="spread_box">
						<view class="item_con first">
							<view class="left">事故信息-{{index+1}}</view>
						</view>
						<view class="item_con">
							<view class="left">高速公路名称：</view>
							<view class="right">{{ item.highwayName || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">事故发生时间：</view>
							<view class="right">{{ item.accidentEndTime || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">事故处理结束时间：</view>
							<view class="right">{{ item.congestionEndTime || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">发生位置：</view>
							<view class="right">{{ item.location || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">事故内容：</view>
							<view class="right">{{ item.accidentContent || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">事故等级：</view>
							<view class="right">{{ item.accidentLevel || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">阻断/拥堵持续时间：</view>
							<view class="right">{{ item.duration || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">截止当前拥堵空间范围(桩号及方向)：</view>
							<view class="right">{{ item.spatialRange || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">处置工作开展情况：</view>
							<view class="right">{{ item.workStatus || '' }}</view>
						</view>
						<view class="item_con">
							<view class="left">补充说明：</view>
							<view class="right">{{ item.additionalNotes || '' }}</view>
						</view>
					</view>
					<view class="no_spread" v-if="!item.isSpread" @click="handleSpread(item)">
						<view class="item_con first">
							<view class="left">事故信息-{{index+1}}</view>
						</view>
						<view class="item_con">
							<view class="left">高速公路名称：</view>
							<view class="right">{{ item.highwayName || '' }}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="bottom_box">
				<p class="edit_btn" @click="goEditPage">编辑</p>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				roadData: {},
				tabType: 1,
			}
		},
		onLoad(options) {
			let item = JSON.parse(options.item)
			console.log(item)
			let item1 = JSON.parse(JSON.stringify(item));
			item1.highwayAccidentDetailVOS.map((item, index) => {
				item.isSpread = index === 0 ? true : false;
			})
			item1.highwayCongestionDetailVOS.map((item, index) => {
				item.isSpread = index === 0 ? true : false;
			})
			this.roadData = item1;
			// this.getDetail()
		},
		methods: {
			//跳转到编辑
			goEditPage() {
				uni.navigateTo({
					url: '/pages/highway/runStatusData/form?item=' + JSON.stringify(this.roadData)
				})
			},
			//点击收起按钮
			clickPack(item) {
				this.$set(item, "isSpread", false)
			},
			handleSpread(item) {
				this.$set(item, "isSpread", true)
			},
			getDetail() {
				this.$request(getApp().globalData.baseUrl + '/api/biz/highSpeedOperationController/selectById/' +
					'8A47103EE00000018772BC97AE50FFB7', {}, "GET").then(res => {
					console.log(res)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.detail_con {
		width: 100%;
		height: 100%;
		overflow-y: auto;

		.detail_box {
			background: #fff;
			border-radius: 30rpx;
			margin: 30rpx 30rpx 0;

			.top_box {
				width: 630rpx;
				padding: 38rpx 30rpx 0rpx;
				display: flex;
				flex-direction: column;

				.top_item {
					width: 100%;
					// margin-top: 38rpx;
					margin-bottom: 60rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: space-between;

					.unit_left {
						width: 100%;
						display: flex;

						.unit {
							width: 102rpx;
							height: 37rpx;
							background: #FFF7E4;
							border-radius: 10rpx;
							border: 1rpx solid #EF9A4F;
							font-size: 20rpx;
							color: #E37616;
							display: flex;
							align-items: center;
							justify-content: center;
						}

						.unit_name {
							font-size: 30rpx;
							color: #333;
							font-weight: bold;
							line-height: 48rpx;
							margin-left: 20rpx;
						}
					}

					.unit_time {
						margin-top: 30rpx;
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 24rpx;
						color: #999999;
					}
				}

				.all_item {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 32rpx;

					&.first {
						margin-top: 0rpx;
					}

					&.last {
						margin-bottom: 30rpx;
					}

					.all_left {
						color: #666666;
						font-size: 26rpx;
					}

					.all_right {
						font-size: 28rpx;
						color: #333;
					}
				}

				.con_item {
					width: 570rpx;
					background: #F8F8F8;
					border-radius: 30rpx;
					margin: 0 auto;
					margin-top: 30rpx;
					padding: 30rpx 30rpx;

					.spread_box {
						width: 100%;

						.item_con {
							width: 100%;
							display: flex;
							align-items: center;
							justify-content: space-between;
							margin-top: 32rpx;

							&.first {
								color: #333;
								font-size: 30rpx;
								font-weight: bold;
								margin-top: 0rpx;
							}

							.left {
								color: #666666;
								font-size: 26rpx;
							}

							.right {
								font-size: 28rpx;
								color: #333;
							}
						}

						.item_content {
							width: 570rpx;
							margin: 0 auto;
							background-color: #fff;
							border-radius: 30rpx;
							margin-top: 30rpx;


							.content {
								width: 516rpx;
								padding: 34rpx 32rpx 30rpx 22rpx;
								display: flex;
								justify-content: space-between;
								align-items: center;

								&.top {
									border-bottom: 1rpx solid #F2F2F2;
								}


								.left {
									font-size: 24rpx;
									color: #666;
								}

								.right {
									color: #333;
									font-size: 28rpx;

									&.green {
										color: #1ECE5F;
									}

									&.red {
										color: #EB4747;
									}
								}
							}
						}

						.expand_box {
							width: 100%;
							display: flex;
							margin-top: 30rpx;
							align-items: center;
							justify-content: center;

							.img {
								width: 40rpx;
								height: 40rpx;
							}

							.tit {
								color: #2D8CF0;
								font-size: 24rpx;
								margin-left: 12rpx;
							}
						}
					}

					.no_spread {
						width: 100%;
						background: #F8F8F8;
						border-radius: 30rpx;

						.item_con {
							width: 100%;
							display: flex;
							align-items: center;
							justify-content: space-between;
							margin-top: 32rpx;

							&.first {
								margin-top: 0rpx;
							}

							.left {
								color: #666666;
								font-size: 26rpx;
							}

							.right {
								font-size: 28rpx;
								color: #333;
							}
						}
					}
				}
			}

			.bottom_box {
				width: 100%;
				padding: 40rpx 0;
				display: flex;
				justify-content: flex-end;

				.edit_btn {
					width: 180rpx;
					height: 70rpx;
					background: #2D8CF0;
					border-radius: 100rpx;
					color: #fff;
					font-size: 28rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-right: 30rpx;
				}
			}
		}

		.tab_box {
			display: flex;
			justify-content: space-around;

			.tab_nav {
				color: #999999;
				line-height: 42rpx;
				font-size: 30rpx;
				font-family: PingFang SC-Regular, PingFang SC;
				font-weight: 400;
				padding-bottom: 25rpx;

				&.active {
					position: relative;
					color: #2D8CF0;
					font-weight: bold;

					&::after {
						position: absolute;
						content: '';
						left: 50%;
						bottom: 0;
						width: 74rpx;
						height: 6rpx;
						background: #2D8CF0;
						border-radius: 100rpx;
						margin-left: -37rpx;
					}
				}
			}
		}

	}
</style>