diff --git a/apps/web-antd/src/api/bpm/comment/index.ts b/apps/web-antd/src/api/bpm/comment/index.ts new file mode 100644 index 000000000..f00ef2800 --- /dev/null +++ b/apps/web-antd/src/api/bpm/comment/index.ts @@ -0,0 +1,40 @@ +import { requestClient } from '#/api/request'; + +export namespace BpmCommentApi { + /** 流程评论 */ + export interface Comment { + id: string; + taskId?: string; + task?: { + id: string; + name: string; + taskDefinitionKey: string; + }; + processInstanceId: string; + type: string; + message: string; + createTime: string; + user?: { + id: number; + nickname: string; + avatar?: string; + deptName?: string; + }; + } +} + +/** 获得指定流程实例的评论列表 */ +export const getCommentListByProcessInstanceId = async ( + processInstanceId: string, +) => { + return await requestClient.get( + '/bpm/comment/list-by-process-instance-id', + { params: { processInstanceId } }, + ); +}; + +/** 创建流程评论 */ +export const createComment = async (taskId: string, message: string) => { + return await requestClient.post('/bpm/comment/create', { taskId, message }); +}; + diff --git a/apps/web-antd/src/views/bpm/processInstance/detail/index.vue b/apps/web-antd/src/views/bpm/processInstance/detail/index.vue index aa6488f4c..be639e88b 100644 --- a/apps/web-antd/src/views/bpm/processInstance/detail/index.vue +++ b/apps/web-antd/src/views/bpm/processInstance/detail/index.vue @@ -33,6 +33,7 @@ import { setConfAndFields2 } from '#/components/form-create'; import { registerComponent } from '#/utils'; import ProcessInstanceBpmnViewer from './modules/bpm-viewer.vue'; +import BpmProcessInstanceCommentList from './modules/comment-list.vue'; import ProcessInstanceOperationButton from './modules/operation-button.vue'; import ProcessPrint from './modules/process-print.vue'; import ProcessInstanceSimpleViewer from './modules/simple-bpm-viewer.vue'; @@ -53,6 +54,7 @@ const processDefinition = ref({}); // 流程定义 const processModelView = ref({}); // 流程模型视图 const operationButtonRef = ref(); // 操作按钮组件 ref const activeTab = ref('form'); +const commentListRef = ref(); // 评论列表组件 ref const taskListRef = ref(); const auditIconsMap: { [key: string]: @@ -189,6 +191,8 @@ function setFieldPermission(field: string, permission: string) { const refresh = () => { // 重新获取详情 getDetail(); + // 重新获取评论 + commentListRef.value?.getList(); }; const [PrintModal, printModalApi] = useVbenModal({ @@ -209,6 +213,10 @@ watch( // 如果切换到流转记录标签,刷新任务列表 await nextTick(); taskListRef.value?.refresh(); + } else if (newVal === 'comment') { + // 如果切换到流程评论标签,刷新评论列表 + await nextTick(); + commentListRef.value?.getList(); } }, ); @@ -356,9 +364,12 @@ onMounted(async () => { :id="id" /> - - -
待开发
+ + diff --git a/apps/web-antd/src/views/bpm/processInstance/detail/modules/comment-list.vue b/apps/web-antd/src/views/bpm/processInstance/detail/modules/comment-list.vue new file mode 100644 index 000000000..568770323 --- /dev/null +++ b/apps/web-antd/src/views/bpm/processInstance/detail/modules/comment-list.vue @@ -0,0 +1,144 @@ + + + diff --git a/apps/web-antd/src/views/bpm/processInstance/detail/modules/operation-button.vue b/apps/web-antd/src/views/bpm/processInstance/detail/modules/operation-button.vue index 9e0628b62..99595240a 100644 --- a/apps/web-antd/src/views/bpm/processInstance/detail/modules/operation-button.vue +++ b/apps/web-antd/src/views/bpm/processInstance/detail/modules/operation-button.vue @@ -44,6 +44,7 @@ import { cancelProcessInstanceByStartUser, getNextApprovalNodes, } from '#/api/bpm/processInstance'; +import { createComment } from '#/api/bpm/comment'; import { approveTask, copyTask, @@ -91,6 +92,7 @@ const popOverVisible: any = ref({ addSign: false, return: false, copy: false, + comment: false, cancel: false, deleteSign: false, }); // 气泡卡是否展示 @@ -187,6 +189,14 @@ const copyFormRule: Record = reactive({ ], }); +const commentFormRef = ref(); // 评论表单 +const commentForm = reactive({ + message: '', +}); +const commentFormRule: Record = reactive({ + message: [{ required: true, message: '评论内容不能为空', trigger: 'blur' }], +}); + const transferFormRef = ref(); // 转办表单 const transferForm = reactive({ assigneeUserId: undefined, @@ -503,6 +513,30 @@ async function handleCopy() { } } +/** 处理评论 */ +async function handleComment() { + formLoading.value = true; + try { + // 1. 校验表单 + if (!commentFormRef.value) return; + await commentFormRef.value.validate(); + const content = commentForm.message.trim(); + if (!content) { + message.warning('评论内容不能为空'); + return; + } + // 2. 提交评论 + await createComment(runningTask.value.id, content); + commentFormRef.value.resetFields(); + popOverVisible.value.comment = false; + message.success('评论成功'); + // 3. 加载最新数据 + reload(); + } finally { + formLoading.value = false; + } +} + /** 处理转交 */ async function handleTransfer() { formLoading.value = true; @@ -1020,6 +1054,56 @@ defineExpose({ loadTodoTask }); + + + +