<template>
    <div class="app-container">
        <div class="page-container">
            <el-form :model="queryParams" :inline="true" label-width="80px">

                <el-form-item label="动态内容">
                    <el-input placeholder="请输入" v-model="queryParams.content" style="width: 220px;"></el-input>
                </el-form-item>
                <el-form-item label="创建时间">
                    <el-date-picker placeholder="请选择" value-format="YYYY-MM-DD"
                        v-model="queryParams.createTime"></el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="handleQuery">查询</el-button>
                    <el-button @click="handleReset">重置</el-button>
                </el-form-item>
            </el-form>
            <el-row class="mb10">

            </el-row>
            <el-table :data="tableList">
                <el-table-column label="序号" width="55" type="index" align="center"></el-table-column>
                <el-table-column label="动态内容" prop="nikeName" align="center"></el-table-column>
                <el-table-column label="话题" align="center" prop="goodsName"></el-table-column>
                <el-table-column label="帐号" prop="goodsExchangePoints" align="center"></el-table-column>
                <el-table-column label="姓名" prop="createTime" align="center"></el-table-column>
                <el-table-column label="表情数" prop="userGradeName" align="center"></el-table-column>
                <el-table-column label="评论数" prop="userRemainingPoints" align="center"></el-table-column>
                <el-table-column label="创建时间" prop="userRemainingPoints" align="center"></el-table-column>
                <el-table-column label="操作" align="center">
                    <template #default="{ row }">
                        <el-button type="text" @click="handleUpdate(row)">详情</el-button>
                        <el-button type="text" @click="handleDelete(row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @pagination="getList" />
        </div>

    </div>
</template>

<script>
import { listData } from '@/api/moments';

export default {
    name: 'Moments',
    data() {
        return {
            queryParams: {
                pageNum: 1,
                pageSize: 10
            },
            tableList: [],
            total: 0,
            dateRange: [],
            optionList: []
        }
    },

    created() {

    },
    mounted() {
        this.getList()
    },
    methods: {
        // 列表数据
        getList() {
            listData(this.queryParams).then(res => {
                console.log(res)
                this.tableList = res.rows;
                this.total = res.total
            })
        },
        // 兑换商品列表
        getOptions() {
            pointsExchange().then(res => {
                console.log(res)
                this.optionList = res.data
            })
        },
        // 新增
        handleAdd() {
            this.$refs.exchangeDialogRef.openModal()
        },
        // 删除
        handleDelete(row) {
            this.$modal.confirm('确认要删除商品名称为：' + row.name + '的数据吗？').then(function () {
                return delData(row.id);
            }).then(() => {
                this.$modal.msgSuccess("删除成功");
                this.getList()
            })
        },
        // 导出积分明细
        handleExport() {
            this.download('/bbs/points/exchange/export', {
                ...this.queryParams
            }, `积分明细_${new Date().getTime()}.xlsx`)
        },
        // 时间段选择
        dateChange(val) {
            if (val) {
                this.queryParams.startTime = val[0]
                this.queryParams.endTime = val[1]
            }
        },
        // 查询
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList()
        },
        // 重置
        handleReset() {
            this.queryParams = {
                pageNum: 1,
                pageSize: 10
            }
            this.getList()
        }
    }
}
</script>

<style lang="scss" scoped>
.app-container {
    background-color: rgba(241, 242, 247, 1);
    height: calc(100vh - 50px);

    .page-container {
        background-color: white;
        height: 100%;
        border-radius: 6px;
        padding: 20px 30px;
        box-sizing: border-box;
        overflow: auto;
    }
}
</style>