<template>
    <div class="pd10">
        <el-form :inline="true" :model="formData" class="demo-form-inline">
            <el-form-item>
                <Timeinterval ref="interval" :interval="3"></Timeinterval>
            </el-form-item>
            <el-form-item label="筛选数据:">
                <el-input v-model.trim="formData.loginName" placeholder="请输入筛选数据" clearable></el-input>
            </el-form-item>
            <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
            v-loading="loading"
            element-loading-text="数据加载中"
            header-cell-class-name="table_header"
            :data="datamock"
            style="width: 100%"
            :height="vh + 'px'"
        >
            <el-table-column prop="userName" label="登录用户" align="center"></el-table-column>
            <el-table-column prop="ip" label="登录IP" align="center"></el-table-column>
            <el-table-column prop="time" label="登录时间" align="center"></el-table-column>
        </el-table>
        <el-pagination
            background
            align="right"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="formData.pageNum"
            :page-sizes="[20, 30, 50, 100]"
            :page-size="formData.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            class="mt10"
        ></el-pagination>
    </div>
</template>
<script>
import Timeinterval from '@/views/components/Timeinterval.vue'
import { getAuditLog } from '@/api/AuditManagement/AuditManagement'
export default {
    components: {
        Timeinterval
    },
    props: {},
    data() {
        return {
            loading: false,
            zoom: '', //图表焦点校验
            vh: undefined,
            formData: {
                operateType: '认证',
                loginName: '',
                pageNum: 1,
                pageSize: 20
            },
            datamock: [],
            total: undefined
        }
    },
    created() {},
    mounted() {
        this.setHeight()
        window.addEventListener('resize', this.setHeight)

        this.onSubmit()
    },
    beforeDestroy() {
        window.removeEventListener('resize', this.setHeight)
    },
    methods: {
        setHeight() {
            this.vh = window.sessionStorage.getItem('appheight') - 95
        },
        //查询
        onSubmit() {
            this.loading = true
            this.item = this.$refs.interval.timeValue
            this.formData.searchBeginTime = this.item[0]
            this.formData.searchEndTime = this.item[1]
            getAuditLog(this.formData).then(res => {
                this.datamock = res.data.records
                this.total = res.data.total
                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>
