@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.cjs.js
CHANGED
|
@@ -652,9 +652,10 @@ async function getFieldTpl (field, options){
|
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
654
|
|
|
655
|
-
async function getFieldsTemplate(fields,
|
|
656
|
-
|
|
657
|
-
|
|
655
|
+
async function getFieldsTemplate(fields, display){
|
|
656
|
+
let expandFields = [];
|
|
657
|
+
if(display != false){
|
|
658
|
+
display = true;
|
|
658
659
|
}
|
|
659
660
|
let fieldsName = ['_id'];
|
|
660
661
|
let displayFields = [];
|
|
@@ -666,33 +667,43 @@ async function getFieldsTemplate(fields, expand){
|
|
|
666
667
|
}
|
|
667
668
|
for (const field of fieldsArr) {
|
|
668
669
|
//graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
|
|
669
|
-
if(field.
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
670
|
+
if(field.expand){
|
|
671
|
+
expandFields.push(field);
|
|
672
|
+
}else {
|
|
673
|
+
if(field.name.indexOf('.') < 0){
|
|
674
|
+
if(display && (field.type == 'lookup' || field.type == 'master_detail')){
|
|
675
|
+
fieldsName.push(`${field.name}`);
|
|
676
|
+
displayFields.push(`${field.name}`);
|
|
677
|
+
}else {
|
|
678
|
+
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
|
|
679
|
+
}
|
|
680
|
+
if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
681
|
+
fieldsName.push(`${field.name}`);
|
|
682
|
+
}
|
|
683
|
+
if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
684
|
+
displayFields.push(`${field.name}`);
|
|
685
|
+
}
|
|
673
686
|
}else {
|
|
674
|
-
|
|
687
|
+
objectFieldName = field.name.split('.')[0];
|
|
688
|
+
fieldsName.push(objectFieldName);
|
|
689
|
+
displayFields.push(objectFieldName);
|
|
675
690
|
}
|
|
676
|
-
if(_$1.includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
677
|
-
fieldsName.push(`${field.name}`);
|
|
678
|
-
}
|
|
679
|
-
if(_$1.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
680
|
-
displayFields.push(`${field.name}`);
|
|
681
|
-
}
|
|
682
|
-
}else {
|
|
683
|
-
objectFieldName = field.name.split('.')[0];
|
|
684
|
-
fieldsName.push(objectFieldName);
|
|
685
|
-
displayFields.push(objectFieldName);
|
|
686
691
|
}
|
|
687
692
|
}
|
|
688
693
|
|
|
689
694
|
displayFields = ___namespace.uniq(displayFields);
|
|
690
695
|
fieldsName = ___namespace.uniq(fieldsName);
|
|
696
|
+
let expandFieldsQuery = "";
|
|
697
|
+
if(expandFields.length > 0){
|
|
698
|
+
___namespace.each(expandFields, function(field){
|
|
699
|
+
expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
|
|
700
|
+
});
|
|
701
|
+
}
|
|
691
702
|
|
|
692
703
|
if(displayFields.length > 0){
|
|
693
|
-
return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
|
|
704
|
+
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
694
705
|
}
|
|
695
|
-
return `${fieldsName.join(' ')}`
|
|
706
|
+
return `${fieldsName.join(' ')},${expandFieldsQuery}`
|
|
696
707
|
}
|
|
697
708
|
|
|
698
709
|
function getRecordPermissionsTemplate(){
|
|
@@ -3368,7 +3379,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3368
3379
|
if(!event.data.isLookup){
|
|
3369
3380
|
// 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
|
|
3370
3381
|
const listViewId = event.data.listViewId;
|
|
3371
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
3382
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
3372
3383
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3373
3384
|
if(localListViewProps){
|
|
3374
3385
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3400,7 +3411,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3400
3411
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3401
3412
|
}
|
|
3402
3413
|
else{
|
|
3403
|
-
searchableFieldsStoreKey += listViewId;
|
|
3414
|
+
searchableFieldsStoreKey += (listViewId || "");
|
|
3404
3415
|
}
|
|
3405
3416
|
let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
|
|
3406
3417
|
if(defaultSearchableFields){
|
|
@@ -3427,7 +3438,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3427
3438
|
setData({ showFieldsFilter: false });
|
|
3428
3439
|
}
|
|
3429
3440
|
else{
|
|
3430
|
-
|
|
3441
|
+
console.log("===listViewPropsStoreKey=data==", data);
|
|
3442
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
|
|
3443
|
+
console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
|
|
3431
3444
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3432
3445
|
if(localListViewProps){
|
|
3433
3446
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3473,7 +3486,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3473
3486
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3474
3487
|
}
|
|
3475
3488
|
else{
|
|
3476
|
-
searchableFieldsStoreKey += listViewId;
|
|
3489
|
+
searchableFieldsStoreKey += (listViewId || "");
|
|
3477
3490
|
}
|
|
3478
3491
|
sessionStorage.setItem(searchableFieldsStoreKey, value);
|
|
3479
3492
|
|
|
@@ -3531,7 +3544,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3531
3544
|
}
|
|
3532
3545
|
|
|
3533
3546
|
// 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
|
|
3534
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
3547
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
3535
3548
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3536
3549
|
if(localListViewProps){
|
|
3537
3550
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3650,7 +3663,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3650
3663
|
const fields = uiSchema.fields;
|
|
3651
3664
|
const options = (payload.data?.options || []).filter(function(item){
|
|
3652
3665
|
let field = fields[item.value];
|
|
3653
|
-
|
|
3666
|
+
// TODO: 暂时禁用location类型字段的列表搜索
|
|
3667
|
+
return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'
|
|
3654
3668
|
});
|
|
3655
3669
|
payload.data = {
|
|
3656
3670
|
"options": options
|
|
@@ -5253,6 +5267,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
5253
5267
|
|
|
5254
5268
|
function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
|
|
5255
5269
|
// console.log(`getObjectHeaderToolbar====>`, filterVisible)
|
|
5270
|
+
console.log(`getObjectHeaderToolbar`, mainObject);
|
|
5256
5271
|
const isMobile = window.innerWidth < 768;
|
|
5257
5272
|
if(isMobile){
|
|
5258
5273
|
showDisplayAs = false;
|
|
@@ -5352,7 +5367,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5352
5367
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
5353
5368
|
},
|
|
5354
5369
|
// getExportExcelToolbarButtonSchema(),
|
|
5355
|
-
getSettingListviewToolbarButtonSchema(),
|
|
5370
|
+
mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
|
|
5356
5371
|
getDisplayAsButton(mainObject?.name),
|
|
5357
5372
|
filterVisible ? {
|
|
5358
5373
|
"label": i18next__default["default"].t('frontend_button_search_tooltip'),
|
|
@@ -7192,12 +7207,35 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7192
7207
|
}
|
|
7193
7208
|
}
|
|
7194
7209
|
|
|
7210
|
+
const coordinatesType = field.coordinatesType || "bd09";
|
|
7195
7211
|
convertData = {
|
|
7196
7212
|
type: getAmisStaticFieldType('location', readonly),
|
|
7197
7213
|
tpl: readonly ? getLocationTpl(field) : null,
|
|
7198
7214
|
ak,
|
|
7199
7215
|
vendor,
|
|
7200
|
-
|
|
7216
|
+
clearable: true,
|
|
7217
|
+
coordinatesType,
|
|
7218
|
+
label: field.label,
|
|
7219
|
+
pipeOut: (value, oldValue, data) => {
|
|
7220
|
+
if (value) {
|
|
7221
|
+
const lng = value.lng;
|
|
7222
|
+
const lat = value.lat;
|
|
7223
|
+
let coordinates = [lng,lat];
|
|
7224
|
+
if(window.coordtransform){
|
|
7225
|
+
if(coordinatesType.toLowerCase() === 'bd09'){
|
|
7226
|
+
const bd09togcj02 = window.coordtransform.bd09togcj02(lng,lat);
|
|
7227
|
+
coordinates = window.coordtransform.gcj02towgs84(bd09togcj02[0],bd09togcj02[1]);
|
|
7228
|
+
}else if(coordinatesType.toLowerCase() === 'gcj02'){
|
|
7229
|
+
coordinates = window.coordtransform.gcj02towgs84(lng,lat);
|
|
7230
|
+
}
|
|
7231
|
+
}
|
|
7232
|
+
value.wgs84 = {
|
|
7233
|
+
type: "Point",
|
|
7234
|
+
coordinates
|
|
7235
|
+
};
|
|
7236
|
+
return value; // 切换到数字之后的默认值
|
|
7237
|
+
}
|
|
7238
|
+
}
|
|
7201
7239
|
};
|
|
7202
7240
|
break;
|
|
7203
7241
|
case 'avatar':
|
|
@@ -7665,6 +7703,10 @@ async function getQuickEditSchema(field, options){
|
|
|
7665
7703
|
if(field.type == "file" && field.multiple){
|
|
7666
7704
|
quickEditSchema = false;
|
|
7667
7705
|
}
|
|
7706
|
+
//TODO:location字段在列表中快速编辑后存在bug,保存时可能会丢失部分数据,暂时禁用
|
|
7707
|
+
if(field.type == "location"){
|
|
7708
|
+
quickEditSchema = false;
|
|
7709
|
+
}
|
|
7668
7710
|
}
|
|
7669
7711
|
return quickEditSchema;
|
|
7670
7712
|
}
|
|
@@ -8219,7 +8261,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8219
8261
|
try{
|
|
8220
8262
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8221
8263
|
const listViewId = api.data.listViewId;
|
|
8222
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
8264
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
8223
8265
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
8224
8266
|
if(localListViewProps){
|
|
8225
8267
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -8420,7 +8462,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8420
8462
|
try{
|
|
8421
8463
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8422
8464
|
const listViewId = api.body.listViewId;
|
|
8423
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
8465
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
8424
8466
|
/**
|
|
8425
8467
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
8426
8468
|
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
@@ -10389,7 +10431,7 @@ async function getRelatedListSchema(
|
|
|
10389
10431
|
* @Author: baozhoutao@steedos.com
|
|
10390
10432
|
* @Date: 2022-07-05 15:55:39
|
|
10391
10433
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
10392
|
-
* @LastEditTime: 2023-
|
|
10434
|
+
* @LastEditTime: 2023-08-01 14:50:23
|
|
10393
10435
|
* @Description:
|
|
10394
10436
|
*/
|
|
10395
10437
|
|
|
@@ -10654,7 +10696,7 @@ async function getListSchema(
|
|
|
10654
10696
|
* 本次存储代码段
|
|
10655
10697
|
*/
|
|
10656
10698
|
try {
|
|
10657
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + ctx.listViewId;
|
|
10699
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
|
|
10658
10700
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
10659
10701
|
/**
|
|
10660
10702
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
@@ -10723,6 +10765,7 @@ async function getListSchema(
|
|
|
10723
10765
|
"filterVisible": ctx.filterVisible,
|
|
10724
10766
|
"rowClassNameExpr": ctx.rowClassNameExpr
|
|
10725
10767
|
};
|
|
10768
|
+
// console.log(`getListSchema===>`,amisSchema)
|
|
10726
10769
|
return {
|
|
10727
10770
|
uiSchema,
|
|
10728
10771
|
amisSchema,
|
|
@@ -10736,7 +10779,7 @@ async function getTableSchema(
|
|
|
10736
10779
|
columns,
|
|
10737
10780
|
ctx = {}
|
|
10738
10781
|
) {
|
|
10739
|
-
// console.time('getTableSchema');
|
|
10782
|
+
// console.time('getTableSchema', columns);
|
|
10740
10783
|
const uiSchema = await getUISchema(objectName);
|
|
10741
10784
|
|
|
10742
10785
|
let sort = ctx.sort;
|
|
@@ -10750,19 +10793,52 @@ async function getTableSchema(
|
|
|
10750
10793
|
}
|
|
10751
10794
|
|
|
10752
10795
|
let fields = [];
|
|
10753
|
-
|
|
10754
|
-
if (_$1.isString(column)
|
|
10755
|
-
|
|
10756
|
-
|
|
10757
|
-
|
|
10758
|
-
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
10763
|
-
|
|
10796
|
+
for(const column of columns){
|
|
10797
|
+
if (_$1.isString(column)) {
|
|
10798
|
+
if(column.indexOf('.') > 0){
|
|
10799
|
+
const fieldName = column.split('.')[0];
|
|
10800
|
+
const displayName = column.split('.')[1];
|
|
10801
|
+
const filedInfo = uiSchema.fields[fieldName];
|
|
10802
|
+
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to) ){
|
|
10803
|
+
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10804
|
+
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10805
|
+
fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
|
|
10806
|
+
}
|
|
10807
|
+
}else {
|
|
10808
|
+
if(uiSchema.fields[column]){
|
|
10809
|
+
fields.push(uiSchema.fields[column]);
|
|
10810
|
+
}
|
|
10811
|
+
}
|
|
10812
|
+
} else if (_$1.isObject(column)) {
|
|
10813
|
+
if(column.field.indexOf('.') > 0){
|
|
10814
|
+
const fieldName = column.field.split('.')[0];
|
|
10815
|
+
const displayName = column.field.split('.')[1];
|
|
10816
|
+
const filedInfo = uiSchema.fields[fieldName];
|
|
10817
|
+
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to) ){
|
|
10818
|
+
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10819
|
+
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10820
|
+
fields.push(Object.assign({}, rfFieldInfo,
|
|
10821
|
+
{name: column.field, expand: true, expandInfo: {fieldName, displayName}},
|
|
10822
|
+
{
|
|
10823
|
+
width: column.width,
|
|
10824
|
+
wrap: column.wrap, // wrap = true 是没效果的
|
|
10825
|
+
amis: column.amis
|
|
10826
|
+
}
|
|
10827
|
+
));
|
|
10828
|
+
}
|
|
10829
|
+
}else {
|
|
10830
|
+
if(uiSchema.fields[column.field]){
|
|
10831
|
+
fields.push(
|
|
10832
|
+
Object.assign({}, uiSchema.fields[column.field], {
|
|
10833
|
+
width: column.width,
|
|
10834
|
+
wrap: column.wrap, // wrap = true 是没效果的
|
|
10835
|
+
amis: column.amis
|
|
10836
|
+
})
|
|
10837
|
+
);
|
|
10838
|
+
}
|
|
10839
|
+
}
|
|
10764
10840
|
}
|
|
10765
|
-
}
|
|
10841
|
+
}
|
|
10766
10842
|
|
|
10767
10843
|
const extraColumns = ctx.extraColumns;
|
|
10768
10844
|
|