<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-user"></i> Apply list
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-select
                    v-model="query.journalId"
                    @change="getdate"
                    placeholder="Please select journal"
                >
                    <el-option :key="0" label="All journal" :value="0"></el-option>
                    <el-option
                        v-for="item in journalList"
                        :key="item.journal_id"
                        :label="item.title"
                        :value="item.journal_id"
                    ></el-option>
                </el-select>
            </div>
            <el-table
                :data="tableData"
                border
                stripe
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
            >
                <!-- <el-table-column prop="reviewer_id" label="No." align="center" width="50"></el-table-column> -->
                <el-table-column prop="name" label="Name" align="center"></el-table-column>
                <el-table-column prop="email" label="Email" align="center"></el-table-column>
                <el-table-column prop="company" label="Affiliation" align="center"></el-table-column>
                <el-table-column label="" width="100" align="center">
                    <template slot-scope="scope">
                        <el-button
                            type="text"
                            plain
                            icon="el-icon-tickets"
                            @click="showdetail(scope.row)"
                        >Detail</el-button>
                        <!-- <el-button
                            type="text"
                            plain
                            icon="el-icon-edit"
                            @click="handleChange(scope.row)"
                        >change</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:'reviewerApplyList',
    data() {
        return {
            query: {
                username: localStorage.getItem('U_name'),
                journalId: 0,
                pageIndex: 1,
                pageSize: 10
            },
            tableData: [],
            journalList: [],
            Total: 0
        };
    },
    created() {
        this.getdate();
        this.initselect();
    },
    methods: {
        // 获取编辑列表数据
        getdate() {
            this.$api
                .post('api/User/getReviewerApplyList', 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) {
            this.$router.push({ path: 'reviewerApplyDetail', query: { id: row.reviewer_id } });
        },
        //初始化期刊选项
        initselect() {
            this.$api
                .post('api/Article/getJournal', { username: this.query.username })
                .then(res => {
                    this.journalList = res;
                })
                .catch(err => {
                    console.log(err);
                });
        }
    }
};
</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>
