<template>
    <div class="container-box">
        <el-table ref="multipleTable" v-loading="loading" element-loading-text="拼命加载中" :aline="center"
            element-loading-spinner="el-icon-loading" element-loading-background="rgba(255, 255, 255, 0.6)"
            :data="tableData" tooltip-effect="dark" :border="true" size="small" :lazy="true" height="570"
            :empty-text="$i18n.locale == 'en' ? 'Sorry no data!' : '暂无数据'" @selection-change="handleSelectionChange">
            <el-table-column prop="exhibitionName" :label="$i18n.locale == 'en' ? 'Events' : '会展名称'" align="center">
            </el-table-column>
            <el-table-column prop="contact" :label="$i18n.locale == 'en' ? 'Contacts' : '联系人'" align="center">
            </el-table-column>
            <el-table-column prop="unitName" :label="$i18n.locale == 'en' ? 'Company Name' : '公司名称'" align="center">
            </el-table-column>
            <el-table-column prop="email" :label="$i18n.locale == 'en' ? 'Email' : '邮箱'" align="center">
            </el-table-column>
            <el-table-column prop="mobile" :label="$i18n.locale == 'en' ? 'Phone' : '电话'" align="center">
            </el-table-column>
            <el-table-column prop="approvalStatus" :label="$i18n.locale == 'en' ? 'Audit Status' : '审核状态'"
                align="center">
                <template slot-scope="scope">{{ scope.row.approvalStatus == 0 ? $i18n.locale == 'zh' ? '待审批' : 'Approval pending' : scope.row.approvalStatus == 1 ? $i18n.locale == 'zh' ? '通过' : 'Pass' : $i18n.locale ==
                                    'zh' ? '不通过' : 'No pass'
                }}</template>
            </el-table-column>
        </el-table>
        <div class="ui-bottom">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="queryInfo.pageNo" :page-sizes="[5, 10, 15]" :page-size="queryInfo.pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination>
        </div>
    </div>
</template>

<script>
import { ConventionRegistrationList } from '@/api/exhibition'
// import { getDicts } from "@/api/dict";
export default {
    data() {
        return {
            tableData: [],
            multipleSelection: [],
            meetingInfoArray: [],
            statusArray: [],
            statusEnArray: [],
            cureentPage: 1,
            queryInfo: {
                pageNo: 1,
                pageSize: 10,
                extend2: this.$i18n.locale.toUpperCase()
            },
            total: 0,
            loading: true
        }
    },
    mounted() {
        let language = this.$i18n.locale.toUpperCase()
        console.log(language);
        this.getList();

    },
    watch: {
        "$i18n.locale"() {
            this.getList()
            this.queryInfo.extend2 = this.$i18n.locale.toUpperCase()
        },
    },

    methods: {

        getList() {
            let params = this.queryInfo
            ConventionRegistrationList(params).then(res => {
                let that = this;
                if (res.data) {
                    if (res.data.exhibitionApplys) {
                        this.total = Number(res.data.page.totalCount);
                    }
                    if (res.data.exhibitionApplys) {
                        that.tableData = res.data.exhibitionApplys;
                    } else {
                        that.tableData = []
                    }
                    this.loading = false
                } else {
                    that.tableData = []
                }
            }).catch(() => {
                this.loading = false
            })
        },
        handleSizeChange(pagesize) {
            this.queryInfo.pageSize = pagesize
            this.getList()
        },
        //监听当前页数
        handleCurrentChange(pageNum) {
            this.queryInfo.pageNo = pageNum
            this.getList()
        },
        handleSelectionChange(val) {
            this.multipleSelection = val;
        },
        formatDate(t) {
            if (!t) {
                return ''
            } else {
                var original = new Date(t);
                var year = original.getFullYear();
                var month = original.getMonth() + 1;
                var date = original.getDate();
                var hour = original.getHours();
                var minute = original.getMinutes();
                var second = original.getSeconds();
                // return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second; 
                return year + "/" + month + "/" + date;
            }
        },
        toView(router, json) {
            this.$router.push({ name: router, params: { key: json } });
        },
    }
}
</script>

<style scoped>
.container-box {
    padding: 20px;
}

.ui-bottom {
    width: 100%;
    text-align: center;
}
</style>