<template>
    <div class="app-container calendar-list-container">

        <!-- 查询和其他操作 -->
        <div class="filter-container">
            <el-input clearable class="filter-item" style="width: 200px;" placeholder="员工"
                v-model="listQuery.userName"></el-input>
            <el-input clearable class="filter-item" style="width: 200px;" placeholder="活动名称"
                v-model="listQuery.actTitle"></el-input>
            <el-date-picker
            class="filter-item"
            value-format="yyyy-MM-dd"
            v-model="listQuery.createTime"
            type="date"
            placeholder="日期">
            </el-date-picker>
            <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilter">查找</el-button>
            <el-button class="filter-item" type="primary"  :loading="downloadLoading" v-waves icon="el-icon-download" @click="handleDownload">导出</el-button>
        </div>

        <!-- 查询结果 -->
        <el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit
            highlight-current-row>
            <el-table-column type="index" label="序号" header-align="center" align="center">
            </el-table-column>
            <el-table-column align="center" min-width="180px" label="部门" prop="deptName">
            </el-table-column>
            <el-table-column align="center" min-width="80px" label="员工" prop="userName">
            </el-table-column>
            <el-table-column align="center" min-width="80px" label="活动名称" prop="actTitle">
            </el-table-column>
            <el-table-column align="center" min-width="80px" label="消耗积分" prop="expenseIntegral">
            </el-table-column>
            <el-table-column align="center" min-width="80px" label="奖号" prop="couponNumber">
            </el-table-column>
            <el-table-column align="center" min-width="150px" label="日期" prop="createTime">
            </el-table-column>
           
        </el-table>

        <!-- 分页 -->
        <div class="pagination-container">
            <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50]" :page-size="listQuery.limit"
                layout="total, sizes, prev, pager, next, jumper" :total="total">
            </el-pagination>
        </div>
    </div>
</template>
  
<style>
.demo-table-expand {
    font-size: 0;
}

.demo-table-expand label {
    width: 200px;
    color: #99a9bf;
}

.demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
}
</style>
  
<script>
import { logsList } from "@/api/lotteryManage";
import waves from "@/directive/waves"; // 水波纹指令

export default {
    directives: { waves },
    data() {
        return {
            list: [],
            total: 0,
            listLoading: false,
            downloadLoading: false,
            listQuery: {
                page: 1,
                limit: 10,
                userName: '',
                actTitle:'',
                createTime: '',
            },
        }
    },
    created() {
        this.getList();
    },
    methods: {
        handleDownload() {
            window.location.href = process.env.BASE_API + '/mall-prize/export/log?userName=' + this.listQuery.userName + '&actTitle=' + this.listQuery.actTitle + '&createTime=' + this.listQuery.createTime;
        },
        getList() {
            this.listLoading = true
            logsList(this.listQuery).then(response => {
                this.list = response.data.data.items
                this.total = response.data.data.total
                this.listLoading = false
            }).catch(() => {})
        },
       

        handleFilter() {
            this.listQuery.page = 1
            this.getList()
        },
        handleSizeChange(val) {
            this.listQuery.limit = val
            this.getList()
        },
        handleCurrentChange(val) {
            this.listQuery.page = val
            this.getList()
        },

        
    }
}
</script>
<style>
.ad-avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.ad-avatar-uploader .el-upload:hover {
    border-color: #409EFF;
}

.ad-avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
}

.ad-avatar {
    display: block;
}
</style>
  