<template>
    <div class="app-container">
        <el-table v-loading="loading" fit highlight-current-row border stripe :data="typeList">
            <el-table-column label="标题" align="center" prop="title" />
            <el-table-column label="充值金额（元）" align="center" prop="rechargeAmount" />
            <el-table-column label="赠送金额（元）" align="center" prop="giveAmount" />
            <el-table-column label="赠送积分" align="center" prop="givePointAmount" />
        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
</template>

<script>
import { listType, getType, delType, addType, updateType, updateTypeStatus } from '@/api/recharge/type'

export default {
    name: 'Type',
    dicts: ['sys_normal_disable'],
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 充值规则管理表格数据
            typeList: [],
            // 弹出层标题
            title: '',
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                title: null
            },
            // 表单参数
            form: {
                status: '0'
            },
            // 表单校验
            rules: {}
        }
    },
    created() {
        this.getList()
    },
    methods: {
        /** 查询充值规则管理列表 */
        getList() {
            this.loading = true
            listType(this.queryParams).then((response) => {
                this.typeList = response.rows
                this.total = response.total
                this.loading = false
            })
        },
        // 取消按钮
        cancel() {
            this.open = false
            this.reset()
        },
        // 表单重置
        reset() {
            this.form = {
                id: null,
                title: null,
                rechargeAmount: null,
                giveAmount: null,
                givePointAmount: null,
                expireMonth: null,
                status: '0',
                delFlag: null,
                createById: null,
                createBy: null,
                createTime: null,
                updateById: null,
                updateBy: null,
                updateTime: null,
                remark: null
            }
            this.resetForm('form')
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1
            this.getList()
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.resetForm('queryForm')
            this.handleQuery()
        }
    }
}
</script>
