<template>
    <common-table
        ref="pageRef"
        :pageConfig="pageConfig"
        :columns="columns"
        :tools="false"
        :bodyStyle="{ padding: 0 }"
    />
</template>

<script setup>
    import { ref, reactive } from 'vue';
    import CommonTable from '@/components/CommonPage/CommonTable.vue';

    defineOptions({ name: 'RecommendInfo' });

    const props = defineProps({
        row: {
            type: Object,
            default() {
                return {};
            }
        }
    });
    /** 页面组件实例 */
    const pageRef = ref(null);

    const pageConfig = reactive({
        pageUrl: '/user/userInviteLog/myInviteLog',
        fileName: '推荐信息',
        cacheKey: 'recommendInfo'
    });

    watch(
        () => props.row,
        (row) => {
            if (!row || (row && !row.id)) return;
            pageConfig.pageUrl = `/user/userInviteLog/myInviteLog`;
            pageConfig.params = { inviteUserId: row.id };
            pageRef.value?.reload();
        },
        {
            immediate: true,
            deep: true
        }
    );

    /** 表格列配置 */
    const columns = ref([
        { label: 'UID', prop: 'beInviteUserId', align: 'center' },
        { label: '昵称', prop: 'nickName', align: 'center' },
        { label: '手机号', prop: 'mobile', align: 'center' },
        {
            label: '邀请时间',
            prop: 'createTime',
            align: 'center',
            minWidth: 120
        }
    ]);

    //刷新表格
    function reload(where) {
        pageRef.value?.reload(where);
    }
</script>
