<template>
    <div>
        <van-progress :percentage="num" :show-pivot="false"/>
        <div style='text-align:center;margin-top:40px'>
            跳转中... 
        </div>
    </div>
</template>

<script>
import { getFun,postFun } from '@/service/table'
export default {
    data(){
        return {
            num:0,
            params:{
                id:0,
                path:'',
                theme:'隐患'
            },
            api:{
                隐患:'/hdreport/hdDetailsApp',
                风险:'/riskMain/riskDetailsApp',
                安全监督检查:'/check/notify/trouble'
            }
        }
    },
    methods:{
        
    },
    mounted(){
        postFun(`${this.api[this.params.theme]}/${this.params.id}`)
        .then(res=>{
            let data = res.data.hdReport||res.data.riskMain;
            this.num=100
            // return false;
            this.$router.replace({
                name: this.params.path,
                params: {
                    id:this.params.id,
                    data: {
                        ...data,
                        taskId:this.params.id
                    },
                    taskId:this.params.id
                },
            });
        })
        .catch(err=>{
             this.num=100;
             this.$router.replace({
                 name:'fail',
                 query:{
                     text:'响应错误',
                     content:'请联系管理员'
                 }
             })
        })
    },
    created(){
        let time = setInterval(()=>{
            if(this.time>=80){
                clearInterval(time)
                return false;
            }
            this.num++
        },10)
        if(this.$route.params.id&&this.$route.params.path){
            this.params=this.$route.params;
        } else {
             this.num=100;
             this.$router.replace({
                 name:'fail',
                 query:{
                     text:'参数错误',
                     content:'请联系管理员'
                 }
             })
        }
    }
}
</script>

<style>

</style>