@steedos/standard-process-approval 3.0.0-beta.25 → 3.0.0-beta.27

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.
@@ -38,11 +38,7 @@ Steedos.ProcessManager.allowSubmit = function(object_name, record_id){
38
38
  if(!object_name || !record_id){
39
39
  return false;
40
40
  }
41
- var _window$Creator;
42
- const object = this.object || ((_window$Creator = window.Creator) === null || _window$Creator === void 0 ? void 0 : _window$Creator.getObject(object_name));
43
- if(!object.enable_process){
44
- return false;
45
- }
41
+
46
42
  var result = Steedos.authRequest(`/api/v4/process/permission/submit/${object_name}/${record_id}`, {type: 'get', async: false});
47
43
  if(result && result.allowSubmit){
48
44
  return true;
@@ -0,0 +1,58 @@
1
+ name: copy
2
+ amis_schema: |-
3
+ {
4
+ "type": "service",
5
+ "body": [
6
+ {
7
+ "type": "button",
8
+ "label": "${'CustomAction.process_definition.copy' | t}",
9
+ "id": "u:copy",
10
+ "onEvent": {
11
+ "click": {
12
+ "weight": 0,
13
+ "actions": [
14
+ {
15
+ "ignoreError": false,
16
+ "actionType": "ajax",
17
+ "outputVar": "responseResult",
18
+ "options": {},
19
+ "api": {
20
+ "url": "${context.rootUrl}/service/api/approval_process/process_definition/${recordId}/copy",
21
+ "method": "get",
22
+ "adaptor": "",
23
+ "messages": {}
24
+ }
25
+ },
26
+ {
27
+ "actionType": "custom",
28
+ "script": "window.location.href = '/app/admin/process_definition/view/' + (event.data.responseResult && event.data.responseResult._id);",
29
+ "expression": "${responseResult.state == 'SUCCESS'}"
30
+ }
31
+ ]
32
+ }
33
+ }
34
+ }
35
+ ],
36
+ "regions": [
37
+ "body"
38
+ ],
39
+ "data": {
40
+ "context": {},
41
+ "dataComponentId": "",
42
+ "record_id": "",
43
+ "record": {},
44
+ "permissions": {}
45
+ },
46
+ "bodyClassName": "p-0",
47
+ "dsType": "api",
48
+ "asideResizor": false,
49
+ "editorState": "default",
50
+ "pullRefresh": {
51
+ "disabled": true
52
+ }
53
+ }
54
+ is_enable: true
55
+ label: 复制
56
+ "on": record
57
+ type: amis_button
58
+ visible: true
@@ -0,0 +1,64 @@
1
+ name: disable
2
+ amis_schema: |-
3
+ {
4
+ "type": "service",
5
+ "body": [
6
+ {
7
+ "type": "button",
8
+ "label": "${'CustomAction.process_definition.disable' | t}",
9
+ "id": "u:disable",
10
+ "onEvent": {
11
+ "click": {
12
+ "weight": 0,
13
+ "actions": [
14
+ {
15
+ "ignoreError": false,
16
+ "actionType": "ajax",
17
+ "outputVar": "responseResult",
18
+ "options": {},
19
+ "api": {
20
+ "url": "${context.rootUrl}/api/v1/process_definition/${recordId}",
21
+ "method": "put",
22
+ "requestAdaptor": "return {\n ...api,\n data: {\n doc: {\n active: false\n }\n }\n};",
23
+ "adaptor": "",
24
+ "messages": {}
25
+ }
26
+ },
27
+ {
28
+ "actionType": "broadcast",
29
+ "args": {
30
+ "eventName": "@data.changed.process_definition"
31
+ },
32
+ "data": {
33
+ "objectName": "process_definition"
34
+ }
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ "visibleOn": "${active && !is_system}"
40
+ }
41
+ ],
42
+ "regions": [
43
+ "body"
44
+ ],
45
+ "data": {
46
+ "context": {},
47
+ "dataComponentId": "",
48
+ "record_id": "",
49
+ "record": {},
50
+ "permissions": {}
51
+ },
52
+ "bodyClassName": "p-0",
53
+ "dsType": "api",
54
+ "asideResizor": false,
55
+ "editorState": "default",
56
+ "pullRefresh": {
57
+ "disabled": true
58
+ }
59
+ }
60
+ is_enable: true
61
+ label: 停用
62
+ "on": record
63
+ type: amis_button
64
+ visible: true
@@ -0,0 +1,64 @@
1
+ name: enable
2
+ amis_schema: |-
3
+ {
4
+ "type": "service",
5
+ "body": [
6
+ {
7
+ "type": "button",
8
+ "label": "${'CustomAction.process_definition.enable' | t}",
9
+ "id": "u:enable",
10
+ "onEvent": {
11
+ "click": {
12
+ "weight": 0,
13
+ "actions": [
14
+ {
15
+ "ignoreError": false,
16
+ "actionType": "ajax",
17
+ "outputVar": "responseResult",
18
+ "options": {},
19
+ "api": {
20
+ "url": "${context.rootUrl}/api/v1/process_definition/${recordId}",
21
+ "method": "put",
22
+ "requestAdaptor": "return {\n ...api,\n data: {\n doc: {\n active: true\n }\n }\n};",
23
+ "adaptor": "",
24
+ "messages": {}
25
+ }
26
+ },
27
+ {
28
+ "actionType": "broadcast",
29
+ "args": {
30
+ "eventName": "@data.changed.process_definition"
31
+ },
32
+ "data": {
33
+ "objectName": "process_definition"
34
+ }
35
+ }
36
+ ]
37
+ }
38
+ },
39
+ "visibleOn": "${!active && !is_system}"
40
+ }
41
+ ],
42
+ "regions": [
43
+ "body"
44
+ ],
45
+ "data": {
46
+ "context": {},
47
+ "dataComponentId": "",
48
+ "record_id": "",
49
+ "record": {},
50
+ "permissions": {}
51
+ },
52
+ "bodyClassName": "p-0",
53
+ "dsType": "api",
54
+ "asideResizor": false,
55
+ "editorState": "default",
56
+ "pullRefresh": {
57
+ "disabled": true
58
+ }
59
+ }
60
+ is_enable: true
61
+ label: 启用
62
+ "on": record
63
+ type: amis_button
64
+ visible: true
@@ -1,27 +1,10 @@
1
+ /*
2
+ * @Author: 殷亮辉 yinlianghui@hotoa.com
3
+ * @Date: 2025-04-14 09:47:57
4
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5
+ * @LastEditTime: 2025-05-13 12:09:08
6
+ */
1
7
  module.exports = {
2
- enableVisible: function (object_name, record_id, record_permissions) {
3
- var result = Steedos.authRequest(`/api/v4/${object_name}/${record_id}`, { type: 'get', async: false });
4
- return !result.active && !result.is_system
5
- },
6
- enable: function (object_name, record_id, fields) {
7
- Steedos.authRequest(`/api/v4/${object_name}/${record_id}`, { type: 'put', async: false, data: JSON.stringify({ active: true }) });
8
- FlowRouter.reload();
9
- },
10
- disableVisible: function (object_name, record_id, record_permissions) {
11
- var result = Steedos.authRequest(`/api/v4/${object_name}/${record_id}`, { type: 'get', async: false });
12
- return result.active && !result.is_system
13
- },
14
- disable: function (object_name, record_id, fields) {
15
- Steedos.authRequest(`/api/v4/${object_name}/${record_id}`, { type: 'put', async: false, data: JSON.stringify({ active: false }) });
16
- FlowRouter.reload();
17
- },
18
- copyVisible: function(){
19
- return true;
20
- },
21
- copy: function (object_name, record_id, fields) {
22
- let result = Steedos.authRequest(`/api/v4/${object_name}/${record_id}/copy`, { type: 'get', async: false });
23
- FlowRouter.go(`/app/admin/process_definition/view/${result._id}`);
24
- },
25
8
  customize: function (object_name, record_id, fields) {
26
9
  var doc = Creator.odata.get(object_name, record_id);
27
10
  var newDoc = {}
@@ -35,9 +18,9 @@ module.exports = {
35
18
  let docName = doc.name
36
19
  let docObjectName = doc.object_name
37
20
 
38
- Creator.odata.insert(object_name, Object.assign(newDoc, { name: docName, object_name: docObjectName, active:false }), function (result, error) {
21
+ Creator.odata.insert(object_name, Object.assign(newDoc, { name: docName, object_name: docObjectName, active: false }), function (result, error) {
39
22
  if (result) {
40
- for(let node of doc.process_nodes){
23
+ for (let node of doc.process_nodes) {
41
24
  let nodeName = node.name
42
25
  var newNode = {}
43
26
  _.each(Creator.getObject('process_node').fields, function (v, k) {
@@ -89,23 +89,22 @@ fields:
89
89
  visible_on: "{{ formData.approver != 'submitter_choose' }}"
90
90
  depend_on:
91
91
  - process_definition
92
- optionsFunction: !!js/function |
93
- function (doc){
94
- var options = [];
95
- if(doc.process_definition){
96
- var pid = doc.process_definition;
97
- if(_.isObject(pid)){
98
- pid = pid._id;
99
- }
100
- var object_name = Creator.odata.get("process_definition", pid, "object_name").object_name;
101
- var userFields = _.filter(Creator.getObject(object_name).fields, function(field){
102
- return (field.type === 'lookup' || field.type === 'master_detail') && field.omit != true && (field.reference_to === 'users' || (field.reference_to === 'space_users' && field.reference_to_field === 'user'))
103
- });
104
- _.each(userFields, function(field){
105
- options.push({label:field.label, value:field.name});
106
- })
92
+ reference_to: object_fields
93
+ reference_to_field: name
94
+ filtersFunction: !<tag:yaml.org,2002:js/function> |-
95
+ function (filters, values) {
96
+ var pid = values.process_definition;
97
+ if(_.isObject(pid)){
98
+ pid = pid._id;
99
+ }
100
+ var result = Steedos.authRequest("/api/v1/process_definition/" + pid + "?fields=[\"object_name\"]", {type: 'get', async: false});
101
+ var pObjectName = result && result.data && result.data.object_name;
102
+ if(pObjectName){
103
+ return [['object', '=', pObjectName], [['type', '=', 'lookup'], 'or', ['type', '=', 'master_detail']], [['reference_to', '=', 'users'], 'or', [['reference_to', '=', 'space_users'],['reference_to_field', '=', 'user']]], ['omit', '!=', true]];
104
+ }
105
+ else{
106
+ return ['object', '=', -1];
107
107
  }
108
- return options;
109
108
  }
110
109
  when_multiple_approvers:
111
110
  type: select
@@ -149,8 +148,14 @@ fields:
149
148
  if(_.isObject(pid)){
150
149
  pid = pid._id;
151
150
  }
152
- var object_name = Creator.odata.get("process_definition", pid, "object_name").object_name;
153
- return "object_name eq '" + object_name + "'";
151
+ var result = Steedos.authRequest("/api/v1/process_definition/" + pid + "?fields=[\"object_name\"]", {type: 'get', async: false});
152
+ var pObjectName = result && result.data && result.data.object_name;
153
+ if(pObjectName){
154
+ return ['object_name', '=', pObjectName];
155
+ }
156
+ else{
157
+ return ['object_name', '=', -1];
158
+ }
154
159
  }
155
160
  }
156
161
  group: Approval Actions
@@ -169,8 +174,14 @@ fields:
169
174
  if(_.isObject(pid)){
170
175
  pid = pid._id;
171
176
  }
172
- var object_name = Creator.odata.get("process_definition", pid, "object_name").object_name;
173
- return "object_name eq '" + object_name + "'";
177
+ var result = Steedos.authRequest("/api/v1/process_definition/" + pid + "?fields=[\"object_name\"]", {type: 'get', async: false});
178
+ var pObjectName = result && result.data && result.data.object_name;
179
+ if(pObjectName){
180
+ return ['object_name', '=', pObjectName];
181
+ }
182
+ else{
183
+ return ['object_name', '=', -1];
184
+ }
174
185
  }
175
186
  }
176
187
  group: Approval Actions
@@ -189,8 +200,14 @@ fields:
189
200
  if(_.isObject(pid)){
190
201
  pid = pid._id;
191
202
  }
192
- var object_name = Creator.odata.get("process_definition", pid, "object_name").object_name;
193
- return "object_name eq '" + object_name + "'";
203
+ var result = Steedos.authRequest("/api/v1/process_definition/" + pid + "?fields=[\"object_name\"]", {type: 'get', async: false});
204
+ var pObjectName = result && result.data && result.data.object_name;
205
+ if(pObjectName){
206
+ return ['object_name', '=', pObjectName];
207
+ }
208
+ else{
209
+ return ['object_name', '=', -1];
210
+ }
194
211
  }
195
212
  }
196
213
  group: Rejection Actions
@@ -209,8 +226,14 @@ fields:
209
226
  if(_.isObject(pid)){
210
227
  pid = pid._id;
211
228
  }
212
- var object_name = Creator.odata.get("process_definition", pid, "object_name").object_name;
213
- return "object_name eq '" + object_name + "'";
229
+ var result = Steedos.authRequest("/api/v1/process_definition/" + pid + "?fields=[\"object_name\"]", {type: 'get', async: false});
230
+ var pObjectName = result && result.data && result.data.object_name;
231
+ if(pObjectName){
232
+ return ['object_name', '=', pObjectName];
233
+ }
234
+ else{
235
+ return ['object_name', '=', -1];
236
+ }
214
237
  }
215
238
  }
216
239
  group: Rejection Actions
@@ -0,0 +1,35 @@
1
+ {
2
+ "type": "service",
3
+ "body": [
4
+ {
5
+ "type": "steedos-object-form",
6
+ "label": "对象表单",
7
+ "objectApiName": "process_definition",
8
+ "recordId": "${recordId}",
9
+ "className": "",
10
+ "enableTabs": false,
11
+ "mode": "edit",
12
+ "layout": "normal",
13
+ "tabsMode": "",
14
+ "fieldsExtend": {
15
+ "entry_criteria": {
16
+ "amis": {
17
+ "type": "service",
18
+ "schemaApi": {
19
+ "method": "get",
20
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
21
+ "cache": 30000,
22
+ "adaptor": "const field = context.uiSchema.fields.entry_criteria; const variables = SteedosUI.getFormulaVariables(payload.data.options); \n var fieldSchema={label: field.label, type:'input-formula', name: 'entry_criteria', 'evalMode': false, variableMode: 'tabs', variables: variables, labelRemark: field.inlineHelpText, description: field.description } \n return {...payload, data:fieldSchema};",
23
+ "trackExpression": "${object_name}",
24
+ "sendOn": "${object_name}"
25
+ },
26
+ "dsType": "api"
27
+ }
28
+ }
29
+ }
30
+ }
31
+ ],
32
+ "data": {},
33
+ "name": "page_process_definition_form",
34
+ "dsType": "api"
35
+ }
@@ -0,0 +1,13 @@
1
+ name: process_definition_form
2
+ is_active: true
3
+ label: 批准过程表单
4
+ locked: false
5
+ object_name: process_definition
6
+ pageAssignments:
7
+ - type: orgDefault
8
+ page: process_definition_form
9
+ desktop: true
10
+ mobile: true
11
+ render_engine: amis
12
+ type: form
13
+ widgets: []
@@ -0,0 +1,65 @@
1
+ {
2
+ "type": "service",
3
+ "body": [
4
+ {
5
+ "type": "steedos-object-form",
6
+ "label": "对象表单",
7
+ "objectApiName": "process_node",
8
+ "recordId": "${recordId}",
9
+ "className": "",
10
+ "enableTabs": false,
11
+ "mode": "edit",
12
+ "layout": "normal",
13
+ "tabsMode": "",
14
+ "id": "u:1c918e931a42",
15
+ "onEvent": {
16
+ "inited": {
17
+ "actions": [
18
+ {
19
+ "actionType": "ajax",
20
+ "api": {
21
+ "method": "get",
22
+ "url": "${context.rootUrl}/api/v1/process_definition/${process_definition}?fields=[\"object_name\"]",
23
+ "cache": 30000,
24
+ "adaptor": "return {...payload, data:{processDefinitionObjectName: payload.data.object_name}};",
25
+ "headers": {
26
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
27
+ }
28
+ }
29
+ },
30
+ {
31
+ "actionType": "setValue",
32
+ "args": {
33
+ "value": {
34
+ "processDefinitionObjectName": "${event.data.processDefinitionObjectName}"
35
+ }
36
+ },
37
+ "componentId": "page_process_node_form"
38
+ }
39
+ ]
40
+ }
41
+ },
42
+ "fieldsExtend": {
43
+ "entry_criteria": {
44
+ "amis": {
45
+ "type": "service",
46
+ "id": "u:46bf09af8f92",
47
+ "schemaApi": {
48
+ "method": "get",
49
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${processDefinitionObjectName}/fields/options",
50
+ "cache": 30000,
51
+ "adaptor": "const field = context.uiSchema.fields.entry_criteria; const variables = SteedosUI.getFormulaVariables(payload.data.options); \n var fieldSchema={label: field.label, type:'input-formula', name: 'entry_criteria', 'evalMode': false, variableMode: 'tabs', variables: variables, labelRemark: field.inlineHelpText, description: field.description } \n return {...payload, data:fieldSchema};",
52
+ "trackExpression": "${processDefinitionObjectName}",
53
+ "sendOn": "${processDefinitionObjectName}"
54
+ },
55
+ "dsType": "api"
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ],
61
+ "data": {},
62
+ "name": "page_process_node_form",
63
+ "dsType": "api",
64
+ "id": "page_process_node_form"
65
+ }
@@ -0,0 +1,13 @@
1
+ name: process_node_form
2
+ is_active: true
3
+ label: 批准步骤表单
4
+ locked: false
5
+ object_name: process_node
6
+ pageAssignments:
7
+ - type: orgDefault
8
+ page: process_node_form
9
+ desktop: true
10
+ mobile: true
11
+ render_engine: amis
12
+ type: form
13
+ widgets: []
@@ -1,11 +1,12 @@
1
1
  /*
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 2022-12-14 10:26:50
4
- * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2022-12-14 17:15:10
4
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5
+ * @LastEditTime: 2025-05-13 12:14:22
6
6
  * @Description:
7
7
  */
8
8
  const { getObjectProcessDefinition, recordSubmit } = require('@steedos/process')
9
+ const objectql = require('@steedos/objectql');
9
10
  "use strict";
10
11
  /**
11
12
  * @typedef {import('moleculer').Context} Context Moleculer's Context
@@ -89,6 +90,69 @@ module.exports = {
89
90
  }
90
91
  },
91
92
 
93
+ /**
94
+ * @api {call} copy 复制
95
+ * @apiVersion 0.0.0
96
+ * @apiName copy
97
+ * @apiGroup approval_process.service.js
98
+ * @apiBody {String} recordId 记录ID
99
+ * @apiSuccess {String} state 返回复制结果
100
+ * @apiSuccessExample {json} Success-Response:
101
+ * HTTP/1.1 200 OK
102
+ * {
103
+ * "state": "SUCCESS",
104
+ * _id: newPDID
105
+ * }
106
+ * @apiErrorExample {json} Error-Response:
107
+ * HTTP/1.1 200 OK
108
+ * {
109
+ * "state": "FAILURE",
110
+ * "error": ""
111
+ * }
112
+ */
113
+ copy: {
114
+ // 访问地址: GET /service/api/approval_process/process_definition/:recordId/copy
115
+ rest: {
116
+ method: "GET",
117
+ path: '/process_definition/:recordId/copy'
118
+ },
119
+ params: {
120
+ recordId: { type: 'string' }
121
+ },
122
+ async handler(ctx) {
123
+ try {
124
+ this.broker.logger.info('[service][approval_process]===>', 'process_definition/:recordId/copy', ctx.params.name, ctx.params.recordId)
125
+ const userSession = ctx.meta.user;
126
+ const params = ctx.params;
127
+ const recordId = params.recordId;
128
+ const pdObj = objectql.getObject('process_definition');
129
+ const pnObj = objectql.getObject('process_node');
130
+ const nowTime = new Date().getTime();
131
+ let pd = await pdObj.findOne(recordId, undefined, userSession);
132
+ delete pd._id;
133
+ pd.name = `pd_${nowTime}`; // 名称长度不能大于20个字符;名称只能包含小写字母、数字,必须以字母开头,不能以下划线字符结尾或包含两个连续的下划线字符
134
+ pd.active = false; // 批准过程已启用或者已提交过审批, 禁止添加、删除批准步骤
135
+ let newPD = await pdObj.insert(pd);
136
+ let newPDID = newPD._id;
137
+ let pns = await pnObj.find({ filters: ['process_definition', '=', recordId] }, userSession);
138
+ for (let index = 0; index < pns.length; index++) {
139
+ let pn = pns[index];
140
+ delete pn._id;
141
+ pn.process_definition = newPDID;
142
+ pn.name = `pn_${nowTime}_${index}`;
143
+ const now = new Date();
144
+ pn.created = now;
145
+ pn.created_by = userSession.userId
146
+ pn.modified = now;
147
+ pn.modified_by = userSession.userId
148
+ await pnObj.directInsert(pn);
149
+ }
150
+ return { state: 'SUCCESS', _id: newPDID };
151
+ } catch (error) {
152
+ return { state: 'FAILURE', error: error.message };
153
+ }
154
+ }
155
+ }
92
156
  },
93
157
 
94
158
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-process-approval",
3
- "version": "3.0.0-beta.25",
3
+ "version": "3.0.0-beta.27",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -10,11 +10,11 @@
10
10
  "steedos"
11
11
  ],
12
12
  "dependencies": {
13
- "@steedos/process": "3.0.0-beta.25",
13
+ "@steedos/process": "3.0.0-beta.27",
14
14
  "nanoid": "^3.3.4"
15
15
  },
16
16
  "description": "steedos package",
17
17
  "repository": {},
18
18
  "license": "MIT",
19
- "gitHead": "bcc2f288c4444202c4ec728beed73d00fe429841"
19
+ "gitHead": "fe5a3b939e02c85e644b84a03c4dc2d62d8af5e1"
20
20
  }
@@ -1,155 +0,0 @@
1
- Steedos.ProcessFieldUpdatesManager = {};
2
-
3
- Steedos.ProcessFieldUpdatesManager.changeSchema = function (doc, schema) {
4
- var objectSchema = Creator.getObjectSchema(Creator.getObject("action_field_updates"));
5
- var operation = doc.operation;
6
-
7
- var hiddenField = function (fieldName) {
8
- schema._schema[fieldName].autoform.omit = true;
9
- schema._schema[fieldName].autoform.type = 'hidden';
10
- }
11
- // var recordId = Session.get("record_id");
12
- var objectName = Session.get("object_name");
13
- var actionObjectName = Session.get("action_object_name");
14
- var actionOperation = Session.get("cmOperation");
15
- if (objectName == 'process_node') {
16
- var processDefinitionId = AutoForm.getFormValues("creatorEditForm").insertDoc.process_definition; //Creator.odata.get("process_node", recordId, "process_definition").process_definition;
17
- if(processDefinitionId){
18
- var object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
19
- schema._schema.object_name.autoform.readonly = true;
20
- doc.object_name = object_name;
21
- }else{
22
- toastr.error(t("action_field_updates_field__error_process_node_process_definition_required"));
23
- }
24
- }
25
-
26
- if (objectName == 'process_definition') {
27
- var object_name = null;
28
- if(actionObjectName == "process_definition"){
29
- // 当前正在新建或编辑批准过程
30
- if (actionOperation == 'update') {
31
- object_name = AutoForm.getFormValues("creatorEditForm").insertDoc.object_name;
32
- } else {
33
- object_name = AutoForm.getFormValues("creatorAddForm").insertDoc.object_name;
34
- }
35
- if(!object_name){
36
- toastr.error(t("action_field_updates_field__error_process_definition_object_required"));
37
- }
38
- }else{
39
- // 当前正在新建或编辑批准过程以外其他对象,目前只有批准过程详细界面新建或编辑批准步骤
40
- if (actionOperation == 'update') {
41
- var processDefinitionId = AutoForm.getFormValues("creatorEditForm").insertDoc.process_definition;
42
- if(processDefinitionId){
43
- object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
44
- }
45
- else{
46
- toastr.error(t("action_field_updates_field__error_process_node_process_definition_required"));
47
- }
48
- } else {
49
- var formValues = AutoForm.getFormValues("creatorAddRelatedForm");
50
- if(!formValues){
51
- // 有可能是在批准过程详细界面点击了批准步骤列表顶部的链接进入了“相关批准步骤列表界面”然后点击的右上角的新建按钮触发的
52
- formValues = AutoForm.getFormValues("creatorAddForm");
53
- }
54
- var processDefinitionId = formValues.insertDoc.process_definition;
55
- if(processDefinitionId){
56
- object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
57
- }
58
- else{
59
- toastr.error(t("action_field_updates_field__error_process_node_process_definition_required"));
60
- }
61
- }
62
- }
63
- schema._schema.object_name.autoform.readonly = true;
64
- doc.object_name = object_name;
65
- }
66
-
67
- if (objectName == 'workflow_rule') {
68
- var object_name = null;
69
- if (actionOperation == 'update') {
70
- object_name = AutoForm.getFormValues("creatorEditForm").insertDoc.object_name //Creator.odata.get("workflow_rule", Session.get("record_id"), "object_name").object_name;
71
- } else {
72
- object_name = AutoForm.getFormValues("creatorAddForm").insertDoc.object_name
73
- }
74
- schema._schema.object_name.autoform.readonly = true;
75
- if(object_name){
76
- doc.object_name = object_name;
77
- }
78
- else{
79
- toastr.error(t("action_field_updates_field__error_workflow_rule_object_required"));
80
- }
81
- }
82
-
83
- // if(doc.process_definition){
84
- // hiddenField('process_node');
85
- // schema._schema.when.autoform.options = _.filter(objectSchema.when.autoform.options, function(option){return _.include(['final_approval','final_rejection','recall','initial_submission'], option.value)});
86
- // var pid = doc.process_definition;
87
- // if(_.isObject(pid)){
88
- // if(_.has(pid, 'ids') && pid.ids.length > 0){
89
- // pid = pid.ids[0];
90
- // }else{
91
- // pid = pid._id;
92
- // }
93
- // }
94
- // var object_name = Creator.odata.get("process_definition", pid, "object_name").object_name;
95
- // schema._schema.object_name.optionsFunction = function(){var _obj = Creator.getObject(object_name); return [{label: _obj.label, value: _obj.name, icon: _obj.icon}]}
96
- // doc.object_name = object_name;
97
- // }else{
98
- // schema._schema.process_node = objectSchema.process_node;
99
- // schema._schema.when.autoform.options = _.filter(objectSchema.when.autoform.options, function(option){return _.include(['approval','rejection'], option.value)})
100
- // }
101
-
102
- // if(doc.process_node){
103
- // hiddenField('process_definition');
104
- // var pnid = doc.process_node;
105
- // if(_.isObject(pnid)){
106
- // if(_.has(pnid, 'ids') && pnid.ids.length > 0){
107
- // pnid = pnid.ids[0];
108
- // }else{
109
- // pnid = pnid._id;
110
- // }
111
- // }
112
- // var processDefinitionId = Creator.odata.get("process_node", pnid, "process_definition").process_definition;
113
- // var object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
114
- // schema._schema.object_name.optionsFunction = function(){var _obj = Creator.getObject(object_name); return [{label: _obj.label, value: _obj.name, icon: _obj.icon}]}
115
- // doc.object_name = object_name;
116
- // schema._schema.when.autoform.options = _.filter(objectSchema.when.autoform.options, function(option){return _.include(['approval','rejection'], option.value)})
117
- // }else{
118
- // schema._schema.process_definition = objectSchema.process_definition;
119
- // schema._schema.when.autoform.options = _.filter(objectSchema.when.autoform.options, function(option){return _.include(['final_approval','final_rejection','recall','initial_submission'], option.value)})
120
- // }
121
-
122
- if (operation === 'null') {
123
- hiddenField('formula');
124
- hiddenField('literal_value');
125
- }
126
-
127
- if (operation === 'formula') {
128
- schema._schema.formula = objectSchema.formula;
129
- hiddenField('literal_value');
130
- }
131
-
132
- if (operation === 'literal') {
133
- schema._schema.formula.autoform.type = 'hidden';
134
- var doc = doc;
135
- var mainObjectName = null;
136
- if (doc.target_object && doc.target_object != doc.object_name) {
137
- var mainObjectName = Creator.objectsByName[doc.object_name].fields[doc.target_object].reference_to;
138
- } else {
139
- mainObjectName = doc.object_name;
140
- }
141
- var object = Creator.objectsByName[mainObjectName];
142
- if (object && doc.field_name) {
143
- schema._schema.literal_value = Object.assign({}, Creator.getObjectSchema(Creator.getObject(mainObjectName))[doc.field_name], { label: schema._schema.literal_value.label });
144
- schema._schema.literal_value.autoform.disabled = false;
145
- schema._schema.literal_value.autoform.omit = false;
146
- schema._schema.literal_value.autoform.readonly = false;
147
- schema._schema.literal_value.autoform.is_wide = true;
148
- } else {
149
- schema._schema.literal_value.autoform.type = 'text';
150
- }
151
-
152
- }else{
153
- schema._schema.literal_value.optional = true;
154
- }
155
- }
@@ -1,74 +0,0 @@
1
- Steedos.WorkflowNotificationsManager = {};
2
-
3
- Steedos.WorkflowNotificationsManager.changeSchema = function (doc, schema) {
4
- var objectName = Session.get("object_name");
5
- var actionObjectName = Session.get("action_object_name");
6
- var actionOperation = Session.get("cmOperation");
7
- if (objectName == 'process_node') {
8
- var processDefinitionId = AutoForm.getFormValues("creatorEditForm").insertDoc.process_definition; //Creator.odata.get("process_node", recordId, "process_definition").process_definition;
9
- if(processDefinitionId){
10
- var object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
11
- schema._schema.object_name.autoform.readonly = true;
12
- doc.object_name = object_name;
13
- }else{
14
- toastr.error(t("workflow_notifications_field__error_process_node_process_definition_required"));
15
- }
16
- }
17
-
18
- if (objectName == 'process_definition') {
19
- var object_name = null;
20
- if(actionObjectName == "process_definition"){
21
- // 当前正在新建或编辑批准过程
22
- if (actionOperation == 'update') {
23
- object_name = AutoForm.getFormValues("creatorEditForm").insertDoc.object_name;
24
- } else {
25
- object_name = AutoForm.getFormValues("creatorAddForm").insertDoc.object_name;
26
- }
27
- if(!object_name){
28
- toastr.error(t("workflow_notifications_field__error_process_definition_object_required"));
29
- }
30
- }else{
31
- // 当前正在新建或编辑批准过程以外其他对象,目前只有批准过程详细界面新建或编辑批准步骤
32
- if (actionOperation == 'update') {
33
- var processDefinitionId = AutoForm.getFormValues("creatorEditForm").insertDoc.process_definition;
34
- if(processDefinitionId){
35
- object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
36
- }
37
- else{
38
- toastr.error(t("workflow_notifications_field__error_process_node_process_definition_required"));
39
- }
40
- } else {
41
- var formValues = AutoForm.getFormValues("creatorAddRelatedForm");
42
- if(!formValues){
43
- // 有可能是在批准过程详细界面点击了批准步骤列表顶部的链接进入了“相关批准步骤列表界面”然后点击的右上角的新建按钮触发的
44
- formValues = AutoForm.getFormValues("creatorAddForm");
45
- }
46
- var processDefinitionId = formValues.insertDoc.process_definition;
47
- if(processDefinitionId){
48
- object_name = Creator.odata.get("process_definition", processDefinitionId, "object_name").object_name;
49
- }
50
- else{
51
- toastr.error(t("workflow_notifications_field__error_process_node_process_definition_required"));
52
- }
53
- }
54
- }
55
- schema._schema.object_name.autoform.readonly = true;
56
- doc.object_name = object_name;
57
- }
58
-
59
- if (objectName == 'workflow_rule') {
60
- var object_name = null;
61
- if (actionOperation == 'update') {
62
- object_name = AutoForm.getFormValues("creatorEditForm").insertDoc.object_name //Creator.odata.get("workflow_rule", Session.get("record_id"), "object_name").object_name;
63
- } else {
64
- object_name = AutoForm.getFormValues("creatorAddForm").insertDoc.object_name
65
- }
66
- schema._schema.object_name.autoform.readonly = true;
67
- if(object_name){
68
- doc.object_name = object_name;
69
- }
70
- else{
71
- toastr.error(t("workflow_notifications_field__error_workflow_rule_object_required"));
72
- }
73
- }
74
- }