<template>
    <div class="content">
        <div class="table-wrapper">
            <div class="title">
                <h6>Task List</h6>
            </div>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column prop="taskName" label="Task Name"></el-table-column>
                <el-table-column prop="runningState" label="Running State"></el-table-column>
                <el-table-column prop="lastRunTime" label="Last run time"></el-table-column>
                <el-table-column prop="executeNow" label="Execute Now">
                    <template slot-scope="scope">
                        <span class="table-row-btn">Sync Now</span>
                    </template>
                </el-table-column>
                <template slot="empty" v-if="tableData.length == 0">
                    <span>No data available</span>
                </template>
            </el-table>
            <el-pagination v-if="totalPage>1" :page-size="limit" :total="total" @current-change="handleCurrentChange" background layout="prev, pager, next"></el-pagination>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return {
            tableData: [
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'},
                {taskName: 'Task Name', runningState: 'Done', lastRunTime: '2021.09.23 12:34:21'}
            ],
            maxHeight: 0,
            page: 1,
            limit: 10,
            total: 300,
            totalPage: 10,

        }
    },
    created() {
        this.getTableData();
        // this.getMaxHeight();
        // window.addEventListener('resize', () => {
        //     this.getMaxHeight();
        // })
    },
    methods: {
        getTableData(){

        },
        handleCurrentChange(val){
            this.page = val;
            this.getTableData();
        },
        getMaxHeight(){
            let bodyHeight = document.documentElement.clientHeight || document.body.clientHeight;
            this.maxHeight = bodyHeight - 194;
        }
    }
}
</script>
