<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-calendar"></i> Manuscript revise
                </el-breadcrumb-item>
                <el-breadcrumb-item>Manuscript revise</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="form-box" v-loading="loading">
                <el-form ref="articleform" :model="form" :rules="rules" label-width="110px">
                    <el-form-item label="Status:">
                        <span>{{articleState}}</span>
                    </el-form-item>
                    <el-form-item v-if="form.accept_sn != ''" label="Manuscript ID:">
                        <span>{{form.accept_sn}}</span>
                    </el-form-item>
                    <el-form-item label="Journal:">
                        <span>{{form.journalname}}</span>
                    </el-form-item>
                    <el-form-item label="Title:">
                        <span>{{form.title}}</span>
                    </el-form-item>
                    <el-form-item label="Suggest">
                        <el-input
                            type="textarea"
                            autosize
                            v-model="suggest"
                        ></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-col :offset="4">
                            <el-button type="primary" @click="revise" >Revise</el-button>
                        </el-col>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            baseUrl: this.Common.baseUrl,
            mediaUrl: this.Common.mediaUrl,
            suggest : '',
            form: {
                articleId: this.$route.query.id,
                journal: '',
                journalname: '',
                username: localStorage.getItem('U_name'),
                title: '',
                accept_sn: '',
                abstrart: '',
                keyWords: '',
                type: '',
                approval: false,
                fund: '',
                coverLetter: '',
                picturesAndTables: [],
                manuscirpt: '',
                state: '',
                ctime: '',
                authorList: []
            }
        };
    },
    created: function () {
        this.initarticle();
    },
    computed: {
        articleState: function () {
            let str = '';
            switch (this.form.state) {
                case 0:
                    str = this.$t('artstate.state0');
                    break;
                case 1:
                    str = this.$t('artstate.state1');
                    break;
                case 2:
                    str = this.$t('artstate.state2');
                    break;
                case 3:
                    str = this.$t('artstate.state3');
                    break;
                case 4:
                    str = this.$t('artstate.state4');
                    break;
                case 5:
                    str = this.$t('artstate.state5');
                    break;
            }
            return str;
        }
    },
    methods: {
        revise(){
            this.$router.push({ path: 'articleDetail', query: { id: this.$route.query.id } });
        },
        //初始化期刊信息
        initarticle() {
            this.$api
                .post('api/Article/getArticleDetail', { articleId: this.form.articleId, human: 'author' })
                .then((res) => {
                    this.form.title = res.article.title;
                    this.form.journal = res.article.journal_id;
                    this.form.journalname = res.article.journalname;
                    this.form.abstrart = res.article.abstrart;
                    this.form.accept_sn = res.article.accept_sn;
                    this.form.keyWords = res.article.keywords;
                    this.form.fund = res.article.fund;
                    this.form.state = res.article.state;
                    this.form.type = res.article.type;
                    (this.form.approval = res.article.approval == 1 ? true : false), (this.form.ctime = res.article.ctime);
                    this.msgs = res.msg;
                    this.suggest = res.suggest;
                    this.form.authorList = [];
                    var alist = res.authors;
                    for (var i in alist) {
                        this.form.authorList.push({
                            art_aut_id: alist[i].art_aut_id,
                            firstname: alist[i].firstname,
                            lastname: alist[i].lastname,
                            company: alist[i].company,
                            department: alist[i].department,
                            title: alist[i].author_title,
                            country: alist[i].country,
                            email: alist[i].email,
                            address: alist[i].address,
                            isSuper: alist[i].is_super == 1 ? true : false,
                            isReport: alist[i].is_report == 1 ? true : false
                        });
                    }
                })
                .catch((err) => {
                    console.log(err);
                });
        }
    }
};
</script>