<script lang="ts" setup>
|
import { onBeforeUnmount, onMounted } from 'vue';
|
|
import { usePopup } from '@jnpf/ui/popup';
|
|
import { onlineUtils } from '#/utils/jnpf';
|
|
import FlowListPopup from './FlowListPopup.vue';
|
|
defineOptions({ name: 'GlobalFlowListModal' });
|
|
interface OpenFlowListConfig {
|
flow_id?: number | string;
|
flowId?: number | string;
|
menuId?: number | string;
|
params?: Record<string, any>;
|
path?: string;
|
query?: Record<string, any>;
|
routeQuery?: Record<string, any>;
|
title?: string;
|
}
|
|
const [registerFlowListPopup, { openPopup: openFlowListPopup }] = usePopup();
|
const emitter = onlineUtils.getEmitter();
|
|
function handleOpen(config: OpenFlowListConfig) {
|
const flowId = config?.flowId ?? config?.flow_id;
|
if (!flowId && !config?.menuId && !config?.path) {
|
console.error('[onlineUtils.openFlowList] flowId, menuId or path is required');
|
return;
|
}
|
openFlowListPopup(true, config);
|
}
|
|
onMounted(() => {
|
emitter.on('OPEN_FLOW_LIST_MODAL', handleOpen as any);
|
});
|
|
onBeforeUnmount(() => {
|
emitter.off('OPEN_FLOW_LIST_MODAL', handleOpen as any);
|
});
|
</script>
|
|
<template>
|
<FlowListPopup @register="registerFlowListPopup" />
|
</template>
|