<template>
    <div>
        <div class="autoBox box" >
            <div class="crumbs">
                <el-breadcrumb separator="/">
                    <el-breadcrumb-item :to="{ path: 'home' }">{{$t('common.Home')}}</el-breadcrumb-item>
                    <el-breadcrumb-item :to="{ path: 'financialServices' }">{{$t('common.FinancialServices')}}</el-breadcrumb-item>
                    <el-breadcrumb-item :to="{ path: 'FinancialServiceProjectEvaluation' }">{{$t('common.ProjectAppraisal')}}</el-breadcrumb-item>
                    <el-breadcrumb-item :to="{ path: 'FinancialServiceProjectEvaluation' }">{{init.projectReportName}}</el-breadcrumb-item>

                </el-breadcrumb>
            </div>

            <div style="margin-top: 60px;padding: 0 100px;text-align: center;"  v-if="havePdf == false">{{$t('common.NoFile')}}</div>
            <div style="margin-top: 60px;padding: 0 100px;text-align: center;" v-if="havePdf == true">
                <img src="@/assets/img/financialService/header1.png" alt="" style="width: 100%;height: 280px">
<!--                <div style="min-width: 500px;max-height: 800px">-->
                <img :src="'api/file/pub/'+ pdfDetails.fileAddress + '\\' + pdfParams.pageNo +'.png'" alt="" style="width:100%;height:100%;margin: 0;">
<!--                </div>-->
<!--                <iframe  width="100%" id="pdflist"  height="1100px" :src="'api/file/pub/'+showPdfDeta.attachmentSavePath" frameborder="0"></iframe>-->
                <div class="footerSty">
                    <div style="line-height: 20px">
                        <span style="display: block;">{{$t('common.GEIDcpTitle')}}</span>
                        <span style="display: block">{{$t('common.mail')}}：geidcp-info@geidco.org</span>
                        <span style="display: block">{{$t('common.tel')}}：010-66598554</span>
                    </div>

                </div>
            </div>

        </div>
        <!-- 分页 -->
        <div style="width: 100%;position: relative;height: 100px;">
            <el-pagination
                    type="index"
                    style="height: 80px;position: absolute;left: 50%;top: 80px;transform: translate(-50%,-50%);"
                    background
                    :index="indexMethod"
                    layout="prev, pager, next"
                    :page-size="1"
                    :total="pdfNum-0"
                    @current-change="handleCurrentChange"
            ></el-pagination>
        </div>

    </div>
</template>
<script>
    import {sysAttachmentInfos} from '@/api/cooperation/baseCooperationUnit';
    import {getBaseProjectEvaluationReportInfos} from "../../api/financialService/baseProjectEvaluationReportInfo";
    import {gateResearchResultFileById} from "../../api/research/baseResearchResultView";
    export default {
        name:'FinancialServiceEvaluationPdfDetails.vue',
        data(){
            return{
                init:'',
                pdfDetails:'',
                showPdfDeta:{},
                havePdf:false,
                params:{
                    pageSize:"5",
                    pageNo:"1",
                    language:'',
                    baseEntityId:'',
                    statusDict:'2'
                },
                isLogin:false,
                pdfNum:0,
                pdfParams:{
                    pageNo:1,
                    pageSize:1,
                    language:'',
                    researchResultFileId:''
                },

            }
        },
        mounted() {
            this.getData();
            this.confLogin();
        },
        watch:{
          '$i18n.locale'(){
              this.getData();
              this.confLogin();
          }
        },
        methods:{

            getData(){
                const that = this;
                this.params.language = this.$i18n.locale.toUpperCase();
                this.params.baseEntityId = this.$route.query.key.baseEntityId;
                getBaseProjectEvaluationReportInfos(this.params).then((res)=>{
                    this.init = res.data.baseProjectEvaluationReportInfos[0];
                    this.getPdfList();
                    // // 获取iframe中的pdf
                    // let list={
                    //     attachmentBusinessId: this.init.id,
                    //     attachmentBusinessType:'base_investment_guide'
                    // };
                    // sysAttachmentInfos(list).then((res)=>{
                    //     debugger
                    //     if(res.data){
                    //         this.showPdfDeta = res.data.attachmentInfos[0];
                    //     }
                    //
                    // })
                })
            },
            getPdfList(){
                this.pdfParams.language = this.$i18n.locale.toUpperCase();
                this.pdfParams.researchResultFileId = this.init.pdfToPictureFileIds;
                gateResearchResultFileById(this.pdfParams).then((res)=>{

                    let newData = res.data.baseResearchResultFile;
                    if (newData == '无数据' || newData == null){
                        debugger
                        this.havePdf = false;
                    }else{
                        this.havePdf = true;
                        this.pdfDetails = res.data.baseResearchResultFile;
                        this.pdfNum =this.pdfDetails.filePages;
                    }


                })
            },
            //分页索引接着上一页的索引
            indexMethod(index){
                return (this.page-1)*10+index+1;
            },
            // 分页
            handleCurrentChange(val){
                this.pdfParams.pageNo=val
                this.getData();
            },
            confLogin(){
                if (!this.$Cookies.get('token')) {
                    this.isLogin=false
                }else{
                    this.isLogin= true
                }
            },

            confLogin(){
                if (!this.$Cookies.get('token')) {
                    this.isLogin=false
                }else{
                    this.isLogin= true
                }
            },
            toView(router, json) {
                console.log(router,json)
                this.$router.push({
                    name: router,
                    query:{
                        key:json,
                    }
                })
            },

        }

    }
</script>
<style scoped>
    .box {
        margin-top: 10px;
        background: #fff;



        /* height: 500px; */
        padding: 20px 0;
    }
    .crumbs {
        margin-left: 20px;
    }
    body {
        margin: 0;
    }
    .footerSty{
        width: 100%;
        height: 60px;
        margin: 0;
        text-align: center;
        font-size: 14px;
        color: #fff;
        padding: 20px 0;
        background-image: url("../../assets/img/financialService/footer2.png");
    }
</style>