<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-collection"></i>
                    <router-link :to="{ path: '/editPeerewer' }">
                        <span class="top_dao"> Final Review Article</span>
                    </router-link>
                    >> Final Review Article Detail
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div
            class="container_l" style="padding-top: 5px;"
            v-loading="loading"
            element-loading-text="Loading..."
            element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.8)"
        >
            <el-row :gutter="20">
                <el-col :span="10">
                    <iframe ref="mainiframe" :src="pdfUrl" class="lookpdf" frameborder="0"></iframe>
                </el-col>
                <el-col :span="14" style="height: 760px; overflow-y: scroll">
                    <!-- <el-col :span="24"> -->
                    <el-card class="box-card">
                        <div class="tet_list" :model="txt_mess">
                            <h4>{{ txt_mess.article_title }}</h4>
                            <h5>
                                <a :href="txt_mess.website" target="_blank" class="titlink">{{ txt_mess.title }}</a>
                                <span style="margin: 0 10px"> >> </span>
                                Manuscript ID: {{ txt_mess.accept_sn }}
                            </h5>
                            <p style="display: inline-block; margin: 0 35px"><b>Type :</b> {{ txt_mess.atype }}</p>
                            <p style="display: inline-block"><b>Submitted time :</b> {{ txt_mess.ctime?txt_mess.ctime.split(' ')[0]:'' }}</p>

                            <div>
                                <p><b>Abstract :</b> <br />{{ txt_mess.abstrart }}</p>
                                <div class="file_sty" v-for="item in fileList" style="margin-top: 15px">
                                    <img src="../../assets/img/icon_0.png" alt="" class="icon_img" />
                                    <a :href="mediaUrl + item.file_url" target="_blank" class="txt_pdf"
                                        >Manuscirpt
                                        <span style="margin-left: 50px; color: #888; font-size: 13px">{{ item.ctime }}</span>
                                        <i class="el-icon-download" style="margin-left: 20px; color: #66b1ff; font-weight: bold"></i> </a
                                    ><br />
                                </div>

                                <div class="file_sty" v-for="item in picList">
                                    <img src="../../assets/img/icon_0.png" alt="" class="icon_img" />
                                    <a :href="mediaUrl + item.file_url" target="_blank" class="txt_pdf"
                                        >Figures and Tables
                                        <span style="margin-left: 50px; color: #888; font-size: 13px">{{ item.ctime }}</span>
                                        <i class="el-icon-download" style="margin-left: 20px; color: #66b1ff; font-weight: bold"></i> </a
                                    ><br />
                                </div>
                                <div class="file_sty" v-for="item in SMList">
                                    <img src="../../assets/img/icon_0.png" alt="" class="icon_img" />
                                    <a :href="mediaUrl + item.file_url" target="_blank" class="txt_pdf"
                                        >Supplementary Material
                                        <span style="margin-left: 50px; color: #888; font-size: 13px">{{ item.ctime }}</span>
                                        <i class="el-icon-download" style="margin-left: 20px; color: #66b1ff; font-weight: bold"></i> </a
                                    ><br />
                                </div>

                                <p style="margin-top: 5px; color: #999; font-size: 14px;">
                                    <b style="color: #e41411">Download failed?</b>
                                    <p style="line-height: 18px;color: #999; font-size: 14px;margin-top: 4px;">
                                         <!-- If you have upgraded the Google Chrome browser to version 86, released on October 6, 2020, you may
                                    have noticed that some file downloads don't work anymore in the browser. You click on the download link
                                    and nothing happens. <br />1. Right now, the easiest option available is to
                                    <b style="color: #e41411">right-click on the download link and select "save link as".</b>
                                    The download is executed when you do that.
                                    <br />2. Please try to use a different browser for downloads. For now, a browser like Firefox, Internet
                                    Explorer, Brave, Vivaldi, the new Edge, or Opera all allow the download. -->
                                    It seems like you're encountering a download issue with Google Chrome version 86. Here are the steps you can follow to resolve or bypass the issue:
                                    <br />1. Right-click on the download link: Instead of clicking the link normally, right-click on it and select  <b style="color: #e41411">"save link as".</b> This should allow the download to start.
                                    <br />2. Try a different browser:
If you're still having trouble with Chrome, you could use other browsers to complete your downloads. Browsers like Firefox, Internet Explorer, Brave, Vivaldi, the new Edge, or Opera are known to work well for downloads without this issue.
                                
                                
                                </p>
                                  
                                </p>
                            </div>
                            <el-collapse v-model="activeNames" accordion v-if="conmentList.length > 0" style="margin-top: 10px;">

  <el-collapse-item name="1">
    <template slot="title">
        <div class="review_title">

             <b>Peer-review Archive</b>

        </div>
       
    </template>
    <div v-for="(item, index) in conmentList" class="comment_item">
        <p style="margin-top: 4px;margin-bottom: 4px;font-weight: bold;"><span style="color:#006699;font-size: 16px !important;">Comment {{ index+1 }}</span>

        

        </p>
        <p><span class="comment_item_recommend_title">Reviewer : </span>
       
                        <b v-if="item.reviewer_id == User_Id">{{ item.realname }}</b>
                        <b v-if="item.reviewer_id != User_Id">XXXXXXXXXX</b>
                   

        </p>
        <p>
        
        <span class="comment_item_recommend_title"
    >Recommendation : </span>
    
    <span class="comment_item_recommend"><b v-if="item.question.recommend == 1">Minor revision</b>
                        <b v-if="item.question.recommend == 2">Major revision</b>
                        <b v-if="item.question.recommend == 3">Reject in current form, but may be resubmitted</b>
                        <b v-if="item.question.recommend == 4">Reject</b></span>
    </p>
        <p>
        
        <span class="comment_item_recommend_title"
    >Score : </span>
    
    <span>{{item.question.score}}</span>
    </p>

    <p>
        <span class="comment_item_recommend_title">Reviewed Time : </span>
        <span class="">{{ item.ctime?item.ctime.split(' ')[0]:''  }}</span>
        
        <el-button type="primary" v-if="item.question&&item.question.art_rev_id"  size="mini" @click="ques_visible(item.question)"
    
    style="padding: 4px 10px;margin-left: 20px;">Referee's Assessment</el-button> 
    </p>




      

   
    </div>
    
    
  </el-collapse-item>
  
</el-collapse> 
                            <!-- <p class="morSou" v-if="!morShow" @click="morShow=true">
								<i class="el-icon-bottom"></i>
								More article information
							</p>
							<p class="morSou" v-if="morShow" @click="morShow=false">
								<i class="el-icon-top"></i>
								More article information
							</p> -->
                        </div>
                    </el-card>

                    <el-card class="box-card" v-if="this.add_apply == 1">
                        Thank you for your time and consideration on the manuscript. We are sorry that this manuscript has went through peer
                        review and the final review has been obtained according to the timetable. Accordingly, your review process has
                        been discontinued. Your comments do not need to be submitted now. We would like to express our sincere gratitude for
                        your contributions as well.
                    </el-card>

                   
                    <el-card class="box-card" v-if="this.add_apply == 0&&questionform.article_id">


                       
                         <!-- 审稿人表单修改  -->
                         <!-- Accept(录用)、Revision(退修)、Reject(退稿) -->
                        <common-editor-article  @refresh="getData"  type="questionform" :form="questionform" :txt_mess="txt_mess" :btn_submit="btn_submit" :articleId="articleId" :journal_id="journal_id"></common-editor-article>
                        </el-card>
                </el-col>
            </el-row>
        </div>
         <!-- 证书弹出框 -->
         <el-dialog :visible.sync="questionVisible" width="1000px">
                <!-- 审稿人表单修改  -->
                <!-- 不显示给编辑的话  -->
                <common-review-article
                    :form="questionform1"
                    type="questionform"
                    :txt_mess="txt_mess"
                    :confident="false"
                    :btn_submit="1"
                    :articleId="articleId"
                    :journal_id="journal_id"
                ></common-review-article>
                </el-dialog>
    </div>
</template>

<script>
import pdf from 'vue-pdf';
export default {
    data() {
        return {
            activeNames:['1'],
            questionVisible: false,
            User_Id: localStorage.getItem('U_id'),

            loading: false,
            articleId: null,
            Direct_log: this.$route.query.act,
            Art_id: this.$route.query.Art_id,
            // morShow: false,
            txt_mess: {},
            fileList: [],
            conmentList: [],
            picList: [],
            SMList: [], //补充材料
            mediaUrl: this.Common.mediaUrl,
            add_edit: {
                article_id: this.$route.query.Art_id,
                user_id: localStorage.getItem('U_id'),
                content: ''
            },
            head_line: '',
            questionform1:{},
            questionform: {
               article_id: '',
               reviewer_id: '',

                art_rev_id: this.$route.query.Art_id,
                record_id: this.$route.query.Art_id,
               
            },
            add_apply: 0,
            btn_submit: 0,
            pdfUrl: '',
            journal_id: null,
            rules: {
                qu6: [
                    {
                        required: true,
                        message: 'please select',
                        trigger: 'blur'
                    }
                ],
                rated: [
                    {
                        required: true,
                        message: 'please select',
                        trigger: 'blur'
                    }
                ],
                comment: [
                    {
                        required: true,
                        message: 'please input content',
                        trigger: 'blur'
                    }
                ],
                recommend: [
                    {
                        required: true,
                        message: 'please select',
                        trigger: 'blur'
                    }
                ]
            }
        };
    },
    created() {
       
            this.getData();
       
    },
    methods: {
           //初始化问卷
           ques_visible(e) {
            this.questionVisible = true;
            this.questionform1.rev_qu_id = e.rev_qu_id;
            this.questionform1.art_rev_id = e.art_rev_id;
            this.questionform1.qu1 = e.qu1;
            this.questionform1.qu2 = e.qu2;
            this.questionform1.qu3 = e.qu3;
            this.questionform1.qu4 = e.qu4;
            this.questionform1.qu5 = e.qu5;
            this.questionform1.qu6 = e.qu6;
            this.questionform1.qu7 = e.qu7;
            this.questionform1.qu8 = e.qu8;
            this.questionform1.qu9 = e.qu9 == 0 ? false : true;
            this.questionform1.qu9contents = e.qu9_contents;
            this.questionform1.qu10 = e.qu10 == 0 ? false : true;
            this.questionform1.qu10contents = e.qu10_contents;
            this.questionform1.qu11 = e.qu11 == 0 ? false : true;
            this.questionform1.qu11contents = e.qu11_contents;
            this.questionform1.qu12 = e.qu12 == 0 ? false : true;
            this.questionform1.qu12contents = e.qu12_contents;
            this.questionform1.qu13 = e.qu13 == 0 ? false : true;
            this.questionform1.qu13contents = e.qu13_contents;
            this.questionform1.qu14 = e.qu14 == 0 ? false : true;
            this.questionform1.qu14contents = e.qu14_contents;
            this.questionform1.qu15 = e.qu15 == 0 ? false : true;
            this.questionform1.qu15contents = e.qu15_contents;
            this.questionform1.rated = e.rated;
            this.questionform1.recommend = e.recommend;
            this.questionform1.other = e.other;
            this.questionform1.confident = e.confidential;
            this.questionform1.comment = e.comments;
            this.questionform1.is_anonymous = e.is_anonymous;
            this.questionform1.type = e.type;
            this.questionform1.score = e.score;
        },
        getData() {
            // 获取文章信息
            this.$api
                .post('api/Finalreview/view', {
                    record_id: this.Art_id,
                    
						'reviewer_id': localStorage.getItem('U_id'),
                })
                .then((res) => {
                    this.articleId=res.data.article.article_id
                    
                    this.questionform ={...this.questionform,...res.data.article_final} 
                    console.log('this.questionform at line 224:', this.questionform)
                    if (res.data.article_final.state != 0) {
                        this.btn_submit = 1;
                    }

                    this.txt_mess = res.data.article;
                    this.journal_id = res.journal_id;
                    this.conmentList = res.data.article_review;

                    // console.log('journal_id', this.journal_id);

                    // 文章状态
                    if (res.data.article_final.state == 0) {
                        this.add_apply = 0;
                    } else {
                        this.add_apply = 1;
                    }
                })
                .catch((err) => {
                    this.$message.error(err);
                });

            this.$api
                .post('api/Finalreview/getArticleFile ', {
                    record_id: this.Art_id
                })
                .then((res) => {
                    for (var i = 0; i < res.data.length; i++) {
                        let date = new Date(parseInt(res.data[i].ctime) * 1000);
                        let Y = date.getFullYear() + '-';
                        let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-';
                        let D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
                        res.data[i].ctime = Y + M + D;
                    }
                    this.fileList = [res.data.manuscirpt];
                    this.picList = res.data.picturesAndTables;
                    this.SMList = res.data.supplementary;

                    // 获取格式
                    let pdfOut = this.fileList[this.fileList.length - 1].file_url;

                    if (pdfOut.substring(pdfOut.lastIndexOf('.') + 1) == 'docx') {
                        this.pdfUrl =
                            'https://view.officeapps.live.com/op/view.aspx?src=https://submission.tmrjournals.com/public/' + pdfOut+`&ui=en-US`;
                        // this.pdfUrl =
                        // 	'https://view.xdocin.com/view?src=https://submission.tmrjournals.com/public/' +
                        // 	pdfOut
                    } else {
                        this.pdfUrl = 'https://submission.tmrjournals.com/public/' + pdfOut+`&ui=en-US`;
                    }
                })
                .catch((err) => {
                    this.$message.error(err);
                });

          
          

           
        },

      
    },
    mounted() {}
};
</script>

<style scoped>
.tet_list {
    font-size: 20px;
}

.box-card {
    margin-bottom: 20px;
    line-height: 24px;
}

.upload-txtc .el-upload-list__item .el-icon-upload-success {
    display: none !important;
}

.tet_list h5 {
    font-size: 15px;
    margin: 20px 0 5px 0;
    font-weight: normal;
    display: inline-block;
}

.tet_list p {
    font-family: Calibri;
    line-height: 22px;
    font-size: 16px;
}

.file_sty {
    margin-bottom: 6px;
}

.file_sty a {
    color: #606266;
    font-size: 14px;
}

.file_sty a:hover {
    text-decoration: underline;
}

.red {
    color: #ff0000;
}

.el-collapse {
    border-top: 0;
    border-bottom: 0;
}

.top_dao:hover {
    text-decoration: underline;
    cursor: pointer;
}

.icon_img {
    width: 15px;
    height: 15px;
    margin-right: 10px;
    vertical-align: middle;
}

.trah_c .icon_img {
    width: 24px;
    height: 24px;
    margin: 0 20px;
}

.el-divider {
    background-color: #006699;
}

.container_l {
    box-sizing: border-box;
    min-width: 1000px;
}

.container_l .box-card {
    height: auto;
}

.lookpdf {
    height: 760px;
    width: 100%;
}

.titlink {
    color: #006699;
    text-decoration: underline;
    cursor: pointer;
}

.morSou {
    color: #006699;
    text-align: right;
    font-weight: bold;
    margin: 5px 0 -10px 0;
}

.morSou i {
    margin-right: 3px;
    font-weight: bold;
}

.morSou:hover {
    text-decoration: underline;
    cursor: pointer;
}

.jouLink {
    color: #006699;
    font-weight: bold;
    margin: 0 0 0 5px;
}

.jouLink:hover {
    text-decoration: underline;
    cursor: pointer;
}
/* 
	#WACRibbonPanel {
		display: none;
	}

	.css-124 {
		display: none;
	}

	.css-138 {
		display: none;
	} */
    ::v-deep .el-descriptions__title{
font-size: 12px !important;
color: #606266 !important;

    }
    ::v-deep .el-descriptions__header{

margin-bottom: 4px !important;
    }
    ::v-deep .el-collapse-item__wrap{

border-bottom: none !important;
    }
    ::v-deep .el-collapse-item__header{

border-bottom: none !important;

/*  */
}
.comment_item{
    border-top: 1px solid #EBEEF5;
    padding-top: 8px;
    padding-bottom: 8px;



}
    .review_title{
        
    }
    .comment_item_recommend_title{
        color: #888;
    margin: 0 5px 0 0;
    font-weight: 600;
    

    }
    .comment_item_recommend b{
        font-weight: 600 !important;

    }
</style>
