<template>
	<view>		
		<view style="margin:10px 10px;" v-show="isShow">
			<button type="primary" style="border-radius: 5px;" class="mini-btn" size="mini" @click="modify">修改</button>
			<button type="primary" style="border-radius: 5px;" class="mini-btn" size="mini" @click="relationMaterial"  v-show="isMaterialShow">关联材料</button>
			<button type="primary" style="border-radius: 5px;margin-left:15px;" class="mini-btn" size="mini" @click="workFlow" v-show="isWorkFlow">流程审核</button>
		</view>
		<uni-list>
			<uni-list-item v-if="listData.entity">
				<view slot="body" class="slot-box">
					<view class="row">
						<view class="column-left">工程名称：</view>
						<view class="column-right">{{listData.entity.projectName}}</view>
					</view>
					<view class="row">
						<view class="column-left">编号：</view>
						<view class="column-right">{{listData.entity.checkCode}}</view>
					</view>
					<view class="row" v-if="$util.getQuery('type')=='2'">
						<view class="column-left">检查类型：</view>
						<view class="column-right">{{listData.entity.inspectType}}</view>
					</view>
					<view class="row">
						<view class="column-left">检查日期：</view>
						<view class="column-right">{{listData.entity.checkDateStr}}</view>
					</view>
					<view class="row">
						<view class="column-left">审核状态：</view>
						<view class="column-right">{{listData.entity.statusName}}</view>
					</view>
					
					<view class="row">
						<view class="column-left">附件：</view>
						<view class="column-right">
							<view v-for="(item,index) in listData.attachments" :key="index">								
								<a :href="'/api/common/ShowImg?code='+item.attachMentCode">{{item.fileName}}</a>
							</view>
						</view>
					</view>
				</view>
			</uni-list-item>
		</uni-list>
		 
		
		<uni-section title="检查项目明细"  type="line"></uni-section>
		<uni-list>
			<uni-list-item v-if="listData.list"  v-for="(item, index) in listData.list"  :key="index">
				<view slot="body" class="slot-box">
					<view class="row">
						<view class="column-left">检查项目：</view>
						<view class="column-right">{{item.checkContent}}</view>
					</view>
					<view class="row">
						<view class="column-left">检查结果：</view>
						<view class="column-right">{{item.checkResult}}</view>
					</view>
					<view class="row">
						<view class="column-left">关联材料：</view>
						<view class="column-right">{{item.checkResult}}</view>
					</view>
					</view> 
			</uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import {
		 GetSafeQualityCheckDTO
	} from "@/common/api/SafeQualityCheckApi.js";
	import {
		Decimal
	} from 'decimal.js';
	export default {
		data() {
			return {
				listData: {},
				isShow:false,        //是否显示修改按钮
				isMaterialShow:false,  //是否显示关联材料按钮
				isWorkFlow:false,    //是否显示流程审核按钮
				procedureName:""     //流程审批名
			}
		},
		onLoad() {
			//console.info("当前登录状态:" + this.$store.state.isLogin);
			//console.info(this);
			this.$util.persistLogin(this);
			let type=this.$util.getQuery("type")-0;
			if(type==1){
				uni.setNavigationBarTitle({
					title:'安全检查明细'
				});
			}
			else if(type==2){
				uni.setNavigationBarTitle({
					title:'材料检查明细'
				});
			}
			else{
				uni.setNavigationBarTitle({
					title:'质量检查明细'
				});
			}
		},
		created: function() {
			this.getDetail(this.$util.getQuery("id"));
		},
		mounted:function(){
			
		},
		methods: {
			getDetail(id) {
				let that = this;
				GetSafeQualityCheckDTO(id).then((res) => {
					console.info('GetSafeQualityCheckDTO',res);
					let type=this.$util.getQuery("type")-0;
					if(res.entity.status==0){
						that.isShow=true;
					}
					else{
						that.isShow=false;
					}
					if(res.entity.status==0&&type==2)
					{
						that.isMaterialShow=true;
					}
					else{
						that.isMaterialShow=false;
					}
					that.listData=res;
					
					that.procedureName=res.procedureName;
					/* 是否显示流程审核按钮 */
					if(!that.$util.isEmpty(that.procedureName)){
						if(res.entity.status==0){
							that.isWorkFlow=true;
						}
						else{
							that.isWorkFlow=false;
						}
						console.info('isWorkFlow',that.isWorkFlow);
					}
					 
					//console.info(that.listData);
				});
			},
			 
			 modify: function() { //跳转到修改页面
			 	let id = this.$util.getQuery("id");
			 	uni.navigateTo({
			 		url: '/pages/template/SafeQualityCheckEdit/SafeQualityCheckEdit?id=' + id
			 	});
			 },
			 /* 流程审核按钮点击事件处理 */
			 workFlow:function(){
			 	let url="../GetWorkFlowProcedureList/GetWorkFlowProcedureList?procedureName="+this.procedureName+"&applicationCode="+this.$util.getQuery("id");
			 	uni.navigateTo({    //跳转到流程控制列表页面
			 		url:url
			 	});
			 },
			 relationMaterial:function(){
				 let id = this.$util.getQuery("id");
				 uni.navigateTo({
				 	url: '/pages/template/GetRelationMaterialList/GetRelationMaterialList?id=' + id
				 });
			 }
		}
	}
</script>

<style>
  /deep/ .uni-section__content-title{
	  font-size:15px;
	  font-weight: 600;
  }
  
 /deep/ .uni-list-item{
	  background-color: #f8f8f8;
  }
  .slot-box{
	  background-color: #fff;
	  padding: 5px 8px;
  }
  .mini-btn{
	  margin-left:15px;
  }
</style>
