Skip to content

Commit a26cb12

Browse files
committed
【功能新增】BPM:支持通过“历史”进行恢复
1 parent 2a73b9c commit a26cb12

File tree

4 files changed

+78
-46
lines changed

4 files changed

+78
-46
lines changed

src/api/bpm/model/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export const getModelList = async (name: string | undefined) => {
3131
}
3232

3333
export const getModel = async (id: string) => {
34+
debugger
3435
return await request.get({ url: '/bpm/model/get?id=' + id })
3536
}
3637

src/views/bpm/model/CategoryDraggableModel.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ import { checkPermi } from '@/utils/permission'
277277
import { useUserStoreWithOut } from '@/store/modules/user'
278278
import { useAppStore } from '@/store/modules/app'
279279
import { cloneDeep, isEqual } from 'lodash-es'
280-
import { useTagsView } from '@/hooks/web/useTagsView'
281280
import { useDebounceFn } from '@vueuse/core'
282281
import { subString } from '@/utils/index'
283282
@@ -589,8 +588,7 @@ const handleDeleteCategory = async () => {
589588
} catch {}
590589
}
591590
592-
/** 添加流程模型弹窗 */
593-
const tagsView = useTagsView()
591+
/** 添加/修改/复制流程模型弹窗 */
594592
const openModelForm = async (type: string, id?: number) => {
595593
if (type === 'create') {
596594
await push({ name: 'BpmModelCreate' })
@@ -599,10 +597,6 @@ const openModelForm = async (type: string, id?: number) => {
599597
name: 'BpmModelUpdate',
600598
params: { id, type }
601599
})
602-
// 设置标题
603-
if (type === 'copy') {
604-
tagsView.setTitle('复制流程')
605-
}
606600
}
607601
}
608602

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@
6666
width="180"
6767
:formatter="dateFormatter"
6868
/>
69+
<el-table-column label="操作" align="center">
70+
<template #default="scope">
71+
<el-button
72+
link
73+
type="primary"
74+
@click="openModelForm(scope.row.id)"
75+
v-hasPermi="['bpm:model:update']"
76+
>
77+
恢复
78+
</el-button>
79+
</template>
80+
</el-table-column>
6981
</el-table>
7082
<!-- 分页 -->
7183
<Pagination
@@ -134,6 +146,14 @@ const handleFormDetail = async (row: any) => {
134146
}
135147
}
136148
149+
/** 恢复流程模型弹窗 */
150+
const openModelForm = async (id?: number) => {
151+
await push({
152+
name: 'BpmModelUpdate',
153+
params: { id, type: 'definition' }
154+
})
155+
}
156+
137157
/** 初始化 **/
138158
onMounted(() => {
139159
getList()

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

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@
4444

4545
<!-- 右侧按钮 -->
4646
<div class="w-200px flex items-center justify-end gap-2">
47-
<el-button v-if="route.params.id" type="success" @click="handleDeploy">发 布</el-button>
48-
<el-button type="primary" @click="handleSave">保 存</el-button>
47+
<el-button v-if="actionType === 'update'" type="success" @click="handleDeploy">
48+
发 布
49+
</el-button>
50+
<el-button type="primary" @click="handleSave">
51+
<span v-if="actionType === 'definition'">恢 复</span>
52+
<span v-else>保 存</span>
53+
</el-button>
4954
</div>
5055
</div>
5156

@@ -81,20 +86,23 @@
8186
<script lang="ts" setup>
8287
import { useRoute, useRouter } from 'vue-router'
8388
import { useMessage } from '@/hooks/web/useMessage'
89+
import { useTagsViewStore } from '@/store/modules/tagsView'
90+
import { useUserStoreWithOut } from '@/store/modules/user'
8491
import * as ModelApi from '@/api/bpm/model'
8592
import * as FormApi from '@/api/bpm/form'
8693
import { CategoryApi, CategoryVO } from '@/api/bpm/category'
8794
import * as UserApi from '@/api/system/user'
88-
import { useUserStoreWithOut } from '@/store/modules/user'
95+
import * as DefinitionApi from '@/api/bpm/definition'
8996
import { BpmModelFormType, BpmModelType, BpmAutoApproveType } from '@/utils/constants'
9097
import BasicInfo from './BasicInfo.vue'
9198
import FormDesign from './FormDesign.vue'
9299
import ProcessDesign from './ProcessDesign.vue'
93-
import { useTagsViewStore } from '@/store/modules/tagsView'
94100
import ExtraSettings from './ExtraSettings.vue'
101+
import { useTagsView } from '@/hooks/web/useTagsView'
95102
96103
const router = useRouter()
97104
const { delView } = useTagsViewStore() // 视图操作
105+
const tagsView = useTagsView()
98106
const route = useRoute()
99107
const message = useMessage()
100108
const userStore = useUserStoreWithOut()
@@ -165,7 +173,7 @@ const formData: any = ref({
165173
}
166174
})
167175
168-
//流程数据
176+
// 流程数据
169177
const processData = ref<any>()
170178
171179
provide('processData', processData)
@@ -177,20 +185,36 @@ const categoryList = ref<CategoryVO[]>([])
177185
const userList = ref<UserApi.UserVO[]>([])
178186
179187
/** 初始化数据 */
188+
const actionType = route.params.type as string
180189
const initData = async () => {
181-
const modelId = route.params.id as string
182-
if (modelId) {
183-
// 修改场景
190+
if (actionType === 'definition') {
191+
// 情况一:流程定义场景(恢复)
192+
const definitionId = route.params.id as string
193+
const data = await DefinitionApi.getProcessDefinition(definitionId)
194+
// 将 definition => model,最终赋值
195+
data.type = data.modelType
196+
delete data.modelType
197+
data.id = data.modelId
198+
delete data.modelId
199+
if (data.simpleModel) {
200+
data.simpleModel = JSON.parse(data.simpleModel)
201+
}
202+
formData.value = data
203+
formData.value.startUserType = formData.value.startUserIds?.length > 0 ? 1 : 0
204+
} else if (['update', 'copy'].includes(actionType)) {
205+
// 情况二:修改场景/复制场景
206+
const modelId = route.params.id as string
184207
formData.value = await ModelApi.getModel(modelId)
185208
formData.value.startUserType = formData.value.startUserIds?.length > 0 ? 1 : 0
186-
// 复制场景
187-
if (route.params.type === 'copy') {
209+
// 特殊:复制场景
210+
if (actionType === 'copy') {
188211
delete formData.value.id
189212
formData.value.name += '副本'
190213
formData.value.key += '_copy'
214+
tagsView.setTitle('复制流程')
191215
}
192216
} else {
193-
// 新增场景
217+
// 情况三:新增场景
194218
formData.value.startUserType = 0 // 全体
195219
formData.value.managerUserIds.push(userStore.getUser.id)
196220
}
@@ -271,37 +295,31 @@ const handleSave = async () => {
271295
...formData.value
272296
}
273297
274-
if (formData.value.id) {
298+
if (actionType === 'definition') {
299+
// 情况一:流程定义场景(恢复)
300+
await ModelApi.updateModel(modelData)
301+
// 提示成功
302+
message.success('恢复成功,可点击【发布】按钮,进行发布模型')
303+
} else if (actionType === 'update') {
275304
// 修改场景
276305
await ModelApi.updateModel(modelData)
277-
// 询问是否发布流程
278-
try {
279-
await message.confirm('修改流程成功,是否发布流程?')
280-
// 用户点击确认,执行发布
281-
await handleDeploy()
282-
} catch {
283-
// 用户点击取消,停留在当前页面
284-
}
306+
// 提示成功
307+
message.success('修改成功,可点击【发布】按钮,进行发布模型')
308+
} else if (actionType === 'copy') {
309+
// 情况三:复制场景
310+
formData.value.id = await ModelApi.createModel(modelData)
311+
// 提示成功
312+
message.success('复制成功,可点击【发布】按钮,进行发布模型')
285313
} else {
286-
// 新增场景
314+
// 情况四:新增场景
287315
formData.value.id = await ModelApi.createModel(modelData)
288-
try {
289-
await message.confirm('流程创建成功,是否继续编辑?')
290-
// 用户点击继续编辑,跳转到编辑页面
291-
await nextTick()
292-
// 先删除当前页签
293-
delView(unref(router.currentRoute))
294-
// 跳转到编辑页面
295-
await router.push({
296-
name: 'BpmModelUpdate',
297-
params: { id: formData.value.id }
298-
})
299-
} catch {
300-
// 先删除当前页签
301-
delView(unref(router.currentRoute))
302-
// 用户点击返回列表
303-
await router.push({ name: 'BpmModel' })
304-
}
316+
// 提示成功
317+
message.success('新建成功,可点击【发布】按钮,进行发布模型')
318+
}
319+
320+
// 返回列表页(排除更新的情况)
321+
if (actionType !== 'update') {
322+
await router.push({ name: 'BpmModel' })
305323
}
306324
} catch (error: any) {
307325
console.error('保存失败:', error)
@@ -346,7 +364,6 @@ const handleDeploy = async () => {
346364
/** 步骤切换处理 */
347365
const handleStepClick = async (index: number) => {
348366
try {
349-
console.log('index', index)
350367
if (index !== 0) {
351368
await validateBasic()
352369
}

0 commit comments

Comments
 (0)