<!-- 安全检查-开展检查 -->
<template>
  <view class="examine">
	<scroll-view scroll-y @scrolltolower="scrollGet" class="info-max-box">
		<view class="basics">
			<view class="basics_li">
				<view class="basics_li_l">实验室</view>
				<view class="basics_li_r lab_r" :class="addDisabledType?'addDisabled':''">
					<input class="picker-text" @click="popupClick(1)" type="text" disabled v-model="form.subjectName"
					placeholder="请选择实验室" placeholder-style="font-size: 30rpx;color:#333;">
					<view class="img-box" @click.stop="saoCode" v-if="!addDisabledType">
						<img src="@/pages_safetyExamine/images/icon_aqjc_sm.png">
					</view>
				</view>
			</view>
			<view class="basics_li">
				<view class="basics_li_l">学院</view>
				<picker disabled @change="collegeChange" :value="collegeIndex" :range="collegeArray" class="scope_r">
					<view class="basics_li_r college_r" style="background-color: #F5F5F5 ;">
						<view>{{form.collegeName?form.collegeName:'未选择实验室'}}</view>
						<img src="@/pages_safetyExamine/images/icon_06.png">
					</view>
				</picker>
			</view>
			<view class="basics_li">
				<view class="basics_li_l">楼栋</view>
				<picker @change="buildingChange" disabled="" :value="collegeIndex" :range="buildingArray" class="scope_r">
					<view class="basics_li_r college_r" style="background-color: #F5F5F5 ;">
						<view>{{form.buildName?form.buildName:'未选择实验室'}}</view>
						<img src="@/pages_safetyExamine/images/icon_06.png">
					</view>
				</picker>
			</view>
			<view class="basics_li">
				<view class="basics_li_l">计划标题</view>
				<picker v-if="isCustom" @change="planChange" :disabled='addDisabledType' :value="planIndex" :range="planArray" class="scope_r">
					<view class="basics_li_r college_r" :class="addDisabledType?'addDisabled':''">
						<view>{{form.title?form.title:'选择计划标题'}}</view>
						<img src="@/pages_safetyExamine/images/icon_06.png">
					</view>
				</picker>
				<view v-if="!isCustom" class="basics_li_r college_r">
				   <input type="text" v-model="form.title" maxlength="30" placeholder="输入计划标题">
				</view>
			</view>
			<view class="basics_li" style="justify-content: flex-end;" v-if='planArray[0]&&!addDisabledType'>
				<view class="custom"  @click="customFun">{{isCustom?'自定义输入':'选择计划'}}</view>
			</view>

			<view class="basics_li">
				<view class="basics_li_l">检查组织</view>
				<picker @change="categoryChange" :value="categoryIndex" disabled :range="categoryArray" class="scope_r">
					<view class="basics_li_r college_r" style="background-color: #F5F5F5 ;">
						<view>{{form.checkType?(form.checkType==1?'校院巡查':'实验室自查'):'选择检查组织'}}</view>
						<img src="@/pages_safetyExamine/images/icon_06.png">
					</view>
				</picker>
			</view>
			<view class="basics_li">
				<view class="basics_li_l">检查类型</view>
				<picker @change="specialChange" :value="specialIndex" :range="specialArray" :disabled="isCustom" class="scope_r">
					<view class="basics_li_r college_r" :class="isCustom?'addDisabled':''">
						<view>{{form.checkCategory?(form.checkCategory==1?'综合检查':'专项检查'):'选择检查类型'}}</view>
						<img src="@/pages_safetyExamine/images/icon_06.png">
					</view>
				</picker>
			</view>
			<view class="period">
				<view class="period_l">计划周期</view>
				<view class="period_r" :class="isCustom?'addDisabled':''">
					<picker mode="date" @change="startChange(form,$event)" :disabled="isCustom">
						<input class="picker-text"  disabled type="text" v-model="form.cycleStartTime" placeholder="开始时间">
					</picker>
					<view>至</view>
					<picker mode="date"  @change="endChange(form,$event)" :disabled="isCustom">
						<input class="picker-text2" disabled type="text" v-model="form.cycleEndTime" placeholder="结束时间">
					</picker>
				</view>
			</view>

		</view>
		<view class="attachment" v-if="form.isAttachment==1">
			<view class="attachment_t">
				<text>材料附件</text>
				<text>点击文件标题查看</text>
			</view>
			<view class="attachment_li" v-for="item in attachmentList">
				<img src="@/pages_safetyExamine/images/icon_djc_wj.png"/>
				<text  @click="attachmentPreview(item)">{{item.fileName}}</text>
			</view>
		</view>
		<view class="inspect" v-if='form.checkCategory==1 || (form.checkResult==0 || form.checkCategory==2)'>
			<view class="inspect_li" v-if='form.checkCategory==1'>
				<view class="inspect_li_l">检查结果</view>
				<picker @change="resultChange" :value="resultIndex" :range="resultArray" class="scope_r">
					<view class="inspect_li_r college_r">
						<view>{{form.checkResult==1?'符合':'不符合'}}</view>
						<img src="@/pages_safetyExamine/images/icon_06.png">
					</view>
				</picker>
			</view>
			<view class="inspect_li" v-if="form.checkResult==0 || form.checkCategory==2">
				<view class="inspect_li_l">整改日期</view>
				<picker mode="date" @change="rectifyDeadline(form,$event)" :start="currentDate">
					<view class="inspect_li_r date_r">
						<input disabled class="picker-text" type="text" v-model="form.rectifyDeadline" placeholder="请选择日期" placeholder-style="font-size: 30rpx;color:#333;">
						<img src="@/pages_safetyExamine/images/icon_rl.png">
					</view>
				</picker>
			</view>
			<view class="inspect_li" v-if="form.checkResult==0 || form.checkCategory==2">
				<view class="inspect_li_l">整改通知</view>
				<view class="inform_r">
					<view v-for="(item,index) in informArray" :key="index" @click="tabClick(index)"><text :class="informIndex==index?'checked':'inform_r_l' "></text><text class="inform_r_r">{{item}}</text></view>
				</view>
			</view>
		</view>
	</scroll-view>
	<!-- 房间选择弹出层 -->
	<view class="popup-max-box" v-if="popupType">
		<view class="popup-null" @click="popupClick(2)"></view>
		<view class="popup-big-box">
			<view class="popup-input-box">
				<input type="text" maxlength="10" v-model="room" placeholder="请输入关键字">
				<view @click="buildBySub">搜索</view>
			</view>
			<view class="popup-for-max-box">
				<view class="popup-for-null" v-if="!roomList[0]">暂无数据</view>
				<view class="popup-for-box" v-for="(item,index) in roomList" :key="index">
					<view class="name-p">{{item.name}}</view>
					<view class="button-p" @click="popupClickItem(item)">确定</view>
				</view>
			</view>
		</view>
	</view>
	<!-- 检查名称弹窗 -->
	<uni-popup ref="popup" class="inspect_name" type="bottom">
		<view class="popup-content">
			<view class="inspect_name_t">
				<input type="text" v-model="customTitle" maxlength="30" placeholder="请输入计划标题"/>
			</view>
			<view class="inspect_name_b">
				<text @click="titleCancel()">取消</text>
				<text @click="titleConfirm()">确定</text>
			</view>
		</view>
	</uni-popup>
	<view class="bottom_btn" @click="handleClick('nextStep')" v-if="form.checkResult==0 || form.checkCategory==2">下一步</view>
	<view class="bottom_btn" @click="handleClick('submitForm')" v-if="form.checkResult==1 && form.checkCategory==1">提交</view>
  </view>

</template>

<script>
import { config } from '@/api/request/config.js'
import { buildBySub,listDepartments,
subjectList,getCheckPlanBySubId,
checkManageUpdate,checkManageAdd,
findCheckManage,buildFloorGetlist,
buildBySubList,findByPlanIdAttachment,subjectFindSubjectInfo} from '@/api/index.js'
export default {
  name: "rectifyList",
  components: {

  },
  data() {
    return {
		pageType:0,
		//列表请求参数
		getData:{
		 pageNum:1,
		 pageSize:20,
		},
		customTitle:'',
		attachmentList:[],//材料附件
		form:{
			id:'',
			checkPlanId:'',
			manageStatus:'',//保存1  提交2
			subIds:'',//实验室
			subjectName:'',
			title:'',//计划标题
			deptId:'',//学院
			collegeName:'',
			buildId:'',//楼栋
			buildName:'',
			roomNumber:'',//房间号
			checkType:2,// 检查组织(1校院巡查 2实验室自查)
			checkResult:1,// 检查结果 0不符合 1符合
			rectifyDeadline:'',//整改期限
			rectifyNotice:'1',//整改通知(1整改告知书 2整改通知书)
			cycleStartTime:'',
			cycleEndTime:'',
            checkCategory:'',//检查类型  1综合检查  2专项检查
			checkHazardDtoList:[
				{
					voiceRemark:[],//语音备忘存储
					hazardLevel:2,//隐患等级
					hazardLevelName:'一般隐患',//隐患等级
					hazardCheckCode:'', //检查项目code序号
					hazardCheckName:'', //检查项目名称
					hazardCheckPro:'', //最后一级的id
					hazardCheckPoint:'',// 检查要点
					hazardDescribe:'', //隐患描述
					uploadDtoList:[],//隐患照片
				}
			],
			checkHazardInfoVoList:[],
		},
		collegeIndex :0,
		collegeArray:[],
		categoryIndex :0,
		categoryArray:['校院巡查','实验室自查'],
		planIndex :0,
		specialIndex:0,
		specialArray:['综合检查','专项检查'],
		planArray:[],
		planList:[],
		resultIndex :0,
		resultArray:['符合','不符合'],
		informIndex:0,
		informArray:['整改告知书','整改通知书'],


		//房间弹层 状态
		popupType:false,
		//房间搜索字段
		room:"",
		roomList:[],
		item:{},
		isCustom:false,
		buildingArray:[],
		buildingList:[],
		//扫一扫进入
		laboratoryList:[],
		currentDate:'',//当前日期
		//
		addDisabledType:false
	}
  },
  onLoad(option) {
	  //通过微信扫一扫进入
	  if(option.q){
		console.log('外部扫一扫')
	    let text = decodeURIComponent(option.q)
	    let codeId = "";
	    let newList = text.split("?")[1].split("&")
	    let list = newList[0].split("=")[1].split("-")
	    codeId = list[0];
		uni.showToast({
			title: codeId,
			icon:"none",
			mask:true,
			duration: 2000
		});
		this.form.subIds=codeId
		this.getCheckPlanBySubId(codeId)
		this.getByIdLaboratoryList();
	  }
	 if(option.id){
		console.log('开始/编辑')
	 	this.findCheckManage('add',option.id)
	 }
	 if(option.form){
		console.log('子页面返回')
		 this.form=JSON.parse(decodeURIComponent(option.form));
		 this.isCustom=this.form.isCustom;
		 if(this.form.isAttachment==1){//0没有附件 1有附件
		 	this.findByPlanIdAttachment()
		 }
	 }
	 //通过实验室id查询计划
	 if(option.subId){
		console.log('内部扫一扫')
		this.form.subIds=option.subId
	 	this.getCheckPlanBySubId(option.subId)
		this.getByIdLaboratoryList();
	 }

  },
  onShow() {
	  this.buildFloorGetlist()
  },
  mounted(){
		//获取当前日期
		this.currentDate = this.getNowFormatDate()
		this.listDepartments();

  },
  methods: {
		//滚动事件
		scrollGet(){},
		
		
	    handleClick(doType){
		  let self=this;
		  if(!this.form.subIds){
			uni.showToast({
				title: '请选择实验室!',
				icon:"none",
				mask:true,
				duration: 2000
			});
			return
		  }
		  if(!this.form.deptId){
			uni.showToast({
				title: '请选择学院!',
				icon:"none",
				mask:true,
				duration: 2000
			});
			return
		  }
		  if(!this.form.buildId){
			uni.showToast({
				title: '请选择楼栋!',
				icon:"none",
				mask:true,
				duration: 2000
			});
			return
		  }
		  if(!this.form.title){
			  if(!this.isCustom){
				  uni.showToast({
				  	title: '请输入计划标题!',
				  	icon:"none",
				  	mask:true,
				  	duration: 2000
				  });
			  }else{
				  uni.showToast({
				  	title: '请选择计划标题!',
				  	icon:"none",
				  	mask:true,
				  	duration: 2000
				  });
			  }

			return
		  }
		  if(!this.form.cycleStartTime || !this.form.cycleEndTime){
			uni.showToast({
				title: '请选择计划周期!',
				icon:"none",
				mask:true,
				duration: 2000
			});
			return
		  }
		  if(this.currentDate<this.form.cycleStartTime){
		  	uni.showToast({
		  		title: '当前时间不在计划周期内',
		  		icon:"none",
		  		mask:true,
		  		duration: 2000
		  	});
		  	return
		  }
		  if( doType=='nextStep'){//下一步
		   // 打开扫描页面
		   if(!this.form.rectifyDeadline){
				  uni.showToast({
					title: '整改日期不能为空!',
					icon:"none",
					mask:true,
					duration: 2000
				  });
				  return
		   }
		   this.form.isCustom=this.isCustom;
		   if(this.form.checkCategory==1){//综合检查
			   
			   uni.navigateTo({
			   		url: '/pages_safetyExamine/examineManage/examineAddTow?form='+encodeURIComponent(JSON.stringify(this.form))
			   });
		   }else if(this.form.checkCategory==2){//专项检查
				if(this.form.checkHazardInfoVoList[0]){
					uni.navigateTo({
							url: '/pages_safetyExamine/examineManage/examineAddTow?form='+encodeURIComponent(JSON.stringify(this.form))
					});
				}else{
					uni.redirectTo({
							url: '/pages/saoCode/scan?form='+encodeURIComponent(JSON.stringify(this.form))
					});
				}
			   
		   }
			  
		  }else if(doType=='submitForm'){
			  self.submitForm()
		  }

	    },
		customFun(){
			let self=this;
			if(!self.isCustom){//自定义
				self.form.title='';
				self.form.id='';
				self.form.checkType='';
				self.form.cycleStartTime='';
				self.form.cycleEndTime='';
				self.isCustom=!self.isCustom
			}else{//选择计划
				
			    this.$set(this.form,'isAttachment',0);
			    this.$set(this,'customTitle','');
				self.form.checkHazardInfoVoList=[];
				self.$refs.popup.open()
			}
		},
		titleCancel(){
			let self=this;
			self.$refs.popup.close()
		},
		titleConfirm(){
			let self=this;
			self.isCustom=!self.isCustom
			this.$set(this.form,'title',this.customTitle);
			this.$set(this.form,'id','');
			this.$set(this.form,'checkType',2);
			this.$set(this.form,'checkResult',1);
			this.$set(this.form,'rectifyDeadline','');
			this.$set(this,'informIndex',0);
			this.$set(this.form,'cycleStartTime','');
			this.$set(this.form,'cycleEndTime','');
			this.$set(this.form,'checkHazardDtoList',[{
					voiceRemark:[],//语音备忘存储
					hazardLevel:2,//隐患等级
					hazardLevelName:'一般隐患',//隐患等级
					hazardCheckCode:'', //检查项目code序号
					hazardCheckName:'', //检查项目名称
					hazardCheckPro:'', //最后一级的id
					hazardCheckPoint:'',// 检查要点
					hazardDescribe:'', //隐患描述
					uploadDtoList:[],//隐患照片
				}]);
			self.$refs.popup.close()
		},
		//开始时间选中事件
		startChange(form,e){
			if(new Date(e.target.value).getTime()>new Date(form.cycleEndTime).getTime()){
				 uni.showToast({
					title: '结束时间不能小于开始时间',
					icon:"none",
					mask:true,
					duration: 2000
				});
			}else{
				form.cycleStartTime=e.target.value
			}
		},
		//结束时间选中事件
		endChange(form,e){
			if(new Date(form.cycleStartTime).getTime()>new Date(e.target.value).getTime()){
				 uni.showToast({
					title: '结束时间不能小于开始时间',
					icon:"none",
					mask:true,
					duration: 2000
				});
			}else{
				form.cycleEndTime=e.target.value
			}
		},
		//获取当前日期函数
		getNowFormatDate() {
		  let date = new Date(),
		    year = date.getFullYear(), //获取完整的年份(4位)
		    month = date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
		    strDate = date.getDate() // 获取当前日(1-31)
		  if (month < 10) month = `0${month}` // 如果月份是个位数，在前面补0
		  if (strDate < 10) strDate = `0${strDate}` // 如果日是个位数，在前面补0

		  return `${year}-${month}-${strDate}`
		},
		//根据计划id查询附件列表
		async findByPlanIdAttachment(){
			let _this = this;
			const {data} = await findByPlanIdAttachment({checkPlanId:this.form.checkPlanId});
			if(data.code == 200){
				_this.attachmentList=data.data;
			}
		},
		//详情
		async findCheckManage(type,id){
			let _this = this;
			const {data} = await findCheckManage({id:id});
			if(data.code == 200){
				
				if(type == 'add'){
					if(data.data.checkPlanId){
					  this.$set(this,'isCustom',true);
					}
					
					this.$set(this,'addDisabledType',true);
				}
				this.$set(this,'form',data.data);
				this.$set(this.form,'subIds',data.data.subId);
				this.form.rectifyNotice=data.data.rectifyNotice==null?'1':data.data.rectifyNotice;
				this.informIndex=this.form.rectifyNotice==1?0:1;
				if(data.data.checkCategory==1){//综合检查
					this.form.checkResult=data.data.checkResult==null?'1':data.data.checkResult;
					if(data.data.checkHazardDtoList[0]){//隐患项
						this.form.checkHazardDtoList=data.data.checkHazardDtoList;
						//语音备注
						for(let i=0;i<this.form.checkHazardDtoList.length;i++){
							if(this.form.checkHazardDtoList[i].voiceRemark){
								this.form.checkHazardDtoList[i].voiceRemark=JSON.parse(this.form.checkHazardDtoList[i].voiceRemark)
							}else{
								this.form.checkHazardDtoList[i].voiceRemark=[];
							}
						}
					}
				}else if(data.data.checkCategory==2){//专项检查
					if(_this.form.checkHazardInfoVoList[0]){
					  _this.form.checkHazardInfoVoList.forEach(function(item) {
						item.switch = true;
						// item.checkHazardDtoList.forEach(function(item2) {
						//   item2.hazardCheckCode=item2.code
						// })
					  })
					}
					if(_this.form.checkHazardInfoVoList[0]){//隐患项
						//语音备注
						for(let k=0;k<_this.form.checkHazardInfoVoList.length;k++){
							
							for(let i=0;i<_this.form.checkHazardInfoVoList[k].checkHazardDtoList.length;i++){
								if(_this.form.checkHazardInfoVoList[k].checkHazardDtoList[i].voiceRemark){
									_this.form.checkHazardInfoVoList[k].checkHazardDtoList[i].voiceRemark=JSON.parse(_this.form.checkHazardInfoVoList[k].checkHazardDtoList[i].voiceRemark)
								}else{
									_this.form.checkHazardInfoVoList[k].checkHazardDtoList[i].voiceRemark=[];
								}
							}
						}
						
					}
				}
				//根据实验室id查询实验室计划
				if(data.data.subId){
					this.form.cycleStartTime=data.data.cycleStartTime;
					this.form.cycleEndTime=data.data.cycleEndTime;
				}
				if(data.data.isAttachment==1){//0没有附件 1有附件
					this.findByPlanIdAttachment()
				}
			}
		},
		//查询学院列表
		async listDepartments(){
			let _this = this;
			const {data} = await listDepartments();
			if(data.code == 200){

				for(let i=0;i<data.data.length;i++){
					_this.collegeArray.push(data.data[i].deptName)
				}
				_this.collegeList=data.data;
			}
		},
		//根据实验室id查询该实验室有关计划
		async getCheckPlanBySubId(subId){
			let _this = this;
			const {data} = await getCheckPlanBySubId({'subId':subId});
			if(data.code == 200){
				if(data.data.length>0){
					let titleList = [];
					let list = [];
					for(let i=0;i<data.data.length;i++){
						if(data.data[i].isSelfData==1){
							titleList.push(data.data[i].title)
							list.push(data.data[i]);
						}
					}
					this.$set(this.form,'id','');
					this.$set(this.form,'title','');
					this.$set(this,'planArray',titleList);
					this.$set(this,'planList',list);
					_this.isCustom=true;
					_this.form.checkType=null;
				}else{
					_this.isCustom=false;
					_this.form.checkType=2;
				}
			}
		},

		//查询楼栋
		async buildFloorGetlist(){
			let _this = this;
			const {data} = await buildFloorGetlist({type:2});
			if(data.code == 200){
				let idList = [];
				let nameList = [];
				for(let i=0;i<data.rows.length;i++){
					idList.push(data.rows[i].id)
					nameList.push(data.rows[i].name)
				}
				this.$set(this,"buildingList",idList)
				this.$set(this,"buildingArray",nameList)
			}
		},
		//楼栋选中
		buildingChange(e){
			this.form.buildId=this.buildingList[e.target.value]
			this.form.buildName=this.buildingArray[e.target.value]
			this.buildBySubList(this.buildingList[e.target.value]);
		},
		//根据楼栋ID查询实验室列表
		async buildBySubList(buildId){
			let self = this;
			const {data} = await buildBySubList({buildId:buildId});
			if(data.code == 200){
				this.$set(this.form,'subIds','')
				this.$set(this.form,'subjectName','')
				this.$set(this,'room','')
				this.$set(this,'roomList',data.data);
			}
		},
		//学院选中
		collegeChange(e){
			this.collegeIndex = e.target.value;
			 this.form.deptId=this.collegeList[e.target.value].deptId
			 this.form.collegeName=this.collegeList[e.target.value].deptName
			 this.buildFloorGetlist(this.form.deptId)
		},
		//检查组织
		categoryChange(e){
			this.categoryIndex = e.target.value;
			if(e.target.value==0){
				this.form.checkType=1
			}else if(e.target.value==1){
				this.form.checkType=2
			}
		},
		//检查类型
		specialChange(e){
			this.specialIndex = e.target.value;
			if(e.target.value==0){
				this.form.checkCategory=1
			}else if(e.target.value==1){
				this.form.checkCategory=2
			}
		},
		//计划
		planChange(e){
			this.planIndex = e.target.value;
			this.form.id=this.planList[e.target.value].id
			this.findCheckManage('check',this.planList[e.target.value].id);
			// this.form.title=this.planList[e.target.value].title
			// this.form.checkPlanId=this.planList[e.target.value].checkPlanId

			// this.form.subIds=this.planList[e.target.value].subId;
			// this.form.subjectName=this.planList[e.target.value].subjectName;
			// this.form.deptId=this.planList[e.target.value].deptId;
			// this.form.collegeName=this.planList[e.target.value].collegeName;
			// this.form.buildId=this.planList[e.target.value].buildId;
			// this.form.buildName=this.planList[e.target.value].buildName;
			// this.form.checkType=this.planList[e.target.value].checkType;
			// this.form.cycleStartTime=this.planList[e.target.value].cycleStartTime;
			// this.form.cycleEndTime=this.planList[e.target.value].cycleEndTime;




		},
		resultChange(e){
			this.resultIndex = e.target.value;
			if(e.target.value==0){
				this.form.checkResult=1;
			}else if(e.target.value==1){
				this.form.checkResult=0;
			}

		},
		//开始时间选中事件
		rectifyDeadline(form,e){
			form.rectifyDeadline=e.target.value

		},
		//整改通知
		tabClick(index) {
			this.informIndex = index;
			if(index==0){
				this.form.rectifyNotice='1';
			}else if(index==1){
				this.form.rectifyNotice='2';
			}

		},
		//搜索房间弹层开关
		popupClick(type){
			if(type == 1){
				if(this.addDisabledType){
					return
				}
				this.popupType = true;
			}else if(type == 2){
				this.popupType = false;
			}
		},
		//扫一扫进入通过id查询实验室列表
		async getByIdLaboratoryList(){
			let self = this;
			const {data} = await subjectFindSubjectInfo({subIds:this.form.subIds});
			if(data.code==200){
				if(data.data){
					self.form.subjectName=data.data.subjectName;
					self.form.deptId=data.data.deptId;
					self.form.collegeName=data.data.collegeName;
					self.form.buildId=data.data.buildId;
					self.form.buildName=data.data.buildName;
					self.form.roomNumber=data.data.roomNumber;
				}
			}
		},
		//搜索房间接口
		async buildBySub(){
			let self = this;
			if(!this.room){
				uni.showToast({
					title: '请输入要搜索关键词',
					icon:"none",
					mask:true,
					duration: 2000
				});
				return
			}
			const {data} = await buildBySub({'searchValue':this.room});
			if(data.code==200){
				if(data.data[0]){
					this.roomList = data.data;
				}else{
					uni.showToast({
						title: '未找到相关实验室',
						icon:"none",
						mask:true,
						duration: 2000
					});
				}
			}
		},
		//确认搜索房间
		popupClickItem(item){
			this.$set(this.form,"subIds",item.id)
			this.$set(this.form,"subjectName",item.name)
			this.$set(this.form,"deptId",item.deptId)
			this.$set(this.form,"buildId",item.buildId)
			this.$set(this.form,"roomNumber",item.room)
			this.$set(this.form,'title','');
			this.$set(this.form,'id','');
			this.$set(this.form,'checkType',2);
			this.$set(this.form,'checkResult',1);
			this.$set(this.form,'rectifyDeadline','');
			this.$set(this,'informIndex',0);
			this.$set(this.form,'cycleStartTime','');
			this.$set(this.form,'cycleEndTime','');
			this.$set(this.form,'checkHazardDtoList',[{
					voiceRemark:[],//语音备忘存储
					hazardLevel:2,//隐患等级
					hazardLevelName:'一般隐患',//隐患等级
					hazardCheckCode:'', //检查项目code序号
					hazardCheckName:'', //检查项目名称
					hazardCheckPro:'', //最后一级的id
					hazardCheckPoint:'',// 检查要点
					hazardDescribe:'', //隐患描述
					uploadDtoList:[],//隐患照片
				}]);
			//匹配学院名称
			for(let i=0;i<this.collegeList.length;i++){
				if(this.collegeList[i].deptId==item.deptId){
					this.$set(this.form,"collegeName",this.collegeList[i].deptName)
				}
			}
			//匹配楼栋名称
			for(let i=0;i<this.buildingList.length;i++){
				if(this.buildingList[i]==item.buildId){
					this.$set(this.form,"buildName",this.buildingArray[i])
				}
			}
			this.popupType = false;
			this.getCheckPlanBySubId(item.id)
		},
		//调用摄像头
		saoCode(){
			let self = this;
			uni.scanCode({
				onlyFromCamera: true,
				success: function (res) {
					if(res.result.indexOf("code") != -1 && res.result.indexOf("-") != -1 && res.result.indexOf("&") != -1){
						let codeRoom = "";
						let newList = res.result.split("?")[1].split("&")
						let list = newList[0].split("=")[1].split("-")
						codeRoom = list[1];
						if(codeRoom){
							self.roomList = [];
							self.room = codeRoom;
							self.buildBySub();
							self.popupType = true;
						}else{
							uni.showToast({
								title: '请扫描正确的二维码',
								icon:"none",
								mask:true,
								duration: 2000
							});
						}
					}else{
						uni.showToast({
							title: '请扫描正确的二维码',
							icon:"none",
							mask:true,
							duration: 2000
						});
					}
				}
			});
		},
		//附件查看
		attachmentPreview(item){
			uni.showLoading({
				title: '下载中'
			});
			wx.downloadFile({
				url: config.base_url+item.fileUrl,
				header: {
					Authorization: uni.getStorageSync('token')
				},
				success: function (res) {
					uni.hideLoading();
					const filePath = res.tempFilePath
					wx.openDocument({
					  filePath: filePath,
					  success: function (res) {
						console.log('打开文档成功')
					  }
					})
				},
				fail: function (res){
					uni.hideLoading();
					uni.showToast({
						title: '下载失败',
						icon:"none",
						mask:true,
						duration: 2000
					});
				}
			})
		},
	    //提交
	    async submitForm(){
			let self = this;
			this.form.manageStatus=2;
			let obj=self.form;
			//复合的情况下,删除隐患项
			 obj.checkHazardDtoList=[];
			if(self.form.id){
				const {data} = await checkManageUpdate(obj);
				if(data.code == 200){
					uni.showToast({
						title: '提交成功',
						icon:"none",
						mask:true,
						duration: 2000
					});
					uni.redirectTo({
					    url: '/pages_safetyExamine/examineManage/examineList?pageType='+this.form.checkType
					});
				}
			}else{
				const {data} = await checkManageAdd(obj);
				if(data.code == 200){
					uni.showToast({
						title: '提交成功',
						icon:"none",
						mask:true,
						duration: 2000
					});
					uni.redirectTo({
					    url: '/pages_safetyExamine/examineManage/examineList?pageType='+this.form.checkType
					});
				}
			}

		  },
  }
}
</script>

<style lang="stylus" scoped>
.examine{
	height:100%;
	display flex;
	box-sizing: border-box;
	.info-max-box{
		flex: 1;
		overflow: scroll;
		padding: 20rpx 0rpx 128rpx;
		box-sizing: border-box;
	}
	.addDisabled{
		background-color: #f5f5f5;
	}
	.basics{
		margin: 0 30rpx;
		width: 690rpx;
		height:auto;
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 30rpx 28rpx 30rpx;
		box-sizing: border-box;
		.basics_li{
			display: flex;
			justify-content: flex-start;
			margin-bottom: 24rpx;
			.basics_li_l{
				width: 146rpx;
				text-align: left;
				font-size: 30rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 80rpx;
			}
			.basics_li_r{
				width: 486rpx;
				height: 80rpx;
				border-radius: 10rpx;
				opacity: 1;
				border: 1rpx solid #E0E0E0;
				padding-left: 20rpx;
				box-sizing: border-box;


			}
			/* 学院 */
			.college_r{
				width: 486rpx;
				height: 80rpx;
				border-radius: 10rpx;
				border: 1rpx solid #E0E0E0;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				>view{
					flex:1;
					line-height:80rpx;
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 80rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				>img{
					width: 14rpx;
					height: 8rpx;
					margin-right: 30rpx;
				}
			}
			/* 实验室 */
			.lab_r{
				width: 486rpx;
				height: 80rpx;
				display: flex;
				justify-content: flex-start;
				.picker-text{
					width: 438rpx;
					height: 80rpx;
				}
				.img-box{
					width: 48rpx;
					>img{
						width:30rpx;
						height:28rpx;
						margin:26rpx 18rpx 0 0;
					}
				}
			}
			/* 楼栋 */
			.building_r{
				width: 486rpx;
				height: 80rpx;
				>input{
					height: 80rpx;
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 80rpx;
				}
			}
		}
		.period{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-bottom: 24rpx;
			.period_l{
				width: 146rpx;
				font-size: 30rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 42rpx;
				text-align: left;
			}
			.period_r{
				width: 490rpx;
				height: 80rpx;
				border-radius: 10rpx;
				border: 1rpx solid #E0E0E0;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				.picker-text{
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #333;
					line-height: 80rpx;
					width: 230rpx;
					text-align: center;
				}
				.picker-text2{
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #333;
					line-height: 80rpx;
					width: 230rpx;
					text-align: center;
				}
			}
		}
		.custom{
			width: 150rpx;
			height: 60rpx;
			border-radius: 10rpx 10rpx 10rpx 10rpx;
			opacity: 1;
			border: 1rpx solid #0183FA;
			font-size: 26rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 400;
			color: #0183FA;
			line-height: 60rpx;
			text-align: center;
			float: right;
		}
	}
	.attachment{
		width: 690rpx;
		background: #FFFFFF;
		border-radius: 20rpx;
		margin: 20rpx 30rpx 0;
		padding-bottom: 32rpx;
		box-sizing: border-box;
		.attachment_t{
			border-bottom: 1rpx solid #D8D8D8;
			>text:nth-of-type(1){
				font-size: 30rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 110rpx;
				margin-left: 28rpx;
			}
			>text:nth-of-type(2){
				font-size: 30rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #999999;
				line-height: 110rpx;
				margin-left: 24rpx;
			}
		}
		.attachment_li{
			height: 40rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-top: 32rpx;
			>img{
				width: 30rpx;
				height: 26rpx;
				margin-right: 20rpx;
				margin-left: 50rpx;
			}
			>text{
				flex: 1;
				font-size: 28rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #0183FA;
				line-height: 40rpx;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			.attachment_li_del{
				width: 30rpx;
				height: 30rpx;
			}
		}
	}
	.inspect{
		margin: 20rpx 30rpx 0;
		width: 690rpx;
		height: auto;
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 40rpx 28rpx 20rpx;
		box-sizing: border-box;
		.inspect_li{
			display: flex;
			justify-content: flex-start;
			margin-bottom: 24rpx;
			.inspect_li_l{
				width: 146rpx;
				text-align: left;
				font-size: 30rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 80rpx;
			}
			.inspect_li_r{
				width: 486rpx;
				height: 80rpx;
				border-radius: 10rpx;
				opacity: 1;
				border: 1rpx solid #E0E0E0;
				padding-left: 20rpx;
				box-sizing: border-box;

			}
			.college_r{
				width: 486rpx;
				height: 80rpx;
				border-radius: 10rpx;
				border: 1rpx solid #E0E0E0;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				>view{
					flex:1;
					line-height:80rpx;
					font-size: 30rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 400;
					color: #333333;
					line-height: 80rpx;
				}
				>img{
					width: 14rpx;
					height: 8rpx;
					margin-right: 30rpx;
				}
			}
			/* 整改日期 */
			.date_r{
				width: 486rpx;
				height: 80rpx;
				display: flex;
				justify-content: flex-start;
				.picker-text{
					width: 438rpx;
					height: 80rpx;
				}
				>img{
					width:30rpx;
					height:28rpx;
					margin:16rpx 18rpx 0 0;
				}
			}
			/* 整改通知 */
			.inform_r{
				width: 486rpx;
				height: 80rpx;
				padding-left: 20rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				>view{
					display: flex;
					justify-content: flex-start;
					align-items: center;
					margin-right: 24rpx;
					.inform_r_l{
						display: inline-block;
						width: 30rpx;
						height: 30rpx;
						border-radius: 50%;
						border: 1rpx solid #E0E0E0;
						margin-right: 14rpx;
					}
					.inform_r_r{
						font-size: 30rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 400;
						color: #333333;
						line-height: 80rpx;
					}
					.checked{
						display: inline-block;
						width: 30rpx;
						height: 30rpx;
						border-radius: 50%;
						border: 1rpx solid #0183FA;
						margin-right: 14rpx;
						position: relative;
					}
					.checked::after{
						content: '';
						position: absolute;
						top: 5rpx;
						left:5rpx;
						width: 20rpx;
						height: 20rpx;
						border-radius: 50%;
						background: #0183FA;
					}
				}
			}
		}
	}
	.popup-max-box{
		z-index:10;
		height:100%;
		width:100%;
		position fixed;
		background rgba(0,0,0,0.2)
		display flex;
		flex-direction column
		.popup-null{
			flex:1;
		}
		.popup-big-box{
			border-top-left-radius:20rpx;
			border-top-right-radius:20rpx;
			background #fff
			.popup-input-box{
				padding:30rpx 20rpx;
				display:flex;
				input{
					flex:1;
					height:70rpx;
					border:1rpx solid #e0e0e0;
					border-radius:10rpx;
					margin-right:20rpx;
					padding:0 20rpx;
				}
				view{
					background #0183FA
					color:#fff;
					border-radius:10rpx;
					width:140rpx;
					line-height:70rpx;
					text-align center;
					font-size:28rpx;
				}
			}
			.popup-for-max-box{
				margin:0 20rpx 30rpx;
				height:600rpx;
				overflow-y scroll;
				.popup-for-null{
					line-height:100rpx;
					text-align center
					color:#999;
				}
				.popup-for-box{
					display:flex;
					padding:10px 0;
					.name-p{
						flex:1;
						line-height:60rpx;
					}
					.button-p{
						background #0183FA
						color:#fff;
						text-align center
						width:100rpx;
						line-height:60rpx;
						height:60rpx;
						border-radius:10rpx;
					}
				}
			}
		}
	}
	/* 计划标题 */
	.inspect_name{

		.popup-content{
			width: 750rpx;
			height: 350rpx;
			background: #FFFFFF;
			border-radius: 10rpx 10rpx 0px 0px;
			padding :0 50rpx;
			box-sizing :border-box;
			overflow :hidden;
			.inspect_name_t{
				margin-top:66rpx;
				padding: 0 30rpx;
				box-sizing: border-box;
				>input{
					width:100%;
					height:80rpx;
					border: 2rpx solid #E0E0E0;
					color:#A2A2A2;
					font-size:28rpx;
					line-height 80rpx
					border-radius:10rpx;
					padding: 0 20rpx;
					box-sizing: border-box;
				}
			}
			.inspect_name_b{
				margin-top :64rpx;
				display: flex;
				justify-content: center;
				>text:nth-of-type(1){
					width: 160rpx;
					height: 60rpx;
					border-radius: 40rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 60rpx;
					text-align :center;
					margin-right: 120rpx;
					border: 2rpx solid #e0e0e0;
				}
				>text:nth-of-type(2){
					width: 160rpx;
					height: 60rpx;
					background: linear-gradient(-35deg, #309CFF, #0183FA);
					border-radius: 40rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					line-height: 60rpx;
					text-align :center;
				}


			}

		}

	}
	.bottom_btn{
		position: fixed;
		bottom: 26rpx;
		left: 30rpx;
		font-size: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 90rpx;
		width: 690rpx;
		height: 90rpx;
		background: #0183FA;
		border-radius: 20rpx;
		text-align: center;

	}
}
</style>
