<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.firemanName}}</text>
						</view>
						<view class="list-info">
							动火方式：<text class="detail-data">{{detailData.hotMethod}}</text>
						</view>
						<view class="list-info">
							动火实施时间：<text class="detail-data">{{detailData.hotWorkExecutionBeginTime+'-'+detailData.hotWorkExecutionEndTime}}</text>
						</view>
						<view class="list-info">
							动火地点和动火部位：<text class="detail-data">{{detailData.fireLocationAndFirePart}}</text>
						</view>
						<view class="" v-if="isShow">
							<view class="list-info">
								作业内容：<text class="detail-data">{{detailData.jobContent}}</text>
							</view>
							<view class="list-info">
								作业单位：<text class="detail-data">{{detailData.operatingUnitName}}</text>
							</view>
							<view class="list-info">
								动火作业级别：<text class="detail-data">{{detailData.hotWorkLevel}}</text>
							</view>
							<view class="list-info">
								作业负责人：<text class="detail-data">{{detailData.assignmentPersonInChargeName}}</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.otherRelatedSpecialTask}}</text>
							</view>
							<view class="list-info">
								证书编号：<text class="detail-data">{{detailData.certificateNo}}</text>
							</view>
							<view class="list-info">
								安全作业票编号：<text class="detail-data">{{detailData.safetyWorkTicketCode}}</text>
							</view>
							<view class="list-info">
								风险辨识结果：<text class="detail-data">{{detailData.riskIdentificationResult}}</text>
							</view>
							<view class="table-info" style="">
								<uni-table emptyText="暂无更多数据" style="" class="uni-table-font">
									<uni-td style="font-size: 20rpx;background-color: #eaeaea;" align="center">
										<uni-tr style="">气体取样分析时间</uni-tr>
										<uni-tr>代表性气体</uni-tr>
										<uni-tr>分析结果/%</uni-tr>
									</uni-td>
									<uni-td style="font-size: 20rpx;" align="center" v-for="item in detailData.xzGasAnalyzeList" :key="item.id">
										<uni-tr style="">{{item.gasAnalyzeTime}}</uni-tr>
										<uni-tr>{{item.representativeGas}}</uni-tr>
										<uni-tr>{{item.analyzeResult}}</uni-tr>
									</uni-td>
								</uni-table>
							</view>
						</view>
						
						
						<!-- <view class="list-info">
							工程名称：<text class="detail-data">{{detailData.engineeringName}}</text>
						</view>
						<view class="list-info">
							工程类别：<text class="detail-data">{{detailData.engineeringTypeName}}</text>
						</view>
						<view v-show="isShow">
							<view class="list-info">
								工程概况：<text class="detail-data">{{detailData.engineeringSurvey ? detailData.engineeringSurvey : "无"}}</text>
							</view>
							<view class="list-info">
								类别描述：<text class="detail-data">{{detailData.describeName ? detailData.describeName : "无"}}</text>
							</view>
							<view class="list-info">
								施工部位：<text class="detail-data">{{detailData.constructionLocation ? detailData.constructionLocation : "无"}}</text>
							</view>
							<view class="list-info">
								计划时间：<text class="detail-data">{{detailData.planStartTime}}~{{detailData.planEndTime}}</text>
							</view>
							<view class="list-info">
								负责人：<text class="detail-data">{{detailData.personLiable ? detailData.personLiable : "无"}}</text>
							</view>
							<view class="list-info">
								责任分包：<text class="detail-data">{{detailData.responsibilityCompany ? detailData.responsibilityCompany : "无"}}</text>
							</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">
							<fireWorkPlan ref="listBox" v-if="componentName == 'fireWorkPlan'" :detailId="detailId" :info="detailData"></fireWorkPlan>
							<fireWorkSafe ref="list" v-if="componentName == 'fireWorkSafe'" :detailId="detailId" :info="detailData"></fireWorkSafe>
							<fireWorkSide ref="list" v-if="componentName == 'fireWorkSide'" :detailId="detailId" :info="detailData"></fireWorkSide>
							<fireWorkFinally ref="list" v-if="componentName =='fireWorkFinally'" :detailId="detailId" :info="detailData" ></fireWorkFinally>
						</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 fireWorkPlan from './fireWorkPlan.vue'
	import fireWorkSafe from './fireWorkSafe.vue'
	import fireWorkSide from './fireWorkSide.vue'
	import fireWorkFinally from './fireWorkFinally.vue'
	
	export default {
		components:{
			fireWorkPlan,
			fireWorkSafe,
			fireWorkSide,
			fireWorkFinally,
		},
		data(){
			return{
				statusBarHeight: 0,
				isShow: true,
				componentName: "fireWorkPlan",
				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.getFireWork()
			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
			// if(val.)
			// this.initData()
		},
		mounted() {
		},
		methods:{
			getFireWork(){
				this.sendRequest({
					url:'xmgl/xzSpecialOperationFireSafety/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;
						// }
						console.log("fireWork=======================",this.detailData)
						this.getApply()
					}
				})
			},
			initData(){
				this.sendRequest({
					url:'xmgl/dangerousEngineeringRecord/queryById',
					method:'post',
					data:{id:this.detailId,type:2},
					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;
						}
						console.log(this.detailData)
						this.getApply()
					}
				})
			},
			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:2
					},
					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 = "fireWorkPlan"
				} else if(val.id == 2){
					this.componentName = "fireWorkSafe"
				} else if(val.id == 3){
					this.componentName = "fireWorkSide"
				} else if(val.id == 4){
					this.componentName = "fireWorkFinally"
				}
			},
			addForm(){
				if(this.activeIndex == 1){
					uni.navigateTo({
						url:'./addFireWorkPlan?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=1&engineeringId='+this.detailId + '&moduleType=safeCheck&type=2'
					})
				} else if(this.activeIndex == 3){
					uni.navigateTo({
						url:'./addFireWorkSide?id='+this.detailId
					})
				} else if(this.activeIndex == 4){
					if(this.isShowBtn){
						uni.navigateTo({
							url:'./addFireWorkFinally?id='+this.detailId+'&name='+this.detailData.engineeringName
						})
					}else{
						uni.showToast({
							title: '请勿重复操作',
							icon: "none",
							duration: 2000
						});
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
.table-info{
	display: flex;
	justify-content: center;
	align-items: center;
	background-color: #fff;
	.uni-table-font{
		margin: 0 10rpx;
		// width: 95%;
		box-shadow: 0rpx 0rpx 0rpx 2rpx darkgray;
		uni-td{
			border: 1rpx solid lightgray;
		}
	}
}
.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: 14px;
		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>
