【功能修复】 修复流程详情页面 请求模型视图接口两次的问题

pull/582/head
jason 2024-11-03 22:06:35 +08:00
parent 13272c2293
commit 65f0b2f8ab
3 changed files with 72 additions and 32 deletions

View File

@ -6,31 +6,28 @@
<script lang="ts" setup> <script lang="ts" setup>
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { MyProcessViewer } from '@/components/bpmnProcessDesigner/package' import { MyProcessViewer } from '@/components/bpmnProcessDesigner/package'
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
defineOptions({ name: 'BpmProcessInstanceBpmnViewer' }) defineOptions({ name: 'BpmProcessInstanceBpmnViewer' })
const props = defineProps({ const props = defineProps({
loading: propTypes.bool.def(false), // loading: propTypes.bool.def(false), //
id: propTypes.string, // bpmnXml: propTypes.string, // BPMN XML
bpmnXml: propTypes.string // BPMN XML modelView: propTypes.object
}) })
const view = ref({ const view = ref({
bpmnXml: '' bpmnXml: ''
}) // BPMN }) // BPMN
/** 只有 loading 完成时,才去加载流程列表 */ /** 只有 loading 完成时,才去加载流程列表 */
watch( watch(
() => props.loading, () => props.modelView,
async (value) => { async (newModelView) => {
//
view.value = {
bpmnXml: ''
}
// //
if (value && props.id) { if (newModelView) {
view.value = await ProcessInstanceApi.getProcessInstanceBpmnModelView(props.id) //@ts-ignore
view.value = newModelView
} }
} }
) )

View File

@ -8,45 +8,71 @@ import { propTypes } from '@/utils/propTypes'
import { TaskStatusEnum } from '@/api/bpm/task' import { TaskStatusEnum } from '@/api/bpm/task'
import { SimpleFlowNode, NodeType } from '@/components/SimpleProcessDesignerV2/src/consts' import { SimpleFlowNode, NodeType } from '@/components/SimpleProcessDesignerV2/src/consts'
import { SimpleProcessViewer } from '@/components/SimpleProcessDesignerV2/src/' import { SimpleProcessViewer } from '@/components/SimpleProcessDesignerV2/src/'
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
defineOptions({ name: 'BpmProcessInstanceSimpleViewer' }) defineOptions({ name: 'BpmProcessInstanceSimpleViewer' })
const props = defineProps({ const props = defineProps({
loading: propTypes.bool.def(false), // loading: propTypes.bool.def(false), //
id: propTypes.string // modelView: propTypes.object
}) })
const simpleModel = ref() const simpleModel = ref()
// //
const tasks = ref([]) const tasks = ref([])
// //
const processInstance = ref() const processInstance = ref()
/** 只有 loading 完成时,才去加载流程列表 */ // /** 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.loading, () => props.modelView,
async (value) => { async (newModelView) => {
if (value && props.id) { if (newModelView) {
const modelView = await ProcessInstanceApi.getProcessInstanceBpmnModelView(props.id) if (newModelView) {
if (modelView) { tasks.value = newModelView.tasks
tasks.value = modelView.tasks processInstance.value = newModelView.processInstance
processInstance.value = modelView.processInstance
// UserTask // UserTask
const rejectedTaskActivityIds: string[] = modelView.rejectedTaskActivityIds const rejectedTaskActivityIds: string[] = newModelView.rejectedTaskActivityIds
// UserTask // UserTask
const unfinishedTaskActivityIds: string[] = modelView.unfinishedTaskActivityIds const unfinishedTaskActivityIds: string[] = newModelView.unfinishedTaskActivityIds
// UserTaskGateway // UserTaskGateway
const finishedActivityIds: string[] = modelView.finishedTaskActivityIds const finishedActivityIds: string[] = newModelView.finishedTaskActivityIds
// 线 SequenceFlow // 线 SequenceFlow
const finishedSequenceFlowActivityIds: string[] = modelView.finishedSequenceFlowActivityIds const finishedSequenceFlowActivityIds: string[] = newModelView.finishedSequenceFlowActivityIds
setSimpleModelNodeTaskStatus( setSimpleModelNodeTaskStatus(
modelView.simpleModel, newModelView.simpleModel,
modelView.processInstance.status, newModelView.processInstance.status,
rejectedTaskActivityIds, rejectedTaskActivityIds,
unfinishedTaskActivityIds, unfinishedTaskActivityIds,
finishedActivityIds, finishedActivityIds,
finishedSequenceFlowActivityIds finishedSequenceFlowActivityIds
) )
simpleModel.value = modelView.simpleModel simpleModel.value = newModelView.simpleModel
} }
} }
} }

View File

@ -79,15 +79,15 @@
v-show=" v-show="
processDefinition.modelType && processDefinition.modelType === BpmModelType.SIMPLE processDefinition.modelType && processDefinition.modelType === BpmModelType.SIMPLE
" "
:id="`${id}`"
:loading="processInstanceLoading" :loading="processInstanceLoading"
:model-view="processModelView"
/> />
<ProcessInstanceBpmnViewer <ProcessInstanceBpmnViewer
v-show=" v-show="
processDefinition.modelType && processDefinition.modelType === BpmModelType.BPMN processDefinition.modelType && processDefinition.modelType === BpmModelType.BPMN
" "
:id="`${id}`"
:loading="processInstanceLoading" :loading="processInstanceLoading"
:model-view="processModelView"
/> />
</div> </div>
</el-tab-pane> </el-tab-pane>
@ -153,7 +153,7 @@ const message = useMessage() // 消息弹窗
const processInstanceLoading = ref(false) // const processInstanceLoading = ref(false) //
const processInstance = ref<any>({}) // const processInstance = ref<any>({}) //
const processDefinition = ref<any>({}) // const processDefinition = ref<any>({}) //
const processModelView = ref<any>({}) //
const operationButtonRef = ref() // ref const operationButtonRef = ref() // ref
const auditIcons = { const auditIcons = {
1: audit1, 1: audit1,
@ -173,6 +173,8 @@ const detailForm = ref({
/** 获得详情 */ /** 获得详情 */
const getDetail = () => { const getDetail = () => {
getApprovalDetail() getApprovalDetail()
getProcessModelView()
} }
/** 加载流程实例 */ /** 加载流程实例 */
@ -238,6 +240,21 @@ const getApprovalDetail = async () => {
} }
} }
/** 获取流程模型视图*/
const getProcessModelView = async () => {
if (BpmModelType.BPMN === processDefinition.value?.modelType) {
// BPMN
processModelView.value = {
bpmnXml: ''
}
}
const data = await ProcessInstanceApi.getProcessInstanceBpmnModelView(props.id)
if (data) {
processModelView.value = data
}
}
// //
const activityNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([]) const activityNodes = ref<ProcessInstanceApi.ApprovalNodeInfo[]>([])
/** /**