<template>
    <div>
        <span style="font-size: 14px; color: #606266; margin: 0 10px 0 0">Research direction :</span>
        <el-input
            v-model="messform.email"
            clearable
            placeholder="Please enter email"
            style="width: 190px; display: inline-block; margin: 0 10px 20px 0"
        ></el-input>
        <el-input
            v-model="messform.field"
            clearable
            placeholder="Please enter field"
            style="width: 190px; display: inline-block; margin: 0 10px 20px 0"
        ></el-input>
        <el-button type="primary" icon="el-icon-search" @click="handleSearch">Search</el-button>
        <el-table
            :data="revTable"
            border
            stripe
            class="table"
            ref="multipleTable"
            header-cell-class-name="table-header"
            empty-text="New messages (0)"
        >
            <el-table-column width="360" label="Base Information">
                <template slot-scope="scope">
                    <p class="tab_tie_col">
                        <span>Realname: </span><b style="font-size: 14px">{{ scope.row.realname }}</b><el-button 
                         
                                    size="mini"
                                    type="success"
                                    plain
                                    icon="el-icon-tickets"
                                    @click="openDetail(scope.row)"
                                    style="margin-left: 10px;padding:4px;float: right;"
                                    >Detail</el-button
                                >
                    </p>
                    <p class="tab_tie_col"><span>Account: </span>{{ scope.row.account }}</p>
                    <p class="tab_tie_col"><span>Email: </span>{{ scope.row.email }}</p>
                    
                </template>
            </el-table-column>
            <el-table-column label="Other Information">
                <template slot-scope="scope">
                    <p class="tab_tie_col" v-if="scope.row.company != ''"><span>Affiliation: </span>{{ scope.row.company }}</p>
                    <p class="tab_tie_col" v-if="scope.row.field != ''"><span>Field: </span>{{ scope.row.field }}</p>
                    <!-- <p class="tab_tie_col" v-if="scope.row.majorstr != ''"><span>Major: </span>{{ scope.row.majorstr }}</p> -->
                </template>
            </el-table-column>
            <el-table-column label="Research areas" width="260">
                        <template slot-scope="scope">
                            <commonMajorTableList
                                :user_id="scope.row.user_id"
                                :baseInfo="scope.row"
                                :key="scope.row.user_id"
                                :disabled="true"
                            ></commonMajorTableList>
                        </template>
                    </el-table-column>
            <el-table-column prop="rs_num" label="Review Record" width="180">
                <template slot-scope="scope">
                    Major review: {{ scope.row.major_times }} ({{ scope.row.major_rate }}%)
                    <br />
                    Cancel review : {{ scope.row.rd_num }}

                    <!-- <font style="margin-left: 5px">(Reviewing:{{ scope.row.now }})</font> -->
                </template>
            </el-table-column>
            <el-table-column prop="rs_num" label="Reviewed Times" width="140">
                <template slot-scope="scope">
                    Total: {{ scope.row.rs_num }}
                    <br />
                    <div>
                        <i class="el-icon-check" style="font-weight: bold; color: green; margin-right: 4px"> </i>
                        <span style="margin-right: 4px; color: green">{{ scope.row.right_times }}</span>
                        <span>({{ scope.row.right_rate }}%)</span>
                    </div>
                    <div>
                        <i class="el-icon-close" style="font-weight: bold; color: red; margin-right: 4px"> </i>
                        <span style="margin-right: 4px; color: red">{{ scope.row.error_times }}</span>
                        <span>({{ scope.row.error_rate }}%)</span>
                    </div>
                    <!-- <font style="margin-left: 5px">(Reviewing:{{ scope.row.now }})</font> -->
                </template>
            </el-table-column>
            <!-- <el-table-column prop="rd_num" label="Fail number" width="140"></el-table-column> -->
            <el-table-column label="" width="120" align="center">
                <template slot-scope="scope">
                    <!-- <el-button size="mini" type="success" plain icon="el-icon-tickets" @click="openDetail(scope.row)">Detail</el-button> -->
                    <el-button size="mini" type="primary" plain icon="el-icon-check" @click="openSelect(scope.row)"> Select</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="pagination">
            <el-pagination
                background
                layout="total, prev, pager, next"
                :current-page="messform.page"
                :page-size="messform.size"
                :total="Total"
                @current-change="handlePageChange"
            ></el-pagination>
        </div>
    </div>
</template>

<script>
import commonMajorTableList from '../page/components/major/tableList.vue';

export default {components: {
       
        commonMajorTableList
    },
    data() {
        return {
            messform: {
                article_id: this.$route.query.id,

                page: 1,
                size: 15
            },
            revTable: [],
            mesOpen: [],
            mesOpenVisble: false,
            loading: false,
            Total: 0,
            majors_a: [],
            majors_b: [],
            majors_c: [],
            allFileds: [], // 全部领域
            fieldsProps: {
                checkStrictly: true,
                value: 'major_id',
                label: 'major_title',
                children: 'children'
            },
            selectFileds: []
        };
    },
    created() {
        this.getDate();
    },
    computed: {},
    methods: {
        // 获取编辑列表数据
        getDate() {
            this.$emit('loading', true);
            this.$api
                .post('/api/Recommend/lists', this.messform)
                .then((res) => {
                    this.$emit('loading', false);
                    this.revTable = res.data.lists;
                    this.Total = res.data.total;

                    // this.loading = false;
                })
                .catch((err) => {
                    console.log(err);
                    this.$emit('loading', false);
                });
        },

        // 关键字搜索
        handleSearch() {
            // this.loading = true;
            // console.log(this.messform)
            this.getDate();
        },

        // 审稿人详情
        openDetail(row) {
            this.$emit('openDetail', row);
        },
        // 保存添加操作
        openSelect(row) {
            this.$emit('openSelect', row);
        },

        // 分页导航
        handlePageChange(val) {
            this.$set(this.messform, 'page', val);
            this.getDate();
        }
    }
};
</script>

<style scoped>
.table {
    width: 100%;
    font-size: 14px;
}
.tab_tie_col {
    margin-bottom: 5px;
    color: #333;
}

.tab_tie_col > span {
    color: #888;
    margin: 0 5px 0 0;
    font-size: 13px;
}
</style>
