@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.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$1 from 'lodash';
|
|
2
|
-
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, clone, filter, startsWith } from 'lodash';
|
|
2
|
+
import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, has, slice, defaultsDeep as defaultsDeep$1, reverse, isObject as isObject$1, clone, filter, startsWith } from 'lodash';
|
|
3
3
|
import i18next from 'i18next';
|
|
4
4
|
export { default as i18next } from 'i18next';
|
|
5
5
|
import { initReactI18next } from 'react-i18next';
|
|
@@ -1403,9 +1403,9 @@ var frontend_display_type_is_split = "分栏视图";
|
|
|
1403
1403
|
var frontend_display_as = "显示为";
|
|
1404
1404
|
var frontend_record_sum = "个项目";
|
|
1405
1405
|
var frontend_button_reload_tooltip = "刷新";
|
|
1406
|
-
var frontend_button_search_tooltip = "
|
|
1406
|
+
var frontend_button_search_tooltip = "搜索";
|
|
1407
1407
|
var frontend_fields_filter_button_search = "搜索";
|
|
1408
|
-
var frontend_fields_filter_button_settings = "
|
|
1408
|
+
var frontend_fields_filter_button_settings = "选择搜索项";
|
|
1409
1409
|
var frontend_button_listview_control_tooltip = "列表视图控制";
|
|
1410
1410
|
var frontend_button_listview_control_label = "列表视图控制";
|
|
1411
1411
|
var frontend_listview_control_columns = "显示的列";
|
|
@@ -2062,7 +2062,7 @@ async function getTableColumns(fields, options){
|
|
|
2062
2062
|
if(field.wrap != true){
|
|
2063
2063
|
className += " whitespace-nowrap ";
|
|
2064
2064
|
}else {
|
|
2065
|
-
className += " break-
|
|
2065
|
+
className += " break-words ";
|
|
2066
2066
|
}
|
|
2067
2067
|
let columnItem;
|
|
2068
2068
|
if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
|
|
@@ -2498,7 +2498,8 @@ async function getTableOperation(ctx){
|
|
|
2498
2498
|
label: " ",
|
|
2499
2499
|
fixed: 'right',
|
|
2500
2500
|
labelClassName: 'text-center',
|
|
2501
|
-
|
|
2501
|
+
//TODO:目前3.6.3-patch.3版本中对于动态classname处理存在问题,简单处理固定列问题,等待amis解决crud的columns不支持动态classname的问题
|
|
2502
|
+
className: 'text-center steedos-listview-operation w-10 is-sticky is-sticky-right is-sticky-first-right',
|
|
2502
2503
|
buttons: [
|
|
2503
2504
|
{
|
|
2504
2505
|
"type": "steedos-dropdown-button",
|
|
@@ -2594,7 +2595,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2594
2595
|
}
|
|
2595
2596
|
return {
|
|
2596
2597
|
mode: "cards",
|
|
2597
|
-
perPageAvailable: [
|
|
2598
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2598
2599
|
name: "thelist",
|
|
2599
2600
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2600
2601
|
className: "",
|
|
@@ -2627,7 +2628,7 @@ async function getTableSchema$1(fields, options){
|
|
|
2627
2628
|
|
|
2628
2629
|
return {
|
|
2629
2630
|
mode: "table",
|
|
2630
|
-
perPageAvailable: [
|
|
2631
|
+
perPageAvailable: [20, 50, 100, 500],
|
|
2631
2632
|
name: "thelist",
|
|
2632
2633
|
headerToolbarClassName: "py-2 px-2 border-gray-300 border-solid border-b",
|
|
2633
2634
|
className: "",
|
|
@@ -3131,12 +3132,21 @@ function getReadonlyFormAdaptor(object, fields, options){
|
|
|
3131
3132
|
}
|
|
3132
3133
|
payload.data = data;
|
|
3133
3134
|
payload.data.__objectName = "${object.name}";
|
|
3134
|
-
payload.data.
|
|
3135
|
+
payload.data.record = record;
|
|
3136
|
+
|
|
3137
|
+
payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
|
|
3138
|
+
payload.data._master = {
|
|
3139
|
+
record: record,
|
|
3140
|
+
objectName: "${object.name}",
|
|
3141
|
+
recordId: record._id
|
|
3142
|
+
}
|
|
3135
3143
|
window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
|
|
3136
3144
|
}
|
|
3137
3145
|
if(payload.errors){
|
|
3138
3146
|
payload.status = 2;
|
|
3139
3147
|
payload.msg = payload.errors[0].message;
|
|
3148
|
+
}else{
|
|
3149
|
+
payload.data.recordLoaded = true;
|
|
3140
3150
|
}
|
|
3141
3151
|
${options && options.initApiAdaptor || ''}
|
|
3142
3152
|
return payload;
|
|
@@ -3279,7 +3289,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3279
3289
|
cache: API_CACHE,
|
|
3280
3290
|
requestAdaptor: `
|
|
3281
3291
|
// 所有不想在network请求中发送的数据都应该从data中分离出来,data变量只需要留下query才需要发送出去
|
|
3282
|
-
var { recordId, objectName, uiSchema, global, context, ...data} = api.data;
|
|
3292
|
+
var { recordId, objectName, uiSchema, global, context, _master, ...data} = api.data;
|
|
3283
3293
|
if(!recordId){
|
|
3284
3294
|
// 新建则不请求任何数据
|
|
3285
3295
|
data.query = "{data:" + objectName + "(filters: " + JSON.stringify(["_id", "=", null]) + ", top: 1){_id}}";
|
|
@@ -3354,15 +3364,17 @@ async function getEditFormInitApi(object, recordId, fields, options){
|
|
|
3354
3364
|
}
|
|
3355
3365
|
// data下的变量需要在保存接口(getSaveApi)中被删除。
|
|
3356
3366
|
payload.data = {
|
|
3357
|
-
...initialValues
|
|
3367
|
+
...initialValues,
|
|
3368
|
+
editFormInited: true
|
|
3358
3369
|
}
|
|
3359
3370
|
${options.initApiAdaptor || ''}
|
|
3371
|
+
// console.log('getEditFormInitApi======>', payload);
|
|
3360
3372
|
return payload;
|
|
3361
3373
|
`,
|
|
3362
|
-
responseData: {
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
},
|
|
3374
|
+
// responseData: {
|
|
3375
|
+
// initialValues: "$$",
|
|
3376
|
+
// editFormInited: true
|
|
3377
|
+
// },
|
|
3366
3378
|
data: data,
|
|
3367
3379
|
headers: {
|
|
3368
3380
|
Authorization: "Bearer ${context.tenantId},${context.authToken}"
|
|
@@ -5113,7 +5125,7 @@ const StandardButtons = {
|
|
|
5113
5125
|
}
|
|
5114
5126
|
};
|
|
5115
5127
|
|
|
5116
|
-
const getGlobalData
|
|
5128
|
+
const getGlobalData = () => {
|
|
5117
5129
|
return {
|
|
5118
5130
|
now: new Date(),
|
|
5119
5131
|
};
|
|
@@ -5172,7 +5184,7 @@ const getButtonVisible = (button, ctx) => {
|
|
|
5172
5184
|
button._visible,
|
|
5173
5185
|
props.record,
|
|
5174
5186
|
"#",
|
|
5175
|
-
getGlobalData
|
|
5187
|
+
getGlobalData(),
|
|
5176
5188
|
props.userSession
|
|
5177
5189
|
);
|
|
5178
5190
|
};
|
|
@@ -6550,6 +6562,48 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6550
6562
|
return headerSchema;
|
|
6551
6563
|
}
|
|
6552
6564
|
|
|
6565
|
+
function getBackButtonSchema(){
|
|
6566
|
+
return {
|
|
6567
|
+
"type": "service",
|
|
6568
|
+
"onEvent": {
|
|
6569
|
+
"@history_paths.changed": {
|
|
6570
|
+
"actions": [
|
|
6571
|
+
{
|
|
6572
|
+
"actionType": "reload",
|
|
6573
|
+
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6574
|
+
"data": {
|
|
6575
|
+
}
|
|
6576
|
+
}
|
|
6577
|
+
]
|
|
6578
|
+
}
|
|
6579
|
+
},
|
|
6580
|
+
"body":[{
|
|
6581
|
+
"type": "button",
|
|
6582
|
+
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6583
|
+
"className":"flex mr-4",
|
|
6584
|
+
"onEvent": {
|
|
6585
|
+
"click": {
|
|
6586
|
+
"actions": [
|
|
6587
|
+
{
|
|
6588
|
+
"actionType": "custom",
|
|
6589
|
+
"script": "window.goBack()"
|
|
6590
|
+
}
|
|
6591
|
+
]
|
|
6592
|
+
}
|
|
6593
|
+
},
|
|
6594
|
+
"body": [
|
|
6595
|
+
{
|
|
6596
|
+
"type": "steedos-icon",
|
|
6597
|
+
"category": "utility",
|
|
6598
|
+
"name": "back",
|
|
6599
|
+
"colorVariant": "default",
|
|
6600
|
+
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6601
|
+
}
|
|
6602
|
+
]
|
|
6603
|
+
}]
|
|
6604
|
+
}
|
|
6605
|
+
}
|
|
6606
|
+
|
|
6553
6607
|
/**
|
|
6554
6608
|
* 记录详细界面顶部头amisSchema,也是标题面板组件的amisSchema
|
|
6555
6609
|
* @param {*} objectSchema 对象UISchema
|
|
@@ -6558,11 +6612,21 @@ function getObjectListHeader$1(objectSchema, listViewName, ctx) {
|
|
|
6558
6612
|
* @returns amisSchema
|
|
6559
6613
|
*/
|
|
6560
6614
|
async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
6615
|
+
// console.log(`getObjectRecordDetailHeader====>`, options)
|
|
6561
6616
|
const { showRecordTitle = true } = options || {};
|
|
6562
6617
|
// console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
|
|
6563
6618
|
const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
|
|
6564
6619
|
|
|
6565
|
-
let amisButtonsSchema =
|
|
6620
|
+
let amisButtonsSchema = [];
|
|
6621
|
+
if(options.showButtons != false){
|
|
6622
|
+
amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
|
|
6623
|
+
}
|
|
6624
|
+
|
|
6625
|
+
let backButtonsSchema = null;
|
|
6626
|
+
|
|
6627
|
+
if(options.showBackButton != false){
|
|
6628
|
+
backButtonsSchema = getBackButtonSchema();
|
|
6629
|
+
}
|
|
6566
6630
|
|
|
6567
6631
|
// console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
|
|
6568
6632
|
|
|
@@ -6577,45 +6641,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6577
6641
|
"type": "grid",
|
|
6578
6642
|
"columns": [
|
|
6579
6643
|
{
|
|
6580
|
-
"body": [
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
"@history_paths.changed": {
|
|
6584
|
-
"actions": [
|
|
6585
|
-
{
|
|
6586
|
-
"actionType": "reload",
|
|
6587
|
-
// amis 3.6需要传入data来触发下面的window:historyPaths重新计算,此问题随机偶发,加上data后正常
|
|
6588
|
-
"data": {
|
|
6589
|
-
}
|
|
6590
|
-
}
|
|
6591
|
-
]
|
|
6592
|
-
}
|
|
6593
|
-
},
|
|
6594
|
-
"body":[{
|
|
6595
|
-
"type": "button",
|
|
6596
|
-
"visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
|
|
6597
|
-
"className":"flex mr-4",
|
|
6598
|
-
"onEvent": {
|
|
6599
|
-
"click": {
|
|
6600
|
-
"actions": [
|
|
6601
|
-
{
|
|
6602
|
-
"actionType": "custom",
|
|
6603
|
-
"script": "window.goBack()"
|
|
6604
|
-
}
|
|
6605
|
-
]
|
|
6606
|
-
}
|
|
6607
|
-
},
|
|
6608
|
-
"body": [
|
|
6609
|
-
{
|
|
6610
|
-
"type": "steedos-icon",
|
|
6611
|
-
"category": "utility",
|
|
6612
|
-
"name": "back",
|
|
6613
|
-
"colorVariant": "default",
|
|
6614
|
-
"className": "slds-button_icon slds-global-header__icon w-4"
|
|
6615
|
-
}
|
|
6616
|
-
]
|
|
6617
|
-
}]
|
|
6618
|
-
},{
|
|
6644
|
+
"body": [
|
|
6645
|
+
backButtonsSchema
|
|
6646
|
+
,{
|
|
6619
6647
|
"type": "tpl",
|
|
6620
6648
|
"className": "block",
|
|
6621
6649
|
// "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'>`
|
|
@@ -6636,8 +6664,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6636
6664
|
},
|
|
6637
6665
|
{
|
|
6638
6666
|
"type": "tpl",
|
|
6639
|
-
"tpl": "${
|
|
6640
|
-
// "tpl": "${(record && uiSchema && record[uiSchema.NAME_FIELD_KEY]) || name}",
|
|
6667
|
+
"tpl": "${NAME_FIELD_VALUE}",
|
|
6641
6668
|
"inline": false,
|
|
6642
6669
|
"wrapperComponent": "",
|
|
6643
6670
|
"className": "record-detail-header-name leading-5 text-xl font-bold"
|
|
@@ -6665,7 +6692,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6665
6692
|
let body = [
|
|
6666
6693
|
{
|
|
6667
6694
|
"type": "wrapper",
|
|
6668
|
-
"className": "p-
|
|
6695
|
+
"className": "p-4",
|
|
6669
6696
|
"body": [
|
|
6670
6697
|
{
|
|
6671
6698
|
"type": "grid",
|
|
@@ -6680,7 +6707,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6680
6707
|
if(showRecordTitle){
|
|
6681
6708
|
body.push({
|
|
6682
6709
|
"type": "wrapper",
|
|
6683
|
-
"className": "p-
|
|
6710
|
+
"className": "p-4",
|
|
6684
6711
|
"body": [
|
|
6685
6712
|
{
|
|
6686
6713
|
"type": "grid",
|
|
@@ -6692,11 +6719,38 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
|
|
|
6692
6719
|
});
|
|
6693
6720
|
}
|
|
6694
6721
|
|
|
6722
|
+
let max = 10;
|
|
6723
|
+
if(options.formFactor === 'SMALL'){
|
|
6724
|
+
max = 4;
|
|
6725
|
+
}
|
|
6726
|
+
|
|
6727
|
+
if(objectSchema.compactLayouts){
|
|
6728
|
+
const details = [];
|
|
6729
|
+
_.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
|
|
6730
|
+
const field = objectSchema.fields[fieldName];
|
|
6731
|
+
if(field){
|
|
6732
|
+
details.push({
|
|
6733
|
+
type: 'steedos-field',
|
|
6734
|
+
static: true,
|
|
6735
|
+
config: field,
|
|
6736
|
+
});
|
|
6737
|
+
}
|
|
6738
|
+
});
|
|
6739
|
+
|
|
6740
|
+
body.push({
|
|
6741
|
+
"type": "form",
|
|
6742
|
+
"className": "p-4 pb-0 bg-white compact-layouts",
|
|
6743
|
+
"wrapWithPanel": false,
|
|
6744
|
+
"actions": [],
|
|
6745
|
+
"body": details,
|
|
6746
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
6747
|
+
});
|
|
6748
|
+
}
|
|
6749
|
+
|
|
6695
6750
|
return {
|
|
6696
6751
|
type: 'service',
|
|
6697
6752
|
id: `page_readonly_${name}_header`,
|
|
6698
6753
|
name: `page`,
|
|
6699
|
-
data: { objectName: name, _id: recordId, recordPermissions: objectSchema.permissions, uiSchema: objectSchema, record: "${record}" },
|
|
6700
6754
|
body: body,
|
|
6701
6755
|
className: ''
|
|
6702
6756
|
}
|
|
@@ -7903,7 +7957,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
|
|
|
7903
7957
|
{
|
|
7904
7958
|
"type": "search-box",
|
|
7905
7959
|
"name": keywordsSearchBoxName,
|
|
7906
|
-
"placeholder": "
|
|
7960
|
+
"placeholder": "快捷搜索",
|
|
7907
7961
|
"value": crudKeywords,
|
|
7908
7962
|
// "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
|
|
7909
7963
|
"clearAndSubmit": true,
|
|
@@ -8504,7 +8558,9 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8504
8558
|
return payload;
|
|
8505
8559
|
`
|
|
8506
8560
|
},
|
|
8507
|
-
rowClassNameExpr
|
|
8561
|
+
// 外层data发生变化的时候, 不会重新渲染rowClassNameExpr, 所以先用css标记tr唯一标识
|
|
8562
|
+
// 使用表达式给tr添加初始选中状态
|
|
8563
|
+
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 %>"
|
|
8508
8564
|
}, bodyProps);
|
|
8509
8565
|
|
|
8510
8566
|
}
|
|
@@ -8519,7 +8575,7 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8519
8575
|
|
|
8520
8576
|
if(body.columns && options.formFactor != 'SMALL'){
|
|
8521
8577
|
//将_display放入crud的columns的倒数第二列中(最后一列会影响固定列),可以通过setvalue修改行内数据域的_display,而不影响上层items的_display,用于批量编辑
|
|
8522
|
-
body.columns.splice(body.columns.length -
|
|
8578
|
+
body.columns.splice(body.columns.length -1 , 0, {name: '_display',type: 'static', width: 1, placeholder: "",id: objectSchema.name + "_display_${_index}", tpl: "${''}"});
|
|
8523
8579
|
}
|
|
8524
8580
|
|
|
8525
8581
|
if (defaults) {
|
|
@@ -8577,11 +8633,6 @@ async function getObjectCRUD(objectSchema, fields, options){
|
|
|
8577
8633
|
}
|
|
8578
8634
|
}
|
|
8579
8635
|
|
|
8580
|
-
const getGlobalData = (mode)=>{
|
|
8581
|
-
const user = getSteedosAuth();
|
|
8582
|
-
return {mode: mode, user: user, spaceId: user.spaceId, userId: user.userId}
|
|
8583
|
-
};
|
|
8584
|
-
|
|
8585
8636
|
const getFormFields$1 = (objectSchema, formProps)=>{
|
|
8586
8637
|
/**
|
|
8587
8638
|
* fieldsExtend: 重写字段定义
|
|
@@ -8659,9 +8710,7 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8659
8710
|
id: `service_${formSchema.id}`,
|
|
8660
8711
|
className: 'p-0',
|
|
8661
8712
|
name: `page_edit_${recordId}`,
|
|
8662
|
-
api: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8663
8713
|
data:{
|
|
8664
|
-
editFormInited: false,
|
|
8665
8714
|
...amisData
|
|
8666
8715
|
},
|
|
8667
8716
|
// data: {global: getGlobalData('edit'), recordId: recordId, objectName: objectSchema.name, context: {rootUrl: getRootUrl(), tenantId: getTenantId(), authToken: getAuthToken()}},
|
|
@@ -8670,8 +8719,9 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8670
8719
|
body: [defaultsDeep({}, formSchema, {
|
|
8671
8720
|
type: "form",
|
|
8672
8721
|
mode: layout,
|
|
8722
|
+
initApi: await getEditFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8673
8723
|
data: {
|
|
8674
|
-
|
|
8724
|
+
editFormInited: false,
|
|
8675
8725
|
},
|
|
8676
8726
|
labelAlign,
|
|
8677
8727
|
persistData: false,
|
|
@@ -8685,11 +8735,15 @@ async function getObjectForm(objectSchema, ctx){
|
|
|
8685
8735
|
submitText: "", // amis 表单不显示提交按钮, 表单提交由项目代码接管
|
|
8686
8736
|
api: await getSaveApi(objectSchema, recordId, fields, ctx),
|
|
8687
8737
|
initFetch: recordId != 'new',
|
|
8688
|
-
body:
|
|
8738
|
+
body: {
|
|
8739
|
+
type: 'wrapper',
|
|
8740
|
+
className: 'p-0 m-0',
|
|
8741
|
+
body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
|
|
8742
|
+
hiddenOn: "${editFormInited != true}",
|
|
8743
|
+
},
|
|
8689
8744
|
panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
|
|
8690
8745
|
bodyClassName: 'p-0',
|
|
8691
8746
|
className: 'steedos-amis-form',
|
|
8692
|
-
hiddenOn: "${editFormInited != true}",
|
|
8693
8747
|
onEvent: {
|
|
8694
8748
|
"submitSucc": {
|
|
8695
8749
|
"weight": 0,
|
|
@@ -8743,8 +8797,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8743
8797
|
type: 'service',
|
|
8744
8798
|
name: `page_readonly_${recordId}`,
|
|
8745
8799
|
id: serviceId,
|
|
8746
|
-
|
|
8747
|
-
api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8800
|
+
// api: await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx),
|
|
8748
8801
|
body: [
|
|
8749
8802
|
{
|
|
8750
8803
|
"type": "wrapper", //form 的 hiddenOn 会导致 form onEvent 异常, 使用wrapper包裹一次form,并在wrapper上控制显隐
|
|
@@ -8770,60 +8823,41 @@ async function getObjectDetail(objectSchema, recordId, ctx){
|
|
|
8770
8823
|
),
|
|
8771
8824
|
className: 'steedos-amis-form bg-white',
|
|
8772
8825
|
actions: [], // 不显示表单默认的提交按钮
|
|
8773
|
-
onEvent: {
|
|
8774
|
-
[`@data.changed.${objectSchema.name}`]: { // 由于amis service 组件的 onEvent 存在bug ,此处借助form来刷新 上层 service https://github.com/baidu/amis/issues/6294
|
|
8775
|
-
"actions": [
|
|
8776
|
-
{
|
|
8777
|
-
"actionType": "reload",
|
|
8778
|
-
"componentId": serviceId,
|
|
8779
|
-
"expression": "this.__deletedRecord != true"
|
|
8780
|
-
},
|
|
8781
|
-
{
|
|
8782
|
-
// "args": {
|
|
8783
|
-
// "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
|
|
8784
|
-
// "blank": false
|
|
8785
|
-
// },
|
|
8786
|
-
"actionType": "custom",
|
|
8787
|
-
"script": "window.goBack()",
|
|
8788
|
-
"expression": "this.__deletedRecord === true"
|
|
8789
|
-
}
|
|
8790
|
-
]
|
|
8791
|
-
}
|
|
8792
|
-
}
|
|
8793
8826
|
},
|
|
8794
8827
|
}
|
|
8795
8828
|
],
|
|
8796
|
-
onEvent: {
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
}
|
|
8829
|
+
// onEvent: {
|
|
8830
|
+
// "fetchInited": {
|
|
8831
|
+
// "weight": 0,
|
|
8832
|
+
// "actions": [
|
|
8833
|
+
// {
|
|
8834
|
+
// actionType: 'broadcast',
|
|
8835
|
+
// eventName: "recordLoaded",
|
|
8836
|
+
// args: {
|
|
8837
|
+
// eventName: "recordLoaded"
|
|
8838
|
+
// },
|
|
8839
|
+
// data: {
|
|
8840
|
+
// objectName: "${event.data.__objectName}",
|
|
8841
|
+
// record: "${event.data.__record}"
|
|
8842
|
+
// },
|
|
8843
|
+
// expression: "${event.data.__response.error != true}"
|
|
8844
|
+
// },
|
|
8845
|
+
// {
|
|
8846
|
+
// "actionType": "setValue",
|
|
8847
|
+
// "args": {
|
|
8848
|
+
// value: {
|
|
8849
|
+
// "recordLoaded": true,
|
|
8850
|
+
// }
|
|
8851
|
+
// },
|
|
8852
|
+
// expression: "${event.data.__response.error != true}"
|
|
8853
|
+
// }
|
|
8854
|
+
// ]
|
|
8855
|
+
// }
|
|
8856
|
+
// }
|
|
8824
8857
|
};
|
|
8825
8858
|
|
|
8826
8859
|
amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
|
|
8860
|
+
// console.log('getObjectDetail=====>', amisSchema);
|
|
8827
8861
|
return amisSchema;
|
|
8828
8862
|
}
|
|
8829
8863
|
|
|
@@ -8903,8 +8937,8 @@ const getRecordPermissions = async (objectName, recordId)=>{
|
|
|
8903
8937
|
/*
|
|
8904
8938
|
* @Author: baozhoutao@steedos.com
|
|
8905
8939
|
* @Date: 2022-07-05 15:55:39
|
|
8906
|
-
* @LastEditors:
|
|
8907
|
-
* @LastEditTime:
|
|
8940
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
8941
|
+
* @LastEditTime: 2024-01-15 10:34:46
|
|
8908
8942
|
* @Description:
|
|
8909
8943
|
*/
|
|
8910
8944
|
|
|
@@ -9284,11 +9318,44 @@ async function getRelatedListSchema(
|
|
|
9284
9318
|
};
|
|
9285
9319
|
}
|
|
9286
9320
|
|
|
9321
|
+
async function getObjectRelatedListsMiniSchema(objectApiName){
|
|
9322
|
+
const relatedLists = await getObjectRelatedList(objectApiName);
|
|
9323
|
+
|
|
9324
|
+
const relatedListsMiniSchema = [];
|
|
9325
|
+
|
|
9326
|
+
for (const relatedList of relatedLists) {
|
|
9327
|
+
relatedListsMiniSchema.push(
|
|
9328
|
+
{
|
|
9329
|
+
type: 'steedos-record-detail-list-mini',
|
|
9330
|
+
objectApiName: objectApiName,
|
|
9331
|
+
// recordId: recordId,
|
|
9332
|
+
formFactor: formFactor,
|
|
9333
|
+
relatedObjectApiName: relatedList.object_name,
|
|
9334
|
+
foreign_key: relatedList.foreign_key,
|
|
9335
|
+
relatedKey: relatedList.foreign_key,
|
|
9336
|
+
columns: relatedList.columns,
|
|
9337
|
+
sort: relatedList.sort,
|
|
9338
|
+
filters: relatedList.filters,
|
|
9339
|
+
visible_on: relatedList.visible_on,
|
|
9340
|
+
perPage: relatedList.page_size || perPage,
|
|
9341
|
+
hiddenEmptyTable: true,
|
|
9342
|
+
relatedLabel: relatedList.label
|
|
9343
|
+
}
|
|
9344
|
+
);
|
|
9345
|
+
}
|
|
9346
|
+
|
|
9347
|
+
return {
|
|
9348
|
+
type: 'wrapper',
|
|
9349
|
+
className: "steedos-record-detail-related-lists-mini",
|
|
9350
|
+
body: relatedListsMiniSchema
|
|
9351
|
+
}
|
|
9352
|
+
}
|
|
9353
|
+
|
|
9287
9354
|
/*
|
|
9288
9355
|
* @Author: baozhoutao@steedos.com
|
|
9289
9356
|
* @Date: 2022-07-05 15:55:39
|
|
9290
|
-
* @LastEditors:
|
|
9291
|
-
* @LastEditTime:
|
|
9357
|
+
* @LastEditors: baozhoutao@steedos.com
|
|
9358
|
+
* @LastEditTime: 2024-01-16 11:14:34
|
|
9292
9359
|
* @Description:
|
|
9293
9360
|
*/
|
|
9294
9361
|
|
|
@@ -9460,7 +9527,7 @@ async function getField(objectName, fieldName) {
|
|
|
9460
9527
|
async function getFormSchema(objectName, ctx) {
|
|
9461
9528
|
const uiSchema = await getUISchema(objectName);
|
|
9462
9529
|
const amisSchema = await getObjectForm(uiSchema, ctx);
|
|
9463
|
-
console.log(`getFormSchema====>`, amisSchema)
|
|
9530
|
+
// console.log(`getFormSchema====>`, amisSchema)
|
|
9464
9531
|
return {
|
|
9465
9532
|
uiSchema,
|
|
9466
9533
|
amisSchema,
|
|
@@ -9818,78 +9885,136 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
|
|
|
9818
9885
|
if(relatedLists.length){
|
|
9819
9886
|
content.tabs.push(related);
|
|
9820
9887
|
}
|
|
9888
|
+
content.tabs = reverse(content.tabs);
|
|
9821
9889
|
return {
|
|
9822
9890
|
uiSchema,
|
|
9823
9891
|
amisSchema: {
|
|
9824
|
-
"type": "service",
|
|
9892
|
+
"type": "steedos-record-service",
|
|
9825
9893
|
"body": [
|
|
9826
9894
|
{
|
|
9827
9895
|
"type": "steedos-record-detail-header",
|
|
9828
9896
|
"label": "标题面板",
|
|
9829
9897
|
"objectApiName": "${objectName}",
|
|
9830
9898
|
"recordId": "${recordId}",
|
|
9831
|
-
"id": "u:48d2c28eb755"
|
|
9899
|
+
"id": "u:48d2c28eb755",
|
|
9900
|
+
"showButtons": props.showButtons,
|
|
9901
|
+
"showBackButton": props.showBackButton,
|
|
9832
9902
|
},
|
|
9833
9903
|
content
|
|
9834
9904
|
],
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
},
|
|
9839
|
-
onEvent: {
|
|
9840
|
-
"recordLoaded": {
|
|
9841
|
-
"actions": [
|
|
9842
|
-
{
|
|
9843
|
-
"actionType": "reload",
|
|
9844
|
-
"data": {
|
|
9845
|
-
"name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
|
|
9846
|
-
"_master.record": `\${record}`,
|
|
9847
|
-
// 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
|
|
9848
|
-
"_master.objectName": "${objectName}",
|
|
9849
|
-
"_master.recordId": "${recordId}"
|
|
9850
|
-
}
|
|
9851
|
-
}
|
|
9852
|
-
]
|
|
9853
|
-
},
|
|
9854
|
-
...props.onEvent
|
|
9855
|
-
},
|
|
9905
|
+
"objectApiName": "${objectName}",
|
|
9906
|
+
"recordId": "${recordId}",
|
|
9907
|
+
onEvent: props.onEvent,
|
|
9856
9908
|
}
|
|
9857
9909
|
}
|
|
9858
9910
|
}
|
|
9859
9911
|
|
|
9860
|
-
async function getRecordServiceSchema(objectName, appId, props = {}) {
|
|
9912
|
+
async function getRecordServiceSchema(objectName, appId, props = {}, body) {
|
|
9861
9913
|
const uiSchema = await getUISchema(objectName);
|
|
9914
|
+
const fields = ___default.values(uiSchema.fields);
|
|
9915
|
+
const serviceId = `u:steedos-record-service-${objectName}`;
|
|
9862
9916
|
return {
|
|
9863
9917
|
uiSchema,
|
|
9864
9918
|
amisSchema: {
|
|
9865
|
-
|
|
9866
|
-
"
|
|
9867
|
-
data: {
|
|
9868
|
-
"_master.objectName": "${objectName}",
|
|
9869
|
-
"_master.recordId": "${recordId}"
|
|
9870
|
-
},
|
|
9871
|
-
"style": {
|
|
9872
|
-
"padding": "var(--Page-body-padding)",
|
|
9873
|
-
...props.style
|
|
9874
|
-
},
|
|
9919
|
+
type: 'service',
|
|
9920
|
+
className: "p-0 m-0",
|
|
9875
9921
|
onEvent: {
|
|
9876
|
-
|
|
9922
|
+
[`@data.changed.${objectName}`]: {
|
|
9877
9923
|
"actions": [
|
|
9878
9924
|
{
|
|
9879
9925
|
"actionType": "reload",
|
|
9880
|
-
"
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9926
|
+
"componentId": serviceId,
|
|
9927
|
+
"expression": "this.__deletedRecord != true"
|
|
9928
|
+
},
|
|
9929
|
+
{
|
|
9930
|
+
"actionType": "custom",
|
|
9931
|
+
"script": "window.goBack()",
|
|
9932
|
+
"expression": "this.__deletedRecord === true"
|
|
9887
9933
|
}
|
|
9888
9934
|
]
|
|
9889
9935
|
},
|
|
9890
|
-
|
|
9936
|
+
},
|
|
9937
|
+
body: {
|
|
9938
|
+
"type": "service",
|
|
9939
|
+
id: serviceId,
|
|
9940
|
+
className: 'steedos-record-service p-0 md:p-2',
|
|
9941
|
+
api: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
9942
|
+
body: {
|
|
9943
|
+
"type": "wrapper",
|
|
9944
|
+
"className": "p-0 m-0",
|
|
9945
|
+
"body": body || [],
|
|
9946
|
+
"hiddenOn": "${recordLoaded != true}"
|
|
9947
|
+
},
|
|
9948
|
+
data: {
|
|
9949
|
+
"_master.objectName": "${objectName}",
|
|
9950
|
+
"_master.recordId": "${recordId}",
|
|
9951
|
+
...(props.data || {})
|
|
9952
|
+
},
|
|
9953
|
+
"style": {
|
|
9954
|
+
// "padding": "var(--Page-body-padding)",
|
|
9955
|
+
...props.style
|
|
9956
|
+
},
|
|
9957
|
+
onEvent: {
|
|
9958
|
+
// 如果定义了fetchInited,则无法接收到广播事件@data.changed
|
|
9959
|
+
"fetchInited": {
|
|
9960
|
+
"weight": 0,
|
|
9961
|
+
"actions": [
|
|
9962
|
+
{
|
|
9963
|
+
actionType: 'broadcast',
|
|
9964
|
+
eventName: "recordLoaded",
|
|
9965
|
+
data: {
|
|
9966
|
+
objectName: "${event.data.__objectName}",
|
|
9967
|
+
record: "${event.data.record}"
|
|
9968
|
+
},
|
|
9969
|
+
expression: "${event.data.__response.error != true}"
|
|
9970
|
+
},
|
|
9971
|
+
]
|
|
9972
|
+
},
|
|
9973
|
+
...props.onEvent
|
|
9974
|
+
}
|
|
9891
9975
|
}
|
|
9892
9976
|
}
|
|
9977
|
+
|
|
9978
|
+
|
|
9979
|
+
}
|
|
9980
|
+
}
|
|
9981
|
+
|
|
9982
|
+
async function getRecordDetailMiniSchema(objectName, appId, props = {}){
|
|
9983
|
+
const uiSchema = await getUISchema(objectName);
|
|
9984
|
+
const fields = ___default.values(uiSchema.fields);
|
|
9985
|
+
|
|
9986
|
+
props.initApiAdaptor = 'payload.data=Object.assign({}, payload.data, payload.data.record); payload.data._finished=true; console.log("payload data is ====>", payload)';
|
|
9987
|
+
|
|
9988
|
+
// TODO 处理相关表
|
|
9989
|
+
// getObjectRelatedListsMiniSchema
|
|
9990
|
+
|
|
9991
|
+
return {
|
|
9992
|
+
type: "form",
|
|
9993
|
+
wrapWithPanel: false,
|
|
9994
|
+
actions: [],
|
|
9995
|
+
initApi: await getReadonlyFormInitApi(uiSchema, props.recordId, fields, props),
|
|
9996
|
+
body: {
|
|
9997
|
+
"type": "wrapper",
|
|
9998
|
+
"className": "p-0 m-0",
|
|
9999
|
+
"body": [
|
|
10000
|
+
{
|
|
10001
|
+
"type": "steedos-record-detail-header",
|
|
10002
|
+
"showButtons": false,
|
|
10003
|
+
"showBackButton": false,
|
|
10004
|
+
"objectApiName": "${objectName}",
|
|
10005
|
+
"recordId": "${recordId}",
|
|
10006
|
+
},
|
|
10007
|
+
// {
|
|
10008
|
+
// "type": "steedos-object-related-lists",
|
|
10009
|
+
// "label": "相关列表",
|
|
10010
|
+
// "objectApiName": "${objectName}",
|
|
10011
|
+
// "staticRecordId": "${recordId}",
|
|
10012
|
+
// formFactor: "SMALL",
|
|
10013
|
+
// appId: appId
|
|
10014
|
+
// }
|
|
10015
|
+
],
|
|
10016
|
+
"hiddenOn": "${_finished != true}"
|
|
10017
|
+
}
|
|
9893
10018
|
}
|
|
9894
10019
|
}
|
|
9895
10020
|
|
|
@@ -11040,7 +11165,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
|
|
|
11040
11165
|
labelField: referenceTo.labelField.name,
|
|
11041
11166
|
valueField: referenceTo.valueField.name,
|
|
11042
11167
|
// disabledOn: this._master目的是相关表新建时禁止编辑关联字段; this.relatedKey目的是相关表编辑时禁止编辑关联字段,多选字段可以编辑。
|
|
11043
|
-
disabledOn: `${readonly}
|
|
11168
|
+
disabledOn: `${readonly}`,
|
|
11169
|
+
hiddenOn: `( (this._master && (this._master.relatedKey ==='${field.name}')) || ((this.relatedKey ==='${field.name}') && (${field.multiple} != true)) )`,
|
|
11044
11170
|
modalMode: 'dialog', //TODO 设置 dialog 或者 drawer,用来配置弹出方式
|
|
11045
11171
|
source: source,
|
|
11046
11172
|
size: "lg",
|
|
@@ -11284,9 +11410,15 @@ async function lookupToAmis(field, readonly, ctx){
|
|
|
11284
11410
|
// console.log(`lookupToAmis====`, field, readonly, ctx)
|
|
11285
11411
|
if(readonly){
|
|
11286
11412
|
return {
|
|
11287
|
-
type:
|
|
11288
|
-
|
|
11413
|
+
type: 'steedos-field',
|
|
11414
|
+
config: field,
|
|
11415
|
+
static: true
|
|
11289
11416
|
}
|
|
11417
|
+
|
|
11418
|
+
// return {
|
|
11419
|
+
// type: Field.getAmisStaticFieldType('picker', readonly),
|
|
11420
|
+
// tpl: Tpl.getRelatedFieldTpl(field, ctx)
|
|
11421
|
+
// }
|
|
11290
11422
|
}
|
|
11291
11423
|
if(field.reference_to && !_$1.isString(field.reference_to) && !readonly){
|
|
11292
11424
|
return {
|
|
@@ -12279,11 +12411,9 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
|
|
|
12279
12411
|
if(field.subFields){
|
|
12280
12412
|
convertData = {
|
|
12281
12413
|
type: 'steedos-input-table',
|
|
12282
|
-
showIndex: true,
|
|
12283
12414
|
editable: !readonly,
|
|
12284
12415
|
addable: !readonly,
|
|
12285
12416
|
removable: !readonly,
|
|
12286
|
-
draggable: !readonly,
|
|
12287
12417
|
fields: [],
|
|
12288
12418
|
amis:{
|
|
12289
12419
|
columnsTogglable: false
|
|
@@ -12741,7 +12871,7 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
12741
12871
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
12742
12872
|
* @Date: 2023-11-15 09:50:22
|
|
12743
12873
|
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
12744
|
-
* @LastEditTime: 2024-01-14
|
|
12874
|
+
* @LastEditTime: 2024-01-16 14:58:51
|
|
12745
12875
|
*/
|
|
12746
12876
|
|
|
12747
12877
|
/**
|
|
@@ -12890,8 +13020,15 @@ function getFormPagination(props, mode) {
|
|
|
12890
13020
|
let currentIndex = event.data.index;
|
|
12891
13021
|
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
12892
13022
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
12893
|
-
|
|
12894
|
-
|
|
13023
|
+
var parent = event.data.parent;
|
|
13024
|
+
var __parentIndex = event.data.__parentIndex;
|
|
13025
|
+
if(parent){
|
|
13026
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13027
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13028
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13029
|
+
children: fieldValue[__parentIndex].children,
|
|
13030
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13031
|
+
});
|
|
12895
13032
|
}
|
|
12896
13033
|
else{
|
|
12897
13034
|
fieldValue[currentIndex] = currentFormValues;
|
|
@@ -13029,9 +13166,14 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
13029
13166
|
}
|
|
13030
13167
|
];
|
|
13031
13168
|
let onServiceInitedScript = `
|
|
13032
|
-
|
|
13169
|
+
var parent = event.data.parent;
|
|
13170
|
+
var fieldValue = event.data.__tableItems;
|
|
13171
|
+
if(parent){
|
|
13033
13172
|
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
13034
|
-
|
|
13173
|
+
var primaryKey = "${props.primaryKey}";
|
|
13174
|
+
event.data.__parentIndex = _.findIndex(fieldValue, function(item){
|
|
13175
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13176
|
+
});
|
|
13035
13177
|
}
|
|
13036
13178
|
// 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
13037
13179
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
@@ -13143,6 +13285,11 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
13143
13285
|
var __parentIndex = event.data.__super.__super.__parentIndex;
|
|
13144
13286
|
if(parent){
|
|
13145
13287
|
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
13288
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13289
|
+
fieldValue[__parentIndex] = Object.assign({}, fieldValue[__parentIndex], {
|
|
13290
|
+
children: fieldValue[__parentIndex].children,
|
|
13291
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13292
|
+
});
|
|
13146
13293
|
}
|
|
13147
13294
|
else{
|
|
13148
13295
|
fieldValue[currentIndex] = currentFormValues;
|
|
@@ -13287,9 +13434,13 @@ async function getButtonActions(props, mode) {
|
|
|
13287
13434
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
13288
13435
|
// 新建一条空白行并保存到子表组件
|
|
13289
13436
|
var parent = event.data.__super.parent;
|
|
13290
|
-
var
|
|
13437
|
+
var primaryKey = "${props.primaryKey}";
|
|
13438
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13439
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13440
|
+
});
|
|
13291
13441
|
if(parent){
|
|
13292
13442
|
fieldValue[__parentIndex].children.push({});
|
|
13443
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13293
13444
|
}
|
|
13294
13445
|
else{
|
|
13295
13446
|
fieldValue.push({});
|
|
@@ -13324,9 +13475,13 @@ async function getButtonActions(props, mode) {
|
|
|
13324
13475
|
// 复制当前页数据到新建行并保存到子表组件
|
|
13325
13476
|
// fieldValue.push(newItem);
|
|
13326
13477
|
var parent = event.data.__super.parent;
|
|
13327
|
-
var
|
|
13478
|
+
var primaryKey = "${props.primaryKey}";
|
|
13479
|
+
var __parentIndex = parent && _.findIndex(fieldValue, function(item){
|
|
13480
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13481
|
+
});
|
|
13328
13482
|
if(parent){
|
|
13329
13483
|
fieldValue[__parentIndex].children.push(newItem);
|
|
13484
|
+
// 这里实测不需要fieldValue[__parentIndex] = ... 来重写整个父行让子表回显,所以没加相关代码
|
|
13330
13485
|
}
|
|
13331
13486
|
else{
|
|
13332
13487
|
fieldValue.push(newItem);
|
|
@@ -13342,7 +13497,6 @@ async function getButtonActions(props, mode) {
|
|
|
13342
13497
|
let __paginationServiceId = "${formPaginationId}";
|
|
13343
13498
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
13344
13499
|
event.data.index = __paginationData.index;
|
|
13345
|
-
// event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13346
13500
|
if(parent){
|
|
13347
13501
|
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
13348
13502
|
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
@@ -13431,8 +13585,9 @@ async function getButtonActions(props, mode) {
|
|
|
13431
13585
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
13432
13586
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
13433
13587
|
// "__tableItems": `\${${props.name}|json|toJson}`
|
|
13434
|
-
//
|
|
13435
|
-
|
|
13588
|
+
// 在节点嵌套情况下,当前节点正好是带children属性的节点的话,这里弹出的dialog映射到的会是children数组,这是amis目前的规则,
|
|
13589
|
+
// 所以这里加判断有children时,用__super.__super让映射到正确的作用域层,如果不加,则__tableItems取到的会是children数组,而不是整个子表组件的值
|
|
13590
|
+
"__tableItems": `\${((children ? __super.__super.${props.name} : __super.${props.name}) || [])|json|toJson}`
|
|
13436
13591
|
},
|
|
13437
13592
|
"actions": dialogButtons,
|
|
13438
13593
|
"onEvent": {
|
|
@@ -13550,9 +13705,17 @@ async function getButtonActions(props, mode) {
|
|
|
13550
13705
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
13551
13706
|
var currentIndex = event.data.index;
|
|
13552
13707
|
var parent = event.data.__super.parent;
|
|
13553
|
-
var
|
|
13708
|
+
var primaryKey = "${props.primaryKey}";
|
|
13709
|
+
var __parentIndex = parent && _.findIndex(lastestFieldValue, function(item){
|
|
13710
|
+
return item[primaryKey] == parent[primaryKey];
|
|
13711
|
+
});
|
|
13554
13712
|
if(parent){
|
|
13555
13713
|
lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
|
|
13714
|
+
// 重写父节点,并且改变其某个属性以让子节点修改的内容回显到界面上
|
|
13715
|
+
lastestFieldValue[__parentIndex] = Object.assign({}, lastestFieldValue[__parentIndex], {
|
|
13716
|
+
children: lastestFieldValue[__parentIndex].children,
|
|
13717
|
+
__fix_rerender_after_children_modified_tag: new Date().getTime()
|
|
13718
|
+
});
|
|
13556
13719
|
}
|
|
13557
13720
|
else{
|
|
13558
13721
|
lastestFieldValue.splice(currentIndex, 1);
|
|
@@ -13642,39 +13805,48 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13642
13805
|
if (!props.id) {
|
|
13643
13806
|
props.id = "steedos_input_table_" + props.name + "_" + Math.random().toString(36).substr(2, 9);
|
|
13644
13807
|
}
|
|
13808
|
+
if (!props.primaryKey) {
|
|
13809
|
+
props.primaryKey = "_id";
|
|
13810
|
+
}
|
|
13811
|
+
let showOperation = props.showOperation;
|
|
13812
|
+
if(showOperation !== false){
|
|
13813
|
+
showOperation = true;
|
|
13814
|
+
}
|
|
13645
13815
|
let serviceId = getComponentId("table_service", props.id);
|
|
13646
13816
|
let buttonsForColumnOperations = [];
|
|
13647
13817
|
let inlineEditMode = props.inlineEditMode;
|
|
13648
13818
|
let showAsInlineEditMode = inlineEditMode && props.editable;
|
|
13649
|
-
if
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13653
|
-
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13819
|
+
if(showOperation){
|
|
13820
|
+
if (props.editable) {
|
|
13821
|
+
let showEditButton = true;
|
|
13822
|
+
if (showAsInlineEditMode) {
|
|
13823
|
+
// 始终显示弹出子表表单按钮,如果需要判断只在有列被隐藏时才需要显示弹出表单按钮放开下面的if逻辑就好
|
|
13824
|
+
showEditButton = true;
|
|
13825
|
+
// // inline edit模式下只在有列被隐藏时才需要显示编辑按钮
|
|
13826
|
+
// if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length) {
|
|
13827
|
+
// showEditButton = true;
|
|
13828
|
+
// }
|
|
13829
|
+
// else {
|
|
13830
|
+
// showEditButton = false;
|
|
13831
|
+
// }
|
|
13832
|
+
}
|
|
13833
|
+
// 编辑时显示编辑按钮
|
|
13834
|
+
if (showEditButton) {
|
|
13835
|
+
let buttonEditSchema = await getButtonEdit(props, showAsInlineEditMode);
|
|
13836
|
+
buttonsForColumnOperations.push(buttonEditSchema);
|
|
13837
|
+
}
|
|
13838
|
+
}
|
|
13839
|
+
else {
|
|
13840
|
+
// 只读时显示查看按钮
|
|
13841
|
+
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13842
|
+
let buttonViewSchema = await getButtonView(props);
|
|
13843
|
+
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13661
13844
|
}
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
buttonsForColumnOperations.push(buttonEditSchema);
|
|
13845
|
+
if (props.removable) {
|
|
13846
|
+
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13847
|
+
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13666
13848
|
}
|
|
13667
13849
|
}
|
|
13668
|
-
else {
|
|
13669
|
-
// 只读时显示查看按钮
|
|
13670
|
-
// 如果想只在有列被隐藏时才需要显示查看按钮可以加上判断:if (props.columns && props.columns.length > 0 && props.columns.length < props.fields.length)
|
|
13671
|
-
let buttonViewSchema = await getButtonView(props);
|
|
13672
|
-
buttonsForColumnOperations.push(buttonViewSchema);
|
|
13673
|
-
}
|
|
13674
|
-
if (props.removable) {
|
|
13675
|
-
let buttonDeleteSchema = await getButtonDelete(props);
|
|
13676
|
-
buttonsForColumnOperations.push(buttonDeleteSchema);
|
|
13677
|
-
}
|
|
13678
13850
|
let inputTableSchema = {
|
|
13679
13851
|
"type": "input-table",
|
|
13680
13852
|
"label": props.label,
|
|
@@ -13692,7 +13864,13 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13692
13864
|
"strictMode": props.strictMode,
|
|
13693
13865
|
"showTableAddBtn": false,
|
|
13694
13866
|
"showFooterAddBtn": false,
|
|
13695
|
-
"className": props.tableClassName
|
|
13867
|
+
"className": props.tableClassName,
|
|
13868
|
+
"pipeOut": (value, data) => {
|
|
13869
|
+
return (value || []).map(function(item){
|
|
13870
|
+
delete item.__fix_rerender_after_children_modified_tag;
|
|
13871
|
+
return item;
|
|
13872
|
+
});
|
|
13873
|
+
}
|
|
13696
13874
|
};
|
|
13697
13875
|
if (buttonsForColumnOperations.length) {
|
|
13698
13876
|
inputTableSchema.columns.push({
|
|
@@ -13715,7 +13893,7 @@ const getAmisInputTableSchema = async (props) => {
|
|
|
13715
13893
|
return item.depend_on;
|
|
13716
13894
|
});
|
|
13717
13895
|
if (isAnyFieldHasDependOn) {
|
|
13718
|
-
// 有任意一个子字段有depend_on
|
|
13896
|
+
// 有任意一个子字段有depend_on属性时,强制设置禁用静态模式,因为strictMode模式下,dependOn的字段值变更后,不会rerender整个子表
|
|
13719
13897
|
Object.assign(inputTableSchema, {
|
|
13720
13898
|
strictMode: false
|
|
13721
13899
|
});
|
|
@@ -13820,7 +13998,7 @@ async function getListPageInitSchema(objectApiName, formFactor, userSession) {
|
|
|
13820
13998
|
// 获取
|
|
13821
13999
|
async function getRecordPageInitSchema(objectApiName){
|
|
13822
14000
|
const relatedList = await getObjectRelatedList(objectApiName);
|
|
13823
|
-
|
|
14001
|
+
await getUISchema(objectApiName);
|
|
13824
14002
|
let body = [
|
|
13825
14003
|
// detailHeaderAmisSchema,
|
|
13826
14004
|
{
|
|
@@ -13828,28 +14006,7 @@ async function getRecordPageInitSchema(objectApiName){
|
|
|
13828
14006
|
"label": "标题面板",
|
|
13829
14007
|
"objectApiName": "${objectName}",
|
|
13830
14008
|
"recordId": "${recordId}",
|
|
13831
|
-
"onEvent": {
|
|
13832
|
-
"recordLoaded": {
|
|
13833
|
-
"actions": [
|
|
13834
|
-
{
|
|
13835
|
-
"actionType": "setValue",
|
|
13836
|
-
"args": {
|
|
13837
|
-
"value": {
|
|
13838
|
-
"recordLoaded": true,
|
|
13839
|
-
}
|
|
13840
|
-
}
|
|
13841
|
-
},
|
|
13842
|
-
{
|
|
13843
|
-
"actionType": "reload",
|
|
13844
|
-
"data": {
|
|
13845
|
-
"name": `\${record.${uiSchema?.NAME_FIELD_KEY || 'name'}}`,
|
|
13846
|
-
"record": `\${record}`,
|
|
13847
|
-
"recordLoaded": true,
|
|
13848
|
-
}
|
|
13849
|
-
}
|
|
13850
|
-
]
|
|
13851
|
-
}
|
|
13852
|
-
}
|
|
14009
|
+
"onEvent": {}
|
|
13853
14010
|
}
|
|
13854
14011
|
];
|
|
13855
14012
|
let contentBody = {
|
|
@@ -16414,5 +16571,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
|
|
|
16414
16571
|
};
|
|
16415
16572
|
};
|
|
16416
16573
|
|
|
16417
|
-
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 };
|
|
16574
|
+
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 };
|
|
16418
16575
|
//# sourceMappingURL=index.esm.js.map
|