<template>
    <div class="pd10" v-loading="loading" element-loading-text="数据加载中">
        <el-form :inline="true" :model="formData" class="demo-form-inline">
            <el-form-item>
                <el-button type="primary" @click="onSubmit" icon="el-icon-search">查询</el-button>
            </el-form-item>
        </el-form>
        <el-table
            stripe
            size="mini"
            :row-config="{ isCurrent: true, isHover: true }"
            border
            highlight-current-row
            header-cell-class-name="table_header"
            :data="datamock"
            style="width: 100%"
            :height="vh + 'px'"
        >
            <el-table-column prop="name" label="昵称" align="center"></el-table-column>
            <el-table-column prop="loginName" label="登录名" align="center"></el-table-column>
            <el-table-column prop="phone" label="手机号" align="center">
                <template slot-scope="scope">
                    <span>{{ scope.row.phone == '' ? '/' : scope.row.phone }}</span>
                </template>
            </el-table-column>
            <el-table-column prop="time" label="登录过期时间" align="center"></el-table-column>
            <el-table-column prop="result" label="状态" align="center">
                <template>
                    <span>在线</span>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            background
            align="right"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="formData.pageNum"
            :page-sizes="[100, 200, 300, 500, 1000]"
            :page-size="formData.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            class="mt10"
        ></el-pagination>
    </div>
</template>
<script>
import { getOnlineUsers } from '@/api/AuditManagement/AuditManagement'
export default {
    props: {},
    data() {
        return {
            loading: false,
            zoom: '', //图表焦点校验
            vh: undefined,
            formData: {
                pageNum: 1,
                pageSize: 100
            },
            datamock: [],
            total: undefined
        }
    },
    created() {},
    mounted() {
        this.setHeight()
        window.addEventListener('resize', this.setHeight)
        this.zoom = 1 / document.body.style.zoom

        this.onSubmit()
    },
    beforeDestroy() {
        window.removeEventListener('resize', this.setHeight)
    },
    methods: {
        setHeight() {
            this.vh = window.sessionStorage.getItem('appheight') - 95
            this.zoom = 1 / document.body.style.zoom
        },
        //查询
        onSubmit() {
            this.loading = true
            getOnlineUsers().then(res => {
                this.datamock = res.data
                this.total = this.datamock.length
                this.loading = false
            })
        },
        //每页条数改变时触发 选择一页显示多少行
        handleSizeChange(val) {
            this.formData.pageSize = val
            this.onSubmit()
        },
        //当前页改变时触发 跳转其他页
        handleCurrentChange(val) {
            this.formData.pageNum = val
            this.onSubmit()
        }
    },

    computed: {},

    watch: {}
}
</script>
<style lang="less" scoped>
@import url('../../../styles/comStyle.less');
// ::v-deep .el-form-item--small .el-form-item__content,
// .el-form-item--small .el-form-item__label {
//   height: 32px;
// }
// ::v-deep .el-table .cell {
//   text-align: center;
// }
</style>
