Skip to content

Commit 05b408d

Browse files
committed
BPM:新增流程的重新发起
1 parent 0d4b6f6 commit 05b408d

File tree

3 files changed

+49
-19
lines changed

3 files changed

+49
-19
lines changed

src/router/modules/remaining.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
243243
},
244244
children: [
245245
{
246-
path: '/manager/form/edit',
246+
path: 'manager/form/edit',
247247
component: () => import('@/views/bpm/form/editor/index.vue'),
248248
name: 'BpmFormEditor',
249249
meta: {
@@ -255,7 +255,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
255255
}
256256
},
257257
{
258-
path: '/manager/model/edit',
258+
path: 'manager/model/edit',
259259
component: () => import('@/views/bpm/model/editor/index.vue'),
260260
name: 'BpmModelEditor',
261261
meta: {
@@ -267,7 +267,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
267267
}
268268
},
269269
{
270-
path: '/manager/simple/workflow/model/edit',
270+
path: 'manager/simple/workflow/model/edit',
271271
component: () => import('@/views/bpm/simpleWorkflow/index.vue'),
272272
name: 'SimpleWorkflowDesignEditor',
273273
meta: {
@@ -279,7 +279,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
279279
}
280280
},
281281
{
282-
path: '/manager/definition',
282+
path: 'manager/definition',
283283
component: () => import('@/views/bpm/definition/index.vue'),
284284
name: 'BpmProcessDefinition',
285285
meta: {
@@ -291,19 +291,19 @@ const remainingRouter: AppRouteRecordRaw[] = [
291291
}
292292
},
293293
{
294-
path: '/process-instance/detail',
294+
path: 'process-instance/detail',
295295
component: () => import('@/views/bpm/processInstance/detail/index.vue'),
296296
name: 'BpmProcessInstanceDetail',
297297
meta: {
298298
noCache: true,
299299
hidden: true,
300300
canTo: true,
301301
title: '流程详情',
302-
activeMenu: 'bpm/processInstance/detail'
302+
activeMenu: '/bpm/task/my'
303303
}
304304
},
305305
{
306-
path: '/bpm/oa/leave/create',
306+
path: 'oa/leave/create',
307307
component: () => import('@/views/bpm/oa/leave/create.vue'),
308308
name: 'OALeaveCreate',
309309
meta: {
@@ -315,7 +315,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
315315
}
316316
},
317317
{
318-
path: '/bpm/oa/leave/detail',
318+
path: 'oa/leave/detail',
319319
component: () => import('@/views/bpm/oa/leave/detail.vue'),
320320
name: 'OALeaveDetail',
321321
meta: {

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

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<form-create
5252
:rule="detailForm.rule"
5353
v-model:api="fApi"
54+
v-model="detailForm.value"
5455
:option="detailForm.option"
5556
@submit="submitForm"
5657
/>
@@ -67,12 +68,16 @@ import { setConfAndFields2 } from '@/utils/formCreate'
6768
import type { ApiAttrs } from '@form-create/element-ui/types/config'
6869
import ProcessInstanceBpmnViewer from '../detail/ProcessInstanceBpmnViewer.vue'
6970
import { CategoryApi } from '@/api/bpm/category'
71+
import { useTagsViewStore } from '@/store/modules/tagsView'
7072
7173
defineOptions({ name: 'BpmProcessInstanceCreate' })
7274
73-
const router = useRouter() // 路由
75+
const route = useRoute() // 路由
76+
const { push, currentRoute } = useRouter() // 路由
7477
const message = useMessage() // 消息
78+
const { delView } = useTagsViewStore() // 视图操作
7579
80+
const processInstanceId = route.query.processInstanceId
7681
const loading = ref(true) // 加载中
7782
const categoryList = ref([]) // 分类的列表
7883
const categoryActive = ref('') // 选中的分类
@@ -91,6 +96,23 @@ const getList = async () => {
9196
processDefinitionList.value = await DefinitionApi.getProcessDefinitionList({
9297
suspensionState: 1
9398
})
99+
100+
// 如果 processInstanceId 非空,说明是重新发起
101+
if (processInstanceId?.length > 0) {
102+
const processInstance = await ProcessInstanceApi.getProcessInstance(processInstanceId)
103+
if (!processInstance) {
104+
message.error('重新发起流程失败,原因:流程实例不存在')
105+
return
106+
}
107+
const processDefinition = processDefinitionList.value.find(
108+
(item) => item.key == processInstance.processDefinition?.key
109+
)
110+
if (!processDefinition) {
111+
message.error('重新发起流程失败,原因:流程定义不存在')
112+
return
113+
}
114+
await handleSelect(processDefinition, processInstance.formVariables)
115+
}
94116
} finally {
95117
loading.value = false
96118
}
@@ -105,26 +127,26 @@ const categoryProcessDefinitionList = computed(() => {
105127
const bpmnXML = ref(null) // BPMN 数据
106128
const fApi = ref<ApiAttrs>()
107129
const detailForm = ref({
108-
// 流程表单详情
109130
rule: [],
110-
option: {}
111-
})
131+
option: {},
132+
value: {}
133+
}) // 流程表单详情
112134
const selectProcessDefinition = ref() // 选择的流程定义
113135
114136
/** 处理选择流程的按钮操作 **/
115-
const handleSelect = async (row) => {
137+
const handleSelect = async (row, formVariables) => {
116138
// 设置选择的流程
117139
selectProcessDefinition.value = row
118140
119141
// 情况一:流程表单
120142
if (row.formType == 10) {
121143
// 设置表单
122-
setConfAndFields2(detailForm, row.formConf, row.formFields)
144+
setConfAndFields2(detailForm, row.formConf, row.formFields, formVariables)
123145
// 加载流程图
124146
bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(row.id)
125147
// 情况二:业务表单
126148
} else if (row.formCustomCreatePath) {
127-
await router.push({
149+
await push({
128150
path: row.formCustomCreatePath
129151
})
130152
// 这里暂时无需加载流程图,因为跳出到另外个 Tab;
@@ -145,7 +167,11 @@ const submitForm = async (formData) => {
145167
})
146168
// 提示
147169
message.success('发起流程成功')
148-
router.go(-1)
170+
// 跳转回去
171+
delView(unref(currentRoute))
172+
await push({
173+
name: 'BpmProcessInstance'
174+
})
149175
} finally {
150176
fApi.value.btn.loading(false)
151177
}

src/views/bpm/processInstance/index.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
type="primary"
7777
plain
7878
v-hasPermi="['bpm:process-instance:query']"
79-
@click="handleCreate"
79+
@click="handleCreate()"
8080
>
8181
<Icon icon="ep:plus" class="mr-5px" /> 发起流程
8282
</el-button>
@@ -135,6 +135,9 @@
135135
>
136136
取消
137137
</el-button>
138+
<el-button link type="primary" v-else @click="handleCreate(scope.row.id)">
139+
重新发起
140+
</el-button>
138141
</template>
139142
</el-table-column>
140143
</el-table>
@@ -200,9 +203,10 @@ const resetQuery = () => {
200203
}
201204
202205
/** 发起流程操作 **/
203-
const handleCreate = () => {
206+
const handleCreate = (id) => {
204207
router.push({
205-
name: 'BpmProcessInstanceCreate'
208+
name: 'BpmProcessInstanceCreate',
209+
query: { processInstanceId: id }
206210
})
207211
}
208212

0 commit comments

Comments
 (0)