<template>
	<view class="dangerbig-details">
		<headers class="fixedheader" :themeType="true" :showBack="true">
			<view class="headerName">
				吊装安全作业详情
			</view>
		</headers>
		<view :style="{ 'padding-top': statusBarHeight + 45 + 'px' }">
			<view class="detail-content">
					<view class="list">
						<view class="list-info">
							作业票编号：<text class="detail-data">{{detailData.workTicketCode}}</text>
						</view>
						<view class="list-info">
							作业申请单位：<text class="detail-data">{{detailData.jobApplicationUnitName}}</text>
						</view>
						<view class="list-info">
							作业申请时间：<text class="detail-data">{{detailData.jobApplicationTime}}</text>
						</view>
						<view class="list-info">
							作业负责人：<text class="detail-data">{{detailData.assignmentPersonInChargeName}}</text>
						</view>
						<view class="" v-if="isShow">
							<view class="list-info">
								作业单位：<text class="detail-data">{{detailData.operatingUnitName}}</text>
							</view>
							<view class="list-info">
								吊装地点：<text class="detail-data">{{detailData.hoistPlace}}</text>
							</view>
							<view class="list-info">
								吊具名称：<text class="detail-data">{{detailData.hoistName}}</text>
							</view>
							<view class="list-info">
								吊物内容：<text class="detail-data">{{detailData.hoistContent}}</text>
							</view>
							<view class="list-info">
								吊装作业人：<text class="detail-data">{{detailData.hoistJobPersonName}}</text>
							</view>
							<view class="list-info">
								司索人：<text class="detail-data">{{detailData.siSuoPersonName}}</text>
							</view>
							<!-- <view class="list-info">
								监护人：<text class="detail-data">{{detailData.guardianName}}</text>
							</view> -->
							<view class="list-info">
								指挥人员：<text class="detail-data">{{detailData.commanderName}}</text>
							</view>
							<view class="list-info">
								吊物质量(t)：<text class="detail-data">{{detailData.hoistWeight}}</text>
							</view>
							<view class="list-info">
								作业级别：<text class="detail-data">{{detailData.jobLevel}}</text>
							</view>
							<view class="list-info">
								风险辨识结果：<text class="detail-data">{{detailData.riskIdentificationResult}}</text>
							</view>
							<view class="list-info">
								作业实施时间：<text class="detail-data" v-if="detailData.workExecutionBeginTime && detailData.workExecutionEndTime">{{detailData.workExecutionBeginTime+'-'+detailData.workExecutionEndTime}}</text>
							</view>
							<!-- <view class="list-info">
								安全隐患总数：<text class="detail-data">{{detailData.hiddenDangerNum}}</text>
							</view> -->
							<!-- <view class="list-info">
								安全作业票编号：<text class="detail-data">{{detailData.riskIdentificationResult}}</text>
							</view> -->
							<!-- <view class="list-info">
								关联的其他特殊作业及安全作业编号：<text class="detail-data">{{detailData.otherRelatedSpecialTask}}</text>
							</view> -->
							<!-- <view class="table-info" style="">
									<scroll-view :scroll-x="true" class="teble-list">
										<view class="teble-item">
											<view class="item-col" style="background-color: lightgray;">气体取样分析时间</view>
											<view class="item-col" style="background-color: lightgray;">代表性气体</view>
											<view class="item-col" style="background-color: lightgray;">分析结果/%</view>
											<view class="item-col" style="margin-bottom: 5rpx;background-color: lightgray;">分析人</view>
										</view>
										<view class="teble-item" v-for="(item,i) in detailData.xzGasAnalyzeList" :key="i">
											<view class="item-col" style="background-color: lightgray;"><text>{{item.gasAnalyzeTime||'暂无数据'}}</text></view>
											<view class="item-col"><text>{{item.representativeGas||'暂无数据'}}</text></view>
											<view class="item-col"><text>{{item.analyzeResult||'暂无数据'}}</text></view>
											<view class="item-col" style="margin-bottom: 5rpx;"><text>{{item.analyzer||'暂无数据'}}</text></view>
										</view>
									</scroll-view>
							</view> -->
							<view class="safe-mesure">
								<view class="safe-btn" @click="goSafeMesure">查看安全措施</view>
							</view>
							<view class="other-safe">
								<view class="other-head">
									<view class="other-icon"></view>
									<view class="other-text">安全技术交底</view>
								</view>
								<view class="other-content">
									<view class="content-1"><text style="float: right;">安全交底人：</text></view>
									<view class="content-2">{{detailData.safetyInformantName}}</view>
									<view class="content-3"><text style="float: right;">接受交底人：</text></view>
									<view class="content-4">{{detailData.acceptTheInformantName}}</view>
								</view>
								<view class="other-content">
									<view class="content-1"><text style="float: right;">监护人：</text></view>
									<view class="content-2">{{detailData.guardianName}}</view>
								</view>
							</view>
						</view>
						
						<view v-if="COMPANY != 'longguang'" class="more-btn" @click="isShow=!isShow">
							{{isShow ? "收起详情":"展开详情"}}
							<uni-icons :type="isShow ? 'arrowup':'arrowdown'"></uni-icons>
						</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>
					<!-- <view class="add-btn" v-if="activeIndex != 7 && activeIndex != 2 && !(activeIndex == 1 && detailData.engineeringState == 3) -->
					<view class="add-btn" v-if="activeIndex != 7
					&& COMPANY != 'longguang' && detailData.finalAcceptanceStatus !== 2 && isShowBtn"
					@click="addForm">
						<uni-icons v-if="activeIndex == 5" type="camera" size="30" color="#fff"></uni-icons>
						<uni-icons v-else type="plusempty" size="30" color="#fff"></uni-icons>
						<span>+</span>
					</view>
			</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'
	
	export default {
		components:{
			plan,
			safe,
			side,
			workFinally,
		},
		data(){
			return{
				statusBarHeight: 0,
				isShow: false,
				componentName: "plan",
				navList:[{
					id: 1,
					name: "当前进度"
				},{
					id: 2,
					name: "安全检查"
				},{
					id: 3,
					name: "施工旁站"
				},{
					id: 4,
					name: "最终验收"
				}],
				activeIndex: 1,
				detailId: "",
				detailData:{},
				isShowBtn: null,
			}
		},
		onReachBottom() {
			console.log(1,this.$refs['list'])
		},
		onPullDownRefresh() {
			console.log(2)
		},
		onShow(){
			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.detailId = val.id
		},
		mounted() {
		},
		methods:{
			getWork(){
				this.sendRequest({
					url:'xmgl/xzHoistSafetyWork/queryById',
					method:'get',
					data:{id:this.detailId},
					success:res=>{
						uni.hideLoading()
						// if(res.code==200){
						// 	this.listData = res.result.records
						// }
						this.detailData =  res.result
						// 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: 6
					},
					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"
				}
			},
			addForm(){
				if(this.activeIndex == 1){
					uni.navigateTo({
						url:'./addPlan?id='+this.detailId
					})
				} else if(this.activeIndex == 2){
					if(uni.getStorageSync('dangerData')){
						uni.removeStorageSync('dangerData');
					}
					if(uni.getStorageSync('detailData')){
						uni.removeStorageSync('detailData');
					}
					uni.navigateTo({
						// url:'../safeManage/addExamine?type=1&engineeringId='+this.detailId + '&moduleType=safeCheck'
						url:'../../safeSame/addIssue?type=6&engineeringId='+this.detailId + '&moduleType=safeCheck'
					})
				} else if(this.activeIndex == 3){
					uni.navigateTo({
						url:'./addSide?id='+this.detailId
					})
				} else if(this.activeIndex == 4){
					if(this.isShowBtn){
						uni.navigateTo({
							url:'./addWorkFinally?id='+this.detailId+'&workTicketCode='+this.detailData.workTicketCode
						})
					}else{
						uni.showToast({
							title: '请勿重复操作',
							icon: "none",
							duration: 2000
						});
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
.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;
		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: auto;
		// max-width: 100%;
		
		// width: 100rpx;
		// width: auto;
		font-size: 18rpx;
		// background-color: gainsboro;
		background-color: #fff;
		white-space: nowrap;
		.teble-item{
			display: inline-block;
			white-space: normal;
			// width: 24.8%;
			width: 220rpx;
			// line-height: 40rpx;
			// border: 1rpx solid black;
			// background-color: darkred;
			
			// margin-left: 5rpx;
			// margin-top: 5rpx;
			// padding: 3rpx;
			.item-col{
			padding: 3rpx;
			margin-top: 5rpx;
			margin-left: 5rpx;
				// margin: 0 5rpx;
				line-height: 50rpx;
				// min-height: 50rpx;
				// height: 50rpx;
				text-align: center;
				background-color: #F6F6F6;
			}
		}
	}
	.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;
	}
	.more-btn{
		text-align: center;
		font-size: 14px;
		height: 50rpx;
		background: #F1F7FE;
		line-height: 50rpx;
	}
	.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: 14px;
		}
		.active-nav{
			border-bottom: 2px solid #4396E7;
		}
	}
	.detail-nav{
		width: 100%;
	}
	.scrollx-wrap{
		width: 100%;
		background: #fff;
	}
	.add-btn{
		background: #4181FE;
		width: 96rpx;
		height: 96rpx;
		border-radius: 50%;
		text-align: center;
		line-height: 96rpx;
		position: fixed;
		bottom: 40rpx;
		right: 40rpx;
		span{
			font-size: 30px;
			    line-height: 45px;
			    color: #fff;
		}
	}
}
</style>
