用户任务
活动节点也提供了一组事件监听器
一个listener定义
src/module/test-flow/backend/src/config/static/flowDef/listener/set01_atomUserTask.spec.js
- 1const require3 = require('require3');
- 2const assert = require3('assert');
- 3
- 4module.exports = class Listener {
- 5 constructor(context) {
- 6 this.context = context;
- 7 }
- 8
- 9 async onNodeEnter(contextNode) {
- 10 if (contextNode._nodeDef.id === 'startEvent_1') {
- 11 const _flowDefKey = this.context.atom._flowDefKey;
- 12 assert.equal(_flowDefKey, 'set01_atomUserTask');
- 13 }
- 14 }
- 15
- 16 async onTaskCreated(contextTask, contextNode) {
- 17 console.log('onTaskCreated: ', contextTask._flowTaskId, ' of node: ', contextNode._nodeDef.id);
- 18 }
- 19
- 20 async onTaskClaimed(contextTask, contextNode) {
- 21 console.log('onTaskClaimed: ', contextTask._flowTaskId, ' of node: ', contextNode._nodeDef.id);
- 22 }
- 23
- 24 async onTaskCompleted(contextTask, contextNode) {
- 25 console.log('onTaskCompleted: ', contextTask._flowTaskId, ' of node: ', contextNode._nodeDef.id);
- 26 console.log('handleStatus: %d, handleRemark: %s', contextTask._flowTask.handleStatus, contextTask._flowTask.handleRemark);
- 27 }
- 28
- 29 async getSchemaRead(contextTask, contextNode/* { schemaBase, schema }*/) {
- 30 console.log('getSchemaRead: ', contextTask._flowTaskId, ' of node: ', contextNode._nodeDef.id);
- 31 }
- 32
- 33 async getSchemaWrite(contextTask, contextNode/* { schemaBase, schema }*/) {
- 34 console.log('getSchemaWrite: ', contextTask._flowTaskId, ' of node: ', contextNode._nodeDef.id);
- 35 }
- 36
- 37 getNodeDefOptions(contextNode /* { options }*/) {
- 38 console.log('getNodeDefOptions: ', contextNode._nodeDef.id);
- 39 }
- 40
- 41};
1. 环境对象
- this.context:流程实例环境对象
- contextNode:活动节点环境对象
- contextTask:用户任务环境对象
2. 用户任务事件
- onTaskCreated:用户任务创建事件
- 1async onTaskCreated(contextTask, contextNode)
- onTaskClaimed:用户任务签收事件
- 1async onTaskClaimed(contextTask, contextNode)
- onTaskCompleted:用户任务完成事件
- 1async onTaskCompleted(contextTask, contextNode)
3. 工具方法
- getSchemaRead
Read Schema
可以控制当前用户任务可以读取
哪些字段
通过重载此方法,可以提供动态修改之后的用户任务
的Read Schema
参数
- 1async getSchemaRead(contextTask, contextNode, { schemaBase, schema })
- getSchemaWrite
Write Schema
可以控制当前用户任务可以修改
哪些字段
通过重载此方法,可以提供动态修改之后的用户任务
的Write Schema
参数
- 1async getSchemaWrite(contextTask, contextNode, { schemaBase, schema })
评论: