@steedos-widgets/amis-lib 1.2.9 → 1.2.11
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 +109 -99
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +110 -100
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +109 -99
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/fields_filter.d.ts +7 -5
- package/dist/types/lib/converter/amis/header.d.ts +9 -5
- package/dist/types/lib/converter/amis/toolbar.d.ts +7 -5
- package/dist/types/lib/converter/amis/toolbars/setting_listview/columns.d.ts +1 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview/copy.d.ts +1 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview/filters.d.ts +1 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview/new.d.ts +1 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview/rename.d.ts +1 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview/share.d.ts +1 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview/sort.d.ts +1 -1
- package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +6 -4
- package/dist/types/lib/converter/amis/tpl.d.ts +1 -0
- package/dist/types/lib/converter/amis/util.d.ts +1 -1
- package/dist/types/lib/objects.d.ts +2 -0
- package/dist/types/schema/standard_import_data.amis.d.ts +5 -0
- package/dist/types/standard/button.d.ts +5 -0
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -408,11 +408,28 @@
|
|
|
408
408
|
|
|
409
409
|
};
|
|
410
410
|
|
|
411
|
+
/*
|
|
412
|
+
* @Author: baozhoutao@steedos.com
|
|
413
|
+
* @Date: 2022-07-20 16:29:22
|
|
414
|
+
* @LastEditors: Please set LastEditors
|
|
415
|
+
* @LastEditTime: 2023-05-18 15:22:51
|
|
416
|
+
* @Description:
|
|
417
|
+
*/
|
|
418
|
+
|
|
419
|
+
function getContrastColor(bgColor) {
|
|
420
|
+
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
421
|
+
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
422
|
+
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
423
|
+
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
424
|
+
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
425
|
+
return brightness < 128 ? "#ffffff" : "#000000";
|
|
426
|
+
}
|
|
427
|
+
|
|
411
428
|
/*
|
|
412
429
|
* @Author: baozhoutao@steedos.com
|
|
413
430
|
* @Date: 2022-05-23 09:53:08
|
|
414
|
-
* @LastEditors:
|
|
415
|
-
* @LastEditTime: 2023-
|
|
431
|
+
* @LastEditors: Please set LastEditors
|
|
432
|
+
* @LastEditTime: 2023-05-22 15:13:18
|
|
416
433
|
* @Description:
|
|
417
434
|
*/
|
|
418
435
|
|
|
@@ -465,6 +482,22 @@
|
|
|
465
482
|
function getSelectTpl(field){
|
|
466
483
|
return `<div>\${_display.${field.name}}</div>`
|
|
467
484
|
}
|
|
485
|
+
function getSelectMap(selectOptions){
|
|
486
|
+
let map = {};
|
|
487
|
+
_$1.forEach(selectOptions,(option)=>{
|
|
488
|
+
const optionValue = option.value + '';
|
|
489
|
+
const optionColor = option.color + '';
|
|
490
|
+
if(optionColor){
|
|
491
|
+
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
492
|
+
const color = getContrastColor(background);
|
|
493
|
+
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
494
|
+
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
495
|
+
}else {
|
|
496
|
+
map[optionValue] = option.label;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
return map;
|
|
500
|
+
}
|
|
468
501
|
|
|
469
502
|
function getNameTplUrl(field, ctx){
|
|
470
503
|
if(ctx.objectName === 'cms_files'){
|
|
@@ -1861,9 +1894,10 @@
|
|
|
1861
1894
|
{
|
|
1862
1895
|
name: "template_url",
|
|
1863
1896
|
label: "导入模板",
|
|
1864
|
-
type: "
|
|
1865
|
-
|
|
1866
|
-
|
|
1897
|
+
type: "markdown",
|
|
1898
|
+
options: {
|
|
1899
|
+
html: true
|
|
1900
|
+
},
|
|
1867
1901
|
className: "whitespace-nowrap",
|
|
1868
1902
|
},
|
|
1869
1903
|
null,
|
|
@@ -2710,6 +2744,7 @@
|
|
|
2710
2744
|
if (!ctx) {
|
|
2711
2745
|
ctx = {};
|
|
2712
2746
|
}
|
|
2747
|
+
const btnSearchId = "btn_filter_form_search_" + new Date().getTime();
|
|
2713
2748
|
const filterFormSchema = await getObjectFieldsFilterFormSchema(ctx);
|
|
2714
2749
|
const onSearchScript = `
|
|
2715
2750
|
const scope = event.context.scoped;
|
|
@@ -2726,7 +2761,7 @@
|
|
|
2726
2761
|
// // 这会造成handleFilterSubmit时把移除掉的搜索项字段之前的值加到过滤条件中
|
|
2727
2762
|
// for(var k in filterFormValues){
|
|
2728
2763
|
// if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
|
|
2729
|
-
// removedValues[k] =
|
|
2764
|
+
// removedValues[k] = null;
|
|
2730
2765
|
// }
|
|
2731
2766
|
// }
|
|
2732
2767
|
// listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
|
|
@@ -2765,7 +2800,7 @@
|
|
|
2765
2800
|
const removedValues = {};
|
|
2766
2801
|
for(var k in filterFormValues){
|
|
2767
2802
|
if(/^__searchable__/.test(k)){
|
|
2768
|
-
removedValues[k] =
|
|
2803
|
+
removedValues[k] = null;
|
|
2769
2804
|
}
|
|
2770
2805
|
}
|
|
2771
2806
|
if(!event.data.isLookup){
|
|
@@ -2776,7 +2811,7 @@
|
|
|
2776
2811
|
if(localListViewProps){
|
|
2777
2812
|
localListViewProps = JSON.parse(localListViewProps);
|
|
2778
2813
|
for(var k in localListViewProps){
|
|
2779
|
-
removedValues[k] =
|
|
2814
|
+
removedValues[k] = null;
|
|
2780
2815
|
}
|
|
2781
2816
|
}
|
|
2782
2817
|
}
|
|
@@ -2934,7 +2969,7 @@
|
|
|
2934
2969
|
});
|
|
2935
2970
|
const removedValues = {};
|
|
2936
2971
|
removedKeys.forEach(function(key){
|
|
2937
|
-
removedValues[key] =
|
|
2972
|
+
removedValues[key] = null;
|
|
2938
2973
|
});
|
|
2939
2974
|
filterForm.setValues(removedValues);//这里使用filterInnerForm也可以
|
|
2940
2975
|
|
|
@@ -2947,10 +2982,14 @@
|
|
|
2947
2982
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
2948
2983
|
if(localListViewProps){
|
|
2949
2984
|
localListViewProps = JSON.parse(localListViewProps);
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2985
|
+
_.each(localListViewProps, function(n,k){
|
|
2986
|
+
// __searchable__开头的不在searchableFields范围则清除其值
|
|
2987
|
+
let isRemoved = !!removedFields.find(function(fieldName){
|
|
2988
|
+
return new RegExp("__searchable__\.*" + fieldName + "$").test(k);
|
|
2989
|
+
});
|
|
2990
|
+
if(isRemoved){
|
|
2991
|
+
delete localListViewProps[k];
|
|
2992
|
+
}
|
|
2954
2993
|
});
|
|
2955
2994
|
sessionStorage.setItem(listViewPropsStoreKey, JSON.stringify(localListViewProps));
|
|
2956
2995
|
}
|
|
@@ -2984,9 +3023,10 @@
|
|
|
2984
3023
|
"body": [
|
|
2985
3024
|
{
|
|
2986
3025
|
"type": "button",
|
|
3026
|
+
"id": btnSearchId,
|
|
2987
3027
|
"label": "搜索",
|
|
2988
3028
|
"icon": "fa fa-search",
|
|
2989
|
-
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3029
|
+
// "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
2990
3030
|
"onEvent": {
|
|
2991
3031
|
"click": {
|
|
2992
3032
|
"actions": [
|
|
@@ -3002,7 +3042,7 @@
|
|
|
3002
3042
|
"type": "button",
|
|
3003
3043
|
"label": "取消",
|
|
3004
3044
|
"name": "btn_filter_form_cancel",
|
|
3005
|
-
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3045
|
+
// "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
3006
3046
|
"onEvent": {
|
|
3007
3047
|
"click": {
|
|
3008
3048
|
"actions": [
|
|
@@ -3117,6 +3157,10 @@
|
|
|
3117
3157
|
"actionType": "custom",
|
|
3118
3158
|
"script": onSearchableFieldsChangeScript
|
|
3119
3159
|
},
|
|
3160
|
+
{
|
|
3161
|
+
"actionType": "click",
|
|
3162
|
+
"componentId": btnSearchId
|
|
3163
|
+
},
|
|
3120
3164
|
{
|
|
3121
3165
|
"componentId": "",
|
|
3122
3166
|
"args": {},
|
|
@@ -3424,8 +3468,8 @@
|
|
|
3424
3468
|
},
|
|
3425
3469
|
"body":[{
|
|
3426
3470
|
"type": "button",
|
|
3427
|
-
"visibleOn": "${window:innerWidth > 768 && window:historyPaths.length > 1}",
|
|
3428
|
-
"className":"flex mr-
|
|
3471
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
3472
|
+
"className":"flex mr-4",
|
|
3429
3473
|
"onEvent": {
|
|
3430
3474
|
"click": {
|
|
3431
3475
|
"actions": [
|
|
@@ -3442,7 +3486,7 @@
|
|
|
3442
3486
|
"category": "utility",
|
|
3443
3487
|
"name": "back",
|
|
3444
3488
|
"colorVariant": "default",
|
|
3445
|
-
"className": "slds-button_icon slds-global-header__icon"
|
|
3489
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
3446
3490
|
}
|
|
3447
3491
|
]
|
|
3448
3492
|
}]
|
|
@@ -3471,7 +3515,7 @@
|
|
|
3471
3515
|
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
3472
3516
|
"inline": false,
|
|
3473
3517
|
"wrapperComponent": "",
|
|
3474
|
-
"className": "leading-5 text-xl font-bold"
|
|
3518
|
+
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
3475
3519
|
}
|
|
3476
3520
|
],
|
|
3477
3521
|
"columnClassName": "p-l-xs"
|
|
@@ -3480,6 +3524,7 @@
|
|
|
3480
3524
|
"className": "flex justify-between"
|
|
3481
3525
|
}
|
|
3482
3526
|
],
|
|
3527
|
+
"columnClassName": "flex-initial",
|
|
3483
3528
|
"md": "auto",
|
|
3484
3529
|
});
|
|
3485
3530
|
}
|
|
@@ -3500,7 +3545,7 @@
|
|
|
3500
3545
|
{
|
|
3501
3546
|
"type": "grid",
|
|
3502
3547
|
"columns": gridBody,
|
|
3503
|
-
"className": "flex justify-between"
|
|
3548
|
+
"className": "flex justify-between flex-nowrap"
|
|
3504
3549
|
}
|
|
3505
3550
|
],
|
|
3506
3551
|
"hiddenOn": "${recordLoaded != true}"
|
|
@@ -3717,12 +3762,13 @@
|
|
|
3717
3762
|
"type": "dialog",
|
|
3718
3763
|
"title": "新建 列表视图",
|
|
3719
3764
|
"data": {
|
|
3720
|
-
"&":
|
|
3765
|
+
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
3721
3766
|
"all": "${uiSchema.list_views.all}",
|
|
3722
3767
|
"list_view": "${uiSchema.list_views[listName]}",
|
|
3723
3768
|
"appId": "${appId}",
|
|
3724
3769
|
"global": "${global}",
|
|
3725
3770
|
"targetObjectName": "${objectName}",
|
|
3771
|
+
"context": "${context}"
|
|
3726
3772
|
},
|
|
3727
3773
|
"body": [
|
|
3728
3774
|
{
|
|
@@ -3866,12 +3912,13 @@
|
|
|
3866
3912
|
"type": "dialog",
|
|
3867
3913
|
"title": "复制 列表视图",
|
|
3868
3914
|
"data": {
|
|
3869
|
-
"&":
|
|
3915
|
+
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
3870
3916
|
"listName": "${listName}",
|
|
3871
3917
|
"targetObjectName": "${objectName}",
|
|
3872
3918
|
"list_view": "${uiSchema.list_views[listName]}",
|
|
3873
3919
|
"appId": "${appId}",
|
|
3874
|
-
"global": "${global}"
|
|
3920
|
+
"global": "${global}",
|
|
3921
|
+
"context": "${context}"
|
|
3875
3922
|
},
|
|
3876
3923
|
"body": [
|
|
3877
3924
|
{
|
|
@@ -4013,7 +4060,8 @@
|
|
|
4013
4060
|
"data": {
|
|
4014
4061
|
"targetObjectName": "${objectName}",
|
|
4015
4062
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4016
|
-
"appId": "${appId}"
|
|
4063
|
+
"appId": "${appId}",
|
|
4064
|
+
"context": "${context}"
|
|
4017
4065
|
},
|
|
4018
4066
|
"body": [
|
|
4019
4067
|
{
|
|
@@ -4070,6 +4118,7 @@
|
|
|
4070
4118
|
"title": "共享设置",
|
|
4071
4119
|
"data": {
|
|
4072
4120
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4121
|
+
"context": "${context}"
|
|
4073
4122
|
},
|
|
4074
4123
|
"body": [
|
|
4075
4124
|
{
|
|
@@ -4115,7 +4164,8 @@
|
|
|
4115
4164
|
"targetObjectName": "${objectName}",
|
|
4116
4165
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4117
4166
|
"listName": "${listName}",
|
|
4118
|
-
"appId": "${appId}"
|
|
4167
|
+
"appId": "${appId}",
|
|
4168
|
+
"context": "${context}"
|
|
4119
4169
|
},
|
|
4120
4170
|
"body": [
|
|
4121
4171
|
{
|
|
@@ -4259,11 +4309,12 @@
|
|
|
4259
4309
|
"type": "dialog",
|
|
4260
4310
|
"title": "显示的列",
|
|
4261
4311
|
"data": {
|
|
4262
|
-
"&":
|
|
4312
|
+
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
4263
4313
|
"targetObjectName": "${objectName}",
|
|
4264
4314
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4265
4315
|
"listName": "${listName}",
|
|
4266
|
-
"appId": "${appId}"
|
|
4316
|
+
"appId": "${appId}",
|
|
4317
|
+
"context": "${context}"
|
|
4267
4318
|
},
|
|
4268
4319
|
"body": [
|
|
4269
4320
|
{
|
|
@@ -4410,13 +4461,14 @@
|
|
|
4410
4461
|
{
|
|
4411
4462
|
"dialog": {
|
|
4412
4463
|
"type": "dialog",
|
|
4413
|
-
"title": "
|
|
4464
|
+
"title": "默认排序规则",
|
|
4414
4465
|
"data": {
|
|
4415
|
-
"&":
|
|
4466
|
+
//"&":"$$",2.7、2.9、3.0在此处失效
|
|
4416
4467
|
"targetObjectName": "${objectName}",
|
|
4417
4468
|
"recordId": "${uiSchema.list_views[listName]._id}",
|
|
4418
4469
|
"listName": "${listName}",
|
|
4419
|
-
"appId": "${appId}"
|
|
4470
|
+
"appId": "${appId}",
|
|
4471
|
+
"context": "${context}"
|
|
4420
4472
|
},
|
|
4421
4473
|
"body": [
|
|
4422
4474
|
{
|
|
@@ -5106,24 +5158,13 @@ else{
|
|
|
5106
5158
|
"actionType": "custom",
|
|
5107
5159
|
"script": `
|
|
5108
5160
|
const scope = event.context.scoped;
|
|
5109
|
-
|
|
5110
|
-
// var filterForm = scope.parent.parent.getComponents().find(function(n){
|
|
5111
|
-
// return n.props.type === "form";
|
|
5112
|
-
// });
|
|
5113
|
-
// var filterFormValues = filterForm.getValues();
|
|
5114
|
-
filterFormValues={
|
|
5161
|
+
var filterFormValues={
|
|
5115
5162
|
"__searchable__organizations_parents":event.data.value.value
|
|
5116
5163
|
}
|
|
5117
5164
|
var listView = scope.parent.getComponents().find(function(n){
|
|
5118
5165
|
return n.props.type === "crud";
|
|
5119
5166
|
});
|
|
5120
|
-
|
|
5121
|
-
// for(var k in filterFormValues){
|
|
5122
|
-
// if(filterFormValues[k] === "" && !filterFormValues.hasOwnProperty(k)){
|
|
5123
|
-
// removedValues[k] = "";
|
|
5124
|
-
// }
|
|
5125
|
-
// }
|
|
5126
|
-
listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
|
|
5167
|
+
listView.handleFilterSubmit(Object.assign({}, filterFormValues));
|
|
5127
5168
|
`
|
|
5128
5169
|
}
|
|
5129
5170
|
]
|
|
@@ -5237,7 +5278,7 @@ else{
|
|
|
5237
5278
|
|
|
5238
5279
|
const source = await getApi$1(refObjectConfig, null, fields, {expand: true, alias: 'rows', queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
|
|
5239
5280
|
|
|
5240
|
-
if(source.url){
|
|
5281
|
+
if(source.url && !ctx.inFilterForm){
|
|
5241
5282
|
const depend_on = [];
|
|
5242
5283
|
const sendOn = [];
|
|
5243
5284
|
___namespace.each(field.depend_on, (fName)=>{
|
|
@@ -5301,9 +5342,10 @@ else{
|
|
|
5301
5342
|
filters.push(fieldFilters);
|
|
5302
5343
|
}
|
|
5303
5344
|
|
|
5345
|
+
const inFilterForm = ${ctx.inFilterForm};
|
|
5304
5346
|
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
5305
5347
|
|
|
5306
|
-
if(filtersFunction){
|
|
5348
|
+
if(filtersFunction && !inFilterForm){
|
|
5307
5349
|
const _filters = filtersFunction(filters, api.data.$self.__super.__super);
|
|
5308
5350
|
if(_filters && _filters.length > 0){
|
|
5309
5351
|
filters.push(_filters);
|
|
@@ -5523,7 +5565,8 @@ else{
|
|
|
5523
5565
|
sort = getListViewSort(listView);
|
|
5524
5566
|
}
|
|
5525
5567
|
|
|
5526
|
-
|
|
5568
|
+
// 列表视图搜索栏中,即inFilterForm=true时,不需要执行depend_on
|
|
5569
|
+
if(apiInfo.url && !ctx.inFilterForm){
|
|
5527
5570
|
const depend_on = [];
|
|
5528
5571
|
const sendOn = [];
|
|
5529
5572
|
___namespace.each(field.depend_on, (fName)=>{
|
|
@@ -5560,9 +5603,10 @@ else{
|
|
|
5560
5603
|
filters.push(fieldFilters);
|
|
5561
5604
|
}
|
|
5562
5605
|
|
|
5606
|
+
const inFilterForm = ${ctx.inFilterForm};
|
|
5563
5607
|
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
5564
5608
|
|
|
5565
|
-
if(filtersFunction){
|
|
5609
|
+
if(filtersFunction && !inFilterForm){
|
|
5566
5610
|
const _filters = filtersFunction(filters, api.data.$);
|
|
5567
5611
|
if(_filters && _filters.length > 0){
|
|
5568
5612
|
filters.push(_filters);
|
|
@@ -5588,7 +5632,14 @@ else{
|
|
|
5588
5632
|
referenceTo ? referenceTo.valueField.name : '';
|
|
5589
5633
|
if(field.optionsFunction || field._optionsFunction){
|
|
5590
5634
|
apiInfo.adaptor = `
|
|
5591
|
-
|
|
5635
|
+
var options = eval(${field.optionsFunction || field._optionsFunction})(api.data.$);
|
|
5636
|
+
if(api.data.$term){
|
|
5637
|
+
options = _.filter(options, function(o) {
|
|
5638
|
+
var label = o.label;
|
|
5639
|
+
return label.toLowerCase().indexOf(api.data.$term.toLowerCase()) > -1;
|
|
5640
|
+
});
|
|
5641
|
+
}
|
|
5642
|
+
payload.data.options = options;
|
|
5592
5643
|
return payload;
|
|
5593
5644
|
`;
|
|
5594
5645
|
}
|
|
@@ -5724,7 +5775,7 @@ else{
|
|
|
5724
5775
|
source.data.$term = "$term";
|
|
5725
5776
|
source.data.$self = "$$";
|
|
5726
5777
|
|
|
5727
|
-
if(idsDependOn && source.url){
|
|
5778
|
+
if(idsDependOn && source.url && !ctx.inFilterForm){
|
|
5728
5779
|
source.sendOn = `\${${idsDependOn} && ${idsDependOn}.length}`;
|
|
5729
5780
|
source.url = `${source.url}&depend_on_${idsDependOn}=\${${idsDependOn}|join}`;
|
|
5730
5781
|
}
|
|
@@ -6010,23 +6061,6 @@ else{
|
|
|
6010
6061
|
return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
|
|
6011
6062
|
};
|
|
6012
6063
|
|
|
6013
|
-
/*
|
|
6014
|
-
* @Author: baozhoutao@steedos.com
|
|
6015
|
-
* @Date: 2022-07-20 16:29:22
|
|
6016
|
-
* @LastEditors: Please set LastEditors
|
|
6017
|
-
* @LastEditTime: 2023-05-11 11:19:54
|
|
6018
|
-
* @Description:
|
|
6019
|
-
*/
|
|
6020
|
-
|
|
6021
|
-
function getContrastColor(bgColor) {
|
|
6022
|
-
var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
|
|
6023
|
-
var r = parseInt(backgroundColor.substr(0, 2), 16);
|
|
6024
|
-
var g = parseInt(backgroundColor.substr(2, 2), 16);
|
|
6025
|
-
var b = parseInt(backgroundColor.substr(4, 2), 16);
|
|
6026
|
-
var brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
6027
|
-
return brightness >= 128 ? "#000000" : "#ffffff";
|
|
6028
|
-
}
|
|
6029
|
-
|
|
6030
6064
|
const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
|
|
6031
6065
|
// const Lookup = require('./lookup');
|
|
6032
6066
|
|
|
@@ -6217,19 +6251,7 @@ else{
|
|
|
6217
6251
|
// break;
|
|
6218
6252
|
case 'select':
|
|
6219
6253
|
if(readonly){
|
|
6220
|
-
const
|
|
6221
|
-
let map = {};
|
|
6222
|
-
___namespace.forEach(selectOptions,(option)=>{
|
|
6223
|
-
const optionValue = option.value + '';
|
|
6224
|
-
if(option.color){
|
|
6225
|
-
const background = '#'+option.color;
|
|
6226
|
-
const color = getContrastColor(background);
|
|
6227
|
-
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
6228
|
-
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
6229
|
-
}else {
|
|
6230
|
-
map[optionValue] = option.label;
|
|
6231
|
-
}
|
|
6232
|
-
});
|
|
6254
|
+
const map = getSelectMap(field.options);
|
|
6233
6255
|
convertData = {
|
|
6234
6256
|
type: "static-mapping",
|
|
6235
6257
|
name: field.name,
|
|
@@ -6595,7 +6617,7 @@ else{
|
|
|
6595
6617
|
convertData.className = fieldTypeClassName;
|
|
6596
6618
|
}
|
|
6597
6619
|
|
|
6598
|
-
if(field.visible_on){
|
|
6620
|
+
if(field.visible_on && !ctx.inFilterForm){
|
|
6599
6621
|
// convertData.visibleOn = `\$${field.visible_on.substring(1, field.visible_on.length -1).replace(/formData./g, '')}`;
|
|
6600
6622
|
if(field.visible_on.startsWith("{{")){
|
|
6601
6623
|
convertData.visibleOn = `${field.visible_on.substring(2, field.visible_on.length -2).replace(/formData./g, 'data.')}`;
|
|
@@ -6688,7 +6710,7 @@ else{
|
|
|
6688
6710
|
_field.multiple = true;
|
|
6689
6711
|
_field.is_wide = false;
|
|
6690
6712
|
_field.defaultValue = undefined;
|
|
6691
|
-
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true}));
|
|
6713
|
+
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
|
|
6692
6714
|
if(amisField){
|
|
6693
6715
|
return amisField;
|
|
6694
6716
|
}
|
|
@@ -6928,7 +6950,8 @@ else{
|
|
|
6928
6950
|
data.global = "${global}";
|
|
6929
6951
|
data.context = "${context}";
|
|
6930
6952
|
data.defaultData = "${defaultData}";
|
|
6931
|
-
|
|
6953
|
+
data._master = "${_master}";
|
|
6954
|
+
|
|
6932
6955
|
return {
|
|
6933
6956
|
method: "post",
|
|
6934
6957
|
url: getApi$2() + '&objectName=${objectName}' ,
|
|
@@ -6994,7 +7017,7 @@ else{
|
|
|
6994
7017
|
formInitialValuesFun = new Function("return " + formInitialValuesFun)();
|
|
6995
7018
|
}
|
|
6996
7019
|
if(typeof formInitialValuesFun === "function"){
|
|
6997
|
-
initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global})
|
|
7020
|
+
initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global, master: api.body._master })
|
|
6998
7021
|
}
|
|
6999
7022
|
}
|
|
7000
7023
|
catch(ex){
|
|
@@ -7650,19 +7673,7 @@ else{
|
|
|
7650
7673
|
}, field.amis, {name: field.name}));
|
|
7651
7674
|
}
|
|
7652
7675
|
else if(field.type === 'select'){
|
|
7653
|
-
const
|
|
7654
|
-
let map = {};
|
|
7655
|
-
_$1.forEach(selectOptions,(option)=>{
|
|
7656
|
-
const optionValue = option.value + '';
|
|
7657
|
-
if(option.color){
|
|
7658
|
-
const background = '#'+option.color;
|
|
7659
|
-
const color = getContrastColor(background);
|
|
7660
|
-
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
7661
|
-
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
7662
|
-
}else {
|
|
7663
|
-
map[optionValue] = option.label;
|
|
7664
|
-
}
|
|
7665
|
-
});
|
|
7676
|
+
const map = getSelectMap(field.options);
|
|
7666
7677
|
columns.push(Object.assign({}, {
|
|
7667
7678
|
type: "mapping",
|
|
7668
7679
|
name: field.name,
|
|
@@ -7701,7 +7712,7 @@ else{
|
|
|
7701
7712
|
tpl: tpl,
|
|
7702
7713
|
toggled: field.toggled,
|
|
7703
7714
|
className,
|
|
7704
|
-
|
|
7715
|
+
options: field.type === 'html' ? {html: true} : null
|
|
7705
7716
|
// toggled: true
|
|
7706
7717
|
}, field.amis, {name: field.name}));
|
|
7707
7718
|
}
|
|
@@ -8215,11 +8226,10 @@ else{
|
|
|
8215
8226
|
if(api.data.$self._isRelated){
|
|
8216
8227
|
const self = api.data.$self;
|
|
8217
8228
|
const relatedKey = self.relatedKey;
|
|
8218
|
-
const recordId = self.recordId;
|
|
8219
8229
|
const refField = self.uiSchema.fields[relatedKey];
|
|
8220
8230
|
const masterRecord = self._master.record;
|
|
8221
8231
|
const masterObjectName = self._master.objectName;
|
|
8222
|
-
let relatedValue = recordId;
|
|
8232
|
+
let relatedValue = self._master.recordId;
|
|
8223
8233
|
if(refField.reference_to_field && refField.reference_to_field != '_id'){
|
|
8224
8234
|
relatedValue = masterRecord[refField.reference_to_field]
|
|
8225
8235
|
}
|