2024-10-04 16:16:33 +08:00
|
|
|
|
<!-- 审批详情的右侧:审批流 -->
|
2024-09-02 11:34:03 +08:00
|
|
|
|
<template>
|
|
|
|
|
<el-timeline class="pt-20px">
|
2024-10-04 16:16:33 +08:00
|
|
|
|
<!-- 遍历每个审批节点 -->
|
2024-10-01 23:35:11 +08:00
|
|
|
|
<el-timeline-item
|
2024-10-26 22:55:28 +08:00
|
|
|
|
v-for="(activity, index) in activityNodes"
|
2024-10-01 23:35:11 +08:00
|
|
|
|
:key="index"
|
|
|
|
|
size="large"
|
|
|
|
|
:icon="getApprovalNodeIcon(activity.status, activity.nodeType)"
|
|
|
|
|
:color="getApprovalNodeColor(activity.status)"
|
|
|
|
|
>
|
2024-10-22 16:23:35 +08:00
|
|
|
|
<template #dot>
|
|
|
|
|
<div
|
|
|
|
|
class="position-absolute left--10px top--6px rounded-full border border-solid border-#dedede w-30px h-30px flex justify-center items-center bg-#3f73f7 p-5px"
|
|
|
|
|
>
|
|
|
|
|
<img class="w-full h-full" :src="getApprovalNodeImg(activity.nodeType)" alt="" />
|
|
|
|
|
<div
|
2024-10-29 16:32:08 +08:00
|
|
|
|
v-if="showStatusIcon"
|
2024-10-22 16:23:35 +08:00
|
|
|
|
class="position-absolute top-17px left-17px bg-#fff rounded-full flex items-center p-2px"
|
|
|
|
|
>
|
|
|
|
|
<el-icon :size="12" :color="getApprovalNodeColor(activity.status)">
|
|
|
|
|
<component :is="getApprovalNodeIcon(activity.status, activity.nodeType)" />
|
|
|
|
|
</el-icon>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2024-09-02 11:34:03 +08:00
|
|
|
|
<div class="flex flex-col items-start">
|
2024-10-22 16:23:35 +08:00
|
|
|
|
<!-- 第一行:节点名称、时间 -->
|
|
|
|
|
<div class="flex w-full">
|
|
|
|
|
<div class="font-bold"> {{ activity.name }}</div>
|
|
|
|
|
<!-- 信息:时间 -->
|
|
|
|
|
<div
|
|
|
|
|
v-if="activity.status !== TaskStatusEnum.NOT_START"
|
|
|
|
|
class="text-#a5a5a5 text-13px mt-1 ml-auto"
|
|
|
|
|
>
|
|
|
|
|
{{ getApprovalNodeTime(activity) }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-10-19 19:01:38 +08:00
|
|
|
|
<div class="flex items-center flex-wrap mt-1">
|
2024-10-04 16:16:33 +08:00
|
|
|
|
<!-- 情况一:遍历每个审批节点下的【进行中】task 任务 -->
|
2024-10-01 23:35:11 +08:00
|
|
|
|
<div v-for="(task, idx) in activity.tasks" :key="idx" class="flex items-center">
|
2024-10-23 10:58:43 +08:00
|
|
|
|
<div class="flex flex-col pr-2 gap2">
|
|
|
|
|
<div
|
|
|
|
|
class="position-relative flex flex-wrap gap2"
|
|
|
|
|
v-if="task.assigneeUser || task.ownerUser"
|
|
|
|
|
>
|
|
|
|
|
<!-- 信息:头像昵称 -->
|
2024-10-04 16:16:33 +08:00
|
|
|
|
<div
|
2024-10-23 10:58:43 +08:00
|
|
|
|
class="bg-gray-100 h-35px rounded-3xl flex items-center p-8px gap-2 dark:color-gray-600 position-relative"
|
2024-10-01 23:35:11 +08:00
|
|
|
|
>
|
2024-10-23 10:58:43 +08:00
|
|
|
|
<template v-if="task.assigneeUser?.avatar || task.assigneeUser?.nickname">
|
|
|
|
|
<el-avatar
|
|
|
|
|
:size="28"
|
|
|
|
|
v-if="task.assigneeUser?.avatar"
|
|
|
|
|
:src="task.assigneeUser?.avatar"
|
|
|
|
|
/>
|
|
|
|
|
<el-avatar :size="28" v-else>
|
|
|
|
|
{{ task.assigneeUser?.nickname.substring(0, 1) }}
|
|
|
|
|
</el-avatar>
|
|
|
|
|
{{ task.assigneeUser?.nickname }}
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else-if="task.ownerUser?.avatar || task.ownerUser?.nickname">
|
|
|
|
|
<el-avatar
|
|
|
|
|
:size="28"
|
|
|
|
|
v-if="task.ownerUser?.avatar"
|
|
|
|
|
:src="task.ownerUser?.avatar"
|
|
|
|
|
/>
|
|
|
|
|
<el-avatar :size="28" v-else>
|
|
|
|
|
{{ task.ownerUser?.nickname.substring(0, 1) }}
|
|
|
|
|
</el-avatar>
|
|
|
|
|
{{ task.ownerUser?.nickname }}
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 信息:任务 ICON -->
|
|
|
|
|
<div
|
|
|
|
|
v-if="onlyStatusIconShow.includes(task.status)"
|
|
|
|
|
class="position-absolute top-22px left-26px bg-#fff rounded-full flex items-center p-2px"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
:size="12"
|
|
|
|
|
:icon="statusIconMap2[task.status]?.icon"
|
|
|
|
|
:color="statusIconMap2[task.status]?.color"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-10-04 16:16:33 +08:00
|
|
|
|
</div>
|
2024-10-01 23:35:11 +08:00
|
|
|
|
</div>
|
2024-10-23 10:58:43 +08:00
|
|
|
|
<div
|
2024-10-26 22:55:28 +08:00
|
|
|
|
v-if="
|
|
|
|
|
task.reason &&
|
|
|
|
|
[NodeType.USER_TASK_NODE, NodeType.END_EVENT_NODE].includes(activity.nodeType)
|
|
|
|
|
"
|
2024-10-23 10:58:43 +08:00
|
|
|
|
class="text-#a5a5a5 text-13px mt-1 w-full bg-#f8f8fa p2 rounded-md"
|
|
|
|
|
>
|
|
|
|
|
审批意见:{{ task.reason }}
|
|
|
|
|
</div>
|
2024-10-01 23:35:11 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-10-31 22:47:10 +08:00
|
|
|
|
<!-- 情况二:遍历每个审批节点下的【候选的】task 任务。例如说,1)依次审批,2)未来的审批任务等 -->
|
|
|
|
|
<div
|
|
|
|
|
v-for="(user, idx1) in activity.candidateUsers"
|
|
|
|
|
:key="idx1"
|
|
|
|
|
class="bg-gray-100 h-35px rounded-3xl flex items-center p-8px gap-2 dark:color-gray-600 position-relative"
|
|
|
|
|
>
|
|
|
|
|
<el-avatar :size="28" v-if="user.avatar" :src="user.avatar" />
|
|
|
|
|
<el-avatar :size="28" v-else>
|
|
|
|
|
{{ user.nickname.substring(0, 1) }}
|
|
|
|
|
</el-avatar>
|
|
|
|
|
{{ user.nickname }}
|
|
|
|
|
|
|
|
|
|
<!-- 信息:任务 ICON -->
|
|
|
|
|
<div
|
|
|
|
|
class="position-absolute top-22px left-26px bg-#fff rounded-full flex items-center p-2px"
|
|
|
|
|
>
|
|
|
|
|
<Icon
|
|
|
|
|
:size="12"
|
|
|
|
|
:icon="statusIconMap2['-1']?.icon"
|
|
|
|
|
:color="statusIconMap2['-1']?.color"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-10-01 23:35:11 +08:00
|
|
|
|
</div>
|
2024-09-02 11:34:03 +08:00
|
|
|
|
</div>
|
|
|
|
|
</el-timeline-item>
|
|
|
|
|
</el-timeline>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { formatDate } from '@/utils/formatTime'
|
2024-10-01 23:35:11 +08:00
|
|
|
|
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
|
|
|
|
|
import { TaskStatusEnum } from '@/api/bpm/task'
|
|
|
|
|
import { NodeType } from '@/components/SimpleProcessDesignerV2/src/consts'
|
|
|
|
|
import { Check, Close, Loading, Clock, Minus, Delete } from '@element-plus/icons-vue'
|
2024-10-22 16:23:35 +08:00
|
|
|
|
import starterSvg from '@/assets/svgs/bpm/starter.svg'
|
|
|
|
|
import auditorSvg from '@/assets/svgs/bpm/auditor.svg'
|
|
|
|
|
import copySvg from '@/assets/svgs/bpm/copy.svg'
|
|
|
|
|
import conditionSvg from '@/assets/svgs/bpm/condition.svg'
|
|
|
|
|
import parallelSvg from '@/assets/svgs/bpm/parallel.svg'
|
2024-10-26 21:30:59 +08:00
|
|
|
|
import endSvg from '@/assets/svgs/bpm/end.svg'
|
2024-10-29 16:32:08 +08:00
|
|
|
|
import finishSvg from '@/assets/svgs/bpm/finish.svg'
|
2024-10-22 16:23:35 +08:00
|
|
|
|
|
2024-09-02 11:34:03 +08:00
|
|
|
|
defineOptions({ name: 'BpmProcessInstanceTimeline' })
|
2024-10-23 10:58:43 +08:00
|
|
|
|
defineProps<{
|
2024-10-26 22:55:28 +08:00
|
|
|
|
activityNodes: ProcessInstanceApi.ApprovalNodeInfo[] // 审批节点信息
|
2024-10-23 10:58:43 +08:00
|
|
|
|
}>()
|
2024-10-29 16:32:08 +08:00
|
|
|
|
withDefaults(
|
|
|
|
|
defineProps<{
|
|
|
|
|
approveNodes: ProcessInstanceApi.ApprovalNodeInfo[] // 审批节点信息
|
|
|
|
|
showStatusIcon?: boolean // 是否显示头像右下角状态图标
|
|
|
|
|
}>(),
|
|
|
|
|
{
|
|
|
|
|
showStatusIcon: true // 默认值为 true
|
|
|
|
|
}
|
|
|
|
|
)
|
2024-09-02 11:34:03 +08:00
|
|
|
|
|
2024-10-01 23:35:11 +08:00
|
|
|
|
// 审批节点
|
|
|
|
|
const statusIconMap2 = {
|
|
|
|
|
// 未开始
|
2024-10-22 16:23:35 +08:00
|
|
|
|
'-1': { color: '#909398', icon: 'ep-clock' },
|
2024-10-01 23:35:11 +08:00
|
|
|
|
// 待审批
|
|
|
|
|
'0': { color: '#e5e7ec', icon: 'ep:loading' },
|
2024-09-02 11:34:03 +08:00
|
|
|
|
// 审批中
|
2024-10-04 16:16:33 +08:00
|
|
|
|
'1': { color: '#448ef7', icon: 'ep:loading' },
|
2024-09-02 11:34:03 +08:00
|
|
|
|
// 审批通过
|
2024-10-01 23:35:11 +08:00
|
|
|
|
'2': { color: '#00b32a', icon: 'ep:circle-check-filled' },
|
2024-09-02 11:34:03 +08:00
|
|
|
|
// 审批不通过
|
2024-10-01 23:35:11 +08:00
|
|
|
|
'3': { color: '#f46b6c', icon: 'fa-solid:times-circle' },
|
|
|
|
|
// 取消
|
|
|
|
|
'4': { color: '#cccccc', icon: 'ep:delete-filled' },
|
2024-10-19 19:01:38 +08:00
|
|
|
|
// 退回
|
2024-10-01 23:35:11 +08:00
|
|
|
|
'5': { color: '#f46b6c', icon: 'ep:remove-filled' },
|
|
|
|
|
// 委派中
|
|
|
|
|
'6': { color: '#448ef7', icon: 'ep:loading' },
|
|
|
|
|
// 审批通过中
|
2024-10-04 16:16:33 +08:00
|
|
|
|
'7': { color: '#00b32a', icon: 'ep:circle-check-filled' }
|
2024-10-01 23:35:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const statusIconMap = {
|
|
|
|
|
// 审批未开始
|
2024-10-22 16:23:35 +08:00
|
|
|
|
'-1': { color: '#909398', icon: Clock },
|
2024-10-01 23:35:11 +08:00
|
|
|
|
'0': { color: '#e5e7ec', icon: Clock },
|
|
|
|
|
// 审批中
|
|
|
|
|
'1': { color: '#448ef7', icon: Loading },
|
|
|
|
|
// 审批通过
|
|
|
|
|
'2': { color: '#00b32a', icon: Check },
|
|
|
|
|
// 审批不通过
|
|
|
|
|
'3': { color: '#f46b6c', icon: Close },
|
|
|
|
|
// 已取消
|
|
|
|
|
'4': { color: '#cccccc', icon: Delete },
|
2024-10-19 19:01:38 +08:00
|
|
|
|
// 退回
|
2024-10-04 16:16:33 +08:00
|
|
|
|
'5': { color: '#f46b6c', icon: Minus },
|
2024-10-01 23:35:11 +08:00
|
|
|
|
// 委派中
|
|
|
|
|
'6': { color: '#448ef7', icon: Loading },
|
|
|
|
|
// 审批通过中
|
2024-10-04 16:16:33 +08:00
|
|
|
|
'7': { color: '#00b32a', icon: Check }
|
2024-10-01 23:35:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-22 16:23:35 +08:00
|
|
|
|
const nodeTypeSvgMap = {
|
2024-10-29 16:32:08 +08:00
|
|
|
|
// 结束节点
|
|
|
|
|
[NodeType.END_EVENT_NODE]: { color: '#ffffff', svg: finishSvg },
|
2024-10-22 16:23:35 +08:00
|
|
|
|
// 发起人节点
|
2024-10-23 10:58:43 +08:00
|
|
|
|
[NodeType.START_USER_NODE]: { color: '#ffffff', svg: starterSvg },
|
2024-10-22 16:23:35 +08:00
|
|
|
|
// 审批人节点
|
2024-10-23 10:58:43 +08:00
|
|
|
|
[NodeType.USER_TASK_NODE]: { color: '#ff943e', svg: auditorSvg },
|
2024-10-22 16:23:35 +08:00
|
|
|
|
// 抄送人节点
|
2024-10-23 10:58:43 +08:00
|
|
|
|
[NodeType.COPY_TASK_NODE]: { color: '#3296fb', svg: copySvg },
|
2024-10-22 16:23:35 +08:00
|
|
|
|
// 条件分支节点
|
2024-10-23 10:58:43 +08:00
|
|
|
|
[NodeType.CONDITION_NODE]: { color: '#14bb83', svg: conditionSvg },
|
2024-10-22 16:23:35 +08:00
|
|
|
|
// 并行分支节点
|
2024-10-26 21:30:59 +08:00
|
|
|
|
[NodeType.PARALLEL_BRANCH_NODE]: { color: '#14bb83', svg: parallelSvg },
|
|
|
|
|
// 结束节点
|
|
|
|
|
[NodeType.END_EVENT_NODE]: { color: '#ffffff', svg: endSvg }
|
2024-10-22 16:23:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-23 10:58:43 +08:00
|
|
|
|
// 只有只有状态是 -1、0、1 才展示头像右小角状态小icon
|
|
|
|
|
const onlyStatusIconShow = [-1, 0, 1]
|
|
|
|
|
|
|
|
|
|
// timeline时间线上icon图标
|
2024-10-22 16:23:35 +08:00
|
|
|
|
const getApprovalNodeImg = (nodeType: NodeType) => {
|
|
|
|
|
return nodeTypeSvgMap[nodeType]?.svg
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-04 16:16:33 +08:00
|
|
|
|
const getApprovalNodeIcon = (taskStatus: number, nodeType: NodeType) => {
|
|
|
|
|
if (taskStatus == TaskStatusEnum.NOT_START) {
|
2024-10-01 23:35:11 +08:00
|
|
|
|
return statusIconMap[taskStatus]?.icon
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-26 21:30:59 +08:00
|
|
|
|
if (
|
|
|
|
|
nodeType === NodeType.START_USER_NODE ||
|
|
|
|
|
nodeType === NodeType.USER_TASK_NODE ||
|
|
|
|
|
nodeType === NodeType.END_EVENT_NODE
|
|
|
|
|
) {
|
2024-10-01 23:35:11 +08:00
|
|
|
|
return statusIconMap[taskStatus]?.icon
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getApprovalNodeColor = (taskStatus: number) => {
|
|
|
|
|
return statusIconMap[taskStatus]?.color
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getApprovalNodeTime = (node: ProcessInstanceApi.ApprovalNodeInfo) => {
|
2024-10-20 10:24:35 +08:00
|
|
|
|
if (node.nodeType === NodeType.START_USER_NODE && node.startTime) {
|
2024-10-22 16:23:35 +08:00
|
|
|
|
return `${formatDate(node.startTime)}`
|
2024-10-20 10:24:35 +08:00
|
|
|
|
}
|
2024-10-04 16:16:33 +08:00
|
|
|
|
if (node.endTime) {
|
2024-10-22 16:23:35 +08:00
|
|
|
|
return `${formatDate(node.endTime)}`
|
2024-10-01 23:35:11 +08:00
|
|
|
|
}
|
2024-10-04 16:16:33 +08:00
|
|
|
|
if (node.startTime) {
|
2024-10-22 16:23:35 +08:00
|
|
|
|
return `${formatDate(node.startTime)}`
|
2024-10-01 23:35:11 +08:00
|
|
|
|
}
|
2024-09-02 11:34:03 +08:00
|
|
|
|
}
|
|
|
|
|
</script>
|