<template>
	<view class="dangerbig-details">
		<view class="fixedheader">
			<headers :showBack="true">
				<view class="headerName">
					浇筑令台账详情
				</view>
			</headers>
		</view>
		<view :style="{ 'padding-top': ((statusBarHeight * 2) + 45) * 1.5 + 'rpx' }">
			<view class="detail-content">
				<view class="list">
					<view class="list-info">
						混凝土编号：<text class="detail-data">{{detailData.concreteNumber}}</text>
					</view>
					<view class="list-info">
						浇筑时间：<text class="detail-data"
							v-if="detailData.pouringBeginTime && detailData.pouringEndTime">{{detailData.pouringBeginTime+'-'+detailData.pouringEndTime}}</text>
					</view>
					<view class="list-info">
						装置：<text class="detail-data">{{detailData.deviceName}}</text>
					</view>
					<view class="list-info">
						浇筑部位：<text class="detail-data">{{detailData.castingLocation}}</text>
					</view>
					<view class="" v-if="isShow">
						<view class="list-info">
							混凝土供应商：<text class="detail-data">{{detailData.concreteSupplierName}}</text>
						</view>
						<view class="list-info">
							项目组：<text class="detail-data">{{detailData.projectGroupName}}</text>
						</view>
						<view class="list-info">
							EPC/PC承包商：<text class="detail-data">{{detailData.epcPcContractorName}}</text>
						</view>
						<view class="list-info">
							计划放量：<text class="detail-data">{{detailData.plannedVolume}}</text>
						</view>
					</view>

					<view v-if="COMPANY != 'longguang'" class="more-btn" @click="isShow=!isShow">
						<text>{{isShow ? "收起详情":"展开详情"}}</text>
					<image class="detail_icon_up" :class="{'detail_icon_down': isShow}" src="/static/bthgIcon/detail_icon.png"></image>
					<!-- <uni-icons2 :type="isShow ? 'arrowup':'arrowdown'"></uni-icons2> -->
					</view>
				</view>

				<view class="detail-nav" v-if="COMPANY != 'longguang'">
					<!-- <scroll-view class="scrollx-wrap" scroll-x>
						<view class="nav-list">
							<view class="nav-item" :class="{'active-nav': activeIndex == item.id}"
								v-for="(item,index) in navList" :key="index" @click="checkNav(item)">
								{{item.name}}
							</view>
						</view>
					</scroll-view>
					<view class="detail-wrap">
						<plan ref="list" v-if="componentName == 'plan'" :detailId="detailId" :info="detailData"></plan>
						<safe ref="list" v-if="componentName == 'safe'" :detailId="detailId" :info="detailData"></safe>
						<side ref="list" v-if="componentName == 'side'" :detailId="detailId" :info="detailData"></side>
						<workFinally ref="list" v-if="componentName =='workFinally'" :detailId="detailId"
							:info="detailData"></workFinally>
					</view> -->
					<view class="nav_title">施工旁站</view>
					<view class="box" @click="viewWorkerAnalysis">
						<view class="box_1">
							<image src="/static/bthgIcon/aqjc1.png" class="img" style="width: 64rpx; height: 64rpx">
							</image>
							<text class="num">施工旁站</text>
						</view>
						<uni-icons2 class="arrowright" type="arrowright"></uni-icons2>
					</view>
				</view>
				<!-- <view class="add-btn" v-if="activeIndex != 7 && activeIndex != 2 && !(activeIndex == 1 && detailData.engineeringState == 3) -->
				<!-- v-if="activeIndex != 7 && userInfo.userId === detailData.assignmentPersonInCharge
					&& COMPANY != 'longguang' && detailData.finalAcceptanceStatus !== 2 && isShowBtn && btnAuth" -->

			</view>
		</view>
		<view class="fixed" :class="{show:showIframe}" v-if="show" @click="show=false">
			<view class="iframeMain" @click.stop="show=true">
				<video v-if="getType(iframeUrl) == 'video'" class="iframe" :src="iframeUrl"></video>
				<image v-else-if="getType(iframeUrl) == 'image'" class="iframe" :src="iframeUrl" mode="aspectFit">
				</image>
				<iframe v-else class="iframe" ref="iframe" :src="iframeUrl" frameborder="0"></iframe>
			</view>
		</view>
	</view>
</template>

<script>
	import plan from './plan.vue'
	import safe from './safe.vue'
	import side from './side.vue'
	import workFinally from './workFinally.vue'
	import {
		isVideoLink,
		isImageLink,
		openOutsideFile,
		openLocalFile,
		removeNetWorkFileTemp
	} from '@/utils/tool.js'
	export default {
		components: {
			plan,
			safe,
			side,
			workFinally,
		},
		data() {
			return {
				statusBarHeight: 0,
				isShow: false,
				componentName: "side",
				navList: [{
					id: 3,
					name: "施工旁站"
				}],
				activeIndex: 3,
				detailId: "",
				detailData: {},
				isShowBtn: null,
				userInfo: {},
				btnAuth: true,
				showIframe: false,
				show: false,
				iframeUrl: ""
			}
		},
		onReachBottom() {
			console.log(1, this.$refs['list'])
		},
		onPullDownRefresh() {
			console.log(2)
		},
		onShow() {
			this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
			this.statusBarHeight = uni.getStorageSync('systemInfo').statusBarHeight;
			// this.initData()
			this.getWork()
			let that = this;
			setTimeout(function() {
				console.log(that.$refs, 777)
				console.log(that.$refs.listBox, 777)
				if (that.$refs['list'] && that.$refs['list'].initData) {
					console.log(777888)
					that.$refs['list'].initData()
				}
			}, 200)
		},
		onLoad(val) {
			this.btnAuth = this.checkBtnPermission({
				key: 'towerOverWork_add',
				menuPath: '/project/specialWork/towerOverWork'
			})
			this.detailId = val.id
		},
		onUnload() {
			removeNetWorkFileTemp();
		},
		mounted() {},
		methods: {
			viewWorkerAnalysis() {
				uni.navigateTo({
					url: "./side?detailId=" + this.detailId,
				});
			},
			getType(url) {
				if (isImageLink(url)) {
					return "image"
				} else if (isVideoLink(url)) {
					return "video"
				} else {
					return ''
				}
			},
			downloadFile(url) {
				// 下载所有的文件
				let name = url.substring(url.lastIndexOf('/') + 1);
				console.log(name, "文件名称");
				if (isVideoLink(url) || isImageLink(url)) {
					// 是图片和视频
					this.show = true;
					this.showIframe = true;
					this.iframeUrl = this.url_config + 'image/' + url;
				} else {
					// openOutsideFile(`${this.url_config}image/${url}`)
					openLocalFile(name, `${this.url_config}image/${url}`)
				}

				return;
			},
			//预览图片
			previewImage(url) {
				uni.previewImage({
					urls: [url]
				})
			},
			getWork() {
				this.sendRequest({
					url: 'xmgl/pouringOrderLedger/queryById',
					method: 'get',
					data: {
						id: this.detailId
					},
					success: res => {
						uni.hideLoading()
						// if(res.code==200){
						// 	this.listData = res.result.records
						// }
						this.detailData = {
							...res.result,
							hotWorkExecutionTime: [
								res.result.pouringBeginTime ? res.result.pouringBeginTime : '',
								res.result.pouringEndTime ? res.result.pouringEndTime : '',
							],
						}
						// let str = '';
						// if(res.result.chooseTypeDescribeList){
						// 	this.detailData.describeName
						// 	res.result.chooseTypeDescribeList.map((item,index) => {
						// 		if(index == res.result.chooseTypeDescribeList.length - 1){
						// 			str = str + item.describeName
						// 		} else {
						// 			str = str + item.describeName + ','
						// 		}
						// 	})
						// 	console.log(str,123456789)
						// 	this.detailData.describeName = str;
						// }
						this.getApply()
					}
				})
			},
			goSafeMesure() {
				uni.navigateTo({
					url: "./safeMesure?detailId=" + this.detailId
				})
			},
			getApply() {
				console.log("=====================================================detail");
				console.log(this.detailData);
				this.sendRequest({
					url: 'xmgl/xzDangerousEngineeringAcceptance/list',
					method: 'get',
					data: {
						engineeringId: this.detailData.id,
						projectSn: JSON.parse(uni.getStorageSync('projectDetail')).projectSn,
						type: 10
					},
					success: res => {
						uni.hideLoading()
						console.log("xmgl/xzDangerousEngineeringAcceptance/list", res);
						let result = res.result
						if (res.result.length > 0) {
							if (res.result[0].acceptanceResult === null) this.isShowBtn = false
							if (res.result[0].acceptanceResult === 1) this.isShowBtn = false
							if (res.result[0].acceptanceResult === 2) this.isShowBtn = true
						} else {
							this.isShowBtn = true
						}
					}
				})
			},
			checkNav(val) {
				this.activeIndex = val.id
				if (val.id == 1) {
					this.componentName = "plan"
				} else if (val.id == 2) {
					this.componentName = "safe"
				} else if (val.id == 3) {
					this.componentName = "side"
				} else if (val.id == 4) {
					this.componentName = "workFinally"
				}
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	.rules-text2 {
		display: flex;
		justify-content: center;
		align-items: center;
		color: #3190F3;
		font-size: 28rpx;
		white-space: nowrap;

		>text:first-child {
			margin-right: 20rpx;
		}
	}
	.detail-nav >.fileItem:not(:last-child){
		margin-bottom: 20rpx;
	}
	.fileItem {
		font-size: 30rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 22rpx 40rpx;
		margin: 0 40rpx;
		// color: $uni-text-color;
		color: #3592F3;
		background-color: #F4F7FE;
		// border-bottom: 1px solid rgba(221, 221, 221, 0.8);

		.left {
			display: flex;
			align-items: center;
			width: 70%;

			.left_text {
				flex: 1;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
				-o-text-overflow: ellipsis;
			}
		}

		.fileIcon {
			width: 40rpx;
			height: 24rpx;
			margin-right: 20rpx;
		}

		.ellipsis {
			width: 40rpx;
			height: 10rpx;
		}
	}

	.detail-wrap .fileItem:not(:first-child) {
		margin-top: 20rpx;
	}

	.uni-form-item {
		position: relative;

		.search-icon {
			position: absolute;
			top: 50%;
			right: 50rpx;
			transform: translateY(-50%);
		}
	}

	.fixed {
		position: fixed;
		z-index: 9999;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, .3);
		display: none;

		&.show {
			display: initial;
		}
	}

	.iframeMain {
		position: absolute;
		left: 50%;
		top: 50%;
		transform: translate(-50%, -50%);
		width: 650rpx;
		font-size: 0;

		.iframe {
			width: 100%;
			height: 500rpx;
		}
	}

	.other-safe {
		background-color: #fff;
		// margin-top: 50rpx;
		padding: 15rpx 15rpx;
		line-height: 40rpx;

		.other-head {
			display: flex;

			.other-icon {
				width: 10rpx;
				height: 40rpx;
				background-color: #2b8df3;
				border-radius: 100rpx;
			}

			.other-text {
				margin-left: 20rpx;
			}
		}

		.other-content {
			font-size: 22rpx;
			width: auto;
			min-height: 50rpx;
			// background-color: darkred;
			// border: 1rpx solid black;
			margin: 0 30rpx;
			margin-top: 15rpx;
			display: flex;

			.content-1 {
				width: 22%;
			}

			.content-2 {
				width: 24%;
			}

			.content-3 {
				width: 23%;
				// margin-left: 10%;
			}

			.content-4 {
				width: 26%;
			}
		}

	}

	.safe-mesure {
		width: 100%;
		height: 100rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #fff;

		.safe-btn {
			text-align: center;
			width: 80%;
			line-height: 70rpx;
			// background-color: darkred;
			border: 4rpx solid #2b8df3;
			color: #2b8df3;
			border-radius: 20rpx;
			font-weight: bold;
		}
	}

	.table-info {
		display: flex;
		justify-content: center;
		align-items: center;
		background-color: #fff;

		.teble-list {
			display: flex;
			justify-content: flex-start;
			width: 100%;
			font-size: 18rpx;
			background-color: gainsboro;

			.teble-item {
				width: 24.8%;
				line-height: 40rpx;

				// border: 1rpx solid black;
				// background-color: darkred;
				.item-col {
					// margin: 0 5rpx;
					margin-left: 5rpx;
					margin-top: 5rpx;
					padding: 3rpx;
					text-align: center;
					background-color: #fff;
				}
			}
		}

		.u-td {
			height: auto;
		}
	}

	.dangerbig-details {
		min-height: 100%;
		// background: #F6F6F6;

		.fixedheader {
			position: fixed;
			top: 0;
			left: 0;
			width: 100%;
			z-index: 2;
		}

		.detail-content {
			// padding-top: 20rpx;
		}

		.list {
			// margin-bottom: 20rpx;
		}

		.list-info {
			background: #fff;
			// border-bottom: 1px solid #F6F6F6;
			font-size: 26rpx;
			padding: 20rpx 30rpx;
			// display: flex;
			// align-items: center;
		}

		.list-info {
			.source-box {
				display: flex;
				flex-direction: column;

				text {
					color: #8F8FF7;
					text-decoration: underline;
					margin-top: 20rpx;
				}
			}
		}

		.list-info ul {
			list-style: none;
			padding: 0;
			display: flex;
			flex-wrap: wrap;
			align-items: center;
			margin-top: 20rpx;
		}

		.list-info ul li {
			width: 30%;
			height: 100px;
			margin: 0 10rpx;
			margin-bottom: 20rpx;
		}

		.list-info ul li image {
			width: 100%;
			height: 100%;
		}

		.more-btn {
			text-align: center;
			font-size: 28rpx;
			// height: 50rpx;
			background: #F1F7FE;
			line-height: 50rpx;
			border-top: 2rpx dashed #CCCCCC;
			border-bottom: 2rpx dashed #CCCCCC;
			padding: 14rpx 0;
			color: #3190F3;
		}

		.nav_title {
			padding: 28rpx 40rpx;
			font-size: 30rpx;
		}

		.nav-list {
			display: flex;
			height: 80rpx;
			align-items: center;
			padding: 0 20rpx;

			.nav-item {
				width: 25%;
				text-align: center;
				white-space: nowrap;
				padding: 0 20rpx;
				height: 80rpx;
				box-sizing: border-box;
				line-height: 80rpx;
				font-size: 28rpx;
			}

			.active-nav {
				border-bottom: 4rpx solid #4396E7;
			}
		}

		.detail-nav {
			width: 100%;
			padding-bottom: 40rpx;

			.box {
				// flex: 1;
				// display: inline-flex;

				height: 100rpx;
				// background: #FFFFFF;
				border: 2rpx solid rgba(102, 111, 232, 0.08);
				border-radius: 8rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin: 0 40rpx;
				padding: 0 40rpx 0 44rpx;

				.box_1 {
					display: flex;
					align-items: center;

					.img {
						margin-right: 16rpx;
						// margin-left: 40rpx;
					}

					>view {
						display: flex;
					}

					.num {
						color: #2D8EF3;
						font-size: 30rpx;
						margin-left: 36rpx;
					}
				}

				.arrowright {
					color: #2D8EF3 !important;
					font-size: 40rpx !important;
				}

			}
		}

		.scrollx-wrap {
			width: 100%;
			background: #fff;
		}


	}
</style>