<template>
    <div style="">
        <div style="display: flex; justify-content: space-between">
            <div style="width: 100%; min-width: 1020px; position: relative">
                <div class="step_list_new">
                    <el-steps align-center>
                        <!-- 状态  已完成 未完成 正在填写 -->
                        <el-step
                            @click.native="StepCode(item, i)"
                            style="cursor: pointer; padding: 20px 0 10px"
                            v-for="(item, i) in listStep"
                            :key="item.index"
                            :data-step-index="item.index"
                            :class="{
                                C_style: show_step === item.index,
                                'step-success': stepStatus[i] && stepStatus[i].status == 1,
                                'step-edit': stepStatus[i] && stepStatus[i].status == 2,
                                'step-saved': stepStatus[i] && stepStatus[i].status == 3
                            }"
                        >
                            <template #icon v-if="stepStatus && stepStatus.length > 0" @click.stop="StepCode(item)">
                                <span v-if="stepStatus[i].status == 0"> </span>
                                <span class="step_icon" v-if="stepStatus[i].status == 1">
                                    <i class="el-icon-check" style="font-size: 21px"></i>
                                </span>

                                <span class="step_icon" v-if="stepStatus[i].status == 2">
                                    <i class="el-icon-edit-outline" style="font-size: 22px"></i>
                                </span>
                                <span class="step_icon" v-if="stepStatus[i].status == 3">
                                    <i class="el-icon-check" style="font-size: 21px"></i>
                                </span>
                            </template>
                            <template #icon v-else>
                                <span @click.stop="StepCode(item)"> </span>
                            </template>
                            <template #title>
                                <div style="" class="step_title" @click.stop="StepCode(item)">
                                    <div style="">
                                        <i :class="item.icon" style="font-size: 22px; margin-right: 4px"></i>
                                        <span style="font-size: 17px">{{ item.title }}</span>
                                    </div>
                                </div>
                            </template>
                        </el-step>
                    </el-steps>
                </div>

                <!-- <ProgressBar :progress="uploadPercentage" v-if="isShowProgress" /> -->
                <div class="manu_add" style="width: calc(100% - 20px)" v-loading="loading">
                    <el-form ref="articleform" :model="form" :rules="rules" label-width="120px">
                        <div class="bag_color" v-if="show_step == 1">
                            <div>
                                <h3>Manuscript Information</h3>

                                <el-form-item label="Journal :" prop="journal">
                                    <JournalSelector
                                        ref="journalSelector"
                                        @selected="handleJournalSelected"
                                        :list="items"
                                        :check_item="check_item"
                                        :journal_id="form.journal ? Number(form.journal) : 0"
                                    />
                                </el-form-item>

                                <el-form-item label="Type :" prop="type">
                                    <el-select v-model="form.type" style="width: 240px" placeholder="">
                                        <el-option
                                            v-for="item in journal_type"
                                            :key="item.value"
                                            :label="item.name"
                                            :value="item.value"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="Manuscript :" prop="manuscirpt" label-width="120px">
                                    <el-upload
                                        :on-progress="handleProgress"
                                        ref="uploadFileManuscirpt"
                                        class="upload-demo up_newstyle"
                                        :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"
                                        :file-list="fileL_manuscirpt"
                                        :on-preview="dowloadFile"
                                    >
                                        <div class="el-upload__text" @click="removefilemanuscirpt">
                                            <em>Upload</em>
                                        </div>
                                        <div class="el-upload__tip" slot="tip">
                                            Only Word and compressed files can be uploaded (file format: .docx).
                                        </div>
                                    </el-upload>
                                </el-form-item>
                                <el-form-item label="Manuscript Title :" prop="title" label-width="160px">
                                    <el-input v-model="form.title" type="textarea" rows="2"></el-input>
                                </el-form-item>

                                <el-form-item label="Whether ethical approval was obtained ?" prop="approval" label-width="290px">
                                    <el-radio-group v-model="form.approval">
                                        <el-radio :label="1">Yes</el-radio>
                                        <el-radio :label="0">No</el-radio>
                                    </el-radio-group>
                                </el-form-item>
                                <el-form-item
                                    label="Ethical approval file :"
                                    prop="approval_file"
                                    v-if="form.approval == 1"
                                    label-width="290px"
                                >
                                    <el-upload
                                        ref="approval_file"
                                        class="upload-demo up_newstyle"
                                        :action="upload_articleApproval"
                                        accept=".pdf"
                                        name="articleApproval"
                                        :before-upload="beforeupload_articleApproval"
                                        :on-error="uperr_coverLetter"
                                        :on-success="upSuccess_articleApproval"
                                        :limit="1"
                                        :on-exceed="alertlimit"
                                        :on-remove="removefilearticleApproval"
                                        :file-list="fileL_articleApproval"
                                        :on-preview="dowloadFile"
                                    >
                                        <div class="el-upload__text">
                                            <em>Upload</em>
                                        </div>
                                        <div
                                            class="el-upload__tip"
                                            slot="tip"
                                            style="line-height: 20px; left: 80px; font-size: 13px; top: -9px"
                                        >
                                            Only PDF and compressed files can be uploaded.<br />
                                            <span style="color: #8c8d8f"
                                                >Please ensure that the file includes the ethics approval number and the institutional
                                                approval document.</span
                                            >
                                        </div>
                                    </el-upload>
                                </el-form-item>
                                <el-form-item
                                    label="Explain the reason clearly :"
                                    prop="approval_content"
                                    v-if="form.approval === 0"
                                    label-width="290px"
                                >
                                    <el-input type="textarea" rows="2" v-model="form.approval_content"></el-input>
                                </el-form-item>
                                <el-form-item label="Abstract :" prop="abstrart">
                                    <el-input
                                        type="textarea"
                                        v-model="form.abstrart"
                                        :autosize="{ minRows: 1, maxRows: 100 }"
                                        class="full-show-no-scroll"
                                        placeholder=""
                                    />
                                </el-form-item>
                                <!-- 话题 -->
                                <!-- <el-form-item label="Topics :" prop="topics">
							<el-cascader disabled class="formTopics" @change="topicsChange"
							v-model="form.topics"
							:options="topicsList"
							:props="topicsProps"
							clearable></el-cascader>
						</el-form-item> -->

                                <el-form-item label="Key words :">
                                    <div v-if="keywordsList && keywordsList.length > 0">
                                        <el-checkbox
                                            :indeterminate="isIndeterminate"
                                            v-model="checkAll"
                                            @change="handleCheckAllChange"
                                            style="color: #006699"
                                            >Select All</el-checkbox
                                        >
                                        <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
                                            <div
                                                v-for="(item, index) in keywordsList"
                                                :key="index"
                                                style="margin-right: 16px; display: inline-block"
                                            >
                                                <el-checkbox style="margin-right: 4px" :label="index + 1" v-model="item.checked">{{
                                                    item.keyword
                                                }}</el-checkbox>
                                                <el-input
                                                    :name="index + 1"
                                                    v-model="item.ke"
                                                    clearable
                                                    style="width: 150px; margin-right: 15px; margin-bottom: 3px"
                                                >
                                                </el-input>
                                            </div>
                                        </el-checkbox-group>
                                    </div>

                                    <el-button type="text" @click="addfund">
                                        <i class="el-icon-circle-plus-outline">Add</i>
                                    </el-button>
                                    <el-button
                                        v-if="checkedCities.length > 0"
                                        type="text"
                                        @click="deletefund"
                                        style="color: #f56c6c; margin-left: 20px"
                                    >
                                        <i class="el-icon-remove-outline" style="color: #f56c6c">Delete</i>
                                    </el-button>
                                </el-form-item>
                                <el-form-item label="Fund :">
                                    <el-input v-model="form.fund" type="textarea" rows="2"> </el-input>
                                </el-form-item>

                                <div style="text-align: center; margin: 40px 0 0 0">
                                    <el-button type="warning" @click="onStagingSave(1)" class="pro_stage">Save as draft </el-button>
                                    <el-button type="primary" @click="onStep(1)" class="pro_ceed"
                                        >Save and proceed to the next step</el-button
                                    >
                                </div>
                            </div>
                        </div>

                        <div class="bag_color" v-if="show_step == 2">
                            <div>
                                <div>
                                    <h3 style="display: none">
                                        Associated Authors
                                        <el-tooltip
                                            class="item"
                                            effect="light"
                                            content="If you've submitted articles to TMR Publishing Group before, we'll display your previous collaborators' information here."
                                            placement="right"
                                        >
                                            <i class="el-icon-info"></i>
                                        </el-tooltip>

                                        <el-button @click="forWarMark" type="primary" style="float: right">
                                            <i class="el-icon-arrow-up" v-if="!forWard"> Show all authors</i>
                                            <i class="el-icon-arrow-down" v-else> Hide all authors</i>
                                        </el-button>
                                        <!-- <p class="zyfont" style="font-weight: normal;margin-top: 5px;">
									If you have previously published articles with the TMR Publishing Group, information
									about your past collaborators will be displayed here.
								</p> -->
                                    </h3>
                                    <!-- <div
                                        v-if="!forWard"
                                        style="height: 1px; background-color: #b3d0ef; width: 900px; margin: -5px auto 20px auto"
                                    ></div> -->
                                    <div class="forWard" v-if="forWard">
                                        <div v-for="(item, index) in raltiAutList" style="position: relative">
                                            <p style="font-weight: bold; margin-bottom: 10px">
                                                {{ item.firstname }} {{ item.lastname }}
                                                <span v-if="!item.showHide" style="font-weight: normal; margin-left: 10px"
                                                    >({{ item.email }})</span
                                                >
                                                <i
                                                    v-if="item.showHide"
                                                    @click="raltSHpin(index, 0)"
                                                    class="el-icon-caret-top jiantouBiao"
                                                ></i>
                                                <i
                                                    v-if="!item.showHide"
                                                    @click="raltSHpin(index, 1)"
                                                    class="el-icon-caret-bottom jiantouBiao"
                                                ></i>
                                            </p>
                                            <p v-if="item.showHide">
                                                <font>E-mail :</font>
                                                {{ item.email }}
                                            </p>
                                            <p v-if="item.orcid && item.showHide">
                                                <font>ORCID iD :</font>
                                                {{ item.orcid }}
                                            </p>

                                            <p v-if="item.title && item.showHide">
                                                <font>Title :</font>
                                                {{ item.title }}
                                            </p>
                                            <p v-if="item.company && item.showHide">
                                                <font>Affiliation :</font>
                                                {{ item.company }}
                                            </p>
                                            <p v-if="item.department && item.showHide">
                                                <font>Department :</font>
                                                {{ item.department }}
                                            </p>
                                            <p v-if="item.address && item.showHide">
                                                <font>Address :</font>
                                                {{ item.address }}
                                            </p>
                                            <p v-if="item.country && item.showHide">
                                                <font>Country :</font>
                                                {{ item.country }}
                                            </p>
                                            <div style="position: absolute; right: 0; top: 0">
                                                <el-button type="primary" plain size="mini" @click="checkAuthor(item, index)">
                                                    <i class="el-icon-plus" style="font-size: 10px; display: inline"></i>
                                                    Add author
                                                </el-button>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <h3>
                                    Author Information
                                    <el-button @click="addAuthor" type="primary" style="float: right">
                                        <i class="el-icon-plus"> Add author</i>
                                    </el-button>
                                    <p class="zyfont" style="font-weight: normal; margin-top: 5px">
                                        The number of First Authors and Corresponding Authors should not exceed two each.
                                    </p>
                                </h3>
                                <div class="partyAry">
                                    <div v-for="(item, index) in form.authorList">
                                        <p style="text-align: right; margin-bottom: 10px; border-bottom: 1px solid #dae8f7">
                                            <span style="float: left; margin-top: 5px">Author {{ index + 1 }}</span>
                                            <el-button @click="editAuthor(item, index)" type="text">
                                                <i class="el-icon-edit" style="font-weight: bold; font-size: 14px"></i>
                                            </el-button>
                                            <el-button type="text" @click="gaPaiXu(item, 'top')" v-if="index != 0">
                                                <i class="el-icon-top" style="font-weight: bold; font-size: 14px"></i>
                                            </el-button>
                                            <el-button type="text" @click="gaPaiXu(item, 'bot')" v-if="index != form.authorList.length - 1">
                                                <i class="el-icon-bottom" style="font-weight: bold; font-size: 14px"></i>
                                            </el-button>
                                            <el-button @click="deleteAuthor(item, index)" type="text" class="Del_btn">
                                                <i class="el-icon-delete" style="font-weight: bold; font-size: 14px"></i>
                                            </el-button>
                                        </p>
                                        <p style="font-weight: bold; margin-bottom: 10px">
                                            {{ item.firstname }} {{ item.lastname }} {{ item.isSuper ? '#' : ''
                                            }}{{ item.isReport ? '*' : '' }}
                                        </p>
                                        <p>
                                            <font>E-mail :</font>
                                            {{ item.email }}
                                        </p>
                                        <p v-if="item.orcid">
                                            <font>ORCID iD :</font>
                                            {{ item.orcid }}
                                        </p>
                                        <p v-if="item.title">
                                            <font>Title :</font>
                                            {{ item.title }}
                                        </p>
                                        <div
                                            v-if="item.organ_name"
                                            style="display: flex; align-items: flex-start; justify-content: space-between"
                                        >
                                            <font style="color: #777; line-height: 24px">Affiliation :</font>
                                            <p style="width: calc(100% - 80px)">
                                                <span
                                                    v-for="(organ_name, index) in item.organ_name"
                                                    :key="index"
                                                    style="
                                                        margin-bottom: 4px;
                                                        display: flex;
                                                        align-items: flex-start;
                                                        justify-content: space-between;
                                                    "
                                                >
                                                    <span style="color: #006699">{{ index + 1 }}.</span>
                                                    <span style="width: calc(100% - 20px); display: inline-block; line-height: 24px">{{
                                                        organ_name
                                                    }}</span>
                                                </span>
                                            </p>
                                        </div>
                                        <!-- <p v-if="item.department">
                                            <font>Department :</font>
                                            {{ item.department }}
                                        </p>
                                        <p v-if="item.address">
                                            <font>Address :</font>
                                            {{ item.address }}
                                        </p> -->
                                        <p v-if="item.country">
                                            <font>Country :</font>
                                            {{ item.country }}
                                        </p>
                                    </div>
                                </div>

                                <p style="color: #777; font-size: 14px; margin-bottom: 5px">
                                    Please note that based on your input the author names will appear as follows:
                                </p>
                                <p>
                                    <span v-for="(item, index) in form.authorList">
                                        {{ item.firstname }} {{ item.lastname }} {{ item.isSuper ? '#' : '' }}{{ item.isReport ? '*' : '' }}
                                        <span v-if="index != form.authorList.length - 1">;</span>
                                    </span>
                                </p>

                                <div style="text-align: center; margin: 40px 0 0 0">
                                    <!-- <el-button type="warning" @click="onStagingSave(2)" class="pro_stage">Save as draft
							</el-button> -->
                                    <el-button type="primary" @click="onStep(2)" class="pro_ceed">Proceed to the next step</el-button>
                                </div>
                            </div>
                        </div>

                        <div class="bag_color" v-if="show_step == 3">
                            <div>
                                <h3>Upload Manuscript</h3>
                                <el-form-item label="Cover letter :" label-width="220px">
                                    <el-upload
                                        class="upload-demo up_newstyle"
                                        :action="upload_coverLetter"
                                        accept=".pdf, .doc, .docx"
                                        name="coverLetter"
                                        :before-upload="beforeupload_coverLetter"
                                        :on-error="uperr_coverLetter"
                                        :on-success="upSuccess_coverLetter"
                                        :limit="1"
                                        :on-exceed="alertlimit"
                                        :on-remove="removefilecoverLetter"
                                        :file-list="fileL_coverLetter"
                                        :on-preview="dowloadFile"
                                    >
                                        <div class="el-upload__text">
                                            <em>Upload</em>
                                        </div>
                                        <div class="el-upload__tip" slot="tip">
                                            Only PDF and Word files can be uploaded (file formats: .pdf, .doc, .docx).
                                        </div>
                                    </el-upload>
                                </el-form-item>
                                <el-form-item label-width="220px">
                                    <span slot="label">
                                        Figures
                                        <el-popover placement="top-start" width="350" trigger="hover">
                                            <p style="line-height: 24px; word-wrap: break-word; word-break: normal; text-align: left">
                                                Dear Author
                                                <br />Except for the experimental graphs covered in this article; the statistical graphs of
                                                the experimental results in this article; the model graphs produced by the author of this
                                                article. <br />For images from any other source : <br />1. Please make sure that the author
                                                owns the copyright of the image. <br />2. Obtain written authorization from the original
                                                copyright owner (please upload proof of copyright authorization, including a screenshot of
                                                the other party's authorization email or authorization letter).
                                            </p>
                                            <i
                                                class="el-icon-info"
                                                slot="reference"
                                                style="color: #ef8429; cursor: pointer; vertical-align: super; font-size: 20px"
                                            ></i>
                                        </el-popover>
                                        :
                                    </span>
                                    <el-upload
                                        class="upload-demo up_newstyle"
                                        :action="upload_picturesAndTables"
                                        accept=".zip"
                                        name="picturesAndTables"
                                        :before-upload="beforeupload_picturesAndTables"
                                        :on-error="uperr_coverLetter"
                                        :on-success="upSuccess_picturesAndTables"
                                        :limit="1"
                                        :on-exceed="alertlimit"
                                        :on-remove="removefilepicturesAndTables"
                                        :file-list="fileL_picturesAndTables"
                                        :on-preview="dowloadFile"
                                    >
                                        <div class="el-upload__text">
                                            <em>Upload</em>
                                        </div>
                                        <div class="el-upload__tip" slot="tip">Only ZIP files can be uploaded (file format: .zip).</div>
                                    </el-upload>
                                </el-form-item>
                                <!-- <el-form-item label="Title page :" prop="totalpage">
							<el-upload class="upload-dem up_newstyle" :action="upload_totalpage" accept=".doc, .docx" name="totalpage"
							 :before-upload="beforeupload_totalpage" :on-error="uperr_coverLetter" :on-success="upSuccess_totalpage" :limit="1"
							 :on-exceed="alertlimit" :on-remove="removefiletotalpage">
								<div class="el-upload__text">
									<em>Upload</em>
								</div>
								<div class="el-upload__tip" slot="tip">Only word files can be uploaded(.doc,.docx)</div>
							</el-upload>
						</el-form-item> -->
                                <el-form-item label="Manuscript :" prop="manuscirpt" label-width="220px">
                                    <el-upload
                                        :on-progress="handleProgress"
                                        ref="uploadFileManuscirpt"
                                        class="upload-demo up_newstyle up_disabled"
                                        :action="upload_manuscirpt"
                                        accept=".docx"
                                        name="manuscirpt"
                                        :disabled="true"
                                        :before-upload="beforeupload_manuscirpt"
                                        :on-error="uperr_coverLetter"
                                        :on-success="upSuccess_manuscirpt"
                                        :limit="1"
                                        :on-exceed="alertlimit"
                                        :file-list="fileL_manuscirpt"
                                        :on-preview="dowloadFile"
                                    >
                                        <div class="el-upload__text" style="border: none !important">
                                            <!-- <em>Upload</em> -->
                                        </div>
                                    </el-upload>
                                </el-form-item>
                                <el-form-item label="Supplementary Material :" label-width="220px">
                                    <el-upload
                                        class="upload-demo up_newstyle"
                                        :action="upload_supplementary"
                                        accept=".zip"
                                        name="supplementary"
                                        :before-upload="beforeupload_supplementary"
                                        :on-error="uperr_coverLetter"
                                        :on-success="upSuccess_supplementary"
                                        :limit="1"
                                        :on-exceed="alertlimit"
                                        :on-remove="removefilesupplementary"
                                        :file-list="fileL_supplementary"
                                        :on-preview="dowloadFile"
                                    >
                                        <div class="el-upload__text">
                                            <em>Upload</em>
                                        </div>
                                        <div
                                            class="el-upload__tip"
                                            slot="tip"
                                            style="line-height: 20px; left: 80px; font-size: 13px; top: -9px"
                                        >
                                            Only ZIP files can be uploaded (file formats: .zip).

                                            <br />
                                            <span style="color: #888"
                                                >Please upload the original, uncropped full-length Western blot images.</span
                                            >
                                        </div>
                                    </el-upload>
                                </el-form-item>
                                <el-form-item label="Figure Copyright Declaration :" label-width="220px" prop="is_figure_copyright">
                                    <div style="color: #333">
                                        <el-radio v-model="form.is_figure_copyright" label="2" style="width: 100%"
                                            >I confirm that all figures in this manuscript are original.</el-radio
                                        >
                                        <el-radio v-model="form.is_figure_copyright" label="1"
                                            >I confirm that all figures in this manuscript used with proper permission.</el-radio
                                        >

                                        <el-form-item
                                            label=""
                                            prop="figurecopyright_file"
                                            v-if="form.is_figure_copyright == 1"
                                            label-width="0px"
                                        >
                                            <div style="position: relative; top: 4px; margin-left: 14px">
                                                <el-upload
                                                    ref="uploadFile"
                                                    class="upload-demo up_newstyle"
                                                    :action="upload_articleCopyright"
                                                    accept=".pdf, .zip"
                                                    name="figurecopyright"
                                                    :before-upload="beforeupload_articleCopyright"
                                                    :on-error="uperr_coverLetter"
                                                    :on-success="upSuccess_articleCopyright"
                                                    :limit="1"
                                                    :on-exceed="alertlimit"
                                                    :on-remove="removefilearticleCopyright"
                                                    :file-list="fileL_articleCopyright"
                                                    :on-preview="dowloadFile"
                                                >
                                                    <div class="el-upload__text" @click="clearUploadedCopyrightFile">
                                                        <em>Upload</em>
                                                    </div>
                                                    <div class="el-upload__tip" slot="tip" style="color: #888; left: 80px; font-size: 13px">
                                                        Upload the copyright permission letters or license documents figures. (file format:
                                                        .pdf, .zip)<br />
                                                    </div>
                                                </el-upload>
                                            </div>
                                        </el-form-item>
                                    </div>
                                </el-form-item>

                                <el-form-item
                                    label="Has artificial intelligence been used in the article ?"
                                    prop="is_use_ai"
                                    label-width="340px"
                                >
                                    <el-radio-group v-model="form.is_use_ai" @input="changeUseAi">
                                        <el-radio :label="1">Yes</el-radio>
                                        <el-radio :label="2">No</el-radio>
                                    </el-radio-group>
                                    <div v-if="form.is_use_ai == 1">
                                        <el-input type="textarea" v-model="form.use_ai_explain" :rows="4"></el-input>
                                    </div>
                                </el-form-item>
                                <div style="text-align: center; margin: 40px 0 0 0">
                                    <el-button type="warning" @click="onStagingSave(3)" class="pro_stage">Save as draft </el-button>
                                    <el-button type="primary" @click="onStep(3)" class="pro_ceed"
                                        >Save and proceed to the next step</el-button
                                    >
                                </div>
                            </div>
                        </div>
                        <!-- 提交 submit -->
                        <div class="bag_color" v-show="show_step == 4">
                            <div>
                                <el-form-item label="Research areas :" prop="major" label-width="120px">
                                    <template slot="label">
                                        <span style="color: #f56c6c; margin-right: 4px">*</span>Research area :
                                    </template>

                                    <common-major-list :list="majorValueList" @load="(e) => (this.majorValueList = e)"></common-major-list>
                                </el-form-item>
                                <!-- <h3>Co-submitting</h3>
                                <p style="line-height: 25px; margin: 0 10px 0 55px; font-size: 14px">
                                    TMR Publishing Group publishes multiple journals and offers you the opportunity to co-submit your paper.
                                    If your manuscript is not deemed suitable for the first journal, it can be automatically transferred
                                    along with reviews and reviewers' identities (cascading peer-review) to another journal of your choice.
                                    Please note that you can choose up to two journals only.
                                    <br />
                                    <el-switch
                                        style="margin-top: 20px"
                                        @change="changeSwitch($event)"
                                        v-model="form.istransfer"
                                        active-text="Yes"
                                        inactive-text="No"
                                    ></el-switch>
                                </p>
                                <el-form-item label="Journals :" v-show="form.istransfer" label-width="130px" style="margin-top: 20px">
                                    <div style="margin-bottom: 0">
                                        <p class="zyfont">1. {{ getjournalbyid(form.journal) }}</p>
                                        <p class="zyfont" v-for="(cjou, index) in form.checkedjours" :key="index">
                                            {{ index + 2 }}. {{ getjournalbyid(cjou) }}
                                        </p>
                                    </div>
                                    <el-checkbox-group v-model="form.checkedjours" :max="1" style="margin-top: 10px">
                                        <el-checkbox
                                            v-for="jour in mj_jour"
                                            :label="jour.journal_id"
                                            :disabled="jour.journal_id == form.journal"
                                            :key="jour.journal_id"
                                            class="tally_jour"
                                            v-if="jour.journal_id != form.journal"
                                            >{{ jour.title }}
                                        </el-checkbox>
                                    </el-checkbox-group>
                                </el-form-item> -->

                                <h3 style="margin-top: 35px">Suggesting reviewers</h3>
                                <p style="margin: -55px 10px 0 55px; font-size: 14px; text-align: right">
                                    <el-button
                                        :disabled="tuiJianForm.length == 3"
                                        type="primary"
                                        @click="onAddTuijian"
                                        plain
                                        icon="el-icon-plus"
                                        style="width: 210px"
                                        >Add Recommended Reviewer</el-button
                                    >
                                </p>
                                <p style="margin: 5px 10px 0 55px; font-size: 14px; line-height: 22px">
                                    (Non-essential)
                                    <br />While authors are welcome to suggest potential reviewers, the final review on the selection of
                                    reviewers is at the discretion of the editorial board. The following criteria are generally considered
                                    when selecting reviewers: <br />1. The reviewer should hold a Ph.D. degree (or equivalent) in a relevant
                                    field. <br />2. The reviewer should have published at least three articles on the subject matter of the
                                    manuscript, one of which was published within the last five years and is indexed in the WOS database.
                                    <br />3. The reviewer should not be affiliated with the same institution as the author, and should not
                                    have a close collaborative or personal relationship with the author. Conflict of interest should be
                                    avoided. <br />4. The editorial board encourages diversity in reviewer selection, with respect to gender
                                    and geographic location.
                                </p>
                                <el-form
                                    ref="tuiJianForm"
                                    v-for="(item, index) in tuiJianForm"
                                    :rules="tuiJianRules"
                                    label-position="top"
                                    label-width="110px"
                                    class="tuijian_f"
                                    :model="item"
                                >
                                    <p>
                                        Reviewer <span style="margin: 0 0 0 3px">{{ index + 1 }}</span>
                                    </p>
                                    <el-form-item label="Realname :" prop="realname">
                                        <template slot="label">
                                            <span style="color: red">*</span>
                                            Name :
                                        </template>
                                        <el-input v-model="item.realname" clearable></el-input>
                                    </el-form-item>
                                    <el-form-item label="Email :" prop="email">
                                        <template slot="label">
                                            <span style="color: red">*</span>
                                            Email :
                                        </template>
                                        <el-input v-model="item.email" :validate-event="false" clearable></el-input>
                                    </el-form-item>
                                    <!-- <el-form-item label="Department :" prop="department">
                                        <template slot="label">
                                            <span style="color: red">*</span>
                                            Department :
                                        </template>
                                        <el-input v-model="item.department" clearable></el-input>
                                    </el-form-item> -->
                                    <el-form-item label="Affiliation :" prop="company">
                                        <template slot="label">
                                            <span style="color: red">*</span>
                                            Affiliation :
                                        </template>
                                        <el-input v-model="item.company" :validate-event="false" clearable></el-input>
                                    </el-form-item>
                                    <el-form-item label="Filed :" prop="major_all">
                                        <template slot="label"> Filed : </template>
                                        <el-cascader
                                            placeholder=""
                                            :options="step4MajorList"
                                            v-model="item.major_all"
                                            :props="default4Params"
                                            clearable
                                        ></el-cascader>
                                    </el-form-item>
                                    <el-button
                                        :disabled="tuiJianForm.length == 1"
                                        @click="onDeleteTuijian(item, index)"
                                        type="danger"
                                        icon="el-icon-delete"
                                        class="shanchu_tj"
                                    ></el-button>
                                </el-form>

                                <p style="font-size: 12px; color: #888; margin: 15px 10px 0px 55px; line-height: 18px">
                                    You can suggest 3 potential reviewers, which can help speed up the review process.
                                    <br /><b style="letter-spacing: -0.5px">Please pay attention:</b> <br />Authors may suggest potential
                                    reviewers if they wish. However, whether or not to consider these reviewers is at the editor's
                                    discretion. Authors should not suggest recent collaborators or colleagues who work in the same
                                    institution as themselves. Authors who wish to suggest peer reviewers should provide institutional email
                                    addresses where possible or information that will help the editor verify the identity of the reviewer.
                                    <br />Authors may request the exclusion of individuals as peer reviewers, but they should explain the
                                    reasons in their cover letter on submission. Authors should not exclude too many individuals as this may
                                    hinder the peer review process. Intentionally falsifying information, for example, suggesting reviewers
                                    with a false name or email address, will result in rejection of the manuscript and may lead to further
                                    investigation in line with our misconduct policy.
                                </p>

                                <div style="margin: 30px 0 30px 0px">
                                    <el-form-item label-width="180px">
                                        <span slot="label">
                                            Invitation code
                                            <el-popover placement="top-start" width="320" trigger="hover">
                                                <p style="line-height: 24px; word-wrap: break-word; word-break: normal; text-align: left">
                                                    The journal encourages scientists to invite their colleagues or collaborators to submit
                                                    manuscripts in order to promote collaboration and expand the journal's author network.
                                                    You will be rewarded with credits that can be used to offset APC (specific details
                                                    subject to journal policies) and gain priority in editorial board selection.
                                                </p>
                                                <i
                                                    class="el-icon-info"
                                                    slot="reference"
                                                    style="color: #ef8429; cursor: pointer; vertical-align: super; font-size: 20px"
                                                ></i>
                                            </el-popover>
                                            :
                                        </span>
                                        <el-input v-model="form.code" style="width: 200px"></el-input>
                                    </el-form-item>
                                </div>
                                <el-form-item
                                    label="Article Processing Charge :"
                                    v-if="form.journal && form.journal != 0"
                                    label-width="220px"
                                >
                                    $ {{ getFee(form.journal) }}
                                    <div style="color: #8c8d8f" v-if="getFee(form.journal) && getFee(form.journal) != '0.00'">
                                       
                                        <div v-if="check_item.apc_url&&check_item.apc_content" >
                                            <i class="el-icon-warning" style="color: #517fd5; margin-right: 4px"></i><span class="apc_content" v-html="check_item.apc_content"></span>
                                        </div>
                                        <!-- <div v-if="form.journal == 1">
                                            <i class="el-icon-warning" style="color: #517fd5; margin-right: 4px"></i>The article processing
                                            fee applies to papers submitted and ultimately accepted for publication after January 1, 2025.
                                            For authors seeking to apply for fee discounts, please
                                            <a
                                                style="color: rgb(81, 127, 213); cursor: pointer; text-decoration: underline"
                                                href="https://www.tmrjournals.com/tmr/free-application/"
                                                target="_blank"
                                                >click here</a
                                            >
                                            to view detailed policies.
                                        </div> -->
                                        <div v-else>
                                            <i class="el-icon-warning" style="color: #517fd5; margin-right: 4px"></i>For more details about the Article Processing Charge (APC), please visit:
                                            <a
                                                style="color: rgb(81, 127, 213); cursor: pointer; text-decoration: underline"
                                                :href="check_item.apc_url"
                                                target="_blank"
                                                >{{check_item.apc_url}}</a
                                            >
                                           
                                        </div>
                                    </div>
                                </el-form-item>

                                <div style="margin: 0px 0 30px 30px">
                                    <el-checkbox v-model="agreechecked" style="font-weight: bold">I accept </el-checkbox>
                                    <el-link @click="licensebox = true" type="primary" style="padding-left: 5px; font-weight: bold">
                                        the license agreement</el-link
                                    >
                                </div>

                                <div style="text-align: center; margin: 40px 0 0 0">
                                    <el-button type="warning" @click="onStagingSave(4)" class="pro_stage">Save as draft </el-button>
                                    <el-button type="primary" @click="onSubmit(1)" class="pro_ceed">Confirm Submit </el-button>
                                </div>
                            </div>
                        </div>
                    </el-form>
                </div>
            </div>
            <div
                style="
                    padding: 0;
                    background: none;
                    margin-top: 20px;
                    line-height: 20px;
                    color: #999;
                    left: 990px;
                    top: 120px;
                    width: 400px;
                    font-size: 14px;
                "
            >
                <p
                    style="
                        width: 400px;
                        border: 1px solid #ebeef5;
                        font-size: 12px;
                        line-height: 16px;
                        background-color: #fff;
                        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
                        border-radius: 8px;
                        padding: 10px;
                        box-sizing: border-box;
                    "
                >
                    We encourage authors to upload a Cover Letter file and Highlights is also be encouraged. That will help authors let
                    editors quickly obtain information and evaluate the scientific value of their research correctly.
                    <br />Please remind our editor in the cover letter if you want your manuscript processed quickly. <br />Please note that
                    manuscripts with at least one of the following characteristics will be included in the journal's manuscript fast track:
                    <br />
                    <font style="color: #006699">1.Interest:</font> This manuscript has a novel perspective.
                    <br />
                    <font style="color: #006699">2.Importance:</font> This manuscript belongs to the focus area.
                    <br />
                    <font style="color: #006699">3.Value:</font> This manuscript belongs to the advanced topic and can attract wide
                    attention.
                    <br />
                    <span style="margin-top: 6px">
                        please download the manuscript template
                        <font @click="dowloadFileTemplate()" style="color: #006699; margin-left: 2px; cursor: pointer">
                            <i class="el-icon-download" style="font-weight: bold"></i> Microsoft Word template</font
                        >.
                    </span>
                </p>
                <common-word-html
                    :articleId="stagingID"
                    imgHeight="120px"
                    v-if="isShowCommonWord && stagingID"
                    style="margin-top: 10px; box-sizing: border-box; background-color: #fff"
                ></common-word-html>
            </div>
        </div>

        <el-dialog title="" :visible.sync="licensebox" width="500px" :close-on-click-modal="false">
            <span style="word-wrap: break-word; word-break: normal; line-height: 22px">
                Creative Commons Licensing<br /><br />
                TMR Publishing Group provides authors the choice of applying the Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
                licenses defined below, to be determined after acceptance:<br /><br />
                Attribution: CC BY-NC 4.0<br /><br />
                This license lets others distribute, remix, tweak, and build upon your work. They can not use the material for commercial
                purposes.<br /><br />
                Copyright<br />
                Authors retain the copyright of their manuscripts.
            </span>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="licensebox = false">OK</el-button>
            </span>
        </el-dialog>

        <!-- 选择期刊弹出框 -->
        <el-dialog title="Change Journal" :visible.sync="changeVisible" width="780px" :close-on-click-modal="false">
            <el-form :model="jour_form" :rules="rules" label-width="85px">
                <el-form-item label="Journal" prop="journal">
                    <div
                        v-for="item in items"
                        @click="ch_Jour(item.journal_id)"
                        :class="jour_form.journal == item.journal_id ? 'jour_ku B_style' : 'jour_ku'"
                    >
                        {{ item.title }}
                    </div>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="changeVisible = false">Cancel</el-button>
                <el-button type="primary" @click="close_ch_Jour()">OK</el-button>
            </span>
        </el-dialog>

        <!-- 添加修改作者弹出框 -->
        <el-dialog
            title="Author Information"
            :visible.sync="authorVisible"
            width="900px"
            @close="closeAuthorDialog"
            :close-on-click-modal="false"
        >
            <p style="font-weight: bold; margin: -10px 30px 30px 30px">
                {{ authMeaIN.firstname }} {{ authMeaIN.lastname }} {{ authMeaIN.isSuper ? '#' : '' }}{{ authMeaIN.isReport ? '*' : '' }}
            </p>

            <el-form :model="authMeaIN" :rules="rules" label-width="85px" ref="authMeaINForm">
                <el-form-item label-width="120px">
                    <span slot="label">
                        <span style="color: #f56c6c">*</span>
                        E-mail :
                    </span>
                    <el-autocomplete
                        class="inline-input"
                        v-model="authMeaIN.email"
                        :fetch-suggestions="
                            (queryString, callback) => {
                                chaMateFit(queryString, callback, 1);
                            }
                        "
                        :trigger-on-focus="false"
                        @select="
                            (authMeaIN) => {
                                chaSelChose(authMeaIN, 1);
                            }
                        "
                        style="width: 578px"
                    >
                        <i class="el-icon-loading el-input__icon" slot="suffix" v-if="authMeaIN.load"> </i>
                    </el-autocomplete>
                </el-form-item>
                <el-form-item label-width="120px">
                    <span slot="label">
                        <span style="color: #f56c6c">*</span>
                        Name :
                    </span>
                    <el-input v-model="authMeaIN.firstname" style="width: 280px; margin-right: 20px"></el-input>
                    <el-input v-model="authMeaIN.lastname" style="width: 280px"> </el-input>
                </el-form-item>
                <el-form-item label="ORCID iD :" label-width="120px" prop="orcid">
                    <el-input v-model="authMeaIN.orcid" style="width: 280px"> </el-input>
                    <a href="https://orcid.org/register" target="_blank" class="orcid_link">Register for an ORCID iD</a>
                </el-form-item>
                <el-form-item label="First author :" label-width="180px">
                    <el-switch v-model="authMeaIN.isSuper" active-text="yes" inactive-text="no" @change="chanSelt"> </el-switch>
                </el-form-item>
                <el-form-item label="Corresponding author :" label-width="180px">
                    <el-switch v-model="authMeaIN.isReport" active-text="yes" inactive-text="no" @change="chanSelt"> </el-switch>
                </el-form-item>
                <el-form-item label="Title :" label-width="120px">
                    <span slot="label">
                        <span style="color: #f56c6c">*</span>
                        Title :
                    </span>
                    <el-select v-model="authMeaIN.title" style="width: 280px" @change="chanSelt" placeholder="">
                        <el-option key="Prof." label="Prof." value="Prof."></el-option>
                        <el-option key="Associate Prof." label="Associate Prof." value="Associate Prof."></el-option>
                        <el-option key="Assistant Prof." label="Assistant Prof." value="Assistant Prof."></el-option>
                        <el-option key="Ph.D." label="Ph.D." value="Ph.D."></el-option>
                        <el-option key="Others" label="Others" value="Others"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="Affiliation :" label-width="120px" prop="affiliation">
                    <template slot="label">
                        <span style="color: red">*</span>
                        Affiliation :
                    </template>
                    <div class="checkbox-container">
                        <span style="margin-bottom: 4px; display: inline-block">
                            <i class="el-icon-warning" style="color: #517fd5; margin-right: 4px"></i>If the organization name you're looking
                            for doesn't appear, you can
                            <span style="color: rgb(81, 127, 213); cursor: pointer; text-decoration: underline" @click="handleClickHere"
                                >click here</span
                            >
                            to add your organization.
                        </span>

                        <div class="add-new-option" style="display: flex; align-items: center" v-if="showAddOption">
                            <el-input
                                size="mini"
                                ref="newOptionInput"
                                v-model="newOptionLabel"
                                placeholder=""
                                class="input-new-option"
                            ></el-input>
                            <el-button
                                type="primary"
                                plain
                                size="mini"
                                style="margin-left: 20px"
                                @click="addNewOption"
                                :disabled="!newOptionLabel.trim()"
                            >
                                + Add
                            </el-button>
                            <el-button
                                type=""
                                size="mini"
                                style="margin-left: 10px"
                                @click="
                                    newOptionLabel = '';
                                    showAddOption = false;
                                "
                            >
                                Cancel
                            </el-button>
                        </div>

                        <!-- 复选框组 - 两栏布局 -->
                        <el-checkbox-group v-model="selectedAffiliations" class="checkbox-group">
                            <div class="checkbox-two-columns">
                                <div v-for="item in affiliationList" :key="item.id" class="checkbox-item">
                                    <el-checkbox style="" :label="item.id">
                                        <div class="checkbox-item-title">{{ item.label }}</div>
                                    </el-checkbox>
                                    <span class="checkbox-item-actions" style=""
                                        ><i class="el-icon-edit" style="color: #006699" @click="editAffiliation(item.id, item.label)"></i>
                                        <i class="el-icon-delete-solid" style="color: red" @click="removeAffiliation(item.id)"></i
                                    ></span>
                                </div>
                            </div>
                        </el-checkbox-group>
                    </div>
                </el-form-item>
                <!-- <el-form-item label="Department :" label-width="120px">
                    <el-input v-model="authMeaIN.department"></el-input>
                </el-form-item>
                <el-form-item label="Address :" label-width="120px">
                    <span slot="label">
                        <span style="color: #f56c6c" v-show="authMeaIN.isReport">*</span>
                        Address :
                    </span>
                    <el-input v-model="authMeaIN.address"></el-input>
                </el-form-item> -->
                <el-form-item label-width="120px">
                    <span slot="label">
                        <span style="color: #f56c6c">*</span>
                        Country :
                    </span>
                    <el-select v-model="authMeaIN.country" filterable style="width: 280px" placeholder="">
                        <el-option v-for="it in countrys" :key="it.en_name" :label="it.en_name" :value="it.en_name"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="closeAuthorDialog">Cancel</el-button>
                <el-button type="primary" @click="saveAuthor(authMeaIN)">OK</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import bus from '@/components/common/bus.js';
import { debounce, throttle } from '@/common/js/debounce';
import JournalSelector from '@/components/page/components/article/journal-selector.vue';
import ProgressBar from '@/components/page/components/article/progress.vue';
import { updateStepStatus, markStepAsSaved } from '@/components/page/components/article/checkStepCompletion.js';
import deepEqual from '@/components/page/components/article/deepEqual.js';
import { set } from 'vue';
export default {
    components: {
        JournalSelector,
        ProgressBar
    },
    data() {
        // 自定义校验：禁止QQ邮箱
        const validateNotQQEmail = (rule, value, callback) => {
            // 通用邮箱格式正则（基础校验，匹配大多数标准邮箱格式）
            const emailReg = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
            // QQ邮箱正则（以@qq.com结尾，不区分大小写）
            const qqEmailReg = /@qq\.com$/i;

            if (value) {
                // 1. 先校验是否为合法邮箱格式
                if (!emailReg.test(value)) {
                    return callback(new Error('Please enter a valid email address'));
                }
                // 2. 再校验是否为QQ邮箱
                if (qqEmailReg.test(value)) {
                    return callback(new Error('QQ email is not allowed'));
                }
                // 两者都通过
                callback();
            } else {
                // 空值由必填校验处理
                callback();
            }
        };
        // 自定义校验：approval

        const validateApproval = (rule, value, callback) => {
            if (value || value == 0) {
                callback(); // 校验通过
            } else {
                callback(); // 空值由必填校验处理，这里不重复判断
            }
        };
        return {
            checkAll: false,
            isIndeterminate: false,
            stepStatusCurrent: '',
            isNewArticle: true,
            oldMajorValueList: [],
            checkedCities: [],
            newOptionLabel: '',
            showAddOption: false,
            nextId: 0, // 用于生成新选项的ID
            selectedAffiliations: [],
            affiliationList: [],
            formList: [],
            stepStatus: [],
            isShowProgress: false,
            hasAIContent: ['1'],
            isHasAI: '0',
            majorValueList: [],
            baseUrl: this.Common.baseUrl,
            usercap: localStorage.getItem('U_role'),
            ms_alias: localStorage.getItem('ms_journal_alias'),
            stagingID: this.$route.query.id,
            isShowCommonWord: true,
            move_step: 1, //进行步骤
            show_step: 1, //显示内容
            items: [],
            check_item: {},
            jour_form: {
                journal: 0
            },
            changeVisible: false,
            licensebox: false,
            agreechecked: false,
            loading: false,
            listStep: [
                {
                    index: 1,
                    icon: 'el-icon-s-order',
                    title: 'Manuscript Information'
                },
                {
                    index: 2,
                    icon: 'el-icon-s-custom',
                    title: 'Author Information'
                },
                {
                    index: 3,
                    icon: 'el-icon-s-management',
                    title: 'Upload Manuscript'
                },
                {
                    index: 4,
                    icon: 'el-icon-s-check',
                    title: 'Submit'
                }
            ],
            form: {
                article_id: 0,
                journal: localStorage.getItem('ms_journal_alias') ? parseInt(localStorage.getItem('ms_journal_alias')) : '',
                username: localStorage.getItem('U_name'),
                user_id: localStorage.getItem('U_id'),
                title: '',
                major: '',
                major_a: '',
                major_b: '',
                major_c: '',
                authorList: [
                    // 	{
                    // 	firstname: '',
                    // 	lastname: '',
                    // 	orcid: '',
                    // 	company: '',
                    // 	department: '',
                    // 	title: '',
                    // 	country: '',
                    // 	email: '',
                    // 	address: '',
                    // 	isSuper: false,
                    // 	isReport: false,
                    // 	load: false,
                    // 	sort: 0
                    // },
                ],

                // checkedjours: [],
                abstrart: '',
                type: '',
                approval: '',
                // istransfer: false,
                // becomeRev: false,
                keyWords: '',
                fund: '',
                reviewers: [],
                coverLetter: '',
                picturesAndTables: '',
                totalpage: '',
                manuscirpt: '',
                supplementary: '',
                approval_file: '',
                is_figure_copyright: '',
                figurecopyright_file: '',
                approval_content: '',
                code: '',
                is_use_ai: '',
                use_ai_explain: ''
                // topics:null
            },
            raltiAutList: [],
            journal_type: [],
            reviewerForm: {
                username: localStorage.getItem('U_name'),
                gender: 1,
                introduction: '',
                country: '',
                major: '',
                field: '',
                technical: '',
                company: '',
                qualifications: ''
            },
            tuiJianForm: [
                {
                    realname: '',
                    email: '',
                    department: '',
                    company: '',
                    major_all: ''
                },
                {
                    realname: '',
                    email: '',
                    department: '',
                    company: '',
                    major_all: ''
                },
                {
                    realname: '',
                    email: '',
                    department: '',
                    company: '',
                    major_all: ''
                }
            ],
            countrys: [],
            fileL_articleApproval: [],
            fileL_coverLetter: [],
            fileL_picturesAndTables: [],
            fileL_manuscirpt: [],
            fileL_supplementary: [],
            fileL_articleCopyright: [],
            tuiJianRules: {
                realname: [
                    {
                        required: true,
                        message: 'Please enter a realname',
                        trigger: 'blur'
                    }
                ],
                email: [
                    {
                        required: true,
                        message: 'Please enter a email',
                        trigger: 'blur'
                    },
                    {
                        validator: validateNotQQEmail, // 绑定自定义校验
                        trigger: 'blur'
                    }
                ],
                // department: [
                //     {
                //         required: true,
                //         message: 'Please enter a department',
                //         trigger: 'blur'
                //     }
                // ],
                company: [
                    {
                        required: true,
                        message: 'Please select a affiliation',
                        trigger: 'blur'
                    }
                ]
                // major_all: [
                //     {
                //         required: true,
                //         message: 'Please select a Filed',
                //         trigger: 'blur'
                //     }
                // ]
            },
            rules: {
                journal: [
                    {
                        required: true,
                        message: 'Please select Journal',
                        trigger: 'blur'
                    }
                ],
                title: [
                    {
                        required: true,
                        message: 'Please enter a title',
                        trigger: 'blur'
                    }
                ],
                // company: [
                //     {
                //         required: true,
                //         message: 'Please enter a affiliation',
                //         trigger: 'blur'
                //     }
                // ],
                // orcid: [
                //     {
                //         required: true,
                //         message: 'Please enter a orcid',
                //         trigger: 'blur'
                //     }
                // ],
                type: [
                    {
                        required: true,
                        message: 'Please select type',
                        trigger: 'blur'
                    }
                ],
                // major: [
                //     {
                //         required: true,
                //         validator: (rule, value, callback) => {
                //             console.log('value at line 1202:', this.form);
                //             var major = this.majorValueList.map((item) => item.selectedValue[item.selectedValue.length - 1]).toString(',');
                //             if (major == '') {
                //                 callback(new Error('Please select the Research areas'));
                //             } else {
                //                 callback();
                //             }
                //             // 如果你需要在此处使用 this 访问 Vue 实例的数据，使用箭头函数保持上下文
                //             // 其他逻辑
                //         }
                //     }
                // ],
                abstrart: [
                    {
                        required: true,
                        message: 'Please enter the abstract',
                        trigger: 'blur'
                    }
                ],
                keyWords: [
                    {
                        required: true,
                        message: 'Please enter keywords',
                        trigger: 'blur'
                    }
                ],
                fund: [
                    {
                        required: true,
                        message: 'Please input fund',
                        trigger: 'blur'
                    }
                ],
                totalpage: [
                    {
                        required: true,
                        message: 'Please upload totalpage',
                        trigger: 'blur'
                    }
                ],
                manuscirpt: [
                    {
                        required: true,
                        message: 'Please upload manuscript',
                        trigger: 'blur'
                    }
                ],
                qualification: [
                    {
                        required: true,
                        message: 'Please select qualification',
                        trigger: 'blur'
                    }
                ],
                introduction: [
                    {
                        required: true,
                        message: 'Please input personal qualification and resume',
                        trigger: 'blur'
                    }
                ],
                country: [
                    {
                        required: true,
                        message: 'Please select country',
                        trigger: 'blur'
                    }
                ],
                technical: [
                    {
                        required: true,
                        message: 'Please select technical',
                        trigger: 'blur'
                    }
                ],
                field: [
                    {
                        required: true,
                        message: 'Please enter field',
                        trigger: 'blur'
                    }
                ],

                email: [
                    {
                        required: true,
                        message: 'Please enter email'
                    },
                    {
                        validator: function (rule, value, callback) {
                            if (/^[-.-_A-Za-z0-9]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value) == false) {
                                callback(new Error('Please enter the correct email format'));
                            } else {
                                callback();
                            }
                        }
                    }
                ],
                realname: [
                    {
                        message: 'Please enter realname',
                        trigger: 'blur'
                    }
                ],
                country: [
                    {
                        required: true,
                        message: 'Please select country',
                        trigger: 'blur'
                    }
                ],
                major_all: [
                    {
                        required: true,
                        message: 'Please select major',
                        trigger: 'blur'
                    }
                ],
                approval: [
                    {
                        required: true,
                        message: 'Please select whether ethical approval was obtained',
                        trigger: 'blur'
                    }
                ],
                is_use_ai: [
                    {
                        required: true,
                        message: 'Please check whether to use AI technology',
                        trigger: 'blur'
                    }
                ],
                is_figure_copyright: [
                    {
                        required: true,
                        message: 'Please select figure copyright declaration',
                        trigger: 'blur'
                    }
                ],
                approval_content: [
                    {
                        required: true,
                        message: 'Please enter reason',
                        trigger: 'blur'
                    }
                ],
                approval_file: [
                    {
                        required: true,
                        message: 'Please upload ethical approva file',
                        trigger: 'blur'
                    }
                ],
                figurecopyright_file: [
                    {
                        required: true,
                        message: 'Please upload figure copyright declaration',
                        trigger: 'blur'
                    }
                ]
            },
            forWard: false,
            authorVisible: false,
            authMeaIN: {
                firstname: '',
                lastname: '',
                orcid: '',
                department: '',
                title: '',
                country: '',
                email: '',
                address: '',
                isSuper: false,
                isReport: false,
                load: false,
                sort: 0
            },
            activeNames: [1],
            keywordsList: [
                {
                    ke: ''
                }
            ],
            majors_a: [],
            majors_b: [],
            majors_c: [],
            Reviewerof: {
                username: localStorage.getItem('U_name'),
                journal: localStorage.getItem('ms_journal_alias') ? parseInt(localStorage.getItem('ms_journal_alias')) : 1
            },
            checkReviewerof: 0,

            countrys: [],
            majorList: [],
            step4MajorList: [], // 第四步的major数据
            jl_major: [],
            defaultParams: {
                label: 'title',
                value: 'major_id',
                children: 'children'
            },
            default4Params: {
                label: 'major_title',
                value: 'major_id',
                children: 'children'
            },
            mj_jour: [],
            jour_name: '',
            topicsList: null, // 话题列表
            topicsProps: {
                multiple: true,
                emitPath: false, // 只返回该节点的值
                value: 'journal_topic_id', // 自定义要映射的键名
                label: 'title',
                children: 'children'
            },
            tables: [],
            uploadPercentage: 0,
            wordimgList: [],
            tablesHtml: [],
            imagesHtml: []
        };
    },
    watch: {
        collapseValue: {
            handler(e) {
                // console.log(e);
            },
            immediate: true
        },
        form: {
            async handler(newVal, oldVal) {},
            deep: true,
            immediate: true
        }
    },
    async created() {
       this.initArticleInfo()
    },

    computed: {
        collapseValue() {
            return localStorage.getItem('collapse');
        },
        upload_articleApproval: function () {
            return this.baseUrl + 'api/Article/up_approval_file';
        },
        //图片版权
        upload_articleCopyright: function () {
            return this.baseUrl + 'api/Article/up_file/type/figurecopyright';
        },

        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_totalpage: function () {
            return this.baseUrl + 'api/Article/up_file/type/totalpage';
        },
        upload_manuscirpt: function () {
            return this.baseUrl + 'api/Article/up_file/type/manuscirpt';
        },
        upload_supplementary: function () {
            return this.baseUrl + 'api/Article/up_file/type/supplementary';
        },
        upload_qualifications: function () {
            return this.baseUrl + 'api/Admin/up_file';
        }
    },
    methods: {
      async  initArticleInfo(){
            this.journal_type = await this.$commonJS.journalTypeList();
        // 依次执行初始化步骤
        this.initSelect();
        this.getAutData();
        try {
            // 获取期刊类型列表

            // 分支处理
            if (this.stagingID !== undefined) {
                this.form.article_id = this.stagingID;
                await this.getMajorData();
                await this.initStepStatus((step1Incomplete) => {
                    this.show_step = step1Incomplete.current.step;
                    this.move_step = step1Incomplete.current.step;
                });
                await this.Temporary();
            } else {
                this.isNewArticle = true;
                await this.initMajor();
            }

            // 最后执行步骤状态初始化
        } catch (err) {
            // 控制台打印错误
            console.error('初始化失败：', err.message || err);
            load.close();
        }
        },
        handleCheckAllChange(val) {
            this.checkedCities = val
                ? this.keywordsList.map((_, index) => index + 1) // 遍历数组，取 index+1 作为选中值
                : [];
            this.isIndeterminate = false;
        },
        handleCheckedCitiesChange() {
            console.log('this.checkedCities at line 1594:', this.checkedCities);
        },
        handleDelete(index) {
            this.keywordsList.splice(index, 1);
        },
        closeAuthorDialog() {
            this.getAuthorList();
            this.authorVisible = false;
        },
        handleClickHere() {
            this.showAddOption = true;
            this.$nextTick(() => {
                this.$refs.newOptionInput.focus();
            });
        },
        addNewOption: throttle(function () {
            const label = this.newOptionLabel.trim();
            if (!label) return;

            // 检查是否已存在相同名称的选项
            //   const exists = this.affiliationList.some(item => item.label === label);
            //   if (exists) {
            //     this.$message.warning('The affiliation already exists');
            //     return;
            //   }

            // 创建新选项

            this.$api
                .post('api/Organ/add', {
                    article_id: this.form.article_id,
                    user_id: this.form.user_id,
                    organ_name: label
                })
                .then((res) => {
                    if (res.status == 1) {
                        this.getAffiliationList();
                        this.selectedAffiliations.push(Number(res.data.organ_id));

                        this.newOptionLabel = '';
                        this.showAddOption = false;
                    } else {
                        this.$message.error(res.msg);
                    }
                });

            // 清空输入框

            // 移除新选项标记（用于动画效果）
            //   setTimeout(() => {
            //     newOption.isNew = false;
            //   }, 1500);
        }, 1000),
        editAffiliation(id, label) {
            this.$prompt('Please enter a new affiliation name', 'Prompt', {
                confirmButtonText: 'Save',
                cancelButtonText: 'Cancel',
                inputValue: label,

                inputType: 'textarea', // 使用多行文本框
                inputRows: 4, // 设置默认行数
                inputPattern: /.+/,
                inputErrorMessage: 'affiliation name cannot be empty' // 错误提示改为不能为空
            })
                .then(({ value }) => {
                    this.$api
                        .post('api/Organ/modify', {
                            article_id: this.form.article_id,
                            user_id: this.form.user_id,
                            organ_id: id,
                            organ_name: value
                        })
                        .then((res) => {
                            if (res.status == 1) {
                                this.getAffiliationList();
                            } else {
                                this.$message.error(res.msg);
                            }
                        });
                })
                .catch(() => {});
        },
        removeAffiliation(id) {
            this.$confirm('This operation will permanently delete the affiliation. Do you want to continue?', 'Prompt', {
                confirmButtonText: 'OK',
                cancelButtonText: 'Cancel',
                type: 'warning'
            })
                .then(() => {
                    this.$api
                        .post('api/Organ/remove', {
                            article_id: this.form.article_id,
                            user_id: this.form.user_id,
                            organ_id: id
                        })
                        .then((res) => {
                            if (res.status == 1) {
                                this.getAffiliationList();
                                this.selectedAffiliations = this.selectedAffiliations.filter((item) => item !== id);
                            } else {
                                this.$message.error(res.msg);
                            }
                        });
                })
                .catch(() => {});
        },
        selectCompany(id) {
            // 假设存储选中公司ID的数组是 selectedCompanyIds
            const index = this.selectedAffiliations.findIndex((item) => item === id);
            if (index === -1) {
                // 不存在则添加（push）
                this.selectedAffiliations.push(id);
            } else {
                // 存在则删除（取消）
                this.selectedAffiliations.splice(index, 1);
            }
            this.$forceUpdate();
        },
        save(data, fn) {
            if (this.form.article_id) {
                data.article_id = this.form.article_id;
            }
            this.$api
                .post('api/Article/addArticleStaging', {
                    user_id: this.form.user_id,
                    ...data
                })
                .then((res) => {
                    if (res.status == 1) {
                        this.stagingID = res.data.article_id;
                        this.form.article_id = res.data.article_id;
                        this.initStepStatus();
                        this.$message.success('Saving succeeded!');
                    } else {
                        this.$message.error(res.msg);

                        return false;
                    }

                    if (fn) {
                        fn(res);
                    }
                });
        },
        handleStepClick(e) {
            console.log('e at line 1469:', e);
            // 通过事件源找到点击的步骤项
            const stepEl = e.target.closest('.el-step');
            if (stepEl) {
                // 获取步骤标识（item.index）
                const stepIndex = stepEl.getAttribute('data-step-index');
                // 找到对应的item
                const item = this.listStep.find((item) => item.index === stepIndex);
                if (item) {
                    this.StepCode(item); // 调用原逻辑
                }
            }
        },
        async initStepStatus(fn) {
            const step1Incomplete = {
                list: [
                    { step: 1, status: 0, name: 'first', msg: 'first_msg' },
                    { step: 2, status: 0, name: 'second', msg: 'second_msg' },
                    { step: 3, status: 0, name: 'three', msg: 'three_msg' },
                    { step: 4, status: 0, name: 'four', msg: 'four_msg' }
                ]
            };
            await this.$api
                .post('api/Article/getArticleState', {
                    article_id: this.form.article_id,
                    user_id: this.form.user_id
                })
                .then(async (res) => {
                    if (res.status == 1) {
                        step1Incomplete.list = step1Incomplete.list.map((item) => ({
                            ...item,
                            status: res.data[item.name],
                            msg: res.data[item.msg]
                        }));
                        this.stepStatus = step1Incomplete.list;
                        if (res.data.current_step) {
                            step1Incomplete.current = step1Incomplete.list.find((item) => item.name == res.data.current_step);
                            this.stepStatusCurrent = step1Incomplete.current;
                        }

                        if (fn) {
                            console.log('step1Incomplete at line 1766:', step1Incomplete);
                            fn(step1Incomplete);
                        }
                        console.log('this.stepStatus at line 1571:', this.stepStatus);
                    }
                });

            // const step1Incomplete = await updateStepStatus({ ...this.form, majorValueList: this.majorValueList }, [1, 2, 3, 4]);

            // this.stepStatus = step1Incomplete.list;

            this.$forceUpdate();
        },
        // 提交前校验所有评审人表单
        async validateAllReviewers() {
            // 统计「已填写且通过校验」的表单数量
            let validFilledCount = 0;
            // 定义「表单是否为空」的判断逻辑（根据你的实际核心字段调整！）
            // 示例：判断核心字段（如姓名、专业）是否都为空，可根据业务增删字段
            const isFormEmpty = (formData) => {
                // 核心字段列表：请替换为你的实际必填字段（空表单的判断标准）
                const coreFields = ['realname', 'email', 'company']; // 示例字段：姓名、专业
                return coreFields.every((field) => {
                    const value = formData[field];
                    // 空值判断：包括 undefined、null、''、空数组等
                    return value === undefined || value === null || value === '' || (Array.isArray(value) && value.length === 0);
                });
            };

            // 遍历所有表单实例
            for (const form of this.$refs.tuiJianForm) {
                try {
                    // 1. 获取当前表单的绑定数据（根据你的表单组件调整！）
                    // 若你的表单用 v-model 绑定在 form.model 上，就取 form.model；若绑定在其他属性，需对应修改
                    const formData = form.model || form;

                    // 2. 判断表单是否「未填写」：未填写则跳过校验
                    if (isFormEmpty(formData)) {
                        continue;
                    }

                    // 3. 已填写的表单：必须通过校验
                    await form.validate();
                    // 4. 校验通过，计数+1
                    validFilledCount++;
                } catch (error) {
                    // 已填写的表单校验失败，直接终止并返回false
                    return false;
                }
            }

            // 5. 最终校验：至少有1条已填写且通过校验
            return validFilledCount >= 1;
        },
        handleJournalSelected(journal) {
            if (journal == '') {
                this.check_item = {};
                this.ms_alias = '';
                this.form.journal = '';
                this.reviewerof.journal = 1;

                if (localStorage.getItem('ms_journal_alias')) {
                    localStorage.removeItem('ms_journal_alias');
                }
            } else {
                this.check_item = journal;
                this.ch_Jour_all(journal.journal_id);
            }
        },
        async onSubmit() {
            // 1. 校验协议勾选
            if (!this.agreechecked) {
                this.$message.error(
                    'Dear author, the licenses need to be accepted before you submit the manuscript. You could find more information in http://creativecommons.org/licenses/by/4.0/'
                );
                return false;
            }

            // 3. 处理并校验研究领域
            if (this.majorValueList.length > 0) {
                this.form.major = this.majorValueList
                    .map((item) => {
                        const selectedValues = item.selectedValue || [];
                        return selectedValues.length > 0 ? selectedValues[selectedValues.length - 1] : '';
                    })
                    .filter(Boolean) // 过滤空值
                    .join(',');
            }
            if (!this.form.major) {
                this.$message.error('Please select the Research areas');
                return false;
            }
            // 2. 校验所有评审人表单（复用现有校验方法）

            // // 4. 校验转投期刊选择
            // if (this.form.istransfer && (!this.form.checkedjours || this.form.checkedjours.length === 0)) {
            //     this.$message.error('If you chose co-submission, you need to select at least one journal.');
            //     return false;
            // }

            // 5. 处理推荐审稿人信息及校验
            const hasReviewerInfo = this.tuiJianForm.some((item) =>
                item.major_all ? item.major_all.length > 0 : '' || item.realname || item.email || item.country
            );
            if (!(await this.validateAllReviewers())) {
                this.$message.error(
                    'Please recommend at least one reviewer and fill in their complete information. This will help speed up the review process!'
                );
                return false;
            } else {
                this.tuiJianForm.forEach((item) => {
                    item.major = item.major_all && item.major_all.length > 0 ? item.major_all[item.major_all.length - 1] : '';
                });
                this.form.reviewers = this.tuiJianForm;
            }

            // 6. 所有校验通过，提交 manuscript
            this.Submission_of_manuscripts();
        },

        Submission_of_manuscripts() {
            const load = this.$loading({
                lock: true,
                text: 'Loading...',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });

            this.$api
                // api/Article/addArticle
                .post('api/Article/addArticlePart4', this.form)
                .then((res) => {
                    this.loading = false;
                    if (res.code == 0) {
                        this.$message.success('Successful submission!');
                        load.close();
                        this.$router.push('/articleList');
                    } else {
                        if (res.msg == undefined) {
                            this.$message.error('Failed to submit, please contact administrator!');
                        } else {
                            this.$message({
                                duration: 0,
                                showClose: true,
                                message: res.msg,
                                type: 'warning'
                            });
                            return false;
                        }
                    }
                })
                .catch((err) => {
                    console.log(err);
                });
        },

        addfund() {
            this.keywordsList.push({
                ke: ''
            });
        },
        deletefund() {
            if (!this.checkedCities.length) {
                this.$message.error('please select the key word to delete');
                return;
            }

            // 2. 将选中的序号（index+1）转成原始索引（index），并存入集合（提高查询效率）
            const selectedIndexes = new Set(
                this.checkedCities.map((seq) => seq - 1) // 序号 - 1 = 原始索引
            );

            // 3. 过滤 keywordsList：保留索引不在选中集合中的项
            this.keywordsList = this.keywordsList.filter((_, index) => !selectedIndexes.has(index));
            this.checkAll = false;
            // 4. 清空选中状态和半选状态（删除后无选中项）
            this.checkedCities = [];
            this.isIndeterminate = false;
        },
        //初始化期刊选项
        initSelect() {
            this.items = this.$store.state.journalList;
            for (let i in this.items) {
                if (this.items[i].journal_id == this.form.journal) {
                    this.check_item = this.items[i];
                    this.jour_form.journal = this.items[i].journal_id;
                }
            }

            this.$api
                .post('api/Reviewer/getAllMajor')
                .then((res) => {
                    this.jl_major = res.data.majors;
                })
                .catch((err) => {
                    this.$message.error(err);
                });
            this.$api.post('api/Major/getMajorList').then((res) => {
                this.step4MajorList = res.data.majors;
            });
            this.$api.post('api/Admin/getCountrys').then((res) => {
                this.countrys = res;
            });
            // this.$api.post('api/Article/getAllCompany').then((res) => {
            //     this.companyList = [];
            //     for (let i in res.data.companys) {
            //         this.companyList.push({
            //             value: res.data.companys[i].title
            //         });
            //     }
            // });
            this.$api
                .post('/api/Reviewer/getMajorForReviewer', {
                    username: localStorage.getItem('U_name')
                })
                .then((res) => {
                    if (res.data.major != 0) {
                        this.$api.post('api/User/getMajorList').then((res) => {
                            this.majorList = res.data;
                        });
                    }
                });

            this.checkReviewer();
        },

        // 邮箱用户模糊搜索
        chaMateFit(value, cb, num) {
            console.log('num at line 1587:', value);
            // var mailRegular = /^\w+([-+._']\w+)*@\w+(\.[a-zA-Z]{2,3}){1,2}$/
            var mailRegular = /^\w+([-+._']\w+)*@/;
            // if (mailRegular.test(value)) {

            // this.form.authorList[num].load = true;
            // this.$forceUpdate();
            this.$api
                .post('api/Article/getRelationAuthorByEmail', {
                    email: value,
                    page: 1,
                    limit: 10
                })
                .then((res) => {
                    var restaurants = res.data.authors;
                    for (let i in restaurants) {
                        restaurants[i].value = restaurants[i].email + ' | ' + restaurants[i].firstname + restaurants[i].lastname;
                    }
                    var results = value ? restaurants.filter(this.createMata(value)) : restaurants;
                  
                    // 调用 callback 返回建议列表的数据
                    cb(results);
                    // this.form.authorList[num].load = false;
                    this.$forceUpdate();
                });
            // }
        },

        createMata(queryString) {
            return (restList) => {
                return restList.value.toLowerCase().indexOf(queryString.toLowerCase()) != -1;
            };
        },

        // 选中用户
        chaSelChose(value, num) {
            console.log(value);
            console.log(num);
            this.authMeaIN.firstname = value.firstname ? value.firstname : '';
            this.authMeaIN.lastname = value.lastname ? value.lastname : '';
            this.authMeaIN.orcid = value.orcid ? value.orcid : '';
            // this.authMeaIN.company = value.company ? value.company : '';
            // this.authMeaIN.department = value.department ? value.department : '';
            this.authMeaIN.title = value.title ? value.title : value.author_title ? value.author_title : '';
            this.authMeaIN.country = value.country ? value.country : '';
            this.authMeaIN.email = value.email ? value.email : '';
            // this.authMeaIN.address = value.address ? value.address : '';
            this.authMeaIN.isSuper = false;
            this.authMeaIN.isReport = false;
            this.authMeaIN.load = false;
            this.authMeaIN.sort = num;
            if (value.organ && Array.isArray(value.organ)) {
                this.selectedAffiliations = value.organ_id;
            }
            this.$forceUpdate();
        },

        // 相关作者展开隐藏
        forWarMark() {
            if (this.forWard) {
                this.forWard = false;
            } else {
                this.forWard = true;
            }
        },
        raltSHpin(index, num) {
            if (num == 0) {
                this.raltiAutList[index].showHide = false;
            } else {
                this.raltiAutList[index].showHide = true;
            }
            this.$forceUpdate();
        },

        // 选择推荐作者
        async checkAuthor(value, num) {
            var isHaveAuthor = this.form.authorList.findIndex((e) => {
                if (e.email == value.email) {
                    return e;
                }
            });
            if (isHaveAuthor >= 0) {
                this.$message.error('The same author can only be added once');
                return false;
            }

            var data = {
                firstname: value.firstname ? value.firstname : '',
                lastname: value.lastname ? value.lastname : '',
                orcid: value.orcid ? value.orcid : '',
                // value.company = value.company ? value.company : '';
                // value.department = value.department ? value.department : '';
                title: value.title ? value.title : value.author_title ? value.author_title : '',
                country: value.country ? value.country : '',
                email: value.email ? value.email : '',
                // value.address = value.address ? value.address : '';
                isSuper: false,
                isReport: false,
                load: false,
                sort: num,
                article_id: this.stagingID
            };

            await this.$api.post('api/Article/addAuthor', data).then(async (res) => {
                await this.TempoAuthor();
                this.$message.success('Added successfully');
            });
        },
        // 获取机构列表
        getAffiliationList() {
            this.$api.post('api/Organ/lists', { article_id: this.form.article_id, user_id: this.form.user_id }).then((res) => {
                if (res.status == 1) {
                    console.log('res.status at line 1985:', res.data);
                    this.affiliationList = res.data.map((item) => ({
                        id: item.organ_id,
                        label: item.organ_name
                    }));
                }
            });
        },
        // 添加作者信息
        async addAuthor() {
            this.selectedAffiliations = [];
            await this.getAffiliationList();
            this.showAddOption = false;
            this.authorVisible = true;
            this.authMeaIN.art_aut_id = '';
            this.authMeaIN.firstname = '';
            this.authMeaIN.lastname = '';
            this.authMeaIN.orcid = '';
            this.authMeaIN.company = '';
            this.authMeaIN.department = '';
            this.authMeaIN.title = '';
            this.authMeaIN.country = '';
            this.authMeaIN.email = '';
            this.authMeaIN.address = '';
            this.authMeaIN.isSuper = false;
            this.authMeaIN.isReport = false;
            this.authMeaIN.load = false;
            this.authMeaIN.sort = this.form.authorList.length;
            console.log(this.form.authorList);
        },

        // 修改用户信息
        async editAuthor(value, num) {
            this.selectedAffiliations = [];
            await this.getAffiliationList();
            this.authMeaIN.art_aut_id = value.art_aut_id ? value.art_aut_id : '';
            this.authMeaIN.firstname = value.firstname ? value.firstname : '';
            this.authMeaIN.lastname = value.lastname ? value.lastname : '';
            this.authMeaIN.orcid = value.orcid ? value.orcid : '';

            this.authMeaIN.department = value.department ? value.department : '';
            this.authMeaIN.title = value.title ? value.title : '';
            this.authMeaIN.country = value.country ? value.country : '';
            this.authMeaIN.email = value.email ? value.email : '';
            this.authMeaIN.address = value.address ? value.address : '';
            this.authMeaIN.isSuper = value.isSuper == 1 ? true : false;
            this.authMeaIN.isReport = value.isReport == 1 ? true : false;
            this.authMeaIN.load = false;
            this.selectedAffiliations = value.organ_id;
            this.authMeaIN.sort = num;
            this.authorVisible = true;
        },

        // 保存修改用户信息
        saveAuthor(value) {
            if (value.email === '') {
                this.$message.error('Please provide the email address!');
                return;
            }
            if (value.firstname === '') {
                this.$message.error('Please provide the first name!');
                return;
            }
            if (value.lastname === '') {
                this.$message.error('Please provide the last name!');
                return;
            }
            // 统计：isReport为true且orcid非空的作者数量
            console.log('this.form.authorList.filter at line 2162:', this.form.authorList);
            // const validOrcidCount = this.form.authorList.filter((item) => {

            //     return item.isReport && item.orcid != '';
            // }).length;
            // console.log('validOrcidCount at line 2162:', validOrcidCount)
            // if (this.authMeaIN.isReport && validOrcidCount === 0) {
            //     if (value.orcid === '') {
            //         this.$message.error('Please provide the ORCID ID!');
            //         return;
            //     }
            // }

            if (value.title === '') {
                this.$message.error('Please provide the title!');
                return;
            }

            if (this.selectedAffiliations.length == 0) {
                this.$message.error('Please provide the affiliation!');
                return;
            }
            value.organ = this.selectedAffiliations.join(',');
            const fieldsToDelete = ['company', 'address', 'department'];

            fieldsToDelete.forEach((field) => {
                // 存在该字段则删除（不关心字段值）
                if (value.hasOwnProperty(field)) {
                    delete value[field];
                }
            });
            // // 检查isReport为true时的address字段
            // if (value.isReport && value.address === '') {
            //     this.$message.error('Please provide the address!');
            //     return;
            // }
            value.article_id = this.stagingID;
            var urlLink = '';
            if (!value.art_aut_id) {
                urlLink = 'api/Article/addAuthor';
            } else {
                urlLink = 'api/Article/editAuthor';
            }
            this.$api.post(urlLink, value).then((res) => {
                if (res.code == 0) {
                    this.TempoAuthor();
                    this.authorVisible = false;
                    this.$message.success('Successfully saved');
                } else {
                    this.$message.error(res.msg);
                }
            });
        },

        // 删除作者信息
        deleteAuthor(item, index) {
            // 二次确认删除
            this.$confirm('Are you sure you want to delete this author?', 'Delete', {
                type: 'warning'
            })
                .then(() => {
                    item.article_id = this.stagingID;
                    this.$api
                        .post('api/Article/delAuthor', {
                            art_aut_id: item.art_aut_id
                        })
                        .then((res) => {
                            if (res.code == 0) {
                                this.TempoAuthor();
                                this.$message.success('Delete successful');
                            } else {
                                this.$message.error(res.msg);
                            }
                        });
                })
                .catch(() => {});
        },

        // 用户排序更改
        gaPaiXu(value, inx) {
            if (inx == 'top') {
                this.$api
                    .post('api/Article/upAuthors', {
                        art_aut_id: value.art_aut_id
                    })
                    .then((res) => {
                        if (res.code == 0) {
                            this.TempoAuthor();
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
            } else {
                this.$api
                    .post('api/Article/downAuthors', {
                        art_aut_id: value.art_aut_id
                    })
                    .then((res) => {
                        if (res.code == 0) {
                            this.TempoAuthor();
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
            }
            // for (let i in this.form.authorList) {
            // 	this.form.authorList[i].sort = i
            // }
        },

        // 获取相关作者列表
        getAutData() {
            this.$api
                .post('api/Article/getRelationAuthor', {
                    user_id: localStorage.getItem('U_id')
                })
                .then((res) => {
                    this.raltiAutList = res.data.authors;
                    for (let i in this.raltiAutList) {
                        this.raltiAutList[i].showHide = false;
                    }
                });
        },

        // // 机构模糊搜索
        // searchCompany(queryString, cb) {
        //     var companyList = this.companyList;
        //     var results = queryString ? companyList.filter(this.createFilter(queryString)) : companyList;
        //     // 调用 callback 返回建议列表的数据
        //     cb(results);
        // },

        createFilter(queryString) {
            return (companyList) => {
                return companyList.value.toLowerCase().indexOf(queryString.toLowerCase()) != -1;
            };
        },

        selCompany(item, index) {
            console.log('item at line 2078:', item);
            // this.form.authorList[index].company = item.value;
        },

        checkReviewer() {
            this.$api.post('api/Reviewer/checkReviewerOfJournal', this.Reviewerof).then((res) => {
                this.checkReviewerof = res.data.has;
            });
        },

        open() {
            let str =
                'Creative Commons Licensing<br> Medicine provides authors the choice of applying the Creative Commons 4.0 licenses defined below, to be determined after acceptance:<br>Attribution: CC-BY<br>This license lets others distribute, remix, tweak, and build upon your work, even commercially, if they credit you for the original creation. <br>This is the most accommodating of licenses offered.';
            this.$alert(str, '', {
                confirmButtonText: 'ok'
            });
        },

        initMajor() {
            this.$api
                .post('api/Major/getMajorForAddArticle', {
                    journal_id: this.form.journal,
                    major_id: 1
                })
                .then((res) => {
                    this.majors_a = res.data.majors;
                });
        },

        majorChange(e) {
            if (e == 1) {
                this.$api
                    .post('api/Major/getMajorForAddArticle', {
                        journal_id: this.form.journal,
                        major_id: this.form.major_a
                    })
                    .then((res) => {
                        this.majors_b = res.data.majors;
                        this.majors_c = [];
                        this.form.major_b = '';
                        this.form.major_c = '';
                        this.majorChange_panduan();
                    });
            } else if (e == 2 && this.form.major_b != 0) {
                this.$api
                    .post('api/Major/getMajorForAddArticle', {
                        journal_id: this.form.journal,
                        major_id: this.form.major_b
                    })
                    .then((res) => {
                        this.majors_c = res.data.majors;
                        this.form.major_c = '';
                        this.majorChange_panduan();
                    });
            } else {
                this.majorChange_panduan();
            }
        },

        majorChange_panduan() {
            if (this.form.major_c != '' || this.form.major_c != 0) {
                this.form.major = this.form.major_c;
            } else if (this.form.major_b != '' || this.form.major_b != 0) {
                this.form.major = this.form.major_b;
            } else {
                this.form.major = this.form.major_a;
            }
            // 选择共同投稿清除
            this.mj_jour = [];
            // this.form.checkedjours = [];
            // this.form.istransfer = false;
        },

        getjournalbyid(jid) {
            for (var i in this.items) {
                if (this.items[i].journal_id == jid) {
                    return this.items[i].title;
                }
            }
        },

        uperr_coverLetter(err) {
            this.$message.error('Upload error');
        },

        // 共同投稿
        changeSwitch(val) {
            if (val === true) {
                let flag = val;
                this.form.istransfer = false;
                // // 二次确认
                this.$confirm(
                    'Please confirm this information again. When you select this Co-submission again. if the manuscript is not suitable for the first journal, the manuscript will be automatically submitted to the journal you selected.',
                    'Tips',
                    {
                        confirmButtonText: 'OK',
                        cancelButtonText: 'Cancel',
                        type: 'warning'
                    }
                )
                    .then(() => {
                        this.form.istransfer = true;
                        this.save({ istransfer: this.form.istransfer });
                        // 获取期刊by领域
                        this.$api
                            .post('api/Article/getJournalsByMajor', {
                                major_id: this.form.major
                            })
                            .then((res) => {
                                this.mj_jour = res.data.journals;
                            });
                    })
                    .catch(() => {});
            } else {
                this.save({ istransfer: false });
            }
        },
        // 是否申请审稿人
        changeBecome(val) {
            if (val === true) {
                let flag = val;
                this.form.becomeRev = false;
                // // 二次确认
                this.$confirm('Do you want to apply to be a reviewer of ' + this.getjournalbyid(this.form.journal) + '?', 'Tips', {
                    type: 'warning'
                })
                    .then(() => {
                        this.form.becomeRev = true;
                        // 作者同意申请审稿人
                    })
                    .catch(() => {});
            }
        },

        // 添加推荐审稿人
        onAddTuijian() {
            this.tuiJianForm.push({
                realname: '',
                email: '',
                department: '',
                company: '',
                major_all: ''
            });
        },

        onDeleteTuijian(item, index) {
            this.tuiJianForm.splice(index, 1);
        },
        dowloadFileTemplate() {
            var filePath = 'https://submission.tmrjournals.com/public/ArticleTemplate/manuscirpt/ManuscirptWordTemplate.docx';

            // 获取heads中的filename文件名
            let downloadElement = document.createElement('a');
            // 创建下载的链接
            downloadElement.href = filePath; // 下载后文件名

            downloadElement.target = '_blank';
            document.body.appendChild(downloadElement);
            // 点击下载
            downloadElement.click();
            // 下载完成移除元素
            document.body.removeChild(downloadElement);
        },
        // 下载文件
        dowloadFile(file) {
            let filePath = '/public/' + file.url;
            let fileName = file.name;

            // 获取heads中的filename文件名
            let downloadElement = document.createElement('a');
            // 创建下载的链接
            downloadElement.href = filePath; // 下载后文件名
            downloadElement.download = fileName;
            downloadElement.target = '_blank';
            document.body.appendChild(downloadElement);
            // 点击下载
            downloadElement.click();
            // 下载完成移除元素
            document.body.removeChild(downloadElement);
        },
        //检验上传文件的格式
        beforeupload_articleApproval(file) {
            // 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;
        },
        beforeupload_articleCopyright(file) {},

        beforeupload_coverLetter(file) {
            // const isWORd =
            //     file.type === 'application/msword' ||
            //     file.type === 'application/pdf' ||
            //     file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
            // if (!isWORd) {
            //     this.$message.error('Only word and pdf files can be uploaded(.pdf,.doc,.docx)');
            // }
            // return isWORd;
        },
        beforeupload_picturesAndTables(file) {
            let flieArr = file.name.split('.');
            let fileSuffix = flieArr[flieArr.length - 1];
            if (fileSuffix != 'zip') {
                this.$message.error('Only ZIP files can be uploaded (file format: .zip).');
                return false;
            }

            // const iszip =
            //     file.type === 'application/x-zip-compressed';
            // if (!iszip) {
            //     this.$message.error('Only compressed files can be uploaded(.zip)');
            //     return false;
            // }
            // return iszip;
        },
        beforeupload_totalpage(file) {},
        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;
        },
        beforeupload_supplementary(file) {
            let flieArr = file.name.split('.');
            let fileSuffix = flieArr[flieArr.length - 1];
            if (fileSuffix != 'zip') {
                this.$message.error('Only zip files can be uploaded(.zip)');
                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;
        },
        //文件上传成功后的操作
        upSuccess_articleApproval(res, file) {
            if (res.code == 0) {
                this.form.approval_file = 'articleApproval/' + res.upurl;
                this.fileL_articleApproval = [{}];
                this.fileL_articleApproval[0].name = 'Ethical approval File';
                this.fileL_articleApproval[0].url = 'articleApproval/' + res.upurl;
                this.$refs.articleform.clearValidate('approval_file');

                this.save({
                    approval: this.form.approval,
                    approval_file: this.form.approval_file
                });
            } else {
                this.$message.error('service error: ' + res.msg);
            }
            console.log(this.form);
        },
        //图片版权
        upSuccess_articleCopyright(res, file) {
            if (res.code == 0) {
                this.form.figurecopyright_file = 'figurecopyright/' + res.upurl;
                this.fileL_articleCopyright = [{}];
                this.fileL_articleCopyright[0].name = 'Figure Copyright Declaration File';
                this.fileL_articleCopyright[0].url = 'figurecopyright/' + res.upurl;
                this.onStaging(7);
            } else {
                this.$message.error('service error: ' + res.msg);
            }
            console.log(this.form);
        },
        upSuccess_coverLetter(res, file) {
            if (res.code == 0) {
                this.form.coverLetter = 'coverLetter/' + res.upurl;
                this.fileL_coverLetter = [{}];
                this.fileL_coverLetter[0].name = 'Cover letter File';
                this.fileL_coverLetter[0].url = 'coverLetter/' + res.upurl;
                this.onStaging(3);
            } else {
                this.$message.error('service error：' + res.msg);
            }
        },
        upSuccess_picturesAndTables(res, file, fileList) {
            if (res.code == 0) {
                this.form.picturesAndTables = 'picturesAndTables/' + res.upurl;
                this.fileL_picturesAndTables = [{}];
                this.fileL_picturesAndTables[0].name = 'Figures File';
                this.fileL_picturesAndTables[0].url = 'picturesAndTables/' + res.upurl;
                this.onStaging(4);
            } else {
                this.$message.error('service error：' + res.msg);
            }
        },
        upSuccess_totalpage(res, file) {
            if (res.code == 0) {
                this.form.totalpage = 'totalpage/' + res.upurl;
            } else {
                this.$message.error('service error：' + res.msg);
            }
        },
        // 进度回调：实时获取进度
        handleProgress(event, file, fileList) {
            this.isShowProgress = true;

            // event.percentage 就是当前进度（百分比，浮点数）
            this.uploadPercentage = Math.round(event.percent); // 取整数
        },
        addWordTablesList(tables) {
            var data = {
                article_id: this.stagingID,

                list: tables.map((e) => ({
                    table: JSON.stringify([...e]),
                    type: 0,
                    html_data: ''
                }))
            };
            this.$api.post('api/Article/addArticleTable', data).then((res) => {
                this.isShowCommonWord = true;
                setTimeout(() => {
                    this.isShowProgress = false;
                }, 500);
            });
        },
        upLoadWordTables() {},
        upSuccess_manuscirpt(res, File) {
            // console.log('file at line 2174:', file.raw)

            if (res.code == 0) {
                this.form.manuscirpt = 'manuscirpt/' + res.upurl;
                this.fileL_manuscirpt = [{}];
                this.isShowCommonWord = false;
                this.fileL_manuscirpt[0].name = 'Manuscript File';
                this.fileL_manuscirpt[0].url = 'manuscirpt/' + res.upurl;
                this.contribute(res.upurl, File);

                // this.onStaging(5);
            } else {
                this.$message.error('service error: ' + res.msg);
            }
        },
        async contribute(file_url, File) {
            const loading = this.$loading({
                lock: true,
                text: 'Loading...',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            var that = this;
            var data = {
                file_url: '/public/manuscirpt/' + file_url,
                user_id: this.form.user_id
            };
            if (this.form.article_id) {
                data.article_id = this.form.article_id;
            }

            await this.$api
                .post('api/Contribute/contribute', {
                    ...data
                })
                .then(async (res) => {
                    if (res.status == 1) {
                        console.log('res.status at line 2646:', res);

                        if (res.article && res.article.article_id) {
                            this.stagingID = res.article.article_id;
                            this.form.article_id = res.article.article_id;

                            if (res.article.title) {
                                this.form.title = res.article.title;
                            }
                            if (res.article.abstrart) {
                                this.form.abstrart = res.article.abstrart;
                            }
                            if (res.article.fund) {
                                this.form.fund = res.article.fund;
                            }
                            if (res.article.keywords && res.article.keywords.length > 0) {
                                let keyList = res.article.keywords.split(',');
                                this.keywordsList = [];
                                for (let i = 0; i < keyList.length; i++) {
                                    this.keywordsList.push({
                                        ke: keyList[i]
                                    });
                                }
                            }

                            this.$forceUpdate();

                            const url = new URL(window.location.href);

                            url.searchParams.set('id', res.article.article_id); // 替换或新增 id 参数
                            window.history.replaceState({}, document.title, url.toString());

                            if (this.form.article_id) {
                                if (File) {
                                    loading.close();
                                    var that = this;
                                    const reader = new FileReader();
                                    reader.onload = function (e) {
                                        that.$commonJS.extractWordTablesToArrays(File.raw, function (wordTables) {
                                            that.addWordTablesList(wordTables);
                                            loading.close();
                                        },that.form.article_id);
                                    };
                                    reader.readAsArrayBuffer(File.raw);
                                }
                                await this.onStaging(5);
                                await this.TempoAuthor();
                            }
                        }

                        // this.$message.success('Contribution added successfully!');
                    } else {
                        this.form.manuscirpt = '';
    this.fileL_manuscirpt = [];
    this.isShowCommonWord = false;
    this.initStepStatus();
    // 1. 统一关闭 loading
    loading.close();

    // 2. 根据状态码处理逻辑
    if (res.status == 21) {
        // 系统内编辑已经拒绝 - 禁用遮罩层关闭
        this.$alert(
            'Please note that the manuscript with the same title has already been rejected. For more details, please contact the journal.', 
            'System Notice', 
            { 
        showConfirmButton: false, // 隐藏蓝色的确定按钮
        showCancelButton: true,    // 显示取消按钮
        cancelButtonText: 'Cancel', // 按钮文字设为 Cancel
        closeOnClickModal: false,   // 依然禁止点击遮罩层关闭
        type: 'warning',
        customClass: 'only-cancel-box' // 用于微调样式的类名
    }
        );
    } 
    else if (res.status == 20) {
        // 其他状况 不可操作 - 禁用遮罩层关闭
        this.$alert(
            'Please note that the manuscript with the same title is already under processing. Do not submit it again.', 
            'System Notice', 
            { 
        showConfirmButton: false, // 隐藏蓝色的确定按钮
        showCancelButton: true,    // 显示取消按钮
        cancelButtonText: 'Cancel', // 按钮文字设为 Cancel
        closeOnClickModal: false,   // 依然禁止点击遮罩层关闭
        type: 'warning',
        customClass: 'only-cancel-box' // 用于微调样式的类名
    }
        );
    } 
    else if (res.status == 22) {
        // 已经在垃圾箱（草稿箱）- 禁用遮罩层关闭，增加跳转按钮
        this.$confirm(
            'Please notice that the manuscript with the same title is already in the draft status. Would you like to view it?', 
            'System Notice', 
            {
                confirmButtonText: 'Click here',
                cancelButtonText: 'Cancel',
                type: 'info',
                closeOnClickModal: false, // 禁止点击背景关闭
                closeOnPressEscape: false  // 建议同时禁止 ESC 键关闭，增强强制性
            }
        ).then(() => {
            // 跳转逻辑：使用后端返回的 draft_id 或 article_id
            const draftId = res.draft_id;
            if (draftId) {
                bus.$emit('close_current_tags')
                            this.$router.replace({
                path: '/redirect',
                
                query: {
                    path: '/articleAdd', // 你当前页面的路由路径
                    id: draftId    ,
                   
                }
            });
            }
        }).catch(() => {
            // 点击取消的操作
        });
    } 
    else {
        // 其他普通错误
        this.$message.error(res.msg || 'Unknown error');

    }
 
    // 3. 重置表单状态
  
}
                })
                .catch(() => {
                    loading.close();
                });
        },
        upSuccess_supplementary(res, file) {
            if (res.code == 0) {
                this.form.supplementary = 'supplementary/' + res.upurl;
                this.fileL_supplementary = [{}];
                this.fileL_supplementary[0].name = 'Supplementary Material';
                this.fileL_supplementary[0].url = 'supplementary/' + res.upurl;
                this.onStaging(6);
            } else {
                this.$message.error('service error: ' + res.msg);
            }
        },
        clearUploadedFile() {
            this.form.approval_file = '';
            this.fileL_articleApproval = [];
            this.$refs['articleApproval'].clearFiles();
        },
        clearUploadedCopyrightFile() {
            this.$refs['articleCopyright'].clearFiles();
        },
        //超出传送文件个数限制
        alertlimit() {
            this.$message.error('The maximum number of uploaded files has been exceeded');
        },
        //清除文件时的事件
        removefilearticleApproval(file, fileList) {
            this.form.approval_file = '';
            this.fileL_articleApproval = [];
            this.save({
                approval_file: this.form.approval_file
            });
        },
        removefilearticleCopyright(file, fileList) {
            this.form.copyright_file = '';
            this.fileL_articleCopyright = [];
        },
        removefilecoverLetter(file, fileList) {
            this.form.coverLetter = '';
            this.fileL_coverLetter = [];
            this.$api
                .post('api/Article/delArticleFile', {
                    file_id: this.form.coverLetterId
                })
                .then((res) => {
                    if (res.code == 0) {
                        this.$message.success('Deletion succeeded!');
                    } else {
                        this.$message.error(res.msg);
                    }
                });
        },
        removefilepicturesAndTables(file, fileList) {
            console.log('file at line 2199:', file);
            if (!file) {
                return false;
            }
            this.form.picturesAndTables = '';
            this.fileL_picturesAndTables = [];
            this.$api
                .post('api/Article/delArticleFile', {
                    file_id: this.form.picturesAndTablesId
                })
                .then((res) => {
                    if (res.code == 0) {
                        this.$message.success('Deletion succeeded!');
                    } else {
                        this.$message.error(res.msg);
                    }
                });
        },
        removefiletotalpage(file, fileList) {
            this.form.totalpage = '';
        },
        clearFileManuscript() {
            this.wordimgList = [];
            this.imagesHtml = '';
            this.tables = [];
            this.tablesHtmlHtml = '';
            this.isShowCommonWord = false;
            this.$api
                .post('api/Article/reloadArticleImages', {
                    article_id: this.stagingID
                })
                .then((res) => {});

            this.$api
                .post('api/Article/reloadArticleTable', {
                    article_id: this.stagingID
                })
                .then((res) => {});
        },
        removefilemanuscirpt(file, fileList) {
            console.log('fileList at line 2337:', file, fileList);
            if (this.form.manuscirpt != '') {
            }
            this.form.manuscirpt = '';
            this.fileL_manuscirpt = [];
            this.$refs['uploadFileManuscirpt'].clearFiles();
            this.clearFileManuscript();
            if (this.form.manuscirptId) {
                this.$api
                    .post('api/Article/delArticleFile', {
                        file_id: this.form.manuscirptId
                    })
                    .then((res) => {
                        if (res.code == 0) {
                            this.$message.success('Deletion succeeded!');
                            this.initStepStatus();
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
            }
        },
        removefilesupplementary() {
            this.form.supplementary = '';
            this.fileL_supplementary = [];
            this.$api
                .post('api/Article/delArticleFile', {
                    file_id: this.form.supplementaryId
                })
                .then((res) => {
                    if (res.code == 0) {
                        this.$message.success('Deletion succeeded!');
                    } else {
                        this.$message.error(res.msg);
                    }
                });
        },
        removefilearticleCopyright() {
            this.form.copyright_file = '';
            this.fileL_articleCopyright = [];
            this.$api
                .post('api/Article/delArticleFile', {
                    file_id: this.form.figurecopyrightId
                })
                .then((res) => {
                    if (res.code == 0) {
                        this.$message.success('Deletion succeeded!');
                        this.form.figurecopyrightId = '';
                        this.form.figurecopyright_file = '';
                        this.initStepStatus();
                    } else {
                        this.$message.error(res.msg);
                    }
                });
        },
        getOpState(index) {
            let a = this.activeNames.indexOf(index) > -1 ? 'Close' : 'Open';
        },
        checkfiletype(file) {},

        // 上传文件-简历
        uperr(err) {
            this.$message.error('upload defailed:' + err);
        },
        upSuccess(res, file) {
            if (res.code == 0) {
                this.reviewerForm.qualifications = res.upurl;
            } else {
                this.$message.error('Server upload error：' + res.msg);
            }
        },
        alertlimit() {
            this.$message.error('The maximum number of uploaded files has been exceeded');
        },
        removefile() {
            this.reviewerForm.qualifications = '';
        },

        // 点击更换期刊
        change_Journal() {
            this.jour_form.journal = this.form.journal;
            this.changeVisible = true;
        },

        // 点击期刊-更换
        ch_Jour(e) {
            this.jour_form.journal = e;
        },

        // 点击期刊-确定
        close_ch_Jour() {
            for (let i in this.items) {
                if (this.items[i].journal_id == this.jour_form.journal) {
                    this.check_item = this.items[i];
                }
            }
            this.Reviewerof.journal = this.jour_form.journal;
            this.checkReviewer();
            this.form.journal = this.jour_form.journal;
            this.form.major = '';
            this.form.major_a = '';
            this.form.major_b = '';
            this.form.major_c = '';
            this.majors_a = [];
            this.majors_b = [];
            this.majors_c = [];
            this.mj_jour = [];

            this.changeVisible = false;
            this.initMajor();
        },
        getFee(id) {
            if (this.items.find((e) => e.journal_id == id)) {
                return this.items.find((e) => e.journal_id == id).fee;
            } else {
                return null;
            }

            // console.log('this.journals at line 2409:', this.journals)
        },
        // 点击期刊-更换-所有
        ch_Jour_all(e) {
            this.Reviewerof.journal = e;
            this.checkReviewer();
            this.form.journal = e;
            this.$refs.articleform.clearValidate(['journal']);
            this.form.major = '';
            this.form.major_a = '';
            this.form.major_b = '';
            this.form.major_c = '';
            this.majors_a = [];
            this.majors_b = [];
            this.majors_c = [];
            this.mj_jour = [];

            if (this.$route.query.id) {
                this.saveArticle();
            }
            this.initMajor();
            // this.getTopics()
        },
        saveArticle() {
            // api/Article/changeJournal

            this.$api
                .post('api/Article/changeJournal', {
                    article_id: this.$route.query.id,
                    journal_id: this.form.journal
                })
                .then((res) => {
                    if (res.code == 0) {
                    } else {
                        // this.$message.error(res.msg);
                    }
                });
        },
        // 点击tab变化
        StepCode1(step) {
            var e = step.index;
            console.log('.status at line 2749:', this.stepStatus);
            if (this.move_step > e) {
                if (this.move_step == 2) {
                    this.onStaging(2);
                }
                this.show_step = e;
                this.move_step = e;
            } else if (this.move_step < e) {
                this.$refs.articleform.validate((valid) => {
                    if (valid) {
                        if (this.move_step == 1) {
                            this.move_step = 2;
                            this.show_step = 2;
                        } else if (this.move_step == 2) {
                            this.onStaging(2);
                            this.show_step = 3;
                            this.move_step = 3;
                        } else {
                            this.show_step = e;
                            this.move_step = e;
                        }
                    } else {
                        this.$message.error('Please fill in the current content first!');
                    }
                });
            } else {
                if (e == 1) {
                    this.onStaging(1);
                }
                if (e == 2) {
                    this.onStaging(2);
                }
                if (e == 4) {
                    this.getMajorData();
                }
            }
        },
        isArrayEqual(arr1, arr2) {
            if ((arr1 === null || arr1 === undefined) && (arr2 === null || arr2 === undefined)) return true;
            if (arr1 === null || arr1 === undefined || arr2 === null || arr2 === undefined) return false;

            if (!Array.isArray(arr1) || !Array.isArray(arr2)) return false;

            if (arr1.length !== arr2.length) return false;

            return arr1.every((val, index) => val === arr2[index]);
        },
        isMajorValueListEqual(list1, list2) {
            if ((list1 === null || list1 === undefined) && (list2 === null || list2 === undefined)) return true;
            if (list1 === null || list1 === undefined || list2 === null || list2 === undefined) return false;

            if (!Array.isArray(list1) || !Array.isArray(list2)) return false;

            if (list1.length !== list2.length) return false;

            return list1.every((item1, index) => {
                const item2 = list2[index];

                if ((item1 === null || item1 === undefined) && (item2 === null || item2 === undefined)) return true;
                if (item1 === null || item1 === undefined || item2 === null || item2 === undefined) return false;

                const sv1 = item1.selectedValue;
                const sv2 = item2.selectedValue;
                return this.isArrayEqual(sv1, sv2);
            });
        },

        StepCode(step, i) {
            var that = this;
            const targetIndex = step.index; // 目标步骤索引（1、2、3等）
            const currentStep = this.move_step; // 当前所在步骤

            // 1. 后退
            if (currentStep > targetIndex) {
                if (currentStep == 4) {
                    // if (this.majorValueList.length > 0) {
                    //     const isEqual = this.isMajorValueListEqual(this.majorValueList, this.oldMajorValueList);
                    //     if (!isEqual) {
                    //         var major = '';
                    //         major = this.majorValueList
                    //             .map((item) =>
                    //                 item.selectedValue && item.selectedValue.length > 0
                    //                     ? item.selectedValue[item.selectedValue.length - 1]
                    //                     : []
                    //             )
                    //             .toString(',');
                    //         this.$api
                    //         .post('api/Article/addArticleStaging', {
                    //             user_id: this.form.user_id,
                    //             article_id: this.form.article_id,
                    //             major: major
                    //         })
                    //         .then((res) => {
                    //             if (res.status == 1) {
                    //                 this.oldMajorValueList = [...this.majorValueList];
                    //             }
                    //         });
                    //     }
                    // }
                }
                this.show_step = targetIndex;
                this.move_step = targetIndex;
                return;
            }

            // 2. 前进
            if (currentStep < targetIndex) {
                this.$refs.articleform.validate((valid) => {
                    if (!valid) {
                        this.$message.error('Please fill in the current content first!');
                        return false;
                    } else {
                        let invalidStep = null;
                        for (let i = 0; i < targetIndex - 1; i++) {
                            const step = this.stepStatus[i];
                            if (step.status !== 1) {
                                invalidStep = step;
                                break;
                            }
                        }

                        if (invalidStep) {
                            this.$message.error(
                                this.stepStatusCurrent.msg ? this.stepStatusCurrent.msg : 'Please fill in the current content first!'
                            );

                            this.show_step = this.stepStatusCurrent.step;
                            this.move_step = this.stepStatusCurrent.step;
                            this.$forceUpdate();
                        } else {
                            this.show_step = targetIndex;
                            this.move_step = targetIndex;
                        }
                        if (targetIndex == 4) {
                            if (
                                Array.isArray(this.majorValueList) &&
                                this.majorValueList.some((item) => item.selectedValue !== null && item.selectedValue !== undefined)
                            ) {
                            } else {
                                if (this.isNewArticle) {
                                    this.getMajorData();
                                }
                            }
                        }
                    }
                });
                // return;
            }

            // 3. 停留在当前步骤（点击当前步骤时）
            if (currentStep === targetIndex) {
                // 触发对应步骤的暂存或数据加载
            }
        },

        // 辅助方法：检查目标步骤的所有前置步骤是否都已完成
        checkAllPrevStepsCompleted(targetIndex) {
            // 前置步骤为：1 ~ targetIndex-1（例如：目标步骤3的前置步骤是1和2）
            for (let i = 1; i < targetIndex; i++) {
                // 假设步骤状态通过表单验证结果判断（也可根据this.stepStatus中的状态判断）
                // 若需用stepStatus，可替换为：!this.stepStatus[i-1].isCompleted（需确保数组索引对应步骤）
                const isPrevCompleted = this.$refs.articleform.validateStep(i); // 假设validateStep可验证指定步骤
                if (!isPrevCompleted) {
                    return false; // 有前置步骤未完成，返回false
                }
            }
            return true; // 所有前置步骤已完成
        },

        // 辅助方法：找到第一个未完成的步骤
        findFirstUncompletedStep() {
            // 从步骤1开始检查，返回第一个未完成的步骤
            for (let i = 1; i <= 3; i++) {
                // 假设步骤1~3
                const isCompleted = this.$refs.articleform.validateStep(i);
                if (!isCompleted) {
                    return i;
                }
            }
            return 3; // 若都完成，返回最后一个步骤（3）
        },

        // 辅助方法：处理步骤前进逻辑
        handleStepForward(targetIndex) {
            // 步骤1→2：无需额外操作（直接跳转）
            if (targetIndex === 2 && this.move_step === 1) {
                this.move_step = 2;
                this.show_step = 2;
            }
            // 步骤2→3：需先暂存步骤2
            else if (targetIndex === 3 && this.move_step === 2) {
                this.onStaging(2);
                this.move_step = 3;
                this.show_step = 3;
            }
            // 其他合法前进场景（如扩展更多步骤）
            else {
                this.move_step = targetIndex;
                this.show_step = targetIndex;
            }
        },
        showFiles() {
            // 文件显示出来
            this.fileL_articleApproval = [];
            if (this.form.approval_file != '') {
                this.fileL_articleApproval = [{}];
                this.fileL_articleApproval[0].name = 'Ethical approval file';
                this.fileL_articleApproval[0].url = this.form.approval_file;
            }

            this.fileL_coverLetter = [];
            if (this.form.coverLetter != '') {
                this.fileL_coverLetter = [{}];
                this.fileL_coverLetter[0].name = 'Cover letter File';
                this.fileL_coverLetter[0].url = this.form.coverLetter;
            }
            this.fileL_picturesAndTables = [];
            if (this.form.picturesAndTables != '') {
                this.fileL_picturesAndTables = [{}];
                this.fileL_picturesAndTables[0].name = 'Figures File';
                this.fileL_picturesAndTables[0].url = this.form.picturesAndTables;
            }
            this.fileL_manuscirpt = [];
            if (this.form.manuscirpt != '') {
                this.fileL_manuscirpt = [{}];
                this.fileL_manuscirpt[0].name = 'Manuscript File';
                this.fileL_manuscirpt[0].url = this.form.manuscirpt;
            }
            this.fileL_supplementary = [];
            if (this.form.supplementary != '') {
                this.fileL_supplementary = [{}];
                this.fileL_supplementary[0].name = 'Supplementary Material';
                this.fileL_supplementary[0].url = this.form.supplementary;
            }
            this.fileL_articleCopyright = [];
            if (this.form.figurecopyright_file != '') {
                this.fileL_articleCopyright = [{}];
                this.fileL_articleCopyright[0].name = 'Figure Copyright Declaration File';
                this.fileL_articleCopyright[0].url = this.form.figurecopyright_file;
            }
        },

        // 点击进行下一步
         onStep:throttle(function async(e) {
            this.$refs.articleform.validate((valid) => {
                if (valid) {
                    if (e == 1) {
                        if (this.form.journal == 0 || !this.form.journal) {
                            this.$message.error('Please select the Journal');
                            return false;
                        }

                        var flist = this.keywordsList;
                        var fstr = '';
                        for (var fu in flist) {
                            if (flist[fu].ke != '') {
                                fstr += flist[fu].ke.trim() + ',';
                            }
                        }
                        this.form.keyWords = fstr == '' ? '' : fstr.substring(0, fstr.length - 1);
                        if (this.form.abstrart && this.isAbstractTooShort(this.form.abstrart)) {
                            this.$message.error('The abstract should not be less than 200 Chinese characters or English words!');
                            return false;
                        }
                        this.$api
                            .post('api/Article/addArticlePart1', {
                                article_id: this.form.article_id,
                                journal: this.form.journal,
                                title: this.form.title,
                                keyWords: this.form.keyWords,
                                abstrart: this.form.abstrart,
                                type: this.form.type,
                                username: this.form.username,
                                user_id: this.form.user_id,
                                approval: this.form.approval,
                                approval_file: this.form.approval_file,
                                approval_content: this.form.approval_content,

                                fund: this.form.fund
                            })
                            .then((res) => {
                                if (res.code == 0) {
                                    this.stagingID = res.data.article_id;
                                    this.form.article_id = res.data.article_id;
                                    this.$message.success('Saving succeeded!');
                                    this.initStepStatus((step1Incomplete) => {
                                        console.log('step1Incomplete at line 3283:', step1Incomplete);
                                        this.$nextTick(() => {
                                            if (
                                                step1Incomplete.list &&
                                                step1Incomplete.list.length > 0 &&
                                                step1Incomplete.list[0].status == 1
                                            ) {
                                                this.move_step = 2; //进行步骤
                                                this.show_step = 2; //显示内容
                                                this.$forceUpdate();
                                            }
                                        });
                                    });
                                }
                                else {
                       

    // 2. 根据状态码处理逻辑
    if (res.code == 21) {
        // 系统内编辑已经拒绝 - 禁用遮罩层关闭
        this.$alert(
            'Please note that the manuscript with the same title has already been rejected. For more details, please contact the journal.', 
            'System Notice', 
            { 
        showConfirmButton: false, // 隐藏蓝色的确定按钮
        showCancelButton: true,    // 显示取消按钮
        cancelButtonText: 'Cancel', // 按钮文字设为 Cancel
        closeOnClickModal: false,   // 依然禁止点击遮罩层关闭
        type: 'warning',
        customClass: 'only-cancel-box' // 用于微调样式的类名
    }
        );
    } 
    else if (res.code == 20) {
        // 其他状况 不可操作 - 禁用遮罩层关闭
        this.$alert(
    'Please note that the manuscript with the same title is already under processing. Do not submit it again.', 
    'System Notice', 
    { 
        showConfirmButton: false, // 隐藏蓝色的确定按钮
        showCancelButton: true,    // 显示取消按钮
        cancelButtonText: 'Cancel', // 按钮文字设为 Cancel
        closeOnClickModal: false,   // 依然禁止点击遮罩层关闭
        type: 'warning',
        customClass: 'only-cancel-box' // 用于微调样式的类名
    }
);
    } 
    else if (res.code == 22) {
        // 已经在垃圾箱（草稿箱）- 禁用遮罩层关闭，增加跳转按钮
        this.$confirm(
            'Please notice that the manuscript with the same title is already in the draft status. Would you like to view it?', 
            'System Notice', 
            {
                confirmButtonText: 'Click here',
                cancelButtonText: 'Cancel',
                type: 'info',
                closeOnClickModal: false, // 禁止点击背景关闭
                closeOnPressEscape: false  // 建议同时禁止 ESC 键关闭，增强强制性
            }
        ).then(() => {
            // 跳转逻辑：使用后端返回的 draft_id 或 article_id
            const draftId = res.draft_id;
            if (draftId) {
                bus.$emit('close_current_tags')
                            this.$router.replace({
                path: '/redirect',
                
                query: {
                    path: '/articleAdd', // 你当前页面的路由路径
                    id: draftId    ,
                   
                }
            });
            }
        }).catch(() => {
            // 点击取消的操作
        });
    } 
    else {
        this.$message.error(res.msg);
       
       

    }
 

  
}
                                
                               
                            });
                    }
                    if (e == 2) {
                        // // this.onStaging(e); //暂存
                        // // 作者邮箱必填
                        // let Firsta = 0;
                        // let Corra = 0;
                        // if (this.form.authorList.length == 0) {
                        //     this.$message.error('Author is required');
                        //     return;
                        // }
                        // for (let i in this.form.authorList) {
                        //     if (this.form.authorList[i].email == '') {
                        //         this.$message.error('Please fill in the email information!');
                        //         return;
                        //     }
                        //     if (this.form.authorList[i].firstname == '') {
                        //         this.$message.error('Please fill in the author name!');
                        //         return;
                        //     }
                        //     if (this.form.authorList[i].country == '') {
                        //         this.$message.error('Country is necessary for author!');
                        //         return;
                        //     }
                        //     if (this.form.authorList[i].isReport && this.form.authorList[i].address == '') {
                        //         this.$message.error('Address is necessary for corresponding author');
                        //         return;
                        //     }
                        //     if (this.form.authorList[i].isReport) {
                        //         Corra++;
                        //     }
                        //     if (this.form.authorList[i].isSuper) {
                        //         Firsta++;
                        //     }
                        // }
                        // if (Firsta == 0 || Corra == 0) {
                        //     // this.$message.error('First author and corresponding author must be exist');
                        //     // return;
                        // }
                        if (this.stepStatus[1].status == 1) {
                            this.move_step = 3; //进行步骤
                            this.show_step = 3; //显示内容
                        } else {
                            this.$message.error(
                                this.stepStatus[1].msg ? this.stepStatus[1].msg : 'Please fill in the current content first!'
                            );
                            return false;
                        }
                    }
                    if (e == 3) {
                        if (this.form.is_use_ai == 1 && this.form.use_ai_explain == '') {
                            this.$message.error('Please describe how artificial intelligence is utilized in this article');
                            return false;
                        }

                        this.onStagingSubmit(e);
                    }
                } else {
                    // this.$message.error('The submission encountered an error.');
                    return false;
                }
            });
        }, 1000),

        // save暂存
        onStagingSave: throttle(function (e) {
            if (e == 1) {
                this.onStaging(1);
            } else if (e == 2) {
                this.onStaging(2);
            } else if (e == 3) {
                this.onStaging('save3');
            } else if (e == 4) {
                this.onStaging('save4');
            }
        }, 1000),
        //暂存加下一步
        onStagingSubmit: throttle(function (e) {
            if (e == 3) {
                this.$api
                    .post('api/Article/addArticlePart3', {
                        article_id: this.form.article_id,
                        user_id: this.form.user_id,
                        is_use_ai: this.form.is_use_ai,
                        use_ai_explain: this.form.use_ai_explain,
                        is_figure_copyright: this.form.is_figure_copyright
                    })
                    .then((res) => {
                        if (res.status == 1) {
                            this.initStepStatus();
                            if (
                                Array.isArray(this.majorValueList) &&
                                this.majorValueList.some((item) => item.selectedValue !== null && item.selectedValue !== undefined)
                            ) {
                            } else {
                                if (this.isNewArticle) {
                                    this.getMajorData();
                                }
                            }
                            this.move_step = 4;
                            this.show_step = 4;
                            this.$message.success('Saving succeeded!');
                        } else {
                            this.$message.error(res.msg);

                            return false;
                        }
                    });
            }
        }, 1000),

        // 暂存
        onStaging(e) {
            var that = this;
            if (e == 1) {
                if (this.form.journal == 0 || !this.form.journal) {
                    this.$message.error('Please select the Journal');
                    return false;
                }
                if (!this.form.title) {
                    this.$message.error('Please enter a title');
                    return false;
                }
                var flist = this.keywordsList;
                var fstr = '';
                for (var fu in flist) {
                    if (flist[fu].ke != '') {
                        fstr += flist[fu].ke.trim() + ',';
                    }
                }
                this.form.keyWords = fstr == '' ? '' : fstr.substring(0, fstr.length - 1);
                this.save(
                    {
                        article_id: this.form.article_id,
                        journal: this.form.journal,
                        title: this.form.title,
                        keywords: this.form.keyWords,
                        abstrart: this.form.abstrart,
                        type: this.form.type,
                        username: this.form.username,
                        user_id: this.form.user_id,
                        approval: this.form.approval,
                        approval_file: this.form.approval_file,
                        approval_content: this.form.approval_content,

                        fund: this.form.fund
                    },
                    (res) => {
                        if (res.status == 1) {
                            const url = new URL(window.location.href);
                            url.searchParams.set('id', res.data.article_id); // 替换或新增 id 参数
                            window.history.replaceState({}, document.title, url.toString());
                        }
                    }
                );
                // this.$api.post('api/Article/addArticlePart1', this.form).then((res) => {
                //     if (res.code == 0) {
                //         this.stagingID = res.data.article_id;
                //         this.form.article_id = res.data.article_id;
                //         this.initStepStatus();
                //         this.getMajorData();
                //         this.$message.success('Saving succeeded!');
                //     } else {
                //         this.$message.error(res.msg);
                //         console.log('456');
                //         return false;
                //     }
                // });
            } else if (e == 2) {
            } else if (e == 3) {
                this.$api
                    .post('api/Article/addArticlefile', {
                        article_id: this.form.article_id,
                        type: 'coverLetter',
                        url: this.form.coverLetter
                    })
                    .then((res) => {
                        if (res.code == 0) {
                            this.form.coverLetterId = res.data.file_id;
                            this.$refs.articleform.clearValidate('coverLetterId');
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
            } else if (e == 4) {
                this.$api
                    .post('api/Article/addArticlefile', {
                        article_id: this.form.article_id,
                        type: 'picturesAndTables',
                        url: this.form.picturesAndTables
                    })
                    .then((res) => {
                        if (res.code == 0) {
                            this.form.picturesAndTablesId = res.data.file_id;
                            this.$refs.articleform.clearValidate('picturesAndTables');
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
            } else if (e == 5) {
                this.$api
                    .post('api/Article/addArticlefile', {
                        article_id: this.form.article_id,
                        type: 'manuscirpt',
                        url: this.form.manuscirpt
                    })
                    .then((res) => {
                        if (res.code == 0) {
                            this.form.manuscirptId = res.data.file_id;
                            this.$refs.articleform.clearValidate('manuscirpt');
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
            } else if (e == 6) {
                this.$api
                    .post('api/Article/addArticlefile', {
                        article_id: this.form.article_id,
                        type: 'supplementary',
                        url: this.form.supplementary
                    })
                    .then((res) => {
                        if (res.code == 0) {
                            this.form.supplementaryId = res.data.file_id;
                            this.$refs.articleform.clearValidate('supplementary');
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
            } else if (e == 7) {
                //文件
                this.$api
                    .post('api/Article/addFigureCopyright', {
                        article_id: this.form.article_id,
                        user_id: this.form.user_id,
                        type: 'figurecopyright',
                        url: this.form.figurecopyright_file,
                        is_figure_copyright: this.form.is_figure_copyright
                    })
                    .then((res) => {
                        if (res.status == 1) {
                            this.initStepStatus();
                            this.form.figurecopyrightId = res.data.file_id;
                            this.$refs.articleform.clearValidate('figurecopyright_file');
                        } else {
                            this.$message.error(res.msg);
                        }
                    });
            } else if (e == 'save3') {
                this.save({
                    is_use_ai: this.form.is_use_ai,
                    use_ai_explain: this.form.use_ai_explain,
                    is_figure_copyright: this.form.is_figure_copyright
                });
            } else if (e == 'save4') {
                var data = { reviewers: [] };
                if (this.majorValueList.length > 0) {
                    data.major = this.majorValueList
                        .map((item) =>
                            item.selectedValue && item.selectedValue.length > 0 ? item.selectedValue[item.selectedValue.length - 1] : []
                        )
                        .toString(',');
                }

                if (this.tuiJianForm.length > 0) {
                    // const hasInvalidEmail = this.tuiJianForm.some((item) => {
                    //     // 假设邮箱字段为 item.email，根据实际字段名修改
                    //     return !item.email || item.email.trim() === '';
                    // });

                    // if (hasInvalidEmail) {
                    //     // 提示用户“所有项的邮箱为必填项”
                    //     this.$message.error(`Each reviewer's email is required, please fill it out completely`);
                    //     return; // 终止后续逻辑（比如不执行下面的 data.major 赋值）
                    // }
                    // 方法2：使用map返回新数组（如果不想修改原数组）
                    var list = this.tuiJianForm.map((item) => {
                        // 复制原对象，避免修改原数组元素
                        const newItem = { ...item };
                        newItem.major =
                            item.major_all && Array.isArray(item.major_all) && item.major_all.length > 0
                                ? item.major_all[item.major_all.length - 1]
                                : '';
                        return newItem;
                    });
                    console.log('list:', list);
                    data.reviewers = list;
                    console.log('data.reviewers at line 3219:', data.reviewers);
                }
                // if (this.istransfer && this.form.checkedjours.length > 0) {
                //     data.checkedjours = this.form.checkedjours;
                // }
                // if (this.form.istransfer) {
                //     data.istransfer = this.form.istransfer;
                // } else {
                //     data.istransfer = false;
                // }
                // if (this.form.BecomeRev) {
                //     data.BecomeRev = this.form.BecomeRev;
                // } else {
                //     data.BecomeRev = false;
                // }
                if (this.form.code) {
                    data.code = this.form.code;
                }
                if (this.agreechecked) {
                    data.is_agree = 1;
                } else {
                    data.is_agree = 2;
                }
                this.save(data);
            }
        },

        isAbstractTooShort(text) {
            let chineseCount = (text.match(/[\u4e00-\u9fa5]/g) || []).length;
            let englishCount = (text.match(/[A-Za-z0-9]/g) || []).length;

            const total = chineseCount + englishCount;

            return total < 200; // 不足 200，说明太短
        },
        // 读取getMajorData
        getMajorData() {
            this.$api
                .post('api/Article/getArticleField', {
                    article_id: this.stagingID
                })
                .then((res) => {
                    this.majorValueList = res.data.map((item) => ({
                        selectedValue: Array.isArray(item.major)
                            ? item.shu
                            : typeof item.shu === 'string'
                            ? item.shu.split(',').map(Number)
                            : [item.shu]
                    }));
                    this.isNewArticle = false;
                });
        },
        changeUseAi(e) {
            console.log('e at line 2837:', e);
            if (e == 2) {
                this.form.use_ai_explain = '';
            }
        },
        // 读取
        async Temporary() {
            const load = this.$loading({
                lock: true,
                text: 'Loading...',
                spinner: 'el-icon-loading',
                background: 'rgba(0, 0, 0, 0.7)'
            });
            this.$api
                .post('api/Article/getSaveArticleDetail', {
                    article_id: this.stagingID
                })
                .then(async (res) => {
                    console.log(res, '已经保存的值');
                    if (res.code == 0) {
                        // 基本信息
                        this.form.journal = res.data.base.journal_id;
                        this.$forceUpdate();
                        this.form.type = res.data.base.type;
                        this.form.title = res.data.base.title;
                        this.form.approval = res.data.base.approval;
                        this.form.approval_file = res.data.base.approval_file;
                        this.form.approval_content = res.data.base.approval_content;
                        this.form.abstrart = res.data.base.abstrart;
                        // this.form.istransfer = res.data.base.is_transfer == 1 ? true : false;
                        this.form.fund = res.data.base.fund;
                        this.form.is_use_ai = res.data.base.is_use_ai == 1 || res.data.base.is_use_ai == 2 ? res.data.base.is_use_ai : '';
                        this.agreechecked = res.data.base.is_agree == 1 ? true : false;
                        console.log('this.form.is_use_ai at line 3442:', this.form.is_use_ai);
                        this.form.code = res.data.base.code;
                        if (res.data.reviewer.length > 0) {
                            // 处理原有评审员数据
                            const processedList = res.data.reviewer.map((e) => ({
                                ...e,
                                major_all: e.p_major ? e.p_major.split(',').map(Number) : []
                            }));

                            // 计算需要补充的数量（不足3个则补全）
                            const needAddCount = Math.max(0, 3 - processedList.length);

                            // 补充空白对象（结构与处理后的数据一致，可根据实际需求调整默认值）
                            const List = Array.from({ length: needAddCount }, () => ({
                                // 这里可以根据实际业务需求设置默认值，保持字段结构一致
                                id: '', // 示例字段，可根据实际情况调整
                                name: '', // 示例字段，可根据实际情况调整
                                p_major: '', // 与原数据字段对应
                                major_all: [] // 保持处理后的字段结构
                                // 其他必要字段可按需添加
                            }));

                            // 合并处理后的数据和补充数据，赋值给tuiJianForm
                            this.tuiJianForm = [...processedList, ...List];
                        } else {
                            // 可选：如果原reviewer为空，也默认设置3个空白对象（根据需求决定是否保留）
                            this.tuiJianForm = Array.from({ length: 3 }, () => ({
                                id: '',
                                name: '',
                                p_major: '',
                                major_all: []
                            }));
                        }

                        console.log('this.tuiJianForm at line 3506:', this.tuiJianForm);
                        this.form.use_ai_explain = res.data.base.use_ai_explain;
                        this.form.is_figure_copyright =
                            res.data.base.is_figure_copyright == 1 || res.data.base.is_figure_copyright == 2
                                ? res.data.base.is_figure_copyright.toString()
                                : '';

                        if (this.items.find((e) => e.journal_id == this.form.journal)) {
                            this.check_item = this.items.find((e) => e.journal_id == this.form.journal);
                        }
                        let keyList = res.data.base.keywords.split(',');
                        this.keywordsList = [];
                        for (let i = 0; i < keyList.length; i++) {
                            this.keywordsList.push({
                                ke: keyList[i]
                            });
                        }

                        // 文件
                        if (res.data.files.length > 0) {
                            for (let i = 0; i < res.data.files.length; i++) {
                                if (res.data.files[i].type_name == 'articleApprova') {
                                    this.form.approval_file = res.data.files[i].file_url;
                                    this.form.approval_fileId = res.data.files[i].file_id;
                                }
                                if (res.data.files[i].type_name == 'coverLetter') {
                                    this.form.coverLetter = res.data.files[i].file_url;
                                    this.form.coverLetterId = res.data.files[i].file_id;
                                }
                                if (res.data.files[i].type_name == 'picturesAndTables') {
                                    this.form.picturesAndTables = res.data.files[i].file_url;
                                    this.form.picturesAndTablesId = res.data.files[i].file_id;
                                }
                                if (res.data.files[i].type_name == 'manuscirpt') {
                                    this.form.manuscirpt = res.data.files[i].file_url;
                                    this.form.manuscirptId = res.data.files[i].file_id;
                                }
                                if (res.data.files[i].type_name == 'supplementary') {
                                    this.form.supplementary = res.data.files[i].file_url;
                                    this.form.supplementaryId = res.data.files[i].file_id;
                                }
                                if (res.data.files[i].type_name == 'figurecopyright') {
                                    this.form.figurecopyright_file = res.data.files[i].file_url;
                                    this.form.figurecopyrightId = res.data.files[i].file_id;
                                    console.log('this.form.figurecopyrightId at line 3363:', this.form.figurecopyright_file);
                                }
                            }
                            this.showFiles();
                        }
                    } else {
                        this.$message.error(res.msg);
                    }
                    await this.TempoAuthor();
                    load.close();
                });
        },

        // 读取作者
        async getAuthorList(fn) {
            await this.$api
                .post('api/Article/getAuthors', {
                    article_id: this.stagingID
                })
                .then(async (res) => {
                    if (res.code == 0) {
                        // 作者
                        if (res.data.authors.length > 0) {
                            this.form.authorList = res.data.authors;
                            this.activeNames = [];
                            for (let i = 0; i < this.form.authorList.length; i++) {
                                if (this.form.authorList[i].is_report == 1) {
                                    this.form.authorList[i].isReport = true;
                                } else {
                                    this.form.authorList[i].isReport = false;
                                }
                                if (this.form.authorList[i].is_super == 1) {
                                    this.form.authorList[i].isSuper = true;
                                } else {
                                    this.form.authorList[i].isSuper = false;
                                }
                                this.form.authorList[i].title = this.form.authorList[i].author_title;
                                this.activeNames.push(i + 1);
                            }
                        } else {
                            this.form.authorList = [];
                        }
                        if (fn) {
                            fn();
                        }
                    } else {
                        this.$message.error(res.msg);
                    }
                });
        },
        async TempoAuthor() {
            await this.getAuthorList(() => {
                this.$nextTick(() => {
                    this.initStepStatus();
                });
            });
        },

        // 选择
        chanSelt() {
            this.$forceUpdate();
        },

        // 获取话题
        getTopics() {
            this.$api
                .post('api/Article/getJournalTopics', {
                    journal_id: this.Reviewerof.journal
                })
                .then((res) => {
                    if (res.code == 0) {
                        this.topicsList = res.data.topics;
                        // console.log(res.data.topics,'话题')
                    } else {
                        this.$message.error(res.msg);
                    }
                });
        },
        // 选中值变化
        topicsChange(e) {
            // console.log(this.form.topics,'选中的话题id')
        }
    }
};
</script>

<style scoped>
/deep/.apc_content a{
    color: rgb(81, 127, 213) !important; cursor: pointer !important; text-decoration: underline !important;
}
.formTopics {
    width: 100%;
}
/* f8fbff */
.step_list_new {
    background-color: #f8f8f8;
    box-shadow: 2px 30px 15px -20px #eee inset;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    width: calc(100% - 20px);
    margin-top: 20px;
}
::v-deep .step_list_new .el-step__icon.is-text {
    border: 3px solid !important;
}
::v-deep .step_list_new .el-step__icon {
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    font-size: 18px !important;
}
::v-deep .step_list_new .el-step__head.is-process {
    color: #006699 !important;
    border-color: #006699 !important;
}
::v-deep .step_list_new .el-step__title.is-process {
    color: #006699 !important;
    font-weight: bold !important;
}
::v-deep .step_list_new .el-step.is-center .el-step__line {
    left: 57% !important;
    right: -43% !important;
    z-index: 2 !important;
}
.checkbox-item-title {
    width: calc(100% - 60px);
    white-space: wrap;
}
.manu_add h3 {
    font-size: 16px;
    margin-top: 0px;
}
::v-deep .step-success .el-step__head {
    color: #67c23a !important;
    border-color: #67c23a !important;
}
::v-deep .step-saved .el-step__head {
    color: #f58b00 !important;
    border-color: #f58b00 !important;
}
::v-deep .step-edit .el-step__head {
    color: #006699 !important;
    border-color: #006699 !important;
}
::v-deep .step-success .step_title {
    color: #67c23a !important;
    border-color: #67c23a !important;
}
::v-deep .step-saved .step_title {
    color: #f58b00 !important;
    border-color: #f58b00 !important;
}
::v-deep .step-edit .step_title {
    color: #006699 !important;
    border-color: #006699 !important;
}
::v-deep .el-step.is-horizontal .el-step__line {
    top: 18px !important;
}
::v-deep .step_title {
    display: flex;
    align-items: center;
    justify-content: center;
}
::v-deep .step_title > div {
    display: flex;
    align-items: center;
    width: auto;
    margin: 0 auto;
}
.step_icon {
    display: flex;
    align-items: center;
    justify-content: center;
}
.step_icon i {
    font-weight: bold;
}

.step_list_new .C_style {
    background-color: #ecf5ff !important;
    -webkit-box-shadow: 2px 30px 15px -20px #ebf5ff inset !important;
    box-shadow: 2px 30px 15px -20px #ebf5ff inset !important;
}
::v-deep .up_disabled .el-upload--text {
    border: none !important;
    display: none !important;
}
::v-deep .up_disabled .el-upload-list__item:first-child {
    margin-top: 5px !important;
}
::v-deep .el-upload-list__item:first-child {
    margin-top: 5px !important;
}
::v-deep .checkbox-item {
    width: calc(100% - 0px) !important;
    display: flex;

    justify-content: flex-start;
    align-items: center;
}
::v-deep .checkbox-item .el-checkbox {
    display: flex;

    align-items: center;
}

/* 每列占50%宽度，实现两栏布局 */
::v-deep .checkbox-two-columns .el-checkbox {
    width: calc(100% - 20px) !important; /* 减去一半的gap间距 */
    box-sizing: border-box;
    margin-right: 0;
}
::v-deep .checkbox-two-columns .el-checkbox__label {
    width: calc(100% - 20px) !important; /* 减去一半的gap间距 */
    box-sizing: border-box;
    margin-right: 0;
}
::v-deep .checkbox-two-columns .checkbox-item-actions {
    display: inline-block;
    width: 70px;
    height: 20px;
}
::v-deep .checkbox-two-columns .checkbox-item-actions i {
    font-size: 18px;
    margin-left: 10px;
    cursor: pointer;
}
/* 穿透Element UI的样式，强制覆盖所有限制 */
.full-show-no-scroll::v-deep .el-textarea {
    overflow: visible !important;
}

.full-show-no-scroll::v-deep .el-textarea__inner {
    white-space: normal !important; /* 强制换行 */
    word-wrap: break-word !important; /* 长文本/长单词换行 */
    overflow: visible !important; /* 溢出内容显示，不隐藏 */

    max-height: none !important; /* 取消最大高度限制 */
    resize: none !important; /* 禁止手动调整大小 */
    padding: 12px; /* 可选：调整内边距，避免内容贴边 */
}

/* 隐藏滚动条（即使偶尔出现也看不见） */
.full-show-no-scroll::v-deep ::-webkit-scrollbar {
    display: none !important;
}
::v-deep .el-textarea__inner {
    line-height: 1.5 !important;
    font-family: 'Helvetica Neue For Number', 'Elsevier Gulliver', Georgia, serif !important;
}
/* 修改确定按钮的颜色，去掉蓝色 */
/deep/.el-message-box__wrapper .el-message-box__btns.my-custom-button {
    background-color: #606266 !important; /* 灰色 */
    border-color: #606266 !important;
    color: #fff !important;
}
/deep/.my-custom-button:hover {
    background-color: #909399 !important;
    border-color: #909399 !important;
}

/* /deep/ .my-custom-button:hover {
 .my-custom-alert .el-message-box__status.el-icon-info {
    color: #909399 !important; 
} */
</style>

<style>
.author-box {
    width: 150%;
}

.author-box .el-row {
    margin-bottom: 5px;
}

.author-box .author-title {
    color: #969595;
    text-align: center;
    background-color: #eceaea;
}

.author-box .author-delete {
    text-align: center;
}

.author-box .author-delete i {
    color: red;
}

.zyfont {
    font-size: 14px;
    color: rgb(133, 131, 131);
}

.tffont {
    font-size: 10px;
    line-height: 1.5;
    color: rgb(133, 131, 131);
}

.orcid_link {
    color: #409eff;
    margin-left: 20px;
}

.orcid_link:hover {
    text-decoration: underline;
}

.manu_add .el-upload__tip {
    position: absolute;
    top: -5px;
    left: 80px;
    color: #999;
    font-size: 13px;
}

.el-collapse-item__content {
    padding-bottom: 8px !important;
}

.up_newstyle {
    margin-left: 10px;
}

.up_newstyle .el-upload--text {
    background-color: #006699;
    border: 1px solid #006699;
    padding: 0 7px;
    /* margin-left: 10px; */
}

.up_newstyle .el-upload__text em {
    color: #fff !important;
    font-size: 12px;
}

.Del_btn {
    color: #df1f1f !important;
    margin-left: 30px;
}

.Del_btn:hover {
    text-decoration: underline;
}

.manu_add .el-form-item__label {
    color: #000;
}

.manu_add .el-upload__tip {
    color: #333;
}

.manu_add .zyfont {
    color: #111;
}

.manu_add h3 {
    margin: 5px 20px 30px 20px;
    color: #006699;
}

.manu_add .el-collapse {
    border-top: 1px solid #bfcdd3;
    border-bottom: 1px solid #bfcdd3;
}

.manu_add .el-collapse-item__header {
    background-color: #f8fbff;
    border-bottom: 1px solid #bfcdd3;
}

.manu_add .el-collapse-item__wrap {
    background-color: #f8fbff;
}

.manu_add .el-collapse-item__header.is-active {
    border-bottom-color: transparent;
}

.manu_add .bag_color {
    border-top: 1px solid #88888830;
    padding-top: 30px;
    background-color: #fff;
}

.manu_add .bag_color > div {
    padding: 0px 15px;
}

.manu_add .pro_ceed {
    width: 260px;
    margin-bottom: 50px;
    font-size: 14px;
}

.manu_add .pro_stage {
    width: 120px;
    margin-bottom: 50px;
    font-size: 14px;
}

.manu_add .el-form-item__error {
    margin-left: 10px;
    top: 99%;
    color: #e52d2d;
}

.step_list {
    margin: 30px 0 0 0;
}

.step_list > div {
    position: relative;
    float: left;
    background-color: #eee;
    padding-top: 20px;
}

.step_list > div > .bor_der {
    position: absolute;
    height: 70px;
    width: 2px;
    background-color: #d5dee3;
    top: 40px;
    left: 0;
}

.step_list > div > div {
    width: 240px;
    height: 85px;
    text-align: center;
    color: #777;
    background-color: #eee;
    padding-top: 5px;
    font-weight: bold;
    cursor: pointer;
}

.step_list > div > div:hover {
    color: #006699;
}

.step_list > div > div i {
    display: block;
    font-size: 35px;
    margin-bottom: 5px;
}

.step_list > div.C_style {
    background-color: #f8fbff !important;
    box-shadow: 2px 30px 15px -20px #ebf5ff inset !important;
}

.step_list > div.C_style > div {
    background-color: #f8fbff;
    box-shadow: 2px -30px 15px -20px #ebf5ff inset;
    color: #006699;
}

.step_list > div .num {
    position: absolute;
    top: 0;
    left: 0;
    height: 20px;
    line-height: 20px;
    width: 20px;
    text-align: center;
    color: #fff;
    background: #006699;
}

.step_list > div .num::before,
.step_list > div .num::after {
    content: '';
    position: absolute;
    border-top: 10px solid #006699;
    border-right: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 10px solid #006699;
}

.step_list > div .num::before {
    bottom: -20px;
    left: 0;
}

.step_list > div .num::after {
    right: -20px;
    top: 0;
}

.forWard {
    line-height: 20px;
    color: #333;
    font-size: 14px;
    padding: 10px 10px 0 10px;
    background-color: #ffffff80;
    border: 1px dashed #dae8f7;
    margin-top: -10px;
    margin-bottom: 20px;
}

.forWard > div {
    border-bottom: 1px solid #dae8f7;
    padding: 0 20px 10px 20px;
    margin-bottom: 10px;
}

.forWard > div:nth-last-child(1) {
    border-bottom: 0;
}

.forWard > div > p {
    margin: 0 0 3px 0;
    line-height: 22px;
    color: #333;
}

.forWard > div > p > font {
    color: #777;
}

.forWard .jiantouBiao {
    cursor: pointer;
    color: #006699;
    margin-left: 10px;
    font-size: 20px;
}

.jour_ku {
    font-size: 14px;
    float: left;
    width: 330px;
    padding-left: 10px;
    cursor: pointer;
    color: #666;
    line-height: 34px;
}

.jour_ku:nth-child(2n) {
    width: 280px;
}

.jour_ku.B_style {
    background-color: #006699;
    color: #fff;
    font-weight: bold;
}

.jour_ku_all {
    font-size: 14px;
    float: left;
    width: 48%;
    padding-left: 10px;
    cursor: pointer;
    color: #666;
    line-height: 26px;
}

/* .jour_ku_all:nth-child(3n + 1) {
    width: 230px;
}

.jour_ku_all:nth-child(3n + 2) {
    width: 220px;
} */

.jour_ku_all.B_style {
    color: #1161ea;
    font-weight: bold;
    font-size: 16px;
    background: #ebf5ff;
    border-radius: 4px;
    /* border: 1px solid #b3d8ff ; */
}

.tally_jour {
    line-height: 18px;
    width: 350px;
    margin-right: 0;
    font-size: 13px;
}

.tally_jour .el-checkbox__label {
    font-size: 13px;
}

.web_stite:hover {
    text-decoration: underline;
}

.tuijian_f {
    width: calc(100% - 100px);
    padding: 10px 5px 15px 5px;
    margin: 20px 0px 0px 55px;
    box-shadow: 0 0 8px #b7d2ed;
    position: relative;
}

.tuijian_f > p {
    margin: 0 0 0 10px;
    color: #006699;
    font-weight: bold;
    letter-spacing: -1px;
    font-size: 14px;
}

.tuijian_f > .shanchu_tj {
    position: absolute;
    right: 0;
    top: 5px;
    padding: 5px 10px;
}

.tuijian_f > .el-form-item {
    display: inline-block;
    margin: 0 8px;
}

.tuijian_f > .el-form-item .el-form-item__label {
    padding: 0;
}

.tuijian_f .el-form-item > .el-form-item__label:before {
    content: '' !important;
}
/* 评审人表单容器 - 网格布局设置 */
.tuijian_f {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4列平均分布 */
    gap: 10px; /* 字段间间距 */
    /* padding:0 10px; */
    border: 1px solid #eee; /* 可选：加个边框区分每个评审人表单 */
    border-radius: 4px;
    margin-bottom: 10px; /* 多个评审人表单之间的间距 */
}

/* 标题和删除按钮样式调整 */
.tuijian_f > p {
    grid-column: 1 / -1; /* 标题占满整行 */
    margin: 0 0 0px 0;
    font-weight: 500;
    padding: 0 6px;
}

.tuijian_f .shanchu_tj {
    grid-column: 4 / 5; /* 删除按钮放在第4列 */
    align-self: end; /* 靠下对齐 */
    justify-self: end; /* 靠右对齐 */
}

/* Filed字段单独占一行 */
.tuijian_f .el-form-item:nth-child(6) {
    /* 因为Filed是第6个表单项（从p开始算第1个） */
    grid-column: 1 / -1; /* 占满所有列（整行） */
}

/* 调整字段宽度和对齐（可选，根据需要微调） */
.tuijian_f .el-form-item {
    margin-bottom: 0; /* 取消默认margin，用grid的gap控制间距 */
}

.tuijian_f .el-input,
.tuijian_f .el-cascader {
    width: 100% !important; /* 让输入框自适应网格列宽 */
}
.el-popover {
    word-break: break-word;
    text-align: left;
}

.partyAry {
}

.partyAry > div {
    font-size: 14px;
    /* width: 258px; */
    width: 96%;
    display: inline-block;
    padding: 5px 15px 10px 15px;
    margin-bottom: 20px;
    box-shadow: 0 0 8px #b7d2ed;
    background-color: #ffffff80;
}

/* 	.partyAry>div:nth-child(3n+2) {
		margin-left: 20px;
		margin-right: 20px;
	} */

.partyAry > div > p {
    margin: 0 0 3px 0;
    line-height: 22px;
}

.partyAry > div > p > font {
    color: #777;
}
::v-deep .el-collapse-item__header {
    background-color: transparent !important;
}
</style>
