<template>
<el-container direction="vertical">
    <el-header height="40px" style="border-bottom: 1px solid #eee">日志管理</el-header>
    <!-- <div style="margin:10px 0;">
      <el-date-picker v-model="selectDate" type="date" placeholder="选择日期"></el-date-picker>
      <el-button style="margin-left:10px;" type="primary">查询</el-button>
    </div>
    -->
    <el-table :data="tableData" border style="width: 100%">
        <el-table-column align="center" prop="id" label="记录ID"></el-table-column>
        <el-table-column align="center" prop="admin_id" label="管理员ID"></el-table-column>
        <el-table-column align="center" prop="username" label="管理员名称"></el-table-column>
        <el-table-column align="center" prop="content" label="操作接口地址"></el-table-column>
        <el-table-column align="center" prop="ip" label="IP地址"></el-table-column>
        <el-table-column align="center" prop="date" label="记录日期"></el-table-column>
    </el-table>
    <el-row style="margin-top:10px;" type="flex" justify="end">
        <el-pagination background layout="prev, pager, next" :total="total" :page-size="pageSize" :current-page="pageNumber" @current-change="onPageChange"></el-pagination>
    </el-row>
</el-container>
</template>

<script>
import {
    actionLogList
} from "@/api";
export default {
    data() {
        return {
            tableData: [],
            pageSize: 10,
            pageNumber: 1,
            total: 0,
        };
    },
    mounted() {
        this.getActionLogList();
    },
    methods: {
        getActionLogList() {
            const _self = this;
            actionLogList({
                pageSize: _self.pageSize,
                pageNumber: _self.pageNumber,
            }).then((res) => {
                console.log(res);
                if (res && res.msg == "ok") {
                    _self.total = res.data.total;
                    _self.tableData = [...res.data.rows];
                }
            });
        },
        onPageChange(page) {
            if (page == this.pageNumber) {
                return;
            } else {
                this.pageNumber = page;
                setTimeout(() => {
                    this.getActionLogList();
                }, 0);
            }
        },
    },
};
</script>

<style scoped>
</style>
