@steedos-widgets/amis-lib 1.2.19 → 1.2.26
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/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs.js +217 -115
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +217 -115
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +217 -115
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields/editor.d.ts +2 -0
- package/dist/types/lib/converter/amis/fields_filter.d.ts +12 -2
- package/dist/types/lib/converter/amis/header.d.ts +9 -2
- package/dist/types/lib/converter/amis/toolbar.d.ts +9 -2
- package/dist/types/lib/converter/amis/toolbars/setting_listview/new.d.ts +21 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +21 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -336,7 +336,7 @@ const getSteedosAuth = () => {
|
|
|
336
336
|
* @Author: baozhoutao@steedos.com
|
|
337
337
|
* @Date: 2022-08-16 17:02:08
|
|
338
338
|
* @LastEditors: baozhoutao@steedos.com
|
|
339
|
-
* @LastEditTime: 2023-
|
|
339
|
+
* @LastEditTime: 2023-06-20 13:50:15
|
|
340
340
|
* @Description:
|
|
341
341
|
*/
|
|
342
342
|
|
|
@@ -347,14 +347,14 @@ const Router = {
|
|
|
347
347
|
if(urlSearch.has('display')){
|
|
348
348
|
return urlSearch.get('display')
|
|
349
349
|
}
|
|
350
|
-
|
|
351
|
-
const key = `page_display`;
|
|
350
|
+
const key = `tab_${tab_id}_display`;
|
|
351
|
+
// const key = `page_display`;
|
|
352
352
|
const value = localStorage.getItem(key);
|
|
353
353
|
return value ? value : 'grid'
|
|
354
354
|
},
|
|
355
355
|
|
|
356
356
|
setTabDisplayAs(tab_id, displayAs){
|
|
357
|
-
const key = `
|
|
357
|
+
const key = `tab_${tab_id}_display`;
|
|
358
358
|
localStorage.setItem(key, displayAs);
|
|
359
359
|
},
|
|
360
360
|
getAppPath({formFactor, appId}){
|
|
@@ -368,15 +368,10 @@ const Router = {
|
|
|
368
368
|
},
|
|
369
369
|
getObjectDetailPath(props){
|
|
370
370
|
const {formFactor, appId, objectName, recordId, listViewName, _templateType} = props;
|
|
371
|
-
// var urlParams = new URLSearchParams(window.location.search);
|
|
372
|
-
// if(objectName === 'instances'){
|
|
373
|
-
// return `/workflow/space/\${context.tenantId}/\${listName}/${recordId}`;
|
|
374
|
-
// }
|
|
375
|
-
const displayAs = Router.getTabDisplayAs(objectName); //urlParams.get("display") ||
|
|
376
371
|
if(_templateType === 'JavaScript'){
|
|
377
|
-
return `/app/${appId}/${objectName}/view/${recordId}?
|
|
372
|
+
return `/app/${appId}/${objectName}/view/${recordId}?side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
|
|
378
373
|
}
|
|
379
|
-
return `/app/${appId}/${objectName}/view/${recordId}?
|
|
374
|
+
return `/app/${appId}/${objectName}/view/${recordId}?side_object=\${objectName}&side_listview_id=\${listName}`;
|
|
380
375
|
},
|
|
381
376
|
getObjectRelatedViewPath({formFactor, appId, masterObjectName, masterRecordId, objectName, foreignKey}){
|
|
382
377
|
return `/app/${appId}/${masterObjectName}/${masterRecordId}/${objectName}/grid?related_field_name=${foreignKey}`;
|
|
@@ -3126,7 +3121,10 @@ async function getObjectFieldsFilterFormSchema(ctx) {
|
|
|
3126
3121
|
const formSchema = {
|
|
3127
3122
|
"type": "service",
|
|
3128
3123
|
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3129
|
-
"className": ctx.formFactor === 'SMALL' ? "slds-filters__body p-0 mb-2" : "slds-filters__body p-0 sm:grid sm:gap-2 sm:grid-cols-4 mb-2",
|
|
3124
|
+
"className": ctx.formFactor === 'SMALL' ? "slds-filters__body p-0 mb-2 overflow-y-auto overflow-x-hidden" : "slds-filters__body p-0 sm:grid sm:gap-2 sm:grid-cols-4 mb-2",
|
|
3125
|
+
"style":{
|
|
3126
|
+
"max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
|
|
3127
|
+
},
|
|
3130
3128
|
"schemaApi": {
|
|
3131
3129
|
method: 'post',
|
|
3132
3130
|
url: `\${context.rootUrl}/graphql?reload=\${filterFormSearchableFields|join}`,
|
|
@@ -3215,28 +3213,42 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3215
3213
|
// }
|
|
3216
3214
|
// }
|
|
3217
3215
|
// listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
|
|
3218
|
-
|
|
3219
|
-
let
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3216
|
+
// 点击搜索的时候自动收起搜索栏
|
|
3217
|
+
let resizeWindow = function(){
|
|
3218
|
+
//触发amis crud 高度重算
|
|
3219
|
+
setTimeout(()=>{
|
|
3220
|
+
window.dispatchEvent(new Event("resize"))
|
|
3221
|
+
}, 500);
|
|
3222
|
+
}
|
|
3223
|
+
const filterService = filterForm.context.getComponents().find(function(n){
|
|
3224
|
+
return n.props.type === "service";
|
|
3225
|
+
});
|
|
3226
|
+
let showFieldsFilter = false;
|
|
3227
|
+
const isMobile = window.innerWidth < 768;
|
|
3228
|
+
if(event.data.__from_fields_filter_settings_confirm){
|
|
3229
|
+
// 如果是从设置搜索项点击确认按钮触发的搜索事件不应该自动关闭搜索栏
|
|
3230
|
+
showFieldsFilter = true;
|
|
3231
|
+
}
|
|
3232
|
+
else if(isMobile){
|
|
3233
|
+
// 如果是手机端,点击搜索后自动关闭搜索栏
|
|
3234
|
+
showFieldsFilter = false;
|
|
3235
|
+
}
|
|
3236
|
+
else if(event.data.displayAs === "split") {
|
|
3237
|
+
// PC上分栏模式下的列表,始终按手机上效果处理,即自动关闭搜索栏
|
|
3238
|
+
showFieldsFilter = false;
|
|
3239
|
+
}
|
|
3240
|
+
else if(window.innerHeight >= 1200){
|
|
3241
|
+
// 高分辨率屏幕(2k+),列表高度比较高,没必要自动关闭搜索栏
|
|
3242
|
+
showFieldsFilter = true;
|
|
3239
3243
|
}
|
|
3244
|
+
filterService.setData({showFieldsFilter});
|
|
3245
|
+
resizeWindow();
|
|
3246
|
+
// 使用filterForm.getValues()的话,并不能拿到本地存储中的过滤条件,所以需要从event.data中取。
|
|
3247
|
+
let filterFormValues = event.data;
|
|
3248
|
+
let isFieldsFilterEmpty = SteedosUI.isFilterFormValuesEmpty(filterFormValues);
|
|
3249
|
+
let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
|
|
3250
|
+
let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
|
|
3251
|
+
crudService && crudService.setData({isFieldsFilterEmpty, showFieldsFilter});
|
|
3240
3252
|
`;
|
|
3241
3253
|
const onCancelScript = `
|
|
3242
3254
|
const scope = event.context.scoped;
|
|
@@ -3275,12 +3287,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3275
3287
|
setTimeout(()=>{
|
|
3276
3288
|
window.dispatchEvent(new Event("resize"))
|
|
3277
3289
|
}, 100);
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
|
|
3282
|
-
crudService && crudService.setData({isFieldsFilterEmpty: true, showFieldsFilter: false});
|
|
3283
|
-
}
|
|
3290
|
+
// 移除搜索按钮上的红点
|
|
3291
|
+
let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
|
|
3292
|
+
crudService && crudService.setData({isFieldsFilterEmpty: true, showFieldsFilter: false});
|
|
3284
3293
|
`;
|
|
3285
3294
|
const dataProviderInited = `
|
|
3286
3295
|
const objectName = data.objectName;
|
|
@@ -3333,17 +3342,11 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3333
3342
|
|| (_.isArray(n) && _.isEmpty(n.filter(function(item){return !_.isNil(item)})))
|
|
3334
3343
|
|| (_.isString(n) && n.length === 0);
|
|
3335
3344
|
});
|
|
3336
|
-
//
|
|
3345
|
+
// 有过滤条件时只显示搜索按钮上的红点,不自动展开搜索栏
|
|
3337
3346
|
if(!_.isEmpty(omitedEmptyFormValue)){
|
|
3338
|
-
let
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
let crudService = SteedosUI.getRef(data.$scopeId).getComponentById("service_listview_" + data.objectName)
|
|
3342
|
-
crudService && crudService.setData({isFieldsFilterEmpty: false});
|
|
3343
|
-
}
|
|
3344
|
-
else{
|
|
3345
|
-
setData({ showFieldsFilter: true });
|
|
3346
|
-
}
|
|
3347
|
+
let crudService = SteedosUI.getRef(data.$scopeId).getComponentById("service_listview_" + data.objectName)
|
|
3348
|
+
crudService && crudService.setData({isFieldsFilterEmpty: false});
|
|
3349
|
+
// setData({ showFieldsFilter: true });//自动展开搜索栏
|
|
3347
3350
|
}
|
|
3348
3351
|
}
|
|
3349
3352
|
}
|
|
@@ -3609,7 +3612,10 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3609
3612
|
},
|
|
3610
3613
|
{
|
|
3611
3614
|
"actionType": "click",
|
|
3612
|
-
"componentId": btnSearchId
|
|
3615
|
+
"componentId": btnSearchId,
|
|
3616
|
+
"args": {
|
|
3617
|
+
"__from_fields_filter_settings_confirm": true
|
|
3618
|
+
}
|
|
3613
3619
|
},
|
|
3614
3620
|
{
|
|
3615
3621
|
"componentId": "",
|
|
@@ -4141,7 +4147,8 @@ const getNewListviewButtonSchema = ()=>{
|
|
|
4141
4147
|
"name":"",
|
|
4142
4148
|
"label":"",
|
|
4143
4149
|
"filters":"",
|
|
4144
|
-
"shared":false
|
|
4150
|
+
"shared":false,
|
|
4151
|
+
"object_name": "${targetObjectName}",
|
|
4145
4152
|
},
|
|
4146
4153
|
"fieldsExtend": fieldsExtend$4(),
|
|
4147
4154
|
"fields": fields$1(),
|
|
@@ -4188,13 +4195,11 @@ function fields$1(){
|
|
|
4188
4195
|
"object_name",
|
|
4189
4196
|
"filter_scope",
|
|
4190
4197
|
"show_count",
|
|
4191
|
-
"columns
|
|
4192
|
-
"
|
|
4193
|
-
"sort.$.field_name",
|
|
4194
|
-
"sort.$.order",
|
|
4198
|
+
"columns",
|
|
4199
|
+
"sort",
|
|
4195
4200
|
"filters",
|
|
4196
|
-
"mobile_columns
|
|
4197
|
-
"searchable_fields
|
|
4201
|
+
"mobile_columns",
|
|
4202
|
+
"searchable_fields",
|
|
4198
4203
|
"is_system",
|
|
4199
4204
|
"shared"
|
|
4200
4205
|
]
|
|
@@ -4207,7 +4212,8 @@ function fieldsExtend$4(){
|
|
|
4207
4212
|
},
|
|
4208
4213
|
"name": {
|
|
4209
4214
|
"amis": {
|
|
4210
|
-
"hidden": true
|
|
4215
|
+
"hidden": true,
|
|
4216
|
+
"required": false
|
|
4211
4217
|
}
|
|
4212
4218
|
},
|
|
4213
4219
|
"object_name": {
|
|
@@ -4217,37 +4223,56 @@ function fieldsExtend$4(){
|
|
|
4217
4223
|
},
|
|
4218
4224
|
"filter_scope": {
|
|
4219
4225
|
"amis": {
|
|
4220
|
-
"hidden": true
|
|
4226
|
+
"hidden": true,
|
|
4227
|
+
"required": false
|
|
4221
4228
|
}
|
|
4222
4229
|
},
|
|
4223
4230
|
"columns": {
|
|
4224
4231
|
"amis": {
|
|
4225
|
-
"hidden": true
|
|
4232
|
+
"hidden": true,
|
|
4233
|
+
"required": false
|
|
4234
|
+
}
|
|
4235
|
+
},
|
|
4236
|
+
"mobile_columns":{
|
|
4237
|
+
"amis": {
|
|
4238
|
+
"hidden": true,
|
|
4239
|
+
"required": false
|
|
4240
|
+
}
|
|
4241
|
+
},
|
|
4242
|
+
"searchable_fields":{
|
|
4243
|
+
"amis": {
|
|
4244
|
+
"hidden": true,
|
|
4245
|
+
"required": false
|
|
4226
4246
|
}
|
|
4227
4247
|
},
|
|
4228
4248
|
"filter_fields": {
|
|
4229
4249
|
"amis": {
|
|
4230
|
-
"hidden": true
|
|
4250
|
+
"hidden": true,
|
|
4251
|
+
"required": false
|
|
4231
4252
|
}
|
|
4232
4253
|
},
|
|
4233
4254
|
"scrolling_mode": {
|
|
4234
4255
|
"amis": {
|
|
4235
|
-
"hidden": true
|
|
4256
|
+
"hidden": true,
|
|
4257
|
+
"required": false
|
|
4236
4258
|
}
|
|
4237
4259
|
},
|
|
4238
4260
|
"sort": {
|
|
4239
4261
|
"amis": {
|
|
4240
|
-
"hidden": true
|
|
4262
|
+
"hidden": true,
|
|
4263
|
+
"required": false
|
|
4241
4264
|
}
|
|
4242
4265
|
},
|
|
4243
4266
|
"show_count": {
|
|
4244
4267
|
"amis": {
|
|
4245
|
-
"hidden": true
|
|
4268
|
+
"hidden": true,
|
|
4269
|
+
"required": false
|
|
4246
4270
|
}
|
|
4247
4271
|
},
|
|
4248
4272
|
"type": {
|
|
4249
4273
|
"amis": {
|
|
4250
|
-
"hidden": true
|
|
4274
|
+
"hidden": true,
|
|
4275
|
+
"required": false
|
|
4251
4276
|
}
|
|
4252
4277
|
},
|
|
4253
4278
|
"shared": {
|
|
@@ -5032,14 +5057,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
5032
5057
|
{
|
|
5033
5058
|
"type": "button",
|
|
5034
5059
|
"label": i18next.t('frontend_display_type_is_table'),
|
|
5035
|
-
"onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
|
|
5060
|
+
"onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
|
|
5036
5061
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
5037
5062
|
"rightIconClassName": "m-l-sm"
|
|
5038
5063
|
},
|
|
5039
5064
|
{
|
|
5040
5065
|
"type": "button",
|
|
5041
5066
|
"label": i18next.t('frontend_display_type_is_split'),
|
|
5042
|
-
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
5067
|
+
"onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
5043
5068
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
5044
5069
|
"rightIconClassName": "m-l-sm"
|
|
5045
5070
|
}
|
|
@@ -5070,36 +5095,38 @@ const filterForm = scope.getComponents().find(function(n){
|
|
|
5070
5095
|
const filterService = filterForm.context.getComponents().find(function(n){
|
|
5071
5096
|
return n.props.type === "service";
|
|
5072
5097
|
});
|
|
5073
|
-
|
|
5098
|
+
let toShowFieldsFilter = !!!filterService.props.data.showFieldsFilter;
|
|
5099
|
+
filterService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
5074
5100
|
let resizeWindow = function(){
|
|
5075
5101
|
//触发amis crud 高度重算
|
|
5076
5102
|
setTimeout(()=>{
|
|
5077
5103
|
window.dispatchEvent(new Event("resize"))
|
|
5078
5104
|
}, 500);
|
|
5079
5105
|
}
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
}
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
}
|
|
5106
|
+
resizeWindow();
|
|
5107
|
+
// 手机端在显示搜索栏时隐藏crud上的刷新按钮,因为点击后crud高度显示有问题
|
|
5108
|
+
let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
|
|
5109
|
+
crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
5110
|
+
// if(filterService.props.data.showFieldsFilter){
|
|
5111
|
+
// if(isMobile){
|
|
5112
|
+
// // 手机上只能通过取消按钮来关闭搜索栏
|
|
5113
|
+
// return;
|
|
5114
|
+
// }
|
|
5115
|
+
// let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
|
|
5116
|
+
// direction: "down",
|
|
5117
|
+
// name: "btn_filter_form_cancel"
|
|
5118
|
+
// });
|
|
5119
|
+
// buttonCancel.props.dispatchEvent('click', {}).then(function(){
|
|
5120
|
+
// resizeWindow();
|
|
5121
|
+
// });
|
|
5122
|
+
// }
|
|
5123
|
+
// else{
|
|
5124
|
+
// if(isMobile){
|
|
5125
|
+
// // 手机端在显示搜索栏时隐藏crud上的刷新按钮,因为点击后crud高度显示有问题
|
|
5126
|
+
// let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
|
|
5127
|
+
// crudService && crudService.setData({showFieldsFilter: true});
|
|
5128
|
+
// }
|
|
5129
|
+
// }
|
|
5103
5130
|
`;
|
|
5104
5131
|
|
|
5105
5132
|
|
|
@@ -5145,7 +5172,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5145
5172
|
},
|
|
5146
5173
|
},
|
|
5147
5174
|
filterVisible ? {
|
|
5148
|
-
"label":
|
|
5175
|
+
"label": i18next.t('frontend_button_search_tooltip'),
|
|
5149
5176
|
"icon": "fa fa-search",
|
|
5150
5177
|
"type": "button",
|
|
5151
5178
|
"tooltip": i18next.t('frontend_button_search_tooltip'),
|
|
@@ -5198,12 +5225,23 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5198
5225
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
5199
5226
|
},
|
|
5200
5227
|
// getExportExcelToolbarButtonSchema(),
|
|
5228
|
+
getSettingListviewToolbarButtonSchema(),
|
|
5229
|
+
getDisplayAsButton(mainObject?.name),
|
|
5201
5230
|
filterVisible ? {
|
|
5202
|
-
"label":
|
|
5231
|
+
"label": i18next.t('frontend_button_search_tooltip'),
|
|
5203
5232
|
"icon": "fa fa-search",
|
|
5204
5233
|
"tooltip": i18next.t('frontend_button_search_tooltip'),
|
|
5205
5234
|
"tooltipPlacement": "bottom",
|
|
5206
5235
|
"type": "button",
|
|
5236
|
+
"badge": {
|
|
5237
|
+
"offset": [
|
|
5238
|
+
-5,
|
|
5239
|
+
1
|
|
5240
|
+
],
|
|
5241
|
+
"size":8,
|
|
5242
|
+
"animation": true,
|
|
5243
|
+
"visibleOn": "${isFieldsFilterEmpty == false}"
|
|
5244
|
+
},
|
|
5207
5245
|
"align": "right",
|
|
5208
5246
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5209
5247
|
"onEvent": {
|
|
@@ -5216,9 +5254,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5216
5254
|
]
|
|
5217
5255
|
}
|
|
5218
5256
|
}
|
|
5219
|
-
} : {}
|
|
5220
|
-
getSettingListviewToolbarButtonSchema(),
|
|
5221
|
-
getDisplayAsButton(showDisplayAs)
|
|
5257
|
+
} : {}
|
|
5222
5258
|
// {
|
|
5223
5259
|
// "type": "search-box",
|
|
5224
5260
|
// "align": "right",
|
|
@@ -5848,6 +5884,58 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5848
5884
|
"actions": [
|
|
5849
5885
|
{
|
|
5850
5886
|
"actionType": "reload"
|
|
5887
|
+
},
|
|
5888
|
+
{
|
|
5889
|
+
"actionType": "custom",
|
|
5890
|
+
"script": `
|
|
5891
|
+
const masterRecord = event.data._master?.record;
|
|
5892
|
+
const fieldConfig = ${JSON.stringify(field)};
|
|
5893
|
+
let reference_to = fieldConfig.reference_to;
|
|
5894
|
+
let saveValue;
|
|
5895
|
+
const newRecord = {
|
|
5896
|
+
_id: event.data.result.data.recordId,
|
|
5897
|
+
...event.data.__super.__super
|
|
5898
|
+
}
|
|
5899
|
+
const saveField = fieldConfig.reference_to_field || '_id';
|
|
5900
|
+
const saveFieldValue = newRecord[saveField];
|
|
5901
|
+
|
|
5902
|
+
if( fieldConfig._reference_to && (_.isArray(fieldConfig._reference_to) || _.isFunction(fieldConfig._reference_to) || fieldConfig._reference_to.startsWith('function') ) ){
|
|
5903
|
+
|
|
5904
|
+
const fieldValue = masterRecord ? masterRecord[fieldConfig.name] : {o: reference_to, ids: []};
|
|
5905
|
+
const baseSaveValue = {
|
|
5906
|
+
o: reference_to,
|
|
5907
|
+
ids: [saveFieldValue]
|
|
5908
|
+
};
|
|
5909
|
+
if(fieldValue && fieldValue.o){
|
|
5910
|
+
if(fieldValue.o === reference_to){
|
|
5911
|
+
saveValue = fieldConfig.multiple ? { o: reference_to, ids: fieldValue.ids.concat(saveFieldValue)} : baseSaveValue;
|
|
5912
|
+
}else{
|
|
5913
|
+
saveValue = baseSaveValue;
|
|
5914
|
+
}
|
|
5915
|
+
}else{
|
|
5916
|
+
saveValue = baseSaveValue;
|
|
5917
|
+
}
|
|
5918
|
+
|
|
5919
|
+
}else{
|
|
5920
|
+
if(fieldConfig.multiple){
|
|
5921
|
+
// TODO: 连续新建多个记录时,因为获取的主记录不是实时的,所以只会勾选最后一个新建的记录。
|
|
5922
|
+
const fieldValue = (masterRecord && masterRecord[fieldConfig.name]) || [];
|
|
5923
|
+
saveValue = fieldValue.concat(saveFieldValue);
|
|
5924
|
+
}else{
|
|
5925
|
+
saveValue = saveFieldValue;
|
|
5926
|
+
}
|
|
5927
|
+
}
|
|
5928
|
+
|
|
5929
|
+
const ctx = ${JSON.stringify(ctx)};
|
|
5930
|
+
const componentId = ctx.defaults.formSchema.id ? 'service-'+ctx.defaults.formSchema.id : 'new-'+ctx.defaults.formSchema.objectApiName;
|
|
5931
|
+
doAction({
|
|
5932
|
+
actionType: 'setValue',
|
|
5933
|
+
componentId: componentId,
|
|
5934
|
+
args: {
|
|
5935
|
+
value: { [fieldConfig.name]: saveValue }
|
|
5936
|
+
}
|
|
5937
|
+
});
|
|
5938
|
+
`
|
|
5851
5939
|
}
|
|
5852
5940
|
]
|
|
5853
5941
|
};
|
|
@@ -6078,7 +6166,7 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
6078
6166
|
type: 'steedos-field-lookup',
|
|
6079
6167
|
field,
|
|
6080
6168
|
readonly,
|
|
6081
|
-
ctx
|
|
6169
|
+
ctx,
|
|
6082
6170
|
}
|
|
6083
6171
|
// return await lookupToAmisGroup(field, readonly, ctx);
|
|
6084
6172
|
}
|
|
@@ -6232,8 +6320,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6232
6320
|
/*
|
|
6233
6321
|
* @Author: baozhoutao@steedos.com
|
|
6234
6322
|
* @Date: 2023-01-13 17:27:54
|
|
6235
|
-
* @LastEditors:
|
|
6236
|
-
* @LastEditTime: 2023-
|
|
6323
|
+
* @LastEditors: liaodaxue
|
|
6324
|
+
* @LastEditTime: 2023-06-16 15:58:21
|
|
6237
6325
|
* @Description:
|
|
6238
6326
|
*/
|
|
6239
6327
|
|
|
@@ -6285,6 +6373,7 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
|
|
|
6285
6373
|
}else {
|
|
6286
6374
|
return {
|
|
6287
6375
|
"type": "input-rich-text",
|
|
6376
|
+
"receiver": "${context.rootUrl}/s3/images",
|
|
6288
6377
|
"name": field.name
|
|
6289
6378
|
}
|
|
6290
6379
|
// return {
|
|
@@ -7968,13 +8057,13 @@ async function getTableApi(mainObject, fields, options){
|
|
|
7968
8057
|
const masterRecord = self._master.record;
|
|
7969
8058
|
const masterObjectName = self._master.objectName;
|
|
7970
8059
|
let relatedValue = self._master.recordId;
|
|
7971
|
-
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
8060
|
+
if(refField && refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
7972
8061
|
relatedValue = masterRecord[refField.reference_to_field]
|
|
7973
8062
|
}
|
|
7974
8063
|
let relatedFilters;
|
|
7975
8064
|
if (
|
|
7976
|
-
refField._reference_to ||
|
|
7977
|
-
(refField.reference_to && !_.isString(refField.reference_to))
|
|
8065
|
+
refField && (refField._reference_to ||
|
|
8066
|
+
(refField.reference_to && !_.isString(refField.reference_to)))
|
|
7978
8067
|
) {
|
|
7979
8068
|
relatedFilters = [
|
|
7980
8069
|
[relatedKey + "/o", "=", masterObjectName],
|
|
@@ -8124,7 +8213,7 @@ function getRecordPermissionsApi(object, recordId, options){
|
|
|
8124
8213
|
|
|
8125
8214
|
const API_CACHE = 100;
|
|
8126
8215
|
|
|
8127
|
-
function getReadonlyFormAdaptor(object, fields){
|
|
8216
|
+
function getReadonlyFormAdaptor(object, fields, options){
|
|
8128
8217
|
let scriptStr = '';
|
|
8129
8218
|
const selectFields = _$1.filter(fields, function(field){return field.name.indexOf('.') < 0 && ((field.type == 'select' && field.options) || ((field.type == 'lookup' || field.type == 'master_detail') && !field.reference_to))});
|
|
8130
8219
|
const gridAndObjectFieldsName = _$1.map(_$1.filter(fields, function(field){return field.name.indexOf('.') < 0 && (field.type === 'object' || field.type === 'grid')}), 'name');
|
|
@@ -8164,9 +8253,16 @@ function getReadonlyFormAdaptor(object, fields){
|
|
|
8164
8253
|
|
|
8165
8254
|
return `
|
|
8166
8255
|
if(payload.data.data.length === 0){
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8256
|
+
var isEditor = !!${options && options.isEditor};
|
|
8257
|
+
if(isEditor){
|
|
8258
|
+
// 设计器中始终显示表单,有记录则显示第一条记录,没记录时显示为空表单
|
|
8259
|
+
payload.data.data = [{}];
|
|
8260
|
+
}
|
|
8261
|
+
else{
|
|
8262
|
+
return {
|
|
8263
|
+
status: 2,
|
|
8264
|
+
msg: "无法找到记录"
|
|
8265
|
+
}
|
|
8170
8266
|
}
|
|
8171
8267
|
}
|
|
8172
8268
|
if(payload.data.data){
|
|
@@ -8183,7 +8279,7 @@ function getReadonlyFormAdaptor(object, fields){
|
|
|
8183
8279
|
var record = _.cloneDeep(data);
|
|
8184
8280
|
try{
|
|
8185
8281
|
_.each(gridAndObjectFieldsName, function(name){
|
|
8186
|
-
data[name] = data._display[name];
|
|
8282
|
+
data[name] = data._display && data._display[name];
|
|
8187
8283
|
})
|
|
8188
8284
|
}catch(e){
|
|
8189
8285
|
console.error(e)
|
|
@@ -8204,10 +8300,10 @@ function getReadonlyFormAdaptor(object, fields){
|
|
|
8204
8300
|
async function getReadonlyFormInitApi(object, recordId, fields, options){
|
|
8205
8301
|
return {
|
|
8206
8302
|
method: "post",
|
|
8207
|
-
url: getApi$2()+"&recordId=${recordId}",
|
|
8303
|
+
url: getApi$2() + '&objectName=${objectName}' + "&recordId=${recordId}",
|
|
8208
8304
|
cache: API_CACHE,
|
|
8209
8305
|
// requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
|
|
8210
|
-
adaptor: getReadonlyFormAdaptor(object, fields),
|
|
8306
|
+
adaptor: getReadonlyFormAdaptor(object, fields, options),
|
|
8211
8307
|
data: await getFindOneQuery$1(object, recordId, fields, options),
|
|
8212
8308
|
headers: {
|
|
8213
8309
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -9471,6 +9567,8 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
9471
9567
|
};
|
|
9472
9568
|
if(formSchema.id){
|
|
9473
9569
|
amisSchema.id = `service-${formSchema.id}`;
|
|
9570
|
+
}else {
|
|
9571
|
+
amisSchema.id = `new-${objectSchema.name}`;
|
|
9474
9572
|
}
|
|
9475
9573
|
return amisSchema;
|
|
9476
9574
|
}
|
|
@@ -9637,8 +9735,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
9637
9735
|
/*
|
|
9638
9736
|
* @Author: baozhoutao@steedos.com
|
|
9639
9737
|
* @Date: 2022-07-05 15:55:39
|
|
9640
|
-
* @LastEditors:
|
|
9641
|
-
* @LastEditTime: 2023-
|
|
9738
|
+
* @LastEditors: liaodaxue
|
|
9739
|
+
* @LastEditTime: 2023-06-20 14:05:50
|
|
9642
9740
|
* @Description:
|
|
9643
9741
|
*/
|
|
9644
9742
|
|
|
@@ -9681,10 +9779,11 @@ async function getObjectRelatedList(
|
|
|
9681
9779
|
if(!isEmpty(relatedLists)){
|
|
9682
9780
|
for (const relatedList of relatedLists) {
|
|
9683
9781
|
const arr = relatedList.related_field_fullname.split(".");
|
|
9782
|
+
const foreign_key = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
9684
9783
|
related.push({
|
|
9685
9784
|
masterObjectName: objectName,
|
|
9686
9785
|
object_name: arr[0],
|
|
9687
|
-
foreign_key
|
|
9786
|
+
foreign_key,
|
|
9688
9787
|
label: relatedList.label,
|
|
9689
9788
|
columns: relatedList.field_names,
|
|
9690
9789
|
sort: relatedList.sort,
|
|
@@ -9697,10 +9796,11 @@ async function getObjectRelatedList(
|
|
|
9697
9796
|
const details = [].concat(uiSchema.details || []);
|
|
9698
9797
|
for (const detail of details) {
|
|
9699
9798
|
const arr = detail.split(".");
|
|
9799
|
+
const foreign_key = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
9700
9800
|
related.push({
|
|
9701
9801
|
masterObjectName: objectName,
|
|
9702
9802
|
object_name: arr[0],
|
|
9703
|
-
foreign_key
|
|
9803
|
+
foreign_key
|
|
9704
9804
|
});
|
|
9705
9805
|
}
|
|
9706
9806
|
}
|
|
@@ -9732,14 +9832,16 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9732
9832
|
if(!isEmpty(mainRelatedLists)){
|
|
9733
9833
|
for (const relatedList of mainRelatedLists) {
|
|
9734
9834
|
const arr = relatedList.related_field_fullname.split(".");
|
|
9735
|
-
|
|
9835
|
+
const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
9836
|
+
mainRelated[arr[0]] = foreign_key_value;
|
|
9736
9837
|
}
|
|
9737
9838
|
}else {
|
|
9738
9839
|
const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
|
|
9739
9840
|
for (const detail of details) {
|
|
9740
9841
|
const arr = detail.split(".");
|
|
9842
|
+
const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
9741
9843
|
if(!has(mainRelated,arr[0])){
|
|
9742
|
-
mainRelated[arr[0]] =
|
|
9844
|
+
mainRelated[arr[0]] = foreign_key_value;
|
|
9743
9845
|
}
|
|
9744
9846
|
}
|
|
9745
9847
|
}
|