BPM:新增流程的重新发起

This commit is contained in:
YunaiV 2024-03-21 00:34:10 +08:00
parent 0d4b6f6344
commit 05b408d107
3 changed files with 49 additions and 19 deletions

View File

@ -243,7 +243,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
},
children: [
{
path: '/manager/form/edit',
path: 'manager/form/edit',
component: () => import('@/views/bpm/form/editor/index.vue'),
name: 'BpmFormEditor',
meta: {
@ -255,7 +255,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
},
{
path: '/manager/model/edit',
path: 'manager/model/edit',
component: () => import('@/views/bpm/model/editor/index.vue'),
name: 'BpmModelEditor',
meta: {
@ -267,7 +267,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
},
{
path: '/manager/simple/workflow/model/edit',
path: 'manager/simple/workflow/model/edit',
component: () => import('@/views/bpm/simpleWorkflow/index.vue'),
name: 'SimpleWorkflowDesignEditor',
meta: {
@ -279,7 +279,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
},
{
path: '/manager/definition',
path: 'manager/definition',
component: () => import('@/views/bpm/definition/index.vue'),
name: 'BpmProcessDefinition',
meta: {
@ -291,7 +291,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
},
{
path: '/process-instance/detail',
path: 'process-instance/detail',
component: () => import('@/views/bpm/processInstance/detail/index.vue'),
name: 'BpmProcessInstanceDetail',
meta: {
@ -299,11 +299,11 @@ const remainingRouter: AppRouteRecordRaw[] = [
hidden: true,
canTo: true,
title: '流程详情',
activeMenu: 'bpm/processInstance/detail'
activeMenu: '/bpm/task/my'
}
},
{
path: '/bpm/oa/leave/create',
path: 'oa/leave/create',
component: () => import('@/views/bpm/oa/leave/create.vue'),
name: 'OALeaveCreate',
meta: {
@ -315,7 +315,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
}
},
{
path: '/bpm/oa/leave/detail',
path: 'oa/leave/detail',
component: () => import('@/views/bpm/oa/leave/detail.vue'),
name: 'OALeaveDetail',
meta: {

View File

@ -51,6 +51,7 @@
<form-create
:rule="detailForm.rule"
v-model:api="fApi"
v-model="detailForm.value"
:option="detailForm.option"
@submit="submitForm"
/>
@ -67,12 +68,16 @@ import { setConfAndFields2 } from '@/utils/formCreate'
import type { ApiAttrs } from '@form-create/element-ui/types/config'
import ProcessInstanceBpmnViewer from '../detail/ProcessInstanceBpmnViewer.vue'
import { CategoryApi } from '@/api/bpm/category'
import { useTagsViewStore } from '@/store/modules/tagsView'
defineOptions({ name: 'BpmProcessInstanceCreate' })
const router = useRouter() //
const route = useRoute() //
const { push, currentRoute } = useRouter() //
const message = useMessage() //
const { delView } = useTagsViewStore() //
const processInstanceId = route.query.processInstanceId
const loading = ref(true) //
const categoryList = ref([]) //
const categoryActive = ref('') //
@ -91,6 +96,23 @@ const getList = async () => {
processDefinitionList.value = await DefinitionApi.getProcessDefinitionList({
suspensionState: 1
})
// processInstanceId
if (processInstanceId?.length > 0) {
const processInstance = await ProcessInstanceApi.getProcessInstance(processInstanceId)
if (!processInstance) {
message.error('重新发起流程失败,原因:流程实例不存在')
return
}
const processDefinition = processDefinitionList.value.find(
(item) => item.key == processInstance.processDefinition?.key
)
if (!processDefinition) {
message.error('重新发起流程失败,原因:流程定义不存在')
return
}
await handleSelect(processDefinition, processInstance.formVariables)
}
} finally {
loading.value = false
}
@ -105,26 +127,26 @@ const categoryProcessDefinitionList = computed(() => {
const bpmnXML = ref(null) // BPMN
const fApi = ref<ApiAttrs>()
const detailForm = ref({
//
rule: [],
option: {}
})
option: {},
value: {}
}) //
const selectProcessDefinition = ref() //
/** 处理选择流程的按钮操作 **/
const handleSelect = async (row) => {
const handleSelect = async (row, formVariables) => {
//
selectProcessDefinition.value = row
//
if (row.formType == 10) {
//
setConfAndFields2(detailForm, row.formConf, row.formFields)
setConfAndFields2(detailForm, row.formConf, row.formFields, formVariables)
//
bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(row.id)
//
} else if (row.formCustomCreatePath) {
await router.push({
await push({
path: row.formCustomCreatePath
})
// Tab
@ -145,7 +167,11 @@ const submitForm = async (formData) => {
})
//
message.success('发起流程成功')
router.go(-1)
//
delView(unref(currentRoute))
await push({
name: 'BpmProcessInstance'
})
} finally {
fApi.value.btn.loading(false)
}

View File

@ -76,7 +76,7 @@
type="primary"
plain
v-hasPermi="['bpm:process-instance:query']"
@click="handleCreate"
@click="handleCreate()"
>
<Icon icon="ep:plus" class="mr-5px" /> 发起流程
</el-button>
@ -135,6 +135,9 @@
>
取消
</el-button>
<el-button link type="primary" v-else @click="handleCreate(scope.row.id)">
重新发起
</el-button>
</template>
</el-table-column>
</el-table>
@ -200,9 +203,10 @@ const resetQuery = () => {
}
/** 发起流程操作 **/
const handleCreate = () => {
const handleCreate = (id) => {
router.push({
name: 'BpmProcessInstanceCreate'
name: 'BpmProcessInstanceCreate',
query: { processInstanceId: id }
})
}