@steedos-widgets/amis-lib 1.3.0-beta.13 → 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 +79 -46
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +79 -46
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +26 -23
- 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
|
|
@@ -968,7 +994,7 @@ function getApi$2 (isMobile){
|
|
|
968
994
|
}
|
|
969
995
|
}
|
|
970
996
|
|
|
971
|
-
var frontend_field_group_generalization$1 = "
|
|
997
|
+
var frontend_field_group_generalization$1 = "General";
|
|
972
998
|
var frontend_download$1 = "Download";
|
|
973
999
|
var frontend_form_save$1 = "Save";
|
|
974
1000
|
var frontend_form_save_and_new$1 = "Save and New";
|
|
@@ -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
|
|
|
@@ -6038,8 +6057,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
6038
6057
|
modalTitle: i18next.t('frontend_form_please_select') + " " + refObjectConfig.label,
|
|
6039
6058
|
labelField: referenceTo.labelField.name,
|
|
6040
6059
|
valueField: referenceTo.valueField.name,
|
|
6041
|
-
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey
|
|
6042
|
-
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || (this.relatedKey ==='${field.name}') )`,
|
|
6060
|
+
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
|
|
6061
|
+
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
|
|
6043
6062
|
modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
|
|
6044
6063
|
source: source,
|
|
6045
6064
|
size: "lg",
|
|
@@ -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){
|
|
@@ -6219,8 +6235,8 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
6219
6235
|
joinValues: false,
|
|
6220
6236
|
extractValue: true,
|
|
6221
6237
|
clearable: true,
|
|
6222
|
-
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey
|
|
6223
|
-
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || (this.relatedKey ==='${field.name}') )`,
|
|
6238
|
+
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
|
|
6239
|
+
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
|
|
6224
6240
|
// labelField: labelField,
|
|
6225
6241
|
// valueField: valueField,
|
|
6226
6242
|
source: apiInfo,
|
|
@@ -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
|
|
|
@@ -6407,8 +6433,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
|
|
|
6407
6433
|
valueField: referenceTo.valueField.name,
|
|
6408
6434
|
modalMode: 'dialog',
|
|
6409
6435
|
source: source,
|
|
6410
|
-
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey
|
|
6411
|
-
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || (this.relatedKey ==='${field.name}') )`,
|
|
6436
|
+
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
|
|
6437
|
+
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
|
|
6412
6438
|
size: "lg",
|
|
6413
6439
|
pickerSchema: pickerSchema,
|
|
6414
6440
|
joinValues: false,
|
|
@@ -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
|
});
|
|
@@ -9539,14 +9565,15 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
9539
9565
|
/*
|
|
9540
9566
|
* @Author: baozhoutao@steedos.com
|
|
9541
9567
|
* @Date: 2022-05-26 16:02:08
|
|
9542
|
-
* @LastEditors:
|
|
9543
|
-
* @LastEditTime: 2023-
|
|
9568
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
9569
|
+
* @LastEditTime: 2023-09-05 15:42:26
|
|
9544
9570
|
* @Description:
|
|
9545
9571
|
*/
|
|
9546
9572
|
|
|
9547
|
-
const getFieldSchemaArray = (formFields) => {
|
|
9573
|
+
const getFieldSchemaArray = (formFields, ctx) => {
|
|
9548
9574
|
let fieldSchemaArray = [];
|
|
9549
9575
|
fieldSchemaArray.length = 0;
|
|
9576
|
+
const recordId = ctx && ctx.recordId;
|
|
9550
9577
|
|
|
9551
9578
|
_$1.forEach(formFields, (field) => {
|
|
9552
9579
|
if (!field.group || field.group == 'null' || field.group == '-')
|
|
@@ -9558,8 +9585,14 @@ const getFieldSchemaArray = (formFields) => {
|
|
|
9558
9585
|
field.is_wide = true;
|
|
9559
9586
|
}
|
|
9560
9587
|
|
|
9588
|
+
let forceHidden = false;
|
|
9589
|
+
if(!recordId && field.readonly){
|
|
9590
|
+
// 新建记录时,只读字段先隐藏,后续支持显示后,即任务:https://github.com/steedos/steedos-platform/issues/3164 完成后再放开
|
|
9591
|
+
forceHidden = true;
|
|
9592
|
+
}
|
|
9593
|
+
|
|
9561
9594
|
if (!isObjectField) {
|
|
9562
|
-
if (!field.hidden) {
|
|
9595
|
+
if (!field.hidden && !forceHidden) {
|
|
9563
9596
|
fieldSchemaArray.push(Object.assign({ name: fieldName }, field, { permission: { allowEdit: true } }));
|
|
9564
9597
|
}
|
|
9565
9598
|
}
|
|
@@ -9630,7 +9663,7 @@ const getSections = async (permissionFields, formFields, ctx) => {
|
|
|
9630
9663
|
if (!ctx) {
|
|
9631
9664
|
ctx = {};
|
|
9632
9665
|
}
|
|
9633
|
-
const fieldSchemaArray = getFieldSchemaArray(formFields);
|
|
9666
|
+
const fieldSchemaArray = getFieldSchemaArray(formFields, ctx);
|
|
9634
9667
|
const _sections = _$1.groupBy(fieldSchemaArray, 'group');
|
|
9635
9668
|
const sections = [];
|
|
9636
9669
|
var sectionVisibleOns = [];
|