<template>
    <div>
        <el-dialog title="渠道推广明细" :visible.sync="dialog" center width="1000px" top="50px">
            <div>
                <el-table :data="tableData" v-loading="tableLoading" border fit>
                    <el-table-column prop="date" label="日期"></el-table-column>
                    <el-table-column prop="uvs" label="页面浏览量UV"></el-table-column>
                    <el-table-column prop="pvs" label="页面浏览量PV"></el-table-column>
                    <el-table-column prop="users_counts" label="注册用户"></el-table-column>
                    <el-table-column prop="recharge_counts" label="充值用户数"></el-table-column>
                    <el-table-column prop="recharge_moneys" label="累计充值金额"></el-table-column>
                </el-table>
                <el-pagination
                    class="marginT-20"
                    @current-change="handleCurrentChange"
                    :hide-on-single-page="false"
                    :current-page="pageNo"
                    :page-size="pageSize"
                    background
                    layout="total, prev, pager, next, jumper"
                    :total="totalCount"
                />
            </div>
            <div slot="footer" class="dialog-footer text-center">
                <el-button @click="dialog = false">取 消</el-button>
                <el-button type="primary" @click="handleSubmit">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import page from '@/mixin/page'
export default {
    mixins: [page],
    props: {
        value: {
            type: Boolean,
            default: true,
        },
        exData: {
            type: Object,
            default: {},
        },
    },
    data() {
        return {
            tableData: [],
            searchForm: {
                id: undefined,
            },
            tableUrl: '/listChannelPromoteDetail',
            dialog: !!this.value,
        }
    },
    methods: {
        async handleSubmit() {
            this.$refs.form.validate(async valid => {
                if (valid) {
                    const data = await this.$fetch('/addPromoteType', {...this.form})
                    if (data.code == 200) {
                        this.$message.success('成功')
                        this.dialog = false
                        this.$emit('success')
                    }
                }
            })
        },
    },
    mounted() {
        this.searchForm.id = this.exData.id
        this.init()
    },
    watch: {
        dialog(val) {
            if (!val) this.$emit('input', val)
        },
    },
}
</script>
<style lang="scss">

</style>
