@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.cjs.js
CHANGED
|
@@ -363,7 +363,7 @@ const getSteedosAuth = () => {
|
|
|
363
363
|
* @Author: baozhoutao@steedos.com
|
|
364
364
|
* @Date: 2022-08-16 17:02:08
|
|
365
365
|
* @LastEditors: baozhoutao@steedos.com
|
|
366
|
-
* @LastEditTime: 2023-
|
|
366
|
+
* @LastEditTime: 2023-06-20 13:50:15
|
|
367
367
|
* @Description:
|
|
368
368
|
*/
|
|
369
369
|
|
|
@@ -374,14 +374,14 @@ const Router = {
|
|
|
374
374
|
if(urlSearch.has('display')){
|
|
375
375
|
return urlSearch.get('display')
|
|
376
376
|
}
|
|
377
|
-
|
|
378
|
-
const key = `page_display`;
|
|
377
|
+
const key = `tab_${tab_id}_display`;
|
|
378
|
+
// const key = `page_display`;
|
|
379
379
|
const value = localStorage.getItem(key);
|
|
380
380
|
return value ? value : 'grid'
|
|
381
381
|
},
|
|
382
382
|
|
|
383
383
|
setTabDisplayAs(tab_id, displayAs){
|
|
384
|
-
const key = `
|
|
384
|
+
const key = `tab_${tab_id}_display`;
|
|
385
385
|
localStorage.setItem(key, displayAs);
|
|
386
386
|
},
|
|
387
387
|
getAppPath({formFactor, appId}){
|
|
@@ -395,15 +395,10 @@ const Router = {
|
|
|
395
395
|
},
|
|
396
396
|
getObjectDetailPath(props){
|
|
397
397
|
const {formFactor, appId, objectName, recordId, listViewName, _templateType} = props;
|
|
398
|
-
// var urlParams = new URLSearchParams(window.location.search);
|
|
399
|
-
// if(objectName === 'instances'){
|
|
400
|
-
// return `/workflow/space/\${context.tenantId}/\${listName}/${recordId}`;
|
|
401
|
-
// }
|
|
402
|
-
const displayAs = Router.getTabDisplayAs(objectName); //urlParams.get("display") ||
|
|
403
398
|
if(_templateType === 'JavaScript'){
|
|
404
|
-
return `/app/${appId}/${objectName}/view/${recordId}?
|
|
399
|
+
return `/app/${appId}/${objectName}/view/${recordId}?side_object=<%=item.objectName%>&side_listview_id=<%=item.listName%>`;
|
|
405
400
|
}
|
|
406
|
-
return `/app/${appId}/${objectName}/view/${recordId}?
|
|
401
|
+
return `/app/${appId}/${objectName}/view/${recordId}?side_object=\${objectName}&side_listview_id=\${listName}`;
|
|
407
402
|
},
|
|
408
403
|
getObjectRelatedViewPath({formFactor, appId, masterObjectName, masterRecordId, objectName, foreignKey}){
|
|
409
404
|
return `/app/${appId}/${masterObjectName}/${masterRecordId}/${objectName}/grid?related_field_name=${foreignKey}`;
|
|
@@ -3153,7 +3148,10 @@ async function getObjectFieldsFilterFormSchema(ctx) {
|
|
|
3153
3148
|
const formSchema = {
|
|
3154
3149
|
"type": "service",
|
|
3155
3150
|
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3156
|
-
"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",
|
|
3151
|
+
"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",
|
|
3152
|
+
"style":{
|
|
3153
|
+
"max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
|
|
3154
|
+
},
|
|
3157
3155
|
"schemaApi": {
|
|
3158
3156
|
method: 'post',
|
|
3159
3157
|
url: `\${context.rootUrl}/graphql?reload=\${filterFormSearchableFields|join}`,
|
|
@@ -3242,28 +3240,42 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3242
3240
|
// }
|
|
3243
3241
|
// }
|
|
3244
3242
|
// listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
|
|
3245
|
-
|
|
3246
|
-
let
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3243
|
+
// 点击搜索的时候自动收起搜索栏
|
|
3244
|
+
let resizeWindow = function(){
|
|
3245
|
+
//触发amis crud 高度重算
|
|
3246
|
+
setTimeout(()=>{
|
|
3247
|
+
window.dispatchEvent(new Event("resize"))
|
|
3248
|
+
}, 500);
|
|
3249
|
+
}
|
|
3250
|
+
const filterService = filterForm.context.getComponents().find(function(n){
|
|
3251
|
+
return n.props.type === "service";
|
|
3252
|
+
});
|
|
3253
|
+
let showFieldsFilter = false;
|
|
3254
|
+
const isMobile = window.innerWidth < 768;
|
|
3255
|
+
if(event.data.__from_fields_filter_settings_confirm){
|
|
3256
|
+
// 如果是从设置搜索项点击确认按钮触发的搜索事件不应该自动关闭搜索栏
|
|
3257
|
+
showFieldsFilter = true;
|
|
3258
|
+
}
|
|
3259
|
+
else if(isMobile){
|
|
3260
|
+
// 如果是手机端,点击搜索后自动关闭搜索栏
|
|
3261
|
+
showFieldsFilter = false;
|
|
3262
|
+
}
|
|
3263
|
+
else if(event.data.displayAs === "split") {
|
|
3264
|
+
// PC上分栏模式下的列表,始终按手机上效果处理,即自动关闭搜索栏
|
|
3265
|
+
showFieldsFilter = false;
|
|
3266
|
+
}
|
|
3267
|
+
else if(window.innerHeight >= 1200){
|
|
3268
|
+
// 高分辨率屏幕(2k+),列表高度比较高,没必要自动关闭搜索栏
|
|
3269
|
+
showFieldsFilter = true;
|
|
3266
3270
|
}
|
|
3271
|
+
filterService.setData({showFieldsFilter});
|
|
3272
|
+
resizeWindow();
|
|
3273
|
+
// 使用filterForm.getValues()的话,并不能拿到本地存储中的过滤条件,所以需要从event.data中取。
|
|
3274
|
+
let filterFormValues = event.data;
|
|
3275
|
+
let isFieldsFilterEmpty = SteedosUI.isFilterFormValuesEmpty(filterFormValues);
|
|
3276
|
+
let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
|
|
3277
|
+
let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
|
|
3278
|
+
crudService && crudService.setData({isFieldsFilterEmpty, showFieldsFilter});
|
|
3267
3279
|
`;
|
|
3268
3280
|
const onCancelScript = `
|
|
3269
3281
|
const scope = event.context.scoped;
|
|
@@ -3302,12 +3314,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3302
3314
|
setTimeout(()=>{
|
|
3303
3315
|
window.dispatchEvent(new Event("resize"))
|
|
3304
3316
|
}, 100);
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
|
|
3309
|
-
crudService && crudService.setData({isFieldsFilterEmpty: true, showFieldsFilter: false});
|
|
3310
|
-
}
|
|
3317
|
+
// 移除搜索按钮上的红点
|
|
3318
|
+
let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
|
|
3319
|
+
crudService && crudService.setData({isFieldsFilterEmpty: true, showFieldsFilter: false});
|
|
3311
3320
|
`;
|
|
3312
3321
|
const dataProviderInited = `
|
|
3313
3322
|
const objectName = data.objectName;
|
|
@@ -3360,17 +3369,11 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3360
3369
|
|| (_.isArray(n) && _.isEmpty(n.filter(function(item){return !_.isNil(item)})))
|
|
3361
3370
|
|| (_.isString(n) && n.length === 0);
|
|
3362
3371
|
});
|
|
3363
|
-
//
|
|
3372
|
+
// 有过滤条件时只显示搜索按钮上的红点,不自动展开搜索栏
|
|
3364
3373
|
if(!_.isEmpty(omitedEmptyFormValue)){
|
|
3365
|
-
let
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
let crudService = SteedosUI.getRef(data.$scopeId).getComponentById("service_listview_" + data.objectName)
|
|
3369
|
-
crudService && crudService.setData({isFieldsFilterEmpty: false});
|
|
3370
|
-
}
|
|
3371
|
-
else{
|
|
3372
|
-
setData({ showFieldsFilter: true });
|
|
3373
|
-
}
|
|
3374
|
+
let crudService = SteedosUI.getRef(data.$scopeId).getComponentById("service_listview_" + data.objectName)
|
|
3375
|
+
crudService && crudService.setData({isFieldsFilterEmpty: false});
|
|
3376
|
+
// setData({ showFieldsFilter: true });//自动展开搜索栏
|
|
3374
3377
|
}
|
|
3375
3378
|
}
|
|
3376
3379
|
}
|
|
@@ -3636,7 +3639,10 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3636
3639
|
},
|
|
3637
3640
|
{
|
|
3638
3641
|
"actionType": "click",
|
|
3639
|
-
"componentId": btnSearchId
|
|
3642
|
+
"componentId": btnSearchId,
|
|
3643
|
+
"args": {
|
|
3644
|
+
"__from_fields_filter_settings_confirm": true
|
|
3645
|
+
}
|
|
3640
3646
|
},
|
|
3641
3647
|
{
|
|
3642
3648
|
"componentId": "",
|
|
@@ -4168,7 +4174,8 @@ const getNewListviewButtonSchema = ()=>{
|
|
|
4168
4174
|
"name":"",
|
|
4169
4175
|
"label":"",
|
|
4170
4176
|
"filters":"",
|
|
4171
|
-
"shared":false
|
|
4177
|
+
"shared":false,
|
|
4178
|
+
"object_name": "${targetObjectName}",
|
|
4172
4179
|
},
|
|
4173
4180
|
"fieldsExtend": fieldsExtend$4(),
|
|
4174
4181
|
"fields": fields$1(),
|
|
@@ -4215,13 +4222,11 @@ function fields$1(){
|
|
|
4215
4222
|
"object_name",
|
|
4216
4223
|
"filter_scope",
|
|
4217
4224
|
"show_count",
|
|
4218
|
-
"columns
|
|
4219
|
-
"
|
|
4220
|
-
"sort.$.field_name",
|
|
4221
|
-
"sort.$.order",
|
|
4225
|
+
"columns",
|
|
4226
|
+
"sort",
|
|
4222
4227
|
"filters",
|
|
4223
|
-
"mobile_columns
|
|
4224
|
-
"searchable_fields
|
|
4228
|
+
"mobile_columns",
|
|
4229
|
+
"searchable_fields",
|
|
4225
4230
|
"is_system",
|
|
4226
4231
|
"shared"
|
|
4227
4232
|
]
|
|
@@ -4234,7 +4239,8 @@ function fieldsExtend$4(){
|
|
|
4234
4239
|
},
|
|
4235
4240
|
"name": {
|
|
4236
4241
|
"amis": {
|
|
4237
|
-
"hidden": true
|
|
4242
|
+
"hidden": true,
|
|
4243
|
+
"required": false
|
|
4238
4244
|
}
|
|
4239
4245
|
},
|
|
4240
4246
|
"object_name": {
|
|
@@ -4244,37 +4250,56 @@ function fieldsExtend$4(){
|
|
|
4244
4250
|
},
|
|
4245
4251
|
"filter_scope": {
|
|
4246
4252
|
"amis": {
|
|
4247
|
-
"hidden": true
|
|
4253
|
+
"hidden": true,
|
|
4254
|
+
"required": false
|
|
4248
4255
|
}
|
|
4249
4256
|
},
|
|
4250
4257
|
"columns": {
|
|
4251
4258
|
"amis": {
|
|
4252
|
-
"hidden": true
|
|
4259
|
+
"hidden": true,
|
|
4260
|
+
"required": false
|
|
4261
|
+
}
|
|
4262
|
+
},
|
|
4263
|
+
"mobile_columns":{
|
|
4264
|
+
"amis": {
|
|
4265
|
+
"hidden": true,
|
|
4266
|
+
"required": false
|
|
4267
|
+
}
|
|
4268
|
+
},
|
|
4269
|
+
"searchable_fields":{
|
|
4270
|
+
"amis": {
|
|
4271
|
+
"hidden": true,
|
|
4272
|
+
"required": false
|
|
4253
4273
|
}
|
|
4254
4274
|
},
|
|
4255
4275
|
"filter_fields": {
|
|
4256
4276
|
"amis": {
|
|
4257
|
-
"hidden": true
|
|
4277
|
+
"hidden": true,
|
|
4278
|
+
"required": false
|
|
4258
4279
|
}
|
|
4259
4280
|
},
|
|
4260
4281
|
"scrolling_mode": {
|
|
4261
4282
|
"amis": {
|
|
4262
|
-
"hidden": true
|
|
4283
|
+
"hidden": true,
|
|
4284
|
+
"required": false
|
|
4263
4285
|
}
|
|
4264
4286
|
},
|
|
4265
4287
|
"sort": {
|
|
4266
4288
|
"amis": {
|
|
4267
|
-
"hidden": true
|
|
4289
|
+
"hidden": true,
|
|
4290
|
+
"required": false
|
|
4268
4291
|
}
|
|
4269
4292
|
},
|
|
4270
4293
|
"show_count": {
|
|
4271
4294
|
"amis": {
|
|
4272
|
-
"hidden": true
|
|
4295
|
+
"hidden": true,
|
|
4296
|
+
"required": false
|
|
4273
4297
|
}
|
|
4274
4298
|
},
|
|
4275
4299
|
"type": {
|
|
4276
4300
|
"amis": {
|
|
4277
|
-
"hidden": true
|
|
4301
|
+
"hidden": true,
|
|
4302
|
+
"required": false
|
|
4278
4303
|
}
|
|
4279
4304
|
},
|
|
4280
4305
|
"shared": {
|
|
@@ -5059,14 +5084,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
5059
5084
|
{
|
|
5060
5085
|
"type": "button",
|
|
5061
5086
|
"label": i18next__default["default"].t('frontend_display_type_is_table'),
|
|
5062
|
-
"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');",
|
|
5087
|
+
"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');",
|
|
5063
5088
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
5064
5089
|
"rightIconClassName": "m-l-sm"
|
|
5065
5090
|
},
|
|
5066
5091
|
{
|
|
5067
5092
|
"type": "button",
|
|
5068
5093
|
"label": i18next__default["default"].t('frontend_display_type_is_split'),
|
|
5069
|
-
"onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
5094
|
+
"onClick": "const key = 'tab_"+objectName+"_display';localStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
5070
5095
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
5071
5096
|
"rightIconClassName": "m-l-sm"
|
|
5072
5097
|
}
|
|
@@ -5097,36 +5122,38 @@ const filterForm = scope.getComponents().find(function(n){
|
|
|
5097
5122
|
const filterService = filterForm.context.getComponents().find(function(n){
|
|
5098
5123
|
return n.props.type === "service";
|
|
5099
5124
|
});
|
|
5100
|
-
|
|
5125
|
+
let toShowFieldsFilter = !!!filterService.props.data.showFieldsFilter;
|
|
5126
|
+
filterService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
5101
5127
|
let resizeWindow = function(){
|
|
5102
5128
|
//触发amis crud 高度重算
|
|
5103
5129
|
setTimeout(()=>{
|
|
5104
5130
|
window.dispatchEvent(new Event("resize"))
|
|
5105
5131
|
}, 500);
|
|
5106
5132
|
}
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
}
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
}
|
|
5133
|
+
resizeWindow();
|
|
5134
|
+
// 手机端在显示搜索栏时隐藏crud上的刷新按钮,因为点击后crud高度显示有问题
|
|
5135
|
+
let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
|
|
5136
|
+
crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
5137
|
+
// if(filterService.props.data.showFieldsFilter){
|
|
5138
|
+
// if(isMobile){
|
|
5139
|
+
// // 手机上只能通过取消按钮来关闭搜索栏
|
|
5140
|
+
// return;
|
|
5141
|
+
// }
|
|
5142
|
+
// let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
|
|
5143
|
+
// direction: "down",
|
|
5144
|
+
// name: "btn_filter_form_cancel"
|
|
5145
|
+
// });
|
|
5146
|
+
// buttonCancel.props.dispatchEvent('click', {}).then(function(){
|
|
5147
|
+
// resizeWindow();
|
|
5148
|
+
// });
|
|
5149
|
+
// }
|
|
5150
|
+
// else{
|
|
5151
|
+
// if(isMobile){
|
|
5152
|
+
// // 手机端在显示搜索栏时隐藏crud上的刷新按钮,因为点击后crud高度显示有问题
|
|
5153
|
+
// let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
|
|
5154
|
+
// crudService && crudService.setData({showFieldsFilter: true});
|
|
5155
|
+
// }
|
|
5156
|
+
// }
|
|
5130
5157
|
`;
|
|
5131
5158
|
|
|
5132
5159
|
|
|
@@ -5172,7 +5199,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5172
5199
|
},
|
|
5173
5200
|
},
|
|
5174
5201
|
filterVisible ? {
|
|
5175
|
-
"label": "",
|
|
5202
|
+
"label": i18next__default["default"].t('frontend_button_search_tooltip'),
|
|
5176
5203
|
"icon": "fa fa-search",
|
|
5177
5204
|
"type": "button",
|
|
5178
5205
|
"tooltip": i18next__default["default"].t('frontend_button_search_tooltip'),
|
|
@@ -5225,12 +5252,23 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5225
5252
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
5226
5253
|
},
|
|
5227
5254
|
// getExportExcelToolbarButtonSchema(),
|
|
5255
|
+
getSettingListviewToolbarButtonSchema(),
|
|
5256
|
+
getDisplayAsButton(mainObject?.name),
|
|
5228
5257
|
filterVisible ? {
|
|
5229
|
-
"label": "",
|
|
5258
|
+
"label": i18next__default["default"].t('frontend_button_search_tooltip'),
|
|
5230
5259
|
"icon": "fa fa-search",
|
|
5231
5260
|
"tooltip": i18next__default["default"].t('frontend_button_search_tooltip'),
|
|
5232
5261
|
"tooltipPlacement": "bottom",
|
|
5233
5262
|
"type": "button",
|
|
5263
|
+
"badge": {
|
|
5264
|
+
"offset": [
|
|
5265
|
+
-5,
|
|
5266
|
+
1
|
|
5267
|
+
],
|
|
5268
|
+
"size":8,
|
|
5269
|
+
"animation": true,
|
|
5270
|
+
"visibleOn": "${isFieldsFilterEmpty == false}"
|
|
5271
|
+
},
|
|
5234
5272
|
"align": "right",
|
|
5235
5273
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500",
|
|
5236
5274
|
"onEvent": {
|
|
@@ -5243,9 +5281,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5243
5281
|
]
|
|
5244
5282
|
}
|
|
5245
5283
|
}
|
|
5246
|
-
} : {}
|
|
5247
|
-
getSettingListviewToolbarButtonSchema(),
|
|
5248
|
-
getDisplayAsButton(showDisplayAs)
|
|
5284
|
+
} : {}
|
|
5249
5285
|
// {
|
|
5250
5286
|
// "type": "search-box",
|
|
5251
5287
|
// "align": "right",
|
|
@@ -5875,6 +5911,58 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5875
5911
|
"actions": [
|
|
5876
5912
|
{
|
|
5877
5913
|
"actionType": "reload"
|
|
5914
|
+
},
|
|
5915
|
+
{
|
|
5916
|
+
"actionType": "custom",
|
|
5917
|
+
"script": `
|
|
5918
|
+
const masterRecord = event.data._master?.record;
|
|
5919
|
+
const fieldConfig = ${JSON.stringify(field)};
|
|
5920
|
+
let reference_to = fieldConfig.reference_to;
|
|
5921
|
+
let saveValue;
|
|
5922
|
+
const newRecord = {
|
|
5923
|
+
_id: event.data.result.data.recordId,
|
|
5924
|
+
...event.data.__super.__super
|
|
5925
|
+
}
|
|
5926
|
+
const saveField = fieldConfig.reference_to_field || '_id';
|
|
5927
|
+
const saveFieldValue = newRecord[saveField];
|
|
5928
|
+
|
|
5929
|
+
if( fieldConfig._reference_to && (_.isArray(fieldConfig._reference_to) || _.isFunction(fieldConfig._reference_to) || fieldConfig._reference_to.startsWith('function') ) ){
|
|
5930
|
+
|
|
5931
|
+
const fieldValue = masterRecord ? masterRecord[fieldConfig.name] : {o: reference_to, ids: []};
|
|
5932
|
+
const baseSaveValue = {
|
|
5933
|
+
o: reference_to,
|
|
5934
|
+
ids: [saveFieldValue]
|
|
5935
|
+
};
|
|
5936
|
+
if(fieldValue && fieldValue.o){
|
|
5937
|
+
if(fieldValue.o === reference_to){
|
|
5938
|
+
saveValue = fieldConfig.multiple ? { o: reference_to, ids: fieldValue.ids.concat(saveFieldValue)} : baseSaveValue;
|
|
5939
|
+
}else{
|
|
5940
|
+
saveValue = baseSaveValue;
|
|
5941
|
+
}
|
|
5942
|
+
}else{
|
|
5943
|
+
saveValue = baseSaveValue;
|
|
5944
|
+
}
|
|
5945
|
+
|
|
5946
|
+
}else{
|
|
5947
|
+
if(fieldConfig.multiple){
|
|
5948
|
+
// TODO: 连续新建多个记录时,因为获取的主记录不是实时的,所以只会勾选最后一个新建的记录。
|
|
5949
|
+
const fieldValue = (masterRecord && masterRecord[fieldConfig.name]) || [];
|
|
5950
|
+
saveValue = fieldValue.concat(saveFieldValue);
|
|
5951
|
+
}else{
|
|
5952
|
+
saveValue = saveFieldValue;
|
|
5953
|
+
}
|
|
5954
|
+
}
|
|
5955
|
+
|
|
5956
|
+
const ctx = ${JSON.stringify(ctx)};
|
|
5957
|
+
const componentId = ctx.defaults.formSchema.id ? 'service-'+ctx.defaults.formSchema.id : 'new-'+ctx.defaults.formSchema.objectApiName;
|
|
5958
|
+
doAction({
|
|
5959
|
+
actionType: 'setValue',
|
|
5960
|
+
componentId: componentId,
|
|
5961
|
+
args: {
|
|
5962
|
+
value: { [fieldConfig.name]: saveValue }
|
|
5963
|
+
}
|
|
5964
|
+
});
|
|
5965
|
+
`
|
|
5878
5966
|
}
|
|
5879
5967
|
]
|
|
5880
5968
|
};
|
|
@@ -6105,7 +6193,7 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
6105
6193
|
type: 'steedos-field-lookup',
|
|
6106
6194
|
field,
|
|
6107
6195
|
readonly,
|
|
6108
|
-
ctx
|
|
6196
|
+
ctx,
|
|
6109
6197
|
}
|
|
6110
6198
|
// return await lookupToAmisGroup(field, readonly, ctx);
|
|
6111
6199
|
}
|
|
@@ -6259,8 +6347,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6259
6347
|
/*
|
|
6260
6348
|
* @Author: baozhoutao@steedos.com
|
|
6261
6349
|
* @Date: 2023-01-13 17:27:54
|
|
6262
|
-
* @LastEditors:
|
|
6263
|
-
* @LastEditTime: 2023-
|
|
6350
|
+
* @LastEditors: liaodaxue
|
|
6351
|
+
* @LastEditTime: 2023-06-16 15:58:21
|
|
6264
6352
|
* @Description:
|
|
6265
6353
|
*/
|
|
6266
6354
|
|
|
@@ -6312,6 +6400,7 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
|
|
|
6312
6400
|
}else {
|
|
6313
6401
|
return {
|
|
6314
6402
|
"type": "input-rich-text",
|
|
6403
|
+
"receiver": "${context.rootUrl}/s3/images",
|
|
6315
6404
|
"name": field.name
|
|
6316
6405
|
}
|
|
6317
6406
|
// return {
|
|
@@ -7995,13 +8084,13 @@ async function getTableApi(mainObject, fields, options){
|
|
|
7995
8084
|
const masterRecord = self._master.record;
|
|
7996
8085
|
const masterObjectName = self._master.objectName;
|
|
7997
8086
|
let relatedValue = self._master.recordId;
|
|
7998
|
-
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
8087
|
+
if(refField && refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
7999
8088
|
relatedValue = masterRecord[refField.reference_to_field]
|
|
8000
8089
|
}
|
|
8001
8090
|
let relatedFilters;
|
|
8002
8091
|
if (
|
|
8003
|
-
refField._reference_to ||
|
|
8004
|
-
(refField.reference_to && !_.isString(refField.reference_to))
|
|
8092
|
+
refField && (refField._reference_to ||
|
|
8093
|
+
(refField.reference_to && !_.isString(refField.reference_to)))
|
|
8005
8094
|
) {
|
|
8006
8095
|
relatedFilters = [
|
|
8007
8096
|
[relatedKey + "/o", "=", masterObjectName],
|
|
@@ -8151,7 +8240,7 @@ function getRecordPermissionsApi(object, recordId, options){
|
|
|
8151
8240
|
|
|
8152
8241
|
const API_CACHE = 100;
|
|
8153
8242
|
|
|
8154
|
-
function getReadonlyFormAdaptor(object, fields){
|
|
8243
|
+
function getReadonlyFormAdaptor(object, fields, options){
|
|
8155
8244
|
let scriptStr = '';
|
|
8156
8245
|
const selectFields = ___namespace.filter(fields, function(field){return field.name.indexOf('.') < 0 && ((field.type == 'select' && field.options) || ((field.type == 'lookup' || field.type == 'master_detail') && !field.reference_to))});
|
|
8157
8246
|
const gridAndObjectFieldsName = ___namespace.map(___namespace.filter(fields, function(field){return field.name.indexOf('.') < 0 && (field.type === 'object' || field.type === 'grid')}), 'name');
|
|
@@ -8191,9 +8280,16 @@ function getReadonlyFormAdaptor(object, fields){
|
|
|
8191
8280
|
|
|
8192
8281
|
return `
|
|
8193
8282
|
if(payload.data.data.length === 0){
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8283
|
+
var isEditor = !!${options && options.isEditor};
|
|
8284
|
+
if(isEditor){
|
|
8285
|
+
// 设计器中始终显示表单,有记录则显示第一条记录,没记录时显示为空表单
|
|
8286
|
+
payload.data.data = [{}];
|
|
8287
|
+
}
|
|
8288
|
+
else{
|
|
8289
|
+
return {
|
|
8290
|
+
status: 2,
|
|
8291
|
+
msg: "无法找到记录"
|
|
8292
|
+
}
|
|
8197
8293
|
}
|
|
8198
8294
|
}
|
|
8199
8295
|
if(payload.data.data){
|
|
@@ -8210,7 +8306,7 @@ function getReadonlyFormAdaptor(object, fields){
|
|
|
8210
8306
|
var record = _.cloneDeep(data);
|
|
8211
8307
|
try{
|
|
8212
8308
|
_.each(gridAndObjectFieldsName, function(name){
|
|
8213
|
-
data[name] = data._display[name];
|
|
8309
|
+
data[name] = data._display && data._display[name];
|
|
8214
8310
|
})
|
|
8215
8311
|
}catch(e){
|
|
8216
8312
|
console.error(e)
|
|
@@ -8231,10 +8327,10 @@ function getReadonlyFormAdaptor(object, fields){
|
|
|
8231
8327
|
async function getReadonlyFormInitApi(object, recordId, fields, options){
|
|
8232
8328
|
return {
|
|
8233
8329
|
method: "post",
|
|
8234
|
-
url: getApi$2()+"&recordId=${recordId}",
|
|
8330
|
+
url: getApi$2() + '&objectName=${objectName}' + "&recordId=${recordId}",
|
|
8235
8331
|
cache: API_CACHE,
|
|
8236
8332
|
// requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
|
|
8237
|
-
adaptor: getReadonlyFormAdaptor(object, fields),
|
|
8333
|
+
adaptor: getReadonlyFormAdaptor(object, fields, options),
|
|
8238
8334
|
data: await getFindOneQuery$1(object, recordId, fields, options),
|
|
8239
8335
|
headers: {
|
|
8240
8336
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -9498,6 +9594,8 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
9498
9594
|
};
|
|
9499
9595
|
if(formSchema.id){
|
|
9500
9596
|
amisSchema.id = `service-${formSchema.id}`;
|
|
9597
|
+
}else {
|
|
9598
|
+
amisSchema.id = `new-${objectSchema.name}`;
|
|
9501
9599
|
}
|
|
9502
9600
|
return amisSchema;
|
|
9503
9601
|
}
|
|
@@ -9664,8 +9762,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
9664
9762
|
/*
|
|
9665
9763
|
* @Author: baozhoutao@steedos.com
|
|
9666
9764
|
* @Date: 2022-07-05 15:55:39
|
|
9667
|
-
* @LastEditors:
|
|
9668
|
-
* @LastEditTime: 2023-
|
|
9765
|
+
* @LastEditors: liaodaxue
|
|
9766
|
+
* @LastEditTime: 2023-06-20 14:05:50
|
|
9669
9767
|
* @Description:
|
|
9670
9768
|
*/
|
|
9671
9769
|
|
|
@@ -9708,10 +9806,11 @@ async function getObjectRelatedList(
|
|
|
9708
9806
|
if(!_$1.isEmpty(relatedLists)){
|
|
9709
9807
|
for (const relatedList of relatedLists) {
|
|
9710
9808
|
const arr = relatedList.related_field_fullname.split(".");
|
|
9809
|
+
const foreign_key = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
9711
9810
|
related.push({
|
|
9712
9811
|
masterObjectName: objectName,
|
|
9713
9812
|
object_name: arr[0],
|
|
9714
|
-
foreign_key
|
|
9813
|
+
foreign_key,
|
|
9715
9814
|
label: relatedList.label,
|
|
9716
9815
|
columns: relatedList.field_names,
|
|
9717
9816
|
sort: relatedList.sort,
|
|
@@ -9724,10 +9823,11 @@ async function getObjectRelatedList(
|
|
|
9724
9823
|
const details = [].concat(uiSchema.details || []);
|
|
9725
9824
|
for (const detail of details) {
|
|
9726
9825
|
const arr = detail.split(".");
|
|
9826
|
+
const foreign_key = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
9727
9827
|
related.push({
|
|
9728
9828
|
masterObjectName: objectName,
|
|
9729
9829
|
object_name: arr[0],
|
|
9730
|
-
foreign_key
|
|
9830
|
+
foreign_key
|
|
9731
9831
|
});
|
|
9732
9832
|
}
|
|
9733
9833
|
}
|
|
@@ -9759,14 +9859,16 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9759
9859
|
if(!_$1.isEmpty(mainRelatedLists)){
|
|
9760
9860
|
for (const relatedList of mainRelatedLists) {
|
|
9761
9861
|
const arr = relatedList.related_field_fullname.split(".");
|
|
9762
|
-
|
|
9862
|
+
const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
9863
|
+
mainRelated[arr[0]] = foreign_key_value;
|
|
9763
9864
|
}
|
|
9764
9865
|
}else {
|
|
9765
9866
|
const details = _$1.union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
|
|
9766
9867
|
for (const detail of details) {
|
|
9767
9868
|
const arr = detail.split(".");
|
|
9869
|
+
const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
9768
9870
|
if(!_$1.has(mainRelated,arr[0])){
|
|
9769
|
-
mainRelated[arr[0]] =
|
|
9871
|
+
mainRelated[arr[0]] = foreign_key_value;
|
|
9770
9872
|
}
|
|
9771
9873
|
}
|
|
9772
9874
|
}
|