Skip to content

Commit 0ffd074

Browse files
YunaiVgitee-org
authored andcommitted
!248 【工作流】流程实例的任务节点回退
Merge pull request !248 from Youkehai/master
2 parents 7958475 + de79e79 commit 0ffd074

File tree

5 files changed

+160
-2
lines changed

5 files changed

+160
-2
lines changed

src/api/bpm/task/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,19 @@ export const getTaskListByProcessInstanceId = async (processInstanceId) => {
4141
export const exportTask = async (params) => {
4242
return await request.download({ url: '/bpm/task/export', params })
4343
}
44+
45+
/**
46+
* 获取所有可回退的节点
47+
* @param params
48+
*/
49+
export const getReturnList = async (params) => {
50+
return await request.get({ url: '/bpm/task/get-return-list', params })
51+
}
52+
53+
/**
54+
* 确认回退
55+
* @param params
56+
*/
57+
export const okRollback = async (data) => {
58+
return await request.put({ url: '/bpm/task/rollback', data })
59+
}

src/components/bpmnProcessDesigner/package/designer/ProcessViewer.vue

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ const getResultCss = (result) => {
229229
} else if (result === 4) {
230230
// 已取消
231231
return 'highlight-cancel'
232+
} else if (result === 5) {
233+
// 退回
234+
return 'highlight-rollback'
232235
}
233236
return ''
234237
}
@@ -564,6 +567,45 @@ watch(
564567
stroke: grey !important;
565568
}
566569
570+
/** 回退 */
571+
.highlight-rollback.djs-shape .djs-visual > :nth-child(1) {
572+
fill: #e6a23c !important;
573+
stroke: #e6a23c !important;
574+
fill-opacity: 0.2 !important;
575+
}
576+
.highlight-rollback.djs-shape .djs-visual > :nth-child(2) {
577+
fill: #e6a23c !important;
578+
}
579+
.highlight-rollback.djs-shape .djs-visual > path {
580+
fill: #e6a23c !important;
581+
fill-opacity: 0.2 !important;
582+
stroke: #e6a23c !important;
583+
}
584+
.highlight-rollback.djs-connection > .djs-visual > path {
585+
stroke: #e6a23c !important;
586+
}
587+
588+
.highlight-rollback:not(.djs-connection) .djs-visual > :nth-child(1) {
589+
fill: #e6a23c !important; /* color elements as green */
590+
}
591+
592+
:deep(.highlight-rollback.djs-shape .djs-visual > :nth-child(1)) {
593+
fill: #e6a23c !important;
594+
stroke: #e6a23c !important;
595+
fill-opacity: 0.2 !important;
596+
}
597+
:deep(.highlight-rollback.djs-shape .djs-visual > :nth-child(2)) {
598+
fill: #e6a23c !important;
599+
}
600+
:deep(.highlight-rollback.djs-shape .djs-visual > path) {
601+
fill: #e6a23c !important;
602+
fill-opacity: 0.2 !important;
603+
stroke: #e6a23c !important;
604+
}
605+
:deep(.highlight-rollback.djs-connection > .djs-visual > path) {
606+
stroke: #e6a23c !important;
607+
}
608+
567609
.element-overlays {
568610
width: 200px;
569611
padding: 8px;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ const getTimelineItemIcon = (item) => {
6969
if (item.result === 4) {
7070
return 'el-icon-remove-outline'
7171
}
72+
if (item.result === 5) {
73+
return 'el-icon-back'
74+
}
7275
return ''
7376
}
7477
@@ -86,6 +89,9 @@ const getTimelineItemType = (item) => {
8689
if (item.result === 4) {
8790
return 'info'
8891
}
92+
if (item.result === 5) {
93+
return 'warning'
94+
}
8995
return ''
9096
}
9197
</script>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<template>
2+
<Dialog v-model="dialogVisible" title="回退" width="500">
3+
<el-form
4+
ref="formRef"
5+
v-loading="formLoading"
6+
:model="formData"
7+
:rules="formRules"
8+
label-width="110px"
9+
>
10+
<el-form-item label="退回节点" prop="targetDefinitionKey">
11+
<el-select v-model="formData.targetDefinitionKey" clearable style="width: 100%">
12+
<el-option
13+
v-for="item in returnList"
14+
:key="item.taskDefinitionKey"
15+
:label="item.name"
16+
:value="item.taskDefinitionKey"
17+
/>
18+
</el-select>
19+
</el-form-item>
20+
<el-form-item label="回退理由" prop="reason">
21+
<el-input v-model="formData.reason" clearable placeholder="请输入回退理由" />
22+
</el-form-item>
23+
</el-form>
24+
<template #footer>
25+
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
26+
<el-button @click="dialogVisible = false">取 消</el-button>
27+
</template>
28+
</Dialog>
29+
</template>
30+
<script lang="ts" name="TaskRollbackDialogForm" setup>
31+
import * as TaskApi from '@/api/bpm/task'
32+
33+
const message = useMessage() // 消息弹窗
34+
const dialogVisible = ref(false) // 弹窗的是否展示
35+
const formLoading = ref(false) // 表单的加载中
36+
const formData = ref({
37+
id: '',
38+
targetDefinitionKey: undefined,
39+
reason: ''
40+
})
41+
const formRules = ref({
42+
targetDefinitionKey: [{ required: true, message: '必须选择回退节点', trigger: 'change' }],
43+
reason: [{ required: true, message: '回退理由不能为空', trigger: 'blur' }]
44+
})
45+
46+
const formRef = ref() // 表单 Ref
47+
const returnList = ref([])
48+
/** 打开弹窗 */
49+
const open = async (id: string) => {
50+
returnList.value = await TaskApi.getReturnList({ taskId: id })
51+
if (returnList.value.length === 0) {
52+
message.warning('当前没有可回退的节点')
53+
return false
54+
}
55+
dialogVisible.value = true
56+
resetForm()
57+
formData.value.id = id
58+
}
59+
defineExpose({ open }) // 提供 openModal 方法,用于打开弹窗
60+
61+
/** 提交表单 */
62+
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
63+
const submitForm = async () => {
64+
// 校验表单
65+
if (!formRef) return
66+
const valid = await formRef.value.validate()
67+
if (!valid) return
68+
// 提交请求
69+
formLoading.value = true
70+
try {
71+
await TaskApi.okRollback(formData.value)
72+
message.success('回退成功')
73+
dialogVisible.value = false
74+
// 发送操作成功的事件
75+
emit('success')
76+
} finally {
77+
formLoading.value = false
78+
}
79+
}
80+
81+
/** 重置表单 */
82+
const resetForm = () => {
83+
formData.value = {
84+
id: '',
85+
targetDefinitionKey: undefined,
86+
reason: ''
87+
}
88+
formRef.value?.resetFields()
89+
}
90+
</script>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191

9292
<!-- 弹窗:转派审批人 -->
9393
<TaskUpdateAssigneeForm ref="taskUpdateAssigneeFormRef" @success="getDetail" />
94+
<!-- 弹窗,回退节点 -->
95+
<TaskRollbackDialog ref="taskRollbackRef" @success="getDetail" />
9496
</ContentWrap>
9597
</template>
9698
<script lang="ts" setup>
@@ -103,6 +105,7 @@ import * as TaskApi from '@/api/bpm/task'
103105
import TaskUpdateAssigneeForm from './TaskUpdateAssigneeForm.vue'
104106
import ProcessInstanceBpmnViewer from './ProcessInstanceBpmnViewer.vue'
105107
import ProcessInstanceTaskList from './ProcessInstanceTaskList.vue'
108+
import TaskRollbackDialog from './TaskRollbackDialogForm.vue'
106109
import { registerComponent } from '@/utils/routerHelper'
107110
108111
defineOptions({ name: 'BpmProcessInstanceDetail' })
@@ -172,10 +175,11 @@ const handleDelegate = async (task) => {
172175
console.log(task)
173176
}
174177
178+
//回退弹框组件
179+
const taskRollbackRef = ref()
175180
/** 处理审批退回的操作 */
176181
const handleBack = async (task) => {
177-
message.error('暂不支持【退回】功能!')
178-
console.log(task)
182+
taskRollbackRef.value.open(task.id)
179183
}
180184
181185
/** 获得详情 */

0 commit comments

Comments
 (0)