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 }) 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 }) return await request.get({ url: '/bpm/process-instance/get?id=' + id })
} }

View File

@ -4,23 +4,23 @@ export type TaskVO = {
id: number id: number
} }
export const getTodoTaskPage = async (params) => { export const getTodoTaskPage = async (params: any) => {
return await request.get({ url: '/bpm/task/todo-page', params }) 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 }) 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 }) 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 }) return await request.put({ url: '/bpm/task/reject', data })
} }
export const getTaskListByProcessInstanceId = async (processInstanceId) => { export const getTaskListByProcessInstanceId = async (processInstanceId: string) => {
return await request.get({ return await request.get({
url: '/bpm/task/list-by-process-instance-id?processInstanceId=' + processInstanceId 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 }) return await request.put({ url: '/bpm/task/transfer', data })
} }
/** // 加签
* export const signCreateTask = async (data: any) => {
*/
export const taskAddSign = async (data) => {
return await request.put({ url: '/bpm/task/create-sign', data }) return await request.put({ url: '/bpm/task/create-sign', data })
} }
/** // 减签
* export const signDeleteTask = async (data: any) => {
*/
export const getChildrenTaskList = async (id: string) => {
return await request.get({ url: '/bpm/task/children-list?parentId=' + id })
}
/**
*
*/
export const taskSubSign = async (data) => {
return await request.delete({ url: '/bpm/task/delete-sign', data }) 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> </el-timeline>
</div> </div>
</el-col> </el-col>
<!-- 子任务 -->
<ProcessInstanceChildrenTaskList ref="processInstanceChildrenTaskList" /> <!-- 弹窗子任务 -->
<TaskSignList ref="taskSignListRef" @success="refresh" />
</el-card> </el-card>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -59,7 +60,7 @@ import { formatDate, formatPast2 } from '@/utils/formatTime'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import { isEmpty } from '@/utils/is' import { isEmpty } from '@/utils/is'
import ProcessInstanceChildrenTaskList from './ProcessInstanceChildrenTaskList.vue' import TaskSignList from './dialog/TaskSignList.vue'
defineOptions({ name: 'BpmProcessInstanceTaskList' }) defineOptions({ name: 'BpmProcessInstanceTaskList' })
@ -69,6 +70,7 @@ defineProps({
}) })
/** 获得任务对应的 icon */ /** 获得任务对应的 icon */
// TODO @ icon
const getTimelineItemIcon = (item) => { const getTimelineItemIcon = (item) => {
if (item.status === 1) { if (item.status === 1) {
return 'el-icon-time' return 'el-icon-time'
@ -114,12 +116,15 @@ const getTimelineItemType = (item: any) => {
return '' return ''
} }
/** /** 子任务 */
* 子任务 const taskSignListRef = ref()
*/ const openChildrenTask = (item: any) => {
const processInstanceChildrenTaskList = ref() taskSignListRef.value.open(item)
}
const openChildrenTask = (item) => { /** 刷新数据 */
processInstanceChildrenTaskList.value.open(item) const emit = defineEmits(['refresh']) // success
const refresh = () => {
emit('refresh')
} }
</script> </script>

View File

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

View File

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

View File

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

View File

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

View File

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