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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<script lang="ts" setup>
import { defineAsyncComponent, markRaw, reactive, toRefs } from 'vue';
 
import { BasicPopup, usePopupInner } from '@jnpf/ui/popup';
 
import { getStartFormInfo } from '#/api/workFlow/task';
import { importViewsFile } from '#/utils/jnpf';
 
interface State {
  config: any;
  loading: boolean;
  currentView: any;
  formData: any;
  formInfo: any;
  title: string;
}
 
defineEmits(['register']);
const [registerPopup] = usePopupInner(init);
 
const state = reactive<State>({
  config: {},
  loading: false,
  currentView: null,
  formData: {},
  formInfo: {},
  title: '',
});
const { config, loading, currentView, title } = toRefs(state);
 
function init(data) {
  state.title = data.title;
  state.currentView = null;
  state.loading = true;
  state.config = data;
  getBeforeInfo(state.config);
}
function getBeforeInfo(config) {
  getStartFormInfo(config.taskId)
    .then((res) => {
      state.formInfo = res.data.formInfo;
      config.formData = res.data.formData || {};
      config.formConf = state.formInfo.formData;
      config.disabled = true;
      const formUrl =
        state.formInfo.type == 1
          ? 'workFlow/workFlowForm/dynamicForm'
          : state.formInfo.urlAddress
            ? state.formInfo.urlAddress.replaceAll(/\s*/g, '')
            : `workFlow/workFlowForm/${state.formInfo.enCode}`;
      state.currentView = markRaw(defineAsyncComponent(() => importViewsFile(formUrl)));
      state.loading = false;
    })
    .catch(() => {
      state.loading = false;
    });
}
</script>
<template>
  <BasicPopup v-bind="$attrs" @register="registerPopup" :title="title" :show-cancel-btn="false" destroy-on-close class="full-popup basic-flow-parser">
    <div class="jnpf-common-form-wrapper" v-loading="loading">
      <div class="jnpf-common-form-wrapper__main p-[10px]">
        <component :is="currentView" :config="config" />
      </div>
    </div>
  </BasicPopup>
</template>