<template>
    <d2-container>
        <div class="d2-table-view-full">
            <div class="d2-table-view-header">
                <el-form size="small" :inline="true" :model="filter" @keyup.enter.native="handleList" class="demo-form-inline">
                    <el-form-item label="工号">
                        <el-input v-model="filter.intervieweeNo" placeholder="工号" clearable/>
                    </el-form-item>
                    <el-form-item label="姓名">
                        <el-input v-model="filter.intervieweeName" placeholder="姓名" clearable/>
                    </el-form-item>
                    <el-form-item label="部门">
                        <el-input v-model="filter.depNm" placeholder="部门" clearable/>
                    </el-form-item>
                    <el-form-item label="受访时间">
                        <el-date-picker
                                v-model="time"
                                type="datetimerange"
                                @change="dateChange"
                                range-separator="至"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                value-format="yyyy-MM-dd HH:mm:ss" clearable></el-date-picker>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="handleList('1')">查询</el-button>
                    </el-form-item>
                </el-form>
            </div>
            <div class="d2-table-view-content">
                <d2-crud
                        title="受访统计"
                        :columns="columns"
                        :data="data"
                        :options="tableOptions"
                        :loading="loading"
                ></d2-crud>
            </div>
            <div class="d2-table-view-footer">
                <el-pagination
                        @current-change="handleCurrentChange"
                        @size-change="handleSizeChange"
                        :page-size="tableOptions.pageList[0]"
                        :page-sizes="tableOptions.pageList"
                        :current-page.sync="currentPage"
                        layout="total,sizes, prev, pager, next,jumper"
                        :total="pagination.total"
                ></el-pagination>
            </div>
        </div>
    </d2-container>
</template>

<script>
    import {getPageList} from "../../../../api/visitor/visitorExcel/interviewExcel";
    import {tableOptions} from "../../../../assets/options";

    export default {
        name: "index",
        data(){
            return{
                time:'',
                loading:false,
                tableOptions,
                currentPage:1,
                pagination:{
                    total:0
                },
                filter:{
                    intervieweeNo:'',
                    intervieweeName:'',
                    depNm:'',
                    bgTm:'',
                    endTm:'',
                    pageNum:1,
                    pageSize:10,
                },
                columns:[
                    {
                        title:'序号',
                        key:'index',
                        minWidth:'50',
                        formatter (row, column, cellValue, index) {
                            return index+1
                        }
                    },
                    {
                        title:'受访人工号',
                        key:'intervieweeNo',
                        minWidth:'100',
                        showOverflowTooltip: true
                    },
                    {
                        title:'受访人姓名',
                        key:'intervieweeName',
                        minWidth:'100',
                        showOverflowTooltip: true
                    },
                    {
                        title:'受访人部门',
                        key:'depNm',
                        minWidth:'100',
                        showOverflowTooltip: true
                    },
                    {
                        title:'受访时间',
                        key:'visitTime',
                        minWidth:'100',
                        showOverflowTooltip: true
                    },
                    {
                        title:'访客姓名',
                        key:'visitorName',
                        minWidth:'100',
                        showOverflowTooltip: true
                    },
                ],
                data:[],
            }
        },
        methods:{
            handleList(val){
                if(val){
                    this.filter.pageNum = 1
                    this.currentPage = 1
                }
                this.loading = true
                getPageList(this.filter).then(res => {
                    this.loading = false
                    this.data = res.intervieweePage.list
                    this.pagination.total = res.intervieweePage.total
                }).catch(err => {
                    this.loading = false
                })
            },
            handleCurrentChange(val){
                this.filter.pageNum = val
                this.handleList()
            },
            handleSizeChange(val){
                this.filter.pageNum = 1
                this.filter.pageSize = val
                this.handleList()
            },
            dateChange(val){
                if(val == null){
                    this.filter.bgTm=''
                    this.filter.endTm=''
                }else {
                    this.filter.bgTm=val[0]
                    this.filter.endTm=val[1]
                }
            },
        },
        mounted() {
            this.filter.pageSize = this.tableOptions.pageList[0]
            this.tableOptions = this.$calcTableHeight(tableOptions,55)
            this.handleList()
        }
    }
</script>

<style scoped>

</style>
