@steedos/service-core-objects 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.
- package/main/default/objects/_base/base.client.js +10 -9
- package/main/default/objects/_base/base.object.js +108 -105
- package/main/default/objects/apps/buttons/disable.button.js +3 -1
- package/main/default/objects/apps/buttons/enable.button.js +3 -1
- package/main/default/objects/object_fields/buttons/recomputeFormulaValues.button.js +6 -2
- package/main/default/objects/object_fields/buttons/recomputeSummaryValues.button.js +6 -2
- package/main/default/objects/object_listviews/buttons/showDesign.button.js +6 -6
- package/main/default/objects/objects/buttons/show_object.button.js +1 -28
- package/main/default/objects/objects/listviews/all.listview.yml +1 -0
- package/main/default/objects/queue_import.object.yml +15 -1
- package/main/default/routes/importRecords.router.js +87 -0
- package/main/default/services/notifications.service.js +189 -0
- package/main/default/triggers/queue_import.trigger.js +16 -0
- package/package.json +4 -3
- package/main/default/objects/object_listviews/buttons/copy.button.js +0 -58
- package/main/default/objects/object_listviews/buttons/copy.button.yml +0 -3
|
@@ -166,14 +166,14 @@ Steedos.StandardObjects = {
|
|
|
166
166
|
// });
|
|
167
167
|
// }
|
|
168
168
|
// },
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
169
|
+
standard_submit_for_approval:{
|
|
170
|
+
visible: function (object_name, record_id) {
|
|
171
|
+
return Steedos.ProcessManager.allowSubmit(object_name, record_id);
|
|
172
|
+
},
|
|
173
|
+
// todo: function (object_name, record_id) {
|
|
174
|
+
// Steedos.ProcessManager.submit(object_name, record_id);
|
|
175
|
+
// }
|
|
176
|
+
},
|
|
177
177
|
standard_import_data:{
|
|
178
178
|
visible: function(objectName){
|
|
179
179
|
var allowCreate = Steedos.Object.base.actions.standard_new.visible.apply(this, arguments);
|
|
@@ -202,7 +202,8 @@ Steedos.StandardObjects = {
|
|
|
202
202
|
}
|
|
203
203
|
window._hasImportTemplates[objectName] = false;
|
|
204
204
|
return false;
|
|
205
|
-
}
|
|
205
|
+
},
|
|
206
|
+
todo: function(object_name){}
|
|
206
207
|
},
|
|
207
208
|
standard_export_excel:{
|
|
208
209
|
visible: function(objectName, record_id, record_permissions, props){
|
|
@@ -266,111 +266,114 @@ module.exports = {
|
|
|
266
266
|
// return Steedos.StandardObjects.Base.Actions.standard_view_instance.todo.apply(this, arguments)
|
|
267
267
|
// }
|
|
268
268
|
// },
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
269
|
+
standard_submit_for_approval: {
|
|
270
|
+
visible: function (object_name, record_id, record_permissions, data) {
|
|
271
|
+
if (data && data.uiSchema && data.uiSchema.enable_process){
|
|
272
|
+
return Steedos.StandardObjects.Base.Actions.standard_submit_for_approval.visible.apply(this, arguments)
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
},
|
|
276
|
+
on: "record_only",
|
|
277
|
+
type: 'amis_button',
|
|
278
|
+
amis_schema: {
|
|
279
|
+
"type": "service",
|
|
280
|
+
"body": [
|
|
281
|
+
{
|
|
282
|
+
"type": "button",
|
|
283
|
+
"label": "提请审批",
|
|
284
|
+
"id": "u:standard_submit_for_approval",
|
|
285
|
+
"onEvent": {
|
|
286
|
+
"click": {
|
|
287
|
+
"actions": [
|
|
288
|
+
{
|
|
289
|
+
"actionType": "dialog",
|
|
290
|
+
"dialog": {
|
|
291
|
+
"type": "dialog",
|
|
292
|
+
"title": "提交待审核",
|
|
293
|
+
"body": [
|
|
294
|
+
{
|
|
295
|
+
"type": "form",
|
|
296
|
+
"id": "u:1eb06e6962d8",
|
|
297
|
+
"title": "表单",
|
|
298
|
+
"body": [
|
|
299
|
+
{
|
|
300
|
+
"type": "steedos-field",
|
|
301
|
+
"id": "u:9f4486c22f52",
|
|
302
|
+
"field": "{\n \"label\": \"意见\",\n \"name\": \"comment\",\n \"type\": \"textarea\",\n \"rows\": 3,\n \"is_wide\": true\n}",
|
|
303
|
+
"name": "comment"
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
"type": "steedos-field",
|
|
307
|
+
"id": "u:9f4486c22f52",
|
|
308
|
+
"field": "{\n \"label\": \"选择下一位批准人\",\n \"name\": \"approver\",\n \"type\": \"lookup\",\n \"reference_to\": \"space_users\",\n \"reference_to_field\": \"user\",\n \"required\": true,\n \"is_wide\": true\n}",
|
|
309
|
+
"name": "approver",
|
|
310
|
+
"placeholder": "",
|
|
311
|
+
"visibleOn": "${showApprover === true}"
|
|
312
|
+
}
|
|
313
|
+
],
|
|
314
|
+
"wrapWithPanel": false,
|
|
315
|
+
"mode": "normal",
|
|
316
|
+
"api": {
|
|
317
|
+
"method": "post",
|
|
318
|
+
"url": "${context.rootUrl}/api/v4/process/submit/${objectName}/${recordId}",
|
|
319
|
+
"data": {
|
|
320
|
+
"&": "$$"
|
|
321
|
+
},
|
|
322
|
+
"requestAdaptor": "\napi.data = {\n comment: api.body.comment\n};\n\nif (api.body.approver) {\n api.data.approver = api.body.approver;\n}\n\nreturn api;",
|
|
323
|
+
"adaptor": "\npayload.data = {};\npayload.data.showApprover = payload.error === 'process_approval_error_needToChooseApprover'\n\nif (payload.state === 'FAILURE') {\n if (payload.data.showApprover) {\n payload.msg = \"请选择下一位批准人\";\n } else { \n payload.msg = window.t(payload.error)\n }\n}\n\n\nreturn payload;",
|
|
324
|
+
"responseData": {
|
|
325
|
+
"&": "$$"
|
|
326
|
+
},
|
|
327
|
+
"headers": {
|
|
328
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
"debug": false,
|
|
332
|
+
"onEvent": {
|
|
333
|
+
"submitSucc": {
|
|
334
|
+
"weight": 0,
|
|
335
|
+
"actions": [
|
|
336
|
+
{
|
|
337
|
+
"actionType": "custom",
|
|
338
|
+
"script": `
|
|
339
|
+
doAction({
|
|
340
|
+
"actionType": "broadcast",
|
|
341
|
+
"args": {
|
|
342
|
+
"eventName": \`@data.changed.\${event.data.objectName}\`
|
|
343
|
+
},
|
|
344
|
+
"data": {
|
|
345
|
+
"objectName": \`\${event.data.objectName}\`
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
`
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
],
|
|
355
|
+
"id": "u:7a3f92e56805",
|
|
356
|
+
"closeOnEsc": false,
|
|
357
|
+
"closeOnOutside": false,
|
|
358
|
+
"showCloseButton": true,
|
|
359
|
+
"size": "md"
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
],
|
|
363
|
+
"weight": 0
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
],
|
|
368
|
+
"regions": [
|
|
369
|
+
"body"
|
|
370
|
+
],
|
|
371
|
+
"data": {
|
|
372
|
+
},
|
|
373
|
+
"bodyClassName": "p-0",
|
|
374
|
+
"id": "u:50444554a302"
|
|
375
|
+
}
|
|
376
|
+
},
|
|
374
377
|
standard_export_excel: {
|
|
375
378
|
label: "Export Excel",
|
|
376
379
|
visible: function (object_name, record_id, record_permissions) {
|
|
@@ -28,7 +28,9 @@ module.exports = {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
setTimeout(function(){
|
|
31
|
-
SteedosUI.notification.success(
|
|
31
|
+
SteedosUI.notification.success({
|
|
32
|
+
message: t('steedos_packages.disable.toastr_success')
|
|
33
|
+
});
|
|
32
34
|
window.location.reload()
|
|
33
35
|
}, 100 * 1)
|
|
34
36
|
},
|
|
@@ -12,10 +12,14 @@ module.exports = {
|
|
|
12
12
|
}),
|
|
13
13
|
success: function(data){
|
|
14
14
|
if(data.status == 1){
|
|
15
|
-
SteedosUI.notification.error(
|
|
15
|
+
SteedosUI.notification.error({
|
|
16
|
+
message: t('object_fields_function_recomputeFormulaValues_error')
|
|
17
|
+
});
|
|
16
18
|
return;
|
|
17
19
|
}
|
|
18
|
-
SteedosUI.notification.success(
|
|
20
|
+
SteedosUI.notification.success({
|
|
21
|
+
message: t('object_fields_function_recomputeFormulaValues_success')
|
|
22
|
+
});
|
|
19
23
|
},
|
|
20
24
|
error: function(XMLHttpRequest){
|
|
21
25
|
SteedosUI.notification.error({message: XMLHttpRequest.responseJSON.msg});
|
|
@@ -13,10 +13,14 @@ module.exports = {
|
|
|
13
13
|
}),
|
|
14
14
|
success: function(data){
|
|
15
15
|
if(data.status == 1){
|
|
16
|
-
SteedosUI.notification.error(
|
|
16
|
+
SteedosUI.notification.error({
|
|
17
|
+
message: t('object_fields_function_recomputeSummaryValues_error')
|
|
18
|
+
});
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
|
-
SteedosUI.notification.success(
|
|
21
|
+
SteedosUI.notification.success({
|
|
22
|
+
message: t('object_fields_function_recomputeSummaryValues_success')
|
|
23
|
+
});
|
|
20
24
|
},
|
|
21
25
|
error: function(XMLHttpRequest){
|
|
22
26
|
SteedosUI.notification.error({message: XMLHttpRequest.responseJSON.msg});
|
|
@@ -2,9 +2,12 @@ module.exports = {
|
|
|
2
2
|
showDesign:function (object_name, record_id) {
|
|
3
3
|
document.location = Steedos.absoluteUrl(`/api/amisListviewDesign?id=${record_id}&object=${this.record.object_name}&assetUrls=${Builder.settings.assetUrls}&locale=${Builder.settings.locale}`);
|
|
4
4
|
},
|
|
5
|
-
showDesignVisible:function (object_name, record_id, record_permissions) {
|
|
5
|
+
showDesignVisible:function (object_name, record_id, record_permissions, data) {
|
|
6
6
|
var perms= {};
|
|
7
|
-
var record =
|
|
7
|
+
var record = data && data.record;
|
|
8
|
+
if (!Steedos.isSpaceAdmin()) {
|
|
9
|
+
return false
|
|
10
|
+
}
|
|
8
11
|
if(!record){
|
|
9
12
|
return false;
|
|
10
13
|
}
|
|
@@ -14,10 +17,7 @@ showDesignVisible:function (object_name, record_id, record_permissions) {
|
|
|
14
17
|
if (record_permissions) {
|
|
15
18
|
perms = record_permissions;
|
|
16
19
|
} else {
|
|
17
|
-
|
|
18
|
-
if (record_permissions) {
|
|
19
|
-
perms = record_permissions;
|
|
20
|
-
}
|
|
20
|
+
return false
|
|
21
21
|
}
|
|
22
22
|
return perms["allowEdit"];
|
|
23
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
|
|
3
3
|
show_object: function(object_name, record_id, item_element) {
|
|
4
|
-
var record = this.record
|
|
4
|
+
var record = this.record;
|
|
5
5
|
if (record && record.record) {
|
|
6
6
|
record = record.record;
|
|
7
7
|
}
|
|
@@ -13,34 +13,7 @@ module.exports = {
|
|
|
13
13
|
return toastr.warning("请先启动对象");
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
if (record.datasource && record.datasource != 'default' && record.datasource != 'meteor') {
|
|
17
|
-
var datasource = Creator.odata.get('datasources', record.datasource, 'is_enable');
|
|
18
|
-
if (!datasource) {
|
|
19
|
-
return toastr.error("未找到数据源");
|
|
20
|
-
}
|
|
21
|
-
if (!datasource.is_enable) {
|
|
22
|
-
return toastr.warning("请先启动数据源");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
16
|
window.open(Steedos.getRelativeUrl("/app/admin/" + (record.name || this.record.name)));
|
|
26
|
-
// SteedosUI.Object.getUISchema(record.name).then((res)=>{
|
|
27
|
-
// if(res.idFieldName){
|
|
28
|
-
// window.open(Steedos.getRelativeUrl("/app/-/" + record.name));
|
|
29
|
-
// }else{
|
|
30
|
-
// return toastr.error("请配置主键字段");
|
|
31
|
-
// }
|
|
32
|
-
// }).catch(function(err){
|
|
33
|
-
// return window.toastr.error(err.message);
|
|
34
|
-
// })
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// var allViews = Creator.odata.query('object_listviews', { $select: '_id', $filter: `((object_name eq '${record.name}') and (name eq 'all'))` }, true);
|
|
39
|
-
// if(allViews && allViews.length > 0){
|
|
40
|
-
// Steedos.openWindow(Steedos.getRelativeUrl("/app/-/" + record.name + "/grid/" + allViews[0]._id))
|
|
41
|
-
// }else{
|
|
42
|
-
// Steedos.openWindow(Steedos.getRelativeUrl("/app/-/" + record.name + "/grid/all"))
|
|
43
|
-
// }
|
|
44
17
|
},
|
|
45
18
|
show_objectVisible: function(object_name, record_id, record_permissions, data) {
|
|
46
19
|
var record = data && data.record;
|
|
@@ -205,7 +205,21 @@ list_views:
|
|
|
205
205
|
- name
|
|
206
206
|
- object_name
|
|
207
207
|
- operation
|
|
208
|
-
- template_url
|
|
208
|
+
- field: template_url
|
|
209
|
+
amis:
|
|
210
|
+
"type": "button-group"
|
|
211
|
+
"static": false
|
|
212
|
+
"buttons":
|
|
213
|
+
- "type": "button"
|
|
214
|
+
"label": "下载"
|
|
215
|
+
"visibleOn": "${template_url}"
|
|
216
|
+
"level": "link"
|
|
217
|
+
"actionType": "download"
|
|
218
|
+
"api":
|
|
219
|
+
"url": "${template_url}"
|
|
220
|
+
"method": "get"
|
|
221
|
+
"headers":
|
|
222
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
209
223
|
filter_scope: space
|
|
210
224
|
permission_set:
|
|
211
225
|
user:
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
|
|
2
|
+
const { requireAuthentication } = require('@steedos/auth');
|
|
3
|
+
const { importWithCmsFile } = require('@steedos/data-import/lib/index')
|
|
4
|
+
const express = require('express');
|
|
5
|
+
const router = express.Router();
|
|
6
|
+
|
|
7
|
+
const json2xls = require('json2xls');
|
|
8
|
+
const { getObject } = require('@steedos/objectql');
|
|
9
|
+
const _ = require('lodash');
|
|
10
|
+
|
|
11
|
+
const initiateImport = async function (req, res) {
|
|
12
|
+
try {
|
|
13
|
+
const userSession = req.user;
|
|
14
|
+
// const spaceId = userSession.spaceId;
|
|
15
|
+
let { importObjId, importObjectHistoryId } = req.body;
|
|
16
|
+
let fileId = null;
|
|
17
|
+
const isSpaceAdmin = req.user.is_space_admin;
|
|
18
|
+
//传入了importObjId参数,必须是工作区管理员权限
|
|
19
|
+
if (importObjId && !isSpaceAdmin) {
|
|
20
|
+
return res
|
|
21
|
+
.status(401)
|
|
22
|
+
.send({ status: "error", message: "Permission denied" });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (importObjectHistoryId) {
|
|
26
|
+
const record = await getObject('queue_import_history').findOne(importObjectHistoryId);
|
|
27
|
+
if (!record) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`can not find queue_import_history record with given id "${importObjectHistoryId}"`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (!record.file) {
|
|
33
|
+
throw new Error(`Upload excel file, please.`);
|
|
34
|
+
}
|
|
35
|
+
fileId = record.file
|
|
36
|
+
importObjId = record.queue_import
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// if (!Steedos.hasFeature('metadata_api', spaceId)) {
|
|
40
|
+
// return res.status(403).send({ status: 'error', message: 'Please upgrade the platform license to Enterprise Edition' });
|
|
41
|
+
// }
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
let result = await importWithCmsFile(importObjId, userSession, importObjectHistoryId, fileId);
|
|
45
|
+
return res.status(200).send({ status: "success", result });
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.log(error)
|
|
48
|
+
return res
|
|
49
|
+
.status(500)
|
|
50
|
+
.send({ status: "failed", message: error.message });
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.log(error)
|
|
54
|
+
return res.status(500).send({ status: "failed", error: error.message });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
router.post('/api/data/initiateImport', requireAuthentication, initiateImport);
|
|
59
|
+
|
|
60
|
+
router.get('/api/data/download/template/:record_id', requireAuthentication, async function (req, res) {
|
|
61
|
+
try {
|
|
62
|
+
const { record_id } = req.params;
|
|
63
|
+
let queueImportDoc = await getObject("queue_import").findOne(record_id);
|
|
64
|
+
let fieldMaps = queueImportDoc.field_mappings;
|
|
65
|
+
if (_.isEmpty(fieldMaps)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
let json = {};
|
|
69
|
+
for (const fMap of fieldMaps) {
|
|
70
|
+
json[fMap.header] = null;
|
|
71
|
+
}
|
|
72
|
+
let xls = json2xls([json]);
|
|
73
|
+
res.writeHead(200, {
|
|
74
|
+
'Content-Type': 'application/octet-stream',
|
|
75
|
+
'Content-Disposition': 'attachment;filename=' + encodeURI(queueImportDoc.description + '.xlsx'),
|
|
76
|
+
'Access-Control-Expose-Headers': 'Content-Disposition'
|
|
77
|
+
});
|
|
78
|
+
res.end(xls, 'binary');
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error);
|
|
81
|
+
res.status(500).send({ error: error.message });
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
exports.default = router;
|
|
87
|
+
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
2
|
+
const _ = require("lodash");
|
|
3
|
+
const objectql = require('@steedos/objectql');
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
name: 'notifications',
|
|
7
|
+
namespace: "steedos",
|
|
8
|
+
mixins: [],
|
|
9
|
+
/**
|
|
10
|
+
* Settings
|
|
11
|
+
*/
|
|
12
|
+
settings: {
|
|
13
|
+
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Dependencies
|
|
18
|
+
*/
|
|
19
|
+
dependencies: [],
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Actions
|
|
23
|
+
*/
|
|
24
|
+
actions: {
|
|
25
|
+
/**
|
|
26
|
+
* @api {post} add 发送通知
|
|
27
|
+
* @apiName add
|
|
28
|
+
* @apiGroup notifications.service.js
|
|
29
|
+
* @apiParam {Object} message 消息主体
|
|
30
|
+
* @apiParam {String} message[name] 消息标题
|
|
31
|
+
* @apiParam {String} message[body] 消息内容
|
|
32
|
+
* @apiParam {String} message[related_to] 关联记录
|
|
33
|
+
* @apiParam {String} message[related_name] 关联名称
|
|
34
|
+
* @apiParam {String} message[from] 发送者ID,选填
|
|
35
|
+
* @apiParam {String} message[space] 工作区ID
|
|
36
|
+
* @apiParam {String} from 发送者ID
|
|
37
|
+
* @apiParam {String[]} to 接受者ID
|
|
38
|
+
*/
|
|
39
|
+
add: {
|
|
40
|
+
params: {
|
|
41
|
+
message: {
|
|
42
|
+
type: "object",
|
|
43
|
+
props: {
|
|
44
|
+
name: { type: "string" },
|
|
45
|
+
body: { type: "string" },
|
|
46
|
+
related_to: {
|
|
47
|
+
type: "object",
|
|
48
|
+
props: {
|
|
49
|
+
o: { type: "string" },
|
|
50
|
+
ids: { type: "array", items: "string" },
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
related_name: { type: "string", optional: true },
|
|
54
|
+
from: { type: "string", optional: true },
|
|
55
|
+
space: { type: "string" },
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
from: { type: "string" },
|
|
59
|
+
to: {
|
|
60
|
+
type: "multi",
|
|
61
|
+
rules: [
|
|
62
|
+
{ type: "string" },
|
|
63
|
+
{ type: "array", items: "string" }
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
async handler(ctx) {
|
|
68
|
+
let { from, to, message } = ctx.params;
|
|
69
|
+
this.broker.emit('notifications.add', {from, to, message})
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
let notifications_ids = [];
|
|
73
|
+
if(!_.isArray(to) && _.isString(to)){
|
|
74
|
+
to = [to]
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (_.isEmpty(to)) {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
let now = new Date();
|
|
81
|
+
const datasource = objectql.getDataSource('default');
|
|
82
|
+
const adapter = datasource.adapter
|
|
83
|
+
await adapter.connect()
|
|
84
|
+
const collection = adapter.collection('notifications');
|
|
85
|
+
let bulk = collection.initializeUnorderedBulkOp();
|
|
86
|
+
|
|
87
|
+
let doc = Object.assign({
|
|
88
|
+
created: now,
|
|
89
|
+
modified: now,
|
|
90
|
+
created_by: from,
|
|
91
|
+
modified_by: from
|
|
92
|
+
}, message)
|
|
93
|
+
|
|
94
|
+
for (const userId of to) {
|
|
95
|
+
let notifications_id = await objectql.getObject('notifications')._makeNewID();
|
|
96
|
+
bulk.insert(Object.assign({}, doc, {_id: notifications_id, owner: userId}));
|
|
97
|
+
notifications_ids.push(notifications_id)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
bulk.execute().catch(function (error) {
|
|
101
|
+
console.error("通知数据插入失败,错误信息:", error);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
this.broker.emit(`notifications.hasBeenSent`, {
|
|
106
|
+
ids: notifications_ids
|
|
107
|
+
});
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
109
|
+
} catch (Exception) { /* empty */ }
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* @api {post} remove 删除通知
|
|
114
|
+
* @apiName remove
|
|
115
|
+
* @apiGroup notifications.service.js
|
|
116
|
+
* @apiParam {Object} doc 消息主体
|
|
117
|
+
* @apiParam {String} doc[_id] 消息ID
|
|
118
|
+
* @apiParam {String[]} assignees 接受者ID
|
|
119
|
+
* @apiParam {String} objectName 关联对象名称
|
|
120
|
+
*/
|
|
121
|
+
remove: {
|
|
122
|
+
params: {
|
|
123
|
+
doc: {
|
|
124
|
+
type: "object",
|
|
125
|
+
props: {
|
|
126
|
+
_id: { type: "string" },
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
assignees: {
|
|
130
|
+
type: "array", items: "string"
|
|
131
|
+
},
|
|
132
|
+
objectName: { type: "string" },
|
|
133
|
+
},
|
|
134
|
+
async handler(ctx) {
|
|
135
|
+
const { doc, assignees, objectName } = ctx.params;
|
|
136
|
+
const datasource = objectql.getDataSource('default');
|
|
137
|
+
const adapter = datasource.adapter
|
|
138
|
+
await adapter.connect()
|
|
139
|
+
const collection = adapter.collection('notifications');
|
|
140
|
+
let bulk = collection.initializeUnorderedBulkOp();
|
|
141
|
+
assignees.forEach(function (assignee) {
|
|
142
|
+
bulk.find({
|
|
143
|
+
"related_to.o": objectName,
|
|
144
|
+
"related_to.ids": doc._id,
|
|
145
|
+
owner: assignee
|
|
146
|
+
}).remove();
|
|
147
|
+
});
|
|
148
|
+
return bulk.execute().catch(function (error) {
|
|
149
|
+
console.error("通知数据删除失败,错误信息:", error);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Events
|
|
157
|
+
*/
|
|
158
|
+
events: {
|
|
159
|
+
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Methods
|
|
164
|
+
*/
|
|
165
|
+
methods: {
|
|
166
|
+
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Service created lifecycle event handler
|
|
171
|
+
*/
|
|
172
|
+
created() {
|
|
173
|
+
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Service started lifecycle event handler
|
|
178
|
+
*/
|
|
179
|
+
async started() {
|
|
180
|
+
this.broker.logger.info('[service][notifications]===>', 'started')
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Service stopped lifecycle event handler
|
|
185
|
+
*/
|
|
186
|
+
async stopped() {
|
|
187
|
+
|
|
188
|
+
}
|
|
189
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
const objectql = require('@steedos/objectql');
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
listenTo: 'queue_import',
|
|
6
|
+
|
|
7
|
+
afterFind: async function () {
|
|
8
|
+
if (this.data.values) {
|
|
9
|
+
for (const value of this.data.values) {
|
|
10
|
+
if (value) {
|
|
11
|
+
value.template_url = objectql.absoluteUrl(`/api/data/download/template/${value._id}`)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-core-objects",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.27",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
"steedos"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@steedos/service-package-loader": "3.0.0-beta.
|
|
13
|
+
"@steedos/service-package-loader": "3.0.0-beta.27",
|
|
14
|
+
"json2xls": "^0.1.2",
|
|
14
15
|
"lodash": "^4.17.21"
|
|
15
16
|
},
|
|
16
17
|
"description": "steedos package",
|
|
17
18
|
"repository": {},
|
|
18
19
|
"license": "MIT",
|
|
19
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "fe5a3b939e02c85e644b84a03c4dc2d62d8af5e1"
|
|
20
21
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
copy:function(object_name, record_id){
|
|
3
|
-
let newRecord = null; // _.clone(Creator.getListView(Session.get("object_name"), record_id));
|
|
4
|
-
if(!newRecord){
|
|
5
|
-
let doc = Creator.odata.get(object_name, record_id);
|
|
6
|
-
if(!doc.columns || !doc.columns.length){
|
|
7
|
-
const objectName_label = record_id.split('.');
|
|
8
|
-
let columns = Creator.getListView(objectName_label[0], objectName_label[1], true).columns;
|
|
9
|
-
doc.columns = columns || [];
|
|
10
|
-
}
|
|
11
|
-
doc.columns = doc.columns.map((item)=>{
|
|
12
|
-
if(typeof item === 'string'){
|
|
13
|
-
return { field: item }
|
|
14
|
-
}
|
|
15
|
-
return item;
|
|
16
|
-
})
|
|
17
|
-
newRecord = _.pick(doc, Creator.getObjectFieldsName(object_name));
|
|
18
|
-
}
|
|
19
|
-
delete newRecord.is_system;
|
|
20
|
-
delete newRecord._id;
|
|
21
|
-
delete newRecord.name;
|
|
22
|
-
delete newRecord.from_code_id;
|
|
23
|
-
delete newRecord.label;
|
|
24
|
-
delete newRecord.owner;
|
|
25
|
-
|
|
26
|
-
var data = newRecord || { _filters_type_controller: 'conditions' };
|
|
27
|
-
//数据格式转换
|
|
28
|
-
if (data) {
|
|
29
|
-
data.sort = lodash.map(data.sort, (item) => {
|
|
30
|
-
return `${item.field_name}:${item.order || 'asc'}`
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
data.searchable_fields = lodash.map(data.searchable_fields, 'field');
|
|
34
|
-
|
|
35
|
-
if (data.filters && lodash.isString(data.filters)) {
|
|
36
|
-
try {
|
|
37
|
-
data.filters = JSON.parse(data.filters);
|
|
38
|
-
}catch(e){}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (data.filters && lodash.isString(data.filters)) {
|
|
42
|
-
data._filters_type_controller = 'function';
|
|
43
|
-
} else {
|
|
44
|
-
data._filters_type_controller = 'conditions'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (data._filters_type_controller === 'conditions') {
|
|
48
|
-
data._filters_conditions = window.amisConvert.filtersToConditions(data.filters || []);
|
|
49
|
-
} else {
|
|
50
|
-
data._filters_function = data.filters;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
Steedos.Page.Form.StandardNew.render(Session.get("app_id"), 'object_listviews', t("creator_list_copy_list_view"), { defaultData:data }, {});
|
|
54
|
-
},
|
|
55
|
-
copyVisible:function(object_name, record_id, record_permissions, data){
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
}
|