<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-user"></i> Reviewer 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>
                <!-- <el-button type="primary" icon="el-icon-circle-plus-outline" @click="addJournal">add</el-button> -->
            </div>
            <el-table
                :data="tableData"
                border
                stripe
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
            >
                <!-- <el-table-column prop="user_id" label="No." align="center"></el-table-column> -->
                <el-table-column prop="account" label="Account" align="center"></el-table-column>
                <el-table-column prop="country" label="Country" align="center"></el-table-column>
                <el-table-column prop="company" label="Affiliation" 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>
        <!-- <el-dialog title="change" :visible.sync="editVisible" width="40%">
            <el-form ref="changform" :model="change" label-width="80px">
                <el-form-item label="editormsg">
                    <span>{{change.title}}</span>
                </el-form-item>
                <el-form-item label="state">
                    <el-select v-model="change.editorId" placeholder="Please select">
                        <el-option :key="0" label="Please select" :value="0"></el-option>
                        <el-option
                            v-for="item in editorList"
                            :key="item.user_id"
                            :label="item.account"
                            :value='item.user_id'
                        ></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="editVisible = false">cancel</el-button>
                <el-button type="primary" @click="">save</el-button>
            </span>
        </el-dialog> -->
    </div>
</template>

<script>
export default {
    name:'reviewerList',
    data() {
        return {
            query: {
                username: localStorage.getItem('ms_username'),
                journalId:0,
                pageIndex: 1,
                pageSize: 10
            },
            tableData: [],
            journalList:[],
            Total: 0,
            editVisible: false,
        };
    },
    created() {
        this.getdate();
        this.initselect();
    },
    methods: {
        // 获取编辑列表数据
        getdate() {
            this.$api
                .post('api/User/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) {
            this.$router.push({ path: 'reviewerDetail', query: { id: row.user_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>
