@steedos/standard-object-database 2.7.10-beta.1 → 2.7.10-beta.10
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/objects/buttons/design_field_layout.button.yml +2 -1
- package/main/default/objects/objects/buttons/design_fields_layout.button.yml +2 -3
- package/main/default/routes/object_fields_design.ejs +76 -2
- package/main/default/server/object_fields.object.js +3 -2
- package/main/default/server/objects.object.js +4 -1
- package/main/default/services/object_fields.service.js +56 -19
- package/package.json +5 -5
- package/package.service.js +4 -4
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: baozhoutao@steedos.com
|
|
3
3
|
* @Date: 2022-06-02 17:45:15
|
|
4
4
|
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
-
* @LastEditTime: 2024-
|
|
5
|
+
* @LastEditTime: 2024-10-10 10:20:19
|
|
6
6
|
* @Description:
|
|
7
7
|
-->
|
|
8
8
|
<html>
|
|
@@ -11,6 +11,15 @@
|
|
|
11
11
|
<script src="/unpkg.com/axios@0.26.1/dist/axios.min.js"></script>
|
|
12
12
|
<script src="https://unpkg.steedos.cn/flowbite@2.3.0/dist/flowbite.min.js"></script>
|
|
13
13
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
14
|
+
<link href="/toast/toastr.min.css" rel="stylesheet" />
|
|
15
|
+
<script src="/jquery.min.js" ></script>
|
|
16
|
+
<script src="/toast/toastr.min.js"></script>
|
|
17
|
+
<style>
|
|
18
|
+
#toast-container.toast-bottom-center>div, #toast-container.toast-top-center>div {
|
|
19
|
+
width: 450px;
|
|
20
|
+
opacity: 1;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
14
23
|
</head>
|
|
15
24
|
|
|
16
25
|
<body>
|
|
@@ -185,7 +194,7 @@
|
|
|
185
194
|
|
|
186
195
|
}
|
|
187
196
|
|
|
188
|
-
|
|
197
|
+
const result = await axios.post(
|
|
189
198
|
`${rootUrl}/service/api/object_fields/amis/design/schema?oid=${oid}`,
|
|
190
199
|
{
|
|
191
200
|
withCredentials: true,
|
|
@@ -199,6 +208,43 @@
|
|
|
199
208
|
// handle error
|
|
200
209
|
console.log(error);
|
|
201
210
|
});
|
|
211
|
+
const actionNames = ['insert', 'update', 'delete'];
|
|
212
|
+
|
|
213
|
+
toastr.options = {
|
|
214
|
+
"closeButton": true,
|
|
215
|
+
"debug": false,
|
|
216
|
+
"newestOnTop": false,
|
|
217
|
+
"progressBar": false,
|
|
218
|
+
"positionClass": "toast-top-center",
|
|
219
|
+
"preventDuplicates": false,
|
|
220
|
+
"onclick": null,
|
|
221
|
+
"showDuration": "300",
|
|
222
|
+
"hideDuration": "1000",
|
|
223
|
+
"timeOut": "5000",
|
|
224
|
+
"extendedTimeOut": "1000",
|
|
225
|
+
"showEasing": "swing",
|
|
226
|
+
"hideEasing": "linear",
|
|
227
|
+
"showMethod": "fadeIn",
|
|
228
|
+
"hideMethod": "fadeOut"
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
actionNames.forEach(function(actionName){
|
|
232
|
+
const actionData = result.data.data[actionName];
|
|
233
|
+
let actionLabel = '';
|
|
234
|
+
if(actionName === 'insert'){
|
|
235
|
+
actionLabel = '新增';
|
|
236
|
+
}else if(actionName === 'update'){
|
|
237
|
+
actionLabel = '更新';
|
|
238
|
+
}else if(actionName === 'delete'){
|
|
239
|
+
actionLabel = '删除';
|
|
240
|
+
}
|
|
241
|
+
if(actionData.error && actionData.error.length > 0){
|
|
242
|
+
actionData.error.forEach((error)=>{
|
|
243
|
+
toastr.warning(error.message, `${actionLabel}字段「${error.fieldLabel}(${error.fieldName})」失败:`);
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
return result;
|
|
202
248
|
};
|
|
203
249
|
window.addEventListener('message', function (event) {
|
|
204
250
|
const { data } = event;
|
|
@@ -208,6 +254,34 @@
|
|
|
208
254
|
onDndAccept: function(event){
|
|
209
255
|
return true;
|
|
210
256
|
},
|
|
257
|
+
beforeDelete: function(event){
|
|
258
|
+
const toastConfig = {
|
|
259
|
+
"closeButton": true,
|
|
260
|
+
"debug": false,
|
|
261
|
+
"newestOnTop": false,
|
|
262
|
+
"progressBar": false,
|
|
263
|
+
"positionClass": "toast-top-center",
|
|
264
|
+
"preventDuplicates": false,
|
|
265
|
+
"onclick": null,
|
|
266
|
+
"showDuration": "300",
|
|
267
|
+
"hideDuration": "1000",
|
|
268
|
+
"timeOut": "5000",
|
|
269
|
+
"extendedTimeOut": "1000",
|
|
270
|
+
"showEasing": "swing",
|
|
271
|
+
"hideEasing": "linear",
|
|
272
|
+
"showMethod": "fadeIn",
|
|
273
|
+
"hideMethod": "fadeOut"
|
|
274
|
+
}
|
|
275
|
+
if(event.context.schema.type.startsWith('sfield') && event.context.schema.config.is_system){
|
|
276
|
+
parent.toastr.warning('禁止删除系统字段', '', toastConfig)
|
|
277
|
+
return event.preventDefault();
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
if(event.context.schema.type.startsWith('sfield') && event.context.schema.config.name === 'name'){
|
|
281
|
+
parent.toastr.warning('禁止删除名称字段', '', toastConfig)
|
|
282
|
+
return event.preventDefault();
|
|
283
|
+
}
|
|
284
|
+
},
|
|
211
285
|
onInit: function(){
|
|
212
286
|
// 创建一个新的 style 元素
|
|
213
287
|
var style = document.createElement('style');
|
|
@@ -2,6 +2,7 @@ var _ = require("underscore");
|
|
|
2
2
|
var objectql = require('@steedos/objectql');
|
|
3
3
|
var clone = require('clone');
|
|
4
4
|
var objectCore = require('./objects.core.js');
|
|
5
|
+
var lodash = require('lodash');
|
|
5
6
|
|
|
6
7
|
const objectFieldsFind = function (filter) {
|
|
7
8
|
return objectql.wrapAsync(async function () {
|
|
@@ -31,7 +32,7 @@ function getFieldName(objectName, fieldName, spaceId, oldFieldName){
|
|
|
31
32
|
if(object && object.datasource && object.datasource != 'default'){
|
|
32
33
|
return fieldName;
|
|
33
34
|
}else{
|
|
34
|
-
if(
|
|
35
|
+
if(!lodash.includes(['name', 'owner', 'created', 'created_by', 'modified', 'modified_by'], fieldName) ){
|
|
35
36
|
return objectql._makeNewFieldName(fieldName, spaceId, oldFieldName);
|
|
36
37
|
}else{
|
|
37
38
|
return fieldName
|
|
@@ -470,7 +471,7 @@ var triggers = {
|
|
|
470
471
|
}
|
|
471
472
|
|
|
472
473
|
checkName(doc._name);
|
|
473
|
-
if(['name','owner','parent','children'].indexOf(doc._name)>-1){
|
|
474
|
+
if(['name','owner','parent','children'].indexOf(doc._name)>-1 || doc._name && doc.is_system){
|
|
474
475
|
doc.name = doc._name;
|
|
475
476
|
}else{
|
|
476
477
|
doc.name = getFieldName(doc.object,doc._name,doc.space);
|
|
@@ -322,6 +322,7 @@ let objectTriggers = {
|
|
|
322
322
|
object: doc.name,
|
|
323
323
|
owner: userId,
|
|
324
324
|
_name: "created",
|
|
325
|
+
name: "created",
|
|
325
326
|
label: "创建时间",
|
|
326
327
|
space: doc.space,
|
|
327
328
|
type: "datetime",
|
|
@@ -335,6 +336,7 @@ let objectTriggers = {
|
|
|
335
336
|
object: doc.name,
|
|
336
337
|
owner: userId,
|
|
337
338
|
_name: "created_by",
|
|
339
|
+
name: "created_by",
|
|
338
340
|
label: "创建人",
|
|
339
341
|
space: doc.space,
|
|
340
342
|
type: "lookup",
|
|
@@ -348,6 +350,7 @@ let objectTriggers = {
|
|
|
348
350
|
object: doc.name,
|
|
349
351
|
owner: userId,
|
|
350
352
|
_name: "modified",
|
|
353
|
+
name: "modified",
|
|
351
354
|
label: "修改时间",
|
|
352
355
|
space: doc.space,
|
|
353
356
|
type: "datetime",
|
|
@@ -361,9 +364,9 @@ let objectTriggers = {
|
|
|
361
364
|
object: doc.name,
|
|
362
365
|
owner: userId,
|
|
363
366
|
_name: "modified_by",
|
|
367
|
+
name: "modified_by",
|
|
364
368
|
label: "修改人",
|
|
365
369
|
space: doc.space,
|
|
366
|
-
space: doc.space,
|
|
367
370
|
type: "lookup",
|
|
368
371
|
reference_to: 'users',
|
|
369
372
|
group: '',
|
|
@@ -315,7 +315,15 @@ module.exports = {
|
|
|
315
315
|
_.map(objectFields, (objectField)=>{
|
|
316
316
|
if(!objectField.group){
|
|
317
317
|
objectField.group = '通用'
|
|
318
|
-
}
|
|
318
|
+
};
|
|
319
|
+
delete objectField.owner;
|
|
320
|
+
delete objectField.space;
|
|
321
|
+
delete objectField.created;
|
|
322
|
+
delete objectField.modified;
|
|
323
|
+
delete objectField.created_by;
|
|
324
|
+
delete objectField.modified_by;
|
|
325
|
+
delete objectField.company_id;
|
|
326
|
+
delete objectField.company_ids;
|
|
319
327
|
})
|
|
320
328
|
|
|
321
329
|
return {
|
|
@@ -326,12 +334,13 @@ module.exports = {
|
|
|
326
334
|
data: {
|
|
327
335
|
objectName
|
|
328
336
|
},
|
|
329
|
-
className: "steedos-amis-form steedos-field-layout-page
|
|
337
|
+
className: "steedos-amis-form steedos-field-layout-page",
|
|
330
338
|
body: _.map(_.groupBy(_.orderBy(objectFields, function(o) { return o.sort_no || 100 }), 'group'), (items, groupName)=>{
|
|
331
339
|
const group = getGroup(groupName)
|
|
332
340
|
return {
|
|
333
341
|
type: 'steedos-field-group',
|
|
334
342
|
title: group.group_name,
|
|
343
|
+
collapsable: true,
|
|
335
344
|
collapsed: group.collapsed,
|
|
336
345
|
visible_on: group.visible_on,
|
|
337
346
|
body: _.map(items, (field)=>{
|
|
@@ -376,22 +385,32 @@ module.exports = {
|
|
|
376
385
|
return {}
|
|
377
386
|
}
|
|
378
387
|
let sort_no = 50;
|
|
379
|
-
_.each(schema.body, (
|
|
380
|
-
if(
|
|
381
|
-
const groupName =
|
|
382
|
-
_.each(
|
|
388
|
+
_.each(schema.body, (bodyItem)=>{
|
|
389
|
+
if(bodyItem.type === 'steedos-field-group'){
|
|
390
|
+
const groupName = bodyItem.title;
|
|
391
|
+
_.each(bodyItem.body, (field)=>{
|
|
383
392
|
if(_.startsWith(field.type, 'sfield-')){
|
|
384
|
-
|
|
393
|
+
|
|
394
|
+
if(field.config && field.config.amis){
|
|
395
|
+
delete field.config.amis.name
|
|
396
|
+
delete field.config.amis.mode
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
fields.push(Object.assign({}, field.config, {group: groupName, sort_no, _name: field.config.name}));
|
|
385
400
|
sort_no += 50;
|
|
386
401
|
}
|
|
387
402
|
})
|
|
388
403
|
groups.push({
|
|
389
|
-
group_name:
|
|
390
|
-
collapsed:
|
|
391
|
-
visible_on:
|
|
404
|
+
group_name: bodyItem.title,
|
|
405
|
+
collapsed: bodyItem.collapsed,
|
|
406
|
+
visible_on: bodyItem.visible_on
|
|
392
407
|
})
|
|
393
|
-
}else if(_.startsWith(
|
|
394
|
-
|
|
408
|
+
}else if(_.startsWith(bodyItem.type, 'sfield-')){
|
|
409
|
+
if(bodyItem.config && bodyItem.config.amis){
|
|
410
|
+
delete bodyItem.config.amis.name
|
|
411
|
+
delete bodyItem.config.amis.mode
|
|
412
|
+
}
|
|
413
|
+
fields.push(Object.assign({}, bodyItem.config, {sort_no, _name: bodyItem.config.name}));
|
|
395
414
|
sort_no += 50;
|
|
396
415
|
}
|
|
397
416
|
})
|
|
@@ -423,10 +442,11 @@ module.exports = {
|
|
|
423
442
|
|
|
424
443
|
// 循环需要增加的字段
|
|
425
444
|
for (const fieldName of insertFields) {
|
|
445
|
+
const newId = await object_fields._makeNewID();
|
|
446
|
+
const now = new Date();
|
|
447
|
+
const field = _.find(fields, { name: fieldName });
|
|
426
448
|
try {
|
|
427
|
-
|
|
428
|
-
const now = new Date();
|
|
429
|
-
const field = _.find(fields, { name: fieldName });
|
|
449
|
+
|
|
430
450
|
const doc = Object.assign({}, field, {
|
|
431
451
|
_id: newId,
|
|
432
452
|
owner: userSession.userId,
|
|
@@ -445,7 +465,11 @@ module.exports = {
|
|
|
445
465
|
await object_fields.directInsert(doc);
|
|
446
466
|
log.insert.success.push(fieldName);
|
|
447
467
|
} catch (e) {
|
|
448
|
-
log.insert.error.push(
|
|
468
|
+
log.insert.error.push({
|
|
469
|
+
fieldName: fieldName,
|
|
470
|
+
fieldLabel: field.label,
|
|
471
|
+
message: steedosI18n.t(e.message, null, 'zh-CN')
|
|
472
|
+
});
|
|
449
473
|
console.error(`新增字段 ${fieldName} 时出错:`, e);
|
|
450
474
|
}
|
|
451
475
|
}
|
|
@@ -453,32 +477,45 @@ module.exports = {
|
|
|
453
477
|
// 循环需要修改的字段
|
|
454
478
|
const now = new Date();
|
|
455
479
|
for (const fieldName of updateFields) {
|
|
480
|
+
const field = _.find(fields, { name: fieldName });
|
|
456
481
|
try {
|
|
457
|
-
const field = _.find(fields, { name: fieldName });
|
|
458
482
|
const id = _.find(dbFields, { name: fieldName })._id;
|
|
459
483
|
const submitField = _.omit(field, ['name', '_name']);
|
|
460
484
|
|
|
461
485
|
if(submitField.type === "summary"){
|
|
462
486
|
await initSummaryDoc(submitField);
|
|
463
487
|
}
|
|
488
|
+
if(submitField){
|
|
489
|
+
delete submitField._id;
|
|
490
|
+
}
|
|
464
491
|
await object_fields.directUpdate(id, Object.assign({}, submitField, {
|
|
465
492
|
modified: now,
|
|
466
493
|
modified_by: userSession.userId
|
|
467
494
|
}));
|
|
468
495
|
log.update.success.push(fieldName);
|
|
469
496
|
} catch (e) {
|
|
470
|
-
log.update.error.push(
|
|
497
|
+
log.update.error.push({
|
|
498
|
+
fieldName: fieldName,
|
|
499
|
+
fieldLabel: field.label,
|
|
500
|
+
message: steedosI18n.t(e.message, null, 'zh-CN')
|
|
501
|
+
});
|
|
471
502
|
console.log(`dbFields`, fieldName, dbFields)
|
|
472
503
|
console.error(`更新字段 ${fieldName} 时出错:`, e);
|
|
473
504
|
}
|
|
474
505
|
}
|
|
475
506
|
// 循环需要删除的字段
|
|
476
507
|
for (const fieldName of deleteFields) {
|
|
508
|
+
const field = _.find(dbFields, { name: fieldName })._id;
|
|
477
509
|
try {
|
|
478
|
-
const id =
|
|
510
|
+
const id = field._id;
|
|
479
511
|
await object_fields.directDelete(id);
|
|
480
512
|
log.delete.success.push(fieldName);
|
|
481
513
|
} catch (e) {
|
|
514
|
+
log.delete.error.push({
|
|
515
|
+
fieldName: fieldName,
|
|
516
|
+
fieldLabel: field.label,
|
|
517
|
+
message: steedosI18n.t(e.message, null, 'zh-CN')
|
|
518
|
+
});
|
|
482
519
|
log.delete.error.push(fieldName);
|
|
483
520
|
console.error(`删除字段 ${fieldName} 时出错:`, e);
|
|
484
521
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-object-database",
|
|
3
|
-
"version": "2.7.10-beta.
|
|
3
|
+
"version": "2.7.10-beta.10",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"description": "steedos package",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@steedos-widgets/amis-lib": "^1.0.22",
|
|
15
|
-
"@steedos/metadata-core": "2.7.10-beta.
|
|
16
|
-
"@steedos/service-object-mixin": "2.7.10-beta.
|
|
17
|
-
"@steedos/standard-objects": "2.7.10-beta.
|
|
15
|
+
"@steedos/metadata-core": "2.7.10-beta.10",
|
|
16
|
+
"@steedos/service-object-mixin": "2.7.10-beta.10",
|
|
17
|
+
"@steedos/standard-objects": "2.7.10-beta.10",
|
|
18
18
|
"amis-formula": "~6.3.0",
|
|
19
19
|
"clone": "^2.1.2",
|
|
20
20
|
"moleculer-bullmq": "3.0.0"
|
|
21
21
|
},
|
|
22
22
|
"repository": {},
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "cffd1ba851c6e18adcdd8b92f2c20d4d9d76247e"
|
|
25
25
|
}
|
package/package.service.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @Author: sunhaolin@hotoa.com
|
|
3
3
|
* @Date: 1985-10-26 16:15:00
|
|
4
4
|
* @LastEditors: baozhoutao@steedos.com
|
|
5
|
-
* @LastEditTime: 2024-
|
|
5
|
+
* @LastEditTime: 2024-10-10 15:58:37
|
|
6
6
|
* @Description:
|
|
7
7
|
*/
|
|
8
8
|
"use strict";
|
|
@@ -169,7 +169,7 @@ module.exports = {
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
const tab_items = app.tab_items || {};
|
|
172
|
-
tab_items[`object_${obj.name}`] = {
|
|
172
|
+
tab_items[`object_${obj.name.replace(/__c$/, "")}`] = {
|
|
173
173
|
group: groupId
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -273,7 +273,7 @@ module.exports = {
|
|
|
273
273
|
fullPath: "/service/api/apps/create_by_design"
|
|
274
274
|
},
|
|
275
275
|
async handler(ctx) {
|
|
276
|
-
const { code, name } = ctx.params;
|
|
276
|
+
const { code, name, icon } = ctx.params;
|
|
277
277
|
const userSession = ctx.meta.user;
|
|
278
278
|
|
|
279
279
|
if(!code || !name){
|
|
@@ -288,7 +288,7 @@ module.exports = {
|
|
|
288
288
|
mobile : true,
|
|
289
289
|
visible : true,
|
|
290
290
|
showSidebar : true,
|
|
291
|
-
icon_slds : "account",
|
|
291
|
+
icon_slds : icon || "account",
|
|
292
292
|
}, userSession);
|
|
293
293
|
}
|
|
294
294
|
},
|