import { NFProcess } from "../process"; import { NFNodeCfg } from "../types"; import { NFEventBus } from "../eventbus"; /** * 基础节点 */ export class NFNode{ /** * 所属流程 */ process:NFProcess; /** * 节点id,流程内唯一 */ id:string; /** * 节点名,用于显示 */ name:string; /** * 类型 */ type:string; /** * 创建基础节点。 * * @param cfg - 节点配置 * @param process - 所属流程 */ constructor(cfg:NFNodeCfg,process:NFProcess){ this.name = cfg.name; this.type = cfg.type; this.id = cfg.id; this.process = process; } /** * 进入节点:设为当前节点并触发 `node.enter`。 * * @param _args - 子类扩展参数 */ async run(..._args:any[]):Promise{ this.process.nodeManager.setCurrentNode(this); await NFEventBus.emit('node.enter',{ process:this.process, node:this }); }; /** * 委托流程实例推进。 * * @param cfg - 办理参数 */ async next(cfg?){ await this.process.next(cfg); } }