【功能修改】发起流程时,如果是 Simple 模型展示 Simple 流程图

pull/582/head
jason 2024-11-03 23:12:13 +08:00
parent 65f0b2f8ab
commit 55da358336
2 changed files with 52 additions and 56 deletions

View File

@ -71,8 +71,17 @@
<!-- 流程图 -->
<el-tab-pane label="流程图" name="diagram">
<div class="form-scroll-area">
<!-- 流程图预览 -->
<ProcessInstanceBpmnViewer :bpmn-xml="bpmnXML" />
<!-- BPMN 流程图预览 -->
<ProcessInstanceBpmnViewer
:bpmn-xml="bpmnXML"
v-if="BpmModelType.BPMN === selectProcessDefinition.modelType"
/>
<!-- Simple 流程图预览 -->
<ProcessInstanceSimpleViewer
:simple-json="simpleJson"
v-if="BpmModelType.SIMPLE === selectProcessDefinition.modelType"
/>
</div>
</el-tab-pane>
</el-tabs>
@ -98,7 +107,9 @@
</template>
<script lang="ts" setup>
import { decodeFields, setConfAndFields2 } from '@/utils/formCreate'
import { BpmModelType } from '@/utils/constants'
import ProcessInstanceBpmnViewer from '../detail/ProcessInstanceBpmnViewer.vue'
import ProcessInstanceSimpleViewer from '../detail/ProcessInstanceSimpleViewer.vue'
import ProcessInstanceTimeline from '../detail/ProcessInstanceTimeline.vue'
import type { ApiAttrs } from '@form-create/element-ui/types/config'
import { useTagsViewStore } from '@/store/modules/tagsView'
@ -127,6 +138,7 @@ const startUserSelectAssignees = ref({}) // 发起人选择审批人的数据
const startUserSelectAssigneesFormRules = ref({}) // Rules
const userList = ref<any[]>([]) //
const bpmnXML: any = ref(null) // BPMN
const simpleJson = ref<string|undefined>() // Simple json
/** 当前的Tab */
const activeTab = ref('form')
const emit = defineEmits(['cancel'])
@ -162,6 +174,7 @@ const initProcessInfo = async (row: any, formVariables?: any) => {
const processDefinitionDetail = await DefinitionApi.getProcessDefinition(row.id)
if (processDefinitionDetail) {
bpmnXML.value = processDefinitionDetail.bpmnXml
simpleJson.value = processDefinitionDetail.simpleModel
startUserSelectTasks.value = processDefinitionDetail.startUserSelectTasks
//

View File

@ -1,6 +1,10 @@
<template>
<div v-loading="loading" class="mb-20px">
<SimpleProcessViewer :flow-node="simpleModel" :tasks="tasks" :process-instance="processInstance"/>
<SimpleProcessViewer
:flow-node="simpleModel"
:tasks="tasks"
:process-instance="processInstance"
/>
</div>
</template>
<script lang="ts" setup>
@ -12,72 +16,51 @@ defineOptions({ name: 'BpmProcessInstanceSimpleViewer' })
const props = defineProps({
loading: propTypes.bool.def(false), //
modelView: propTypes.object
modelView: propTypes.object,
simpleJson: propTypes.string // Simple (json )
})
const simpleModel = ref()
//
const tasks = ref([])
//
const processInstance = ref()
// /** loading */
// watch(
// () => props.loading,
// async (value) => {
// if (value && props.id) {
// const modelView = await ProcessInstanceApi.getProcessInstanceBpmnModelView(props.id)
// if (modelView) {
// tasks.value = modelView.tasks
// processInstance.value = modelView.processInstance
// // UserTask
// const rejectedTaskActivityIds: string[] = modelView.rejectedTaskActivityIds
// // UserTask
// const unfinishedTaskActivityIds: string[] = modelView.unfinishedTaskActivityIds
// // UserTaskGateway
// const finishedActivityIds: string[] = modelView.finishedTaskActivityIds
// // 线 SequenceFlow
// const finishedSequenceFlowActivityIds: string[] = modelView.finishedSequenceFlowActivityIds
// setSimpleModelNodeTaskStatus(
// modelView.simpleModel,
// modelView.processInstance.status,
// rejectedTaskActivityIds,
// unfinishedTaskActivityIds,
// finishedActivityIds,
// finishedSequenceFlowActivityIds
// )
// simpleModel.value = modelView.simpleModel
// }
// }
// }
// )
/** 监控模型视图 包括任务列表、进行中的活动节点编号等 */
watch(
() => props.modelView,
async (newModelView) => {
if (newModelView) {
if (newModelView) {
tasks.value = newModelView.tasks
processInstance.value = newModelView.processInstance
// UserTask
const rejectedTaskActivityIds: string[] = newModelView.rejectedTaskActivityIds
// UserTask
const unfinishedTaskActivityIds: string[] = newModelView.unfinishedTaskActivityIds
// UserTaskGateway
const finishedActivityIds: string[] = newModelView.finishedTaskActivityIds
// 线 SequenceFlow
const finishedSequenceFlowActivityIds: string[] = newModelView.finishedSequenceFlowActivityIds
setSimpleModelNodeTaskStatus(
newModelView.simpleModel,
newModelView.processInstance.status,
rejectedTaskActivityIds,
unfinishedTaskActivityIds,
finishedActivityIds,
finishedSequenceFlowActivityIds
)
simpleModel.value = newModelView.simpleModel
}
tasks.value = newModelView.tasks
processInstance.value = newModelView.processInstance
// UserTask
const rejectedTaskActivityIds: string[] = newModelView.rejectedTaskActivityIds
// UserTask
const unfinishedTaskActivityIds: string[] = newModelView.unfinishedTaskActivityIds
// UserTaskGateway
const finishedActivityIds: string[] = newModelView.finishedTaskActivityIds
// 线 SequenceFlow
const finishedSequenceFlowActivityIds: string[] = newModelView.finishedSequenceFlowActivityIds
setSimpleModelNodeTaskStatus(
newModelView.simpleModel,
newModelView.processInstance.status,
rejectedTaskActivityIds,
unfinishedTaskActivityIds,
finishedActivityIds,
finishedSequenceFlowActivityIds
)
simpleModel.value = newModelView.simpleModel
}
}
)
/** 监控模型结构数据 */
watch(
() => props.simpleJson,
async (value) => {
if (value) {
simpleModel.value = JSON.parse(value)
}
}
)
const setSimpleModelNodeTaskStatus = (
simpleModel: SimpleFlowNode | undefined,
processStatus: number,