feat: 【BPM 工作流】完善操作按钮、流程签名组件

This commit is contained in:
子夜
2025-05-24 15:10:03 +08:00
parent 66ac3de5c1
commit 01f929e10f
18 changed files with 1962 additions and 91 deletions

View File

@@ -7,16 +7,7 @@ import { nextTick, onMounted, ref, shallowRef, watch } from 'vue';
import { Page } from '@vben/common-ui';
import { formatDateTime } from '@vben/utils';
import {
Avatar,
Button,
Card,
Col,
message,
Row,
TabPane,
Tabs,
} from 'ant-design-vue';
import { Avatar, Card, Col, message, Row, TabPane, Tabs } from 'ant-design-vue';
import {
getApprovalDetail as getApprovalDetailApi,
@@ -39,6 +30,9 @@ import {
SvgBpmRunningIcon,
} from '#/views/bpm/processInstance/detail/modules/icons';
import ProcessInstanceBpmnViewer from './modules/bpm-viewer.vue';
import ProcessInstanceOperationButton from './modules/operation-button.vue';
import ProcessInstanceSimpleViewer from './modules/simple-bpm-viewer.vue';
import BpmProcessInstanceTaskList from './modules/task-list.vue';
import ProcessInstanceTimeline from './modules/time-line.vue';
@@ -72,7 +66,7 @@ const processInstanceLoading = ref(false); // 流程实例的加载中
const processInstance = ref<BpmProcessInstanceApi.ProcessInstanceVO>(); // 流程实例
const processDefinition = ref<any>({}); // 流程定义
const processModelView = ref<any>({}); // 流程模型视图
// const operationButtonRef = ref(); // 操作按钮组件 ref
const operationButtonRef = ref(); // 操作按钮组件 ref
const auditIconsMap: {
[key: string]:
| typeof SvgBpmApproveIcon
@@ -162,6 +156,7 @@ async function getApprovalDetail() {
});
} else {
// 注意data.processDefinition.formCustomViewPath 是组件的全路径,例如说:/crm/contract/detail/index.vue
BusinessFormComponent.value = registerComponent(
data?.processDefinition?.formCustomViewPath || '',
);
@@ -169,6 +164,9 @@ async function getApprovalDetail() {
// 获取审批节点,显示 Timeline 的数据
activityNodes.value = data.activityNodes;
// 获取待办任务显示操作按钮
operationButtonRef.value?.loadTodoTask(data.todoTask);
} catch {
message.error('获取审批详情失败!');
} finally {
@@ -249,9 +247,7 @@ onMounted(async () => {
<template>
<Page auto-content-height>
<Card
class="h-full"
:body-style="{
height: 'calc(100% - 140px)',
overflowY: 'auto',
paddingTop: '12px',
}"
@@ -306,18 +302,25 @@ onMounted(async () => {
</div>
<!-- 流程操作 -->
<div class="flex-1">
<Tabs v-model:active-key="activeTab" class="mt-0">
<TabPane tab="审批详情" key="form">
<Row :gutter="[48, 24]">
<Col :xs="24" :sm="24" :md="18" :lg="18" :xl="16">
<div class="process-tabs-container flex flex-1 flex-col">
<Tabs v-model:active-key="activeTab" class="mt-0 h-full">
<TabPane tab="审批详情" key="form" class="tab-pane-content">
<Row :gutter="[48, 24]" class="h-full">
<Col
:xs="24"
:sm="24"
:md="18"
:lg="18"
:xl="16"
class="h-full"
>
<!-- 流程表单 -->
<div
v-if="
processDefinition?.formType === BpmModelFormType.NORMAL
"
class="h-full"
>
<!-- v-model="detailForm.value" -->
<form-create
v-model="detailForm.value"
v-model:api="fApi"
@@ -330,23 +333,41 @@ onMounted(async () => {
v-if="
processDefinition?.formType === BpmModelFormType.CUSTOM
"
class="h-full"
>
<BusinessFormComponent :id="processInstance?.businessKey" />
</div>
</Col>
<Col :xs="24" :sm="24" :md="6" :lg="6" :xl="8">
<div class="mt-2">
<Col :xs="24" :sm="24" :md="6" :lg="6" :xl="8" class="h-full">
<div class="mt-4 h-full">
<ProcessInstanceTimeline :activity-nodes="activityNodes" />
</div>
</Col>
</Row>
</TabPane>
<TabPane tab="流程图" key="diagram">
<div>待开发</div>
<TabPane tab="流程图" key="diagram" class="tab-pane-content">
<div class="h-full">
<ProcessInstanceSimpleViewer
v-show="
processDefinition.modelType &&
processDefinition.modelType === BpmModelType.SIMPLE
"
:loading="processInstanceLoading"
:model-view="processModelView"
/>
<ProcessInstanceBpmnViewer
v-show="
processDefinition.modelType &&
processDefinition.modelType === BpmModelType.BPMN
"
:loading="processInstanceLoading"
:model-view="processModelView"
/>
</div>
</TabPane>
<TabPane tab="流转记录" key="record">
<TabPane tab="流转记录" key="record" class="tab-pane-content">
<div class="h-full">
<BpmProcessInstanceTaskList
ref="taskListRef"
@@ -357,19 +378,65 @@ onMounted(async () => {
</TabPane>
<!-- TODO 待开发 -->
<TabPane tab="流转评论" key="comment" v-if="false">
<div>待开发</div>
<TabPane
tab="流转评论"
key="comment"
v-if="false"
class="tab-pane-content"
>
<div class="h-full">待开发</div>
</TabPane>
</Tabs>
</div>
</div>
<template #actions>
<div class="flex justify-start gap-x-2 p-4">
<Button type="primary">驳回</Button>
<Button type="primary">同意</Button>
<div class="px-4">
<ProcessInstanceOperationButton
ref="operationButtonRef"
:process-instance="processInstance"
:process-definition="processDefinition"
:user-options="userOptions"
:normal-form="detailForm"
:normal-form-api="fApi"
:writable-fields="writableFields"
@success="getDetail"
/>
</div>
</template>
</Card>
</Page>
</template>
<style lang="scss" scoped>
.ant-tabs-content {
height: 100%;
}
.process-tabs-container {
display: flex;
flex-direction: column;
height: 100%;
}
:deep(.ant-tabs) {
display: flex;
flex-direction: column;
height: 100%;
}
:deep(.ant-tabs-content) {
flex: 1;
overflow-y: auto;
}
:deep(.ant-tabs-tabpane) {
height: 100%;
}
.tab-pane-content {
height: calc(100vh - 420px);
padding-right: 12px;
overflow: hidden auto;
}
</style>