@steedos-widgets/amis-lib 1.3.0-beta.14 → 1.3.0-beta.15
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 +60 -34
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +60 -34
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +15 -13
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/header.d.ts +7 -1
- package/dist/types/lib/converter/amis/util.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -382,8 +382,8 @@ const Router = {
|
|
|
382
382
|
/*
|
|
383
383
|
* @Author: baozhoutao@steedos.com
|
|
384
384
|
* @Date: 2022-07-20 16:29:22
|
|
385
|
-
* @LastEditors:
|
|
386
|
-
* @LastEditTime: 2023-
|
|
385
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
386
|
+
* @LastEditTime: 2023-09-06 18:59:40
|
|
387
387
|
* @Description:
|
|
388
388
|
*/
|
|
389
389
|
|
|
@@ -396,6 +396,32 @@ function getContrastColor(bgColor) {
|
|
|
396
396
|
return brightness < 128 ? "#ffffff" : "#000000";
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
+
function getLookupListView(refObjectConfig) {
|
|
400
|
+
const listNameAll = "all";
|
|
401
|
+
const listNameLookup = "lookup";
|
|
402
|
+
let listViewAll, listViewLookup;
|
|
403
|
+
|
|
404
|
+
_.each(
|
|
405
|
+
refObjectConfig.list_views,
|
|
406
|
+
(view, name) => {
|
|
407
|
+
if (name === listNameAll) {
|
|
408
|
+
listViewAll = view;
|
|
409
|
+
if(!listViewAll.name){
|
|
410
|
+
listViewAll.name = name;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
else if (name === listNameLookup) {
|
|
414
|
+
listViewLookup = view;
|
|
415
|
+
if(!listViewLookup.name){
|
|
416
|
+
listViewLookup.name = name;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
);
|
|
421
|
+
let listView = listViewLookup || listViewAll;
|
|
422
|
+
return listView;
|
|
423
|
+
}
|
|
424
|
+
|
|
399
425
|
/*
|
|
400
426
|
* @Author: baozhoutao@steedos.com
|
|
401
427
|
* @Date: 2022-05-23 09:53:08
|
|
@@ -1653,10 +1679,7 @@ async function getSearchApi(field, ctx) {
|
|
|
1653
1679
|
}
|
|
1654
1680
|
|
|
1655
1681
|
function getRefListViewSort$1(refObject){
|
|
1656
|
-
|
|
1657
|
-
refObject.list_views,
|
|
1658
|
-
(view, name) => name === "all"
|
|
1659
|
-
);
|
|
1682
|
+
let listView = getLookupListView(refObject);
|
|
1660
1683
|
let sort = "";
|
|
1661
1684
|
if(listView){
|
|
1662
1685
|
sort = getListViewSort(listView);
|
|
@@ -3591,6 +3614,10 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
|
|
|
3591
3614
|
each(
|
|
3592
3615
|
objectSchema.list_views,
|
|
3593
3616
|
(listView, name) => {
|
|
3617
|
+
if(name === "lookup"){
|
|
3618
|
+
// 内置lookup为弹出选择专用视图,不显示在列表切换区域
|
|
3619
|
+
return;
|
|
3620
|
+
}
|
|
3594
3621
|
listViewButtonOptions.push({
|
|
3595
3622
|
type: "button",
|
|
3596
3623
|
label: listView.label,
|
|
@@ -5454,10 +5481,8 @@ async function getDeferApi(field, ctx) {
|
|
|
5454
5481
|
}
|
|
5455
5482
|
|
|
5456
5483
|
function getRefListViewSort(refObject){
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
(view, name) => name === "all"
|
|
5460
|
-
);
|
|
5484
|
+
let listView = getLookupListView(refObject);
|
|
5485
|
+
|
|
5461
5486
|
let sort = "";
|
|
5462
5487
|
if(listView){
|
|
5463
5488
|
sort = getListViewSort(listView);
|
|
@@ -5674,19 +5699,14 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5674
5699
|
ctx.objectName = refObjectConfig.name;
|
|
5675
5700
|
|
|
5676
5701
|
let tableFields = [];
|
|
5677
|
-
let i = 0;
|
|
5678
5702
|
const searchableFields = [];
|
|
5679
5703
|
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
const listName = "all";
|
|
5704
|
+
let fieldsArr = [];
|
|
5683
5705
|
|
|
5684
5706
|
const isMobile = window.innerWidth < 768;
|
|
5685
5707
|
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
(listView, name) => name === listName
|
|
5689
|
-
);
|
|
5708
|
+
let listView = getLookupListView(refObjectConfig);
|
|
5709
|
+
let listName = listView && listView.name;
|
|
5690
5710
|
if (listView && listView.columns) {
|
|
5691
5711
|
_$1.each(listView.columns, function (column) {
|
|
5692
5712
|
if (_$1.isString(column) && refObjectConfig.fields[column]) {
|
|
@@ -5701,7 +5721,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5701
5721
|
}
|
|
5702
5722
|
});
|
|
5703
5723
|
}else {
|
|
5704
|
-
_$1.each(refObjectConfig.fields
|
|
5724
|
+
_$1.each(refObjectConfig.fields, (field, field_name)=>{
|
|
5705
5725
|
if(field_name != '_id' && !field.hidden){
|
|
5706
5726
|
if(!_$1.has(field, "name")){
|
|
5707
5727
|
field.name = field_name;
|
|
@@ -5709,16 +5729,15 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
5709
5729
|
fieldsArr.push(field);
|
|
5710
5730
|
}
|
|
5711
5731
|
});
|
|
5732
|
+
// 没有视图权限时,取对象上前5个字段,按sort_no排序
|
|
5733
|
+
fieldsArr = _$1.sortBy(fieldsArr, "sort_no").slice(0,5);
|
|
5712
5734
|
}
|
|
5713
5735
|
|
|
5714
|
-
_$1.each(
|
|
5715
|
-
if(
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
i++;
|
|
5720
|
-
tableFields.push(field);
|
|
5721
|
-
}
|
|
5736
|
+
_$1.each(fieldsArr,function(field){
|
|
5737
|
+
if(!_$1.find(tableFields, function(f){
|
|
5738
|
+
return f.name === field.name
|
|
5739
|
+
})){
|
|
5740
|
+
tableFields.push(field);
|
|
5722
5741
|
}
|
|
5723
5742
|
});
|
|
5724
5743
|
|
|
@@ -6105,10 +6124,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
6105
6124
|
}
|
|
6106
6125
|
|
|
6107
6126
|
const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
|
|
6108
|
-
|
|
6109
|
-
refObjectConfig.list_views,
|
|
6110
|
-
(listView, name) => name === "all"
|
|
6111
|
-
);
|
|
6127
|
+
let listView = getLookupListView(refObjectConfig);
|
|
6112
6128
|
|
|
6113
6129
|
let sort = "";
|
|
6114
6130
|
if(listView){
|
|
@@ -6343,7 +6359,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6343
6359
|
|
|
6344
6360
|
const tableFields = [referenceTo.labelField];
|
|
6345
6361
|
|
|
6346
|
-
const source = await getApi$1(refObjectConfig, null, fields, {expand: true, alias: 'rows', queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}`});
|
|
6362
|
+
const source = await getApi$1(refObjectConfig, null, fields, {expand: true, alias: 'rows', queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
|
|
6347
6363
|
|
|
6348
6364
|
source.data.$term = "$term";
|
|
6349
6365
|
source.data.$self = "$$";
|
|
@@ -6352,6 +6368,12 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6352
6368
|
source.sendOn = `\${${idsDependOn} && ${idsDependOn}.length}`;
|
|
6353
6369
|
source.url = `${source.url}&depend_on_${idsDependOn}=\${${idsDependOn}|join}`;
|
|
6354
6370
|
}
|
|
6371
|
+
|
|
6372
|
+
let listView = getLookupListView(refObjectConfig);
|
|
6373
|
+
let sort = "";
|
|
6374
|
+
if(listView){
|
|
6375
|
+
sort = getListViewSort(listView);
|
|
6376
|
+
}
|
|
6355
6377
|
|
|
6356
6378
|
source.requestAdaptor = `
|
|
6357
6379
|
const selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
@@ -6359,6 +6381,10 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6359
6381
|
var pageSize = api.data.pageSize || 1000;
|
|
6360
6382
|
var pageNo = api.data.pageNo || 1;
|
|
6361
6383
|
var skip = (pageNo - 1) * pageSize;
|
|
6384
|
+
var orderBy = api.data.orderBy || '';
|
|
6385
|
+
var orderDir = api.data.orderDir || '';
|
|
6386
|
+
var sort = orderBy + ' ' + orderDir;
|
|
6387
|
+
sort = orderBy ? sort : "${sort}";
|
|
6362
6388
|
if(selfData.op === 'loadOptions' && selfData.value){
|
|
6363
6389
|
if(selfData.value && selfData.value.indexOf(',') > 0){
|
|
6364
6390
|
filters = [["${referenceTo.valueField.name}", "=", selfData.value.split(',')]];
|
|
@@ -6376,7 +6402,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6376
6402
|
filters.push(["${referenceTo.valueField.name}", "=", ids]);
|
|
6377
6403
|
}
|
|
6378
6404
|
|
|
6379
|
-
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip);
|
|
6405
|
+
api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());
|
|
6380
6406
|
return api;
|
|
6381
6407
|
`;
|
|
6382
6408
|
|
|
@@ -8881,7 +8907,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
8881
8907
|
var defaultValues = {};
|
|
8882
8908
|
_.each(uiSchema && uiSchema.fields, function(field){
|
|
8883
8909
|
var value = SteedosUI.getFieldDefaultValue(field, api.body.global);
|
|
8884
|
-
if(value){
|
|
8910
|
+
if(!_.isNil(value)){
|
|
8885
8911
|
defaultValues[field.name] = value;
|
|
8886
8912
|
}
|
|
8887
8913
|
});
|