2023-02-11 00:44:00 +08:00
|
|
|
|
<template>
|
2023-03-28 08:10:11 +08:00
|
|
|
|
<!-- 第一步,通过流程定义的列表,选择对应的流程 -->
|
2024-11-02 10:52:31 +08:00
|
|
|
|
<ContentWrap
|
|
|
|
|
class="process-definition-container position-relative pb-20px"
|
|
|
|
|
v-if="!selectProcessDefinition"
|
|
|
|
|
v-loading="loading"
|
|
|
|
|
>
|
|
|
|
|
<el-row :gutter="20" class="!flex-nowrap">
|
|
|
|
|
<el-col :span="5">
|
|
|
|
|
<div class="flex flex-col">
|
|
|
|
|
<div
|
|
|
|
|
v-for="category in categoryList"
|
|
|
|
|
:key="category.code"
|
|
|
|
|
class="flex items-center p-10px cursor-pointer text-14px rounded-md"
|
|
|
|
|
:class="categoryActive.code === category.code ? 'text-#3e7bff bg-#e8eeff' : ''"
|
|
|
|
|
@click="handleCategoryClick(category)"
|
|
|
|
|
>
|
|
|
|
|
{{ category.name }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="19">
|
|
|
|
|
<h3 class="text-16px font-bold mb-10px mt-5px">{{ categoryActive.name }}</h3>
|
|
|
|
|
<div class="grid grid-cols-3 gap3" v-if="categoryProcessDefinitionList.length">
|
|
|
|
|
<el-card
|
2024-03-19 19:49:52 +08:00
|
|
|
|
v-for="definition in categoryProcessDefinitionList"
|
|
|
|
|
:key="definition.id"
|
2024-11-02 10:52:31 +08:00
|
|
|
|
shadow="hover"
|
|
|
|
|
class="cursor-pointer definition-item-card"
|
|
|
|
|
@click="handleSelect(definition)"
|
2024-03-19 19:49:52 +08:00
|
|
|
|
>
|
2024-11-02 10:52:31 +08:00
|
|
|
|
<template #default>
|
|
|
|
|
<div class="flex">
|
|
|
|
|
<el-image :src="definition.icon" class="w-32px h-32px" />
|
|
|
|
|
<el-text class="!ml-10px" size="large">{{ definition.name }}</el-text>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</el-card>
|
|
|
|
|
</div>
|
|
|
|
|
<el-empty v-else />
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
2023-03-28 08:10:11 +08:00
|
|
|
|
</ContentWrap>
|
|
|
|
|
|
|
|
|
|
<!-- 第二步,填写表单,进行流程的提交 -->
|
2024-11-02 10:52:31 +08:00
|
|
|
|
<ProcessDefinitionDetail
|
|
|
|
|
v-else
|
|
|
|
|
ref="processDefinitionDetailRef"
|
|
|
|
|
:selectProcessDefinition="selectProcessDefinition"
|
|
|
|
|
@cancel="selectProcessDefinition = undefined"
|
|
|
|
|
/>
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</template>
|
2024-11-02 10:52:31 +08:00
|
|
|
|
|
2023-06-21 19:35:11 +08:00
|
|
|
|
<script lang="ts" setup>
|
2023-02-11 00:44:00 +08:00
|
|
|
|
import * as DefinitionApi from '@/api/bpm/definition'
|
|
|
|
|
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
|
2024-03-19 19:49:52 +08:00
|
|
|
|
import { CategoryApi } from '@/api/bpm/category'
|
2024-11-02 10:52:31 +08:00
|
|
|
|
import ProcessDefinitionDetail from './ProcessDefinitionDetail.vue'
|
2023-06-21 19:14:34 +08:00
|
|
|
|
|
|
|
|
|
defineOptions({ name: 'BpmProcessInstanceCreate' })
|
|
|
|
|
|
2024-03-21 00:34:10 +08:00
|
|
|
|
const route = useRoute() // 路由
|
2023-02-11 00:44:00 +08:00
|
|
|
|
const message = useMessage() // 消息
|
|
|
|
|
|
2024-11-02 10:52:31 +08:00
|
|
|
|
const processInstanceId: any = route.query.processInstanceId
|
2024-03-19 19:49:52 +08:00
|
|
|
|
const loading = ref(true) // 加载中
|
2024-11-02 10:52:31 +08:00
|
|
|
|
const categoryList: any = ref([]) // 分类的列表
|
|
|
|
|
const categoryActive: any = ref({}) // 选中的分类
|
2024-03-19 19:49:52 +08:00
|
|
|
|
const processDefinitionList = ref([]) // 流程定义的列表
|
2023-03-28 08:10:11 +08:00
|
|
|
|
/** 查询列表 */
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
2024-03-19 19:49:52 +08:00
|
|
|
|
// 流程分类
|
|
|
|
|
categoryList.value = await CategoryApi.getCategorySimpleList()
|
|
|
|
|
if (categoryList.value.length > 0) {
|
2024-11-02 10:52:31 +08:00
|
|
|
|
categoryActive.value = categoryList.value[0]
|
2024-03-19 19:49:52 +08:00
|
|
|
|
}
|
|
|
|
|
// 流程定义
|
|
|
|
|
processDefinitionList.value = await DefinitionApi.getProcessDefinitionList({
|
|
|
|
|
suspensionState: 1
|
|
|
|
|
})
|
2024-03-21 00:34:10 +08:00
|
|
|
|
|
|
|
|
|
// 如果 processInstanceId 非空,说明是重新发起
|
|
|
|
|
if (processInstanceId?.length > 0) {
|
|
|
|
|
const processInstance = await ProcessInstanceApi.getProcessInstance(processInstanceId)
|
|
|
|
|
if (!processInstance) {
|
|
|
|
|
message.error('重新发起流程失败,原因:流程实例不存在')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const processDefinition = processDefinitionList.value.find(
|
2024-11-02 10:52:31 +08:00
|
|
|
|
(item: any) => item.key == processInstance.processDefinition?.key
|
2024-03-21 00:34:10 +08:00
|
|
|
|
)
|
|
|
|
|
if (!processDefinition) {
|
|
|
|
|
message.error('重新发起流程失败,原因:流程定义不存在')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
await handleSelect(processDefinition, processInstance.formVariables)
|
|
|
|
|
}
|
2023-03-28 08:10:11 +08:00
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
2024-03-19 19:49:52 +08:00
|
|
|
|
/** 选中分类对应的流程定义列表 */
|
2024-11-02 10:52:31 +08:00
|
|
|
|
const categoryProcessDefinitionList: any = computed(() => {
|
|
|
|
|
return processDefinitionList.value.filter(
|
|
|
|
|
(item: any) => item.category == categoryActive.value.code
|
|
|
|
|
)
|
2024-03-19 19:49:52 +08:00
|
|
|
|
})
|
|
|
|
|
|
2023-03-28 08:10:11 +08:00
|
|
|
|
// ========== 表单相关 ==========
|
2024-03-19 19:49:52 +08:00
|
|
|
|
const selectProcessDefinition = ref() // 选择的流程定义
|
2024-11-02 10:52:31 +08:00
|
|
|
|
const processDefinitionDetailRef = ref()
|
2024-03-23 00:54:33 +08:00
|
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
|
/** 处理选择流程的按钮操作 **/
|
2024-11-02 10:52:31 +08:00
|
|
|
|
const handleSelect = async (row, formVariables?) => {
|
2023-02-11 00:44:00 +08:00
|
|
|
|
// 设置选择的流程
|
2024-03-19 19:49:52 +08:00
|
|
|
|
selectProcessDefinition.value = row
|
2024-11-02 10:52:31 +08:00
|
|
|
|
// 初始化流程定义详情
|
|
|
|
|
await nextTick()
|
|
|
|
|
processDefinitionDetailRef.value?.initProcessInfo(row, formVariables)
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
2024-11-02 10:52:31 +08:00
|
|
|
|
// 左侧分类切换
|
|
|
|
|
const handleCategoryClick = (val: number) => {
|
|
|
|
|
categoryActive.value = val
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-28 08:10:11 +08:00
|
|
|
|
/** 初始化 */
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
getList()
|
|
|
|
|
})
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</script>
|
2024-11-02 10:52:31 +08:00
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.process-definition-container::before {
|
|
|
|
|
content: '';
|
|
|
|
|
border-left: 1px solid #e6e6e6;
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 20.8%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
:deep() {
|
|
|
|
|
.definition-item-card {
|
|
|
|
|
.el-card__body {
|
|
|
|
|
padding: 14px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|