@steedos-widgets/amis-object 3.6.2-beta.2 → 3.6.2-beta.3
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/amis-object.cjs.js +141 -44
- package/dist/amis-object.cjs.js.map +1 -1
- package/dist/amis-object.esm.js +141 -44
- package/dist/amis-object.esm.js.map +1 -1
- package/dist/amis-object.umd.js +51 -12
- package/dist/amis-object.umd.js.map +1 -1
- package/dist/assets.json +21 -21
- package/package.json +3 -3
package/dist/amis-object.cjs.js
CHANGED
|
@@ -6580,6 +6580,18 @@ function getBatchDelete(objectName){
|
|
|
6580
6580
|
return {
|
|
6581
6581
|
method: 'post',
|
|
6582
6582
|
url: getApi$2(),
|
|
6583
|
+
adaptor: `
|
|
6584
|
+
if(payload.errors){
|
|
6585
|
+
payload.data.deleteErrorMessage = [];
|
|
6586
|
+
payload.errors.forEach(function(error){
|
|
6587
|
+
let errorRecord = error.path.map(function (item) {
|
|
6588
|
+
return item.split('delete__')[1].to_float() + 1;
|
|
6589
|
+
}).toString();
|
|
6590
|
+
payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
|
|
6591
|
+
})
|
|
6592
|
+
}
|
|
6593
|
+
return payload;
|
|
6594
|
+
`,
|
|
6583
6595
|
requestAdaptor: `
|
|
6584
6596
|
var ids = api.data.ids.split(",");
|
|
6585
6597
|
var deleteArray = [];
|
|
@@ -11298,7 +11310,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
11298
11310
|
else {
|
|
11299
11311
|
if(options && options.isRelated){
|
|
11300
11312
|
return [
|
|
11301
|
-
"statistics",
|
|
11302
11313
|
{
|
|
11303
11314
|
"type": "pagination",
|
|
11304
11315
|
"maxButtons": 10,
|
|
@@ -11311,7 +11322,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
|
|
|
11311
11322
|
const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
|
|
11312
11323
|
const is_lookup = options.isLookup;
|
|
11313
11324
|
const commonConfig = [
|
|
11314
|
-
"statistics",
|
|
11315
11325
|
{
|
|
11316
11326
|
"type": "pagination",
|
|
11317
11327
|
"maxButtons": 10,
|
|
@@ -11430,6 +11440,29 @@ function getBulkActions(objectSchema){
|
|
|
11430
11440
|
"className": "hidden",
|
|
11431
11441
|
"id": "batchDelete",
|
|
11432
11442
|
"api": getBatchDelete(objectSchema.name),
|
|
11443
|
+
"feedback": {
|
|
11444
|
+
"title": "删除警告",
|
|
11445
|
+
"visibleOn": "${deleteErrorMessage}",
|
|
11446
|
+
"body": [
|
|
11447
|
+
{
|
|
11448
|
+
"type": "each",
|
|
11449
|
+
"name": "deleteErrorMessage",
|
|
11450
|
+
"items": {
|
|
11451
|
+
"type": "alert",
|
|
11452
|
+
"body": "${item}",
|
|
11453
|
+
"level": "danger",
|
|
11454
|
+
"className": "mb-3"
|
|
11455
|
+
}
|
|
11456
|
+
}
|
|
11457
|
+
],
|
|
11458
|
+
"actions": [
|
|
11459
|
+
{
|
|
11460
|
+
"type": "button",
|
|
11461
|
+
"actionType": "close",
|
|
11462
|
+
"label": "关闭"
|
|
11463
|
+
}
|
|
11464
|
+
]
|
|
11465
|
+
}
|
|
11433
11466
|
}
|
|
11434
11467
|
// {
|
|
11435
11468
|
// "label": "批量修改",
|
|
@@ -15882,8 +15915,8 @@ async function getFormBody(permissionFields, formFields, ctx){
|
|
|
15882
15915
|
/*
|
|
15883
15916
|
* @Author: 殷亮辉 yinlianghui@hotoa.com
|
|
15884
15917
|
* @Date: 2023-11-15 09:50:22
|
|
15885
|
-
* @LastEditors:
|
|
15886
|
-
* @LastEditTime: 2024-01-
|
|
15918
|
+
* @LastEditors: 殷亮辉 yinlianghui@hotoa.com
|
|
15919
|
+
* @LastEditTime: 2024-01-12 14:51:00
|
|
15887
15920
|
*/
|
|
15888
15921
|
|
|
15889
15922
|
/**
|
|
@@ -16032,7 +16065,12 @@ function getFormPagination(props, mode) {
|
|
|
16032
16065
|
let currentIndex = event.data.index;
|
|
16033
16066
|
// 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
|
|
16034
16067
|
let currentFormValues = scope.getComponentById(__formId).getValues();
|
|
16035
|
-
|
|
16068
|
+
if(event.data.parent){
|
|
16069
|
+
fieldValue[event.data.__parentIndex].children[currentIndex] = currentFormValues;
|
|
16070
|
+
}
|
|
16071
|
+
else{
|
|
16072
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
16073
|
+
}
|
|
16036
16074
|
// 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
|
|
16037
16075
|
doAction({
|
|
16038
16076
|
"componentId": "${props.id}",
|
|
@@ -16099,7 +16137,8 @@ function getFormPagination(props, mode) {
|
|
|
16099
16137
|
},
|
|
16100
16138
|
{
|
|
16101
16139
|
"type": "tpl",
|
|
16102
|
-
|
|
16140
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
16141
|
+
"tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
|
|
16103
16142
|
},
|
|
16104
16143
|
{
|
|
16105
16144
|
"type": "button",
|
|
@@ -16107,7 +16146,9 @@ function getFormPagination(props, mode) {
|
|
|
16107
16146
|
"icon": `fa fa-angle-right`,
|
|
16108
16147
|
"level": "link",
|
|
16109
16148
|
"pageChangeDirection": "next",
|
|
16110
|
-
"disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
16149
|
+
// "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
|
|
16150
|
+
// 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
|
|
16151
|
+
"disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
|
|
16111
16152
|
"size": "sm",
|
|
16112
16153
|
"id": buttonNextId,
|
|
16113
16154
|
"onEvent": {
|
|
@@ -16140,7 +16181,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
16140
16181
|
"data": {
|
|
16141
16182
|
// 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
16142
16183
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
16143
|
-
"&": "${__tableItems[__super.index]}"
|
|
16184
|
+
"&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
|
|
16144
16185
|
}
|
|
16145
16186
|
});
|
|
16146
16187
|
let formBody = [
|
|
@@ -16163,6 +16204,10 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
16163
16204
|
}
|
|
16164
16205
|
];
|
|
16165
16206
|
let onServiceInitedScript = `
|
|
16207
|
+
if(event.data.parent){
|
|
16208
|
+
// 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
|
|
16209
|
+
event.data.__parentIndex = _.findIndex(event.data.__tableItems, {_id: event.data.parent._id});
|
|
16210
|
+
}
|
|
16166
16211
|
// 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
|
|
16167
16212
|
// 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
|
|
16168
16213
|
// 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
|
|
@@ -16218,6 +16263,7 @@ function getFormPaginationWrapper(props, form, mode) {
|
|
|
16218
16263
|
// "body": formBody,
|
|
16219
16264
|
"data": {
|
|
16220
16265
|
"__page": "${index + 1}",
|
|
16266
|
+
"__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
|
|
16221
16267
|
// "__total": `\${${props.name}.length}`,
|
|
16222
16268
|
// "__total": "${__tableItems.length}",
|
|
16223
16269
|
// "__paginationServiceId": serviceId,
|
|
@@ -16265,7 +16311,17 @@ async function getForm(props, mode = "edit", formId) {
|
|
|
16265
16311
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
16266
16312
|
//这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
|
|
16267
16313
|
// 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
|
|
16268
|
-
fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
16314
|
+
// fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
|
|
16315
|
+
var currentIndex = event.data.__super.__super.index;
|
|
16316
|
+
var currentFormValues = JSON.parse(JSON.stringify(event.data));
|
|
16317
|
+
var parent = event.data.__super.__super.parent;
|
|
16318
|
+
var __parentIndex = event.data.__super.__super.__parentIndex;
|
|
16319
|
+
if(parent){
|
|
16320
|
+
fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
|
|
16321
|
+
}
|
|
16322
|
+
else{
|
|
16323
|
+
fieldValue[currentIndex] = currentFormValues;
|
|
16324
|
+
}
|
|
16269
16325
|
doAction({
|
|
16270
16326
|
"componentId": "${props.id}",
|
|
16271
16327
|
"actionType": "setValue",
|
|
@@ -16405,7 +16461,14 @@ async function getButtonActions(props, mode) {
|
|
|
16405
16461
|
let scope = event.context.scoped;
|
|
16406
16462
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
16407
16463
|
// 新建一条空白行并保存到子表组件
|
|
16408
|
-
|
|
16464
|
+
var parent = event.data.__super.parent;
|
|
16465
|
+
var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
|
|
16466
|
+
if(parent){
|
|
16467
|
+
fieldValue[__parentIndex].children.push({});
|
|
16468
|
+
}
|
|
16469
|
+
else{
|
|
16470
|
+
fieldValue.push({});
|
|
16471
|
+
}
|
|
16409
16472
|
doAction({
|
|
16410
16473
|
"componentId": "${props.id}",
|
|
16411
16474
|
"actionType": "setValue",
|
|
@@ -16417,7 +16480,13 @@ async function getButtonActions(props, mode) {
|
|
|
16417
16480
|
let __paginationServiceId = "${formPaginationId}";
|
|
16418
16481
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
16419
16482
|
event.data.index = __paginationData.index;
|
|
16420
|
-
|
|
16483
|
+
if(parent){
|
|
16484
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
16485
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
16486
|
+
}
|
|
16487
|
+
else{
|
|
16488
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
16489
|
+
}
|
|
16421
16490
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
16422
16491
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
16423
16492
|
`;
|
|
@@ -16428,7 +16497,15 @@ async function getButtonActions(props, mode) {
|
|
|
16428
16497
|
let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
|
|
16429
16498
|
let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
|
|
16430
16499
|
// 复制当前页数据到新建行并保存到子表组件
|
|
16431
|
-
fieldValue.push(newItem);
|
|
16500
|
+
// fieldValue.push(newItem);
|
|
16501
|
+
var parent = event.data.__super.parent;
|
|
16502
|
+
var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
|
|
16503
|
+
if(parent){
|
|
16504
|
+
fieldValue[__parentIndex].children.push(newItem);
|
|
16505
|
+
}
|
|
16506
|
+
else{
|
|
16507
|
+
fieldValue.push(newItem);
|
|
16508
|
+
}
|
|
16432
16509
|
doAction({
|
|
16433
16510
|
"componentId": "${props.id}",
|
|
16434
16511
|
"actionType": "setValue",
|
|
@@ -16440,7 +16517,14 @@ async function getButtonActions(props, mode) {
|
|
|
16440
16517
|
let __paginationServiceId = "${formPaginationId}";
|
|
16441
16518
|
let __paginationData = scope.getComponentById(__paginationServiceId).getData();
|
|
16442
16519
|
event.data.index = __paginationData.index;
|
|
16443
|
-
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
16520
|
+
// event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
16521
|
+
if(parent){
|
|
16522
|
+
event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
16523
|
+
event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
|
|
16524
|
+
}
|
|
16525
|
+
else{
|
|
16526
|
+
event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
|
|
16527
|
+
}
|
|
16444
16528
|
// 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
|
|
16445
16529
|
scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
|
|
16446
16530
|
`;
|
|
@@ -16516,7 +16600,8 @@ async function getButtonActions(props, mode) {
|
|
|
16516
16600
|
"_master": "${_master}",
|
|
16517
16601
|
"global": "${global}",
|
|
16518
16602
|
"uiSchema": "${uiSchema}",
|
|
16519
|
-
"index": "${index}"
|
|
16603
|
+
"index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
|
|
16604
|
+
"parent": "${parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
|
|
16520
16605
|
// "__tableItems": `\${${props.name}}`
|
|
16521
16606
|
// 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
|
|
16522
16607
|
// 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
|
|
@@ -16544,35 +16629,39 @@ async function getButtonActions(props, mode) {
|
|
|
16544
16629
|
Object.assign(actionShowEditDialog.dialog, props.dialog);
|
|
16545
16630
|
}
|
|
16546
16631
|
if (mode == "new") {
|
|
16547
|
-
`
|
|
16548
|
-
|
|
16549
|
-
|
|
16550
|
-
|
|
16551
|
-
|
|
16552
|
-
|
|
16553
|
-
|
|
16554
|
-
|
|
16555
|
-
|
|
16556
|
-
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
|
|
16566
|
-
|
|
16567
|
-
|
|
16568
|
-
|
|
16569
|
-
|
|
16570
|
-
|
|
16571
|
-
|
|
16572
|
-
|
|
16573
|
-
|
|
16574
|
-
|
|
16575
|
-
`;
|
|
16632
|
+
// let onNewLineScript = `
|
|
16633
|
+
// let newItem = {};
|
|
16634
|
+
// if(event.data["${props.name}"]){
|
|
16635
|
+
// // let fieldValue = event.data.__tableItems;
|
|
16636
|
+
// // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
|
|
16637
|
+
// // let fieldValue = _.clone(event.data["${props.name}"]);
|
|
16638
|
+
// let fieldValue = event.data["${props.name}"];
|
|
16639
|
+
// fieldValue.push(newItem);
|
|
16640
|
+
// doAction({
|
|
16641
|
+
// "componentId": "${props.id}",
|
|
16642
|
+
// "actionType": "setValue",
|
|
16643
|
+
// "args": {
|
|
16644
|
+
// "value": fieldValue
|
|
16645
|
+
// }
|
|
16646
|
+
// });
|
|
16647
|
+
// event.data.index = fieldValue.length - 1;
|
|
16648
|
+
// }
|
|
16649
|
+
// else{
|
|
16650
|
+
// // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
|
|
16651
|
+
// doAction({
|
|
16652
|
+
// "componentId": "${props.id}",
|
|
16653
|
+
// "actionType": "setValue",
|
|
16654
|
+
// "args": {
|
|
16655
|
+
// "value": [newItem]
|
|
16656
|
+
// }
|
|
16657
|
+
// });
|
|
16658
|
+
// event.data.index = 1;
|
|
16659
|
+
// }
|
|
16660
|
+
// `;
|
|
16661
|
+
// let actionNewLine = {
|
|
16662
|
+
// "actionType": "custom",
|
|
16663
|
+
// "script": onNewLineScript
|
|
16664
|
+
// };
|
|
16576
16665
|
// 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
|
|
16577
16666
|
// actions = [actionNewLine, actionShowEditDialog];
|
|
16578
16667
|
actions = [actionShowEditDialog];
|
|
@@ -16631,7 +16720,15 @@ async function getButtonActions(props, mode) {
|
|
|
16631
16720
|
// 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
|
|
16632
16721
|
// 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
|
|
16633
16722
|
let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
|
|
16634
|
-
|
|
16723
|
+
var currentIndex = event.data.index;
|
|
16724
|
+
var parent = event.data.__super.parent;
|
|
16725
|
+
var __parentIndex = parent && _.findIndex(lastestFieldValue, {_id: parent._id});
|
|
16726
|
+
if(parent){
|
|
16727
|
+
lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
|
|
16728
|
+
}
|
|
16729
|
+
else{
|
|
16730
|
+
lastestFieldValue.splice(currentIndex, 1);
|
|
16731
|
+
}
|
|
16635
16732
|
doAction({
|
|
16636
16733
|
"componentId": "${props.id}",
|
|
16637
16734
|
"actionType": "setValue",
|