@steedos/service-plugin-amis 2.3.0-beta.17 → 2.3.0-beta.19

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.
@@ -57,7 +57,8 @@
57
57
  "labelClassName": "text-left",
58
58
  "en-US": {
59
59
  "label": "Label"
60
- }
60
+ },
61
+ "id": "u:a45229ed29f8"
61
62
  },
62
63
  {
63
64
  "name": "name",
@@ -70,7 +71,8 @@
70
71
  "en-US": {
71
72
  "label": "API Name",
72
73
  "labelRemark": "Can only contain lowercase letters and numbers, must start with a letter,cannot end with an underscore character or contain two consecutive underscore characters"
73
- }
74
+ },
75
+ "id": "u:ff927884ec36"
74
76
  },
75
77
  {
76
78
  "name": "object_name",
@@ -92,7 +94,8 @@
92
94
  },
93
95
  "en-US": {
94
96
  "label": "Object"
95
- }
97
+ },
98
+ "id": "u:1427b8edc8f5"
96
99
  },
97
100
  {
98
101
  "name": "filter_scope",
@@ -110,7 +113,6 @@
110
113
  "en-US": {
111
114
  "label": "Mine"
112
115
  }
113
-
114
116
  },
115
117
  {
116
118
  "label": "工作区",
@@ -125,8 +127,8 @@
125
127
  "labelClassName": "text-left",
126
128
  "en-US": {
127
129
  "label": "Filter Scope"
128
- }
129
-
130
+ },
131
+ "id": "u:5f00b15822d5"
130
132
  },
131
133
  {
132
134
  "name": "shared",
@@ -137,7 +139,8 @@
137
139
  "option": "共享视图到工作区",
138
140
  "en-US": {
139
141
  "option": "Shared to All Users"
140
- }
142
+ },
143
+ "id": "u:3ba5090f7fd0"
141
144
  },
142
145
  {
143
146
  "name": "show_count",
@@ -148,13 +151,15 @@
148
151
  "option": "显示条目数",
149
152
  "en-US": {
150
153
  "option": "Show Record Count"
151
- }
154
+ },
155
+ "id": "u:811f0c5d03ad"
152
156
  },
153
157
  {
154
158
  "label": "显示的列",
155
159
  "type": "transfer",
156
160
  "name": "columns",
157
161
  "options": [],
162
+ "multiple": true,
158
163
  "id": "u:92c0b3cccca0",
159
164
  "required": true,
160
165
  "placeholder": "-",
@@ -186,9 +191,11 @@
186
191
  "labelClassName": "text-left",
187
192
  "en-US": {
188
193
  "label": "Sort NO."
189
- }
194
+ },
195
+ "id": "u:25a6ee957503"
190
196
  }
191
- ]
197
+ ],
198
+ "id": "u:7f7b2d3ea064"
192
199
  },
193
200
  {
194
201
  "type": "fieldSet",
@@ -217,7 +224,8 @@
217
224
  "extractValue": true,
218
225
  "en-US": {
219
226
  "label": "Default Filter Fields"
220
- }
227
+ },
228
+ "multiple": true
221
229
  },
222
230
  {
223
231
  "type": "radios",
@@ -241,7 +249,6 @@
241
249
  "en-US": {
242
250
  "label": "Controller"
243
251
  }
244
-
245
252
  },
246
253
  {
247
254
  "type": "condition-builder",
@@ -276,7 +283,8 @@
276
283
  "collapsed": true,
277
284
  "en-US": {
278
285
  "title": "Filter"
279
- }
286
+ },
287
+ "id": "u:7d4a03469ab2"
280
288
  },
281
289
  {
282
290
  "type": "fieldSet",
@@ -308,15 +316,16 @@
308
316
  "extractValue": true,
309
317
  "en-US": {
310
318
  "label": "Default Sort Order"
311
- }
319
+ },
320
+ "multiple": true
312
321
  }
313
322
  ],
314
323
  "visibleOn": "!!this.object_name",
315
324
  "collapsed": true,
316
325
  "en-US": {
317
326
  "title": "Order"
318
- }
319
-
327
+ },
328
+ "id": "u:82b56e7d9639"
320
329
  },
321
330
  {
322
331
  "type": "fieldSet",
@@ -349,14 +358,16 @@
349
358
  "className": "col-span-2 m-0",
350
359
  "en-US": {
351
360
  "label": "Mobile Columns"
352
- }
361
+ },
362
+ "multiple": true
353
363
  }
354
364
  ],
355
365
  "collapsed": true,
356
366
  "visibleOn": "!!this.object_name",
357
367
  "en-US": {
358
368
  "title": "Mobile"
359
- }
369
+ },
370
+ "id": "u:51174159a42e"
360
371
  }
361
372
  ],
362
373
  "panelClassName": "m-0",
@@ -371,7 +382,8 @@
371
382
  "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
372
383
  "en-US": {
373
384
  "label": "Cancel"
374
- }
385
+ },
386
+ "id": "u:2b559c02ad83"
375
387
  },
376
388
  {
377
389
  "type": "button",
@@ -380,12 +392,14 @@
380
392
  "level": "info",
381
393
  "en-US": {
382
394
  "label": "Save"
383
- }
395
+ },
396
+ "id": "u:a48a8052e83a"
384
397
  }
385
398
  ],
386
399
  "actionsClassName": "p-sm b-t b-light text-center",
387
400
  "className": "steedos-amis-form",
388
- "language": "javascript"
401
+ "language": "javascript",
402
+ "id": "u:d951542bb161"
389
403
  }
390
404
  ],
391
405
  "regions": [
@@ -394,11 +408,12 @@
394
408
  "data": {
395
409
  "objectName": "object_listviews",
396
410
  "context": {
397
- "rootUrl": "http://127.0.0.1:5000"
411
+ "rootUrl": "http://127.0.0.1:5800"
398
412
  }
399
413
  },
400
414
  "bodyClassName": "p-0",
401
415
  "name": "page_edit_${recordId}",
402
416
  "initApi": null,
403
- "initFetch": null
417
+ "initFetch": null,
418
+ "id": "u:6ada123f9d4a"
404
419
  }
@@ -0,0 +1,201 @@
1
+ /*
2
+ * @Description: 提供amis选人组件需要的数据接口
3
+ */
4
+
5
+ const objectql = require("@steedos/objectql");
6
+ const _ = require("lodash");
7
+ const clone = require("clone");
8
+
9
+
10
+ module.exports = {
11
+ name: "amis-metadata-space_users",
12
+ mixins: [],
13
+ /**
14
+ * Settings
15
+ */
16
+ settings: {
17
+
18
+ },
19
+
20
+ /**
21
+ * Dependencies
22
+ */
23
+ dependencies: [],
24
+
25
+ /**
26
+ * Actions
27
+ */
28
+ actions: {
29
+ getSpaceUsersOptions: {
30
+ rest: {
31
+ method: "GET",
32
+ path: "/space_users/options"
33
+ },
34
+ async handler(ctx) {
35
+ const options = await this.getSpaceUsersOptions(ctx);
36
+ return { status: 0, data: { options } }
37
+ }
38
+ }
39
+ },
40
+
41
+ /**
42
+ * Events
43
+ */
44
+ events: {
45
+
46
+ },
47
+
48
+ /**
49
+ * Methods
50
+ */
51
+ methods: {
52
+ /**
53
+ 1.当没有传入参数,即第一次请求接口时返回如下格式的数据:
54
+ [
55
+ {
56
+ "leftOptions": [
57
+ {
58
+ "label": "总公司",
59
+ "value": 1,
60
+ "defer": true
61
+ }
62
+ ],
63
+ "children": [
64
+ {
65
+ "ref": 1,
66
+ "defer": true
67
+ },
68
+ {
69
+ "ref": 2,
70
+ "defer": true
71
+ },
72
+ {
73
+ "ref": 3,
74
+ "defer": true
75
+ },
76
+ {
77
+ "ref": 4,
78
+ "defer": true
79
+ },
80
+ {
81
+ "ref": 5,
82
+ "defer": true
83
+ },
84
+ {
85
+ "ref": 6,
86
+ "defer": true
87
+ }
88
+ ]
89
+ }
90
+ ]
91
+ 2.当传入def参数值时,表示展开左侧组织树某个组织,此时返回如下格式的数据:
92
+ [
93
+ {
94
+ "label": "部门 A",
95
+ "value": 2
96
+ },
97
+ {
98
+ "label": "部门 B",
99
+ "value": 3,
100
+ "defer": true
101
+ },
102
+ {
103
+ "label": "部门 C",
104
+ "value": 4
105
+ }
106
+ ]
107
+ 2.当传入ref参数值时,表示点击左侧某个组织,按此组织过滤右侧人员列表,此时返回如下格式的数据:
108
+ [
109
+ {
110
+ "label": "用户 1",
111
+ "value": "user1"
112
+ },
113
+ {
114
+ "label": "用户 2",
115
+ "value": "user2"
116
+ }
117
+ ]
118
+ */
119
+ getSpaceUsersOptions: {
120
+ async handler(ctx) {
121
+ const userSession = ctx.meta.user;
122
+ const spaceId = userSession.spaceId;
123
+ // 有 dep 值则是懒加载部门树,有 ref 值则是懒加载人员,否则按第一次加载返回第一个 option作为select的基本配置
124
+ // 需要懒加载的项通过返回相关项的 defer 为 true 来标记。左右两部分都支持懒加载。
125
+ // 参考 https://aisuda.bce.baidu.com/amis/zh-CN/components/form/select#%E4%BA%BA%E5%91%98%E7%82%B9%E9%80%89
126
+ const dep = ctx.params.dep;
127
+ const ref = ctx.params.ref;
128
+ const valueField = ctx.params.valueField || "user";//user or _id
129
+ const term = ctx.params.term;
130
+ if(dep){
131
+ // 有 dep 值则是懒加载部门树,返回展开后的部门列表
132
+ const fields = "_id,name,children".split(",");
133
+ const filters = [['space', '=', spaceId], ['parent', '=', dep]];
134
+ const orgs = await objectql.getObject('organizations').find({filters: filters, fields: fields});
135
+ const reOptions = _.map(orgs, (org)=>{
136
+ return {
137
+ value: org._id,
138
+ label: org.name,
139
+ defer: !!(org.children && org.children.length)
140
+ }
141
+ });
142
+ return reOptions;
143
+ }
144
+ else if(ref || term){
145
+ // 有 ref 值则是懒加载人员,返回按ref值过滤后的人员列表
146
+ const fields = "_id,name,user".split(",");
147
+ const filters = [['space', '=', spaceId], ['user_accepted', '=', true]];
148
+ if(term){
149
+ const fieldsForSearch = ["name", "username", "email", "mobile"];
150
+ const termFilters = [];
151
+ fieldsForSearch.forEach(function(field){
152
+ termFilters.push([field, 'contains', term]);
153
+ termFilters.push("or");
154
+ });
155
+ termFilters.pop();
156
+ filters.push(termFilters);
157
+ }
158
+ else{
159
+ filters.push(['organizations_parents', '=', ref]);
160
+ }
161
+ const sus = await objectql.getObject('space_users').find({filters: filters, fields: fields});
162
+ const reOptions = _.map(sus, (su)=>{
163
+ return {
164
+ value: su[valueField],
165
+ label: su.name
166
+ }
167
+ });
168
+ return reOptions;
169
+ }
170
+ else{
171
+ // 接口返回的选项中,第一个 option 是以下这种格式时,
172
+ // 也会把 options[0].leftOptions 当成 leftOptions
173
+ // options[0].children 当 options。
174
+ // 同时 options[0].leftDefaultValue 可以用来配置左侧选项的默认值。
175
+ const reOptions = [{
176
+ children: [],
177
+ leftOptions: [],
178
+ leftDefaultValue: ''
179
+ }];
180
+ const fields = "_id,name,children".split(",");
181
+ const filters = [['space', '=', spaceId], ['parent', '=', null]];
182
+ const rootOrgs = await objectql.getObject('organizations').find({filters: filters, fields: fields});
183
+ reOptions[0].leftOptions = _.map(rootOrgs, (org)=>{
184
+ return {
185
+ value: org._id,
186
+ label: org.name,
187
+ defer: !!(org.children && org.children.length)
188
+ }
189
+ });
190
+ reOptions[0].children = _.map(rootOrgs, (org)=>{
191
+ return {
192
+ ref: org._id,
193
+ defer: !!(org.children && org.children.length)
194
+ }
195
+ });
196
+ return reOptions;
197
+ }
198
+ }
199
+ }
200
+ }
201
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "2.3.0-beta.17",
3
+ "version": "2.3.0-beta.19",
4
4
  "main": "package.service.js",
5
5
  "scripts": {
6
6
  "build": "node .scripts/build.tailwind.js"
@@ -10,5 +10,5 @@
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "gitHead": "c538df4a4cb88a220b0ab3b2a3eda70471e709a3"
13
+ "gitHead": "80ce49d0436a902175913e8324c5b5c5c1391e4a"
14
14
  }