line增加执行Hook配置

This commit is contained in:
Jam committed 2022-11-14 16:35:40 +08:00
1 parent b3eaccc05a
commit b6ff0d0a5e
5 files changed
+46 -54

No files matched your search

+1
View File
@@ -16,6 +16,7 @@ const errorInfoEnum = {
task_not_found: { errorCode: 'task_not_found', errorReason: '任务不存在' },
node_not_found: { errorCode: 'node_not_found', errorReason: '节点不存在' },
line_not_found: { errorCode: 'line_not_found', errorReason: '线路不存在' },
line_hook_error: { errorCode: 'line_hook_error', errorReason: '线路Hook异常' }
};
module.exports = {
+15
View File
@@ -0,0 +1,15 @@
'use strict';
const Service = require('egg').Service;
class HookService extends Service {
async executeFinishLine(actionData) {
const { taskId } = actionData;
// 根据任务ID找到绑定的业务数据,进行处理
console.log("审批结束", actionData)
}
async executeRejectLine(actionData) {
console.log("审批拒绝", actionData)
}
}
module.exports = HookService;
+11 -1
View File
@@ -344,8 +344,18 @@ class TaskService extends Service {
taskConfigId: nextNode.id,
taskStatus: (nextLineList.length === 0 || currentNode.id.includes('end-')) ? 'end' : type === 'deny' ? 'deny' : 'running'
});
await this.executeLineHook(line);
}
}
async executeLineHook(line) {
try {
const { service, serviceFunction } = JSON.parse(line.hook || '{}');
if (service && serviceFunction) {
await this.ctx.service[service][serviceFunction](this.ctx.request.body.appData.actionData, this.ctx)
}
} catch (error) {
throw new BizError(errorInfoEnum.line_hook_error);
}
}
}
+4 -4
View File
@@ -47,10 +47,10 @@
v-model="line.type"
></v-select>
</v-col>
<!-- <v-col cols="12" class=" pb-3">
<span class="inputLabel">课程Resource</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="课程Resource" v-model="line.hook"></v-text-field>
</v-col> -->
<v-col cols="12" class=" pb-3">
<span class="inputLabel">执行Hook</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="执行Hook" v-model="line.hook"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3">
<span class="inputLabel">备注说明</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="备注说明" v-model="line.Remark"></v-text-field>