@steedos/service-plugin-amis 2.7.4-beta.8 → 2.7.4

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.
@@ -2,13 +2,48 @@
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2024-01-26 11:40:59
4
4
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5
- * @LastEditTime: 2024-03-01 14:19:42
5
+ * @LastEditTime: 2024-08-06 16:56:04
6
6
  * @Description:
7
7
  */
8
8
 
9
9
 
10
10
  let amisLib = amisRequire('amis');
11
11
 
12
+ const draftsApiRequestAdaptor = `
13
+ api.data = {
14
+ "Instances": [{
15
+ "flow": api.body.flows[0].flow_id,
16
+ "applicant": api.body.context.userId,
17
+ "space": api.body.context.tenantId,
18
+ "record_ids": [{ o: api.body.objectName, ids: [api.body.recordId] }]
19
+ }]
20
+ }
21
+
22
+ return api;
23
+ `;
24
+
25
+ const draftsApiAdaptor = `
26
+ if (payload.error) {
27
+ return {
28
+ status: 2,
29
+ msg: payload.error
30
+ }
31
+ }
32
+ var instance = payload.inserts[0];
33
+ var url = Steedos.absoluteUrl("/app/" + FlowRouter.current().params.app_id + "/instances/view/" + instance._id + "?display=" + (Steedos.Page.getDisplay('instances') || '') + "&side_object=instances&side_listview_id=draft");
34
+ // 这里不可以直接openWindow,因为手机浏览器上打不开新窗口,迁移到下面的afterDrafts脚本中,在custom动作单独执行openWindow才行
35
+ // Steedos.openWindow(url);
36
+ // if(!Steedos.isMobile()){ FlowRouter.reload();}
37
+ payload.draftUrl = url;
38
+ return payload;
39
+ `;
40
+
41
+ const afterDrafts = `
42
+ var url = event.data.draftUrl;
43
+ Steedos.openWindow(url);
44
+ if(!Steedos.isMobile()){ FlowRouter.reload();}
45
+ `;
46
+
12
47
  amisLib.registerAction('steedos_actions_standard_approve', {
13
48
  run: function(action, renderer, event, mergeData){
14
49
  return amisLib.runActions([
@@ -18,14 +53,16 @@ amisLib.registerAction('steedos_actions_standard_approve', {
18
53
  },
19
54
  {
20
55
  "actionType": "ajax",
21
- "outputVar": "responseResult",
56
+ "outputVar": "responseDraftsResult",
22
57
  "args": {
23
58
  "options": {},
24
59
  "api": {
25
60
  "url": "${context.rootUrl}/api/object/workflow/drafts",
26
61
  "method": "post",
27
- "requestAdaptor":"api.data = {\n \'Instances\': [{\n \'flow\': api.body.flows[0].flow_id,\n \'applicant\': api.body.context.userId,\n \'space\': api.body.context.tenantId,\n \'record_ids\': [{ o: api.body.objectName, ids: [api.body.recordId] }]\n }]\n}\n\nreturn api;",
28
- "adaptor":"\nif (payload.error) { \n return {\n status: 2,\n msg: payload.error\n }\n}\nconst instance = payload.inserts[0];\nSteedos.openWindow(Steedos.absoluteUrl(\'/app/\' + FlowRouter.current().params.app_id + \'/instances/view/\' + instance._id + \'?display=\' + (Steedos.Page.getDisplay('instances') || '') + \'&side_object=instances&side_listview_id=draft\'))\n if(!Steedos.isMobile()){ FlowRouter.reload();} \nreturn payload;",
62
+ "requestAdaptor": draftsApiRequestAdaptor,
63
+ // "requestAdaptor":"api.data = {\n \'Instances\': [{\n \'flow\': api.body.flows[0].flow_id,\n \'applicant\': api.body.context.userId,\n \'space\': api.body.context.tenantId,\n \'record_ids\': [{ o: api.body.objectName, ids: [api.body.recordId] }]\n }]\n}\n\nreturn api;",
64
+ "adaptor": draftsApiAdaptor,
65
+ // "adaptor":"\nif (payload.error) { \n return {\n status: 2,\n msg: payload.error\n }\n}\nconst instance = payload.inserts[0];\nSteedos.openWindow(Steedos.absoluteUrl(\'/app/\' + FlowRouter.current().params.app_id + \'/instances/view/\' + instance._id + \'?display=\' + (Steedos.Page.getDisplay('instances') || '') + \'&side_object=instances&side_listview_id=draft\'))\n if(!Steedos.isMobile()){ FlowRouter.reload();} \nreturn payload;",
29
66
  "messages": {},
30
67
  "headers": {
31
68
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
@@ -40,6 +77,11 @@ amisLib.registerAction('steedos_actions_standard_approve', {
40
77
  },
41
78
  "expression": "${event.data.flowCount == 1}"
42
79
  },
80
+ {
81
+ "actionType": "custom",
82
+ "script": afterDrafts,
83
+ "expression": "${event.data.flowCount == 1}"
84
+ },
43
85
  {
44
86
  "actionType": "dialog",
45
87
  "expression": "${event.data.flowCount > 1}",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "2.7.4-beta.8",
3
+ "version": "2.7.4",
4
4
  "main": "package.service.js",
5
5
  "scripts": {
6
6
  "build": "yarn build:tailwind-base && yarn build:tailwind",
@@ -13,7 +13,7 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "gitHead": "8ac12a0c7221d87c1f391c159e8a76a4206629b1",
16
+ "gitHead": "108f3aa82b8c8b284078254ccd4ce75f2b6e777d",
17
17
  "devDependencies": {
18
18
  "tailwindcss": "3.2.4"
19
19
  }