Skip to content

Commit 1b0fe23

Browse files
committed
feat: 发布流程时校验当前流程版本是否存在正在进行中的单据
1 parent 85c6971 commit 1b0fe23

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

src/api/bpm/model/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,13 @@ export const deployModel = async (id: number) => {
7676
export const cleanModel = async (id: number) => {
7777
return await request.delete({ url: '/bpm/model/clean?id=' + id })
7878
}
79+
/**
80+
* 查询当前流程实例下是否存在正在进行中的单据
81+
* @param processDefinitionId 流程定义id
82+
* @returns true/false
83+
*/
84+
export const getProcessInstance = async (processDefinitionId: string) => {
85+
return await request.get({
86+
url: '/bpm/task/manager-list?processDefinitionId=' + processDefinitionId
87+
})
88+
}

src/views/bpm/model/CategoryDraggableModel.vue

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
<el-button
160160
link
161161
type="primary"
162-
@click="openModelForm('update', scope.row.id)"
162+
@click="openModelForm('update', scope.row.id, scope.row.processDefinition.id)"
163163
v-if="hasPermiUpdate"
164164
:disabled="!isManagerUser(scope.row)"
165165
>
@@ -445,11 +445,17 @@ const handleChangeState = async (row: any) => {
445445
/** 发布流程 */
446446
const handleDeploy = async (row: any) => {
447447
try {
448-
// 删除的二次确认
449-
await message.confirm('是否部署该流程!!')
448+
// 发布的二次确认
449+
await message.confirm('是否发布该流程!!')
450+
//校验当前版本的流程下是否存在正在进行中的单据
451+
const res = await ModelApi.getProcessInstance(row.processDefinition.id)
452+
if (res) {
453+
message.error('当前版本下存在正在进行中的单据,请先结束单据后再发布')
454+
return
455+
}
450456
// 发起部署
451457
await ModelApi.deployModel(row.id)
452-
message.success(t('部署成功'))
458+
message.success(t('发布成功'))
453459
// 刷新列表
454460
emit('success')
455461
} catch {}
@@ -587,7 +593,8 @@ const handleDeleteCategory = async () => {
587593
588594
/** 添加流程模型弹窗 */
589595
const tagsView = useTagsView()
590-
const openModelForm = async (type: string, id?: number) => {
596+
const openModelForm = async (type: string, id?: number, processDefinitionId?: string) => {
597+
alert(processDefinitionId)
591598
if (type === 'create') {
592599
await push({ name: 'BpmModelCreate' })
593600
} else {

src/views/bpm/model/form/index.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ const formData: any = ref({
162162
summarySetting: {
163163
enable: false,
164164
summary: []
165-
}
165+
},
166+
processDefinitionId: undefined
166167
})
167168
168169
//流程数据
@@ -285,17 +286,16 @@ const handleSave = async () => {
285286
} else {
286287
// 新增场景
287288
formData.value.id = await ModelApi.createModel(modelData)
288-
message.success('新增成功')
289289
try {
290-
await message.confirm('创建流程成功,是否继续编辑?')
290+
await message.confirm('流程创建成功,是否继续编辑?')
291291
// 用户点击继续编辑,跳转到编辑页面
292292
await nextTick()
293293
// 先删除当前页签
294294
delView(unref(router.currentRoute))
295295
// 跳转到编辑页面
296296
await router.push({
297297
name: 'BpmModelUpdate',
298-
params: { id: formData.value.id }
298+
params: { id: formData.value.id, processDefinitionId: formData.value.processDefinitionId }
299299
})
300300
} catch {
301301
// 先删除当前页签
@@ -318,6 +318,13 @@ const handleDeploy = async () => {
318318
await message.confirm('是否确认发布该流程?')
319319
}
320320
321+
//校验当前版本的流程下是否存在正在进行中的单据
322+
const res = await ModelApi.getProcessInstance(row.processDefinition.id)
323+
if (res) {
324+
message.error('当前版本下存在正在进行中的单据,请先结束单据后再发布')
325+
return
326+
}
327+
321328
// 校验所有步骤
322329
await validateAllSteps()
323330
@@ -345,6 +352,11 @@ const handleDeploy = async () => {
345352
}
346353
}
347354
355+
const validateProcessInstance = async (processDefinitionId) => {
356+
const valid = await ModelApi.getProcessInstance(processDefinitionId)
357+
console.log(valid)
358+
}
359+
348360
/** 步骤切换处理 */
349361
const handleStepClick = async (index: number) => {
350362
try {

0 commit comments

Comments
 (0)