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

View File

@ -1,6 +1,10 @@
<template> <template>
<div v-loading="loading" class="mb-20px"> <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> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -12,72 +16,51 @@ defineOptions({ name: 'BpmProcessInstanceSimpleViewer' })
const props = defineProps({ const props = defineProps({
loading: propTypes.bool.def(false), // loading: propTypes.bool.def(false), //
modelView: propTypes.object modelView: propTypes.object,
simpleJson: propTypes.string // Simple (json )
}) })
const simpleModel = ref() const simpleModel = ref()
// //
const tasks = ref([]) const tasks = ref([])
// //
const processInstance = 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( watch(
() => props.modelView, () => props.modelView,
async (newModelView) => { async (newModelView) => {
if (newModelView) { if (newModelView) {
if (newModelView) { tasks.value = newModelView.tasks
tasks.value = newModelView.tasks processInstance.value = newModelView.processInstance
processInstance.value = newModelView.processInstance // UserTask
// UserTask const rejectedTaskActivityIds: string[] = newModelView.rejectedTaskActivityIds
const rejectedTaskActivityIds: string[] = newModelView.rejectedTaskActivityIds // UserTask
// UserTask const unfinishedTaskActivityIds: string[] = newModelView.unfinishedTaskActivityIds
const unfinishedTaskActivityIds: string[] = newModelView.unfinishedTaskActivityIds // UserTaskGateway
// UserTaskGateway const finishedActivityIds: string[] = newModelView.finishedTaskActivityIds
const finishedActivityIds: string[] = newModelView.finishedTaskActivityIds // 线 SequenceFlow
// 线 SequenceFlow const finishedSequenceFlowActivityIds: string[] = newModelView.finishedSequenceFlowActivityIds
const finishedSequenceFlowActivityIds: string[] = newModelView.finishedSequenceFlowActivityIds setSimpleModelNodeTaskStatus(
setSimpleModelNodeTaskStatus( newModelView.simpleModel,
newModelView.simpleModel, newModelView.processInstance.status,
newModelView.processInstance.status, rejectedTaskActivityIds,
rejectedTaskActivityIds, unfinishedTaskActivityIds,
unfinishedTaskActivityIds, finishedActivityIds,
finishedActivityIds, finishedSequenceFlowActivityIds
finishedSequenceFlowActivityIds )
) simpleModel.value = newModelView.simpleModel
simpleModel.value = newModelView.simpleModel }
} }
)
/** 监控模型结构数据 */
watch(
() => props.simpleJson,
async (value) => {
if (value) {
simpleModel.value = JSON.parse(value)
} }
} }
) )
const setSimpleModelNodeTaskStatus = ( const setSimpleModelNodeTaskStatus = (
simpleModel: SimpleFlowNode | undefined, simpleModel: SimpleFlowNode | undefined,
processStatus: number, processStatus: number,