@steedos/standard-object-database 2.7.1-beta.6 → 2.7.1-beta.8

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.
@@ -54,6 +54,10 @@ fields:
54
54
  label: Enable Notes
55
55
  help:
56
56
  description:
57
+ enable_form_tabs:
58
+ label: Enable Form Tabs
59
+ help: This feature exclusively affects the editable pages, with precedence given to configurations specified on the components.
60
+ description:
57
61
  enable_events:
58
62
  label: Enable Events
59
63
  help:
@@ -51,6 +51,10 @@ fields:
51
51
  label: 允许添加备注
52
52
  help:
53
53
  description:
54
+ enable_form_tabs:
55
+ label: 表单启用选项卡模式
56
+ help: 该功能只影响编辑页面,但会优先识别组件上的配置
57
+ description:
54
58
  enable_events:
55
59
  label: 允许添加日程
56
60
  help:
@@ -4,17 +4,19 @@ depend_on:
4
4
  filtersFunction: !<tag:yaml.org,2002:js/function> |-
5
5
  function(filters,values
6
6
  ) {
7
-
8
-
7
+ var currentFilter = [];
8
+ //当前字段为多选时,from的字段不能选择multiple为true的
9
+ if (values.multiple) {
10
+ currentFilter.push(['multiple', '!=', true]);
11
+ }
9
12
 
10
13
  if(values && values.reference_to){
11
- return ['object', '=', values.reference_to]
14
+ currentFilter.push(['object', '=', values.reference_to]);
12
15
  }else{
13
- return ['_id', '=', 'no']
16
+ currentFilter.push(['_id', '=', 'no']);
14
17
  }
15
18
 
16
-
17
-
19
+ return currentFilter;
18
20
  }
19
21
  group: auto_fill
20
22
  hidden: false
@@ -24,6 +24,19 @@ filtersFunction: !<tag:yaml.org,2002:js/function> |-
24
24
  var referenceObject = BuilderAmisObject && BuilderAmisObject.AmisLib && BuilderAmisObject.AmisLib.getUISchemaSync(values.reference_to);
25
25
  var fromField = referenceObject && referenceObject.fields[values.from];
26
26
 
27
+ if (values.multiple) {
28
+ //当前字段为多选时,若from的字段类型为lookup、master_detail、select时,to的字段则必须选择multiple为true的
29
+ if (_.includes(["lookup","master_detail","select"], fromField.type)) {
30
+ currentFilter.push(['multiple', '=', true]);
31
+ }
32
+ }else {
33
+ //当前字段为单选时,若from的字段多选,to的字段则也必须多选;若from不是多选,则to也不能是多选
34
+ if (fromField.multiple){
35
+ currentFilter.push(['multiple', '=', true]);
36
+ } else {
37
+ currentFilter.push(['multiple', '!=', true]);
38
+ }
39
+ }
27
40
  if (fromField && fromField.data_type) {
28
41
  currentFilter.push(['type', 'in', fieldFilters[fromField.data_type] || fromField.data_type.split()]);
29
42
  }else if (fromField) {
@@ -13,4 +13,4 @@ sort_no: 500
13
13
  type: table
14
14
  visible_on: >-
15
15
  {{(formData.type === 'lookup' || formData.type === 'master_detail') &&
16
- formData.reference_to && !!!formData.multiple}}
16
+ formData.reference_to}}
@@ -1,5 +1,4 @@
1
1
  name: sortable
2
- defaultValue: true
3
2
  group: Advanced
4
3
  hidden: false
5
4
  label: Sortable
@@ -4,6 +4,7 @@ label: Fields
4
4
  multiple: true
5
5
  is_wide: true
6
6
  sort_no: 60
7
+ description: 如果未配置, 则推送所有字段
7
8
  depend_on:
8
9
  - object_name
9
10
  optionsFunction: !!js/function |
@@ -0,0 +1,6 @@
1
+ # 只影响编辑页面
2
+ name: enable_form_tabs
3
+ label: Enable Form Tabs
4
+ sort_no: 461
5
+ type: boolean
6
+ inlineHelpText: This feature exclusively affects the editable pages, with precedence given to configurations specified on the components.
@@ -10,204 +10,255 @@
10
10
  "id": "service_field_design",
11
11
  "body": [
12
12
  {
13
- "type": "panel",
14
- "header": {
15
- "type": "flex",
16
- "id": "u:b2c8374e93fe",
17
- "items": [
18
- {
19
- "type": "tpl",
20
- "tpl": "<p><h4><strong>设计字段布局</strong></h4> ${designObjectLabel}<span style=\"color: rgb(149, 165, 166);\"> ${designObjectName}</span></p>",
21
- "id": "u:4c7bef616400"
22
- },
23
- {
13
+ "type": "form",
14
+ "title": "",
15
+ "body": [
16
+ {
17
+ "type": "panel",
18
+ "header": {
24
19
  "type": "flex",
25
- "id": "u:1bfde03380f8",
20
+ "id": "u:b2c8374e93fe",
26
21
  "items": [
27
22
  {
28
- "type": "button",
29
- "id": "u:ec9931ea883c",
30
- "actionType": "dialog",
31
- "dialog": {
32
- "type": "dialog",
33
- "title": "设置分组",
34
- "size": "lg",
35
- "data": {
36
- "&": "$$",
37
- "groups": "${groups|filter:is_default:isFalse|filter:is_hidden:isFalse}",
38
- "designObjectName": "${designObjectName}"
39
- },
40
- "body": [
41
- {
42
- "type": "form",
43
- "mode": "normal",
23
+ "type": "tpl",
24
+ "tpl": "<p><h4><strong>设计字段布局</strong></h4> ${designObjectLabel}<span style=\"color: rgb(149, 165, 166);\"> ${designObjectName}</span></p>",
25
+ "id": "u:4c7bef616400"
26
+ },
27
+ {
28
+ "type": "flex",
29
+ "id": "u:1bfde03380f8",
30
+ "items": [
31
+ {
32
+ "type": "button",
33
+ "id": "u:ec9931ea883c",
34
+ "actionType": "dialog",
35
+ "dialog": {
36
+ "type": "dialog",
37
+ "title": "设置分组",
38
+ "size": "lg",
39
+ "data": {
40
+ "&": "$$",
41
+ "groups": "${groups|filter:is_default:isFalse|filter:is_hidden:isFalse}",
42
+ "designObjectName": "${designObjectName}",
43
+ "__updateDone": false
44
+ },
44
45
  "body": [
45
46
  {
46
- "type": "service",
47
+ "type": "form",
48
+ "mode": "normal",
49
+ "onEvent": {
50
+ "change": {
51
+ "actions": [
52
+ {
53
+ "actionType": "setValue",
54
+ "componentId": "steedos-set-group",
55
+ "args": {
56
+ "value": {
57
+ "__updateDone": true
58
+ }
59
+ }
60
+ }
61
+ ]
62
+ }
63
+ },
47
64
  "body": [
48
65
  {
49
- "type": "steedos-input-table",
50
- "enableDialog": false,
51
- "fields": [
52
- {
53
- "name": "group_name",
54
- "label": "名称",
55
- "type": "text",
56
- "id": "u:31952daa443c"
57
- },
66
+ "type": "service",
67
+ "body": [
58
68
  {
59
- "name": "visible_on",
60
- "label": "显示条件",
61
- "type": "text",
62
- "amis": {
63
- "type": "input-formula",
64
- "name": "formula",
65
- "evalMode": false,
66
- "variableMode": "tabs",
67
- "variables": "${variables}"
69
+ "type": "steedos-input-table",
70
+ "enableDialog": false,
71
+ "input-table": {
72
+ "onEvent": {
73
+ "change": {
74
+ "actions": [
75
+ {
76
+ "actionType": "setValue",
77
+ "componentId": "steedos-set-group",
78
+ "args": {
79
+ "value": {
80
+ "__updateDone": false
81
+ }
82
+ }
83
+ }
84
+ ]
85
+ }
86
+ }
68
87
  },
69
- "id": "u:8d7551abcd28",
70
- "value": null
71
- },
72
- {
73
- "name": "collapsed",
74
- "label": "默认折叠",
75
- "type": "boolean"
88
+ "fields": [
89
+ {
90
+ "name": "group_name",
91
+ "label": "名称",
92
+ "type": "text",
93
+ "id": "u:31952daa443c"
94
+ },
95
+ {
96
+ "name": "visible_on",
97
+ "label": "显示条件",
98
+ "type": "text",
99
+ "amis": {
100
+ "type": "input-formula",
101
+ "name": "formula",
102
+ "evalMode": false,
103
+ "variableMode": "tabs",
104
+ "variables": "${variables}"
105
+ },
106
+ "id": "u:8d7551abcd28",
107
+ "value": null
108
+ },
109
+ {
110
+ "name": "collapsed",
111
+ "label": "默认折叠",
112
+ "type": "boolean"
113
+ }
114
+ ],
115
+ "columns": [
116
+ {
117
+ "name": "group_name"
118
+ },
119
+ {
120
+ "name": "visible_on"
121
+ },
122
+ {
123
+ "name": "collapsed",
124
+ "width": 50
125
+ }
126
+ ],
127
+ "name": "groups",
128
+ "addable": true,
129
+ "editable": true,
130
+ "removable": true,
131
+ "draggable": false,
132
+ "id": "u:776ec89804c0",
133
+ "label": "",
134
+ "visibleOn": "${variables}"
76
135
  }
77
136
  ],
78
- "columns": [
79
- {
80
- "name": "group_name"
81
- },
82
- {
83
- "name": "visible_on"
84
- },
85
- {
86
- "name": "collapsed",
87
- "width": 50
137
+ "api": {
138
+ "method": "get",
139
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${designObjectName}/fields/options",
140
+ "adaptor": "payload = {data: {variables: SteedosUI.getFormulaVariables(payload.data.options)}};return payload;",
141
+ "cache": 30000,
142
+ "headers": {
143
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
88
144
  }
89
- ],
90
- "name": "groups",
91
- "addable": true,
92
- "editable": true,
93
- "removable": true,
94
- "draggable": false,
95
- "id": "u:776ec89804c0",
96
- "label": "",
97
- "visibleOn": "${variables}"
98
- }
99
- ],
100
- "api": {
101
- "method": "get",
102
- "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${designObjectName}/fields/options",
103
- "adaptor": "payload = {data: {variables: SteedosUI.getFormulaVariables(payload.data.options)}};return payload;",
104
- "cache": 30000,
105
- "headers": {
106
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
145
+ }
107
146
  }
108
- }
147
+ ]
109
148
  }
110
- ]
111
- }
112
- ],
113
- "onEvent": {
114
- "confirm": {
149
+ ],
115
150
  "actions": [
116
151
  {
117
- "actionType": "custom",
118
- "script": "///整理分组数据\nconst defaultGroupName = \"未分组\";\nconst hiddenGroupName = \"隐藏\";\nlet setting_groups = _.cloneDeep(event.data.groups);\nif (!_.find(setting_groups, { is_default: true })) {\n setting_groups.unshift({\n \"id\": defaultGroupName,\n \"group_name\": defaultGroupName,\n \"visible_on\": \"\",\n \"is_default\": true\n })\n}\nif (!_.find(setting_groups, { is_hidden: true })) {\n setting_groups.push({\n id: hiddenGroupName,\n group_name: hiddenGroupName,\n visible_on: \"\",\n is_hidden: true\n });\n}\nsetting_groups.forEach(function (group) {\n if (!group.id || group.id != group.group_name) {\n group.id = group.group_name;\n }\n if (/\\$\\{.+\\}/.test(group.visible_on)) {\n group.visible_on = group.visible_on.replaceAll('${', '\\\\${');\n }\n})\n\n//整理字段与分组关系的数据\nlet fieldForGroup = {};\nlet oldGroup = _.cloneDeep(event.data.fieldForGroup);\nsetting_groups.forEach(function (group) {\n if (_.has(oldGroup, group.id)) {\n fieldForGroup[group.id] = oldGroup[group.id];\n oldGroup = _.omit(oldGroup, group.id);\n } else {\n fieldForGroup[group.id] = [];\n }\n})\nif (oldGroup && !_.isEmpty(oldGroup)) {\n _.forEach(oldGroup, function (value, key) {\n fieldForGroup[defaultGroupName] = _.unionBy(fieldForGroup[defaultGroupName], value);\n });\n}\n\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\nconst defaultGroup = fieldForGroup[defaultGroupName];\nconst hiddenGroup = fieldForGroup[hiddenGroupName];\ndelete fieldForGroup[defaultGroupName];\ndelete fieldForGroup[hiddenGroupName];\nfieldForGroup = _.merge({ [defaultGroupName]: defaultGroup }, fieldForGroup, { [hiddenGroupName]: hiddenGroup });\n\n//根据fieldForGroup调整groups顺序,设置分组与保存时需要groups按照顺序\nconst keys = _.keys(fieldForGroup);\nsetting_groups = _.sortBy(setting_groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\n\ndoAction({\n actionType: 'setValue',\n componentId: 'service_field_design',\n args: {\n value: {\n groups: setting_groups\n }\n }\n});\n\ndoAction({\n actionType: 'setValue',\n componentId: \"form_field_design\",\n args: {\n value: { design_field: fieldForGroup }\n }\n});"
152
+ "type": "action",
153
+ "label": "取消",
154
+ "actionType": "cancel"
155
+ },
156
+ {
157
+ "type": "action",
158
+ "label": "确认",
159
+ "level": "primary",
160
+ "onEvent": {
161
+ "click": {
162
+ "actions": [
163
+ {
164
+ "actionType": "custom",
165
+ "script": "///整理分组数据\nconst defaultGroupName = \"未分组\";\nconst hiddenGroupName = \"隐藏\";\nlet setting_groups = _.cloneDeep(event.data.groups);\nif (!_.find(setting_groups, { is_default: true })) {\n setting_groups.unshift({\n \"id\": \"default-group\",\n \"group_name\": defaultGroupName,\n \"visible_on\": \"\",\n \"is_default\": true\n })\n}\nif (!_.find(setting_groups, { is_hidden: true })) {\n setting_groups.push({\n id: \"hidden-group\",\n group_name: hiddenGroupName,\n visible_on: \"\",\n is_hidden: true\n });\n}\nsetting_groups.forEach(function (group) {\n if (!group.id) {\n group.id = window.crypto.randomUUID();\n }\n if (/\\$\\{.+\\}/.test(group.visible_on)) {\n group.visible_on = group.visible_on.replaceAll('${', '\\\\${');\n }\n})\n\n//整理字段与分组关系的数据\nlet design_field = {};\nlet oldGroup = _.cloneDeep(event.data.design_field);\nsetting_groups.forEach(function (group) {\n if (_.has(oldGroup, group.id)) {\n design_field[group.id] = oldGroup[group.id];\n oldGroup = _.omit(oldGroup, group.id);\n } else {\n design_field[group.id] = [];\n }\n})\n//当有分组被删除时,会进入以下if,将该分组下所有字段放入未分组中\nif (oldGroup && !_.isEmpty(oldGroup)) {\n _.forEach(oldGroup, function (value, key) {\n design_field[\"default-group\"] = _.unionBy(design_field[\"default-group\"], value);\n });\n}\n\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\nconst defaultGroup = design_field['default-group'];\nconst hiddenGroup = design_field['hidden-group'];\ndelete design_field['default-group'];\ndelete design_field['hidden-group'];\ndesign_field = _.merge({ 'default-group': defaultGroup }, design_field, { 'hidden-group': hiddenGroup });\n\n//根据design_field调整groups顺序,设置分组与保存时需要groups按照顺序\nconst keys = _.keys(design_field);\nsetting_groups = _.sortBy(setting_groups, function (group) { return _.findIndex(keys, function (key) { return key == group.id }) });\n\ndoAction({\n actionType: 'setValue',\n componentId: 'form_field_design',\n args: {\n value: {\n groups: setting_groups,\n design_field\n }\n }\n});"
166
+ },
167
+ {
168
+ "actionType": "closeDialog"
169
+ }
170
+ ]
171
+ }
172
+ },
173
+ "disabledOn": "${!__updateDone}"
119
174
  }
120
- ]
121
- }
122
- },
123
- "id": "u:e02c8f59216e",
124
- "closeOnEsc": false,
125
- "closeOnOutside": false,
126
- "showCloseButton": true,
127
- "showErrorMsg": true,
128
- "showLoading": true
129
- },
130
- "label": "设置分组",
131
- "className": ""
132
- },
133
- {
134
- "type": "button",
135
- "label": "新增字段",
136
- "actionType": "dialog",
137
- "id": "u:5857ae729799",
138
- "visible": false,
139
- "dialog": {
140
- "type": "dialog",
141
- "title": "新增字段",
142
- "data": {
143
- "appId": "${appId}",
144
- "global": "${global}",
145
- "context": "${context}",
146
- "designObjectName": "${designObjectName}",
147
- "_master": "${_master}"
175
+ ],
176
+ "id": "steedos-set-group",
177
+ "closeOnEsc": false,
178
+ "closeOnOutside": false,
179
+ "showCloseButton": true,
180
+ "showErrorMsg": true,
181
+ "showLoading": true
182
+ },
183
+ "label": "设置分组",
184
+ "className": "",
185
+ "disabledOn": "${!__changeDone}"
148
186
  },
149
- "body": [
150
- {
151
- "type": "steedos-object-form",
152
- "label": "对象表单",
153
- "objectApiName": "object_fields",
154
- "recordId": "",
155
- "mode": "edit",
156
- "defaultData": {
157
- "object": "${designObjectName}"
187
+ {
188
+ "type": "button",
189
+ "label": "新增字段",
190
+ "actionType": "dialog",
191
+ "id": "u:5857ae729799",
192
+ "visible": false,
193
+ "dialog": {
194
+ "type": "dialog",
195
+ "title": "新增字段",
196
+ "data": {
197
+ "appId": "${appId}",
198
+ "global": "${global}",
199
+ "context": "${context}",
200
+ "designObjectName": "${designObjectName}",
201
+ "_master": "${_master}"
158
202
  },
159
- "fieldsExtend": {
160
- "object": {
161
- "amis": {
162
- "disabledOn": "true"
163
- }
164
- },
165
- "group": {
166
- "amis": {
167
- "hidden": true
168
- }
203
+ "body": [
204
+ {
205
+ "type": "steedos-object-form",
206
+ "label": "对象表单",
207
+ "objectApiName": "object_fields",
208
+ "recordId": "",
209
+ "mode": "edit",
210
+ "defaultData": {
211
+ "object": "${designObjectName}"
212
+ },
213
+ "fieldsExtend": {
214
+ "object": {
215
+ "amis": {
216
+ "disabledOn": "true"
217
+ }
218
+ },
219
+ "group": {
220
+ "amis": {
221
+ "hidden": true
222
+ }
223
+ }
224
+ },
225
+ "fields": "",
226
+ "id": "u:b71796d3cb8c",
227
+ "className": "mb-4",
228
+ "enableTabs": true,
229
+ "tabsMode": "line"
169
230
  }
170
- },
171
- "fields": "",
172
- "id": "u:b71796d3cb8c",
173
- "className": "mb-4",
174
- "enableTabs": true,
175
- "tabsMode": "line"
231
+ ],
232
+ "showCloseButton": true,
233
+ "showErrorMsg": true,
234
+ "showLoading": true,
235
+ "closeOnEsc": false,
236
+ "dataMapSwitch": false,
237
+ "size": "lg",
238
+ "id": "u:066b3884bdd8"
176
239
  }
177
- ],
178
- "showCloseButton": true,
179
- "showErrorMsg": true,
180
- "showLoading": true,
181
- "closeOnEsc": false,
182
- "dataMapSwitch": false,
183
- "size": "lg",
184
- "id": "u:066b3884bdd8"
185
- }
186
- },
187
- {
188
- "type": "button",
189
- "label": "保存",
190
- "actionType": "submit",
191
- "id": "u:d9039421ea6b",
192
- "target": "form_field_design",
193
- "level": "primary"
240
+ },
241
+ {
242
+ "type": "button",
243
+ "label": "保存",
244
+ "actionType": "submit",
245
+ "id": "u:d9039421ea6b",
246
+ "target": "form_field_design",
247
+ "level": "primary",
248
+ "disabledOn": "${!__changeDone}"
249
+ }
250
+ ]
194
251
  }
195
- ]
196
- }
197
- ],
198
- "style": {
199
- "position": "static",
200
- "flexWrap": "nowrap",
201
- "justifyContent": "space-between",
202
- "alignItems": "baseline"
203
- },
204
- "isFixedHeight": false,
205
- "isFixedWidth": false
206
- },
207
- "body": [
208
- {
209
- "type": "form",
210
- "title": "",
252
+ ],
253
+ "style": {
254
+ "position": "static",
255
+ "flexWrap": "nowrap",
256
+ "justifyContent": "space-between",
257
+ "alignItems": "baseline"
258
+ },
259
+ "isFixedHeight": false,
260
+ "isFixedWidth": false
261
+ },
211
262
  "body": [
212
263
  {
213
264
  "type": "steedos-board",
@@ -340,55 +391,73 @@
340
391
  },
341
392
  "cardSource": "${fields}",
342
393
  "vertical": true,
394
+ "value": "${fieldForGroup}",
343
395
  "onEvent": {
344
396
  "change": {
345
397
  "actions": [
346
398
  {
347
- "actionType": "custom",
348
- "script": "const newGroups = _.keys(event.data.value);\nconst lastGroups = _.map(context.props.data.groups, 'group_name');\nif (newGroups != lastGroups) {\n doAction({\n actionType: 'setValue',\n componentId: 'service_field_design',\n args: {\n value: {\n fieldForGroup: event.data.value, groups: field_groups = _.sortBy(context.props.data.groups, function (group) { return _.findIndex(newGroups, function (group_name) { return group.group_name === group_name; }); })\n }\n }\n });\n}\n"
399
+ "actionType": "setValue",
400
+ "componentId": "service_field_design",
401
+ "args": {
402
+ "value": {
403
+ "__changeDone": false
404
+ }
405
+ }
349
406
  }
350
407
  ]
351
408
  }
352
- },
353
- "value": "${fieldForGroup}"
409
+ }
354
410
  }
355
411
  ],
356
- "id": "form_field_design",
357
- "api": {
358
- "url": "${context.rootUrl}/graphql",
359
- "method": "post",
360
- "dataType": "json",
361
- "headers": {
362
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
363
- },
364
- "requestAdaptor": "var graphqlOrder = \"\";\nvar field_groups = _.cloneDeep(api.data.groups);\n//先修改字段,使系统对象自行自定义\n//根据design_field,修改对象字段的sort_no与groups\nvar index = 1;\nconst defaultGroupName = _.find(field_groups, { 'is_default': true })?.name || \"未分组\";\nconst hiddenGroupName = _.find(field_groups, { 'is_hidden': true })?.name || \"隐藏\";\n_.forEach(api.data.design_field, function (items, key) {\n let group = key;\n if (key == defaultGroupName || key == hiddenGroupName) {\n group = null;\n }\n _.forEach(items, function (item) {\n const field = _.find(api.data.fields, { 'id': item });\n //如果是在隐藏分组里的字段,就给visible_on属性赋予{{false}};如果不在隐藏分组里,就判断来自数据库内的visible_on属性是不是{{false}},是就清除,不是就保持不变\n const visible_on = key == hiddenGroupName ? \"{{false}}\" : (field.attr_visible_on == \"{{false}}\" ? \"{{true}}\" : field.attr_visible_on);\n let docJson = {\n sort_no: index * 10,\n group, visible_on\n }\n if (field.id == field._id && field.is_system) {\n docJson = {\n object: api.data.$self.designObjectName,\n type: field.type,\n _name: field._name,\n label: field.label,\n sort_no: index * 10,\n group,\n visible_on,\n is_system: field.is_system\n }\n }\n if (key != hiddenGroupName) {\n docJson.hidden = false;\n }\n let itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify(docJson)) + '){_id}\\n';\n graphqlOrder += itemOrder;\n index++;\n })\n})\n\n//根据groups,修改对象的字段分组field_groups\n_.remove(field_groups, { is_default: true });\n_.remove(field_groups, { is_hidden: true });\nfield_groups = field_groups.map(function (group) {\n return _.omit(group, 'id');\n})\nconst keys = _.keys(api.data.design_field);\nfield_groups = _.sortBy(field_groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\nconst groupOrder = 'upsert0:objects__upsert(id:\"' + api.data.$self.designObjectId + '\" , doc:' + JSON.stringify(JSON.stringify({ field_groups, name: api.data.$self.designObjectName })) + ') {_id}';\ngraphqlOrder += groupOrder;\n\n\ngraphqlOrder = 'mutation {' + graphqlOrder + '}';\nreturn {\n ...api,\n data: {\n query: graphqlOrder\n }\n}",
365
- "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = window.t ? window.t(payload.errors[\n 0\n ].message) : payload.errors[\n 0\n ].message;\n}\nreturn payload;",
366
- "messages": {},
367
- "data": {
368
- "design_field": "${design_field}",
369
- "groups": "${groups}",
370
- "fields": "${fields}",
371
- "$self": "$$"
412
+ "className": "Panel--default max-w-4xl m-auto",
413
+ "id": "u:3a90104cb6b4"
414
+ }
415
+ ],
416
+ "id": "form_field_design",
417
+ "api": {
418
+ "url": "${context.rootUrl}/graphql",
419
+ "method": "post",
420
+ "dataType": "json",
421
+ "headers": {
422
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
423
+ },
424
+ "requestAdaptor": "var graphqlOrder = \"\";\nvar field_groups = _.cloneDeep(api.data.groups);\n//先修改字段,使系统对象自行自定义\n//根据design_field,修改对象字段的sort_no与groups\nvar index = 1;\nconst defaultGroupId = _.find(field_groups, { 'is_default': true })?.id;\nconst hiddenGroupId = _.find(field_groups, { 'is_hidden': true })?.id;\n_.forEach(api.data.design_field, function (items, key) {\n let group = _.find(field_groups, { 'id': key }).group_name;\n if (key == defaultGroupId || key == hiddenGroupId) {\n group = null;\n }\n _.forEach(items, function (item) {\n const field = _.find(api.data.fields, { 'id': item });\n //如果是在隐藏分组里的字段,就给visible_on属性赋予{{false}};如果不在隐藏分组里,就判断来自数据库内的visible_on属性是不是{{false}},是就清除,不是就保持不变\n const visible_on = key == hiddenGroupId ? \"{{false}}\" : (field.attr_visible_on == \"{{false}}\" ? \"{{true}}\" : field.attr_visible_on);\n let docJson = {\n sort_no: index * 10,\n group, visible_on\n }\n if (field.id == field._id && field.is_system) {\n docJson = {\n object: api.data.$self.designObjectName,\n type: field.type,\n _name: field._name,\n label: field.label,\n sort_no: index * 10,\n group,\n visible_on,\n is_system: field.is_system\n }\n }\n if (key != hiddenGroupId) {\n docJson.hidden = false;\n }\n let itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify(docJson)) + '){_id}\\n';\n graphqlOrder += itemOrder;\n index++;\n })\n})\n\n//根据groups,修改对象的字段分组field_groups\n_.remove(field_groups, { is_default: true });\n_.remove(field_groups, { is_hidden: true });\nconst keys = _.keys(api.data.design_field);\nfield_groups = _.sortBy(field_groups, function (group) { return _.findIndex(keys, function (key) { return key == group.id }) });\nfield_groups = field_groups.map(function (group) {\n return _.omit(group, 'id');\n})\nconst groupOrder = 'upsert0:objects__upsert(id:\"' + api.data.$self.designObjectId + '\" , doc:' + JSON.stringify(JSON.stringify({ field_groups, name: api.data.$self.designObjectName })) + ') {_id}';\ngraphqlOrder += groupOrder;\n\n\ngraphqlOrder = 'mutation {' + graphqlOrder + '}';\nreturn {\n ...api,\n data: {\n query: graphqlOrder\n }\n}",
425
+ "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = window.t ? window.t(payload.errors[\n 0\n ].message) : payload.errors[\n 0\n ].message;\n}\nreturn payload;",
426
+ "messages": {},
427
+ "data": {
428
+ "design_field": "${design_field}",
429
+ "groups": "${groups}",
430
+ "fields": "${fields}",
431
+ "$self": "$$"
432
+ }
433
+ },
434
+ "visibleOn": "${dataInitialed}",
435
+ "wrapWithPanel": false,
436
+ "name": "form_field_design",
437
+ "onEvent": {
438
+ "submitSucc": {
439
+ "weight": 0,
440
+ "actions": [
441
+ {
442
+ "actionType": "custom",
443
+ "script": "setTimeout(() => {\n doAction({\n \"actionType\": \"broadcast\",\n \"args\": {\n \"eventName\": \"@data.changed.object_fields\"\n }\n });\n}, 500);\n\n\n"
372
444
  }
373
- },
374
- "visibleOn": "${dataInitialed}",
375
- "wrapWithPanel": false,
376
- "name": "form_field_design",
377
- "onEvent": {
378
- "submitSucc": {
379
- "weight": 0,
380
- "actions": [
381
- {
382
- "actionType": "custom",
383
- "script": "setTimeout(() => {\n doAction({\n \"actionType\": \"broadcast\",\n \"args\": {\n \"eventName\": \"@data.changed.object_fields\"\n }\n });\n}, 500);\n\n\n"
445
+ ]
446
+ },
447
+ "change": {
448
+ "actions": [
449
+ {
450
+ "actionType": "setValue",
451
+ "componentId": "service_field_design",
452
+ "args": {
453
+ "value": {
454
+ "__changeDone": true
384
455
  }
385
- ]
456
+ }
386
457
  }
387
- }
458
+ ]
388
459
  }
389
- ],
390
- "className": "Panel--default max-w-4xl m-auto",
391
- "id": "u:3a90104cb6b4"
460
+ }
392
461
  }
393
462
  ],
394
463
  "api": {
@@ -407,7 +476,7 @@
407
476
  },
408
477
  "messages": {},
409
478
  "requestAdaptor": "",
410
- "adaptor": "//筛选出可编辑的字段\nvar oldFields = _.filter(payload.data.fields, function (obj) { return obj.recordPermissions.allowEdit; });\n//将group为空的字段分为未分组的组中,将系统字段的_id改为对象名.字段名\noldFields = _.map(oldFields, function (obj) {\n obj.originId = obj._id;\n if (obj.hidden || obj.visible_on == \"{{false}}\") {\n obj.group = \"隐藏\";\n }else if (obj.group === null) {\n obj.group = \"未分组\";\n }\n if (obj.is_system) {\n obj._id = api.data.designObjectName + \".\" + obj._name;\n }\n return obj;\n});\n\n//整合出字段的属性集合\nconst fields = oldFields.map((field) => {\n return {\n \"id\": field._id,//用与steedos-board组件的关系分辨\n \"_name\": field._name,\n \"label\": field.label,\n \"_id\": field.originId,//用于打开steedos-objectform\n \"columnSpan\": field.is_wide ? 2 : 1,\n \"is_system\": field.is_system,\n \"type\": field.type,\n \"attr_visible_on\": field.visible_on\n }\n})\n\n//从字段的group属性中,整合出字段分组的属性集合\nlet field_groups = _.map(_.uniqBy(oldFields, \"group\"), function (obj) {\n return {\n \"id\": obj.group,\n \"group_name\": obj.group,\n \"visible_on\": \"\"\n };\n});\n\n//合并对象上的field_groups与字段上的group\nlet groups = _.unionBy(api.data.field_groups, field_groups, 'id');\n\n//判断是否第一次调用接口,不是的话(说明是触发了datachange事件),返回fields与fieldUpdateData;目前新增与删除都不支持\nif (api.data.dataInitialed) {\n const eventData = api.data.eventData;\n let fieldUpdateData = \"\";\n const fieldForGroup = api.data.fieldForGroup;\n let fieldForGroupLength = 0;\n _.forIn(fieldForGroup, function (value, key) {\n fieldForGroupLength += value.length;\n });\n if (fieldForGroupLength < fields.length) {\n fieldUpdateData = {\n type: \"insert\",\n id: eventData.result.data.recordId\n }\n } else if (fieldForGroupLength > fields.length) {\n fieldUpdateData = {\n type: \"delete\",\n id: eventData._id\n }\n }\n return payload = {\n data: {\n fields,\n fieldUpdateData,\n \n }\n }\n}\n\n//整合字段与分组的关系\nconst oldFieldsInGroups = _.groupBy(oldFields, \"group\");\nlet fieldForGroup = _.mapValues(_.groupBy(groups, \"id\"), function (group,key) {\n if (oldFieldsInGroups[key]) {\n return _.map(oldFieldsInGroups[key], function (obj) {\n return obj._id;\n });\n } else {\n return [];\n }\n});\n\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\nconst defaultGroupName = _.find(groups, { 'is_default': true })?.name || \"未分组\";\nconst hiddenGroupName = _.find(groups, { 'is_hidden': true })?.name || \"隐藏\";\nconst defaultGroup = fieldForGroup[defaultGroupName];\nconst hiddenGroup = fieldForGroup[hiddenGroupName];\ndelete fieldForGroup[defaultGroupName];\ndelete fieldForGroup[hiddenGroupName];\nfieldForGroup = _.merge({ [defaultGroupName]: defaultGroup }, fieldForGroup, { [hiddenGroupName]: hiddenGroup });\n\n//根据fieldForGroup调整groups顺序,设置分组与保存时需要groups按照顺序\nconst keys = _.keys(fieldForGroup);\ngroups = _.sortBy(groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\n\nreturn payload = {\n data: {\n fields,\n groups,\n fieldForGroup,\n dataInitialed: true\n }\n};",
479
+ "adaptor": "//筛选出可编辑的字段\nvar oldFields = _.filter(payload.data.fields, function (obj) { return obj.recordPermissions.allowEdit; });\n//将group为空的字段分为未分组的组中,将系统字段的_id改为对象名.字段名\noldFields = _.map(oldFields, function (obj) {\n obj.originId = obj._id;\n if (obj.hidden || obj.visible_on == \"{{false}}\") {\n obj.group = \"隐藏\";\n }else if (obj.group === null) {\n obj.group = \"未分组\";\n }\n if (obj.is_system) {\n obj._id = api.data.designObjectName + \".\" + obj._name;\n }\n return obj;\n});\n\n//整合出字段的属性集合\nconst fields = oldFields.map((field) => {\n return {\n \"id\": field._id,//用与steedos-board组件的关系分辨\n \"_name\": field._name,\n \"label\": field.label,\n \"_id\": field.originId,//用于打开steedos-object-form\n \"columnSpan\": field.is_wide ? 2 : 1,\n \"is_system\": field.is_system,\n \"type\": field.type,\n \"attr_visible_on\": field.visible_on\n }\n})\n\n//去重并去除隐藏和未分组\nlet newArray = _.reject(_.uniqBy(oldFields, \"group\"), function(obj) {\n return obj.group == \"隐藏\" || obj.group == \"未分组\";\n});\n//从字段的group属性中,整合出字段分组的属性集合\nlet field_groups = _.map(newArray, function (obj) {\n return {\n \"id\": window.crypto.randomUUID(), \n \"group_name\": obj.group,\n \"visible_on\": \"\"\n };\n});\n\n//合并对象上的field_groups与字段上的group\nlet groups = _.unionBy(api.data.field_groups, field_groups, 'group_name');\n\n//判断是否第一次调用接口,不是的话(说明是触发了datachange事件),返回fields与fieldUpdateData;目前新增与删除都不支持\nif (api.data.dataInitialed) {\n const eventData = api.data.eventData;\n let fieldUpdateData = \"\";\n const fieldForGroup = api.data.fieldForGroup;\n let fieldForGroupLength = 0;\n _.forIn(fieldForGroup, function (value, key) {\n fieldForGroupLength += value.length;\n });\n if (fieldForGroupLength < fields.length) {\n fieldUpdateData = {\n type: \"insert\",\n id: eventData.result.data.recordId\n }\n } else if (fieldForGroupLength > fields.length) {\n fieldUpdateData = {\n type: \"delete\",\n id: eventData._id\n }\n }\n return payload = {\n data: {\n fields,\n fieldUpdateData\n }\n }\n}\n\n//整合字段与分组的关系\nconst oldFieldsInGroups = _.groupBy(oldFields, \"group\");\nlet fieldForGroup = _.mapValues(_.groupBy(groups, \"id\"), function (group,key) {\n if (oldFieldsInGroups[group[0].group_name]) {\n return _.map(oldFieldsInGroups[group[0].group_name], function (obj) {\n return obj._id;\n });\n } else {\n return [];\n }\n});\n\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\nconst defaultGroupId = _.find(groups, { 'is_default': true }).id;\nconst hiddenGroupId = _.find(groups, { 'is_hidden': true }).id;\nconst defaultGroup = fieldForGroup[defaultGroupId];\nconst hiddenGroup = fieldForGroup[hiddenGroupId];\ndelete fieldForGroup[defaultGroupId];\ndelete fieldForGroup[hiddenGroupId];\nfieldForGroup = _.merge({ [defaultGroupId]: defaultGroup }, fieldForGroup, { [hiddenGroupId]: hiddenGroup });\n\n//根据fieldForGroup调整groups顺序,设置分组与保存时需要groups按照顺序\nconst keys = _.keys(fieldForGroup);\ngroups = _.sortBy(groups, function (group) { return _.findIndex(keys, function (key) { return key == group.id }) });\n\nreturn payload = {\n data: {\n fields,\n groups,\n fieldForGroup,\n dataInitialed: true\n }\n};",
411
480
  "sendOn": "!!this.designObjectId"
412
481
  },
413
482
  "messages": {},
@@ -424,7 +493,8 @@
424
493
  },
425
494
  "initFetch": false,
426
495
  "data": {
427
- "eventData": ""
496
+ "eventData": "",
497
+ "__changeDone": true
428
498
  }
429
499
  }
430
500
  ],
@@ -440,7 +510,7 @@
440
510
  },
441
511
  "messages": {},
442
512
  "requestAdaptor": "",
443
- "adaptor": "const field_groups = payload.data.objects[0] && _.map(payload.data.objects[0].field_groups, function (obj) {\n return {\n \"id\": obj.group_name,\n \"group_name\": obj.group_name,\n \"visible_on\": obj.visible_on,\n \"collapsed\": obj.collapsed\n }\n});\nfield_groups.unshift({\n id: \"隐藏\",\n group_name: \"隐藏\",\n visible_on: \"\",\n is_hidden: true\n});\nfield_groups.unshift({\n id: \"未分组\",\n group_name: \"未分组\",\n visible_on: \"\",\n is_default: true\n});\n\n\n\nconst designObjectId = payload.data.objects[0] && payload.data.objects[0]._id;\nreturn payload = {\n data: {\n field_groups,\n designObjectId,\n designObjectLabel: payload.data.objects[0] && payload.data.objects[0].label,\n _master: {\n recordId: designObjectId\n }\n }\n}"
513
+ "adaptor": "const field_groups = payload.data.objects[0] && _.map(payload.data.objects[0].field_groups, function (obj) {\n return {\n \"id\": window.crypto.randomUUID(), //唯一性id\n \"group_name\": obj.group_name,\n \"visible_on\": obj.visible_on,\n \"collapsed\": obj.collapsed\n }\n});\nfield_groups.unshift({\n id: \"hidden-group\",\n group_name: \"隐藏\",\n visible_on: \"\",\n is_hidden: true\n});\nfield_groups.unshift({\n id: \"default-group\",\n group_name: \"未分组\",\n visible_on: \"\",\n is_default: true\n});\n\n\n\nconst designObjectId = payload.data.objects[0] && payload.data.objects[0]._id;\nreturn payload = {\n data: {\n field_groups,\n designObjectId,\n designObjectLabel: payload.data.objects[0] && payload.data.objects[0].label,\n _master: {\n recordId: designObjectId\n }\n }\n}"
444
514
  },
445
515
  "messages": {},
446
516
  "onEvent": {
@@ -143,15 +143,18 @@
143
143
  "amis": {
144
144
  "onEvent": {
145
145
  "change": {
146
- "actions": [{
147
- "actionType": "setValue",
148
- "args": {
149
- "value": {
150
- "defaultValue": null
151
- }
152
- },
153
- "componentId": "steedos_object_fields_form"
154
- }]
146
+ "actions": [
147
+ {
148
+ "actionType": "setValue",
149
+ "args": {
150
+ "value": {
151
+ "defaultValue": null,
152
+ "sortable": "${ARRAYSOME(allowSort, item => item === event.data.value)}"
153
+ }
154
+ },
155
+ "componentId": "steedos_object_fields_form"
156
+ }
157
+ ]
155
158
  }
156
159
  },
157
160
  "disabledOn": "${is_system == true}",
@@ -197,8 +200,33 @@
197
200
  "tabsMode": "line"
198
201
  }],
199
202
  "data": {
200
- "context": {}
203
+ "context": {},
204
+ "allowSort": [
205
+ "text",
206
+ "select",
207
+ "date",
208
+ "datetime",
209
+ "time",
210
+ "number",
211
+ "currency",
212
+ "percent",
213
+ "autoumber",
214
+ "summary",
215
+ "formula"
216
+ ]
217
+ },
218
+ "onEvent": {
219
+ "init": {
220
+ "weight": 0,
221
+ "actions": [
222
+ {
223
+ "actionType": "custom",
224
+ "script": "//初始化时给外层dialog加上类名,使过滤组件popover正常显示\n$('.steedos-object-fields-form-page').closest('.amis-dialog-widget.antd-Modal').addClass('steedos-overflow-visible-dialog');"
225
+ }
226
+ ]
227
+ }
201
228
  },
202
229
  "name": "object_fields_form",
230
+ "className": "steedos-object-fields-form-page",
203
231
  "id": "steedos_object_fields_service"
204
232
  }
@@ -16,7 +16,7 @@
16
16
  "method": "get",
17
17
  "url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/options",
18
18
  "cache": 30000,
19
- "adaptor": "const visibleOnVariables = SteedosUI.getFormulaVariables(payload.data.options);\n const defaultValueVariables = [visibleOnVariables[1]];\n const variables = [];\n const varItem = {\n label: '对象字段',\n children: _.map(payload.data.options, (item)=>{\n return {\n label: item.label,\n value: item.value\n }\n })\n };\n variables.push(varItem);\n payload.data={label: '准入条件', type:'input-formula', name: 'condition', variables: variables} \n return payload;",
19
+ "adaptor": "const field = context.uiSchema.fields.condition; const visibleOnVariables = SteedosUI.getFormulaVariables(payload.data.options);\n const defaultValueVariables = [visibleOnVariables[1]];\n const variables = [];\n const varItem = {\n label: '对象字段',\n children: _.map(payload.data.options, (item)=>{\n return {\n label: item.label,\n value: item.value\n }\n })\n };\n variables.push(varItem);\n payload.data={label: field.label, type:'input-formula', name: 'condition', variables: variables, labelRemark: field.inlineHelpText, description: field.description } \n return payload;",
20
20
  "trackExpression": "${object_name}",
21
21
  "sendOn": "${object_name}"
22
22
  }
@@ -2,7 +2,7 @@
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2024-04-23 14:35:03
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2024-04-26 12:02:56
5
+ * @LastEditTime: 2024-05-06 11:45:46
6
6
  * @Description:
7
7
  */
8
8
 
@@ -22,22 +22,28 @@ module.exports = {
22
22
  },
23
23
  events: {
24
24
  "*.inserted": async function(ctx){
25
- // TODO 校验是否是objectql的记录新增事件. 使用@objectApiName + .inserted 后,与ctx.eventName对比,看是否相同
26
25
  const { objectApiName, id, spaceId, userId } = ctx.params;
26
+ if(ctx.eventName != `@${objectApiName}.inserted`){
27
+ return
28
+ }
27
29
  if(objectApiName && id && spaceId){
28
30
  await this.addQueue(ctx, objectApiName, "create", id, spaceId, userId)
29
31
  }
30
32
  },
31
33
  "*.updated": async function(ctx){
32
- // TODO 校验是否是objectql的记录新增事件. 使用@objectApiName + .updated 后,与ctx.eventName对比,看是否相同
33
34
  const { objectApiName, id, spaceId, userId, previousDoc } = ctx.params;
35
+ if(ctx.eventName != `@${objectApiName}.updated`){
36
+ return
37
+ }
34
38
  if(objectApiName && id && spaceId){
35
39
  await this.addQueue(ctx, objectApiName, "update", id, spaceId, userId, previousDoc)
36
40
  }
37
41
  },
38
42
  "*.deleted": async function(ctx){
39
- // TODO 校验是否是objectql的记录新增事件. 使用@objectApiName + .deleted 后,与ctx.eventName对比,看是否相同
40
43
  const { objectApiName, id, spaceId, userId, previousDoc } = ctx.params;
44
+ if(ctx.eventName != `@${objectApiName}.deleted`){
45
+ return
46
+ }
41
47
  if(objectApiName && id){
42
48
  await this.addQueue(ctx, objectApiName, "delete", id, spaceId, userId, previousDoc)
43
49
  }
@@ -50,7 +56,6 @@ module.exports = {
50
56
  const { url, data } = ctx.params
51
57
  const result = await axios.post(url, data);
52
58
  ctx.locals.job.updateProgress(100)
53
- console.log('====>send', url, data.doc?.name)
54
59
  return result.data;
55
60
  }
56
61
  }
@@ -71,14 +76,14 @@ module.exports = {
71
76
  const userSession = await ctx.call('@steedos/service-accounts.getUserSession', {userId, spaceId})
72
77
  if(userSession){
73
78
  sender = {
74
- id: userSession.userId,
79
+ _id: userSession.userId,
75
80
  username: userSession.username,
76
81
  name: userSession.name,
77
82
  email: userSession.email
78
83
  }
79
84
 
80
85
  space = {
81
- id: userSession.space._id,
86
+ _id: userSession.space._id,
82
87
  name: userSession.space.name
83
88
  }
84
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.7.1-beta.6",
3
+ "version": "2.7.1-beta.8",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -12,13 +12,13 @@
12
12
  "description": "steedos package",
13
13
  "dependencies": {
14
14
  "@steedos-widgets/amis-lib": "^1.0.22",
15
- "@steedos/metadata-core": "2.7.1-beta.6",
16
- "@steedos/service-object-mixin": "2.7.1-beta.6",
17
- "@steedos/standard-objects": "2.7.1-beta.6",
15
+ "@steedos/metadata-core": "2.7.1-beta.8",
16
+ "@steedos/service-object-mixin": "2.7.1-beta.8",
17
+ "@steedos/standard-objects": "2.7.1-beta.8",
18
18
  "amis-formula": "~6.3.0",
19
19
  "moleculer-bullmq": "3.0.0"
20
20
  },
21
21
  "repository": {},
22
22
  "license": "MIT",
23
- "gitHead": "19d628fda2d45a82bc7658524a0889490c33f74b"
23
+ "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113"
24
24
  }