@steedos-widgets/amis-lib 1.3.4-beta.9 → 1.3.6
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 +681 -178
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +681 -179
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +275 -148
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/buttons.d.ts +1 -0
- package/dist/types/lib/converter/amis/api.d.ts +1 -0
- package/dist/types/lib/converter/amis/fields/file.d.ts +4 -8
- package/dist/types/lib/converter/amis/fields/lookup.d.ts +40 -24
- package/dist/types/lib/converter/amis/fields/table.d.ts +20 -0
- package/dist/types/lib/converter/amis/header.d.ts +1 -0
- package/dist/types/lib/converter/amis/index.d.ts +2 -3
- package/dist/types/lib/converter/amis/toolbar.d.ts +10 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview/copy.d.ts +1 -0
- package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +1 -0
- package/dist/types/lib/expression.d.ts +5 -0
- package/dist/types/lib/objects.d.ts +3 -3
- package/dist/types/lib/objectsRelated.d.ts +3 -0
- package/dist/types/lib/page_init.d.ts +1 -3
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -443,8 +443,8 @@ function getLookupListView(refObjectConfig) {
|
|
|
443
443
|
/*
|
|
444
444
|
* @Author: baozhoutao@steedos.com
|
|
445
445
|
* @Date: 2022-05-23 09:53:08
|
|
446
|
-
* @LastEditors:
|
|
447
|
-
* @LastEditTime: 2023-
|
|
446
|
+
* @LastEditors: liaodaxue
|
|
447
|
+
* @LastEditTime: 2023-10-11 17:32:17
|
|
448
448
|
* @Description:
|
|
449
449
|
*/
|
|
450
450
|
|
|
@@ -505,7 +505,7 @@ function getSelectMap(selectOptions){
|
|
|
505
505
|
if(optionColor){
|
|
506
506
|
const background = optionColor.charAt(0) === '#' ? optionColor : '#'+optionColor;
|
|
507
507
|
const color = getContrastColor(background);
|
|
508
|
-
const optionColorStyle = 'background:'+background+';color:'+color;
|
|
508
|
+
const optionColorStyle = 'background:'+background+';color:'+color+';line-height:1.5rem';
|
|
509
509
|
map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
|
|
510
510
|
}else {
|
|
511
511
|
map[optionValue] = option.label;
|
|
@@ -962,17 +962,17 @@ async function getFindQuery(object, recordId, fields, options){
|
|
|
962
962
|
}
|
|
963
963
|
|
|
964
964
|
const countQuery = options.count === false ? "" : `,count:${object.name}__count(filters:{__filters})`;
|
|
965
|
-
const moreQuerie = options.moreQueries?.length ? ("," + options.moreQueries.map(function(item){
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
}).join(",")) : "";
|
|
965
|
+
// const moreQuerie = options.moreQueries?.length ? ("," + options.moreQueries.map(function(item){
|
|
966
|
+
// // 把最外层的{}去除
|
|
967
|
+
// return item.replace(/^{/,"").replace(/}$/,"");
|
|
968
|
+
// }).join(",")) : "";
|
|
969
969
|
|
|
970
970
|
return {
|
|
971
971
|
orderBy: "${orderBy}",
|
|
972
972
|
orderDir: "${orderDir}",
|
|
973
973
|
pageNo: "${page}",
|
|
974
974
|
pageSize: "${perPage}",
|
|
975
|
-
query: `{${alias}:${object.name}${queryOptions}{${await getFieldsTemplate(fields, options.expand)}${treeFields}${cfsFields}}${countQuery}
|
|
975
|
+
query: `{${alias}:${object.name}${queryOptions}{${await getFieldsTemplate(fields, options.expand)}${treeFields}${cfsFields}}${countQuery}}`
|
|
976
976
|
}
|
|
977
977
|
}
|
|
978
978
|
|
|
@@ -1764,6 +1764,13 @@ async function getSelectUserSchema(field, readonly, ctx) {
|
|
|
1764
1764
|
return amisSchema;
|
|
1765
1765
|
}
|
|
1766
1766
|
|
|
1767
|
+
/*
|
|
1768
|
+
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
1769
|
+
* @Date: 2023-03-22 09:31:21
|
|
1770
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
1771
|
+
* @LastEditTime: 2023-11-05 16:31:38
|
|
1772
|
+
*/
|
|
1773
|
+
|
|
1767
1774
|
const globalTag = '__G_L_O_B_A_L__';
|
|
1768
1775
|
|
|
1769
1776
|
const getParentPath = function (path) {
|
|
@@ -1803,7 +1810,43 @@ const isExpression = function (func) {
|
|
|
1803
1810
|
return false;
|
|
1804
1811
|
};
|
|
1805
1812
|
|
|
1813
|
+
const getMoment$1 = () => {
|
|
1814
|
+
if (window.amisRequire) {
|
|
1815
|
+
return window.amisRequire("moment");
|
|
1816
|
+
} else if (window.moment) {
|
|
1817
|
+
return window.moment;
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
|
|
1821
|
+
const getGlobalNowData = () => {
|
|
1822
|
+
let now = new Date();
|
|
1823
|
+
let moment = getMoment$1();
|
|
1824
|
+
let today = moment().utc();
|
|
1825
|
+
today.set("hours", 0);
|
|
1826
|
+
today.set("minutes", 0);
|
|
1827
|
+
today.set("seconds", 0);
|
|
1828
|
+
today.set("milliseconds", 0);
|
|
1829
|
+
today = today.toDate();
|
|
1830
|
+
let timeNow = moment();
|
|
1831
|
+
timeNow.set("year", 1970);
|
|
1832
|
+
timeNow.set("month", 0);
|
|
1833
|
+
timeNow.set("date", 1);
|
|
1834
|
+
timeNow.set("hours", timeNow.hours() + timeNow.utcOffset() / 60);
|
|
1835
|
+
timeNow.set("seconds", 0);
|
|
1836
|
+
timeNow.set("milliseconds", 0);
|
|
1837
|
+
timeNow = timeNow.toDate();
|
|
1838
|
+
return {
|
|
1839
|
+
now,
|
|
1840
|
+
today,
|
|
1841
|
+
timeNow
|
|
1842
|
+
};
|
|
1843
|
+
};
|
|
1844
|
+
|
|
1806
1845
|
const parseSingleExpression = function (func, formData, dataPath, global, userSession = {}) {
|
|
1846
|
+
if (global) {
|
|
1847
|
+
Object.assign(global, getGlobalNowData());
|
|
1848
|
+
}
|
|
1849
|
+
|
|
1807
1850
|
var error, funcBody, parent, parentPath, str;
|
|
1808
1851
|
|
|
1809
1852
|
if (formData === void 0) {
|
|
@@ -2570,20 +2613,29 @@ function getButtonVisibleOn$1(button){
|
|
|
2570
2613
|
// return 'false';
|
|
2571
2614
|
// }
|
|
2572
2615
|
if(visible.trim().startsWith('function')){
|
|
2573
|
-
|
|
2616
|
+
visible = `${visible}.apply({
|
|
2574
2617
|
object: uiSchema
|
|
2575
|
-
}, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])
|
|
2618
|
+
}, [objectName, typeof _id === 'undefined' ? null: _id, typeof record === 'undefined' ? (typeof recordPermissions === 'undefined' ? {} : recordPermissions) : record.recordPermissions, data])`;
|
|
2576
2619
|
}
|
|
2577
|
-
return visible;
|
|
2578
2620
|
}
|
|
2579
2621
|
|
|
2580
2622
|
if(button.type === 'amis_button'){
|
|
2581
|
-
|
|
2623
|
+
let amisSchema = button.amis_schema;
|
|
2624
|
+
if(_$1.isString(amisSchema)){
|
|
2625
|
+
amisSchema = JSON.parse(amisSchema);
|
|
2626
|
+
}
|
|
2582
2627
|
if(amisSchema && amisSchema.body && amisSchema.body.length > 0){
|
|
2583
2628
|
const btn1 = amisSchema.body[0];
|
|
2584
|
-
|
|
2629
|
+
if(_$1.hasIn(btn1, 'visibleOn')){
|
|
2630
|
+
/* 当含有“更多”按钮或者“下拉”箭头按钮时,单个按钮的visibleOn需要合并到 “更多”按钮或者“下拉”箭头按钮的 visibleOn 中,用||隔开。
|
|
2631
|
+
visibleOn的格式需要保持一致; 不能是 js 和 ${xxx} 混合的表达式;
|
|
2632
|
+
visibleOn的值需要是js格式,因为默认的编辑、删除等系统按钮的visibleOn的格式就是js格式(function(){});
|
|
2633
|
+
*/
|
|
2634
|
+
return btn1.visibleOn
|
|
2635
|
+
}
|
|
2585
2636
|
}
|
|
2586
2637
|
}
|
|
2638
|
+
return visible;
|
|
2587
2639
|
}
|
|
2588
2640
|
|
|
2589
2641
|
const getButtonVisible = (button, ctx) => {
|
|
@@ -2909,9 +2961,30 @@ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
|
|
|
2909
2961
|
const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
|
|
2910
2962
|
const { buttons, moreButtons, moreButtonsVisibleOn } = getObjectDetailHeaderButtons(objectSchema, recordId);
|
|
2911
2963
|
if(ctx.formFactor === 'SMALL'){
|
|
2964
|
+
const dropdownButtons = [
|
|
2965
|
+
..._$1.map(buttons, (button) => {
|
|
2966
|
+
button.className += ' w-full';
|
|
2967
|
+
return button;
|
|
2968
|
+
}),
|
|
2969
|
+
..._$1.map(moreButtons, (button) => {
|
|
2970
|
+
button.className += ' w-full';
|
|
2971
|
+
return button;
|
|
2972
|
+
})
|
|
2973
|
+
];
|
|
2974
|
+
|
|
2975
|
+
let phoneMoreButtonsVisibleOn = '';
|
|
2976
|
+
_$1.forEach(dropdownButtons, (button, index) => {
|
|
2977
|
+
if(index === 0){
|
|
2978
|
+
phoneMoreButtonsVisibleOn = button.visibleOn;
|
|
2979
|
+
}else {
|
|
2980
|
+
phoneMoreButtonsVisibleOn = phoneMoreButtonsVisibleOn + ' || ' + button.visibleOn;
|
|
2981
|
+
}
|
|
2982
|
+
});
|
|
2983
|
+
|
|
2912
2984
|
return {
|
|
2913
2985
|
"type": "button",
|
|
2914
2986
|
"icon": "fa fa-angle-down",
|
|
2987
|
+
"visibleOn": phoneMoreButtonsVisibleOn,
|
|
2915
2988
|
"onEvent": {
|
|
2916
2989
|
"click": {
|
|
2917
2990
|
"actions": [
|
|
@@ -2927,16 +3000,7 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
|
|
|
2927
3000
|
"id": "u:fd837823be5b",
|
|
2928
3001
|
"vertical": true,
|
|
2929
3002
|
"tiled": true,
|
|
2930
|
-
"buttons":
|
|
2931
|
-
..._$1.map(buttons, (button)=>{
|
|
2932
|
-
button.className += ' w-full';
|
|
2933
|
-
return button;
|
|
2934
|
-
}),
|
|
2935
|
-
..._$1.map(moreButtons, (button)=>{
|
|
2936
|
-
button.className += ' w-full';
|
|
2937
|
-
return button;
|
|
2938
|
-
})
|
|
2939
|
-
],
|
|
3003
|
+
"buttons": dropdownButtons,
|
|
2940
3004
|
"btnLevel": "enhance",
|
|
2941
3005
|
"className": "w-full",
|
|
2942
3006
|
"btnClassName": "w-full",
|
|
@@ -3243,7 +3307,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3243
3307
|
showFieldsFilter = true;
|
|
3244
3308
|
}
|
|
3245
3309
|
filterService.setData({showFieldsFilter});
|
|
3246
|
-
resizeWindow()
|
|
3310
|
+
// resizeWindow();//已迁移到搜索栏表单提交事件中执行,因为表单项change后也会触发表单提交了
|
|
3247
3311
|
// 使用filterForm.getValues()的话,并不能拿到本地存储中的过滤条件,所以需要从event.data中取。
|
|
3248
3312
|
let filterFormValues = event.data;
|
|
3249
3313
|
let isFieldsFilterEmpty = SteedosUI.isFilterFormValuesEmpty(filterFormValues);
|
|
@@ -3307,7 +3371,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3307
3371
|
if(isLookup){
|
|
3308
3372
|
searchableFieldsStoreKey += "/lookup/" + objectName;
|
|
3309
3373
|
}
|
|
3310
|
-
|
|
3374
|
+
searchableFieldsStoreKey = searchableFieldsStoreKey + "/" + (data.context && data.context.userId);
|
|
3375
|
+
let defaultSearchableFields = localStorage.getItem(searchableFieldsStoreKey);
|
|
3311
3376
|
if(defaultSearchableFields){
|
|
3312
3377
|
defaultSearchableFields = defaultSearchableFields.split(",");
|
|
3313
3378
|
}
|
|
@@ -3376,7 +3441,8 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
3376
3441
|
if(isLookup){
|
|
3377
3442
|
searchableFieldsStoreKey += "/lookup/" + objectName;
|
|
3378
3443
|
}
|
|
3379
|
-
|
|
3444
|
+
searchableFieldsStoreKey = searchableFieldsStoreKey + "/" + (data.context && data.context.userId);
|
|
3445
|
+
localStorage.setItem(searchableFieldsStoreKey, value);
|
|
3380
3446
|
|
|
3381
3447
|
// ===START===:当变更可搜索字段时,如果被移除的可搜索字段在本地存储中已经存入过滤条件中则应该清除本地存储中相关字段的过滤条件。
|
|
3382
3448
|
const searchableFields = data.fields;
|
|
@@ -4342,7 +4408,8 @@ const getCopyListviewButtonSchema = ()=>{
|
|
|
4342
4408
|
"&": "${list_view}",
|
|
4343
4409
|
"name":"",
|
|
4344
4410
|
"label": i18next.t('frontend_listview_control_clone_defaultData_label_start') + " ${list_view.label} " + i18next.t('frontend_listview_control_clone_defaultData_label_end'),
|
|
4345
|
-
"shared":false
|
|
4411
|
+
"shared":false,
|
|
4412
|
+
"object_name": "${targetObjectName}",
|
|
4346
4413
|
},
|
|
4347
4414
|
"fieldsExtend": fieldsExtend$3(),
|
|
4348
4415
|
"fields": fields(),
|
|
@@ -5130,7 +5197,7 @@ let resizeWindow = function(){
|
|
|
5130
5197
|
//触发amis crud 高度重算
|
|
5131
5198
|
setTimeout(()=>{
|
|
5132
5199
|
window.dispatchEvent(new Event("resize"))
|
|
5133
|
-
},
|
|
5200
|
+
}, 1000);
|
|
5134
5201
|
}
|
|
5135
5202
|
resizeWindow();
|
|
5136
5203
|
// 手机端在显示搜索栏时隐藏crud上的刷新按钮,因为点击后crud高度显示有问题
|
|
@@ -5192,7 +5259,8 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
5192
5259
|
"placeholder": "搜索此列表",
|
|
5193
5260
|
"value": crudKeywords,
|
|
5194
5261
|
"clearable": true,
|
|
5195
|
-
"clearAndSubmit": true
|
|
5262
|
+
"clearAndSubmit": true,
|
|
5263
|
+
"searchImediately": true
|
|
5196
5264
|
}
|
|
5197
5265
|
]
|
|
5198
5266
|
}
|
|
@@ -5367,6 +5435,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
5367
5435
|
}
|
|
5368
5436
|
|
|
5369
5437
|
function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
5438
|
+
// crud card模式与table模式两种情况下showPageInput默认值不一样,所以需要显式设置为false
|
|
5370
5439
|
if (formFactor === 'SMALL') {
|
|
5371
5440
|
// return [
|
|
5372
5441
|
// "load-more",
|
|
@@ -5376,14 +5445,17 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
5376
5445
|
"switch-per-page",
|
|
5377
5446
|
{
|
|
5378
5447
|
"type": "pagination",
|
|
5379
|
-
"maxButtons": 5
|
|
5448
|
+
"maxButtons": 5,
|
|
5449
|
+
"showPageInput": false
|
|
5380
5450
|
}
|
|
5381
5451
|
]
|
|
5382
5452
|
}else {
|
|
5383
5453
|
return [
|
|
5454
|
+
// "statistics",
|
|
5384
5455
|
{
|
|
5385
5456
|
"type": "pagination",
|
|
5386
|
-
"maxButtons": 5
|
|
5457
|
+
"maxButtons": 5,
|
|
5458
|
+
"showPageInput": false
|
|
5387
5459
|
}
|
|
5388
5460
|
]
|
|
5389
5461
|
}
|
|
@@ -5392,32 +5464,81 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
5392
5464
|
if(options && options.isRelated){
|
|
5393
5465
|
return [
|
|
5394
5466
|
"statistics",
|
|
5395
|
-
|
|
5467
|
+
{
|
|
5468
|
+
"type": "pagination",
|
|
5469
|
+
"maxButtons": 10,
|
|
5470
|
+
"showPageInput": false
|
|
5471
|
+
}
|
|
5396
5472
|
]
|
|
5397
5473
|
|
|
5398
5474
|
}
|
|
5399
5475
|
else {
|
|
5400
|
-
|
|
5401
|
-
|
|
5476
|
+
const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
|
|
5477
|
+
const is_lookup = options.isLookup;
|
|
5478
|
+
const commonConfig = [
|
|
5402
5479
|
"statistics",
|
|
5403
|
-
|
|
5404
|
-
|
|
5480
|
+
{
|
|
5481
|
+
"type": "pagination",
|
|
5482
|
+
"maxButtons": 10,
|
|
5483
|
+
"showPageInput": false
|
|
5484
|
+
}
|
|
5485
|
+
];
|
|
5486
|
+
|
|
5487
|
+
if (no_pagination && is_lookup) {
|
|
5488
|
+
return commonConfig;
|
|
5489
|
+
} else {
|
|
5490
|
+
return ["switch-per-page", ...commonConfig];
|
|
5491
|
+
}
|
|
5405
5492
|
}
|
|
5406
5493
|
}
|
|
5407
5494
|
}
|
|
5408
5495
|
|
|
5409
5496
|
async function getObjectFilter(objectSchema, fields, options) {
|
|
5410
5497
|
const fieldsFilterBarSchema = await getObjectListHeaderFieldsFilterBar(objectSchema, null, options);
|
|
5498
|
+
let onSubmitSuccScript = `
|
|
5499
|
+
let isLookup = event.data.isLookup;
|
|
5500
|
+
if(isLookup){
|
|
5501
|
+
return;
|
|
5502
|
+
}
|
|
5503
|
+
// 列表搜索栏字段值变更后立刻触发提交表单执行crud搜索,所以这里需要额外重算crud高度及筛选按钮红色星号图标显示隐藏
|
|
5504
|
+
let resizeWindow = function(){
|
|
5505
|
+
//触发amis crud 高度重算
|
|
5506
|
+
setTimeout(()=>{
|
|
5507
|
+
window.dispatchEvent(new Event("resize"))
|
|
5508
|
+
}, 1000);
|
|
5509
|
+
}
|
|
5510
|
+
resizeWindow();
|
|
5511
|
+
const scope = event.context.scoped;
|
|
5512
|
+
// let filterFormValues = event.data;
|
|
5513
|
+
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
5514
|
+
let filterFormService = SteedosUI.getClosestAmisComponentByType(filterForm.context, "service");
|
|
5515
|
+
// 使用event.data的话,并不能拿到本地存储中的过滤条件,所以需要从filterFormService中取。
|
|
5516
|
+
let filterFormValues = filterFormService.getData()
|
|
5517
|
+
let isFieldsFilterEmpty = SteedosUI.isFilterFormValuesEmpty(filterFormValues);
|
|
5518
|
+
let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
|
|
5519
|
+
let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
|
|
5520
|
+
crudService && crudService.setData({isFieldsFilterEmpty});
|
|
5521
|
+
`;
|
|
5411
5522
|
return {
|
|
5412
5523
|
"title": "",
|
|
5413
5524
|
"submitText": "",
|
|
5414
5525
|
"className": "",
|
|
5415
|
-
|
|
5526
|
+
"debug": true,
|
|
5416
5527
|
"mode": "normal",
|
|
5417
5528
|
"wrapWithPanel": false,
|
|
5418
5529
|
"body": [
|
|
5419
5530
|
fieldsFilterBarSchema
|
|
5420
|
-
]
|
|
5531
|
+
],
|
|
5532
|
+
"onEvent": {
|
|
5533
|
+
"submitSucc": {
|
|
5534
|
+
"actions": [
|
|
5535
|
+
{
|
|
5536
|
+
"actionType": "custom",
|
|
5537
|
+
"script": onSubmitSuccScript
|
|
5538
|
+
}
|
|
5539
|
+
]
|
|
5540
|
+
}
|
|
5541
|
+
}
|
|
5421
5542
|
}
|
|
5422
5543
|
}
|
|
5423
5544
|
|
|
@@ -6038,13 +6159,15 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
6038
6159
|
pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { headerToolbarItems, isLookup: true, keywordsSearchBoxName });
|
|
6039
6160
|
const isAllowCreate = refObjectConfig.permissions.allowCreate;
|
|
6040
6161
|
const isCreate = _$1.isBoolean(field.create) ? field.create : true;
|
|
6041
|
-
|
|
6162
|
+
// lookup字段配置过滤条件就强制不显示新建按钮
|
|
6163
|
+
let isHasFilters = (field.filters || field._filtersFunction) ? true : false;
|
|
6164
|
+
if (isAllowCreate && isCreate && !isHasFilters) {
|
|
6042
6165
|
const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
|
|
6043
6166
|
new_button.align = "right";
|
|
6044
6167
|
// 保持快速搜索放在最左侧,新建按钮往里插,而不是push到最后
|
|
6045
6168
|
pickerSchema.headerToolbar.splice(pickerSchema.headerToolbar.length - 1, 0, new_button);
|
|
6046
6169
|
}
|
|
6047
|
-
pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
|
|
6170
|
+
pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar(refObjectConfig,ctx.formFactor,{isLookup: true});
|
|
6048
6171
|
if (ctx.filterVisible !== false) {
|
|
6049
6172
|
pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
|
|
6050
6173
|
...ctx,
|
|
@@ -6172,10 +6295,10 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
6172
6295
|
// const labelFieldKey = referenceTo && referenceTo.labelField?.name || 'name';
|
|
6173
6296
|
|
|
6174
6297
|
let apiInfo;
|
|
6175
|
-
|
|
6298
|
+
let defaultValueOptionsQueryData;
|
|
6176
6299
|
if(referenceTo){
|
|
6177
6300
|
// 字段值单独走一个请求合并到source的同一个GraphQL接口中
|
|
6178
|
-
|
|
6301
|
+
defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
|
|
6179
6302
|
Object.assign({}, referenceTo.labelField, {alias: 'label'}),
|
|
6180
6303
|
Object.assign({}, referenceTo.valueField, {alias: 'value'})
|
|
6181
6304
|
], {
|
|
@@ -6188,7 +6311,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
6188
6311
|
}, null, [
|
|
6189
6312
|
Object.assign({}, referenceTo.labelField, {alias: 'label'}),
|
|
6190
6313
|
Object.assign({}, referenceTo.valueField, {alias: 'value'})
|
|
6191
|
-
], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"
|
|
6314
|
+
], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`});
|
|
6192
6315
|
|
|
6193
6316
|
apiInfo.adaptor = `
|
|
6194
6317
|
const data = payload.data;
|
|
@@ -6282,11 +6405,16 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
6282
6405
|
var optionsFiltersOp = "${field.multiple ? "in" : "="}";
|
|
6283
6406
|
var optionsFilters = [["${valueFieldKey}", optionsFiltersOp, []]];
|
|
6284
6407
|
if (defaultValue && !api.data.$term) {
|
|
6408
|
+
const defaultValueOptionsQueryData = ${JSON.stringify(defaultValueOptionsQueryData)};
|
|
6409
|
+
const defaultValueOptionsQuery = defaultValueOptionsQueryData?.query?.replace(/^{/,"").replace(/}$/,"");
|
|
6285
6410
|
// 字段值单独请求,没值的时候在请求中返回空
|
|
6286
6411
|
optionsFilters = [["${valueFieldKey}", optionsFiltersOp, defaultValue]];
|
|
6287
6412
|
if(filters.length > 0){
|
|
6288
6413
|
optionsFilters = [filters, optionsFilters];
|
|
6289
6414
|
}
|
|
6415
|
+
if(defaultValueOptionsQuery){
|
|
6416
|
+
api.data.query = "{"+api.data.query.replace(/^{/,"").replace(/}$/,"")+","+defaultValueOptionsQuery+"}";
|
|
6417
|
+
}
|
|
6290
6418
|
}
|
|
6291
6419
|
api.data.query = api.data.query.replace(/{__options_filters}/g, JSON.stringify(optionsFilters));
|
|
6292
6420
|
return api;
|
|
@@ -6328,7 +6456,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
6328
6456
|
disabledOn: `${readonly} || ( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
|
|
6329
6457
|
// labelField: labelField,
|
|
6330
6458
|
// valueField: valueField,
|
|
6331
|
-
source: apiInfo,
|
|
6459
|
+
// source: apiInfo,
|
|
6332
6460
|
autoComplete: apiInfo,
|
|
6333
6461
|
searchable: true,
|
|
6334
6462
|
};
|
|
@@ -6407,10 +6535,10 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
6407
6535
|
|
|
6408
6536
|
const refObject = await getUISchema(referenceTo.objectName);
|
|
6409
6537
|
|
|
6410
|
-
//
|
|
6411
|
-
|
|
6412
|
-
//
|
|
6413
|
-
if(
|
|
6538
|
+
// 优先取字段中配置的enable_enhanced_lookup,字段上没配置时,才从对象上取enable_enhanced_lookup属性
|
|
6539
|
+
let enableEnhancedLookup = _$1.isBoolean(field.enable_enhanced_lookup) ? field.enable_enhanced_lookup : refObject.enable_enhanced_lookup;
|
|
6540
|
+
// 默认使用下拉框模式显示lookup选项,只能配置了enable_enhanced_lookup才使用弹出增强模式
|
|
6541
|
+
if(enableEnhancedLookup == true){
|
|
6414
6542
|
return await lookupToAmisPicker(field, readonly, ctx);
|
|
6415
6543
|
}else if(refObject.enable_tree) {
|
|
6416
6544
|
return await lookupToAmisTreeSelect(field, readonly, Object.assign({}, ctx, {
|
|
@@ -6727,8 +6855,8 @@ function getAmisStaticFieldType(type, readonly, options){
|
|
|
6727
6855
|
/*
|
|
6728
6856
|
* @Author: baozhoutao@steedos.com
|
|
6729
6857
|
* @Date: 2022-10-28 14:15:09
|
|
6730
|
-
* @LastEditors:
|
|
6731
|
-
* @LastEditTime:
|
|
6858
|
+
* @LastEditors: liaodaxue
|
|
6859
|
+
* @LastEditTime: 2023-10-30 17:51:54
|
|
6732
6860
|
* @Description:
|
|
6733
6861
|
*/
|
|
6734
6862
|
|
|
@@ -6779,11 +6907,26 @@ const getAmisFileEditSchema = (steedosField)=>{
|
|
|
6779
6907
|
useChunk: false, // 关闭分块上传
|
|
6780
6908
|
receiver: {
|
|
6781
6909
|
method: "post",
|
|
6910
|
+
dataType: "form-data",
|
|
6782
6911
|
url: `\${context.rootUrl}/s3/${tableName}`,
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6912
|
+
requestAdaptor: `
|
|
6913
|
+
const { _master, global,context } = api.body;
|
|
6914
|
+
// const { recordId, objectName } = _master;
|
|
6915
|
+
const { spaceId, userId, user } = global;
|
|
6916
|
+
/*
|
|
6917
|
+
record_id: recordId,
|
|
6918
|
+
parent: recordId,
|
|
6919
|
+
object_name: objectName,
|
|
6920
|
+
owner_name: user.name,
|
|
6921
|
+
space: spaceId,
|
|
6922
|
+
owner: userId
|
|
6923
|
+
*/
|
|
6924
|
+
// 参考platform 2.2版本,附件字段保存时cfs.files.filerecord、cfs.images.filerecord表中的metadata下只保存space、owner两个属性值。
|
|
6925
|
+
api.data.append('space', spaceId);
|
|
6926
|
+
api.data.append('owner', userId);
|
|
6927
|
+
|
|
6928
|
+
return api;
|
|
6929
|
+
`,
|
|
6787
6930
|
adaptor: `
|
|
6788
6931
|
const { context } = api.body;
|
|
6789
6932
|
var rootUrl = context.rootUrl + "/api/files/${tableName}/";
|
|
@@ -6969,8 +7112,6 @@ function getSelectFieldOptions(field){
|
|
|
6969
7112
|
}
|
|
6970
7113
|
|
|
6971
7114
|
async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
6972
|
-
// console.log('convertSFieldToAmisField====>', field, readonly, ctx)
|
|
6973
|
-
const isMobile = window.innerWidth <= 768;
|
|
6974
7115
|
// 创建人和修改人、创建时间和修改时间不显示
|
|
6975
7116
|
if(_$1.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
|
|
6976
7117
|
return;
|
|
@@ -7059,26 +7200,33 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7059
7200
|
};
|
|
7060
7201
|
break;
|
|
7061
7202
|
case 'date':
|
|
7062
|
-
convertData = isMobile && !readonly ? {
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
} : {
|
|
7203
|
+
// convertData = isMobile && !readonly ? {
|
|
7204
|
+
// type: "native-date",
|
|
7205
|
+
// pipeIn: (value, data) => {
|
|
7206
|
+
// if (value) {
|
|
7207
|
+
// value = moment(value).utc().format('YYYY-MM-DD');
|
|
7208
|
+
// return value;
|
|
7209
|
+
// } else {
|
|
7210
|
+
// return "";
|
|
7211
|
+
// }
|
|
7212
|
+
|
|
7213
|
+
// },
|
|
7214
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7215
|
+
// if (value) {
|
|
7216
|
+
// value = moment(value).format('YYYY-MM-DDT00:00:00.000[Z]');
|
|
7217
|
+
// return value;
|
|
7218
|
+
// } else {
|
|
7219
|
+
// return "";
|
|
7220
|
+
// }
|
|
7221
|
+
// }
|
|
7222
|
+
// } : {
|
|
7223
|
+
// type: getAmisStaticFieldType('date', readonly),
|
|
7224
|
+
// inputFormat: "YYYY-MM-DD",
|
|
7225
|
+
// format:'YYYY-MM-DDT00:00:00.000[Z]',
|
|
7226
|
+
// tpl: readonly ? Tpl.getDateTpl(field) : null,
|
|
7227
|
+
// // utc: true
|
|
7228
|
+
// }
|
|
7229
|
+
convertData = {
|
|
7082
7230
|
type: getAmisStaticFieldType('date', readonly),
|
|
7083
7231
|
inputFormat: "YYYY-MM-DD",
|
|
7084
7232
|
format:'YYYY-MM-DDT00:00:00.000[Z]',
|
|
@@ -7097,43 +7245,51 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7097
7245
|
};
|
|
7098
7246
|
break;
|
|
7099
7247
|
case 'datetime':
|
|
7100
|
-
convertData = isMobile && !readonly ? {
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7110
|
-
|
|
7111
|
-
|
|
7112
|
-
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
} : {
|
|
7248
|
+
// convertData = isMobile && !readonly ? {
|
|
7249
|
+
// type: "combo",
|
|
7250
|
+
// pipeIn: (value, data) => {
|
|
7251
|
+
// let revalue = {};
|
|
7252
|
+
// if (value && value != "Invalid date") {
|
|
7253
|
+
// value = moment(value).format('YYYY-MM-DD HH:mm:ss');
|
|
7254
|
+
// revalue[field.name + "-native-date"] = value.split(' ')[0];
|
|
7255
|
+
// revalue[field.name + "-native-time"] = value.split(' ')[1];
|
|
7256
|
+
// } else {
|
|
7257
|
+
// revalue[field.name + "-native-date"] = "";
|
|
7258
|
+
// revalue[field.name + "-native-time"] = "";
|
|
7259
|
+
// }
|
|
7260
|
+
// return revalue;
|
|
7261
|
+
// },
|
|
7262
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7263
|
+
// let revalue = "";
|
|
7264
|
+
// if (value[field.name + "-native-date"] && value[field.name + "-native-time"]) {
|
|
7265
|
+
// revalue = value[field.name + "-native-date"] + " " + value[field.name + "-native-time"];
|
|
7266
|
+
// revalue = moment(revalue).utc().format('YYYY-MM-DDTHH:mm:ss.SSS[Z]');
|
|
7267
|
+
// }
|
|
7268
|
+
// return revalue;
|
|
7269
|
+
// },
|
|
7270
|
+
// items: [
|
|
7271
|
+
// {
|
|
7272
|
+
// type: "native-date",
|
|
7273
|
+
// name: field.name + "-native-date",
|
|
7274
|
+
// className: "steedos-native-date",
|
|
7275
|
+
// value: ""
|
|
7276
|
+
// },
|
|
7277
|
+
// {
|
|
7278
|
+
// type: "native-time",
|
|
7279
|
+
// name: field.name + "-native-time",
|
|
7280
|
+
// className: "steedos-native-time",
|
|
7281
|
+
// value: ""
|
|
7282
|
+
// }
|
|
7283
|
+
// ]
|
|
7284
|
+
// } : {
|
|
7285
|
+
// type: getAmisStaticFieldType('datetime', readonly),
|
|
7286
|
+
// inputFormat: 'YYYY-MM-DD HH:mm',
|
|
7287
|
+
// format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
7288
|
+
// tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
|
|
7289
|
+
// utc: true,
|
|
7290
|
+
// }
|
|
7291
|
+
|
|
7292
|
+
convertData = {
|
|
7137
7293
|
type: getAmisStaticFieldType('datetime', readonly),
|
|
7138
7294
|
inputFormat: 'YYYY-MM-DD HH:mm',
|
|
7139
7295
|
format: 'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
@@ -7153,26 +7309,34 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7153
7309
|
};
|
|
7154
7310
|
break;
|
|
7155
7311
|
case 'time':
|
|
7156
|
-
convertData = isMobile && !readonly ? {
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
} : {
|
|
7312
|
+
// convertData = isMobile && !readonly ? {
|
|
7313
|
+
// type: "native-time",
|
|
7314
|
+
// pipeIn: (value, data) => {
|
|
7315
|
+
// if (value) {
|
|
7316
|
+
// value = moment(value).utc().format('HH:mm');
|
|
7317
|
+
// return value;
|
|
7318
|
+
// } else {
|
|
7319
|
+
// return "";
|
|
7320
|
+
// }
|
|
7321
|
+
|
|
7322
|
+
// },
|
|
7323
|
+
// pipeOut: (value, oldValue, data) => {
|
|
7324
|
+
// if (value) {
|
|
7325
|
+
// value = moment('1970-01-01 ' + value).format('1970-01-01THH:mm:00.000[Z]');
|
|
7326
|
+
// return value;
|
|
7327
|
+
// } else {
|
|
7328
|
+
// return "";
|
|
7329
|
+
// }
|
|
7330
|
+
// }
|
|
7331
|
+
// } : {
|
|
7332
|
+
// type: getAmisStaticFieldType('time', readonly),
|
|
7333
|
+
// inputFormat: 'HH:mm',
|
|
7334
|
+
// timeFormat:'HH:mm',
|
|
7335
|
+
// format:'1970-01-01THH:mm:00.000[Z]',
|
|
7336
|
+
// tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
|
|
7337
|
+
// // utc: true
|
|
7338
|
+
// }
|
|
7339
|
+
convertData = {
|
|
7176
7340
|
type: getAmisStaticFieldType('time', readonly),
|
|
7177
7341
|
inputFormat: 'HH:mm',
|
|
7178
7342
|
timeFormat:'HH:mm',
|
|
@@ -7222,7 +7386,20 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
7222
7386
|
type: getAmisStaticFieldType('number', readonly),
|
|
7223
7387
|
min: field.min,
|
|
7224
7388
|
max: field.max,
|
|
7225
|
-
precision: field.scale
|
|
7389
|
+
precision: field.scale,
|
|
7390
|
+
suffix: "%",
|
|
7391
|
+
pipeIn: (value, data) => {
|
|
7392
|
+
if(value){
|
|
7393
|
+
return value*100;
|
|
7394
|
+
}
|
|
7395
|
+
return value;
|
|
7396
|
+
},
|
|
7397
|
+
pipeOut: (value, oldValue, data) => {
|
|
7398
|
+
if(value){
|
|
7399
|
+
return value/100;
|
|
7400
|
+
}
|
|
7401
|
+
return value;
|
|
7402
|
+
},
|
|
7226
7403
|
};
|
|
7227
7404
|
}
|
|
7228
7405
|
break;
|
|
@@ -7556,7 +7733,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
|
|
|
7556
7733
|
|
|
7557
7734
|
const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
|
|
7558
7735
|
if(amisField){
|
|
7559
|
-
return amisField
|
|
7736
|
+
return Object.assign({}, amisField,{
|
|
7737
|
+
submitOnChange: true
|
|
7738
|
+
});
|
|
7560
7739
|
}
|
|
7561
7740
|
}
|
|
7562
7741
|
}
|
|
@@ -7634,8 +7813,46 @@ var config = {
|
|
|
7634
7813
|
};
|
|
7635
7814
|
|
|
7636
7815
|
async function getQuickEditSchema(field, options){
|
|
7637
|
-
|
|
7816
|
+
//判断在amis3.2以上环境下,放开批量编辑
|
|
7817
|
+
let isAmisVersionforBatchEdit = false;
|
|
7818
|
+
if(window.amisRequire && window.amisRequire('amis')){
|
|
7819
|
+
isAmisVersionforBatchEdit = window.amisRequire('amis').version[0] >= 3 && window.amisRequire('amis').version[2] >= 2;
|
|
7820
|
+
}else if(window.Amis){
|
|
7821
|
+
isAmisVersionforBatchEdit = window.Amis.version[0] >= 3 && window.Amis.version[2] >= 2;
|
|
7822
|
+
}
|
|
7823
|
+
const quickEditId = options.objectName + "_" + field.name + "_quickEdit";//定义快速编辑的表单id,用于setvalue传值
|
|
7638
7824
|
var quickEditSchema = { body: [], id: quickEditId };
|
|
7825
|
+
//select,avatar,image,file等组件无法行记录字段赋值,暂不支持批量编辑;
|
|
7826
|
+
if(field.type != 'avatar' && field.type != 'image' && field.type != 'file' && isAmisVersionforBatchEdit){
|
|
7827
|
+
const submitEvent = {
|
|
7828
|
+
submit: {
|
|
7829
|
+
actions: [
|
|
7830
|
+
{
|
|
7831
|
+
actionType: "custom",
|
|
7832
|
+
script: `
|
|
7833
|
+
let items = _.cloneDeep(event.data.items);
|
|
7834
|
+
let selectedItems = _.cloneDeep(event.data.selectedItems);
|
|
7835
|
+
if(event.data.isBatchEdit){
|
|
7836
|
+
selectedItems.forEach(function(selectedItem){
|
|
7837
|
+
selectedItem._display.${field.name} = event.data._display.${field.name};
|
|
7838
|
+
doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: "_display_" + selectedItem._index});
|
|
7839
|
+
doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + selectedItem._index});
|
|
7840
|
+
})
|
|
7841
|
+
}else{
|
|
7842
|
+
doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: "_display_" + event.data._index});
|
|
7843
|
+
doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + event.data._index});
|
|
7844
|
+
}
|
|
7845
|
+
`
|
|
7846
|
+
},
|
|
7847
|
+
{
|
|
7848
|
+
"actionType": "closeDialog"
|
|
7849
|
+
}
|
|
7850
|
+
]
|
|
7851
|
+
}
|
|
7852
|
+
};
|
|
7853
|
+
quickEditSchema.onEvent = submitEvent;
|
|
7854
|
+
}
|
|
7855
|
+
|
|
7639
7856
|
if (field.disabled) {
|
|
7640
7857
|
quickEditSchema = false;
|
|
7641
7858
|
} else {
|
|
@@ -7652,7 +7869,7 @@ async function getQuickEditSchema(field, options){
|
|
|
7652
7869
|
{
|
|
7653
7870
|
"actionType": "custom",
|
|
7654
7871
|
"script": `
|
|
7655
|
-
var _display = event.data._display;
|
|
7872
|
+
var _display = _.cloneDeep(event.data._display);
|
|
7656
7873
|
${displayField}
|
|
7657
7874
|
doAction({actionType: 'setValue', "args": {"value": {_display}},componentId: "${quickEditId}"});
|
|
7658
7875
|
`
|
|
@@ -7674,7 +7891,7 @@ async function getQuickEditSchema(field, options){
|
|
|
7674
7891
|
第二种是增加选项时,按照value的值,找到对应选项,并按照_display的规则为其赋值
|
|
7675
7892
|
*/
|
|
7676
7893
|
TempDisplayField = `
|
|
7677
|
-
const preData = event.data.__super.${field.name};
|
|
7894
|
+
const preData = _.cloneDeep(event.data.__super.${field.name});
|
|
7678
7895
|
if(preData && event.data.${field.name}.length < preData.length){
|
|
7679
7896
|
let deletedIndex;
|
|
7680
7897
|
preData.forEach(function(item,index){
|
|
@@ -7718,7 +7935,7 @@ async function getQuickEditSchema(field, options){
|
|
|
7718
7935
|
break;
|
|
7719
7936
|
case "percent":
|
|
7720
7937
|
TempDisplayField = `
|
|
7721
|
-
_display["${field.name}"] =
|
|
7938
|
+
_display["${field.name}"] = event.data.value.toFixed(${field.scale}) + '%';
|
|
7722
7939
|
`;
|
|
7723
7940
|
quickEditSchema.body[0].onEvent["change"] = quickEditOnEvent(TempDisplayField);
|
|
7724
7941
|
break;
|
|
@@ -7869,6 +8086,131 @@ async function getQuickEditSchema(field, options){
|
|
|
7869
8086
|
}
|
|
7870
8087
|
|
|
7871
8088
|
});
|
|
8089
|
+
if(field.type != 'avatar' && field.type != 'image' && field.type != 'file' && isAmisVersionforBatchEdit){
|
|
8090
|
+
quickEditSchema.body.push({
|
|
8091
|
+
"name": "isBatchEdit",
|
|
8092
|
+
"type": "checkbox",
|
|
8093
|
+
"option": [
|
|
8094
|
+
{
|
|
8095
|
+
"type": "tpl",
|
|
8096
|
+
"tpl": "更新${COUNT(selectedItems)}个选定记录"
|
|
8097
|
+
},
|
|
8098
|
+
{
|
|
8099
|
+
"type": "spinner",
|
|
8100
|
+
"showOn": "${batchPermissionLoading}",
|
|
8101
|
+
"size": "sm",
|
|
8102
|
+
"className": "mr-4"
|
|
8103
|
+
}
|
|
8104
|
+
],
|
|
8105
|
+
"visibleOn": "${ARRAYSOME(selectedItems, item => item._id === _id) && COUNT(selectedItems)>1 && quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}",
|
|
8106
|
+
"disabledOn": "${batchPermissionLoading}",
|
|
8107
|
+
"onEvent":{
|
|
8108
|
+
"change":{
|
|
8109
|
+
"actions":[
|
|
8110
|
+
{
|
|
8111
|
+
"actionType": "setValue",
|
|
8112
|
+
"componentId": quickEditId,
|
|
8113
|
+
"args": {
|
|
8114
|
+
"value":{
|
|
8115
|
+
"batchPermissionLoading": true
|
|
8116
|
+
}
|
|
8117
|
+
},
|
|
8118
|
+
"expression":"${event.data.value}"
|
|
8119
|
+
},
|
|
8120
|
+
{
|
|
8121
|
+
"actionType": "ajax",
|
|
8122
|
+
"args": {
|
|
8123
|
+
"api": {
|
|
8124
|
+
"url": "${context.rootUrl}/graphql",
|
|
8125
|
+
"method": "post",
|
|
8126
|
+
"headers": {
|
|
8127
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
8128
|
+
},
|
|
8129
|
+
"data": {
|
|
8130
|
+
"query": "{rows:${objectName}(filters:[\"_id\",\"in\",${selectedItems | pick:_id | split | json}]){_id,_permissions{allowEdit}}}"
|
|
8131
|
+
},
|
|
8132
|
+
"adaptor": `
|
|
8133
|
+
const noPermission = [];
|
|
8134
|
+
payload.data.rows.forEach(function (row) {
|
|
8135
|
+
if(!row._permissions.allowEdit){
|
|
8136
|
+
noPermission.push(row._id);
|
|
8137
|
+
}
|
|
8138
|
+
})
|
|
8139
|
+
payload.data.noPermission = noPermission;
|
|
8140
|
+
return payload;
|
|
8141
|
+
`
|
|
8142
|
+
}
|
|
8143
|
+
},
|
|
8144
|
+
"expression":"${event.data.value}"
|
|
8145
|
+
},
|
|
8146
|
+
{
|
|
8147
|
+
"actionType": "setValue",
|
|
8148
|
+
"componentId": quickEditId,
|
|
8149
|
+
"args": {
|
|
8150
|
+
"value":{
|
|
8151
|
+
"batchPermissionLoading": false
|
|
8152
|
+
}
|
|
8153
|
+
},
|
|
8154
|
+
"expression":"${event.data.value}"
|
|
8155
|
+
},
|
|
8156
|
+
{
|
|
8157
|
+
"actionType": "dialog",
|
|
8158
|
+
"dialog":{
|
|
8159
|
+
"title": "记录权限",
|
|
8160
|
+
"showCloseButton": false,
|
|
8161
|
+
"body":[
|
|
8162
|
+
{
|
|
8163
|
+
"type": "tpl",
|
|
8164
|
+
"tpl": "当前选中记录中,有${COUNT(noPermission)}条记录无编辑权限,是否需要批量编辑其他记录?"
|
|
8165
|
+
}
|
|
8166
|
+
],
|
|
8167
|
+
"onEvent":{
|
|
8168
|
+
"confirm":{
|
|
8169
|
+
"actions":[
|
|
8170
|
+
{
|
|
8171
|
+
"actionType": "custom",
|
|
8172
|
+
"script": `
|
|
8173
|
+
const noPermission = event.data.noPermission;
|
|
8174
|
+
const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
|
|
8175
|
+
const selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
|
|
8176
|
+
noPermission.forEach(function (item) {
|
|
8177
|
+
crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
|
|
8178
|
+
})
|
|
8179
|
+
`
|
|
8180
|
+
},
|
|
8181
|
+
{
|
|
8182
|
+
"actionType": "setValue",
|
|
8183
|
+
"componentId": quickEditId,
|
|
8184
|
+
"args": {
|
|
8185
|
+
"value":{
|
|
8186
|
+
"isBatchEdit": true
|
|
8187
|
+
}
|
|
8188
|
+
},
|
|
8189
|
+
}
|
|
8190
|
+
]
|
|
8191
|
+
},
|
|
8192
|
+
"cancel":{
|
|
8193
|
+
"actions":[
|
|
8194
|
+
{
|
|
8195
|
+
"actionType": "setValue",
|
|
8196
|
+
"componentId": quickEditId,
|
|
8197
|
+
"args": {
|
|
8198
|
+
"value":{
|
|
8199
|
+
"isBatchEdit": false
|
|
8200
|
+
}
|
|
8201
|
+
},
|
|
8202
|
+
}
|
|
8203
|
+
]
|
|
8204
|
+
}
|
|
8205
|
+
}
|
|
8206
|
+
},
|
|
8207
|
+
"expression":"${COUNT(event.data.noPermission)>0}"
|
|
8208
|
+
}
|
|
8209
|
+
]
|
|
8210
|
+
}
|
|
8211
|
+
}
|
|
8212
|
+
});
|
|
8213
|
+
}
|
|
7872
8214
|
} else {
|
|
7873
8215
|
quickEditSchema = false;
|
|
7874
8216
|
}
|
|
@@ -7903,6 +8245,8 @@ async function getTableColumns(fields, options){
|
|
|
7903
8245
|
const columns = [];
|
|
7904
8246
|
if(!options.isLookup){
|
|
7905
8247
|
columns.push({name: '_index',type: 'text', width: 32, placeholder: ""});
|
|
8248
|
+
//将_display放入crud的columns中,可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8249
|
+
columns.push({name: '_display',type: 'static', width: 32, placeholder: "",id: "_display_${_index}", className: "hidden"});
|
|
7906
8250
|
}
|
|
7907
8251
|
const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
|
|
7908
8252
|
|
|
@@ -7934,7 +8278,7 @@ async function getTableColumns(fields, options){
|
|
|
7934
8278
|
{
|
|
7935
8279
|
"args": {
|
|
7936
8280
|
"api": {
|
|
7937
|
-
"url": "${context.rootUrl
|
|
8281
|
+
"url": "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}",
|
|
7938
8282
|
"method": "get",
|
|
7939
8283
|
"headers": {
|
|
7940
8284
|
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -7981,7 +8325,7 @@ async function getTableColumns(fields, options){
|
|
|
7981
8325
|
else if(field.type === 'select'){
|
|
7982
8326
|
const map = getSelectMap(field.options);
|
|
7983
8327
|
columnItem = Object.assign({}, {
|
|
7984
|
-
type: "mapping",
|
|
8328
|
+
type: "static-mapping",
|
|
7985
8329
|
name: field.name,
|
|
7986
8330
|
label: field.label,
|
|
7987
8331
|
map: map,
|
|
@@ -7996,7 +8340,7 @@ async function getTableColumns(fields, options){
|
|
|
7996
8340
|
const tpl = await getFieldTpl(field, options);
|
|
7997
8341
|
let type = 'text';
|
|
7998
8342
|
if(tpl){
|
|
7999
|
-
type = '
|
|
8343
|
+
type = 'static';
|
|
8000
8344
|
}else if(field.type === 'html'){
|
|
8001
8345
|
type = 'markdown';
|
|
8002
8346
|
}else if(field.type === 'url'){
|
|
@@ -8037,6 +8381,7 @@ async function getTableColumns(fields, options){
|
|
|
8037
8381
|
columnItem.quickEdit = quickEditSchema;
|
|
8038
8382
|
columnItem.quickEditEnabledOn = "${is_system !== true}";
|
|
8039
8383
|
}
|
|
8384
|
+
columnItem.id = `${options.objectName}_${field.name}_\${_index}`;
|
|
8040
8385
|
columns.push(columnItem);
|
|
8041
8386
|
}
|
|
8042
8387
|
}
|
|
@@ -8315,7 +8660,7 @@ async function getTableOperation(ctx){
|
|
|
8315
8660
|
}
|
|
8316
8661
|
return {
|
|
8317
8662
|
type: 'operation',
|
|
8318
|
-
label:
|
|
8663
|
+
label: "",
|
|
8319
8664
|
fixed: 'right',
|
|
8320
8665
|
labelClassName: 'text-center',
|
|
8321
8666
|
className: 'text-center steedos-listview-operation w-10',
|
|
@@ -8349,23 +8694,87 @@ async function getTableOperation(ctx){
|
|
|
8349
8694
|
}
|
|
8350
8695
|
}
|
|
8351
8696
|
|
|
8697
|
+
async function getDefaultCrudCard(columns, options) {
|
|
8698
|
+
let labelFieldName = options?.labelFieldName || "name";
|
|
8699
|
+
let titleColumn, bodyColumns = [];
|
|
8700
|
+
columns.forEach(function (item) {
|
|
8701
|
+
delete item.quickEdit;
|
|
8702
|
+
delete item.width;
|
|
8703
|
+
if (item.name === labelFieldName) {
|
|
8704
|
+
titleColumn = item;
|
|
8705
|
+
}
|
|
8706
|
+
else {
|
|
8707
|
+
if (item.name !== "_index") {
|
|
8708
|
+
bodyColumns.push(item);
|
|
8709
|
+
}
|
|
8710
|
+
}
|
|
8711
|
+
});
|
|
8712
|
+
let card = {
|
|
8713
|
+
"header": {
|
|
8714
|
+
"title": titleColumn.tpl
|
|
8715
|
+
},
|
|
8716
|
+
body: bodyColumns,
|
|
8717
|
+
// useCardLabel: false,
|
|
8718
|
+
toolbar: []
|
|
8719
|
+
};
|
|
8720
|
+
let hideToolbarOperation = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
8721
|
+
if(!hideToolbarOperation){
|
|
8722
|
+
let toolbarOperation = await getTableOperation(options);
|
|
8723
|
+
if (toolbarOperation) {
|
|
8724
|
+
toolbarOperation.className += " inline-block w-auto";
|
|
8725
|
+
}
|
|
8726
|
+
card.toolbar.push(toolbarOperation);
|
|
8727
|
+
}
|
|
8728
|
+
return card;
|
|
8729
|
+
}
|
|
8730
|
+
|
|
8352
8731
|
async function getTableSchema$1(fields, options){
|
|
8353
8732
|
if(!options){
|
|
8354
8733
|
options = {};
|
|
8355
8734
|
}
|
|
8356
8735
|
let { isLookup, hiddenColumnOperation } = options;
|
|
8736
|
+
const defaults = options.defaults;
|
|
8737
|
+
const listSchema = (defaults && defaults.listSchema) || {};
|
|
8738
|
+
|
|
8357
8739
|
let columns = [];
|
|
8358
8740
|
let useMobileColumns = options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1;
|
|
8359
8741
|
if(isLookup){
|
|
8360
8742
|
// 在lookup手机端列表模式调式好之前不使用getMobileTableColumns
|
|
8361
8743
|
useMobileColumns = false;
|
|
8362
8744
|
}
|
|
8745
|
+
if(listSchema.mode && listSchema.mode !== "table"){
|
|
8746
|
+
// 如果指定的mode,则不走我们内置的手机端列表效果,使用steedos组件内部开发的默认card/list效果,或者由用户自己实现card/list模式的crud列表
|
|
8747
|
+
useMobileColumns = false;
|
|
8748
|
+
}
|
|
8363
8749
|
if(useMobileColumns){
|
|
8364
8750
|
columns = await getMobileTableColumns(fields, options);
|
|
8365
8751
|
}
|
|
8366
8752
|
else {
|
|
8367
8753
|
columns = await getTableColumns(fields, options);
|
|
8368
8754
|
|
|
8755
|
+
if(listSchema.mode === "cards"){
|
|
8756
|
+
let card = listSchema.card;
|
|
8757
|
+
if(!card){
|
|
8758
|
+
card = await getDefaultCrudCard(columns, options);
|
|
8759
|
+
}
|
|
8760
|
+
return {
|
|
8761
|
+
mode: "cards",
|
|
8762
|
+
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
8763
|
+
name: "thelist",
|
|
8764
|
+
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
8765
|
+
className: "",
|
|
8766
|
+
draggable: false,
|
|
8767
|
+
defaultParams: getDefaultParams(options),
|
|
8768
|
+
card: card,
|
|
8769
|
+
syncLocation: false,
|
|
8770
|
+
keepItemSelectionOnPageChange: true,
|
|
8771
|
+
checkOnItemClick: isLookup ? true : false,
|
|
8772
|
+
labelTpl: `\${${options.labelFieldName}}`,
|
|
8773
|
+
autoFillHeight: false, // 自动高度效果不理想,先关闭
|
|
8774
|
+
columnsTogglable: false
|
|
8775
|
+
}
|
|
8776
|
+
}
|
|
8777
|
+
|
|
8369
8778
|
if(!isLookup && !hiddenColumnOperation){
|
|
8370
8779
|
columns.push(await getTableOperation(options));
|
|
8371
8780
|
}
|
|
@@ -8373,6 +8782,7 @@ async function getTableSchema$1(fields, options){
|
|
|
8373
8782
|
|
|
8374
8783
|
return {
|
|
8375
8784
|
mode: "table",
|
|
8785
|
+
perPageAvailable: [5, 10, 20, 50, 100, 500],
|
|
8376
8786
|
name: "thelist",
|
|
8377
8787
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
8378
8788
|
className: "",
|
|
@@ -8843,18 +9253,30 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
8843
9253
|
payload.status = 2;
|
|
8844
9254
|
payload.msg = payload.errors[0].message;
|
|
8845
9255
|
}
|
|
9256
|
+
${options && options.initApiAdaptor || ''}
|
|
8846
9257
|
return payload;
|
|
8847
9258
|
`
|
|
8848
9259
|
}
|
|
8849
9260
|
|
|
8850
9261
|
async function getReadonlyFormInitApi(object, recordId, fields, options){
|
|
9262
|
+
let findOneOptions;
|
|
9263
|
+
if (!recordId && options && options.isEditor) {
|
|
9264
|
+
// 设计器中只读表单返回第一条记录
|
|
9265
|
+
findOneOptions = {
|
|
9266
|
+
filters: [],
|
|
9267
|
+
queryOptions: "top: 1"
|
|
9268
|
+
};
|
|
9269
|
+
}
|
|
8851
9270
|
return {
|
|
8852
9271
|
method: "post",
|
|
8853
9272
|
url: getApi$2() + '&objectName=${objectName}' + "&recordId=${recordId}",
|
|
8854
9273
|
cache: API_CACHE,
|
|
8855
|
-
|
|
9274
|
+
requestAdaptor: `
|
|
9275
|
+
${options && options.initApiRequestAdaptor || ''}
|
|
9276
|
+
return api;
|
|
9277
|
+
`,
|
|
8856
9278
|
adaptor: getReadonlyFormAdaptor(object, fields, options),
|
|
8857
|
-
data: await getFindOneQuery$1(object, recordId, fields,
|
|
9279
|
+
data: await getFindOneQuery$1(object, recordId, fields, findOneOptions),
|
|
8858
9280
|
headers: {
|
|
8859
9281
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
8860
9282
|
}
|
|
@@ -8995,7 +9417,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
8995
9417
|
${getScriptForRewriteValueForFileFields(fields)}
|
|
8996
9418
|
|
|
8997
9419
|
_.each(dataKeys, function(key){
|
|
8998
|
-
if(fieldKeys.indexOf(key)<0){
|
|
9420
|
+
if(fieldKeys.indexOf(key)<0 && key !== "_display"){
|
|
8999
9421
|
delete data[key];
|
|
9000
9422
|
}
|
|
9001
9423
|
})
|
|
@@ -9170,6 +9592,8 @@ async function getCalendarApi(mainObject, fields, options) {
|
|
|
9170
9592
|
|
|
9171
9593
|
if(api.data.$self.additionalFilters){
|
|
9172
9594
|
filters.push(api.data.$self.additionalFilters)
|
|
9595
|
+
}else if(api.data.$self.event.data.additionalFilters){
|
|
9596
|
+
filters.push(api.data.$self.event.data.additionalFilters)
|
|
9173
9597
|
}
|
|
9174
9598
|
|
|
9175
9599
|
var pageSize = api.data.pageSize || 10;
|
|
@@ -9495,6 +9919,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
9495
9919
|
businessHours.endTime = `${calendarOptions.endDayHour}:00`;
|
|
9496
9920
|
}
|
|
9497
9921
|
|
|
9922
|
+
// api.trackExpression="\\\${additionalFilters}";
|
|
9498
9923
|
const onEvent = {
|
|
9499
9924
|
"getEvents": {
|
|
9500
9925
|
"weight": 0,
|
|
@@ -9506,6 +9931,22 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
|
|
|
9506
9931
|
"actionType": "custom",
|
|
9507
9932
|
"script": onGetEventsScript
|
|
9508
9933
|
}
|
|
9934
|
+
// {
|
|
9935
|
+
// "actionType": "ajax",
|
|
9936
|
+
// "outputVar": "responseResult",
|
|
9937
|
+
// "args": {
|
|
9938
|
+
// "options": {
|
|
9939
|
+
// },
|
|
9940
|
+
// "api": api
|
|
9941
|
+
// // {
|
|
9942
|
+
// // "url": "111",
|
|
9943
|
+
// // "method": "post",
|
|
9944
|
+
// // "data": {
|
|
9945
|
+
// // "calendarOptions": JSON.stringify(calendarOptions);
|
|
9946
|
+
// // }
|
|
9947
|
+
// // }
|
|
9948
|
+
// }
|
|
9949
|
+
// }
|
|
9509
9950
|
]
|
|
9510
9951
|
},
|
|
9511
9952
|
"select": {
|
|
@@ -9829,7 +10270,7 @@ function deleteVariable(data, key) {
|
|
|
9829
10270
|
* @Author: baozhoutao@steedos.com
|
|
9830
10271
|
* @Date: 2022-05-26 16:02:08
|
|
9831
10272
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
9832
|
-
* @LastEditTime: 2023-
|
|
10273
|
+
* @LastEditTime: 2023-10-12 18:25:05
|
|
9833
10274
|
* @Description:
|
|
9834
10275
|
*/
|
|
9835
10276
|
|
|
@@ -9849,8 +10290,9 @@ const getFieldSchemaArray = (formFields, ctx) => {
|
|
|
9849
10290
|
}
|
|
9850
10291
|
|
|
9851
10292
|
let forceHidden = false;
|
|
9852
|
-
if(!recordId && field.readonly){
|
|
10293
|
+
if(!recordId && field.readonly && !ctx.isEditor){
|
|
9853
10294
|
// 新建记录时,只读字段先隐藏,后续支持显示后,即任务:https://github.com/steedos/steedos-platform/issues/3164 完成后再放开
|
|
10295
|
+
// 表单只读时所有字段都是readonly,设计器中如果forceHidden会造成整个表单在只读的时候显示为空白了,所以要排除掉
|
|
9854
10296
|
forceHidden = true;
|
|
9855
10297
|
}
|
|
9856
10298
|
|
|
@@ -10092,6 +10534,9 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10092
10534
|
const nonpaged = objectSchema.paging && objectSchema.paging.enabled === false;
|
|
10093
10535
|
const isTreeObject = objectSchema.enable_tree;
|
|
10094
10536
|
const bulkActions = getBulkActions(objectSchema);
|
|
10537
|
+
const defaults = options.defaults;
|
|
10538
|
+
const listSchema = (defaults && defaults.listSchema) || {};
|
|
10539
|
+
|
|
10095
10540
|
const bodyProps = {
|
|
10096
10541
|
// toolbar: getToolbar(),
|
|
10097
10542
|
// headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
|
|
@@ -10103,9 +10548,12 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10103
10548
|
filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
|
|
10104
10549
|
};
|
|
10105
10550
|
if(options.formFactor !== 'SMALL' || ["split"].indexOf(options.displayAs) == -1){
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10551
|
+
if(listSchema.mode !== "cards"){
|
|
10552
|
+
// card模式时默认不显示勾选框
|
|
10553
|
+
Object.assign(bodyProps, {
|
|
10554
|
+
bulkActions: options.bulkActions != false ? bulkActions : false
|
|
10555
|
+
});
|
|
10556
|
+
}
|
|
10109
10557
|
}
|
|
10110
10558
|
// yml里配置的 不分页和enable_tree:true 优先级最高,组件中输入的top次之。
|
|
10111
10559
|
options.queryCount = true;
|
|
@@ -10164,17 +10612,19 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10164
10612
|
}
|
|
10165
10613
|
let tableOptions = Object.assign({
|
|
10166
10614
|
idFieldName: objectSchema.idFieldName, labelFieldName: labelFieldName,
|
|
10167
|
-
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit
|
|
10615
|
+
permissions:objectSchema.permissions,enable_inline_edit:objectSchema.enable_inline_edit,
|
|
10616
|
+
crudId: listSchema.id || id
|
|
10168
10617
|
}, options);
|
|
10169
10618
|
tableOptions.amisData = createObject(options.amisData || {}, {});
|
|
10170
10619
|
const table = await getTableSchema$1(fields, tableOptions);
|
|
10171
|
-
delete table.mode;
|
|
10620
|
+
// delete table.mode;
|
|
10172
10621
|
//image与avatar需要在提交修改时特别处理
|
|
10173
10622
|
const imageNames = ___default.compact(___default.map(___default.filter(fields, (field) => ["image","avatar"].includes(field.type)), 'name'));
|
|
10174
10623
|
const quickSaveApiRequestAdaptor = `
|
|
10175
10624
|
var graphqlOrder = "";
|
|
10176
10625
|
var imageNames = ${JSON.stringify(imageNames)};
|
|
10177
|
-
api.data.rowsDiff
|
|
10626
|
+
const rowsDiff = _.cloneDeep(api.data.rowsDiff);
|
|
10627
|
+
rowsDiff.forEach(function (item, index) {
|
|
10178
10628
|
for(key in item){
|
|
10179
10629
|
if(_.includes(imageNames, key)){
|
|
10180
10630
|
if(typeof item[key] == "string"){
|
|
@@ -10188,6 +10638,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10188
10638
|
}
|
|
10189
10639
|
}
|
|
10190
10640
|
}
|
|
10641
|
+
item = _.omit(item, '_display');
|
|
10191
10642
|
const itemOrder = 'update' + index + ':' + api.data.objectName + '__update(id:"' + item._id + '", doc:' + JSON.stringify(JSON.stringify(_.omit(item, '_id'))) + ') {_id}';
|
|
10192
10643
|
graphqlOrder += itemOrder;
|
|
10193
10644
|
})
|
|
@@ -10238,12 +10689,14 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10238
10689
|
|
|
10239
10690
|
}
|
|
10240
10691
|
|
|
10241
|
-
const defaults = options.defaults;
|
|
10242
|
-
|
|
10243
|
-
const listSchema = (defaults && defaults.listSchema) || {};
|
|
10244
10692
|
body = defaultsDeep({}, listSchema, body);
|
|
10245
10693
|
body = await getCrudSchemaWithDataFilter(body, { crudDataFilter, onCrudDataFilter, amisData, env });
|
|
10246
10694
|
|
|
10695
|
+
let crudModeClassName = "";
|
|
10696
|
+
if(body.mode){
|
|
10697
|
+
crudModeClassName = `steedos-crud-mode-${body.mode}`;
|
|
10698
|
+
}
|
|
10699
|
+
|
|
10247
10700
|
if (defaults) {
|
|
10248
10701
|
const headerSchema = defaults.headerSchema;
|
|
10249
10702
|
const footerSchema = defaults.footerSchema;
|
|
@@ -10272,7 +10725,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
10272
10725
|
// TODO: data应该只留loaded,其他属性都改为从上层传递下来
|
|
10273
10726
|
return {
|
|
10274
10727
|
type: 'service',
|
|
10275
|
-
className:
|
|
10728
|
+
className: crudModeClassName,
|
|
10276
10729
|
//目前crud的service层id不认用户自定义id,只支持默认规则id,许多地方的格式都写死了service_listview_${objectname}
|
|
10277
10730
|
id: `service_${id}`,
|
|
10278
10731
|
name: `page`,
|
|
@@ -10326,8 +10779,29 @@ const getFormFields = (objectSchema, formProps)=>{
|
|
|
10326
10779
|
return lodash.sortBy(___default.values(fields), "sort_no");
|
|
10327
10780
|
};
|
|
10328
10781
|
|
|
10782
|
+
async function getFormSchemaWithDataFilter(form, options = {}){
|
|
10783
|
+
const { formDataFilter, amisData, env } = options;
|
|
10784
|
+
let onFormDataFilter = options.onFormDataFilter;
|
|
10785
|
+
if (!onFormDataFilter && typeof formDataFilter === 'string') {
|
|
10786
|
+
onFormDataFilter = new Function(
|
|
10787
|
+
'form',
|
|
10788
|
+
'env',
|
|
10789
|
+
'data',
|
|
10790
|
+
formDataFilter
|
|
10791
|
+
);
|
|
10792
|
+
}
|
|
10793
|
+
|
|
10794
|
+
try {
|
|
10795
|
+
onFormDataFilter && (form = await onFormDataFilter(form, env, amisData) || form);
|
|
10796
|
+
} catch (e) {
|
|
10797
|
+
console.warn(e);
|
|
10798
|
+
}
|
|
10799
|
+
return form;
|
|
10800
|
+
}
|
|
10801
|
+
|
|
10329
10802
|
async function getObjectForm(objectSchema, ctx){
|
|
10330
|
-
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, tabId, appId, defaults
|
|
10803
|
+
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
|
|
10804
|
+
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
10331
10805
|
const fields = ___default.values(objectSchema.fields);
|
|
10332
10806
|
const formFields = getFormFields(objectSchema, ctx);
|
|
10333
10807
|
const formSchema = defaults && defaults.formSchema || {};
|
|
@@ -10344,7 +10818,8 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
10344
10818
|
name: `page_edit_${recordId}`,
|
|
10345
10819
|
api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
10346
10820
|
data:{
|
|
10347
|
-
editFormInited: false
|
|
10821
|
+
editFormInited: false,
|
|
10822
|
+
...amisData
|
|
10348
10823
|
},
|
|
10349
10824
|
// data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
10350
10825
|
initApi: null,
|
|
@@ -10397,9 +10872,10 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
10397
10872
|
},
|
|
10398
10873
|
"expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
|
|
10399
10874
|
},
|
|
10875
|
+
...submitSuccActions,
|
|
10400
10876
|
// {
|
|
10401
10877
|
// "actionType": "custom",
|
|
10402
|
-
// "script":
|
|
10878
|
+
// "script": `setTimeout(function(){doAction({'actionType': 'setValue','componentId': '${formSchema.id}','args': {'value': {'sort_no': 879}}})}, 300)`
|
|
10403
10879
|
// },
|
|
10404
10880
|
// {
|
|
10405
10881
|
// "args": {},
|
|
@@ -10410,20 +10886,22 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
10410
10886
|
}
|
|
10411
10887
|
})]
|
|
10412
10888
|
};
|
|
10889
|
+
amisSchema.body[0] = await getFormSchemaWithDataFilter(amisSchema.body[0], { formDataFilter, onFormDataFilter, amisData, env });
|
|
10413
10890
|
return amisSchema;
|
|
10414
10891
|
}
|
|
10415
10892
|
|
|
10416
10893
|
async function getObjectDetail(objectSchema, recordId, ctx){
|
|
10417
|
-
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign,
|
|
10894
|
+
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "normal", labelAlign,
|
|
10895
|
+
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
10418
10896
|
const fields = ___default.values(objectSchema.fields);
|
|
10419
10897
|
const formFields = getFormFields(objectSchema, ctx);
|
|
10420
10898
|
const serviceId = `service_detail_page`;
|
|
10421
|
-
|
|
10899
|
+
const amisSchema = {
|
|
10422
10900
|
type: 'service',
|
|
10423
10901
|
name: `page_readonly_${recordId}`,
|
|
10424
10902
|
id: serviceId,
|
|
10425
10903
|
data: {global: getGlobalData('read'), context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
10426
|
-
api: await getReadonlyFormInitApi(objectSchema, recordId, fields,
|
|
10904
|
+
api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
10427
10905
|
body: [
|
|
10428
10906
|
{
|
|
10429
10907
|
"type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
|
|
@@ -10442,7 +10920,11 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
10442
10920
|
"formData": "$$"
|
|
10443
10921
|
},
|
|
10444
10922
|
wrapWithPanel: false,
|
|
10445
|
-
body: await getFormBody(
|
|
10923
|
+
body: await getFormBody(
|
|
10924
|
+
map(fields, (field) => { field.readonly = true; return field; }),
|
|
10925
|
+
map(formFields, (field) => { field.readonly = true; return field; }),
|
|
10926
|
+
Object.assign({}, ctx, { showSystemFields: true, fieldGroups: objectSchema.field_groups })
|
|
10927
|
+
),
|
|
10446
10928
|
className: 'steedos-amis-form bg-white',
|
|
10447
10929
|
actions: [], // 不显示表单默认的提交按钮
|
|
10448
10930
|
onEvent: {
|
|
@@ -10496,7 +10978,10 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
10496
10978
|
]
|
|
10497
10979
|
}
|
|
10498
10980
|
}
|
|
10499
|
-
}
|
|
10981
|
+
};
|
|
10982
|
+
|
|
10983
|
+
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
10984
|
+
return amisSchema;
|
|
10500
10985
|
}
|
|
10501
10986
|
|
|
10502
10987
|
/*
|
|
@@ -10576,7 +11061,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
10576
11061
|
* @Author: baozhoutao@steedos.com
|
|
10577
11062
|
* @Date: 2022-07-05 15:55:39
|
|
10578
11063
|
* @LastEditors: liaodaxue
|
|
10579
|
-
* @LastEditTime: 2023-
|
|
11064
|
+
* @LastEditTime: 2023-11-14 15:55:32
|
|
10580
11065
|
* @Description:
|
|
10581
11066
|
*/
|
|
10582
11067
|
|
|
@@ -10867,11 +11352,15 @@ async function getRelatedListSchema(
|
|
|
10867
11352
|
ctx
|
|
10868
11353
|
) {
|
|
10869
11354
|
const uiSchema = await getUISchema(objectName);
|
|
11355
|
+
if(!uiSchema){
|
|
11356
|
+
return {}
|
|
11357
|
+
}
|
|
11358
|
+
const listViewNames = map(uiSchema.list_views, 'name');
|
|
10870
11359
|
const listView = find(
|
|
10871
11360
|
uiSchema.list_views,
|
|
10872
11361
|
(listView, name) => {
|
|
10873
|
-
// 传入listViewName
|
|
10874
|
-
if(!listViewName){
|
|
11362
|
+
// 传入listViewName空值 或者 不存在 则取第一个
|
|
11363
|
+
if(!listViewName || listViewNames.indexOf(listViewName)<0){
|
|
10875
11364
|
listViewName = name;
|
|
10876
11365
|
}
|
|
10877
11366
|
return name === listViewName || listView._id === listViewName;
|
|
@@ -10920,7 +11409,11 @@ async function getRelatedListSchema(
|
|
|
10920
11409
|
if(setDataToComponentId){
|
|
10921
11410
|
if(payload.data.count){
|
|
10922
11411
|
setTimeout(function(){
|
|
10923
|
-
window
|
|
11412
|
+
// 设计器中获取不到window.$从而导致报错, 所以用纯js替换下。
|
|
11413
|
+
// window.$("." + setDataToComponentId + " .antd-Crud").removeClass("hidden");
|
|
11414
|
+
document.querySelectorAll("." + setDataToComponentId + " .antd-Crud").forEach(function(element) {
|
|
11415
|
+
element.classList.remove("hidden");
|
|
11416
|
+
});
|
|
10924
11417
|
}, 10);
|
|
10925
11418
|
}
|
|
10926
11419
|
};
|
|
@@ -10951,8 +11444,8 @@ async function getRelatedListSchema(
|
|
|
10951
11444
|
/*
|
|
10952
11445
|
* @Author: baozhoutao@steedos.com
|
|
10953
11446
|
* @Date: 2022-07-05 15:55:39
|
|
10954
|
-
* @LastEditors:
|
|
10955
|
-
* @LastEditTime: 2023-
|
|
11447
|
+
* @LastEditors: liaodaxue
|
|
11448
|
+
* @LastEditTime: 2023-10-20 11:38:25
|
|
10956
11449
|
* @Description:
|
|
10957
11450
|
*/
|
|
10958
11451
|
|
|
@@ -11281,8 +11774,8 @@ async function getListSchema(
|
|
|
11281
11774
|
"filtersFunction": listview_filters,
|
|
11282
11775
|
"sort": sort,
|
|
11283
11776
|
"ctx": ctx,
|
|
11284
|
-
"requestAdaptor": listView.requestAdaptor,
|
|
11285
|
-
"adaptor": listView.adaptor,
|
|
11777
|
+
"requestAdaptor": listView.requestAdaptor || ctx.requestAdaptor,
|
|
11778
|
+
"adaptor": listView.adaptor || ctx.adaptor,
|
|
11286
11779
|
"headerToolbarItems": ctx.headerToolbarItems,
|
|
11287
11780
|
"filterVisible": ctx.filterVisible,
|
|
11288
11781
|
"rowClassNameExpr": ctx.rowClassNameExpr,
|
|
@@ -13927,10 +14420,18 @@ const getOpinionFieldStepsName = (field, top_keywords) => {
|
|
|
13927
14420
|
* @Author: baozhoutao@steedos.com
|
|
13928
14421
|
* @Date: 2022-09-09 17:47:37
|
|
13929
14422
|
* @LastEditors: baozhoutao@steedos.com
|
|
13930
|
-
* @LastEditTime: 2023-
|
|
14423
|
+
* @LastEditTime: 2023-10-10 13:57:02
|
|
13931
14424
|
* @Description:
|
|
13932
14425
|
*/
|
|
13933
14426
|
|
|
14427
|
+
const getMoment = ()=>{
|
|
14428
|
+
if(window.amisRequire){
|
|
14429
|
+
return window.amisRequire("moment");
|
|
14430
|
+
}else if(window.moment){
|
|
14431
|
+
return window.moment;
|
|
14432
|
+
}
|
|
14433
|
+
};
|
|
14434
|
+
|
|
13934
14435
|
const getTrace = ({ instance, traceId }) => {
|
|
13935
14436
|
return find(instance.traces, (trace) => {
|
|
13936
14437
|
return trace._id === traceId;
|
|
@@ -14150,6 +14651,8 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
14150
14651
|
method: "get",
|
|
14151
14652
|
});
|
|
14152
14653
|
|
|
14654
|
+
const moment = getMoment();
|
|
14655
|
+
|
|
14153
14656
|
return {
|
|
14154
14657
|
box: box,
|
|
14155
14658
|
_id: instanceId,
|
|
@@ -14160,7 +14663,7 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
14160
14663
|
applicant_name: instance.applicant_name,
|
|
14161
14664
|
submitter: instance.submitter,
|
|
14162
14665
|
submit_date: instance.submit_date
|
|
14163
|
-
?
|
|
14666
|
+
? (moment && moment(instance.submit_date).format("YYYY-MM-DD"))
|
|
14164
14667
|
: "",
|
|
14165
14668
|
state: instance.state,
|
|
14166
14669
|
approveValues: values,
|
|
@@ -14200,8 +14703,7 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
14200
14703
|
finishDate = approve.is_read ? "已读" : "未处理";
|
|
14201
14704
|
judge = null;
|
|
14202
14705
|
} else {
|
|
14203
|
-
finishDate =
|
|
14204
|
-
amisRequire("moment")(finishDate).format("YYYY-MM-DD HH:mm");
|
|
14706
|
+
finishDate = moment && moment(finishDate).format("YYYY-MM-DD HH:mm");
|
|
14205
14707
|
}
|
|
14206
14708
|
|
|
14207
14709
|
switch (judge) {
|
|
@@ -14254,5 +14756,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
14254
14756
|
};
|
|
14255
14757
|
};
|
|
14256
14758
|
|
|
14257
|
-
export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
|
|
14759
|
+
export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
|
|
14258
14760
|
//# sourceMappingURL=index.esm.js.map
|