@steedos-widgets/amis-lib 3.6.2-beta.4 → 3.6.2-beta.6
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 +397 -238
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +397 -240
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +164 -153
- package/dist/index.umd.js.map +1 -1
- package/dist/types/lib/converter/amis/api.d.ts +0 -4
- package/dist/types/lib/converter/amis/fields/lookup.d.ts +1 -0
- package/dist/types/lib/converter/amis/header.d.ts +1 -56
- package/dist/types/lib/converter/amis/index.d.ts +0 -87
- package/dist/types/lib/input_table.d.ts +1 -0
- package/dist/types/lib/objects.d.ts +77 -153
- package/dist/types/lib/objectsRelated.d.ts +19 -0
- package/dist/types/lib/page_init.d.ts +1 -38
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -1430,9 +1430,9 @@ var frontend_display_type_is_split = "分栏视图";
|
|
|
1430
1430
|
var frontend_display_as = "显示为";
|
|
1431
1431
|
var frontend_record_sum = "个项目";
|
|
1432
1432
|
var frontend_button_reload_tooltip = "刷新";
|
|
1433
|
-
var frontend_button_search_tooltip = "
|
|
1433
|
+
var frontend_button_search_tooltip = "搜索";
|
|
1434
1434
|
var frontend_fields_filter_button_search = "搜索";
|
|
1435
|
-
var frontend_fields_filter_button_settings = "
|
|
1435
|
+
var frontend_fields_filter_button_settings = "选择搜索项";
|
|
1436
1436
|
var frontend_button_listview_control_tooltip = "列表视图控制";
|
|
1437
1437
|
var frontend_button_listview_control_label = "列表视图控制";
|
|
1438
1438
|
var frontend_listview_control_columns = "显示的列";
|
|
@@ -2089,7 +2089,7 @@ async function getTableColumns(fields, options){
|
|
|
2089
2089
|
if(field.wrap != true){
|
|
2090
2090
|
className += " whitespace-nowrap ";
|
|
2091
2091
|
}else {
|
|
2092
|
-
className += " break-
|
|
2092
|
+
className += " break-words ";
|
|
2093
2093
|
}
|
|
2094
2094
|
let columnItem;
|
|
2095
2095
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
@@ -2525,7 +2525,8 @@ async function getTableOperation(ctx){
|
|
|
2525
2525
|
label: " ",
|
|
2526
2526
|
fixed: 'right',
|
|
2527
2527
|
labelClassName: 'text-center',
|
|
2528
|
-
|
|
2528
|
+
//TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
|
|
2529
|
+
className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
|
|
2529
2530
|
buttons: [
|
|
2530
2531
|
{
|
|
2531
2532
|
"type": "steedos-dropdown-button",
|
|
@@ -2621,7 +2622,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2621
2622
|
}
|
|
2622
2623
|
return {
|
|
2623
2624
|
mode: "cards",
|
|
2624
|
-
perPageAvailable: [
|
|
2625
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2625
2626
|
name: "thelist",
|
|
2626
2627
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2627
2628
|
className: "",
|
|
@@ -2654,7 +2655,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2654
2655
|
|
|
2655
2656
|
return {
|
|
2656
2657
|
mode: "table",
|
|
2657
|
-
perPageAvailable: [
|
|
2658
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2658
2659
|
name: "thelist",
|
|
2659
2660
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2660
2661
|
className: "",
|
|
@@ -3158,12 +3159,21 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3158
3159
|
}
|
|
3159
3160
|
payload.data = data;
|
|
3160
3161
|
payload.data.__objectName = "${object.name}";
|
|
3161
|
-
payload.data.
|
|
3162
|
+
payload.data.record = record;
|
|
3163
|
+
|
|
3164
|
+
payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
|
|
3165
|
+
payload.data._master = {
|
|
3166
|
+
record: record,
|
|
3167
|
+
objectName: "${object.name}",
|
|
3168
|
+
recordId: record._id
|
|
3169
|
+
}
|
|
3162
3170
|
window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
|
|
3163
3171
|
}
|
|
3164
3172
|
if(payload.errors){
|
|
3165
3173
|
payload.status = 2;
|
|
3166
3174
|
payload.msg = payload.errors[0].message;
|
|
3175
|
+
}else{
|
|
3176
|
+
payload.data.recordLoaded = true;
|
|
3167
3177
|
}
|
|
3168
3178
|
${options && options.initApiAdaptor || ''}
|
|
3169
3179
|
return payload;
|
|
@@ -3306,7 +3316,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3306
3316
|
cache: API_CACHE,
|
|
3307
3317
|
requestAdaptor: `
|
|
3308
3318
|
// 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
|
|
3309
|
-
var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
|
|
3319
|
+
var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
|
|
3310
3320
|
if(!recordId){
|
|
3311
3321
|
// 新建则不请求任何数据
|
|
3312
3322
|
data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
|
|
@@ -3381,15 +3391,17 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3381
3391
|
}
|
|
3382
3392
|
// data下的变量需要在保存接口(getSaveApi)中被删除。
|
|
3383
3393
|
payload.data = {
|
|
3384
|
-
...initialValues
|
|
3394
|
+
...initialValues,
|
|
3395
|
+
editFormInited: true
|
|
3385
3396
|
}
|
|
3386
3397
|
${options.initApiAdaptor || ''}
|
|
3398
|
+
// console.log('getEditFormInitApi======>', payload);
|
|
3387
3399
|
return payload;
|
|
3388
3400
|
`,
|
|
3389
|
-
responseData: {
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
},
|
|
3401
|
+
// responseData: {
|
|
3402
|
+
// initialValues: "$$",
|
|
3403
|
+
// editFormInited: true
|
|
3404
|
+
// },
|
|
3393
3405
|
data: data,
|
|
3394
3406
|
headers: {
|
|
3395
3407
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -5140,7 +5152,7 @@ const StandardButtons = {
|
|
|
5140
5152
|
}
|
|
5141
5153
|
};
|
|
5142
5154
|
|
|
5143
|
-
const getGlobalData
|
|
5155
|
+
const getGlobalData = () => {
|
|
5144
5156
|
return {
|
|
5145
5157
|
now: new Date(),
|
|
5146
5158
|
};
|
|
@@ -5199,7 +5211,7 @@ const getButtonVisible = (button, ctx) => {
|
|
|
5199
5211
|
button._visible,
|
|
5200
5212
|
props.record,
|
|
5201
5213
|
"#",
|
|
5202
|
-
getGlobalData
|
|
5214
|
+
getGlobalData(),
|
|
5203
5215
|
props.userSession
|
|
5204
5216
|
);
|
|
5205
5217
|
};
|
|
@@ -6577,6 +6589,48 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6577
6589
|
return headerSchema;
|
|
6578
6590
|
}
|
|
6579
6591
|
|
|
6592
|
+
function getBackButtonSchema(){
|
|
6593
|
+
return {
|
|
6594
|
+
"type": "service",
|
|
6595
|
+
"onEvent": {
|
|
6596
|
+
"@history_paths.changed": {
|
|
6597
|
+
"actions": [
|
|
6598
|
+
{
|
|
6599
|
+
"actionType": "reload",
|
|
6600
|
+
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6601
|
+
"data": {
|
|
6602
|
+
}
|
|
6603
|
+
}
|
|
6604
|
+
]
|
|
6605
|
+
}
|
|
6606
|
+
},
|
|
6607
|
+
"body":[{
|
|
6608
|
+
"type": "button",
|
|
6609
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6610
|
+
"className":"flex mr-4",
|
|
6611
|
+
"onEvent": {
|
|
6612
|
+
"click": {
|
|
6613
|
+
"actions": [
|
|
6614
|
+
{
|
|
6615
|
+
"actionType": "custom",
|
|
6616
|
+
"script": "window.goBack()"
|
|
6617
|
+
}
|
|
6618
|
+
]
|
|
6619
|
+
}
|
|
6620
|
+
},
|
|
6621
|
+
"body": [
|
|
6622
|
+
{
|
|
6623
|
+
"type": "steedos-icon",
|
|
6624
|
+
"category": "utility",
|
|
6625
|
+
"name": "back",
|
|
6626
|
+
"colorVariant": "default",
|
|
6627
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6628
|
+
}
|
|
6629
|
+
]
|
|
6630
|
+
}]
|
|
6631
|
+
}
|
|
6632
|
+
}
|
|
6633
|
+
|
|
6580
6634
|
/**
|
|
6581
6635
|
* 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
|
|
6582
6636
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -6585,11 +6639,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6585
6639
|
* @returns amisSchema
|
|
6586
6640
|
*/
|
|
6587
6641
|
async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
6642
|
+
// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
6588
6643
|
const { showRecordTitle = true } = options || {};
|
|
6589
6644
|
// console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
|
|
6590
6645
|
const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
|
|
6591
6646
|
|
|
6592
|
-
let amisButtonsSchema =
|
|
6647
|
+
let amisButtonsSchema = [];
|
|
6648
|
+
if(options.showButtons != false){
|
|
6649
|
+
amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
|
|
6650
|
+
}
|
|
6651
|
+
|
|
6652
|
+
let backButtonsSchema = null;
|
|
6653
|
+
|
|
6654
|
+
if(options.showBackButton != false){
|
|
6655
|
+
backButtonsSchema = getBackButtonSchema();
|
|
6656
|
+
}
|
|
6593
6657
|
|
|
6594
6658
|
// console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
|
|
6595
6659
|
|
|
@@ -6604,45 +6668,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6604
6668
|
"type": "grid",
|
|
6605
6669
|
"columns": [
|
|
6606
6670
|
{
|
|
6607
|
-
"body": [
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
"@history_paths.changed": {
|
|
6611
|
-
"actions": [
|
|
6612
|
-
{
|
|
6613
|
-
"actionType": "reload",
|
|
6614
|
-
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6615
|
-
"data": {
|
|
6616
|
-
}
|
|
6617
|
-
}
|
|
6618
|
-
]
|
|
6619
|
-
}
|
|
6620
|
-
},
|
|
6621
|
-
"body":[{
|
|
6622
|
-
"type": "button",
|
|
6623
|
-
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6624
|
-
"className":"flex mr-4",
|
|
6625
|
-
"onEvent": {
|
|
6626
|
-
"click": {
|
|
6627
|
-
"actions": [
|
|
6628
|
-
{
|
|
6629
|
-
"actionType": "custom",
|
|
6630
|
-
"script": "window.goBack()"
|
|
6631
|
-
}
|
|
6632
|
-
]
|
|
6633
|
-
}
|
|
6634
|
-
},
|
|
6635
|
-
"body": [
|
|
6636
|
-
{
|
|
6637
|
-
"type": "steedos-icon",
|
|
6638
|
-
"category": "utility",
|
|
6639
|
-
"name": "back",
|
|
6640
|
-
"colorVariant": "default",
|
|
6641
|
-
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6642
|
-
}
|
|
6643
|
-
]
|
|
6644
|
-
}]
|
|
6645
|
-
},{
|
|
6671
|
+
"body": [
|
|
6672
|
+
backButtonsSchema
|
|
6673
|
+
,{
|
|
6646
6674
|
"type": "tpl",
|
|
6647
6675
|
"className": "block",
|
|
6648
6676
|
// "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'>`
|
|
@@ -6663,8 +6691,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6663
6691
|
},
|
|
6664
6692
|
{
|
|
6665
6693
|
"type": "tpl",
|
|
6666
|
-
"tpl": "${
|
|
6667
|
-
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
6694
|
+
"tpl": "${NAME_FIELD_VALUE}",
|
|
6668
6695
|
"inline": false,
|
|
6669
6696
|
"wrapperComponent": "",
|
|
6670
6697
|
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
@@ -6692,7 +6719,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6692
6719
|
let body = [
|
|
6693
6720
|
{
|
|
6694
6721
|
"type": "wrapper",
|
|
6695
|
-
"className": "p-
|
|
6722
|
+
"className": "p-4",
|
|
6696
6723
|
"body": [
|
|
6697
6724
|
{
|
|
6698
6725
|
"type": "grid",
|
|
@@ -6707,7 +6734,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6707
6734
|
if(showRecordTitle){
|
|
6708
6735
|
body.push({
|
|
6709
6736
|
"type": "wrapper",
|
|
6710
|
-
"className": "p-
|
|
6737
|
+
"className": "p-4",
|
|
6711
6738
|
"body": [
|
|
6712
6739
|
{
|
|
6713
6740
|
"type": "grid",
|
|
@@ -6719,11 +6746,38 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6719
6746
|
});
|
|
6720
6747
|
}
|
|
6721
6748
|
|
|
6749
|
+
let max = 10;
|
|
6750
|
+
if(options.formFactor === 'SMALL'){
|
|
6751
|
+
max = 4;
|
|
6752
|
+
}
|
|
6753
|
+
|
|
6754
|
+
if(objectSchema.compactLayouts){
|
|
6755
|
+
const details = [];
|
|
6756
|
+
_.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
|
|
6757
|
+
const field = objectSchema.fields[fieldName];
|
|
6758
|
+
if(field){
|
|
6759
|
+
details.push({
|
|
6760
|
+
type: 'steedos-field',
|
|
6761
|
+
static: true,
|
|
6762
|
+
config: field,
|
|
6763
|
+
});
|
|
6764
|
+
}
|
|
6765
|
+
});
|
|
6766
|
+
|
|
6767
|
+
body.push({
|
|
6768
|
+
"type": "form",
|
|
6769
|
+
"className": "p-4 pb-0 bg-white compact-layouts",
|
|
6770
|
+
"wrapWithPanel": false,
|
|
6771
|
+
"actions": [],
|
|
6772
|
+
"body": details,
|
|
6773
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
6774
|
+
});
|
|
6775
|
+
}
|
|
6776
|
+
|
|
6722
6777
|
return {
|
|
6723
6778
|
type: 'service',
|
|
6724
6779
|
id: `page_readonly_${name}_header`,
|
|
6725
6780
|
name: `page`,
|
|
6726
|
-
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
6727
6781
|
body: body,
|
|
6728
6782
|
className: ''
|
|
6729
6783
|
}
|
|
@@ -7930,7 +7984,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7930
7984
|
{
|
|
7931
7985
|
"type": "search-box",
|
|
7932
7986
|
"name": keywordsSearchBoxName,
|
|
7933
|
-
"placeholder": "
|
|
7987
|
+
"placeholder": "快捷搜索",
|
|
7934
7988
|
"value": crudKeywords,
|
|
7935
7989
|
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7936
7990
|
"clearAndSubmit": true,
|
|
@@ -8531,7 +8585,9 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8531
8585
|
return payload;
|
|
8532
8586
|
`
|
|
8533
8587
|
},
|
|
8534
|
-
rowClassNameExpr
|
|
8588
|
+
// 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
|
|
8589
|
+
// 使用表达式给tr添加初始选中状态
|
|
8590
|
+
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 %>"
|
|
8535
8591
|
}, bodyProps);
|
|
8536
8592
|
|
|
8537
8593
|
}
|
|
@@ -8546,7 +8602,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8546
8602
|
|
|
8547
8603
|
if(body.columns && options.formFactor != 'SMALL'){
|
|
8548
8604
|
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8549
|
-
body.columns.splice(body.columns.length -
|
|
8605
|
+
body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
|
|
8550
8606
|
}
|
|
8551
8607
|
|
|
8552
8608
|
if (defaults) {
|
|
@@ -8604,11 +8660,6 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8604
8660
|
}
|
|
8605
8661
|
}
|
|
8606
8662
|
|
|
8607
|
-
const getGlobalData = (mode)=>{
|
|
8608
|
-
const user = getSteedosAuth();
|
|
8609
|
-
return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
|
|
8610
|
-
};
|
|
8611
|
-
|
|
8612
8663
|
const getFormFields$1 = (objectSchema, formProps)=>{
|
|
8613
8664
|
/**
|
|
8614
8665
|
* fieldsExtend: 重写字段定义
|
|
@@ -8686,9 +8737,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8686
8737
|
id: `service_${formSchema.id}`,
|
|
8687
8738
|
className: 'p-0',
|
|
8688
8739
|
name: `page_edit_${recordId}`,
|
|
8689
|
-
api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8690
8740
|
data:{
|
|
8691
|
-
editFormInited: false,
|
|
8692
8741
|
...amisData
|
|
8693
8742
|
},
|
|
8694
8743
|
// data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
@@ -8697,8 +8746,9 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8697
8746
|
body: [defaultsDeep({}, formSchema, {
|
|
8698
8747
|
type: "form",
|
|
8699
8748
|
mode: layout,
|
|
8749
|
+
initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8700
8750
|
data: {
|
|
8701
|
-
|
|
8751
|
+
editFormInited: false,
|
|
8702
8752
|
},
|
|
8703
8753
|
labelAlign,
|
|
8704
8754
|
persistData: false,
|
|
@@ -8712,11 +8762,15 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8712
8762
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
8713
8763
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
8714
8764
|
initFetch: recordId != 'new',
|
|
8715
|
-
body:
|
|
8765
|
+
body: {
|
|
8766
|
+
type: 'wrapper',
|
|
8767
|
+
className: 'p-0 m-0',
|
|
8768
|
+
body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
|
|
8769
|
+
hiddenOn: "${editFormInited != true}",
|
|
8770
|
+
},
|
|
8716
8771
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
8717
8772
|
bodyClassName: 'p-0',
|
|
8718
8773
|
className: 'steedos-amis-form',
|
|
8719
|
-
hiddenOn: "${editFormInited != true}",
|
|
8720
8774
|
onEvent: {
|
|
8721
8775
|
"submitSucc": {
|
|
8722
8776
|
"weight": 0,
|
|
@@ -8770,8 +8824,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8770
8824
|
type: 'service',
|
|
8771
8825
|
name: `page_readonly_${recordId}`,
|
|
8772
8826
|
id: serviceId,
|
|
8773
|
-
|
|
8774
|
-
api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8827
|
+
// api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8775
8828
|
body: [
|
|
8776
8829
|
{
|
|
8777
8830
|
"type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
|
|
@@ -8797,60 +8850,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8797
8850
|
),
|
|
8798
8851
|
className: 'steedos-amis-form bg-white',
|
|
8799
8852
|
actions: [], // 不显示表单默认的提交按钮
|
|
8800
|
-
onEvent: {
|
|
8801
|
-
[`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
|
|
8802
|
-
"actions": [
|
|
8803
|
-
{
|
|
8804
|
-
"actionType": "reload",
|
|
8805
|
-
"componentId": serviceId,
|
|
8806
|
-
"expression": "this.__deletedRecord != true"
|
|
8807
|
-
},
|
|
8808
|
-
{
|
|
8809
|
-
// "args": {
|
|
8810
|
-
// "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
|
|
8811
|
-
// "blank": false
|
|
8812
|
-
// },
|
|
8813
|
-
"actionType": "custom",
|
|
8814
|
-
"script": "window.goBack()",
|
|
8815
|
-
"expression": "this.__deletedRecord === true"
|
|
8816
|
-
}
|
|
8817
|
-
]
|
|
8818
|
-
}
|
|
8819
|
-
}
|
|
8820
8853
|
},
|
|
8821
8854
|
}
|
|
8822
8855
|
],
|
|
8823
|
-
onEvent: {
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8831
|
-
|
|
8832
|
-
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
|
|
8850
|
-
}
|
|
8856
|
+
// onEvent: {
|
|
8857
|
+
// "fetchInited": {
|
|
8858
|
+
// "weight": 0,
|
|
8859
|
+
// "actions": [
|
|
8860
|
+
// {
|
|
8861
|
+
// actionType: 'broadcast',
|
|
8862
|
+
// eventName: "recordLoaded",
|
|
8863
|
+
// args: {
|
|
8864
|
+
// eventName: "recordLoaded"
|
|
8865
|
+
// },
|
|
8866
|
+
// data: {
|
|
8867
|
+
// objectName: "${event.data.__objectName}",
|
|
8868
|
+
// record: "${event.data.__record}"
|
|
8869
|
+
// },
|
|
8870
|
+
// expression: "${event.data.__response.error != true}"
|
|
8871
|
+
// },
|
|
8872
|
+
// {
|
|
8873
|
+
// "actionType": "setValue",
|
|
8874
|
+
// "args": {
|
|
8875
|
+
// value: {
|
|
8876
|
+
// "recordLoaded": true,
|
|
8877
|
+
// }
|
|
8878
|
+
// },
|
|
8879
|
+
// expression: "${event.data.__response.error != true}"
|
|
8880
|
+
// }
|
|
8881
|
+
// ]
|
|
8882
|
+
// }
|
|
8883
|
+
// }
|
|
8851
8884
|
};
|
|
8852
8885
|
|
|
8853
8886
|
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
8887
|
+
// console.log('getObjectDetail=====>', amisSchema);
|
|
8854
8888
|
return amisSchema;
|
|
8855
8889
|
}
|
|
8856
8890
|
|
|
@@ -8930,8 +8964,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
8930
8964
|
/*
|
|
8931
8965
|
* @Author: baozhoutao@steedos.com
|
|
8932
8966
|
* @Date: 2022-07-05 15:55:39
|
|
8933
|
-
* @LastEditors:
|
|
8934
|
-
* @LastEditTime:
|
|
8967
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
8968
|
+
* @LastEditTime: 2024-01-15 10:34:46
|
|
8935
8969
|
* @Description:
|
|
8936
8970
|
*/
|
|
8937
8971
|
|
|
@@ -9311,11 +9345,44 @@ async function getRelatedListSchema(
|
|
|
9311
9345
|
};
|
|
9312
9346
|
}
|
|
9313
9347
|
|
|
9348
|
+
async function getObjectRelatedListsMiniSchema(objectApiName){
|
|
9349
|
+
const relatedLists = await getObjectRelatedList(objectApiName);
|
|
9350
|
+
|
|
9351
|
+
const relatedListsMiniSchema = [];
|
|
9352
|
+
|
|
9353
|
+
for (const relatedList of relatedLists) {
|
|
9354
|
+
relatedListsMiniSchema.push(
|
|
9355
|
+
{
|
|
9356
|
+
type: 'steedos-record-detail-list-mini',
|
|
9357
|
+
objectApiName: objectApiName,
|
|
9358
|
+
// recordId: recordId,
|
|
9359
|
+
formFactor: formFactor,
|
|
9360
|
+
relatedObjectApiName: relatedList.object_name,
|
|
9361
|
+
foreign_key: relatedList.foreign_key,
|
|
9362
|
+
relatedKey: relatedList.foreign_key,
|
|
9363
|
+
columns: relatedList.columns,
|
|
9364
|
+
sort: relatedList.sort,
|
|
9365
|
+
filters: relatedList.filters,
|
|
9366
|
+
visible_on: relatedList.visible_on,
|
|
9367
|
+
perPage: relatedList.page_size || perPage,
|
|
9368
|
+
hiddenEmptyTable: true,
|
|
9369
|
+
relatedLabel: relatedList.label
|
|
9370
|
+
}
|
|
9371
|
+
);
|
|
9372
|
+
}
|
|
9373
|
+
|
|
9374
|
+
return {
|
|
9375
|
+
type: 'wrapper',
|
|
9376
|
+
className: "steedos-record-detail-related-lists-mini",
|
|
9377
|
+
body: relatedListsMiniSchema
|
|
9378
|
+
}
|
|
9379
|
+
}
|
|
9380
|
+
|
|
9314
9381
|
/*
|
|
9315
9382
|
* @Author: baozhoutao@steedos.com
|
|
9316
9383
|
* @Date: 2022-07-05 15:55:39
|
|
9317
|
-
* @LastEditors:
|
|
9318
|
-
* @LastEditTime:
|
|
9384
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9385
|
+
* @LastEditTime: 2024-01-16 11:14:34
|
|
9319
9386
|
* @Description:
|
|
9320
9387
|
*/
|
|
9321
9388
|
|
|
@@ -9487,7 +9554,7 @@ async function getField(objectName, fieldName) {
|
|
|
9487
9554
|
async function getFormSchema(objectName, ctx) {
|
|
9488
9555
|
const uiSchema = await getUISchema(objectName);
|
|
9489
9556
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
9490
|
-
console.log(`getFormSchema====>`, amisSchema)
|
|
9557
|
+
// console.log(`getFormSchema====>`, amisSchema)
|
|
9491
9558
|
return {
|
|
9492
9559
|
uiSchema,
|
|
9493
9560
|
amisSchema,
|
|
@@ -9845,78 +9912,136 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9845
9912
|
if(relatedLists.length){
|
|
9846
9913
|
content.tabs.push(related);
|
|
9847
9914
|
}
|
|
9915
|
+
content.tabs = _$1.reverse(content.tabs);
|
|
9848
9916
|
return {
|
|
9849
9917
|
uiSchema,
|
|
9850
9918
|
amisSchema: {
|
|
9851
|
-
"type": "service",
|
|
9919
|
+
"type": "steedos-record-service",
|
|
9852
9920
|
"body": [
|
|
9853
9921
|
{
|
|
9854
9922
|
"type": "steedos-record-detail-header",
|
|
9855
9923
|
"label": "标题面板",
|
|
9856
9924
|
"objectApiName": "${objectName}",
|
|
9857
9925
|
"recordId": "${recordId}",
|
|
9858
|
-
"id": "u:48d2c28eb755"
|
|
9926
|
+
"id": "u:48d2c28eb755",
|
|
9927
|
+
"showButtons": props.showButtons,
|
|
9928
|
+
"showBackButton": props.showBackButton,
|
|
9859
9929
|
},
|
|
9860
9930
|
content
|
|
9861
9931
|
],
|
|
9862
|
-
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
},
|
|
9866
|
-
onEvent: {
|
|
9867
|
-
"recordLoaded": {
|
|
9868
|
-
"actions": [
|
|
9869
|
-
{
|
|
9870
|
-
"actionType": "reload",
|
|
9871
|
-
"data": {
|
|
9872
|
-
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
9873
|
-
"_master.record": `\${record}`,
|
|
9874
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
9875
|
-
"_master.objectName": "${objectName}",
|
|
9876
|
-
"_master.recordId": "${recordId}"
|
|
9877
|
-
}
|
|
9878
|
-
}
|
|
9879
|
-
]
|
|
9880
|
-
},
|
|
9881
|
-
...props.onEvent
|
|
9882
|
-
},
|
|
9932
|
+
"objectApiName": "${objectName}",
|
|
9933
|
+
"recordId": "${recordId}",
|
|
9934
|
+
onEvent: props.onEvent,
|
|
9883
9935
|
}
|
|
9884
9936
|
}
|
|
9885
9937
|
}
|
|
9886
9938
|
|
|
9887
|
-
async function getRecordServiceSchema(objectName, appId, props = {}) {
|
|
9939
|
+
async function getRecordServiceSchema(objectName, appId, props = {}, body) {
|
|
9888
9940
|
const uiSchema = await getUISchema(objectName);
|
|
9941
|
+
const fields = ___default["default"].values(uiSchema.fields);
|
|
9942
|
+
const serviceId = `u:steedos-record-service-${objectName}`;
|
|
9889
9943
|
return {
|
|
9890
9944
|
uiSchema,
|
|
9891
9945
|
amisSchema: {
|
|
9892
|
-
|
|
9893
|
-
"
|
|
9894
|
-
data: {
|
|
9895
|
-
"_master.objectName": "${objectName}",
|
|
9896
|
-
"_master.recordId": "${recordId}"
|
|
9897
|
-
},
|
|
9898
|
-
"style": {
|
|
9899
|
-
"padding": "var(--Page-body-padding)",
|
|
9900
|
-
...props.style
|
|
9901
|
-
},
|
|
9946
|
+
type: 'service',
|
|
9947
|
+
className: "p-0 m-0",
|
|
9902
9948
|
onEvent: {
|
|
9903
|
-
|
|
9949
|
+
[`@data.changed.${objectName}`]: {
|
|
9904
9950
|
"actions": [
|
|
9905
9951
|
{
|
|
9906
9952
|
"actionType": "reload",
|
|
9907
|
-
"
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9953
|
+
"componentId": serviceId,
|
|
9954
|
+
"expression": "this.__deletedRecord != true"
|
|
9955
|
+
},
|
|
9956
|
+
{
|
|
9957
|
+
"actionType": "custom",
|
|
9958
|
+
"script": "window.goBack()",
|
|
9959
|
+
"expression": "this.__deletedRecord === true"
|
|
9914
9960
|
}
|
|
9915
9961
|
]
|
|
9916
9962
|
},
|
|
9917
|
-
|
|
9963
|
+
},
|
|
9964
|
+
body: {
|
|
9965
|
+
"type": "service",
|
|
9966
|
+
id: serviceId,
|
|
9967
|
+
className: 'steedos-record-service p-0 md:p-2',
|
|
9968
|
+
api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
9969
|
+
body: {
|
|
9970
|
+
"type": "wrapper",
|
|
9971
|
+
"className": "p-0 m-0",
|
|
9972
|
+
"body": body || [],
|
|
9973
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
9974
|
+
},
|
|
9975
|
+
data: {
|
|
9976
|
+
"_master.objectName": "${objectName}",
|
|
9977
|
+
"_master.recordId": "${recordId}",
|
|
9978
|
+
...(props.data || {})
|
|
9979
|
+
},
|
|
9980
|
+
"style": {
|
|
9981
|
+
// "padding": "var(--Page-body-padding)",
|
|
9982
|
+
...props.style
|
|
9983
|
+
},
|
|
9984
|
+
onEvent: {
|
|
9985
|
+
// 如果定义了fetchInited,则无法接收到广播事件@data.changed
|
|
9986
|
+
"fetchInited": {
|
|
9987
|
+
"weight": 0,
|
|
9988
|
+
"actions": [
|
|
9989
|
+
{
|
|
9990
|
+
actionType: 'broadcast',
|
|
9991
|
+
eventName: "recordLoaded",
|
|
9992
|
+
data: {
|
|
9993
|
+
objectName: "${event.data.__objectName}",
|
|
9994
|
+
record: "${event.data.record}"
|
|
9995
|
+
},
|
|
9996
|
+
expression: "${event.data.__response.error != true}"
|
|
9997
|
+
},
|
|
9998
|
+
]
|
|
9999
|
+
},
|
|
10000
|
+
...props.onEvent
|
|
10001
|
+
}
|
|
9918
10002
|
}
|
|
9919
10003
|
}
|
|
10004
|
+
|
|
10005
|
+
|
|
10006
|
+
}
|
|
10007
|
+
}
|
|
10008
|
+
|
|
10009
|
+
async function getRecordDetailMiniSchema(objectName, appId, props = {}){
|
|
10010
|
+
const uiSchema = await getUISchema(objectName);
|
|
10011
|
+
const fields = ___default["default"].values(uiSchema.fields);
|
|
10012
|
+
|
|
10013
|
+
props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
|
|
10014
|
+
|
|
10015
|
+
// TODO 处理相关表
|
|
10016
|
+
// getObjectRelatedListsMiniSchema
|
|
10017
|
+
|
|
10018
|
+
return {
|
|
10019
|
+
type: "form",
|
|
10020
|
+
wrapWithPanel: false,
|
|
10021
|
+
actions: [],
|
|
10022
|
+
initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
10023
|
+
body: {
|
|
10024
|
+
"type": "wrapper",
|
|
10025
|
+
"className": "p-0 m-0",
|
|
10026
|
+
"body": [
|
|
10027
|
+
{
|
|
10028
|
+
"type": "steedos-record-detail-header",
|
|
10029
|
+
"showButtons": false,
|
|
10030
|
+
"showBackButton": false,
|
|
10031
|
+
"objectApiName": "${objectName}",
|
|
10032
|
+
"recordId": "${recordId}",
|
|
10033
|
+
},
|
|
10034
|
+
// {
|
|
10035
|
+
// "type": "steedos-object-related-lists",
|
|
10036
|
+
// "label": "相关列表",
|
|
10037
|
+
// "objectApiName": "${objectName}",
|
|
10038
|
+
// "staticRecordId": "${recordId}",
|
|
10039
|
+
// formFactor: "SMALL",
|
|
10040
|
+
// appId: appId
|
|
10041
|
+
// }
|
|
10042
|
+
],
|
|
10043
|
+
"hiddenOn": "${_finished != true}"
|
|
10044
|
+
}
|
|
9920
10045
|
}
|
|
9921
10046
|
}
|
|
9922
10047
|
|
|
@@ -11067,7 +11192,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
11067
11192
|
labelField: referenceTo.labelField.name,
|
|
11068
11193
|
valueField: referenceTo.valueField.name,
|
|
11069
11194
|
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
|
|
11070
|
-
disabledOn: `${readonly}
|
|
11195
|
+
disabledOn: `${readonly}`,
|
|
11196
|
+
hiddenOn: `( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
|
|
11071
11197
|
modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
|
|
11072
11198
|
source: source,
|
|
11073
11199
|
size: "lg",
|
|
@@ -11311,9 +11437,15 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
11311
11437
|
// console.log(`lookupToAmis====`, field, readonly, ctx)
|
|
11312
11438
|
if(readonly){
|
|
11313
11439
|
return {
|
|
11314
|
-
type:
|
|
11315
|
-
|
|
11440
|
+
type: 'steedos-field',
|
|
11441
|
+
config: field,
|
|
11442
|
+
static: true
|
|
11316
11443
|
}
|
|
11444
|
+
|
|
11445
|
+
// return {
|
|
11446
|
+
// type: Field.getAmisStaticFieldType('picker', readonly),
|
|
11447
|
+
// tpl: Tpl.getRelatedFieldTpl(field, ctx)
|
|
11448
|
+
// }
|
|
11317
11449
|
}
|
|
11318
11450
|
if(field.reference_to && !___namespace.isString(field.reference_to) && !readonly){
|
|
11319
11451
|
return {
|
|
@@ -12306,11 +12438,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12306
12438
|
if(field.subFields){
|
|
12307
12439
|
convertData = {
|
|
12308
12440
|
type: 'steedos-input-table',
|
|
12309
|
-
showIndex: true,
|
|
12310
12441
|
editable: !readonly,
|
|
12311
12442
|
addable: !readonly,
|
|
12312
12443
|
removable: !readonly,
|
|
12313
|
-
draggable: !readonly,
|
|
12314
12444
|
fields: [],
|
|
12315
12445
|
amis:{
|
|
12316
12446
|
columnsTogglable: false
|
|
@@ -12768,7 +12898,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12768
12898
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12769
12899
|
* @Date: 2023-11-15 09:50:22
|
|
12770
12900
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12771
|
-
* @LastEditTime: 2024-01-14
|
|
12901
|
+
* @LastEditTime: 2024-01-16 14:58:51
|
|
12772
12902
|
*/
|
|
12773
12903
|
|
|
12774
12904
|
/**
|
|
@@ -12917,8 +13047,15 @@ function getFormPagination(props, mode) {
|
|
|
12917
13047
|
let currentIndex = event.data.index;
|
|
12918
13048
|
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12919
13049
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12920
|
-
|
|
12921
|
-
|
|
13050
|
+
var parent = event.data.parent;
|
|
13051
|
+
var __parentIndex = event.data.__parentIndex;
|
|
13052
|
+
if(parent){
|
|
13053
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13054
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13055
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13056
|
+
children: fieldValue[__parentIndex].children,
|
|
13057
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13058
|
+
});
|
|
12922
13059
|
}
|
|
12923
13060
|
else{
|
|
12924
13061
|
fieldValue[currentIndex] = currentFormValues;
|
|
@@ -13056,9 +13193,14 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13056
13193
|
}
|
|
13057
13194
|
];
|
|
13058
13195
|
let onServiceInitedScript = `
|
|
13059
|
-
|
|
13196
|
+
var parent = event.data.parent;
|
|
13197
|
+
var fieldValue = event.data.__tableItems;
|
|
13198
|
+
if(parent){
|
|
13060
13199
|
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13061
|
-
|
|
13200
|
+
var primaryKey = "${props.primaryKey}";
|
|
13201
|
+
event.data.__parentIndex = _.findIndex(fieldValue, function(item){
|
|
13202
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13203
|
+
});
|
|
13062
13204
|
}
|
|
13063
13205
|
// 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
13064
13206
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
@@ -13170,6 +13312,11 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13170
13312
|
var __parentIndex = event.data.__super.__super.__parentIndex;
|
|
13171
13313
|
if(parent){
|
|
13172
13314
|
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13315
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13316
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13317
|
+
children: fieldValue[__parentIndex].children,
|
|
13318
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13319
|
+
});
|
|
13173
13320
|
}
|
|
13174
13321
|
else{
|
|
13175
13322
|
fieldValue[currentIndex] = currentFormValues;
|
|
@@ -13314,9 +13461,13 @@ async function getButtonActions(props, mode) {
|
|
|
13314
13461
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13315
13462
|
// 新建一条空白行并保存到子表组件
|
|
13316
13463
|
var parent = event.data.__super.parent;
|
|
13317
|
-
var
|
|
13464
|
+
var primaryKey = "${props.primaryKey}";
|
|
13465
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13466
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13467
|
+
});
|
|
13318
13468
|
if(parent){
|
|
13319
13469
|
fieldValue[__parentIndex].children.push({});
|
|
13470
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13320
13471
|
}
|
|
13321
13472
|
else{
|
|
13322
13473
|
fieldValue.push({});
|
|
@@ -13351,9 +13502,13 @@ async function getButtonActions(props, mode) {
|
|
|
13351
13502
|
// 复制当前页数据到新建行并保存到子表组件
|
|
13352
13503
|
// fieldValue.push(newItem);
|
|
13353
13504
|
var parent = event.data.__super.parent;
|
|
13354
|
-
var
|
|
13505
|
+
var primaryKey = "${props.primaryKey}";
|
|
13506
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13507
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13508
|
+
});
|
|
13355
13509
|
if(parent){
|
|
13356
13510
|
fieldValue[__parentIndex].children.push(newItem);
|
|
13511
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13357
13512
|
}
|
|
13358
13513
|
else{
|
|
13359
13514
|
fieldValue.push(newItem);
|
|
@@ -13369,7 +13524,6 @@ async function getButtonActions(props, mode) {
|
|
|
13369
13524
|
let __paginationServiceId = "${formPaginationId}";
|
|
13370
13525
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13371
13526
|
event.data.index = __paginationData.index;
|
|
13372
|
-
// event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13373
13527
|
if(parent){
|
|
13374
13528
|
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13375
13529
|
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
@@ -13458,8 +13612,9 @@ async function getButtonActions(props, mode) {
|
|
|
13458
13612
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13459
13613
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13460
13614
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13461
|
-
//
|
|
13462
|
-
|
|
13615
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
13616
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
13617
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13463
13618
|
},
|
|
13464
13619
|
"actions": dialogButtons,
|
|
13465
13620
|
"onEvent": {
|
|
@@ -13577,9 +13732,17 @@ async function getButtonActions(props, mode) {
|
|
|
13577
13732
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13578
13733
|
var currentIndex = event.data.index;
|
|
13579
13734
|
var parent = event.data.__super.parent;
|
|
13580
|
-
var
|
|
13735
|
+
var primaryKey = "${props.primaryKey}";
|
|
13736
|
+
var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
|
|
13737
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13738
|
+
});
|
|
13581
13739
|
if(parent){
|
|
13582
13740
|
lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
|
|
13741
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13742
|
+
lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
|
|
13743
|
+
children: lastestFieldValue[__parentIndex].children,
|
|
13744
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13745
|
+
});
|
|
13583
13746
|
}
|
|
13584
13747
|
else{
|
|
13585
13748
|
lastestFieldValue.splice(currentIndex, 1);
|
|
@@ -13669,39 +13832,48 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13669
13832
|
if (!props.id) {
|
|
13670
13833
|
props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
|
|
13671
13834
|
}
|
|
13835
|
+
if (!props.primaryKey) {
|
|
13836
|
+
props.primaryKey = "_id";
|
|
13837
|
+
}
|
|
13838
|
+
let showOperation = props.showOperation;
|
|
13839
|
+
if(showOperation !== false){
|
|
13840
|
+
showOperation = true;
|
|
13841
|
+
}
|
|
13672
13842
|
let serviceId = getComponentId("table_service", props.id);
|
|
13673
13843
|
let buttonsForColumnOperations = [];
|
|
13674
13844
|
let inlineEditMode = props.inlineEditMode;
|
|
13675
13845
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
13676
|
-
if
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13846
|
+
if(showOperation){
|
|
13847
|
+
if (props.editable) {
|
|
13848
|
+
let showEditButton = true;
|
|
13849
|
+
if (showAsInlineEditMode) {
|
|
13850
|
+
// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
13851
|
+
showEditButton = true;
|
|
13852
|
+
// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
13853
|
+
// if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
|
|
13854
|
+
// showEditButton = true;
|
|
13855
|
+
// }
|
|
13856
|
+
// else {
|
|
13857
|
+
// showEditButton = false;
|
|
13858
|
+
// }
|
|
13859
|
+
}
|
|
13860
|
+
// 编辑时显示编辑按钮
|
|
13861
|
+
if (showEditButton) {
|
|
13862
|
+
let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
|
|
13863
|
+
buttonsForColumnOperations.push(buttonEditSchema);
|
|
13864
|
+
}
|
|
13865
|
+
}
|
|
13866
|
+
else {
|
|
13867
|
+
// 只读时显示查看按钮
|
|
13868
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13869
|
+
let buttonViewSchema = await getButtonView(props);
|
|
13870
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13688
13871
|
}
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
buttonsForColumnOperations.push(buttonEditSchema);
|
|
13872
|
+
if (props.removable) {
|
|
13873
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13874
|
+
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13693
13875
|
}
|
|
13694
13876
|
}
|
|
13695
|
-
else {
|
|
13696
|
-
// 只读时显示查看按钮
|
|
13697
|
-
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13698
|
-
let buttonViewSchema = await getButtonView(props);
|
|
13699
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13700
|
-
}
|
|
13701
|
-
if (props.removable) {
|
|
13702
|
-
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13703
|
-
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13704
|
-
}
|
|
13705
13877
|
let inputTableSchema = {
|
|
13706
13878
|
"type": "input-table",
|
|
13707
13879
|
"label": props.label,
|
|
@@ -13719,7 +13891,13 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13719
13891
|
"strictMode": props.strictMode,
|
|
13720
13892
|
"showTableAddBtn": false,
|
|
13721
13893
|
"showFooterAddBtn": false,
|
|
13722
|
-
"className": props.tableClassName
|
|
13894
|
+
"className": props.tableClassName,
|
|
13895
|
+
"pipeOut": (value, data) => {
|
|
13896
|
+
return (value || []).map(function(item){
|
|
13897
|
+
delete item.__fix_rerender_after_children_modified_tag;
|
|
13898
|
+
return item;
|
|
13899
|
+
});
|
|
13900
|
+
}
|
|
13723
13901
|
};
|
|
13724
13902
|
if (buttonsForColumnOperations.length) {
|
|
13725
13903
|
inputTableSchema.columns.push({
|
|
@@ -13742,7 +13920,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13742
13920
|
return item.depend_on;
|
|
13743
13921
|
});
|
|
13744
13922
|
if (isAnyFieldHasDependOn) {
|
|
13745
|
-
// 有任意一个子字段有depend_on
|
|
13923
|
+
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
|
|
13746
13924
|
Object.assign(inputTableSchema, {
|
|
13747
13925
|
strictMode: false
|
|
13748
13926
|
});
|
|
@@ -13847,7 +14025,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
|
|
|
13847
14025
|
// 获取
|
|
13848
14026
|
async function getRecordPageInitSchema(objectApiName){
|
|
13849
14027
|
const relatedList = await getObjectRelatedList(objectApiName);
|
|
13850
|
-
|
|
14028
|
+
await getUISchema(objectApiName);
|
|
13851
14029
|
let body = [
|
|
13852
14030
|
// detailHeaderAmisSchema,
|
|
13853
14031
|
{
|
|
@@ -13855,28 +14033,7 @@ async function getRecordPageInitSchema(objectApiName){
|
|
|
13855
14033
|
"label": "标题面板",
|
|
13856
14034
|
"objectApiName": "${objectName}",
|
|
13857
14035
|
"recordId": "${recordId}",
|
|
13858
|
-
"onEvent": {
|
|
13859
|
-
"recordLoaded": {
|
|
13860
|
-
"actions": [
|
|
13861
|
-
{
|
|
13862
|
-
"actionType": "setValue",
|
|
13863
|
-
"args": {
|
|
13864
|
-
"value": {
|
|
13865
|
-
"recordLoaded": true,
|
|
13866
|
-
}
|
|
13867
|
-
}
|
|
13868
|
-
},
|
|
13869
|
-
{
|
|
13870
|
-
"actionType": "reload",
|
|
13871
|
-
"data": {
|
|
13872
|
-
"name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
13873
|
-
"record": `\${record}`,
|
|
13874
|
-
"recordLoaded": true,
|
|
13875
|
-
}
|
|
13876
|
-
}
|
|
13877
|
-
]
|
|
13878
|
-
}
|
|
13879
|
-
}
|
|
14036
|
+
"onEvent": {}
|
|
13880
14037
|
}
|
|
13881
14038
|
];
|
|
13882
14039
|
let contentBody = {
|
|
@@ -16511,9 +16668,11 @@ exports.getObjectRelated = getObjectRelated;
|
|
|
16511
16668
|
exports.getObjectRelatedList = getObjectRelatedList;
|
|
16512
16669
|
exports.getObjectRelatedListButtons = getObjectRelatedListButtons;
|
|
16513
16670
|
exports.getObjectRelatedListHeader = getObjectRelatedListHeader;
|
|
16671
|
+
exports.getObjectRelatedListsMiniSchema = getObjectRelatedListsMiniSchema;
|
|
16514
16672
|
exports.getPage = getPage;
|
|
16515
16673
|
exports.getRecord = getRecord;
|
|
16516
16674
|
exports.getRecordDetailHeaderSchema = getRecordDetailHeaderSchema;
|
|
16675
|
+
exports.getRecordDetailMiniSchema = getRecordDetailMiniSchema;
|
|
16517
16676
|
exports.getRecordDetailRelatedListSchema = getRecordDetailRelatedListSchema;
|
|
16518
16677
|
exports.getRecordDetailSchema = getRecordDetailSchema;
|
|
16519
16678
|
exports.getRecordPageInitSchema = getRecordPageInitSchema;
|