@steedos-labs/plugin-workflow 3.0.69 → 3.0.70

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.
@@ -5,7 +5,7 @@
5
5
  <link rel="shortcut icon" type="image/svg+xml" href="/images/logo.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>designer</title>
8
- <script type="module" crossorigin src="/api/workflow/designer-v2/assets/index-CRxbSR2M.js"></script>
8
+ <script type="module" crossorigin src="/api/workflow/designer-v2/assets/index-CK4K0ssy.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/api/workflow/designer-v2/assets/index-BocXPX7W.css">
10
10
  </head>
11
11
  <body>
@@ -1,4 +1,5 @@
1
1
  waitForThing(window, 'antd').then(function(){
2
- loadJs('/amis-renderer/amis-renderer.js');
3
- loadCss('/amis-renderer/amis-renderer.css')
2
+ var v = '20260505';
3
+ loadJs('/amis-renderer/amis-renderer.js?v=' + v);
4
+ loadCss('/amis-renderer/amis-renderer.css?v=' + v)
4
5
  })
@@ -87,8 +87,11 @@ window.waitForThing(window, 'socket').then(()=>{
87
87
  return pathname.endsWith(`/instances`) || pathname.includes(`/instances/view`) || pathname.includes(`/instances/grid`) || pathname.endsWith(`/instance_tasks`) || pathname.includes(`/instance_tasks/view`) || pathname.includes(`/instance_tasks/grid`);
88
88
  };
89
89
  if (shouldReloadView()) {
90
+ // 仅刷新列表。审批中心左侧菜单(approval-tree-menu)的角标/分类
91
+ // 完全派生自 badge 数据,由 badge:change 链路负责广播 reload;
92
+ // 此处不再额外广播 approval-tree-menu:reload,避免同一次提交动作
93
+ // 触发两次 nav 接口请求(issue: steedos/steedos-widgets#627)。
90
94
  window.$(".list-view-btn-reload").click()
91
- window.postMessage({ type: "approval-tree-menu:reload" }, "*")
92
95
  }
93
96
  });
94
97
 
@@ -412,12 +412,20 @@ pushManager.get_badge = async function (send_from, user_id) {
412
412
  });
413
413
  let spaceKeyValue = spaceKeyValues.length > 0 ? spaceKeyValues[0] : null;
414
414
 
415
- // app 分组的 category badge 更新
415
+ // 先把当前 value 拷一份,循环里把所有 app categoryBadge + workflow 都写入
416
+ // 这个本地变量,循环结束后再一次性 update 到 DB;
417
+ // 否则每个 app 一次 update + workflow 再一次 update,会触发 N+1 次
418
+ // @steedos_keyvalues.* 事件 → N+1 次 socket s:workflow:badge:change 推送,
419
+ // 导致前端 ApprovalTreeMenu 在一次审批动作后被刷 N+1 次(issue: steedos/steedos-widgets#627)。
420
+ const newValue = spaceKeyValue ? { ...(spaceKeyValue.value || {}) } : {};
421
+
422
+ // 按 app 分组的 category badge(仅算值,不写库)
416
423
  const categories = await categoriesCol.find(
417
424
  { space: spaceId, app: { $ne: null } },
418
425
  { projection: { app: 1 } }
419
426
  ).toArray();
420
427
 
428
+ // 在循环中只把每个 app 的 categoryBadge 累加到 newValue,不立即写库
421
429
  if (categories.length > 0) {
422
430
  const appCategories = _.groupBy(categories, 'app');
423
431
 
@@ -434,44 +442,32 @@ pushManager.get_badge = async function (send_from, user_id) {
434
442
  category: { $in: categoryIds },
435
443
  });
436
444
 
437
- if (spaceKeyValue) {
438
- if (spaceKeyValue.value?.[appName] !== categoryBadge) {
439
- await keyvaluesObj.update(spaceKeyValue._id, {
440
- value: { ...spaceKeyValue.value, [appName]: categoryBadge }
441
- });
442
- spaceKeyValue.value = { ...spaceKeyValue.value, [appName]: categoryBadge };
443
- }
444
- } else {
445
- const inserted = await keyvaluesObj.insert({
446
- user: user_id,
447
- space: spaceId,
448
- key: 'badge',
449
- value: { [appName]: categoryBadge }
450
- });
451
- spaceKeyValue = inserted;
452
- }
445
+ newValue[appName] = categoryBadge;
453
446
  }
454
447
  }
455
448
 
456
- // workflow 记录所有待办数量
449
+ // workflow 总待办数量也累加到 newValue,下面统一写库
457
450
  const taskCount = await count_instance_tasks({
458
451
  handler: user_id,
459
452
  is_finished: false,
460
453
  space: spaceId,
461
454
  });
455
+ newValue.workflow = taskCount;
462
456
 
457
+ // 一次性写库:与原 value 比较,仅在真正发生变化时 update / insert
463
458
  if (spaceKeyValue) {
464
- if (spaceKeyValue.value?.workflow !== taskCount) {
465
- await keyvaluesObj.update(spaceKeyValue._id, {
466
- value: { ...spaceKeyValue.value, workflow: taskCount }
467
- });
459
+ const oldValue = spaceKeyValue.value || {};
460
+ const changed = Object.keys(newValue).some(k => oldValue[k] !== newValue[k])
461
+ || Object.keys(oldValue).some(k => oldValue[k] !== newValue[k]);
462
+ if (changed) {
463
+ await keyvaluesObj.update(spaceKeyValue._id, { value: newValue });
468
464
  }
469
465
  } else {
470
466
  await keyvaluesObj.insert({
471
467
  user: user_id,
472
468
  space: spaceId,
473
469
  key: 'badge',
474
- value: { workflow: taskCount }
470
+ value: newValue
475
471
  });
476
472
  }
477
473
 
@@ -62,7 +62,7 @@ amis_schema: |-
62
62
  },
63
63
  {
64
64
  "actionType": "custom",
65
- "script": "const {instance, appId, objectName} = event.data;\nconsole.log(`instance===`);doAction({\n actionType: 'link',\n args: {\n blank: false,\n link: `/app/${appId}/instances/view/${instance._id}?side_object=instances&side_listview_id=draft`\n }\n});\n;"
65
+ "script": "try { sessionStorage.removeItem('flowId'); sessionStorage.removeItem('categoryId'); } catch(e) {}\nconst {instance, appId, objectName} = event.data;\nconsole.log(`instance===`);doAction({\n actionType: 'link',\n args: {\n blank: false,\n link: `/app/${appId}/instances/view/${instance._id}?side_object=instances&side_listview_id=draft&additionalFilters=&flowId=&categoryId=`\n }\n});\n;"
66
66
  },
67
67
  {
68
68
  "actionType": "wait",
@@ -27,7 +27,7 @@ amis_schema: |-
27
27
  {
28
28
  "ignoreError": false,
29
29
  "actionType": "custom",
30
- "script": "SteedosWorkflow.Instance.changed=false; navigate('/app/approve_workflow/instances/view/none?side_object=instances&side_listview_id=draft')"
30
+ "script": "try { sessionStorage.removeItem('flowId'); sessionStorage.removeItem('categoryId'); } catch(e) {} SteedosWorkflow.Instance.changed=false; navigate('/app/approve_workflow/instances/view/none?side_object=instances&side_listview_id=draft&additionalFilters=&flowId=&categoryId=')"
31
31
  },
32
32
  {
33
33
  "actionType": "wait",
@@ -63,7 +63,7 @@ amis_schema: |-
63
63
  ,
64
64
  {
65
65
  "actionType": "custom",
66
- "script": "const {instance, appId, objectName} = event.data;\nconsole.log(`instance===`);doAction({\n actionType: 'link',\n args: {\n blank: false,\n link: `/app/${appId}/instances/view/${instance._id}?side_object=instances&side_listview_id=draft`\n }\n});\n;"
66
+ "script": "try { sessionStorage.removeItem('flowId'); sessionStorage.removeItem('categoryId'); } catch(e) {}\nconst {instance, appId, objectName} = event.data;\nconsole.log(`instance===`);doAction({\n actionType: 'link',\n args: {\n blank: false,\n link: `/app/${appId}/instances/view/${instance._id}?side_object=instances&side_listview_id=draft&additionalFilters=&flowId=&categoryId=`\n }\n});\n;"
67
67
  },
68
68
  {
69
69
  "actionType": "wait",
@@ -20,11 +20,13 @@ amis_schema: |-
20
20
  "title": "取回",
21
21
  "body": [
22
22
  {
23
- "type": "input-text",
23
+ "type": "textarea",
24
24
  "label": "备注",
25
25
  "name": "retrieve_comment",
26
26
  "id": "u:c7fa318c8af1",
27
- "editorState": "default"
27
+ "editorState": "default",
28
+ "minRows": 3,
29
+ "maxRows": 20
28
30
  }
29
31
  ],
30
32
  "id": "u:b05694926b78",
@@ -79,16 +79,7 @@ router.get('/api/workflow/instance/:instanceId', requireAuthentication, async fu
79
79
 
80
80
  if (!box) {
81
81
  // 验证login user_id对该流程有管理、观察申请单的权限
82
- const permissions = await new Promise((resolve, reject) => {
83
- Fiber(function () {
84
- try {
85
- const permissions = PermissionManager.getFlowPermissions(flowId, userId);
86
- resolve(permissions);
87
- } catch (error) {
88
- reject(error);
89
- }
90
- }).run();
91
- });
82
+ const permissions = await PermissionManager.getFlowPermissions(flowId, userId);
92
83
  const space = await spaceObj.findOne(spaceId, {
93
84
  fields: ['admins']
94
85
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-labs/plugin-workflow",
3
- "version": "3.0.69",
3
+ "version": "3.0.70",
4
4
  "main": "package.service.js",
5
5
  "license": "MIT",
6
6
  "files": [