@steedos/standard-object-database 2.5.20-beta.20 → 2.5.20-beta.22
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.
|
@@ -25,6 +25,8 @@ fields:
|
|
|
25
25
|
label: Label
|
|
26
26
|
is_name: true
|
|
27
27
|
sort_no: 120
|
|
28
|
+
amis:
|
|
29
|
+
disabledOn: "${is_system == true}"
|
|
28
30
|
_name:
|
|
29
31
|
type: text
|
|
30
32
|
label: Field Name
|
|
@@ -106,26 +108,6 @@ fields:
|
|
|
106
108
|
amis:
|
|
107
109
|
disabledOn: "${is_system == true}"
|
|
108
110
|
searchable: true
|
|
109
|
-
onEvent:
|
|
110
|
-
change:
|
|
111
|
-
weight: 0
|
|
112
|
-
actions:
|
|
113
|
-
- componentId: 'u:6a556d8a8514'
|
|
114
|
-
args:
|
|
115
|
-
value: '${"lookup"=== type}'
|
|
116
|
-
actionType: visibility
|
|
117
|
-
- componentId: 'u:6a556d8a8514'
|
|
118
|
-
args:
|
|
119
|
-
value: clear
|
|
120
|
-
groupType: component
|
|
121
|
-
actionType: setValue
|
|
122
|
-
expression: '${"lookup"=== type && required!=true}'
|
|
123
|
-
- componentId: 'u:6a556d8a8514'
|
|
124
|
-
args:
|
|
125
|
-
value: retain
|
|
126
|
-
groupType: component
|
|
127
|
-
actionType: setValue
|
|
128
|
-
expression: '${"lookup"=== type && required==true}'
|
|
129
111
|
language:
|
|
130
112
|
type: select
|
|
131
113
|
label: 语言
|
|
@@ -704,18 +686,6 @@ fields:
|
|
|
704
686
|
# group: Advanced
|
|
705
687
|
visible_on: "{{['autonumber','summary','formula'].indexOf(formData.type) > -1 ? false: true}}"
|
|
706
688
|
sort_no: 272
|
|
707
|
-
amis:
|
|
708
|
-
# disabledOn: "${is_system == true}"
|
|
709
|
-
onEvent:
|
|
710
|
-
change:
|
|
711
|
-
weight: 0
|
|
712
|
-
actions:
|
|
713
|
-
- componentId: 'u:6a556d8a8514'
|
|
714
|
-
args:
|
|
715
|
-
value: retain
|
|
716
|
-
groupType: component
|
|
717
|
-
actionType: setValue
|
|
718
|
-
expression: '${"lookup"=== type && required==true}'
|
|
719
689
|
deleted_lookup_record_behavior:
|
|
720
690
|
type: select
|
|
721
691
|
label: 如果相关表记录被删除怎么办?
|
|
@@ -728,10 +698,9 @@ fields:
|
|
|
728
698
|
value: retain
|
|
729
699
|
sort_no: 276
|
|
730
700
|
is_wide: true
|
|
731
|
-
defaultValue: clear
|
|
732
701
|
amis:
|
|
733
|
-
"id": "u:6a556d8a8514"
|
|
734
702
|
"disabledOn": "${required==true}"
|
|
703
|
+
"value": "${IFS(true===required, \"retain\", !required && !deleted_lookup_record_behavior, \"clear\", deleted_lookup_record_behavior)}"
|
|
735
704
|
is_wide:
|
|
736
705
|
type: boolean
|
|
737
706
|
label: Is Wide
|
|
@@ -34,25 +34,29 @@
|
|
|
34
34
|
"size": "lg",
|
|
35
35
|
"body": [
|
|
36
36
|
{
|
|
37
|
-
"type": "input-table",
|
|
38
|
-
"
|
|
37
|
+
"type": "steedos-input-table",
|
|
38
|
+
"fields": [
|
|
39
39
|
{
|
|
40
40
|
"name": "group_name",
|
|
41
41
|
"label": "名称",
|
|
42
|
-
"
|
|
42
|
+
"type": "text",
|
|
43
|
+
"id": "u:31952daa443c"
|
|
43
44
|
},
|
|
44
45
|
{
|
|
45
46
|
"name": "visible_on",
|
|
46
47
|
"label": "显示条件",
|
|
47
|
-
"
|
|
48
|
+
"type": "text",
|
|
49
|
+
"id": "u:8d7551abcd28",
|
|
50
|
+
"value": null
|
|
48
51
|
}
|
|
49
52
|
],
|
|
50
|
-
"
|
|
51
|
-
"name": "setting_groups",
|
|
53
|
+
"name": "groups",
|
|
52
54
|
"addable": true,
|
|
53
55
|
"editable": true,
|
|
54
56
|
"removable": true,
|
|
55
|
-
"
|
|
57
|
+
"draggable": false,
|
|
58
|
+
"showIndex": false,
|
|
59
|
+
"id": "u:776ec89804c0"
|
|
56
60
|
}
|
|
57
61
|
],
|
|
58
62
|
"onEvent": {
|
|
@@ -60,7 +64,7 @@
|
|
|
60
64
|
"actions": [
|
|
61
65
|
{
|
|
62
66
|
"actionType": "custom",
|
|
63
|
-
"script": "
|
|
67
|
+
"script": "debugger;//整理分组数据\nlet setting_groups = _.cloneDeep(event.data.groups);\nif (!_.find(setting_groups, { is_default: true })) {\n setting_groups.unshift({\n \"id\": \"未分组\",\n \"group_name\": \"未分组\",\n \"visible_on\": \"\",\n \"is_default\": true\n })\n}\nif (!_.find(setting_groups, { is_hidden: true })) {\n setting_groups.push({\n id: \"隐藏\",\n group_name: \"隐藏\",\n visible_on: \"\",\n is_hidden: true\n });\n}\nsetting_groups.forEach(function (group) {\n if (group.is_hidden) {\n group.group_name = \"隐藏\";\n group.visible_on = \"\";\n }\n if (group.is_default) {\n group.group_name = \"未分组\";\n group.visible_on = \"\";\n }\n if (!group.id) {\n group.id = group.group_name;\n }\n if (!group.visible_on) {\n group.visible_on = \"\"\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[\"未分组\"] = _.unionBy(fieldForGroup[\"未分组\"], value);\n });\n}\n\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\nconst defaultGroup = fieldForGroup[\"未分组\"];\nconst hiddenGroup = fieldForGroup[\"隐藏\"];\ndelete fieldForGroup[\"未分组\"];\ndelete fieldForGroup[\"隐藏\"];\nfieldForGroup = _.merge({ \"未分组\": defaultGroup }, fieldForGroup, { \"隐藏\": 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});"
|
|
64
68
|
}
|
|
65
69
|
]
|
|
66
70
|
}
|
|
@@ -178,35 +182,81 @@
|
|
|
178
182
|
{
|
|
179
183
|
"type": "tpl",
|
|
180
184
|
"tpl": "<p><strong>${label}</strong> ${designObjectLabel}<span style=\"color: rgb(149, 165, 166);\">${_name}</span></p>",
|
|
181
|
-
"className": "w-4/5",
|
|
182
|
-
"inline": true
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
185
|
+
"className": "w-4/5 field-amplify",
|
|
186
|
+
"inline": true,
|
|
187
|
+
"onEvent": {
|
|
188
|
+
"click": {
|
|
189
|
+
"actions": [
|
|
190
|
+
{
|
|
191
|
+
"actionType": "dialog",
|
|
192
|
+
"dialog": {
|
|
193
|
+
"type": "dialog",
|
|
194
|
+
"title": "编辑字段",
|
|
195
|
+
"data": {
|
|
196
|
+
"appId": "${appId}",
|
|
197
|
+
"global": "${global}",
|
|
198
|
+
"context": "${context}",
|
|
199
|
+
"designObjectName": "${designObjectName}",
|
|
200
|
+
"_master": "${_master}",
|
|
201
|
+
"_id": "${_id}"
|
|
202
|
+
},
|
|
203
|
+
"body": [
|
|
204
|
+
{
|
|
205
|
+
"type": "steedos-object-form",
|
|
206
|
+
"label": "对象表单",
|
|
207
|
+
"objectApiName": "object_fields",
|
|
208
|
+
"recordId": "${_id}",
|
|
209
|
+
"mode": "edit",
|
|
210
|
+
"defaultData": {
|
|
211
|
+
"name": "",
|
|
212
|
+
"shared": false,
|
|
213
|
+
"object": "${designObjectName}"
|
|
214
|
+
},
|
|
215
|
+
"fields": [
|
|
216
|
+
"label",
|
|
217
|
+
"readonly",
|
|
218
|
+
"is_wide"
|
|
219
|
+
],
|
|
220
|
+
"fieldsExtend": {
|
|
221
|
+
"label": {
|
|
222
|
+
"is_wide": true,
|
|
223
|
+
"group": ""
|
|
224
|
+
},
|
|
225
|
+
"readonly": {
|
|
226
|
+
"group": ""
|
|
227
|
+
},
|
|
228
|
+
"is_wide": {
|
|
229
|
+
"group": ""
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"id": "u:b71796d3cb8c",
|
|
233
|
+
"className": "mb-4",
|
|
234
|
+
"apiRequestAdaptor": "api.data.query = api.data.query.replace('object_fields__update', 'object_fields__upsert')",
|
|
235
|
+
"onEvent": {
|
|
236
|
+
"submitSucc": {
|
|
237
|
+
"weight": 0,
|
|
238
|
+
"actions": [
|
|
239
|
+
{
|
|
240
|
+
"actionType": "custom",
|
|
241
|
+
"script": "setTimeout(() => {\n doAction({\n \"actionType\": \"broadcast\",\n \"args\": {\n \"eventName\": \"@data.changed.object_fields\"\n }\n });\n}, 500);\n\n\n"
|
|
242
|
+
}
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
],
|
|
248
|
+
"showCloseButton": true,
|
|
249
|
+
"showErrorMsg": true,
|
|
250
|
+
"showLoading": true,
|
|
251
|
+
"closeOnEsc": false,
|
|
252
|
+
"dataMapSwitch": false,
|
|
253
|
+
"size": "md",
|
|
254
|
+
"id": "u:066b3884bdd8"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
]
|
|
200
258
|
}
|
|
201
|
-
|
|
202
|
-
"placement": "bottomRight",
|
|
203
|
-
"overlayClassName": "shadow !min-w-[160px]",
|
|
204
|
-
"trigger": [
|
|
205
|
-
"click"
|
|
206
|
-
],
|
|
207
|
-
"id": "u:c2140a365019",
|
|
208
|
-
"mode": "edit",
|
|
209
|
-
"className": "mr-7 w-fit h-fit opacity-0"
|
|
259
|
+
}
|
|
210
260
|
}
|
|
211
261
|
],
|
|
212
262
|
"bodyClassName": "h-7 flex justify-between items-center p-0 pl-10 my-2",
|
|
@@ -238,7 +288,7 @@
|
|
|
238
288
|
"headers": {
|
|
239
289
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
240
290
|
},
|
|
241
|
-
"requestAdaptor": "var graphqlOrder = \"\";\n
|
|
291
|
+
"requestAdaptor": "var graphqlOrder = \"\";\n//先修改字段,使系统对象自行自定义\n//根据design_field,修改对象字段的sort_no与groups\nvar index = 1;\n_.forEach(api.data.design_field, function (items, key) {\n let group = key;\n if (key == \"未分组\" || key == \"隐藏\") {\n group = null;\n }\n _.forEach(items, function (item) {\n const field = _.find(api.data.fields, { 'id': item });\n let itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify({ sort_no: index * 10, group, hidden: key == \"隐藏\" ? true : false })) + '){_id}\\n';\n if (field.id == field._id && field.is_system) {\n itemOrder = 'upsert' + index + ':object_fields__upsert(id:\"' + item + '\" , doc:' + JSON.stringify(JSON.stringify({ object: api.data.$self.designObjectName,type:field.type, _name: field._name, label: field.label, sort_no: index * 10, group, hidden: key == \"隐藏\" ? true : false, is_system: field.is_system })) + '){_id}\\n';\n }\n graphqlOrder += itemOrder;\n index++;\n })\n})\n\n//根据groups,修改对象的字段分组field_groups\nvar field_groups = _.cloneDeep(api.data.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}",
|
|
242
292
|
"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;",
|
|
243
293
|
"messages": {
|
|
244
294
|
},
|
|
@@ -283,7 +333,8 @@
|
|
|
283
333
|
"headers": {
|
|
284
334
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
285
335
|
},
|
|
286
|
-
"messages": {
|
|
336
|
+
"messages": {
|
|
337
|
+
},
|
|
287
338
|
"requestAdaptor": "",
|
|
288
339
|
"adaptor": "//筛选出可编辑的字段\r\nvar oldFields = _.filter(payload.data.fields, function (obj) { return obj.recordPermissions.allowEdit; });\r\n//将group为空的字段分为未分组的组中,将系统字段的_id改为对象名.字段名\r\noldFields = _.map(oldFields, function (obj) {\r\n obj.originId = obj._id;\r\n if (obj.hidden) {\r\n obj.group = \"隐藏\";\r\n }else if (obj.group === null) {\r\n obj.group = \"未分组\";\r\n }\r\n if (obj.is_system) {\r\n obj._id = api.data.designObjectName + \".\" + obj._name;\r\n }\r\n return obj;\r\n});\r\n\r\n//整合出字段的属性集合\r\nconst fields = oldFields.map((field) => {\r\n return {\r\n \"id\": field._id,//用与steedos-board组件的关系分辨\r\n \"_name\": field._name,\r\n \"label\": field.label,\r\n \"_id\": field.originId,//用于打开steedos-objectform\r\n \"columnSpan\": field.is_wide ? 2 : 1,\r\n \"is_system\": field.is_system,\r\n \"type\": field.type\r\n }\r\n})\r\n\r\n//从字段的group属性中,整合出字段分组的属性集合\r\nlet field_groups = _.map(_.uniqBy(oldFields, \"group\"), function (obj) {\r\n return {\r\n \"id\": obj.group,\r\n \"group_name\": obj.group,\r\n \"visible_on\": \"\"\r\n };\r\n});\r\n\r\n//合并对象上的field_groups与字段上的group\r\nlet groups = _.unionBy(api.data.field_groups, field_groups, 'id');\r\n\r\n//判断是否第一次调用接口,不是的话(说明是触发了datachange事件),返回fields与fieldUpdateData\r\nif (api.data.dataInitialed) {\r\n const eventData = api.data.eventData;\r\n let fieldUpdateData = \"\";\r\n const fieldForGroup = api.data.fieldForGroup;\r\n let fieldForGroupLength = 0;\r\n _.forIn(fieldForGroup, function (value, key) {\r\n fieldForGroupLength += value.length;\r\n });\r\n if (fieldForGroupLength < fields.length) {\r\n fieldUpdateData = {\r\n type: \"insert\",\r\n id: eventData.result.data.recordId\r\n }\r\n } else if (fieldForGroupLength > fields.length) {\r\n fieldUpdateData = {\r\n type: \"delete\",\r\n id: eventData._id\r\n }\r\n }\r\n return payload = {\r\n data: {\r\n fields,\r\n fieldUpdateData\r\n }\r\n }\r\n}\r\n\r\n//整合字段与分组的关系\r\nconst oldFieldsInGroups = _.groupBy(oldFields, \"group\");\r\nlet fieldForGroup = _.mapValues(_.groupBy(groups, \"id\"), function (group,key) {\r\n if (oldFieldsInGroups[key]) {\r\n return _.map(oldFieldsInGroups[key], function (obj) {\r\n return obj._id;\r\n });\r\n } else {\r\n return [];\r\n }\r\n});\r\n\r\n//未分组 放在所有分组开头,隐藏 放在所有分组最后\r\nconst defaultGroup = fieldForGroup[\"未分组\"];\r\nconst hiddenGroup = fieldForGroup[\"隐藏\"];\r\ndelete fieldForGroup[\"未分组\"];\r\ndelete fieldForGroup[\"隐藏\"];\r\nfieldForGroup = _.merge({ \"未分组\": defaultGroup }, fieldForGroup, { \"隐藏\": hiddenGroup });\r\n\r\n//根据fieldForGroup调整groups顺序,设置分组与保存时需要groups按照顺序\r\nconst keys = _.keys(fieldForGroup);\r\ngroups = _.sortBy(groups, function (group) { return _.findIndex(keys, function (key) { return key == group.group_name }) });\r\n\r\nreturn payload = {\r\n data: {\r\n fields,\r\n groups,\r\n fieldForGroup,\r\n dataInitialed: true\r\n }\r\n};",
|
|
289
340
|
"sendOn": "!!this.designObjectId"
|
|
@@ -295,7 +346,7 @@
|
|
|
295
346
|
"actions": [
|
|
296
347
|
{
|
|
297
348
|
"actionType": "custom",
|
|
298
|
-
"script": "
|
|
349
|
+
"script": "\nconst fieldForGroup = context.props.data.fieldForGroup;\nconst fieldUpdateData = event.data.fieldUpdateData;\nif (fieldUpdateData && fieldUpdateData.type == \"delete\") {\n _.forIn(fieldForGroup, function (group, group_name) {\n _.remove(group, function (field) {\n return field === fieldUpdateData.id;\n })\n });\n} else if (fieldUpdateData && fieldUpdateData.type == \"insert\") {\n fieldForGroup[\"未分组\"].push(fieldUpdateData.id);\n}\n// doAction({\n// actionType: 'setValue',\n// componentId: \"service_field_design\",\n// args: {\n// value: { fieldForGroup }\n// }\n// });\n\ndoAction({\n actionType: 'setValue',\n componentId: \"form_field_design\",\n args: {\n value: { design_field:fieldForGroup }\n }\n});\n\n",
|
|
299
350
|
"expression": "${event.data.fieldUpdateData}"
|
|
300
351
|
}
|
|
301
352
|
]
|
|
@@ -352,11 +403,11 @@
|
|
|
352
403
|
},
|
|
353
404
|
"id": "u:993ee4316643",
|
|
354
405
|
"css": {
|
|
355
|
-
".steedos-design-field li.p-1:hover .opacity-0": {
|
|
356
|
-
"opacity": "0.99"
|
|
357
|
-
},
|
|
358
406
|
".antd-TplField p": {
|
|
359
407
|
"margin": "0.625rem 0.625rem"
|
|
408
|
+
},
|
|
409
|
+
".steedos-design-field li.p-1 .field-amplify:hover": {
|
|
410
|
+
"font-size": "17px"
|
|
360
411
|
}
|
|
361
412
|
},
|
|
362
413
|
"className": "steedos-design-field",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-object-database",
|
|
3
|
-
"version": "2.5.20-beta.
|
|
3
|
+
"version": "2.5.20-beta.22",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
},
|
|
16
16
|
"repository": {},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "25b4069f768dcad4cb258f381b2532651b9b1875"
|
|
19
19
|
}
|
package/package.service.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 1985-10-26 16:15:00
|
|
4
|
-
* @LastEditors:
|
|
5
|
-
* @LastEditTime: 2023-11-10
|
|
4
|
+
* @LastEditors: 孙浩林 sunhaolin@steedos.com
|
|
5
|
+
* @LastEditTime: 2023-11-30 10:13:13
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
"use strict";
|
|
@@ -114,7 +114,8 @@ module.exports = {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
if(data.is_system){
|
|
117
|
-
|
|
117
|
+
// 'label' 先禁止编辑label , 目前由于i18n的问题导致 label无效.
|
|
118
|
+
data = _.pick(data, ['defaultValue', 'group', 'rows', 'sort_no', 'is_wide', 'index', 'sortable', 'searchable', 'filterable', 'visible_on', 'inlineHelpText', 'description', 'amis', 'required', 'unique', 'readonly', 'hidden', 'deleted_lookup_record_behavior']);
|
|
118
119
|
}
|
|
119
120
|
return object.update(id, data, userSession)
|
|
120
121
|
},
|