feat: notice hard coded (#1136)
Reviewed-on: daoyoucloud/tachybase#1136
This commit is contained in:
parent
8b47ac3f7c
commit
8cb3893caa
@ -38,7 +38,7 @@ export const useNoticeManager = () => {
|
|||||||
return useContext(NoticeManagerContext);
|
return useContext(NoticeManagerContext);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useNoticeSub = (name: string, handler: () => {}) => {
|
export const useNoticeSub = (name: string, handler: () => void) => {
|
||||||
const { manager } = useNoticeManager();
|
const { manager } = useNoticeManager();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
manager.emitter.on(name, handler);
|
manager.emitter.on(name, handler);
|
||||||
|
@ -32,7 +32,6 @@ export class NoticeInstruction extends Instruction {
|
|||||||
notifiedPerson: {
|
notifiedPerson: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
title: tval('The Notified Person'),
|
title: tval('The Notified Person'),
|
||||||
required: true,
|
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'ArrayItems',
|
'x-component': 'ArrayItems',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
// import { PlusOutlined } from '@ant-design/icons';
|
|
||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback, useState } from 'react';
|
||||||
import { ArrayItems } from '@tachybase/components';
|
import { ArrayItems } from '@tachybase/components';
|
||||||
import { useWorkflowExecuted } from '@tachybase/plugin-workflow/client';
|
import { useWorkflowExecuted } from '@tachybase/plugin-workflow/client';
|
||||||
@ -29,13 +28,7 @@ export const AdditionNotifiedPerson = () => {
|
|||||||
onOpenChange={setIsOpen}
|
onOpenChange={setIsOpen}
|
||||||
content={<PopoverContent onSlecet={onSlecet} onQuery={onQuery} />}
|
content={<PopoverContent onSlecet={onSlecet} onQuery={onQuery} />}
|
||||||
>
|
>
|
||||||
<Button
|
<Button className="ant-formily-array-base-addition" type="dashed" block={true} disabled={isWorkflowExecuted}>
|
||||||
className="ant-formily-array-base-addition"
|
|
||||||
// icon={<PlusOutlined />}
|
|
||||||
type="dashed"
|
|
||||||
block={true}
|
|
||||||
disabled={isWorkflowExecuted}
|
|
||||||
>
|
|
||||||
{t('Add Notified Person')}
|
{t('Add Notified Person')}
|
||||||
</Button>
|
</Button>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
@ -15,6 +15,7 @@ class NoticeInstruction extends Instruction {
|
|||||||
upstreamId: prevJob?.id ?? null,
|
upstreamId: prevJob?.id ?? null,
|
||||||
});
|
});
|
||||||
const notifiedPerson = await parsePerson(node, processor);
|
const notifiedPerson = await parsePerson(node, processor);
|
||||||
|
if (notifiedPerson) {
|
||||||
const { db } = processor.options.plugin;
|
const { db } = processor.options.plugin;
|
||||||
// TODO-A: 改成取上一个节点的数据集, 或者当前执行流数据源的数据集, 目前是对审批事件做了特化处理; 需要理解下其他类型的触发事件, 怎么拿数据
|
// TODO-A: 改成取上一个节点的数据集, 或者当前执行流数据源的数据集, 目前是对审批事件做了特化处理; 需要理解下其他类型的触发事件, 怎么拿数据
|
||||||
const ApprovalRepo = db.getRepository('approvals');
|
const ApprovalRepo = db.getRepository('approvals');
|
||||||
@ -46,6 +47,10 @@ class NoticeInstruction extends Instruction {
|
|||||||
await NoticeModel.bulkCreate(notifiedPersonMapData, {
|
await NoticeModel.bulkCreate(notifiedPersonMapData, {
|
||||||
transaction: processor.transaction,
|
transaction: processor.transaction,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// notify
|
||||||
|
this.workflow.noticeManager.notify('workflow:regular', { msg: 'done' });
|
||||||
|
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import {
|
|||||||
useCollection_deprecated,
|
useCollection_deprecated,
|
||||||
useCompile,
|
useCompile,
|
||||||
useLocalVariables,
|
useLocalVariables,
|
||||||
|
useNoticeSub,
|
||||||
useRecord,
|
useRecord,
|
||||||
useRequest,
|
useRequest,
|
||||||
useTableBlockContext,
|
useTableBlockContext,
|
||||||
@ -42,6 +43,9 @@ export const usePropsAPIRegular = () => {
|
|||||||
manual: true,
|
manual: true,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
useNoticeSub('workflow:regular', () => {
|
||||||
|
service.refresh();
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
async onClick() {
|
async onClick() {
|
||||||
|
Loading…
Reference in New Issue
Block a user