@steedos-labs/plugin-workflow 3.0.68 → 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
 
@@ -1699,8 +1699,17 @@ UUFlowManager.workflow_engine = async function (approve_from_client, current_use
1699
1699
  const t10 = Date.now();
1700
1700
  // Send message to current user and trigger webhook
1701
1701
  await pushManager.send_message_current_user(current_user_info);
1702
-
1702
+
1703
+ // 给下一步处理人(inbox_users)推送 badge,确保被驳回人/审批人的待办角标实时更新
1703
1704
  let to_users = finalInstance.inbox_users;
1705
+ if (to_users && to_users.length > 0) {
1706
+ for (const to_user_id of to_users) {
1707
+ if (to_user_id !== current_user) {
1708
+ await pushManager.send_message_to_specifyUser("current_user", to_user_id);
1709
+ }
1710
+ }
1711
+ }
1712
+
1704
1713
  const last_trace = _.last(finalInstance.traces);
1705
1714
  const last_step = await UUFlowManager.getStep(finalInstance, flow, last_trace.step);
1706
1715
 
@@ -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&additionalFilters=&flowId=&categoryId=`\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&additionalFilters=&flowId=&categoryId=')"
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&additionalFilters=&flowId=&categoryId=`\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",
@@ -246,7 +246,8 @@
246
246
  "background-color": "#fff"
247
247
  },
248
248
  ".steedos-instance-related-view-wrapper .steedos-amis-instance-view-content": {
249
- "min-width": "0 !important"
249
+ "min-width": "0 !important",
250
+ "padding": "12px 15px 0 15px"
250
251
  },
251
252
  ".steedos-instance-related-view-wrapper > .antd-Page-content": {
252
253
  "transition": "width 0.5s ease-in-out"
@@ -254,13 +255,11 @@
254
255
  ".steedos-instance-related-view-wrapper .instance-form": {
255
256
  "width": "100%",
256
257
  "margin": "0 auto",
257
- "padding": "0 15px",
258
258
  "transition": "width 0.5s ease-in-out"
259
259
  },
260
260
  ".steedos-instance-related-view-wrapper .instance-approve-history": {
261
261
  "width": "100%",
262
262
  "margin": "0 auto",
263
- "padding": "0 15px",
264
263
  "transition": "width 0.5s ease-in-out"
265
264
  },
266
265
  ".steedos-instance-related-view-wrapper .instance-approve-history table td": {
@@ -317,7 +316,8 @@
317
316
  ".instance-approve-history": {
318
317
  },
319
318
  ".instance-file-list": {
320
- "display": "none"
319
+ "display": "none",
320
+ "margin-bottom": "8px"
321
321
  },
322
322
  ".instance-file-list .no-print": {
323
323
  "display": "none !important"
@@ -328,6 +328,9 @@
328
328
  ".instance-related-list .no-print": {
329
329
  "display": "none !important"
330
330
  },
331
+ ".instance-file-list .liquid-amis-container button, .instance-related-list .liquid-amis-container a": {
332
+ "font-weight": "400 !important"
333
+ },
331
334
  ".antd-Form-star":{
332
335
  "display": "none !important"
333
336
  },
@@ -403,14 +406,18 @@
403
406
  "padding": "0 !important",
404
407
  "margin": "0 !important"
405
408
  },
409
+ ".steedos-instance-related-view-wrapper .steedos-amis-instance-view-content": {
410
+ "padding": "0 15px !important"
411
+ },
412
+ ".steedos-instance-related-view-wrapper .steedos-amis-instance-view-content > .antd-TplField": {
413
+ "display": "block !important"
414
+ },
406
415
  ".steedos-instance-related-view-wrapper .instance-form": {
407
416
  "margin": "0 auto",
408
- "padding": "0 15px !important",
409
417
  "width": "100% !important"
410
418
  },
411
419
  ".steedos-instance-related-view-wrapper .instance-approve-history": {
412
420
  "margin": "0 auto",
413
- "padding": "0 15px !important",
414
421
  "width": "100% !important"
415
422
  },
416
423
  ".steedos-instance-related-view-wrapper .instance-form-view": {
@@ -428,8 +435,9 @@
428
435
  "height": "auto !important"
429
436
  },
430
437
  ".steedos-instance-related-view-wrapper .instance-form .td-childfield": {
431
- "overflow-x": "auto !important",
432
- "overflow-y": "visible !important"
438
+ "overflow": "visible !important",
439
+ "vertical-align": "top !important",
440
+ "padding": "0 !important"
433
441
  },
434
442
  ".steedos-instance-related-view-wrapper .instance-form-view td": {
435
443
  "border-width": "1px !important"
@@ -460,6 +468,20 @@
460
468
  ".steedos-instance-related-view-wrapper .steedos-input-table .antd-Table-table td": {
461
469
  "border": "1px solid #000 !important"
462
470
  },
471
+ ".steedos-instance-related-view-wrapper td.td-childfield .antd-Form-item, .steedos-instance-related-view-wrapper td.td-childfield .antd-Service, .steedos-instance-related-view-wrapper td.td-childfield .antd-InputTable, .steedos-instance-related-view-wrapper td.td-childfield .antd-Table, .steedos-instance-related-view-wrapper td.td-childfield .antd-Table-contentWrap, .steedos-instance-related-view-wrapper td.td-childfield .antd-Table-content": {
472
+ "padding-top": "0 !important",
473
+ "margin-top": "0 !important",
474
+ "border-top": "0 !important",
475
+ "border-radius": "0 !important"
476
+ },
477
+ ".steedos-instance-related-view-wrapper .steedos-input-table table.antd-Table-table th, .steedos-instance-related-view-wrapper .steedos-input-table table.antd-Table-table td": {
478
+ "box-shadow": "inset -1px 0 0 #666, inset 0 -1px 0 #666 !important",
479
+ "background-image": "none !important",
480
+ "outline": "0 !important"
481
+ },
482
+ ".steedos-instance-related-view-wrapper .steedos-input-table table.antd-Table-table th:last-child, .steedos-instance-related-view-wrapper .steedos-input-table table.antd-Table-table td:last-child": {
483
+ "box-shadow": "inset 0 -1px 0 #666 !important"
484
+ },
463
485
  ".steedos-instance-related-view-wrapper .steedos-input-table .antd-Table-table th.antd-Table-operationCell, .steedos-instance-related-view-wrapper .steedos-input-table .antd-Table-table td.antd-Table-operationCell, .steedos-instance-related-view-wrapper .steedos-input-table .antd-Table-table td.steedos-input-table-column-operation": {
464
486
  "display": "none !important"
465
487
  },
@@ -510,6 +532,13 @@
510
532
  },
511
533
  ".steedos-instance-related-view-wrapper .table-page-body.form-table > tbody > tr:nth-child(2) td": {
512
534
  "border-top": "none !important"
535
+ },
536
+ ".instance-related-list .liquid-amis-container a": {
537
+ "display": "inline !important",
538
+ "font-weight": "400 !important"
539
+ },
540
+ ".instance-file-list .liquid-amis-container button": {
541
+ "font-weight": "400 !important"
513
542
  }
514
543
  }
515
544
  },
@@ -181,7 +181,7 @@ router.post('/am/forms', async function (req, res) {
181
181
  space: form['space'],
182
182
  user: userId
183
183
  });
184
- let companyId = currentSpaceUser.company_id;
184
+ let companyId = form.company_id || currentSpaceUser.company_id;
185
185
  let newForm = {
186
186
  _id: form["id"] || form["_id"],
187
187
  name: form["name"],
@@ -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
  });
@@ -280,19 +280,19 @@ router.post('/api/workflow/v2/nextStepUsersValue', requireAuthentication, async
280
280
 
281
281
  let instance = await UUFlowManager.getInstance(instanceId);
282
282
 
283
- // 优先从最近一次 traces 中查找 nextStepId 对应的处理人
283
+ // // 优先从最近一次 traces 中查找 nextStepId 对应的处理人
284
284
  let newNextUsers = [];
285
- const traces = instance.traces || [];
286
- for (let i = traces.length - 1; i >= 0; i--) {
287
- const trace = traces[i];
288
- if (trace.step === nextStepId && trace.approves && trace.approves.length > 0) {
289
- // 需要排除以下 approve.jude ['returned', 'terminated', 'retrieved'].includes(judge)
290
- newNextUsers = trace.approves
291
- .filter(approve => !['returned', 'terminated', 'retrieved'].includes(approve.judge))
292
- .map(approve => approve.handler);
293
- break;
294
- }
295
- }
285
+ // const traces = instance.traces || [];
286
+ // for (let i = traces.length - 1; i >= 0; i--) {
287
+ // const trace = traces[i];
288
+ // if (trace.step === nextStepId && trace.approves && trace.approves.length > 0) {
289
+ // // 需要排除以下 approve.jude ['returned', 'terminated', 'retrieved'].includes(judge)
290
+ // newNextUsers = trace.approves
291
+ // .filter(approve => !['returned', 'terminated', 'retrieved'].includes(approve.judge))
292
+ // .map(approve => approve.handler);
293
+ // break;
294
+ // }
295
+ // }
296
296
 
297
297
  // 如果 traces 中没有找到,回退到 step_approve
298
298
  if (newNextUsers.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos-labs/plugin-workflow",
3
- "version": "3.0.68",
3
+ "version": "3.0.70",
4
4
  "main": "package.service.js",
5
5
  "license": "MIT",
6
6
  "files": [