刘光辉
9 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<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>