BPM:优化 task 加减签的实现

This commit is contained in:
YunaiV 2024-03-19 01:31:51 +08:00
parent a40866e27f
commit 2d424fc9a6
8 changed files with 102 additions and 82 deletions

View File

@ -47,7 +47,7 @@ export const cancelProcessInstance = async (id: number, reason: string) => {
return await request.delete({ url: '/bpm/process-instance/cancel', data: data })
}
export const getProcessInstance = async (id: number) => {
export const getProcessInstance = async (id: string) => {
return await request.get({ url: '/bpm/process-instance/get?id=' + id })
}

View File

@ -4,23 +4,23 @@ export type TaskVO = {
id: number
}
export const getTodoTaskPage = async (params) => {
export const getTodoTaskPage = async (params: any) => {
return await request.get({ url: '/bpm/task/todo-page', params })
}
export const getDoneTaskPage = async (params) => {
export const getDoneTaskPage = async (params: any) => {
return await request.get({ url: '/bpm/task/done-page', params })
}
export const approveTask = async (data) => {
export const approveTask = async (data: any) => {
return await request.put({ url: '/bpm/task/approve', data })
}
export const rejectTask = async (data) => {
export const rejectTask = async (data: any) => {
return await request.put({ url: '/bpm/task/reject', data })
}
export const getTaskListByProcessInstanceId = async (processInstanceId) => {
export const getTaskListByProcessInstanceId = async (processInstanceId: string) => {
return await request.get({
url: '/bpm/task/list-by-process-instance-id?processInstanceId=' + processInstanceId
})
@ -46,23 +46,17 @@ export const transferTask = async (data: any) => {
return await request.put({ url: '/bpm/task/transfer', data })
}
/**
*
*/
export const taskAddSign = async (data) => {
// 加签
export const signCreateTask = async (data: any) => {
return await request.put({ url: '/bpm/task/create-sign', data })
}
/**
*
*/
export const getChildrenTaskList = async (id: string) => {
return await request.get({ url: '/bpm/task/children-list?parentId=' + id })
}
/**
*
*/
export const taskSubSign = async (data) => {
// 减签
export const signDeleteTask = async (data: any) => {
return await request.delete({ url: '/bpm/task/delete-sign', data })
}
// 获取减签任务列表
export const getChildrenTaskList = async (id: string) => {
return await request.get({ url: '/bpm/task/list-by-parent-task-id?parentTaskId=' + id })
}

View File

@ -50,8 +50,9 @@
</el-timeline>
</div>
</el-col>
<!-- 子任务 -->
<ProcessInstanceChildrenTaskList ref="processInstanceChildrenTaskList" />
<!-- 弹窗子任务 -->
<TaskSignList ref="taskSignListRef" @success="refresh" />
</el-card>
</template>
<script lang="ts" setup>
@ -59,7 +60,7 @@ import { formatDate, formatPast2 } from '@/utils/formatTime'
import { propTypes } from '@/utils/propTypes'
import { DICT_TYPE } from '@/utils/dict'
import { isEmpty } from '@/utils/is'
import ProcessInstanceChildrenTaskList from './ProcessInstanceChildrenTaskList.vue'
import TaskSignList from './dialog/TaskSignList.vue'
defineOptions({ name: 'BpmProcessInstanceTaskList' })
@ -69,6 +70,7 @@ defineProps({
})
/** 获得任务对应的 icon */
// TODO @ icon
const getTimelineItemIcon = (item) => {
if (item.status === 1) {
return 'el-icon-time'
@ -114,12 +116,15 @@ const getTimelineItemType = (item: any) => {
return ''
}
/**
* 子任务
*/
const processInstanceChildrenTaskList = ref()
/** 子任务 */
const taskSignListRef = ref()
const openChildrenTask = (item: any) => {
taskSignListRef.value.open(item)
}
const openChildrenTask = (item) => {
processInstanceChildrenTaskList.value.open(item)
/** 刷新数据 */
const emit = defineEmits(['refresh']) // success
const refresh = () => {
emit('refresh')
}
</script>

View File

@ -7,8 +7,8 @@
:rules="formRules"
label-width="110px"
>
<el-form-item label="加签处理人" prop="userIdList">
<el-select v-model="formData.userIdList" multiple clearable style="width: 100%">
<el-form-item label="加签处理人" prop="userIds">
<el-select v-model="formData.userIds" multiple clearable style="width: 100%">
<el-option
v-for="item in userList"
:key="item.id"
@ -36,18 +36,19 @@
import * as TaskApi from '@/api/bpm/task'
import * as UserApi from '@/api/system/user'
const message = useMessage() //
defineOptions({ name: 'BpmTaskUpdateAssigneeForm' })
defineOptions({ name: 'TaskSignCreateForm' })
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) //
const formData = ref({
id: '',
userIdList: [],
type: ''
userIds: [],
type: '',
reason: ''
})
const formRules = ref({
userIdList: [{ required: true, message: '加签处理人不能为空', trigger: 'change' }],
userIds: [{ required: true, message: '加签处理人不能为空', trigger: 'change' }],
reason: [{ required: true, message: '加签理由不能为空', trigger: 'change' }]
})
@ -75,7 +76,7 @@ const submitForm = async (type: string) => {
formLoading.value = true
formData.value.type = type
try {
await TaskApi.taskAddSign(formData.value)
await TaskApi.signCreateTask(formData.value)
message.success('加签成功')
dialogVisible.value = false
//
@ -89,8 +90,9 @@ const submitForm = async (type: string) => {
const resetForm = () => {
formData.value = {
id: '',
userIdList: [],
type: ''
userIds: [],
type: '',
reason: ''
}
formRef.value?.resetFields()
}

View File

@ -9,8 +9,10 @@
>
<el-form-item label="减签任务" prop="id">
<el-radio-group v-model="formData.id">
<el-radio-button v-for="item in subTaskList" :key="item.id" :label="item.id">
{{ item.name }}({{ item.assigneeUser.deptName }}{{ item.assigneeUser.nickname }}--审批)
<el-radio-button v-for="item in childrenTaskList" :key="item.id" :label="item.id">
{{ item.name }}
({{ item.assigneeUser?.deptName || item.ownerUser?.deptName }} -
{{ item.assigneeUser?.nickname || item.ownerUser?.nickname }})
</el-radio-button>
</el-radio-group>
</el-form-item>
@ -24,10 +26,12 @@
</template>
</Dialog>
</template>
<script lang="ts" name="TaskRollbackDialogForm" setup>
<script lang="ts" setup>
import * as TaskApi from '@/api/bpm/task'
import { isEmpty } from '@/utils/is'
defineOptions({ name: 'TaskSignDeleteForm' })
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) //
@ -41,11 +45,11 @@ const formRules = ref({
})
const formRef = ref() // Ref
const subTaskList = ref([])
const childrenTaskList = ref([])
/** 打开弹窗 */
const open = async (id: string) => {
subTaskList.value = await TaskApi.getChildrenTaskList(id)
if (isEmpty(subTaskList.value)) {
childrenTaskList.value = await TaskApi.getChildrenTaskList(id)
if (isEmpty(childrenTaskList.value)) {
message.warning('当前没有可减签的任务')
return false
}
@ -64,7 +68,7 @@ const submitForm = async () => {
//
formLoading.value = true
try {
await TaskApi.taskSubSign(formData.value)
await TaskApi.signDeleteTask(formData.value)
message.success('减签成功')
dialogVisible.value = false
//

View File

@ -1,23 +1,31 @@
<template>
<el-drawer v-model="drawerVisible" title="子任务" size="70%">
<el-drawer v-model="drawerVisible" title="子任务" size="880px">
<!-- 当前任务 -->
<template #header>
<h4>{{ baseTask.name }} 审批人{{ baseTask.assigneeUser?.nickname }}</h4>
<h4>{{ parentTask.name }} 审批人{{ parentTask?.assigneeUser?.nickname }}</h4>
<el-button
style="margin-left: 5px"
v-if="isSubSignButtonVisible(baseTask)"
v-if="isSignDeleteButtonVisible(parentTask)"
type="danger"
plain
@click="handleSubSign(baseTask)"
@click="handleSignDelete(parentTask)"
>
<Icon icon="ep:remove" /> 减签
</el-button>
</template>
<!-- 子任务列表 -->
<el-table :data="baseTask.children" style="width: 100%" row-key="id" border>
<el-table-column prop="assigneeUser.nickname" label="审批人" />
<el-table-column prop="assigneeUser.deptName" label="所在部门" />
<el-table-column label="审批状态" prop="status">
<el-table :data="parentTask.children" style="width: 100%" row-key="id" border>
<el-table-column prop="assigneeUser.nickname" label="审批人" min-width="100">
<template #default="scope">
{{ scope.row.assigneeUser?.nickname || scope.row.ownerUser?.nickname }}
</template>
</el-table-column>
<el-table-column prop="assigneeUser.deptName" label="所在部门" min-width="100">
<template #default="scope">
{{ scope.row.assigneeUser?.deptName || scope.row.ownerUser?.deptName }}
</template>
</el-table-column>
<el-table-column label="审批状态" prop="status" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.status" />
</template>
@ -36,61 +44,63 @@
width="180"
:formatter="dateFormatter"
/>
<el-table-column label="操作" prop="operation">
<el-table-column label="操作" prop="operation" width="90">
<template #default="scope">
<el-button
v-if="isSubSignButtonVisible(scope.row)"
v-if="isSignDeleteButtonVisible(scope.row)"
type="danger"
plain
@click="handleSubSign(scope.row)"
size="small"
@click="handleSignDelete(scope.row)"
>
<Icon icon="ep:remove" /> 减签
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 减签 -->
<TaskSubSignDialogForm ref="taskSubSignDialogForm" />
<TaskSignDeleteForm ref="taskSignDeleteFormRef" @success="handleSignDeleteSuccess" />
</el-drawer>
</template>
<script lang="ts" setup>
import { isEmpty } from '@/utils/is'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import TaskSubSignDialogForm from './TaskSubSignDialogForm.vue'
import TaskSignDeleteForm from './TaskSignDeleteForm.vue'
defineOptions({ name: 'ProcessInstanceChildrenTaskList' })
defineOptions({ name: 'TaskSignList' })
const message = useMessage() //
const drawerVisible = ref(false) //
const parentTask = ref({} as any)
const baseTask = ref<object>({})
/** 打开弹窗 */
const open = async (task: any) => {
if (isEmpty(task.children)) {
message.warning('该任务没有子任务')
return
}
baseTask.value = task
parentTask.value = task
//
drawerVisible.value = true
}
defineExpose({ open }) // openModal
/** 发起减签 */
const taskSubSignDialogForm = ref()
const handleSubSign = (item) => {
taskSubSignDialogForm.value.open(item.id)
// TODO @
const taskSignDeleteFormRef = ref()
const emit = defineEmits(['success']) // success
const handleSignDelete = (item: any) => {
taskSignDeleteFormRef.value.open(item.id)
}
const handleSignDeleteSuccess = () => {
emit('success')
//
drawerVisible.value = false
}
/** 是否显示减签按钮 */
const isSubSignButtonVisible = (task: any) => {
if (task && task.children && !isEmpty(task.children)) {
//
const subTask = task.children.find((item) => item.status === 1 || item.status === 9)
return !isEmpty(subTask)
}
return false
const isSignDeleteButtonVisible = (task: any) => {
return task && task.children && !isEmpty(task.children)
}
</script>

View File

@ -92,7 +92,7 @@
</el-card>
<!-- 审批记录 -->
<ProcessInstanceTaskList :loading="tasksLoad" :tasks="tasks" />
<ProcessInstanceTaskList :loading="tasksLoad" :tasks="tasks" @refresh="getTaskList" />
<!-- 高亮流程图 -->
<ProcessInstanceBpmnViewer
@ -110,7 +110,7 @@
<!-- 弹窗委派将任务委派给别人处理处理完成后会重新回到原审批人手中-->
<TaskDelegateForm ref="taskDelegateForm" @success="getDetail" />
<!-- 弹窗加签当前任务审批人为A向前加签选了一个C则需要C先审批然后再是A审批向后加签BA审批完需要B再审批完才算完成这个任务节点 -->
<TaskAddSignDialogForm ref="taskAddSignDialogForm" @success="getDetail" />
<TaskSignCreateForm ref="taskSignCreateFormRef" @success="getDetail" />
</ContentWrap>
</template>
<script lang="ts" setup>
@ -125,7 +125,7 @@ import ProcessInstanceTaskList from './ProcessInstanceTaskList.vue'
import TaskReturnForm from './dialog/TaskReturnForm.vue'
import TaskDelegateForm from './dialog/TaskDelegateForm.vue'
import TaskTransferForm from './dialog/TaskTransferForm.vue'
import TaskAddSignDialogForm from './TaskAddSignDialogForm.vue'
import TaskSignCreateForm from './dialog/TaskSignCreateForm.vue'
import { registerComponent } from '@/utils/routerHelper'
import { isEmpty } from '@/utils/is'
import * as UserApi from '@/api/system/user'
@ -137,7 +137,7 @@ const message = useMessage() // 消息弹窗
const { proxy } = getCurrentInstance() as any
const userId = useUserStore().getUser.id //
const id = query.id as unknown as number //
const id = query.id as unknown as string //
const processInstanceLoading = ref(false) //
const processInstance = ref<any>({}) //
const bpmnXML = ref('') // BPMN XML
@ -205,9 +205,9 @@ const handleBack = async (task: any) => {
}
/** 处理审批加签的操作 */
const taskAddSignDialogForm = ref()
const handleSign = async (task) => {
taskAddSignDialogForm.value.open(task.id)
const taskSignCreateFormRef = ref()
const handleSign = async (task: any) => {
taskSignCreateFormRef.value.open(task.id)
}
/** 获得详情 */

View File

@ -133,7 +133,7 @@
<el-button
link
type="primary"
v-if="scope.row.result === 1"
v-if="scope.row.status === 1"
v-hasPermi="['bpm:process-instance:query']"
@click="handleCancel(scope.row)"
>
@ -234,6 +234,11 @@ const handleCancel = async (row) => {
await getList()
}
/** 激活时 **/
onActivated(() => {
getList()
})
/** 初始化 **/
onMounted(() => {
getList()