@steedos/standard-process-approval 2.4.0-beta.30 → 2.4.0-beta.32
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/objectTranslations/action_field_updates.zh-CN/action_field_updates.zh-CN.objectTranslation.yml +7 -0
- package/main/default/objects/workflow-actions/action_field_updates.object.yml +12 -75
- package/main/default/objects/workflow-actions/workflow_rule.object.yml +6 -6
- package/main/default/services/action_field_updates.service.js +249 -0
- package/package.json +3 -3
|
@@ -21,96 +21,33 @@ fields:
|
|
|
21
21
|
target_object:
|
|
22
22
|
type: lookup
|
|
23
23
|
label: Object to Update
|
|
24
|
+
reference_to: objects
|
|
25
|
+
reference_to_field: name
|
|
24
26
|
depend_on:
|
|
25
27
|
- object_name
|
|
26
|
-
optionsFunction: !!js/function |
|
|
27
|
-
function (doc) {
|
|
28
|
-
var object = Creator.objectsByName[doc.object_name];
|
|
29
|
-
if(object){
|
|
30
|
-
var _options = [{label: object.label, value: object.name}];
|
|
31
|
-
_.forEach(object.fields, function (field, fname) {
|
|
32
|
-
if(field && field.type === 'master_detail' && _.isString(field.reference_to)){
|
|
33
|
-
var referenceToObject = Creator.objectsByName[field.reference_to];
|
|
34
|
-
if(referenceToObject){
|
|
35
|
-
_options.push({
|
|
36
|
-
label: referenceToObject.label,
|
|
37
|
-
value: field.name,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
return _options;
|
|
43
|
-
}
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
28
|
field_name:
|
|
47
29
|
label: Field to Update
|
|
48
30
|
type: lookup
|
|
49
31
|
showIcon: false
|
|
32
|
+
reference_to: object_fields
|
|
33
|
+
reference_to_field: name
|
|
50
34
|
depend_on:
|
|
51
35
|
- object_name
|
|
52
36
|
- target_object
|
|
53
|
-
optionsFunction: !!js/function |
|
|
54
|
-
function (doc) {
|
|
55
|
-
var mainObjectName = null;
|
|
56
|
-
if(doc.target_object && doc.target_object != doc.object_name){
|
|
57
|
-
mainObjectName = Creator.objectsByName[doc.object_name].fields[doc.target_object].reference_to;
|
|
58
|
-
}else{
|
|
59
|
-
mainObjectName = doc.object_name;
|
|
60
|
-
}
|
|
61
|
-
var object = Creator.objectsByName[mainObjectName];
|
|
62
|
-
if(object){
|
|
63
|
-
var _options = [];
|
|
64
|
-
_.forEach(object.fields, function (field, fname) {
|
|
65
|
-
if(["formula", "summary", "autonumber"].indexOf(field.type) < 0){
|
|
66
|
-
/*公式、累计汇总、自动编号三种字段类型是只读的,不允许字段更新来变更其值*/
|
|
67
|
-
_options.push({
|
|
68
|
-
label: field.label,
|
|
69
|
-
value: field.name,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return _options;
|
|
74
|
-
}
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
37
|
operation:
|
|
78
|
-
type:
|
|
38
|
+
type: select
|
|
79
39
|
showIcon: false
|
|
80
40
|
depend_on:
|
|
81
41
|
- field_name
|
|
82
42
|
- target_object
|
|
83
43
|
- object_name
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
var object = Creator.objectsByName[mainObjectName];
|
|
93
|
-
if(object && doc.field_name){
|
|
94
|
-
var _options = [];
|
|
95
|
-
var field = object.fields[doc.field_name];
|
|
96
|
-
if(field && field.type != 'boolean'){
|
|
97
|
-
_options.push({
|
|
98
|
-
label: TAPi18n.__("action_field_updates_field_operation_options_null"),
|
|
99
|
-
value: 'null',
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
_options.push({
|
|
103
|
-
label: TAPi18n.__("action_field_updates_field_operation_options_formula"),
|
|
104
|
-
value: 'formula',
|
|
105
|
-
});
|
|
106
|
-
_options.push({
|
|
107
|
-
label: TAPi18n.__("action_field_updates_field_operation_options_literal"),
|
|
108
|
-
value: 'literal',
|
|
109
|
-
})
|
|
110
|
-
return _options;
|
|
111
|
-
}
|
|
112
|
-
return [];
|
|
113
|
-
}
|
|
44
|
+
options:
|
|
45
|
+
- label: 'null'
|
|
46
|
+
value: 'null'
|
|
47
|
+
- label: formula
|
|
48
|
+
value: formula
|
|
49
|
+
- label: literal
|
|
50
|
+
value: literal
|
|
114
51
|
# options:
|
|
115
52
|
# - label: 'Null'
|
|
116
53
|
# value: 'null'
|
|
@@ -50,7 +50,7 @@ fields:
|
|
|
50
50
|
filtersFunction: !!js/function |
|
|
51
51
|
function (filters, dependValues) {
|
|
52
52
|
if(dependValues && dependValues.object_name){
|
|
53
|
-
return
|
|
53
|
+
return ['object_name','=',dependValues.object_name];
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
workflow_notifications_actions:
|
|
@@ -66,7 +66,7 @@ fields:
|
|
|
66
66
|
filtersFunction: !!js/function |
|
|
67
67
|
function (filters, dependValues) {
|
|
68
68
|
if(dependValues && dependValues.object_name){
|
|
69
|
-
return
|
|
69
|
+
return ['object_name','=',dependValues.object_name];
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
workflow_outbound_messages_actions:
|
|
@@ -82,7 +82,7 @@ fields:
|
|
|
82
82
|
filtersFunction: !!js/function |
|
|
83
83
|
function (filters, dependValues) {
|
|
84
84
|
if(dependValues && dependValues.object_name){
|
|
85
|
-
return
|
|
85
|
+
return ['object_name','=',dependValues.object_name];
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
# boolean_filter: # TODO 暂不支持
|
|
@@ -172,7 +172,7 @@ fields:
|
|
|
172
172
|
filtersFunction: !!js/function |
|
|
173
173
|
function (filters, dependValues) {
|
|
174
174
|
if(dependValues && dependValues.object_name){
|
|
175
|
-
return
|
|
175
|
+
return ['object_name','=',dependValues.object_name];
|
|
176
176
|
}
|
|
177
177
|
}
|
|
178
178
|
time_triggers.$.workflow_notifications_actions:
|
|
@@ -187,7 +187,7 @@ fields:
|
|
|
187
187
|
filtersFunction: !!js/function |
|
|
188
188
|
function (filters, dependValues) {
|
|
189
189
|
if(dependValues && dependValues.object_name){
|
|
190
|
-
return
|
|
190
|
+
return ['object_name','=',dependValues.object_name];
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
time_triggers.$.workflow_outbound_messages_actions:
|
|
@@ -202,7 +202,7 @@ fields:
|
|
|
202
202
|
filtersFunction: !!js/function |
|
|
203
203
|
function (filters, dependValues) {
|
|
204
204
|
if(dependValues && dependValues.object_name){
|
|
205
|
-
return
|
|
205
|
+
return ['object_name','=',dependValues.object_name];
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
description:
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Description: 提供action_field_updates(字段更新对象)需要的数据接口
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const objectql = require("@steedos/objectql");
|
|
6
|
+
const steedosI18n = require("@steedos/i18n");
|
|
7
|
+
const _ = require("lodash");
|
|
8
|
+
const clone = require("clone");
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
name: "action_field_updates",
|
|
13
|
+
mixins: [],
|
|
14
|
+
/**
|
|
15
|
+
* Settings
|
|
16
|
+
*/
|
|
17
|
+
settings: {
|
|
18
|
+
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Dependencies
|
|
23
|
+
*/
|
|
24
|
+
dependencies: [],
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Actions
|
|
28
|
+
*/
|
|
29
|
+
actions: {
|
|
30
|
+
getTargetObjectOptions: {
|
|
31
|
+
// 需要传 objectName 参数进来。
|
|
32
|
+
rest: {
|
|
33
|
+
method: "GET",
|
|
34
|
+
path: "/target_object/options"
|
|
35
|
+
},
|
|
36
|
+
async handler(ctx) {
|
|
37
|
+
const options = await this.getTargetObjectOptions(ctx);
|
|
38
|
+
return { status: 0, data: { options } }
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
getFieldNameOptions: {
|
|
42
|
+
// 需要传 objectName, targetObject 参数进来。
|
|
43
|
+
rest: {
|
|
44
|
+
method: "GET",
|
|
45
|
+
path: "/field_name/options"
|
|
46
|
+
},
|
|
47
|
+
async handler(ctx) {
|
|
48
|
+
const options = await this.getFieldNameOptions(ctx);
|
|
49
|
+
return { status: 0, data: { options } }
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
getOperationOptions: {
|
|
53
|
+
// 需要传 objectName, targetObject(非必填), field_name 参数进来。
|
|
54
|
+
rest: {
|
|
55
|
+
method: "GET",
|
|
56
|
+
path: "/operation/options"
|
|
57
|
+
},
|
|
58
|
+
async handler(ctx) {
|
|
59
|
+
const options = await this.getOperationOptions(ctx);
|
|
60
|
+
return { status: 0, data: { options } }
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
getLiteralValueOptions: {
|
|
64
|
+
// 需要传 objectName, targetObject(非必填), field_name 参数进来。
|
|
65
|
+
rest: {
|
|
66
|
+
method: "GET",
|
|
67
|
+
path: "/literal_value/options"
|
|
68
|
+
},
|
|
69
|
+
async handler(ctx) {
|
|
70
|
+
const data = await this.getLiteralValueOptions(ctx);
|
|
71
|
+
return { status: 0, msg: "", data: data }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Events
|
|
78
|
+
*/
|
|
79
|
+
events: {
|
|
80
|
+
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Methods
|
|
85
|
+
*/
|
|
86
|
+
methods: {
|
|
87
|
+
/* target_object 字段使用*/
|
|
88
|
+
getTargetObjectOptions: {
|
|
89
|
+
async handler(ctx) {
|
|
90
|
+
const userSession = ctx.meta.user;
|
|
91
|
+
const lng = userSession.language || 'zh-CN';
|
|
92
|
+
const objectName = ctx.params.objectName;
|
|
93
|
+
if(!objectName){
|
|
94
|
+
return []
|
|
95
|
+
}
|
|
96
|
+
const objectConfig = await objectql.getObjectConfig(objectName);
|
|
97
|
+
steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
|
|
98
|
+
|
|
99
|
+
const options = [{ label: objectConfig.label, value: objectConfig.name }];
|
|
100
|
+
for (fieldName in objectConfig.fields) {
|
|
101
|
+
const field = objectConfig.fields[fieldName]
|
|
102
|
+
if (field && field.type === 'master_detail' && _.isString(field.reference_to)) {
|
|
103
|
+
const referenceToObjectConfig = await objectql.getObjectConfig(field.reference_to);
|
|
104
|
+
steedosI18n.translationObject(lng, referenceToObjectConfig.name, referenceToObjectConfig);
|
|
105
|
+
if (referenceToObjectConfig) {
|
|
106
|
+
options.push({
|
|
107
|
+
label: referenceToObjectConfig.label,
|
|
108
|
+
value: field.name,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return options;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
/* field_name 字段使用*/
|
|
117
|
+
getFieldNameOptions: {
|
|
118
|
+
async handler(ctx) {
|
|
119
|
+
const userSession = ctx.meta.user;
|
|
120
|
+
const lng = userSession.language || 'zh-CN';
|
|
121
|
+
const objectName = ctx.params.objectName;
|
|
122
|
+
const targetObject = ctx.params.targetObject;
|
|
123
|
+
if (!objectName || !targetObject) {
|
|
124
|
+
return []
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let mainObjectName = null;
|
|
128
|
+
if (targetObject && targetObject != objectName) {
|
|
129
|
+
mainObjectName = await objectql.getObjectConfig(objectName).fields[targetObject]?.reference_to;
|
|
130
|
+
} else {
|
|
131
|
+
mainObjectName = objectName;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const objectConfig = await objectql.getObjectConfig(mainObjectName);
|
|
135
|
+
const options = [];
|
|
136
|
+
if (objectConfig) {
|
|
137
|
+
steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
|
|
138
|
+
_.forEach(objectConfig.fields, function (field, fname) {
|
|
139
|
+
if (["formula", "summary", "autonumber"].indexOf(field.type) < 0 && !field.hidden && !field.omit && !field.readonly && field.visible_on !== '{{false}}') {
|
|
140
|
+
/*公式、累计汇总、自动编号三种字段类型是只读的,不允许字段更新来变更其值*/
|
|
141
|
+
options.push({
|
|
142
|
+
label: field.label,
|
|
143
|
+
value: field.name,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return options;
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
/* operation 字段使用*/
|
|
152
|
+
getOperationOptions: {
|
|
153
|
+
async handler(ctx) {
|
|
154
|
+
const userSession = ctx.meta.user;
|
|
155
|
+
const lng = userSession.language || 'zh-CN';
|
|
156
|
+
const objectName = ctx.params.objectName;
|
|
157
|
+
const targetObject = ctx.params.targetObject;
|
|
158
|
+
const fieldName = ctx.params.fieldName;
|
|
159
|
+
|
|
160
|
+
if (!objectName || !fieldName) {
|
|
161
|
+
return []
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
let mainObjectName = null;
|
|
165
|
+
if (targetObject && targetObject != objectName) {
|
|
166
|
+
mainObjectName = await objectql.getObjectConfig(objectName).fields[targetObject]?.reference_to;
|
|
167
|
+
} else {
|
|
168
|
+
mainObjectName = objectName;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const objectConfig = await objectql.getObjectConfig(mainObjectName);
|
|
172
|
+
const options = [];
|
|
173
|
+
if (objectConfig) {
|
|
174
|
+
steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
|
|
175
|
+
const field = objectConfig.fields[fieldName];
|
|
176
|
+
if (field && field.type != 'boolean') {
|
|
177
|
+
options.push({
|
|
178
|
+
label: TAPi18n.__("action_field_updates_field_operation_options_null",{},lng),
|
|
179
|
+
value: 'null',
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
options.push({
|
|
183
|
+
label: TAPi18n.__("action_field_updates_field_operation_options_formula",{},lng),
|
|
184
|
+
value: 'formula',
|
|
185
|
+
});
|
|
186
|
+
options.push({
|
|
187
|
+
label: TAPi18n.__("action_field_updates_field_operation_options_literal",{},lng),
|
|
188
|
+
value: 'literal',
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
return options;
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
/* literal_value 字段使用*/
|
|
195
|
+
getLiteralValueOptions: {
|
|
196
|
+
async handler(ctx) {
|
|
197
|
+
const userSession = ctx.meta.user;
|
|
198
|
+
const lng = userSession.language || 'zh-CN';
|
|
199
|
+
const objectName = ctx.params.objectName;
|
|
200
|
+
const targetObject = ctx.params.targetObject;
|
|
201
|
+
const fieldName = ctx.params.fieldName;
|
|
202
|
+
|
|
203
|
+
if (!objectName || !fieldName) {
|
|
204
|
+
return []
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
let mainObjectName = null;
|
|
208
|
+
if (targetObject && targetObject != objectName) {
|
|
209
|
+
mainObjectName = await objectql.getObjectConfig(objectName).fields[targetObject]?.reference_to;
|
|
210
|
+
} else {
|
|
211
|
+
mainObjectName = objectName;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const objectConfig = await objectql.getObjectConfig(mainObjectName);
|
|
215
|
+
let literal_value_schema = {
|
|
216
|
+
"type": "text",
|
|
217
|
+
"name": "literal_value",
|
|
218
|
+
"label": "指定新字段值",
|
|
219
|
+
"required": false,
|
|
220
|
+
"is_wide": true,
|
|
221
|
+
"labelClassName": "text-left"
|
|
222
|
+
}
|
|
223
|
+
if (objectConfig) {
|
|
224
|
+
steedosI18n.translationObject(lng, objectConfig.name, objectConfig);
|
|
225
|
+
const field = objectConfig.fields[fieldName];
|
|
226
|
+
literal_value_schema = Object.assign({}, field, {
|
|
227
|
+
name: "literal_value",
|
|
228
|
+
label: "指定新字段值",
|
|
229
|
+
disabled: false,
|
|
230
|
+
readonly: false,
|
|
231
|
+
is_wide: true
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
"body": [
|
|
236
|
+
{
|
|
237
|
+
"type": "steedos-field",
|
|
238
|
+
"field": literal_value_schema,
|
|
239
|
+
"name": "literal_value",
|
|
240
|
+
"clearValueOnHidden": true,
|
|
241
|
+
"fieldName": "literal_value",
|
|
242
|
+
"visibleOn": "this.operation === 'literal'"
|
|
243
|
+
}
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-process-approval",
|
|
3
|
-
"version": "2.4.0-beta.
|
|
3
|
+
"version": "2.4.0-beta.32",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"steedos"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@steedos/process": "2.4.0-beta.
|
|
13
|
+
"@steedos/process": "2.4.0-beta.32"
|
|
14
14
|
},
|
|
15
15
|
"description": "steedos package",
|
|
16
16
|
"repository": {},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "6ce63579f48afb751446023df8ff93a859e606ae"
|
|
19
19
|
}
|