@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.esm.js
CHANGED
|
@@ -340,22 +340,29 @@ const getSteedosAuth = () => {
|
|
|
340
340
|
* @Description:
|
|
341
341
|
*/
|
|
342
342
|
|
|
343
|
-
|
|
344
343
|
const Router = {
|
|
345
344
|
getTabDisplayAs(tab_id){
|
|
345
|
+
const uiSchema = getUISchemaSync$1(tab_id, false);
|
|
346
346
|
var urlSearch = new URLSearchParams(document.location.search);
|
|
347
347
|
if(urlSearch.has('display')){
|
|
348
348
|
return urlSearch.get('display')
|
|
349
349
|
}
|
|
350
350
|
const key = `tab_${tab_id}_display`;
|
|
351
351
|
// const key = `page_display`;
|
|
352
|
-
const value =
|
|
353
|
-
|
|
352
|
+
const value = sessionStorage.getItem(key);
|
|
353
|
+
let defaultDisplay = "grid";
|
|
354
|
+
if(uiSchema.enable_split){
|
|
355
|
+
defaultDisplay = "split";
|
|
356
|
+
}
|
|
357
|
+
if(window.innerWidth <= 768){
|
|
358
|
+
return "grid";
|
|
359
|
+
}
|
|
360
|
+
return value ? value : defaultDisplay;
|
|
354
361
|
},
|
|
355
362
|
|
|
356
363
|
setTabDisplayAs(tab_id, displayAs){
|
|
357
364
|
const key = `tab_${tab_id}_display`;
|
|
358
|
-
|
|
365
|
+
sessionStorage.setItem(key, displayAs);
|
|
359
366
|
},
|
|
360
367
|
getAppPath({formFactor, appId}){
|
|
361
368
|
return `/app/${appId}`;
|
|
@@ -382,8 +389,8 @@ const Router = {
|
|
|
382
389
|
/*
|
|
383
390
|
* @Author: baozhoutao@steedos.com
|
|
384
391
|
* @Date: 2022-07-20 16:29:22
|
|
385
|
-
* @LastEditors:
|
|
386
|
-
* @LastEditTime:
|
|
392
|
+
* @LastEditors: liaodaxue
|
|
393
|
+
* @LastEditTime: 2024-01-25 14:44:17
|
|
387
394
|
* @Description:
|
|
388
395
|
*/
|
|
389
396
|
|
|
@@ -455,11 +462,30 @@ function getComparableAmisVersion() {
|
|
|
455
462
|
}
|
|
456
463
|
}
|
|
457
464
|
|
|
465
|
+
/**
|
|
466
|
+
* 判断浏览器类型
|
|
467
|
+
* @returns 按需返回浏览器类型;
|
|
468
|
+
*/
|
|
469
|
+
function getBowserType() {
|
|
470
|
+
const userAgent = navigator.userAgent;
|
|
471
|
+
if (userAgent.indexOf("Chrome")!== -1 && userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Edg") === -1) {
|
|
472
|
+
return "Chrome";
|
|
473
|
+
} else if (userAgent.indexOf("Firefox") !== -1) {
|
|
474
|
+
return "Firefox";
|
|
475
|
+
} else if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1 && userAgent.indexOf("Edge") === -1) {
|
|
476
|
+
return "Safari";
|
|
477
|
+
} else if (userAgent.indexOf("Edg") !== -1) {
|
|
478
|
+
return "Edge";
|
|
479
|
+
} else {
|
|
480
|
+
return "Unknown browser"; // 其他浏览器...(可根据自己需要确定是否新增其他浏览器的判断)
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
458
484
|
/*
|
|
459
485
|
* @Author: baozhoutao@steedos.com
|
|
460
486
|
* @Date: 2022-05-23 09:53:08
|
|
461
487
|
* @LastEditors: liaodaxue
|
|
462
|
-
* @LastEditTime:
|
|
488
|
+
* @LastEditTime: 2024-01-17 16:00:27
|
|
463
489
|
* @Description:
|
|
464
490
|
*/
|
|
465
491
|
|
|
@@ -531,7 +557,7 @@ function getSelectMap(selectOptions){
|
|
|
531
557
|
|
|
532
558
|
function getNameTplUrl(field, ctx){
|
|
533
559
|
if(ctx.objectName === 'cms_files'){
|
|
534
|
-
return
|
|
560
|
+
return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
|
|
535
561
|
}
|
|
536
562
|
const href = Router.getObjectDetailPath({
|
|
537
563
|
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
@@ -1277,6 +1303,7 @@ var frontend_notifications$1 = "Notifications";
|
|
|
1277
1303
|
var frontend_notifications_allread$1 = "Mark all as read";
|
|
1278
1304
|
var frontend_notifications_allread_message$1 = "All marked as read";
|
|
1279
1305
|
var frontend_profile$1 = "Profile";
|
|
1306
|
+
var switch_space$1 = "Switch Space";
|
|
1280
1307
|
var frontend_about$1 = "About";
|
|
1281
1308
|
var frontend_log_out$1 = "Log out";
|
|
1282
1309
|
var frontend_listview_warning_start$1 = "The current ";
|
|
@@ -1364,6 +1391,7 @@ var en_us = {
|
|
|
1364
1391
|
frontend_notifications_allread: frontend_notifications_allread$1,
|
|
1365
1392
|
frontend_notifications_allread_message: frontend_notifications_allread_message$1,
|
|
1366
1393
|
frontend_profile: frontend_profile$1,
|
|
1394
|
+
switch_space: switch_space$1,
|
|
1367
1395
|
frontend_about: frontend_about$1,
|
|
1368
1396
|
frontend_log_out: frontend_log_out$1,
|
|
1369
1397
|
frontend_listview_warning_start: frontend_listview_warning_start$1,
|
|
@@ -1403,9 +1431,9 @@ var frontend_display_type_is_split = "分栏视图";
|
|
|
1403
1431
|
var frontend_display_as = "显示为";
|
|
1404
1432
|
var frontend_record_sum = "个项目";
|
|
1405
1433
|
var frontend_button_reload_tooltip = "刷新";
|
|
1406
|
-
var frontend_button_search_tooltip = "
|
|
1434
|
+
var frontend_button_search_tooltip = "搜索";
|
|
1407
1435
|
var frontend_fields_filter_button_search = "搜索";
|
|
1408
|
-
var frontend_fields_filter_button_settings = "
|
|
1436
|
+
var frontend_fields_filter_button_settings = "选择搜索项";
|
|
1409
1437
|
var frontend_button_listview_control_tooltip = "列表视图控制";
|
|
1410
1438
|
var frontend_button_listview_control_label = "列表视图控制";
|
|
1411
1439
|
var frontend_listview_control_columns = "显示的列";
|
|
@@ -1453,6 +1481,7 @@ var frontend_notifications = "通知";
|
|
|
1453
1481
|
var frontend_notifications_allread = "全部标记为已读";
|
|
1454
1482
|
var frontend_notifications_allread_message = "已全部标记为已读";
|
|
1455
1483
|
var frontend_profile = "个人资料";
|
|
1484
|
+
var switch_space = "切换工作区";
|
|
1456
1485
|
var frontend_about = "关于";
|
|
1457
1486
|
var frontend_log_out = "注销";
|
|
1458
1487
|
var frontend_listview_warning_start = "当前";
|
|
@@ -1541,6 +1570,7 @@ var zh_cn = {
|
|
|
1541
1570
|
frontend_notifications_allread: frontend_notifications_allread,
|
|
1542
1571
|
frontend_notifications_allread_message: frontend_notifications_allread_message,
|
|
1543
1572
|
frontend_profile: frontend_profile,
|
|
1573
|
+
switch_space: switch_space,
|
|
1544
1574
|
frontend_about: frontend_about,
|
|
1545
1575
|
frontend_log_out: frontend_log_out,
|
|
1546
1576
|
frontend_listview_warning_start: frontend_listview_warning_start,
|
|
@@ -1854,7 +1884,8 @@ async function getQuickEditSchema(field, options){
|
|
|
1854
1884
|
"failed": "失败了呢。。"
|
|
1855
1885
|
}
|
|
1856
1886
|
}
|
|
1857
|
-
}
|
|
1887
|
+
},
|
|
1888
|
+
"expression": "${!recordPermissions.modifyAllRecords}"
|
|
1858
1889
|
},
|
|
1859
1890
|
{
|
|
1860
1891
|
"actionType": "setValue",
|
|
@@ -1870,7 +1901,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1870
1901
|
"componentId": quickEditId,
|
|
1871
1902
|
"args": {
|
|
1872
1903
|
"value":{
|
|
1873
|
-
"quickedit_record_permissions": "${event.data}"
|
|
1904
|
+
"quickedit_record_permissions": "${recordPermissions.modifyAllRecords ? {'allowEdit': true} : event.data}"
|
|
1874
1905
|
}
|
|
1875
1906
|
}
|
|
1876
1907
|
}
|
|
@@ -1934,7 +1965,7 @@ async function getQuickEditSchema(field, options){
|
|
|
1934
1965
|
`
|
|
1935
1966
|
}
|
|
1936
1967
|
},
|
|
1937
|
-
"expression":"${event.data.value}"
|
|
1968
|
+
"expression":"${event.data.value && !recordPermissions.modifyAllRecords}"
|
|
1938
1969
|
},
|
|
1939
1970
|
{
|
|
1940
1971
|
"actionType": "setValue",
|
|
@@ -1965,10 +1996,20 @@ async function getQuickEditSchema(field, options){
|
|
|
1965
1996
|
"script": `
|
|
1966
1997
|
const noPermission = event.data.noPermission;
|
|
1967
1998
|
const crudComponent = event.context.scoped.getComponentById("${options.crudId}");
|
|
1968
|
-
|
|
1999
|
+
let selectedItems = crudComponent && crudComponent.props.store.selectedItems.concat();
|
|
1969
2000
|
noPermission.forEach(function (item) {
|
|
1970
2001
|
crudComponent && crudComponent.unSelectItem(_.find(selectedItems,{_id:item}));
|
|
2002
|
+
_.remove(selectedItems, (selected) => selected._id === item);
|
|
1971
2003
|
})
|
|
2004
|
+
doAction({
|
|
2005
|
+
"componentId": "${quickEditId}",
|
|
2006
|
+
"actionType": "setValue",
|
|
2007
|
+
"args": {
|
|
2008
|
+
"value": {
|
|
2009
|
+
selectedItems
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
});
|
|
1972
2013
|
`
|
|
1973
2014
|
},
|
|
1974
2015
|
{
|
|
@@ -2029,7 +2070,7 @@ async function getQuickEditSchema(field, options){
|
|
|
2029
2070
|
}
|
|
2030
2071
|
|
|
2031
2072
|
function getFieldWidth(width){
|
|
2032
|
-
const defaultWidth =
|
|
2073
|
+
const defaultWidth = null;
|
|
2033
2074
|
if(typeof width == 'string'){
|
|
2034
2075
|
if(isNaN(width)){
|
|
2035
2076
|
return width || defaultWidth;
|
|
@@ -2059,18 +2100,35 @@ async function getTableColumns(fields, options){
|
|
|
2059
2100
|
//增加quickEdit属性,实现快速编辑
|
|
2060
2101
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
2061
2102
|
let className = "";
|
|
2062
|
-
|
|
2103
|
+
const bowserType = getBowserType();
|
|
2104
|
+
if(bowserType === "Safari"){
|
|
2063
2105
|
className += " whitespace-nowrap ";
|
|
2064
2106
|
}else {
|
|
2065
|
-
|
|
2107
|
+
if(field.wrap != true){
|
|
2108
|
+
className += " whitespace-nowrap ";
|
|
2109
|
+
}else {
|
|
2110
|
+
className += " break-words ";
|
|
2111
|
+
}
|
|
2066
2112
|
}
|
|
2113
|
+
|
|
2114
|
+
if (typeof field.amis?.className == "object") {
|
|
2115
|
+
className = {
|
|
2116
|
+
[className]: "true",
|
|
2117
|
+
...field.amis.className
|
|
2118
|
+
};
|
|
2119
|
+
} else if (typeof field.amis?.className == "string") {
|
|
2120
|
+
className = `${className} ${field.amis.className} `;
|
|
2121
|
+
}
|
|
2122
|
+
let fieldAmis = _$1.clone(field.amis);
|
|
2123
|
+
delete fieldAmis?.className;
|
|
2124
|
+
|
|
2067
2125
|
let columnItem;
|
|
2068
2126
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
2069
2127
|
const previewFileScript = `
|
|
2070
2128
|
var data = event.data;
|
|
2071
2129
|
var file_name = data.versions ? data.name : "${field.label}";
|
|
2072
|
-
var file_id = data._id;
|
|
2073
|
-
|
|
2130
|
+
var file_id = data.versions && data.versions[0] && data.versions[0]._id;
|
|
2131
|
+
window.previewFile && window.previewFile({file_name, file_id});
|
|
2074
2132
|
`;
|
|
2075
2133
|
columnItem = {
|
|
2076
2134
|
"type": "button",
|
|
@@ -2095,11 +2153,11 @@ async function getTableColumns(fields, options){
|
|
|
2095
2153
|
"expression": "!!!(window && window.nw && window.nw.require)"//浏览器上直接下载
|
|
2096
2154
|
},
|
|
2097
2155
|
{
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2156
|
+
"args": {},
|
|
2157
|
+
"actionType": "custom",
|
|
2158
|
+
"script": previewFileScript,
|
|
2159
|
+
// "expression": "!!window?.nw?.require" //PC客户端预览附件
|
|
2160
|
+
"expression": "!!(window && window.nw && window.nw.require)"//PC客户端预览附件
|
|
2103
2161
|
}
|
|
2104
2162
|
]
|
|
2105
2163
|
}
|
|
@@ -2114,7 +2172,7 @@ async function getTableColumns(fields, options){
|
|
|
2114
2172
|
toggled: field.toggled,
|
|
2115
2173
|
static: true,
|
|
2116
2174
|
className,
|
|
2117
|
-
},
|
|
2175
|
+
}, fieldAmis, {name: field.name});
|
|
2118
2176
|
}else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
|
|
2119
2177
|
columnItem = Object.assign({}, {
|
|
2120
2178
|
type: "switch",
|
|
@@ -2125,7 +2183,7 @@ async function getTableColumns(fields, options){
|
|
|
2125
2183
|
static: true,
|
|
2126
2184
|
className,
|
|
2127
2185
|
...getAmisFileReadonlySchema(field)
|
|
2128
|
-
},
|
|
2186
|
+
}, fieldAmis, {name: field.name});
|
|
2129
2187
|
}
|
|
2130
2188
|
else if(field.type === 'select'){
|
|
2131
2189
|
const map = getSelectMap(field.options);
|
|
@@ -2140,7 +2198,7 @@ async function getTableColumns(fields, options){
|
|
|
2140
2198
|
className,
|
|
2141
2199
|
inputClassName: "inline",
|
|
2142
2200
|
static: true,
|
|
2143
|
-
},
|
|
2201
|
+
}, fieldAmis, {name: field.name});
|
|
2144
2202
|
}
|
|
2145
2203
|
else {
|
|
2146
2204
|
const tpl = await getFieldTpl(field, options);
|
|
@@ -2159,23 +2217,14 @@ async function getTableColumns(fields, options){
|
|
|
2159
2217
|
if(field.type === 'textarea'){
|
|
2160
2218
|
className += 'min-w-56';
|
|
2161
2219
|
}
|
|
2162
|
-
if(field.type === 'date'){
|
|
2163
|
-
|
|
2164
|
-
}
|
|
2165
|
-
if(field.type === 'datetime'){
|
|
2166
|
-
|
|
2167
|
-
}
|
|
2220
|
+
// if(field.type === 'date'){
|
|
2221
|
+
// className += 'date-min-w';
|
|
2222
|
+
// }
|
|
2223
|
+
// if(field.type === 'datetime'){
|
|
2224
|
+
// className += 'datetime-min-w';
|
|
2225
|
+
// }
|
|
2168
2226
|
|
|
2169
2227
|
//field上的amis属性里的clssname需要单独判断类型合并
|
|
2170
|
-
if (typeof field.amis?.className == "object") {
|
|
2171
|
-
className = {
|
|
2172
|
-
[className]: "true",
|
|
2173
|
-
...field.amis.className
|
|
2174
|
-
};
|
|
2175
|
-
} else if (typeof field.amis?.className == "string") {
|
|
2176
|
-
className = `${className} ${field.amis.className} `;
|
|
2177
|
-
}
|
|
2178
|
-
delete field.amis?.className;
|
|
2179
2228
|
|
|
2180
2229
|
if(!field.hidden && !field.extra){
|
|
2181
2230
|
columnItem = Object.assign({}, {
|
|
@@ -2192,7 +2241,7 @@ async function getTableColumns(fields, options){
|
|
|
2192
2241
|
static: true,
|
|
2193
2242
|
options: field.type === 'html' ? {html: true} : null
|
|
2194
2243
|
// toggled: true
|
|
2195
|
-
},
|
|
2244
|
+
}, fieldAmis, {name: field.name});
|
|
2196
2245
|
|
|
2197
2246
|
if(field.type === 'color'){
|
|
2198
2247
|
columnItem.type = 'color';
|
|
@@ -2259,7 +2308,7 @@ function getMobileLines(tpls){
|
|
|
2259
2308
|
}
|
|
2260
2309
|
if(isLeft){
|
|
2261
2310
|
// 左侧半行
|
|
2262
|
-
lineChildrenClassName = "steedos-listview-item-left truncate";
|
|
2311
|
+
lineChildrenClassName = "steedos-listview-item-left truncate h-5";
|
|
2263
2312
|
if(item.field.is_wide){
|
|
2264
2313
|
// 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
|
|
2265
2314
|
lineChildrenClassName = "steedos-listview-item-wide";
|
|
@@ -2271,7 +2320,7 @@ function getMobileLines(tpls){
|
|
|
2271
2320
|
}
|
|
2272
2321
|
else {
|
|
2273
2322
|
// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
2274
|
-
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
|
|
2323
|
+
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
|
|
2275
2324
|
}
|
|
2276
2325
|
//支持字段amis属性配置classname,识别classname的类型,与原样式合并
|
|
2277
2326
|
var className;
|
|
@@ -2382,8 +2431,16 @@ async function getMobileTableColumns(fields, options){
|
|
|
2382
2431
|
"actions": [
|
|
2383
2432
|
{
|
|
2384
2433
|
"script": `
|
|
2385
|
-
let cms_url =
|
|
2386
|
-
|
|
2434
|
+
let cms_url = '';
|
|
2435
|
+
let value = event.data.versions[0];
|
|
2436
|
+
if(value){
|
|
2437
|
+
if(value.url){
|
|
2438
|
+
cms_url = value.url;
|
|
2439
|
+
}else{
|
|
2440
|
+
cms_url = Steedos.absoluteUrl("/api/files/files/"+value+"?download=true");
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
Steedos.cordovaDownload(encodeURI(cms_url), event.data.name);
|
|
2387
2444
|
`,
|
|
2388
2445
|
"actionType": "custom"
|
|
2389
2446
|
}
|
|
@@ -2498,7 +2555,8 @@ async function getTableOperation(ctx){
|
|
|
2498
2555
|
label: " ",
|
|
2499
2556
|
fixed: 'right',
|
|
2500
2557
|
labelClassName: 'text-center',
|
|
2501
|
-
|
|
2558
|
+
//TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
|
|
2559
|
+
className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
|
|
2502
2560
|
buttons: [
|
|
2503
2561
|
{
|
|
2504
2562
|
"type": "steedos-dropdown-button",
|
|
@@ -2594,7 +2652,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2594
2652
|
}
|
|
2595
2653
|
return {
|
|
2596
2654
|
mode: "cards",
|
|
2597
|
-
perPageAvailable: [
|
|
2655
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2598
2656
|
name: "thelist",
|
|
2599
2657
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2600
2658
|
className: "",
|
|
@@ -2627,7 +2685,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2627
2685
|
|
|
2628
2686
|
return {
|
|
2629
2687
|
mode: "table",
|
|
2630
|
-
perPageAvailable: [
|
|
2688
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2631
2689
|
name: "thelist",
|
|
2632
2690
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2633
2691
|
className: "",
|
|
@@ -2882,6 +2940,21 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2882
2940
|
return api;
|
|
2883
2941
|
`;
|
|
2884
2942
|
api.adaptor = `
|
|
2943
|
+
let fields = ${JSON.stringify(_$1.map(fields, 'name'))};
|
|
2944
|
+
// 这里把行数据中所有为空的字段值配置为空字符串,是因为amis有bug:crud的columns中的列如果type为static-前缀的话,行数据中该字段为空的话会显示为父作用域中同名变量值,见:https://github.com/baidu/amis/issues/9556
|
|
2945
|
+
(payload.data.rows || []).forEach((itemRow) => {
|
|
2946
|
+
(fields || []).forEach((itemField) => {
|
|
2947
|
+
if(itemField && itemField.indexOf(".") > -1){
|
|
2948
|
+
return;
|
|
2949
|
+
}
|
|
2950
|
+
if(itemField && (itemRow[itemField] === undefined || itemRow[itemField] === null)){
|
|
2951
|
+
// 这里itemRow中不存在 itemField 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
|
|
2952
|
+
// 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
|
|
2953
|
+
itemRow[itemField] = "";
|
|
2954
|
+
}
|
|
2955
|
+
});
|
|
2956
|
+
});
|
|
2957
|
+
|
|
2885
2958
|
if(api.body.listName == "recent"){
|
|
2886
2959
|
payload.data.rows = _.sortBy(payload.data.rows, function(item){
|
|
2887
2960
|
return _.indexOf(api.body._ids, item._id)
|
|
@@ -2906,7 +2979,13 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2906
2979
|
value = [value]
|
|
2907
2980
|
};
|
|
2908
2981
|
if(field.type === 'file'){
|
|
2909
|
-
item[key] = value
|
|
2982
|
+
// item[key] = value
|
|
2983
|
+
// PC客户端附件子表列表点击标题预览附件功能依赖了_id,所以这里拼出来
|
|
2984
|
+
let itemKeyValue = item[key];
|
|
2985
|
+
item[key] = value.map(function(item, index){
|
|
2986
|
+
item._id = itemKeyValue[index];
|
|
2987
|
+
return item;
|
|
2988
|
+
});
|
|
2910
2989
|
}else{
|
|
2911
2990
|
item[key] = _.map(value, (item)=>{
|
|
2912
2991
|
if(field.type === 'image'){
|
|
@@ -2948,15 +3027,8 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2948
3027
|
}
|
|
2949
3028
|
});
|
|
2950
3029
|
};
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
isTreeOptionsComputed = true;
|
|
2954
|
-
}
|
|
2955
|
-
if(!isTreeOptionsComputed){
|
|
2956
|
-
// 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
|
|
2957
|
-
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
2958
|
-
assignIndexToTreeRecords(payload.data.rows, '');
|
|
2959
|
-
}
|
|
3030
|
+
payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
|
|
3031
|
+
assignIndexToTreeRecords(payload.data.rows, '');
|
|
2960
3032
|
}
|
|
2961
3033
|
|
|
2962
3034
|
|
|
@@ -3013,12 +3085,15 @@ async function getTableApi(mainObject, fields, options){
|
|
|
3013
3085
|
}
|
|
3014
3086
|
// SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
3015
3087
|
};
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3088
|
+
let formFactor = "${options.formFactor}";
|
|
3089
|
+
if(formFactor !== "SMALL"){
|
|
3090
|
+
const listviewComponent = $(".steedos-object-listview .antd-Table-table");
|
|
3091
|
+
const firstListviewComponent = listviewComponent && listviewComponent[0];
|
|
3092
|
+
if(firstListviewComponent){
|
|
3093
|
+
setTimeout(()=>{
|
|
3094
|
+
firstListviewComponent.scrollIntoView();
|
|
3095
|
+
}, 600);
|
|
3096
|
+
}
|
|
3022
3097
|
}
|
|
3023
3098
|
${options.adaptor || ''}
|
|
3024
3099
|
return payload;
|
|
@@ -3131,12 +3206,21 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3131
3206
|
}
|
|
3132
3207
|
payload.data = data;
|
|
3133
3208
|
payload.data.__objectName = "${object.name}";
|
|
3134
|
-
payload.data.
|
|
3209
|
+
payload.data.record = record;
|
|
3210
|
+
|
|
3211
|
+
payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
|
|
3212
|
+
payload.data._master = {
|
|
3213
|
+
record: record,
|
|
3214
|
+
objectName: "${object.name}",
|
|
3215
|
+
recordId: record._id
|
|
3216
|
+
}
|
|
3135
3217
|
window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
|
|
3136
3218
|
}
|
|
3137
3219
|
if(payload.errors){
|
|
3138
3220
|
payload.status = 2;
|
|
3139
3221
|
payload.msg = payload.errors[0].message;
|
|
3222
|
+
}else{
|
|
3223
|
+
payload.data.recordLoaded = true;
|
|
3140
3224
|
}
|
|
3141
3225
|
${options && options.initApiAdaptor || ''}
|
|
3142
3226
|
return payload;
|
|
@@ -3279,7 +3363,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3279
3363
|
cache: API_CACHE,
|
|
3280
3364
|
requestAdaptor: `
|
|
3281
3365
|
// 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
|
|
3282
|
-
var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
|
|
3366
|
+
var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
|
|
3283
3367
|
if(!recordId){
|
|
3284
3368
|
// 新建则不请求任何数据
|
|
3285
3369
|
data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
|
|
@@ -3357,10 +3441,11 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3357
3441
|
...initialValues
|
|
3358
3442
|
}
|
|
3359
3443
|
${options.initApiAdaptor || ''}
|
|
3444
|
+
// console.log('getEditFormInitApi======>', payload);
|
|
3360
3445
|
return payload;
|
|
3361
3446
|
`,
|
|
3362
3447
|
responseData: {
|
|
3363
|
-
|
|
3448
|
+
"&": "$$",
|
|
3364
3449
|
editFormInited: true
|
|
3365
3450
|
},
|
|
3366
3451
|
data: data,
|
|
@@ -3399,6 +3484,18 @@ function getBatchDelete(objectName){
|
|
|
3399
3484
|
return {
|
|
3400
3485
|
method: 'post',
|
|
3401
3486
|
url: getApi$2(),
|
|
3487
|
+
adaptor: `
|
|
3488
|
+
if(payload.errors){
|
|
3489
|
+
payload.data.deleteErrorMessage = [];
|
|
3490
|
+
payload.errors.forEach(function(error){
|
|
3491
|
+
let errorRecord = error.path.map(function (item) {
|
|
3492
|
+
return item.split('delete__')[1].to_float() + 1;
|
|
3493
|
+
}).toString();
|
|
3494
|
+
payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
|
|
3495
|
+
})
|
|
3496
|
+
}
|
|
3497
|
+
return payload;
|
|
3498
|
+
`,
|
|
3402
3499
|
requestAdaptor: `
|
|
3403
3500
|
var ids = api.data.ids.split(",");
|
|
3404
3501
|
var deleteArray = [];
|
|
@@ -4193,7 +4290,7 @@ async function getListBody(fields, options){
|
|
|
4193
4290
|
|
|
4194
4291
|
function getDefaultParams(options){
|
|
4195
4292
|
return {
|
|
4196
|
-
perPage: options.top || options.perPage ||
|
|
4293
|
+
perPage: options.top || options.perPage || 20
|
|
4197
4294
|
}
|
|
4198
4295
|
}
|
|
4199
4296
|
|
|
@@ -4396,7 +4493,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
4396
4493
|
"objectApiName": "\${objectName}",
|
|
4397
4494
|
"recordId": "",
|
|
4398
4495
|
"mode": "edit",
|
|
4399
|
-
"layout": "normal"
|
|
4400
4496
|
};
|
|
4401
4497
|
|
|
4402
4498
|
if (payload && payload.schema) {
|
|
@@ -4828,9 +4924,16 @@ const getSchema$2 = (uiSchema) => {
|
|
|
4828
4924
|
"form": {
|
|
4829
4925
|
debug: false,
|
|
4830
4926
|
resetAfterSubmit: false,
|
|
4927
|
+
data: {
|
|
4928
|
+
editFormInited: true,
|
|
4929
|
+
},
|
|
4831
4930
|
initApi: {
|
|
4931
|
+
method: 'GET',
|
|
4832
4932
|
url: '/api/v1/queue_import_history/${recordId}?fields=["state"]',
|
|
4833
4933
|
sendOn: 'this.recordId',
|
|
4934
|
+
data: null,
|
|
4935
|
+
requestAdaptor: "return api;",
|
|
4936
|
+
adaptor: "return payload;",
|
|
4834
4937
|
responseData: {
|
|
4835
4938
|
importState: "${state}"
|
|
4836
4939
|
}
|
|
@@ -5101,7 +5204,7 @@ const StandardButtons = {
|
|
|
5101
5204
|
}
|
|
5102
5205
|
};
|
|
5103
5206
|
|
|
5104
|
-
const getGlobalData
|
|
5207
|
+
const getGlobalData = () => {
|
|
5105
5208
|
return {
|
|
5106
5209
|
now: new Date(),
|
|
5107
5210
|
};
|
|
@@ -5160,7 +5263,7 @@ const getButtonVisible = (button, ctx) => {
|
|
|
5160
5263
|
button._visible,
|
|
5161
5264
|
props.record,
|
|
5162
5265
|
"#",
|
|
5163
|
-
getGlobalData
|
|
5266
|
+
getGlobalData(),
|
|
5164
5267
|
props.userSession
|
|
5165
5268
|
);
|
|
5166
5269
|
};
|
|
@@ -5702,7 +5805,7 @@ async function getObjectFieldsFilterFormSchema(ctx) {
|
|
|
5702
5805
|
const formSchema = {
|
|
5703
5806
|
"type": "service",
|
|
5704
5807
|
"visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
|
|
5705
|
-
"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-
|
|
5808
|
+
"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",
|
|
5706
5809
|
"style":{
|
|
5707
5810
|
"max-height":ctx.formFactor === 'SMALL'?"30vh":"unset"
|
|
5708
5811
|
},
|
|
@@ -6289,7 +6392,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
|
|
|
6289
6392
|
"className": "slds-filters"
|
|
6290
6393
|
},
|
|
6291
6394
|
"size": "xs",
|
|
6292
|
-
"className": `border-
|
|
6395
|
+
"className": `border-y slds-grid slds-grid_vertical slds-nowrap ${!ctx.isLookup && "mt-2"}`,
|
|
6293
6396
|
"visibleOn": "this.showFieldsFilter",
|
|
6294
6397
|
},
|
|
6295
6398
|
"className": "bg-white"
|
|
@@ -6477,7 +6580,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
|
|
|
6477
6580
|
"icon": "fa fa-refresh",
|
|
6478
6581
|
"actionType": "reload",
|
|
6479
6582
|
"target": amisListViewId,
|
|
6480
|
-
"className": "bg-white p-2 rounded
|
|
6583
|
+
"className": "bg-white p-2 rounded text-gray-500"
|
|
6481
6584
|
},
|
|
6482
6585
|
fieldsFilterButtonSchema,
|
|
6483
6586
|
// {
|
|
@@ -6485,7 +6588,7 @@ async function getObjectListHeaderSecordLine(objectSchema, listViewName, ctx) {
|
|
|
6485
6588
|
// "label": "",
|
|
6486
6589
|
// "icon": "fa fa-filter",
|
|
6487
6590
|
// "actionType": "custom",
|
|
6488
|
-
// "className": "bg-transparent p-2 rounded
|
|
6591
|
+
// "className": "bg-transparent p-2 rounded text-gray-500",
|
|
6489
6592
|
// "id": "u:c20cb87d96c9",
|
|
6490
6593
|
// "onEvent": {
|
|
6491
6594
|
// "click": {
|
|
@@ -6533,11 +6636,53 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6533
6636
|
let headerSchema = [{
|
|
6534
6637
|
"type": "wrapper",
|
|
6535
6638
|
"body": body,
|
|
6536
|
-
"className": `
|
|
6639
|
+
"className": `sm:rounded-tl sm:rounded-tr p-4 -mb-4`
|
|
6537
6640
|
}];
|
|
6538
6641
|
return headerSchema;
|
|
6539
6642
|
}
|
|
6540
6643
|
|
|
6644
|
+
function getBackButtonSchema(){
|
|
6645
|
+
return {
|
|
6646
|
+
"type": "service",
|
|
6647
|
+
"onEvent": {
|
|
6648
|
+
"@history_paths.changed": {
|
|
6649
|
+
"actions": [
|
|
6650
|
+
{
|
|
6651
|
+
"actionType": "reload",
|
|
6652
|
+
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6653
|
+
"data": {
|
|
6654
|
+
}
|
|
6655
|
+
}
|
|
6656
|
+
]
|
|
6657
|
+
}
|
|
6658
|
+
},
|
|
6659
|
+
"body":[{
|
|
6660
|
+
"type": "button",
|
|
6661
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6662
|
+
"className":"flex mr-4",
|
|
6663
|
+
"onEvent": {
|
|
6664
|
+
"click": {
|
|
6665
|
+
"actions": [
|
|
6666
|
+
{
|
|
6667
|
+
"actionType": "custom",
|
|
6668
|
+
"script": "window.goBack()"
|
|
6669
|
+
}
|
|
6670
|
+
]
|
|
6671
|
+
}
|
|
6672
|
+
},
|
|
6673
|
+
"body": [
|
|
6674
|
+
{
|
|
6675
|
+
"type": "steedos-icon",
|
|
6676
|
+
"category": "utility",
|
|
6677
|
+
"name": "back",
|
|
6678
|
+
"colorVariant": "default",
|
|
6679
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6680
|
+
}
|
|
6681
|
+
]
|
|
6682
|
+
}]
|
|
6683
|
+
}
|
|
6684
|
+
}
|
|
6685
|
+
|
|
6541
6686
|
/**
|
|
6542
6687
|
* 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
|
|
6543
6688
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -6546,11 +6691,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6546
6691
|
* @returns amisSchema
|
|
6547
6692
|
*/
|
|
6548
6693
|
async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
6694
|
+
// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
6549
6695
|
const { showRecordTitle = true } = options || {};
|
|
6550
6696
|
// console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
|
|
6551
6697
|
const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
|
|
6552
6698
|
|
|
6553
|
-
let amisButtonsSchema =
|
|
6699
|
+
let amisButtonsSchema = [];
|
|
6700
|
+
if(options.showButtons != false){
|
|
6701
|
+
amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
|
|
6702
|
+
}
|
|
6703
|
+
|
|
6704
|
+
let backButtonsSchema = null;
|
|
6705
|
+
|
|
6706
|
+
if(options.showBackButton != false){
|
|
6707
|
+
backButtonsSchema = getBackButtonSchema();
|
|
6708
|
+
}
|
|
6554
6709
|
|
|
6555
6710
|
// console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
|
|
6556
6711
|
|
|
@@ -6565,45 +6720,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6565
6720
|
"type": "grid",
|
|
6566
6721
|
"columns": [
|
|
6567
6722
|
{
|
|
6568
|
-
"body": [
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
"@history_paths.changed": {
|
|
6572
|
-
"actions": [
|
|
6573
|
-
{
|
|
6574
|
-
"actionType": "reload",
|
|
6575
|
-
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6576
|
-
"data": {
|
|
6577
|
-
}
|
|
6578
|
-
}
|
|
6579
|
-
]
|
|
6580
|
-
}
|
|
6581
|
-
},
|
|
6582
|
-
"body":[{
|
|
6583
|
-
"type": "button",
|
|
6584
|
-
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6585
|
-
"className":"flex mr-4",
|
|
6586
|
-
"onEvent": {
|
|
6587
|
-
"click": {
|
|
6588
|
-
"actions": [
|
|
6589
|
-
{
|
|
6590
|
-
"actionType": "custom",
|
|
6591
|
-
"script": "window.goBack()"
|
|
6592
|
-
}
|
|
6593
|
-
]
|
|
6594
|
-
}
|
|
6595
|
-
},
|
|
6596
|
-
"body": [
|
|
6597
|
-
{
|
|
6598
|
-
"type": "steedos-icon",
|
|
6599
|
-
"category": "utility",
|
|
6600
|
-
"name": "back",
|
|
6601
|
-
"colorVariant": "default",
|
|
6602
|
-
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6603
|
-
}
|
|
6604
|
-
]
|
|
6605
|
-
}]
|
|
6606
|
-
},{
|
|
6723
|
+
"body": [
|
|
6724
|
+
backButtonsSchema
|
|
6725
|
+
,{
|
|
6607
6726
|
"type": "tpl",
|
|
6608
6727
|
"className": "block",
|
|
6609
6728
|
// "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'>`
|
|
@@ -6624,8 +6743,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6624
6743
|
},
|
|
6625
6744
|
{
|
|
6626
6745
|
"type": "tpl",
|
|
6627
|
-
"tpl": "${
|
|
6628
|
-
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
6746
|
+
"tpl": "${NAME_FIELD_VALUE}",
|
|
6629
6747
|
"inline": false,
|
|
6630
6748
|
"wrapperComponent": "",
|
|
6631
6749
|
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
@@ -6653,7 +6771,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6653
6771
|
let body = [
|
|
6654
6772
|
{
|
|
6655
6773
|
"type": "wrapper",
|
|
6656
|
-
"className": "p-
|
|
6774
|
+
"className": "p-4 border-b",
|
|
6657
6775
|
"body": [
|
|
6658
6776
|
{
|
|
6659
6777
|
"type": "grid",
|
|
@@ -6668,7 +6786,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6668
6786
|
if(showRecordTitle){
|
|
6669
6787
|
body.push({
|
|
6670
6788
|
"type": "wrapper",
|
|
6671
|
-
"className": "p-
|
|
6789
|
+
"className": "p-4",
|
|
6672
6790
|
"body": [
|
|
6673
6791
|
{
|
|
6674
6792
|
"type": "grid",
|
|
@@ -6680,11 +6798,76 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6680
6798
|
});
|
|
6681
6799
|
}
|
|
6682
6800
|
|
|
6801
|
+
let max = 10;
|
|
6802
|
+
if(options.formFactor === 'SMALL'){
|
|
6803
|
+
max = 4;
|
|
6804
|
+
}else {
|
|
6805
|
+
|
|
6806
|
+
let divWidth = window.innerWidth;
|
|
6807
|
+
|
|
6808
|
+
if(options.display === 'split'){
|
|
6809
|
+
divWidth = divWidth - 388;
|
|
6810
|
+
}
|
|
6811
|
+
|
|
6812
|
+
if(document.body.classList.contains('sidebar')){
|
|
6813
|
+
divWidth = divWidth - 210;
|
|
6814
|
+
}
|
|
6815
|
+
|
|
6816
|
+
// 根据屏幕宽度计算显示数量, 使高亮字段只占1行
|
|
6817
|
+
max = Math.trunc(divWidth / 200 );
|
|
6818
|
+
if(max > 10){
|
|
6819
|
+
max = 10;
|
|
6820
|
+
}
|
|
6821
|
+
}
|
|
6822
|
+
|
|
6823
|
+
// console.log('=======================max=========================', max)
|
|
6824
|
+
|
|
6825
|
+
if(objectSchema.compactLayouts){
|
|
6826
|
+
const details = [];
|
|
6827
|
+
_.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
|
|
6828
|
+
const field = objectSchema.fields[fieldName];
|
|
6829
|
+
if(field){
|
|
6830
|
+
details.push({
|
|
6831
|
+
type: 'steedos-field',
|
|
6832
|
+
static: true,
|
|
6833
|
+
config: field,
|
|
6834
|
+
});
|
|
6835
|
+
}
|
|
6836
|
+
});
|
|
6837
|
+
|
|
6838
|
+
// 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
|
|
6839
|
+
// lg:grid-cols-1
|
|
6840
|
+
// lg:grid-cols-2
|
|
6841
|
+
// lg:grid-cols-3
|
|
6842
|
+
// lg:grid-cols-4
|
|
6843
|
+
// lg:grid-cols-5
|
|
6844
|
+
// lg:grid-cols-6
|
|
6845
|
+
// lg:grid-cols-7
|
|
6846
|
+
// lg:grid-cols-8
|
|
6847
|
+
// lg:grid-cols-9
|
|
6848
|
+
// lg:grid-cols-10
|
|
6849
|
+
// lg:grid-cols-11
|
|
6850
|
+
// lg:grid-cols-12
|
|
6851
|
+
|
|
6852
|
+
body.push({
|
|
6853
|
+
"type": "wrapper",
|
|
6854
|
+
"body": {
|
|
6855
|
+
"type": "form",
|
|
6856
|
+
// "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
|
|
6857
|
+
"className": `gap-2 grid grid-cols-1 lg:grid-cols-${max}`,
|
|
6858
|
+
"wrapWithPanel": false,
|
|
6859
|
+
"actions": [],
|
|
6860
|
+
"body": details,
|
|
6861
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
6862
|
+
},
|
|
6863
|
+
"className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
|
|
6864
|
+
});
|
|
6865
|
+
}
|
|
6866
|
+
|
|
6683
6867
|
return {
|
|
6684
6868
|
type: 'service',
|
|
6685
6869
|
id: `page_readonly_${name}_header`,
|
|
6686
6870
|
name: `page`,
|
|
6687
|
-
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
6688
6871
|
body: body,
|
|
6689
6872
|
className: ''
|
|
6690
6873
|
}
|
|
@@ -6756,7 +6939,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
6756
6939
|
"className": "flex justify-between"
|
|
6757
6940
|
}
|
|
6758
6941
|
],
|
|
6759
|
-
"className": "
|
|
6942
|
+
"className": "steedos-record-related-header py-2 px-3 bg-gray-50 border"
|
|
6760
6943
|
};
|
|
6761
6944
|
return recordRelatedListHeader;
|
|
6762
6945
|
}
|
|
@@ -7714,7 +7897,7 @@ const getSettingListviewToolbarButtonSchema = ()=>{
|
|
|
7714
7897
|
"icon": "fa fa-cog",
|
|
7715
7898
|
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
7716
7899
|
// "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
|
|
7717
|
-
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded
|
|
7900
|
+
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
|
|
7718
7901
|
"align": "right",
|
|
7719
7902
|
"visibleOn": "${!isLookup}",
|
|
7720
7903
|
"buttons": [
|
|
@@ -7741,14 +7924,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
7741
7924
|
{
|
|
7742
7925
|
"type": "button",
|
|
7743
7926
|
"label": i18next.t('frontend_display_type_is_table'),
|
|
7744
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7927
|
+
"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');",
|
|
7745
7928
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
7746
7929
|
"rightIconClassName": "m-l-sm"
|
|
7747
7930
|
},
|
|
7748
7931
|
{
|
|
7749
7932
|
"type": "button",
|
|
7750
7933
|
"label": i18next.t('frontend_display_type_is_split'),
|
|
7751
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7934
|
+
"onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
7752
7935
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
7753
7936
|
"rightIconClassName": "m-l-sm"
|
|
7754
7937
|
}
|
|
@@ -7759,7 +7942,7 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
7759
7942
|
"icon": "fa fa-table-columns",
|
|
7760
7943
|
//TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
7761
7944
|
// "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
|
|
7762
|
-
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded
|
|
7945
|
+
"btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
|
|
7763
7946
|
"align": "right",
|
|
7764
7947
|
"visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
|
|
7765
7948
|
"buttons": [
|
|
@@ -7891,7 +8074,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7891
8074
|
{
|
|
7892
8075
|
"type": "search-box",
|
|
7893
8076
|
"name": keywordsSearchBoxName,
|
|
7894
|
-
"placeholder": "
|
|
8077
|
+
"placeholder": "快捷搜索",
|
|
7895
8078
|
"value": crudKeywords,
|
|
7896
8079
|
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7897
8080
|
"clearAndSubmit": true,
|
|
@@ -7952,7 +8135,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
7952
8135
|
// //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
|
|
7953
8136
|
// // "tooltip": i18next.t('frontend_button_reload_tooltip'),
|
|
7954
8137
|
// "tooltipPlacement": "top",
|
|
7955
|
-
// "className": "bg-white p-2 rounded
|
|
8138
|
+
// "className": "bg-white p-2 rounded text-gray-500",
|
|
7956
8139
|
// "label": "",
|
|
7957
8140
|
// "icon": "fa fa-sync",
|
|
7958
8141
|
// "visibleOn": "${!showFieldsFilter}",
|
|
@@ -7976,7 +8159,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
7976
8159
|
// "tooltip": i18next.t('frontend_button_reload_tooltip'),
|
|
7977
8160
|
"tooltip":"",
|
|
7978
8161
|
"tooltipPlacement": "top",
|
|
7979
|
-
"className": "bg-white p-2 rounded
|
|
8162
|
+
"className": "bg-white p-2 rounded text-gray-500"
|
|
7980
8163
|
};
|
|
7981
8164
|
}
|
|
7982
8165
|
else {
|
|
@@ -7987,7 +8170,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
7987
8170
|
// "tooltip": i18next.t('frontend_button_reload_tooltip'),
|
|
7988
8171
|
"tooltip":"",
|
|
7989
8172
|
"tooltipPlacement": "top",
|
|
7990
|
-
"className": "bg-white p-2 rounded
|
|
8173
|
+
"className": "bg-white p-2 rounded text-gray-500"
|
|
7991
8174
|
};
|
|
7992
8175
|
}
|
|
7993
8176
|
let toolbarFilter;
|
|
@@ -8009,7 +8192,7 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
|
|
|
8009
8192
|
"visibleOn": "${isFieldsFilterEmpty == false && isLookup != true}"
|
|
8010
8193
|
},
|
|
8011
8194
|
"align": "right",
|
|
8012
|
-
"className": "bg-white p-2 rounded
|
|
8195
|
+
"className": "bg-white p-2 rounded text-gray-500",
|
|
8013
8196
|
"onEvent": {
|
|
8014
8197
|
"click": {
|
|
8015
8198
|
"actions": [
|
|
@@ -8095,7 +8278,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8095
8278
|
// ]
|
|
8096
8279
|
if(options.displayAs === 'split'){
|
|
8097
8280
|
return [
|
|
8098
|
-
|
|
8281
|
+
{
|
|
8282
|
+
"type": "switch-per-page",
|
|
8283
|
+
"visibleOn": "${count >= 20}"
|
|
8284
|
+
},
|
|
8099
8285
|
{
|
|
8100
8286
|
"type": "pagination",
|
|
8101
8287
|
"maxButtons": 5,
|
|
@@ -8117,7 +8303,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8117
8303
|
else {
|
|
8118
8304
|
if(options && options.isRelated){
|
|
8119
8305
|
return [
|
|
8120
|
-
"statistics",
|
|
8121
8306
|
{
|
|
8122
8307
|
"type": "pagination",
|
|
8123
8308
|
"maxButtons": 10,
|
|
@@ -8130,7 +8315,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8130
8315
|
const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
|
|
8131
8316
|
const is_lookup = options.isLookup;
|
|
8132
8317
|
const commonConfig = [
|
|
8133
|
-
"statistics",
|
|
8134
8318
|
{
|
|
8135
8319
|
"type": "pagination",
|
|
8136
8320
|
"maxButtons": 10,
|
|
@@ -8141,7 +8325,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8141
8325
|
if (no_pagination && is_lookup) {
|
|
8142
8326
|
return commonConfig;
|
|
8143
8327
|
} else {
|
|
8144
|
-
return [
|
|
8328
|
+
return [{
|
|
8329
|
+
"type": "switch-per-page",
|
|
8330
|
+
"visibleOn": "${count >= 20}"
|
|
8331
|
+
}, ...commonConfig];
|
|
8145
8332
|
}
|
|
8146
8333
|
}
|
|
8147
8334
|
}
|
|
@@ -8165,7 +8352,6 @@ async function getObjectFilter(objectSchema, fields, options) {
|
|
|
8165
8352
|
"timeOut": 1000
|
|
8166
8353
|
}
|
|
8167
8354
|
});
|
|
8168
|
-
resizeWindow();
|
|
8169
8355
|
const scope = event.context.scoped;
|
|
8170
8356
|
// let filterFormValues = event.data;
|
|
8171
8357
|
let filterForm = SteedosUI.getClosestAmisComponentByType(scope, "form");
|
|
@@ -8249,6 +8435,29 @@ function getBulkActions(objectSchema){
|
|
|
8249
8435
|
"className": "hidden",
|
|
8250
8436
|
"id": "batchDelete",
|
|
8251
8437
|
"api": getBatchDelete(objectSchema.name),
|
|
8438
|
+
"feedback": {
|
|
8439
|
+
"title": "删除警告",
|
|
8440
|
+
"visibleOn": "${deleteErrorMessage}",
|
|
8441
|
+
"body": [
|
|
8442
|
+
{
|
|
8443
|
+
"type": "each",
|
|
8444
|
+
"name": "deleteErrorMessage",
|
|
8445
|
+
"items": {
|
|
8446
|
+
"type": "alert",
|
|
8447
|
+
"body": "${item}",
|
|
8448
|
+
"level": "danger",
|
|
8449
|
+
"className": "mb-3"
|
|
8450
|
+
}
|
|
8451
|
+
}
|
|
8452
|
+
],
|
|
8453
|
+
"actions": [
|
|
8454
|
+
{
|
|
8455
|
+
"type": "button",
|
|
8456
|
+
"actionType": "close",
|
|
8457
|
+
"label": "关闭"
|
|
8458
|
+
}
|
|
8459
|
+
]
|
|
8460
|
+
}
|
|
8252
8461
|
}
|
|
8253
8462
|
// {
|
|
8254
8463
|
// "label": "批量修改",
|
|
@@ -8309,7 +8518,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8309
8518
|
const bodyProps = {
|
|
8310
8519
|
// toolbar: getToolbar(),
|
|
8311
8520
|
// headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
|
|
8312
|
-
headerToolbarClassName: "px-4 py-2 border-
|
|
8521
|
+
headerToolbarClassName: "px-4 py-2 border-b",
|
|
8313
8522
|
footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
|
|
8314
8523
|
...options,
|
|
8315
8524
|
disableStatistics: options.queryCount === false
|
|
@@ -8445,7 +8654,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8445
8654
|
// "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8446
8655
|
// },
|
|
8447
8656
|
bodyClassName: {
|
|
8448
|
-
"
|
|
8657
|
+
"mb-0": true,
|
|
8449
8658
|
"is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8450
8659
|
},
|
|
8451
8660
|
crudClassName: crudClassName,
|
|
@@ -8456,16 +8665,11 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8456
8665
|
headers: {
|
|
8457
8666
|
Authorization: "Bearer ${context.tenantId},${context.authToken}",
|
|
8458
8667
|
},
|
|
8459
|
-
requestAdaptor: quickSaveApiRequestAdaptor
|
|
8460
|
-
adaptor: `
|
|
8461
|
-
if(payload.errors){
|
|
8462
|
-
payload.status = 2;
|
|
8463
|
-
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
8464
|
-
}
|
|
8465
|
-
return payload;
|
|
8466
|
-
`
|
|
8668
|
+
requestAdaptor: quickSaveApiRequestAdaptor
|
|
8467
8669
|
},
|
|
8468
|
-
rowClassNameExpr
|
|
8670
|
+
// 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
|
|
8671
|
+
// 使用表达式给tr添加初始选中状态
|
|
8672
|
+
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 %>"
|
|
8469
8673
|
}, bodyProps);
|
|
8470
8674
|
|
|
8471
8675
|
}
|
|
@@ -8478,9 +8682,23 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8478
8682
|
crudModeClassName = `steedos-crud-mode-${body.mode}`;
|
|
8479
8683
|
}
|
|
8480
8684
|
|
|
8685
|
+
body.quickSaveApi.adaptor = `
|
|
8686
|
+
if(payload.errors){
|
|
8687
|
+
payload.status = 2;
|
|
8688
|
+
payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
|
|
8689
|
+
}
|
|
8690
|
+
var scope = SteedosUI.getRef(context.scopeId);
|
|
8691
|
+
var scopeParent = scope && scope.parent;
|
|
8692
|
+
var crudScoped = scopeParent.getComponentById('${body.id}');
|
|
8693
|
+
setTimeout(()=>{
|
|
8694
|
+
crudScoped && crudScoped.control.updateAutoFillHeight();
|
|
8695
|
+
}, 500);
|
|
8696
|
+
return payload;
|
|
8697
|
+
`;
|
|
8698
|
+
|
|
8481
8699
|
if(body.columns && options.formFactor != 'SMALL'){
|
|
8482
8700
|
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8483
|
-
body.columns.splice(body.columns.length -
|
|
8701
|
+
body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
|
|
8484
8702
|
}
|
|
8485
8703
|
|
|
8486
8704
|
if (defaults) {
|
|
@@ -8538,11 +8756,6 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8538
8756
|
}
|
|
8539
8757
|
}
|
|
8540
8758
|
|
|
8541
|
-
const getGlobalData = (mode)=>{
|
|
8542
|
-
const user = getSteedosAuth();
|
|
8543
|
-
return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
|
|
8544
|
-
};
|
|
8545
|
-
|
|
8546
8759
|
const getFormFields$1 = (objectSchema, formProps)=>{
|
|
8547
8760
|
/**
|
|
8548
8761
|
* fieldsExtend: 重写字段定义
|
|
@@ -8604,7 +8817,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
|
|
|
8604
8817
|
}
|
|
8605
8818
|
|
|
8606
8819
|
async function getObjectForm(objectSchema, ctx){
|
|
8607
|
-
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8820
|
+
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
|
|
8608
8821
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8609
8822
|
const fields = ___default.values(objectSchema.fields);
|
|
8610
8823
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8620,9 +8833,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8620
8833
|
id: `service_${formSchema.id}`,
|
|
8621
8834
|
className: 'p-0',
|
|
8622
8835
|
name: `page_edit_${recordId}`,
|
|
8623
|
-
api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8624
8836
|
data:{
|
|
8625
|
-
editFormInited: false,
|
|
8626
8837
|
...amisData
|
|
8627
8838
|
},
|
|
8628
8839
|
// data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
@@ -8631,8 +8842,9 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8631
8842
|
body: [defaultsDeep({}, formSchema, {
|
|
8632
8843
|
type: "form",
|
|
8633
8844
|
mode: layout,
|
|
8845
|
+
initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8634
8846
|
data: {
|
|
8635
|
-
|
|
8847
|
+
editFormInited: false,
|
|
8636
8848
|
},
|
|
8637
8849
|
labelAlign,
|
|
8638
8850
|
persistData: false,
|
|
@@ -8646,11 +8858,15 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8646
8858
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
8647
8859
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
8648
8860
|
initFetch: recordId != 'new',
|
|
8649
|
-
body:
|
|
8861
|
+
body: {
|
|
8862
|
+
type: 'wrapper',
|
|
8863
|
+
className: 'p-0 m-0',
|
|
8864
|
+
body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
|
|
8865
|
+
hiddenOn: "${editFormInited != true}",
|
|
8866
|
+
},
|
|
8650
8867
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
8651
8868
|
bodyClassName: 'p-0',
|
|
8652
8869
|
className: 'steedos-amis-form',
|
|
8653
|
-
hiddenOn: "${editFormInited != true}",
|
|
8654
8870
|
onEvent: {
|
|
8655
8871
|
"submitSucc": {
|
|
8656
8872
|
"weight": 0,
|
|
@@ -8695,7 +8911,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8695
8911
|
}
|
|
8696
8912
|
|
|
8697
8913
|
async function getObjectDetail(objectSchema, recordId, ctx){
|
|
8698
|
-
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8914
|
+
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
|
|
8699
8915
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8700
8916
|
const fields = ___default.values(objectSchema.fields);
|
|
8701
8917
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8704,8 +8920,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8704
8920
|
type: 'service',
|
|
8705
8921
|
name: `page_readonly_${recordId}`,
|
|
8706
8922
|
id: serviceId,
|
|
8707
|
-
|
|
8708
|
-
api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8923
|
+
// api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8709
8924
|
body: [
|
|
8710
8925
|
{
|
|
8711
8926
|
"type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
|
|
@@ -8731,60 +8946,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8731
8946
|
),
|
|
8732
8947
|
className: 'steedos-amis-form bg-white',
|
|
8733
8948
|
actions: [], // 不显示表单默认的提交按钮
|
|
8734
|
-
onEvent: {
|
|
8735
|
-
[`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
|
|
8736
|
-
"actions": [
|
|
8737
|
-
{
|
|
8738
|
-
"actionType": "reload",
|
|
8739
|
-
"componentId": serviceId,
|
|
8740
|
-
"expression": "this.__deletedRecord != true"
|
|
8741
|
-
},
|
|
8742
|
-
{
|
|
8743
|
-
// "args": {
|
|
8744
|
-
// "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
|
|
8745
|
-
// "blank": false
|
|
8746
|
-
// },
|
|
8747
|
-
"actionType": "custom",
|
|
8748
|
-
"script": "window.goBack()",
|
|
8749
|
-
"expression": "this.__deletedRecord === true"
|
|
8750
|
-
}
|
|
8751
|
-
]
|
|
8752
|
-
}
|
|
8753
|
-
}
|
|
8754
8949
|
},
|
|
8755
8950
|
}
|
|
8756
8951
|
],
|
|
8757
|
-
onEvent: {
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
}
|
|
8952
|
+
// onEvent: {
|
|
8953
|
+
// "fetchInited": {
|
|
8954
|
+
// "weight": 0,
|
|
8955
|
+
// "actions": [
|
|
8956
|
+
// {
|
|
8957
|
+
// actionType: 'broadcast',
|
|
8958
|
+
// eventName: "recordLoaded",
|
|
8959
|
+
// args: {
|
|
8960
|
+
// eventName: "recordLoaded"
|
|
8961
|
+
// },
|
|
8962
|
+
// data: {
|
|
8963
|
+
// objectName: "${event.data.__objectName}",
|
|
8964
|
+
// record: "${event.data.__record}"
|
|
8965
|
+
// },
|
|
8966
|
+
// expression: "${event.data.__response.error != true}"
|
|
8967
|
+
// },
|
|
8968
|
+
// {
|
|
8969
|
+
// "actionType": "setValue",
|
|
8970
|
+
// "args": {
|
|
8971
|
+
// value: {
|
|
8972
|
+
// "recordLoaded": true,
|
|
8973
|
+
// }
|
|
8974
|
+
// },
|
|
8975
|
+
// expression: "${event.data.__response.error != true}"
|
|
8976
|
+
// }
|
|
8977
|
+
// ]
|
|
8978
|
+
// }
|
|
8979
|
+
// }
|
|
8785
8980
|
};
|
|
8786
8981
|
|
|
8787
8982
|
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
8983
|
+
// console.log('getObjectDetail=====>', amisSchema);
|
|
8788
8984
|
return amisSchema;
|
|
8789
8985
|
}
|
|
8790
8986
|
|
|
@@ -8864,8 +9060,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
8864
9060
|
/*
|
|
8865
9061
|
* @Author: baozhoutao@steedos.com
|
|
8866
9062
|
* @Date: 2022-07-05 15:55:39
|
|
8867
|
-
* @LastEditors:
|
|
8868
|
-
* @LastEditTime:
|
|
9063
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9064
|
+
* @LastEditTime: 2024-01-24 10:18:17
|
|
8869
9065
|
* @Description:
|
|
8870
9066
|
*/
|
|
8871
9067
|
|
|
@@ -8964,7 +9160,9 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
8964
9160
|
const foreign_key_value = arr[2] ? arr[1]+'.'+arr[2] : arr[1];
|
|
8965
9161
|
mainRelated[arr[0]] = foreign_key_value;
|
|
8966
9162
|
}
|
|
8967
|
-
}
|
|
9163
|
+
}
|
|
9164
|
+
// 防止related_lists中没有相关子表,但是details中有相关子表的情况
|
|
9165
|
+
if(!mainRelated[relatedObjectName]){
|
|
8968
9166
|
const details = union(mainObjectUiSchema.details,mainObjectUiSchema.lookup_details) || [];
|
|
8969
9167
|
for (const detail of details) {
|
|
8970
9168
|
const arr = detail.split(".");
|
|
@@ -9040,7 +9238,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9040
9238
|
setDataToComponentId: componentId,
|
|
9041
9239
|
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
9042
9240
|
appId: appId,
|
|
9043
|
-
crudClassName: '
|
|
9241
|
+
crudClassName: 'steedos-record-related-crud hidden',
|
|
9044
9242
|
refField,
|
|
9045
9243
|
...ctx
|
|
9046
9244
|
};
|
|
@@ -9053,7 +9251,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9053
9251
|
amisSchema: {
|
|
9054
9252
|
type: "service",
|
|
9055
9253
|
id: componentId,
|
|
9056
|
-
className: `steedos-record-related-list
|
|
9254
|
+
className: `steedos-record-related-list mb-4 last:mb-0 ${componentId} ${className}`,
|
|
9057
9255
|
data: {
|
|
9058
9256
|
relatedKey: relatedKey,
|
|
9059
9257
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
@@ -9245,11 +9443,44 @@ async function getRelatedListSchema(
|
|
|
9245
9443
|
};
|
|
9246
9444
|
}
|
|
9247
9445
|
|
|
9446
|
+
async function getObjectRelatedListsMiniSchema(objectApiName){
|
|
9447
|
+
const relatedLists = await getObjectRelatedList(objectApiName);
|
|
9448
|
+
|
|
9449
|
+
const relatedListsMiniSchema = [];
|
|
9450
|
+
|
|
9451
|
+
for (const relatedList of relatedLists) {
|
|
9452
|
+
relatedListsMiniSchema.push(
|
|
9453
|
+
{
|
|
9454
|
+
type: 'steedos-record-detail-list-mini',
|
|
9455
|
+
objectApiName: objectApiName,
|
|
9456
|
+
// recordId: recordId,
|
|
9457
|
+
formFactor: formFactor,
|
|
9458
|
+
relatedObjectApiName: relatedList.object_name,
|
|
9459
|
+
foreign_key: relatedList.foreign_key,
|
|
9460
|
+
relatedKey: relatedList.foreign_key,
|
|
9461
|
+
columns: relatedList.columns,
|
|
9462
|
+
sort: relatedList.sort,
|
|
9463
|
+
filters: relatedList.filters,
|
|
9464
|
+
visible_on: relatedList.visible_on,
|
|
9465
|
+
perPage: relatedList.page_size || perPage,
|
|
9466
|
+
hiddenEmptyTable: true,
|
|
9467
|
+
relatedLabel: relatedList.label
|
|
9468
|
+
}
|
|
9469
|
+
);
|
|
9470
|
+
}
|
|
9471
|
+
|
|
9472
|
+
return {
|
|
9473
|
+
type: 'wrapper',
|
|
9474
|
+
className: "steedos-record-detail-related-lists-mini",
|
|
9475
|
+
body: relatedListsMiniSchema
|
|
9476
|
+
}
|
|
9477
|
+
}
|
|
9478
|
+
|
|
9248
9479
|
/*
|
|
9249
9480
|
* @Author: baozhoutao@steedos.com
|
|
9250
9481
|
* @Date: 2022-07-05 15:55:39
|
|
9251
|
-
* @LastEditors:
|
|
9252
|
-
* @LastEditTime:
|
|
9482
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9483
|
+
* @LastEditTime: 2024-01-16 11:14:34
|
|
9253
9484
|
* @Description:
|
|
9254
9485
|
*/
|
|
9255
9486
|
|
|
@@ -9421,7 +9652,7 @@ async function getField(objectName, fieldName) {
|
|
|
9421
9652
|
async function getFormSchema(objectName, ctx) {
|
|
9422
9653
|
const uiSchema = await getUISchema(objectName);
|
|
9423
9654
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
9424
|
-
console.log(`getFormSchema====>`, amisSchema)
|
|
9655
|
+
// console.log(`getFormSchema====>`, amisSchema)
|
|
9425
9656
|
return {
|
|
9426
9657
|
uiSchema,
|
|
9427
9658
|
amisSchema,
|
|
@@ -9747,118 +9978,172 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9747
9978
|
"label": "对象表单",
|
|
9748
9979
|
"objectApiName": "${objectName}",
|
|
9749
9980
|
"recordId": "${recordId}",
|
|
9750
|
-
"id": "u:d4a495811d57",
|
|
9751
9981
|
appId: appId
|
|
9752
9982
|
}
|
|
9753
9983
|
],
|
|
9754
|
-
"id": "u:5d4e7e3f6ecc"
|
|
9755
9984
|
};
|
|
9756
9985
|
const related = {
|
|
9757
9986
|
"title": i18next.t('frontend_record_detail_tab_related'),
|
|
9758
|
-
"className": "px-0
|
|
9987
|
+
"className": "px-0 py-4",
|
|
9759
9988
|
"body": [
|
|
9760
9989
|
{
|
|
9761
9990
|
"type": "steedos-object-related-lists",
|
|
9762
9991
|
"label": "相关列表",
|
|
9763
9992
|
"objectApiName": "${objectName}",
|
|
9764
9993
|
"recordId": "${recordId}",
|
|
9765
|
-
"id": "u:3b85b7b7a7f6",
|
|
9766
9994
|
appId: appId
|
|
9767
9995
|
}
|
|
9768
9996
|
],
|
|
9769
|
-
"id": "u:1a0326aeec2b"
|
|
9770
9997
|
};
|
|
9771
9998
|
const content = {
|
|
9772
9999
|
"type": "tabs",
|
|
9773
|
-
"className": "
|
|
10000
|
+
"className": "steedos-record-tabs bg-white p-4 mt-3 border-y",
|
|
10001
|
+
"contentClassName": "bg-none",
|
|
9774
10002
|
"tabs": [
|
|
9775
10003
|
detailed
|
|
9776
10004
|
],
|
|
9777
|
-
"id": "u:a649e4094a12"
|
|
9778
10005
|
};
|
|
9779
10006
|
if(relatedLists.length){
|
|
9780
10007
|
content.tabs.push(related);
|
|
9781
10008
|
}
|
|
10009
|
+
// content.tabs = reverse(content.tabs)
|
|
9782
10010
|
return {
|
|
9783
10011
|
uiSchema,
|
|
9784
10012
|
amisSchema: {
|
|
9785
|
-
"type": "service",
|
|
10013
|
+
"type": "steedos-record-service",
|
|
9786
10014
|
"body": [
|
|
9787
10015
|
{
|
|
9788
10016
|
"type": "steedos-record-detail-header",
|
|
9789
10017
|
"label": "标题面板",
|
|
9790
10018
|
"objectApiName": "${objectName}",
|
|
9791
10019
|
"recordId": "${recordId}",
|
|
9792
|
-
"id": "u:48d2c28eb755"
|
|
10020
|
+
"id": "u:48d2c28eb755",
|
|
10021
|
+
"showButtons": props.showButtons,
|
|
10022
|
+
"showBackButton": props.showBackButton,
|
|
9793
10023
|
},
|
|
9794
10024
|
content
|
|
9795
10025
|
],
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
},
|
|
9800
|
-
onEvent: {
|
|
9801
|
-
"recordLoaded": {
|
|
9802
|
-
"actions": [
|
|
9803
|
-
{
|
|
9804
|
-
"actionType": "reload",
|
|
9805
|
-
"data": {
|
|
9806
|
-
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
9807
|
-
"_master.record": `\${record}`,
|
|
9808
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
9809
|
-
"_master.objectName": "${objectName}",
|
|
9810
|
-
"_master.recordId": "${recordId}"
|
|
9811
|
-
}
|
|
9812
|
-
}
|
|
9813
|
-
]
|
|
9814
|
-
},
|
|
9815
|
-
...props.onEvent
|
|
9816
|
-
},
|
|
10026
|
+
"objectApiName": "${objectName}",
|
|
10027
|
+
"recordId": "${recordId}",
|
|
10028
|
+
onEvent: props.onEvent,
|
|
9817
10029
|
}
|
|
9818
10030
|
}
|
|
9819
10031
|
}
|
|
9820
10032
|
|
|
9821
|
-
async function getRecordServiceSchema(objectName, appId, props = {}) {
|
|
10033
|
+
async function getRecordServiceSchema(objectName, appId, props = {}, body) {
|
|
9822
10034
|
const uiSchema = await getUISchema(objectName);
|
|
10035
|
+
const fields = ___default.values(uiSchema.fields);
|
|
10036
|
+
const serviceId = `u:steedos-record-service-${objectName}`;
|
|
9823
10037
|
return {
|
|
9824
10038
|
uiSchema,
|
|
9825
10039
|
amisSchema: {
|
|
9826
|
-
|
|
9827
|
-
"
|
|
9828
|
-
data: {
|
|
9829
|
-
"_master.objectName": "${objectName}",
|
|
9830
|
-
"_master.recordId": "${recordId}"
|
|
9831
|
-
},
|
|
9832
|
-
"style": {
|
|
9833
|
-
"padding": "var(--Page-body-padding)",
|
|
9834
|
-
...props.style
|
|
9835
|
-
},
|
|
10040
|
+
type: 'service',
|
|
10041
|
+
className: "p-0 m-0",
|
|
9836
10042
|
onEvent: {
|
|
9837
|
-
|
|
10043
|
+
[`@data.changed.${objectName}`]: {
|
|
9838
10044
|
"actions": [
|
|
9839
10045
|
{
|
|
9840
10046
|
"actionType": "reload",
|
|
9841
|
-
"
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
10047
|
+
"componentId": serviceId,
|
|
10048
|
+
"expression": "this.__deletedRecord != true"
|
|
10049
|
+
},
|
|
10050
|
+
{
|
|
10051
|
+
"actionType": "custom",
|
|
10052
|
+
"script": "window.goBack()",
|
|
10053
|
+
"expression": "this.__deletedRecord === true"
|
|
9848
10054
|
}
|
|
9849
10055
|
]
|
|
9850
10056
|
},
|
|
9851
|
-
|
|
10057
|
+
},
|
|
10058
|
+
body: {
|
|
10059
|
+
"type": "service",
|
|
10060
|
+
id: serviceId,
|
|
10061
|
+
className: 'steedos-record-service p-0',
|
|
10062
|
+
api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
10063
|
+
body: {
|
|
10064
|
+
"type": "wrapper",
|
|
10065
|
+
"className": "p-0 m-0",
|
|
10066
|
+
"body": body || [],
|
|
10067
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
10068
|
+
},
|
|
10069
|
+
data: {
|
|
10070
|
+
"_master.objectName": "${objectName}",
|
|
10071
|
+
"_master.recordId": "${recordId}",
|
|
10072
|
+
...(props.data || {})
|
|
10073
|
+
},
|
|
10074
|
+
"style": {
|
|
10075
|
+
// "padding": "var(--Page-body-padding)",
|
|
10076
|
+
...props.style
|
|
10077
|
+
},
|
|
10078
|
+
onEvent: {
|
|
10079
|
+
// 如果定义了fetchInited,则无法接收到广播事件@data.changed
|
|
10080
|
+
"fetchInited": {
|
|
10081
|
+
"weight": 0,
|
|
10082
|
+
"actions": [
|
|
10083
|
+
{
|
|
10084
|
+
actionType: 'broadcast',
|
|
10085
|
+
eventName: "recordLoaded",
|
|
10086
|
+
data: {
|
|
10087
|
+
objectName: "${event.data.__objectName}",
|
|
10088
|
+
record: "${event.data.record}"
|
|
10089
|
+
},
|
|
10090
|
+
expression: "${event.data.__response.error != true}"
|
|
10091
|
+
},
|
|
10092
|
+
]
|
|
10093
|
+
},
|
|
10094
|
+
...props.onEvent
|
|
10095
|
+
}
|
|
9852
10096
|
}
|
|
9853
10097
|
}
|
|
10098
|
+
|
|
10099
|
+
|
|
9854
10100
|
}
|
|
9855
10101
|
}
|
|
9856
10102
|
|
|
9857
|
-
|
|
9858
|
-
|
|
9859
|
-
|
|
9860
|
-
|
|
9861
|
-
|
|
10103
|
+
async function getRecordDetailMiniSchema(objectName, appId, props = {}){
|
|
10104
|
+
const uiSchema = await getUISchema(objectName);
|
|
10105
|
+
const fields = ___default.values(uiSchema.fields);
|
|
10106
|
+
|
|
10107
|
+
props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
|
|
10108
|
+
|
|
10109
|
+
// TODO 处理相关表
|
|
10110
|
+
// getObjectRelatedListsMiniSchema
|
|
10111
|
+
|
|
10112
|
+
return {
|
|
10113
|
+
type: "form",
|
|
10114
|
+
wrapWithPanel: false,
|
|
10115
|
+
actions: [],
|
|
10116
|
+
initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
10117
|
+
body: {
|
|
10118
|
+
"type": "wrapper",
|
|
10119
|
+
"className": "p-0 m-0",
|
|
10120
|
+
"body": [
|
|
10121
|
+
{
|
|
10122
|
+
"type": "steedos-record-detail-header",
|
|
10123
|
+
"showButtons": false,
|
|
10124
|
+
"showBackButton": false,
|
|
10125
|
+
"objectApiName": "${objectName}",
|
|
10126
|
+
"recordId": "${recordId}",
|
|
10127
|
+
},
|
|
10128
|
+
// {
|
|
10129
|
+
// "type": "steedos-object-related-lists",
|
|
10130
|
+
// "label": "相关列表",
|
|
10131
|
+
// "objectApiName": "${objectName}",
|
|
10132
|
+
// "staticRecordId": "${recordId}",
|
|
10133
|
+
// formFactor: "SMALL",
|
|
10134
|
+
// appId: appId
|
|
10135
|
+
// }
|
|
10136
|
+
],
|
|
10137
|
+
"hiddenOn": "${_finished != true}"
|
|
10138
|
+
}
|
|
10139
|
+
}
|
|
10140
|
+
}
|
|
10141
|
+
|
|
10142
|
+
// 获取单个相关表
|
|
10143
|
+
async function getObjectRelated(
|
|
10144
|
+
{appName,
|
|
10145
|
+
masterObjectName,
|
|
10146
|
+
objectName,
|
|
9862
10147
|
relatedFieldName,
|
|
9863
10148
|
recordId,
|
|
9864
10149
|
formFactor}
|
|
@@ -10413,17 +10698,13 @@ function getReferenceToSync(field) {
|
|
|
10413
10698
|
|
|
10414
10699
|
function getLookupSapceUserTreeSchema(isMobile){
|
|
10415
10700
|
let apiAdaptor = `
|
|
10416
|
-
// console.log("===getLookupSapceUserTreeSchema===", JSON.stringify(payload));
|
|
10417
10701
|
const records = payload.data.options;
|
|
10418
|
-
let isTreeOptionsComputed = false;
|
|
10419
|
-
if(records.length === 1 && records[0].children){
|
|
10420
|
-
isTreeOptionsComputed = true;
|
|
10421
|
-
}
|
|
10422
|
-
if(isTreeOptionsComputed){
|
|
10423
|
-
return payload;
|
|
10424
|
-
}
|
|
10425
10702
|
const treeRecords = [];
|
|
10426
|
-
const getChildren = (records, childrenIds) => {
|
|
10703
|
+
const getChildren = (currentRecord, records, childrenIds) => {
|
|
10704
|
+
if (currentRecord.children && typeof currentRecord.children[0] === "object") {
|
|
10705
|
+
// 考虑api配置了cache缓存的话,不会请求接口但是会重新进这个接收适配器脚本且payload.data.options返回的会是上一次计算结果,这里直接返回计算过的children
|
|
10706
|
+
return currentRecord.children;
|
|
10707
|
+
}
|
|
10427
10708
|
if (!childrenIds) {
|
|
10428
10709
|
return;
|
|
10429
10710
|
}
|
|
@@ -10432,7 +10713,7 @@ function getLookupSapceUserTreeSchema(isMobile){
|
|
|
10432
10713
|
});
|
|
10433
10714
|
_.each(children, (item) => {
|
|
10434
10715
|
if (item.children) {
|
|
10435
|
-
item.children = getChildren(records, item.children)
|
|
10716
|
+
item.children = getChildren(item, records, item.children)
|
|
10436
10717
|
}else{
|
|
10437
10718
|
item.children = [];
|
|
10438
10719
|
}
|
|
@@ -10458,7 +10739,7 @@ function getLookupSapceUserTreeSchema(isMobile){
|
|
|
10458
10739
|
|
|
10459
10740
|
_.each(records, (record) => {
|
|
10460
10741
|
if (record.noParent == 1) {
|
|
10461
|
-
treeRecords.push(Object.assign({}, record, { children: getChildren(records, record.children) }));
|
|
10742
|
+
treeRecords.push(Object.assign({}, record, { children: getChildren(record, records, record.children) }));
|
|
10462
10743
|
}
|
|
10463
10744
|
});
|
|
10464
10745
|
console.log(treeRecords)
|
|
@@ -10508,6 +10789,7 @@ function getLookupSapceUserTreeSchema(isMobile){
|
|
|
10508
10789
|
}
|
|
10509
10790
|
},
|
|
10510
10791
|
"label": "",
|
|
10792
|
+
"mode": "normal",
|
|
10511
10793
|
"name": "organizations",
|
|
10512
10794
|
"multiple": false,
|
|
10513
10795
|
"joinValues": false,
|
|
@@ -10650,6 +10932,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10650
10932
|
}
|
|
10651
10933
|
});
|
|
10652
10934
|
|
|
10935
|
+
let listviewFilter = getListViewFilter(listView);
|
|
10936
|
+
let listviewFiltersFunction = listView && listView._filters;
|
|
10937
|
+
|
|
10653
10938
|
let sort = "";
|
|
10654
10939
|
if(listView){
|
|
10655
10940
|
sort = getListViewSort(listView);
|
|
@@ -10696,7 +10981,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10696
10981
|
Object.assign(api.data.$self, __changedSearchBoxValues, __changedFilterFormValues);
|
|
10697
10982
|
}
|
|
10698
10983
|
const selfData = JSON.parse(JSON.stringify(api.data.$self));
|
|
10699
|
-
var filters = [];
|
|
10984
|
+
${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
|
|
10700
10985
|
var pageSize = api.data.pageSize || 10;
|
|
10701
10986
|
var pageNo = api.data.pageNo || 1;
|
|
10702
10987
|
var skip = (pageNo - 1) * pageSize;
|
|
@@ -10758,6 +11043,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10758
11043
|
}
|
|
10759
11044
|
|
|
10760
11045
|
const inFilterForm = ${ctx.inFilterForm};
|
|
11046
|
+
|
|
11047
|
+
const listviewFiltersFunction = ${listviewFiltersFunction};
|
|
11048
|
+
|
|
11049
|
+
if(listviewFiltersFunction && !inFilterForm){
|
|
11050
|
+
const _filters0 = listviewFiltersFunction(filters, api.data.$self.__super);
|
|
11051
|
+
if(_filters0 && _filters0.length){
|
|
11052
|
+
filters.push(_filters0);
|
|
11053
|
+
}
|
|
11054
|
+
}
|
|
11055
|
+
|
|
10761
11056
|
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
10762
11057
|
|
|
10763
11058
|
if(filtersFunction && !inFilterForm){
|
|
@@ -10876,13 +11171,15 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10876
11171
|
|
|
10877
11172
|
pickerSchema.affixHeader = false;
|
|
10878
11173
|
|
|
10879
|
-
|
|
11174
|
+
|
|
11175
|
+
|
|
11176
|
+
pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { isLookup: true, keywordsSearchBoxName });
|
|
11177
|
+
|
|
10880
11178
|
if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
|
|
10881
|
-
|
|
11179
|
+
pickerSchema.headerToolbar.push(getLookupSapceUserTreeSchema(isMobile));
|
|
10882
11180
|
pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
|
|
10883
11181
|
}
|
|
10884
|
-
|
|
10885
|
-
pickerSchema.headerToolbar = getObjectHeaderToolbar(refObjectConfig, fieldsArr, ctx.formFactor, { headerToolbarItems, isLookup: true, keywordsSearchBoxName });
|
|
11182
|
+
|
|
10886
11183
|
const isAllowCreate = refObjectConfig.permissions.allowCreate;
|
|
10887
11184
|
const isCreate = _$1.isBoolean(field.create) ? field.create : true;
|
|
10888
11185
|
// lookup字段配置过滤条件就强制不显示新建按钮
|
|
@@ -10995,6 +11292,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10995
11292
|
pickerSchema.footerToolbar = ["pagination"];
|
|
10996
11293
|
}
|
|
10997
11294
|
|
|
11295
|
+
if(field.inlineHelpText){
|
|
11296
|
+
pickerSchema.toolbarClassName = "hasHelpText";
|
|
11297
|
+
pickerSchema.headerToolbar = [{
|
|
11298
|
+
"type": "tpl",
|
|
11299
|
+
"tpl": field.inlineHelpText,
|
|
11300
|
+
"className": "text-secondary"
|
|
11301
|
+
}, ...pickerSchema.headerToolbar];
|
|
11302
|
+
}
|
|
11303
|
+
pickerSchema.className = (pickerSchema.className || "") + " steedos-lookup-crud";
|
|
11304
|
+
|
|
10998
11305
|
const data = {
|
|
10999
11306
|
type: getAmisStaticFieldType('picker', readonly),
|
|
11000
11307
|
modalTitle: i18next.t('frontend_form_please_select') + " " + refObjectConfig.label,
|
|
@@ -11070,6 +11377,9 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
11070
11377
|
const refObjectConfig = referenceTo && await getUISchema(referenceTo.objectName);
|
|
11071
11378
|
let listView = getLookupListView(refObjectConfig);
|
|
11072
11379
|
|
|
11380
|
+
let listviewFilter = getListViewFilter(listView);
|
|
11381
|
+
let listviewFiltersFunction = listView && listView._filters;
|
|
11382
|
+
|
|
11073
11383
|
let sort = "";
|
|
11074
11384
|
if(listView){
|
|
11075
11385
|
sort = getListViewSort(listView);
|
|
@@ -11099,7 +11409,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
11099
11409
|
apiInfo.data['rfield'] = `\${object_name}`;
|
|
11100
11410
|
// [["_id", "=", "$${field.name}._id"],"or",["name", "contains", "$term"]]
|
|
11101
11411
|
apiInfo.requestAdaptor = `
|
|
11102
|
-
var filters = [];
|
|
11412
|
+
${listviewFilter && !ctx.inFilterForm ? `var filters = ${JSON.stringify(listviewFilter)};` : 'var filters = [];'}
|
|
11103
11413
|
var top = 200;
|
|
11104
11414
|
if(api.data.$term){
|
|
11105
11415
|
filters = [["${referenceTo?.NAME_FIELD_KEY || 'name'}", "contains", api.data.$term]];
|
|
@@ -11122,6 +11432,16 @@ async function lookupToAmisSelect(field, readonly, ctx){
|
|
|
11122
11432
|
}
|
|
11123
11433
|
|
|
11124
11434
|
const inFilterForm = ${ctx.inFilterForm};
|
|
11435
|
+
|
|
11436
|
+
const listviewFiltersFunction = ${listviewFiltersFunction};
|
|
11437
|
+
|
|
11438
|
+
if(listviewFiltersFunction && !inFilterForm){
|
|
11439
|
+
const _filters0 = listviewFiltersFunction(filters, api.data.$);
|
|
11440
|
+
if(_filters0 && _filters0.length){
|
|
11441
|
+
filters.push(_filters0);
|
|
11442
|
+
}
|
|
11443
|
+
}
|
|
11444
|
+
|
|
11125
11445
|
const filtersFunction = ${field.filtersFunction || field._filtersFunction};
|
|
11126
11446
|
|
|
11127
11447
|
if(filtersFunction && !inFilterForm){
|
|
@@ -11244,9 +11564,17 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
11244
11564
|
}
|
|
11245
11565
|
// console.log(`lookupToAmis====`, field, readonly, ctx)
|
|
11246
11566
|
if(readonly){
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11567
|
+
if(field.reference_to){
|
|
11568
|
+
return {
|
|
11569
|
+
type: 'steedos-field',
|
|
11570
|
+
config: field,
|
|
11571
|
+
static: true
|
|
11572
|
+
}
|
|
11573
|
+
}else {
|
|
11574
|
+
return {
|
|
11575
|
+
type: getAmisStaticFieldType('picker', readonly),
|
|
11576
|
+
tpl: getRelatedFieldTpl(field, ctx)
|
|
11577
|
+
}
|
|
11250
11578
|
}
|
|
11251
11579
|
}
|
|
11252
11580
|
if(field.reference_to && !_$1.isString(field.reference_to) && !readonly){
|
|
@@ -11898,13 +12226,31 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
11898
12226
|
};
|
|
11899
12227
|
break;
|
|
11900
12228
|
case 'input-datetime-range':
|
|
12229
|
+
// convertData = {
|
|
12230
|
+
// type: "input-datetime-range",
|
|
12231
|
+
// inputFormat: 'YYYY-MM-DD HH:mm',
|
|
12232
|
+
// format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
12233
|
+
// tpl: readonly ? Tpl.getDateTimeTpl(field) : null,
|
|
12234
|
+
// utc: true,
|
|
12235
|
+
// joinValues: false
|
|
12236
|
+
// }
|
|
12237
|
+
// 日期时间字段,按日期方式展现显示控件,用户不用关心小时分钟
|
|
11901
12238
|
convertData = {
|
|
11902
|
-
type: "input-
|
|
11903
|
-
inputFormat:
|
|
12239
|
+
type: "input-date-range",
|
|
12240
|
+
inputFormat: "YYYY-MM-DD HH:mm",
|
|
11904
12241
|
format:'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
11905
12242
|
tpl: readonly ? getDateTimeTpl(field) : null,
|
|
11906
12243
|
utc: true,
|
|
11907
|
-
joinValues: false
|
|
12244
|
+
joinValues: false,
|
|
12245
|
+
"shortcuts": [
|
|
12246
|
+
"thismonth",
|
|
12247
|
+
"2monthsago",
|
|
12248
|
+
"3monthslater",
|
|
12249
|
+
"prevquarter",
|
|
12250
|
+
"thisquarter",
|
|
12251
|
+
"thisyear",
|
|
12252
|
+
"lastYear"
|
|
12253
|
+
]
|
|
11908
12254
|
};
|
|
11909
12255
|
break;
|
|
11910
12256
|
case 'datetime':
|
|
@@ -11955,7 +12301,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
11955
12301
|
convertData = {
|
|
11956
12302
|
type: getAmisStaticFieldType('datetime', readonly),
|
|
11957
12303
|
inputFormat: 'YYYY-MM-DD HH:mm',
|
|
11958
|
-
format: 'YYYY-MM-DDTHH:mm:
|
|
12304
|
+
format: 'YYYY-MM-DDTHH:mm:00.000Z',
|
|
11959
12305
|
tpl: readonly ? getDateTimeTpl(field) : null,
|
|
11960
12306
|
utc: true,
|
|
11961
12307
|
};
|
|
@@ -12086,6 +12432,36 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12086
12432
|
convertData = {
|
|
12087
12433
|
type: 'static-text'
|
|
12088
12434
|
};
|
|
12435
|
+
}else if(field.autonumber_enable_modify){
|
|
12436
|
+
convertData = {
|
|
12437
|
+
"type": "input-group",
|
|
12438
|
+
"body": [
|
|
12439
|
+
{
|
|
12440
|
+
"type": "input-text",
|
|
12441
|
+
"name": field.name
|
|
12442
|
+
},
|
|
12443
|
+
{
|
|
12444
|
+
"type": "button",
|
|
12445
|
+
"label": "自动获取",
|
|
12446
|
+
"actionType": "ajax",
|
|
12447
|
+
"api": {
|
|
12448
|
+
"url": `\${context.rootUrl}/api/autonumber/generator/\${objectName}/${field.name}`,
|
|
12449
|
+
"method": "post",
|
|
12450
|
+
"headers": {
|
|
12451
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
12452
|
+
},
|
|
12453
|
+
"adaptor": `
|
|
12454
|
+
payload.data["${field.name}"] = payload.data && payload.data.autonumber;
|
|
12455
|
+
delete payload.data.autonumber;
|
|
12456
|
+
return payload;
|
|
12457
|
+
`
|
|
12458
|
+
},
|
|
12459
|
+
"messages": {
|
|
12460
|
+
"success": "获取成功"
|
|
12461
|
+
}
|
|
12462
|
+
}
|
|
12463
|
+
]
|
|
12464
|
+
};
|
|
12089
12465
|
}
|
|
12090
12466
|
break;
|
|
12091
12467
|
case 'url':
|
|
@@ -12240,11 +12616,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12240
12616
|
if(field.subFields){
|
|
12241
12617
|
convertData = {
|
|
12242
12618
|
type: 'steedos-input-table',
|
|
12243
|
-
showIndex: true,
|
|
12244
12619
|
editable: !readonly,
|
|
12245
12620
|
addable: !readonly,
|
|
12246
12621
|
removable: !readonly,
|
|
12247
|
-
draggable: !readonly,
|
|
12248
12622
|
fields: [],
|
|
12249
12623
|
amis:{
|
|
12250
12624
|
columnsTogglable: false
|
|
@@ -12296,9 +12670,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12296
12670
|
if(field.is_wide || convertData.type === 'group'){
|
|
12297
12671
|
convertData.className = 'col-span-2 m-0';
|
|
12298
12672
|
}else {
|
|
12299
|
-
convertData.className = 'm-
|
|
12673
|
+
convertData.className = 'm-0';
|
|
12300
12674
|
}
|
|
12301
|
-
if(readonly){
|
|
12675
|
+
if(readonly && ctx.mode !== 'edit'){
|
|
12302
12676
|
convertData.className = `${convertData.className} border-b`;
|
|
12303
12677
|
}
|
|
12304
12678
|
if(readonly){
|
|
@@ -12321,6 +12695,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12321
12695
|
}
|
|
12322
12696
|
}
|
|
12323
12697
|
|
|
12698
|
+
if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
|
|
12699
|
+
convertData.className = `${convertData.className || ''} hidden`;
|
|
12700
|
+
}
|
|
12701
|
+
|
|
12324
12702
|
if(_$1.isString(baseData.required)){
|
|
12325
12703
|
if(baseData.required.startsWith("{{")){
|
|
12326
12704
|
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
@@ -12389,8 +12767,9 @@ async function getFieldSearchable(perField, permissionFields, ctx){
|
|
|
12389
12767
|
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
12390
12768
|
}
|
|
12391
12769
|
if(_field.type === 'datetime'){
|
|
12392
|
-
//
|
|
12393
|
-
|
|
12770
|
+
// 这里如果想把搜索范围展示效果改为日期范围,不可以直接改为input-date-range,因为它们规则不一样,包括时区规则和小时分秒的存值规则都不一样
|
|
12771
|
+
// 所以想改为展示日期范围效果,只能改input-datetime-range类型本身的属性来实现
|
|
12772
|
+
_field.type = 'input-datetime-range';
|
|
12394
12773
|
_field.is_wide = true;
|
|
12395
12774
|
fieldNamePrefix = `${fieldNamePrefix}between__`;
|
|
12396
12775
|
}
|
|
@@ -12576,6 +12955,13 @@ const getSection = async (formFields, permissionFields, fieldSchemaArray, sectio
|
|
|
12576
12955
|
}
|
|
12577
12956
|
}
|
|
12578
12957
|
|
|
12958
|
+
fieldSetBody.forEach((field)=>{
|
|
12959
|
+
//判断label是否存在,不存在时将label的空占位元素隐藏
|
|
12960
|
+
if(!field.label){
|
|
12961
|
+
field.labelClassName = "none";
|
|
12962
|
+
}
|
|
12963
|
+
});
|
|
12964
|
+
|
|
12579
12965
|
// fieldSet 已支持显隐控制
|
|
12580
12966
|
const sectionFieldsVisibleOn = _$1.map(_$1.compact(_$1.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
|
|
12581
12967
|
let visible = visibleOn;
|
|
@@ -12698,19 +13084,200 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12698
13084
|
return await getSections(permissionFields, formFields, ctx);
|
|
12699
13085
|
}
|
|
12700
13086
|
|
|
13087
|
+
/*
|
|
13088
|
+
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
13089
|
+
* @Date: 2024-01-18 15:12:41
|
|
13090
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
13091
|
+
* @LastEditTime: 2024-01-18 15:12:49
|
|
13092
|
+
*/
|
|
13093
|
+
/**
|
|
13094
|
+
* 生成符合标准uuid格式的36位满足唯一性的随机串
|
|
13095
|
+
* @returns uuid
|
|
13096
|
+
*/
|
|
13097
|
+
function uuidv4() {
|
|
13098
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
|
|
13099
|
+
(c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
13100
|
+
);
|
|
13101
|
+
}
|
|
13102
|
+
|
|
12701
13103
|
/*
|
|
12702
13104
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12703
13105
|
* @Date: 2023-11-15 09:50:22
|
|
12704
|
-
* @LastEditors:
|
|
12705
|
-
* @LastEditTime: 2024-01-
|
|
13106
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
13107
|
+
* @LastEditTime: 2024-01-26 17:47:16
|
|
13108
|
+
*/
|
|
13109
|
+
|
|
13110
|
+
/**
|
|
13111
|
+
* 子表组件字段值中每行数据补上字段值为空的的字段值,把值统一设置为空字符串,是为了解决amis amis 3.6/6.0 input-table组件bug:行中字段值为空时会显示为父作用域中的同名变量值,见:https://github.com/baidu/amis/issues/9520
|
|
13112
|
+
* amis #9520修正后此函数及相关代码可以移除
|
|
13113
|
+
* @param {*} value 子表组件字段值,数组
|
|
13114
|
+
* @param {*} fields 子表组件fields属性,数组
|
|
13115
|
+
* @returns 转换后的子表组件字段值
|
|
13116
|
+
*/
|
|
13117
|
+
function getTableValueWithEmptyValue(value, fields) {
|
|
13118
|
+
return (value || []).map((itemValue) => {
|
|
13119
|
+
//这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里字段值会被改了
|
|
13120
|
+
const newItemValue = clone(itemValue);
|
|
13121
|
+
(fields || []).forEach((itemField) => {
|
|
13122
|
+
if(itemField.name && (newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
|
|
13123
|
+
// 这里newItemValue中不存在 itemField.name 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
|
|
13124
|
+
// 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
|
|
13125
|
+
newItemValue[itemField.name] = "";
|
|
13126
|
+
}
|
|
13127
|
+
if (newItemValue.children) {
|
|
13128
|
+
newItemValue.children = getTableValueWithEmptyValue(newItemValue.children, fields);
|
|
13129
|
+
}
|
|
13130
|
+
});
|
|
13131
|
+
return newItemValue;
|
|
13132
|
+
});
|
|
13133
|
+
}
|
|
13134
|
+
|
|
13135
|
+
/**
|
|
13136
|
+
* 把子表组件字段值中每行数据中经过上面getTableValueWithEmptyValue函数空字段值移除
|
|
13137
|
+
* amis #9520修正后此函数及相关代码可以移除
|
|
13138
|
+
* @param {*} value 子表组件字段值,数组
|
|
13139
|
+
* @param {*} fields 子表组件fields属性,数组
|
|
13140
|
+
* @returns 转换后的子表组件字段值
|
|
13141
|
+
*/
|
|
13142
|
+
function getTableValueWithoutEmptyValue(value, fields) {
|
|
13143
|
+
return (value || []).map((itemValue) => {
|
|
13144
|
+
const newItemValue = clone(itemValue);
|
|
13145
|
+
(fields || []).forEach((itemField) => {
|
|
13146
|
+
if(itemField.name && (newItemValue[itemField.name] === "" || newItemValue[itemField.name] === undefined || newItemValue[itemField.name] === null)){
|
|
13147
|
+
// 这里额外把null和undefined值也删除掉纯粹是没必要输出保存它们
|
|
13148
|
+
delete newItemValue[itemField.name];
|
|
13149
|
+
}
|
|
13150
|
+
if (newItemValue.children) {
|
|
13151
|
+
newItemValue.children = getTableValueWithoutEmptyValue(newItemValue.children, fields);
|
|
13152
|
+
}
|
|
13153
|
+
});
|
|
13154
|
+
return newItemValue;
|
|
13155
|
+
});
|
|
13156
|
+
}
|
|
13157
|
+
|
|
13158
|
+
function getTablePrimaryKey(props) {
|
|
13159
|
+
return props.primaryKey || "_id";
|
|
13160
|
+
}
|
|
13161
|
+
|
|
13162
|
+
/**
|
|
13163
|
+
* 子表组件字段值中每行数据的补上唯一标识字段值,其值为随机uuid
|
|
13164
|
+
* @param {*} value 子表组件字段值,数组
|
|
13165
|
+
* @param {*} primaryKey 主键字段名,一般为_id
|
|
13166
|
+
* @returns 转换后的子表组件字段值
|
|
13167
|
+
*/
|
|
13168
|
+
function getTableValueWithPrimaryKeyValue(value, primaryKey) {
|
|
13169
|
+
if (!primaryKey) {
|
|
13170
|
+
return value;
|
|
13171
|
+
}
|
|
13172
|
+
return (value || []).map((itemValue) => {
|
|
13173
|
+
//这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
|
|
13174
|
+
const newItemValue = clone(itemValue);
|
|
13175
|
+
if (newItemValue[primaryKey]) {
|
|
13176
|
+
if (newItemValue.children) {
|
|
13177
|
+
newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13178
|
+
}
|
|
13179
|
+
return newItemValue;
|
|
13180
|
+
}
|
|
13181
|
+
else {
|
|
13182
|
+
newItemValue[primaryKey] = uuidv4();
|
|
13183
|
+
if (newItemValue.children) {
|
|
13184
|
+
newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13185
|
+
}
|
|
13186
|
+
return newItemValue;
|
|
13187
|
+
}
|
|
13188
|
+
});
|
|
13189
|
+
}
|
|
13190
|
+
|
|
13191
|
+
/**
|
|
13192
|
+
* 子表组件字段值中每行数据的移除唯一标识字段值,因为该字段值一般只作临时标记,不存库
|
|
13193
|
+
* @param {*} value 子表组件字段值,数组
|
|
13194
|
+
* @param {*} primaryKey 主键字段名,一般为_id
|
|
13195
|
+
* @returns 转换后的子表组件字段值
|
|
12706
13196
|
*/
|
|
13197
|
+
function getTableValueWithoutPrimaryKeyValue(value, primaryKey) {
|
|
13198
|
+
if (!primaryKey) {
|
|
13199
|
+
return value;
|
|
13200
|
+
}
|
|
13201
|
+
return (value || []).map((itemValue) => {
|
|
13202
|
+
//这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
|
|
13203
|
+
const newItemValue = clone(itemValue);
|
|
13204
|
+
if (newItemValue.children) {
|
|
13205
|
+
newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13206
|
+
}
|
|
13207
|
+
delete newItemValue[primaryKey];
|
|
13208
|
+
return newItemValue;
|
|
13209
|
+
});
|
|
13210
|
+
}
|
|
13211
|
+
|
|
13212
|
+
/**
|
|
13213
|
+
* 子表组件字段值中每行数据的键值key移除指定前缀
|
|
13214
|
+
* @param {*} value 子表组件字段值,数组
|
|
13215
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13216
|
+
* @returns 转换后的子表组件字段值
|
|
13217
|
+
*/
|
|
13218
|
+
function getTableValueWithoutFieldPrefix(value, fieldPrefix) {
|
|
13219
|
+
let convertedValue = [];
|
|
13220
|
+
(value || []).forEach((itemValue) => {
|
|
13221
|
+
var newItemValue = {};
|
|
13222
|
+
for (let n in itemValue) {
|
|
13223
|
+
if (itemValue.hasOwnProperty(n)) {
|
|
13224
|
+
newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
|
|
13225
|
+
}
|
|
13226
|
+
}
|
|
13227
|
+
convertedValue.push(newItemValue);
|
|
13228
|
+
});
|
|
13229
|
+
return convertedValue;
|
|
13230
|
+
}
|
|
13231
|
+
|
|
13232
|
+
/**
|
|
13233
|
+
* 子表组件字段值中每行数据的键值key补上指定前缀
|
|
13234
|
+
* @param {*} value 子表组件字段值,数组
|
|
13235
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13236
|
+
* @param {*} primaryKey 主键字段名,主键不参与被键值key规则,需要排除,审批王amis表单也是这个规则
|
|
13237
|
+
* @returns 转换后的子表组件字段值
|
|
13238
|
+
*/
|
|
13239
|
+
function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey) {
|
|
13240
|
+
let convertedValue = [];
|
|
13241
|
+
(value || []).forEach((itemValue) => {
|
|
13242
|
+
var newItemValue = {};
|
|
13243
|
+
for (let n in itemValue) {
|
|
13244
|
+
if (itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey) {
|
|
13245
|
+
newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
|
|
13246
|
+
}
|
|
13247
|
+
}
|
|
13248
|
+
if (primaryKey && itemValue[primaryKey]) {
|
|
13249
|
+
newItemValue[primaryKey] = itemValue[primaryKey];
|
|
13250
|
+
}
|
|
13251
|
+
convertedValue.push(newItemValue);
|
|
13252
|
+
});
|
|
13253
|
+
return convertedValue;
|
|
13254
|
+
}
|
|
13255
|
+
|
|
13256
|
+
/**
|
|
13257
|
+
* 子表组件字段集合属性中每个字段name移除指定前缀
|
|
13258
|
+
* @param {*} fields 子表组件字段集合,数组
|
|
13259
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13260
|
+
* @returns 转换后的子表组件字段值
|
|
13261
|
+
*/
|
|
13262
|
+
function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix) {
|
|
13263
|
+
return (fields || []).map((item) => {
|
|
13264
|
+
const newItem = clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
|
|
13265
|
+
newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
|
|
13266
|
+
return newItem;
|
|
13267
|
+
});
|
|
13268
|
+
}
|
|
12707
13269
|
|
|
12708
13270
|
/**
|
|
12709
13271
|
* @param {*} props
|
|
12710
13272
|
* @param {*} mode edit/new/readonly
|
|
12711
13273
|
*/
|
|
12712
13274
|
function getFormFields(props, mode = "edit") {
|
|
12713
|
-
|
|
13275
|
+
let fieldPrefix = props.fieldPrefix;
|
|
13276
|
+
let fields = props.fields || [];
|
|
13277
|
+
if (fieldPrefix) {
|
|
13278
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
13279
|
+
}
|
|
13280
|
+
return (fields || []).map(function (item) {
|
|
12714
13281
|
let formItem = {
|
|
12715
13282
|
"type": "steedos-field",
|
|
12716
13283
|
"name": item.name,
|
|
@@ -12730,6 +13297,7 @@ function getInputTableCell(field, showAsInlineEditMode) {
|
|
|
12730
13297
|
name: field.name,
|
|
12731
13298
|
quickEdit: {
|
|
12732
13299
|
"type": "steedos-field",
|
|
13300
|
+
"mode": "inline",
|
|
12733
13301
|
"config": Object.assign({}, field, {
|
|
12734
13302
|
label: false
|
|
12735
13303
|
})
|
|
@@ -12782,7 +13350,12 @@ async function getInputTableColumns(props) {
|
|
|
12782
13350
|
let inlineEditMode = props.inlineEditMode;
|
|
12783
13351
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
12784
13352
|
// 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
|
|
12785
|
-
|
|
13353
|
+
|
|
13354
|
+
let fieldPrefix = props.fieldPrefix;
|
|
13355
|
+
let fields = props.fields || [];
|
|
13356
|
+
if (fieldPrefix) {
|
|
13357
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
13358
|
+
}
|
|
12786
13359
|
if (columns && columns.length) {
|
|
12787
13360
|
return columns.map(function (column) {
|
|
12788
13361
|
let field, extendColumnProps = {};
|
|
@@ -12804,8 +13377,26 @@ async function getInputTableColumns(props) {
|
|
|
12804
13377
|
}
|
|
12805
13378
|
}
|
|
12806
13379
|
if (field) {
|
|
12807
|
-
let
|
|
12808
|
-
|
|
13380
|
+
let mode = typeof extendColumnProps.inlineEditMode === "boolean" ?
|
|
13381
|
+
extendColumnProps.inlineEditMode : showAsInlineEditMode;
|
|
13382
|
+
let tableCell = getInputTableCell(field, mode);
|
|
13383
|
+
let className = "";
|
|
13384
|
+
//判断是否换行,目前规则默认换行
|
|
13385
|
+
if(extendColumnProps.wrap != true){
|
|
13386
|
+
className += " whitespace-nowrap ";
|
|
13387
|
+
}else {
|
|
13388
|
+
className += " break-words ";
|
|
13389
|
+
}
|
|
13390
|
+
//合并classname
|
|
13391
|
+
if (typeof extendColumnProps.className == "object") {
|
|
13392
|
+
className = {
|
|
13393
|
+
[className]: "true",
|
|
13394
|
+
...extendColumnProps.className
|
|
13395
|
+
};
|
|
13396
|
+
} else if (typeof extendColumnProps.className == "string") {
|
|
13397
|
+
className = `${className} ${extendColumnProps.className} `;
|
|
13398
|
+
}
|
|
13399
|
+
return Object.assign({}, tableCell, extendColumnProps, {className});
|
|
12809
13400
|
}
|
|
12810
13401
|
else {
|
|
12811
13402
|
return column;
|
|
@@ -12815,6 +13406,7 @@ async function getInputTableColumns(props) {
|
|
|
12815
13406
|
else {
|
|
12816
13407
|
return fields.map(function (field) {
|
|
12817
13408
|
let tableCell = getInputTableCell(field, showAsInlineEditMode);
|
|
13409
|
+
tableCell.className = " whitespace-nowrap ";
|
|
12818
13410
|
return tableCell;
|
|
12819
13411
|
}) || [];
|
|
12820
13412
|
}
|
|
@@ -12827,7 +13419,7 @@ async function getInputTableColumns(props) {
|
|
|
12827
13419
|
*/
|
|
12828
13420
|
function getFormPagination(props, mode) {
|
|
12829
13421
|
let showPagination = true;
|
|
12830
|
-
if(mode === "new" && !!!props.editable){
|
|
13422
|
+
if (mode === "new" && !!!props.editable) {
|
|
12831
13423
|
//不允许编辑只允许新建时不应该让用户操作翻页
|
|
12832
13424
|
showPagination = false;
|
|
12833
13425
|
}
|
|
@@ -12843,23 +13435,41 @@ function getFormPagination(props, mode) {
|
|
|
12843
13435
|
let __formId = "${formId}";
|
|
12844
13436
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
12845
13437
|
let pageChangeDirection = context.props.pageChangeDirection;
|
|
13438
|
+
let mode = "${mode}";
|
|
12846
13439
|
// event.data中的index和__page分别表示当前要把表单数据提交到的行索引和用于标定下一页页码的当前页页码
|
|
12847
13440
|
// 一般来说__page = index + 1,但是可以让event.data中传入__page和index值不是这种联系。
|
|
12848
13441
|
// 比如__page设置为3,index设置为0表示把当前表单数据提交到第一页,但是跳转到第4页,弹出的表单中底下的新增和复制按钮依赖了此功能
|
|
12849
13442
|
// let currentPage = currentIndex + 1;
|
|
12850
13443
|
let currentPage = event.data.__page;
|
|
12851
13444
|
let currentIndex = event.data.index;
|
|
12852
|
-
|
|
12853
|
-
|
|
12854
|
-
|
|
12855
|
-
|
|
12856
|
-
|
|
12857
|
-
|
|
12858
|
-
|
|
12859
|
-
|
|
12860
|
-
|
|
13445
|
+
if(mode !== "readonly"){
|
|
13446
|
+
// 新建编辑时,翻页才需要把当前页表单保存,只读时直接翻页即可
|
|
13447
|
+
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
13448
|
+
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
13449
|
+
// 这里不clone的话,其值会带上__super属性
|
|
13450
|
+
currentFormValues = _.clone(currentFormValues);
|
|
13451
|
+
var parent = event.data.parent;
|
|
13452
|
+
var __parentIndex = event.data.__parentIndex;
|
|
13453
|
+
if(parent){
|
|
13454
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13455
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13456
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13457
|
+
children: fieldValue[__parentIndex].children,
|
|
13458
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13459
|
+
});
|
|
12861
13460
|
}
|
|
12862
|
-
|
|
13461
|
+
else{
|
|
13462
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13463
|
+
}
|
|
13464
|
+
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
13465
|
+
doAction({
|
|
13466
|
+
"componentId": "${props.id}",
|
|
13467
|
+
"actionType": "setValue",
|
|
13468
|
+
"args": {
|
|
13469
|
+
"value": fieldValue
|
|
13470
|
+
}
|
|
13471
|
+
});
|
|
13472
|
+
}
|
|
12863
13473
|
|
|
12864
13474
|
// 以下是翻页逻辑,翻到下一页并把下一页内容显示到表单上
|
|
12865
13475
|
let targetPage;
|
|
@@ -12908,9 +13518,14 @@ function getFormPagination(props, mode) {
|
|
|
12908
13518
|
"onEvent": {
|
|
12909
13519
|
"click": {
|
|
12910
13520
|
"actions": [
|
|
13521
|
+
{
|
|
13522
|
+
"actionType": "validate",
|
|
13523
|
+
"componentId": formId
|
|
13524
|
+
},
|
|
12911
13525
|
{
|
|
12912
13526
|
"actionType": "custom",
|
|
12913
|
-
"script": onPageChangeScript
|
|
13527
|
+
"script": onPageChangeScript,
|
|
13528
|
+
"expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
12914
13529
|
}
|
|
12915
13530
|
]
|
|
12916
13531
|
}
|
|
@@ -12918,7 +13533,8 @@ function getFormPagination(props, mode) {
|
|
|
12918
13533
|
},
|
|
12919
13534
|
{
|
|
12920
13535
|
"type": "tpl",
|
|
12921
|
-
|
|
13536
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13537
|
+
"tpl": "${__page}/${__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length}"
|
|
12922
13538
|
},
|
|
12923
13539
|
{
|
|
12924
13540
|
"type": "button",
|
|
@@ -12926,15 +13542,22 @@ function getFormPagination(props, mode) {
|
|
|
12926
13542
|
"icon": `fa fa-angle-right`,
|
|
12927
13543
|
"level": "link",
|
|
12928
13544
|
"pageChangeDirection": "next",
|
|
12929
|
-
"disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
13545
|
+
// "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
13546
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13547
|
+
"disabledOn": showPagination ? "${__page >= (__super.parent ? COMPACT(__tableItems[__parentIndex]['children']).length : COMPACT(__tableItems).length)}" : "true",
|
|
12930
13548
|
"size": "sm",
|
|
12931
13549
|
"id": buttonNextId,
|
|
12932
13550
|
"onEvent": {
|
|
12933
13551
|
"click": {
|
|
12934
13552
|
"actions": [
|
|
13553
|
+
{
|
|
13554
|
+
"actionType": "validate",
|
|
13555
|
+
"componentId": formId
|
|
13556
|
+
},
|
|
12935
13557
|
{
|
|
12936
13558
|
"actionType": "custom",
|
|
12937
|
-
"script": onPageChangeScript
|
|
13559
|
+
"script": onPageChangeScript,
|
|
13560
|
+
"expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
12938
13561
|
}
|
|
12939
13562
|
]
|
|
12940
13563
|
}
|
|
@@ -12955,18 +13578,19 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12955
13578
|
// console.log("==getFormPaginationWrapper===", props, mode);
|
|
12956
13579
|
let serviceId = getComponentId("form_pagination", props.id);
|
|
12957
13580
|
let tableServiceId = getComponentId("table_service", props.id);
|
|
13581
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
12958
13582
|
let innerForm = Object.assign({}, form, {
|
|
12959
13583
|
"data": {
|
|
12960
13584
|
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12961
13585
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12962
|
-
"&": "${__tableItems[__super.index]}"
|
|
13586
|
+
"&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
|
|
12963
13587
|
}
|
|
12964
13588
|
});
|
|
12965
13589
|
let formBody = [
|
|
12966
13590
|
{
|
|
12967
13591
|
"type": "wrapper",
|
|
12968
13592
|
"size": "none",
|
|
12969
|
-
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white
|
|
13593
|
+
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
|
|
12970
13594
|
"body": [
|
|
12971
13595
|
getFormPagination(props, mode)
|
|
12972
13596
|
]
|
|
@@ -12982,7 +13606,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12982
13606
|
}
|
|
12983
13607
|
];
|
|
12984
13608
|
let onServiceInitedScript = `
|
|
12985
|
-
//
|
|
13609
|
+
// 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
12986
13610
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12987
13611
|
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
12988
13612
|
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
@@ -12995,8 +13619,13 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12995
13619
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12996
13620
|
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
12997
13621
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
13622
|
+
let fieldPrefix = "${props.fieldPrefix || ''}";
|
|
13623
|
+
if(fieldPrefix){
|
|
13624
|
+
let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
|
|
13625
|
+
lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
|
|
13626
|
+
}
|
|
12998
13627
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12999
|
-
let mode = "${mode}";
|
|
13628
|
+
let mode = "${mode || ''}";
|
|
13000
13629
|
if(mode === "new"){
|
|
13001
13630
|
// 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
|
|
13002
13631
|
// 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
|
|
@@ -13017,6 +13646,26 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13017
13646
|
event.data.__tableItems.forEach(function(n,i){
|
|
13018
13647
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
13019
13648
|
});
|
|
13649
|
+
|
|
13650
|
+
var parent = event.data.parent;
|
|
13651
|
+
var fieldValue = event.data.__tableItems;
|
|
13652
|
+
if(parent){
|
|
13653
|
+
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13654
|
+
var primaryKey = "${primaryKey}";
|
|
13655
|
+
event.data.__parentIndex = _.findIndex(fieldValue, function(item){
|
|
13656
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13657
|
+
});
|
|
13658
|
+
if(event.data.__parentIndex < 0){
|
|
13659
|
+
let tableId = "${props.id}";
|
|
13660
|
+
let table = scope.getComponentById(tableId)
|
|
13661
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
13662
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
13663
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
13664
|
+
event.data.__parentIndex = _.findIndex(table.props.value, function(item){
|
|
13665
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13666
|
+
});
|
|
13667
|
+
}
|
|
13668
|
+
}
|
|
13020
13669
|
`;
|
|
13021
13670
|
let schema = {
|
|
13022
13671
|
"type": "service",
|
|
@@ -13037,6 +13686,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13037
13686
|
// "body": formBody,
|
|
13038
13687
|
"data": {
|
|
13039
13688
|
"__page": "${index + 1}",
|
|
13689
|
+
"__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
|
|
13040
13690
|
// "__total": `\${${props.name}.length}`,
|
|
13041
13691
|
// "__total": "${__tableItems.length}",
|
|
13042
13692
|
// "__paginationServiceId": serviceId,
|
|
@@ -13063,6 +13713,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13063
13713
|
async function getForm(props, mode = "edit", formId) {
|
|
13064
13714
|
let formFields = getFormFields(props, mode);
|
|
13065
13715
|
let body = await getFormBody(null, formFields);
|
|
13716
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
13066
13717
|
if (!formId) {
|
|
13067
13718
|
formId = getComponentId("form", props.id);
|
|
13068
13719
|
}
|
|
@@ -13081,10 +13732,41 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13081
13732
|
// 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
|
|
13082
13733
|
let onEditItemSubmitScript = `
|
|
13083
13734
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
13735
|
+
let removeEmptyItems = function(items){
|
|
13736
|
+
let i = _.findIndex(items, function(item){
|
|
13737
|
+
return item === undefined
|
|
13738
|
+
});
|
|
13739
|
+
if(i > -1){
|
|
13740
|
+
items.splice(i, 1);
|
|
13741
|
+
removeEmptyItems(items);
|
|
13742
|
+
}
|
|
13743
|
+
}
|
|
13744
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
13745
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
13746
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13084
13747
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13085
13748
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
13086
13749
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
13087
|
-
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13750
|
+
// fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13751
|
+
var currentIndex = event.data.__super.__super.index;
|
|
13752
|
+
var currentFormValues = JSON.parse(JSON.stringify(event.data));
|
|
13753
|
+
var parent = event.data.__super.__super.parent;
|
|
13754
|
+
var __parentIndex = event.data.__super.__super.__parentIndex;
|
|
13755
|
+
let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
|
|
13756
|
+
var primaryKey = "${primaryKey}";
|
|
13757
|
+
if(parent){
|
|
13758
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13759
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13760
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13761
|
+
children: fieldValue[__parentIndex].children,
|
|
13762
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13763
|
+
});
|
|
13764
|
+
}
|
|
13765
|
+
else{
|
|
13766
|
+
// 这里currentFormValues中如果没有primaryKey字段值不用处理,因为组件的pipeIn/pipeOut中会为每行自动生成
|
|
13767
|
+
// 也不用担心复制行时_id会重复,因为点击复制按钮时已经处理过了
|
|
13768
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13769
|
+
}
|
|
13088
13770
|
doAction({
|
|
13089
13771
|
"componentId": "${props.id}",
|
|
13090
13772
|
"actionType": "setValue",
|
|
@@ -13180,13 +13862,14 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13180
13862
|
*/
|
|
13181
13863
|
async function getButtonActions(props, mode) {
|
|
13182
13864
|
let actions = [];
|
|
13865
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
13183
13866
|
let formId = getComponentId("form", props.id);
|
|
13184
13867
|
let dialogId = getComponentId("dialog", props.id);
|
|
13185
13868
|
let buttonNextId = getComponentId("button_next", props.id);
|
|
13186
13869
|
let formPaginationId = getComponentId("form_pagination", props.id);
|
|
13187
13870
|
let parentFormData = "${__super.__super.__super.__super || {}}";
|
|
13188
13871
|
let amisVersion = getComparableAmisVersion();
|
|
13189
|
-
if(amisVersion < 3.6){
|
|
13872
|
+
if (amisVersion < 3.6) {
|
|
13190
13873
|
parentFormData = "${__super.__super || {}}";
|
|
13191
13874
|
}
|
|
13192
13875
|
if (mode == "new" || mode == "edit") {
|
|
@@ -13222,9 +13905,42 @@ async function getButtonActions(props, mode) {
|
|
|
13222
13905
|
// };
|
|
13223
13906
|
let onSaveAndNewItemScript = `
|
|
13224
13907
|
let scope = event.context.scoped;
|
|
13908
|
+
let removeEmptyItems = function(items){
|
|
13909
|
+
let i = _.findIndex(items, function(item){
|
|
13910
|
+
return item === undefined
|
|
13911
|
+
});
|
|
13912
|
+
if(i > -1){
|
|
13913
|
+
items.splice(i, 1);
|
|
13914
|
+
removeEmptyItems(items);
|
|
13915
|
+
}
|
|
13916
|
+
}
|
|
13917
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
13918
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
13919
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13225
13920
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13226
13921
|
// 新建一条空白行并保存到子表组件
|
|
13227
|
-
|
|
13922
|
+
var parent = event.data.__super.parent;
|
|
13923
|
+
var primaryKey = "${primaryKey}";
|
|
13924
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13925
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13926
|
+
});
|
|
13927
|
+
if(parent && __parentIndex < 0){
|
|
13928
|
+
let tableId = "${props.id}";
|
|
13929
|
+
let table = scope.getComponentById(tableId)
|
|
13930
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
13931
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
13932
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
13933
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
13934
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13935
|
+
});
|
|
13936
|
+
}
|
|
13937
|
+
if(parent){
|
|
13938
|
+
fieldValue[__parentIndex].children.push({});
|
|
13939
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13940
|
+
}
|
|
13941
|
+
else{
|
|
13942
|
+
fieldValue.push({});
|
|
13943
|
+
}
|
|
13228
13944
|
doAction({
|
|
13229
13945
|
"componentId": "${props.id}",
|
|
13230
13946
|
"actionType": "setValue",
|
|
@@ -13236,7 +13952,13 @@ async function getButtonActions(props, mode) {
|
|
|
13236
13952
|
let __paginationServiceId = "${formPaginationId}";
|
|
13237
13953
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13238
13954
|
event.data.index = __paginationData.index;
|
|
13239
|
-
|
|
13955
|
+
if(parent){
|
|
13956
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13957
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
13958
|
+
}
|
|
13959
|
+
else{
|
|
13960
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13961
|
+
}
|
|
13240
13962
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13241
13963
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13242
13964
|
`;
|
|
@@ -13245,9 +13967,49 @@ async function getButtonActions(props, mode) {
|
|
|
13245
13967
|
let __formId = "${formId}";
|
|
13246
13968
|
// let newItem = JSON.parse(JSON.stringify(event.data));
|
|
13247
13969
|
let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
|
|
13970
|
+
newItem = _.clone(newItem);
|
|
13971
|
+
let removeEmptyItems = function(items){
|
|
13972
|
+
let i = _.findIndex(items, function(item){
|
|
13973
|
+
return item === undefined
|
|
13974
|
+
});
|
|
13975
|
+
if(i > -1){
|
|
13976
|
+
items.splice(i, 1);
|
|
13977
|
+
removeEmptyItems(items);
|
|
13978
|
+
}
|
|
13979
|
+
}
|
|
13980
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
13981
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
13982
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13248
13983
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13249
13984
|
// 复制当前页数据到新建行并保存到子表组件
|
|
13250
|
-
fieldValue.push(newItem);
|
|
13985
|
+
// fieldValue.push(newItem);
|
|
13986
|
+
var parent = event.data.__super.parent;
|
|
13987
|
+
var primaryKey = "${primaryKey}";
|
|
13988
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13989
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13990
|
+
});
|
|
13991
|
+
if(parent && __parentIndex < 0){
|
|
13992
|
+
let tableId = "${props.id}";
|
|
13993
|
+
let table = scope.getComponentById(tableId)
|
|
13994
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
13995
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
13996
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
13997
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
13998
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13999
|
+
});
|
|
14000
|
+
}
|
|
14001
|
+
if(newItem[primaryKey]){
|
|
14002
|
+
// 如果newItem已经有主键字段值,则重新生成新的主键值,否则会重复。
|
|
14003
|
+
let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
|
|
14004
|
+
newItem[primaryKey] = uuidv4();
|
|
14005
|
+
}
|
|
14006
|
+
if(parent){
|
|
14007
|
+
fieldValue[__parentIndex].children.push(newItem);
|
|
14008
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
14009
|
+
}
|
|
14010
|
+
else{
|
|
14011
|
+
fieldValue.push(newItem);
|
|
14012
|
+
}
|
|
13251
14013
|
doAction({
|
|
13252
14014
|
"componentId": "${props.id}",
|
|
13253
14015
|
"actionType": "setValue",
|
|
@@ -13259,19 +14021,25 @@ async function getButtonActions(props, mode) {
|
|
|
13259
14021
|
let __paginationServiceId = "${formPaginationId}";
|
|
13260
14022
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13261
14023
|
event.data.index = __paginationData.index;
|
|
13262
|
-
|
|
14024
|
+
if(parent){
|
|
14025
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
14026
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
14027
|
+
}
|
|
14028
|
+
else{
|
|
14029
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
14030
|
+
}
|
|
13263
14031
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13264
14032
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13265
14033
|
`;
|
|
13266
14034
|
let dialogButtons = [
|
|
13267
14035
|
{
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
|
|
14036
|
+
"type": "button",
|
|
14037
|
+
"label": "完成",
|
|
14038
|
+
"actionType": "confirm",
|
|
14039
|
+
"level": "primary"
|
|
13272
14040
|
}
|
|
13273
14041
|
];
|
|
13274
|
-
if(props.addable){
|
|
14042
|
+
if (props.addable) {
|
|
13275
14043
|
// 有新增行权限时额外添加新增和复制按钮
|
|
13276
14044
|
dialogButtons = [
|
|
13277
14045
|
{
|
|
@@ -13281,9 +14049,14 @@ async function getButtonActions(props, mode) {
|
|
|
13281
14049
|
"onEvent": {
|
|
13282
14050
|
"click": {
|
|
13283
14051
|
"actions": [
|
|
14052
|
+
{
|
|
14053
|
+
"actionType": "validate",
|
|
14054
|
+
"componentId": formId
|
|
14055
|
+
},
|
|
13284
14056
|
{
|
|
13285
14057
|
"actionType": "custom",
|
|
13286
|
-
"script": onSaveAndNewItemScript
|
|
14058
|
+
"script": onSaveAndNewItemScript,
|
|
14059
|
+
"expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
13287
14060
|
}
|
|
13288
14061
|
]
|
|
13289
14062
|
}
|
|
@@ -13296,9 +14069,14 @@ async function getButtonActions(props, mode) {
|
|
|
13296
14069
|
"onEvent": {
|
|
13297
14070
|
"click": {
|
|
13298
14071
|
"actions": [
|
|
14072
|
+
{
|
|
14073
|
+
"actionType": "validate",
|
|
14074
|
+
"componentId": formId
|
|
14075
|
+
},
|
|
13299
14076
|
{
|
|
13300
14077
|
"actionType": "custom",
|
|
13301
|
-
"script": onSaveAndCopyItemScript
|
|
14078
|
+
"script": onSaveAndCopyItemScript,
|
|
14079
|
+
"expression": "${!!!event.data.validateResult.error}" //触发表单校验结果会存入validateResult,amis 3.2不支持,高版本比如 3.5.3支持
|
|
13302
14080
|
}
|
|
13303
14081
|
]
|
|
13304
14082
|
}
|
|
@@ -13335,12 +14113,15 @@ async function getButtonActions(props, mode) {
|
|
|
13335
14113
|
"_master": "${_master}",
|
|
13336
14114
|
"global": "${global}",
|
|
13337
14115
|
"uiSchema": "${uiSchema}",
|
|
13338
|
-
"index": "${index}"
|
|
14116
|
+
"index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
|
|
14117
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13339
14118
|
// "__tableItems": `\${${props.name}}`
|
|
13340
14119
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13341
14120
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13342
14121
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13343
|
-
|
|
14122
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
14123
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
14124
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13344
14125
|
},
|
|
13345
14126
|
"actions": dialogButtons,
|
|
13346
14127
|
"onEvent": {
|
|
@@ -13363,35 +14144,39 @@ async function getButtonActions(props, mode) {
|
|
|
13363
14144
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13364
14145
|
}
|
|
13365
14146
|
if (mode == "new") {
|
|
13366
|
-
`
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
`;
|
|
14147
|
+
// let onNewLineScript = `
|
|
14148
|
+
// let newItem = {};
|
|
14149
|
+
// if(event.data["${props.name}"]){
|
|
14150
|
+
// // let fieldValue = event.data.__tableItems;
|
|
14151
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
14152
|
+
// // let fieldValue = _.clone(event.data["${props.name}"]);
|
|
14153
|
+
// let fieldValue = event.data["${props.name}"];
|
|
14154
|
+
// fieldValue.push(newItem);
|
|
14155
|
+
// doAction({
|
|
14156
|
+
// "componentId": "${props.id}",
|
|
14157
|
+
// "actionType": "setValue",
|
|
14158
|
+
// "args": {
|
|
14159
|
+
// "value": fieldValue
|
|
14160
|
+
// }
|
|
14161
|
+
// });
|
|
14162
|
+
// event.data.index = fieldValue.length - 1;
|
|
14163
|
+
// }
|
|
14164
|
+
// else{
|
|
14165
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
14166
|
+
// doAction({
|
|
14167
|
+
// "componentId": "${props.id}",
|
|
14168
|
+
// "actionType": "setValue",
|
|
14169
|
+
// "args": {
|
|
14170
|
+
// "value": [newItem]
|
|
14171
|
+
// }
|
|
14172
|
+
// });
|
|
14173
|
+
// event.data.index = 1;
|
|
14174
|
+
// }
|
|
14175
|
+
// `;
|
|
14176
|
+
// let actionNewLine = {
|
|
14177
|
+
// "actionType": "custom",
|
|
14178
|
+
// "script": onNewLineScript
|
|
14179
|
+
// };
|
|
13395
14180
|
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13396
14181
|
// actions = [actionNewLine, actionShowEditDialog];
|
|
13397
14182
|
actions = [actionShowEditDialog];
|
|
@@ -13426,15 +14211,20 @@ async function getButtonActions(props, mode) {
|
|
|
13426
14211
|
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
13427
14212
|
// "__parentForm": "${__super.__super || {}}",
|
|
13428
14213
|
"__parentForm": parentFormData,
|
|
14214
|
+
"_master": "${_master}",
|
|
13429
14215
|
"global": "${global}",
|
|
13430
14216
|
"uiSchema": "${uiSchema}",
|
|
13431
14217
|
"index": "${index}",
|
|
14218
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13432
14219
|
// "__tableItems": `\${${props.name}}`
|
|
13433
14220
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13434
14221
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13435
14222
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13436
|
-
"__tableItems": `\${(
|
|
13437
|
-
|
|
14223
|
+
// "__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
14224
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
14225
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
14226
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
14227
|
+
},
|
|
13438
14228
|
}
|
|
13439
14229
|
}
|
|
13440
14230
|
];
|
|
@@ -13449,8 +14239,40 @@ async function getButtonActions(props, mode) {
|
|
|
13449
14239
|
let wrapperServiceData = wrapperService.getData();
|
|
13450
14240
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13451
14241
|
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
14242
|
+
// 也因为这里clone没有直接删除,所以弹出编辑表单提交事件中event.data.__tableItems中取到的值会有被删除的行数据为undefined
|
|
13452
14243
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13453
|
-
|
|
14244
|
+
var currentIndex = event.data.index;
|
|
14245
|
+
var parent = event.data.__super.parent;
|
|
14246
|
+
var primaryKey = "${primaryKey}";
|
|
14247
|
+
var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
|
|
14248
|
+
return item[primaryKey] == parent[primaryKey];
|
|
14249
|
+
});
|
|
14250
|
+
if(parent && __parentIndex < 0){
|
|
14251
|
+
let tableId = "${props.id}";
|
|
14252
|
+
let table = scope.getComponentById(tableId)
|
|
14253
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
14254
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
14255
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
14256
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
14257
|
+
return item[primaryKey] == parent[primaryKey];
|
|
14258
|
+
});
|
|
14259
|
+
}
|
|
14260
|
+
if(parent){
|
|
14261
|
+
lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
|
|
14262
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
14263
|
+
lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
|
|
14264
|
+
children: lastestFieldValue[__parentIndex].children,
|
|
14265
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
14266
|
+
});
|
|
14267
|
+
}
|
|
14268
|
+
else{
|
|
14269
|
+
lastestFieldValue.splice(currentIndex, 1);
|
|
14270
|
+
}
|
|
14271
|
+
let fieldPrefix = "${props.fieldPrefix || ''}";
|
|
14272
|
+
if(fieldPrefix){
|
|
14273
|
+
let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
|
|
14274
|
+
lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
|
|
14275
|
+
}
|
|
13454
14276
|
doAction({
|
|
13455
14277
|
"componentId": "${props.id}",
|
|
13456
14278
|
"actionType": "setValue",
|
|
@@ -13520,58 +14342,104 @@ async function getButtonView(props) {
|
|
|
13520
14342
|
|
|
13521
14343
|
async function getButtonDelete(props) {
|
|
13522
14344
|
return {
|
|
13523
|
-
"type": "button",
|
|
13524
|
-
"label": "",
|
|
13525
|
-
"icon": "fa fa-trash-alt",//不可以用fa-trash-o,因为设计字段布局界面中弹出的设置分组列表中显示不了这个图标
|
|
14345
|
+
"type": "dropdown-button",
|
|
13526
14346
|
"level": "link",
|
|
13527
|
-
"
|
|
13528
|
-
|
|
13529
|
-
|
|
14347
|
+
"icon": "fa fa-trash-alt",
|
|
14348
|
+
"size": "xs",
|
|
14349
|
+
"hideCaret": true,
|
|
14350
|
+
"closeOnClick": true,
|
|
14351
|
+
"body": [
|
|
14352
|
+
{
|
|
14353
|
+
"type": "wrapper",
|
|
14354
|
+
"size": "md",
|
|
14355
|
+
"className": "w-80",
|
|
14356
|
+
"body": [
|
|
14357
|
+
{
|
|
14358
|
+
"tpl": "确定要删除吗?",
|
|
14359
|
+
"type": "tpl"
|
|
14360
|
+
},
|
|
14361
|
+
{
|
|
14362
|
+
"type": "flex",
|
|
14363
|
+
"justify": "flex-end",
|
|
14364
|
+
"className": "mt-3",
|
|
14365
|
+
"items": [
|
|
14366
|
+
{
|
|
14367
|
+
"type": "button",
|
|
14368
|
+
"label": "取消",
|
|
14369
|
+
"className": "mr-2"
|
|
14370
|
+
},
|
|
14371
|
+
{
|
|
14372
|
+
"type": "button",
|
|
14373
|
+
"label": "删除",
|
|
14374
|
+
"level": "danger",
|
|
14375
|
+
"onEvent": {
|
|
14376
|
+
"click": {
|
|
14377
|
+
"actions": await getButtonActions(props, "delete")
|
|
14378
|
+
}
|
|
14379
|
+
}
|
|
14380
|
+
}
|
|
14381
|
+
]
|
|
14382
|
+
}
|
|
14383
|
+
]
|
|
13530
14384
|
}
|
|
13531
|
-
|
|
13532
|
-
}
|
|
14385
|
+
]
|
|
14386
|
+
}
|
|
13533
14387
|
}
|
|
13534
14388
|
|
|
14389
|
+
|
|
13535
14390
|
const getAmisInputTableSchema = async (props) => {
|
|
13536
14391
|
if (!props.id) {
|
|
13537
14392
|
props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
|
|
13538
14393
|
}
|
|
14394
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
14395
|
+
let showOperation = props.showOperation;
|
|
14396
|
+
if (showOperation !== false) {
|
|
14397
|
+
showOperation = true;
|
|
14398
|
+
}
|
|
14399
|
+
let fieldPrefix = props.fieldPrefix;
|
|
14400
|
+
let fields = props.fields || [];
|
|
14401
|
+
if (fieldPrefix) {
|
|
14402
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
14403
|
+
}
|
|
13539
14404
|
let serviceId = getComponentId("table_service", props.id);
|
|
13540
14405
|
let buttonsForColumnOperations = [];
|
|
13541
14406
|
let inlineEditMode = props.inlineEditMode;
|
|
13542
14407
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
13543
|
-
if (
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
14408
|
+
if (showOperation) {
|
|
14409
|
+
if (props.editable) {
|
|
14410
|
+
let showEditButton = true;
|
|
14411
|
+
if (showAsInlineEditMode) {
|
|
14412
|
+
// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
14413
|
+
showEditButton = true;
|
|
14414
|
+
// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
14415
|
+
// if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
|
|
14416
|
+
// showEditButton = true;
|
|
14417
|
+
// }
|
|
14418
|
+
// else {
|
|
14419
|
+
// showEditButton = false;
|
|
14420
|
+
// }
|
|
14421
|
+
}
|
|
14422
|
+
// 编辑时显示编辑按钮
|
|
14423
|
+
if (showEditButton) {
|
|
14424
|
+
let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
|
|
14425
|
+
buttonsForColumnOperations.push(buttonEditSchema);
|
|
14426
|
+
}
|
|
13555
14427
|
}
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
14428
|
+
else {
|
|
14429
|
+
// 只读时显示查看按钮
|
|
14430
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
|
|
14431
|
+
let buttonViewSchema = await getButtonView(props);
|
|
14432
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
14433
|
+
}
|
|
14434
|
+
if (props.removable) {
|
|
14435
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
14436
|
+
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13560
14437
|
}
|
|
13561
14438
|
}
|
|
13562
|
-
|
|
13563
|
-
// 只读时显示查看按钮
|
|
13564
|
-
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13565
|
-
let buttonViewSchema = await getButtonView(props);
|
|
13566
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13567
|
-
}
|
|
13568
|
-
if (props.removable) {
|
|
13569
|
-
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13570
|
-
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13571
|
-
}
|
|
14439
|
+
let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13572
14440
|
let inputTableSchema = {
|
|
13573
14441
|
"type": "input-table",
|
|
13574
|
-
"
|
|
14442
|
+
"mode": "normal",
|
|
13575
14443
|
"name": props.name,
|
|
13576
14444
|
//不可以addable/editable/removable设置为true,因为会在原生的操作列显示操作按钮图标,此开关实测只控制这个按钮显示不会影响功能
|
|
13577
14445
|
// "addable": props.addable,
|
|
@@ -13586,7 +14454,53 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13586
14454
|
"strictMode": props.strictMode,
|
|
13587
14455
|
"showTableAddBtn": false,
|
|
13588
14456
|
"showFooterAddBtn": false,
|
|
13589
|
-
"className": props.tableClassName
|
|
14457
|
+
"className": props.tableClassName,
|
|
14458
|
+
"pipeIn": (value, data) => {
|
|
14459
|
+
if (fieldPrefix) {
|
|
14460
|
+
value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
|
|
14461
|
+
}
|
|
14462
|
+
value = getTableValueWithEmptyValue(value, fields);
|
|
14463
|
+
if (primaryKey) {
|
|
14464
|
+
// 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
|
|
14465
|
+
// 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
|
|
14466
|
+
// 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
|
|
14467
|
+
value = getTableValueWithPrimaryKeyValue(value, primaryKey);
|
|
14468
|
+
}
|
|
14469
|
+
if (amis.pipeIn) {
|
|
14470
|
+
if (typeof amis.pipeIn === 'function') {
|
|
14471
|
+
return amis.pipeIn(value, data);
|
|
14472
|
+
}
|
|
14473
|
+
}
|
|
14474
|
+
return value;
|
|
14475
|
+
},
|
|
14476
|
+
"pipeOut": (value, data) => {
|
|
14477
|
+
value = (value || []).map(function (item) {
|
|
14478
|
+
delete item.__fix_rerender_after_children_modified_tag;
|
|
14479
|
+
return item;
|
|
14480
|
+
});
|
|
14481
|
+
if (fieldPrefix) {
|
|
14482
|
+
value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
|
|
14483
|
+
}
|
|
14484
|
+
value = getTableValueWithoutEmptyValue(value, fields);
|
|
14485
|
+
if (props.autoGeneratePrimaryKeyValue === true) {
|
|
14486
|
+
// 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
|
|
14487
|
+
// 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
|
|
14488
|
+
value = getTableValueWithPrimaryKeyValue(value, primaryKey);
|
|
14489
|
+
}
|
|
14490
|
+
else {
|
|
14491
|
+
// 默认情况下,也就是没有配置autoGeneratePrimaryKey时,最终输出的字段值要移除行中的primaryKey值
|
|
14492
|
+
// 需要注意如果没有配置autoGeneratePrimaryKey时,因为每次弹出行编辑窗口保存后都会先后进入pipeOut和pipeIn,
|
|
14493
|
+
// 这里删除掉了primaryKey值,所以primaryKey值每次弹出编辑窗口保存后都会给每行重新生成新的primaryKey值
|
|
14494
|
+
// 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
|
|
14495
|
+
value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
|
|
14496
|
+
}
|
|
14497
|
+
if (amis.pipeOut) {
|
|
14498
|
+
if (typeof amis.pipeOut === 'function') {
|
|
14499
|
+
return amis.pipeOut(value, data);
|
|
14500
|
+
}
|
|
14501
|
+
}
|
|
14502
|
+
return value;
|
|
14503
|
+
}
|
|
13590
14504
|
};
|
|
13591
14505
|
if (buttonsForColumnOperations.length) {
|
|
13592
14506
|
inputTableSchema.columns.push({
|
|
@@ -13596,20 +14510,22 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13596
14510
|
"width": buttonsForColumnOperations.length > 1 ? "60px" : "20px"
|
|
13597
14511
|
});
|
|
13598
14512
|
}
|
|
13599
|
-
if (showAsInlineEditMode) {
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
14513
|
+
// if (showAsInlineEditMode) {
|
|
14514
|
+
// // 因为要支持不同的列上配置inlineEditMode属性,所有不可以把整个子表组件都设置为inlineEditMode
|
|
14515
|
+
// inputTableSchema.needConfirm = false;
|
|
14516
|
+
// }
|
|
13603
14517
|
if (amis) {
|
|
13604
14518
|
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13605
14519
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
14520
|
+
delete amis.pipeIn;//该属性在上面合并过了
|
|
14521
|
+
delete amis.pipeOut;//该属性在上面合并过了
|
|
13606
14522
|
Object.assign(inputTableSchema, amis);
|
|
13607
14523
|
}
|
|
13608
|
-
const isAnyFieldHasDependOn = (
|
|
14524
|
+
const isAnyFieldHasDependOn = (fields || []).find(function (item) {
|
|
13609
14525
|
return item.depend_on;
|
|
13610
14526
|
});
|
|
13611
14527
|
if (isAnyFieldHasDependOn) {
|
|
13612
|
-
// 有任意一个子字段有depend_on
|
|
14528
|
+
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
|
|
13613
14529
|
Object.assign(inputTableSchema, {
|
|
13614
14530
|
strictMode: false
|
|
13615
14531
|
});
|
|
@@ -13638,11 +14554,31 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13638
14554
|
"body": headerToolbar
|
|
13639
14555
|
});
|
|
13640
14556
|
}
|
|
14557
|
+
let className = "steedos-input-table";
|
|
14558
|
+
|
|
14559
|
+
if (typeof props.className == "object") {
|
|
14560
|
+
className = {
|
|
14561
|
+
[className]: "true",
|
|
14562
|
+
...props.className
|
|
14563
|
+
};
|
|
14564
|
+
} else if (typeof props.className == "string") {
|
|
14565
|
+
className = `${className} ${props.className} `;
|
|
14566
|
+
}
|
|
14567
|
+
|
|
13641
14568
|
let schema = {
|
|
13642
|
-
"type": "
|
|
13643
|
-
"body":
|
|
13644
|
-
|
|
13645
|
-
|
|
14569
|
+
"type": "control",
|
|
14570
|
+
"body": {
|
|
14571
|
+
"type": "service",
|
|
14572
|
+
"body": schemaBody,
|
|
14573
|
+
"id": serviceId
|
|
14574
|
+
},
|
|
14575
|
+
"label": props.label,
|
|
14576
|
+
"labelClassName": props.label ? props.labelClassName : "none",
|
|
14577
|
+
"labelRemark": props.labelRemark,
|
|
14578
|
+
"labelAlign": props.labelAlign,
|
|
14579
|
+
//控制control的mode属性,https://aisuda.bce.baidu.com/amis/zh-CN/components/form/formitem#表单项展示
|
|
14580
|
+
"mode": props.mode || null,
|
|
14581
|
+
className
|
|
13646
14582
|
};
|
|
13647
14583
|
// console.log("===schema===", schema);
|
|
13648
14584
|
return schema;
|
|
@@ -13714,7 +14650,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
|
|
|
13714
14650
|
// 获取
|
|
13715
14651
|
async function getRecordPageInitSchema(objectApiName){
|
|
13716
14652
|
const relatedList = await getObjectRelatedList(objectApiName);
|
|
13717
|
-
|
|
14653
|
+
await getUISchema(objectApiName);
|
|
13718
14654
|
let body = [
|
|
13719
14655
|
// detailHeaderAmisSchema,
|
|
13720
14656
|
{
|
|
@@ -13722,28 +14658,7 @@ async function getRecordPageInitSchema(objectApiName){
|
|
|
13722
14658
|
"label": "标题面板",
|
|
13723
14659
|
"objectApiName": "${objectName}",
|
|
13724
14660
|
"recordId": "${recordId}",
|
|
13725
|
-
"onEvent": {
|
|
13726
|
-
"recordLoaded": {
|
|
13727
|
-
"actions": [
|
|
13728
|
-
{
|
|
13729
|
-
"actionType": "setValue",
|
|
13730
|
-
"args": {
|
|
13731
|
-
"value": {
|
|
13732
|
-
"recordLoaded": true,
|
|
13733
|
-
}
|
|
13734
|
-
}
|
|
13735
|
-
},
|
|
13736
|
-
{
|
|
13737
|
-
"actionType": "reload",
|
|
13738
|
-
"data": {
|
|
13739
|
-
"name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
13740
|
-
"record": `\${record}`,
|
|
13741
|
-
"recordLoaded": true,
|
|
13742
|
-
}
|
|
13743
|
-
}
|
|
13744
|
-
]
|
|
13745
|
-
}
|
|
13746
|
-
}
|
|
14661
|
+
"onEvent": {}
|
|
13747
14662
|
}
|
|
13748
14663
|
];
|
|
13749
14664
|
let contentBody = {
|
|
@@ -16308,5 +17223,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
16308
17223
|
};
|
|
16309
17224
|
};
|
|
16310
17225
|
|
|
16311
|
-
export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
|
|
17226
|
+
export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getObjectRelatedListsMiniSchema, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailMiniSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
|
|
16312
17227
|
//# sourceMappingURL=index.esm.js.map
|