@steedos-widgets/amis-lib 3.6.2-beta.2 → 3.6.2-beta.21
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 +1363 -446
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1362 -447
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +364 -200
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/api.d.ts +2 -1
- package/dist/types/lib/converter/amis/fields/lookup.d.ts +2 -0
- package/dist/types/lib/converter/amis/header.d.ts +1 -56
- package/dist/types/lib/converter/amis/index.d.ts +0 -87
- package/dist/types/lib/converter/amis/toolbar.d.ts +7 -1
- package/dist/types/lib/converter/amis/util.d.ts +5 -0
- package/dist/types/lib/input_table.d.ts +24 -14
- package/dist/types/lib/objects.d.ts +78 -156
- package/dist/types/lib/objectsRelated.d.ts +19 -0
- package/dist/types/lib/page_init.d.ts +1 -38
- package/dist/types/schema/standard_import_data.amis.d.ts +7 -0
- package/dist/types/standard/button.d.ts +7 -0
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -367,22 +367,29 @@ const getSteedosAuth = () => {
|
|
|
367
367
|
* @Description:
|
|
368
368
|
*/
|
|
369
369
|
|
|
370
|
-
|
|
371
370
|
const Router = {
|
|
372
371
|
getTabDisplayAs(tab_id){
|
|
372
|
+
const uiSchema = getUISchemaSync$1(tab_id, false);
|
|
373
373
|
var urlSearch = new URLSearchParams(document.location.search);
|
|
374
374
|
if(urlSearch.has('display')){
|
|
375
375
|
return urlSearch.get('display')
|
|
376
376
|
}
|
|
377
377
|
const key = `tab_${tab_id}_display`;
|
|
378
378
|
// const key = `page_display`;
|
|
379
|
-
const value =
|
|
380
|
-
|
|
379
|
+
const value = sessionStorage.getItem(key);
|
|
380
|
+
let defaultDisplay = "grid";
|
|
381
|
+
if(uiSchema.enable_split){
|
|
382
|
+
defaultDisplay = "split";
|
|
383
|
+
}
|
|
384
|
+
if(window.innerWidth <= 768){
|
|
385
|
+
return "grid";
|
|
386
|
+
}
|
|
387
|
+
return value ? value : defaultDisplay;
|
|
381
388
|
},
|
|
382
389
|
|
|
383
390
|
setTabDisplayAs(tab_id, displayAs){
|
|
384
391
|
const key = `tab_${tab_id}_display`;
|
|
385
|
-
|
|
392
|
+
sessionStorage.setItem(key, displayAs);
|
|
386
393
|
},
|
|
387
394
|
getAppPath({formFactor, appId}){
|
|
388
395
|
return `/app/${appId}`;
|
|
@@ -409,8 +416,8 @@ const Router = {
|
|
|
409
416
|
/*
|
|
410
417
|
* @Author: baozhoutao@steedos.com
|
|
411
418
|
* @Date: 2022-07-20 16:29:22
|
|
412
|
-
* @LastEditors:
|
|
413
|
-
* @LastEditTime:
|
|
419
|
+
* @LastEditors: liaodaxue
|
|
420
|
+
* @LastEditTime: 2024-01-25 14:44:17
|
|
414
421
|
* @Description:
|
|
415
422
|
*/
|
|
416
423
|
|
|
@@ -482,11 +489,30 @@ function getComparableAmisVersion() {
|
|
|
482
489
|
}
|
|
483
490
|
}
|
|
484
491
|
|
|
492
|
+
/**
|
|
493
|
+
* 判断浏览器类型
|
|
494
|
+
* @returns 按需返回浏览器类型;
|
|
495
|
+
*/
|
|
496
|
+
function getBowserType() {
|
|
497
|
+
const userAgent = navigator.userAgent;
|
|
498
|
+
if (userAgent.indexOf("Chrome")!== -1 && userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Edg") === -1) {
|
|
499
|
+
return "Chrome";
|
|
500
|
+
} else if (userAgent.indexOf("Firefox") !== -1) {
|
|
501
|
+
return "Firefox";
|
|
502
|
+
} else if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1 && userAgent.indexOf("Edge") === -1) {
|
|
503
|
+
return "Safari";
|
|
504
|
+
} else if (userAgent.indexOf("Edg") !== -1) {
|
|
505
|
+
return "Edge";
|
|
506
|
+
} else {
|
|
507
|
+
return "Unknown browser"; // 其他浏览器...(可根据自己需要确定是否新增其他浏览器的判断)
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
485
511
|
/*
|
|
486
512
|
* @Author: baozhoutao@steedos.com
|
|
487
513
|
* @Date: 2022-05-23 09:53:08
|
|
488
514
|
* @LastEditors: liaodaxue
|
|
489
|
-
* @LastEditTime:
|
|
515
|
+
* @LastEditTime: 2024-01-17 16:00:27
|
|
490
516
|
* @Description:
|
|
491
517
|
*/
|
|
492
518
|
|
|
@@ -558,7 +584,7 @@ function getSelectMap(selectOptions){
|
|
|
558
584
|
|
|
559
585
|
function getNameTplUrl(field, ctx){
|
|
560
586
|
if(ctx.objectName === 'cms_files'){
|
|
561
|
-
return
|
|
587
|
+
return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
|
|
562
588
|
}
|
|
563
589
|
const href = Router.getObjectDetailPath({
|
|
564
590
|
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
@@ -1304,6 +1330,7 @@ var frontend_notifications$1 = "Notifications";
|
|
|
1304
1330
|
var frontend_notifications_allread$1 = "Mark all as read";
|
|
1305
1331
|
var frontend_notifications_allread_message$1 = "All marked as read";
|
|
1306
1332
|
var frontend_profile$1 = "Profile";
|
|
1333
|
+
var switch_space$1 = "Switch Space";
|
|
1307
1334
|
var frontend_about$1 = "About";
|
|
1308
1335
|
var frontend_log_out$1 = "Log out";
|
|
1309
1336
|
var frontend_listview_warning_start$1 = "The current ";
|
|
@@ -1391,6 +1418,7 @@ var en_us = {
|
|
|
1391
1418
|
frontend_notifications_allread: frontend_notifications_allread$1,
|
|
1392
1419
|
frontend_notifications_allread_message: frontend_notifications_allread_message$1,
|
|
1393
1420
|
frontend_profile: frontend_profile$1,
|
|
1421
|
+
switch_space: switch_space$1,
|
|
1394
1422
|
frontend_about: frontend_about$1,
|
|
1395
1423
|
frontend_log_out: frontend_log_out$1,
|
|
1396
1424
|
frontend_listview_warning_start: frontend_listview_warning_start$1,
|
|
@@ -1430,9 +1458,9 @@ var frontend_display_type_is_split = "分栏视图";
|
|
|
1430
1458
|
var frontend_display_as = "显示为";
|
|
1431
1459
|
var frontend_record_sum = "个项目";
|
|
1432
1460
|
var frontend_button_reload_tooltip = "刷新";
|
|
1433
|
-
var frontend_button_search_tooltip = "
|
|
1461
|
+
var frontend_button_search_tooltip = "搜索";
|
|
1434
1462
|
var frontend_fields_filter_button_search = "搜索";
|
|
1435
|
-
var frontend_fields_filter_button_settings = "
|
|
1463
|
+
var frontend_fields_filter_button_settings = "选择搜索项";
|
|
1436
1464
|
var frontend_button_listview_control_tooltip = "列表视图控制";
|
|
1437
1465
|
var frontend_button_listview_control_label = "列表视图控制";
|
|
1438
1466
|
var frontend_listview_control_columns = "显示的列";
|
|
@@ -1480,6 +1508,7 @@ var frontend_notifications = "通知";
|
|
|
1480
1508
|
var frontend_notifications_allread = "全部标记为已读";
|
|
1481
1509
|
var frontend_notifications_allread_message = "已全部标记为已读";
|
|
1482
1510
|
var frontend_profile = "个人资料";
|
|
1511
|
+
var switch_space = "切换工作区";
|
|
1483
1512
|
var frontend_about = "关于";
|
|
1484
1513
|
var frontend_log_out = "注销";
|
|
1485
1514
|
var frontend_listview_warning_start = "当前";
|
|
@@ -1568,6 +1597,7 @@ var zh_cn = {
|
|
|
1568
1597
|
frontend_notifications_allread: frontend_notifications_allread,
|
|
1569
1598
|
frontend_notifications_allread_message: frontend_notifications_allread_message,
|
|
1570
1599
|
frontend_profile: frontend_profile,
|
|
1600
|
+
switch_space: switch_space,
|
|
1571
1601
|
frontend_about: frontend_about,
|
|
1572
1602
|
frontend_log_out: frontend_log_out,
|
|
1573
1603
|
frontend_listview_warning_start: frontend_listview_warning_start,
|
|
@@ -1881,7 +1911,8 @@ async function getQuickEditSchema(field, options){
|
|
|
1881
1911
|
"failed": "失败了呢。。"
|
|
1882
1912
|
}
|
|
1883
1913
|
}
|
|
1884
|
-
}
|
|
1914
|
+
},
|
|
1915
|
+
"expression": "${!recordPermissions.modifyAllRecords}"
|
|
1885
1916
|
},
|
|
1886
1917
|
{
|
|
1887
1918
|
"actionType": "setValue",
|
|
@@ -1897,7 +1928,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1897
1928
|
"componentId": quickEditId,
|
|
1898
1929
|
"args": {
|
|
1899
1930
|
"value":{
|
|
1900
|
-
"quickedit_record_permissions": "${event.data}"
|
|
1931
|
+
"quickedit_record_permissions": "${recordPermissions.modifyAllRecords ? {'allowEdit': true} : event.data}"
|
|
1901
1932
|
}
|
|
1902
1933
|
}
|
|
1903
1934
|
}
|
|
@@ -1961,7 +1992,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1961
1992
|
`
|
|
1962
1993
|
}
|
|
1963
1994
|
},
|
|
1964
|
-
"expression":"${event.data.value}"
|
|
1995
|
+
"expression":"${event.data.value && !recordPermissions.modifyAllRecords}"
|
|
1965
1996
|
},
|
|
1966
1997
|
{
|
|
1967
1998
|
"actionType": "setValue",
|
|
@@ -1992,10 +2023,20 @@ async function getQuickEditSchema(field, options){
|
|
|
1992
2023
|
"script": `
|
|
1993
2024
|
const noPermission = event.data.noPermission;
|
|
1994
2025
|
const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
|
|
1995
|
-
|
|
2026
|
+
let selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
|
|
1996
2027
|
noPermission.forEach(function (item) {
|
|
1997
2028
|
crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
|
|
2029
|
+
_.remove(selectedItems, (selected) => selected._id === item);
|
|
1998
2030
|
})
|
|
2031
|
+
doAction({
|
|
2032
|
+
"componentId": "${quickEditId}",
|
|
2033
|
+
"actionType": "setValue",
|
|
2034
|
+
"args": {
|
|
2035
|
+
"value": {
|
|
2036
|
+
selectedItems
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
});
|
|
1999
2040
|
`
|
|
2000
2041
|
},
|
|
2001
2042
|
{
|
|
@@ -2056,7 +2097,7 @@ async function getQuickEditSchema(field, options){
|
|
|
2056
2097
|
}
|
|
2057
2098
|
|
|
2058
2099
|
function getFieldWidth(width){
|
|
2059
|
-
const defaultWidth =
|
|
2100
|
+
const defaultWidth = null;
|
|
2060
2101
|
if(typeof width == 'string'){
|
|
2061
2102
|
if(isNaN(width)){
|
|
2062
2103
|
return width || defaultWidth;
|
|
@@ -2086,18 +2127,35 @@ async function getTableColumns(fields, options){
|
|
|
2086
2127
|
//增加quickEdit属性,实现快速编辑
|
|
2087
2128
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
2088
2129
|
let className = "";
|
|
2089
|
-
|
|
2130
|
+
const bowserType = getBowserType();
|
|
2131
|
+
if(bowserType === "Safari"){
|
|
2090
2132
|
className += " whitespace-nowrap ";
|
|
2091
2133
|
}else {
|
|
2092
|
-
|
|
2134
|
+
if(field.wrap != true){
|
|
2135
|
+
className += " whitespace-nowrap ";
|
|
2136
|
+
}else {
|
|
2137
|
+
className += " break-words ";
|
|
2138
|
+
}
|
|
2093
2139
|
}
|
|
2140
|
+
|
|
2141
|
+
if (typeof field.amis?.className == "object") {
|
|
2142
|
+
className = {
|
|
2143
|
+
[className]: "true",
|
|
2144
|
+
...field.amis.className
|
|
2145
|
+
};
|
|
2146
|
+
} else if (typeof field.amis?.className == "string") {
|
|
2147
|
+
className = `${className} ${field.amis.className} `;
|
|
2148
|
+
}
|
|
2149
|
+
let fieldAmis = ___namespace.clone(field.amis);
|
|
2150
|
+
delete fieldAmis?.className;
|
|
2151
|
+
|
|
2094
2152
|
let columnItem;
|
|
2095
2153
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
2096
2154
|
const previewFileScript = `
|
|
2097
2155
|
var data = event.data;
|
|
2098
2156
|
var file_name = data.versions ? data.name : "${field.label}";
|
|
2099
|
-
var file_id = data._id;
|
|
2100
|
-
|
|
2157
|
+
var file_id = data.versions && data.versions[0] && data.versions[0]._id;
|
|
2158
|
+
window.previewFile && window.previewFile({file_name, file_id});
|
|
2101
2159
|
`;
|
|
2102
2160
|
columnItem = {
|
|
2103
2161
|
"type": "button",
|
|
@@ -2122,11 +2180,11 @@ async function getTableColumns(fields, options){
|
|
|
2122
2180
|
"expression": "!!!(window && window.nw && window.nw.require)"//浏览器上直接下载
|
|
2123
2181
|
},
|
|
2124
2182
|
{
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2183
|
+
"args": {},
|
|
2184
|
+
"actionType": "custom",
|
|
2185
|
+
"script": previewFileScript,
|
|
2186
|
+
// "expression": "!!window?.nw?.require" //PC客户端预览附件
|
|
2187
|
+
"expression": "!!(window && window.nw && window.nw.require)"//PC客户端预览附件
|
|
2130
2188
|
}
|
|
2131
2189
|
]
|
|
2132
2190
|
}
|
|
@@ -2141,7 +2199,7 @@ async function getTableColumns(fields, options){
|
|
|
2141
2199
|
toggled: field.toggled,
|
|
2142
2200
|
static: true,
|
|
2143
2201
|
className,
|
|
2144
|
-
},
|
|
2202
|
+
}, fieldAmis, {name: field.name});
|
|
2145
2203
|
}else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
|
|
2146
2204
|
columnItem = Object.assign({}, {
|
|
2147
2205
|
type: "switch",
|
|
@@ -2152,7 +2210,7 @@ async function getTableColumns(fields, options){
|
|
|
2152
2210
|
static: true,
|
|
2153
2211
|
className,
|
|
2154
2212
|
...getAmisFileReadonlySchema(field)
|
|
2155
|
-
},
|
|
2213
|
+
}, fieldAmis, {name: field.name});
|
|
2156
2214
|
}
|
|
2157
2215
|
else if(field.type === 'select'){
|
|
2158
2216
|
const map = getSelectMap(field.options);
|
|
@@ -2167,7 +2225,7 @@ async function getTableColumns(fields, options){
|
|
|
2167
2225
|
className,
|
|
2168
2226
|
inputClassName: "inline",
|
|
2169
2227
|
static: true,
|
|
2170
|
-
},
|
|
2228
|
+
}, fieldAmis, {name: field.name});
|
|
2171
2229
|
}
|
|
2172
2230
|
else {
|
|
2173
2231
|
const tpl = await getFieldTpl(field, options);
|
|
@@ -2186,23 +2244,14 @@ async function getTableColumns(fields, options){
|
|
|
2186
2244
|
if(field.type === 'textarea'){
|
|
2187
2245
|
className += 'min-w-56';
|
|
2188
2246
|
}
|
|
2189
|
-
if(field.type === 'date'){
|
|
2190
|
-
|
|
2191
|
-
}
|
|
2192
|
-
if(field.type === 'datetime'){
|
|
2193
|
-
|
|
2194
|
-
}
|
|
2247
|
+
// if(field.type === 'date'){
|
|
2248
|
+
// className += 'date-min-w';
|
|
2249
|
+
// }
|
|
2250
|
+
// if(field.type === 'datetime'){
|
|
2251
|
+
// className += 'datetime-min-w';
|
|
2252
|
+
// }
|
|
2195
2253
|
|
|
2196
2254
|
//field上的amis属性里的clssname需要单独判断类型合并
|
|
2197
|
-
if (typeof field.amis?.className == "object") {
|
|
2198
|
-
className = {
|
|
2199
|
-
[className]: "true",
|
|
2200
|
-
...field.amis.className
|
|
2201
|
-
};
|
|
2202
|
-
} else if (typeof field.amis?.className == "string") {
|
|
2203
|
-
className = `${className} ${field.amis.className} `;
|
|
2204
|
-
}
|
|
2205
|
-
delete field.amis?.className;
|
|
2206
2255
|
|
|
2207
2256
|
if(!field.hidden && !field.extra){
|
|
2208
2257
|
columnItem = Object.assign({}, {
|
|
@@ -2219,7 +2268,7 @@ async function getTableColumns(fields, options){
|
|
|
2219
2268
|
static: true,
|
|
2220
2269
|
options: field.type === 'html' ? {html: true} : null
|
|
2221
2270
|
// toggled: true
|
|
2222
|
-
},
|
|
2271
|
+
}, fieldAmis, {name: field.name});
|
|
2223
2272
|
|
|
2224
2273
|
if(field.type === 'color'){
|
|
2225
2274
|
columnItem.type = 'color';
|
|
@@ -2286,7 +2335,7 @@ function getMobileLines(tpls){
|
|
|
2286
2335
|
}
|
|
2287
2336
|
if(isLeft){
|
|
2288
2337
|
// 左侧半行
|
|
2289
|
-
lineChildrenClassName = "steedos-listview-item-left truncate";
|
|
2338
|
+
lineChildrenClassName = "steedos-listview-item-left truncate h-5";
|
|
2290
2339
|
if(item.field.is_wide){
|
|
2291
2340
|
// 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
|
|
2292
2341
|
lineChildrenClassName = "steedos-listview-item-wide";
|
|
@@ -2298,7 +2347,7 @@ function getMobileLines(tpls){
|
|
|
2298
2347
|
}
|
|
2299
2348
|
else {
|
|
2300
2349
|
// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
2301
|
-
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
|
|
2350
|
+
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
|
|
2302
2351
|
}
|
|
2303
2352
|
//支持字段amis属性配置classname,识别classname的类型,与原样式合并
|
|
2304
2353
|
var className;
|
|
@@ -2409,8 +2458,16 @@ async function getMobileTableColumns(fields, options){
|
|
|
2409
2458
|
"actions": [
|
|
2410
2459
|
{
|
|
2411
2460
|
"script": `
|
|
2412
|
-
let cms_url =
|
|
2413
|
-
|
|
2461
|
+
let cms_url = '';
|
|
2462
|
+
let value = event.data.versions[0];
|
|
2463
|
+
if(value){
|
|
2464
|
+
if(value.url){
|
|
2465
|
+
cms_url = value.url;
|
|
2466
|
+
}else{
|
|
2467
|
+
cms_url = Steedos.absoluteUrl("/api/files/files/"+value+"?download=true");
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
Steedos.cordovaDownload(encodeURI(cms_url), event.data.name);
|
|
2414
2471
|
`,
|
|
2415
2472
|
"actionType": "custom"
|
|
2416
2473
|
}
|
|
@@ -2525,7 +2582,8 @@ async function getTableOperation(ctx){
|
|
|
2525
2582
|
label: " ",
|
|
2526
2583
|
fixed: 'right',
|
|
2527
2584
|
labelClassName: 'text-center',
|
|
2528
|
-
|
|
2585
|
+
//TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
|
|
2586
|
+
className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
|
|
2529
2587
|
buttons: [
|
|
2530
2588
|
{
|
|
2531
2589
|
"type": "steedos-dropdown-button",
|
|
@@ -2621,7 +2679,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2621
2679
|
}
|
|
2622
2680
|
return {
|
|
2623
2681
|
mode: "cards",
|
|
2624
|
-
perPageAvailable: [
|
|
2682
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2625
2683
|
name: "thelist",
|
|
2626
2684
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2627
2685
|
className: "",
|
|
@@ -2654,7 +2712,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2654
2712
|
|
|
2655
2713
|
return {
|
|
2656
2714
|
mode: "table",
|
|
2657
|
-
perPageAvailable: [
|
|
2715
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2658
2716
|
name: "thelist",
|
|
2659
2717
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2660
2718
|
className: "",
|
|
@@ -2909,6 +2967,21 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2909
2967
|
return api;
|
|
2910
2968
|
`;
|
|
2911
2969
|
api.adaptor = `
|
|
2970
|
+
let fields = ${JSON.stringify(___namespace.map(fields, 'name'))};
|
|
2971
|
+
// 这里把行数据中所有为空的字段值配置为空字符串,是因为amis有bug:crud的columns中的列如果type为static-前缀的话,行数据中该字段为空的话会显示为父作用域中同名变量值,见:https://github.com/baidu/amis/issues/9556
|
|
2972
|
+
(payload.data.rows || []).forEach((itemRow) => {
|
|
2973
|
+
(fields || []).forEach((itemField) => {
|
|
2974
|
+
if(itemField && itemField.indexOf(".") > -1){
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
if(itemField && (itemRow[itemField] === undefined || itemRow[itemField] === null)){
|
|
2978
|
+
// 这里itemRow中不存在 itemField 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
|
|
2979
|
+
// 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
|
|
2980
|
+
itemRow[itemField] = "";
|
|
2981
|
+
}
|
|
2982
|
+
});
|
|
2983
|
+
});
|
|
2984
|
+
|
|
2912
2985
|
if(api.body.listName == "recent"){
|
|
2913
2986
|
payload.data.rows = _.sortBy(payload.data.rows, function(item){
|
|
2914
2987
|
return _.indexOf(api.body._ids, item._id)
|
|
@@ -2933,7 +3006,13 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2933
3006
|
value = [value]
|
|
2934
3007
|
};
|
|
2935
3008
|
if(field.type === 'file'){
|
|
2936
|
-
item[key] = value
|
|
3009
|
+
// item[key] = value
|
|
3010
|
+
// PC客户端附件子表列表点击标题预览附件功能依赖了_id,所以这里拼出来
|
|
3011
|
+
let itemKeyValue = item[key];
|
|
3012
|
+
item[key] = value.map(function(item, index){
|
|
3013
|
+
item._id = itemKeyValue[index];
|
|
3014
|
+
return item;
|
|
3015
|
+
});
|
|
2937
3016
|
}else{
|
|
2938
3017
|
item[key] = _.map(value, (item)=>{
|
|
2939
3018
|
if(field.type === 'image'){
|
|
@@ -2975,15 +3054,8 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2975
3054
|
}
|
|
2976
3055
|
});
|
|
2977
3056
|
};
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
isTreeOptionsComputed = true;
|
|
2981
|
-
}
|
|
2982
|
-
if(!isTreeOptionsComputed){
|
|
2983
|
-
// 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
|
|
2984
|
-
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
2985
|
-
assignIndexToTreeRecords(payload.data.rows, '');
|
|
2986
|
-
}
|
|
3057
|
+
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
3058
|
+
assignIndexToTreeRecords(payload.data.rows, '');
|
|
2987
3059
|
}
|
|
2988
3060
|
|
|
2989
3061
|
|
|
@@ -3040,12 +3112,15 @@ async function getTableApi(mainObject, fields, options){
|
|
|
3040
3112
|
}
|
|
3041
3113
|
// SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
3042
3114
|
};
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3115
|
+
let formFactor = "${options.formFactor}";
|
|
3116
|
+
if(formFactor !== "SMALL"){
|
|
3117
|
+
const listviewComponent = $(".steedos-object-listview .antd-Table-table");
|
|
3118
|
+
const firstListviewComponent = listviewComponent && listviewComponent[0];
|
|
3119
|
+
if(firstListviewComponent){
|
|
3120
|
+
setTimeout(()=>{
|
|
3121
|
+
firstListviewComponent.scrollIntoView();
|
|
3122
|
+
}, 600);
|
|
3123
|
+
}
|
|
3049
3124
|
}
|
|
3050
3125
|
${options.adaptor || ''}
|
|
3051
3126
|
return payload;
|
|
@@ -3158,12 +3233,21 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3158
3233
|
}
|
|
3159
3234
|
payload.data = data;
|
|
3160
3235
|
payload.data.__objectName = "${object.name}";
|
|
3161
|
-
payload.data.
|
|
3236
|
+
payload.data.record = record;
|
|
3237
|
+
|
|
3238
|
+
payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
|
|
3239
|
+
payload.data._master = {
|
|
3240
|
+
record: record,
|
|
3241
|
+
objectName: "${object.name}",
|
|
3242
|
+
recordId: record._id
|
|
3243
|
+
}
|
|
3162
3244
|
window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
|
|
3163
3245
|
}
|
|
3164
3246
|
if(payload.errors){
|
|
3165
3247
|
payload.status = 2;
|
|
3166
3248
|
payload.msg = payload.errors[0].message;
|
|
3249
|
+
}else{
|
|
3250
|
+
payload.data.recordLoaded = true;
|
|
3167
3251
|
}
|
|
3168
3252
|
${options && options.initApiAdaptor || ''}
|
|
3169
3253
|
return payload;
|
|
@@ -3306,7 +3390,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3306
3390
|
cache: API_CACHE,
|
|
3307
3391
|
requestAdaptor: `
|
|
3308
3392
|
// 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
|
|
3309
|
-
var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
|
|
3393
|
+
var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
|
|
3310
3394
|
if(!recordId){
|
|
3311
3395
|
// 新建则不请求任何数据
|
|
3312
3396
|
data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
|
|
@@ -3384,10 +3468,11 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3384
3468
|
...initialValues
|
|
3385
3469
|
}
|
|
3386
3470
|
${options.initApiAdaptor || ''}
|
|
3471
|
+
// console.log('getEditFormInitApi======>', payload);
|
|
3387
3472
|
return payload;
|
|
3388
3473
|
`,
|
|
3389
3474
|
responseData: {
|
|
3390
|
-
|
|
3475
|
+
"&": "$$",
|
|
3391
3476
|
editFormInited: true
|
|
3392
3477
|
},
|
|
3393
3478
|
data: data,
|
|
@@ -3426,6 +3511,18 @@ function getBatchDelete(objectName){
|
|
|
3426
3511
|
return {
|
|
3427
3512
|
method: 'post',
|
|
3428
3513
|
url: getApi$2(),
|
|
3514
|
+
adaptor: `
|
|
3515
|
+
if(payload.errors){
|
|
3516
|
+
payload.data.deleteErrorMessage = [];
|
|
3517
|
+
payload.errors.forEach(function(error){
|
|
3518
|
+
let errorRecord = error.path.map(function (item) {
|
|
3519
|
+
return item.split('delete__')[1].to_float() + 1;
|
|
3520
|
+
}).toString();
|
|
3521
|
+
payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
|
|
3522
|
+
})
|
|
3523
|
+
}
|
|
3524
|
+
return payload;
|
|
3525
|
+
`,
|
|
3429
3526
|
requestAdaptor: `
|
|
3430
3527
|
var ids = api.data.ids.split(",");
|
|
3431
3528
|
var deleteArray = [];
|
|
@@ -4220,7 +4317,7 @@ async function getListBody(fields, options){
|
|
|
4220
4317
|
|
|
4221
4318
|
function getDefaultParams(options){
|
|
4222
4319
|
return {
|
|
4223
|
-
perPage: options.top || options.perPage ||
|
|
4320
|
+
perPage: options.top || options.perPage || 20
|
|
4224
4321
|
}
|
|
4225
4322
|
}
|
|
4226
4323
|
|
|
@@ -4423,7 +4520,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
4423
4520
|
"objectApiName": "\${objectName}",
|
|
4424
4521
|
"recordId": "",
|
|
4425
4522
|
"mode": "edit",
|
|
4426
|
-
"layout": "normal"
|
|
4427
4523
|
};
|
|
4428
4524
|
|
|
4429
4525
|
if (payload && payload.schema) {
|
|
@@ -4855,9 +4951,16 @@ const getSchema$2 = (uiSchema) => {
|
|
|
4855
4951
|
"form": {
|
|
4856
4952
|
debug: false,
|
|
4857
4953
|
resetAfterSubmit: false,
|
|
4954
|
+
data: {
|
|
4955
|
+
editFormInited: true,
|
|
4956
|
+
},
|
|
4858
4957
|
initApi: {
|
|
4958
|
+
method: 'GET',
|
|
4859
4959
|
url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
|
|
4860
4960
|
sendOn: 'this.recordId',
|
|
4961
|
+
data: null,
|
|
4962
|
+
requestAdaptor: "return api;",
|
|
4963
|
+
adaptor: "return payload;",
|
|
4861
4964
|
responseData: {
|
|
4862
4965
|
importState: "${state}"
|
|
4863
4966
|
}
|
|
@@ -5128,7 +5231,7 @@ const StandardButtons = {
|
|
|
5128
5231
|
}
|
|
5129
5232
|
};
|
|
5130
5233
|
|
|
5131
|
-
const getGlobalData
|
|
5234
|
+
const getGlobalData = () => {
|
|
5132
5235
|
return {
|
|
5133
5236
|
now: new Date(),
|
|
5134
5237
|
};
|
|
@@ -5187,7 +5290,7 @@ const getButtonVisible = (button, ctx) => {
|
|
|
5187
5290
|
button._visible,
|
|
5188
5291
|
props.record,
|
|
5189
5292
|
"#",
|
|
5190
|
-
getGlobalData
|
|
5293
|
+
getGlobalData(),
|
|
5191
5294
|
props.userSession
|
|
5192
5295
|
);
|
|
5193
5296
|
};
|
|
@@ -5729,7 +5832,7 @@ async function getObjectFieldsFilterFormSchema(ctx) {
|
|
|
5729
5832
|
const formSchema = {
|
|
5730
5833
|
"type": "service",
|
|
5731
5834
|
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
5732
|
-
"className": ctx.formFactor === 'SMALL' ? "slds-filters__body p-0 mb-2 overflow-y-auto overflow-x-hidden" : "slds-filters__body p-0 sm:grid sm:gap-
|
|
5835
|
+
"className": ctx.formFactor === 'SMALL' ? "slds-filters__body p-0 mb-2 overflow-y-auto overflow-x-hidden" : "slds-filters__body p-0 sm:grid sm:gap-4 sm:grid-cols-4 p-2",
|
|
5733
5836
|
"style":{
|
|
5734
5837
|
"max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
|
|
5735
5838
|
},
|
|
@@ -6316,7 +6419,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
6316
6419
|
"className": "slds-filters"
|
|
6317
6420
|
},
|
|
6318
6421
|
"size": "xs",
|
|
6319
|
-
"className": `border-
|
|
6422
|
+
"className": `border-y slds-grid slds-grid_vertical slds-nowrap ${!ctx.isLookup && "mt-2"}`,
|
|
6320
6423
|
"visibleOn": "this.showFieldsFilter",
|
|
6321
6424
|
},
|
|
6322
6425
|
"className": "bg-white"
|
|
@@ -6504,7 +6607,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
|
|
|
6504
6607
|
"icon": "fa fa-refresh",
|
|
6505
6608
|
"actionType": "reload",
|
|
6506
6609
|
"target": amisListViewId,
|
|
6507
|
-
"className": "bg-white p-2 rounded
|
|
6610
|
+
"className": "bg-white p-2 rounded text-gray-500"
|
|
6508
6611
|
},
|
|
6509
6612
|
fieldsFilterButtonSchema,
|
|
6510
6613
|
// {
|
|
@@ -6512,7 +6615,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
|
|
|
6512
6615
|
// "label": "",
|
|
6513
6616
|
// "icon": "fa fa-filter",
|
|
6514
6617
|
// "actionType": "custom",
|
|
6515
|
-
// "className": "bg-transparent p-2 rounded
|
|
6618
|
+
// "className": "bg-transparent p-2 rounded text-gray-500",
|
|
6516
6619
|
// "id": "u:c20cb87d96c9",
|
|
6517
6620
|
// "onEvent": {
|
|
6518
6621
|
// "click": {
|
|
@@ -6560,11 +6663,53 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6560
6663
|
let headerSchema = [{
|
|
6561
6664
|
"type": "wrapper",
|
|
6562
6665
|
"body": body,
|
|
6563
|
-
"className": `
|
|
6666
|
+
"className": `sm:rounded-tl sm:rounded-tr p-4 -mb-4`
|
|
6564
6667
|
}];
|
|
6565
6668
|
return headerSchema;
|
|
6566
6669
|
}
|
|
6567
6670
|
|
|
6671
|
+
function getBackButtonSchema(){
|
|
6672
|
+
return {
|
|
6673
|
+
"type": "service",
|
|
6674
|
+
"onEvent": {
|
|
6675
|
+
"@history_paths.changed": {
|
|
6676
|
+
"actions": [
|
|
6677
|
+
{
|
|
6678
|
+
"actionType": "reload",
|
|
6679
|
+
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6680
|
+
"data": {
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
]
|
|
6684
|
+
}
|
|
6685
|
+
},
|
|
6686
|
+
"body":[{
|
|
6687
|
+
"type": "button",
|
|
6688
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6689
|
+
"className":"flex mr-4",
|
|
6690
|
+
"onEvent": {
|
|
6691
|
+
"click": {
|
|
6692
|
+
"actions": [
|
|
6693
|
+
{
|
|
6694
|
+
"actionType": "custom",
|
|
6695
|
+
"script": "window.goBack()"
|
|
6696
|
+
}
|
|
6697
|
+
]
|
|
6698
|
+
}
|
|
6699
|
+
},
|
|
6700
|
+
"body": [
|
|
6701
|
+
{
|
|
6702
|
+
"type": "steedos-icon",
|
|
6703
|
+
"category": "utility",
|
|
6704
|
+
"name": "back",
|
|
6705
|
+
"colorVariant": "default",
|
|
6706
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6707
|
+
}
|
|
6708
|
+
]
|
|
6709
|
+
}]
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6568
6713
|
/**
|
|
6569
6714
|
* 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
|
|
6570
6715
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -6573,11 +6718,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6573
6718
|
* @returns amisSchema
|
|
6574
6719
|
*/
|
|
6575
6720
|
async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
6721
|
+
// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
6576
6722
|
const { showRecordTitle = true } = options || {};
|
|
6577
6723
|
// console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
|
|
6578
6724
|
const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
|
|
6579
6725
|
|
|
6580
|
-
let amisButtonsSchema =
|
|
6726
|
+
let amisButtonsSchema = [];
|
|
6727
|
+
if(options.showButtons != false){
|
|
6728
|
+
amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
|
|
6729
|
+
}
|
|
6730
|
+
|
|
6731
|
+
let backButtonsSchema = null;
|
|
6732
|
+
|
|
6733
|
+
if(options.showBackButton != false){
|
|
6734
|
+
backButtonsSchema = getBackButtonSchema();
|
|
6735
|
+
}
|
|
6581
6736
|
|
|
6582
6737
|
// console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
|
|
6583
6738
|
|
|
@@ -6592,45 +6747,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6592
6747
|
"type": "grid",
|
|
6593
6748
|
"columns": [
|
|
6594
6749
|
{
|
|
6595
|
-
"body": [
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
"@history_paths.changed": {
|
|
6599
|
-
"actions": [
|
|
6600
|
-
{
|
|
6601
|
-
"actionType": "reload",
|
|
6602
|
-
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6603
|
-
"data": {
|
|
6604
|
-
}
|
|
6605
|
-
}
|
|
6606
|
-
]
|
|
6607
|
-
}
|
|
6608
|
-
},
|
|
6609
|
-
"body":[{
|
|
6610
|
-
"type": "button",
|
|
6611
|
-
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6612
|
-
"className":"flex mr-4",
|
|
6613
|
-
"onEvent": {
|
|
6614
|
-
"click": {
|
|
6615
|
-
"actions": [
|
|
6616
|
-
{
|
|
6617
|
-
"actionType": "custom",
|
|
6618
|
-
"script": "window.goBack()"
|
|
6619
|
-
}
|
|
6620
|
-
]
|
|
6621
|
-
}
|
|
6622
|
-
},
|
|
6623
|
-
"body": [
|
|
6624
|
-
{
|
|
6625
|
-
"type": "steedos-icon",
|
|
6626
|
-
"category": "utility",
|
|
6627
|
-
"name": "back",
|
|
6628
|
-
"colorVariant": "default",
|
|
6629
|
-
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6630
|
-
}
|
|
6631
|
-
]
|
|
6632
|
-
}]
|
|
6633
|
-
},{
|
|
6750
|
+
"body": [
|
|
6751
|
+
backButtonsSchema
|
|
6752
|
+
,{
|
|
6634
6753
|
"type": "tpl",
|
|
6635
6754
|
"className": "block",
|
|
6636
6755
|
// "tpl": `<img class='slds-icon slds-icon_container slds-icon-standard-${standardIcon}' src='\${context.rootUrl}/unpkg.com/@salesforce-ux/design-system/assets/icons/standard/${icon}.svg'>`
|
|
@@ -6651,8 +6770,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6651
6770
|
},
|
|
6652
6771
|
{
|
|
6653
6772
|
"type": "tpl",
|
|
6654
|
-
"tpl": "${
|
|
6655
|
-
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
6773
|
+
"tpl": "${NAME_FIELD_VALUE}",
|
|
6656
6774
|
"inline": false,
|
|
6657
6775
|
"wrapperComponent": "",
|
|
6658
6776
|
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
@@ -6680,7 +6798,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6680
6798
|
let body = [
|
|
6681
6799
|
{
|
|
6682
6800
|
"type": "wrapper",
|
|
6683
|
-
"className": "p-
|
|
6801
|
+
"className": "p-4 border-b",
|
|
6684
6802
|
"body": [
|
|
6685
6803
|
{
|
|
6686
6804
|
"type": "grid",
|
|
@@ -6695,7 +6813,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6695
6813
|
if(showRecordTitle){
|
|
6696
6814
|
body.push({
|
|
6697
6815
|
"type": "wrapper",
|
|
6698
|
-
"className": "p-
|
|
6816
|
+
"className": "p-4",
|
|
6699
6817
|
"body": [
|
|
6700
6818
|
{
|
|
6701
6819
|
"type": "grid",
|
|
@@ -6707,11 +6825,76 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6707
6825
|
});
|
|
6708
6826
|
}
|
|
6709
6827
|
|
|
6828
|
+
let max = 10;
|
|
6829
|
+
if(options.formFactor === 'SMALL'){
|
|
6830
|
+
max = 4;
|
|
6831
|
+
}else {
|
|
6832
|
+
|
|
6833
|
+
let divWidth = window.innerWidth;
|
|
6834
|
+
|
|
6835
|
+
if(options.display === 'split'){
|
|
6836
|
+
divWidth = divWidth - 388;
|
|
6837
|
+
}
|
|
6838
|
+
|
|
6839
|
+
if(document.body.classList.contains('sidebar')){
|
|
6840
|
+
divWidth = divWidth - 210;
|
|
6841
|
+
}
|
|
6842
|
+
|
|
6843
|
+
// 根据屏幕宽度计算显示数量, 使高亮字段只占1行
|
|
6844
|
+
max = Math.trunc(divWidth / 200 );
|
|
6845
|
+
if(max > 10){
|
|
6846
|
+
max = 10;
|
|
6847
|
+
}
|
|
6848
|
+
}
|
|
6849
|
+
|
|
6850
|
+
// console.log('=======================max=========================', max)
|
|
6851
|
+
|
|
6852
|
+
if(objectSchema.compactLayouts){
|
|
6853
|
+
const details = [];
|
|
6854
|
+
_.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
|
|
6855
|
+
const field = objectSchema.fields[fieldName];
|
|
6856
|
+
if(field){
|
|
6857
|
+
details.push({
|
|
6858
|
+
type: 'steedos-field',
|
|
6859
|
+
static: true,
|
|
6860
|
+
config: field,
|
|
6861
|
+
});
|
|
6862
|
+
}
|
|
6863
|
+
});
|
|
6864
|
+
|
|
6865
|
+
// 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
|
|
6866
|
+
// lg:grid-cols-1
|
|
6867
|
+
// lg:grid-cols-2
|
|
6868
|
+
// lg:grid-cols-3
|
|
6869
|
+
// lg:grid-cols-4
|
|
6870
|
+
// lg:grid-cols-5
|
|
6871
|
+
// lg:grid-cols-6
|
|
6872
|
+
// lg:grid-cols-7
|
|
6873
|
+
// lg:grid-cols-8
|
|
6874
|
+
// lg:grid-cols-9
|
|
6875
|
+
// lg:grid-cols-10
|
|
6876
|
+
// lg:grid-cols-11
|
|
6877
|
+
// lg:grid-cols-12
|
|
6878
|
+
|
|
6879
|
+
body.push({
|
|
6880
|
+
"type": "wrapper",
|
|
6881
|
+
"body": {
|
|
6882
|
+
"type": "form",
|
|
6883
|
+
// "className": "gap-2 grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-5 3xl:grid-cols-8 4xl:grid-cols-8 5xl:grid-cols-10", //max-h-12 overflow-hidden
|
|
6884
|
+
"className": `gap-2 grid grid-cols-1 lg:grid-cols-${max}`,
|
|
6885
|
+
"wrapWithPanel": false,
|
|
6886
|
+
"actions": [],
|
|
6887
|
+
"body": details,
|
|
6888
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
6889
|
+
},
|
|
6890
|
+
"className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
|
|
6891
|
+
});
|
|
6892
|
+
}
|
|
6893
|
+
|
|
6710
6894
|
return {
|
|
6711
6895
|
type: 'service',
|
|
6712
6896
|
id: `page_readonly_${name}_header`,
|
|
6713
6897
|
name: `page`,
|
|
6714
|
-
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
6715
6898
|
body: body,
|
|
6716
6899
|
className: ''
|
|
6717
6900
|
}
|
|
@@ -6783,7 +6966,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
6783
6966
|
"className": "flex justify-between"
|
|
6784
6967
|
}
|
|
6785
6968
|
],
|
|
6786
|
-
"className": "
|
|
6969
|
+
"className": "steedos-record-related-header py-2 px-3 bg-gray-50 border"
|
|
6787
6970
|
};
|
|
6788
6971
|
return recordRelatedListHeader;
|
|
6789
6972
|
}
|
|
@@ -7741,7 +7924,7 @@ const getSettingListviewToolbarButtonSchema = ()=>{
|
|
|
7741
7924
|
"icon": "fa fa-cog",
|
|
7742
7925
|
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
7743
7926
|
// "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
|
|
7744
|
-
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded
|
|
7927
|
+
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
|
|
7745
7928
|
"align": "right",
|
|
7746
7929
|
"visibleOn": "${!isLookup}",
|
|
7747
7930
|
"buttons": [
|
|
@@ -7768,14 +7951,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
7768
7951
|
{
|
|
7769
7952
|
"type": "button",
|
|
7770
7953
|
"label": i18next__default["default"].t('frontend_display_type_is_table'),
|
|
7771
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7954
|
+
"onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'grid');let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
|
|
7772
7955
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
7773
7956
|
"rightIconClassName": "m-l-sm"
|
|
7774
7957
|
},
|
|
7775
7958
|
{
|
|
7776
7959
|
"type": "button",
|
|
7777
7960
|
"label": i18next__default["default"].t('frontend_display_type_is_split'),
|
|
7778
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7961
|
+
"onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
7779
7962
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
7780
7963
|
"rightIconClassName": "m-l-sm"
|
|
7781
7964
|
}
|
|
@@ -7786,7 +7969,7 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
7786
7969
|
"icon": "fa fa-table-columns",
|
|
7787
7970
|
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
7788
7971
|
// "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
|
|
7789
|
-
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded
|
|
7972
|
+
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
|
|
7790
7973
|
"align": "right",
|
|
7791
7974
|
"visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
|
|
7792
7975
|
"buttons": [
|
|
@@ -7918,7 +8101,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7918
8101
|
{
|
|
7919
8102
|
"type": "search-box",
|
|
7920
8103
|
"name": keywordsSearchBoxName,
|
|
7921
|
-
"placeholder": "
|
|
8104
|
+
"placeholder": "快捷搜索",
|
|
7922
8105
|
"value": crudKeywords,
|
|
7923
8106
|
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7924
8107
|
"clearAndSubmit": true,
|
|
@@ -7979,7 +8162,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
7979
8162
|
// //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
7980
8163
|
// // "tooltip": i18next.t('frontend_button_reload_tooltip'),
|
|
7981
8164
|
// "tooltipPlacement": "top",
|
|
7982
|
-
// "className": "bg-white p-2 rounded
|
|
8165
|
+
// "className": "bg-white p-2 rounded text-gray-500",
|
|
7983
8166
|
// "label": "",
|
|
7984
8167
|
// "icon": "fa fa-sync",
|
|
7985
8168
|
// "visibleOn": "${!showFieldsFilter}",
|
|
@@ -8003,7 +8186,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
8003
8186
|
// "tooltip": i18next.t('frontend_button_reload_tooltip'),
|
|
8004
8187
|
"tooltip":"",
|
|
8005
8188
|
"tooltipPlacement": "top",
|
|
8006
|
-
"className": "bg-white p-2 rounded
|
|
8189
|
+
"className": "bg-white p-2 rounded text-gray-500"
|
|
8007
8190
|
};
|
|
8008
8191
|
}
|
|
8009
8192
|
else {
|
|
@@ -8014,7 +8197,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
8014
8197
|
// "tooltip": i18next.t('frontend_button_reload_tooltip'),
|
|
8015
8198
|
"tooltip":"",
|
|
8016
8199
|
"tooltipPlacement": "top",
|
|
8017
|
-
"className": "bg-white p-2 rounded
|
|
8200
|
+
"className": "bg-white p-2 rounded text-gray-500"
|
|
8018
8201
|
};
|
|
8019
8202
|
}
|
|
8020
8203
|
let toolbarFilter;
|
|
@@ -8036,7 +8219,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
8036
8219
|
"visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
|
|
8037
8220
|
},
|
|
8038
8221
|
"align": "right",
|
|
8039
|
-
"className": "bg-white p-2 rounded
|
|
8222
|
+
"className": "bg-white p-2 rounded text-gray-500",
|
|
8040
8223
|
"onEvent": {
|
|
8041
8224
|
"click": {
|
|
8042
8225
|
"actions": [
|
|
@@ -8122,7 +8305,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8122
8305
|
// ]
|
|
8123
8306
|
if(options.displayAs === 'split'){
|
|
8124
8307
|
return [
|
|
8125
|
-
|
|
8308
|
+
{
|
|
8309
|
+
"type": "switch-per-page",
|
|
8310
|
+
"visibleOn": "${count >= 20}"
|
|
8311
|
+
},
|
|
8126
8312
|
{
|
|
8127
8313
|
"type": "pagination",
|
|
8128
8314
|
"maxButtons": 5,
|
|
@@ -8144,7 +8330,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8144
8330
|
else {
|
|
8145
8331
|
if(options && options.isRelated){
|
|
8146
8332
|
return [
|
|
8147
|
-
"statistics",
|
|
8148
8333
|
{
|
|
8149
8334
|
"type": "pagination",
|
|
8150
8335
|
"maxButtons": 10,
|
|
@@ -8157,7 +8342,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8157
8342
|
const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
|
|
8158
8343
|
const is_lookup = options.isLookup;
|
|
8159
8344
|
const commonConfig = [
|
|
8160
|
-
"statistics",
|
|
8161
8345
|
{
|
|
8162
8346
|
"type": "pagination",
|
|
8163
8347
|
"maxButtons": 10,
|
|
@@ -8168,7 +8352,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8168
8352
|
if (no_pagination && is_lookup) {
|
|
8169
8353
|
return commonConfig;
|
|
8170
8354
|
} else {
|
|
8171
|
-
return [
|
|
8355
|
+
return [{
|
|
8356
|
+
"type": "switch-per-page",
|
|
8357
|
+
"visibleOn": "${count >= 20}"
|
|
8358
|
+
}, ...commonConfig];
|
|
8172
8359
|
}
|
|
8173
8360
|
}
|
|
8174
8361
|
}
|
|
@@ -8192,7 +8379,6 @@ async function getObjectFilter(objectSchema, fields, options) {
|
|
|
8192
8379
|
"timeOut": 1000
|
|
8193
8380
|
}
|
|
8194
8381
|
});
|
|
8195
|
-
resizeWindow();
|
|
8196
8382
|
const scope = event.context.scoped;
|
|
8197
8383
|
// let filterFormValues = event.data;
|
|
8198
8384
|
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
@@ -8276,6 +8462,29 @@ function getBulkActions(objectSchema){
|
|
|
8276
8462
|
"className": "hidden",
|
|
8277
8463
|
"id": "batchDelete",
|
|
8278
8464
|
"api": getBatchDelete(objectSchema.name),
|
|
8465
|
+
"feedback": {
|
|
8466
|
+
"title": "删除警告",
|
|
8467
|
+
"visibleOn": "${deleteErrorMessage}",
|
|
8468
|
+
"body": [
|
|
8469
|
+
{
|
|
8470
|
+
"type": "each",
|
|
8471
|
+
"name": "deleteErrorMessage",
|
|
8472
|
+
"items": {
|
|
8473
|
+
"type": "alert",
|
|
8474
|
+
"body": "${item}",
|
|
8475
|
+
"level": "danger",
|
|
8476
|
+
"className": "mb-3"
|
|
8477
|
+
}
|
|
8478
|
+
}
|
|
8479
|
+
],
|
|
8480
|
+
"actions": [
|
|
8481
|
+
{
|
|
8482
|
+
"type": "button",
|
|
8483
|
+
"actionType": "close",
|
|
8484
|
+
"label": "关闭"
|
|
8485
|
+
}
|
|
8486
|
+
]
|
|
8487
|
+
}
|
|
8279
8488
|
}
|
|
8280
8489
|
// {
|
|
8281
8490
|
// "label": "批量修改",
|
|
@@ -8336,7 +8545,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8336
8545
|
const bodyProps = {
|
|
8337
8546
|
// toolbar: getToolbar(),
|
|
8338
8547
|
// headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
|
|
8339
|
-
headerToolbarClassName: "px-4 py-2 border-
|
|
8548
|
+
headerToolbarClassName: "px-4 py-2 border-b",
|
|
8340
8549
|
footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
|
|
8341
8550
|
...options,
|
|
8342
8551
|
disableStatistics: options.queryCount === false
|
|
@@ -8472,7 +8681,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8472
8681
|
// "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8473
8682
|
// },
|
|
8474
8683
|
bodyClassName: {
|
|
8475
|
-
"
|
|
8684
|
+
"mb-0": true,
|
|
8476
8685
|
"is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8477
8686
|
},
|
|
8478
8687
|
crudClassName: crudClassName,
|
|
@@ -8483,16 +8692,11 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8483
8692
|
headers: {
|
|
8484
8693
|
Authorization: "Bearer ${context.tenantId},${context.authToken}",
|
|
8485
8694
|
},
|
|
8486
|
-
requestAdaptor: quickSaveApiRequestAdaptor
|
|
8487
|
-
adaptor: `
|
|
8488
|
-
if(payload.errors){
|
|
8489
|
-
payload.status = 2;
|
|
8490
|
-
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
8491
|
-
}
|
|
8492
|
-
return payload;
|
|
8493
|
-
`
|
|
8695
|
+
requestAdaptor: quickSaveApiRequestAdaptor
|
|
8494
8696
|
},
|
|
8495
|
-
rowClassNameExpr
|
|
8697
|
+
// 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
|
|
8698
|
+
// 使用表达式给tr添加初始选中状态
|
|
8699
|
+
rowClassNameExpr: options.rowClassNameExpr || "<%= data._id === data.recordId ? 'steedos-record-tr steedos-record-tr-' + data._id + ' steedos-record-selected' : 'steedos-record-tr steedos-record-tr-' + data._id %>"
|
|
8496
8700
|
}, bodyProps);
|
|
8497
8701
|
|
|
8498
8702
|
}
|
|
@@ -8505,9 +8709,23 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8505
8709
|
crudModeClassName = `steedos-crud-mode-${body.mode}`;
|
|
8506
8710
|
}
|
|
8507
8711
|
|
|
8712
|
+
body.quickSaveApi.adaptor = `
|
|
8713
|
+
if(payload.errors){
|
|
8714
|
+
payload.status = 2;
|
|
8715
|
+
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
8716
|
+
}
|
|
8717
|
+
var scope = SteedosUI.getRef(context.scopeId);
|
|
8718
|
+
var scopeParent = scope && scope.parent;
|
|
8719
|
+
var crudScoped = scopeParent.getComponentById('${body.id}');
|
|
8720
|
+
setTimeout(()=>{
|
|
8721
|
+
crudScoped && crudScoped.control.updateAutoFillHeight();
|
|
8722
|
+
}, 500);
|
|
8723
|
+
return payload;
|
|
8724
|
+
`;
|
|
8725
|
+
|
|
8508
8726
|
if(body.columns && options.formFactor != 'SMALL'){
|
|
8509
8727
|
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8510
|
-
body.columns.splice(body.columns.length -
|
|
8728
|
+
body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
|
|
8511
8729
|
}
|
|
8512
8730
|
|
|
8513
8731
|
if (defaults) {
|
|
@@ -8565,11 +8783,6 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8565
8783
|
}
|
|
8566
8784
|
}
|
|
8567
8785
|
|
|
8568
|
-
const getGlobalData = (mode)=>{
|
|
8569
|
-
const user = getSteedosAuth();
|
|
8570
|
-
return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
|
|
8571
|
-
};
|
|
8572
|
-
|
|
8573
8786
|
const getFormFields$1 = (objectSchema, formProps)=>{
|
|
8574
8787
|
/**
|
|
8575
8788
|
* fieldsExtend: 重写字段定义
|
|
@@ -8631,7 +8844,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
|
|
|
8631
8844
|
}
|
|
8632
8845
|
|
|
8633
8846
|
async function getObjectForm(objectSchema, ctx){
|
|
8634
|
-
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8847
|
+
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
|
|
8635
8848
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8636
8849
|
const fields = ___default["default"].values(objectSchema.fields);
|
|
8637
8850
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8647,9 +8860,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8647
8860
|
id: `service_${formSchema.id}`,
|
|
8648
8861
|
className: 'p-0',
|
|
8649
8862
|
name: `page_edit_${recordId}`,
|
|
8650
|
-
api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8651
8863
|
data:{
|
|
8652
|
-
editFormInited: false,
|
|
8653
8864
|
...amisData
|
|
8654
8865
|
},
|
|
8655
8866
|
// data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
@@ -8658,8 +8869,9 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8658
8869
|
body: [defaultsDeep({}, formSchema, {
|
|
8659
8870
|
type: "form",
|
|
8660
8871
|
mode: layout,
|
|
8872
|
+
initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8661
8873
|
data: {
|
|
8662
|
-
|
|
8874
|
+
editFormInited: false,
|
|
8663
8875
|
},
|
|
8664
8876
|
labelAlign,
|
|
8665
8877
|
persistData: false,
|
|
@@ -8673,11 +8885,15 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8673
8885
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
8674
8886
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
8675
8887
|
initFetch: recordId != 'new',
|
|
8676
|
-
body:
|
|
8888
|
+
body: {
|
|
8889
|
+
type: 'wrapper',
|
|
8890
|
+
className: 'p-0 m-0',
|
|
8891
|
+
body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
|
|
8892
|
+
hiddenOn: "${editFormInited != true}",
|
|
8893
|
+
},
|
|
8677
8894
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
8678
8895
|
bodyClassName: 'p-0',
|
|
8679
8896
|
className: 'steedos-amis-form',
|
|
8680
|
-
hiddenOn: "${editFormInited != true}",
|
|
8681
8897
|
onEvent: {
|
|
8682
8898
|
"submitSucc": {
|
|
8683
8899
|
"weight": 0,
|
|
@@ -8722,7 +8938,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8722
8938
|
}
|
|
8723
8939
|
|
|
8724
8940
|
async function getObjectDetail(objectSchema, recordId, ctx){
|
|
8725
|
-
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8941
|
+
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
|
|
8726
8942
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8727
8943
|
const fields = ___default["default"].values(objectSchema.fields);
|
|
8728
8944
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8731,8 +8947,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8731
8947
|
type: 'service',
|
|
8732
8948
|
name: `page_readonly_${recordId}`,
|
|
8733
8949
|
id: serviceId,
|
|
8734
|
-
|
|
8735
|
-
api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8950
|
+
// api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8736
8951
|
body: [
|
|
8737
8952
|
{
|
|
8738
8953
|
"type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
|
|
@@ -8758,60 +8973,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8758
8973
|
),
|
|
8759
8974
|
className: 'steedos-amis-form bg-white',
|
|
8760
8975
|
actions: [], // 不显示表单默认的提交按钮
|
|
8761
|
-
onEvent: {
|
|
8762
|
-
[`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
|
|
8763
|
-
"actions": [
|
|
8764
|
-
{
|
|
8765
|
-
"actionType": "reload",
|
|
8766
|
-
"componentId": serviceId,
|
|
8767
|
-
"expression": "this.__deletedRecord != true"
|
|
8768
|
-
},
|
|
8769
|
-
{
|
|
8770
|
-
// "args": {
|
|
8771
|
-
// "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
|
|
8772
|
-
// "blank": false
|
|
8773
|
-
// },
|
|
8774
|
-
"actionType": "custom",
|
|
8775
|
-
"script": "window.goBack()",
|
|
8776
|
-
"expression": "this.__deletedRecord === true"
|
|
8777
|
-
}
|
|
8778
|
-
]
|
|
8779
|
-
}
|
|
8780
|
-
}
|
|
8781
8976
|
},
|
|
8782
8977
|
}
|
|
8783
8978
|
],
|
|
8784
|
-
onEvent: {
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
}
|
|
8979
|
+
// onEvent: {
|
|
8980
|
+
// "fetchInited": {
|
|
8981
|
+
// "weight": 0,
|
|
8982
|
+
// "actions": [
|
|
8983
|
+
// {
|
|
8984
|
+
// actionType: 'broadcast',
|
|
8985
|
+
// eventName: "recordLoaded",
|
|
8986
|
+
// args: {
|
|
8987
|
+
// eventName: "recordLoaded"
|
|
8988
|
+
// },
|
|
8989
|
+
// data: {
|
|
8990
|
+
// objectName: "${event.data.__objectName}",
|
|
8991
|
+
// record: "${event.data.__record}"
|
|
8992
|
+
// },
|
|
8993
|
+
// expression: "${event.data.__response.error != true}"
|
|
8994
|
+
// },
|
|
8995
|
+
// {
|
|
8996
|
+
// "actionType": "setValue",
|
|
8997
|
+
// "args": {
|
|
8998
|
+
// value: {
|
|
8999
|
+
// "recordLoaded": true,
|
|
9000
|
+
// }
|
|
9001
|
+
// },
|
|
9002
|
+
// expression: "${event.data.__response.error != true}"
|
|
9003
|
+
// }
|
|
9004
|
+
// ]
|
|
9005
|
+
// }
|
|
9006
|
+
// }
|
|
8812
9007
|
};
|
|
8813
9008
|
|
|
8814
9009
|
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
9010
|
+
// console.log('getObjectDetail=====>', amisSchema);
|
|
8815
9011
|
return amisSchema;
|
|
8816
9012
|
}
|
|
8817
9013
|
|
|
@@ -8891,8 +9087,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
8891
9087
|
/*
|
|
8892
9088
|
* @Author: baozhoutao@steedos.com
|
|
8893
9089
|
* @Date: 2022-07-05 15:55:39
|
|
8894
|
-
* @LastEditors:
|
|
8895
|
-
* @LastEditTime:
|
|
9090
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9091
|
+
* @LastEditTime: 2024-01-24 10:18:17
|
|
8896
9092
|
* @Description:
|
|
8897
9093
|
*/
|
|
8898
9094
|
|
|
@@ -8991,7 +9187,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
8991
9187
|
const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
8992
9188
|
mainRelated[arr[0]] = foreign_key_value;
|
|
8993
9189
|
}
|
|
8994
|
-
}
|
|
9190
|
+
}
|
|
9191
|
+
// 防止related_lists中没有相关子表,但是details中有相关子表的情况
|
|
9192
|
+
if(!mainRelated[relatedObjectName]){
|
|
8995
9193
|
const details = _$1.union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
|
|
8996
9194
|
for (const detail of details) {
|
|
8997
9195
|
const arr = detail.split(".");
|
|
@@ -9067,7 +9265,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9067
9265
|
setDataToComponentId: componentId,
|
|
9068
9266
|
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
9069
9267
|
appId: appId,
|
|
9070
|
-
crudClassName: '
|
|
9268
|
+
crudClassName: 'steedos-record-related-crud hidden',
|
|
9071
9269
|
refField,
|
|
9072
9270
|
...ctx
|
|
9073
9271
|
};
|
|
@@ -9080,7 +9278,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9080
9278
|
amisSchema: {
|
|
9081
9279
|
type: "service",
|
|
9082
9280
|
id: componentId,
|
|
9083
|
-
className: `steedos-record-related-list
|
|
9281
|
+
className: `steedos-record-related-list mb-4 last:mb-0 ${componentId} ${className}`,
|
|
9084
9282
|
data: {
|
|
9085
9283
|
relatedKey: relatedKey,
|
|
9086
9284
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
@@ -9272,11 +9470,44 @@ async function getRelatedListSchema(
|
|
|
9272
9470
|
};
|
|
9273
9471
|
}
|
|
9274
9472
|
|
|
9473
|
+
async function getObjectRelatedListsMiniSchema(objectApiName){
|
|
9474
|
+
const relatedLists = await getObjectRelatedList(objectApiName);
|
|
9475
|
+
|
|
9476
|
+
const relatedListsMiniSchema = [];
|
|
9477
|
+
|
|
9478
|
+
for (const relatedList of relatedLists) {
|
|
9479
|
+
relatedListsMiniSchema.push(
|
|
9480
|
+
{
|
|
9481
|
+
type: 'steedos-record-detail-list-mini',
|
|
9482
|
+
objectApiName: objectApiName,
|
|
9483
|
+
// recordId: recordId,
|
|
9484
|
+
formFactor: formFactor,
|
|
9485
|
+
relatedObjectApiName: relatedList.object_name,
|
|
9486
|
+
foreign_key: relatedList.foreign_key,
|
|
9487
|
+
relatedKey: relatedList.foreign_key,
|
|
9488
|
+
columns: relatedList.columns,
|
|
9489
|
+
sort: relatedList.sort,
|
|
9490
|
+
filters: relatedList.filters,
|
|
9491
|
+
visible_on: relatedList.visible_on,
|
|
9492
|
+
perPage: relatedList.page_size || perPage,
|
|
9493
|
+
hiddenEmptyTable: true,
|
|
9494
|
+
relatedLabel: relatedList.label
|
|
9495
|
+
}
|
|
9496
|
+
);
|
|
9497
|
+
}
|
|
9498
|
+
|
|
9499
|
+
return {
|
|
9500
|
+
type: 'wrapper',
|
|
9501
|
+
className: "steedos-record-detail-related-lists-mini",
|
|
9502
|
+
body: relatedListsMiniSchema
|
|
9503
|
+
}
|
|
9504
|
+
}
|
|
9505
|
+
|
|
9275
9506
|
/*
|
|
9276
9507
|
* @Author: baozhoutao@steedos.com
|
|
9277
9508
|
* @Date: 2022-07-05 15:55:39
|
|
9278
|
-
* @LastEditors:
|
|
9279
|
-
* @LastEditTime:
|
|
9509
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9510
|
+
* @LastEditTime: 2024-01-16 11:14:34
|
|
9280
9511
|
* @Description:
|
|
9281
9512
|
*/
|
|
9282
9513
|
|
|
@@ -9448,7 +9679,7 @@ async function getField(objectName, fieldName) {
|
|
|
9448
9679
|
async function getFormSchema(objectName, ctx) {
|
|
9449
9680
|
const uiSchema = await getUISchema(objectName);
|
|
9450
9681
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
9451
|
-
console.log(`getFormSchema====>`, amisSchema)
|
|
9682
|
+
// console.log(`getFormSchema====>`, amisSchema)
|
|
9452
9683
|
return {
|
|
9453
9684
|
uiSchema,
|
|
9454
9685
|
amisSchema,
|
|
@@ -9774,118 +10005,172 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9774
10005
|
"label": "对象表单",
|
|
9775
10006
|
"objectApiName": "${objectName}",
|
|
9776
10007
|
"recordId": "${recordId}",
|
|
9777
|
-
"id": "u:d4a495811d57",
|
|
9778
10008
|
appId: appId
|
|
9779
10009
|
}
|
|
9780
10010
|
],
|
|
9781
|
-
"id": "u:5d4e7e3f6ecc"
|
|
9782
10011
|
};
|
|
9783
10012
|
const related = {
|
|
9784
10013
|
"title": i18next__default["default"].t('frontend_record_detail_tab_related'),
|
|
9785
|
-
"className": "px-0
|
|
10014
|
+
"className": "px-0 py-4",
|
|
9786
10015
|
"body": [
|
|
9787
10016
|
{
|
|
9788
10017
|
"type": "steedos-object-related-lists",
|
|
9789
10018
|
"label": "相关列表",
|
|
9790
10019
|
"objectApiName": "${objectName}",
|
|
9791
10020
|
"recordId": "${recordId}",
|
|
9792
|
-
"id": "u:3b85b7b7a7f6",
|
|
9793
10021
|
appId: appId
|
|
9794
10022
|
}
|
|
9795
10023
|
],
|
|
9796
|
-
"id": "u:1a0326aeec2b"
|
|
9797
10024
|
};
|
|
9798
10025
|
const content = {
|
|
9799
10026
|
"type": "tabs",
|
|
9800
|
-
"className": "
|
|
10027
|
+
"className": "steedos-record-tabs bg-white p-4 mt-3 border-y",
|
|
10028
|
+
"contentClassName": "bg-none",
|
|
9801
10029
|
"tabs": [
|
|
9802
10030
|
detailed
|
|
9803
10031
|
],
|
|
9804
|
-
"id": "u:a649e4094a12"
|
|
9805
10032
|
};
|
|
9806
10033
|
if(relatedLists.length){
|
|
9807
10034
|
content.tabs.push(related);
|
|
9808
10035
|
}
|
|
10036
|
+
// content.tabs = reverse(content.tabs)
|
|
9809
10037
|
return {
|
|
9810
10038
|
uiSchema,
|
|
9811
10039
|
amisSchema: {
|
|
9812
|
-
"type": "service",
|
|
10040
|
+
"type": "steedos-record-service",
|
|
9813
10041
|
"body": [
|
|
9814
10042
|
{
|
|
9815
10043
|
"type": "steedos-record-detail-header",
|
|
9816
10044
|
"label": "标题面板",
|
|
9817
10045
|
"objectApiName": "${objectName}",
|
|
9818
10046
|
"recordId": "${recordId}",
|
|
9819
|
-
"id": "u:48d2c28eb755"
|
|
10047
|
+
"id": "u:48d2c28eb755",
|
|
10048
|
+
"showButtons": props.showButtons,
|
|
10049
|
+
"showBackButton": props.showBackButton,
|
|
9820
10050
|
},
|
|
9821
10051
|
content
|
|
9822
10052
|
],
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
},
|
|
9827
|
-
onEvent: {
|
|
9828
|
-
"recordLoaded": {
|
|
9829
|
-
"actions": [
|
|
9830
|
-
{
|
|
9831
|
-
"actionType": "reload",
|
|
9832
|
-
"data": {
|
|
9833
|
-
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
9834
|
-
"_master.record": `\${record}`,
|
|
9835
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
9836
|
-
"_master.objectName": "${objectName}",
|
|
9837
|
-
"_master.recordId": "${recordId}"
|
|
9838
|
-
}
|
|
9839
|
-
}
|
|
9840
|
-
]
|
|
9841
|
-
},
|
|
9842
|
-
...props.onEvent
|
|
9843
|
-
},
|
|
10053
|
+
"objectApiName": "${objectName}",
|
|
10054
|
+
"recordId": "${recordId}",
|
|
10055
|
+
onEvent: props.onEvent,
|
|
9844
10056
|
}
|
|
9845
10057
|
}
|
|
9846
10058
|
}
|
|
9847
10059
|
|
|
9848
|
-
async function getRecordServiceSchema(objectName, appId, props = {}) {
|
|
10060
|
+
async function getRecordServiceSchema(objectName, appId, props = {}, body) {
|
|
9849
10061
|
const uiSchema = await getUISchema(objectName);
|
|
10062
|
+
const fields = ___default["default"].values(uiSchema.fields);
|
|
10063
|
+
const serviceId = `u:steedos-record-service-${objectName}`;
|
|
9850
10064
|
return {
|
|
9851
10065
|
uiSchema,
|
|
9852
10066
|
amisSchema: {
|
|
9853
|
-
|
|
9854
|
-
"
|
|
9855
|
-
data: {
|
|
9856
|
-
"_master.objectName": "${objectName}",
|
|
9857
|
-
"_master.recordId": "${recordId}"
|
|
9858
|
-
},
|
|
9859
|
-
"style": {
|
|
9860
|
-
"padding": "var(--Page-body-padding)",
|
|
9861
|
-
...props.style
|
|
9862
|
-
},
|
|
10067
|
+
type: 'service',
|
|
10068
|
+
className: "p-0 m-0",
|
|
9863
10069
|
onEvent: {
|
|
9864
|
-
|
|
10070
|
+
[`@data.changed.${objectName}`]: {
|
|
9865
10071
|
"actions": [
|
|
9866
10072
|
{
|
|
9867
10073
|
"actionType": "reload",
|
|
9868
|
-
"
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
10074
|
+
"componentId": serviceId,
|
|
10075
|
+
"expression": "this.__deletedRecord != true"
|
|
10076
|
+
},
|
|
10077
|
+
{
|
|
10078
|
+
"actionType": "custom",
|
|
10079
|
+
"script": "window.goBack()",
|
|
10080
|
+
"expression": "this.__deletedRecord === true"
|
|
9875
10081
|
}
|
|
9876
10082
|
]
|
|
9877
10083
|
},
|
|
9878
|
-
|
|
10084
|
+
},
|
|
10085
|
+
body: {
|
|
10086
|
+
"type": "service",
|
|
10087
|
+
id: serviceId,
|
|
10088
|
+
className: 'steedos-record-service p-0',
|
|
10089
|
+
api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
10090
|
+
body: {
|
|
10091
|
+
"type": "wrapper",
|
|
10092
|
+
"className": "p-0 m-0",
|
|
10093
|
+
"body": body || [],
|
|
10094
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
10095
|
+
},
|
|
10096
|
+
data: {
|
|
10097
|
+
"_master.objectName": "${objectName}",
|
|
10098
|
+
"_master.recordId": "${recordId}",
|
|
10099
|
+
...(props.data || {})
|
|
10100
|
+
},
|
|
10101
|
+
"style": {
|
|
10102
|
+
// "padding": "var(--Page-body-padding)",
|
|
10103
|
+
...props.style
|
|
10104
|
+
},
|
|
10105
|
+
onEvent: {
|
|
10106
|
+
// 如果定义了fetchInited,则无法接收到广播事件@data.changed
|
|
10107
|
+
"fetchInited": {
|
|
10108
|
+
"weight": 0,
|
|
10109
|
+
"actions": [
|
|
10110
|
+
{
|
|
10111
|
+
actionType: 'broadcast',
|
|
10112
|
+
eventName: "recordLoaded",
|
|
10113
|
+
data: {
|
|
10114
|
+
objectName: "${event.data.__objectName}",
|
|
10115
|
+
record: "${event.data.record}"
|
|
10116
|
+
},
|
|
10117
|
+
expression: "${event.data.__response.error != true}"
|
|
10118
|
+
},
|
|
10119
|
+
]
|
|
10120
|
+
},
|
|
10121
|
+
...props.onEvent
|
|
10122
|
+
}
|
|
9879
10123
|
}
|
|
9880
10124
|
}
|
|
10125
|
+
|
|
10126
|
+
|
|
9881
10127
|
}
|
|
9882
10128
|
}
|
|
9883
10129
|
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
10130
|
+
async function getRecordDetailMiniSchema(objectName, appId, props = {}){
|
|
10131
|
+
const uiSchema = await getUISchema(objectName);
|
|
10132
|
+
const fields = ___default["default"].values(uiSchema.fields);
|
|
10133
|
+
|
|
10134
|
+
props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
|
|
10135
|
+
|
|
10136
|
+
// TODO 处理相关表
|
|
10137
|
+
// getObjectRelatedListsMiniSchema
|
|
10138
|
+
|
|
10139
|
+
return {
|
|
10140
|
+
type: "form",
|
|
10141
|
+
wrapWithPanel: false,
|
|
10142
|
+
actions: [],
|
|
10143
|
+
initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
10144
|
+
body: {
|
|
10145
|
+
"type": "wrapper",
|
|
10146
|
+
"className": "p-0 m-0",
|
|
10147
|
+
"body": [
|
|
10148
|
+
{
|
|
10149
|
+
"type": "steedos-record-detail-header",
|
|
10150
|
+
"showButtons": false,
|
|
10151
|
+
"showBackButton": false,
|
|
10152
|
+
"objectApiName": "${objectName}",
|
|
10153
|
+
"recordId": "${recordId}",
|
|
10154
|
+
},
|
|
10155
|
+
// {
|
|
10156
|
+
// "type": "steedos-object-related-lists",
|
|
10157
|
+
// "label": "相关列表",
|
|
10158
|
+
// "objectApiName": "${objectName}",
|
|
10159
|
+
// "staticRecordId": "${recordId}",
|
|
10160
|
+
// formFactor: "SMALL",
|
|
10161
|
+
// appId: appId
|
|
10162
|
+
// }
|
|
10163
|
+
],
|
|
10164
|
+
"hiddenOn": "${_finished != true}"
|
|
10165
|
+
}
|
|
10166
|
+
}
|
|
10167
|
+
}
|
|
10168
|
+
|
|
10169
|
+
// 获取单个相关表
|
|
10170
|
+
async function getObjectRelated(
|
|
10171
|
+
{appName,
|
|
10172
|
+
masterObjectName,
|
|
10173
|
+
objectName,
|
|
9889
10174
|
relatedFieldName,
|
|
9890
10175
|
recordId,
|
|
9891
10176
|
formFactor}
|
|
@@ -10440,17 +10725,13 @@ function getReferenceToSync(field) {
|
|
|
10440
10725
|
|
|
10441
10726
|
function getLookupSapceUserTreeSchema(isMobile){
|
|
10442
10727
|
let apiAdaptor = `
|
|
10443
|
-
// console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
|
|
10444
10728
|
const records = payload.data.options;
|
|
10445
|
-
let isTreeOptionsComputed = false;
|
|
10446
|
-
if(records.length === 1 && records[0].children){
|
|
10447
|
-
isTreeOptionsComputed = true;
|
|
10448
|
-
}
|
|
10449
|
-
if(isTreeOptionsComputed){
|
|
10450
|
-
return payload;
|
|
10451
|
-
}
|
|
10452
10729
|
const treeRecords = [];
|
|
10453
|
-
const getChildren = (records, childrenIds) => {
|
|
10730
|
+
const getChildren = (currentRecord, records, childrenIds) => {
|
|
10731
|
+
if (currentRecord.children && typeof currentRecord.children[0] === "object") {
|
|
10732
|
+
// 考虑api配置了cache缓存的话,不会请求接口但是会重新进这个接收适配器脚本且payload.data.options返回的会是上一次计算结果,这里直接返回计算过的children
|
|
10733
|
+
return currentRecord.children;
|
|
10734
|
+
}
|
|
10454
10735
|
if (!childrenIds) {
|
|
10455
10736
|
return;
|
|
10456
10737
|
}
|
|
@@ -10459,7 +10740,7 @@ function getLookupSapceUserTreeSchema(isMobile){
|
|
|
10459
10740
|
});
|
|
10460
10741
|
_.each(children, (item) => {
|
|
10461
10742
|
if (item.children) {
|
|
10462
|
-
item.children = getChildren(records, item.children)
|
|
10743
|
+
item.children = getChildren(item, records, item.children)
|
|
10463
10744
|
}else{
|
|
10464
10745
|
item.children = [];
|
|
10465
10746
|
}
|
|
@@ -10485,7 +10766,7 @@ function getLookupSapceUserTreeSchema(isMobile){
|
|
|
10485
10766
|
|
|
10486
10767
|
_.each(records, (record) => {
|
|
10487
10768
|
if (record.noParent == 1) {
|
|
10488
|
-
treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
|
|
10769
|
+
treeRecords.push(Object.assign({}, record, { children: getChildren(record, records, record.children) }));
|
|
10489
10770
|
}
|
|
10490
10771
|
});
|
|
10491
10772
|
console.log(treeRecords)
|
|
@@ -10535,6 +10816,7 @@ function getLookupSapceUserTreeSchema(isMobile){
|
|
|
10535
10816
|
}
|
|
10536
10817
|
},
|
|
10537
10818
|
"label": "",
|
|
10819
|
+
"mode": "normal",
|
|
10538
10820
|
"name": "organizations",
|
|
10539
10821
|
"multiple": false,
|
|
10540
10822
|
"joinValues": false,
|
|
@@ -10677,6 +10959,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10677
10959
|
}
|
|
10678
10960
|
});
|
|
10679
10961
|
|
|
10962
|
+
let listviewFilter = getListViewFilter(listView);
|
|
10963
|
+
let listviewFiltersFunction = listView && listView._filters;
|
|
10964
|
+
|
|
10680
10965
|
let sort = "";
|
|
10681
10966
|
if(listView){
|
|
10682
10967
|
sort = getListViewSort(listView);
|
|
@@ -10723,7 +11008,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10723
11008
|
Object.assign(api.data.$self, __changedSearchBoxValues, __changedFilterFormValues);
|
|
10724
11009
|
}
|
|
10725
11010
|
const selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
10726
|
-
var filters = [];
|
|
11011
|
+
${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
|
|
10727
11012
|
var pageSize = api.data.pageSize || 10;
|
|
10728
11013
|
var pageNo = api.data.pageNo || 1;
|
|
10729
11014
|
var skip = (pageNo - 1) * pageSize;
|
|
@@ -10785,6 +11070,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10785
11070
|
}
|
|
10786
11071
|
|
|
10787
11072
|
const inFilterForm = ${ctx.inFilterForm};
|
|
11073
|
+
|
|
11074
|
+
const listviewFiltersFunction = ${listviewFiltersFunction};
|
|
11075
|
+
|
|
11076
|
+
if(listviewFiltersFunction && !inFilterForm){
|
|
11077
|
+
const _filters0 = listviewFiltersFunction(filters, api.data.$self.__super);
|
|
11078
|
+
if(_filters0 && _filters0.length){
|
|
11079
|
+
filters.push(_filters0);
|
|
11080
|
+
}
|
|
11081
|
+
}
|
|
11082
|
+
|
|
10788
11083
|
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
10789
11084
|
|
|
10790
11085
|
if(filtersFunction && !inFilterForm){
|
|
@@ -10903,13 +11198,15 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10903
11198
|
|
|
10904
11199
|
pickerSchema.affixHeader = false;
|
|
10905
11200
|
|
|
10906
|
-
|
|
11201
|
+
|
|
11202
|
+
|
|
11203
|
+
pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { isLookup: true, keywordsSearchBoxName });
|
|
11204
|
+
|
|
10907
11205
|
if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
|
|
10908
|
-
|
|
11206
|
+
pickerSchema.headerToolbar.push(getLookupSapceUserTreeSchema(isMobile));
|
|
10909
11207
|
pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
|
|
10910
11208
|
}
|
|
10911
|
-
|
|
10912
|
-
pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { headerToolbarItems, isLookup: true, keywordsSearchBoxName });
|
|
11209
|
+
|
|
10913
11210
|
const isAllowCreate = refObjectConfig.permissions.allowCreate;
|
|
10914
11211
|
const isCreate = ___namespace.isBoolean(field.create) ? field.create : true;
|
|
10915
11212
|
// lookup字段配置过滤条件就强制不显示新建按钮
|
|
@@ -11022,6 +11319,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
11022
11319
|
pickerSchema.footerToolbar = ["pagination"];
|
|
11023
11320
|
}
|
|
11024
11321
|
|
|
11322
|
+
if(field.inlineHelpText){
|
|
11323
|
+
pickerSchema.toolbarClassName = "hasHelpText";
|
|
11324
|
+
pickerSchema.headerToolbar = [{
|
|
11325
|
+
"type": "tpl",
|
|
11326
|
+
"tpl": field.inlineHelpText,
|
|
11327
|
+
"className": "text-secondary"
|
|
11328
|
+
}, ...pickerSchema.headerToolbar];
|
|
11329
|
+
}
|
|
11330
|
+
pickerSchema.className = (pickerSchema.className || "") + " steedos-lookup-crud";
|
|
11331
|
+
|
|
11025
11332
|
const data = {
|
|
11026
11333
|
type: getAmisStaticFieldType('picker', readonly),
|
|
11027
11334
|
modalTitle: i18next__default["default"].t('frontend_form_please_select') + " " + refObjectConfig.label,
|
|
@@ -11097,6 +11404,9 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
11097
11404
|
const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
|
|
11098
11405
|
let listView = getLookupListView(refObjectConfig);
|
|
11099
11406
|
|
|
11407
|
+
let listviewFilter = getListViewFilter(listView);
|
|
11408
|
+
let listviewFiltersFunction = listView && listView._filters;
|
|
11409
|
+
|
|
11100
11410
|
let sort = "";
|
|
11101
11411
|
if(listView){
|
|
11102
11412
|
sort = getListViewSort(listView);
|
|
@@ -11126,7 +11436,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
11126
11436
|
apiInfo.data['rfield'] = `\${object_name}`;
|
|
11127
11437
|
// [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
|
|
11128
11438
|
apiInfo.requestAdaptor = `
|
|
11129
|
-
var filters = [];
|
|
11439
|
+
${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
|
|
11130
11440
|
var top = 200;
|
|
11131
11441
|
if(api.data.$term){
|
|
11132
11442
|
filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
|
|
@@ -11149,6 +11459,16 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
11149
11459
|
}
|
|
11150
11460
|
|
|
11151
11461
|
const inFilterForm = ${ctx.inFilterForm};
|
|
11462
|
+
|
|
11463
|
+
const listviewFiltersFunction = ${listviewFiltersFunction};
|
|
11464
|
+
|
|
11465
|
+
if(listviewFiltersFunction && !inFilterForm){
|
|
11466
|
+
const _filters0 = listviewFiltersFunction(filters, api.data.$);
|
|
11467
|
+
if(_filters0 && _filters0.length){
|
|
11468
|
+
filters.push(_filters0);
|
|
11469
|
+
}
|
|
11470
|
+
}
|
|
11471
|
+
|
|
11152
11472
|
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
11153
11473
|
|
|
11154
11474
|
if(filtersFunction && !inFilterForm){
|
|
@@ -11271,9 +11591,17 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
11271
11591
|
}
|
|
11272
11592
|
// console.log(`lookupToAmis====`, field, readonly, ctx)
|
|
11273
11593
|
if(readonly){
|
|
11274
|
-
|
|
11275
|
-
|
|
11276
|
-
|
|
11594
|
+
if(field.reference_to){
|
|
11595
|
+
return {
|
|
11596
|
+
type: 'steedos-field',
|
|
11597
|
+
config: field,
|
|
11598
|
+
static: true
|
|
11599
|
+
}
|
|
11600
|
+
}else {
|
|
11601
|
+
return {
|
|
11602
|
+
type: getAmisStaticFieldType('picker', readonly),
|
|
11603
|
+
tpl: getRelatedFieldTpl(field, ctx)
|
|
11604
|
+
}
|
|
11277
11605
|
}
|
|
11278
11606
|
}
|
|
11279
11607
|
if(field.reference_to && !___namespace.isString(field.reference_to) && !readonly){
|
|
@@ -11925,13 +12253,31 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
11925
12253
|
};
|
|
11926
12254
|
break;
|
|
11927
12255
|
case 'input-datetime-range':
|
|
12256
|
+
// convertData = {
|
|
12257
|
+
// type: "input-datetime-range",
|
|
12258
|
+
// inputFormat: 'YYYY-MM-DD HH:mm',
|
|
12259
|
+
// format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
12260
|
+
// tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
|
|
12261
|
+
// utc: true,
|
|
12262
|
+
// joinValues: false
|
|
12263
|
+
// }
|
|
12264
|
+
// 日期时间字段,按日期方式展现显示控件,用户不用关心小时分钟
|
|
11928
12265
|
convertData = {
|
|
11929
|
-
type: "input-
|
|
11930
|
-
inputFormat:
|
|
12266
|
+
type: "input-date-range",
|
|
12267
|
+
inputFormat: "YYYY-MM-DD HH:mm",
|
|
11931
12268
|
format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
11932
12269
|
tpl: readonly ? getDateTimeTpl(field) : null,
|
|
11933
12270
|
utc: true,
|
|
11934
|
-
joinValues: false
|
|
12271
|
+
joinValues: false,
|
|
12272
|
+
"shortcuts": [
|
|
12273
|
+
"thismonth",
|
|
12274
|
+
"2monthsago",
|
|
12275
|
+
"3monthslater",
|
|
12276
|
+
"prevquarter",
|
|
12277
|
+
"thisquarter",
|
|
12278
|
+
"thisyear",
|
|
12279
|
+
"lastYear"
|
|
12280
|
+
]
|
|
11935
12281
|
};
|
|
11936
12282
|
break;
|
|
11937
12283
|
case 'datetime':
|
|
@@ -11982,7 +12328,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
11982
12328
|
convertData = {
|
|
11983
12329
|
type: getAmisStaticFieldType('datetime', readonly),
|
|
11984
12330
|
inputFormat: 'YYYY-MM-DD HH:mm',
|
|
11985
|
-
format: 'YYYY-MM-DDTHH:mm:
|
|
12331
|
+
format: 'YYYY-MM-DDTHH:mm:00.000Z',
|
|
11986
12332
|
tpl: readonly ? getDateTimeTpl(field) : null,
|
|
11987
12333
|
utc: true,
|
|
11988
12334
|
};
|
|
@@ -12113,6 +12459,36 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12113
12459
|
convertData = {
|
|
12114
12460
|
type: 'static-text'
|
|
12115
12461
|
};
|
|
12462
|
+
}else if(field.autonumber_enable_modify){
|
|
12463
|
+
convertData = {
|
|
12464
|
+
"type": "input-group",
|
|
12465
|
+
"body": [
|
|
12466
|
+
{
|
|
12467
|
+
"type": "input-text",
|
|
12468
|
+
"name": field.name
|
|
12469
|
+
},
|
|
12470
|
+
{
|
|
12471
|
+
"type": "button",
|
|
12472
|
+
"label": "自动获取",
|
|
12473
|
+
"actionType": "ajax",
|
|
12474
|
+
"api": {
|
|
12475
|
+
"url": `\${context.rootUrl}/api/autonumber/generator/\${objectName}/${field.name}`,
|
|
12476
|
+
"method": "post",
|
|
12477
|
+
"headers": {
|
|
12478
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
12479
|
+
},
|
|
12480
|
+
"adaptor": `
|
|
12481
|
+
payload.data["${field.name}"] = payload.data && payload.data.autonumber;
|
|
12482
|
+
delete payload.data.autonumber;
|
|
12483
|
+
return payload;
|
|
12484
|
+
`
|
|
12485
|
+
},
|
|
12486
|
+
"messages": {
|
|
12487
|
+
"success": "获取成功"
|
|
12488
|
+
}
|
|
12489
|
+
}
|
|
12490
|
+
]
|
|
12491
|
+
};
|
|
12116
12492
|
}
|
|
12117
12493
|
break;
|
|
12118
12494
|
case 'url':
|
|
@@ -12267,11 +12643,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12267
12643
|
if(field.subFields){
|
|
12268
12644
|
convertData = {
|
|
12269
12645
|
type: 'steedos-input-table',
|
|
12270
|
-
showIndex: true,
|
|
12271
12646
|
editable: !readonly,
|
|
12272
12647
|
addable: !readonly,
|
|
12273
12648
|
removable: !readonly,
|
|
12274
|
-
draggable: !readonly,
|
|
12275
12649
|
fields: [],
|
|
12276
12650
|
amis:{
|
|
12277
12651
|
columnsTogglable: false
|
|
@@ -12323,9 +12697,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12323
12697
|
if(field.is_wide || convertData.type === 'group'){
|
|
12324
12698
|
convertData.className = 'col-span-2 m-0';
|
|
12325
12699
|
}else {
|
|
12326
|
-
convertData.className = 'm-
|
|
12700
|
+
convertData.className = 'm-0';
|
|
12327
12701
|
}
|
|
12328
|
-
if(readonly){
|
|
12702
|
+
if(readonly && ctx.mode !== 'edit'){
|
|
12329
12703
|
convertData.className = `${convertData.className} border-b`;
|
|
12330
12704
|
}
|
|
12331
12705
|
if(readonly){
|
|
@@ -12348,6 +12722,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12348
12722
|
}
|
|
12349
12723
|
}
|
|
12350
12724
|
|
|
12725
|
+
if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
|
|
12726
|
+
convertData.className = `${convertData.className || ''} hidden`;
|
|
12727
|
+
}
|
|
12728
|
+
|
|
12351
12729
|
if(___namespace.isString(baseData.required)){
|
|
12352
12730
|
if(baseData.required.startsWith("{{")){
|
|
12353
12731
|
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
@@ -12416,8 +12794,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
|
|
|
12416
12794
|
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
12417
12795
|
}
|
|
12418
12796
|
if(_field.type === 'datetime'){
|
|
12419
|
-
//
|
|
12420
|
-
|
|
12797
|
+
// 这里如果想把搜索范围展示效果改为日期范围,不可以直接改为input-date-range,因为它们规则不一样,包括时区规则和小时分秒的存值规则都不一样
|
|
12798
|
+
// 所以想改为展示日期范围效果,只能改input-datetime-range类型本身的属性来实现
|
|
12799
|
+
_field.type = 'input-datetime-range';
|
|
12421
12800
|
_field.is_wide = true;
|
|
12422
12801
|
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
12423
12802
|
}
|
|
@@ -12603,6 +12982,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
|
|
|
12603
12982
|
}
|
|
12604
12983
|
}
|
|
12605
12984
|
|
|
12985
|
+
fieldSetBody.forEach((field)=>{
|
|
12986
|
+
//判断label是否存在,不存在时将label的空占位元素隐藏
|
|
12987
|
+
if(!field.label){
|
|
12988
|
+
field.labelClassName = "none";
|
|
12989
|
+
}
|
|
12990
|
+
});
|
|
12991
|
+
|
|
12606
12992
|
// fieldSet 已支持显隐控制
|
|
12607
12993
|
const sectionFieldsVisibleOn = ___namespace.map(___namespace.compact(___namespace.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
|
|
12608
12994
|
let visible = visibleOn;
|
|
@@ -12725,19 +13111,200 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12725
13111
|
return await getSections(permissionFields, formFields, ctx);
|
|
12726
13112
|
}
|
|
12727
13113
|
|
|
13114
|
+
/*
|
|
13115
|
+
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
13116
|
+
* @Date: 2024-01-18 15:12:41
|
|
13117
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
13118
|
+
* @LastEditTime: 2024-01-18 15:12:49
|
|
13119
|
+
*/
|
|
13120
|
+
/**
|
|
13121
|
+
* 生成符合标准uuid格式的36位满足唯一性的随机串
|
|
13122
|
+
* @returns uuid
|
|
13123
|
+
*/
|
|
13124
|
+
function uuidv4() {
|
|
13125
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
|
|
13126
|
+
(c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
13127
|
+
);
|
|
13128
|
+
}
|
|
13129
|
+
|
|
12728
13130
|
/*
|
|
12729
13131
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12730
13132
|
* @Date: 2023-11-15 09:50:22
|
|
12731
|
-
* @LastEditors:
|
|
12732
|
-
* @LastEditTime: 2024-01-
|
|
13133
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
13134
|
+
* @LastEditTime: 2024-01-26 17:47:16
|
|
13135
|
+
*/
|
|
13136
|
+
|
|
13137
|
+
/**
|
|
13138
|
+
* 子表组件字段值中每行数据补上字段值为空的的字段值,把值统一设置为空字符串,是为了解决amis amis 3.6/6.0 input-table组件bug:行中字段值为空时会显示为父作用域中的同名变量值,见:https://github.com/baidu/amis/issues/9520
|
|
13139
|
+
* amis #9520修正后此函数及相关代码可以移除
|
|
13140
|
+
* @param {*} value 子表组件字段值,数组
|
|
13141
|
+
* @param {*} fields 子表组件fields属性,数组
|
|
13142
|
+
* @returns 转换后的子表组件字段值
|
|
13143
|
+
*/
|
|
13144
|
+
function getTableValueWithEmptyValue(value, fields) {
|
|
13145
|
+
return (value || []).map((itemValue) => {
|
|
13146
|
+
//这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里字段值会被改了
|
|
13147
|
+
const newItemValue = _$1.clone(itemValue);
|
|
13148
|
+
(fields || []).forEach((itemField) => {
|
|
13149
|
+
if(itemField.name && (newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
|
|
13150
|
+
// 这里newItemValue中不存在 itemField.name 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
|
|
13151
|
+
// 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
|
|
13152
|
+
newItemValue[itemField.name] = "";
|
|
13153
|
+
}
|
|
13154
|
+
if (newItemValue.children) {
|
|
13155
|
+
newItemValue.children = getTableValueWithEmptyValue(newItemValue.children, fields);
|
|
13156
|
+
}
|
|
13157
|
+
});
|
|
13158
|
+
return newItemValue;
|
|
13159
|
+
});
|
|
13160
|
+
}
|
|
13161
|
+
|
|
13162
|
+
/**
|
|
13163
|
+
* 把子表组件字段值中每行数据中经过上面getTableValueWithEmptyValue函数空字段值移除
|
|
13164
|
+
* amis #9520修正后此函数及相关代码可以移除
|
|
13165
|
+
* @param {*} value 子表组件字段值,数组
|
|
13166
|
+
* @param {*} fields 子表组件fields属性,数组
|
|
13167
|
+
* @returns 转换后的子表组件字段值
|
|
13168
|
+
*/
|
|
13169
|
+
function getTableValueWithoutEmptyValue(value, fields) {
|
|
13170
|
+
return (value || []).map((itemValue) => {
|
|
13171
|
+
const newItemValue = _$1.clone(itemValue);
|
|
13172
|
+
(fields || []).forEach((itemField) => {
|
|
13173
|
+
if(itemField.name && (newItemValue[itemField.name] === "" || newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
|
|
13174
|
+
// 这里额外把null和undefined值也删除掉纯粹是没必要输出保存它们
|
|
13175
|
+
delete newItemValue[itemField.name];
|
|
13176
|
+
}
|
|
13177
|
+
if (newItemValue.children) {
|
|
13178
|
+
newItemValue.children = getTableValueWithoutEmptyValue(newItemValue.children, fields);
|
|
13179
|
+
}
|
|
13180
|
+
});
|
|
13181
|
+
return newItemValue;
|
|
13182
|
+
});
|
|
13183
|
+
}
|
|
13184
|
+
|
|
13185
|
+
function getTablePrimaryKey(props) {
|
|
13186
|
+
return props.primaryKey || "_id";
|
|
13187
|
+
}
|
|
13188
|
+
|
|
13189
|
+
/**
|
|
13190
|
+
* 子表组件字段值中每行数据的补上唯一标识字段值,其值为随机uuid
|
|
13191
|
+
* @param {*} value 子表组件字段值,数组
|
|
13192
|
+
* @param {*} primaryKey 主键字段名,一般为_id
|
|
13193
|
+
* @returns 转换后的子表组件字段值
|
|
13194
|
+
*/
|
|
13195
|
+
function getTableValueWithPrimaryKeyValue(value, primaryKey) {
|
|
13196
|
+
if (!primaryKey) {
|
|
13197
|
+
return value;
|
|
13198
|
+
}
|
|
13199
|
+
return (value || []).map((itemValue) => {
|
|
13200
|
+
//这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
|
|
13201
|
+
const newItemValue = _$1.clone(itemValue);
|
|
13202
|
+
if (newItemValue[primaryKey]) {
|
|
13203
|
+
if (newItemValue.children) {
|
|
13204
|
+
newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13205
|
+
}
|
|
13206
|
+
return newItemValue;
|
|
13207
|
+
}
|
|
13208
|
+
else {
|
|
13209
|
+
newItemValue[primaryKey] = uuidv4();
|
|
13210
|
+
if (newItemValue.children) {
|
|
13211
|
+
newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13212
|
+
}
|
|
13213
|
+
return newItemValue;
|
|
13214
|
+
}
|
|
13215
|
+
});
|
|
13216
|
+
}
|
|
13217
|
+
|
|
13218
|
+
/**
|
|
13219
|
+
* 子表组件字段值中每行数据的移除唯一标识字段值,因为该字段值一般只作临时标记,不存库
|
|
13220
|
+
* @param {*} value 子表组件字段值,数组
|
|
13221
|
+
* @param {*} primaryKey 主键字段名,一般为_id
|
|
13222
|
+
* @returns 转换后的子表组件字段值
|
|
12733
13223
|
*/
|
|
13224
|
+
function getTableValueWithoutPrimaryKeyValue(value, primaryKey) {
|
|
13225
|
+
if (!primaryKey) {
|
|
13226
|
+
return value;
|
|
13227
|
+
}
|
|
13228
|
+
return (value || []).map((itemValue) => {
|
|
13229
|
+
//这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
|
|
13230
|
+
const newItemValue = _$1.clone(itemValue);
|
|
13231
|
+
if (newItemValue.children) {
|
|
13232
|
+
newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13233
|
+
}
|
|
13234
|
+
delete newItemValue[primaryKey];
|
|
13235
|
+
return newItemValue;
|
|
13236
|
+
});
|
|
13237
|
+
}
|
|
13238
|
+
|
|
13239
|
+
/**
|
|
13240
|
+
* 子表组件字段值中每行数据的键值key移除指定前缀
|
|
13241
|
+
* @param {*} value 子表组件字段值,数组
|
|
13242
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13243
|
+
* @returns 转换后的子表组件字段值
|
|
13244
|
+
*/
|
|
13245
|
+
function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
|
|
13246
|
+
let convertedValue = [];
|
|
13247
|
+
(value || []).forEach((itemValue) => {
|
|
13248
|
+
var newItemValue = {};
|
|
13249
|
+
for (let n in itemValue) {
|
|
13250
|
+
if (itemValue.hasOwnProperty(n)) {
|
|
13251
|
+
newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
|
|
13252
|
+
}
|
|
13253
|
+
}
|
|
13254
|
+
convertedValue.push(newItemValue);
|
|
13255
|
+
});
|
|
13256
|
+
return convertedValue;
|
|
13257
|
+
}
|
|
13258
|
+
|
|
13259
|
+
/**
|
|
13260
|
+
* 子表组件字段值中每行数据的键值key补上指定前缀
|
|
13261
|
+
* @param {*} value 子表组件字段值,数组
|
|
13262
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13263
|
+
* @param {*} primaryKey 主键字段名,主键不参与被键值key规则,需要排除,审批王amis表单也是这个规则
|
|
13264
|
+
* @returns 转换后的子表组件字段值
|
|
13265
|
+
*/
|
|
13266
|
+
function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
|
|
13267
|
+
let convertedValue = [];
|
|
13268
|
+
(value || []).forEach((itemValue) => {
|
|
13269
|
+
var newItemValue = {};
|
|
13270
|
+
for (let n in itemValue) {
|
|
13271
|
+
if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
|
|
13272
|
+
newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
|
|
13273
|
+
}
|
|
13274
|
+
}
|
|
13275
|
+
if (primaryKey && itemValue[primaryKey]) {
|
|
13276
|
+
newItemValue[primaryKey] = itemValue[primaryKey];
|
|
13277
|
+
}
|
|
13278
|
+
convertedValue.push(newItemValue);
|
|
13279
|
+
});
|
|
13280
|
+
return convertedValue;
|
|
13281
|
+
}
|
|
13282
|
+
|
|
13283
|
+
/**
|
|
13284
|
+
* 子表组件字段集合属性中每个字段name移除指定前缀
|
|
13285
|
+
* @param {*} fields 子表组件字段集合,数组
|
|
13286
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13287
|
+
* @returns 转换后的子表组件字段值
|
|
13288
|
+
*/
|
|
13289
|
+
function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
|
|
13290
|
+
return (fields || []).map((item) => {
|
|
13291
|
+
const newItem = _$1.clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
|
|
13292
|
+
newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
|
|
13293
|
+
return newItem;
|
|
13294
|
+
});
|
|
13295
|
+
}
|
|
12734
13296
|
|
|
12735
13297
|
/**
|
|
12736
13298
|
* @param {*} props
|
|
12737
13299
|
* @param {*} mode edit/new/readonly
|
|
12738
13300
|
*/
|
|
12739
13301
|
function getFormFields(props, mode = "edit") {
|
|
12740
|
-
|
|
13302
|
+
let fieldPrefix = props.fieldPrefix;
|
|
13303
|
+
let fields = props.fields || [];
|
|
13304
|
+
if (fieldPrefix) {
|
|
13305
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
13306
|
+
}
|
|
13307
|
+
return (fields || []).map(function (item) {
|
|
12741
13308
|
let formItem = {
|
|
12742
13309
|
"type": "steedos-field",
|
|
12743
13310
|
"name": item.name,
|
|
@@ -12757,6 +13324,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
|
|
|
12757
13324
|
name: field.name,
|
|
12758
13325
|
quickEdit: {
|
|
12759
13326
|
"type": "steedos-field",
|
|
13327
|
+
"mode": "inline",
|
|
12760
13328
|
"config": Object.assign({}, field, {
|
|
12761
13329
|
label: false
|
|
12762
13330
|
})
|
|
@@ -12809,7 +13377,12 @@ async function getInputTableColumns(props) {
|
|
|
12809
13377
|
let inlineEditMode = props.inlineEditMode;
|
|
12810
13378
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
12811
13379
|
// 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
|
|
12812
|
-
|
|
13380
|
+
|
|
13381
|
+
let fieldPrefix = props.fieldPrefix;
|
|
13382
|
+
let fields = props.fields || [];
|
|
13383
|
+
if (fieldPrefix) {
|
|
13384
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
13385
|
+
}
|
|
12813
13386
|
if (columns && columns.length) {
|
|
12814
13387
|
return columns.map(function (column) {
|
|
12815
13388
|
let field, extendColumnProps = {};
|
|
@@ -12831,8 +13404,26 @@ async function getInputTableColumns(props) {
|
|
|
12831
13404
|
}
|
|
12832
13405
|
}
|
|
12833
13406
|
if (field) {
|
|
12834
|
-
let
|
|
12835
|
-
|
|
13407
|
+
let mode = typeof extendColumnProps.inlineEditMode === "boolean" ?
|
|
13408
|
+
extendColumnProps.inlineEditMode : showAsInlineEditMode;
|
|
13409
|
+
let tableCell = getInputTableCell(field, mode);
|
|
13410
|
+
let className = "";
|
|
13411
|
+
//判断是否换行,目前规则默认换行
|
|
13412
|
+
if(extendColumnProps.wrap != true){
|
|
13413
|
+
className += " whitespace-nowrap ";
|
|
13414
|
+
}else {
|
|
13415
|
+
className += " break-words ";
|
|
13416
|
+
}
|
|
13417
|
+
//合并classname
|
|
13418
|
+
if (typeof extendColumnProps.className == "object") {
|
|
13419
|
+
className = {
|
|
13420
|
+
[className]: "true",
|
|
13421
|
+
...extendColumnProps.className
|
|
13422
|
+
};
|
|
13423
|
+
} else if (typeof extendColumnProps.className == "string") {
|
|
13424
|
+
className = `${className} ${extendColumnProps.className} `;
|
|
13425
|
+
}
|
|
13426
|
+
return Object.assign({}, tableCell, extendColumnProps, {className});
|
|
12836
13427
|
}
|
|
12837
13428
|
else {
|
|
12838
13429
|
return column;
|
|
@@ -12842,6 +13433,7 @@ async function getInputTableColumns(props) {
|
|
|
12842
13433
|
else {
|
|
12843
13434
|
return fields.map(function (field) {
|
|
12844
13435
|
let tableCell = getInputTableCell(field, showAsInlineEditMode);
|
|
13436
|
+
tableCell.className = " whitespace-nowrap ";
|
|
12845
13437
|
return tableCell;
|
|
12846
13438
|
}) || [];
|
|
12847
13439
|
}
|
|
@@ -12854,7 +13446,7 @@ async function getInputTableColumns(props) {
|
|
|
12854
13446
|
*/
|
|
12855
13447
|
function getFormPagination(props, mode) {
|
|
12856
13448
|
let showPagination = true;
|
|
12857
|
-
if(mode === "new" && !!!props.editable){
|
|
13449
|
+
if (mode === "new" && !!!props.editable) {
|
|
12858
13450
|
//不允许编辑只允许新建时不应该让用户操作翻页
|
|
12859
13451
|
showPagination = false;
|
|
12860
13452
|
}
|
|
@@ -12870,23 +13462,41 @@ function getFormPagination(props, mode) {
|
|
|
12870
13462
|
let __formId = "${formId}";
|
|
12871
13463
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
12872
13464
|
let pageChangeDirection = context.props.pageChangeDirection;
|
|
13465
|
+
let mode = "${mode}";
|
|
12873
13466
|
// event.data中的index和__page分别表示当前要把表单数据提交到的行索引和用于标定下一页页码的当前页页码
|
|
12874
13467
|
// 一般来说__page = index + 1,但是可以让event.data中传入__page和index值不是这种联系。
|
|
12875
13468
|
// 比如__page设置为3,index设置为0表示把当前表单数据提交到第一页,但是跳转到第4页,弹出的表单中底下的新增和复制按钮依赖了此功能
|
|
12876
13469
|
// let currentPage = currentIndex + 1;
|
|
12877
13470
|
let currentPage = event.data.__page;
|
|
12878
13471
|
let currentIndex = event.data.index;
|
|
12879
|
-
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
13472
|
+
if(mode !== "readonly"){
|
|
13473
|
+
// 新建编辑时,翻页才需要把当前页表单保存,只读时直接翻页即可
|
|
13474
|
+
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
13475
|
+
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
13476
|
+
// 这里不clone的话,其值会带上__super属性
|
|
13477
|
+
currentFormValues = _.clone(currentFormValues);
|
|
13478
|
+
var parent = event.data.parent;
|
|
13479
|
+
var __parentIndex = event.data.__parentIndex;
|
|
13480
|
+
if(parent){
|
|
13481
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13482
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13483
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13484
|
+
children: fieldValue[__parentIndex].children,
|
|
13485
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13486
|
+
});
|
|
12888
13487
|
}
|
|
12889
|
-
|
|
13488
|
+
else{
|
|
13489
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13490
|
+
}
|
|
13491
|
+
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
13492
|
+
doAction({
|
|
13493
|
+
"componentId": "${props.id}",
|
|
13494
|
+
"actionType": "setValue",
|
|
13495
|
+
"args": {
|
|
13496
|
+
"value": fieldValue
|
|
13497
|
+
}
|
|
13498
|
+
});
|
|
13499
|
+
}
|
|
12890
13500
|
|
|
12891
13501
|
// 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
|
|
12892
13502
|
let targetPage;
|
|
@@ -12935,9 +13545,14 @@ function getFormPagination(props, mode) {
|
|
|
12935
13545
|
"onEvent": {
|
|
12936
13546
|
"click": {
|
|
12937
13547
|
"actions": [
|
|
13548
|
+
{
|
|
13549
|
+
"actionType": "validate",
|
|
13550
|
+
"componentId": formId
|
|
13551
|
+
},
|
|
12938
13552
|
{
|
|
12939
13553
|
"actionType": "custom",
|
|
12940
|
-
"script": onPageChangeScript
|
|
13554
|
+
"script": onPageChangeScript,
|
|
13555
|
+
"expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
12941
13556
|
}
|
|
12942
13557
|
]
|
|
12943
13558
|
}
|
|
@@ -12945,7 +13560,8 @@ function getFormPagination(props, mode) {
|
|
|
12945
13560
|
},
|
|
12946
13561
|
{
|
|
12947
13562
|
"type": "tpl",
|
|
12948
|
-
|
|
13563
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13564
|
+
"tpl": "${__page}/${__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length}"
|
|
12949
13565
|
},
|
|
12950
13566
|
{
|
|
12951
13567
|
"type": "button",
|
|
@@ -12953,15 +13569,22 @@ function getFormPagination(props, mode) {
|
|
|
12953
13569
|
"icon": `fa fa-angle-right`,
|
|
12954
13570
|
"level": "link",
|
|
12955
13571
|
"pageChangeDirection": "next",
|
|
12956
|
-
"disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
13572
|
+
// "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
13573
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13574
|
+
"disabledOn": showPagination ? "${__page >= (__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length)}" : "true",
|
|
12957
13575
|
"size": "sm",
|
|
12958
13576
|
"id": buttonNextId,
|
|
12959
13577
|
"onEvent": {
|
|
12960
13578
|
"click": {
|
|
12961
13579
|
"actions": [
|
|
13580
|
+
{
|
|
13581
|
+
"actionType": "validate",
|
|
13582
|
+
"componentId": formId
|
|
13583
|
+
},
|
|
12962
13584
|
{
|
|
12963
13585
|
"actionType": "custom",
|
|
12964
|
-
"script": onPageChangeScript
|
|
13586
|
+
"script": onPageChangeScript,
|
|
13587
|
+
"expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
12965
13588
|
}
|
|
12966
13589
|
]
|
|
12967
13590
|
}
|
|
@@ -12982,18 +13605,19 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12982
13605
|
// console.log("==getFormPaginationWrapper===", props, mode);
|
|
12983
13606
|
let serviceId = getComponentId("form_pagination", props.id);
|
|
12984
13607
|
let tableServiceId = getComponentId("table_service", props.id);
|
|
13608
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
12985
13609
|
let innerForm = Object.assign({}, form, {
|
|
12986
13610
|
"data": {
|
|
12987
13611
|
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12988
13612
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12989
|
-
"&": "${__tableItems[__super.index]}"
|
|
13613
|
+
"&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
|
|
12990
13614
|
}
|
|
12991
13615
|
});
|
|
12992
13616
|
let formBody = [
|
|
12993
13617
|
{
|
|
12994
13618
|
"type": "wrapper",
|
|
12995
13619
|
"size": "none",
|
|
12996
|
-
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white
|
|
13620
|
+
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
|
|
12997
13621
|
"body": [
|
|
12998
13622
|
getFormPagination(props, mode)
|
|
12999
13623
|
]
|
|
@@ -13009,7 +13633,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13009
13633
|
}
|
|
13010
13634
|
];
|
|
13011
13635
|
let onServiceInitedScript = `
|
|
13012
|
-
//
|
|
13636
|
+
// 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
13013
13637
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
13014
13638
|
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
13015
13639
|
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
@@ -13022,8 +13646,13 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13022
13646
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13023
13647
|
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
13024
13648
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
13649
|
+
let fieldPrefix = "${props.fieldPrefix || ''}";
|
|
13650
|
+
if(fieldPrefix){
|
|
13651
|
+
let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
|
|
13652
|
+
lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
|
|
13653
|
+
}
|
|
13025
13654
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
13026
|
-
let mode = "${mode}";
|
|
13655
|
+
let mode = "${mode || ''}";
|
|
13027
13656
|
if(mode === "new"){
|
|
13028
13657
|
// 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
|
|
13029
13658
|
// 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
|
|
@@ -13044,6 +13673,26 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13044
13673
|
event.data.__tableItems.forEach(function(n,i){
|
|
13045
13674
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
13046
13675
|
});
|
|
13676
|
+
|
|
13677
|
+
var parent = event.data.parent;
|
|
13678
|
+
var fieldValue = event.data.__tableItems;
|
|
13679
|
+
if(parent){
|
|
13680
|
+
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13681
|
+
var primaryKey = "${primaryKey}";
|
|
13682
|
+
event.data.__parentIndex = _.findIndex(fieldValue, function(item){
|
|
13683
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13684
|
+
});
|
|
13685
|
+
if(event.data.__parentIndex < 0){
|
|
13686
|
+
let tableId = "${props.id}";
|
|
13687
|
+
let table = scope.getComponentById(tableId)
|
|
13688
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
13689
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
13690
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
13691
|
+
event.data.__parentIndex = _.findIndex(table.props.value, function(item){
|
|
13692
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13693
|
+
});
|
|
13694
|
+
}
|
|
13695
|
+
}
|
|
13047
13696
|
`;
|
|
13048
13697
|
let schema = {
|
|
13049
13698
|
"type": "service",
|
|
@@ -13064,6 +13713,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13064
13713
|
// "body": formBody,
|
|
13065
13714
|
"data": {
|
|
13066
13715
|
"__page": "${index + 1}",
|
|
13716
|
+
"__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
|
|
13067
13717
|
// "__total": `\${${props.name}.length}`,
|
|
13068
13718
|
// "__total": "${__tableItems.length}",
|
|
13069
13719
|
// "__paginationServiceId": serviceId,
|
|
@@ -13090,6 +13740,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13090
13740
|
async function getForm(props, mode = "edit", formId) {
|
|
13091
13741
|
let formFields = getFormFields(props, mode);
|
|
13092
13742
|
let body = await getFormBody(null, formFields);
|
|
13743
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
13093
13744
|
if (!formId) {
|
|
13094
13745
|
formId = getComponentId("form", props.id);
|
|
13095
13746
|
}
|
|
@@ -13108,10 +13759,41 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13108
13759
|
// 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
|
|
13109
13760
|
let onEditItemSubmitScript = `
|
|
13110
13761
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
13762
|
+
let removeEmptyItems = function(items){
|
|
13763
|
+
let i = _.findIndex(items, function(item){
|
|
13764
|
+
return item === undefined
|
|
13765
|
+
});
|
|
13766
|
+
if(i > -1){
|
|
13767
|
+
items.splice(i, 1);
|
|
13768
|
+
removeEmptyItems(items);
|
|
13769
|
+
}
|
|
13770
|
+
}
|
|
13771
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
13772
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
13773
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13111
13774
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13112
13775
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
13113
13776
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
13114
|
-
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13777
|
+
// fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13778
|
+
var currentIndex = event.data.__super.__super.index;
|
|
13779
|
+
var currentFormValues = JSON.parse(JSON.stringify(event.data));
|
|
13780
|
+
var parent = event.data.__super.__super.parent;
|
|
13781
|
+
var __parentIndex = event.data.__super.__super.__parentIndex;
|
|
13782
|
+
let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
|
|
13783
|
+
var primaryKey = "${primaryKey}";
|
|
13784
|
+
if(parent){
|
|
13785
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13786
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13787
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13788
|
+
children: fieldValue[__parentIndex].children,
|
|
13789
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13790
|
+
});
|
|
13791
|
+
}
|
|
13792
|
+
else{
|
|
13793
|
+
// 这里currentFormValues中如果没有primaryKey字段值不用处理,因为组件的pipeIn/pipeOut中会为每行自动生成
|
|
13794
|
+
// 也不用担心复制行时_id会重复,因为点击复制按钮时已经处理过了
|
|
13795
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13796
|
+
}
|
|
13115
13797
|
doAction({
|
|
13116
13798
|
"componentId": "${props.id}",
|
|
13117
13799
|
"actionType": "setValue",
|
|
@@ -13207,13 +13889,14 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13207
13889
|
*/
|
|
13208
13890
|
async function getButtonActions(props, mode) {
|
|
13209
13891
|
let actions = [];
|
|
13892
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
13210
13893
|
let formId = getComponentId("form", props.id);
|
|
13211
13894
|
let dialogId = getComponentId("dialog", props.id);
|
|
13212
13895
|
let buttonNextId = getComponentId("button_next", props.id);
|
|
13213
13896
|
let formPaginationId = getComponentId("form_pagination", props.id);
|
|
13214
13897
|
let parentFormData = "${__super.__super.__super.__super || {}}";
|
|
13215
13898
|
let amisVersion = getComparableAmisVersion();
|
|
13216
|
-
if(amisVersion < 3.6){
|
|
13899
|
+
if (amisVersion < 3.6) {
|
|
13217
13900
|
parentFormData = "${__super.__super || {}}";
|
|
13218
13901
|
}
|
|
13219
13902
|
if (mode == "new" || mode == "edit") {
|
|
@@ -13249,9 +13932,42 @@ async function getButtonActions(props, mode) {
|
|
|
13249
13932
|
// };
|
|
13250
13933
|
let onSaveAndNewItemScript = `
|
|
13251
13934
|
let scope = event.context.scoped;
|
|
13935
|
+
let removeEmptyItems = function(items){
|
|
13936
|
+
let i = _.findIndex(items, function(item){
|
|
13937
|
+
return item === undefined
|
|
13938
|
+
});
|
|
13939
|
+
if(i > -1){
|
|
13940
|
+
items.splice(i, 1);
|
|
13941
|
+
removeEmptyItems(items);
|
|
13942
|
+
}
|
|
13943
|
+
}
|
|
13944
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
13945
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
13946
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13252
13947
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13253
13948
|
// 新建一条空白行并保存到子表组件
|
|
13254
|
-
|
|
13949
|
+
var parent = event.data.__super.parent;
|
|
13950
|
+
var primaryKey = "${primaryKey}";
|
|
13951
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13952
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13953
|
+
});
|
|
13954
|
+
if(parent && __parentIndex < 0){
|
|
13955
|
+
let tableId = "${props.id}";
|
|
13956
|
+
let table = scope.getComponentById(tableId)
|
|
13957
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
13958
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
13959
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
13960
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
13961
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13962
|
+
});
|
|
13963
|
+
}
|
|
13964
|
+
if(parent){
|
|
13965
|
+
fieldValue[__parentIndex].children.push({});
|
|
13966
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13967
|
+
}
|
|
13968
|
+
else{
|
|
13969
|
+
fieldValue.push({});
|
|
13970
|
+
}
|
|
13255
13971
|
doAction({
|
|
13256
13972
|
"componentId": "${props.id}",
|
|
13257
13973
|
"actionType": "setValue",
|
|
@@ -13263,7 +13979,13 @@ async function getButtonActions(props, mode) {
|
|
|
13263
13979
|
let __paginationServiceId = "${formPaginationId}";
|
|
13264
13980
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13265
13981
|
event.data.index = __paginationData.index;
|
|
13266
|
-
|
|
13982
|
+
if(parent){
|
|
13983
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13984
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
13985
|
+
}
|
|
13986
|
+
else{
|
|
13987
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13988
|
+
}
|
|
13267
13989
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13268
13990
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13269
13991
|
`;
|
|
@@ -13272,9 +13994,49 @@ async function getButtonActions(props, mode) {
|
|
|
13272
13994
|
let __formId = "${formId}";
|
|
13273
13995
|
// let newItem = JSON.parse(JSON.stringify(event.data));
|
|
13274
13996
|
let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
|
|
13997
|
+
newItem = _.clone(newItem);
|
|
13998
|
+
let removeEmptyItems = function(items){
|
|
13999
|
+
let i = _.findIndex(items, function(item){
|
|
14000
|
+
return item === undefined
|
|
14001
|
+
});
|
|
14002
|
+
if(i > -1){
|
|
14003
|
+
items.splice(i, 1);
|
|
14004
|
+
removeEmptyItems(items);
|
|
14005
|
+
}
|
|
14006
|
+
}
|
|
14007
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
14008
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
14009
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13275
14010
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13276
14011
|
// 复制当前页数据到新建行并保存到子表组件
|
|
13277
|
-
fieldValue.push(newItem);
|
|
14012
|
+
// fieldValue.push(newItem);
|
|
14013
|
+
var parent = event.data.__super.parent;
|
|
14014
|
+
var primaryKey = "${primaryKey}";
|
|
14015
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
14016
|
+
return item[primaryKey] == parent[primaryKey];
|
|
14017
|
+
});
|
|
14018
|
+
if(parent && __parentIndex < 0){
|
|
14019
|
+
let tableId = "${props.id}";
|
|
14020
|
+
let table = scope.getComponentById(tableId)
|
|
14021
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
14022
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
14023
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
14024
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
14025
|
+
return item[primaryKey] == parent[primaryKey];
|
|
14026
|
+
});
|
|
14027
|
+
}
|
|
14028
|
+
if(newItem[primaryKey]){
|
|
14029
|
+
// 如果newItem已经有主键字段值,则重新生成新的主键值,否则会重复。
|
|
14030
|
+
let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
|
|
14031
|
+
newItem[primaryKey] = uuidv4();
|
|
14032
|
+
}
|
|
14033
|
+
if(parent){
|
|
14034
|
+
fieldValue[__parentIndex].children.push(newItem);
|
|
14035
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
14036
|
+
}
|
|
14037
|
+
else{
|
|
14038
|
+
fieldValue.push(newItem);
|
|
14039
|
+
}
|
|
13278
14040
|
doAction({
|
|
13279
14041
|
"componentId": "${props.id}",
|
|
13280
14042
|
"actionType": "setValue",
|
|
@@ -13286,19 +14048,25 @@ async function getButtonActions(props, mode) {
|
|
|
13286
14048
|
let __paginationServiceId = "${formPaginationId}";
|
|
13287
14049
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13288
14050
|
event.data.index = __paginationData.index;
|
|
13289
|
-
|
|
14051
|
+
if(parent){
|
|
14052
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
14053
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
14054
|
+
}
|
|
14055
|
+
else{
|
|
14056
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
14057
|
+
}
|
|
13290
14058
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13291
14059
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13292
14060
|
`;
|
|
13293
14061
|
let dialogButtons = [
|
|
13294
14062
|
{
|
|
13295
|
-
|
|
13296
|
-
|
|
13297
|
-
|
|
13298
|
-
|
|
14063
|
+
"type": "button",
|
|
14064
|
+
"label": "完成",
|
|
14065
|
+
"actionType": "confirm",
|
|
14066
|
+
"level": "primary"
|
|
13299
14067
|
}
|
|
13300
14068
|
];
|
|
13301
|
-
if(props.addable){
|
|
14069
|
+
if (props.addable) {
|
|
13302
14070
|
// 有新增行权限时额外添加新增和复制按钮
|
|
13303
14071
|
dialogButtons = [
|
|
13304
14072
|
{
|
|
@@ -13308,9 +14076,14 @@ async function getButtonActions(props, mode) {
|
|
|
13308
14076
|
"onEvent": {
|
|
13309
14077
|
"click": {
|
|
13310
14078
|
"actions": [
|
|
14079
|
+
{
|
|
14080
|
+
"actionType": "validate",
|
|
14081
|
+
"componentId": formId
|
|
14082
|
+
},
|
|
13311
14083
|
{
|
|
13312
14084
|
"actionType": "custom",
|
|
13313
|
-
"script": onSaveAndNewItemScript
|
|
14085
|
+
"script": onSaveAndNewItemScript,
|
|
14086
|
+
"expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
13314
14087
|
}
|
|
13315
14088
|
]
|
|
13316
14089
|
}
|
|
@@ -13323,9 +14096,14 @@ async function getButtonActions(props, mode) {
|
|
|
13323
14096
|
"onEvent": {
|
|
13324
14097
|
"click": {
|
|
13325
14098
|
"actions": [
|
|
14099
|
+
{
|
|
14100
|
+
"actionType": "validate",
|
|
14101
|
+
"componentId": formId
|
|
14102
|
+
},
|
|
13326
14103
|
{
|
|
13327
14104
|
"actionType": "custom",
|
|
13328
|
-
"script": onSaveAndCopyItemScript
|
|
14105
|
+
"script": onSaveAndCopyItemScript,
|
|
14106
|
+
"expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
13329
14107
|
}
|
|
13330
14108
|
]
|
|
13331
14109
|
}
|
|
@@ -13362,12 +14140,15 @@ async function getButtonActions(props, mode) {
|
|
|
13362
14140
|
"_master": "${_master}",
|
|
13363
14141
|
"global": "${global}",
|
|
13364
14142
|
"uiSchema": "${uiSchema}",
|
|
13365
|
-
"index": "${index}"
|
|
14143
|
+
"index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
|
|
14144
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13366
14145
|
// "__tableItems": `\${${props.name}}`
|
|
13367
14146
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13368
14147
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13369
14148
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13370
|
-
|
|
14149
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
14150
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
14151
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13371
14152
|
},
|
|
13372
14153
|
"actions": dialogButtons,
|
|
13373
14154
|
"onEvent": {
|
|
@@ -13390,35 +14171,39 @@ async function getButtonActions(props, mode) {
|
|
|
13390
14171
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13391
14172
|
}
|
|
13392
14173
|
if (mode == "new") {
|
|
13393
|
-
`
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13400
|
-
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
|
|
13419
|
-
|
|
13420
|
-
|
|
13421
|
-
`;
|
|
14174
|
+
// let onNewLineScript = `
|
|
14175
|
+
// let newItem = {};
|
|
14176
|
+
// if(event.data["${props.name}"]){
|
|
14177
|
+
// // let fieldValue = event.data.__tableItems;
|
|
14178
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
14179
|
+
// // let fieldValue = _.clone(event.data["${props.name}"]);
|
|
14180
|
+
// let fieldValue = event.data["${props.name}"];
|
|
14181
|
+
// fieldValue.push(newItem);
|
|
14182
|
+
// doAction({
|
|
14183
|
+
// "componentId": "${props.id}",
|
|
14184
|
+
// "actionType": "setValue",
|
|
14185
|
+
// "args": {
|
|
14186
|
+
// "value": fieldValue
|
|
14187
|
+
// }
|
|
14188
|
+
// });
|
|
14189
|
+
// event.data.index = fieldValue.length - 1;
|
|
14190
|
+
// }
|
|
14191
|
+
// else{
|
|
14192
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
14193
|
+
// doAction({
|
|
14194
|
+
// "componentId": "${props.id}",
|
|
14195
|
+
// "actionType": "setValue",
|
|
14196
|
+
// "args": {
|
|
14197
|
+
// "value": [newItem]
|
|
14198
|
+
// }
|
|
14199
|
+
// });
|
|
14200
|
+
// event.data.index = 1;
|
|
14201
|
+
// }
|
|
14202
|
+
// `;
|
|
14203
|
+
// let actionNewLine = {
|
|
14204
|
+
// "actionType": "custom",
|
|
14205
|
+
// "script": onNewLineScript
|
|
14206
|
+
// };
|
|
13422
14207
|
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13423
14208
|
// actions = [actionNewLine, actionShowEditDialog];
|
|
13424
14209
|
actions = [actionShowEditDialog];
|
|
@@ -13453,15 +14238,20 @@ async function getButtonActions(props, mode) {
|
|
|
13453
14238
|
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
13454
14239
|
// "__parentForm": "${__super.__super || {}}",
|
|
13455
14240
|
"__parentForm": parentFormData,
|
|
14241
|
+
"_master": "${_master}",
|
|
13456
14242
|
"global": "${global}",
|
|
13457
14243
|
"uiSchema": "${uiSchema}",
|
|
13458
14244
|
"index": "${index}",
|
|
14245
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13459
14246
|
// "__tableItems": `\${${props.name}}`
|
|
13460
14247
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13461
14248
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13462
14249
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13463
|
-
"__tableItems": `\${(
|
|
13464
|
-
|
|
14250
|
+
// "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
14251
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
14252
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
14253
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
14254
|
+
},
|
|
13465
14255
|
}
|
|
13466
14256
|
}
|
|
13467
14257
|
];
|
|
@@ -13476,8 +14266,40 @@ async function getButtonActions(props, mode) {
|
|
|
13476
14266
|
let wrapperServiceData = wrapperService.getData();
|
|
13477
14267
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13478
14268
|
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
14269
|
+
// 也因为这里clone没有直接删除,所以弹出编辑表单提交事件中event.data.__tableItems中取到的值会有被删除的行数据为undefined
|
|
13479
14270
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13480
|
-
|
|
14271
|
+
var currentIndex = event.data.index;
|
|
14272
|
+
var parent = event.data.__super.parent;
|
|
14273
|
+
var primaryKey = "${primaryKey}";
|
|
14274
|
+
var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
|
|
14275
|
+
return item[primaryKey] == parent[primaryKey];
|
|
14276
|
+
});
|
|
14277
|
+
if(parent && __parentIndex < 0){
|
|
14278
|
+
let tableId = "${props.id}";
|
|
14279
|
+
let table = scope.getComponentById(tableId)
|
|
14280
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
14281
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
14282
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
14283
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
14284
|
+
return item[primaryKey] == parent[primaryKey];
|
|
14285
|
+
});
|
|
14286
|
+
}
|
|
14287
|
+
if(parent){
|
|
14288
|
+
lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
|
|
14289
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
14290
|
+
lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
|
|
14291
|
+
children: lastestFieldValue[__parentIndex].children,
|
|
14292
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
14293
|
+
});
|
|
14294
|
+
}
|
|
14295
|
+
else{
|
|
14296
|
+
lastestFieldValue.splice(currentIndex, 1);
|
|
14297
|
+
}
|
|
14298
|
+
let fieldPrefix = "${props.fieldPrefix || ''}";
|
|
14299
|
+
if(fieldPrefix){
|
|
14300
|
+
let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
|
|
14301
|
+
lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
|
|
14302
|
+
}
|
|
13481
14303
|
doAction({
|
|
13482
14304
|
"componentId": "${props.id}",
|
|
13483
14305
|
"actionType": "setValue",
|
|
@@ -13547,58 +14369,104 @@ async function getButtonView(props) {
|
|
|
13547
14369
|
|
|
13548
14370
|
async function getButtonDelete(props) {
|
|
13549
14371
|
return {
|
|
13550
|
-
"type": "button",
|
|
13551
|
-
"label": "",
|
|
13552
|
-
"icon": "fa fa-trash-alt",//不可以用fa-trash-o,因为设计字段布局界面中弹出的设置分组列表中显示不了这个图标
|
|
14372
|
+
"type": "dropdown-button",
|
|
13553
14373
|
"level": "link",
|
|
13554
|
-
"
|
|
13555
|
-
|
|
13556
|
-
|
|
14374
|
+
"icon": "fa fa-trash-alt",
|
|
14375
|
+
"size": "xs",
|
|
14376
|
+
"hideCaret": true,
|
|
14377
|
+
"closeOnClick": true,
|
|
14378
|
+
"body": [
|
|
14379
|
+
{
|
|
14380
|
+
"type": "wrapper",
|
|
14381
|
+
"size": "md",
|
|
14382
|
+
"className": "w-80",
|
|
14383
|
+
"body": [
|
|
14384
|
+
{
|
|
14385
|
+
"tpl": "确定要删除吗?",
|
|
14386
|
+
"type": "tpl"
|
|
14387
|
+
},
|
|
14388
|
+
{
|
|
14389
|
+
"type": "flex",
|
|
14390
|
+
"justify": "flex-end",
|
|
14391
|
+
"className": "mt-3",
|
|
14392
|
+
"items": [
|
|
14393
|
+
{
|
|
14394
|
+
"type": "button",
|
|
14395
|
+
"label": "取消",
|
|
14396
|
+
"className": "mr-2"
|
|
14397
|
+
},
|
|
14398
|
+
{
|
|
14399
|
+
"type": "button",
|
|
14400
|
+
"label": "删除",
|
|
14401
|
+
"level": "danger",
|
|
14402
|
+
"onEvent": {
|
|
14403
|
+
"click": {
|
|
14404
|
+
"actions": await getButtonActions(props, "delete")
|
|
14405
|
+
}
|
|
14406
|
+
}
|
|
14407
|
+
}
|
|
14408
|
+
]
|
|
14409
|
+
}
|
|
14410
|
+
]
|
|
13557
14411
|
}
|
|
13558
|
-
|
|
13559
|
-
}
|
|
14412
|
+
]
|
|
14413
|
+
}
|
|
13560
14414
|
}
|
|
13561
14415
|
|
|
14416
|
+
|
|
13562
14417
|
const getAmisInputTableSchema = async (props) => {
|
|
13563
14418
|
if (!props.id) {
|
|
13564
14419
|
props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
|
|
13565
14420
|
}
|
|
14421
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
14422
|
+
let showOperation = props.showOperation;
|
|
14423
|
+
if (showOperation !== false) {
|
|
14424
|
+
showOperation = true;
|
|
14425
|
+
}
|
|
14426
|
+
let fieldPrefix = props.fieldPrefix;
|
|
14427
|
+
let fields = props.fields || [];
|
|
14428
|
+
if (fieldPrefix) {
|
|
14429
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
14430
|
+
}
|
|
13566
14431
|
let serviceId = getComponentId("table_service", props.id);
|
|
13567
14432
|
let buttonsForColumnOperations = [];
|
|
13568
14433
|
let inlineEditMode = props.inlineEditMode;
|
|
13569
14434
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
13570
|
-
if (
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13574
|
-
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
14435
|
+
if (showOperation) {
|
|
14436
|
+
if (props.editable) {
|
|
14437
|
+
let showEditButton = true;
|
|
14438
|
+
if (showAsInlineEditMode) {
|
|
14439
|
+
// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
14440
|
+
showEditButton = true;
|
|
14441
|
+
// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
14442
|
+
// if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
|
|
14443
|
+
// showEditButton = true;
|
|
14444
|
+
// }
|
|
14445
|
+
// else {
|
|
14446
|
+
// showEditButton = false;
|
|
14447
|
+
// }
|
|
14448
|
+
}
|
|
14449
|
+
// 编辑时显示编辑按钮
|
|
14450
|
+
if (showEditButton) {
|
|
14451
|
+
let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
|
|
14452
|
+
buttonsForColumnOperations.push(buttonEditSchema);
|
|
14453
|
+
}
|
|
13582
14454
|
}
|
|
13583
|
-
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
|
|
14455
|
+
else {
|
|
14456
|
+
// 只读时显示查看按钮
|
|
14457
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
|
|
14458
|
+
let buttonViewSchema = await getButtonView(props);
|
|
14459
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
14460
|
+
}
|
|
14461
|
+
if (props.removable) {
|
|
14462
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
14463
|
+
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13587
14464
|
}
|
|
13588
14465
|
}
|
|
13589
|
-
|
|
13590
|
-
// 只读时显示查看按钮
|
|
13591
|
-
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13592
|
-
let buttonViewSchema = await getButtonView(props);
|
|
13593
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13594
|
-
}
|
|
13595
|
-
if (props.removable) {
|
|
13596
|
-
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13597
|
-
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13598
|
-
}
|
|
14466
|
+
let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13599
14467
|
let inputTableSchema = {
|
|
13600
14468
|
"type": "input-table",
|
|
13601
|
-
"
|
|
14469
|
+
"mode": "normal",
|
|
13602
14470
|
"name": props.name,
|
|
13603
14471
|
//不可以addable/editable/removable设置为true,因为会在原生的操作列显示操作按钮图标,此开关实测只控制这个按钮显示不会影响功能
|
|
13604
14472
|
// "addable": props.addable,
|
|
@@ -13613,7 +14481,53 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13613
14481
|
"strictMode": props.strictMode,
|
|
13614
14482
|
"showTableAddBtn": false,
|
|
13615
14483
|
"showFooterAddBtn": false,
|
|
13616
|
-
"className": props.tableClassName
|
|
14484
|
+
"className": props.tableClassName,
|
|
14485
|
+
"pipeIn": (value, data) => {
|
|
14486
|
+
if (fieldPrefix) {
|
|
14487
|
+
value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
|
|
14488
|
+
}
|
|
14489
|
+
value = getTableValueWithEmptyValue(value, fields);
|
|
14490
|
+
if (primaryKey) {
|
|
14491
|
+
// 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
|
|
14492
|
+
// 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
|
|
14493
|
+
// 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
|
|
14494
|
+
value = getTableValueWithPrimaryKeyValue(value, primaryKey);
|
|
14495
|
+
}
|
|
14496
|
+
if (amis.pipeIn) {
|
|
14497
|
+
if (typeof amis.pipeIn === 'function') {
|
|
14498
|
+
return amis.pipeIn(value, data);
|
|
14499
|
+
}
|
|
14500
|
+
}
|
|
14501
|
+
return value;
|
|
14502
|
+
},
|
|
14503
|
+
"pipeOut": (value, data) => {
|
|
14504
|
+
value = (value || []).map(function (item) {
|
|
14505
|
+
delete item.__fix_rerender_after_children_modified_tag;
|
|
14506
|
+
return item;
|
|
14507
|
+
});
|
|
14508
|
+
if (fieldPrefix) {
|
|
14509
|
+
value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
|
|
14510
|
+
}
|
|
14511
|
+
value = getTableValueWithoutEmptyValue(value, fields);
|
|
14512
|
+
if (props.autoGeneratePrimaryKeyValue === true) {
|
|
14513
|
+
// 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
|
|
14514
|
+
// 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
|
|
14515
|
+
value = getTableValueWithPrimaryKeyValue(value, primaryKey);
|
|
14516
|
+
}
|
|
14517
|
+
else {
|
|
14518
|
+
// 默认情况下,也就是没有配置autoGeneratePrimaryKey时,最终输出的字段值要移除行中的primaryKey值
|
|
14519
|
+
// 需要注意如果没有配置autoGeneratePrimaryKey时,因为每次弹出行编辑窗口保存后都会先后进入pipeOut和pipeIn,
|
|
14520
|
+
// 这里删除掉了primaryKey值,所以primaryKey值每次弹出编辑窗口保存后都会给每行重新生成新的primaryKey值
|
|
14521
|
+
// 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
|
|
14522
|
+
value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
|
|
14523
|
+
}
|
|
14524
|
+
if (amis.pipeOut) {
|
|
14525
|
+
if (typeof amis.pipeOut === 'function') {
|
|
14526
|
+
return amis.pipeOut(value, data);
|
|
14527
|
+
}
|
|
14528
|
+
}
|
|
14529
|
+
return value;
|
|
14530
|
+
}
|
|
13617
14531
|
};
|
|
13618
14532
|
if (buttonsForColumnOperations.length) {
|
|
13619
14533
|
inputTableSchema.columns.push({
|
|
@@ -13623,20 +14537,22 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13623
14537
|
"width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
|
|
13624
14538
|
});
|
|
13625
14539
|
}
|
|
13626
|
-
if (showAsInlineEditMode) {
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
14540
|
+
// if (showAsInlineEditMode) {
|
|
14541
|
+
// // 因为要支持不同的列上配置inlineEditMode属性,所有不可以把整个子表组件都设置为inlineEditMode
|
|
14542
|
+
// inputTableSchema.needConfirm = false;
|
|
14543
|
+
// }
|
|
13630
14544
|
if (amis) {
|
|
13631
14545
|
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13632
14546
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
14547
|
+
delete amis.pipeIn;//该属性在上面合并过了
|
|
14548
|
+
delete amis.pipeOut;//该属性在上面合并过了
|
|
13633
14549
|
Object.assign(inputTableSchema, amis);
|
|
13634
14550
|
}
|
|
13635
|
-
const isAnyFieldHasDependOn = (
|
|
14551
|
+
const isAnyFieldHasDependOn = (fields || []).find(function (item) {
|
|
13636
14552
|
return item.depend_on;
|
|
13637
14553
|
});
|
|
13638
14554
|
if (isAnyFieldHasDependOn) {
|
|
13639
|
-
// 有任意一个子字段有depend_on
|
|
14555
|
+
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
|
|
13640
14556
|
Object.assign(inputTableSchema, {
|
|
13641
14557
|
strictMode: false
|
|
13642
14558
|
});
|
|
@@ -13665,11 +14581,31 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13665
14581
|
"body": headerToolbar
|
|
13666
14582
|
});
|
|
13667
14583
|
}
|
|
14584
|
+
let className = "steedos-input-table";
|
|
14585
|
+
|
|
14586
|
+
if (typeof props.className == "object") {
|
|
14587
|
+
className = {
|
|
14588
|
+
[className]: "true",
|
|
14589
|
+
...props.className
|
|
14590
|
+
};
|
|
14591
|
+
} else if (typeof props.className == "string") {
|
|
14592
|
+
className = `${className} ${props.className} `;
|
|
14593
|
+
}
|
|
14594
|
+
|
|
13668
14595
|
let schema = {
|
|
13669
|
-
"type": "
|
|
13670
|
-
"body":
|
|
13671
|
-
|
|
13672
|
-
|
|
14596
|
+
"type": "control",
|
|
14597
|
+
"body": {
|
|
14598
|
+
"type": "service",
|
|
14599
|
+
"body": schemaBody,
|
|
14600
|
+
"id": serviceId
|
|
14601
|
+
},
|
|
14602
|
+
"label": props.label,
|
|
14603
|
+
"labelClassName": props.label ? props.labelClassName : "none",
|
|
14604
|
+
"labelRemark": props.labelRemark,
|
|
14605
|
+
"labelAlign": props.labelAlign,
|
|
14606
|
+
//控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
|
|
14607
|
+
"mode": props.mode || null,
|
|
14608
|
+
className
|
|
13673
14609
|
};
|
|
13674
14610
|
// console.log("===schema===", schema);
|
|
13675
14611
|
return schema;
|
|
@@ -13741,7 +14677,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
|
|
|
13741
14677
|
// 获取
|
|
13742
14678
|
async function getRecordPageInitSchema(objectApiName){
|
|
13743
14679
|
const relatedList = await getObjectRelatedList(objectApiName);
|
|
13744
|
-
|
|
14680
|
+
await getUISchema(objectApiName);
|
|
13745
14681
|
let body = [
|
|
13746
14682
|
// detailHeaderAmisSchema,
|
|
13747
14683
|
{
|
|
@@ -13749,28 +14685,7 @@ async function getRecordPageInitSchema(objectApiName){
|
|
|
13749
14685
|
"label": "标题面板",
|
|
13750
14686
|
"objectApiName": "${objectName}",
|
|
13751
14687
|
"recordId": "${recordId}",
|
|
13752
|
-
"onEvent": {
|
|
13753
|
-
"recordLoaded": {
|
|
13754
|
-
"actions": [
|
|
13755
|
-
{
|
|
13756
|
-
"actionType": "setValue",
|
|
13757
|
-
"args": {
|
|
13758
|
-
"value": {
|
|
13759
|
-
"recordLoaded": true,
|
|
13760
|
-
}
|
|
13761
|
-
}
|
|
13762
|
-
},
|
|
13763
|
-
{
|
|
13764
|
-
"actionType": "reload",
|
|
13765
|
-
"data": {
|
|
13766
|
-
"name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
13767
|
-
"record": `\${record}`,
|
|
13768
|
-
"recordLoaded": true,
|
|
13769
|
-
}
|
|
13770
|
-
}
|
|
13771
|
-
]
|
|
13772
|
-
}
|
|
13773
|
-
}
|
|
14688
|
+
"onEvent": {}
|
|
13774
14689
|
}
|
|
13775
14690
|
];
|
|
13776
14691
|
let contentBody = {
|
|
@@ -16405,9 +17320,11 @@ exports.getObjectRelated = getObjectRelated;
|
|
|
16405
17320
|
exports.getObjectRelatedList = getObjectRelatedList;
|
|
16406
17321
|
exports.getObjectRelatedListButtons = getObjectRelatedListButtons;
|
|
16407
17322
|
exports.getObjectRelatedListHeader = getObjectRelatedListHeader;
|
|
17323
|
+
exports.getObjectRelatedListsMiniSchema = getObjectRelatedListsMiniSchema;
|
|
16408
17324
|
exports.getPage = getPage;
|
|
16409
17325
|
exports.getRecord = getRecord;
|
|
16410
17326
|
exports.getRecordDetailHeaderSchema = getRecordDetailHeaderSchema;
|
|
17327
|
+
exports.getRecordDetailMiniSchema = getRecordDetailMiniSchema;
|
|
16411
17328
|
exports.getRecordDetailRelatedListSchema = getRecordDetailRelatedListSchema;
|
|
16412
17329
|
exports.getRecordDetailSchema = getRecordDetailSchema;
|
|
16413
17330
|
exports.getRecordPageInitSchema = getRecordPageInitSchema;
|