@steedos-widgets/amis-lib 3.6.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 +765 -319
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +764 -320
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +267 -176
- 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 = "显示的列";
|
|
@@ -1604,16 +1608,17 @@ async function getQuickEditSchema(field, options){
|
|
|
1604
1608
|
{
|
|
1605
1609
|
actionType: "custom",
|
|
1606
1610
|
script: `
|
|
1611
|
+
console.log("asdasd");
|
|
1607
1612
|
let items = _.cloneDeep(event.data.items);
|
|
1608
1613
|
let selectedItems = _.cloneDeep(event.data.selectedItems);
|
|
1609
1614
|
if(event.data.isBatchEdit){
|
|
1610
1615
|
selectedItems.forEach(function(selectedItem){
|
|
1611
1616
|
selectedItem._display.${field.name} = event.data._display.${field.name};
|
|
1612
|
-
doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: ${options.objectName} + "_display_" + selectedItem._index});
|
|
1617
|
+
doAction({actionType: 'setValue', "args": {"value": selectedItem._display},componentId: "${options.objectName}" + "_display_" + selectedItem._index});
|
|
1613
1618
|
doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + selectedItem._index});
|
|
1614
1619
|
})
|
|
1615
1620
|
}else{
|
|
1616
|
-
doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: ${options.objectName} + "_display_" + event.data._index});
|
|
1621
|
+
doAction({actionType: 'setValue', "args": {"value": event.data._display},componentId: "${options.objectName}" + "_display_" + event.data._index});
|
|
1617
1622
|
doAction({actionType: 'setValue', "args": {"value": event.data.${field.name}},componentId: "${options.objectName + "_" + field.name + "_"}" + event.data._index});
|
|
1618
1623
|
}
|
|
1619
1624
|
`
|
|
@@ -2059,9 +2064,13 @@ async function getTableColumns(fields, options){
|
|
|
2059
2064
|
const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
|
|
2060
2065
|
let className = "";
|
|
2061
2066
|
if(field.wrap != true){
|
|
2062
|
-
|
|
2067
|
+
if(field.wrap != false && field.is_wide){
|
|
2068
|
+
className += " break-words ";
|
|
2069
|
+
}else {
|
|
2070
|
+
className += " whitespace-nowrap ";
|
|
2071
|
+
}
|
|
2063
2072
|
}else {
|
|
2064
|
-
className += " break-
|
|
2073
|
+
className += " break-words ";
|
|
2065
2074
|
}
|
|
2066
2075
|
let columnItem;
|
|
2067
2076
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
@@ -2158,12 +2167,24 @@ async function getTableColumns(fields, options){
|
|
|
2158
2167
|
if(field.type === 'textarea'){
|
|
2159
2168
|
className += 'min-w-56';
|
|
2160
2169
|
}
|
|
2161
|
-
if(field.type === 'date'){
|
|
2162
|
-
|
|
2163
|
-
}
|
|
2164
|
-
if(field.type === 'datetime'){
|
|
2165
|
-
|
|
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} `;
|
|
2166
2185
|
}
|
|
2186
|
+
delete field.amis?.className;
|
|
2187
|
+
|
|
2167
2188
|
if(!field.hidden && !field.extra){
|
|
2168
2189
|
columnItem = Object.assign({}, {
|
|
2169
2190
|
name: field.name,
|
|
@@ -2246,7 +2267,7 @@ function getMobileLines(tpls){
|
|
|
2246
2267
|
}
|
|
2247
2268
|
if(isLeft){
|
|
2248
2269
|
// 左侧半行
|
|
2249
|
-
lineChildrenClassName = "steedos-listview-item-left truncate";
|
|
2270
|
+
lineChildrenClassName = "steedos-listview-item-left truncate h-5";
|
|
2250
2271
|
if(item.field.is_wide){
|
|
2251
2272
|
// 左侧全行样式可以单独写,如果需要配置两行省略号效果,可以加样式类 two-lines-truncate
|
|
2252
2273
|
lineChildrenClassName = "steedos-listview-item-wide";
|
|
@@ -2258,14 +2279,26 @@ function getMobileLines(tpls){
|
|
|
2258
2279
|
}
|
|
2259
2280
|
else {
|
|
2260
2281
|
// 右侧半行,这里加样式类 flex flex-shrink-0,是为了省略号只显示在左半行,右半行文字一般比较短,如果也加省略号效果的话,左侧文字多的话,右侧没几个字就显示省略号了
|
|
2261
|
-
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;
|
|
2262
2295
|
}
|
|
2263
2296
|
lineChildren.push({
|
|
2264
2297
|
"type": "tpl",
|
|
2265
2298
|
"tpl": item.tpl,
|
|
2266
|
-
|
|
2299
|
+
className
|
|
2267
2300
|
});
|
|
2268
|
-
|
|
2301
|
+
|
|
2269
2302
|
if(item.field.is_wide){
|
|
2270
2303
|
// 宽字段占整行
|
|
2271
2304
|
isLeft = true;
|
|
@@ -2315,8 +2348,7 @@ async function getMobileTableColumns(fields, options){
|
|
|
2315
2348
|
tpl = await getFieldTpl(field, options);
|
|
2316
2349
|
}
|
|
2317
2350
|
if(!tpl){
|
|
2318
|
-
|
|
2319
|
-
tpl = `\${${field.name} | raw}`;
|
|
2351
|
+
tpl = `\${${field.name}}`;
|
|
2320
2352
|
}
|
|
2321
2353
|
if(!field.hidden && !field.extra){
|
|
2322
2354
|
tpls.push({ field, tpl });
|
|
@@ -2329,7 +2361,7 @@ async function getMobileTableColumns(fields, options){
|
|
|
2329
2361
|
|
|
2330
2362
|
let column = {
|
|
2331
2363
|
name: nameField.name,
|
|
2332
|
-
label: nameField.label,
|
|
2364
|
+
label: options.displayAs == 'split' ? '' : nameField.label,
|
|
2333
2365
|
sortable: nameField.sortable,
|
|
2334
2366
|
type: "button",
|
|
2335
2367
|
level: "link",
|
|
@@ -2358,7 +2390,15 @@ async function getMobileTableColumns(fields, options){
|
|
|
2358
2390
|
"actions": [
|
|
2359
2391
|
{
|
|
2360
2392
|
"script": `
|
|
2361
|
-
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
|
+
}
|
|
2362
2402
|
Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
|
|
2363
2403
|
`,
|
|
2364
2404
|
"actionType": "custom"
|
|
@@ -2474,7 +2514,8 @@ async function getTableOperation(ctx){
|
|
|
2474
2514
|
label: " ",
|
|
2475
2515
|
fixed: 'right',
|
|
2476
2516
|
labelClassName: 'text-center',
|
|
2477
|
-
|
|
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',
|
|
2478
2519
|
buttons: [
|
|
2479
2520
|
{
|
|
2480
2521
|
"type": "steedos-dropdown-button",
|
|
@@ -2570,7 +2611,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2570
2611
|
}
|
|
2571
2612
|
return {
|
|
2572
2613
|
mode: "cards",
|
|
2573
|
-
perPageAvailable: [
|
|
2614
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2574
2615
|
name: "thelist",
|
|
2575
2616
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2576
2617
|
className: "",
|
|
@@ -2603,7 +2644,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2603
2644
|
|
|
2604
2645
|
return {
|
|
2605
2646
|
mode: "table",
|
|
2606
|
-
perPageAvailable: [
|
|
2647
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2607
2648
|
name: "thelist",
|
|
2608
2649
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2609
2650
|
className: "",
|
|
@@ -2989,6 +3030,16 @@ async function getTableApi(mainObject, fields, options){
|
|
|
2989
3030
|
}
|
|
2990
3031
|
// SteedosUI.getRef(api.body.$self.$scopeId)?.parent?.getComponentById(setDataToComponentId)?.setData({$count: payload.data.count})
|
|
2991
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
|
+
}
|
|
2992
3043
|
${options.adaptor || ''}
|
|
2993
3044
|
return payload;
|
|
2994
3045
|
`;
|
|
@@ -3100,12 +3151,21 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3100
3151
|
}
|
|
3101
3152
|
payload.data = data;
|
|
3102
3153
|
payload.data.__objectName = "${object.name}";
|
|
3103
|
-
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
|
+
}
|
|
3104
3162
|
window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
|
|
3105
3163
|
}
|
|
3106
3164
|
if(payload.errors){
|
|
3107
3165
|
payload.status = 2;
|
|
3108
3166
|
payload.msg = payload.errors[0].message;
|
|
3167
|
+
}else{
|
|
3168
|
+
payload.data.recordLoaded = true;
|
|
3109
3169
|
}
|
|
3110
3170
|
${options && options.initApiAdaptor || ''}
|
|
3111
3171
|
return payload;
|
|
@@ -3248,7 +3308,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3248
3308
|
cache: API_CACHE,
|
|
3249
3309
|
requestAdaptor: `
|
|
3250
3310
|
// 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
|
|
3251
|
-
var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
|
|
3311
|
+
var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
|
|
3252
3312
|
if(!recordId){
|
|
3253
3313
|
// 新建则不请求任何数据
|
|
3254
3314
|
data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
|
|
@@ -3326,10 +3386,11 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3326
3386
|
...initialValues
|
|
3327
3387
|
}
|
|
3328
3388
|
${options.initApiAdaptor || ''}
|
|
3389
|
+
// console.log('getEditFormInitApi======>', payload);
|
|
3329
3390
|
return payload;
|
|
3330
3391
|
`,
|
|
3331
3392
|
responseData: {
|
|
3332
|
-
|
|
3393
|
+
"&": "$$",
|
|
3333
3394
|
editFormInited: true
|
|
3334
3395
|
},
|
|
3335
3396
|
data: data,
|
|
@@ -3368,6 +3429,18 @@ function getBatchDelete(objectName){
|
|
|
3368
3429
|
return {
|
|
3369
3430
|
method: 'post',
|
|
3370
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
|
+
`,
|
|
3371
3444
|
requestAdaptor: `
|
|
3372
3445
|
var ids = api.data.ids.split(",");
|
|
3373
3446
|
var deleteArray = [];
|
|
@@ -4162,7 +4235,7 @@ async function getListBody(fields, options){
|
|
|
4162
4235
|
|
|
4163
4236
|
function getDefaultParams(options){
|
|
4164
4237
|
return {
|
|
4165
|
-
perPage: options.top || options.perPage ||
|
|
4238
|
+
perPage: options.top || options.perPage || 20
|
|
4166
4239
|
}
|
|
4167
4240
|
}
|
|
4168
4241
|
|
|
@@ -4365,7 +4438,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
|
|
|
4365
4438
|
"objectApiName": "\${objectName}",
|
|
4366
4439
|
"recordId": "",
|
|
4367
4440
|
"mode": "edit",
|
|
4368
|
-
"layout": "normal"
|
|
4369
4441
|
};
|
|
4370
4442
|
|
|
4371
4443
|
if (payload && payload.schema) {
|
|
@@ -5070,7 +5142,7 @@ const StandardButtons = {
|
|
|
5070
5142
|
}
|
|
5071
5143
|
};
|
|
5072
5144
|
|
|
5073
|
-
const getGlobalData
|
|
5145
|
+
const getGlobalData = () => {
|
|
5074
5146
|
return {
|
|
5075
5147
|
now: new Date(),
|
|
5076
5148
|
};
|
|
@@ -5129,7 +5201,7 @@ const getButtonVisible = (button, ctx) => {
|
|
|
5129
5201
|
button._visible,
|
|
5130
5202
|
props.record,
|
|
5131
5203
|
"#",
|
|
5132
|
-
getGlobalData
|
|
5204
|
+
getGlobalData(),
|
|
5133
5205
|
props.userSession
|
|
5134
5206
|
);
|
|
5135
5207
|
};
|
|
@@ -6507,6 +6579,48 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6507
6579
|
return headerSchema;
|
|
6508
6580
|
}
|
|
6509
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
|
+
|
|
6510
6624
|
/**
|
|
6511
6625
|
* 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
|
|
6512
6626
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -6515,11 +6629,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6515
6629
|
* @returns amisSchema
|
|
6516
6630
|
*/
|
|
6517
6631
|
async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
6632
|
+
// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
6518
6633
|
const { showRecordTitle = true } = options || {};
|
|
6519
6634
|
// console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
|
|
6520
6635
|
const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
|
|
6521
6636
|
|
|
6522
|
-
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
|
+
}
|
|
6523
6647
|
|
|
6524
6648
|
// console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
|
|
6525
6649
|
|
|
@@ -6534,45 +6658,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6534
6658
|
"type": "grid",
|
|
6535
6659
|
"columns": [
|
|
6536
6660
|
{
|
|
6537
|
-
"body": [
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
"@history_paths.changed": {
|
|
6541
|
-
"actions": [
|
|
6542
|
-
{
|
|
6543
|
-
"actionType": "reload",
|
|
6544
|
-
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6545
|
-
"data": {
|
|
6546
|
-
}
|
|
6547
|
-
}
|
|
6548
|
-
]
|
|
6549
|
-
}
|
|
6550
|
-
},
|
|
6551
|
-
"body":[{
|
|
6552
|
-
"type": "button",
|
|
6553
|
-
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6554
|
-
"className":"flex mr-4",
|
|
6555
|
-
"onEvent": {
|
|
6556
|
-
"click": {
|
|
6557
|
-
"actions": [
|
|
6558
|
-
{
|
|
6559
|
-
"actionType": "custom",
|
|
6560
|
-
"script": "window.goBack()"
|
|
6561
|
-
}
|
|
6562
|
-
]
|
|
6563
|
-
}
|
|
6564
|
-
},
|
|
6565
|
-
"body": [
|
|
6566
|
-
{
|
|
6567
|
-
"type": "steedos-icon",
|
|
6568
|
-
"category": "utility",
|
|
6569
|
-
"name": "back",
|
|
6570
|
-
"colorVariant": "default",
|
|
6571
|
-
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6572
|
-
}
|
|
6573
|
-
]
|
|
6574
|
-
}]
|
|
6575
|
-
},{
|
|
6661
|
+
"body": [
|
|
6662
|
+
backButtonsSchema
|
|
6663
|
+
,{
|
|
6576
6664
|
"type": "tpl",
|
|
6577
6665
|
"className": "block",
|
|
6578
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'>`
|
|
@@ -6593,8 +6681,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6593
6681
|
},
|
|
6594
6682
|
{
|
|
6595
6683
|
"type": "tpl",
|
|
6596
|
-
"tpl": "${
|
|
6597
|
-
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
6684
|
+
"tpl": "${NAME_FIELD_VALUE}",
|
|
6598
6685
|
"inline": false,
|
|
6599
6686
|
"wrapperComponent": "",
|
|
6600
6687
|
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
@@ -6622,7 +6709,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6622
6709
|
let body = [
|
|
6623
6710
|
{
|
|
6624
6711
|
"type": "wrapper",
|
|
6625
|
-
"className": "p-
|
|
6712
|
+
"className": "p-4 bg-gray-100 border-b",
|
|
6626
6713
|
"body": [
|
|
6627
6714
|
{
|
|
6628
6715
|
"type": "grid",
|
|
@@ -6637,7 +6724,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6637
6724
|
if(showRecordTitle){
|
|
6638
6725
|
body.push({
|
|
6639
6726
|
"type": "wrapper",
|
|
6640
|
-
"className": "p-
|
|
6727
|
+
"className": "p-4",
|
|
6641
6728
|
"body": [
|
|
6642
6729
|
{
|
|
6643
6730
|
"type": "grid",
|
|
@@ -6649,11 +6736,76 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6649
6736
|
});
|
|
6650
6737
|
}
|
|
6651
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
|
+
|
|
6652
6805
|
return {
|
|
6653
6806
|
type: 'service',
|
|
6654
6807
|
id: `page_readonly_${name}_header`,
|
|
6655
6808
|
name: `page`,
|
|
6656
|
-
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
6657
6809
|
body: body,
|
|
6658
6810
|
className: ''
|
|
6659
6811
|
}
|
|
@@ -6725,7 +6877,7 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
|
|
|
6725
6877
|
"className": "flex justify-between"
|
|
6726
6878
|
}
|
|
6727
6879
|
],
|
|
6728
|
-
"className": "
|
|
6880
|
+
"className": "steedos-record-related-header py-2 px-0"
|
|
6729
6881
|
};
|
|
6730
6882
|
return recordRelatedListHeader;
|
|
6731
6883
|
}
|
|
@@ -7710,14 +7862,14 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
|
|
|
7710
7862
|
{
|
|
7711
7863
|
"type": "button",
|
|
7712
7864
|
"label": i18next.t('frontend_display_type_is_table'),
|
|
7713
|
-
"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');",
|
|
7714
7866
|
"rightIcon": displayAs != 'split' ? "fa fa-check" : null,
|
|
7715
7867
|
"rightIconClassName": "m-l-sm"
|
|
7716
7868
|
},
|
|
7717
7869
|
{
|
|
7718
7870
|
"type": "button",
|
|
7719
7871
|
"label": i18next.t('frontend_display_type_is_split'),
|
|
7720
|
-
"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);",
|
|
7721
7873
|
"rightIcon": displayAs === 'split' ? "fa fa-check" : null,
|
|
7722
7874
|
"rightIconClassName": "m-l-sm"
|
|
7723
7875
|
}
|
|
@@ -7860,7 +8012,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7860
8012
|
{
|
|
7861
8013
|
"type": "search-box",
|
|
7862
8014
|
"name": keywordsSearchBoxName,
|
|
7863
|
-
"placeholder": "
|
|
8015
|
+
"placeholder": "快捷搜索",
|
|
7864
8016
|
"value": crudKeywords,
|
|
7865
8017
|
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7866
8018
|
"clearAndSubmit": true,
|
|
@@ -8064,7 +8216,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8064
8216
|
// ]
|
|
8065
8217
|
if(options.displayAs === 'split'){
|
|
8066
8218
|
return [
|
|
8067
|
-
|
|
8219
|
+
{
|
|
8220
|
+
"type": "switch-per-page",
|
|
8221
|
+
"visibleOn": "${count >= 20}"
|
|
8222
|
+
},
|
|
8068
8223
|
{
|
|
8069
8224
|
"type": "pagination",
|
|
8070
8225
|
"maxButtons": 5,
|
|
@@ -8086,7 +8241,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8086
8241
|
else {
|
|
8087
8242
|
if(options && options.isRelated){
|
|
8088
8243
|
return [
|
|
8089
|
-
"statistics",
|
|
8090
8244
|
{
|
|
8091
8245
|
"type": "pagination",
|
|
8092
8246
|
"maxButtons": 10,
|
|
@@ -8099,7 +8253,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8099
8253
|
const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
|
|
8100
8254
|
const is_lookup = options.isLookup;
|
|
8101
8255
|
const commonConfig = [
|
|
8102
|
-
"statistics",
|
|
8103
8256
|
{
|
|
8104
8257
|
"type": "pagination",
|
|
8105
8258
|
"maxButtons": 10,
|
|
@@ -8110,7 +8263,10 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
8110
8263
|
if (no_pagination && is_lookup) {
|
|
8111
8264
|
return commonConfig;
|
|
8112
8265
|
} else {
|
|
8113
|
-
return [
|
|
8266
|
+
return [{
|
|
8267
|
+
"type": "switch-per-page",
|
|
8268
|
+
"visibleOn": "${count >= 20}"
|
|
8269
|
+
}, ...commonConfig];
|
|
8114
8270
|
}
|
|
8115
8271
|
}
|
|
8116
8272
|
}
|
|
@@ -8218,6 +8374,29 @@ function getBulkActions(objectSchema){
|
|
|
8218
8374
|
"className": "hidden",
|
|
8219
8375
|
"id": "batchDelete",
|
|
8220
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
|
+
}
|
|
8221
8400
|
}
|
|
8222
8401
|
// {
|
|
8223
8402
|
// "label": "批量修改",
|
|
@@ -8364,6 +8543,10 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8364
8543
|
const rowsDiff = _.cloneDeep(api.data.rowsDiff);
|
|
8365
8544
|
rowsDiff.forEach(function (item, index) {
|
|
8366
8545
|
for(key in item){
|
|
8546
|
+
// image、select等字段清空值后保存的空字符串转换为null。
|
|
8547
|
+
if(item[key] === ''){
|
|
8548
|
+
item[key] = null;
|
|
8549
|
+
}
|
|
8367
8550
|
if(_.includes(imageNames, key)){
|
|
8368
8551
|
if(typeof item[key] == "string"){
|
|
8369
8552
|
const match = item[key].match(/\\/([^\\/]+)$/);
|
|
@@ -8410,7 +8593,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8410
8593
|
// "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8411
8594
|
// },
|
|
8412
8595
|
bodyClassName: {
|
|
8413
|
-
"
|
|
8596
|
+
"mb-0": true,
|
|
8414
8597
|
"is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
|
|
8415
8598
|
},
|
|
8416
8599
|
crudClassName: crudClassName,
|
|
@@ -8430,7 +8613,9 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8430
8613
|
return payload;
|
|
8431
8614
|
`
|
|
8432
8615
|
},
|
|
8433
|
-
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 %>"
|
|
8434
8619
|
}, bodyProps);
|
|
8435
8620
|
|
|
8436
8621
|
}
|
|
@@ -8445,7 +8630,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8445
8630
|
|
|
8446
8631
|
if(body.columns && options.formFactor != 'SMALL'){
|
|
8447
8632
|
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8448
|
-
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: "${''}"});
|
|
8449
8634
|
}
|
|
8450
8635
|
|
|
8451
8636
|
if (defaults) {
|
|
@@ -8503,11 +8688,6 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8503
8688
|
}
|
|
8504
8689
|
}
|
|
8505
8690
|
|
|
8506
|
-
const getGlobalData = (mode)=>{
|
|
8507
|
-
const user = getSteedosAuth();
|
|
8508
|
-
return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
|
|
8509
|
-
};
|
|
8510
|
-
|
|
8511
8691
|
const getFormFields$1 = (objectSchema, formProps)=>{
|
|
8512
8692
|
/**
|
|
8513
8693
|
* fieldsExtend: 重写字段定义
|
|
@@ -8569,7 +8749,7 @@ async function getFormSchemaWithDataFilter(form, options = {}){
|
|
|
8569
8749
|
}
|
|
8570
8750
|
|
|
8571
8751
|
async function getObjectForm(objectSchema, ctx){
|
|
8572
|
-
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8752
|
+
const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
|
|
8573
8753
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8574
8754
|
const fields = ___default.values(objectSchema.fields);
|
|
8575
8755
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8585,9 +8765,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8585
8765
|
id: `service_${formSchema.id}`,
|
|
8586
8766
|
className: 'p-0',
|
|
8587
8767
|
name: `page_edit_${recordId}`,
|
|
8588
|
-
api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8589
8768
|
data:{
|
|
8590
|
-
editFormInited: false,
|
|
8591
8769
|
...amisData
|
|
8592
8770
|
},
|
|
8593
8771
|
// data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
@@ -8596,8 +8774,9 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8596
8774
|
body: [defaultsDeep({}, formSchema, {
|
|
8597
8775
|
type: "form",
|
|
8598
8776
|
mode: layout,
|
|
8777
|
+
initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8599
8778
|
data: {
|
|
8600
|
-
|
|
8779
|
+
editFormInited: false,
|
|
8601
8780
|
},
|
|
8602
8781
|
labelAlign,
|
|
8603
8782
|
persistData: false,
|
|
@@ -8611,11 +8790,15 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8611
8790
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
8612
8791
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
8613
8792
|
initFetch: recordId != 'new',
|
|
8614
|
-
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
|
+
},
|
|
8615
8799
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
8616
8800
|
bodyClassName: 'p-0',
|
|
8617
8801
|
className: 'steedos-amis-form',
|
|
8618
|
-
hiddenOn: "${editFormInited != true}",
|
|
8619
8802
|
onEvent: {
|
|
8620
8803
|
"submitSucc": {
|
|
8621
8804
|
"weight": 0,
|
|
@@ -8660,7 +8843,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8660
8843
|
}
|
|
8661
8844
|
|
|
8662
8845
|
async function getObjectDetail(objectSchema, recordId, ctx){
|
|
8663
|
-
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "
|
|
8846
|
+
const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
|
|
8664
8847
|
formDataFilter, onFormDataFilter, amisData, env } = ctx;
|
|
8665
8848
|
const fields = ___default.values(objectSchema.fields);
|
|
8666
8849
|
const formFields = getFormFields$1(objectSchema, ctx);
|
|
@@ -8669,8 +8852,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8669
8852
|
type: 'service',
|
|
8670
8853
|
name: `page_readonly_${recordId}`,
|
|
8671
8854
|
id: serviceId,
|
|
8672
|
-
|
|
8673
|
-
api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8855
|
+
// api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8674
8856
|
body: [
|
|
8675
8857
|
{
|
|
8676
8858
|
"type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
|
|
@@ -8696,60 +8878,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8696
8878
|
),
|
|
8697
8879
|
className: 'steedos-amis-form bg-white',
|
|
8698
8880
|
actions: [], // 不显示表单默认的提交按钮
|
|
8699
|
-
onEvent: {
|
|
8700
|
-
[`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
|
|
8701
|
-
"actions": [
|
|
8702
|
-
{
|
|
8703
|
-
"actionType": "reload",
|
|
8704
|
-
"componentId": serviceId,
|
|
8705
|
-
"expression": "this.__deletedRecord != true"
|
|
8706
|
-
},
|
|
8707
|
-
{
|
|
8708
|
-
// "args": {
|
|
8709
|
-
// "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
|
|
8710
|
-
// "blank": false
|
|
8711
|
-
// },
|
|
8712
|
-
"actionType": "custom",
|
|
8713
|
-
"script": "window.goBack()",
|
|
8714
|
-
"expression": "this.__deletedRecord === true"
|
|
8715
|
-
}
|
|
8716
|
-
]
|
|
8717
|
-
}
|
|
8718
|
-
}
|
|
8719
8881
|
},
|
|
8720
8882
|
}
|
|
8721
8883
|
],
|
|
8722
|
-
onEvent: {
|
|
8723
|
-
|
|
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
|
-
}
|
|
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
|
+
// }
|
|
8750
8912
|
};
|
|
8751
8913
|
|
|
8752
8914
|
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
8915
|
+
// console.log('getObjectDetail=====>', amisSchema);
|
|
8753
8916
|
return amisSchema;
|
|
8754
8917
|
}
|
|
8755
8918
|
|
|
@@ -8829,8 +8992,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
8829
8992
|
/*
|
|
8830
8993
|
* @Author: baozhoutao@steedos.com
|
|
8831
8994
|
* @Date: 2022-07-05 15:55:39
|
|
8832
|
-
* @LastEditors:
|
|
8833
|
-
* @LastEditTime:
|
|
8995
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
8996
|
+
* @LastEditTime: 2024-01-15 10:34:46
|
|
8834
8997
|
* @Description:
|
|
8835
8998
|
*/
|
|
8836
8999
|
|
|
@@ -9005,7 +9168,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9005
9168
|
setDataToComponentId: componentId,
|
|
9006
9169
|
// tableHiddenOn: hiddenEmptyTable ? "this.$count === 0" : null,
|
|
9007
9170
|
appId: appId,
|
|
9008
|
-
crudClassName: '
|
|
9171
|
+
crudClassName: 'steedos-record-related-crud hidden',
|
|
9009
9172
|
refField,
|
|
9010
9173
|
...ctx
|
|
9011
9174
|
};
|
|
@@ -9018,7 +9181,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
|
|
|
9018
9181
|
amisSchema: {
|
|
9019
9182
|
type: "service",
|
|
9020
9183
|
id: componentId,
|
|
9021
|
-
className: `steedos-record-related-list
|
|
9184
|
+
className: `steedos-record-related-list py-2 first:pt-0 border-b last:border-b-0 ${componentId} ${className}`,
|
|
9022
9185
|
data: {
|
|
9023
9186
|
relatedKey: relatedKey,
|
|
9024
9187
|
listViewId: `amis-\${appId}-${relatedObjectName}-listview`,
|
|
@@ -9210,11 +9373,44 @@ async function getRelatedListSchema(
|
|
|
9210
9373
|
};
|
|
9211
9374
|
}
|
|
9212
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
|
+
|
|
9213
9409
|
/*
|
|
9214
9410
|
* @Author: baozhoutao@steedos.com
|
|
9215
9411
|
* @Date: 2022-07-05 15:55:39
|
|
9216
|
-
* @LastEditors:
|
|
9217
|
-
* @LastEditTime:
|
|
9412
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9413
|
+
* @LastEditTime: 2024-01-16 11:14:34
|
|
9218
9414
|
* @Description:
|
|
9219
9415
|
*/
|
|
9220
9416
|
|
|
@@ -9386,7 +9582,7 @@ async function getField(objectName, fieldName) {
|
|
|
9386
9582
|
async function getFormSchema(objectName, ctx) {
|
|
9387
9583
|
const uiSchema = await getUISchema(objectName);
|
|
9388
9584
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
9389
|
-
console.log(`getFormSchema====>`, amisSchema)
|
|
9585
|
+
// console.log(`getFormSchema====>`, amisSchema)
|
|
9390
9586
|
return {
|
|
9391
9587
|
uiSchema,
|
|
9392
9588
|
amisSchema,
|
|
@@ -9712,110 +9908,164 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9712
9908
|
"label": "对象表单",
|
|
9713
9909
|
"objectApiName": "${objectName}",
|
|
9714
9910
|
"recordId": "${recordId}",
|
|
9715
|
-
"id": "u:d4a495811d57",
|
|
9716
9911
|
appId: appId
|
|
9717
9912
|
}
|
|
9718
9913
|
],
|
|
9719
|
-
"id": "u:5d4e7e3f6ecc"
|
|
9720
9914
|
};
|
|
9721
9915
|
const related = {
|
|
9722
9916
|
"title": i18next.t('frontend_record_detail_tab_related'),
|
|
9723
|
-
"className": "px-0
|
|
9917
|
+
"className": "px-0 py-4",
|
|
9724
9918
|
"body": [
|
|
9725
9919
|
{
|
|
9726
9920
|
"type": "steedos-object-related-lists",
|
|
9727
9921
|
"label": "相关列表",
|
|
9728
9922
|
"objectApiName": "${objectName}",
|
|
9729
9923
|
"recordId": "${recordId}",
|
|
9730
|
-
"id": "u:3b85b7b7a7f6",
|
|
9731
9924
|
appId: appId
|
|
9732
9925
|
}
|
|
9733
9926
|
],
|
|
9734
|
-
"id": "u:1a0326aeec2b"
|
|
9735
9927
|
};
|
|
9736
9928
|
const content = {
|
|
9737
9929
|
"type": "tabs",
|
|
9738
|
-
"className": "
|
|
9930
|
+
"className": "steedos-record-tabs bg-white p-4 m-0 mt-2 border-y",
|
|
9931
|
+
"contentClassName": "bg-none",
|
|
9739
9932
|
"tabs": [
|
|
9740
9933
|
detailed
|
|
9741
9934
|
],
|
|
9742
|
-
"id": "u:a649e4094a12"
|
|
9743
9935
|
};
|
|
9744
9936
|
if(relatedLists.length){
|
|
9745
9937
|
content.tabs.push(related);
|
|
9746
9938
|
}
|
|
9939
|
+
// content.tabs = reverse(content.tabs)
|
|
9747
9940
|
return {
|
|
9748
9941
|
uiSchema,
|
|
9749
9942
|
amisSchema: {
|
|
9750
|
-
"type": "service",
|
|
9943
|
+
"type": "steedos-record-service",
|
|
9751
9944
|
"body": [
|
|
9752
9945
|
{
|
|
9753
9946
|
"type": "steedos-record-detail-header",
|
|
9754
9947
|
"label": "标题面板",
|
|
9755
9948
|
"objectApiName": "${objectName}",
|
|
9756
9949
|
"recordId": "${recordId}",
|
|
9757
|
-
"id": "u:48d2c28eb755"
|
|
9950
|
+
"id": "u:48d2c28eb755",
|
|
9951
|
+
"showButtons": props.showButtons,
|
|
9952
|
+
"showBackButton": props.showBackButton,
|
|
9758
9953
|
},
|
|
9759
9954
|
content
|
|
9760
9955
|
],
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
},
|
|
9765
|
-
onEvent: {
|
|
9766
|
-
"recordLoaded": {
|
|
9767
|
-
"actions": [
|
|
9768
|
-
{
|
|
9769
|
-
"actionType": "reload",
|
|
9770
|
-
"data": {
|
|
9771
|
-
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
9772
|
-
"_master.record": `\${record}`,
|
|
9773
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
9774
|
-
"_master.objectName": "${objectName}",
|
|
9775
|
-
"_master.recordId": "${recordId}"
|
|
9776
|
-
}
|
|
9777
|
-
}
|
|
9778
|
-
]
|
|
9779
|
-
},
|
|
9780
|
-
...props.onEvent
|
|
9781
|
-
},
|
|
9956
|
+
"objectApiName": "${objectName}",
|
|
9957
|
+
"recordId": "${recordId}",
|
|
9958
|
+
onEvent: props.onEvent,
|
|
9782
9959
|
}
|
|
9783
9960
|
}
|
|
9784
9961
|
}
|
|
9785
9962
|
|
|
9786
|
-
async function getRecordServiceSchema(objectName, appId, props = {}) {
|
|
9963
|
+
async function getRecordServiceSchema(objectName, appId, props = {}, body) {
|
|
9787
9964
|
const uiSchema = await getUISchema(objectName);
|
|
9965
|
+
const fields = ___default.values(uiSchema.fields);
|
|
9966
|
+
const serviceId = `u:steedos-record-service-${objectName}`;
|
|
9788
9967
|
return {
|
|
9789
9968
|
uiSchema,
|
|
9790
9969
|
amisSchema: {
|
|
9791
|
-
|
|
9792
|
-
"
|
|
9793
|
-
data: {
|
|
9794
|
-
"_master.objectName": "${objectName}",
|
|
9795
|
-
"_master.recordId": "${recordId}"
|
|
9796
|
-
},
|
|
9797
|
-
"style": {
|
|
9798
|
-
"padding": "var(--Page-body-padding)",
|
|
9799
|
-
...props.style
|
|
9800
|
-
},
|
|
9970
|
+
type: 'service',
|
|
9971
|
+
className: "p-0 m-0",
|
|
9801
9972
|
onEvent: {
|
|
9802
|
-
|
|
9973
|
+
[`@data.changed.${objectName}`]: {
|
|
9803
9974
|
"actions": [
|
|
9804
9975
|
{
|
|
9805
9976
|
"actionType": "reload",
|
|
9806
|
-
"
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9977
|
+
"componentId": serviceId,
|
|
9978
|
+
"expression": "this.__deletedRecord != true"
|
|
9979
|
+
},
|
|
9980
|
+
{
|
|
9981
|
+
"actionType": "custom",
|
|
9982
|
+
"script": "window.goBack()",
|
|
9983
|
+
"expression": "this.__deletedRecord === true"
|
|
9813
9984
|
}
|
|
9814
9985
|
]
|
|
9815
9986
|
},
|
|
9816
|
-
|
|
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
|
+
}
|
|
9817
10026
|
}
|
|
9818
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
|
+
}
|
|
9819
10069
|
}
|
|
9820
10070
|
}
|
|
9821
10071
|
|
|
@@ -10756,9 +11006,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
10756
11006
|
*/
|
|
10757
11007
|
if(enable_tree){
|
|
10758
11008
|
const rows = _.map(payload.data.rows, (item)=>{
|
|
10759
|
-
|
|
10760
|
-
|
|
10761
|
-
|
|
11009
|
+
if (!item.children) {
|
|
11010
|
+
return { ...item, children: [] };
|
|
11011
|
+
} else {
|
|
11012
|
+
return item;
|
|
11013
|
+
}
|
|
10762
11014
|
})
|
|
10763
11015
|
payload.data.rows = rows;
|
|
10764
11016
|
}
|
|
@@ -11207,9 +11459,17 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
11207
11459
|
}
|
|
11208
11460
|
// console.log(`lookupToAmis====`, field, readonly, ctx)
|
|
11209
11461
|
if(readonly){
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
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
|
+
}
|
|
11213
11473
|
}
|
|
11214
11474
|
}
|
|
11215
11475
|
if(field.reference_to && !_$1.isString(field.reference_to) && !readonly){
|
|
@@ -12203,11 +12463,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12203
12463
|
if(field.subFields){
|
|
12204
12464
|
convertData = {
|
|
12205
12465
|
type: 'steedos-input-table',
|
|
12206
|
-
showIndex: true,
|
|
12207
12466
|
editable: !readonly,
|
|
12208
12467
|
addable: !readonly,
|
|
12209
12468
|
removable: !readonly,
|
|
12210
|
-
draggable: !readonly,
|
|
12211
12469
|
fields: [],
|
|
12212
12470
|
amis:{
|
|
12213
12471
|
columnsTogglable: false
|
|
@@ -12259,7 +12517,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12259
12517
|
if(field.is_wide || convertData.type === 'group'){
|
|
12260
12518
|
convertData.className = 'col-span-2 m-0';
|
|
12261
12519
|
}else {
|
|
12262
|
-
convertData.className = 'm-
|
|
12520
|
+
convertData.className = 'm-0';
|
|
12263
12521
|
}
|
|
12264
12522
|
if(readonly){
|
|
12265
12523
|
convertData.className = `${convertData.className} border-b`;
|
|
@@ -12284,6 +12542,10 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12284
12542
|
}
|
|
12285
12543
|
}
|
|
12286
12544
|
|
|
12545
|
+
if(ctx.amisData && ctx.amisData._master && ctx.amisData._master.relatedKey === field.name){
|
|
12546
|
+
convertData.className = `${convertData.className || ''} hidden`;
|
|
12547
|
+
}
|
|
12548
|
+
|
|
12287
12549
|
if(_$1.isString(baseData.required)){
|
|
12288
12550
|
if(baseData.required.startsWith("{{")){
|
|
12289
12551
|
baseData.requiredOn = `${baseData.required.substring(2, baseData.required.length -2).replace(/formData./g, 'data.')}`;
|
|
@@ -12664,9 +12926,61 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12664
12926
|
/*
|
|
12665
12927
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12666
12928
|
* @Date: 2023-11-15 09:50:22
|
|
12667
|
-
* @LastEditors:
|
|
12668
|
-
* @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 转换后的子表组件字段值
|
|
12669
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
|
+
}
|
|
12670
12984
|
|
|
12671
12985
|
/**
|
|
12672
12986
|
* @param {*} props
|
|
@@ -12814,7 +13128,19 @@ function getFormPagination(props, mode) {
|
|
|
12814
13128
|
let currentIndex = event.data.index;
|
|
12815
13129
|
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12816
13130
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12817
|
-
|
|
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
|
+
}
|
|
12818
13144
|
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
12819
13145
|
doAction({
|
|
12820
13146
|
"componentId": "${props.id}",
|
|
@@ -12881,7 +13207,8 @@ function getFormPagination(props, mode) {
|
|
|
12881
13207
|
},
|
|
12882
13208
|
{
|
|
12883
13209
|
"type": "tpl",
|
|
12884
|
-
|
|
13210
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
13211
|
+
"tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
|
|
12885
13212
|
},
|
|
12886
13213
|
{
|
|
12887
13214
|
"type": "button",
|
|
@@ -12889,7 +13216,9 @@ function getFormPagination(props, mode) {
|
|
|
12889
13216
|
"icon": `fa fa-angle-right`,
|
|
12890
13217
|
"level": "link",
|
|
12891
13218
|
"pageChangeDirection": "next",
|
|
12892
|
-
"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",
|
|
12893
13222
|
"size": "sm",
|
|
12894
13223
|
"id": buttonNextId,
|
|
12895
13224
|
"onEvent": {
|
|
@@ -12922,14 +13251,14 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12922
13251
|
"data": {
|
|
12923
13252
|
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
12924
13253
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
12925
|
-
"&": "${__tableItems[__super.index]}"
|
|
13254
|
+
"&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
|
|
12926
13255
|
}
|
|
12927
13256
|
});
|
|
12928
13257
|
let formBody = [
|
|
12929
13258
|
{
|
|
12930
13259
|
"type": "wrapper",
|
|
12931
13260
|
"size": "none",
|
|
12932
|
-
"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",
|
|
12933
13262
|
"body": [
|
|
12934
13263
|
getFormPagination(props, mode)
|
|
12935
13264
|
]
|
|
@@ -12945,7 +13274,8 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12945
13274
|
}
|
|
12946
13275
|
];
|
|
12947
13276
|
let onServiceInitedScript = `
|
|
12948
|
-
|
|
13277
|
+
|
|
13278
|
+
// 以下脚本解决了有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
12949
13279
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
12950
13280
|
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
12951
13281
|
// 再比如工作流规则详细页面修改了子表字段”时间触发器“值后,在只读界面点击查看按钮弹出的表单中__tableItems值是修改前的值
|
|
@@ -12958,6 +13288,11 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12958
13288
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
12959
13289
|
// 这里如果不.clone的话,在弹出窗口中显示的子表组件,添加行后点窗口的取消按钮关闭窗口后无法把之前的操作还原,即把之前添加的行自动移除
|
|
12960
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
|
+
}
|
|
12961
13296
|
//不可以直接像event.data.__tableItems = lastestFieldValue; 这样整个赋值,否则作用域会断
|
|
12962
13297
|
let mode = "${mode}";
|
|
12963
13298
|
if(mode === "new"){
|
|
@@ -12980,6 +13315,16 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
12980
13315
|
event.data.__tableItems.forEach(function(n,i){
|
|
12981
13316
|
event.data.__tableItems[i] = lastestFieldValue[i];
|
|
12982
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
|
+
}
|
|
12983
13328
|
`;
|
|
12984
13329
|
let schema = {
|
|
12985
13330
|
"type": "service",
|
|
@@ -13000,6 +13345,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13000
13345
|
// "body": formBody,
|
|
13001
13346
|
"data": {
|
|
13002
13347
|
"__page": "${index + 1}",
|
|
13348
|
+
"__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
|
|
13003
13349
|
// "__total": `\${${props.name}.length}`,
|
|
13004
13350
|
// "__total": "${__tableItems.length}",
|
|
13005
13351
|
// "__paginationServiceId": serviceId,
|
|
@@ -13047,7 +13393,22 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13047
13393
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13048
13394
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
13049
13395
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
13050
|
-
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
|
+
}
|
|
13051
13412
|
doAction({
|
|
13052
13413
|
"componentId": "${props.id}",
|
|
13053
13414
|
"actionType": "setValue",
|
|
@@ -13187,7 +13548,18 @@ async function getButtonActions(props, mode) {
|
|
|
13187
13548
|
let scope = event.context.scoped;
|
|
13188
13549
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13189
13550
|
// 新建一条空白行并保存到子表组件
|
|
13190
|
-
|
|
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
|
+
}
|
|
13191
13563
|
doAction({
|
|
13192
13564
|
"componentId": "${props.id}",
|
|
13193
13565
|
"actionType": "setValue",
|
|
@@ -13199,7 +13571,13 @@ async function getButtonActions(props, mode) {
|
|
|
13199
13571
|
let __paginationServiceId = "${formPaginationId}";
|
|
13200
13572
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13201
13573
|
event.data.index = __paginationData.index;
|
|
13202
|
-
|
|
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
|
+
}
|
|
13203
13581
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13204
13582
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13205
13583
|
`;
|
|
@@ -13210,7 +13588,19 @@ async function getButtonActions(props, mode) {
|
|
|
13210
13588
|
let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
|
|
13211
13589
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13212
13590
|
// 复制当前页数据到新建行并保存到子表组件
|
|
13213
|
-
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
|
+
}
|
|
13214
13604
|
doAction({
|
|
13215
13605
|
"componentId": "${props.id}",
|
|
13216
13606
|
"actionType": "setValue",
|
|
@@ -13222,7 +13612,13 @@ async function getButtonActions(props, mode) {
|
|
|
13222
13612
|
let __paginationServiceId = "${formPaginationId}";
|
|
13223
13613
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13224
13614
|
event.data.index = __paginationData.index;
|
|
13225
|
-
|
|
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
|
+
}
|
|
13226
13622
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
13227
13623
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
13228
13624
|
`;
|
|
@@ -13298,13 +13694,16 @@ async function getButtonActions(props, mode) {
|
|
|
13298
13694
|
"_master": "${_master}",
|
|
13299
13695
|
"global": "${global}",
|
|
13300
13696
|
"uiSchema": "${uiSchema}",
|
|
13301
|
-
"index": "${index}"
|
|
13697
|
+
"index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
|
|
13698
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13302
13699
|
// "__tableItems": `\${${props.name}}`
|
|
13303
13700
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13304
13701
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13305
13702
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13306
|
-
|
|
13307
|
-
|
|
13703
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
13704
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
13705
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13706
|
+
},
|
|
13308
13707
|
"actions": dialogButtons,
|
|
13309
13708
|
"onEvent": {
|
|
13310
13709
|
"confirm": {
|
|
@@ -13326,35 +13725,39 @@ async function getButtonActions(props, mode) {
|
|
|
13326
13725
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
13327
13726
|
}
|
|
13328
13727
|
if (mode == "new") {
|
|
13329
|
-
`
|
|
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
|
-
`;
|
|
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
|
+
// };
|
|
13358
13761
|
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
13359
13762
|
// actions = [actionNewLine, actionShowEditDialog];
|
|
13360
13763
|
actions = [actionShowEditDialog];
|
|
@@ -13389,15 +13792,17 @@ async function getButtonActions(props, mode) {
|
|
|
13389
13792
|
// 映射到中间变量__parentForm而不是直接用&展开映射是为了避免表单中字段名与作用域中变量重名
|
|
13390
13793
|
// "__parentForm": "${__super.__super || {}}",
|
|
13391
13794
|
"__parentForm": parentFormData,
|
|
13795
|
+
"_master": "${_master}",
|
|
13392
13796
|
"global": "${global}",
|
|
13393
13797
|
"uiSchema": "${uiSchema}",
|
|
13394
13798
|
"index": "${index}",
|
|
13799
|
+
"parent": "${__super.parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
13395
13800
|
// "__tableItems": `\${${props.name}}`
|
|
13396
13801
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13397
13802
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13398
13803
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13399
|
-
"__tableItems": `\${(
|
|
13400
|
-
|
|
13804
|
+
"__tableItems": `\${((__super.parent ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13805
|
+
},
|
|
13401
13806
|
}
|
|
13402
13807
|
}
|
|
13403
13808
|
];
|
|
@@ -13413,7 +13818,23 @@ async function getButtonActions(props, mode) {
|
|
|
13413
13818
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
13414
13819
|
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
13415
13820
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13416
|
-
|
|
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
|
+
}
|
|
13417
13838
|
doAction({
|
|
13418
13839
|
"componentId": "${props.id}",
|
|
13419
13840
|
"actionType": "setValue",
|
|
@@ -13499,39 +13920,53 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13499
13920
|
if (!props.id) {
|
|
13500
13921
|
props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
|
|
13501
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
|
+
}
|
|
13502
13934
|
let serviceId = getComponentId("table_service", props.id);
|
|
13503
13935
|
let buttonsForColumnOperations = [];
|
|
13504
13936
|
let inlineEditMode = props.inlineEditMode;
|
|
13505
13937
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
13506
|
-
if
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
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
|
+
}
|
|
13518
13957
|
}
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
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);
|
|
13523
13967
|
}
|
|
13524
13968
|
}
|
|
13525
|
-
|
|
13526
|
-
// 只读时显示查看按钮
|
|
13527
|
-
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13528
|
-
let buttonViewSchema = await getButtonView(props);
|
|
13529
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13530
|
-
}
|
|
13531
|
-
if (props.removable) {
|
|
13532
|
-
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13533
|
-
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13534
|
-
}
|
|
13969
|
+
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13535
13970
|
let inputTableSchema = {
|
|
13536
13971
|
"type": "input-table",
|
|
13537
13972
|
"label": props.label,
|
|
@@ -13549,8 +13984,37 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13549
13984
|
"strictMode": props.strictMode,
|
|
13550
13985
|
"showTableAddBtn": false,
|
|
13551
13986
|
"showFooterAddBtn": false,
|
|
13552
|
-
"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
|
+
}
|
|
13553
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
|
+
}
|
|
13554
14018
|
if (buttonsForColumnOperations.length) {
|
|
13555
14019
|
inputTableSchema.columns.push({
|
|
13556
14020
|
"name": "__op__",
|
|
@@ -13562,17 +14026,18 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13562
14026
|
if (showAsInlineEditMode) {
|
|
13563
14027
|
inputTableSchema.needConfirm = false;
|
|
13564
14028
|
}
|
|
13565
|
-
let amis = props["input-table"] || props.amis;//额外支持"input-table"代替amis属性,是因为在字段yml文件中用amis作为key不好理解
|
|
13566
14029
|
if (amis) {
|
|
13567
14030
|
// 支持配置amis属性重写或添加最终生成的input-table中任何属性。
|
|
13568
14031
|
delete amis.id;//如果steedos-input-table组件配置了amis.id属性,会造成新建编辑行功能不生效
|
|
14032
|
+
delete amis.pipeIn;//该属性在上面合并过了
|
|
14033
|
+
delete amis.pipeOut;//该属性在上面合并过了
|
|
13569
14034
|
Object.assign(inputTableSchema, amis);
|
|
13570
14035
|
}
|
|
13571
14036
|
const isAnyFieldHasDependOn = (props.fields || []).find(function (item) {
|
|
13572
14037
|
return item.depend_on;
|
|
13573
14038
|
});
|
|
13574
14039
|
if (isAnyFieldHasDependOn) {
|
|
13575
|
-
// 有任意一个子字段有depend_on
|
|
14040
|
+
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
|
|
13576
14041
|
Object.assign(inputTableSchema, {
|
|
13577
14042
|
strictMode: false
|
|
13578
14043
|
});
|
|
@@ -13677,7 +14142,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
|
|
|
13677
14142
|
// 获取
|
|
13678
14143
|
async function getRecordPageInitSchema(objectApiName){
|
|
13679
14144
|
const relatedList = await getObjectRelatedList(objectApiName);
|
|
13680
|
-
|
|
14145
|
+
await getUISchema(objectApiName);
|
|
13681
14146
|
let body = [
|
|
13682
14147
|
// detailHeaderAmisSchema,
|
|
13683
14148
|
{
|
|
@@ -13685,28 +14150,7 @@ async function getRecordPageInitSchema(objectApiName){
|
|
|
13685
14150
|
"label": "标题面板",
|
|
13686
14151
|
"objectApiName": "${objectName}",
|
|
13687
14152
|
"recordId": "${recordId}",
|
|
13688
|
-
"onEvent": {
|
|
13689
|
-
"recordLoaded": {
|
|
13690
|
-
"actions": [
|
|
13691
|
-
{
|
|
13692
|
-
"actionType": "setValue",
|
|
13693
|
-
"args": {
|
|
13694
|
-
"value": {
|
|
13695
|
-
"recordLoaded": true,
|
|
13696
|
-
}
|
|
13697
|
-
}
|
|
13698
|
-
},
|
|
13699
|
-
{
|
|
13700
|
-
"actionType": "reload",
|
|
13701
|
-
"data": {
|
|
13702
|
-
"name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
13703
|
-
"record": `\${record}`,
|
|
13704
|
-
"recordLoaded": true,
|
|
13705
|
-
}
|
|
13706
|
-
}
|
|
13707
|
-
]
|
|
13708
|
-
}
|
|
13709
|
-
}
|
|
14153
|
+
"onEvent": {}
|
|
13710
14154
|
}
|
|
13711
14155
|
];
|
|
13712
14156
|
let contentBody = {
|
|
@@ -16271,5 +16715,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
16271
16715
|
};
|
|
16272
16716
|
};
|
|
16273
16717
|
|
|
16274
|
-
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 };
|
|
16275
16719
|
//# sourceMappingURL=index.esm.js.map
|