@steedos-widgets/amis-lib 3.6.2-beta.1 → 3.6.2-beta.10
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 +762 -317
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +761 -318
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +266 -175
- 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 +1 -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.esm.js
CHANGED
|
@@ -340,22 +340,26 @@ const getSteedosAuth = () => {
|
|
|
340
340
|
* @Description:
|
|
341
341
|
*/
|
|
342
342
|
|
|
343
|
-
|
|
344
343
|
const Router = {
|
|
345
344
|
getTabDisplayAs(tab_id){
|
|
345
|
+
const uiSchema = getUISchemaSync$1(tab_id, false);
|
|
346
346
|
var urlSearch = new URLSearchParams(document.location.search);
|
|
347
347
|
if(urlSearch.has('display')){
|
|
348
348
|
return urlSearch.get('display')
|
|
349
349
|
}
|
|
350
350
|
const key = `tab_${tab_id}_display`;
|
|
351
351
|
// const key = `page_display`;
|
|
352
|
-
const value =
|
|
353
|
-
|
|
352
|
+
const value = sessionStorage.getItem(key);
|
|
353
|
+
let defaultDisplay = "grid";
|
|
354
|
+
if(uiSchema.enable_split){
|
|
355
|
+
defaultDisplay = "split";
|
|
356
|
+
}
|
|
357
|
+
return value ? value : defaultDisplay;
|
|
354
358
|
},
|
|
355
359
|
|
|
356
360
|
setTabDisplayAs(tab_id, displayAs){
|
|
357
361
|
const key = `tab_${tab_id}_display`;
|
|
358
|
-
|
|
362
|
+
sessionStorage.setItem(key, displayAs);
|
|
359
363
|
},
|
|
360
364
|
getAppPath({formFactor, appId}){
|
|
361
365
|
return `/app/${appId}`;
|
|
@@ -459,7 +463,7 @@ function getComparableAmisVersion() {
|
|
|
459
463
|
* @Author: baozhoutao@steedos.com
|
|
460
464
|
* @Date: 2022-05-23 09:53:08
|
|
461
465
|
* @LastEditors: liaodaxue
|
|
462
|
-
* @LastEditTime:
|
|
466
|
+
* @LastEditTime: 2024-01-17 16:00:27
|
|
463
467
|
* @Description:
|
|
464
468
|
*/
|
|
465
469
|
|
|
@@ -531,7 +535,7 @@ function getSelectMap(selectOptions){
|
|
|
531
535
|
|
|
532
536
|
function getNameTplUrl(field, ctx){
|
|
533
537
|
if(ctx.objectName === 'cms_files'){
|
|
534
|
-
return
|
|
538
|
+
return "${(versions[0] && versions[0].url) ? versions[0].url+'?download=true' : context.rootUrl+'/api/files/files/'+versions[0]+'?download=true'}"
|
|
535
539
|
}
|
|
536
540
|
const href = Router.getObjectDetailPath({
|
|
537
541
|
...ctx, formFactor: ctx.formFactor, appId: "${appId}", objectName: ctx.objectName || "${objectName}", recordId: `\${${ctx.idFieldName}}`
|
|
@@ -1403,9 +1407,9 @@ var frontend_display_type_is_split = "分栏视图";
|
|
|
1403
1407
|
var frontend_display_as = "显示为";
|
|
1404
1408
|
var frontend_record_sum = "个项目";
|
|
1405
1409
|
var frontend_button_reload_tooltip = "刷新";
|
|
1406
|
-
var frontend_button_search_tooltip = "
|
|
1410
|
+
var frontend_button_search_tooltip = "搜索";
|
|
1407
1411
|
var frontend_fields_filter_button_search = "搜索";
|
|
1408
|
-
var frontend_fields_filter_button_settings = "
|
|
1412
|
+
var frontend_fields_filter_button_settings = "选择搜索项";
|
|
1409
1413
|
var frontend_button_listview_control_tooltip = "列表视图控制";
|
|
1410
1414
|
var frontend_button_listview_control_label = "列表视图控制";
|
|
1411
1415
|
var frontend_listview_control_columns = "显示的列";
|
|
@@ -2060,9 +2064,13 @@ async function getTableColumns(fields, options){
|
|
|
2060
2064
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
2061
2065
|
let className = "";
|
|
2062
2066
|
if(field.wrap != true){
|
|
2063
|
-
|
|
2067
|
+
if(field.wrap != false && field.is_wide){
|
|
2068
|
+
className += " break-words ";
|
|
2069
|
+
}else {
|
|
2070
|
+
className += " whitespace-nowrap ";
|
|
2071
|
+
}
|
|
2064
2072
|
}else {
|
|
2065
|
-
className += " break-
|
|
2073
|
+
className += " break-words ";
|
|
2066
2074
|
}
|
|
2067
2075
|
let columnItem;
|
|
2068
2076
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
@@ -2159,12 +2167,24 @@ async function getTableColumns(fields, options){
|
|
|
2159
2167
|
if(field.type === 'textarea'){
|
|
2160
2168
|
className += 'min-w-56';
|
|
2161
2169
|
}
|
|
2162
|
-
if(field.type === 'date'){
|
|
2163
|
-
|
|
2164
|
-
}
|
|
2165
|
-
if(field.type === 'datetime'){
|
|
2166
|
-
|
|
2170
|
+
// if(field.type === 'date'){
|
|
2171
|
+
// className += 'date-min-w';
|
|
2172
|
+
// }
|
|
2173
|
+
// if(field.type === 'datetime'){
|
|
2174
|
+
// className += 'datetime-min-w';
|
|
2175
|
+
// }
|
|
2176
|
+
|
|
2177
|
+
//field上的amis属性里的clssname需要单独判断类型合并
|
|
2178
|
+
if (typeof field.amis?.className == "object") {
|
|
2179
|
+
className = {
|
|
2180
|
+
[className]: "true",
|
|
2181
|
+
...field.amis.className
|
|
2182
|
+
};
|
|
2183
|
+
} else if (typeof field.amis?.className == "string") {
|
|
2184
|
+
className = `${className} ${field.amis.className} `;
|
|
2167
2185
|
}
|
|
2186
|
+
delete field.amis?.className;
|
|
2187
|
+
|
|
2168
2188
|
if(!field.hidden && !field.extra){
|
|
2169
2189
|
columnItem = Object.assign({}, {
|
|
2170
2190
|
name: field.name,
|
|
@@ -2247,7 +2267,7 @@ function getMobileLines(tpls){
|
|
|
2247
2267
|
}
|
|
2248
2268
|
if(isLeft){
|
|
2249
2269
|
// 左侧半行
|
|
2250
|
-
lineChildrenClassName = "steedos-listview-item-left truncate";
|
|
2270
|
+
lineChildrenClassName = "steedos-listview-item-left truncate h-5";
|
|
2251
2271
|
if(item.field.is_wide){
|
|
2252
2272
|
// 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
|
|
2253
2273
|
lineChildrenClassName = "steedos-listview-item-wide";
|
|
@@ -2259,14 +2279,26 @@ function getMobileLines(tpls){
|
|
|
2259
2279
|
}
|
|
2260
2280
|
else {
|
|
2261
2281
|
// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
2262
|
-
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0";
|
|
2282
|
+
lineChildrenClassName = "steedos-listview-item-right truncate ml-2 flex flex-shrink-0 h-5";
|
|
2283
|
+
}
|
|
2284
|
+
//支持字段amis属性配置classname,识别classname的类型,与原样式合并
|
|
2285
|
+
var className;
|
|
2286
|
+
if (typeof item.field.amis?.className == "object") {
|
|
2287
|
+
className = {
|
|
2288
|
+
[lineChildrenClassName]: "true",
|
|
2289
|
+
...item.field.amis.className
|
|
2290
|
+
};
|
|
2291
|
+
} else if (typeof item.field.amis?.className == "string") {
|
|
2292
|
+
className = `${lineChildrenClassName} ${item.field.amis.className} `;
|
|
2293
|
+
} else {
|
|
2294
|
+
className = lineChildrenClassName;
|
|
2263
2295
|
}
|
|
2264
2296
|
lineChildren.push({
|
|
2265
2297
|
"type": "tpl",
|
|
2266
2298
|
"tpl": item.tpl,
|
|
2267
|
-
|
|
2299
|
+
className
|
|
2268
2300
|
});
|
|
2269
|
-
|
|
2301
|
+
|
|
2270
2302
|
if(item.field.is_wide){
|
|
2271
2303
|
// 宽字段占整行
|
|
2272
2304
|
isLeft = true;
|
|
@@ -2316,8 +2348,7 @@ async function getMobileTableColumns(fields, options){
|
|
|
2316
2348
|
tpl = await getFieldTpl(field, options);
|
|
2317
2349
|
}
|
|
2318
2350
|
if(!tpl){
|
|
2319
|
-
|
|
2320
|
-
tpl = `\${${field.name} | raw}`;
|
|
2351
|
+
tpl = `\${${field.name}}`;
|
|
2321
2352
|
}
|
|
2322
2353
|
if(!field.hidden && !field.extra){
|
|
2323
2354
|
tpls.push({ field, tpl });
|
|
@@ -2330,7 +2361,7 @@ async function getMobileTableColumns(fields, options){
|
|
|
2330
2361
|
|
|
2331
2362
|
let column = {
|
|
2332
2363
|
name: nameField.name,
|
|
2333
|
-
label: nameField.label,
|
|
2364
|
+
label: options.displayAs == 'split' ? '' : nameField.label,
|
|
2334
2365
|
sortable: nameField.sortable,
|
|
2335
2366
|
type: "button",
|
|
2336
2367
|
level: "link",
|
|
@@ -2359,7 +2390,15 @@ async function getMobileTableColumns(fields, options){
|
|
|
2359
2390
|
"actions": [
|
|
2360
2391
|
{
|
|
2361
2392
|
"script": `
|
|
2362
|
-
let cms_url =
|
|
2393
|
+
let cms_url = '';
|
|
2394
|
+
let value = event.data.versions[0];
|
|
2395
|
+
if(value){
|
|
2396
|
+
if(value.url){
|
|
2397
|
+
cms_url = value.url;
|
|
2398
|
+
}else{
|
|
2399
|
+
cms_url = "/api/files/files/"+value+"?download=true"
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2363
2402
|
Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
|
|
2364
2403
|
`,
|
|
2365
2404
|
"actionType": "custom"
|
|
@@ -2475,7 +2514,8 @@ async function getTableOperation(ctx){
|
|
|
2475
2514
|
label: " ",
|
|
2476
2515
|
fixed: 'right',
|
|
2477
2516
|
labelClassName: 'text-center',
|
|
2478
|
-
|
|
2517
|
+
//TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
|
|
2518
|
+
className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
|
|
2479
2519
|
buttons: [
|
|
2480
2520
|
{
|
|
2481
2521
|
"type": "steedos-dropdown-button",
|
|
@@ -2571,7 +2611,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2571
2611
|
}
|
|
2572
2612
|
return {
|
|
2573
2613
|
mode: "cards",
|
|
2574
|
-
perPageAvailable: [
|
|
2614
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2575
2615
|
name: "thelist",
|
|
2576
2616
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2577
2617
|
className: "",
|
|
@@ -2604,7 +2644,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2604
2644
|
|
|
2605
2645
|
return {
|
|
2606
2646
|
mode: "table",
|
|
2607
|
-
perPageAvailable: [
|
|
2647
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2608
2648
|
name: "thelist",
|
|
2609
2649
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2610
2650
|
className: "",
|
|
@@ -2990,6 +3030,16 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2990
3030
|
}
|
|
2991
3031
|
// SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
2992
3032
|
};
|
|
3033
|
+
let formFactor = "${options.formFactor}";
|
|
3034
|
+
if(formFactor !== "SMALL"){
|
|
3035
|
+
const listviewComponent = $(".steedos-object-listview .antd-Table-table");
|
|
3036
|
+
const firstListviewComponent = listviewComponent && listviewComponent[0];
|
|
3037
|
+
if(firstListviewComponent){
|
|
3038
|
+
setTimeout(()=>{
|
|
3039
|
+
firstListviewComponent.scrollIntoView();
|
|
3040
|
+
}, 600);
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
2993
3043
|
${options.adaptor || ''}
|
|
2994
3044
|
return payload;
|
|
2995
3045
|
`;
|
|
@@ -3101,12 +3151,21 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3101
3151
|
}
|
|
3102
3152
|
payload.data = data;
|
|
3103
3153
|
payload.data.__objectName = "${object.name}";
|
|
3104
|
-
payload.data.
|
|
3154
|
+
payload.data.record = record;
|
|
3155
|
+
|
|
3156
|
+
payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
|
|
3157
|
+
payload.data._master = {
|
|
3158
|
+
record: record,
|
|
3159
|
+
objectName: "${object.name}",
|
|
3160
|
+
recordId: record._id
|
|
3161
|
+
}
|
|
3105
3162
|
window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
|
|
3106
3163
|
}
|
|
3107
3164
|
if(payload.errors){
|
|
3108
3165
|
payload.status = 2;
|
|
3109
3166
|
payload.msg = payload.errors[0].message;
|
|
3167
|
+
}else{
|
|
3168
|
+
payload.data.recordLoaded = true;
|
|
3110
3169
|
}
|
|
3111
3170
|
${options && options.initApiAdaptor || ''}
|
|
3112
3171
|
return payload;
|
|
@@ -3249,7 +3308,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3249
3308
|
cache: API_CACHE,
|
|
3250
3309
|
requestAdaptor: `
|
|
3251
3310
|
// 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
|
|
3252
|
-
var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
|
|
3311
|
+
var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
|
|
3253
3312
|
if(!recordId){
|
|
3254
3313
|
// 新建则不请求任何数据
|
|
3255
3314
|
data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
|
|
@@ -3327,10 +3386,11 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3327
3386
|
...initialValues
|
|
3328
3387
|
}
|
|
3329
3388
|
${options.initApiAdaptor || ''}
|
|
3389
|
+
// console.log('getEditFormInitApi======>', payload);
|
|
3330
3390
|
return payload;
|
|
3331
3391
|
`,
|
|
3332
3392
|
responseData: {
|
|
3333
|
-
|
|
3393
|
+
"&": "$$",
|
|
3334
3394
|
editFormInited: true
|
|
3335
3395
|
},
|
|
3336
3396
|
data: data,
|
|
@@ -3369,6 +3429,18 @@ function getBatchDelete(objectName){
|
|
|
3369
3429
|
return {
|
|
3370
3430
|
method: 'post',
|
|
3371
3431
|
url: getApi$2(),
|
|
3432
|
+
adaptor: `
|
|
3433
|
+
if(payload.errors){
|
|
3434
|
+
payload.data.deleteErrorMessage = [];
|
|
3435
|
+
payload.errors.forEach(function(error){
|
|
3436
|
+
let errorRecord = error.path.map(function (item) {
|
|
3437
|
+
return item.split('delete__')[1].to_float() + 1;
|
|
3438
|
+
}).toString();
|
|
3439
|
+
payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
|
|
3440
|
+
})
|
|
3441
|
+
}
|
|
3442
|
+
return payload;
|
|
3443
|
+
`,
|
|
3372
3444
|
requestAdaptor: `
|
|
3373
3445
|
var ids = api.data.ids.split(",");
|
|
3374
3446
|
var deleteArray = [];
|
|
@@ -4163,7 +4235,7 @@ async function getListBody(fields, options){
|
|
|
4163
4235
|
|
|
4164
4236
|
function getDefaultParams(options){
|
|
4165
4237
|
return {
|
|
4166
|
-
perPage: options.top || options.perPage ||
|
|
4238
|
+
perPage: options.top || options.perPage || 20
|
|
4167
4239
|
}
|
|
4168
4240
|
}
|
|
4169
4241
|
|
|
@@ -4366,7 +4438,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
4366
4438
|
"objectApiName": "\${objectName}",
|
|
4367
4439
|
"recordId": "",
|
|
4368
4440
|
"mode": "edit",
|
|
4369
|
-
"layout": "normal"
|
|
4370
4441
|
};
|
|
4371
4442
|
|
|
4372
4443
|
if (payload && payload.schema) {
|
|
@@ -5071,7 +5142,7 @@ const StandardButtons = {
|
|
|
5071
5142
|
}
|
|
5072
5143
|
};
|
|
5073
5144
|
|
|
5074
|
-
const getGlobalData
|
|
5145
|
+
const getGlobalData = () => {
|
|
5075
5146
|
return {
|
|
5076
5147
|
now: new Date(),
|
|
5077
5148
|
};
|
|
@@ -5130,7 +5201,7 @@ const getButtonVisible = (button, ctx) => {
|
|
|
5130
5201
|
button._visible,
|
|
5131
5202
|
props.record,
|
|
5132
5203
|
"#",
|
|
5133
|
-
getGlobalData
|
|
5204
|
+
getGlobalData(),
|
|
5134
5205
|
props.userSession
|
|
5135
5206
|
);
|
|
5136
5207
|
};
|
|
@@ -6508,6 +6579,48 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6508
6579
|
return headerSchema;
|
|
6509
6580
|
}
|
|
6510
6581
|
|
|
6582
|
+
function getBackButtonSchema(){
|
|
6583
|
+
return {
|
|
6584
|
+
"type": "service",
|
|
6585
|
+
"onEvent": {
|
|
6586
|
+
"@history_paths.changed": {
|
|
6587
|
+
"actions": [
|
|
6588
|
+
{
|
|
6589
|
+
"actionType": "reload",
|
|
6590
|
+
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6591
|
+
"data": {
|
|
6592
|
+
}
|
|
6593
|
+
}
|
|
6594
|
+
]
|
|
6595
|
+
}
|
|
6596
|
+
},
|
|
6597
|
+
"body":[{
|
|
6598
|
+
"type": "button",
|
|
6599
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6600
|
+
"className":"flex mr-4",
|
|
6601
|
+
"onEvent": {
|
|
6602
|
+
"click": {
|
|
6603
|
+
"actions": [
|
|
6604
|
+
{
|
|
6605
|
+
"actionType": "custom",
|
|
6606
|
+
"script": "window.goBack()"
|
|
6607
|
+
}
|
|
6608
|
+
]
|
|
6609
|
+
}
|
|
6610
|
+
},
|
|
6611
|
+
"body": [
|
|
6612
|
+
{
|
|
6613
|
+
"type": "steedos-icon",
|
|
6614
|
+
"category": "utility",
|
|
6615
|
+
"name": "back",
|
|
6616
|
+
"colorVariant": "default",
|
|
6617
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6618
|
+
}
|
|
6619
|
+
]
|
|
6620
|
+
}]
|
|
6621
|
+
}
|
|
6622
|
+
}
|
|
6623
|
+
|
|
6511
6624
|
/**
|
|
6512
6625
|
* 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
|
|
6513
6626
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -6516,11 +6629,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6516
6629
|
* @returns amisSchema
|
|
6517
6630
|
*/
|
|
6518
6631
|
async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
6632
|
+
// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
6519
6633
|
const { showRecordTitle = true } = options || {};
|
|
6520
6634
|
// console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
|
|
6521
6635
|
const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
|
|
6522
6636
|
|
|
6523
|
-
let amisButtonsSchema =
|
|
6637
|
+
let amisButtonsSchema = [];
|
|
6638
|
+
if(options.showButtons != false){
|
|
6639
|
+
amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
|
|
6640
|
+
}
|
|
6641
|
+
|
|
6642
|
+
let backButtonsSchema = null;
|
|
6643
|
+
|
|
6644
|
+
if(options.showBackButton != false){
|
|
6645
|
+
backButtonsSchema = getBackButtonSchema();
|
|
6646
|
+
}
|
|
6524
6647
|
|
|
6525
6648
|
// console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
|
|
6526
6649
|
|
|
@@ -6535,45 +6658,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6535
6658
|
"type": "grid",
|
|
6536
6659
|
"columns": [
|
|
6537
6660
|
{
|
|
6538
|
-
"body": [
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
"@history_paths.changed": {
|
|
6542
|
-
"actions": [
|
|
6543
|
-
{
|
|
6544
|
-
"actionType": "reload",
|
|
6545
|
-
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6546
|
-
"data": {
|
|
6547
|
-
}
|
|
6548
|
-
}
|
|
6549
|
-
]
|
|
6550
|
-
}
|
|
6551
|
-
},
|
|
6552
|
-
"body":[{
|
|
6553
|
-
"type": "button",
|
|
6554
|
-
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6555
|
-
"className":"flex mr-4",
|
|
6556
|
-
"onEvent": {
|
|
6557
|
-
"click": {
|
|
6558
|
-
"actions": [
|
|
6559
|
-
{
|
|
6560
|
-
"actionType": "custom",
|
|
6561
|
-
"script": "window.goBack()"
|
|
6562
|
-
}
|
|
6563
|
-
]
|
|
6564
|
-
}
|
|
6565
|
-
},
|
|
6566
|
-
"body": [
|
|
6567
|
-
{
|
|
6568
|
-
"type": "steedos-icon",
|
|
6569
|
-
"category": "utility",
|
|
6570
|
-
"name": "back",
|
|
6571
|
-
"colorVariant": "default",
|
|
6572
|
-
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6573
|
-
}
|
|
6574
|
-
]
|
|
6575
|
-
}]
|
|
6576
|
-
},{
|
|
6661
|
+
"body": [
|
|
6662
|
+
backButtonsSchema
|
|
6663
|
+
,{
|
|
6577
6664
|
"type": "tpl",
|
|
6578
6665
|
"className": "block",
|
|
6579
6666
|
// "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'>`
|
|
@@ -6594,8 +6681,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6594
6681
|
},
|
|
6595
6682
|
{
|
|
6596
6683
|
"type": "tpl",
|
|
6597
|
-
"tpl": "${
|
|
6598
|
-
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
6684
|
+
"tpl": "${NAME_FIELD_VALUE}",
|
|
6599
6685
|
"inline": false,
|
|
6600
6686
|
"wrapperComponent": "",
|
|
6601
6687
|
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
@@ -6623,7 +6709,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6623
6709
|
let body = [
|
|
6624
6710
|
{
|
|
6625
6711
|
"type": "wrapper",
|
|
6626
|
-
"className": "p-
|
|
6712
|
+
"className": "p-4 bg-gray-100 border-b",
|
|
6627
6713
|
"body": [
|
|
6628
6714
|
{
|
|
6629
6715
|
"type": "grid",
|
|
@@ -6638,7 +6724,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6638
6724
|
if(showRecordTitle){
|
|
6639
6725
|
body.push({
|
|
6640
6726
|
"type": "wrapper",
|
|
6641
|
-
"className": "p-
|
|
6727
|
+
"className": "p-4",
|
|
6642
6728
|
"body": [
|
|
6643
6729
|
{
|
|
6644
6730
|
"type": "grid",
|
|
@@ -6650,11 +6736,76 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6650
6736
|
});
|
|
6651
6737
|
}
|
|
6652
6738
|
|
|
6739
|
+
let max = 10;
|
|
6740
|
+
if(options.formFactor === 'SMALL'){
|
|
6741
|
+
max = 4;
|
|
6742
|
+
}else {
|
|
6743
|
+
|
|
6744
|
+
let divWidth = window.innerWidth;
|
|
6745
|
+
|
|
6746
|
+
if(options.display === 'split'){
|
|
6747
|
+
divWidth = divWidth - 388;
|
|
6748
|
+
}
|
|
6749
|
+
|
|
6750
|
+
if(document.body.classList.contains('sidebar')){
|
|
6751
|
+
divWidth = divWidth - 210;
|
|
6752
|
+
}
|
|
6753
|
+
|
|
6754
|
+
// 根据屏幕宽度计算显示数量, 使高亮字段只占1行
|
|
6755
|
+
max = Math.trunc(divWidth / 200 );
|
|
6756
|
+
if(max > 10){
|
|
6757
|
+
max = 10;
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
|
|
6761
|
+
// console.log('=======================max=========================', max)
|
|
6762
|
+
|
|
6763
|
+
if(objectSchema.compactLayouts){
|
|
6764
|
+
const details = [];
|
|
6765
|
+
_.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
|
|
6766
|
+
const field = objectSchema.fields[fieldName];
|
|
6767
|
+
if(field){
|
|
6768
|
+
details.push({
|
|
6769
|
+
type: 'steedos-field',
|
|
6770
|
+
static: true,
|
|
6771
|
+
config: field,
|
|
6772
|
+
});
|
|
6773
|
+
}
|
|
6774
|
+
});
|
|
6775
|
+
|
|
6776
|
+
// 注意: 以下注释不能删除. tailwind css 动态编译时会识别以下注释, 生成对应的样式
|
|
6777
|
+
// lg:grid-cols-1
|
|
6778
|
+
// lg:grid-cols-2
|
|
6779
|
+
// lg:grid-cols-3
|
|
6780
|
+
// lg:grid-cols-4
|
|
6781
|
+
// lg:grid-cols-5
|
|
6782
|
+
// lg:grid-cols-6
|
|
6783
|
+
// lg:grid-cols-7
|
|
6784
|
+
// lg:grid-cols-8
|
|
6785
|
+
// lg:grid-cols-9
|
|
6786
|
+
// lg:grid-cols-10
|
|
6787
|
+
// lg:grid-cols-11
|
|
6788
|
+
// lg:grid-cols-12
|
|
6789
|
+
|
|
6790
|
+
body.push({
|
|
6791
|
+
"type": "wrapper",
|
|
6792
|
+
"body": {
|
|
6793
|
+
"type": "form",
|
|
6794
|
+
// "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
|
|
6795
|
+
"className": `gap-2 grid grid-cols-1 lg:grid-cols-${max}`,
|
|
6796
|
+
"wrapWithPanel": false,
|
|
6797
|
+
"actions": [],
|
|
6798
|
+
"body": details,
|
|
6799
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
6800
|
+
},
|
|
6801
|
+
"className": "steedos-record-compact-layouts p-4 bg-white compact-layouts border-b"
|
|
6802
|
+
});
|
|
6803
|
+
}
|
|
6804
|
+
|
|
6653
6805
|
return {
|
|
6654
6806
|
type: 'service',
|
|
6655
6807
|
id: `page_readonly_${name}_header`,
|
|
6656
6808
|
name: `page`,
|
|
6657
|
-
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
6658
6809
|
body: body,
|
|
6659
6810
|
className: ''
|
|
6660
6811
|
}
|
|
@@ -6726,7 +6877,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
6726
6877
|
"className": "flex justify-between"
|
|
6727
6878
|
}
|
|
6728
6879
|
],
|
|
6729
|
-
"className": "
|
|
6880
|
+
"className": "steedos-record-related-header py-2 px-0"
|
|
6730
6881
|
};
|
|
6731
6882
|
return recordRelatedListHeader;
|
|
6732
6883
|
}
|
|
@@ -7711,14 +7862,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
7711
7862
|
{
|
|
7712
7863
|
"type": "button",
|
|
7713
7864
|
"label": i18next.t('frontend_display_type_is_table'),
|
|
7714
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7865
|
+
"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');",
|
|
7715
7866
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
7716
7867
|
"rightIconClassName": "m-l-sm"
|
|
7717
7868
|
},
|
|
7718
7869
|
{
|
|
7719
7870
|
"type": "button",
|
|
7720
7871
|
"label": i18next.t('frontend_display_type_is_split'),
|
|
7721
|
-
"onClick": "const key = 'tab_"+objectName+"_display';
|
|
7872
|
+
"onClick": "const key = 'tab_"+objectName+"_display';sessionStorage.setItem(key, 'split');const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
|
|
7722
7873
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
7723
7874
|
"rightIconClassName": "m-l-sm"
|
|
7724
7875
|
}
|
|
@@ -7861,7 +8012,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7861
8012
|
{
|
|
7862
8013
|
"type": "search-box",
|
|
7863
8014
|
"name": keywordsSearchBoxName,
|
|
7864
|
-
"placeholder": "
|
|
8015
|
+
"placeholder": "快捷搜索",
|
|
7865
8016
|
"value": crudKeywords,
|
|
7866
8017
|
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7867
8018
|
"clearAndSubmit": true,
|
|
@@ -8065,7 +8216,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8065
8216
|
// ]
|
|
8066
8217
|
if(options.displayAs === 'split'){
|
|
8067
8218
|
return [
|
|
8068
|
-
|
|
8219
|
+
{
|
|
8220
|
+
"type": "switch-per-page",
|
|
8221
|
+
"visibleOn": "${count >= 20}"
|
|
8222
|
+
},
|
|
8069
8223
|
{
|
|
8070
8224
|
"type": "pagination",
|
|
8071
8225
|
"maxButtons": 5,
|
|
@@ -8087,7 +8241,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8087
8241
|
else {
|
|
8088
8242
|
if(options && options.isRelated){
|
|
8089
8243
|
return [
|
|
8090
|
-
"statistics",
|
|
8091
8244
|
{
|
|
8092
8245
|
"type": "pagination",
|
|
8093
8246
|
"maxButtons": 10,
|
|
@@ -8100,7 +8253,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8100
8253
|
const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
|
|
8101
8254
|
const is_lookup = options.isLookup;
|
|
8102
8255
|
const commonConfig = [
|
|
8103
|
-
"statistics",
|
|
8104
8256
|
{
|
|
8105
8257
|
"type": "pagination",
|
|
8106
8258
|
"maxButtons": 10,
|
|
@@ -8111,7 +8263,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8111
8263
|
if (no_pagination && is_lookup) {
|
|
8112
8264
|
return commonConfig;
|
|
8113
8265
|
} else {
|
|
8114
|
-
return [
|
|
8266
|
+
return [{
|
|
8267
|
+
"type": "switch-per-page",
|
|
8268
|
+
"visibleOn": "${count >= 20}"
|
|
8269
|
+
}, ...commonConfig];
|
|
8115
8270
|
}
|
|
8116
8271
|
}
|
|
8117
8272
|
}
|
|
@@ -8219,6 +8374,29 @@ function getBulkActions(objectSchema){
|
|
|
8219
8374
|
"className": "hidden",
|
|
8220
8375
|
"id": "batchDelete",
|
|
8221
8376
|
"api": getBatchDelete(objectSchema.name),
|
|
8377
|
+
"feedback": {
|
|
8378
|
+
"title": "删除警告",
|
|
8379
|
+
"visibleOn": "${deleteErrorMessage}",
|
|
8380
|
+
"body": [
|
|
8381
|
+
{
|
|
8382
|
+
"type": "each",
|
|
8383
|
+
"name": "deleteErrorMessage",
|
|
8384
|
+
"items": {
|
|
8385
|
+
"type": "alert",
|
|
8386
|
+
"body": "${item}",
|
|
8387
|
+
"level": "danger",
|
|
8388
|
+
"className": "mb-3"
|
|
8389
|
+
}
|
|
8390
|
+
}
|
|
8391
|
+
],
|
|
8392
|
+
"actions": [
|
|
8393
|
+
{
|
|
8394
|
+
"type": "button",
|
|
8395
|
+
"actionType": "close",
|
|
8396
|
+
"label": "关闭"
|
|
8397
|
+
}
|
|
8398
|
+
]
|
|
8399
|
+
}
|
|
8222
8400
|
}
|
|
8223
8401
|
// {
|
|
8224
8402
|
// "label": "批量修改",
|
|
@@ -8365,6 +8543,10 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8365
8543
|
const rowsDiff = _.cloneDeep(api.data.rowsDiff);
|
|
8366
8544
|
rowsDiff.forEach(function (item, index) {
|
|
8367
8545
|
for(key in item){
|
|
8546
|
+
// image、select等字段清空值后保存的空字符串转换为null。
|
|
8547
|
+
if(item[key] === ''){
|
|
8548
|
+
item[key] = null;
|
|
8549
|
+
}
|
|
8368
8550
|
if(_.includes(imageNames, key)){
|
|
8369
8551
|
if(typeof item[key] == "string"){
|
|
8370
8552
|
const match = item[key].match(/\\/([^\\/]+)$/);
|
|
@@ -8411,7 +8593,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8411
8593
|
// "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8412
8594
|
// },
|
|
8413
8595
|
bodyClassName: {
|
|
8414
|
-
"
|
|
8596
|
+
"mb-0": true,
|
|
8415
8597
|
"is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8416
8598
|
},
|
|
8417
8599
|
crudClassName: crudClassName,
|
|
@@ -8431,7 +8613,9 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8431
8613
|
return payload;
|
|
8432
8614
|
`
|
|
8433
8615
|
},
|
|
8434
|
-
rowClassNameExpr
|
|
8616
|
+
// 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
|
|
8617
|
+
// 使用表达式给tr添加初始选中状态
|
|
8618
|
+
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 %>"
|
|
8435
8619
|
}, bodyProps);
|
|
8436
8620
|
|
|
8437
8621
|
}
|
|
@@ -8446,7 +8630,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8446
8630
|
|
|
8447
8631
|
if(body.columns && options.formFactor != 'SMALL'){
|
|
8448
8632
|
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8449
|
-
body.columns.splice(body.columns.length -
|
|
8633
|
+
body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
|
|
8450
8634
|
}
|
|
8451
8635
|
|
|
8452
8636
|
if (defaults) {
|
|
@@ -8504,11 +8688,6 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8504
8688
|
}
|
|
8505
8689
|
}
|
|
8506
8690
|
|
|
8507
|
-
const getGlobalData = (mode)=>{
|
|
8508
|
-
const user = getSteedosAuth();
|
|
8509
|
-
return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
|
|
8510
|
-
};
|
|
8511
|
-
|
|
8512
8691
|
const getFormFields$1 = (objectSchema, formProps)=>{
|
|
8513
8692
|
/**
|
|
8514
8693
|
* fieldsExtend: 重写字段定义
|
|
@@ -8570,7 +8749,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
|
|
|
8570
8749
|
}
|
|
8571
8750
|
|
|
8572
8751
|
async function getObjectForm(objectSchema, ctx){
|
|
8573
|
-
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8752
|
+
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
|
|
8574
8753
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8575
8754
|
const fields = ___default.values(objectSchema.fields);
|
|
8576
8755
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8586,9 +8765,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8586
8765
|
id: `service_${formSchema.id}`,
|
|
8587
8766
|
className: 'p-0',
|
|
8588
8767
|
name: `page_edit_${recordId}`,
|
|
8589
|
-
api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8590
8768
|
data:{
|
|
8591
|
-
editFormInited: false,
|
|
8592
8769
|
...amisData
|
|
8593
8770
|
},
|
|
8594
8771
|
// data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
@@ -8597,8 +8774,9 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8597
8774
|
body: [defaultsDeep({}, formSchema, {
|
|
8598
8775
|
type: "form",
|
|
8599
8776
|
mode: layout,
|
|
8777
|
+
initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8600
8778
|
data: {
|
|
8601
|
-
|
|
8779
|
+
editFormInited: false,
|
|
8602
8780
|
},
|
|
8603
8781
|
labelAlign,
|
|
8604
8782
|
persistData: false,
|
|
@@ -8612,11 +8790,15 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8612
8790
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
8613
8791
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
8614
8792
|
initFetch: recordId != 'new',
|
|
8615
|
-
body:
|
|
8793
|
+
body: {
|
|
8794
|
+
type: 'wrapper',
|
|
8795
|
+
className: 'p-0 m-0',
|
|
8796
|
+
body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
|
|
8797
|
+
hiddenOn: "${editFormInited != true}",
|
|
8798
|
+
},
|
|
8616
8799
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
8617
8800
|
bodyClassName: 'p-0',
|
|
8618
8801
|
className: 'steedos-amis-form',
|
|
8619
|
-
hiddenOn: "${editFormInited != true}",
|
|
8620
8802
|
onEvent: {
|
|
8621
8803
|
"submitSucc": {
|
|
8622
8804
|
"weight": 0,
|
|
@@ -8661,7 +8843,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8661
8843
|
}
|
|
8662
8844
|
|
|
8663
8845
|
async function getObjectDetail(objectSchema, recordId, ctx){
|
|
8664
|
-
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8846
|
+
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
|
|
8665
8847
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8666
8848
|
const fields = ___default.values(objectSchema.fields);
|
|
8667
8849
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8670,8 +8852,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8670
8852
|
type: 'service',
|
|
8671
8853
|
name: `page_readonly_${recordId}`,
|
|
8672
8854
|
id: serviceId,
|
|
8673
|
-
|
|
8674
|
-
api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8855
|
+
// api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8675
8856
|
body: [
|
|
8676
8857
|
{
|
|
8677
8858
|
"type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
|
|
@@ -8697,60 +8878,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8697
8878
|
),
|
|
8698
8879
|
className: 'steedos-amis-form bg-white',
|
|
8699
8880
|
actions: [], // 不显示表单默认的提交按钮
|
|
8700
|
-
onEvent: {
|
|
8701
|
-
[`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
|
|
8702
|
-
"actions": [
|
|
8703
|
-
{
|
|
8704
|
-
"actionType": "reload",
|
|
8705
|
-
"componentId": serviceId,
|
|
8706
|
-
"expression": "this.__deletedRecord != true"
|
|
8707
|
-
},
|
|
8708
|
-
{
|
|
8709
|
-
// "args": {
|
|
8710
|
-
// "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
|
|
8711
|
-
// "blank": false
|
|
8712
|
-
// },
|
|
8713
|
-
"actionType": "custom",
|
|
8714
|
-
"script": "window.goBack()",
|
|
8715
|
-
"expression": "this.__deletedRecord === true"
|
|
8716
|
-
}
|
|
8717
|
-
]
|
|
8718
|
-
}
|
|
8719
|
-
}
|
|
8720
8881
|
},
|
|
8721
8882
|
}
|
|
8722
8883
|
],
|
|
8723
|
-
onEvent: {
|
|
8724
|
-
|
|
8725
|
-
|
|
8726
|
-
|
|
8727
|
-
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
}
|
|
8884
|
+
// onEvent: {
|
|
8885
|
+
// "fetchInited": {
|
|
8886
|
+
// "weight": 0,
|
|
8887
|
+
// "actions": [
|
|
8888
|
+
// {
|
|
8889
|
+
// actionType: 'broadcast',
|
|
8890
|
+
// eventName: "recordLoaded",
|
|
8891
|
+
// args: {
|
|
8892
|
+
// eventName: "recordLoaded"
|
|
8893
|
+
// },
|
|
8894
|
+
// data: {
|
|
8895
|
+
// objectName: "${event.data.__objectName}",
|
|
8896
|
+
// record: "${event.data.__record}"
|
|
8897
|
+
// },
|
|
8898
|
+
// expression: "${event.data.__response.error != true}"
|
|
8899
|
+
// },
|
|
8900
|
+
// {
|
|
8901
|
+
// "actionType": "setValue",
|
|
8902
|
+
// "args": {
|
|
8903
|
+
// value: {
|
|
8904
|
+
// "recordLoaded": true,
|
|
8905
|
+
// }
|
|
8906
|
+
// },
|
|
8907
|
+
// expression: "${event.data.__response.error != true}"
|
|
8908
|
+
// }
|
|
8909
|
+
// ]
|
|
8910
|
+
// }
|
|
8911
|
+
// }
|
|
8751
8912
|
};
|
|
8752
8913
|
|
|
8753
8914
|
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
8915
|
+
// console.log('getObjectDetail=====>', amisSchema);
|
|
8754
8916
|
return amisSchema;
|
|
8755
8917
|
}
|
|
8756
8918
|
|
|
@@ -8830,8 +8992,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
8830
8992
|
/*
|
|
8831
8993
|
* @Author: baozhoutao@steedos.com
|
|
8832
8994
|
* @Date: 2022-07-05 15:55:39
|
|
8833
|
-
* @LastEditors:
|
|
8834
|
-
* @LastEditTime:
|
|
8995
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
8996
|
+
* @LastEditTime: 2024-01-15 10:34:46
|
|
8835
8997
|
* @Description:
|
|
8836
8998
|
*/
|
|
8837
8999
|
|
|
@@ -9006,7 +9168,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9006
9168
|
setDataToComponentId: componentId,
|
|
9007
9169
|
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
9008
9170
|
appId: appId,
|
|
9009
|
-
crudClassName: '
|
|
9171
|
+
crudClassName: 'steedos-record-related-crud hidden',
|
|
9010
9172
|
refField,
|
|
9011
9173
|
...ctx
|
|
9012
9174
|
};
|
|
@@ -9019,7 +9181,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9019
9181
|
amisSchema: {
|
|
9020
9182
|
type: "service",
|
|
9021
9183
|
id: componentId,
|
|
9022
|
-
className: `steedos-record-related-list
|
|
9184
|
+
className: `steedos-record-related-list py-2 first:pt-0 border-b last:border-b-0 ${componentId} ${className}`,
|
|
9023
9185
|
data: {
|
|
9024
9186
|
relatedKey: relatedKey,
|
|
9025
9187
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
@@ -9211,11 +9373,44 @@ async function getRelatedListSchema(
|
|
|
9211
9373
|
};
|
|
9212
9374
|
}
|
|
9213
9375
|
|
|
9376
|
+
async function getObjectRelatedListsMiniSchema(objectApiName){
|
|
9377
|
+
const relatedLists = await getObjectRelatedList(objectApiName);
|
|
9378
|
+
|
|
9379
|
+
const relatedListsMiniSchema = [];
|
|
9380
|
+
|
|
9381
|
+
for (const relatedList of relatedLists) {
|
|
9382
|
+
relatedListsMiniSchema.push(
|
|
9383
|
+
{
|
|
9384
|
+
type: 'steedos-record-detail-list-mini',
|
|
9385
|
+
objectApiName: objectApiName,
|
|
9386
|
+
// recordId: recordId,
|
|
9387
|
+
formFactor: formFactor,
|
|
9388
|
+
relatedObjectApiName: relatedList.object_name,
|
|
9389
|
+
foreign_key: relatedList.foreign_key,
|
|
9390
|
+
relatedKey: relatedList.foreign_key,
|
|
9391
|
+
columns: relatedList.columns,
|
|
9392
|
+
sort: relatedList.sort,
|
|
9393
|
+
filters: relatedList.filters,
|
|
9394
|
+
visible_on: relatedList.visible_on,
|
|
9395
|
+
perPage: relatedList.page_size || perPage,
|
|
9396
|
+
hiddenEmptyTable: true,
|
|
9397
|
+
relatedLabel: relatedList.label
|
|
9398
|
+
}
|
|
9399
|
+
);
|
|
9400
|
+
}
|
|
9401
|
+
|
|
9402
|
+
return {
|
|
9403
|
+
type: 'wrapper',
|
|
9404
|
+
className: "steedos-record-detail-related-lists-mini",
|
|
9405
|
+
body: relatedListsMiniSchema
|
|
9406
|
+
}
|
|
9407
|
+
}
|
|
9408
|
+
|
|
9214
9409
|
/*
|
|
9215
9410
|
* @Author: baozhoutao@steedos.com
|
|
9216
9411
|
* @Date: 2022-07-05 15:55:39
|
|
9217
|
-
* @LastEditors:
|
|
9218
|
-
* @LastEditTime:
|
|
9412
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9413
|
+
* @LastEditTime: 2024-01-16 11:14:34
|
|
9219
9414
|
* @Description:
|
|
9220
9415
|
*/
|
|
9221
9416
|
|
|
@@ -9387,7 +9582,7 @@ async function getField(objectName, fieldName) {
|
|
|
9387
9582
|
async function getFormSchema(objectName, ctx) {
|
|
9388
9583
|
const uiSchema = await getUISchema(objectName);
|
|
9389
9584
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
9390
|
-
console.log(`getFormSchema====>`, amisSchema)
|
|
9585
|
+
// console.log(`getFormSchema====>`, amisSchema)
|
|
9391
9586
|
return {
|
|
9392
9587
|
uiSchema,
|
|
9393
9588
|
amisSchema,
|
|
@@ -9713,110 +9908,164 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9713
9908
|
"label": "对象表单",
|
|
9714
9909
|
"objectApiName": "${objectName}",
|
|
9715
9910
|
"recordId": "${recordId}",
|
|
9716
|
-
"id": "u:d4a495811d57",
|
|
9717
9911
|
appId: appId
|
|
9718
9912
|
}
|
|
9719
9913
|
],
|
|
9720
|
-
"id": "u:5d4e7e3f6ecc"
|
|
9721
9914
|
};
|
|
9722
9915
|
const related = {
|
|
9723
9916
|
"title": i18next.t('frontend_record_detail_tab_related'),
|
|
9724
|
-
"className": "px-0
|
|
9917
|
+
"className": "px-0 py-4",
|
|
9725
9918
|
"body": [
|
|
9726
9919
|
{
|
|
9727
9920
|
"type": "steedos-object-related-lists",
|
|
9728
9921
|
"label": "相关列表",
|
|
9729
9922
|
"objectApiName": "${objectName}",
|
|
9730
9923
|
"recordId": "${recordId}",
|
|
9731
|
-
"id": "u:3b85b7b7a7f6",
|
|
9732
9924
|
appId: appId
|
|
9733
9925
|
}
|
|
9734
9926
|
],
|
|
9735
|
-
"id": "u:1a0326aeec2b"
|
|
9736
9927
|
};
|
|
9737
9928
|
const content = {
|
|
9738
9929
|
"type": "tabs",
|
|
9739
|
-
"className": "
|
|
9930
|
+
"className": "steedos-record-tabs bg-white p-4 m-0 mt-2 border-y",
|
|
9931
|
+
"contentClassName": "bg-none",
|
|
9740
9932
|
"tabs": [
|
|
9741
9933
|
detailed
|
|
9742
9934
|
],
|
|
9743
|
-
"id": "u:a649e4094a12"
|
|
9744
9935
|
};
|
|
9745
9936
|
if(relatedLists.length){
|
|
9746
9937
|
content.tabs.push(related);
|
|
9747
9938
|
}
|
|
9939
|
+
// content.tabs = reverse(content.tabs)
|
|
9748
9940
|
return {
|
|
9749
9941
|
uiSchema,
|
|
9750
9942
|
amisSchema: {
|
|
9751
|
-
"type": "service",
|
|
9943
|
+
"type": "steedos-record-service",
|
|
9752
9944
|
"body": [
|
|
9753
9945
|
{
|
|
9754
9946
|
"type": "steedos-record-detail-header",
|
|
9755
9947
|
"label": "标题面板",
|
|
9756
9948
|
"objectApiName": "${objectName}",
|
|
9757
9949
|
"recordId": "${recordId}",
|
|
9758
|
-
"id": "u:48d2c28eb755"
|
|
9950
|
+
"id": "u:48d2c28eb755",
|
|
9951
|
+
"showButtons": props.showButtons,
|
|
9952
|
+
"showBackButton": props.showBackButton,
|
|
9759
9953
|
},
|
|
9760
9954
|
content
|
|
9761
9955
|
],
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
},
|
|
9766
|
-
onEvent: {
|
|
9767
|
-
"recordLoaded": {
|
|
9768
|
-
"actions": [
|
|
9769
|
-
{
|
|
9770
|
-
"actionType": "reload",
|
|
9771
|
-
"data": {
|
|
9772
|
-
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
9773
|
-
"_master.record": `\${record}`,
|
|
9774
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
9775
|
-
"_master.objectName": "${objectName}",
|
|
9776
|
-
"_master.recordId": "${recordId}"
|
|
9777
|
-
}
|
|
9778
|
-
}
|
|
9779
|
-
]
|
|
9780
|
-
},
|
|
9781
|
-
...props.onEvent
|
|
9782
|
-
},
|
|
9956
|
+
"objectApiName": "${objectName}",
|
|
9957
|
+
"recordId": "${recordId}",
|
|
9958
|
+
onEvent: props.onEvent,
|
|
9783
9959
|
}
|
|
9784
9960
|
}
|
|
9785
9961
|
}
|
|
9786
9962
|
|
|
9787
|
-
async function getRecordServiceSchema(objectName, appId, props = {}) {
|
|
9963
|
+
async function getRecordServiceSchema(objectName, appId, props = {}, body) {
|
|
9788
9964
|
const uiSchema = await getUISchema(objectName);
|
|
9965
|
+
const fields = ___default.values(uiSchema.fields);
|
|
9966
|
+
const serviceId = `u:steedos-record-service-${objectName}`;
|
|
9789
9967
|
return {
|
|
9790
9968
|
uiSchema,
|
|
9791
9969
|
amisSchema: {
|
|
9792
|
-
|
|
9793
|
-
"
|
|
9794
|
-
data: {
|
|
9795
|
-
"_master.objectName": "${objectName}",
|
|
9796
|
-
"_master.recordId": "${recordId}"
|
|
9797
|
-
},
|
|
9798
|
-
"style": {
|
|
9799
|
-
"padding": "var(--Page-body-padding)",
|
|
9800
|
-
...props.style
|
|
9801
|
-
},
|
|
9970
|
+
type: 'service',
|
|
9971
|
+
className: "p-0 m-0",
|
|
9802
9972
|
onEvent: {
|
|
9803
|
-
|
|
9973
|
+
[`@data.changed.${objectName}`]: {
|
|
9804
9974
|
"actions": [
|
|
9805
9975
|
{
|
|
9806
9976
|
"actionType": "reload",
|
|
9807
|
-
"
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9977
|
+
"componentId": serviceId,
|
|
9978
|
+
"expression": "this.__deletedRecord != true"
|
|
9979
|
+
},
|
|
9980
|
+
{
|
|
9981
|
+
"actionType": "custom",
|
|
9982
|
+
"script": "window.goBack()",
|
|
9983
|
+
"expression": "this.__deletedRecord === true"
|
|
9814
9984
|
}
|
|
9815
9985
|
]
|
|
9816
9986
|
},
|
|
9817
|
-
|
|
9987
|
+
},
|
|
9988
|
+
body: {
|
|
9989
|
+
"type": "service",
|
|
9990
|
+
id: serviceId,
|
|
9991
|
+
className: 'steedos-record-service p-0',
|
|
9992
|
+
api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
9993
|
+
body: {
|
|
9994
|
+
"type": "wrapper",
|
|
9995
|
+
"className": "p-0 m-0",
|
|
9996
|
+
"body": body || [],
|
|
9997
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
9998
|
+
},
|
|
9999
|
+
data: {
|
|
10000
|
+
"_master.objectName": "${objectName}",
|
|
10001
|
+
"_master.recordId": "${recordId}",
|
|
10002
|
+
...(props.data || {})
|
|
10003
|
+
},
|
|
10004
|
+
"style": {
|
|
10005
|
+
// "padding": "var(--Page-body-padding)",
|
|
10006
|
+
...props.style
|
|
10007
|
+
},
|
|
10008
|
+
onEvent: {
|
|
10009
|
+
// 如果定义了fetchInited,则无法接收到广播事件@data.changed
|
|
10010
|
+
"fetchInited": {
|
|
10011
|
+
"weight": 0,
|
|
10012
|
+
"actions": [
|
|
10013
|
+
{
|
|
10014
|
+
actionType: 'broadcast',
|
|
10015
|
+
eventName: "recordLoaded",
|
|
10016
|
+
data: {
|
|
10017
|
+
objectName: "${event.data.__objectName}",
|
|
10018
|
+
record: "${event.data.record}"
|
|
10019
|
+
},
|
|
10020
|
+
expression: "${event.data.__response.error != true}"
|
|
10021
|
+
},
|
|
10022
|
+
]
|
|
10023
|
+
},
|
|
10024
|
+
...props.onEvent
|
|
10025
|
+
}
|
|
9818
10026
|
}
|
|
9819
10027
|
}
|
|
10028
|
+
|
|
10029
|
+
|
|
10030
|
+
}
|
|
10031
|
+
}
|
|
10032
|
+
|
|
10033
|
+
async function getRecordDetailMiniSchema(objectName, appId, props = {}){
|
|
10034
|
+
const uiSchema = await getUISchema(objectName);
|
|
10035
|
+
const fields = ___default.values(uiSchema.fields);
|
|
10036
|
+
|
|
10037
|
+
props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
|
|
10038
|
+
|
|
10039
|
+
// TODO 处理相关表
|
|
10040
|
+
// getObjectRelatedListsMiniSchema
|
|
10041
|
+
|
|
10042
|
+
return {
|
|
10043
|
+
type: "form",
|
|
10044
|
+
wrapWithPanel: false,
|
|
10045
|
+
actions: [],
|
|
10046
|
+
initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
10047
|
+
body: {
|
|
10048
|
+
"type": "wrapper",
|
|
10049
|
+
"className": "p-0 m-0",
|
|
10050
|
+
"body": [
|
|
10051
|
+
{
|
|
10052
|
+
"type": "steedos-record-detail-header",
|
|
10053
|
+
"showButtons": false,
|
|
10054
|
+
"showBackButton": false,
|
|
10055
|
+
"objectApiName": "${objectName}",
|
|
10056
|
+
"recordId": "${recordId}",
|
|
10057
|
+
},
|
|
10058
|
+
// {
|
|
10059
|
+
// "type": "steedos-object-related-lists",
|
|
10060
|
+
// "label": "相关列表",
|
|
10061
|
+
// "objectApiName": "${objectName}",
|
|
10062
|
+
// "staticRecordId": "${recordId}",
|
|
10063
|
+
// formFactor: "SMALL",
|
|
10064
|
+
// appId: appId
|
|
10065
|
+
// }
|
|
10066
|
+
],
|
|
10067
|
+
"hiddenOn": "${_finished != true}"
|
|
10068
|
+
}
|
|
9820
10069
|
}
|
|
9821
10070
|
}
|
|
9822
10071
|
|
|
@@ -10757,9 +11006,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10757
11006
|
*/
|
|
10758
11007
|
if(enable_tree){
|
|
10759
11008
|
const rows = _.map(payload.data.rows, (item)=>{
|
|
10760
|
-
|
|
10761
|
-
|
|
10762
|
-
|
|
11009
|
+
if (!item.children) {
|
|
11010
|
+
return { ...item, children: [] };
|
|
11011
|
+
} else {
|
|
11012
|
+
return item;
|
|
11013
|
+
}
|
|
10763
11014
|
})
|
|
10764
11015
|
payload.data.rows = rows;
|
|
10765
11016
|
}
|
|
@@ -11208,9 +11459,17 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
11208
11459
|
}
|
|
11209
11460
|
// console.log(`lookupToAmis====`, field, readonly, ctx)
|
|
11210
11461
|
if(readonly){
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11462
|
+
if(field.reference_to){
|
|
11463
|
+
return {
|
|
11464
|
+
type: 'steedos-field',
|
|
11465
|
+
config: field,
|
|
11466
|
+
static: true
|
|
11467
|
+
}
|
|
11468
|
+
}else {
|
|
11469
|
+
return {
|
|
11470
|
+
type: getAmisStaticFieldType('picker', readonly),
|
|
11471
|
+
tpl: getRelatedFieldTpl(field, ctx)
|
|
11472
|
+
}
|
|
11214
11473
|
}
|
|
11215
11474
|
}
|
|
11216
11475
|
if(field.reference_to && !_$1.isString(field.reference_to) && !readonly){
|
|
@@ -12204,11 +12463,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12204
12463
|
if(field.subFields){
|
|
12205
12464
|
convertData = {
|
|
12206
12465
|
type: 'steedos-input-table',
|
|
12207
|
-
showIndex: true,
|
|
12208
12466
|
editable: !readonly,
|
|
12209
12467
|
addable: !readonly,
|
|
12210
12468
|
removable: !readonly,
|
|
12211
|
-
draggable: !readonly,
|
|
12212
12469
|
fields: [],
|
|
12213
12470
|
amis:{
|
|
12214
12471
|
columnsTogglable: false
|
|
@@ -12260,7 +12517,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12260
12517
|
if(field.is_wide || convertData.type === 'group'){
|
|
12261
12518
|
convertData.className = 'col-span-2 m-0';
|
|
12262
12519
|
}else {
|
|
12263
|
-
convertData.className = 'm-
|
|
12520
|
+
convertData.className = 'm-0';
|
|
12264
12521
|
}
|
|
12265
12522
|
if(readonly){
|
|
12266
12523
|
convertData.className = `${convertData.className} border-b`;
|
|
@@ -12285,6 +12542,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12285
12542
|
}
|
|
12286
12543
|
}
|
|
12287
12544
|
|
|
12545
|
+
if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
|
|
12546
|
+
convertData.className = `${convertData.className || ''} hidden`;
|
|
12547
|
+
}
|
|
12548
|
+
|
|
12288
12549
|
if(_$1.isString(baseData.required)){
|
|
12289
12550
|
if(baseData.required.startsWith("{{")){
|
|
12290
12551
|
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
@@ -12665,9 +12926,61 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12665
12926
|
/*
|
|
12666
12927
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12667
12928
|
* @Date: 2023-11-15 09:50:22
|
|
12668
|
-
* @LastEditors:
|
|
12669
|
-
* @LastEditTime: 2024-01-
|
|
12929
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12930
|
+
* @LastEditTime: 2024-01-18 10:29:57
|
|
12931
|
+
*/
|
|
12932
|
+
|
|
12933
|
+
/**
|
|
12934
|
+
* 子表组件字段值中每行数据的键值key移除指定前缀
|
|
12935
|
+
* @param {*} value 子表组件字段值,数组
|
|
12936
|
+
* @param {*} fieldPrefix 字段前缀
|
|
12937
|
+
* @returns 转换后的子表组件字段值
|
|
12938
|
+
*/
|
|
12939
|
+
function getTableValueWithoutFieldPrefix(value, fieldPrefix){
|
|
12940
|
+
let convertedValue = [];
|
|
12941
|
+
(value || []).forEach((itemValue)=>{
|
|
12942
|
+
var newItemValue = {};
|
|
12943
|
+
for(let n in itemValue){
|
|
12944
|
+
newItemValue[n.replace(new RegExp(`^${fieldPrefix}`), "")] = itemValue[n];
|
|
12945
|
+
}
|
|
12946
|
+
convertedValue.push(newItemValue);
|
|
12947
|
+
});
|
|
12948
|
+
return convertedValue;
|
|
12949
|
+
}
|
|
12950
|
+
|
|
12951
|
+
/**
|
|
12952
|
+
* 子表组件字段值中每行数据的键值key补上指定前缀
|
|
12953
|
+
* @param {*} value 子表组件字段值,数组
|
|
12954
|
+
* @param {*} fieldPrefix 字段前缀
|
|
12955
|
+
* @returns 转换后的子表组件字段值
|
|
12670
12956
|
*/
|
|
12957
|
+
function getTableValuePrependFieldPrefix(value, fieldPrefix){
|
|
12958
|
+
let convertedValue = [];
|
|
12959
|
+
(value || []).forEach((itemValue)=>{
|
|
12960
|
+
var newItemValue = {};
|
|
12961
|
+
for(let n in itemValue){
|
|
12962
|
+
if(typeof itemValue[n] !== undefined){
|
|
12963
|
+
newItemValue[`${fieldPrefix}${n}`] = itemValue[n];
|
|
12964
|
+
}
|
|
12965
|
+
}
|
|
12966
|
+
convertedValue.push(newItemValue);
|
|
12967
|
+
});
|
|
12968
|
+
return convertedValue;
|
|
12969
|
+
}
|
|
12970
|
+
|
|
12971
|
+
/**
|
|
12972
|
+
* 子表组件字段集合属性中每个字段name移除指定前缀
|
|
12973
|
+
* @param {*} fields 子表组件字段集合,数组
|
|
12974
|
+
* @param {*} fieldPrefix 字段前缀
|
|
12975
|
+
* @returns 转换后的子表组件字段值
|
|
12976
|
+
*/
|
|
12977
|
+
function getTableFieldsWithoutFieldPrefix(fields, fieldPrefix){
|
|
12978
|
+
return (fields || []).map((item) => {
|
|
12979
|
+
const newItem = clone(item);//这里不clone的话,会造成子表组件重新render,从而审批王那边点开子表行编辑窗口时报错
|
|
12980
|
+
newItem.name = newItem.name.replace(new RegExp(`^${fieldPrefix}`), "");
|
|
12981
|
+
return newItem;
|
|
12982
|
+
});
|
|
12983
|
+
}
|
|
12671
12984
|
|
|
12672
12985
|
/**
|
|
12673
12986
|
* @param {*} props
|
|
@@ -12815,7 +13128,19 @@ function getFormPagination(props, mode) {
|
|
|
12815
13128
|
let currentIndex = event.data.index;
|
|
12816
13129
|
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12817
13130
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12818
|
-
|
|
13131
|
+
var parent = event.data.parent;
|
|
13132
|
+
var __parentIndex = event.data.__parentIndex;
|
|
13133
|
+
if(parent){
|
|
13134
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13135
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13136
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13137
|
+
children: fieldValue[__parentIndex].children,
|
|
13138
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13139
|
+
});
|
|
13140
|
+
}
|
|
13141
|
+
else{
|
|
13142
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13143
|
+
}
|
|
12819
13144
|
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
12820
13145
|
doAction({
|
|
12821
13146
|
"componentId": "${props.id}",
|
|
@@ -12882,7 +13207,8 @@ function getFormPagination(props, mode) {
|
|
|
12882
13207
|
},
|
|
12883
13208
|
{
|
|
12884
13209
|
"type": "tpl",
|
|
12885
|
-
|
|
13210
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13211
|
+
"tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
|
|
12886
13212
|
},
|
|
12887
13213
|
{
|
|
12888
13214
|
"type": "button",
|
|
@@ -12890,7 +13216,9 @@ function getFormPagination(props, mode) {
|
|
|
12890
13216
|
"icon": `fa fa-angle-right`,
|
|
12891
13217
|
"level": "link",
|
|
12892
13218
|
"pageChangeDirection": "next",
|
|
12893
|
-
"disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
13219
|
+
// "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
13220
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13221
|
+
"disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
|
|
12894
13222
|
"size": "sm",
|
|
12895
13223
|
"id": buttonNextId,
|
|
12896
13224
|
"onEvent": {
|
|
@@ -12923,14 +13251,14 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12923
13251
|
"data": {
|
|
12924
13252
|
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12925
13253
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12926
|
-
"&": "${__tableItems[__super.index]}"
|
|
13254
|
+
"&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
|
|
12927
13255
|
}
|
|
12928
13256
|
});
|
|
12929
13257
|
let formBody = [
|
|
12930
13258
|
{
|
|
12931
13259
|
"type": "wrapper",
|
|
12932
13260
|
"size": "none",
|
|
12933
|
-
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white
|
|
13261
|
+
"className": "flex justify-end sticky top-0 right-0 left-0 z-20 bg-white",
|
|
12934
13262
|
"body": [
|
|
12935
13263
|
getFormPagination(props, mode)
|
|
12936
13264
|
]
|
|
@@ -12946,7 +13274,8 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12946
13274
|
}
|
|
12947
13275
|
];
|
|
12948
13276
|
let onServiceInitedScript = `
|
|
12949
|
-
|
|
13277
|
+
|
|
13278
|
+
// 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
12950
13279
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12951
13280
|
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
12952
13281
|
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
@@ -12959,6 +13288,11 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12959
13288
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12960
13289
|
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
12961
13290
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"] || []);
|
|
13291
|
+
let fieldPrefix = "${props.fieldPrefix}";
|
|
13292
|
+
if(fieldPrefix){
|
|
13293
|
+
let getTableValueWithoutFieldPrefix = new Function('v', 'f', "return (" + ${getTableValueWithoutFieldPrefix.toString()} + ")(v, f)");
|
|
13294
|
+
lastestFieldValue = getTableValueWithoutFieldPrefix(lastestFieldValue, fieldPrefix);
|
|
13295
|
+
}
|
|
12962
13296
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12963
13297
|
let mode = "${mode}";
|
|
12964
13298
|
if(mode === "new"){
|
|
@@ -12981,6 +13315,16 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12981
13315
|
event.data.__tableItems.forEach(function(n,i){
|
|
12982
13316
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12983
13317
|
});
|
|
13318
|
+
|
|
13319
|
+
var parent = event.data.parent;
|
|
13320
|
+
var fieldValue = event.data.__tableItems;
|
|
13321
|
+
if(parent){
|
|
13322
|
+
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13323
|
+
var primaryKey = "${props.primaryKey}";
|
|
13324
|
+
event.data.__parentIndex = _.findIndex(fieldValue, function(item){
|
|
13325
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13326
|
+
});
|
|
13327
|
+
}
|
|
12984
13328
|
`;
|
|
12985
13329
|
let schema = {
|
|
12986
13330
|
"type": "service",
|
|
@@ -13001,6 +13345,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13001
13345
|
// "body": formBody,
|
|
13002
13346
|
"data": {
|
|
13003
13347
|
"__page": "${index + 1}",
|
|
13348
|
+
"__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
|
|
13004
13349
|
// "__total": `\${${props.name}.length}`,
|
|
13005
13350
|
// "__total": "${__tableItems.length}",
|
|
13006
13351
|
// "__paginationServiceId": serviceId,
|
|
@@ -13048,7 +13393,22 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13048
13393
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13049
13394
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
13050
13395
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
13051
|
-
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13396
|
+
// fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
13397
|
+
var currentIndex = event.data.__super.__super.index;
|
|
13398
|
+
var currentFormValues = JSON.parse(JSON.stringify(event.data));
|
|
13399
|
+
var parent = event.data.__super.__super.parent;
|
|
13400
|
+
var __parentIndex = event.data.__super.__super.__parentIndex;
|
|
13401
|
+
if(parent){
|
|
13402
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13403
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13404
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13405
|
+
children: fieldValue[__parentIndex].children,
|
|
13406
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13407
|
+
});
|
|
13408
|
+
}
|
|
13409
|
+
else{
|
|
13410
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
13411
|
+
}
|
|
13052
13412
|
doAction({
|
|
13053
13413
|
"componentId": "${props.id}",
|
|
13054
13414
|
"actionType": "setValue",
|
|
@@ -13188,7 +13548,18 @@ async function getButtonActions(props, mode) {
|
|
|
13188
13548
|
let scope = event.context.scoped;
|
|
13189
13549
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13190
13550
|
// 新建一条空白行并保存到子表组件
|
|
13191
|
-
|
|
13551
|
+
var parent = event.data.__super.parent;
|
|
13552
|
+
var primaryKey = "${props.primaryKey}";
|
|
13553
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13554
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13555
|
+
});
|
|
13556
|
+
if(parent){
|
|
13557
|
+
fieldValue[__parentIndex].children.push({});
|
|
13558
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13559
|
+
}
|
|
13560
|
+
else{
|
|
13561
|
+
fieldValue.push({});
|
|
13562
|
+
}
|
|
13192
13563
|
doAction({
|
|
13193
13564
|
"componentId": "${props.id}",
|
|
13194
13565
|
"actionType": "setValue",
|
|
@@ -13200,7 +13571,13 @@ async function getButtonActions(props, mode) {
|
|
|
13200
13571
|
let __paginationServiceId = "${formPaginationId}";
|
|
13201
13572
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13202
13573
|
event.data.index = __paginationData.index;
|
|
13203
|
-
|
|
13574
|
+
if(parent){
|
|
13575
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13576
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
13577
|
+
}
|
|
13578
|
+
else{
|
|
13579
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13580
|
+
}
|
|
13204
13581
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13205
13582
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13206
13583
|
`;
|
|
@@ -13211,7 +13588,19 @@ async function getButtonActions(props, mode) {
|
|
|
13211
13588
|
let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
|
|
13212
13589
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13213
13590
|
// 复制当前页数据到新建行并保存到子表组件
|
|
13214
|
-
fieldValue.push(newItem);
|
|
13591
|
+
// fieldValue.push(newItem);
|
|
13592
|
+
var parent = event.data.__super.parent;
|
|
13593
|
+
var primaryKey = "${props.primaryKey}";
|
|
13594
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13595
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13596
|
+
});
|
|
13597
|
+
if(parent){
|
|
13598
|
+
fieldValue[__parentIndex].children.push(newItem);
|
|
13599
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13600
|
+
}
|
|
13601
|
+
else{
|
|
13602
|
+
fieldValue.push(newItem);
|
|
13603
|
+
}
|
|
13215
13604
|
doAction({
|
|
13216
13605
|
"componentId": "${props.id}",
|
|
13217
13606
|
"actionType": "setValue",
|
|
@@ -13223,7 +13612,13 @@ async function getButtonActions(props, mode) {
|
|
|
13223
13612
|
let __paginationServiceId = "${formPaginationId}";
|
|
13224
13613
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13225
13614
|
event.data.index = __paginationData.index;
|
|
13226
|
-
|
|
13615
|
+
if(parent){
|
|
13616
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13617
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
13618
|
+
}
|
|
13619
|
+
else{
|
|
13620
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13621
|
+
}
|
|
13227
13622
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13228
13623
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13229
13624
|
`;
|
|
@@ -13299,13 +13694,16 @@ async function getButtonActions(props, mode) {
|
|
|
13299
13694
|
"_master": "${_master}",
|
|
13300
13695
|
"global": "${global}",
|
|
13301
13696
|
"uiSchema": "${uiSchema}",
|
|
13302
|
-
"index": "${index}"
|
|
13697
|
+
"index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
|
|
13698
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13303
13699
|
// "__tableItems": `\${${props.name}}`
|
|
13304
13700
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13305
13701
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13306
13702
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13307
|
-
|
|
13308
|
-
|
|
13703
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
13704
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
13705
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13706
|
+
},
|
|
13309
13707
|
"actions": dialogButtons,
|
|
13310
13708
|
"onEvent": {
|
|
13311
13709
|
"confirm": {
|
|
@@ -13327,35 +13725,39 @@ async function getButtonActions(props, mode) {
|
|
|
13327
13725
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13328
13726
|
}
|
|
13329
13727
|
if (mode == "new") {
|
|
13330
|
-
`
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
|
|
13339
|
-
|
|
13340
|
-
|
|
13341
|
-
|
|
13342
|
-
|
|
13343
|
-
|
|
13344
|
-
|
|
13345
|
-
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
|
|
13356
|
-
|
|
13357
|
-
|
|
13358
|
-
`;
|
|
13728
|
+
// let onNewLineScript = `
|
|
13729
|
+
// let newItem = {};
|
|
13730
|
+
// if(event.data["${props.name}"]){
|
|
13731
|
+
// // let fieldValue = event.data.__tableItems;
|
|
13732
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
13733
|
+
// // let fieldValue = _.clone(event.data["${props.name}"]);
|
|
13734
|
+
// let fieldValue = event.data["${props.name}"];
|
|
13735
|
+
// fieldValue.push(newItem);
|
|
13736
|
+
// doAction({
|
|
13737
|
+
// "componentId": "${props.id}",
|
|
13738
|
+
// "actionType": "setValue",
|
|
13739
|
+
// "args": {
|
|
13740
|
+
// "value": fieldValue
|
|
13741
|
+
// }
|
|
13742
|
+
// });
|
|
13743
|
+
// event.data.index = fieldValue.length - 1;
|
|
13744
|
+
// }
|
|
13745
|
+
// else{
|
|
13746
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
13747
|
+
// doAction({
|
|
13748
|
+
// "componentId": "${props.id}",
|
|
13749
|
+
// "actionType": "setValue",
|
|
13750
|
+
// "args": {
|
|
13751
|
+
// "value": [newItem]
|
|
13752
|
+
// }
|
|
13753
|
+
// });
|
|
13754
|
+
// event.data.index = 1;
|
|
13755
|
+
// }
|
|
13756
|
+
// `;
|
|
13757
|
+
// let actionNewLine = {
|
|
13758
|
+
// "actionType": "custom",
|
|
13759
|
+
// "script": onNewLineScript
|
|
13760
|
+
// };
|
|
13359
13761
|
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13360
13762
|
// actions = [actionNewLine, actionShowEditDialog];
|
|
13361
13763
|
actions = [actionShowEditDialog];
|
|
@@ -13390,15 +13792,17 @@ async function getButtonActions(props, mode) {
|
|
|
13390
13792
|
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
13391
13793
|
// "__parentForm": "${__super.__super || {}}",
|
|
13392
13794
|
"__parentForm": parentFormData,
|
|
13795
|
+
"_master": "${_master}",
|
|
13393
13796
|
"global": "${global}",
|
|
13394
13797
|
"uiSchema": "${uiSchema}",
|
|
13395
13798
|
"index": "${index}",
|
|
13799
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13396
13800
|
// "__tableItems": `\${${props.name}}`
|
|
13397
13801
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13398
13802
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13399
13803
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13400
|
-
"__tableItems": `\${(
|
|
13401
|
-
|
|
13804
|
+
"__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13805
|
+
},
|
|
13402
13806
|
}
|
|
13403
13807
|
}
|
|
13404
13808
|
];
|
|
@@ -13414,7 +13818,23 @@ async function getButtonActions(props, mode) {
|
|
|
13414
13818
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13415
13819
|
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
13416
13820
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13417
|
-
|
|
13821
|
+
var currentIndex = event.data.index;
|
|
13822
|
+
var parent = event.data.__super.parent;
|
|
13823
|
+
var primaryKey = "${props.primaryKey}";
|
|
13824
|
+
var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
|
|
13825
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13826
|
+
});
|
|
13827
|
+
if(parent){
|
|
13828
|
+
lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
|
|
13829
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13830
|
+
lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
|
|
13831
|
+
children: lastestFieldValue[__parentIndex].children,
|
|
13832
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13833
|
+
});
|
|
13834
|
+
}
|
|
13835
|
+
else{
|
|
13836
|
+
lastestFieldValue.splice(currentIndex, 1);
|
|
13837
|
+
}
|
|
13418
13838
|
doAction({
|
|
13419
13839
|
"componentId": "${props.id}",
|
|
13420
13840
|
"actionType": "setValue",
|
|
@@ -13500,39 +13920,53 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13500
13920
|
if (!props.id) {
|
|
13501
13921
|
props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
|
|
13502
13922
|
}
|
|
13923
|
+
if (!props.primaryKey) {
|
|
13924
|
+
props.primaryKey = "_id";
|
|
13925
|
+
}
|
|
13926
|
+
let showOperation = props.showOperation;
|
|
13927
|
+
if(showOperation !== false){
|
|
13928
|
+
showOperation = true;
|
|
13929
|
+
}
|
|
13930
|
+
// props.fieldPrefix = "project_milestone_";
|
|
13931
|
+
if (props.fieldPrefix) {
|
|
13932
|
+
props.fields = getTableFieldsWithoutFieldPrefix(props.fields, props.fieldPrefix);
|
|
13933
|
+
}
|
|
13503
13934
|
let serviceId = getComponentId("table_service", props.id);
|
|
13504
13935
|
let buttonsForColumnOperations = [];
|
|
13505
13936
|
let inlineEditMode = props.inlineEditMode;
|
|
13506
13937
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
13507
|
-
if
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13938
|
+
if(showOperation){
|
|
13939
|
+
if (props.editable) {
|
|
13940
|
+
let showEditButton = true;
|
|
13941
|
+
if (showAsInlineEditMode) {
|
|
13942
|
+
// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
13943
|
+
showEditButton = true;
|
|
13944
|
+
// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
13945
|
+
// if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
|
|
13946
|
+
// showEditButton = true;
|
|
13947
|
+
// }
|
|
13948
|
+
// else {
|
|
13949
|
+
// showEditButton = false;
|
|
13950
|
+
// }
|
|
13951
|
+
}
|
|
13952
|
+
// 编辑时显示编辑按钮
|
|
13953
|
+
if (showEditButton) {
|
|
13954
|
+
let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
|
|
13955
|
+
buttonsForColumnOperations.push(buttonEditSchema);
|
|
13956
|
+
}
|
|
13519
13957
|
}
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13958
|
+
else {
|
|
13959
|
+
// 只读时显示查看按钮
|
|
13960
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13961
|
+
let buttonViewSchema = await getButtonView(props);
|
|
13962
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13963
|
+
}
|
|
13964
|
+
if (props.removable) {
|
|
13965
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13966
|
+
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13524
13967
|
}
|
|
13525
13968
|
}
|
|
13526
|
-
|
|
13527
|
-
// 只读时显示查看按钮
|
|
13528
|
-
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13529
|
-
let buttonViewSchema = await getButtonView(props);
|
|
13530
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13531
|
-
}
|
|
13532
|
-
if (props.removable) {
|
|
13533
|
-
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13534
|
-
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13535
|
-
}
|
|
13969
|
+
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13536
13970
|
let inputTableSchema = {
|
|
13537
13971
|
"type": "input-table",
|
|
13538
13972
|
"label": props.label,
|
|
@@ -13550,8 +13984,37 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13550
13984
|
"strictMode": props.strictMode,
|
|
13551
13985
|
"showTableAddBtn": false,
|
|
13552
13986
|
"showFooterAddBtn": false,
|
|
13553
|
-
"className": props.tableClassName
|
|
13987
|
+
"className": props.tableClassName,
|
|
13988
|
+
"pipeOut": (value, data) => {
|
|
13989
|
+
value = (value || []).map(function(item){
|
|
13990
|
+
delete item.__fix_rerender_after_children_modified_tag;
|
|
13991
|
+
return item;
|
|
13992
|
+
});
|
|
13993
|
+
if(props.fieldPrefix){
|
|
13994
|
+
value = getTableValuePrependFieldPrefix(value, props.fieldPrefix);
|
|
13995
|
+
}
|
|
13996
|
+
if(amis.pipeOut){
|
|
13997
|
+
if(typeof amis.pipeOut === 'function'){
|
|
13998
|
+
return amis.pipeOut(value, data);
|
|
13999
|
+
}
|
|
14000
|
+
}
|
|
14001
|
+
return value;
|
|
14002
|
+
}
|
|
13554
14003
|
};
|
|
14004
|
+
if(amis.pipeIn){
|
|
14005
|
+
inputTableSchema.pipeIn = amis.pipeIn;
|
|
14006
|
+
}
|
|
14007
|
+
if(props.fieldPrefix){
|
|
14008
|
+
inputTableSchema.pipeIn = (value, data) => {
|
|
14009
|
+
value = getTableValueWithoutFieldPrefix(value, props.fieldPrefix);
|
|
14010
|
+
if(amis.pipeIn){
|
|
14011
|
+
if(typeof amis.pipeIn === 'function'){
|
|
14012
|
+
return amis.pipeIn(value, data);
|
|
14013
|
+
}
|
|
14014
|
+
}
|
|
14015
|
+
return value;
|
|
14016
|
+
};
|
|
14017
|
+
}
|
|
13555
14018
|
if (buttonsForColumnOperations.length) {
|
|
13556
14019
|
inputTableSchema.columns.push({
|
|
13557
14020
|
"name": "__op__",
|
|
@@ -13563,17 +14026,18 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13563
14026
|
if (showAsInlineEditMode) {
|
|
13564
14027
|
inputTableSchema.needConfirm = false;
|
|
13565
14028
|
}
|
|
13566
|
-
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13567
14029
|
if (amis) {
|
|
13568
14030
|
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13569
14031
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
14032
|
+
delete amis.pipeIn;//该属性在上面合并过了
|
|
14033
|
+
delete amis.pipeOut;//该属性在上面合并过了
|
|
13570
14034
|
Object.assign(inputTableSchema, amis);
|
|
13571
14035
|
}
|
|
13572
14036
|
const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
|
|
13573
14037
|
return item.depend_on;
|
|
13574
14038
|
});
|
|
13575
14039
|
if (isAnyFieldHasDependOn) {
|
|
13576
|
-
// 有任意一个子字段有depend_on
|
|
14040
|
+
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
|
|
13577
14041
|
Object.assign(inputTableSchema, {
|
|
13578
14042
|
strictMode: false
|
|
13579
14043
|
});
|
|
@@ -13678,7 +14142,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
|
|
|
13678
14142
|
// 获取
|
|
13679
14143
|
async function getRecordPageInitSchema(objectApiName){
|
|
13680
14144
|
const relatedList = await getObjectRelatedList(objectApiName);
|
|
13681
|
-
|
|
14145
|
+
await getUISchema(objectApiName);
|
|
13682
14146
|
let body = [
|
|
13683
14147
|
// detailHeaderAmisSchema,
|
|
13684
14148
|
{
|
|
@@ -13686,28 +14150,7 @@ async function getRecordPageInitSchema(objectApiName){
|
|
|
13686
14150
|
"label": "标题面板",
|
|
13687
14151
|
"objectApiName": "${objectName}",
|
|
13688
14152
|
"recordId": "${recordId}",
|
|
13689
|
-
"onEvent": {
|
|
13690
|
-
"recordLoaded": {
|
|
13691
|
-
"actions": [
|
|
13692
|
-
{
|
|
13693
|
-
"actionType": "setValue",
|
|
13694
|
-
"args": {
|
|
13695
|
-
"value": {
|
|
13696
|
-
"recordLoaded": true,
|
|
13697
|
-
}
|
|
13698
|
-
}
|
|
13699
|
-
},
|
|
13700
|
-
{
|
|
13701
|
-
"actionType": "reload",
|
|
13702
|
-
"data": {
|
|
13703
|
-
"name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
13704
|
-
"record": `\${record}`,
|
|
13705
|
-
"recordLoaded": true,
|
|
13706
|
-
}
|
|
13707
|
-
}
|
|
13708
|
-
]
|
|
13709
|
-
}
|
|
13710
|
-
}
|
|
14153
|
+
"onEvent": {}
|
|
13711
14154
|
}
|
|
13712
14155
|
];
|
|
13713
14156
|
let contentBody = {
|
|
@@ -16272,5 +16715,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
16272
16715
|
};
|
|
16273
16716
|
};
|
|
16274
16717
|
|
|
16275
|
-
export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
|
|
16718
|
+
export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getAmisInputTableSchema, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getGlobalNowData, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getObjectRelatedListsMiniSchema, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailMiniSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getReferenceTo, getReferenceToFieldSchema, getReferenceToSync, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync$1 as getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
|
|
16276
16719
|
//# sourceMappingURL=index.esm.js.map
|