<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item> <i class="el-icon-lx-calendar"></i> Manuscript detail </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container_state" v-loading="loading" style="margin: 20px 0 0 0">
            <el-row :gutter="30">
                <el-col :span="16">
                    <div class="art_state_">
                        <div class="art_state_message">
                            <div class="art_state_message_id" style="padding-left: 15px">
                                <font
                                    >Journal : <b style="margin-right: 25px">{{ journal_me }}</b></font
                                >
                                <font
                                    >ID : <b style="margin-right: 25px">{{ form.accept_sn }}</b></font
                                >
                                <font
                                    >Type : <b style="margin-right: 25px">{{ myType }}</b></font
                                >
                                <font
                                    >Major : <b>{{ form.major }}</b></font
                                >
                            </div>
                            <p>
                                <font>Title :</font>
                                <b> {{ form.title }}</b>
                            </p>

                            <!-- <p v-show="form.type=='A'">
								<font>Ethical Approval :</font><b>{{form.approval?'Yes':'No'}}</b>
							</p> -->
                            <p>
                                <font>Ethical Approval :</font><b>{{ form.approval ? 'Yes' : 'No' }}</b>
                                <a
                                    target="_blank"
                                    :href="mediaUrl + form.approval_file"
                                    v-if="form.approval == 1 && form.approval_file != ''"
                                    style="color: #777"
                                >
                                    <img
                                        src="../../assets/img/icon_0.png"
                                        style="vertical-align: text-bottom; margin: 0 10px 0 30px; width: 15px"
                                    />
                                    <font>Ethical approval file</font>
                                    <i
                                        class="el-icon-download download"
                                        style="vertical-align: middle; margin: 0 20px; font-weight: bold; color: #75abf1"
                                    ></i>
                                </a>
                            </p>
                            <p v-if="form.approval == 0 && form.approval_content != ''">
                                <font>Explain the reason clearly :</font><b>{{ form.approval_content }}</b>
                            </p>
                            <p v-if="form.special_num > 0">
                                <font>Special Issues :</font><b>{{ form.special_title }}</b>
                            </p>

                            <el-collapse class="auth_colla auth_collna_ew">
                                <el-collapse-item :title="authorList_name" name="1">
                                    <div v-for="(item, index) in form.authorList" class="auth_mess">
                                        <h4 style="font-weight: bolder">
                                            <img
                                                src="../../assets/img/state_one.png"
                                                v-if="item.isSuper"
                                                style="width: 15px; margin: 0 2px 0 0; vertical-align: text-bottom"
                                            />
                                            {{ item.firstname }} {{ item.lastname }} {{ item.isSuper ? '#' : ''
                                            }}{{ item.isReport ? '*' : '' }}
                                        </h4>
                                        <div>
                                            <p v-if="item.email">
                                                <img
                                                    src="../../assets/img/state_email.png"
                                                    v-if="item.isReport"
                                                    style="width: 14px; margin: 0 8px 0 0; vertical-align: text-bottom"
                                                />
                                                <font>Email : </font>{{ item.email }}
                                            </p>
                                            <p v-if="item.orcid"><font>ORCID iD : </font>{{ item.orcid }}</p>
                                            <p>
                                                <font>First author : </font>
                                                <b v-if="item.isSuper">Yes</b>
                                                <b v-if="!item.isSuper">No</b>
                                            </p>
                                            <p>
                                                <font>Corresponding Author :</font>
                                                <b v-if="item.isReport">Yes</b>
                                                <b v-if="!item.isReport">No</b>
                                            </p>
                                            <!-- <p v-if="item.isReport">
												<font>WOS H index :</font>
												<b v-if="item.indexs_show!=0" style="font-size: 18px;">
													<b :style="{color:item.indexs_color}">{{item.indexs_show}}</b>  
													<font style="font-size: 14px;color: #aaa;margin-left: 5px;">({{now_year}})</font>
												</b>
												<b v-if="item.indexs_show==0" style="color: #aaa;">Null</b>
												<i class="el-icon-edit" @click="HIndexEdit(item)" v-if="form.state==1" style="margin-left: 10px;color: #006699;cursor: pointer;"></i>
											</p> -->
                                            <p v-if="item.address"><font>Address : </font>{{ item.address }}</p>
                                            <p v-if="item.company"><font>Affiliation : </font>{{ item.company }}</p>
                                            <p v-if="item.department"><font>Department : </font>{{ item.department }}</p>
                                            <p v-if="item.title"><font>Title : </font>{{ item.title }}</p>
                                            <p v-if="item.country"><font>Country : </font>{{ item.country }}</p>
                                        </div>
                                    </div>
                                </el-collapse-item>
                            </el-collapse>
                            <el-collapse class="auth_colla auth_collna_ew" style="margin-top: -15px">
                                <el-collapse-item name="2">
                                    <template slot="title">
                                        Abstract
                                        <font v-if="form.keywords" style="margin-left: 3px">, Keywords</font>
                                        <font v-if="form.fund" style="margin-left: 3px">, Fund</font>
                                    </template>
                                    <p>
                                        <font>Abstract :</font><b>{{ form.abstrart }}</b>
                                    </p>
                                    <p v-if="form.keywords">
                                        <font>Keywords :</font><b>{{ form.keywords }}</b>
                                    </p>
                                    <p v-if="form.fund">
                                        <font>Fund :</font><b>{{ form.fund }}</b>
                                    </p>
                                </el-collapse-item>
                            </el-collapse>
                        </div>

                        <div class="art_file_">
                            <el-row :gutter="24">
                                <el-col :span="12" v-if="coverLetterFileList">
                                    <h4>Cover letter :</h4>
                                    <p class="fi_new">
                                        <a v-for="item in coverLetterFileList" :href="mediaUrl + item.file_url">
                                            <img src="../../assets/img/icon_0.png" />
                                            <span>
                                                <font>Uploader : </font>{{ item.username }}
                                                <i><i class="el-icon-time"></i>{{ formatDate(item.ctime) }}</i>
                                            </span>
                                            <i class="el-icon-download download"></i>
                                        </a>
                                    </p>
                                    <br clear="both" />
                                </el-col>
                                <el-col :span="12" v-if="picturesAndTablesFileList">
                                    <h4>Figures :</h4>
                                    <p class="fi_new">
                                        <a v-for="item in picturesAndTablesFileList" :href="mediaUrl + item.file_url">
                                            <img src="../../assets/img/icon_0.png" />
                                            <span>
                                                <font>Uploader : </font>{{ item.username }}
                                                <i><i class="el-icon-time"></i>{{ formatDate(item.ctime) }}</i>
                                            </span>
                                            <i class="el-icon-download download"></i>
                                        </a>
                                    </p>
                                    <br clear="both" />
                                </el-col>
                            </el-row>
                            <el-row :gutter="24">
                                <el-col :span="12" v-if="totalpageFileList">
                                    <h4>Title page :</h4>
                                    <p class="fi_new">
                                        <a v-for="item in totalpageFileList" :href="mediaUrl + item.file_url">
                                            <img src="../../assets/img/icon_0.png" />
                                            <span>
                                                <font>Uploader : </font>{{ item.username }}
                                                <i><i class="el-icon-time"></i>{{ formatDate(item.ctime) }}</i>
                                            </span>
                                            <i class="el-icon-download download"></i>
                                        </a>
                                    </p>
                                    <br clear="both" />
                                </el-col>
                                <el-col :span="12">
                                    <h4>Manuscirpt :</h4>
                                    <p class="fi_new">
                                        <!-- <template v-for="item in manuscirptFileList"> -->
                                            <!-- <a href="#">
                                                <img
                                                    src="../../assets/img/icon_0.png"
                                                    @click="openDrawer(item, mediaUrl + item.file_url)"
                                                />

                                                <span @click="openDrawer(item, mediaUrl + item.file_url)">
                                                    <font>Uploader : </font>{{ item.username }}
                                                    <i><i class="el-icon-time"></i>{{ formatDate(item.ctime) }}</i>
                                                    <i class="el-icon-view" style="font-weight: bold; color: #888; margin: 0 0 0 10px"></i>
                                                </span>
                                                <a :href="mediaUrl + item.file_url">
                                                    <i class="el-icon-download download"></i>
                                                </a>
                                            </a> -->
                                            <a v-for="item in manuscirptFileList" :href="mediaUrl + item.file_url" >
                                            <img src="../../assets/img/icon_0.png" />
                                            <span>
                                                <font>Uploader : </font>{{ form.username }}
                                                <i><i class="el-icon-time"></i>{{ formatDate(item.ctime) }}</i>
                                            </span>
                                            <i class="el-icon-download download"></i>
                                            </a>
                                        <!-- </template> -->
                                    </p>
                                    <br clear="both" />
                                </el-col>
                            </el-row>
                            <el-row :gutter="24" v-if="supplementaryFileList">
                                <el-col :span="24">
                                    <h4>Supplementary Material :</h4>
                                    <p class="fi_new">
                                        <a v-for="item in supplementaryFileList" :href="mediaUrl + item.file_url">
                                            <img src="../../assets/img/icon_0.png" />
                                            <span>
                                                <font>Uploader : </font>{{ item.username }}
                                                <i><i class="el-icon-time"></i>{{ formatDate(item.ctime) }}</i>
                                            </span>
                                            <i class="el-icon-download download"></i>
                                        </a>
                                    </p>
                                    <br clear="both" />
                                </el-col>
                            </el-row>

                            <el-row v-if="responseFileList != ''">
                                <div style="height: 1px; width: 98%; background-color: #ebeef5; margin: 5px auto 20px auto"></div>

                                <el-col :span="24">
                                    <h4>Response to reviewers :</h4>
                                    <p class="fi_new">
                                        <a v-for="item in responseFileList" :href="mediaUrl + item.file_url">
                                            <img src="../../assets/img/icon_0.png" />
                                            <span>
                                                <font>Uploader : </font>{{ form.username }}
                                                <i><i class="el-icon-time"></i>{{ formatDate(item.artr_ctime) }}</i>
                                            </span>
                                            <i class="el-icon-download download"></i>
                                        </a>
                                    </p>
                                </el-col>
                            </el-row>
                        </div>
                        <common-word-html
                            :articleId="$route.query.id"
                            style=" box-sizing: border-box"
                           
                            
                        ></common-word-html>
                    </div>
                    <!-- 被拒稿件操作 --->
                    <div class="art_caozuo_" v-if="opname == 'rejectArticles'">
                        <p>
                            <span>Status : </span>
                            <b>{{ articleState }}</b>
                        </p>
                        <p>
                            <span>Remarks : </span>
                            <b>{{ form.remarks }}</b>
                        </p>
                        <p>
                            <span>Repetition : </span>
                            <b>{{ form.repetition }}%</b>
                        </p>
                        <!--<br clear="both">
							 <el-button type="primary" @click="showResubmit" style="margin: 15px 0 0 0;">Resubmit the manuscript
						</el-button>						 -->
                    </div>
                    <!-- 常规稿件操作 -->
                    <div class="art_caozuo_" v-else>
                        <p>
                            <span>Status : </span>
                            <b>{{ articleState }}</b>
                            <el-button type="text" @click="testvis" icon="el-icon-edit">Change</el-button>
                        </p>
                        <p>
                            <span>Remarks : </span>
                            <b>{{ form.remarks }}</b>
                            <el-button type="text" @click="testedit" icon="el-icon-edit">Change</el-button>
                        </p>
                        <p>
                            <span>Repetition : </span>
                            <b>{{ form.repetition }}%</b>
                            <a :href="mediaUrl + form.repeurl" v-if="form.repeurl" class="zip_load" target="_blank">
                                <img src="../../assets/img/icon_0.png" />
                                <span>Duplicate check file</span>
                                <i class="el-icon-download download"></i>
                            </a>
                            <el-button type="text" @click="changeRepe" icon="el-icon-edit">Change</el-button>
                        </p>
                        <p>
                            <span style="display: inline-block; vertical-align: top; margin-top: 7px">Manuscirpt : </span>
                            <el-upload
                                style="display: inline-block"
                                class="upload-demo"
                                :action="upload_manuscirpt"
                                accept=".docx,"
                                name="manuscirpt"
                                :before-upload="beforeupload_manuscirpt"
                                :on-error="uperr_coverLetter"
                                :on-success="upSuccess_manuscirpt"
                                :limit="1"
                                :on-exceed="alertlimit"
                                :on-remove="removefilemanuscirpt"
                            >
                                <div class="el-upload__text" style="padding: 8px 5px">
                                    <em>Click Upload</em>
                                </div>
                                <div class="el-upload__tip" slot="tip">Only word and compressed files can be uploaded(.docx)</div>
                            </el-upload>
                            <br clear="both" />
                            <el-button type="primary" @click="onsubmit" style="margin: 15px 0 0 0">Upload Submit </el-button>
                        </p>
                    </div>
                </el-col>
                <el-col :span="8">
                    <timetalk :talkMsgs="talkMsgs" :msgform="msgform" @talksave="talksave"></timetalk>
                    <div class="tree_box">
                        <h2 style="margin: 0 0 20px 0">Manuscript Tracking</h2>
                        <div class="block">
                            <el-timeline>
                                <el-timeline-item :timestamp="formatDate_(form.ctime)" placement="top">
                                    <el-card>
                                        <p style="line-height: 20px">
                                            Manuscript submission :
                                            <b>{{ form.username }}</b>
                                            submitted to
                                            <b>{{ journal_me }}</b>
                                        </p>
                                    </el-card>
                                </el-timeline-item>
                                <el-timeline-item
                                    v-for="(activity, index) in msgs"
                                    :key="index"
                                    :timestamp="formatDate_(activity.ctime)"
                                    placement="top"
                                >
                                    <el-card v-if="activity.ftype == 0">
                                        <p>Status change : {{ statetostr(activity.state_to) }}</p>
                                        <p v-if="activity.content != ''">{{ activity.content }}</p>
                                    </el-card>
                                    <el-card v-else>
                                        <p style="margin-bottom: 5px; font-weight: bold">Author message :</p>
                                        <p style="line-height: 18px">{{ activity.content }}</p>
                                    </el-card>
                                    <!-- <el-card>
			                     <p>state change :{{statetostr(activity.state_from)}} => {{statetostr(activity.state_to)}}</p>
			                     <p>{{activity.content}}</p>
			                 </el-card> -->
                                </el-timeline-item>
                            </el-timeline>
                        </div>
                    </div>
                </el-col>
            </el-row>
        </div>

        <!-- H指数修改弹出框 -->
        <el-dialog title="Edit H Index" :visible.sync="HEditVisible" width="400px">
            <div style="margin: 0 0 20px 10px; font-weight: bold">{{ HIxForm.realname }}</div>
            <div style="margin: 0 0 20px 10px">Email :{{ HIxForm.email }}</div>
            <el-form ref="old_Form" :model="HIxForm" label-width="150px">
                <el-form-item>
                    <span slot="label"> WOS H index ({{ this.now_year }}) </span>
                    <el-input v-model="HIxForm.index"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="saveHIx(HIxForm)">OK</el-button>
            </span>
        </el-dialog>

        <el-dialog title="Change Status" :visible.sync="editVisible" width="550px" v-loading="loading1">
            <el-form ref="editform" :model="editform" label-width="170px">
                <el-form-item label="">
                    <span slot="label">
                        <i style="color: #f56c6c">*</i>
                        Status :
                    </span>
                    <el-select v-model="editform.state" placeholder="Please select">
                        <el-option
                            v-for="item in items"
                            :key="item.state"
                            :label="item.title"
                            :value="item.state"
                            :disabled="item.disabled"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="Comments for authors :" v-show="editform.state == 4">
                    <el-input type="textarea" rows="3" v-model="editform.proposal_content" placeholder="" resize="4"> </el-input>
                </el-form-item>
                <el-form-item label="Transfer :" v-show="editform.state == 3 && form.transList.length == 0">
                    <el-select v-model="editform.trsjournal" placeholder="Please select">
                        <el-option :key="0" label="No Transfer" :value="0"></el-option>
                        <el-option
                            v-for="item in journals"
                            :key="item.journal_id"
                            :label="item.title"
                            :value="item.journal_id"
                            :disabled="item.journal_id == form.journal"
                        ></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editVisible = false">Cancel</el-button>
                <el-button type="primary" @click="saveEdit">Save</el-button>
            </span>
        </el-dialog>
        <el-dialog title="Remarks" :visible.sync="editbox" width="550px" v-loading="loading2">
            <el-form ref="remark" :model="remark" label-width="85px">
                <el-form-item label="Content :">
                    <el-input type="textarea" rows="5" v-model="remark.content"></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editbox = false">Cancel</el-button>
                <el-button type="primary" @click="saveRemark">Save</el-button>
            </span>
        </el-dialog>
        <el-dialog title="Repetition" :visible.sync="repebox" width="550px" v-loading="loading3">
            <el-form ref="repetition" :model="repeform" label-width="90px">
                <el-form-item label="Content :">
                    <el-input maxlength="3" style="width: 100px" v-model="repeform.repefen">
                        <template slot="append">%</template>
                    </el-input>
                </el-form-item>
                <el-form-item label="Zip :">
                    <el-upload
                        class="upload-demo"
                        :action="upload_zip"
                        accept=".rar, .zip"
                        name="repezip"
                        :on-success="upSuccess_repezip"
                        :limit="1"
                        :on-exceed="alertlimit"
                        :on-remove="removefilerepezip"
                    >
                        <div class="el-upload__text" style="padding: 0 5px">
                            <em>Click Upload</em>
                        </div>
                        <div class="el-upload__tip" slot="tip">Only pdf and word files can be uploaded(.pdf,.doc,.docx)</div>
                    </el-upload>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="repebox = false">Cancel</el-button>
                <el-button type="primary" @click="saveRepe">Save</el-button>
            </span>
        </el-dialog>
        <el-dialog title="Resubmit the manuscript" :visible.sync="resubmitVisible" width="550px" v-loading="loading4">
            <el-form ref="resubmitJournal" :model="resubmitJournal" label-width="120" :rules="Resubmitrules">
                <el-form-item label="journal" prop="journalId">
                    <el-select
                        v-if="editorJournalList.length > 0"
                        v-model="resubmitJournal.journalId"
                        filterable
                        placeholder="Please select a manuscript"
                    >
                        <el-option v-for="item in editorJournalList" :key="item.journal_id" :label="item.title" :value="item.journal_id">
                        </el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="closeResubmit">Cancel</el-button>
                <el-button type="primary" @click="saveResubmit">Save</el-button>
            </span>
        </el-dialog>
        <el-drawer
            append-to-body
            destroy-on-close
            :title="previewData.drawerTitle"
            :visible.sync="drawer"
            direction="rtl"
            :before-close="handleClose"
            size="1000px"
        >
            <template #title>
                <div style="display: inline-block; vertical-align: top">
                    Manuscirpt :
                    <img
                        src="../../assets/img/icon_0.png"
                        style="
                            width: 15px;

                            margin: 0 5px 0 0;
                            margin-left: 10px;
                        "
                    />

                    <span>
                        <font>Uploader : </font>{{ previewData.username }}
                        <i style="color: #888; margin: 0 20px; font-style: normal"
                            ><i class="el-icon-time" style="margin-right: 10px"></i>{{ formatDate(previewData.ctime) }}</i
                        >
                        <a :href="mediaUrl + previewData.file_url">
                            <i class="el-icon-download download" style="color: #75abf1; font-weight: bold"></i>
                        </a>
                    </span>
                </div>
            </template>
            <iframe
                :src="`https://view.officeapps.live.com/op/view.aspx?src=${previewData.previewUrl}&ui=en-US`"
                width="100%"
                height="98%"
                frameborder="0"
            ></iframe>
        </el-drawer>
    </div>
</template>

<script>
import timetalk from './time_talk';
export default {
    components: {
        timetalk
    },
    data() {
        return {
            previewData: {},
            baseUrl: this.Common.baseUrl,
            mediaUrl: this.Common.mediaUrl,
            now_year: 0,
            items: '',
            drawer: false,
            loading: false,
            loading1: false,
            loading2: false,
            loading3: false,
            loading4: false,
            editVisible: false,
            editbox: false,
            resubmitVisible: false,
            repebox: false,
            HEditVisible: false,
            HIxForm: {
                index: ''
            },
            coverLetterFileList: [],
            picturesAndTablesFileList: [],
            totalpageFileList: [],
            supplementaryFileList: [],
            manuscirptFileList: [],
            responseFileList: [],
            authorList_name: '',
            activeNames: ['2'],
            editform: {
                editname: localStorage.getItem('U_name'),
                articleId: this.$route.query.id,
                state: 0,
                trsjournal: 0,
                editormsg: '',
                proposal_content: ''
            },
            remark: {
                articleId: this.$route.query.id,
                content: ''
            },
            repeform: {
                articleId: this.$route.query.id,
                repefen: '',
                zipurl: ''
            },
            journals: [],
            items: [
                {
                    state: 0,
                    title: this.$t('artstate.state0'),
                    disabled: true
                },
                {
                    state: 1,
                    title: this.$t('artstate.state1')
                },
                {
                    state: 2,
                    title: this.$t('artstate.state2')
                },
                {
                    state: 3,
                    title: this.$t('artstate.state3')
                },
                {
                    state: 4,
                    title: this.$t('artstate.state4')
                },
                {
                    state: 6,
                    title: this.$t('artstate.state6')
                },
                {
                    state: 5,
                    title: this.$t('artstate.state5')
                }
            ],
            form: {
                articleId: this.$route.query.id,
                journal: '',
                journalname: '',
                username: '',
                title: '',
                accept_sn: '',
                abstrart: '',
                keyWords: '',
                fund: '',
                type: '',
                major: '',
                approval: false,
                approval_file: '',
                approval_content: '',
                repetition: '',
                manuscirpt: '',
                remarks: '',
                state: '',
                ctime: '',
                authorList: [],
                transList: []
            },
            msgs: [],
            msgform: {
                username: localStorage.getItem('U_name'),
                article_id: this.$route.query.id,
                user_id: '',
                ad_content: ''
            },
            talkMsgs: [],
            opname: '', // 稿件详细类型
            editorJournalList: [], // 编辑期刊列表
            resubmitJournal: {
                journalId: null, // 转投期刊的id
                manuscriptId: null // article id
            },
            Resubmitrules: {
                journalId: [{ required: true, message: 'Please select the name of the journal to be forwarded to' }]
            }
        };
    },
    created: function () {
        this.initarticle();

        this.initFileList();
        this.getWordimgList();
        this.getWordTablesList();
    },
    computed: {
        myType: function () {
            let frag = '';
            switch (this.form.type) {
                case 'A':
                    frag = 'ARTICLE';
                    break;
                case 'B':
                    frag = 'REVIEW';
                    break;
                case 'C':
                    frag = 'CASE REPORT';
                    break;
                case 'P':
                    frag = 'RESEARCH PROPOSAL';
                    break;
                case 'N':
                    frag = 'NEWS';
                    break;
                case 'T':
                    frag = 'COMMENT';
                    break;
                case 'CT':
                    frag = 'CORRECTION';
                    break;
                case 'HT':
                    frag = 'HYPOTHESIS';
                    break;
                case 'PF':
                    frag = 'PREFACE';
                    break;
                case 'ET':
                    frag = 'EDITORIAL';
                    break;
                case 'RP':
                    frag = 'REPORT';
                    break;
                case 'LR':
                    frag = 'LETTER';
                    break;
                case 'EF':
                    frag = 'EMPIRICAL FORMULA';
                    break;
                case 'EM':
                    frag = 'EVIDENCE-BASED MEDICINE';
                    break;
                case 'EC':
                    frag = 'EXPERT CONSENSUS';
                    break;
                case 'LTE':
                    frag = 'LETTER TO EDITOR';
                    break;
                case 'QI':
                    frag = 'QUESTIONNAIRE INVESTIGATION';
                    break;
                case 'PT':
                    frag = 'PROTOCOL';
                    break;
                case 'CS':
                    frag = 'CASE SERIES';
                    break;
                case 'RT':
                    frag = 'RETRACTION';
                    break;
                case 'MR':
                    frag = 'MINI REVIEW';
                    break;
                default:
                    frag = 'OTHERS';
            }
            return frag;
        },
        // coverLetterUrl: function() {
        //     return this.baseUrl + this.form.coverLetter;
        // },
        // picturesAndTablesUrl: function() {
        //     return this.baseUrl + this.form.picturesAndTables;
        // },
        manuscirptUrl: function () {
            return this.baseUrl + this.form.manuscirpt;
        },
        upload_coverLetter: function () {
            return this.baseUrl + 'api/Article/up_file/type/coverLetter';
        },
        upload_picturesAndTables: function () {
            return this.baseUrl + 'api/Article/up_file/type/picturesAndTables';
        },
        upload_manuscirpt: function () {
            return this.baseUrl + 'api/Article/up_file/type/manuscirpt';
        },
        upload_zip: function () {
            return this.baseUrl + 'api/Article/up_file/type/repezip';
        },
        journal_me: function () {
            var frag = this.form.journalname;
            if (this.form.special_num > 0) {
                frag += '(Special Issues)';
            }
            return frag;
        },
        articleState: function () {
            let str = '';
            switch (this.form.state) {
                case 0:
                    str = this.$t('artstate.state0');
                    break;
                case 1:
                    str = this.$t('artstate.state1');
                    break;
                case 2:
                    str = this.$t('artstate.state2');
                    break;
                case 3:
                    str = this.$t('artstate.state3');
                    break;
                case 4:
                    str = this.$t('artstate.state4');
                    break;
                case 5:
                    str = this.$t('artstate.state5');
                    break;
                case 6:
                    str = this.$t('artstate.state6');
                    break;
            }
            return str;
        }
    },
    methods: {
        async getWordimgList() {
            var that = this;
            await this.$api
                .post('api/Article/getArticleImages', {
                    article_id: this.$route.query.id
                })
                .then(async (res) => {
                    this.wordimgList = res.data.list;
                    if (this.wordimgList.length > 0) {
                        await this.$commonJS.getWordImagesThumbnails(this.wordimgList, function (html) {
                            that.imagesHtml = html;
                        });
                    }
                });
        },
        getWordTablesList() {
            this.$api
                .post('api/Article/getArticleTable', {
                    article_id: this.$route.query.id
                })
                .then((res) => {
                    console.log('res at line 2210:', res);
                    var that = this;
                    that.tables = res.data.list && res.data.list.length > 0 ? JSON.parse(res.data.list[0].table) : [];
                    if (that.tables.length > 0) {
                        that.$commonJS.getWordTablesThumbnails(that.tables, function (html) {
                            that.tablesHtml = html;
                        });
                    }
                });
        },
        openDrawer(data, url) {
        console.log('url at line 799:',data, url)
            this.previewData = {
                ...data,
                previewUrl: url,
                drawerTitle: 'Uploader : ' + data.username + '  ' + this.formatDate(data.ctime)
            };
            this.drawer = true;
        },
        handleClose() {
            this.drawer = false;
        },
        talksave(val) {
            this.msgform.ad_content = '';
            this.getTalkList();
        },
        //弹出编辑框
        testvis() {
            this.editform.state = this.form.state;
            this.editVisible = true;
        },
        testedit() {
            this.editbox = true;
        },
        changeRepe() {
            this.repebox = true;
        },
        statetostr(mystate) {
            let str = '';
            switch (mystate) {
                case 0:
                    str = this.$t('artstate.state0');
                    break;
                case 1:
                    str = this.$t('artstate.state1');
                    break;
                case 2:
                    str = this.$t('artstate.state2');
                    break;
                case 3:
                    str = this.$t('artstate.state3');
                    break;
                case 4:
                    str = this.$t('artstate.state4');
                    break;
                case 5:
                    str = this.$t('artstate.state5');
                    break;
                case 6:
                    str = this.$t('artstate.state6');
                    break;
            }
            return str;
        },
        async editArticleStatus() {
            this.loading1 = true;

            await this.$api
                .post('api/Article/editArticleEditor', this.editform)
                .then((res) => {
                    this.loading1 = false;
                    if (res.code == 1) {
                        this.$message.error(res.msg);
                    } else {
                        this.$message.success('success');
                        this.editVisible = false;
                        this.$router.go(0);
                    }
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        async checkArticleStatus() {
            var status;
            var msg = '';
            await this.$api
                .post('api/Article/checkArticleStart', { article_id: this.editform.articleId })
                .then((res) => {
                    if (res.code == 1) {
                        status = 1;

                        msg = res.msg;
                    } else {
                        status = 0;
                    }
                })
                .catch((err) => {
                    status = 'err';
                    // this.$message.err()
                    console.log(err);
                });

            return { status: status, msg: msg };
        },

        //修改文章状态
        async saveEdit() {
            if (this.form.state == 0) {
                if (this.form.state != this.editform.state) {
                    var data = await this.checkArticleStatus();
                    if (data.status == 1) {
                        await this.$confirm(data.msg, this.$t('journalStatus.Prompt'), {
                            confirmButtonText: this.$t('journalStatus.Continue'),
                            cancelButtonText: this.$t('journalStatus.Cancel'),
                            type: 'warning'
                        })
                            .then(async () => {
                                this.editVisible = false;
                                await this.editArticleStatus();
                            })
                            .catch(() => {
                                this.editVisible = false;
                            });
                    } else if (data.status == 0) {
                        this.editArticleStatus();
                    }
                } else {
                    this.editVisible = false;
                }
            } else {
                this.editArticleStatus();
            }
        },
        saveRemark() {
            this.loading2 = true;
            this.$api.post('api/Article/editArticleRemark', this.remark).then((res) => {
                this.loading2 = false;
                this.$message.success('success');
                this.$router.go(0);
            });
        },
        saveRepe() {
            if (this.repeform.zipurl == '') {
                this.$message.error('please upload zip');
                return false;
            }
            this.loading3 = true;
            this.$api.post('api/Article/changeRepetition', this.repeform).then((res) => {
                this.loading3 = false;
                this.$message.success('success');
                this.$router.go(0);
            });
        },

        //初始化期刊信息
        initarticle() {
            this.now_year = new Date().getFullYear();
            this.$api
                .post('api/Article/getArticleDetail', {
                    articleId: this.editform.articleId,
                    human: 'editor'
                })
                .then((res) => {
                    this.form.username = res.article.account;
                    this.form.title = res.article.title;
                    this.form.journal = res.article.journal_id;
                    this.form.journalname = res.article.journalname;
                    this.form.abstrart = res.article.abstrart;
                    this.form.accept_sn = res.article.accept_sn;
                    this.form.keywords = res.article.keywords;
                    this.form.fund = res.article.fund;
                    this.form.type = res.article.type;
                    this.form.special_num = res.article.special_num;
                    this.form.special_title = res.article.special_title;
                    this.form.major = res.major;
                    this.form.approval = res.article.approval == 1 ? true : false;
                    this.form.approval_file = res.article.approval_file;
                    this.form.approval_content = res.article.approval_content;
                    this.form.repetition = res.article.repetition;
                    this.form.remarks = res.article.remarks;
                    this.form.repeurl = res.article.repeurl;
                    this.repeform.repefen = res.article.repetition;
                    this.remark.content = res.article.remarks;
                    this.form.state = res.article.state;
                    this.form.ctime = res.article.ctime;
                    this.form.transList = res.transfer;
                    this.msgs = res.msg;
                    var alist = res.authors;
                    let alist_name = [];
                    for (var i in alist) {
                        let index_h = 0;
                        let index_c = '#000';
                        this.form.authorList.push({
                            art_aut_id: alist[i].art_aut_id,
                            firstname: alist[i].firstname,
                            lastname: alist[i].lastname,
                            orcid: alist[i].orcid,
                            company: alist[i].company,
                            department: alist[i].department,
                            title: alist[i].author_title,
                            country: alist[i].country,
                            email: alist[i].email,
                            address: alist[i].address,
                            isSuper: alist[i].is_super == 1 ? true : false,
                            isReport: alist[i].is_report == 1 ? true : false
                            // indexs_show: index_h,
                            // indexs_color: index_c,
                        });
                        // if (alist[i].is_report) {
                        // 	this.$api
                        // 		.post('api/User/getIndexByEmail', {
                        // 			email: alist[i].email
                        // 		})
                        // 		.then(res => {
                        // 			if (res.data.indexs.length != 0) {
                        // 				if (res.data.indexs[0].year == this.now_year) {
                        // 					index_h = res.data.indexs[0].h_index
                        // 					if (index_h < 5) {
                        // 						index_c = "#cb160a"
                        // 					} else if (index_h < 10) {
                        // 						index_c = "#cbb504"
                        // 					} else {
                        // 						index_c = "#0cbc15"
                        // 					}
                        // 					this.form.authorList[i].indexs_show = index_h
                        // 					this.form.authorList[i].indexs_color = index_c
                        // 				}
                        // 			}
                        // 		})
                        // 		.catch(err => {
                        // 			console.log(err);
                        // 		});
                        // }
                        if (i == alist.length - 1) {
                            alist_name.push(alist[i].firstname + ' ' + alist[i].lastname);
                        } else {
                            alist_name.push(alist[i].firstname + ' ' + alist[i].lastname + ' , ');
                        }
                    }
                    this.authorList_name = 'Author : ' + alist_name.join('');
                    this.msgform.user_id = res.article.user_id;

                    this.$api
                        .post('api/Article/getJournalsByMajor', {
                            major_id: res.article.major_id
                        })
                        .then((res) => {
                            this.journals = res.data.journals;
                        });
                })
                .catch((err) => {
                    console.log(err);
                });

            // 获取作者发给审稿人邮件列表
            this.$api
                .post('api/Article/getArticleResponseFiles', {
                    article_id: this.editform.articleId
                })
                .then((res) => {
                    this.responseFileList = res.data.files;
                })
                .catch((err) => {
                    console.log(err);
                });

            // 留言板列表
            this.$api
                .post('api/Article/getArticleDialogs', {
                    article_id: this.$route.query.id
                })
                .then((res) => {
                    this.talkMsgs = res.data.dialogs;
                })
                .catch((err) => {
                    console.log(err);
                });
        },

        // 获取留言列表
        getTalkList() {
            this.$api
                .post('api/Article/getArticleDialogs', {
                    article_id: this.$route.query.id
                })
                .then((res) => {
                    this.talkMsgs = res.data.dialogs;
                })
                .catch((err) => {
                    console.log(err);
                });
        },

        // H指数修改
        HIndexEdit(row) {
            this.HEditVisible = true;
            this.HIxForm.email = row.email;
            this.HIxForm.realname = row.firstname + row.lastname;
            this.HIxForm.year = this.now_year;
            if (row.indexs_show != 0) {
                this.HIxForm.index = row.indexs_show;
            } else {
                this.HIxForm.index = '';
            }
        },
        // 保存index
        saveHIx() {
            this.$api
                .post('api/User/editIndexByEmail', this.HIxForm)
                .then((res) => {
                    if (res.code == 0) {
                        this.$message.success('Edit H Index succeeded');
                        this.HEditVisible = false;
                        this.form.authorList = [];
                        this.initarticle();
                    } else {
                        this.$message.error(res.msg);
                    }
                })
                .catch((err) => {
                    this.$message.error(err);
                });
        },

        //初始化filelist
        initFileList() {
            this.$api
                .post('api/Article/getFilelistByArticleID', {
                    articleId: this.form.articleId
                })
                .then((res) => {
                    this.coverLetterFileList = res.coverLetter;
                    this.picturesAndTablesFileList = res.picturesAndTables;
                    this.manuscirptFileList = res.manuscirpt;
                    this.totalpageFileList = res.totalpage;
                    this.supplementaryFileList = res.supplementary;
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        uperr_coverLetter(err) {
            this.$message.error('upload error');
        },
        beforeupload() {},
        filedateformate(row, column, cellValue, index) {
            return this.formatDate(cellValue);
        },
        // upSuccess_coverLetter(res, file) {
        //     if (res.code == 0) {
        //         this.form.coverLetter = 'coverLetter/' + res.upurl;
        //     } else {
        //         this.$message.error('service error：' + res.msg);
        //     }
        // },
        // upSuccess_picturesAndTables(res, file) {
        //     if (res.code == 0) {
        //         this.form.picturesAndTables = 'picturesAndTables/' + res.upurl;
        //     } else {
        //         this.$message.error('service error：' + res.msg);
        //     }
        // },
        upSuccess_manuscirpt(res, file) {
            if (res.code == 0) {
                this.form.manuscirpt = 'manuscirpt/' + res.upurl;
            } else {
                this.$message.error('service error：' + res.msg);
            }
        },
        upSuccess_repezip(res, file) {
            if (res.code == 0) {
                this.repeform.zipurl = 'repezip/' + res.upurl;
            }
        },
        //超出传送文件个数限制
        alertlimit() {
            this.$message.error('The maximum number of uploaded files has been exceeded');
        },
        getlinkurl(row) {
            return this.mediaUrl + row.file_url;
        },
        //检验上传文件的格式
        beforeupload_manuscirpt(file) {
            let flieArr = file.name.split('.');
            let fileSuffix = flieArr[flieArr.length - 1];
            if (fileSuffix != 'docx') {
                this.$message.error('Only word and compressed files can be uploaded(.docx)');
                return false;
            }
            // const ismau =
            //     file.type === 'application/msword' ||
            //     file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'||
            //     file.type === 'application/x-zip-compressed' ||
            //     file.name.split(".")[1] === 'rar';
            // if (!ismau) {
            //     this.$message.error('Only word and compressed files(.doc,.docx,.rar,.zip)');
            // }
            // return ismau;
        },
        //清除文件时的事件
        removefilemanuscirpt(file, fileList) {
            this.form.manuscirpt = '';
        },
        removefilerepezip(file, fileList) {
            this.repeform.zipurl = '';
        },
        formatDate(timestamp) {
            var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
            var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
            var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
            var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
            var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
            return Y + M + D;
        },
        formatDate_(timestamp) {
            var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
            var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
            var h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
            var m = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
            var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
            return Y + M + D + ' ' + h + ':' + m + ':' + s;
        },
        onsubmit() {
            if (this.form.manuscirpt == '') {
                this.$message.error('Manuscirpt is required!');
                return false;
            }
            this.loading = true;
            this.$api
                .post('api/Article/changeArticleFileEditor', this.form)
                .then((res) => {
                    this.loading = false;
                    this.$message.success('success');
                    this.$router.go(0);
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        // 显示转投稿件弹窗
        showResubmit() {
            this.loading4 = true;

            this.$api
                .post('api/Journal/getJournalByeditor', { user_id: localStorage.getItem('U_id') })
                .then((res) => {
                    this.loading4 = false;
                    this.editorJournalList = res.data.journals;
                    console.log(res);
                    this.resubmitVisible = true;
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        // 提交转投稿件
        saveResubmit() {
            // 验证表单
            this.$refs['resubmitJournal'].validate((valid) => {
                if (valid) {
                    alert('submit!');
                    console.log(this.resubmitJournal);
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        // 关闭弹窗
        closeResubmit() {
            (this.resubmitVisible = false), this.$refs['resubmitJournal'].resetFields();
        }
    },
    mounted() {
        this.opname = this.$route.query.mark;
        this.resubmitJournal.manuscriptId = this.$route.query.id;
    }
};
</script>

<style scoped>
.art_state_ {
    padding: 20px 20px 1px 20px;
}

.art_state_ .art_state_message_id {
    margin-bottom: 15px;
    color: #777;
    line-height: 22px;
    padding: 0 0 15px 5px;
}

.art_state_message_id > font {
    display: inline-block;
}

.art_state_message_id b {
    letter-spacing: -1px;
    color: #333;
}

.tree_box {
    border: 1px solid #dcdfe6;
    border-radius: 5px;
    background-color: #fff;
    padding: 20px;
}

.art_caozuo_ > p {
    margin: 0 0 10px 10px;
}

.art_caozuo_ > p:last-child {
    margin-bottom: 0;
}

.art_caozuo_ > p > span {
    color: #777;
    margin: 0 15px 0 0;
}

.art_caozuo_ > p > button {
    margin-left: 25px;
    font-weight: bold;
}

.art_caozuo_ > p > button:hover {
    text-decoration: underline;
}

.el-upload__tip {
    display: inline-block;
    line-height: 32px;
    margin: 0 0 0 15px;
    color: #888 !important;
    vertical-align: text-bottom;
}

.art_file {
}

.art_file_ h4 {
    margin: 1px 0 5px 15px;
    float: left;
    color: #777;
    font-weight: normal;
}

.art_file_ p.fi_new {
    margin: 0 0 0 10px;
    margin-bottom: 10px;
    float: left;
}

.art_file_ p.fi_new > a {
    color: #333;
    display: block;
    margin: 0 0 10px 0;
}

.art_file_ p.fi_new > a:hover {
    text-decoration: underline;
}

.art_file_ p.fi_new > a > img {
    width: 15px;
    vertical-align: text-bottom;
    margin: 0 5px 0 0;
}

.art_file_ p.fi_new > a > span > font {
    color: #888;
    margin: 0 5px 0 0;
    font-size: 13px;
    letter-spacing: -1px;
}

.art_file_ p.fi_new > a > span > i {
    font-size: 12px;
    color: #888;
    margin: 0 0 0 3px;
    font-style: normal;
}

.art_file_ p.fi_new > a > span > i > i {
    margin: 0 5px 0 0;
}

.art_file_ .download {
    font-weight: bold;
    color: #75abf1;
    margin: 0 0 0 10px;
}

.art_state_message p {
    margin-left: 15px;
}
::v-deep .el-drawer__header {
    margin-bottom: 0;
    padding: 15px;
}
::v-deep #wacframe #AppHeaderPanel {
    width: 98% !important;
}
::v-deep .el-drawer__wrapper .WACContainer {
    z-index: 10000 !important;
}
</style>
