<!-- 编辑弹窗 -->
<template>
    <ele-modal
        :width="700"
        v-model="visible"
        title="限制历史"
        @open="handleOpen"
        :body-style="{ padding: '0' }"
    >
        <common-table
            ref="pageRef"
            :pageConfig="pageConfig"
            :columns="columns"
            :tools="false"
            :immediate="false"
        />
        <template #footer>
            <el-button @click="handleCancel">关闭</el-button>
        </template>
    </ele-modal>
</template>

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

    const pageRef = ref(null);
    /** 弹窗是否打开 */
    const visible = defineModel({ type: Boolean });

    /** 关闭弹窗 */
    const handleCancel = () => {
        visible.value = false;
    };

    /** 弹窗打开事件 */
    const handleOpen = (userId) => {
        if (userId) {
            visible.value = true;
            pageConfig.value.pageUrl = `/user/userRequestLimit/logList/${userId}`;
            pageRef.value?.reload();
        }
    };

    /** 表格列配置 */
    const columns = ref([
        { label: '限制时间', prop: 'createTime', align: 'center', width: 180 },
        { label: '限制类型', prop: 'limitTypeDesc', align: 'center' },
        { label: '操作员', prop: 'createName', align: 'center', width: 120 }
    ]);

    const pageConfig = ref({
        pageUrl: '/user/userRequestLimit/logList',
        fileName: '限制历史',
        cacheKey: 'restrict-history'
    });

    defineExpose({
        handleOpen
    });
</script>
