@steedos-widgets/amis-lib 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/index.esm.js CHANGED
@@ -3399,6 +3399,18 @@ function getBatchDelete(objectName){
3399
3399
  return {
3400
3400
  method: 'post',
3401
3401
  url: getApi$2(),
3402
+ adaptor: `
3403
+ if(payload.errors){
3404
+ payload.data.deleteErrorMessage = [];
3405
+ payload.errors.forEach(function(error){
3406
+ let errorRecord = error.path.map(function (item) {
3407
+ return item.split('delete__')[1].to_float() + 1;
3408
+ }).toString();
3409
+ payload.data.deleteErrorMessage.push("第" + errorRecord + "条记录删除出现异常,报错信息为(" + (window.t ? window.t(error.message) : error.message) + ")");
3410
+ })
3411
+ }
3412
+ return payload;
3413
+ `,
3402
3414
  requestAdaptor: `
3403
3415
  var ids = api.data.ids.split(",");
3404
3416
  var deleteArray = [];
@@ -8117,7 +8129,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8117
8129
  else {
8118
8130
  if(options && options.isRelated){
8119
8131
  return [
8120
- "statistics",
8121
8132
  {
8122
8133
  "type": "pagination",
8123
8134
  "maxButtons": 10,
@@ -8130,7 +8141,6 @@ function getObjectFooterToolbar(mainObject, formFactor, options) {
8130
8141
  const no_pagination = mainObject.paging && (mainObject.paging.enabled === false);
8131
8142
  const is_lookup = options.isLookup;
8132
8143
  const commonConfig = [
8133
- "statistics",
8134
8144
  {
8135
8145
  "type": "pagination",
8136
8146
  "maxButtons": 10,
@@ -8249,6 +8259,29 @@ function getBulkActions(objectSchema){
8249
8259
  "className": "hidden",
8250
8260
  "id": "batchDelete",
8251
8261
  "api": getBatchDelete(objectSchema.name),
8262
+ "feedback": {
8263
+ "title": "删除警告",
8264
+ "visibleOn": "${deleteErrorMessage}",
8265
+ "body": [
8266
+ {
8267
+ "type": "each",
8268
+ "name": "deleteErrorMessage",
8269
+ "items": {
8270
+ "type": "alert",
8271
+ "body": "${item}",
8272
+ "level": "danger",
8273
+ "className": "mb-3"
8274
+ }
8275
+ }
8276
+ ],
8277
+ "actions": [
8278
+ {
8279
+ "type": "button",
8280
+ "actionType": "close",
8281
+ "label": "关闭"
8282
+ }
8283
+ ]
8284
+ }
8252
8285
  }
8253
8286
  // {
8254
8287
  // "label": "批量修改",
@@ -12701,8 +12734,8 @@ async function getFormBody(permissionFields, formFields, ctx){
12701
12734
  /*
12702
12735
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12703
12736
  * @Date: 2023-11-15 09:50:22
12704
- * @LastEditors: liaodaxue
12705
- * @LastEditTime: 2024-01-09 18:12:28
12737
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12738
+ * @LastEditTime: 2024-01-12 14:51:00
12706
12739
  */
12707
12740
 
12708
12741
  /**
@@ -12851,7 +12884,12 @@ function getFormPagination(props, mode) {
12851
12884
  let currentIndex = event.data.index;
12852
12885
  // 翻页到下一页之前需要先把当前页改动的内容保存到中间变量__tableItems中
12853
12886
  let currentFormValues = scope.getComponentById(__formId).getValues();
12854
- fieldValue[currentIndex] = currentFormValues;
12887
+ if(event.data.parent){
12888
+ fieldValue[event.data.__parentIndex].children[currentIndex] = currentFormValues;
12889
+ }
12890
+ else{
12891
+ fieldValue[currentIndex] = currentFormValues;
12892
+ }
12855
12893
  // 翻页到下一页前需要同时把改动的内容保存到最终正式的表单字段中,所以额外给正式表单字段执行一次setValue
12856
12894
  doAction({
12857
12895
  "componentId": "${props.id}",
@@ -12918,7 +12956,8 @@ function getFormPagination(props, mode) {
12918
12956
  },
12919
12957
  {
12920
12958
  "type": "tpl",
12921
- "tpl": "${__page}/${__tableItems.length}"
12959
+ // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
12960
+ "tpl": "${__page}/${__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length}"
12922
12961
  },
12923
12962
  {
12924
12963
  "type": "button",
@@ -12926,7 +12965,9 @@ function getFormPagination(props, mode) {
12926
12965
  "icon": `fa fa-angle-right`,
12927
12966
  "level": "link",
12928
12967
  "pageChangeDirection": "next",
12929
- "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
12968
+ // "disabledOn": showPagination ? "${__page >= __tableItems.length}" : "true",
12969
+ // 这里用__super.parent,加__super是为了防止当前记录有字段名为parent的重名变量
12970
+ "disabledOn": showPagination ? "${__page >= (__super.parent ? __tableItems[__parentIndex]['children'].length : __tableItems.length)}" : "true",
12930
12971
  "size": "sm",
12931
12972
  "id": buttonNextId,
12932
12973
  "onEvent": {
@@ -12959,7 +13000,7 @@ function getFormPaginationWrapper(props, form, mode) {
12959
13000
  "data": {
12960
13001
  // 这里加__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
12961
13002
  // 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
12962
- "&": "${__tableItems[__super.index]}"
13003
+ "&": "${__super.parent ? __tableItems[__parentIndex]['children'][__super.index] : __tableItems[__super.index]}"
12963
13004
  }
12964
13005
  });
12965
13006
  let formBody = [
@@ -12982,6 +13023,10 @@ function getFormPaginationWrapper(props, form, mode) {
12982
13023
  }
12983
13024
  ];
12984
13025
  let onServiceInitedScript = `
13026
+ if(event.data.parent){
13027
+ // 如果是子行,即在节点嵌套情况下,当前节点如果是children属性下的子节点时,则算出其所属父行的索引值
13028
+ event.data.__parentIndex = _.findIndex(event.data.__tableItems, {_id: event.data.parent._id});
13029
+ }
12985
13030
  // 以下脚本是为了解决有时弹出编辑表单时,表单中的值比最后一次编辑保存的值会延迟一拍。
12986
13031
  // 比如:inlineEditMode模式时,用户在表格单元格中直接修改数据,然后弹出的表单form中并没有包含单元格中修改的内容
12987
13032
  // 另外有的地方在非inlineEditMode模式时也会有这种延迟一拍问题,比如对象字段中下拉框类型字段的”选择项“属性
@@ -13037,6 +13082,7 @@ function getFormPaginationWrapper(props, form, mode) {
13037
13082
  // "body": formBody,
13038
13083
  "data": {
13039
13084
  "__page": "${index + 1}",
13085
+ "__parentIndex": null,//兼容节点嵌套情况,即节点中有children属性时,这里记录当前节点所属上层节点index,只支持向上找一层,不支持多层
13040
13086
  // "__total": `\${${props.name}.length}`,
13041
13087
  // "__total": "${__tableItems.length}",
13042
13088
  // "__paginationServiceId": serviceId,
@@ -13084,7 +13130,17 @@ async function getForm(props, mode = "edit", formId) {
13084
13130
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13085
13131
  //这里加__super.__super前缀是因为__parentForm变量(即主表单)中可能会正好有名为index的字段
13086
13132
  // 比如“对象字段”对象options字段是一个子表字段,但是主表(即“对象字段”对象)中正好有一个名为index的字段
13087
- fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
13133
+ // fieldValue[event.data.__super.__super.index] = JSON.parse(JSON.stringify(event.data));
13134
+ var currentIndex = event.data.__super.__super.index;
13135
+ var currentFormValues = JSON.parse(JSON.stringify(event.data));
13136
+ var parent = event.data.__super.__super.parent;
13137
+ var __parentIndex = event.data.__super.__super.__parentIndex;
13138
+ if(parent){
13139
+ fieldValue[__parentIndex].children[currentIndex] = currentFormValues;
13140
+ }
13141
+ else{
13142
+ fieldValue[currentIndex] = currentFormValues;
13143
+ }
13088
13144
  doAction({
13089
13145
  "componentId": "${props.id}",
13090
13146
  "actionType": "setValue",
@@ -13224,7 +13280,14 @@ async function getButtonActions(props, mode) {
13224
13280
  let scope = event.context.scoped;
13225
13281
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13226
13282
  // 新建一条空白行并保存到子表组件
13227
- fieldValue.push({});
13283
+ var parent = event.data.__super.parent;
13284
+ var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
13285
+ if(parent){
13286
+ fieldValue[__parentIndex].children.push({});
13287
+ }
13288
+ else{
13289
+ fieldValue.push({});
13290
+ }
13228
13291
  doAction({
13229
13292
  "componentId": "${props.id}",
13230
13293
  "actionType": "setValue",
@@ -13236,7 +13299,13 @@ async function getButtonActions(props, mode) {
13236
13299
  let __paginationServiceId = "${formPaginationId}";
13237
13300
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13238
13301
  event.data.index = __paginationData.index;
13239
- event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13302
+ if(parent){
13303
+ event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13304
+ event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
13305
+ }
13306
+ else{
13307
+ event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13308
+ }
13240
13309
  // 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
13241
13310
  scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
13242
13311
  `;
@@ -13247,7 +13316,15 @@ async function getButtonActions(props, mode) {
13247
13316
  let newItem = scope.getComponentById(__formId).getValues();//这里不可以用event.data,因为其拿到的是弹出表单时的初始值,不是用户实时填写的数据
13248
13317
  let fieldValue = event.data.__tableItems;//这里不可以_.cloneDeep,因为翻页form中用的是event.data.__tableItems,直接变更其值即可改变表单中的值
13249
13318
  // 复制当前页数据到新建行并保存到子表组件
13250
- fieldValue.push(newItem);
13319
+ // fieldValue.push(newItem);
13320
+ var parent = event.data.__super.parent;
13321
+ var __parentIndex = parent && _.findIndex(fieldValue, {_id: parent._id});
13322
+ if(parent){
13323
+ fieldValue[__parentIndex].children.push(newItem);
13324
+ }
13325
+ else{
13326
+ fieldValue.push(newItem);
13327
+ }
13251
13328
  doAction({
13252
13329
  "componentId": "${props.id}",
13253
13330
  "actionType": "setValue",
@@ -13259,7 +13336,14 @@ async function getButtonActions(props, mode) {
13259
13336
  let __paginationServiceId = "${formPaginationId}";
13260
13337
  let __paginationData = scope.getComponentById(__paginationServiceId).getData();
13261
13338
  event.data.index = __paginationData.index;
13262
- event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13339
+ // event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13340
+ if(parent){
13341
+ event.data.__page = fieldValue[__parentIndex].children.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13342
+ event.data.__parentIndex = __parentIndex; //执行下面的翻页按钮事件中依赖了__parentIndex值
13343
+ }
13344
+ else{
13345
+ event.data.__page = fieldValue.length - 1;//这里不可以用Object.assign否则,event.data中上层作用域数据会丢失
13346
+ }
13263
13347
  // 触发翻页按钮事件,实现保存当前页数据并跳转到最后一行
13264
13348
  scope.getComponentById(buttonNextId).props.dispatchEvent("click", event.data);
13265
13349
  `;
@@ -13335,7 +13419,8 @@ async function getButtonActions(props, mode) {
13335
13419
  "_master": "${_master}",
13336
13420
  "global": "${global}",
13337
13421
  "uiSchema": "${uiSchema}",
13338
- "index": "${index}",
13422
+ "index": "${index}",//amis组件自带行索引,在节点嵌套情况下,当前节点如果是children属性下的子节点时,这里的index是当前节点在children中的索引,而不是外层父节点的index
13423
+ "parent": "${parent}",//amis组件自带父节点数据域数据,即节点嵌套情况下,当前节点为某个节点(比如A节点)的children属性下的子节点时,当前节点的父节点(即A节点)的数据域数据
13339
13424
  // "__tableItems": `\${${props.name}}`
13340
13425
  // 为了解决"弹出的dialog窗口中子表组件会影响页面布局界面中父作用域字段值",比如设计字段布局微页面中的设置分组功能,弹出的就是子表dialog
13341
13426
  // 所以这里使用json|toJson转一次,断掉event.data.__tableItems与上层任用域中props.name的联系
@@ -13363,35 +13448,39 @@ async function getButtonActions(props, mode) {
13363
13448
  Object.assign(actionShowEditDialog.dialog, props.dialog);
13364
13449
  }
13365
13450
  if (mode == "new") {
13366
- `
13367
- let newItem = {};
13368
- if(event.data["${props.name}"]){
13369
- // let fieldValue = event.data.__tableItems;
13370
- // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
13371
- // let fieldValue = _.clone(event.data["${props.name}"]);
13372
- let fieldValue = event.data["${props.name}"];
13373
- fieldValue.push(newItem);
13374
- doAction({
13375
- "componentId": "${props.id}",
13376
- "actionType": "setValue",
13377
- "args": {
13378
- "value": fieldValue
13379
- }
13380
- });
13381
- event.data.index = fieldValue.length - 1;
13382
- }
13383
- else{
13384
- // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
13385
- doAction({
13386
- "componentId": "${props.id}",
13387
- "actionType": "setValue",
13388
- "args": {
13389
- "value": [newItem]
13390
- }
13391
- });
13392
- event.data.index = 1;
13393
- }
13394
- `;
13451
+ // let onNewLineScript = `
13452
+ // let newItem = {};
13453
+ // if(event.data["${props.name}"]){
13454
+ // // let fieldValue = event.data.__tableItems;
13455
+ // // 这里不用__tableItems是因为新建的时候没有翻页,里面没有也不需要走__tableItems变量
13456
+ // // let fieldValue = _.clone(event.data["${props.name}"]);
13457
+ // let fieldValue = event.data["${props.name}"];
13458
+ // fieldValue.push(newItem);
13459
+ // doAction({
13460
+ // "componentId": "${props.id}",
13461
+ // "actionType": "setValue",
13462
+ // "args": {
13463
+ // "value": fieldValue
13464
+ // }
13465
+ // });
13466
+ // event.data.index = fieldValue.length - 1;
13467
+ // }
13468
+ // else{
13469
+ // // 这里不可以执行event.data["${props.name}"]=[newItem],数据域会断掉
13470
+ // doAction({
13471
+ // "componentId": "${props.id}",
13472
+ // "actionType": "setValue",
13473
+ // "args": {
13474
+ // "value": [newItem]
13475
+ // }
13476
+ // });
13477
+ // event.data.index = 1;
13478
+ // }
13479
+ // `;
13480
+ // let actionNewLine = {
13481
+ // "actionType": "custom",
13482
+ // "script": onNewLineScript
13483
+ // };
13395
13484
  // 新增行时不需要在弹出编辑表单前先加一行,因为会在编辑表单所在service初始化时判断到是新增就自动增加一行,因为这里拿不到event.data.__tableItems,也无法变更其值
13396
13485
  // actions = [actionNewLine, actionShowEditDialog];
13397
13486
  actions = [actionShowEditDialog];
@@ -13450,7 +13539,15 @@ async function getButtonActions(props, mode) {
13450
13539
  // 这里不可以用event.data["${props.name}"]因为amis input talbe有一层单独的作用域,其值会延迟一拍
13451
13540
  // 这里_.clone是因为字段设计布局设置分组这种弹出窗口中的子表组件,直接删除后,点取消无法还原
13452
13541
  let lastestFieldValue = _.clone(wrapperServiceData["${props.name}"]);
13453
- lastestFieldValue.splice(event.data.index, 1);
13542
+ var currentIndex = event.data.index;
13543
+ var parent = event.data.__super.parent;
13544
+ var __parentIndex = parent && _.findIndex(lastestFieldValue, {_id: parent._id});
13545
+ if(parent){
13546
+ lastestFieldValue[__parentIndex].children.splice(currentIndex, 1);
13547
+ }
13548
+ else{
13549
+ lastestFieldValue.splice(currentIndex, 1);
13550
+ }
13454
13551
  doAction({
13455
13552
  "componentId": "${props.id}",
13456
13553
  "actionType": "setValue",