parent
76f5e1c640
commit
1c1a11b3d0
@ -38,7 +38,7 @@ export const useNoticeManager = () => {
|
||||
return useContext(NoticeManagerContext);
|
||||
};
|
||||
|
||||
export const useNoticeSub = (name: string, handler: () => void) => {
|
||||
export const useNoticeSub = (name: string, handler: (...args: any) => void) => {
|
||||
const { manager } = useNoticeManager();
|
||||
useEffect(() => {
|
||||
manager.emitter.on(name, handler);
|
||||
|
@ -15,6 +15,7 @@ import {
|
||||
import { SchemaExpressionScopeContext, useField, useFieldSchema } from '@tachybase/schema';
|
||||
|
||||
import { App } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { lang } from '../../../locale';
|
||||
@ -25,11 +26,12 @@ export const usePropsAPIRegular = () => {
|
||||
const expressionScope = useContext(SchemaExpressionScopeContext);
|
||||
const tableBlockContext = useTableBlockContext();
|
||||
const { rowKey } = tableBlockContext;
|
||||
const { t } = useTranslation();
|
||||
|
||||
const navigate = useNavigate();
|
||||
const compile = useCompile();
|
||||
const actionField: any = useField();
|
||||
const { modal } = App.useApp();
|
||||
const { modal, notification } = App.useApp();
|
||||
const variables = useVariables();
|
||||
const record = useRecord();
|
||||
const { name, getField } = useCollection_deprecated();
|
||||
@ -43,8 +45,19 @@ export const usePropsAPIRegular = () => {
|
||||
manual: true,
|
||||
},
|
||||
);
|
||||
useNoticeSub('workflow:regular', () => {
|
||||
useNoticeSub('workflow:regular', (event) => {
|
||||
if (event.msg === 'start') {
|
||||
notification.info({ key: 'workflow:regular', message: t('working'), description: t('starting') });
|
||||
} else if (event.msg === 'progress') {
|
||||
notification.info({
|
||||
key: 'workflow:regular',
|
||||
message: t('working'),
|
||||
description: t('process') + `${event.current} / ${event.total}`,
|
||||
});
|
||||
} else if (event.msg === 'done') {
|
||||
notification.info({ key: 'workflow:regular', message: t('working'), description: t('done') });
|
||||
service.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -149,6 +149,10 @@ export class APIRegularTrigger extends Trigger {
|
||||
for (const event of asyncGroup) {
|
||||
this.workflow.trigger(event[0], event[1]);
|
||||
}
|
||||
|
||||
this.workflow.noticeManager.notify('workflow:regular', {
|
||||
msg: 'start',
|
||||
});
|
||||
}
|
||||
|
||||
on(workflow: WorkflowModel): void {}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Processor, Instruction, JOB_STATUS, FlowNodeModel, JobModel } from '../..';
|
||||
import { FlowNodeModel, Instruction, JOB_STATUS, JobModel, Processor } from '../..';
|
||||
|
||||
function getTargetLength(target) {
|
||||
let length = 0;
|
||||
@ -93,6 +93,12 @@ export default class extends Instruction {
|
||||
length,
|
||||
};
|
||||
|
||||
this.workflow.noticeManager.notify('workflow:regular', {
|
||||
msg: 'progress',
|
||||
current: index,
|
||||
total: length,
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user