@steedos-widgets/amis-lib 1.2.35-beta.1 → 1.2.35
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 +121 -45
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +121 -45
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +121 -45
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/graphql.d.ts +1 -1
- package/dist/types/lib/objects.d.ts +10 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -649,9 +649,10 @@
|
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
async function getFieldsTemplate(fields,
|
|
653
|
-
|
|
654
|
-
|
|
652
|
+
async function getFieldsTemplate(fields, display){
|
|
653
|
+
let expandFields = [];
|
|
654
|
+
if(display != false){
|
|
655
|
+
display = true;
|
|
655
656
|
}
|
|
656
657
|
let fieldsName = ['_id'];
|
|
657
658
|
let displayFields = [];
|
|
@@ -663,33 +664,43 @@
|
|
|
663
664
|
}
|
|
664
665
|
for (const field of fieldsArr) {
|
|
665
666
|
//graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
|
|
666
|
-
if(field.
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
667
|
+
if(field.expand){
|
|
668
|
+
expandFields.push(field);
|
|
669
|
+
}else {
|
|
670
|
+
if(field.name.indexOf('.') < 0){
|
|
671
|
+
if(display && (field.type == 'lookup' || field.type == 'master_detail')){
|
|
672
|
+
fieldsName.push(`${field.name}`);
|
|
673
|
+
displayFields.push(`${field.name}`);
|
|
674
|
+
}else {
|
|
675
|
+
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
|
|
676
|
+
}
|
|
677
|
+
if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
678
|
+
fieldsName.push(`${field.name}`);
|
|
679
|
+
}
|
|
680
|
+
if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
681
|
+
displayFields.push(`${field.name}`);
|
|
682
|
+
}
|
|
670
683
|
}else {
|
|
671
|
-
|
|
684
|
+
objectFieldName = field.name.split('.')[0];
|
|
685
|
+
fieldsName.push(objectFieldName);
|
|
686
|
+
displayFields.push(objectFieldName);
|
|
672
687
|
}
|
|
673
|
-
if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
674
|
-
fieldsName.push(`${field.name}`);
|
|
675
|
-
}
|
|
676
|
-
if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
677
|
-
displayFields.push(`${field.name}`);
|
|
678
|
-
}
|
|
679
|
-
}else {
|
|
680
|
-
objectFieldName = field.name.split('.')[0];
|
|
681
|
-
fieldsName.push(objectFieldName);
|
|
682
|
-
displayFields.push(objectFieldName);
|
|
683
688
|
}
|
|
684
689
|
}
|
|
685
690
|
|
|
686
691
|
displayFields = ___namespace.uniq(displayFields);
|
|
687
692
|
fieldsName = ___namespace.uniq(fieldsName);
|
|
693
|
+
let expandFieldsQuery = "";
|
|
694
|
+
if(expandFields.length > 0){
|
|
695
|
+
___namespace.each(expandFields, function(field){
|
|
696
|
+
expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
|
|
697
|
+
});
|
|
698
|
+
}
|
|
688
699
|
|
|
689
700
|
if(displayFields.length > 0){
|
|
690
|
-
return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
|
|
701
|
+
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
691
702
|
}
|
|
692
|
-
return `${fieldsName.join(' ')}`
|
|
703
|
+
return `${fieldsName.join(' ')},${expandFieldsQuery}`
|
|
693
704
|
}
|
|
694
705
|
|
|
695
706
|
function getRecordPermissionsTemplate(){
|
|
@@ -3365,7 +3376,7 @@
|
|
|
3365
3376
|
if(!event.data.isLookup){
|
|
3366
3377
|
// 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
|
|
3367
3378
|
const listViewId = event.data.listViewId;
|
|
3368
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
3379
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
3369
3380
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3370
3381
|
if(localListViewProps){
|
|
3371
3382
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3397,7 +3408,7 @@
|
|
|
3397
3408
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3398
3409
|
}
|
|
3399
3410
|
else{
|
|
3400
|
-
searchableFieldsStoreKey += listViewId;
|
|
3411
|
+
searchableFieldsStoreKey += (listViewId || "");
|
|
3401
3412
|
}
|
|
3402
3413
|
let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
|
|
3403
3414
|
if(defaultSearchableFields){
|
|
@@ -3424,7 +3435,9 @@
|
|
|
3424
3435
|
setData({ showFieldsFilter: false });
|
|
3425
3436
|
}
|
|
3426
3437
|
else{
|
|
3427
|
-
|
|
3438
|
+
console.log("===listViewPropsStoreKey=data==", data);
|
|
3439
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
|
|
3440
|
+
console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
|
|
3428
3441
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3429
3442
|
if(localListViewProps){
|
|
3430
3443
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3470,7 +3483,7 @@
|
|
|
3470
3483
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3471
3484
|
}
|
|
3472
3485
|
else{
|
|
3473
|
-
searchableFieldsStoreKey += listViewId;
|
|
3486
|
+
searchableFieldsStoreKey += (listViewId || "");
|
|
3474
3487
|
}
|
|
3475
3488
|
sessionStorage.setItem(searchableFieldsStoreKey, value);
|
|
3476
3489
|
|
|
@@ -3528,7 +3541,7 @@
|
|
|
3528
3541
|
}
|
|
3529
3542
|
|
|
3530
3543
|
// 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
|
|
3531
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
3544
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
3532
3545
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3533
3546
|
if(localListViewProps){
|
|
3534
3547
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3647,7 +3660,8 @@
|
|
|
3647
3660
|
const fields = uiSchema.fields;
|
|
3648
3661
|
const options = (payload.data?.options || []).filter(function(item){
|
|
3649
3662
|
let field = fields[item.value];
|
|
3650
|
-
|
|
3663
|
+
// TODO: 暂时禁用location类型字段的列表搜索
|
|
3664
|
+
return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'
|
|
3651
3665
|
});
|
|
3652
3666
|
payload.data = {
|
|
3653
3667
|
"options": options
|
|
@@ -5250,6 +5264,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
5250
5264
|
|
|
5251
5265
|
function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
|
|
5252
5266
|
// console.log(`getObjectHeaderToolbar====>`, filterVisible)
|
|
5267
|
+
console.log(`getObjectHeaderToolbar`, mainObject);
|
|
5253
5268
|
const isMobile = window.innerWidth < 768;
|
|
5254
5269
|
if(isMobile){
|
|
5255
5270
|
showDisplayAs = false;
|
|
@@ -5349,7 +5364,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
5349
5364
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
5350
5365
|
},
|
|
5351
5366
|
// getExportExcelToolbarButtonSchema(),
|
|
5352
|
-
getSettingListviewToolbarButtonSchema(),
|
|
5367
|
+
mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
|
|
5353
5368
|
getDisplayAsButton(mainObject?.name),
|
|
5354
5369
|
filterVisible ? {
|
|
5355
5370
|
"label": i18next__default["default"].t('frontend_button_search_tooltip'),
|
|
@@ -7189,12 +7204,35 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
7189
7204
|
}
|
|
7190
7205
|
}
|
|
7191
7206
|
|
|
7207
|
+
const coordinatesType = field.coordinatesType || "bd09";
|
|
7192
7208
|
convertData = {
|
|
7193
7209
|
type: getAmisStaticFieldType('location', readonly),
|
|
7194
7210
|
tpl: readonly ? getLocationTpl(field) : null,
|
|
7195
7211
|
ak,
|
|
7196
7212
|
vendor,
|
|
7197
|
-
|
|
7213
|
+
clearable: true,
|
|
7214
|
+
coordinatesType,
|
|
7215
|
+
label: field.label,
|
|
7216
|
+
pipeOut: (value, oldValue, data) => {
|
|
7217
|
+
if (value) {
|
|
7218
|
+
const lng = value.lng;
|
|
7219
|
+
const lat = value.lat;
|
|
7220
|
+
let coordinates = [lng,lat];
|
|
7221
|
+
if(window.coordtransform){
|
|
7222
|
+
if(coordinatesType.toLowerCase() === 'bd09'){
|
|
7223
|
+
const bd09togcj02 = window.coordtransform.bd09togcj02(lng,lat);
|
|
7224
|
+
coordinates = window.coordtransform.gcj02towgs84(bd09togcj02[0],bd09togcj02[1]);
|
|
7225
|
+
}else if(coordinatesType.toLowerCase() === 'gcj02'){
|
|
7226
|
+
coordinates = window.coordtransform.gcj02towgs84(lng,lat);
|
|
7227
|
+
}
|
|
7228
|
+
}
|
|
7229
|
+
value.wgs84 = {
|
|
7230
|
+
type: "Point",
|
|
7231
|
+
coordinates
|
|
7232
|
+
};
|
|
7233
|
+
return value; // 切换到数字之后的默认值
|
|
7234
|
+
}
|
|
7235
|
+
}
|
|
7198
7236
|
};
|
|
7199
7237
|
break;
|
|
7200
7238
|
case 'avatar':
|
|
@@ -7662,6 +7700,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
7662
7700
|
if(field.type == "file" && field.multiple){
|
|
7663
7701
|
quickEditSchema = false;
|
|
7664
7702
|
}
|
|
7703
|
+
//TODO:location字段在列表中快速编辑后存在bug,保存时可能会丢失部分数据,暂时禁用
|
|
7704
|
+
if(field.type == "location"){
|
|
7705
|
+
quickEditSchema = false;
|
|
7706
|
+
}
|
|
7665
7707
|
}
|
|
7666
7708
|
return quickEditSchema;
|
|
7667
7709
|
}
|
|
@@ -8216,7 +8258,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
8216
8258
|
try{
|
|
8217
8259
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8218
8260
|
const listViewId = api.data.listViewId;
|
|
8219
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
8261
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
8220
8262
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
8221
8263
|
if(localListViewProps){
|
|
8222
8264
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -8417,7 +8459,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
8417
8459
|
try{
|
|
8418
8460
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8419
8461
|
const listViewId = api.body.listViewId;
|
|
8420
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
8462
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
8421
8463
|
/**
|
|
8422
8464
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
8423
8465
|
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
@@ -10386,7 +10428,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
10386
10428
|
* @Author: baozhoutao@steedos.com
|
|
10387
10429
|
* @Date: 2022-07-05 15:55:39
|
|
10388
10430
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
10389
|
-
* @LastEditTime: 2023-
|
|
10431
|
+
* @LastEditTime: 2023-08-01 14:50:23
|
|
10390
10432
|
* @Description:
|
|
10391
10433
|
*/
|
|
10392
10434
|
|
|
@@ -10651,7 +10693,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
10651
10693
|
* 本次存储代码段
|
|
10652
10694
|
*/
|
|
10653
10695
|
try {
|
|
10654
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + ctx.listViewId;
|
|
10696
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
|
|
10655
10697
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
10656
10698
|
/**
|
|
10657
10699
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
@@ -10720,6 +10762,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
10720
10762
|
"filterVisible": ctx.filterVisible,
|
|
10721
10763
|
"rowClassNameExpr": ctx.rowClassNameExpr
|
|
10722
10764
|
};
|
|
10765
|
+
// console.log(`getListSchema===>`,amisSchema)
|
|
10723
10766
|
return {
|
|
10724
10767
|
uiSchema,
|
|
10725
10768
|
amisSchema,
|
|
@@ -10733,7 +10776,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
10733
10776
|
columns,
|
|
10734
10777
|
ctx = {}
|
|
10735
10778
|
) {
|
|
10736
|
-
// console.time('getTableSchema');
|
|
10779
|
+
// console.time('getTableSchema', columns);
|
|
10737
10780
|
const uiSchema = await getUISchema(objectName);
|
|
10738
10781
|
|
|
10739
10782
|
let sort = ctx.sort;
|
|
@@ -10747,19 +10790,52 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
10747
10790
|
}
|
|
10748
10791
|
|
|
10749
10792
|
let fields = [];
|
|
10750
|
-
|
|
10751
|
-
if (_$1.isString(column)
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10793
|
+
for(const column of columns){
|
|
10794
|
+
if (_$1.isString(column)) {
|
|
10795
|
+
if(column.indexOf('.') > 0){
|
|
10796
|
+
const fieldName = column.split('.')[0];
|
|
10797
|
+
const displayName = column.split('.')[1];
|
|
10798
|
+
const filedInfo = uiSchema.fields[fieldName];
|
|
10799
|
+
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to) ){
|
|
10800
|
+
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10801
|
+
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10802
|
+
fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
|
|
10803
|
+
}
|
|
10804
|
+
}else {
|
|
10805
|
+
if(uiSchema.fields[column]){
|
|
10806
|
+
fields.push(uiSchema.fields[column]);
|
|
10807
|
+
}
|
|
10808
|
+
}
|
|
10809
|
+
} else if (_$1.isObject(column)) {
|
|
10810
|
+
if(column.field.indexOf('.') > 0){
|
|
10811
|
+
const fieldName = column.field.split('.')[0];
|
|
10812
|
+
const displayName = column.field.split('.')[1];
|
|
10813
|
+
const filedInfo = uiSchema.fields[fieldName];
|
|
10814
|
+
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to) ){
|
|
10815
|
+
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10816
|
+
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10817
|
+
fields.push(Object.assign({}, rfFieldInfo,
|
|
10818
|
+
{name: column.field, expand: true, expandInfo: {fieldName, displayName}},
|
|
10819
|
+
{
|
|
10820
|
+
width: column.width,
|
|
10821
|
+
wrap: column.wrap, // wrap = true 是没效果的
|
|
10822
|
+
amis: column.amis
|
|
10823
|
+
}
|
|
10824
|
+
));
|
|
10825
|
+
}
|
|
10826
|
+
}else {
|
|
10827
|
+
if(uiSchema.fields[column.field]){
|
|
10828
|
+
fields.push(
|
|
10829
|
+
Object.assign({}, uiSchema.fields[column.field], {
|
|
10830
|
+
width: column.width,
|
|
10831
|
+
wrap: column.wrap, // wrap = true 是没效果的
|
|
10832
|
+
amis: column.amis
|
|
10833
|
+
})
|
|
10834
|
+
);
|
|
10835
|
+
}
|
|
10836
|
+
}
|
|
10761
10837
|
}
|
|
10762
|
-
}
|
|
10838
|
+
}
|
|
10763
10839
|
|
|
10764
10840
|
const extraColumns = ctx.extraColumns;
|
|
10765
10841
|
|