@steedos/standard-object-database 2.6.8-beta.3 → 2.6.8-beta.4
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/client/object_fields.client.js +40 -1
- package/main/default/objects/object_fields.object.yml +44 -3
- package/main/default/objects/objects.action.js +3 -0
- package/main/default/pages/object_fields_form.page.amis.json +17 -1
- package/main/default/services/object_fields.service.js +249 -0
- package/package.json +4 -4
|
@@ -209,4 +209,43 @@ Steedos.ObjectFieldManager.getSummaryFiltersOperation = function(field_type) {
|
|
|
209
209
|
operations.push(optionals.equal, optionals.unequal);
|
|
210
210
|
}
|
|
211
211
|
return operations;
|
|
212
|
-
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
(function () {
|
|
215
|
+
try {
|
|
216
|
+
var styleCss = $(`<style>
|
|
217
|
+
.defaultValue_field div:first-child{
|
|
218
|
+
flex-grow: 1;
|
|
219
|
+
}
|
|
220
|
+
.defaultValue_field .defaultValue_field_formula{
|
|
221
|
+
// margin: 4px;
|
|
222
|
+
}
|
|
223
|
+
.defaultValue_field .defaultValue_field_formula .antd-Form-label{
|
|
224
|
+
visibility: visible;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.defaultValue_field .defaultValue_field_formula_visible{
|
|
228
|
+
flex-grow: 1;
|
|
229
|
+
}
|
|
230
|
+
.defaultValue_field .defaultValue_field_formula_visible .antd-Form-label .antd-TplField{
|
|
231
|
+
visibility: visible;
|
|
232
|
+
}
|
|
233
|
+
.defaultValue_field .defaultValue_field_hidden{
|
|
234
|
+
display: none;
|
|
235
|
+
}
|
|
236
|
+
.defaultValue_field .defaultValue_field_formula_hidden{
|
|
237
|
+
flex-grow: 0;
|
|
238
|
+
}
|
|
239
|
+
.defaultValue_field .defaultValue_field_formula_hidden .antd-Form-label{
|
|
240
|
+
display: none;
|
|
241
|
+
}
|
|
242
|
+
.defaultValue_field .defaultValue_field_formula_hidden .antd-FormulaPicker-input{
|
|
243
|
+
display: none;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
</style>`);
|
|
247
|
+
$("head").append(styleCss);
|
|
248
|
+
} catch (error) {
|
|
249
|
+
console.log(error);
|
|
250
|
+
}
|
|
251
|
+
})();
|
|
@@ -199,9 +199,49 @@ fields:
|
|
|
199
199
|
amis:
|
|
200
200
|
disabledOn: "${is_system == true}"
|
|
201
201
|
defaultValue:
|
|
202
|
-
type:
|
|
202
|
+
type: object
|
|
203
|
+
blackbox: true
|
|
203
204
|
label: Default Value
|
|
204
205
|
sort_no: 160
|
|
206
|
+
visible_on: "{{['autonumber','formula','summary','image','file'].indexOf(formData.type) > -1 ? false: true}}"
|
|
207
|
+
amis:
|
|
208
|
+
type: service
|
|
209
|
+
className:
|
|
210
|
+
antd-Form-item: true
|
|
211
|
+
antd-Form-item--normal: true
|
|
212
|
+
m-0: true
|
|
213
|
+
"md:border-b": global.mode === "read"
|
|
214
|
+
defaultValue_field: true
|
|
215
|
+
flex: true
|
|
216
|
+
schemaApi:
|
|
217
|
+
url: "${context.rootUrl}/service/api/object_fields/defaultValue/schema"
|
|
218
|
+
method: post
|
|
219
|
+
data:
|
|
220
|
+
object: ${object}
|
|
221
|
+
name: ${name}
|
|
222
|
+
options: ${options}
|
|
223
|
+
type: ${type}
|
|
224
|
+
reference_to: ${reference_to}
|
|
225
|
+
multiple: ${multiple}
|
|
226
|
+
filtersFunction: ${filtersFunction}
|
|
227
|
+
reference_to_field: ${reference_to_field}
|
|
228
|
+
mode: ${global.mode}
|
|
229
|
+
scale: ${scale}
|
|
230
|
+
_id: ${_id}
|
|
231
|
+
trackExpression: "${object},${options},${type},${reference_to},${reference_to_field},${multiple},${filtersFunction},${_id},${scale}"
|
|
232
|
+
headers:
|
|
233
|
+
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
234
|
+
# sendOn: "!!this.type"
|
|
235
|
+
onEvent:
|
|
236
|
+
fetchSchemaInited:
|
|
237
|
+
weight: 0
|
|
238
|
+
actions:
|
|
239
|
+
- actionType: "setValue"
|
|
240
|
+
componentId: "service_detail_page"
|
|
241
|
+
args:
|
|
242
|
+
value:
|
|
243
|
+
defaultValue: "${event.data.body[0].value}"
|
|
244
|
+
expression: "global.mode ==='read' && event.data.body[0].value"
|
|
205
245
|
group:
|
|
206
246
|
type: text
|
|
207
247
|
label: Group
|
|
@@ -448,7 +488,7 @@ fields:
|
|
|
448
488
|
amis:
|
|
449
489
|
showIndex: true
|
|
450
490
|
disabledOn: "${is_system == true}"
|
|
451
|
-
|
|
491
|
+
enableDialog: false
|
|
452
492
|
columns:
|
|
453
493
|
- label
|
|
454
494
|
- value
|
|
@@ -481,9 +521,10 @@ fields:
|
|
|
481
521
|
label: Auto Fill Mapping
|
|
482
522
|
is_wide: true
|
|
483
523
|
inlineHelpText: When the data is selected, the field values in the reference object are automatically filled into the current form field according to the following mapping.
|
|
484
|
-
visible_on: "{{formData.type === 'lookup' || formData.type === 'master_detail'}}"
|
|
524
|
+
visible_on: "{{(formData.type === 'lookup' || formData.type === 'master_detail') && formData.reference_to && !!!formData.multiple}}"
|
|
485
525
|
sort_no: 280
|
|
486
526
|
amis:
|
|
527
|
+
enableDialog: false
|
|
487
528
|
disabledOn: "${is_system == true}"
|
|
488
529
|
auto_fill_mapping.$:
|
|
489
530
|
label: Auto Fill Mapping
|
|
@@ -177,6 +177,9 @@ module.exports = {
|
|
|
177
177
|
if(!record){
|
|
178
178
|
record = Creator.odata.get("objects", record_id, "is_deleted");
|
|
179
179
|
}
|
|
180
|
+
if(record.is_system){
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
180
183
|
if(record && !record.is_deleted){
|
|
181
184
|
return Creator.baseObject.actions.standard_delete.visible.apply(this, arguments);
|
|
182
185
|
}
|
|
@@ -10,7 +10,23 @@
|
|
|
10
10
|
"enableTabs": true,
|
|
11
11
|
"mode": "edit",
|
|
12
12
|
"layout": "horizontal",
|
|
13
|
-
"
|
|
13
|
+
"onEvent": {
|
|
14
|
+
"change": {
|
|
15
|
+
"actions": [
|
|
16
|
+
{
|
|
17
|
+
"actionType": "setValue",
|
|
18
|
+
"args": {
|
|
19
|
+
"value": {
|
|
20
|
+
"defaultValue": ""
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"expression": "${!!event.data.defaultValue_formula}"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"initApiAdaptor": "const defaultValue_field_value = payload.data.defaultValue; if(defaultValue_field_value && _.isString(defaultValue_field_value) && defaultValue_field_value.indexOf('{')>-1 ){ payload.data.defaultValue_formula = defaultValue_field_value; delete payload.data.defaultValue; } return payload;",
|
|
29
|
+
"apiRequestAdaptor": "if(formData.defaultValue_formula){ formData.defaultValue = formData.defaultValue_formula } __saveData = JSON.stringify(JSON.stringify(formData)); api.data = {query: query.replace('{__saveData}', __saveData)}; api.data.query = api.data.query.replace('object_fields__update', 'object_fields__upsert')",
|
|
14
30
|
"submitSuccActions": [
|
|
15
31
|
{
|
|
16
32
|
"actionType": "custom",
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Description: 提供action_field_updates(字段更新对象)需要的数据接口
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const register = require("@steedos/metadata-registrar");
|
|
6
|
+
const steedosI18n = require("@steedos/i18n");
|
|
7
|
+
const _ = require("lodash");
|
|
8
|
+
const clone = require("clone");
|
|
9
|
+
|
|
10
|
+
// 默认值字段代码:services/standard-object-database/main/default/services/object_fields.service.js
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
name: "object_fields",
|
|
14
|
+
mixins: [],
|
|
15
|
+
/**
|
|
16
|
+
* Settings
|
|
17
|
+
*/
|
|
18
|
+
settings: {
|
|
19
|
+
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Dependencies
|
|
24
|
+
*/
|
|
25
|
+
dependencies: [],
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Actions
|
|
29
|
+
*/
|
|
30
|
+
actions: {
|
|
31
|
+
getDefaultValueSchema: {
|
|
32
|
+
// 需要传 objectName, targetObject(非必填), field_name 参数进来。
|
|
33
|
+
rest: {
|
|
34
|
+
method: "POST",
|
|
35
|
+
path: "/defaultValue/schema"
|
|
36
|
+
},
|
|
37
|
+
async handler(ctx) {
|
|
38
|
+
const data = await this.getDefaultValueSchema(ctx);
|
|
39
|
+
return { status: 0, msg: "", data: data }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Events
|
|
46
|
+
*/
|
|
47
|
+
events: {
|
|
48
|
+
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Methods
|
|
53
|
+
*/
|
|
54
|
+
methods: {
|
|
55
|
+
/* defaultValue 字段使用*/
|
|
56
|
+
getDefaultValueSchema: {
|
|
57
|
+
async handler(ctx) {
|
|
58
|
+
// console.log('ctx==>', ctx);
|
|
59
|
+
const userSession = ctx.meta.user;
|
|
60
|
+
const lng = userSession.language || 'zh-CN';
|
|
61
|
+
const type = ctx.params.type || 'text';
|
|
62
|
+
const objectName = ctx.params.object;
|
|
63
|
+
const fieldName = ctx.params.name;
|
|
64
|
+
const reference_to = ctx.params.reference_to;
|
|
65
|
+
const options = ctx.params.options;
|
|
66
|
+
const multiple = ctx.params.multiple;
|
|
67
|
+
const filtersFunction = ctx.params.filtersFunction;
|
|
68
|
+
const reference_to_field = ctx.params.reference_to_field || '_id';
|
|
69
|
+
const _id = ctx.params._id;
|
|
70
|
+
const mode = ctx.params.mode;
|
|
71
|
+
const scale = ctx.params.scale;
|
|
72
|
+
// const mode = global.mode;
|
|
73
|
+
|
|
74
|
+
const partialType = ['text','textarea','html','code','markdown','boolean','toggle','date','datetime','time','password','url','email','color','location'];
|
|
75
|
+
// const fieldType = partialType.indexOf(type) > -1 ? type : 'text';
|
|
76
|
+
|
|
77
|
+
let targetField = null;
|
|
78
|
+
let NAME_FIELD_KEY = null;
|
|
79
|
+
if (mode === 'read') {
|
|
80
|
+
const objectConfig = await register.getObjectConfig(objectName);
|
|
81
|
+
NAME_FIELD_KEY = objectConfig.NAME_FIELD_KEY || 'name';
|
|
82
|
+
targetField = objectConfig.fields[fieldName];
|
|
83
|
+
}
|
|
84
|
+
// console.log('targetField==>', targetField);
|
|
85
|
+
const value = (targetField && targetField.defaultValue) || '';
|
|
86
|
+
const translatedLabel = lng === 'zh-CN' ? "默认值" : 'DefaultValue';
|
|
87
|
+
let defaultValue_schema = {
|
|
88
|
+
"type": "text",
|
|
89
|
+
"name": "defaultValue",
|
|
90
|
+
"label": translatedLabel,
|
|
91
|
+
"labelClassName": "text-left"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if(partialType.indexOf(type) > -1){
|
|
95
|
+
defaultValue_schema.type = type;
|
|
96
|
+
}else if(type === 'select' && options){
|
|
97
|
+
defaultValue_schema.type = type;
|
|
98
|
+
defaultValue_schema.options = options;
|
|
99
|
+
defaultValue_schema.multiple = multiple;
|
|
100
|
+
}else if(['lookup','master_detail'].includes(type) && reference_to){
|
|
101
|
+
defaultValue_schema.type = type;
|
|
102
|
+
defaultValue_schema.reference_to = reference_to;
|
|
103
|
+
defaultValue_schema.multiple = multiple;
|
|
104
|
+
defaultValue_schema.filtersFunction = filtersFunction;
|
|
105
|
+
defaultValue_schema.reference_to_field = reference_to_field;
|
|
106
|
+
} else if(['number','currency','percent'].includes(type)){
|
|
107
|
+
defaultValue_schema.type = type;
|
|
108
|
+
defaultValue_schema.scale = scale;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let steedos_field = {
|
|
112
|
+
type:'steedos-field',
|
|
113
|
+
name:'defaultValue',
|
|
114
|
+
clearValueOnHidden: true,
|
|
115
|
+
fieldName: 'defaultValue',
|
|
116
|
+
field: defaultValue_schema,
|
|
117
|
+
value: value,
|
|
118
|
+
readonly: mode === 'read' ? true : false
|
|
119
|
+
};
|
|
120
|
+
if(mode === 'read'){
|
|
121
|
+
const baseFieldConfig = {
|
|
122
|
+
"name": "defaultValue",
|
|
123
|
+
"label": translatedLabel,
|
|
124
|
+
"labelClassName": "text-left",
|
|
125
|
+
"clearValueOnHidden": true,
|
|
126
|
+
"fieldName": "defaultValue"
|
|
127
|
+
}
|
|
128
|
+
if(_.isString(value) && value.indexOf('{')>-1){
|
|
129
|
+
// 只读时值是公式就显示公式
|
|
130
|
+
steedos_field = {
|
|
131
|
+
"type": "control",
|
|
132
|
+
"label": translatedLabel,
|
|
133
|
+
"body": {
|
|
134
|
+
"name": "defaultValue",
|
|
135
|
+
"label": translatedLabel,
|
|
136
|
+
"labelClassName": "text-left",
|
|
137
|
+
"type": "tpl",
|
|
138
|
+
"tpl": value.indexOf('$') > -1 ? "\\"+value : value
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}else if(['number','currency','percent'].includes(type)){
|
|
142
|
+
steedos_field = {
|
|
143
|
+
...baseFieldConfig,
|
|
144
|
+
"type": "static-tpl",
|
|
145
|
+
"tpl": `<div>${value}</div>`,
|
|
146
|
+
"className": "m-1 md:border-b steedos-static-tpl-readonly",
|
|
147
|
+
"quickEdit": false,
|
|
148
|
+
}
|
|
149
|
+
}else if(['date','datetime','time'].includes(type)){
|
|
150
|
+
let fieldTypeConfig ={};
|
|
151
|
+
if(type==='date'){
|
|
152
|
+
fieldTypeConfig = {
|
|
153
|
+
"type": "input-date",
|
|
154
|
+
"inputFormat": "YYYY-MM-DD",
|
|
155
|
+
"format": "YYYY-MM-DDT00:00:00.000[Z]",
|
|
156
|
+
"className": "m-1 steedos-input-date-edit",
|
|
157
|
+
}
|
|
158
|
+
}else if(type==='datetime'){
|
|
159
|
+
fieldTypeConfig = {
|
|
160
|
+
"type": "input-datetime",
|
|
161
|
+
"inputFormat": "YYYY-MM-DD HH:mm",
|
|
162
|
+
"format": "YYYY-MM-DDTHH:mm:ss.SSSZ",
|
|
163
|
+
"className": "m-1 steedos-input-datetime-edit",
|
|
164
|
+
}
|
|
165
|
+
}else if(type==='time'){
|
|
166
|
+
fieldTypeConfig = {
|
|
167
|
+
"type": "input-time",
|
|
168
|
+
"inputFormat": "HH:mm",
|
|
169
|
+
"format": "1970-01-01THH:mm:00.000[Z]",
|
|
170
|
+
"className": "m-1 steedos-input-time-edit",
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
steedos_field = {
|
|
174
|
+
...baseFieldConfig,
|
|
175
|
+
...fieldTypeConfig,
|
|
176
|
+
value: value,
|
|
177
|
+
static: true
|
|
178
|
+
}
|
|
179
|
+
}else if(['boolean'].includes(type)){
|
|
180
|
+
steedos_field = {
|
|
181
|
+
...baseFieldConfig,
|
|
182
|
+
value: value,
|
|
183
|
+
"type": "static",
|
|
184
|
+
"tpl": `${value}`,
|
|
185
|
+
"className": "m-1 md:border-b steedos-static-readonly"
|
|
186
|
+
}
|
|
187
|
+
}else if(['lookup','master_detail'].includes(type)){
|
|
188
|
+
// console.log('t==>', type, reference_to, NAME_FIELD_KEY, targetField)
|
|
189
|
+
if(value && value.length && _.isString(reference_to)){
|
|
190
|
+
const query = {
|
|
191
|
+
fields: [NAME_FIELD_KEY],
|
|
192
|
+
filters: [reference_to_field, '=', value]
|
|
193
|
+
}
|
|
194
|
+
const res = await this.broker.call(
|
|
195
|
+
'objectql.find',
|
|
196
|
+
{
|
|
197
|
+
objectName: reference_to,
|
|
198
|
+
query
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
// console.log('res==>', res, reference_to, NAME_FIELD_KEY, targetField);
|
|
202
|
+
const tpl = _.map(res, NAME_FIELD_KEY).join('、')
|
|
203
|
+
steedos_field = {
|
|
204
|
+
"type": "control",
|
|
205
|
+
"label": translatedLabel,
|
|
206
|
+
"body": {
|
|
207
|
+
"name": "defaultValue",
|
|
208
|
+
"label": translatedLabel,
|
|
209
|
+
"labelClassName": "text-left",
|
|
210
|
+
"type": "tpl",
|
|
211
|
+
"tpl": tpl
|
|
212
|
+
},
|
|
213
|
+
value: value
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
let body = [
|
|
219
|
+
steedos_field
|
|
220
|
+
]
|
|
221
|
+
if(mode === 'edit'){
|
|
222
|
+
body[0].field.amis = {
|
|
223
|
+
// disabledOn: "!!this.defaultValue_formula",
|
|
224
|
+
"className": {
|
|
225
|
+
"defaultValue_field_hidden": "!this.defaultValue && (!this.defaultValue || '').toString() && !!this.defaultValue_formula"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
body.push({
|
|
229
|
+
"name": "defaultValue_formula",
|
|
230
|
+
"label": translatedLabel,
|
|
231
|
+
"evalMode": false,
|
|
232
|
+
"type": "input-formula",
|
|
233
|
+
"placeholder": "公式",
|
|
234
|
+
// "disabledOn": "!!this.defaultValue && !!this.defaultValue.toString()",
|
|
235
|
+
"className": {
|
|
236
|
+
"defaultValue_field_formula": true,
|
|
237
|
+
"defaultValue_field_formula_visible": "!!this.defaultValue_formula",
|
|
238
|
+
"defaultValue_field_formula_hidden": "(!!this.defaultValue && !!this.defaultValue.toString()) || (!this.defaultValue && !this.defaultValue_formula)"
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
// console.log('body==>', body);
|
|
243
|
+
return {
|
|
244
|
+
body
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/standard-object-database",
|
|
3
|
-
"version": "2.6.8-beta.
|
|
3
|
+
"version": "2.6.8-beta.4",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"description": "steedos package",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@steedos-widgets/amis-lib": "^1.0.22",
|
|
15
|
-
"@steedos/metadata-core": "2.6.8-beta.
|
|
16
|
-
"@steedos/standard-objects": "2.6.8-beta.
|
|
15
|
+
"@steedos/metadata-core": "2.6.8-beta.4",
|
|
16
|
+
"@steedos/standard-objects": "2.6.8-beta.4"
|
|
17
17
|
},
|
|
18
18
|
"repository": {},
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "8a12f13e28a5b7faab37c00a5e894bffda4c5c91"
|
|
21
21
|
}
|