diff --git a/packages/core/client/src/application/NoticesManager.tsx b/packages/core/client/src/application/NoticesManager.tsx
index 3bb4043d0..76a5092d9 100644
--- a/packages/core/client/src/application/NoticesManager.tsx
+++ b/packages/core/client/src/application/NoticesManager.tsx
@@ -38,7 +38,7 @@ export const useNoticeManager = () => {
return useContext(NoticeManagerContext);
};
-export const useNoticeSub = (name: string, handler: () => {}) => {
+export const useNoticeSub = (name: string, handler: () => void) => {
const { manager } = useNoticeManager();
useEffect(() => {
manager.emitter.on(name, handler);
diff --git a/packages/plugins/@tachybase/plugin-workflow-notice/src/client/configuration/Notice.instruction.ts b/packages/plugins/@tachybase/plugin-workflow-notice/src/client/configuration/Notice.instruction.ts
index 217d2f23e..fac0d8c97 100644
--- a/packages/plugins/@tachybase/plugin-workflow-notice/src/client/configuration/Notice.instruction.ts
+++ b/packages/plugins/@tachybase/plugin-workflow-notice/src/client/configuration/Notice.instruction.ts
@@ -32,7 +32,6 @@ export class NoticeInstruction extends Instruction {
notifiedPerson: {
type: 'array',
title: tval('The Notified Person'),
- required: true,
'x-decorator': 'FormItem',
'x-component': 'ArrayItems',
'x-component-props': {
diff --git a/packages/plugins/@tachybase/plugin-workflow-notice/src/client/configuration/config-items/AddNotifiedPerson.view.tsx b/packages/plugins/@tachybase/plugin-workflow-notice/src/client/configuration/config-items/AddNotifiedPerson.view.tsx
index 5b4b28064..6b7a6906f 100644
--- a/packages/plugins/@tachybase/plugin-workflow-notice/src/client/configuration/config-items/AddNotifiedPerson.view.tsx
+++ b/packages/plugins/@tachybase/plugin-workflow-notice/src/client/configuration/config-items/AddNotifiedPerson.view.tsx
@@ -1,4 +1,3 @@
-// import { PlusOutlined } from '@ant-design/icons';
import React, { useCallback, useState } from 'react';
import { ArrayItems } from '@tachybase/components';
import { useWorkflowExecuted } from '@tachybase/plugin-workflow/client';
@@ -29,13 +28,7 @@ export const AdditionNotifiedPerson = () => {
onOpenChange={setIsOpen}
content={}
>
- }
- type="dashed"
- block={true}
- disabled={isWorkflowExecuted}
- >
+
diff --git a/packages/plugins/@tachybase/plugin-workflow-notice/src/server/NoticeInstruction.ts b/packages/plugins/@tachybase/plugin-workflow-notice/src/server/NoticeInstruction.ts
index f0c512bab..dc19a01ac 100644
--- a/packages/plugins/@tachybase/plugin-workflow-notice/src/server/NoticeInstruction.ts
+++ b/packages/plugins/@tachybase/plugin-workflow-notice/src/server/NoticeInstruction.ts
@@ -15,37 +15,42 @@ class NoticeInstruction extends Instruction {
upstreamId: prevJob?.id ?? null,
});
const notifiedPerson = await parsePerson(node, processor);
- const { db } = processor.options.plugin;
- // TODO-A: 改成取上一个节点的数据集, 或者当前执行流数据源的数据集, 目前是对审批事件做了特化处理; 需要理解下其他类型的触发事件, 怎么拿数据
- const ApprovalRepo = db.getRepository('approvals');
- const approval = await ApprovalRepo.findOne({
- filter: {
- 'executions.id': processor.execution.id,
- },
- fields: ['id', 'status', 'data', 'summary', 'collectionName'],
- appends: ['approvalExecutions'],
- except: ['data'],
- });
+ if (notifiedPerson) {
+ const { db } = processor.options.plugin;
+ // TODO-A: 改成取上一个节点的数据集, 或者当前执行流数据源的数据集, 目前是对审批事件做了特化处理; 需要理解下其他类型的触发事件, 怎么拿数据
+ const ApprovalRepo = db.getRepository('approvals');
+ const approval = await ApprovalRepo.findOne({
+ filter: {
+ 'executions.id': processor.execution.id,
+ },
+ fields: ['id', 'status', 'data', 'summary', 'collectionName'],
+ appends: ['approvalExecutions'],
+ except: ['data'],
+ });
- const NoticeModel = db.getModel(COLLECTION_NOTICE_NAME);
+ const NoticeModel = db.getModel(COLLECTION_NOTICE_NAME);
- const notifiedPersonMapData = notifiedPerson.map((userId, index) => ({
- userId,
- jobId: job.id,
- nodeId: node.id,
- executionId: job.executionId,
- workflowId: node.workflowId,
- index,
- status: node.config.order && index ? NOTICE_ACTION_STATUS.ASSIGNED : NOTICE_ACTION_STATUS.APPROVED,
- snapshot: approval.data,
- summary: approval.summary,
- collectionName: approval.collectionName,
- dataKey: approval.dataKey,
- }));
+ const notifiedPersonMapData = notifiedPerson.map((userId, index) => ({
+ userId,
+ jobId: job.id,
+ nodeId: node.id,
+ executionId: job.executionId,
+ workflowId: node.workflowId,
+ index,
+ status: node.config.order && index ? NOTICE_ACTION_STATUS.ASSIGNED : NOTICE_ACTION_STATUS.APPROVED,
+ snapshot: approval.data,
+ summary: approval.summary,
+ collectionName: approval.collectionName,
+ dataKey: approval.dataKey,
+ }));
- await NoticeModel.bulkCreate(notifiedPersonMapData, {
- transaction: processor.transaction,
- });
+ await NoticeModel.bulkCreate(notifiedPersonMapData, {
+ transaction: processor.transaction,
+ });
+ }
+
+ // notify
+ this.workflow.noticeManager.notify('workflow:regular', { msg: 'done' });
return job;
}
diff --git a/packages/plugins/@tachybase/plugin-workflow/src/client/features/api-regular/usage/hooks.tsx b/packages/plugins/@tachybase/plugin-workflow/src/client/features/api-regular/usage/hooks.tsx
index d603f5ac5..46741b263 100644
--- a/packages/plugins/@tachybase/plugin-workflow/src/client/features/api-regular/usage/hooks.tsx
+++ b/packages/plugins/@tachybase/plugin-workflow/src/client/features/api-regular/usage/hooks.tsx
@@ -6,6 +6,7 @@ import {
useCollection_deprecated,
useCompile,
useLocalVariables,
+ useNoticeSub,
useRecord,
useRequest,
useTableBlockContext,
@@ -42,6 +43,9 @@ export const usePropsAPIRegular = () => {
manual: true,
},
);
+ useNoticeSub('workflow:regular', () => {
+ service.refresh();
+ });
return {
async onClick() {