<template>
    <Page>
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
            <el-form-item>
                <timepicker ref="timepk" :interval="interval" :dataTree="dataTree"></timepicker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="queryData" icon="el-icon-search">查询</el-button>
            </el-form-item>
        </el-form>
        <el-table
            stripe
            highlight-current-row
            header-cell-class-name="table_header"
            border
            style="width: 100%"
            :data="tableData"
            height="calc(100vh - 225px)"
            v-loading='loading'
        >
            <el-table-column prop="userName" label="推送用户" align="center"></el-table-column>
            <el-table-column prop="info" label="推送内容" align="center"></el-table-column>
            <el-table-column prop="sendTime" label="推送时间" align="center"></el-table-column>
        </el-table>
        <el-pagination
            background
            align="right"
            @size-change="handleSizeChange"
            @current-change="pageChange"
            :current-page="formInline.pageNum"
            :page-sizes="[20, 30, 40, 50, 100]"
            :page-size="formInline.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            class="mt10"
        ></el-pagination>
    </Page>
</template>

<script>
import { queryPushLog } from '@/api/app/device'
import timepicker from '@/views/components/TimePicker/index4'

export default {
    name: 'GovernLogOperation',
    components: {
        timepicker
    },
    data() {
        return {
            interval: 3,
            total: '',
            formInline: {
                searchBeginTime: '',
                searchEndTime: '',
                searchState: 0,
                searchValue: '',
                sortBy: '',
                orderBy: '',
                pageNum: 1,
                pageSize: 50
            },
            loading: false,
            tableData: []
            //tabHeight: 'calc(100vh - 255px)',
        }
    },
    computed: {
        vth() {
            return window.sessionStorage.getItem('appheight') - 95
        }
    },
    mounted() {
        this.queryData()
    },
    methods: {
        queryData() {
            this.loading = true
            this.formInline.searchBeginTime = this.$refs.timepk.timeValue[0]
            this.formInline.searchEndTime = this.$refs.timepk.timeValue[1]
            queryPushLog(this.formInline).then(res => {
                if (res.code == 'A0000') {
                    this.total = res.data.total
                    this.tableData = res.data.records.map(item => {
                        return {
                            info: item.devName + item.showName,
                            ...item
                        }
                    })
                }
                this.loading = false
            })
        },
        onSubmit() {
            console.log('submit!')
        },
        pageChange(e) {
            console.log('pageChange!')
            console.log(e)
            this.formInline.pageNum = e
            this.queryData()
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`)
            this.formInline.pageNum = 1
            this.formInline.pageSize = val
            this.queryData()
        }
    }
}
</script>
<style lang="scss" scoped>
::v-deep.el-table--enable-row-hover .el-table__body tr:hover > td {
    background-color: $hoverf !important;
    color: #000 !important;
}
</style>
