<!-- 资质审核-->
<template>
    <view id="register">
		<view class="register_li">
			<view class="register_li_min">
				<img class="icon_img" src="@/images/Version3.0/icon_zgsq_sqr.png">
				<view>申请人：</view>
				<input v-model="form.applyUser" disabled  type="text" >
			</view>
			<view class="register_li_min" style="border: none;">
				<img class="icon_img" src="@/images/Version3.0/icon_zgsq_dhh.png">
				<view>联系方式：</view>
				<input v-model="form.phone" disabled  type="text" >
			</view>
		</view>
		<view class="register_li" v-if="status=='zg'">
			<view class="register_li_min" v-for="(item,index) in form.airBottlelist" style="border-bottom:0;" >
				<view></view>
				<view>{{item.airConstituents}}-{{item.configName}}：</view>
				<input v-model="'数量：'+item.bottleNumber" disabled  type="text" >
			</view>
		</view>
		<view class="register_li">
			<view class="register_li_min">
				<view></view>
				<view>实验地点：</view>
				<input v-model="form.location" disabled type="text" >
			</view>
			<!-- 使用期限 -->
			<view class="register_li_min2">
				<view><text  style="color: #f00;margin-right: 10rpx;"></text>使用期限:</view>
				<picker mode="date" disabled @change="startChange($event)">
					<input class="picker-text" v-model="form.startTime" disabled  type="text"  placeholder="开始时间">
				</picker>
				<view>-</view>
				<picker mode="date" disabled @change="endChange($event)">
					<input class="picker-text2" v-model="form.endTime" disabled  type="text"  placeholder="结束时间">
				</picker>
			</view>
			<view class="register_li_min">
			    <view></view>
				<view>气体用途：</view>
				<input v-model="form.gasUse" disabled  type="text" >
			</view>
			<view class="register_li_min">
			    <view></view>
				<view>安全措施：</view>
				<input v-model="form.safetyPrecautions" disabled  type="text" >
			</view>
			<view  class="issue_li" style="border-bottom:0;"  @click="lookItem(form.applyCertificate)">
				<view></view>
				<view>用气申请表：</view>
				<img class="issue_img" :src="baseUrl+form.applyCertificate">
			</view>
			<view  class="check_li" style="border-bottom:0;">
				<view></view>
				<view>审核意见：</view>
				<textarea v-model="params.leadAuditCause" class="check_li_b"  placeholder="请输入审核意见"></textarea>
			</view>
		</view>
		<!-- 用气实验室 -->
		<view  class="sub_btn" v-if="status=='yq' && form.leadAuditStaus==0  && form.isAdmin && form.audit">
			<view class="sub_btn_l" @click="submitForm(2)">审核驳回</view>
			<view class="sub_btn_r" @click="submitForm(1)">审核通过</view>
		</view>
		<!-- 用气实验中心 -->
		<view  class="sub_btn" v-if="status=='yq' && form.leadAuditStaus==1 && form.centerAuditStatus!=2  && form.audit">
			<view class="sub_btn_l" @click="submitForm2(2)">审核驳回</view>
			<view class="sub_btn_r" @click="submitForm2(1)">审核通过</view>
		</view>
		<!-- 资格实验室 -->
		<view  class="sub_btn" v-if="status=='zg' && form.leadAuditStatus==0 && form.isAdmin && form.audit">
			<view class="sub_btn_l" @click="submitForm(2)">审核驳回</view>
			<view class="sub_btn_r" @click="submitForm(1)">审核通过</view>
		</view>
		<!-- 资格实验中心 -->
		<view  class="sub_btn" v-if="status=='zg' && form.leadAuditStatus==1 && form.centerAuditStatus!=2  && form.audit">
			<view class="sub_btn_l" @click="submitForm2(2)">审核驳回</view>
			<view class="sub_btn_r" @click="submitForm2(1)">审核通过</view>
		</view>
	</view>
</template>

<script>
    import {auditDetail,qualificationDetail,auditCheck,auditCenterCheck,auditUseAgsCheck,auditUseAgsCenterCheck} from '@/api/index.js'
	import { config } from '@/api/request/config.js'
    export default {
        data() {
            return {
				baseUrl:config.base_url,
				form:{},
				id:'',
				status:null,//yq 用气申请 zg 资格申请
				params:{
					id:'',
					leadAuditCause:'',
					leadAuditStatus:'',//审核状态 0 未审核 1.审核通过 2.审核未通过
				},
            }
        },
        onLoad(option) {
			if(decodeURIComponent(option.item)){
				this.id=JSON.parse(decodeURIComponent(option.item)).id;
				this.status=JSON.parse(decodeURIComponent(option.item)).remark;
			}
			if(this.status=='yq'){
				wx.setNavigationBarTitle({
				  title: '用气申请',
				})
			}else if(this.status=='zg'){
				wx.setNavigationBarTitle({
				  title: '资格申请',
				})
			}
			
			
        },
        onShow(){
			
        },
		
        methods: {
			//获取详情
			async getInfo(){
			    let _this = this;
				if(this.status=='yq'){
					const {data} = await auditDetail({id:this.id})
					if(data.code==200){
						let res=data.data
						_this.form=res.apply;
						_this.form.isAdmin=res.isAdmin;
						_this.form.audit=res.audit;
						_this.form.airBottlelist=res.airBottlelist;
						_this.params.id=res.apply.id;
						
					}
				}else if(this.status=='zg'){
					const {data} = await qualificationDetail({id:this.id})
					if(data.code==200){
						let res=data.data
						_this.form=res.apply;
						_this.form.isAdmin=res.isAdmin;
						_this.form.audit=res.audit;
						_this.form.airBottlelist=res.airBottlelist;
						_this.params.id=res.apply.id;
						
					}
				}
			    
			},
			lookItem(item){
				//查看图片
				wx.previewImage({
					urls: [config.base_url+item], //需要预览的图片http链接列表，多张的时候，url直接写在后面就行了
					current: '', // 当前显示图片的http链接，默认是第一个
					success: function(res) {},
					fail: function(res) {},
					complete: function(res) {},
				})
			},
			//重新提交
			//提交实验室
			async submitForm(auditStatus){
				let _this = this;
				
				if(!_this.params.leadAuditCause){
					uni.showToast({
					    title: '请输入审核意见!',
					    icon:"none",
					    mask:true,
					    duration: 2000
					});
					return
				}
				let obj={};
				obj.leadAuditCause=_this.params.leadAuditCause;
				obj.id=_this.params.id;
				if(this.status=='yq'){
					if(auditStatus==1){//通过
						obj.leadAuditStaus=1
					}else if(auditStatus==2){//驳回
					    obj.leadAuditStaus=2
					}
					const {data} = await auditUseAgsCheck(obj);
					if(data.code == 200){
					    uni.showToast({
					        title: '审核成功',
					        icon:"none",
					        mask:true,
					        duration: 2000
					    });
						uni.removeStorageSync('listDetail');
					    setTimeout(function(){
					       uni.redirectTo({
					            url: '/pages_manage/aptitudeAudit/aptitudeAudit'
					        });
					    },2000);
					}
				}else if(this.status=='zg'){
					obj.leadAuditCause=_this.params.leadAuditCause;
					if(auditStatus==1){//通过
						obj.leadAuditStatus=1
					}else if(auditStatus==2){//驳回
					    obj.leadAuditStatus=2
					}
					const {data} = await auditCheck(obj);
					if(data.code == 200){
					    uni.showToast({
					        title: '审核成功',
					        icon:"none",
					        mask:true,
					        duration: 2000
					    });
						uni.removeStorageSync('listDetail');
					    setTimeout(function(){
					       uni.redirectTo({
					            url: '/pages_manage/aptitudeAudit/aptitudeAudit'
					        });
					    },2000);
					}
				}
				
			},
			//实验中心
			async submitForm2(auditStatus){
				let _this = this;
				let obj={};
				obj.centerAuditCause=_this.params.leadAuditCause;
				obj.id=_this.params.id;
				if(this.status=='yq'){
					if(auditStatus==1){//通过
						obj.centerAuditStatus=1
					}else if(auditStatus==2){//驳回
					    obj.centerAuditStatus=2
					}
					const {data} = await auditUseAgsCenterCheck(obj);
					if(data.code == 200){
					    uni.showToast({
					        title: '审核成功',
					        icon:"none",
					        mask:true,
					        duration: 2000
					    });
						uni.removeStorageSync('listDetail');
					    setTimeout(function(){
					       uni.redirectTo({
					            url: '/pages_manage/aptitudeAudit/aptitudeAudit'
					        });
					    },2000);
					}
				}else if(this.status=='zg'){
					if(auditStatus==1){//通过
						obj.centerAuditStatus=1
					}else if(auditStatus==2){//驳回
					    obj.centerAuditStatus=2
					}
					const {data} = await auditCenterCheck(obj);
					if(data.code == 200){
					    uni.showToast({
					        title: '审核成功',
					        icon:"none",
					        mask:true,
					        duration: 2000
					    });
						uni.removeStorageSync('listDetail');
					    setTimeout(function(){
					       uni.redirectTo({
					            url: '/pages_manage/aptitudeAudit/aptitudeAudit'
					        });
					    },2000);
					}
				}
				
				
			},
        },
		mounted() {
			this.getInfo();
		
		}
    }
</script>

<style lang="stylus" scoped>
    #register{
        height:auto;
        width:100%;
        display flex;
        flex-direction column;
		padding-bottom: 220rpx;
		.register_li{
			background #fff;
			border-radius:20rpx;
			margin:20rpx 20rpx 0;
			padding:20rpx 0;
			box-sizing: border-box;
			.register_li_min{
				margin:0 26rpx;
				display flex;
				align-items center;
				border-bottom: 1px solid #F5F5F5;
				.icon_img{
					width: 30rpx;
					height: 30rpx;
					margin-right: 12rpx;
				}
				view{
					line-height:100rpx;
					font-size:28rpx;
				}
				view:nth-child(1){
					color:red;
					line-height:28rpx;
					margin-right: 12rpx;
				}
				view:nth-child(2){
					//width:140rpx;
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
				
				>input{
					flex:1;
					text-align: right;
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
				}
				
				
			}
			/* 时间 */
			.register_li_min2{
				margin:0 26rpx;
				border-bottom: 1px solid #f5f5f5;
				height: 100rpx;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				>view:nth-child(1){
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
					line-height: 100rpx;
					margin-right: 120rpx;
				}
				.picker-text{
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 100rpx;
					width: 188rpx;
					
				}
				>view:nth-child(2){
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 100rpx;
				}
				.picker-text2{
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 100rpx;
					width: 188rpx;
					text-align: right;
				}
			}
			
			.issue_li{
				margin:34rpx 26rpx 0;
				display flex;
				border-bottom: 1px solid #F5F5F5;
				view:nth-child(1){
					color:red;
					line-height:28rpx;
					margin-right: 12rpx;
				}
				view:nth-child(2){
					//width:140rpx;
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
				.issue_img{
					width: 210rpx;
					height: 210rpx;
					border-radius: 10rpx;
					margin-left:250rpx;
				}
			}
			/* 审核意见 */
			.check_li{
				margin:34rpx 26rpx 0;
				view:nth-child(1){
					color:red;
					line-height:28rpx;
					margin-right: 12rpx;
				}
				view:nth-child(2){
					//width:140rpx;
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
				.check_li_b{
					width: 657rpx;
					height: 211rpx;
					background: #FFFFFF;
					border: 1px solid #E0E0E0;
					border-radius: 10rpx;
					padding: 20rpx;
					box-sizing: border-box;
					margin-top: 20rpx;
				}
				
			}
		}
		/* 按钮 */
		.sub_btn{
			width: 650rpx;
			height: 100rpx;
			display: flex;
			position: fixed;
			bottom: 30rpx;
			left: 50rpx;
			z-index: 1000;
			.sub_btn_l{
				width: 325rpx;
				height: 100rpx;
				background: linear-gradient(-45deg, #FA9901, #F28E26);
				border-radius: 50rpx 0px 0px 50rpx;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 100rpx;
				text-align: center;
			}
			.sub_btn_r{
				width: 325rpx;
				height: 100rpx;
			    background: linear-gradient(-35deg, #309CFF, #0183FA);
			    border-radius: 0px 50rpx 50rpx 0px;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 100rpx;
				text-align: center;
			}
		}
	}
	/deep/.input-value-border{
		display :none !important;
	}
</style>
