<template>
	<view class="wrap">
<!-- 		<uni-list>
			<uni-list-item title="隐患编码" :rightText="baseInfo.dangerCode" ></uni-list-item>
			<uni-list-item title="隐患状态" :rightText="dangerStatus(baseInfo.status)" ></uni-list-item>
			<uni-list-item title="隐患类别" :rightText="baseInfo.dangerCatTitle" ></uni-list-item>
			<uni-list-item title="隐患等级" :rightText="baseInfo.dangerLevel===1?'一般':'重大'" ></uni-list-item>
			<uni-list-item title="所在位置" :rightText="baseInfo.dangerLocation" v-if="baseInfo.dangerLocation"></uni-list-item>
			<uni-list-item title="描述" :rightText="baseInfo.dangerDesc" ></uni-list-item>
			<uni-list-item title="所在部门" :rightText="baseInfo.curGroupName" v-if="baseInfo.curGroupName"></uni-list-item>
			<uni-list-item title="整改人员" :rightText="baseInfo.curAccountName"  v-if="baseInfo.curAccountName"></uni-list-item>
			<uni-list-item title="所在部门" :rightText="baseInfo.submitGroupName" v-if="baseInfo.submitGroupName"></uni-list-item>
			<uni-list-item title="整改人员" :rightText="baseInfo.submitAccountName"  v-if="baseInfo.submitAccountName"></uni-list-item>
			<uni-list-item title="所在部门" :rightText="baseInfo.rectifyGroupName" v-if="baseInfo.rectifyGroupName"></uni-list-item>
			<uni-list-item title="整改人员" :rightText="baseInfo.rectifyAccountName"  v-if="baseInfo.rectifyAccountName"></uni-list-item>
			<uni-list-item title="整改措施" :rightText="baseInfo.rectifyMeasure" v-if="baseInfo.rectifyMeasure"></uni-list-item>
			<uni-list-item title="整改说明" :rightText="baseInfo.rectifyRemark" v-if="baseInfo.rectifyRemark"></uni-list-item>	
		</uni-list>	 -->
		<view class="head">
			<view class="title">{{baseInfo.dangerTitle}}</view>
			<view class="desc">
				<text class="level">{{baseInfo.dangerLevel===1?'一般':'重大'}}</text>
				<text class="code">{{baseInfo.dangerCode}}</text>
			</view>			
		</view>
		<view class="flowlist">
			<view class="flow-item-wrap" v-for="(flow,index) in flows" :key="index">
				<view class="submit-item" v-if="index===0">					
					<view class="item-row">
						<view class="item-row-lable">提交人</view>
						<view class="item-row-cont">{{flow.accountName}}</view>	
					</view>
					<view class="item-row">
						<view class="item-row-lable">所属部门</view>
						<view class="item-row-cont">{{flow.groupName}}</view>	
					</view>
					<view class="item-row">
						<view class="item-row-lable">整改期限</view>
						<view class="item-row-cont">{{baseInfo.dangerDeadLine}}</view>	
					</view>
				</view>
				<view class="flow-item" v-else>
					<view class="flow-head">{{flow.activityInsTitle}}</view>
					<view class="flow-desc">						
						<view class="user">
							<text>{{flow.positionName}}</text>
							<text>{{flow.accountName}}</text>
						</view>
						<view class="time">
							<text>{{flow.actionTime}}</text>
						</view>						
					</view>	
					<view class="remark">
						<view class="flow-title">处理说明</view>
						<view class="remark-cont">{{flow.actionRemark}}</view>
					</view>
					<view class="attachList" v-if="flow.attachList&&flow.attachList.length>0">
						<view class="flow-title">附件</view>
						<view class="attachList-cont">
							<view class="attachbox"  v-for="(attach,attachIdex) in flow.attachList" :key="attachIdex" @click="showImg(attachIdex,flow.attachList)">
								<image class="attach" :src="attach.fileUrl"></image>
							</view>									
						</view>				
					</view>
				</view>				
			</view>			
		</view>
		<view class="submit_bt" @click="onSubmit" v-if="visable">处理</view>
	</view>
</template>

<script>
	import {getWorkflowRecordById} from '@/api/system/wfApi.js'
	export default{
		data(){
			return{
				baseInfo:{},
				user:{},
				flows:[],
				visable:false
			}
		},
		onLoad() {
			let info=uni.getStorageSync('detail-info')
			let accountInfo=uni.getStorageSync('accountInfo')
			this.baseInfo=info
			this.getWorkflowRecord()			
			this.user=accountInfo
			this.visable=(accountInfo.userId===info.curAccountId)&&(info.status===1||info.status===2||info.status===3);
		},
		methods:{
			getWorkflowRecord(){
				getWorkflowRecordById(this.baseInfo.dangerId).then((res)=>{				
					this.flows=res.data
				})	
			},
			showImg(current,attachList){
				let urls=attachList.map(item=>{
					return item.fileUrl
				})
				uni.previewImage({
					urls,
					current
				})
			},
			dangerStatus(i) {
			  if (i >= 0) {
			    const strs = ['待提交','待评审','待整改','待验收','已完成']
			    return strs[i]
			  } else {
			    return '已撤销'
			  }
			},
			handle(){
				uni.navigateTo({
					url:'/pages/app_views/danger/handle/handle'
				})
			},
			isEmpty(val){
				if(val!=="undefined"&&val!==undefined&&val!==""&&val!==null){
					return false
				}
				return true
			}			
		}
	}
</script>

<style  lang="scss" scoped>
.wrap{	
	padding:20rpx;
	background-color: #F5F6F8;
	min-height: 100vh;
	box-sizing: border-box;
	.head{
		padding: 20rpx 32rpx 40rpx 32rpx;
		.title{
			font-family: Abhaya Libre;
			font-size: 36rpx;
			font-weight: 700;
			line-height: 54rpx;
			text-align: justified;	
			color: #212121;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
		}
		.desc{
			padding-top: 8rpx;
			.level,.code{
				font-family: PingFang SC;
				font-size: 14px;
				font-weight: 400;
				line-height: 22px;
				text-align: justified;
				color: #666;
			}
			.code{
				padding-left: 40rpx;						
			}
		}		
	}		
	.flowlist{	
		.flow-item-wrap{
			.submit-item{
				padding: 20rpx 32rpx;
				border-radius: 32rpx 32rpx 0px 0px;
				background-color: #fff;
				.item-row{
					padding: 20rpx 0;
					border-bottom: 1rpx solid #EFF1F3;
					&:last-child{
						border: 0;
					}
					.item-row-lable{
						font-family: Abhaya Libre;
						font-size: 28rpx;
						font-weight: 400;
						line-height: 1;
						color: #999;
					}
					.item-row-cont{
						font-family: Abhaya Libre;
						font-size: 30rpx;
						font-weight: 400;
						line-height: 1;
						color: #212121;
						padding-top: 24rpx;
					}
				}
			}
			.flow-item{
				margin-top: 20rpx;
				padding: 0 32rpx 20rpx 32rpx;
				background-color: #fff;
				.flow-head{
					font-family: Abhaya Libre;
					font-size: 34rpx;
					font-weight: 700;
					line-height: 1;
					color: #212121;
					padding: 32rpx 0;
				}
				.flow-title{
					font-family: SF Pro Text;
					font-size: 30rpx;
					font-weight: 700;
					line-height: 1;
					padding: 24rpx 0;
					color: #666666;
				}
				.flow-desc{
					padding: 24rpx 0;
					display: flex;
					justify-content: space-between;
					align-items: center;
					.user,.time{
						font-family: SF Pro Text;
						font-size: 24rpx;
						font-weight: 400;
						line-height: 24rpx;	
						color: #999999;
					}
				}
				.remark{				
					.remark-cont{
						padding-bottom: 30rpx;							
						border-bottom: 1rpx solid #F0F4F6;	
						font-family: SF Pro Text;
						font-size: 30rpx;
						font-weight: 500;
						line-height: 42rpx;
						color: #434343;
					}
				}
				.attachList{
					.attachList-cont{
						display: flex;
						flex-wrap: wrap;
						.attachbox{
							display: block;
							width: 224rpx;
							height: 224rpx;
							border-radius: 8px;
							overflow: hidden;
							&:nth-child(2n){
								margin: 0 8rpx;
							}
							&:nth-child(n+4){
								margin-top: 24rpx;
							}
							.attach{
								display: block;
								width: 224rpx;
								height: 224rpx;
								border-radius: 8px;
							}
						}
					}
				}
			}
		}
	}
	.submit_bt{
		width: 750rpx;
		height:88rpx;
		line-height:88rpx;
		color: #4D73FF;
		text-align: center;
		font-size: 32rpx;
		padding-bottom: 68rpx;
		background-color: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 99;
		box-shadow: 0px 0px 12px 0px #0000000A;
		border-radius: 8px 8px 0px 0px
	}
}
</style>