Skip to content

Commit 2d424fc

Browse files
committed
BPM:优化 task 加减签的实现
1 parent a40866e commit 2d424fc

File tree

8 files changed

+101
-81
lines changed

8 files changed

+101
-81
lines changed

src/api/bpm/processInstance/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const cancelProcessInstance = async (id: number, reason: string) => {
4747
return await request.delete({ url: '/bpm/process-instance/cancel', data: data })
4848
}
4949

50-
export const getProcessInstance = async (id: number) => {
50+
export const getProcessInstance = async (id: string) => {
5151
return await request.get({ url: '/bpm/process-instance/get?id=' + id })
5252
}
5353

src/api/bpm/task/index.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ export type TaskVO = {
44
id: number
55
}
66

7-
export const getTodoTaskPage = async (params) => {
7+
export const getTodoTaskPage = async (params: any) => {
88
return await request.get({ url: '/bpm/task/todo-page', params })
99
}
1010

11-
export const getDoneTaskPage = async (params) => {
11+
export const getDoneTaskPage = async (params: any) => {
1212
return await request.get({ url: '/bpm/task/done-page', params })
1313
}
1414

15-
export const approveTask = async (data) => {
15+
export const approveTask = async (data: any) => {
1616
return await request.put({ url: '/bpm/task/approve', data })
1717
}
1818

19-
export const rejectTask = async (data) => {
19+
export const rejectTask = async (data: any) => {
2020
return await request.put({ url: '/bpm/task/reject', data })
2121
}
2222

23-
export const getTaskListByProcessInstanceId = async (processInstanceId) => {
23+
export const getTaskListByProcessInstanceId = async (processInstanceId: string) => {
2424
return await request.get({
2525
url: '/bpm/task/list-by-process-instance-id?processInstanceId=' + processInstanceId
2626
})
@@ -46,23 +46,17 @@ export const transferTask = async (data: any) => {
4646
return await request.put({ url: '/bpm/task/transfer', data })
4747
}
4848

49-
/**
50-
* 加签
51-
*/
52-
export const taskAddSign = async (data) => {
49+
// 加签
50+
export const signCreateTask = async (data: any) => {
5351
return await request.put({ url: '/bpm/task/create-sign', data })
5452
}
5553

56-
/**
57-
* 获取减签任务列表
58-
*/
59-
export const getChildrenTaskList = async (id: string) => {
60-
return await request.get({ url: '/bpm/task/children-list?parentId=' + id })
54+
// 减签
55+
export const signDeleteTask = async (data: any) => {
56+
return await request.delete({ url: '/bpm/task/delete-sign', data })
6157
}
6258

63-
/**
64-
* 减签
65-
*/
66-
export const taskSubSign = async (data) => {
67-
return await request.delete({ url: '/bpm/task/delete-sign', data })
59+
// 获取减签任务列表
60+
export const getChildrenTaskList = async (id: string) => {
61+
return await request.get({ url: '/bpm/task/list-by-parent-task-id?parentTaskId=' + id })
6862
}

src/views/bpm/processInstance/detail/ProcessInstanceTaskList.vue

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,17 @@
5050
</el-timeline>
5151
</div>
5252
</el-col>
53-
<!-- 子任务 -->
54-
<ProcessInstanceChildrenTaskList ref="processInstanceChildrenTaskList" />
53+
54+
<!-- 弹窗:子任务 -->
55+
<TaskSignList ref="taskSignListRef" @success="refresh" />
5556
</el-card>
5657
</template>
5758
<script lang="ts" setup>
5859
import { formatDate, formatPast2 } from '@/utils/formatTime'
5960
import { propTypes } from '@/utils/propTypes'
6061
import { DICT_TYPE } from '@/utils/dict'
6162
import { isEmpty } from '@/utils/is'
62-
import ProcessInstanceChildrenTaskList from './ProcessInstanceChildrenTaskList.vue'
63+
import TaskSignList from './dialog/TaskSignList.vue'
6364
6465
defineOptions({ name: 'BpmProcessInstanceTaskList' })
6566
@@ -69,6 +70,7 @@ defineProps({
6970
})
7071
7172
/** 获得任务对应的 icon */
73+
// TODO @芋艿:对应的 icon 需要调整
7274
const getTimelineItemIcon = (item) => {
7375
if (item.status === 1) {
7476
return 'el-icon-time'
@@ -114,12 +116,15 @@ const getTimelineItemType = (item: any) => {
114116
return ''
115117
}
116118
117-
/**
118-
* 子任务
119-
*/
120-
const processInstanceChildrenTaskList = ref()
119+
/** 子任务 */
120+
const taskSignListRef = ref()
121+
const openChildrenTask = (item: any) => {
122+
taskSignListRef.value.open(item)
123+
}
121124
122-
const openChildrenTask = (item) => {
123-
processInstanceChildrenTaskList.value.open(item)
125+
/** 刷新数据 */
126+
const emit = defineEmits(['refresh']) // 定义 success 事件,用于操作成功后的回调
127+
const refresh = () => {
128+
emit('refresh')
124129
}
125130
</script>

src/views/bpm/processInstance/detail/TaskAddSignDialogForm.vue renamed to src/views/bpm/processInstance/detail/dialog/TaskSignCreateForm.vue

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
:rules="formRules"
88
label-width="110px"
99
>
10-
<el-form-item label="加签处理人" prop="userIdList">
11-
<el-select v-model="formData.userIdList" multiple clearable style="width: 100%">
10+
<el-form-item label="加签处理人" prop="userIds">
11+
<el-select v-model="formData.userIds" multiple clearable style="width: 100%">
1212
<el-option
1313
v-for="item in userList"
1414
:key="item.id"
@@ -36,18 +36,19 @@
3636
import * as TaskApi from '@/api/bpm/task'
3737
import * as UserApi from '@/api/system/user'
3838
39-
const message = useMessage() // 消息弹窗
40-
defineOptions({ name: 'BpmTaskUpdateAssigneeForm' })
39+
defineOptions({ name: 'TaskSignCreateForm' })
4140
41+
const message = useMessage() // 消息弹窗
4242
const dialogVisible = ref(false) // 弹窗的是否展示
4343
const formLoading = ref(false) // 表单的加载中
4444
const formData = ref({
4545
id: '',
46-
userIdList: [],
47-
type: ''
46+
userIds: [],
47+
type: '',
48+
reason: ''
4849
})
4950
const formRules = ref({
50-
userIdList: [{ required: true, message: '加签处理人不能为空', trigger: 'change' }],
51+
userIds: [{ required: true, message: '加签处理人不能为空', trigger: 'change' }],
5152
reason: [{ required: true, message: '加签理由不能为空', trigger: 'change' }]
5253
})
5354
@@ -75,7 +76,7 @@ const submitForm = async (type: string) => {
7576
formLoading.value = true
7677
formData.value.type = type
7778
try {
78-
await TaskApi.taskAddSign(formData.value)
79+
await TaskApi.signCreateTask(formData.value)
7980
message.success('加签成功')
8081
dialogVisible.value = false
8182
// 发送操作成功的事件
@@ -89,8 +90,9 @@ const submitForm = async (type: string) => {
8990
const resetForm = () => {
9091
formData.value = {
9192
id: '',
92-
userIdList: [],
93-
type: ''
93+
userIds: [],
94+
type: '',
95+
reason: ''
9496
}
9597
formRef.value?.resetFields()
9698
}

src/views/bpm/processInstance/detail/TaskSubSignDialogForm.vue renamed to src/views/bpm/processInstance/detail/dialog/TaskSignDeleteForm.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
>
1010
<el-form-item label="减签任务" prop="id">
1111
<el-radio-group v-model="formData.id">
12-
<el-radio-button v-for="item in subTaskList" :key="item.id" :label="item.id">
13-
{{ item.name }}({{ item.assigneeUser.deptName }}{{ item.assigneeUser.nickname }}--审批)
12+
<el-radio-button v-for="item in childrenTaskList" :key="item.id" :label="item.id">
13+
{{ item.name }}
14+
({{ item.assigneeUser?.deptName || item.ownerUser?.deptName }} -
15+
{{ item.assigneeUser?.nickname || item.ownerUser?.nickname }})
1416
</el-radio-button>
1517
</el-radio-group>
1618
</el-form-item>
@@ -24,10 +26,12 @@
2426
</template>
2527
</Dialog>
2628
</template>
27-
<script lang="ts" name="TaskRollbackDialogForm" setup>
29+
<script lang="ts" setup>
2830
import * as TaskApi from '@/api/bpm/task'
2931
import { isEmpty } from '@/utils/is'
3032
33+
defineOptions({ name: 'TaskSignDeleteForm' })
34+
3135
const message = useMessage() // 消息弹窗
3236
const dialogVisible = ref(false) // 弹窗的是否展示
3337
const formLoading = ref(false) // 表单的加载中
@@ -41,11 +45,11 @@ const formRules = ref({
4145
})
4246
4347
const formRef = ref() // 表单 Ref
44-
const subTaskList = ref([])
48+
const childrenTaskList = ref([])
4549
/** 打开弹窗 */
4650
const open = async (id: string) => {
47-
subTaskList.value = await TaskApi.getChildrenTaskList(id)
48-
if (isEmpty(subTaskList.value)) {
51+
childrenTaskList.value = await TaskApi.getChildrenTaskList(id)
52+
if (isEmpty(childrenTaskList.value)) {
4953
message.warning('当前没有可减签的任务')
5054
return false
5155
}
@@ -64,7 +68,7 @@ const submitForm = async () => {
6468
// 提交请求
6569
formLoading.value = true
6670
try {
67-
await TaskApi.taskSubSign(formData.value)
71+
await TaskApi.signDeleteTask(formData.value)
6872
message.success('减签成功')
6973
dialogVisible.value = false
7074
// 发送操作成功的事件
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
<template>
2-
<el-drawer v-model="drawerVisible" title="子任务" size="70%">
2+
<el-drawer v-model="drawerVisible" title="子任务" size="880px">
33
<!-- 当前任务 -->
44
<template #header>
5-
<h4>【{{ baseTask.name }} 】审批人:{{ baseTask.assigneeUser?.nickname }}</h4>
5+
<h4>【{{ parentTask.name }} 】审批人:{{ parentTask?.assigneeUser?.nickname }}</h4>
66
<el-button
77
style="margin-left: 5px"
8-
v-if="isSubSignButtonVisible(baseTask)"
8+
v-if="isSignDeleteButtonVisible(parentTask)"
99
type="danger"
1010
plain
11-
@click="handleSubSign(baseTask)"
11+
@click="handleSignDelete(parentTask)"
1212
>
1313
<Icon icon="ep:remove" /> 减签
1414
</el-button>
1515
</template>
1616
<!-- 子任务列表 -->
17-
<el-table :data="baseTask.children" style="width: 100%" row-key="id" border>
18-
<el-table-column prop="assigneeUser.nickname" label="审批人" />
19-
<el-table-column prop="assigneeUser.deptName" label="所在部门" />
20-
<el-table-column label="审批状态" prop="status">
17+
<el-table :data="parentTask.children" style="width: 100%" row-key="id" border>
18+
<el-table-column prop="assigneeUser.nickname" label="审批人" min-width="100">
19+
<template #default="scope">
20+
{{ scope.row.assigneeUser?.nickname || scope.row.ownerUser?.nickname }}
21+
</template>
22+
</el-table-column>
23+
<el-table-column prop="assigneeUser.deptName" label="所在部门" min-width="100">
24+
<template #default="scope">
25+
{{ scope.row.assigneeUser?.deptName || scope.row.ownerUser?.deptName }}
26+
</template>
27+
</el-table-column>
28+
<el-table-column label="审批状态" prop="status" width="120">
2129
<template #default="scope">
2230
<dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT" :value="scope.row.status" />
2331
</template>
@@ -36,61 +44,63 @@
3644
width="180"
3745
:formatter="dateFormatter"
3846
/>
39-
<el-table-column label="操作" prop="operation">
47+
<el-table-column label="操作" prop="operation" width="90">
4048
<template #default="scope">
4149
<el-button
42-
v-if="isSubSignButtonVisible(scope.row)"
50+
v-if="isSignDeleteButtonVisible(scope.row)"
4351
type="danger"
4452
plain
45-
@click="handleSubSign(scope.row)"
53+
size="small"
54+
@click="handleSignDelete(scope.row)"
4655
>
4756
<Icon icon="ep:remove" /> 减签
4857
</el-button>
4958
</template>
5059
</el-table-column>
5160
</el-table>
61+
5262
<!-- 减签 -->
53-
<TaskSubSignDialogForm ref="taskSubSignDialogForm" />
63+
<TaskSignDeleteForm ref="taskSignDeleteFormRef" @success="handleSignDeleteSuccess" />
5464
</el-drawer>
5565
</template>
5666
<script lang="ts" setup>
5767
import { isEmpty } from '@/utils/is'
5868
import { DICT_TYPE } from '@/utils/dict'
5969
import { dateFormatter } from '@/utils/formatTime'
60-
import TaskSubSignDialogForm from './TaskSubSignDialogForm.vue'
70+
import TaskSignDeleteForm from './TaskSignDeleteForm.vue'
6171
62-
defineOptions({ name: 'ProcessInstanceChildrenTaskList' })
72+
defineOptions({ name: 'TaskSignList' })
6373
6474
const message = useMessage() // 消息弹窗
6575
const drawerVisible = ref(false) // 抽屉的是否展示
76+
const parentTask = ref({} as any)
6677
67-
const baseTask = ref<object>({})
6878
/** 打开弹窗 */
6979
const open = async (task: any) => {
7080
if (isEmpty(task.children)) {
7181
message.warning('该任务没有子任务')
7282
return
7383
}
74-
baseTask.value = task
84+
parentTask.value = task
7585
// 展开抽屉
7686
drawerVisible.value = true
7787
}
7888
defineExpose({ open }) // 提供 openModal 方法,用于打开弹窗
7989
8090
/** 发起减签 */
81-
const taskSubSignDialogForm = ref()
82-
const handleSubSign = (item) => {
83-
taskSubSignDialogForm.value.open(item.id)
84-
// TODO @海洋:减签后,需要刷新下界面哈
91+
const taskSignDeleteFormRef = ref()
92+
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
93+
const handleSignDelete = (item: any) => {
94+
taskSignDeleteFormRef.value.open(item.id)
95+
}
96+
const handleSignDeleteSuccess = () => {
97+
emit('success')
98+
// 关闭抽屉
99+
drawerVisible.value = false
85100
}
86101
87102
/** 是否显示减签按钮 */
88-
const isSubSignButtonVisible = (task: any) => {
89-
if (task && task.children && !isEmpty(task.children)) {
90-
// 有子任务,且子任务有任意一个是 待处理 和 待前置任务完成 则显示减签按钮
91-
const subTask = task.children.find((item) => item.status === 1 || item.status === 9)
92-
return !isEmpty(subTask)
93-
}
94-
return false
103+
const isSignDeleteButtonVisible = (task: any) => {
104+
return task && task.children && !isEmpty(task.children)
95105
}
96106
</script>

0 commit comments

Comments
 (0)