ny
23 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
47
48
49
<script lang="ts" setup>
import { defineAsyncComponent, markRaw, reactive } from 'vue';
 
import { BasicPopup, usePopupInner } from '@jnpf/ui/popup';
 
import { getConfigData } from '#/api/onlineDev/visualDev';
import { importViewsFile } from '#/utils/jnpf';
 
interface State {
  currentView: any;
  title: string;
  config: any;
}
 
defineEmits(['register']);
const [registerPopup, { changeLoading }] = usePopupInner(init);
const state = reactive<State>({
  currentView: null,
  title: '',
  config: {},
});
 
function init(data) {
  changeLoading(true);
  state.title = `预览表单【${data.fullName}】`;
  getConfigData(data.modelId, { type: data.previewType }).then((res) => {
    if (!res.data || !res.data.formData) return changeLoading(false);
    data.formConf = res.data.formData;
    data.formOperates = [];
    state.config = data;
    const formUrl = res.data.urlAddress ? res.data.urlAddress.replaceAll(/\s*/g, '') : `workFlow/workFlowForm/${data.enCode}`;
    state.currentView = markRaw(defineAsyncComponent(() => importViewsFile(formUrl)));
  });
}
function setPageLoad(val: any = false) {
  changeLoading(!!val);
}
function onClose() {
  state.currentView = null;
  return true;
}
</script>
<template>
  <BasicPopup v-bind="$attrs" @register="registerPopup" :title="state.title" class="full-popup" destroy-on-close :close-func="onClose">
    <div class="h-full overflow-y-auto p-[10px]">
      <component :is="state.currentView" :config="state.config" @set-page-load="setPageLoad" />
    </div>
  </BasicPopup>
</template>