feat: notice hard coded (#1136)

Reviewed-on: daoyoucloud/tachybase#1136
This commit is contained in:
sealday 2024-06-06 14:25:16 +08:00
parent 8b47ac3f7c
commit 8cb3893caa
5 changed files with 39 additions and 38 deletions

View File

@ -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);

View File

@ -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': {

View File

@ -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={<PopoverContent onSlecet={onSlecet} onQuery={onQuery} />}
>
<Button
className="ant-formily-array-base-addition"
// icon={<PlusOutlined />}
type="dashed"
block={true}
disabled={isWorkflowExecuted}
>
<Button className="ant-formily-array-base-addition" type="dashed" block={true} disabled={isWorkflowExecuted}>
{t('Add Notified Person')}
</Button>
</Popover>

View File

@ -15,6 +15,7 @@ class NoticeInstruction extends Instruction {
upstreamId: prevJob?.id ?? null,
});
const notifiedPerson = await parsePerson(node, processor);
if (notifiedPerson) {
const { db } = processor.options.plugin;
// TODO-A: 改成取上一个节点的数据集, 或者当前执行流数据源的数据集, 目前是对审批事件做了特化处理; 需要理解下其他类型的触发事件, 怎么拿数据
const ApprovalRepo = db.getRepository('approvals');
@ -46,6 +47,10 @@ class NoticeInstruction extends Instruction {
await NoticeModel.bulkCreate(notifiedPersonMapData, {
transaction: processor.transaction,
});
}
// notify
this.workflow.noticeManager.notify('workflow:regular', { msg: 'done' });
return job;
}

View File

@ -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() {