<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>
|