<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> Manuscript list
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <el-table
                :data="tableData"
                border
                stripe
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
            >
                <el-table-column type="index" label="No." width="55" align="center"></el-table-column>
                <el-table-column prop="accept_sn" label="Manuscript ID" width="180" align="center"></el-table-column>
                <!-- <el-table-column prop="art_rev_id" label="ID" width="55" align="center"></el-table-column> -->
                <el-table-column prop="article_title" label="Title" align="center"></el-table-column>

                <el-table-column prop="journal_title" label="Journal" align="center"></el-table-column>
                <el-table-column
                    prop="state"
                    label="Status"
                    :formatter="stateFormat"
                    align="center"
                ></el-table-column>
                <el-table-column label="" width="180" align="center">
                    <template slot-scope="scope">
                        <el-button
                            size="mini"
                            type="primary"
                            plain
                            icon="el-icon-tickets"
                            @click="showdetail(scope.row)"
                        >Detail</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination
                    background
                    layout="total, prev, pager, next"
                    :current-page="query.pageIndex"
                    :page-size="query.pageSize"
                    :total="Total"
                    @current-change="handlePageChange"
                ></el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name:'reviewerArticleList',
    data() {
        return {
            userrole:localStorage.getItem('ms_userrole'),
            query: {
                username: localStorage.getItem('ms_username'),
                pageIndex: 1,
                pageSize: 10
            },
            tableData: [],
            Total: 0
        };
    },
    created() {
        if(this.userrole!='reviewer'){
            this.$router.push('/authorApplyReviewer');
        }
        this.getdate();
    },
    methods: {
        // 获取数据
        getdate() {
            this.$api
                .post('api/Reviewer/getReviewerList', this.query)
                .then(res => {
                    this.Total = res.total;
                    this.tableData = res.data;
                })
                .catch(err => {
                    console.log(err);
                });
        },
        // 分页导航
        handlePageChange(val) {
            this.$set(this.query, 'pageIndex', val);
            this.getdate();
        },
        showdetail(row) {
            if(row.state==4){
                this.$message.error('Review expired!');
            }else{
                this.$router.push({ path: 'reviewerArticleDetail', query: { id: row.art_rev_id } });
            }
        },
        stateFormat(row, column, cellValue, index){
            if(cellValue==0){
                return 'With reviewer';
            }else if(cellValue==1){
                return 'Revision';
            }else if(cellValue==2){
                return 'Reject';
            }else if(cellValue==3){
                return 'Accepted';
            }else if(cellValue==4){
                return 'invalid';
            }

        }
    }
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
.el-table .warning-row {
    background: #f3ca7f;
}
.el-table .success-row {
    background: #bcfc9a;
}
.el-table .normol-row{
    background: #d8f1c7
}
.el-table .red-row{
    background: #f05555;
}
</style>
