@mldong/jeeflow 1.8.21 → 1.8.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine.js +21 -3
- package/package.json +1 -1
package/dist/engine.js
CHANGED
|
@@ -253,7 +253,10 @@ export class EngineImpl {
|
|
|
253
253
|
const def = await this.repo.findDefineById(inst.defineId);
|
|
254
254
|
const flow = JSON.parse(typeof def.content === 'string' ? def.content : new TextDecoder().decode(def.content));
|
|
255
255
|
args = filterFieldByPerm(args, findNode(flow, task.taskName));
|
|
256
|
-
|
|
256
|
+
// issues/97:捕获原始实例变量(start 注入的发起人 u_*)——操作人 u_* 只进执行上下文
|
|
257
|
+
// 与任务行,不得整体写回实例(对齐 Java completeTask=putAll(args),args 不含 u_*)。
|
|
258
|
+
const baseVars = inst.variables;
|
|
259
|
+
const vars = { ...baseVars, ...task.variables, ...args };
|
|
257
260
|
await this.addUserInfo(operator, vars);
|
|
258
261
|
const now = new Date();
|
|
259
262
|
// 聚合根:完成任务(子实体状态转换 + 实例变量合并)
|
|
@@ -263,7 +266,8 @@ export class EngineImpl {
|
|
|
263
266
|
// completeTask 改的是外部任务对象,需同步回聚合根
|
|
264
267
|
syncTaskToAggregate(inst, task);
|
|
265
268
|
await this.fireEvent({ type: EventType.TaskComplete, instanceId: inst.id, taskId: task.id, nodeId: task.taskName, operator });
|
|
266
|
-
|
|
269
|
+
// issues/97:实例变量写回排除操作人 u_*,保留 start 注入的发起人 u_*(u_realName 恒为发起人)
|
|
270
|
+
inst.variables = mergeExecIntoInstance(baseVars, vars);
|
|
267
271
|
await this.repo.updateInstance(inst);
|
|
268
272
|
return { task, inst, flow, vars };
|
|
269
273
|
}
|
|
@@ -407,7 +411,8 @@ export class EngineImpl {
|
|
|
407
411
|
else {
|
|
408
412
|
inst.finish(new Date());
|
|
409
413
|
}
|
|
410
|
-
|
|
414
|
+
// issues/97:结束节点写回同样排除操作人 u_*(保留发起人 u_*,与 prepareExecuteTask 一致)
|
|
415
|
+
inst.variables = mergeExecIntoInstance(inst.variables, vars);
|
|
411
416
|
await this.repo.updateInstance(inst);
|
|
412
417
|
await this.fireEvent({ type: EventType.ProcessFinish, instanceId: inst.id, operator });
|
|
413
418
|
return;
|
|
@@ -638,6 +643,19 @@ function syncTaskToAggregate(inst, task) {
|
|
|
638
643
|
}
|
|
639
644
|
}
|
|
640
645
|
}
|
|
646
|
+
/** 实例变量写回合并(issues/97 对齐 Java):以 base(start 注入的发起人 u_*)为底,
|
|
647
|
+
* 并入执行上下文中**非 u_*** 键(f_ 表单字段 / submitType 等流转数据)。
|
|
648
|
+
* addUserInfo 生成的操作人 u_* 只属于当次执行上下文与任务行 ext,不整体写回实例——
|
|
649
|
+
* 实例 u_realName 语义是「发起人」(与 autoGenTitle 一致),不随审批节点漂移。 */
|
|
650
|
+
function mergeExecIntoInstance(base, execVars) {
|
|
651
|
+
const out = { ...base };
|
|
652
|
+
for (const [k, v] of Object.entries(execVars)) {
|
|
653
|
+
if (k.startsWith('u_'))
|
|
654
|
+
continue;
|
|
655
|
+
out[k] = v;
|
|
656
|
+
}
|
|
657
|
+
return out;
|
|
658
|
+
}
|
|
641
659
|
function isTruthy(v) {
|
|
642
660
|
if (typeof v === 'boolean')
|
|
643
661
|
return v;
|