<template>
	<view class="default_page" :style="{'height':h+'px', 'padding-top':mt+'px'}">
		<cus-header title='生成报告' bgColor="transparent"></cus-header>
		<div class="box adffcac">
			<image class="box-loading" src="https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/e6d5bea9491a14aafd3f955d332e62d08e521229/report_success.png" v-if="result==0"></image>
			<image class="box-loading" src="https://gitee.com/hw_0302/chuang-heng-wechat-images/raw/e6d5bea9491a14aafd3f955d332e62d08e521229/report_fail.png" v-else></image>
			<div class="box-p1">{{result==0?'报告正在生成中~':'报告生成失败'}}</div>
			<div class="box-p2" v-if="result==0">预计所需时间7-10分钟</div>
			<div class="box-p3">{{result==0?'稍后可去报告管理中查看结果':'失败原因：网络延迟'}}</div>
		</div>
		<div class="form">
			<div class="form-item adfacjb">
				<div class="form-item-left">问卷名称</div>
				<div class="form-item-right">{{info.title||''}}</div>
			</div>
			<div class="form-item adfacjb">
				<div class="form-item-left">团队名称</div>
				<div class="form-item-right">{{info.teamName||''}}</div>
			</div>
			<div class="form-item adfacjb">
				<div class="form-item-left">创建时间</div>
				<div class="form-item-right">{{info.startTime||info.createDate||''}}</div>
			</div>
		</div>
		<div class="btn">
			<div class="zt_btn" @click="handleBack" v-if="result==0">返回</div>
			<div class="zt_btn" @click="handleReCreate" v-else>重新生成</div>
		</div>
	</view>
</template>

<script>
	export default {
		data(){
			return {
				result:'',
				info:null
			}
		},
		onLoad(options) {
			this.result = options.result;
			this.info = options.info&&JSON.parse(decodeURIComponent(options.info));
		},
		methods:{
			handleBack(){
				uni.navigateBack()
			},
			handleReCreate(){
				this.$api.get(`/core/team/questionnaire/genReport/${this.info.teamQuestionnaireId}`).then(({data:res})=>{
					if(res.code!==0) return this.$showToast(res.msg)
					this.$showToast('重新生成成功')
					setTimeout(()=>{
						uni.redirectTo({
							url:'pagesHome/questionnaire?type=create'
						})
					},1500)
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.default_page{
		background: #F7F7F7;
		.box{
			width: 100%;
			background: #FFFFFF;
			border-radius: 36rpx 36rpx 0rpx 0rpx;
			padding: 54rpx 0 64rpx;
			&-loading{
				width: 340rpx;
				height: 340rpx;
			}
			&-p1{
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 32rpx;
				color: #002846;
				line-height: 40rpx;
				text-align: center;
				margin-top: 41rpx;
			}
			&-p2{
				font-family: PingFang-SC, PingFang-SC;
				font-weight: bold;
				font-size: 28rpx;
				color: #002846;
				line-height: 28rpx;
				text-align: center;
				margin-top: 23rpx;
			}
			&-p3{
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #667E90;
				line-height: 28rpx;
				text-align: center;
				margin-top: 24rpx;
			}
		}
		
		.form{
			width: 100%;
			margin-top: 20rpx;
			&-item{
				padding: 28rpx 24rpx;
				background: #FFFFFF;
				box-shadow: inset 0rpx -1rpx 0rpx 0rpx #EFEFEF;
				&-left{
					width: 140rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 30rpx;
					color: #002846;
					line-height: 42rpx;
				}
				&-right{
					width: calc(100% - 140rpx);
					padding-left: 20rpx;
					box-sizing: border-box;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 30rpx;
					color: #667E90;
					line-height: 32rpx;
					text-align: right;
				}
			}
		}
		
		.btn{
			width: calc(100% -100rpx);
			margin: 120rpx 50rpx 0;
		}
	}
</style>