@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.esm.js
CHANGED
|
@@ -625,9 +625,10 @@ async function getFieldTpl (field, options){
|
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
-
async function getFieldsTemplate(fields,
|
|
629
|
-
|
|
630
|
-
|
|
628
|
+
async function getFieldsTemplate(fields, display){
|
|
629
|
+
let expandFields = [];
|
|
630
|
+
if(display != false){
|
|
631
|
+
display = true;
|
|
631
632
|
}
|
|
632
633
|
let fieldsName = ['_id'];
|
|
633
634
|
let displayFields = [];
|
|
@@ -639,33 +640,43 @@ async function getFieldsTemplate(fields, expand){
|
|
|
639
640
|
}
|
|
640
641
|
for (const field of fieldsArr) {
|
|
641
642
|
//graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
|
|
642
|
-
if(field.
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
643
|
+
if(field.expand){
|
|
644
|
+
expandFields.push(field);
|
|
645
|
+
}else {
|
|
646
|
+
if(field.name.indexOf('.') < 0){
|
|
647
|
+
if(display && (field.type == 'lookup' || field.type == 'master_detail')){
|
|
648
|
+
fieldsName.push(`${field.name}`);
|
|
649
|
+
displayFields.push(`${field.name}`);
|
|
650
|
+
}else {
|
|
651
|
+
fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
|
|
652
|
+
}
|
|
653
|
+
if(includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
654
|
+
fieldsName.push(`${field.name}`);
|
|
655
|
+
}
|
|
656
|
+
if(includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
657
|
+
displayFields.push(`${field.name}`);
|
|
658
|
+
}
|
|
646
659
|
}else {
|
|
647
|
-
|
|
660
|
+
objectFieldName = field.name.split('.')[0];
|
|
661
|
+
fieldsName.push(objectFieldName);
|
|
662
|
+
displayFields.push(objectFieldName);
|
|
648
663
|
}
|
|
649
|
-
if(includes(['time','date','datetime','boolean','number','currency'], field.type)){
|
|
650
|
-
fieldsName.push(`${field.name}`);
|
|
651
|
-
}
|
|
652
|
-
if(includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
|
|
653
|
-
displayFields.push(`${field.name}`);
|
|
654
|
-
}
|
|
655
|
-
}else {
|
|
656
|
-
objectFieldName = field.name.split('.')[0];
|
|
657
|
-
fieldsName.push(objectFieldName);
|
|
658
|
-
displayFields.push(objectFieldName);
|
|
659
664
|
}
|
|
660
665
|
}
|
|
661
666
|
|
|
662
667
|
displayFields = _$1.uniq(displayFields);
|
|
663
668
|
fieldsName = _$1.uniq(fieldsName);
|
|
669
|
+
let expandFieldsQuery = "";
|
|
670
|
+
if(expandFields.length > 0){
|
|
671
|
+
_$1.each(expandFields, function(field){
|
|
672
|
+
expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
|
|
673
|
+
});
|
|
674
|
+
}
|
|
664
675
|
|
|
665
676
|
if(displayFields.length > 0){
|
|
666
|
-
return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
|
|
677
|
+
return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
|
|
667
678
|
}
|
|
668
|
-
return `${fieldsName.join(' ')}`
|
|
679
|
+
return `${fieldsName.join(' ')},${expandFieldsQuery}`
|
|
669
680
|
}
|
|
670
681
|
|
|
671
682
|
function getRecordPermissionsTemplate(){
|
|
@@ -3341,7 +3352,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3341
3352
|
if(!event.data.isLookup){
|
|
3342
3353
|
// 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
|
|
3343
3354
|
const listViewId = event.data.listViewId;
|
|
3344
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
3355
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
3345
3356
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3346
3357
|
if(localListViewProps){
|
|
3347
3358
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3373,7 +3384,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3373
3384
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3374
3385
|
}
|
|
3375
3386
|
else{
|
|
3376
|
-
searchableFieldsStoreKey += listViewId;
|
|
3387
|
+
searchableFieldsStoreKey += (listViewId || "");
|
|
3377
3388
|
}
|
|
3378
3389
|
let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
|
|
3379
3390
|
if(defaultSearchableFields){
|
|
@@ -3400,7 +3411,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3400
3411
|
setData({ showFieldsFilter: false });
|
|
3401
3412
|
}
|
|
3402
3413
|
else{
|
|
3403
|
-
|
|
3414
|
+
console.log("===listViewPropsStoreKey=data==", data);
|
|
3415
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
|
|
3416
|
+
console.log("===listViewPropsStoreKey=122==", listViewPropsStoreKey);
|
|
3404
3417
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3405
3418
|
if(localListViewProps){
|
|
3406
3419
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3446,7 +3459,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3446
3459
|
searchableFieldsStoreKey += "lookup/" + objectName;
|
|
3447
3460
|
}
|
|
3448
3461
|
else{
|
|
3449
|
-
searchableFieldsStoreKey += listViewId;
|
|
3462
|
+
searchableFieldsStoreKey += (listViewId || "");
|
|
3450
3463
|
}
|
|
3451
3464
|
sessionStorage.setItem(searchableFieldsStoreKey, value);
|
|
3452
3465
|
|
|
@@ -3504,7 +3517,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3504
3517
|
}
|
|
3505
3518
|
|
|
3506
3519
|
// 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
|
|
3507
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
3520
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
3508
3521
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
3509
3522
|
if(localListViewProps){
|
|
3510
3523
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -3623,7 +3636,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3623
3636
|
const fields = uiSchema.fields;
|
|
3624
3637
|
const options = (payload.data?.options || []).filter(function(item){
|
|
3625
3638
|
let field = fields[item.value];
|
|
3626
|
-
|
|
3639
|
+
// TODO: 暂时禁用location类型字段的列表搜索
|
|
3640
|
+
return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'
|
|
3627
3641
|
});
|
|
3628
3642
|
payload.data = {
|
|
3629
3643
|
"options": options
|
|
@@ -5226,6 +5240,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
|
|
|
5226
5240
|
|
|
5227
5241
|
function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
|
|
5228
5242
|
// console.log(`getObjectHeaderToolbar====>`, filterVisible)
|
|
5243
|
+
console.log(`getObjectHeaderToolbar`, mainObject);
|
|
5229
5244
|
const isMobile = window.innerWidth < 768;
|
|
5230
5245
|
if(isMobile){
|
|
5231
5246
|
showDisplayAs = false;
|
|
@@ -5325,7 +5340,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
|
|
|
5325
5340
|
"className": "bg-white p-2 rounded border-gray-300 text-gray-500"
|
|
5326
5341
|
},
|
|
5327
5342
|
// getExportExcelToolbarButtonSchema(),
|
|
5328
|
-
getSettingListviewToolbarButtonSchema(),
|
|
5343
|
+
mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
|
|
5329
5344
|
getDisplayAsButton(mainObject?.name),
|
|
5330
5345
|
filterVisible ? {
|
|
5331
5346
|
"label": i18next.t('frontend_button_search_tooltip'),
|
|
@@ -7165,12 +7180,35 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7165
7180
|
}
|
|
7166
7181
|
}
|
|
7167
7182
|
|
|
7183
|
+
const coordinatesType = field.coordinatesType || "bd09";
|
|
7168
7184
|
convertData = {
|
|
7169
7185
|
type: getAmisStaticFieldType('location', readonly),
|
|
7170
7186
|
tpl: readonly ? getLocationTpl(field) : null,
|
|
7171
7187
|
ak,
|
|
7172
7188
|
vendor,
|
|
7173
|
-
|
|
7189
|
+
clearable: true,
|
|
7190
|
+
coordinatesType,
|
|
7191
|
+
label: field.label,
|
|
7192
|
+
pipeOut: (value, oldValue, data) => {
|
|
7193
|
+
if (value) {
|
|
7194
|
+
const lng = value.lng;
|
|
7195
|
+
const lat = value.lat;
|
|
7196
|
+
let coordinates = [lng,lat];
|
|
7197
|
+
if(window.coordtransform){
|
|
7198
|
+
if(coordinatesType.toLowerCase() === 'bd09'){
|
|
7199
|
+
const bd09togcj02 = window.coordtransform.bd09togcj02(lng,lat);
|
|
7200
|
+
coordinates = window.coordtransform.gcj02towgs84(bd09togcj02[0],bd09togcj02[1]);
|
|
7201
|
+
}else if(coordinatesType.toLowerCase() === 'gcj02'){
|
|
7202
|
+
coordinates = window.coordtransform.gcj02towgs84(lng,lat);
|
|
7203
|
+
}
|
|
7204
|
+
}
|
|
7205
|
+
value.wgs84 = {
|
|
7206
|
+
type: "Point",
|
|
7207
|
+
coordinates
|
|
7208
|
+
};
|
|
7209
|
+
return value; // 切换到数字之后的默认值
|
|
7210
|
+
}
|
|
7211
|
+
}
|
|
7174
7212
|
};
|
|
7175
7213
|
break;
|
|
7176
7214
|
case 'avatar':
|
|
@@ -7638,6 +7676,10 @@ async function getQuickEditSchema(field, options){
|
|
|
7638
7676
|
if(field.type == "file" && field.multiple){
|
|
7639
7677
|
quickEditSchema = false;
|
|
7640
7678
|
}
|
|
7679
|
+
//TODO:location字段在列表中快速编辑后存在bug,保存时可能会丢失部分数据,暂时禁用
|
|
7680
|
+
if(field.type == "location"){
|
|
7681
|
+
quickEditSchema = false;
|
|
7682
|
+
}
|
|
7641
7683
|
}
|
|
7642
7684
|
return quickEditSchema;
|
|
7643
7685
|
}
|
|
@@ -8192,7 +8234,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8192
8234
|
try{
|
|
8193
8235
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8194
8236
|
const listViewId = api.data.listViewId;
|
|
8195
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
8237
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
8196
8238
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
8197
8239
|
if(localListViewProps){
|
|
8198
8240
|
localListViewProps = JSON.parse(localListViewProps);
|
|
@@ -8393,7 +8435,7 @@ async function getTableApi(mainObject, fields, options){
|
|
|
8393
8435
|
try{
|
|
8394
8436
|
// TODO: 不应该直接在这里取localStorage,应该从外面传入
|
|
8395
8437
|
const listViewId = api.body.listViewId;
|
|
8396
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
|
|
8438
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
|
|
8397
8439
|
/**
|
|
8398
8440
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
8399
8441
|
* 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
|
|
@@ -10362,7 +10404,7 @@ async function getRelatedListSchema(
|
|
|
10362
10404
|
* @Author: baozhoutao@steedos.com
|
|
10363
10405
|
* @Date: 2022-07-05 15:55:39
|
|
10364
10406
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
10365
|
-
* @LastEditTime: 2023-
|
|
10407
|
+
* @LastEditTime: 2023-08-01 14:50:23
|
|
10366
10408
|
* @Description:
|
|
10367
10409
|
*/
|
|
10368
10410
|
|
|
@@ -10627,7 +10669,7 @@ async function getListSchema(
|
|
|
10627
10669
|
* 本次存储代码段
|
|
10628
10670
|
*/
|
|
10629
10671
|
try {
|
|
10630
|
-
const listViewPropsStoreKey = location.pathname + "/crud/" + ctx.listViewId;
|
|
10672
|
+
const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
|
|
10631
10673
|
let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
|
|
10632
10674
|
/**
|
|
10633
10675
|
* localListViewProps规范来自crud请求api中api.data.$self参数值的。
|
|
@@ -10696,6 +10738,7 @@ async function getListSchema(
|
|
|
10696
10738
|
"filterVisible": ctx.filterVisible,
|
|
10697
10739
|
"rowClassNameExpr": ctx.rowClassNameExpr
|
|
10698
10740
|
};
|
|
10741
|
+
// console.log(`getListSchema===>`,amisSchema)
|
|
10699
10742
|
return {
|
|
10700
10743
|
uiSchema,
|
|
10701
10744
|
amisSchema,
|
|
@@ -10709,7 +10752,7 @@ async function getTableSchema(
|
|
|
10709
10752
|
columns,
|
|
10710
10753
|
ctx = {}
|
|
10711
10754
|
) {
|
|
10712
|
-
// console.time('getTableSchema');
|
|
10755
|
+
// console.time('getTableSchema', columns);
|
|
10713
10756
|
const uiSchema = await getUISchema(objectName);
|
|
10714
10757
|
|
|
10715
10758
|
let sort = ctx.sort;
|
|
@@ -10723,19 +10766,52 @@ async function getTableSchema(
|
|
|
10723
10766
|
}
|
|
10724
10767
|
|
|
10725
10768
|
let fields = [];
|
|
10726
|
-
|
|
10727
|
-
if (isString(column)
|
|
10728
|
-
|
|
10729
|
-
|
|
10730
|
-
|
|
10731
|
-
|
|
10732
|
-
|
|
10733
|
-
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
10769
|
+
for(const column of columns){
|
|
10770
|
+
if (isString(column)) {
|
|
10771
|
+
if(column.indexOf('.') > 0){
|
|
10772
|
+
const fieldName = column.split('.')[0];
|
|
10773
|
+
const displayName = column.split('.')[1];
|
|
10774
|
+
const filedInfo = uiSchema.fields[fieldName];
|
|
10775
|
+
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to) ){
|
|
10776
|
+
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10777
|
+
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10778
|
+
fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
|
|
10779
|
+
}
|
|
10780
|
+
}else {
|
|
10781
|
+
if(uiSchema.fields[column]){
|
|
10782
|
+
fields.push(uiSchema.fields[column]);
|
|
10783
|
+
}
|
|
10784
|
+
}
|
|
10785
|
+
} else if (isObject$1(column)) {
|
|
10786
|
+
if(column.field.indexOf('.') > 0){
|
|
10787
|
+
const fieldName = column.field.split('.')[0];
|
|
10788
|
+
const displayName = column.field.split('.')[1];
|
|
10789
|
+
const filedInfo = uiSchema.fields[fieldName];
|
|
10790
|
+
if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to) ){
|
|
10791
|
+
const rfUiSchema = await getUISchema(filedInfo.reference_to);
|
|
10792
|
+
const rfFieldInfo = rfUiSchema.fields[displayName];
|
|
10793
|
+
fields.push(Object.assign({}, rfFieldInfo,
|
|
10794
|
+
{name: column.field, expand: true, expandInfo: {fieldName, displayName}},
|
|
10795
|
+
{
|
|
10796
|
+
width: column.width,
|
|
10797
|
+
wrap: column.wrap, // wrap = true 是没效果的
|
|
10798
|
+
amis: column.amis
|
|
10799
|
+
}
|
|
10800
|
+
));
|
|
10801
|
+
}
|
|
10802
|
+
}else {
|
|
10803
|
+
if(uiSchema.fields[column.field]){
|
|
10804
|
+
fields.push(
|
|
10805
|
+
Object.assign({}, uiSchema.fields[column.field], {
|
|
10806
|
+
width: column.width,
|
|
10807
|
+
wrap: column.wrap, // wrap = true 是没效果的
|
|
10808
|
+
amis: column.amis
|
|
10809
|
+
})
|
|
10810
|
+
);
|
|
10811
|
+
}
|
|
10812
|
+
}
|
|
10737
10813
|
}
|
|
10738
|
-
}
|
|
10814
|
+
}
|
|
10739
10815
|
|
|
10740
10816
|
const extraColumns = ctx.extraColumns;
|
|
10741
10817
|
|