Vue3 重构:流程实例的详情(流程任务列表)

This commit is contained in:
YunaiV 2023-03-28 07:45:18 +08:00
parent 4388d6565a
commit 7587acedb0

View File

@ -97,9 +97,9 @@
</ContentWrap>
</template>
<script setup lang="ts">
import { useUserStore } from '@/store/modules/user'
import { setConfAndFields2 } from '@/utils/formCreate'
import type { ApiAttrs } from '@form-create/element-ui/types/config'
import { useUserStore } from '@/store/modules/user'
import * as DefinitionApi from '@/api/bpm/definition'
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
import * as TaskApi from '@/api/bpm/task'
@ -177,16 +177,19 @@ const handleBack = async (task) => {
console.log(task)
}
// ========== ==========
onMounted(() => {
getDetail()
})
/** 获得详情 */
const getDetail = () => {
// 1.
getProcessInstance()
// 2.
getTaskList()
}
/** 加载流程实例 */
const getProcessInstance = async () => {
try {
processInstanceLoading.value = true
ProcessInstanceApi.getProcessInstanceApi(id)
.then((data) => {
const data = await ProcessInstanceApi.getProcessInstanceApi(id)
if (!data) {
message.error('查询不到流程信息!')
return
@ -210,29 +213,26 @@ const getDetail = () => {
}
//
DefinitionApi.getProcessDefinitionBpmnXML(processDefinition.id).then((data) => {
bpmnXML.value = data
})
})
.finally(() => {
bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(processDefinition.id)
} finally {
processInstanceLoading.value = false
})
}
}
// 2.
/** 加载任务列表 */
const getTaskList = async () => {
try {
//
tasksLoad.value = true
runningTasks.value = []
auditForms.value = []
TaskApi.getTaskListByProcessInstanceId(id)
.then((data) => {
//
const data = await TaskApi.getTaskListByProcessInstanceId(id)
tasks.value = []
//
// 1.1
data.forEach((task) => {
if (task.result !== 4) {
tasks.value.push(task)
}
})
//
// 1.2
tasks.value.sort((a, b) => {
//
if (a.endTime && b.endTime) {
@ -247,25 +247,31 @@ const getDetail = () => {
}
})
//
//
runningTasks.value = []
auditForms.value = []
tasks.value.forEach((task) => {
// 1.1
// 2.1
if (task.result !== 1) {
return
}
// 1.2
// 2.2
if (!task.assigneeUser || task.assigneeUser.id !== userId) {
return
}
// 2.
// 2.3
runningTasks.value.push({ ...task })
auditForms.value.push({
reason: ''
})
})
})
.finally(() => {
} finally {
tasksLoad.value = false
})
}
}
/** 初始化 */
onMounted(() => {
getDetail()
})
</script>