ny
昨天 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<script lang="ts" setup>
import { defineAsyncComponent, markRaw, reactive, ref, toRefs } from 'vue';
 
import { BasicPopup, usePopupInner } from '@jnpf/ui/popup';
 
import { getFlowTaskInfo } from '#/api/workFlow/task';
import { importViewsFile } from '#/utils/jnpf';
 
interface State {
  config: any;
  properties: any;
  taskInfo: any;
  formInfo: any;
  flowInfo: any;
  formData: any;
  currentView: any;
}
 
defineEmits(['register']);
const [registerPopup, { changeLoading }] = usePopupInner(init);
const formRef = ref<any>(null);
const state = reactive<State>({
  config: {},
  properties: {},
  taskInfo: {},
  formInfo: {},
  flowInfo: {},
  formData: {},
  currentView: null,
});
const { config } = toRefs(state);
 
function init(data) {
  changeLoading(true);
  state.config = data;
  getBeforeInfo(state.config);
}
function getBeforeInfo(config) {
  const query = { taskNodeId: config.taskNodeId, operatorId: config.taskId, flowId: config.flowId, opType: config.opType };
  getFlowTaskInfo(config.id || '0', query)
    .then((res) => {
      state.formInfo = res.data.formInfo;
      state.taskInfo = res.data.taskInfo || {};
      state.flowInfo = res.data.flowInfo;
      const fullName = state.taskInfo.fullName;
      config.fullName = fullName;
      config.type = state.flowInfo.type;
      config.draftData = res.data.draftData || null;
      config.formData = res.data.formData || {};
      config.formEnCode = state.formInfo.enCode;
      state.properties = res.data.nodeProperties || {};
      config.formConf = state.formInfo.formData;
      config.formOperates = res.data.formOperates || [];
      if (config.opType == 0) {
        for (let i = 0; i < config.formOperates.length; i++) {
          config.formOperates[i].write = false;
        }
      }
      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)));
    })
    .catch(() => {
      changeLoading(false);
    });
}
function setPageLoad(val: any = false) {
  changeLoading(!!val);
}
function onClose() {
  state.currentView = null;
  return true;
}
</script>
<template>
  <BasicPopup v-bind="$attrs" @register="registerPopup" destroy-on-close :close-func="onClose" class="full-popup basic-flow-parser">
    <template #title>
      <div class="header-title">{{ config.title }}</div>
    </template>
    <div class="h-full overflow-auto p-[10px]">
      <component :is="state.currentView" ref="formRef" :config="config" @set-page-load="setPageLoad" />
    </div>
  </BasicPopup>
</template>
<style lang="scss">
@use './style/index.scss' as *;
</style>