import { ref } from 'vue';
import type PageModal from '@/components/components/pageDetails.vue';

function usePageModal() {
    const modalRef = ref<InstanceType<typeof PageModal>>();

    // 新增
    function handleNewDataClick() {
        modalRef.value?.setDialogVisible();
    }
    // 编辑
    function handleEditDataClick() {
        modalRef.value?.setDialogVisible(false);
    }
    // 查询
    function handleCheckDataClick() {
        modalRef.value?.setDialogVisible(false, true);
    }
    // 查询数据
    function handlePageDetail(urlId: number | [] | string) {
        modalRef.value?.onPageDetail(urlId);
    }
    // 复制数据
    function handleCopyDataClick() {
        modalRef.value?.setDialogVisible(false, false, true);
    }

    return {
        modalRef,
        handleNewDataClick,
        handleEditDataClick,
        handleCheckDataClick,
        handlePageDetail,
        handleCopyDataClick,
    };
}

export default usePageModal;
