@steedos-labs/plugin-workflow 3.0.7 → 3.0.9
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/main/default/client/instance.client.js +4 -0
- package/main/default/client/navigation_guard.client.js +46 -0
- package/main/default/client/socket.client.js +3 -2
- package/main/default/objects/instance_tasks/buttons/instance_new.button.yml +1 -1
- package/main/default/objects/instances/buttons/instance_cc.button.yml +78 -73
- package/main/default/objects/instances/buttons/instance_new.button.yml +8 -15
- package/main/default/objects/instances/buttons/instance_related.button.yml +3 -2
- package/main/default/objects/instances/buttons/instance_relocate.button.yml +18 -11
- package/main/default/objects/instances/buttons/instance_retrieve.button.yml +5 -1
- package/main/default/objects/instances/buttons/instance_save.button.yml +3 -3
- package/main/default/objects/instances/instances.object.yml +1 -0
- package/main/default/pages/instance_tasks_detail.page.amis.json +1 -1
- package/main/default/pages/instances_list.page.amis.json +1 -1
- package/main/default/routes/afterHook.js +1 -1
- package/main/default/routes/am.router.js +6 -2
- package/main/default/routes/api_have_read.router.js +5 -0
- package/main/default/routes/api_workflow_next_step.router.js +12 -8
- package/main/default/routes/flow_form_design.ejs +2 -2
- package/main/default/triggers/amis_form_design.trigger.js +18 -1
- package/package.json +1 -1
- package/public/workflow/index.css +1 -1
|
@@ -16,6 +16,7 @@ window.SteedosWorkflow.InstanceTask = {
|
|
|
16
16
|
fields.forEach(function (field) {
|
|
17
17
|
if (field.is_list_display) {
|
|
18
18
|
crudDataFilter = crudDataFilter + `
|
|
19
|
+
if (data.display !== 'split'){
|
|
19
20
|
crud.columns.push({
|
|
20
21
|
"name": "instance__expand.values.${field.code}",
|
|
21
22
|
"label": "${field.name || field.code}",
|
|
@@ -25,6 +26,7 @@ window.SteedosWorkflow.InstanceTask = {
|
|
|
25
26
|
"static": true,
|
|
26
27
|
"options": null
|
|
27
28
|
});\r\n
|
|
29
|
+
}\r\n
|
|
28
30
|
`;
|
|
29
31
|
}
|
|
30
32
|
})
|
|
@@ -85,6 +87,7 @@ window.SteedosWorkflow.Instance = {
|
|
|
85
87
|
fields.forEach(function (field) {
|
|
86
88
|
if (field.is_list_display) {
|
|
87
89
|
crudDataFilter = crudDataFilter + `
|
|
90
|
+
if (data.display !== 'split'){
|
|
88
91
|
crud.columns.push({
|
|
89
92
|
"name": "instance__expand.values.${field.code}",
|
|
90
93
|
"label": "${field.name || field.code}",
|
|
@@ -94,6 +97,7 @@ window.SteedosWorkflow.Instance = {
|
|
|
94
97
|
"static": true,
|
|
95
98
|
"options": null
|
|
96
99
|
});\r\n
|
|
100
|
+
}\r\n
|
|
97
101
|
`;
|
|
98
102
|
}
|
|
99
103
|
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
;(
|
|
2
|
+
function (){
|
|
3
|
+
|
|
4
|
+
async function sleep(ms) {
|
|
5
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
Promise.all([
|
|
9
|
+
waitForThing(window, 'SteedosUI'),
|
|
10
|
+
]).then(()=>{
|
|
11
|
+
SteedosUI.navigationGuard.registerBeforeChange(
|
|
12
|
+
async function(blocker){
|
|
13
|
+
console.log(`blocker`, blocker);
|
|
14
|
+
// 检查当前路径是否符合条件
|
|
15
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
16
|
+
const sideListViewId = urlParams.get('side_listview_id');
|
|
17
|
+
if((window.location.pathname.startsWith('/app/approve_workflow/instance_tasks/view/') || window.location.pathname.startsWith('/app/approve_workflow/instances/view/')) && (sideListViewId==='draft' || sideListViewId==='inbox')){
|
|
18
|
+
// 检查是否发生了变化
|
|
19
|
+
if(window.SteedosWorkflow.Instance.changed){
|
|
20
|
+
// 触发保存按钮点击
|
|
21
|
+
$(".instance-save-btn").trigger('click');
|
|
22
|
+
await sleep(100);
|
|
23
|
+
try {
|
|
24
|
+
// 等待 SteedosWorkflow.Instance.changed 变为 false
|
|
25
|
+
await waitForThing(window, 'SteedosWorkflow.Instance', function(){
|
|
26
|
+
console.log('SteedosWorkflow.Instance.changed===>', SteedosWorkflow.Instance.changed)
|
|
27
|
+
return SteedosWorkflow.Instance.changed === false;
|
|
28
|
+
});
|
|
29
|
+
console.log('暂存完成....')
|
|
30
|
+
// 等待完成后返回 true
|
|
31
|
+
return true;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error('等待保存完成时发生错误:', error);
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
)()
|
|
@@ -36,17 +36,18 @@ window.waitForThing(window, 'socket').then(()=>{
|
|
|
36
36
|
});
|
|
37
37
|
})
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
let isFirstRun = true;
|
|
40
40
|
socket.on(SocketEvents.badgeChange, (data)=>{
|
|
41
41
|
window.postMessage({ type: "page.dataProvider.setData", data: { badges: data }}, "*")
|
|
42
42
|
const shouldReloadView = () => {
|
|
43
43
|
const pathname = window.location.pathname;
|
|
44
44
|
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`);
|
|
45
45
|
};
|
|
46
|
-
if (shouldReloadView()) {
|
|
46
|
+
if (isFirstRun === false && shouldReloadView()) {
|
|
47
47
|
window.$(".list-view-btn-reload").click()
|
|
48
48
|
window.$(".instance-nav-reload").click()
|
|
49
49
|
}
|
|
50
|
+
isFirstRun = false;
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
socket.on(SocketEvents.instanceRecordChange, (data)=>{
|
|
@@ -53,7 +53,7 @@ amis_schema: |-
|
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"actionType": "custom",
|
|
56
|
-
"script": "\nconst {instance, appId, objectName} = event.data;\nconsole.log(`instance===`);
|
|
56
|
+
"script": "\nconst {instance, appId, objectName} = event.data;\nconsole.log(`instance===`);doAction({\n actionType: 'link',\n args: {\n blank: false,\n url: `/app/${appId}/instances/view/${instance._id}?side_object=instances&side_listview_id=draft`\n }\n});\n"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"componentId": "",
|
|
@@ -15,11 +15,7 @@ amis_schema: |-
|
|
|
15
15
|
"actionType": "dialog",
|
|
16
16
|
"dialog": {
|
|
17
17
|
"type": "dialog",
|
|
18
|
-
"title": {
|
|
19
|
-
"type": "tpl",
|
|
20
|
-
"id": "u:0bce3c33b6e5",
|
|
21
|
-
"tpl": "<p>${'CustomAction.instances.instance_cc' | t}</p>"
|
|
22
|
-
},
|
|
18
|
+
"title": "${'CustomAction.instances.instance_cc' | t}",
|
|
23
19
|
"body": [
|
|
24
20
|
{
|
|
25
21
|
"type": "tpl",
|
|
@@ -29,69 +25,76 @@ amis_schema: |-
|
|
|
29
25
|
"className": "m-b-sm"
|
|
30
26
|
},
|
|
31
27
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
28
|
+
"type": "form",
|
|
29
|
+
"title": "表单",
|
|
30
|
+
"debug": false,
|
|
31
|
+
"body": [
|
|
32
|
+
{
|
|
33
|
+
"type": "steedos-select-user",
|
|
34
|
+
"label": "${'CustomLabels.instance_action_instance_cc_dialog_field_users' | t}",
|
|
35
|
+
"name": "users",
|
|
36
|
+
"id": "u:c3ad733db360",
|
|
37
|
+
"multiple": true,
|
|
38
|
+
"mode": "normal",
|
|
39
|
+
"required": true
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"type": "textarea",
|
|
43
|
+
"label": "${'CustomLabels.instance_action_instance_cc_dialog_field_description' | t}",
|
|
44
|
+
"name": "description",
|
|
45
|
+
"id": "u:1dc7e49e6e7d",
|
|
46
|
+
"minRows": 3,
|
|
47
|
+
"maxRows": 20
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"id": "u:742f9c0dc8a1",
|
|
51
|
+
"mode": "normal",
|
|
56
52
|
"api": {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
53
|
+
"url": "${context.rootUrl}/api/workflow/v2/cc_do",
|
|
54
|
+
"method": "post",
|
|
55
|
+
"dataType": "json",
|
|
56
|
+
"data": {
|
|
57
|
+
"&": "$$",
|
|
58
|
+
"record": "${record}"
|
|
59
|
+
},
|
|
60
|
+
"requestAdaptor": "console.log(\"api\", api);\nconst { record, users, description } = api.body;\nconst { _id, box, approve, traces } = record;\n\nlet myApprove;\n\nif ('inbox' == box) {\n myApprove = approve;\n} else if ('outbox' == box) {\n\n const getLastCCApprove = function (traces) {\n\n var currentApprove, i, user_id;\n\n user_id = context.global.userId;\n\n currentApprove = null;\n\n i = traces.length - 1;\n\n while (i >= 0) {\n if (!currentApprove && traces[i].is_finished) {\n _.each(traces[i].approves, function (ap) {\n if (!currentApprove) {\n if (ap.is_finished && ap.handler === user_id && (!ap.type || ap.type == 'cc') && ['approved', 'submitted', 'rejected'].includes(ap.judge)) {\n currentApprove = ap;\n }\n }\n });\n }\n i--;\n }\n\n return currentApprove;\n }\n\n myApprove = getLastCCApprove(traces);\n}\n\napi.data = {\n instanceId: _id,\n traceId: myApprove.trace,\n approveId: myApprove._id,\n usersId: users,\n description: description\n};\nreturn api;",
|
|
61
|
+
"adaptor": "console.log('payload', payload);\nreturn payload;",
|
|
62
|
+
"headers": {
|
|
63
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
64
|
+
},
|
|
65
|
+
"messages": {
|
|
66
|
+
"success": "传阅成功!",
|
|
67
|
+
"failed": "传阅失败"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"onEvent": {
|
|
71
|
+
"submitSucc": {
|
|
72
|
+
"actions": [
|
|
73
|
+
{
|
|
74
|
+
"actionType": "broadcast",
|
|
75
|
+
"args": {
|
|
76
|
+
"eventName": "@data.@instanceDetail.changed"
|
|
77
|
+
},
|
|
78
|
+
"data": {}
|
|
85
79
|
},
|
|
86
|
-
|
|
80
|
+
{
|
|
87
81
|
"componentId": "",
|
|
88
82
|
"args": {},
|
|
89
83
|
"actionType": "closeDialog"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"actions": [
|
|
89
|
+
{
|
|
90
|
+
"type": "submit",
|
|
91
|
+
"label": "提交",
|
|
92
|
+
"primary": true
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"feat": "Insert",
|
|
96
|
+
"dsType": "api"
|
|
97
|
+
}
|
|
95
98
|
],
|
|
96
99
|
"id": "u:519ca64b1934",
|
|
97
100
|
"actions": [
|
|
@@ -117,31 +120,32 @@ amis_schema: |-
|
|
|
117
120
|
"onEvent": {
|
|
118
121
|
"click": {
|
|
119
122
|
"actions": [
|
|
120
|
-
|
|
123
|
+
{
|
|
121
124
|
"args": {},
|
|
122
125
|
"actionType": "validate",
|
|
123
126
|
"componentId": "u:742f9c0dc8a1"
|
|
124
127
|
},
|
|
125
128
|
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
129
|
+
"componentId": "u:742f9c0dc8a1",
|
|
130
|
+
"args": {},
|
|
131
|
+
"actionType": "submit"
|
|
132
|
+
}
|
|
131
133
|
]
|
|
132
134
|
}
|
|
133
135
|
},
|
|
134
136
|
"id": "u:f7f767bed23f",
|
|
135
137
|
"level": "primary"
|
|
136
138
|
}
|
|
137
|
-
]
|
|
139
|
+
],
|
|
140
|
+
"actionType": "dialog"
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
],
|
|
141
144
|
"weight": 0
|
|
142
145
|
}
|
|
143
146
|
},
|
|
144
|
-
"hiddenOn": "!(\n
|
|
147
|
+
"hiddenOn": "${!(\n (record.box === 'inbox' && record.state === 'pending' && (_.includes(record.cc_users, context.user.userId) || (record.step && record.step.disableCC != true && record.step.step_type != 'start')))\n || (record.box === 'outbox' && record.state === 'pending' && record.lastCCStep && record.lastCCStep.disableCC != true && record.lastCCStep.step_type != 'start')\n)}",
|
|
148
|
+
"editorState": "default"
|
|
145
149
|
}
|
|
146
150
|
],
|
|
147
151
|
"regions": [
|
|
@@ -150,11 +154,12 @@ amis_schema: |-
|
|
|
150
154
|
"data": {
|
|
151
155
|
},
|
|
152
156
|
"bodyClassName": "p-0",
|
|
153
|
-
"id": "u:7414f3c8128c"
|
|
157
|
+
"id": "u:7414f3c8128c",
|
|
158
|
+
"dsType": "api",
|
|
159
|
+
"definitions": {}
|
|
154
160
|
}
|
|
155
161
|
is_enable: true
|
|
156
162
|
label: 传阅
|
|
157
163
|
'on': record_only
|
|
158
164
|
type: amis_button
|
|
159
165
|
visible: true
|
|
160
|
-
sort: 90
|
|
@@ -52,32 +52,25 @@ amis_schema: |-
|
|
|
52
52
|
"actionType": "ajax"
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
"componentId": "",
|
|
56
|
+
"args": {
|
|
57
|
+
},
|
|
58
|
+
"actionType": "closeDrawer"
|
|
59
59
|
}
|
|
60
60
|
,
|
|
61
61
|
{
|
|
62
62
|
"actionType": "custom",
|
|
63
|
-
"script": "
|
|
63
|
+
"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;"
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
"actionType": "wait",
|
|
67
67
|
"args": {
|
|
68
|
-
"time":
|
|
68
|
+
"time": 100
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
"actionType": "
|
|
73
|
-
"
|
|
74
|
-
"eventName": "@data.changed.steedos_keyvalues"
|
|
75
|
-
},
|
|
76
|
-
"data": {
|
|
77
|
-
"type": "",
|
|
78
|
-
"keyvalue": "",
|
|
79
|
-
"keyvalues": "${ss:keyvalues}"
|
|
80
|
-
}
|
|
72
|
+
"actionType": "custom",
|
|
73
|
+
"script":"window.$('.list-view-btn-reload').click()"
|
|
81
74
|
}
|
|
82
75
|
]
|
|
83
76
|
}
|
|
@@ -32,7 +32,8 @@ amis_schema: |-
|
|
|
32
32
|
"id": "u:ff88cc3375b5",
|
|
33
33
|
"reference_to": "instances",
|
|
34
34
|
"pickerSchema": {
|
|
35
|
-
"rowClassNameExpr": "<%= data.__selected === true ? 'hidden' : '' %>"
|
|
35
|
+
"rowClassNameExpr": "<%= data.__selected === true ? 'hidden' : '' %>",
|
|
36
|
+
"perPage": 20
|
|
36
37
|
},
|
|
37
38
|
"amis": {
|
|
38
39
|
"id": "u:f0273e374d19",
|
|
@@ -55,7 +56,7 @@ amis_schema: |-
|
|
|
55
56
|
"orderBy": "${orderBy}",
|
|
56
57
|
"orderDir": "${orderDir}",
|
|
57
58
|
"pageNo": "${page}",
|
|
58
|
-
"pageSize":
|
|
59
|
+
"pageSize": 20,
|
|
59
60
|
"$self": "$$",
|
|
60
61
|
"keywords": "${keywords}",
|
|
61
62
|
"ids": "${ids}"
|
|
@@ -40,25 +40,32 @@ amis_schema: |-
|
|
|
40
40
|
"tpl": "${'instance_action_instance_relocate_dialog_title_prefix' | t} <p class='font-medium inline'>${record.currentStep.name}</p>",
|
|
41
41
|
"inline": true,
|
|
42
42
|
"wrapperComponent": "",
|
|
43
|
-
"id": "u:1f7dd93080d3"
|
|
43
|
+
"id": "u:1f7dd93080d3",
|
|
44
|
+
"className": "antd-Form-item block"
|
|
44
45
|
},
|
|
45
46
|
{
|
|
46
47
|
"type": "select",
|
|
47
|
-
"label": "${'instance_next_step' | t",
|
|
48
|
+
"label": "${'instance_next_step' | t}",
|
|
48
49
|
"name": "relocate_step",
|
|
49
50
|
"id": "u:ee15214c1808",
|
|
50
51
|
"multiple": false,
|
|
51
52
|
"required": true,
|
|
52
|
-
"source": "${stepsOption}"
|
|
53
|
+
"source": "${stepsOption}",
|
|
54
|
+
"onEvent": {
|
|
55
|
+
"change": {
|
|
56
|
+
"actions": [
|
|
57
|
+
{
|
|
58
|
+
"actionType": "custom",
|
|
59
|
+
"script": "let step = event.data.selectedItems.step; doAction({actionType: 'setValue', componentId: 'u:1779a48caedb', args: {value: {deal_type: step.deal_type, step_type: step.step_type, _id: step._id }}})"
|
|
60
|
+
}]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
53
63
|
},
|
|
54
64
|
{
|
|
55
|
-
"type": "steedos-
|
|
56
|
-
"label": "
|
|
65
|
+
"type": "steedos-instance-handler",
|
|
66
|
+
"label": "处理人",
|
|
67
|
+
"id": "u:relocate_users",
|
|
57
68
|
"name": "relocate_users",
|
|
58
|
-
"id": "u:c3ad733db360",
|
|
59
|
-
"multiple": true,
|
|
60
|
-
"mode": "normal",
|
|
61
|
-
"required": true,
|
|
62
69
|
"visibleOn": "this.relocate_step && !this.relocate_step.startsWith('start.') && !this.relocate_step.startsWith('end.')"
|
|
63
70
|
},
|
|
64
71
|
{
|
|
@@ -79,7 +86,7 @@ amis_schema: |-
|
|
|
79
86
|
"url": "${context.rootUrl}/api/workflow/relocate",
|
|
80
87
|
"method": "post",
|
|
81
88
|
"dataType": "json",
|
|
82
|
-
"requestAdaptor": "const { record, relocate_users, relocate_step, reason } = api.data;\napi.data = {\n \"Instances\": [{\n _id: record._id, relocate_next_step: relocate_step.split('.')[1], relocate_inbox_users: relocate_users, relocate_comment: reason\n }]\n}\n\nreturn api;",
|
|
89
|
+
"requestAdaptor": "const { record, relocate_users, relocate_step, reason } = api.data;\napi.data = {\n \"Instances\": [{\n _id: record._id, relocate_next_step: relocate_step.split('.')[1], relocate_inbox_users: _.isString(relocate_users) ? [relocate_users] : relocate_users, relocate_comment: reason\n }]\n}\n\nreturn api;",
|
|
83
90
|
"adaptor": "return response.status == 200 ? {data: {...payload}, status: 0, msg: t('instance_action_relocate_dialog_msg_success')} : {...payload, status: 1, msg: t('instance_action_relocate_dialog_msg_failed')};"
|
|
84
91
|
},
|
|
85
92
|
"onEvent": {
|
|
@@ -103,7 +110,7 @@ amis_schema: |-
|
|
|
103
110
|
}
|
|
104
111
|
],
|
|
105
112
|
"messages": {},
|
|
106
|
-
"dataProvider": "const stepsOption = [];\n\n_.each(data.record.flowVersion.steps, (step) => {\n stepsOption.push({\n label: step.name,\n value: `${step.step_type}.${step._id}
|
|
113
|
+
"dataProvider": "const stepsOption = [];\n\n_.each(data.record.flowVersion.steps, (step) => {\n stepsOption.push({\n label: step.name,\n value: `${step.step_type}.${step._id}`,\n step: step })\n})\nsetData({ stepsOption })\n\n"
|
|
107
114
|
}
|
|
108
115
|
],
|
|
109
116
|
"showCloseButton": true,
|
|
@@ -54,7 +54,7 @@ amis_schema: |-
|
|
|
54
54
|
"api": {
|
|
55
55
|
"url": "${context.rootUrl}/api/workflow/retrieve",
|
|
56
56
|
"method": "post",
|
|
57
|
-
"requestAdaptor": "
|
|
57
|
+
"requestAdaptor": "api.data = {\n \"_id\": api.body.record._id,\n \"retrieve_comment\": api.body.retrieve_comment\n};\nreturn api;",
|
|
58
58
|
"adaptor": "console.log('payload', payload);\nreturn payload;",
|
|
59
59
|
"messages": {},
|
|
60
60
|
"headers": {
|
|
@@ -72,6 +72,10 @@ amis_schema: |-
|
|
|
72
72
|
"eventName": "@data.@instanceDetail.changed"
|
|
73
73
|
},
|
|
74
74
|
"data": {}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"actionType": "custom",
|
|
78
|
+
"script": "$('.steedos-workflow-reload-btn').trigger('click')"
|
|
75
79
|
}
|
|
76
80
|
]
|
|
77
81
|
}
|
|
@@ -7,7 +7,7 @@ amis_schema: |-
|
|
|
7
7
|
"type": "button",
|
|
8
8
|
"label": "${'CustomAction.instances.instance_save' | t}",
|
|
9
9
|
"id": "u:instance_save",
|
|
10
|
-
"className": "
|
|
10
|
+
"className": "instance-save-btn",
|
|
11
11
|
"onEvent": {
|
|
12
12
|
"click": {
|
|
13
13
|
"actions": [
|
|
@@ -18,7 +18,7 @@ amis_schema: |-
|
|
|
18
18
|
"method": "post",
|
|
19
19
|
"sendOn": "",
|
|
20
20
|
"requestAdaptor": "var _SteedosUI$getRef$get, _approveValues$next_s;\nconst formValues = context._scoped.getComponentById(\"instance_form\").getValues();const _formValues = JSON.parse(JSON.stringify(formValues)); if(_formValues){delete _formValues.__applicant} \nconst approveValues = (_SteedosUI$getRef$get = context._scoped.getComponentById(\"instance_approval\")) === null || _SteedosUI$getRef$get === void 0 ? void 0 : _SteedosUI$getRef$get.getValues();\nlet nextUsers = approveValues === null || approveValues === void 0 ? void 0 : approveValues.next_users;\nif (_.isString(nextUsers)) {\n nextUsers = [approveValues.next_users];\n}\nconst instance = context.record;\nconst body = {\n instance: {\n _id: instance._id,\n applicant: formValues.applicant.user,\n submitter: formValues.submitter,\n traces: [{\n _id: instance.trace._id,\n step: instance.step._id,\n approves: [{\n _id: instance.approve._id,\n next_steps: [{\n step: approveValues === null || approveValues === void 0 || (_approveValues$next_s = approveValues.next_step) === null || _approveValues$next_s === void 0 ? void 0 : _approveValues$next_s._id,\n users: nextUsers\n }],\n description: approveValues === null || approveValues === void 0 ? void 0 : approveValues.suggestion,\n values: _formValues\n }]\n }]\n }\n};\napi.data = body;\nreturn api;",
|
|
21
|
-
"adaptor": "if (payload.instance == \"upgraded\") { window.setTimeout(function(){ window.location.reload(); }, 2000); return {...payload, status: 1, msg: t('instance_action_instance_save_msg_upgraded')}; } \n return payload.instance === true ? {...payload, status: 0, msg: t('instance_action_instance_save_msg_success')} : {...payload, status: 1, msg: t('instance_action_instance_save_msg_failed')};",
|
|
21
|
+
"adaptor": "window.SteedosWorkflow.Instance.changed = false; if (payload.instance == \"upgraded\") { window.setTimeout(function(){ window.location.reload(); }, 2000); return {...payload, status: 1, msg: t('instance_action_instance_save_msg_upgraded')}; } \n return payload.instance === true ? {...payload, status: 0, msg: t('instance_action_instance_save_msg_success')} : {...payload, status: 1, msg: t('instance_action_instance_save_msg_failed')};",
|
|
22
22
|
"headers": {
|
|
23
23
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
24
24
|
},
|
|
@@ -37,7 +37,7 @@ amis_schema: |-
|
|
|
37
37
|
"method": "post",
|
|
38
38
|
"sendOn": "",
|
|
39
39
|
"requestAdaptor": "var _SteedosUI$getRef$get, _approveValues$next_s;\nconst formValues = context._scoped.getComponentById(\"instance_form\").getValues();\nconst approveValues = (_SteedosUI$getRef$get = context._scoped.getComponentById(\"instance_approval\")) === null || _SteedosUI$getRef$get === void 0 ? void 0 : _SteedosUI$getRef$get.getValues();\nlet nextUsers = approveValues === null || approveValues === void 0 ? void 0 : approveValues.next_users;\nif (_.isString(nextUsers)) {\n nextUsers = [approveValues.next_users];\n}\nconst instance = context.record;\nconst body = {\n approve: {\n id: instance.approve._id,\n instance: instance._id,\n trace: instance.trace._id,\n next_steps: [{\n step: approveValues === null || approveValues === void 0 || (_approveValues$next_s = approveValues.next_step) === null || _approveValues$next_s === void 0 ? void 0 : _approveValues$next_s._id,\n users: nextUsers\n }],\n description: approveValues === null || approveValues === void 0 ? void 0 : approveValues.suggestion,\n judge: approveValues === null || approveValues === void 0 ? void 0 : approveValues.judge,\n values: formValues\n }\n};\napi.data = body;\nreturn api;",
|
|
40
|
-
"adaptor": "return payload.instance ? {...payload, status: 0, msg: t('instance_action_instance_save_msg_success')} : {...payload, status: 1, msg: t('instance_action_instance_save_msg_failed')};",
|
|
40
|
+
"adaptor": "window.SteedosWorkflow.Instance.changed = false; return payload.instance ? {...payload, status: 0, msg: t('instance_action_instance_save_msg_success')} : {...payload, status: 1, msg: t('instance_action_instance_save_msg_failed')};",
|
|
41
41
|
"headers": {
|
|
42
42
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
43
43
|
},
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
122
122
|
},
|
|
123
123
|
"requestAdaptor": "\nconst { recordId } = api.body;\napi.data = {\n query: `{instance_task:instance_tasks__findOne(id: \"${recordId}\"){_id,instance,is_read}}`\n};\n\nreturn api;",
|
|
124
|
-
"adaptor": "\nlet boxName = api.body.side_listview_id === 'inbox' ? 'inbox' : 'outbox';\npayload.data = {\n instanceId: payload.data.instance_task.instance,\n boxName: boxName,\n isRead: payload.data.instance_task.is_read\n}\n; console.log('=======>payload===>', payload); \n const result = {data: {'type':'wrapper','className':'p-0 h-full','body':[{'type':'steedos-instance-detail','id':'u:40052b3812c1','label':'Instance Detail','instanceId':payload.data.instanceId,'boxName':context.side_listview_id}],'id':'u:829a40757f0a'}};console.log('result===>', result); return result;"
|
|
124
|
+
"adaptor": "if(!payload.data.instance_task){return payload;}\nlet boxName = api.body.side_listview_id === 'inbox' ? 'inbox' : 'outbox';\npayload.data = {\n instanceId: payload.data.instance_task.instance,\n boxName: boxName,\n isRead: payload.data.instance_task.is_read\n}\n; console.log('=======>payload===>', payload); \n const result = {data: {'type':'wrapper','className':'p-0 h-full','body':[{'type':'steedos-instance-detail','id':'u:40052b3812c1','label':'Instance Detail','instanceId':payload.data.instanceId,'boxName':context.side_listview_id}],'id':'u:829a40757f0a'}};console.log('result===>', result); return result;"
|
|
125
125
|
},
|
|
126
126
|
"onEvent": {
|
|
127
127
|
"fetchSchemaInited": {
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
"listName": "completed",
|
|
203
203
|
"rebuildOn": "${flowId || categoryId}",
|
|
204
204
|
"adaptor": "//在列表上加流程表单字段时,group和user需要特殊处理\nif (api.body.self.listName == \"monitor\") {\n _.each(payload.data.rows, function (item, index) {\n if (item.values) {\n const form_fields = api.body.self.form_fields;\n _.each(item.values, function (field, field_code) {\n const form_field = _.find(form_fields, { code: field_code });\n if (form_field && form_field.type == \"group\") {\n if (form_field.is_multiselect) {\n item.values[field_code] = field && field.length > 0 ? _.map(field, 'fullname').toString() : \"\";\n } else {\n item.values[field_code] = field ? field.fullname : \"\";\n }\n } else if (form_field && form_field.type == \"user\") {\n if (form_field.is_multiselect) {\n item.values[field_code] = field && field.length > 0 ? _.map(field, 'name').toString() : \"\";\n } else {\n item.values[field_code] = field ? field.name : \"\";\n }\n }\n })\n }\n })\n}\n",
|
|
205
|
-
"crudDataFilter": "if (data && data.flowId && (data.listName == 'inbox' || 'monitor') && window.innerWidth > 768) {\r\n var api = {\r\n url: \"${context.rootUrl}/graphql\",\r\n method: \"post\",\r\n dataType: \"json\",\r\n data: {\r\n \"query\": '{flow: flows__findOne(id:\"' + data.flowId + '\"){form__expand{current}}}'\r\n },\r\n headers: {\r\n Authorization:\r\n \"Bearer ${context.tenantId},${context.authToken}\",\r\n },\r\n };\r\n return env.fetcher(api).then((result) => {\r\n if (result.data && result.data.flow && result.data.flow.form__expand.current.fields && result.data.flow.form__expand.current.fields.length > 0) {\r\n let fields = result.data.flow.form__expand.current.fields;\r\n fields.forEach(function (field) {\r\n if (field.is_list_display) {\r\n crud.columns.push({\r\n \"name\": \"values.\" + field.code,\r\n \"label\": field.name || field.code,\r\n \"width\": \"unset\",\r\n \"type\": \"text\",\r\n \"className\": \" whitespace-nowrap\",\r\n \"static\": true,\r\n \"options\": null\r\n });\r\n }\r\n })\r\n let schemaApiService = data._scoped.parent.getComponentById(\"instances_list_service\");\r\n schemaApiService && schemaApiService.setData({ form_fields: fields, isFlowDataDone: true });\r\n // crud.api.sendOn = \"this.isFlowDataDone\";\r\n }\r\n return crud;\r\n });\r\n} else {\r\n let schemaApiService = data._scoped.parent.getComponentById(\"instances_list_service\");\r\n schemaApiService && schemaApiService.setData({ isFlowDataDone: true });\r\n // crud.api.sendOn = \"this.isFlowDataDone\";\r\n return crud;\r\n}\r\n"
|
|
205
|
+
"crudDataFilter": "if (data && data.flowId && (data.listName == 'inbox' || 'monitor') && window.innerWidth > 768) {\r\n var api = {\r\n url: \"${context.rootUrl}/graphql\",\r\n method: \"post\",\r\n dataType: \"json\",\r\n data: {\r\n \"query\": '{flow: flows__findOne(id:\"' + data.flowId + '\"){form__expand{current}}}'\r\n },\r\n headers: {\r\n Authorization:\r\n \"Bearer ${context.tenantId},${context.authToken}\",\r\n },\r\n };\r\n return env.fetcher(api).then((result) => {\r\n if (result.data && result.data.flow && result.data.flow.form__expand.current.fields && result.data.flow.form__expand.current.fields.length > 0) {\r\n let fields = result.data.flow.form__expand.current.fields;\r\n fields.forEach(function (field) {\r\n if (field.is_list_display && data.display !== 'split') {\r\n crud.columns.push({\r\n \"name\": \"values.\" + field.code,\r\n \"label\": field.name || field.code,\r\n \"width\": \"unset\",\r\n \"type\": \"text\",\r\n \"className\": \" whitespace-nowrap\",\r\n \"static\": true,\r\n \"options\": null\r\n });\r\n }\r\n })\r\n let schemaApiService = data._scoped.parent.getComponentById(\"instances_list_service\");\r\n schemaApiService && schemaApiService.setData({ form_fields: fields, isFlowDataDone: true });\r\n // crud.api.sendOn = \"this.isFlowDataDone\";\r\n }\r\n return crud;\r\n });\r\n} else {\r\n let schemaApiService = data._scoped.parent.getComponentById(\"instances_list_service\");\r\n schemaApiService && schemaApiService.setData({ isFlowDataDone: true });\r\n // crud.api.sendOn = \"this.isFlowDataDone\";\r\n return crud;\r\n}\r\n"
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
208
|
"type": "service",
|
|
@@ -17,7 +17,7 @@ const afterHook = (req, res, next) => {
|
|
|
17
17
|
id: ins_id,
|
|
18
18
|
doc: {},
|
|
19
19
|
})
|
|
20
|
-
}else if(req.
|
|
20
|
+
}else if(req.url.includes('/api/workflow/relocate')){
|
|
21
21
|
var hashData = req.body;
|
|
22
22
|
const instance_from_client = hashData['Instances'][0];
|
|
23
23
|
const ins_id = instance_from_client._id;
|
|
@@ -537,8 +537,12 @@ router.put('/am/flows', async function (req, res) {
|
|
|
537
537
|
}
|
|
538
538
|
});
|
|
539
539
|
updateObj.$set.category = form['category'];
|
|
540
|
-
|
|
541
|
-
|
|
540
|
+
const updateData = { ...updateObj.$set };
|
|
541
|
+
if (updateObj.$push) {
|
|
542
|
+
updateData.$push = updateObj.$push;
|
|
543
|
+
}
|
|
544
|
+
await objectql.getObject('flows').update(flowId, updateData);
|
|
545
|
+
console.log('update', flowId, 'end');
|
|
542
546
|
updatedFlows.push(await flowCollection.findOne({_id: flowId}));
|
|
543
547
|
}
|
|
544
548
|
|
|
@@ -43,6 +43,11 @@ router.post('/api/workflow/v2/set_have_read', requireAuthentication, async funct
|
|
|
43
43
|
"type": 1
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
+
if(!instance_task){
|
|
47
|
+
return res.status(200).send({
|
|
48
|
+
success: true
|
|
49
|
+
});
|
|
50
|
+
}
|
|
46
51
|
if (instance_task.is_read){
|
|
47
52
|
return res.status(200).send({
|
|
48
53
|
success: true
|
|
@@ -227,16 +227,20 @@ const calcSteps = async function(instance, flow, flowVersionId, formFields, valu
|
|
|
227
227
|
var judge = 'approved';
|
|
228
228
|
|
|
229
229
|
_steps.push(step);
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
230
|
+
try {
|
|
231
|
+
var nextSteps = await getNextSteps(flow, flowVersionId, instance, step, judge, values);
|
|
232
|
+
for (const nextStep of nextSteps) {
|
|
233
|
+
try {
|
|
234
|
+
if (!_.includes(track, nextStep._id)) {
|
|
235
|
+
const __steps = await calcSteps(instance, flow, flowVersionId, formFields, values, nextStep, track.concat(_.map(_steps, '_id')));
|
|
236
|
+
_steps = _steps.concat(__steps)
|
|
237
|
+
}
|
|
238
|
+
} catch (e) {
|
|
239
|
+
console.log(e)
|
|
236
240
|
}
|
|
237
|
-
} catch (e) {
|
|
238
|
-
console.log(e)
|
|
239
241
|
}
|
|
242
|
+
} catch (error) {
|
|
243
|
+
console.log(error)
|
|
240
244
|
}
|
|
241
245
|
_steps = _.compact(_.uniqBy(_steps, 'id'));
|
|
242
246
|
return _steps;
|
|
@@ -498,9 +498,9 @@
|
|
|
498
498
|
}
|
|
499
499
|
break;
|
|
500
500
|
case "section":
|
|
501
|
-
tpl.type = "
|
|
501
|
+
tpl.type = "steedos-field-group";
|
|
502
502
|
tpl.title = field.name;
|
|
503
|
-
tpl.
|
|
503
|
+
tpl.description = field.description;
|
|
504
504
|
tpl.body = []
|
|
505
505
|
if (field.fields) {
|
|
506
506
|
for (let i = 0; i < field.fields.length; i++) {
|
|
@@ -198,9 +198,13 @@ function transformFormFields(amisField) {
|
|
|
198
198
|
is_list_display: _.includes(amisField.className, "is_list_display"),
|
|
199
199
|
is_searchable: _.includes(amisField.className, "is_searchable"),
|
|
200
200
|
visibleOn: amisField.visibleOn,
|
|
201
|
-
requiredOn: amisField.requiredOn
|
|
201
|
+
requiredOn: amisField.requiredOn,
|
|
202
|
+
description: amisField.description,
|
|
203
|
+
_amisField: amisField
|
|
202
204
|
}
|
|
203
205
|
|
|
206
|
+
// console.log('formFieldsItem', formFieldsItem)
|
|
207
|
+
|
|
204
208
|
switch (amisField.type) {
|
|
205
209
|
case 'steedos-field-group':
|
|
206
210
|
formFieldsItem.type = 'section';
|
|
@@ -560,6 +564,19 @@ module.exports = {
|
|
|
560
564
|
await desingerManager.checkSpaceUserBeforeUpdate(spaceId, userId, roles);
|
|
561
565
|
// 更新表单
|
|
562
566
|
await desingerManager.updateForm(this.id, form, updatedForms, updatedFlows, userId);
|
|
567
|
+
|
|
568
|
+
const flows = await objectql.getObject('flows').directFind({
|
|
569
|
+
filters: ['form', '=', this.id],
|
|
570
|
+
fields: ['_id']
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
for (const flow of flows) {
|
|
574
|
+
await objectql.getObject('flows').directUpdate(flow._id, {
|
|
575
|
+
modified: new Date(),
|
|
576
|
+
modified_by: userId
|
|
577
|
+
})
|
|
578
|
+
}
|
|
579
|
+
|
|
563
580
|
}
|
|
564
581
|
|
|
565
582
|
},
|
package/package.json
CHANGED