@steedos-widgets/amis-lib 3.6.2-beta.1 → 3.6.2-beta.11
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 +965 -321
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +964 -322
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +297 -178
- 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/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/input_table.d.ts +2 -0
- 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/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -367,22 +367,26 @@ const getSteedosAuth = () => {
|
|
|
367
367
|
* @Description:
|
|
368
368
|
*/
|
|
369
369
|
|
|
370
|
-
|
|
371
370
|
const Router = {
|
|
372
371
|
getTabDisplayAs(tab_id){
|
|
372
|
+
const uiSchema = getUISchemaSync$1(tab_id, false);
|
|
373
373
|
var urlSearch = new URLSearchParams(document.location.search);
|
|
374
374
|
if(urlSearch.has('display')){
|
|
375
375
|
return urlSearch.get('display')
|
|
376
376
|
}
|
|
377
377
|
const key = `tab_${tab_id}_display`;
|
|
378
378
|
// const key = `page_display`;
|
|
379
|
-
const value =
|
|
380
|
-
|
|
379
|
+
const value = sessionStorage.getItem(key);
|
|
380
|
+
let defaultDisplay = "grid";
|
|
381
|
+
if(uiSchema.enable_split){
|
|
382
|
+
defaultDisplay = "split";
|
|
383
|
+
}
|
|
384
|
+
return value ? value : defaultDisplay;
|
|
381
385
|
},
|
|
382
386
|
|
|
383
387
|
setTabDisplayAs(tab_id, displayAs){
|
|
384
388
|
const key = `tab_${tab_id}_display`;
|
|
385
|
-
|
|
389
|
+
sessionStorage.setItem(key, displayAs);
|
|
386
390
|
},
|
|
387
391
|
getAppPath({formFactor, appId}){
|
|
388
392
|
return `/app/${appId}`;
|
|
@@ -486,7 +490,7 @@ function getComparableAmisVersion() {
|
|
|
486
490
|
* @Author: baozhoutao@steedos.com
|
|
487
491
|
* @Date: 2022-05-23 09:53:08
|
|
488
492
|
* @LastEditors: liaodaxue
|
|
489
|
-
* @LastEditTime:
|
|
493
|
+
* @LastEditTime: 2024-01-17 16:00:27
|
|
490
494
|
* @Description:
|
|
491
495
|
*/
|
|
492
496
|
|
|
@@ -558,7 +562,7 @@ function getSelectMap(selectOptions){
|
|
|
558
562
|
|
|
559
563
|
function getNameTplUrl(field, ctx){
|
|
560
564
|
if(ctx.objectName === 'cms_files'){
|
|
561
|
-
return
|
|
565
|
+
return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
|
|
562
566
|
}
|
|
563
567
|
const href = Router.getObjectDetailPath({
|
|
564
568
|
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
@@ -1304,6 +1308,7 @@ var frontend_notifications$1 = "Notifications";
|
|
|
1304
1308
|
var frontend_notifications_allread$1 = "Mark all as read";
|
|
1305
1309
|
var frontend_notifications_allread_message$1 = "All marked as read";
|
|
1306
1310
|
var frontend_profile$1 = "Profile";
|
|
1311
|
+
var switch_space$1 = "Switch Space";
|
|
1307
1312
|
var frontend_about$1 = "About";
|
|
1308
1313
|
var frontend_log_out$1 = "Log out";
|
|
1309
1314
|
var frontend_listview_warning_start$1 = "The current ";
|
|
@@ -1391,6 +1396,7 @@ var en_us = {
|
|
|
1391
1396
|
frontend_notifications_allread: frontend_notifications_allread$1,
|
|
1392
1397
|
frontend_notifications_allread_message: frontend_notifications_allread_message$1,
|
|
1393
1398
|
frontend_profile: frontend_profile$1,
|
|
1399
|
+
switch_space: switch_space$1,
|
|
1394
1400
|
frontend_about: frontend_about$1,
|
|
1395
1401
|
frontend_log_out: frontend_log_out$1,
|
|
1396
1402
|
frontend_listview_warning_start: frontend_listview_warning_start$1,
|
|
@@ -1430,9 +1436,9 @@ var frontend_display_type_is_split = "分栏视图";
|
|
|
1430
1436
|
var frontend_display_as = "显示为";
|
|
1431
1437
|
var frontend_record_sum = "个项目";
|
|
1432
1438
|
var frontend_button_reload_tooltip = "刷新";
|
|
1433
|
-
var frontend_button_search_tooltip = "
|
|
1439
|
+
var frontend_button_search_tooltip = "搜索";
|
|
1434
1440
|
var frontend_fields_filter_button_search = "搜索";
|
|
1435
|
-
var frontend_fields_filter_button_settings = "
|
|
1441
|
+
var frontend_fields_filter_button_settings = "选择搜索项";
|
|
1436
1442
|
var frontend_button_listview_control_tooltip = "列表视图控制";
|
|
1437
1443
|
var frontend_button_listview_control_label = "列表视图控制";
|
|
1438
1444
|
var frontend_listview_control_columns = "显示的列";
|
|
@@ -1480,6 +1486,7 @@ var frontend_notifications = "通知";
|
|
|
1480
1486
|
var frontend_notifications_allread = "全部标记为已读";
|
|
1481
1487
|
var frontend_notifications_allread_message = "已全部标记为已读";
|
|
1482
1488
|
var frontend_profile = "个人资料";
|
|
1489
|
+
var switch_space = "切换工作区";
|
|
1483
1490
|
var frontend_about = "关于";
|
|
1484
1491
|
var frontend_log_out = "注销";
|
|
1485
1492
|
var frontend_listview_warning_start = "当前";
|
|
@@ -1568,6 +1575,7 @@ var zh_cn = {
|
|
|
1568
1575
|
frontend_notifications_allread: frontend_notifications_allread,
|
|
1569
1576
|
frontend_notifications_allread_message: frontend_notifications_allread_message,
|
|
1570
1577
|
frontend_profile: frontend_profile,
|
|
1578
|
+
switch_space: switch_space,
|
|
1571
1579
|
frontend_about: frontend_about,
|
|
1572
1580
|
frontend_log_out: frontend_log_out,
|
|
1573
1581
|
frontend_listview_warning_start: frontend_listview_warning_start,
|
|
@@ -2087,9 +2095,13 @@ async function getTableColumns(fields, options){
|
|
|
2087
2095
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
2088
2096
|
let className = "";
|
|
2089
2097
|
if(field.wrap != true){
|
|
2090
|
-
|
|
2098
|
+
if(field.wrap != false && field.is_wide){
|
|
2099
|
+
className += " break-words ";
|
|
2100
|
+
}else {
|
|
2101
|
+
className += " whitespace-nowrap ";
|
|
2102
|
+
}
|
|
2091
2103
|
}else {
|
|
2092
|
-
className += " break-
|
|
2104
|
+
className += " break-words ";
|
|
2093
2105
|
}
|
|
2094
2106
|
let columnItem;
|
|
2095
2107
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
@@ -2186,12 +2198,24 @@ async function getTableColumns(fields, options){
|
|
|
2186
2198
|
if(field.type === 'textarea'){
|
|
2187
2199
|
className += 'min-w-56';
|
|
2188
2200
|
}
|
|
2189
|
-
if(field.type === 'date'){
|
|
2190
|
-
|
|
2191
|
-
}
|
|
2192
|
-
if(field.type === 'datetime'){
|
|
2193
|
-
|
|
2201
|
+
// if(field.type === 'date'){
|
|
2202
|
+
// className += 'date-min-w';
|
|
2203
|
+
// }
|
|
2204
|
+
// if(field.type === 'datetime'){
|
|
2205
|
+
// className += 'datetime-min-w';
|
|
2206
|
+
// }
|
|
2207
|
+
|
|
2208
|
+
//field上的amis属性里的clssname需要单独判断类型合并
|
|
2209
|
+
if (typeof field.amis?.className == "object") {
|
|
2210
|
+
className = {
|
|
2211
|
+
[className]: "true",
|
|
2212
|
+
...field.amis.className
|
|
2213
|
+
};
|
|
2214
|
+
} else if (typeof field.amis?.className == "string") {
|
|
2215
|
+
className = `${className} ${field.amis.className} `;
|
|
2194
2216
|
}
|
|
2217
|
+
delete field.amis?.className;
|
|
2218
|
+
|
|
2195
2219
|
if(!field.hidden && !field.extra){
|
|
2196
2220
|
columnItem = Object.assign({}, {
|
|
2197
2221
|
name: field.name,
|
|
@@ -2274,7 +2298,7 @@ function getMobileLines(tpls){
|
|
|
2274
2298
|
}
|
|
2275
2299
|
if(isLeft){
|
|
2276
2300
|
// 左侧半行
|
|
2277
|
-
lineChildrenClassName = "steedos-listview-item-left truncate";
|
|
2301
|
+
lineChildrenClassName = "steedos-listview-item-left truncate h-5";
|
|
2278
2302
|
if(item.field.is_wide){
|
|
2279
2303
|
// 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
|
|
2280
2304
|
lineChildrenClassName = "steedos-listview-item-wide";
|
|
@@ -2286,14 +2310,26 @@ function getMobileLines(tpls){
|
|
|
2286
2310
|
}
|
|
2287
2311
|
else {
|
|
2288
2312
|
// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
2289
|
-
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
|
|
2313
|
+
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
|
|
2314
|
+
}
|
|
2315
|
+
//支持字段amis属性配置classname,识别classname的类型,与原样式合并
|
|
2316
|
+
var className;
|
|
2317
|
+
if (typeof item.field.amis?.className == "object") {
|
|
2318
|
+
className = {
|
|
2319
|
+
[lineChildrenClassName]: "true",
|
|
2320
|
+
...item.field.amis.className
|
|
2321
|
+
};
|
|
2322
|
+
} else if (typeof item.field.amis?.className == "string") {
|
|
2323
|
+
className = `${lineChildrenClassName} ${item.field.amis.className} `;
|
|
2324
|
+
} else {
|
|
2325
|
+
className = lineChildrenClassName;
|
|
2290
2326
|
}
|
|
2291
2327
|
lineChildren.push({
|
|
2292
2328
|
"type": "tpl",
|
|
2293
2329
|
"tpl": item.tpl,
|
|
2294
|
-
|
|
2330
|
+
className
|
|
2295
2331
|
});
|
|
2296
|
-
|
|
2332
|
+
|
|
2297
2333
|
if(item.field.is_wide){
|
|
2298
2334
|
// 宽字段占整行
|
|
2299
2335
|
isLeft = true;
|
|
@@ -2343,8 +2379,7 @@ async function getMobileTableColumns(fields, options){
|
|
|
2343
2379
|
tpl = await getFieldTpl(field, options);
|
|
2344
2380
|
}
|
|
2345
2381
|
if(!tpl){
|
|
2346
|
-
|
|
2347
|
-
tpl = `\${${field.name} | raw}`;
|
|
2382
|
+
tpl = `\${${field.name}}`;
|
|
2348
2383
|
}
|
|
2349
2384
|
if(!field.hidden && !field.extra){
|
|
2350
2385
|
tpls.push({ field, tpl });
|
|
@@ -2357,7 +2392,7 @@ async function getMobileTableColumns(fields, options){
|
|
|
2357
2392
|
|
|
2358
2393
|
let column = {
|
|
2359
2394
|
name: nameField.name,
|
|
2360
|
-
label: nameField.label,
|
|
2395
|
+
label: options.displayAs == 'split' ? '' : nameField.label,
|
|
2361
2396
|
sortable: nameField.sortable,
|
|
2362
2397
|
type: "button",
|
|
2363
2398
|
level: "link",
|
|
@@ -2386,7 +2421,15 @@ async function getMobileTableColumns(fields, options){
|
|
|
2386
2421
|
"actions": [
|
|
2387
2422
|
{
|
|
2388
2423
|
"script": `
|
|
2389
|
-
let cms_url =
|
|
2424
|
+
let cms_url = '';
|
|
2425
|
+
let value = event.data.versions[0];
|
|
2426
|
+
if(value){
|
|
2427
|
+
if(value.url){
|
|
2428
|
+
cms_url = value.url;
|
|
2429
|
+
}else{
|
|
2430
|
+
cms_url = "/api/files/files/"+value+"?download=true"
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2390
2433
|
Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
|
|
2391
2434
|
`,
|
|
2392
2435
|
"actionType": "custom"
|
|
@@ -2502,7 +2545,8 @@ async function getTableOperation(ctx){
|
|
|
2502
2545
|
label: " ",
|
|
2503
2546
|
fixed: 'right',
|
|
2504
2547
|
labelClassName: 'text-center',
|
|
2505
|
-
|
|
2548
|
+
//TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
|
|
2549
|
+
className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
|
|
2506
2550
|
buttons: [
|
|
2507
2551
|
{
|
|
2508
2552
|
"type": "steedos-dropdown-button",
|
|
@@ -2598,7 +2642,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2598
2642
|
}
|
|
2599
2643
|
return {
|
|
2600
2644
|
mode: "cards",
|
|
2601
|
-
perPageAvailable: [
|
|
2645
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2602
2646
|
name: "thelist",
|
|
2603
2647
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2604
2648
|
className: "",
|
|
@@ -2631,7 +2675,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2631
2675
|
|
|
2632
2676
|
return {
|
|
2633
2677
|
mode: "table",
|
|
2634
|
-
perPageAvailable: [
|
|
2678
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2635
2679
|
name: "thelist",
|
|
2636
2680
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2637
2681
|
className: "",
|
|
@@ -3017,6 +3061,16 @@ async function getTableApi(mainObject, fields, options){
|
|
|
3017
3061
|
}
|
|
3018
3062
|
// SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
3019
3063
|
};
|
|
3064
|
+
let formFactor = "${options.formFactor}";
|
|
3065
|
+
if(formFactor !== "SMALL"){
|
|
3066
|
+
const listviewComponent = $(".steedos-object-listview .antd-Table-table");
|
|
3067
|
+
const firstListviewComponent = listviewComponent && listviewComponent[0];
|
|
3068
|
+
if(firstListviewComponent){
|
|
3069
|
+
setTimeout(()=>{
|
|
3070
|
+
firstListviewComponent.scrollIntoView();
|
|
3071
|
+
}, 600);
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3020
3074
|
${options.adaptor || ''}
|
|
3021
3075
|
return payload;
|
|
3022
3076
|
`;
|
|
@@ -3128,12 +3182,21 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3128
3182
|
}
|
|
3129
3183
|
payload.data = data;
|
|
3130
3184
|
payload.data.__objectName = "${object.name}";
|
|
3131
|
-
payload.data.
|
|
3185
|
+
payload.data.record = record;
|
|
3186
|
+
|
|
3187
|
+
payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
|
|
3188
|
+
payload.data._master = {
|
|
3189
|
+
record: record,
|
|
3190
|
+
objectName: "${object.name}",
|
|
3191
|
+
recordId: record._id
|
|
3192
|
+
}
|
|
3132
3193
|
window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
|
|
3133
3194
|
}
|
|
3134
3195
|
if(payload.errors){
|
|
3135
3196
|
payload.status = 2;
|
|
3136
3197
|
payload.msg = payload.errors[0].message;
|
|
3198
|
+
}else{
|
|
3199
|
+
payload.data.recordLoaded = true;
|
|
3137
3200
|
}
|
|
3138
3201
|
${options && options.initApiAdaptor || ''}
|
|
3139
3202
|
return payload;
|
|
@@ -3276,7 +3339,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3276
3339
|
cache: API_CACHE,
|
|
3277
3340
|
requestAdaptor: `
|
|
3278
3341
|
// 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
|
|
3279
|
-
var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
|
|
3342
|
+
var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
|
|
3280
3343
|
if(!recordId){
|
|
3281
3344
|
// 新建则不请求任何数据
|
|
3282
3345
|
data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
|
|
@@ -3354,10 +3417,11 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3354
3417
|
...initialValues
|
|
3355
3418
|
}
|
|
3356
3419
|
${options.initApiAdaptor || ''}
|
|
3420
|
+
// console.log('getEditFormInitApi======>', payload);
|
|
3357
3421
|
return payload;
|
|
3358
3422
|
`,
|
|
3359
3423
|
responseData: {
|
|
3360
|
-
|
|
3424
|
+
"&": "$$",
|
|
3361
3425
|
editFormInited: true
|
|
3362
3426
|
},
|
|
3363
3427
|
data: data,
|
|
@@ -3396,6 +3460,18 @@ function getBatchDelete(objectName){
|
|
|
3396
3460
|
return {
|
|
3397
3461
|
method: 'post',
|
|
3398
3462
|
url: getApi$2(),
|
|
3463
|
+
adaptor: `
|
|
3464
|
+
if(payload.errors){
|
|
3465
|
+
payload.data.deleteErrorMessage = [];
|
|
3466
|
+
payload.errors.forEach(function(error){
|
|
3467
|
+
let errorRecord = error.path.map(function (item) {
|
|
3468
|
+
return item.split('delete__')[1].to_float() + 1;
|
|
3469
|
+
}).toString();
|
|
3470
|
+
payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
|
|
3471
|
+
})
|
|
3472
|
+
}
|
|
3473
|
+
return payload;
|
|
3474
|
+
`,
|
|
3399
3475
|
requestAdaptor: `
|
|
3400
3476
|
var ids = api.data.ids.split(",");
|
|
3401
3477
|
var deleteArray = [];
|
|
@@ -4190,7 +4266,7 @@ async function getListBody(fields, options){
|
|
|
4190
4266
|
|
|
4191
4267
|
function getDefaultParams(options){
|
|
4192
4268
|
return {
|
|
4193
|
-
perPage: options.top || options.perPage ||
|
|
4269
|
+
perPage: options.top || options.perPage || 20
|
|
4194
4270
|
}
|
|
4195
4271
|
}
|
|
4196
4272
|
|
|
@@ -4393,7 +4469,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
4393
4469
|
"objectApiName": "\${objectName}",
|
|
4394
4470
|
"recordId": "",
|
|
4395
4471
|
"mode": "edit",
|
|
4396
|
-
"layout": "normal"
|
|
4397
4472
|
};
|
|
4398
4473
|
|
|
4399
4474
|
if (payload && payload.schema) {
|
|
@@ -5098,7 +5173,7 @@ const StandardButtons = {
|
|
|
5098
5173
|
}
|
|
5099
5174
|
};
|
|
5100
5175
|
|
|
5101
|
-
const getGlobalData
|
|
5176
|
+
const getGlobalData = () => {
|
|
5102
5177
|
return {
|
|
5103
5178
|
now: new Date(),
|
|
5104
5179
|
};
|
|
@@ -5157,7 +5232,7 @@ const getButtonVisible = (button, ctx) => {
|
|
|
5157
5232
|
button._visible,
|
|
5158
5233
|
props.record,
|
|
5159
5234
|
"#",
|
|
5160
|
-
getGlobalData
|
|
5235
|
+
getGlobalData(),
|
|
5161
5236
|
props.userSession
|
|
5162
5237
|
);
|
|
5163
5238
|
};
|
|
@@ -6535,6 +6610,48 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6535
6610
|
return headerSchema;
|
|
6536
6611
|
}
|
|
6537
6612
|
|
|
6613
|
+
function getBackButtonSchema(){
|
|
6614
|
+
return {
|
|
6615
|
+
"type": "service",
|
|
6616
|
+
"onEvent": {
|
|
6617
|
+
"@history_paths.changed": {
|
|
6618
|
+
"actions": [
|
|
6619
|
+
{
|
|
6620
|
+
"actionType": "reload",
|
|
6621
|
+
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6622
|
+
"data": {
|
|
6623
|
+
}
|
|
6624
|
+
}
|
|
6625
|
+
]
|
|
6626
|
+
}
|
|
6627
|
+
},
|
|
6628
|
+
"body":[{
|
|
6629
|
+
"type": "button",
|
|
6630
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6631
|
+
"className":"flex mr-4",
|
|
6632
|
+
"onEvent": {
|
|
6633
|
+
"click": {
|
|
6634
|
+
"actions": [
|
|
6635
|
+
{
|
|
6636
|
+
"actionType": "custom",
|
|
6637
|
+
"script": "window.goBack()"
|
|
6638
|
+
}
|
|
6639
|
+
]
|
|
6640
|
+
}
|
|
6641
|
+
},
|
|
6642
|
+
"body": [
|
|
6643
|
+
{
|
|
6644
|
+
"type": "steedos-icon",
|
|
6645
|
+
"category": "utility",
|
|
6646
|
+
"name": "back",
|
|
6647
|
+
"colorVariant": "default",
|
|
6648
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6649
|
+
}
|
|
6650
|
+
]
|
|
6651
|
+
}]
|
|
6652
|
+
}
|
|
6653
|
+
}
|
|
6654
|
+
|
|
6538
6655
|
/**
|
|
6539
6656
|
* 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
|
|
6540
6657
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -6543,11 +6660,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6543
6660
|
* @returns amisSchema
|
|
6544
6661
|
*/
|
|
6545
6662
|
async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
6663
|
+
// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
6546
6664
|
const { showRecordTitle = true } = options || {};
|
|
6547
6665
|
// console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
|
|
6548
6666
|
const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
|
|
6549
6667
|
|
|
6550
|
-
let amisButtonsSchema =
|
|
6668
|
+
let amisButtonsSchema = [];
|
|
6669
|
+
if(options.showButtons != false){
|
|
6670
|
+
amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
|
|
6671
|
+
}
|
|
6672
|
+
|
|
6673
|
+
let backButtonsSchema = null;
|
|
6674
|
+
|
|
6675
|
+
if(options.showBackButton != false){
|
|
6676
|
+
backButtonsSchema = getBackButtonSchema();
|
|
6677
|
+
}
|
|
6551
6678
|
|
|
6552
6679
|
// console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
|
|
6553
6680
|
|
|
@@ -6562,45 +6689,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6562
6689
|
"type": "grid",
|
|
6563
6690
|
"columns": [
|
|
6564
6691
|
{
|
|
6565
|
-
"body": [
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
"@history_paths.changed": {
|
|
6569
|
-
"actions": [
|
|
6570
|
-
{
|
|
6571
|
-
"actionType": "reload",
|
|
6572
|
-
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6573
|
-
"data": {
|
|
6574
|
-
}
|
|
6575
|
-
}
|
|
6576
|
-
]
|
|
6577
|
-
}
|
|
6578
|
-
},
|
|
6579
|
-
"body":[{
|
|
6580
|
-
"type": "button",
|
|
6581
|
-
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6582
|
-
"className":"flex mr-4",
|
|
6583
|
-
"onEvent": {
|
|
6584
|
-
"click": {
|
|
6585
|
-
"actions": [
|
|
6586
|
-
{
|
|
6587
|
-
"actionType": "custom",
|
|
6588
|
-
"script": "window.goBack()"
|
|
6589
|
-
}
|
|
6590
|
-
]
|
|
6591
|
-
}
|
|
6592
|
-
},
|
|
6593
|
-
"body": [
|
|
6594
|
-
{
|
|
6595
|
-
"type": "steedos-icon",
|
|
6596
|
-
"category": "utility",
|
|
6597
|
-
"name": "back",
|
|
6598
|
-
"colorVariant": "default",
|
|
6599
|
-
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6600
|
-
}
|
|
6601
|
-
]
|
|
6602
|
-
}]
|
|
6603
|
-
},{
|
|
6692
|
+
"body": [
|
|
6693
|
+
backButtonsSchema
|
|
6694
|
+
,{
|
|
6604
6695
|
"type": "tpl",
|
|
6605
6696
|
"className": "block",
|
|
6606
6697
|
// "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'>`
|
|
@@ -6621,8 +6712,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6621
6712
|
},
|
|
6622
6713
|
{
|
|
6623
6714
|
"type": "tpl",
|
|
6624
|
-
"tpl": "${
|
|
6625
|
-
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
6715
|
+
"tpl": "${NAME_FIELD_VALUE}",
|
|
6626
6716
|
"inline": false,
|
|
6627
6717
|
"wrapperComponent": "",
|
|
6628
6718
|
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
@@ -6650,7 +6740,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6650
6740
|
let body = [
|
|
6651
6741
|
{
|
|
6652
6742
|
"type": "wrapper",
|
|
6653
|
-
"className": "p-
|
|
6743
|
+
"className": "p-4 bg-gray-100 border-b",
|
|
6654
6744
|
"body": [
|
|
6655
6745
|
{
|
|
6656
6746
|
"type": "grid",
|
|
@@ -6665,7 +6755,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6665
6755
|
if(showRecordTitle){
|
|
6666
6756
|
body.push({
|
|
6667
6757
|
"type": "wrapper",
|
|
6668
|
-
"className": "p-
|
|
6758
|
+
"className": "p-4",
|
|
6669
6759
|
"body": [
|
|
6670
6760
|
{
|
|
6671
6761
|
"type": "grid",
|
|
@@ -6677,11 +6767,76 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6677
6767
|
});
|
|
6678
6768
|
}
|
|
6679
6769
|
|
|
6770
|
+
let max = 10;
|
|
6771
|
+
if(options.formFactor === 'SMALL'){
|
|
6772
|
+
max = 4;
|
|
6773
|
+
}else {
|
|
6774
|
+
|
|
6775
|
+
let divWidth = window.innerWidth;
|
|
6776
|
+
|
|
6777
|
+
if(options.display === 'split'){
|
|
6778
|
+
divWidth = divWidth - 388;
|
|
6779
|
+
}
|
|
6780
|
+
|
|
6781
|
+
if(document.body.classList.contains('sidebar')){
|
|
6782
|
+
divWidth = divWidth - 210;
|
|
6783
|
+
}
|
|
6784
|
+
|
|
6785
|
+
// 根据屏幕宽度计算显示数量, 使高亮字段只占1行
|
|
6786
|
+
max = Math.trunc(divWidth / 200 );
|
|
6787
|
+
if(max > 10){
|
|
6788
|
+
max = 10;
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6791
|
+
|
|
6792
|
+
// console.log('=======================max=========================', max)
|
|
6793
|
+
|
|
6794
|
+
if(objectSchema.compactLayouts){
|
|
6795
|
+
const details = [];
|
|
6796
|
+
_.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
|
|
6797
|
+
const field = objectSchema.fields[fieldName];
|
|
6798
|
+
if(field){
|
|
6799
|
+
details.push({
|
|
6800
|
+
type: 'steedos-field',
|
|
6801
|
+
static: true,
|
|
6802
|
+
config: field,
|
|
6803
|
+
});
|
|
6804
|
+
}
|
|
6805
|
+
});
|
|
6806
|
+
|
|
6807
|
+
// 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
|
|
6808
|
+
// lg:grid-cols-1
|
|
6809
|
+
// lg:grid-cols-2
|
|
6810
|
+
// lg:grid-cols-3
|
|
6811
|
+
// lg:grid-cols-4
|
|
6812
|
+
// lg:grid-cols-5
|
|
6813
|
+
// lg:grid-cols-6
|
|
6814
|
+
// lg:grid-cols-7
|
|
6815
|
+
// lg:grid-cols-8
|
|
6816
|
+
// lg:grid-cols-9
|
|
6817
|
+
// lg:grid-cols-10
|
|
6818
|
+
// lg:grid-cols-11
|
|
6819
|
+
// lg:grid-cols-12
|
|
6820
|
+
|
|
6821
|
+
body.push({
|
|
6822
|
+
"type": "wrapper",
|
|
6823
|
+
"body": {
|
|
6824
|
+
"type": "form",
|
|
6825
|
+
// "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
|
|
6826
|
+
"className": `gap-2 grid grid-cols-1 lg:grid-cols-${max}`,
|
|
6827
|
+
"wrapWithPanel": false,
|
|
6828
|
+
"actions": [],
|
|
6829
|
+
"body": details,
|
|
6830
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
6831
|
+
},
|
|
6832
|
+
"className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
|
|
6833
|
+
});
|
|
6834
|
+
}
|
|
6835
|
+
|
|
6680
6836
|
return {
|
|
6681
6837
|
type: 'service',
|
|
6682
6838
|
id: `page_readonly_${name}_header`,
|
|
6683
6839
|
name: `page`,
|
|
6684
|
-
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
6685
6840
|
body: body,
|
|
6686
6841
|
className: ''
|
|
6687
6842
|
}
|
|
@@ -6753,7 +6908,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
6753
6908
|
"className": "flex justify-between"
|
|
6754
6909
|
}
|
|
6755
6910
|
],
|
|
6756
|
-
"className": "
|
|
6911
|
+
"className": "steedos-record-related-header py-2 px-0"
|
|
6757
6912
|
};
|
|
6758
6913
|
return recordRelatedListHeader;
|
|
6759
6914
|
}
|
|
@@ -7738,14 +7893,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
7738
7893
|
{
|
|
7739
7894
|
"type": "button",
|
|
7740
7895
|
"label": i18next__default["default"].t('frontend_display_type_is_table'),
|
|
7741
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7896
|
+
"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');",
|
|
7742
7897
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
7743
7898
|
"rightIconClassName": "m-l-sm"
|
|
7744
7899
|
},
|
|
7745
7900
|
{
|
|
7746
7901
|
"type": "button",
|
|
7747
7902
|
"label": i18next__default["default"].t('frontend_display_type_is_split'),
|
|
7748
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7903
|
+
"onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
7749
7904
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
7750
7905
|
"rightIconClassName": "m-l-sm"
|
|
7751
7906
|
}
|
|
@@ -7888,7 +8043,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7888
8043
|
{
|
|
7889
8044
|
"type": "search-box",
|
|
7890
8045
|
"name": keywordsSearchBoxName,
|
|
7891
|
-
"placeholder": "
|
|
8046
|
+
"placeholder": "快捷搜索",
|
|
7892
8047
|
"value": crudKeywords,
|
|
7893
8048
|
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7894
8049
|
"clearAndSubmit": true,
|
|
@@ -8092,7 +8247,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8092
8247
|
// ]
|
|
8093
8248
|
if(options.displayAs === 'split'){
|
|
8094
8249
|
return [
|
|
8095
|
-
|
|
8250
|
+
{
|
|
8251
|
+
"type": "switch-per-page",
|
|
8252
|
+
"visibleOn": "${count >= 20}"
|
|
8253
|
+
},
|
|
8096
8254
|
{
|
|
8097
8255
|
"type": "pagination",
|
|
8098
8256
|
"maxButtons": 5,
|
|
@@ -8114,7 +8272,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8114
8272
|
else {
|
|
8115
8273
|
if(options && options.isRelated){
|
|
8116
8274
|
return [
|
|
8117
|
-
"statistics",
|
|
8118
8275
|
{
|
|
8119
8276
|
"type": "pagination",
|
|
8120
8277
|
"maxButtons": 10,
|
|
@@ -8127,7 +8284,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8127
8284
|
const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
|
|
8128
8285
|
const is_lookup = options.isLookup;
|
|
8129
8286
|
const commonConfig = [
|
|
8130
|
-
"statistics",
|
|
8131
8287
|
{
|
|
8132
8288
|
"type": "pagination",
|
|
8133
8289
|
"maxButtons": 10,
|
|
@@ -8138,7 +8294,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8138
8294
|
if (no_pagination && is_lookup) {
|
|
8139
8295
|
return commonConfig;
|
|
8140
8296
|
} else {
|
|
8141
|
-
return [
|
|
8297
|
+
return [{
|
|
8298
|
+
"type": "switch-per-page",
|
|
8299
|
+
"visibleOn": "${count >= 20}"
|
|
8300
|
+
}, ...commonConfig];
|
|
8142
8301
|
}
|
|
8143
8302
|
}
|
|
8144
8303
|
}
|
|
@@ -8246,6 +8405,29 @@ function getBulkActions(objectSchema){
|
|
|
8246
8405
|
"className": "hidden",
|
|
8247
8406
|
"id": "batchDelete",
|
|
8248
8407
|
"api": getBatchDelete(objectSchema.name),
|
|
8408
|
+
"feedback": {
|
|
8409
|
+
"title": "删除警告",
|
|
8410
|
+
"visibleOn": "${deleteErrorMessage}",
|
|
8411
|
+
"body": [
|
|
8412
|
+
{
|
|
8413
|
+
"type": "each",
|
|
8414
|
+
"name": "deleteErrorMessage",
|
|
8415
|
+
"items": {
|
|
8416
|
+
"type": "alert",
|
|
8417
|
+
"body": "${item}",
|
|
8418
|
+
"level": "danger",
|
|
8419
|
+
"className": "mb-3"
|
|
8420
|
+
}
|
|
8421
|
+
}
|
|
8422
|
+
],
|
|
8423
|
+
"actions": [
|
|
8424
|
+
{
|
|
8425
|
+
"type": "button",
|
|
8426
|
+
"actionType": "close",
|
|
8427
|
+
"label": "关闭"
|
|
8428
|
+
}
|
|
8429
|
+
]
|
|
8430
|
+
}
|
|
8249
8431
|
}
|
|
8250
8432
|
// {
|
|
8251
8433
|
// "label": "批量修改",
|
|
@@ -8392,6 +8574,10 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8392
8574
|
const rowsDiff = _.cloneDeep(api.data.rowsDiff);
|
|
8393
8575
|
rowsDiff.forEach(function (item, index) {
|
|
8394
8576
|
for(key in item){
|
|
8577
|
+
// image、select等字段清空值后保存的空字符串转换为null。
|
|
8578
|
+
if(item[key] === ''){
|
|
8579
|
+
item[key] = null;
|
|
8580
|
+
}
|
|
8395
8581
|
if(_.includes(imageNames, key)){
|
|
8396
8582
|
if(typeof item[key] == "string"){
|
|
8397
8583
|
const match = item[key].match(/\\/([^\\/]+)$/);
|
|
@@ -8438,7 +8624,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8438
8624
|
// "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8439
8625
|
// },
|
|
8440
8626
|
bodyClassName: {
|
|
8441
|
-
"
|
|
8627
|
+
"mb-0": true,
|
|
8442
8628
|
"is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8443
8629
|
},
|
|
8444
8630
|
crudClassName: crudClassName,
|
|
@@ -8458,7 +8644,9 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8458
8644
|
return payload;
|
|
8459
8645
|
`
|
|
8460
8646
|
},
|
|
8461
|
-
rowClassNameExpr
|
|
8647
|
+
// 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
|
|
8648
|
+
// 使用表达式给tr添加初始选中状态
|
|
8649
|
+
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 %>"
|
|
8462
8650
|
}, bodyProps);
|
|
8463
8651
|
|
|
8464
8652
|
}
|
|
@@ -8473,7 +8661,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8473
8661
|
|
|
8474
8662
|
if(body.columns && options.formFactor != 'SMALL'){
|
|
8475
8663
|
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8476
|
-
body.columns.splice(body.columns.length -
|
|
8664
|
+
body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
|
|
8477
8665
|
}
|
|
8478
8666
|
|
|
8479
8667
|
if (defaults) {
|
|
@@ -8531,11 +8719,6 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8531
8719
|
}
|
|
8532
8720
|
}
|
|
8533
8721
|
|
|
8534
|
-
const getGlobalData = (mode)=>{
|
|
8535
|
-
const user = getSteedosAuth();
|
|
8536
|
-
return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
|
|
8537
|
-
};
|
|
8538
|
-
|
|
8539
8722
|
const getFormFields$1 = (objectSchema, formProps)=>{
|
|
8540
8723
|
/**
|
|
8541
8724
|
* fieldsExtend: 重写字段定义
|
|
@@ -8597,7 +8780,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
|
|
|
8597
8780
|
}
|
|
8598
8781
|
|
|
8599
8782
|
async function getObjectForm(objectSchema, ctx){
|
|
8600
|
-
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8783
|
+
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
|
|
8601
8784
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8602
8785
|
const fields = ___default["default"].values(objectSchema.fields);
|
|
8603
8786
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8613,9 +8796,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8613
8796
|
id: `service_${formSchema.id}`,
|
|
8614
8797
|
className: 'p-0',
|
|
8615
8798
|
name: `page_edit_${recordId}`,
|
|
8616
|
-
api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8617
8799
|
data:{
|
|
8618
|
-
editFormInited: false,
|
|
8619
8800
|
...amisData
|
|
8620
8801
|
},
|
|
8621
8802
|
// data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
@@ -8624,8 +8805,9 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8624
8805
|
body: [defaultsDeep({}, formSchema, {
|
|
8625
8806
|
type: "form",
|
|
8626
8807
|
mode: layout,
|
|
8808
|
+
initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8627
8809
|
data: {
|
|
8628
|
-
|
|
8810
|
+
editFormInited: false,
|
|
8629
8811
|
},
|
|
8630
8812
|
labelAlign,
|
|
8631
8813
|
persistData: false,
|
|
@@ -8639,11 +8821,15 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8639
8821
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
8640
8822
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
8641
8823
|
initFetch: recordId != 'new',
|
|
8642
|
-
body:
|
|
8824
|
+
body: {
|
|
8825
|
+
type: 'wrapper',
|
|
8826
|
+
className: 'p-0 m-0',
|
|
8827
|
+
body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
|
|
8828
|
+
hiddenOn: "${editFormInited != true}",
|
|
8829
|
+
},
|
|
8643
8830
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
8644
8831
|
bodyClassName: 'p-0',
|
|
8645
8832
|
className: 'steedos-amis-form',
|
|
8646
|
-
hiddenOn: "${editFormInited != true}",
|
|
8647
8833
|
onEvent: {
|
|
8648
8834
|
"submitSucc": {
|
|
8649
8835
|
"weight": 0,
|
|
@@ -8688,7 +8874,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8688
8874
|
}
|
|
8689
8875
|
|
|
8690
8876
|
async function getObjectDetail(objectSchema, recordId, ctx){
|
|
8691
|
-
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8877
|
+
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
|
|
8692
8878
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8693
8879
|
const fields = ___default["default"].values(objectSchema.fields);
|
|
8694
8880
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8697,8 +8883,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8697
8883
|
type: 'service',
|
|
8698
8884
|
name: `page_readonly_${recordId}`,
|
|
8699
8885
|
id: serviceId,
|
|
8700
|
-
|
|
8701
|
-
api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8886
|
+
// api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8702
8887
|
body: [
|
|
8703
8888
|
{
|
|
8704
8889
|
"type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
|
|
@@ -8724,60 +8909,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8724
8909
|
),
|
|
8725
8910
|
className: 'steedos-amis-form bg-white',
|
|
8726
8911
|
actions: [], // 不显示表单默认的提交按钮
|
|
8727
|
-
onEvent: {
|
|
8728
|
-
[`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
|
|
8729
|
-
"actions": [
|
|
8730
|
-
{
|
|
8731
|
-
"actionType": "reload",
|
|
8732
|
-
"componentId": serviceId,
|
|
8733
|
-
"expression": "this.__deletedRecord != true"
|
|
8734
|
-
},
|
|
8735
|
-
{
|
|
8736
|
-
// "args": {
|
|
8737
|
-
// "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
|
|
8738
|
-
// "blank": false
|
|
8739
|
-
// },
|
|
8740
|
-
"actionType": "custom",
|
|
8741
|
-
"script": "window.goBack()",
|
|
8742
|
-
"expression": "this.__deletedRecord === true"
|
|
8743
|
-
}
|
|
8744
|
-
]
|
|
8745
|
-
}
|
|
8746
|
-
}
|
|
8747
8912
|
},
|
|
8748
8913
|
}
|
|
8749
8914
|
],
|
|
8750
|
-
onEvent: {
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
|
|
8776
|
-
|
|
8777
|
-
}
|
|
8915
|
+
// onEvent: {
|
|
8916
|
+
// "fetchInited": {
|
|
8917
|
+
// "weight": 0,
|
|
8918
|
+
// "actions": [
|
|
8919
|
+
// {
|
|
8920
|
+
// actionType: 'broadcast',
|
|
8921
|
+
// eventName: "recordLoaded",
|
|
8922
|
+
// args: {
|
|
8923
|
+
// eventName: "recordLoaded"
|
|
8924
|
+
// },
|
|
8925
|
+
// data: {
|
|
8926
|
+
// objectName: "${event.data.__objectName}",
|
|
8927
|
+
// record: "${event.data.__record}"
|
|
8928
|
+
// },
|
|
8929
|
+
// expression: "${event.data.__response.error != true}"
|
|
8930
|
+
// },
|
|
8931
|
+
// {
|
|
8932
|
+
// "actionType": "setValue",
|
|
8933
|
+
// "args": {
|
|
8934
|
+
// value: {
|
|
8935
|
+
// "recordLoaded": true,
|
|
8936
|
+
// }
|
|
8937
|
+
// },
|
|
8938
|
+
// expression: "${event.data.__response.error != true}"
|
|
8939
|
+
// }
|
|
8940
|
+
// ]
|
|
8941
|
+
// }
|
|
8942
|
+
// }
|
|
8778
8943
|
};
|
|
8779
8944
|
|
|
8780
8945
|
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
8946
|
+
// console.log('getObjectDetail=====>', amisSchema);
|
|
8781
8947
|
return amisSchema;
|
|
8782
8948
|
}
|
|
8783
8949
|
|
|
@@ -8857,8 +9023,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
8857
9023
|
/*
|
|
8858
9024
|
* @Author: baozhoutao@steedos.com
|
|
8859
9025
|
* @Date: 2022-07-05 15:55:39
|
|
8860
|
-
* @LastEditors:
|
|
8861
|
-
* @LastEditTime:
|
|
9026
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9027
|
+
* @LastEditTime: 2024-01-15 10:34:46
|
|
8862
9028
|
* @Description:
|
|
8863
9029
|
*/
|
|
8864
9030
|
|
|
@@ -9033,7 +9199,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9033
9199
|
setDataToComponentId: componentId,
|
|
9034
9200
|
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
9035
9201
|
appId: appId,
|
|
9036
|
-
crudClassName: '
|
|
9202
|
+
crudClassName: 'steedos-record-related-crud hidden',
|
|
9037
9203
|
refField,
|
|
9038
9204
|
...ctx
|
|
9039
9205
|
};
|
|
@@ -9046,7 +9212,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9046
9212
|
amisSchema: {
|
|
9047
9213
|
type: "service",
|
|
9048
9214
|
id: componentId,
|
|
9049
|
-
className: `steedos-record-related-list
|
|
9215
|
+
className: `steedos-record-related-list py-2 first:pt-0 border-b last:border-b-0 ${componentId} ${className}`,
|
|
9050
9216
|
data: {
|
|
9051
9217
|
relatedKey: relatedKey,
|
|
9052
9218
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
@@ -9238,11 +9404,44 @@ async function getRelatedListSchema(
|
|
|
9238
9404
|
};
|
|
9239
9405
|
}
|
|
9240
9406
|
|
|
9407
|
+
async function getObjectRelatedListsMiniSchema(objectApiName){
|
|
9408
|
+
const relatedLists = await getObjectRelatedList(objectApiName);
|
|
9409
|
+
|
|
9410
|
+
const relatedListsMiniSchema = [];
|
|
9411
|
+
|
|
9412
|
+
for (const relatedList of relatedLists) {
|
|
9413
|
+
relatedListsMiniSchema.push(
|
|
9414
|
+
{
|
|
9415
|
+
type: 'steedos-record-detail-list-mini',
|
|
9416
|
+
objectApiName: objectApiName,
|
|
9417
|
+
// recordId: recordId,
|
|
9418
|
+
formFactor: formFactor,
|
|
9419
|
+
relatedObjectApiName: relatedList.object_name,
|
|
9420
|
+
foreign_key: relatedList.foreign_key,
|
|
9421
|
+
relatedKey: relatedList.foreign_key,
|
|
9422
|
+
columns: relatedList.columns,
|
|
9423
|
+
sort: relatedList.sort,
|
|
9424
|
+
filters: relatedList.filters,
|
|
9425
|
+
visible_on: relatedList.visible_on,
|
|
9426
|
+
perPage: relatedList.page_size || perPage,
|
|
9427
|
+
hiddenEmptyTable: true,
|
|
9428
|
+
relatedLabel: relatedList.label
|
|
9429
|
+
}
|
|
9430
|
+
);
|
|
9431
|
+
}
|
|
9432
|
+
|
|
9433
|
+
return {
|
|
9434
|
+
type: 'wrapper',
|
|
9435
|
+
className: "steedos-record-detail-related-lists-mini",
|
|
9436
|
+
body: relatedListsMiniSchema
|
|
9437
|
+
}
|
|
9438
|
+
}
|
|
9439
|
+
|
|
9241
9440
|
/*
|
|
9242
9441
|
* @Author: baozhoutao@steedos.com
|
|
9243
9442
|
* @Date: 2022-07-05 15:55:39
|
|
9244
|
-
* @LastEditors:
|
|
9245
|
-
* @LastEditTime:
|
|
9443
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9444
|
+
* @LastEditTime: 2024-01-16 11:14:34
|
|
9246
9445
|
* @Description:
|
|
9247
9446
|
*/
|
|
9248
9447
|
|
|
@@ -9414,7 +9613,7 @@ async function getField(objectName, fieldName) {
|
|
|
9414
9613
|
async function getFormSchema(objectName, ctx) {
|
|
9415
9614
|
const uiSchema = await getUISchema(objectName);
|
|
9416
9615
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
9417
|
-
console.log(`getFormSchema====>`, amisSchema)
|
|
9616
|
+
// console.log(`getFormSchema====>`, amisSchema)
|
|
9418
9617
|
return {
|
|
9419
9618
|
uiSchema,
|
|
9420
9619
|
amisSchema,
|
|
@@ -9740,110 +9939,164 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9740
9939
|
"label": "对象表单",
|
|
9741
9940
|
"objectApiName": "${objectName}",
|
|
9742
9941
|
"recordId": "${recordId}",
|
|
9743
|
-
"id": "u:d4a495811d57",
|
|
9744
9942
|
appId: appId
|
|
9745
9943
|
}
|
|
9746
9944
|
],
|
|
9747
|
-
"id": "u:5d4e7e3f6ecc"
|
|
9748
9945
|
};
|
|
9749
9946
|
const related = {
|
|
9750
9947
|
"title": i18next__default["default"].t('frontend_record_detail_tab_related'),
|
|
9751
|
-
"className": "px-0
|
|
9948
|
+
"className": "px-0 py-4",
|
|
9752
9949
|
"body": [
|
|
9753
9950
|
{
|
|
9754
9951
|
"type": "steedos-object-related-lists",
|
|
9755
9952
|
"label": "相关列表",
|
|
9756
9953
|
"objectApiName": "${objectName}",
|
|
9757
9954
|
"recordId": "${recordId}",
|
|
9758
|
-
"id": "u:3b85b7b7a7f6",
|
|
9759
9955
|
appId: appId
|
|
9760
9956
|
}
|
|
9761
9957
|
],
|
|
9762
|
-
"id": "u:1a0326aeec2b"
|
|
9763
9958
|
};
|
|
9764
9959
|
const content = {
|
|
9765
9960
|
"type": "tabs",
|
|
9766
|
-
"className": "
|
|
9961
|
+
"className": "steedos-record-tabs bg-white p-4 m-0 mt-2 border-y",
|
|
9962
|
+
"contentClassName": "bg-none",
|
|
9767
9963
|
"tabs": [
|
|
9768
9964
|
detailed
|
|
9769
9965
|
],
|
|
9770
|
-
"id": "u:a649e4094a12"
|
|
9771
9966
|
};
|
|
9772
9967
|
if(relatedLists.length){
|
|
9773
9968
|
content.tabs.push(related);
|
|
9774
9969
|
}
|
|
9970
|
+
// content.tabs = reverse(content.tabs)
|
|
9775
9971
|
return {
|
|
9776
9972
|
uiSchema,
|
|
9777
9973
|
amisSchema: {
|
|
9778
|
-
"type": "service",
|
|
9974
|
+
"type": "steedos-record-service",
|
|
9779
9975
|
"body": [
|
|
9780
9976
|
{
|
|
9781
9977
|
"type": "steedos-record-detail-header",
|
|
9782
9978
|
"label": "标题面板",
|
|
9783
9979
|
"objectApiName": "${objectName}",
|
|
9784
9980
|
"recordId": "${recordId}",
|
|
9785
|
-
"id": "u:48d2c28eb755"
|
|
9981
|
+
"id": "u:48d2c28eb755",
|
|
9982
|
+
"showButtons": props.showButtons,
|
|
9983
|
+
"showBackButton": props.showBackButton,
|
|
9786
9984
|
},
|
|
9787
9985
|
content
|
|
9788
9986
|
],
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
},
|
|
9793
|
-
onEvent: {
|
|
9794
|
-
"recordLoaded": {
|
|
9795
|
-
"actions": [
|
|
9796
|
-
{
|
|
9797
|
-
"actionType": "reload",
|
|
9798
|
-
"data": {
|
|
9799
|
-
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
9800
|
-
"_master.record": `\${record}`,
|
|
9801
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
9802
|
-
"_master.objectName": "${objectName}",
|
|
9803
|
-
"_master.recordId": "${recordId}"
|
|
9804
|
-
}
|
|
9805
|
-
}
|
|
9806
|
-
]
|
|
9807
|
-
},
|
|
9808
|
-
...props.onEvent
|
|
9809
|
-
},
|
|
9987
|
+
"objectApiName": "${objectName}",
|
|
9988
|
+
"recordId": "${recordId}",
|
|
9989
|
+
onEvent: props.onEvent,
|
|
9810
9990
|
}
|
|
9811
9991
|
}
|
|
9812
9992
|
}
|
|
9813
9993
|
|
|
9814
|
-
async function getRecordServiceSchema(objectName, appId, props = {}) {
|
|
9994
|
+
async function getRecordServiceSchema(objectName, appId, props = {}, body) {
|
|
9815
9995
|
const uiSchema = await getUISchema(objectName);
|
|
9996
|
+
const fields = ___default["default"].values(uiSchema.fields);
|
|
9997
|
+
const serviceId = `u:steedos-record-service-${objectName}`;
|
|
9816
9998
|
return {
|
|
9817
9999
|
uiSchema,
|
|
9818
10000
|
amisSchema: {
|
|
9819
|
-
|
|
9820
|
-
"
|
|
9821
|
-
data: {
|
|
9822
|
-
"_master.objectName": "${objectName}",
|
|
9823
|
-
"_master.recordId": "${recordId}"
|
|
9824
|
-
},
|
|
9825
|
-
"style": {
|
|
9826
|
-
"padding": "var(--Page-body-padding)",
|
|
9827
|
-
...props.style
|
|
9828
|
-
},
|
|
10001
|
+
type: 'service',
|
|
10002
|
+
className: "p-0 m-0",
|
|
9829
10003
|
onEvent: {
|
|
9830
|
-
|
|
10004
|
+
[`@data.changed.${objectName}`]: {
|
|
9831
10005
|
"actions": [
|
|
9832
10006
|
{
|
|
9833
10007
|
"actionType": "reload",
|
|
9834
|
-
"
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
10008
|
+
"componentId": serviceId,
|
|
10009
|
+
"expression": "this.__deletedRecord != true"
|
|
10010
|
+
},
|
|
10011
|
+
{
|
|
10012
|
+
"actionType": "custom",
|
|
10013
|
+
"script": "window.goBack()",
|
|
10014
|
+
"expression": "this.__deletedRecord === true"
|
|
9841
10015
|
}
|
|
9842
10016
|
]
|
|
9843
10017
|
},
|
|
9844
|
-
|
|
10018
|
+
},
|
|
10019
|
+
body: {
|
|
10020
|
+
"type": "service",
|
|
10021
|
+
id: serviceId,
|
|
10022
|
+
className: 'steedos-record-service p-0',
|
|
10023
|
+
api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
10024
|
+
body: {
|
|
10025
|
+
"type": "wrapper",
|
|
10026
|
+
"className": "p-0 m-0",
|
|
10027
|
+
"body": body || [],
|
|
10028
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
10029
|
+
},
|
|
10030
|
+
data: {
|
|
10031
|
+
"_master.objectName": "${objectName}",
|
|
10032
|
+
"_master.recordId": "${recordId}",
|
|
10033
|
+
...(props.data || {})
|
|
10034
|
+
},
|
|
10035
|
+
"style": {
|
|
10036
|
+
// "padding": "var(--Page-body-padding)",
|
|
10037
|
+
...props.style
|
|
10038
|
+
},
|
|
10039
|
+
onEvent: {
|
|
10040
|
+
// 如果定义了fetchInited,则无法接收到广播事件@data.changed
|
|
10041
|
+
"fetchInited": {
|
|
10042
|
+
"weight": 0,
|
|
10043
|
+
"actions": [
|
|
10044
|
+
{
|
|
10045
|
+
actionType: 'broadcast',
|
|
10046
|
+
eventName: "recordLoaded",
|
|
10047
|
+
data: {
|
|
10048
|
+
objectName: "${event.data.__objectName}",
|
|
10049
|
+
record: "${event.data.record}"
|
|
10050
|
+
},
|
|
10051
|
+
expression: "${event.data.__response.error != true}"
|
|
10052
|
+
},
|
|
10053
|
+
]
|
|
10054
|
+
},
|
|
10055
|
+
...props.onEvent
|
|
10056
|
+
}
|
|
9845
10057
|
}
|
|
9846
10058
|
}
|
|
10059
|
+
|
|
10060
|
+
|
|
10061
|
+
}
|
|
10062
|
+
}
|
|
10063
|
+
|
|
10064
|
+
async function getRecordDetailMiniSchema(objectName, appId, props = {}){
|
|
10065
|
+
const uiSchema = await getUISchema(objectName);
|
|
10066
|
+
const fields = ___default["default"].values(uiSchema.fields);
|
|
10067
|
+
|
|
10068
|
+
props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
|
|
10069
|
+
|
|
10070
|
+
// TODO 处理相关表
|
|
10071
|
+
// getObjectRelatedListsMiniSchema
|
|
10072
|
+
|
|
10073
|
+
return {
|
|
10074
|
+
type: "form",
|
|
10075
|
+
wrapWithPanel: false,
|
|
10076
|
+
actions: [],
|
|
10077
|
+
initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
10078
|
+
body: {
|
|
10079
|
+
"type": "wrapper",
|
|
10080
|
+
"className": "p-0 m-0",
|
|
10081
|
+
"body": [
|
|
10082
|
+
{
|
|
10083
|
+
"type": "steedos-record-detail-header",
|
|
10084
|
+
"showButtons": false,
|
|
10085
|
+
"showBackButton": false,
|
|
10086
|
+
"objectApiName": "${objectName}",
|
|
10087
|
+
"recordId": "${recordId}",
|
|
10088
|
+
},
|
|
10089
|
+
// {
|
|
10090
|
+
// "type": "steedos-object-related-lists",
|
|
10091
|
+
// "label": "相关列表",
|
|
10092
|
+
// "objectApiName": "${objectName}",
|
|
10093
|
+
// "staticRecordId": "${recordId}",
|
|
10094
|
+
// formFactor: "SMALL",
|
|
10095
|
+
// appId: appId
|
|
10096
|
+
// }
|
|
10097
|
+
],
|
|
10098
|
+
"hiddenOn": "${_finished != true}"
|
|
10099
|
+
}
|
|
9847
10100
|
}
|
|
9848
10101
|
}
|
|
9849
10102
|
|
|
@@ -10784,9 +11037,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10784
11037
|
*/
|
|
10785
11038
|
if(enable_tree){
|
|
10786
11039
|
const rows = _.map(payload.data.rows, (item)=>{
|
|
10787
|
-
|
|
10788
|
-
|
|
10789
|
-
|
|
11040
|
+
if (!item.children) {
|
|
11041
|
+
return { ...item, children: [] };
|
|
11042
|
+
} else {
|
|
11043
|
+
return item;
|
|
11044
|
+
}
|
|
10790
11045
|
})
|
|
10791
11046
|
payload.data.rows = rows;
|
|
10792
11047
|
}
|
|
@@ -11235,9 +11490,17 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
11235
11490
|
}
|
|
11236
11491
|
// console.log(`lookupToAmis====`, field, readonly, ctx)
|
|
11237
11492
|
if(readonly){
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
|
|
11493
|
+
if(field.reference_to){
|
|
11494
|
+
return {
|
|
11495
|
+
type: 'steedos-field',
|
|
11496
|
+
config: field,
|
|
11497
|
+
static: true
|
|
11498
|
+
}
|
|
11499
|
+
}else {
|
|
11500
|
+
return {
|
|
11501
|
+
type: getAmisStaticFieldType('picker', readonly),
|
|
11502
|
+
tpl: getRelatedFieldTpl(field, ctx)
|
|
11503
|
+
}
|
|
11241
11504
|
}
|
|
11242
11505
|
}
|
|
11243
11506
|
if(field.reference_to && !___namespace.isString(field.reference_to) && !readonly){
|
|
@@ -12231,11 +12494,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12231
12494
|
if(field.subFields){
|
|
12232
12495
|
convertData = {
|
|
12233
12496
|
type: 'steedos-input-table',
|
|
12234
|
-
showIndex: true,
|
|
12235
12497
|
editable: !readonly,
|
|
12236
12498
|
addable: !readonly,
|
|
12237
12499
|
removable: !readonly,
|
|
12238
|
-
draggable: !readonly,
|
|
12239
12500
|
fields: [],
|
|
12240
12501
|
amis:{
|
|
12241
12502
|
columnsTogglable: false
|
|
@@ -12287,7 +12548,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12287
12548
|
if(field.is_wide || convertData.type === 'group'){
|
|
12288
12549
|
convertData.className = 'col-span-2 m-0';
|
|
12289
12550
|
}else {
|
|
12290
|
-
convertData.className = 'm-
|
|
12551
|
+
convertData.className = 'm-0';
|
|
12291
12552
|
}
|
|
12292
12553
|
if(readonly){
|
|
12293
12554
|
convertData.className = `${convertData.className} border-b`;
|
|
@@ -12312,6 +12573,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12312
12573
|
}
|
|
12313
12574
|
}
|
|
12314
12575
|
|
|
12576
|
+
if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
|
|
12577
|
+
convertData.className = `${convertData.className || ''} hidden`;
|
|
12578
|
+
}
|
|
12579
|
+
|
|
12315
12580
|
if(___namespace.isString(baseData.required)){
|
|
12316
12581
|
if(baseData.required.startsWith("{{")){
|
|
12317
12582
|
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
@@ -12689,19 +12954,151 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12689
12954
|
return await getSections(permissionFields, formFields, ctx);
|
|
12690
12955
|
}
|
|
12691
12956
|
|
|
12957
|
+
/*
|
|
12958
|
+
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12959
|
+
* @Date: 2024-01-18 15:12:41
|
|
12960
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12961
|
+
* @LastEditTime: 2024-01-18 15:12:49
|
|
12962
|
+
*/
|
|
12963
|
+
/**
|
|
12964
|
+
* 生成符合标准uuid格式的36位满足唯一性的随机串
|
|
12965
|
+
* @returns uuid
|
|
12966
|
+
*/
|
|
12967
|
+
function uuidv4() {
|
|
12968
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, c =>
|
|
12969
|
+
(c ^ window.crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
|
12970
|
+
);
|
|
12971
|
+
}
|
|
12972
|
+
|
|
12692
12973
|
/*
|
|
12693
12974
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12694
12975
|
* @Date: 2023-11-15 09:50:22
|
|
12695
|
-
* @LastEditors:
|
|
12696
|
-
* @LastEditTime: 2024-01-
|
|
12976
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12977
|
+
* @LastEditTime: 2024-01-21 23:40:13
|
|
12978
|
+
*/
|
|
12979
|
+
|
|
12980
|
+
function getTablePrimaryKey(props){
|
|
12981
|
+
return props.primaryKey || "_id";
|
|
12982
|
+
}
|
|
12983
|
+
|
|
12984
|
+
/**
|
|
12985
|
+
* 子表组件字段值中每行数据的补上唯一标识字段值,其值为随机uuid
|
|
12986
|
+
* @param {*} value 子表组件字段值,数组
|
|
12987
|
+
* @param {*} primaryKey 主键字段名,一般为_id
|
|
12988
|
+
* @returns 转换后的子表组件字段值
|
|
12989
|
+
*/
|
|
12990
|
+
function getTableValueWithPrimaryKeyValue(value, primaryKey){
|
|
12991
|
+
if(!primaryKey){
|
|
12992
|
+
return value;
|
|
12993
|
+
}
|
|
12994
|
+
return (value || []).map((itemValue)=>{
|
|
12995
|
+
//这里不clone的话,会造成在pipeIn函数执行该函数后像pipeOut一样最终输出到表单项中,即库里把primaryKey字段值保存了
|
|
12996
|
+
const newItemValue = _$1.clone(itemValue);
|
|
12997
|
+
if(newItemValue[primaryKey]){
|
|
12998
|
+
if(newItemValue.children){
|
|
12999
|
+
newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13000
|
+
}
|
|
13001
|
+
return newItemValue;
|
|
13002
|
+
}
|
|
13003
|
+
else {
|
|
13004
|
+
newItemValue[primaryKey] = uuidv4();
|
|
13005
|
+
if(newItemValue.children){
|
|
13006
|
+
newItemValue.children = getTableValueWithPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13007
|
+
}
|
|
13008
|
+
return newItemValue;
|
|
13009
|
+
}
|
|
13010
|
+
});
|
|
13011
|
+
}
|
|
13012
|
+
|
|
13013
|
+
/**
|
|
13014
|
+
* 子表组件字段值中每行数据的移除唯一标识字段值,因为该字段值一般只作临时标记,不存库
|
|
13015
|
+
* @param {*} value 子表组件字段值,数组
|
|
13016
|
+
* @param {*} primaryKey 主键字段名,一般为_id
|
|
13017
|
+
* @returns 转换后的子表组件字段值
|
|
13018
|
+
*/
|
|
13019
|
+
function getTableValueWithoutPrimaryKeyValue(value, primaryKey){
|
|
13020
|
+
if(!primaryKey){
|
|
13021
|
+
return value;
|
|
13022
|
+
}
|
|
13023
|
+
return (value || []).map((itemValue)=>{
|
|
13024
|
+
//这里clone只是为了保险,不是必须的,每次修改子表数据是否都会生成新的primaryKey字段值是由pipeOut中识别autoGeneratePrimaryKeyValue决定的,跟这里没关系
|
|
13025
|
+
const newItemValue = _$1.clone(itemValue);
|
|
13026
|
+
if(newItemValue.children){
|
|
13027
|
+
newItemValue.children = getTableValueWithoutPrimaryKeyValue(newItemValue.children, primaryKey);
|
|
13028
|
+
}
|
|
13029
|
+
delete newItemValue[primaryKey];
|
|
13030
|
+
return newItemValue;
|
|
13031
|
+
});
|
|
13032
|
+
}
|
|
13033
|
+
|
|
13034
|
+
/**
|
|
13035
|
+
* 子表组件字段值中每行数据的键值key移除指定前缀
|
|
13036
|
+
* @param {*} value 子表组件字段值,数组
|
|
13037
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13038
|
+
* @returns 转换后的子表组件字段值
|
|
13039
|
+
*/
|
|
13040
|
+
function getTableValueWithoutFieldPrefix(value, fieldPrefix){
|
|
13041
|
+
let convertedValue = [];
|
|
13042
|
+
(value || []).forEach((itemValue)=>{
|
|
13043
|
+
var newItemValue = {};
|
|
13044
|
+
for(let n in itemValue){
|
|
13045
|
+
if(itemValue.hasOwnProperty(n)){
|
|
13046
|
+
newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
|
|
13047
|
+
}
|
|
13048
|
+
}
|
|
13049
|
+
convertedValue.push(newItemValue);
|
|
13050
|
+
});
|
|
13051
|
+
return convertedValue;
|
|
13052
|
+
}
|
|
13053
|
+
|
|
13054
|
+
/**
|
|
13055
|
+
* 子表组件字段值中每行数据的键值key补上指定前缀
|
|
13056
|
+
* @param {*} value 子表组件字段值,数组
|
|
13057
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13058
|
+
* @returns 转换后的子表组件字段值
|
|
13059
|
+
*/
|
|
13060
|
+
function getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey){
|
|
13061
|
+
let convertedValue = [];
|
|
13062
|
+
(value || []).forEach((itemValue)=>{
|
|
13063
|
+
var newItemValue = {};
|
|
13064
|
+
for(let n in itemValue){
|
|
13065
|
+
if(itemValue.hasOwnProperty(n) && typeof itemValue[n] !== undefined && n !== primaryKey){
|
|
13066
|
+
newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
|
|
13067
|
+
}
|
|
13068
|
+
}
|
|
13069
|
+
if(primaryKey && itemValue[primaryKey]){
|
|
13070
|
+
newItemValue[primaryKey] = itemValue[primaryKey];
|
|
13071
|
+
}
|
|
13072
|
+
convertedValue.push(newItemValue);
|
|
13073
|
+
});
|
|
13074
|
+
return convertedValue;
|
|
13075
|
+
}
|
|
13076
|
+
|
|
13077
|
+
/**
|
|
13078
|
+
* 子表组件字段集合属性中每个字段name移除指定前缀
|
|
13079
|
+
* @param {*} fields 子表组件字段集合,数组
|
|
13080
|
+
* @param {*} fieldPrefix 字段前缀
|
|
13081
|
+
* @returns 转换后的子表组件字段值
|
|
12697
13082
|
*/
|
|
13083
|
+
function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
|
|
13084
|
+
return (fields || []).map((item) => {
|
|
13085
|
+
const newItem = _$1.clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
|
|
13086
|
+
newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
|
|
13087
|
+
return newItem;
|
|
13088
|
+
});
|
|
13089
|
+
}
|
|
12698
13090
|
|
|
12699
13091
|
/**
|
|
12700
13092
|
* @param {*} props
|
|
12701
13093
|
* @param {*} mode edit/new/readonly
|
|
12702
13094
|
*/
|
|
12703
13095
|
function getFormFields(props, mode = "edit") {
|
|
12704
|
-
|
|
13096
|
+
let fieldPrefix = props.fieldPrefix;
|
|
13097
|
+
let fields = props.fields || [];
|
|
13098
|
+
if (fieldPrefix) {
|
|
13099
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
13100
|
+
}
|
|
13101
|
+
return (fields || []).map(function (item) {
|
|
12705
13102
|
let formItem = {
|
|
12706
13103
|
"type": "steedos-field",
|
|
12707
13104
|
"name": item.name,
|
|
@@ -12773,7 +13170,12 @@ async function getInputTableColumns(props) {
|
|
|
12773
13170
|
let inlineEditMode = props.inlineEditMode;
|
|
12774
13171
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
12775
13172
|
// 实测过,直接不生成对应的隐藏column并不会对input-table值造成丢失问题,隐藏的列字段值能正常维护
|
|
12776
|
-
|
|
13173
|
+
|
|
13174
|
+
let fieldPrefix = props.fieldPrefix;
|
|
13175
|
+
let fields = props.fields || [];
|
|
13176
|
+
if (fieldPrefix) {
|
|
13177
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
13178
|
+
}
|
|
12777
13179
|
if (columns && columns.length) {
|
|
12778
13180
|
return columns.map(function (column) {
|
|
12779
13181
|
let field, extendColumnProps = {};
|
|
@@ -12842,7 +13244,21 @@ function getFormPagination(props, mode) {
|
|
|
12842
13244
|
let currentIndex = event.data.index;
|
|
12843
13245
|
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12844
13246
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12845
|
-
|
|
13247
|
+
// 这里不clone的话,其值会带上__super属性
|
|
13248
|
+
currentFormValues = _.clone(currentFormValues);
|
|
13249
|
+
var parent = event.data.parent;
|
|
13250
|
+
var __parentIndex = event.data.__parentIndex;
|
|
13251
|
+
if(parent){
|
|
13252
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13253
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13254
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13255
|
+
children: fieldValue[__parentIndex].children,
|
|
13256
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13257
|
+
});
|
|
13258
|
+
}
|
|
13259
|
+
else{
|
|
13260
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13261
|
+
}
|
|
12846
13262
|
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
12847
13263
|
doAction({
|
|
12848
13264
|
"componentId": "${props.id}",
|
|
@@ -12909,7 +13325,8 @@ function getFormPagination(props, mode) {
|
|
|
12909
13325
|
},
|
|
12910
13326
|
{
|
|
12911
13327
|
"type": "tpl",
|
|
12912
|
-
|
|
13328
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13329
|
+
"tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
|
|
12913
13330
|
},
|
|
12914
13331
|
{
|
|
12915
13332
|
"type": "button",
|
|
@@ -12917,7 +13334,9 @@ function getFormPagination(props, mode) {
|
|
|
12917
13334
|
"icon": `fa fa-angle-right`,
|
|
12918
13335
|
"level": "link",
|
|
12919
13336
|
"pageChangeDirection": "next",
|
|
12920
|
-
"disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
13337
|
+
// "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
13338
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13339
|
+
"disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
|
|
12921
13340
|
"size": "sm",
|
|
12922
13341
|
"id": buttonNextId,
|
|
12923
13342
|
"onEvent": {
|
|
@@ -12946,18 +13365,19 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12946
13365
|
// console.log("==getFormPaginationWrapper===", props, mode);
|
|
12947
13366
|
let serviceId = getComponentId("form_pagination", props.id);
|
|
12948
13367
|
let tableServiceId = getComponentId("table_service", props.id);
|
|
13368
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
12949
13369
|
let innerForm = Object.assign({}, form, {
|
|
12950
13370
|
"data": {
|
|
12951
13371
|
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12952
13372
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12953
|
-
"&": "${__tableItems[__super.index]}"
|
|
13373
|
+
"&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
|
|
12954
13374
|
}
|
|
12955
13375
|
});
|
|
12956
13376
|
let formBody = [
|
|
12957
13377
|
{
|
|
12958
13378
|
"type": "wrapper",
|
|
12959
13379
|
"size": "none",
|
|
12960
|
-
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white
|
|
13380
|
+
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
|
|
12961
13381
|
"body": [
|
|
12962
13382
|
getFormPagination(props, mode)
|
|
12963
13383
|
]
|
|
@@ -12973,7 +13393,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12973
13393
|
}
|
|
12974
13394
|
];
|
|
12975
13395
|
let onServiceInitedScript = `
|
|
12976
|
-
//
|
|
13396
|
+
// 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
12977
13397
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12978
13398
|
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
12979
13399
|
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
@@ -12986,8 +13406,13 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12986
13406
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12987
13407
|
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
12988
13408
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
13409
|
+
let fieldPrefix = "${props.fieldPrefix || ''}";
|
|
13410
|
+
if(fieldPrefix){
|
|
13411
|
+
let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
|
|
13412
|
+
lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
|
|
13413
|
+
}
|
|
12989
13414
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12990
|
-
let mode = "${mode}";
|
|
13415
|
+
let mode = "${mode || ''}";
|
|
12991
13416
|
if(mode === "new"){
|
|
12992
13417
|
// 点击子表组件底部新增按钮时新增一条空白行并自动翻页到新增行
|
|
12993
13418
|
// 注意点击弹出的子表行详细表单中的新增按钮不会进此service init事件函数中
|
|
@@ -13008,6 +13433,26 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13008
13433
|
event.data.__tableItems.forEach(function(n,i){
|
|
13009
13434
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
13010
13435
|
});
|
|
13436
|
+
|
|
13437
|
+
var parent = event.data.parent;
|
|
13438
|
+
var fieldValue = event.data.__tableItems;
|
|
13439
|
+
if(parent){
|
|
13440
|
+
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13441
|
+
var primaryKey = "${primaryKey}";
|
|
13442
|
+
event.data.__parentIndex = _.findIndex(fieldValue, function(item){
|
|
13443
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13444
|
+
});
|
|
13445
|
+
if(event.data.__parentIndex < 0){
|
|
13446
|
+
let tableId = "${props.id}";
|
|
13447
|
+
let table = scope.getComponentById(tableId)
|
|
13448
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
13449
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
13450
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
13451
|
+
event.data.__parentIndex = _.findIndex(table.props.value, function(item){
|
|
13452
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13453
|
+
});
|
|
13454
|
+
}
|
|
13455
|
+
}
|
|
13011
13456
|
`;
|
|
13012
13457
|
let schema = {
|
|
13013
13458
|
"type": "service",
|
|
@@ -13028,6 +13473,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13028
13473
|
// "body": formBody,
|
|
13029
13474
|
"data": {
|
|
13030
13475
|
"__page": "${index + 1}",
|
|
13476
|
+
"__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
|
|
13031
13477
|
// "__total": `\${${props.name}.length}`,
|
|
13032
13478
|
// "__total": "${__tableItems.length}",
|
|
13033
13479
|
// "__paginationServiceId": serviceId,
|
|
@@ -13054,6 +13500,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13054
13500
|
async function getForm(props, mode = "edit", formId) {
|
|
13055
13501
|
let formFields = getFormFields(props, mode);
|
|
13056
13502
|
let body = await getFormBody(null, formFields);
|
|
13503
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
13057
13504
|
if (!formId) {
|
|
13058
13505
|
formId = getComponentId("form", props.id);
|
|
13059
13506
|
}
|
|
@@ -13072,10 +13519,41 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13072
13519
|
// 新增行弹出编辑行表单,在弹出之前已经不用先增加一行,因为在翻页service初始化的时候会判断mode为new时自动新增一行
|
|
13073
13520
|
let onEditItemSubmitScript = `
|
|
13074
13521
|
// let fieldValue = _.cloneDeep(event.data["${props.name}"]);
|
|
13522
|
+
let removeEmptyItems = function(items){
|
|
13523
|
+
let i = _.findIndex(items, function(item){
|
|
13524
|
+
return item === undefined
|
|
13525
|
+
});
|
|
13526
|
+
if(i > -1){
|
|
13527
|
+
items.splice(i, 1);
|
|
13528
|
+
removeEmptyItems(items);
|
|
13529
|
+
}
|
|
13530
|
+
}
|
|
13531
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
13532
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
13533
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13075
13534
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13076
13535
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
13077
13536
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
13078
|
-
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13537
|
+
// fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13538
|
+
var currentIndex = event.data.__super.__super.index;
|
|
13539
|
+
var currentFormValues = JSON.parse(JSON.stringify(event.data));
|
|
13540
|
+
var parent = event.data.__super.__super.parent;
|
|
13541
|
+
var __parentIndex = event.data.__super.__super.__parentIndex;
|
|
13542
|
+
let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
|
|
13543
|
+
var primaryKey = "${primaryKey}";
|
|
13544
|
+
if(parent){
|
|
13545
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13546
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13547
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13548
|
+
children: fieldValue[__parentIndex].children,
|
|
13549
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13550
|
+
});
|
|
13551
|
+
}
|
|
13552
|
+
else{
|
|
13553
|
+
// 这里currentFormValues中如果没有primaryKey字段值不用处理,因为组件的pipeIn/pipeOut中会为每行自动生成
|
|
13554
|
+
// 也不用担心复制行时_id会重复,因为点击复制按钮时已经处理过了
|
|
13555
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13556
|
+
}
|
|
13079
13557
|
doAction({
|
|
13080
13558
|
"componentId": "${props.id}",
|
|
13081
13559
|
"actionType": "setValue",
|
|
@@ -13171,6 +13649,7 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13171
13649
|
*/
|
|
13172
13650
|
async function getButtonActions(props, mode) {
|
|
13173
13651
|
let actions = [];
|
|
13652
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
13174
13653
|
let formId = getComponentId("form", props.id);
|
|
13175
13654
|
let dialogId = getComponentId("dialog", props.id);
|
|
13176
13655
|
let buttonNextId = getComponentId("button_next", props.id);
|
|
@@ -13213,9 +13692,42 @@ async function getButtonActions(props, mode) {
|
|
|
13213
13692
|
// };
|
|
13214
13693
|
let onSaveAndNewItemScript = `
|
|
13215
13694
|
let scope = event.context.scoped;
|
|
13695
|
+
let removeEmptyItems = function(items){
|
|
13696
|
+
let i = _.findIndex(items, function(item){
|
|
13697
|
+
return item === undefined
|
|
13698
|
+
});
|
|
13699
|
+
if(i > -1){
|
|
13700
|
+
items.splice(i, 1);
|
|
13701
|
+
removeEmptyItems(items);
|
|
13702
|
+
}
|
|
13703
|
+
}
|
|
13704
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
13705
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
13706
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13216
13707
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13217
13708
|
// 新建一条空白行并保存到子表组件
|
|
13218
|
-
|
|
13709
|
+
var parent = event.data.__super.parent;
|
|
13710
|
+
var primaryKey = "${primaryKey}";
|
|
13711
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13712
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13713
|
+
});
|
|
13714
|
+
if(parent && __parentIndex < 0){
|
|
13715
|
+
let tableId = "${props.id}";
|
|
13716
|
+
let table = scope.getComponentById(tableId)
|
|
13717
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
13718
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
13719
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
13720
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
13721
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13722
|
+
});
|
|
13723
|
+
}
|
|
13724
|
+
if(parent){
|
|
13725
|
+
fieldValue[__parentIndex].children.push({});
|
|
13726
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13727
|
+
}
|
|
13728
|
+
else{
|
|
13729
|
+
fieldValue.push({});
|
|
13730
|
+
}
|
|
13219
13731
|
doAction({
|
|
13220
13732
|
"componentId": "${props.id}",
|
|
13221
13733
|
"actionType": "setValue",
|
|
@@ -13227,7 +13739,13 @@ async function getButtonActions(props, mode) {
|
|
|
13227
13739
|
let __paginationServiceId = "${formPaginationId}";
|
|
13228
13740
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13229
13741
|
event.data.index = __paginationData.index;
|
|
13230
|
-
|
|
13742
|
+
if(parent){
|
|
13743
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13744
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
13745
|
+
}
|
|
13746
|
+
else{
|
|
13747
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13748
|
+
}
|
|
13231
13749
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13232
13750
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13233
13751
|
`;
|
|
@@ -13236,9 +13754,49 @@ async function getButtonActions(props, mode) {
|
|
|
13236
13754
|
let __formId = "${formId}";
|
|
13237
13755
|
// let newItem = JSON.parse(JSON.stringify(event.data));
|
|
13238
13756
|
let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
|
|
13757
|
+
newItem = _.clone(newItem);
|
|
13758
|
+
let removeEmptyItems = function(items){
|
|
13759
|
+
let i = _.findIndex(items, function(item){
|
|
13760
|
+
return item === undefined
|
|
13761
|
+
});
|
|
13762
|
+
if(i > -1){
|
|
13763
|
+
items.splice(i, 1);
|
|
13764
|
+
removeEmptyItems(items);
|
|
13765
|
+
}
|
|
13766
|
+
}
|
|
13767
|
+
// 因为删除时只是把input-table组件中的行数据删除了,并没有把父层service中的行删除,所以__tableItems会有值为undefined的数据,需要移除掉
|
|
13768
|
+
// 不用event.data.__tableItems = _.compact(event.data.__tableItems)是因为会把__tableItems变量保存到表单中
|
|
13769
|
+
removeEmptyItems(event.data.__tableItems);
|
|
13239
13770
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13240
13771
|
// 复制当前页数据到新建行并保存到子表组件
|
|
13241
|
-
fieldValue.push(newItem);
|
|
13772
|
+
// fieldValue.push(newItem);
|
|
13773
|
+
var parent = event.data.__super.parent;
|
|
13774
|
+
var primaryKey = "${primaryKey}";
|
|
13775
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13776
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13777
|
+
});
|
|
13778
|
+
if(parent && __parentIndex < 0){
|
|
13779
|
+
let tableId = "${props.id}";
|
|
13780
|
+
let table = scope.getComponentById(tableId)
|
|
13781
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
13782
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
13783
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
13784
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
13785
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13786
|
+
});
|
|
13787
|
+
}
|
|
13788
|
+
if(newItem[primaryKey]){
|
|
13789
|
+
// 如果newItem已经有主键字段值,则重新生成新的主键值,否则会重复。
|
|
13790
|
+
let uuidv4 = new Function("return (" + ${uuidv4.toString()} + ")()");
|
|
13791
|
+
newItem[primaryKey] = uuidv4();
|
|
13792
|
+
}
|
|
13793
|
+
if(parent){
|
|
13794
|
+
fieldValue[__parentIndex].children.push(newItem);
|
|
13795
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13796
|
+
}
|
|
13797
|
+
else{
|
|
13798
|
+
fieldValue.push(newItem);
|
|
13799
|
+
}
|
|
13242
13800
|
doAction({
|
|
13243
13801
|
"componentId": "${props.id}",
|
|
13244
13802
|
"actionType": "setValue",
|
|
@@ -13250,7 +13808,13 @@ async function getButtonActions(props, mode) {
|
|
|
13250
13808
|
let __paginationServiceId = "${formPaginationId}";
|
|
13251
13809
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13252
13810
|
event.data.index = __paginationData.index;
|
|
13253
|
-
|
|
13811
|
+
if(parent){
|
|
13812
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13813
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
13814
|
+
}
|
|
13815
|
+
else{
|
|
13816
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13817
|
+
}
|
|
13254
13818
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13255
13819
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13256
13820
|
`;
|
|
@@ -13326,13 +13890,16 @@ async function getButtonActions(props, mode) {
|
|
|
13326
13890
|
"_master": "${_master}",
|
|
13327
13891
|
"global": "${global}",
|
|
13328
13892
|
"uiSchema": "${uiSchema}",
|
|
13329
|
-
"index": "${index}"
|
|
13893
|
+
"index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
|
|
13894
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13330
13895
|
// "__tableItems": `\${${props.name}}`
|
|
13331
13896
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13332
13897
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13333
13898
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13334
|
-
|
|
13335
|
-
|
|
13899
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
13900
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
13901
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13902
|
+
},
|
|
13336
13903
|
"actions": dialogButtons,
|
|
13337
13904
|
"onEvent": {
|
|
13338
13905
|
"confirm": {
|
|
@@ -13354,35 +13921,39 @@ async function getButtonActions(props, mode) {
|
|
|
13354
13921
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13355
13922
|
}
|
|
13356
13923
|
if (mode == "new") {
|
|
13357
|
-
`
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
`;
|
|
13924
|
+
// let onNewLineScript = `
|
|
13925
|
+
// let newItem = {};
|
|
13926
|
+
// if(event.data["${props.name}"]){
|
|
13927
|
+
// // let fieldValue = event.data.__tableItems;
|
|
13928
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
13929
|
+
// // let fieldValue = _.clone(event.data["${props.name}"]);
|
|
13930
|
+
// let fieldValue = event.data["${props.name}"];
|
|
13931
|
+
// fieldValue.push(newItem);
|
|
13932
|
+
// doAction({
|
|
13933
|
+
// "componentId": "${props.id}",
|
|
13934
|
+
// "actionType": "setValue",
|
|
13935
|
+
// "args": {
|
|
13936
|
+
// "value": fieldValue
|
|
13937
|
+
// }
|
|
13938
|
+
// });
|
|
13939
|
+
// event.data.index = fieldValue.length - 1;
|
|
13940
|
+
// }
|
|
13941
|
+
// else{
|
|
13942
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
13943
|
+
// doAction({
|
|
13944
|
+
// "componentId": "${props.id}",
|
|
13945
|
+
// "actionType": "setValue",
|
|
13946
|
+
// "args": {
|
|
13947
|
+
// "value": [newItem]
|
|
13948
|
+
// }
|
|
13949
|
+
// });
|
|
13950
|
+
// event.data.index = 1;
|
|
13951
|
+
// }
|
|
13952
|
+
// `;
|
|
13953
|
+
// let actionNewLine = {
|
|
13954
|
+
// "actionType": "custom",
|
|
13955
|
+
// "script": onNewLineScript
|
|
13956
|
+
// };
|
|
13386
13957
|
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13387
13958
|
// actions = [actionNewLine, actionShowEditDialog];
|
|
13388
13959
|
actions = [actionShowEditDialog];
|
|
@@ -13417,15 +13988,17 @@ async function getButtonActions(props, mode) {
|
|
|
13417
13988
|
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
13418
13989
|
// "__parentForm": "${__super.__super || {}}",
|
|
13419
13990
|
"__parentForm": parentFormData,
|
|
13991
|
+
"_master": "${_master}",
|
|
13420
13992
|
"global": "${global}",
|
|
13421
13993
|
"uiSchema": "${uiSchema}",
|
|
13422
13994
|
"index": "${index}",
|
|
13995
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13423
13996
|
// "__tableItems": `\${${props.name}}`
|
|
13424
13997
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13425
13998
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13426
13999
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13427
|
-
"__tableItems": `\${(
|
|
13428
|
-
|
|
14000
|
+
"__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
14001
|
+
},
|
|
13429
14002
|
}
|
|
13430
14003
|
}
|
|
13431
14004
|
];
|
|
@@ -13440,8 +14013,40 @@ async function getButtonActions(props, mode) {
|
|
|
13440
14013
|
let wrapperServiceData = wrapperService.getData();
|
|
13441
14014
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13442
14015
|
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
14016
|
+
// 也因为这里clone没有直接删除,所以弹出编辑表单提交事件中event.data.__tableItems中取到的值会有被删除的行数据为undefined
|
|
13443
14017
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13444
|
-
|
|
14018
|
+
var currentIndex = event.data.index;
|
|
14019
|
+
var parent = event.data.__super.parent;
|
|
14020
|
+
var primaryKey = "${primaryKey}";
|
|
14021
|
+
var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
|
|
14022
|
+
return item[primaryKey] == parent[primaryKey];
|
|
14023
|
+
});
|
|
14024
|
+
if(parent && __parentIndex < 0){
|
|
14025
|
+
let tableId = "${props.id}";
|
|
14026
|
+
let table = scope.getComponentById(tableId)
|
|
14027
|
+
// autoGeneratePrimaryKeyValue不为true的情况下,即子表组件input-table的pipeOut函数中会移除表单了子表字段的primaryKey字段值,
|
|
14028
|
+
// 此时行primaryKey字段值为空,但是pipeIn函数中已经为input-table自动生成过primaryKey字段值了,只是没有输出到表单字段值中而已
|
|
14029
|
+
// 所以上面从表单字段值中没找到__parentIndex,是因为此时行primaryKey字段值只经过pipeIn保存到table组件内而没有保存到tableService
|
|
14030
|
+
__parentIndex = _.findIndex(table.props.value, function(item){
|
|
14031
|
+
return item[primaryKey] == parent[primaryKey];
|
|
14032
|
+
});
|
|
14033
|
+
}
|
|
14034
|
+
if(parent){
|
|
14035
|
+
lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
|
|
14036
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
14037
|
+
lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
|
|
14038
|
+
children: lastestFieldValue[__parentIndex].children,
|
|
14039
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
14040
|
+
});
|
|
14041
|
+
}
|
|
14042
|
+
else{
|
|
14043
|
+
lastestFieldValue.splice(currentIndex, 1);
|
|
14044
|
+
}
|
|
14045
|
+
let fieldPrefix = "${props.fieldPrefix || ''}";
|
|
14046
|
+
if(fieldPrefix){
|
|
14047
|
+
let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
|
|
14048
|
+
lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
|
|
14049
|
+
}
|
|
13445
14050
|
doAction({
|
|
13446
14051
|
"componentId": "${props.id}",
|
|
13447
14052
|
"actionType": "setValue",
|
|
@@ -13527,39 +14132,52 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13527
14132
|
if (!props.id) {
|
|
13528
14133
|
props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
|
|
13529
14134
|
}
|
|
14135
|
+
let primaryKey = getTablePrimaryKey(props);
|
|
14136
|
+
let showOperation = props.showOperation;
|
|
14137
|
+
if(showOperation !== false){
|
|
14138
|
+
showOperation = true;
|
|
14139
|
+
}
|
|
14140
|
+
let fieldPrefix = props.fieldPrefix;
|
|
14141
|
+
let fields = props.fields || [];
|
|
14142
|
+
if (fieldPrefix) {
|
|
14143
|
+
fields = getTableFieldsWithoutFieldPrefix(fields, fieldPrefix);
|
|
14144
|
+
}
|
|
13530
14145
|
let serviceId = getComponentId("table_service", props.id);
|
|
13531
14146
|
let buttonsForColumnOperations = [];
|
|
13532
14147
|
let inlineEditMode = props.inlineEditMode;
|
|
13533
14148
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
13534
|
-
if
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
14149
|
+
if(showOperation){
|
|
14150
|
+
if (props.editable) {
|
|
14151
|
+
let showEditButton = true;
|
|
14152
|
+
if (showAsInlineEditMode) {
|
|
14153
|
+
// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
14154
|
+
showEditButton = true;
|
|
14155
|
+
// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
14156
|
+
// if (props.columns && props.columns.length > 0 && props.columns.length < fields.length) {
|
|
14157
|
+
// showEditButton = true;
|
|
14158
|
+
// }
|
|
14159
|
+
// else {
|
|
14160
|
+
// showEditButton = false;
|
|
14161
|
+
// }
|
|
14162
|
+
}
|
|
14163
|
+
// 编辑时显示编辑按钮
|
|
14164
|
+
if (showEditButton) {
|
|
14165
|
+
let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
|
|
14166
|
+
buttonsForColumnOperations.push(buttonEditSchema);
|
|
14167
|
+
}
|
|
13546
14168
|
}
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
14169
|
+
else {
|
|
14170
|
+
// 只读时显示查看按钮
|
|
14171
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < fields.length)
|
|
14172
|
+
let buttonViewSchema = await getButtonView(props);
|
|
14173
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
14174
|
+
}
|
|
14175
|
+
if (props.removable) {
|
|
14176
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
14177
|
+
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13551
14178
|
}
|
|
13552
14179
|
}
|
|
13553
|
-
|
|
13554
|
-
// 只读时显示查看按钮
|
|
13555
|
-
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13556
|
-
let buttonViewSchema = await getButtonView(props);
|
|
13557
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13558
|
-
}
|
|
13559
|
-
if (props.removable) {
|
|
13560
|
-
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13561
|
-
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13562
|
-
}
|
|
14180
|
+
let amis = props["input-table"] || props.amis || {};//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13563
14181
|
let inputTableSchema = {
|
|
13564
14182
|
"type": "input-table",
|
|
13565
14183
|
"label": props.label,
|
|
@@ -13577,7 +14195,51 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13577
14195
|
"strictMode": props.strictMode,
|
|
13578
14196
|
"showTableAddBtn": false,
|
|
13579
14197
|
"showFooterAddBtn": false,
|
|
13580
|
-
"className": props.tableClassName
|
|
14198
|
+
"className": props.tableClassName,
|
|
14199
|
+
"pipeIn": (value, data) => {
|
|
14200
|
+
if(fieldPrefix){
|
|
14201
|
+
value = getTableValueWithoutFieldPrefix(value, fieldPrefix);
|
|
14202
|
+
}
|
|
14203
|
+
if(primaryKey){
|
|
14204
|
+
// 这里临时给每行数据补上primaryKey字段值,如果库里不需要保存这里补上的字段值,pipeOut中会识别autoGeneratePrimaryKeyValue属性选择最终移除这里补上的字段值
|
|
14205
|
+
// 这里始终自动生成primaryKey字段值,而不是只在pipeOut输出整个子表字段值时才生成,是因为要支持当数据库里保存的子表字段行数据没有primaryKey字段值时的行嵌套模式(即节点的children属性)功能
|
|
14206
|
+
// 这里要注意,流程详细设置界面的字段设置功能中的子表组件中,数据库里保存的子表字段行数据是有primaryKey字段值的,它不依赖这里自动生成行primaryKey值功能
|
|
14207
|
+
value = getTableValueWithPrimaryKeyValue(value, primaryKey);
|
|
14208
|
+
}
|
|
14209
|
+
if(amis.pipeIn){
|
|
14210
|
+
if(typeof amis.pipeIn === 'function'){
|
|
14211
|
+
return amis.pipeIn(value, data);
|
|
14212
|
+
}
|
|
14213
|
+
}
|
|
14214
|
+
return value;
|
|
14215
|
+
},
|
|
14216
|
+
"pipeOut": (value, data) => {
|
|
14217
|
+
value = (value || []).map(function(item){
|
|
14218
|
+
delete item.__fix_rerender_after_children_modified_tag;
|
|
14219
|
+
return item;
|
|
14220
|
+
});
|
|
14221
|
+
if(fieldPrefix){
|
|
14222
|
+
value = getTableValuePrependFieldPrefix(value, fieldPrefix, primaryKey);
|
|
14223
|
+
}
|
|
14224
|
+
if(props.autoGeneratePrimaryKeyValue === true){
|
|
14225
|
+
// 如果需要把自动生成的primaryKey值输出保存的库中,则补全所有行中的primaryKey值
|
|
14226
|
+
// 这里如果不全部补全的话,初始从库里返回的字段值中拿到的行没primaryKey值的话就不会自动补上
|
|
14227
|
+
value = getTableValueWithPrimaryKeyValue(value, primaryKey);
|
|
14228
|
+
}
|
|
14229
|
+
else {
|
|
14230
|
+
// 默认情况下,也就是没有配置autoGeneratePrimaryKey时,最终输出的字段值要移除行中的primaryKey值
|
|
14231
|
+
// 需要注意如果没有配置autoGeneratePrimaryKey时,因为每次弹出行编辑窗口保存后都会先后进入pipeOut和pipeIn,
|
|
14232
|
+
// 这里删除掉了primaryKey值,所以primaryKey值每次弹出编辑窗口保存后都会给每行重新生成新的primaryKey值
|
|
14233
|
+
// 只有autoGeneratePrimaryKey配置为true时,每行的primaryKey字段值才会始终保持不变
|
|
14234
|
+
value = getTableValueWithoutPrimaryKeyValue(value, primaryKey);
|
|
14235
|
+
}
|
|
14236
|
+
if(amis.pipeOut){
|
|
14237
|
+
if(typeof amis.pipeOut === 'function'){
|
|
14238
|
+
return amis.pipeOut(value, data);
|
|
14239
|
+
}
|
|
14240
|
+
}
|
|
14241
|
+
return value;
|
|
14242
|
+
}
|
|
13581
14243
|
};
|
|
13582
14244
|
if (buttonsForColumnOperations.length) {
|
|
13583
14245
|
inputTableSchema.columns.push({
|
|
@@ -13590,17 +14252,18 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13590
14252
|
if (showAsInlineEditMode) {
|
|
13591
14253
|
inputTableSchema.needConfirm = false;
|
|
13592
14254
|
}
|
|
13593
|
-
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13594
14255
|
if (amis) {
|
|
13595
14256
|
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13596
14257
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
14258
|
+
delete amis.pipeIn;//该属性在上面合并过了
|
|
14259
|
+
delete amis.pipeOut;//该属性在上面合并过了
|
|
13597
14260
|
Object.assign(inputTableSchema, amis);
|
|
13598
14261
|
}
|
|
13599
|
-
const isAnyFieldHasDependOn = (
|
|
14262
|
+
const isAnyFieldHasDependOn = (fields || []).find(function (item) {
|
|
13600
14263
|
return item.depend_on;
|
|
13601
14264
|
});
|
|
13602
14265
|
if (isAnyFieldHasDependOn) {
|
|
13603
|
-
// 有任意一个子字段有depend_on
|
|
14266
|
+
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
|
|
13604
14267
|
Object.assign(inputTableSchema, {
|
|
13605
14268
|
strictMode: false
|
|
13606
14269
|
});
|
|
@@ -13705,7 +14368,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
|
|
|
13705
14368
|
// 获取
|
|
13706
14369
|
async function getRecordPageInitSchema(objectApiName){
|
|
13707
14370
|
const relatedList = await getObjectRelatedList(objectApiName);
|
|
13708
|
-
|
|
14371
|
+
await getUISchema(objectApiName);
|
|
13709
14372
|
let body = [
|
|
13710
14373
|
// detailHeaderAmisSchema,
|
|
13711
14374
|
{
|
|
@@ -13713,28 +14376,7 @@ async function getRecordPageInitSchema(objectApiName){
|
|
|
13713
14376
|
"label": "标题面板",
|
|
13714
14377
|
"objectApiName": "${objectName}",
|
|
13715
14378
|
"recordId": "${recordId}",
|
|
13716
|
-
"onEvent": {
|
|
13717
|
-
"recordLoaded": {
|
|
13718
|
-
"actions": [
|
|
13719
|
-
{
|
|
13720
|
-
"actionType": "setValue",
|
|
13721
|
-
"args": {
|
|
13722
|
-
"value": {
|
|
13723
|
-
"recordLoaded": true,
|
|
13724
|
-
}
|
|
13725
|
-
}
|
|
13726
|
-
},
|
|
13727
|
-
{
|
|
13728
|
-
"actionType": "reload",
|
|
13729
|
-
"data": {
|
|
13730
|
-
"name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
13731
|
-
"record": `\${record}`,
|
|
13732
|
-
"recordLoaded": true,
|
|
13733
|
-
}
|
|
13734
|
-
}
|
|
13735
|
-
]
|
|
13736
|
-
}
|
|
13737
|
-
}
|
|
14379
|
+
"onEvent": {}
|
|
13738
14380
|
}
|
|
13739
14381
|
];
|
|
13740
14382
|
let contentBody = {
|
|
@@ -16369,9 +17011,11 @@ exports.getObjectRelated = getObjectRelated;
|
|
|
16369
17011
|
exports.getObjectRelatedList = getObjectRelatedList;
|
|
16370
17012
|
exports.getObjectRelatedListButtons = getObjectRelatedListButtons;
|
|
16371
17013
|
exports.getObjectRelatedListHeader = getObjectRelatedListHeader;
|
|
17014
|
+
exports.getObjectRelatedListsMiniSchema = getObjectRelatedListsMiniSchema;
|
|
16372
17015
|
exports.getPage = getPage;
|
|
16373
17016
|
exports.getRecord = getRecord;
|
|
16374
17017
|
exports.getRecordDetailHeaderSchema = getRecordDetailHeaderSchema;
|
|
17018
|
+
exports.getRecordDetailMiniSchema = getRecordDetailMiniSchema;
|
|
16375
17019
|
exports.getRecordDetailRelatedListSchema = getRecordDetailRelatedListSchema;
|
|
16376
17020
|
exports.getRecordDetailSchema = getRecordDetailSchema;
|
|
16377
17021
|
exports.getRecordPageInitSchema = getRecordPageInitSchema;
|