feat: 发布流程时校验当前流程版本是否存在正在进行中的单据

This commit is contained in:
lizhixian 2025-02-11 17:16:25 +08:00
parent 85c6971132
commit 1b0fe23292
3 changed files with 38 additions and 9 deletions

View File

@ -76,3 +76,13 @@ export const deployModel = async (id: number) => {
export const cleanModel = async (id: number) => { export const cleanModel = async (id: number) => {
return await request.delete({ url: '/bpm/model/clean?id=' + id }) return await request.delete({ url: '/bpm/model/clean?id=' + id })
} }
/**
*
* @param processDefinitionId id
* @returns true/false
*/
export const getProcessInstance = async (processDefinitionId: string) => {
return await request.get({
url: '/bpm/task/manager-list?processDefinitionId=' + processDefinitionId
})
}

View File

@ -159,7 +159,7 @@
<el-button <el-button
link link
type="primary" type="primary"
@click="openModelForm('update', scope.row.id)" @click="openModelForm('update', scope.row.id, scope.row.processDefinition.id)"
v-if="hasPermiUpdate" v-if="hasPermiUpdate"
:disabled="!isManagerUser(scope.row)" :disabled="!isManagerUser(scope.row)"
> >
@ -445,11 +445,17 @@ const handleChangeState = async (row: any) => {
/** 发布流程 */ /** 发布流程 */
const handleDeploy = async (row: any) => { const handleDeploy = async (row: any) => {
try { try {
// //
await message.confirm('是否部署该流程!!') await message.confirm('是否发布该流程!!')
//
const res = await ModelApi.getProcessInstance(row.processDefinition.id)
if (res) {
message.error('当前版本下存在正在进行中的单据,请先结束单据后再发布')
return
}
// //
await ModelApi.deployModel(row.id) await ModelApi.deployModel(row.id)
message.success(t('部署成功')) message.success(t('发布成功'))
// //
emit('success') emit('success')
} catch {} } catch {}
@ -587,7 +593,8 @@ const handleDeleteCategory = async () => {
/** 添加流程模型弹窗 */ /** 添加流程模型弹窗 */
const tagsView = useTagsView() const tagsView = useTagsView()
const openModelForm = async (type: string, id?: number) => { const openModelForm = async (type: string, id?: number, processDefinitionId?: string) => {
alert(processDefinitionId)
if (type === 'create') { if (type === 'create') {
await push({ name: 'BpmModelCreate' }) await push({ name: 'BpmModelCreate' })
} else { } else {

View File

@ -162,7 +162,8 @@ const formData: any = ref({
summarySetting: { summarySetting: {
enable: false, enable: false,
summary: [] summary: []
} },
processDefinitionId: undefined
}) })
// //
@ -285,9 +286,8 @@ const handleSave = async () => {
} else { } else {
// //
formData.value.id = await ModelApi.createModel(modelData) formData.value.id = await ModelApi.createModel(modelData)
message.success('新增成功')
try { try {
await message.confirm('创建流程成功,是否继续编辑?') await message.confirm('流程创建成功,是否继续编辑?')
// //
await nextTick() await nextTick()
// //
@ -295,7 +295,7 @@ const handleSave = async () => {
// //
await router.push({ await router.push({
name: 'BpmModelUpdate', name: 'BpmModelUpdate',
params: { id: formData.value.id } params: { id: formData.value.id, processDefinitionId: formData.value.processDefinitionId }
}) })
} catch { } catch {
// //
@ -318,6 +318,13 @@ const handleDeploy = async () => {
await message.confirm('是否确认发布该流程?') await message.confirm('是否确认发布该流程?')
} }
//
const res = await ModelApi.getProcessInstance(row.processDefinition.id)
if (res) {
message.error('当前版本下存在正在进行中的单据,请先结束单据后再发布')
return
}
// //
await validateAllSteps() await validateAllSteps()
@ -345,6 +352,11 @@ const handleDeploy = async () => {
} }
} }
const validateProcessInstance = async (processDefinitionId) => {
const valid = await ModelApi.getProcessInstance(processDefinitionId)
console.log(valid)
}
/** 步骤切换处理 */ /** 步骤切换处理 */
const handleStepClick = async (index: number) => { const handleStepClick = async (index: number) => {
try { try {