【功能新增】BPM:支持通过“历史”进行恢复

This commit is contained in:
YunaiV 2025-03-02 09:56:44 +08:00
parent 2a73b9c4fc
commit a26cb120d1
4 changed files with 79 additions and 47 deletions

View File

@ -31,6 +31,7 @@ export const getModelList = async (name: string | undefined) => {
}
export const getModel = async (id: string) => {
debugger
return await request.get({ url: '/bpm/model/get?id=' + id })
}

View File

@ -277,7 +277,6 @@ import { checkPermi } from '@/utils/permission'
import { useUserStoreWithOut } from '@/store/modules/user'
import { useAppStore } from '@/store/modules/app'
import { cloneDeep, isEqual } from 'lodash-es'
import { useTagsView } from '@/hooks/web/useTagsView'
import { useDebounceFn } from '@vueuse/core'
import { subString } from '@/utils/index'
@ -589,8 +588,7 @@ const handleDeleteCategory = async () => {
} catch {}
}
/** 添加流程模型弹窗 */
const tagsView = useTagsView()
/** 添加/修改/复制流程模型弹窗 */
const openModelForm = async (type: string, id?: number) => {
if (type === 'create') {
await push({ name: 'BpmModelCreate' })
@ -599,10 +597,6 @@ const openModelForm = async (type: string, id?: number) => {
name: 'BpmModelUpdate',
params: { id, type }
})
//
if (type === 'copy') {
tagsView.setTitle('复制流程')
}
}
}

View File

@ -66,6 +66,18 @@
width="180"
:formatter="dateFormatter"
/>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
link
type="primary"
@click="openModelForm(scope.row.id)"
v-hasPermi="['bpm:model:update']"
>
恢复
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
@ -134,6 +146,14 @@ const handleFormDetail = async (row: any) => {
}
}
/** 恢复流程模型弹窗 */
const openModelForm = async (id?: number) => {
await push({
name: 'BpmModelUpdate',
params: { id, type: 'definition' }
})
}
/** 初始化 **/
onMounted(() => {
getList()

View File

@ -44,8 +44,13 @@
<!-- 右侧按钮 -->
<div class="w-200px flex items-center justify-end gap-2">
<el-button v-if="route.params.id" type="success" @click="handleDeploy"> </el-button>
<el-button type="primary" @click="handleSave"> </el-button>
<el-button v-if="actionType === 'update'" type="success" @click="handleDeploy">
</el-button>
<el-button type="primary" @click="handleSave">
<span v-if="actionType === 'definition'"> </span>
<span v-else> </span>
</el-button>
</div>
</div>
@ -81,20 +86,23 @@
<script lang="ts" setup>
import { useRoute, useRouter } from 'vue-router'
import { useMessage } from '@/hooks/web/useMessage'
import { useTagsViewStore } from '@/store/modules/tagsView'
import { useUserStoreWithOut } from '@/store/modules/user'
import * as ModelApi from '@/api/bpm/model'
import * as FormApi from '@/api/bpm/form'
import { CategoryApi, CategoryVO } from '@/api/bpm/category'
import * as UserApi from '@/api/system/user'
import { useUserStoreWithOut } from '@/store/modules/user'
import * as DefinitionApi from '@/api/bpm/definition'
import { BpmModelFormType, BpmModelType, BpmAutoApproveType } from '@/utils/constants'
import BasicInfo from './BasicInfo.vue'
import FormDesign from './FormDesign.vue'
import ProcessDesign from './ProcessDesign.vue'
import { useTagsViewStore } from '@/store/modules/tagsView'
import ExtraSettings from './ExtraSettings.vue'
import { useTagsView } from '@/hooks/web/useTagsView'
const router = useRouter()
const { delView } = useTagsViewStore() //
const tagsView = useTagsView()
const route = useRoute()
const message = useMessage()
const userStore = useUserStoreWithOut()
@ -165,7 +173,7 @@ const formData: any = ref({
}
})
//
//
const processData = ref<any>()
provide('processData', processData)
@ -177,20 +185,36 @@ const categoryList = ref<CategoryVO[]>([])
const userList = ref<UserApi.UserVO[]>([])
/** 初始化数据 */
const actionType = route.params.type as string
const initData = async () => {
const modelId = route.params.id as string
if (modelId) {
//
if (actionType === 'definition') {
//
const definitionId = route.params.id as string
const data = await DefinitionApi.getProcessDefinition(definitionId)
// definition => model
data.type = data.modelType
delete data.modelType
data.id = data.modelId
delete data.modelId
if (data.simpleModel) {
data.simpleModel = JSON.parse(data.simpleModel)
}
formData.value = data
formData.value.startUserType = formData.value.startUserIds?.length > 0 ? 1 : 0
} else if (['update', 'copy'].includes(actionType)) {
// /
const modelId = route.params.id as string
formData.value = await ModelApi.getModel(modelId)
formData.value.startUserType = formData.value.startUserIds?.length > 0 ? 1 : 0
//
if (route.params.type === 'copy') {
//
if (actionType === 'copy') {
delete formData.value.id
formData.value.name += '副本'
formData.value.key += '_copy'
tagsView.setTitle('复制流程')
}
} else {
//
//
formData.value.startUserType = 0 //
formData.value.managerUserIds.push(userStore.getUser.id)
}
@ -271,37 +295,31 @@ const handleSave = async () => {
...formData.value
}
if (formData.value.id) {
if (actionType === 'definition') {
//
await ModelApi.updateModel(modelData)
//
message.success('恢复成功,可点击【发布】按钮,进行发布模型')
} else if (actionType === 'update') {
//
await ModelApi.updateModel(modelData)
//
try {
await message.confirm('修改流程成功,是否发布流程?')
//
await handleDeploy()
} catch {
//
}
} else {
//
//
message.success('修改成功,可点击【发布】按钮,进行发布模型')
} else if (actionType === 'copy') {
//
formData.value.id = await ModelApi.createModel(modelData)
try {
await message.confirm('流程创建成功,是否继续编辑?')
//
await nextTick()
//
delView(unref(router.currentRoute))
//
await router.push({
name: 'BpmModelUpdate',
params: { id: formData.value.id }
})
} catch {
//
delView(unref(router.currentRoute))
//
await router.push({ name: 'BpmModel' })
}
//
message.success('复制成功,可点击【发布】按钮,进行发布模型')
} else {
//
formData.value.id = await ModelApi.createModel(modelData)
//
message.success('新建成功,可点击【发布】按钮,进行发布模型')
}
//
if (actionType !== 'update') {
await router.push({ name: 'BpmModel' })
}
} catch (error: any) {
console.error('保存失败:', error)
@ -346,7 +364,6 @@ const handleDeploy = async () => {
/** 步骤切换处理 */
const handleStepClick = async (index: number) => {
try {
console.log('index', index)
if (index !== 0) {
await validateBasic()
}