@steedos-widgets/amis-object 3.6.11-beta.5 → 3.6.11-beta.7

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.
@@ -11436,6 +11436,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
11436
11436
  }
11437
11437
 
11438
11438
  const onChangeScript = `
11439
+ // console.log("==search=onChangeScript===");
11439
11440
  const scope = event.context.scoped;
11440
11441
  let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
11441
11442
  // let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
@@ -11451,14 +11452,13 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
11451
11452
  }
11452
11453
  `;
11453
11454
 
11454
- // onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
11455
+ // 之前onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
11455
11456
  // 而点击回车按键又不会触发blur事件,所以只能每次回车事件中额外再执行一次onChangeScript
11456
11457
  // 等升级到amis 3.4+,blur事件换成change事件执行onChangeScript,就可以不用在onSearchScript中执行onChangeScript了
11458
+ // 基于amis3.6,已经不再用blur事件触发onChangeScript,所以这里把之前加上的onChangeScript去掉了,如果以后还要换blur来触发onChangeScript脚本的话,这里又要加回onChangeScript脚本
11457
11459
  const onSearchScript = `
11458
- ${onChangeScript}
11459
-
11460
11460
  // 下面的脚本只为解决点击搜索表单取消按钮,再重新在其中输入过滤条件但是不点击搜索按钮或回车按键触发搜索,此时在快速搜索框输入过滤条件按回车按键会把搜索表单中的过滤条件清空的问题
11461
- // const scope = event.context.scoped;
11461
+ const scope = event.context.scoped;
11462
11462
  // 如果点击过顶部搜索栏表单的取消按钮,会把此处event.data.__super.__super.__super中的搜索表单项的所有字段设置为null
11463
11463
  // 点击取消按钮后继续在表单项中输入过滤条件且最后没有点击回车按键或点击表单项搜索按钮的话,在快速搜索中点击回车按钮提交搜索会所顶部搜索表单中的字段值清空
11464
11464
  let isLookup = event.data.isLookup;
@@ -11477,6 +11477,16 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
11477
11477
  }, 500);
11478
11478
  `;
11479
11479
 
11480
+ // const onBlurScript = `
11481
+ // // 失去焦点事件触发搜索,先去掉,因为会有bug,见:[Bug]: 列表上快速搜索输入框输入内容后点击放大镜界面上列表未显示过滤后的内容 #6742
11482
+ // const value = event.data.value;
11483
+ // setTimeout(function(){
11484
+ // const scope = event.context.scoped;
11485
+ // const sb = SteedosUI.getClosestAmisComponentByType(scope, "search-box");
11486
+ // sb.handleSearch(value);
11487
+ // }, 500);
11488
+ // `;
11489
+
11480
11490
  return {
11481
11491
  "type": "tooltip-wrapper",
11482
11492
  "id": "steedos_crud_toolbar_quick_search",
@@ -11494,7 +11504,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
11494
11504
  "name": keywordsSearchBoxName,
11495
11505
  "placeholder": "快捷搜索",
11496
11506
  "value": crudKeywords,
11497
- // "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
11507
+ "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
11498
11508
  "clearAndSubmit": true,
11499
11509
  "searchImediately": false,
11500
11510
  "onEvent": {
@@ -11506,14 +11516,22 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
11506
11516
  }
11507
11517
  ]
11508
11518
  },
11509
- "blur": { //这里把change事件换成blur是因为amis 3.2change事件中setData会卡,升级到3.4+后就可以换回change事件
11519
+ "change": { //amis 3.2change事件中setData会卡,升级到amis 3.4+应该不会再卡了,所以这里换回change事件,如果还是会卡就要考虑重新换成blur事件
11510
11520
  "actions": [
11511
11521
  {
11512
11522
  "actionType": "custom",
11513
11523
  "script": onChangeScript
11514
11524
  },
11515
11525
  ]
11516
- }
11526
+ },
11527
+ // "blur": {
11528
+ // "actions": [
11529
+ // {
11530
+ // "actionType": "custom",
11531
+ // "script": onBlurScript
11532
+ // },
11533
+ // ]
11534
+ // }
11517
11535
  }
11518
11536
  }
11519
11537
  ]
@@ -11538,59 +11556,64 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
11538
11556
  };
11539
11557
  }
11540
11558
  let toolbarReloadButton;
11541
- if(formFactor === 'SMALL'){
11542
- // const onReloadScript = `
11543
- // const scope = event.context.scoped;
11544
- // var listView = scope.parent.getComponents().find(function(n){
11545
- // return n.props.type === "crud";
11546
- // });
11547
- // listView.handleChangePage(1);
11548
- // `;
11549
- // toolbarReloadButton = {
11550
- // // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页,这在加载更多按钮的翻页模式下会有问题
11551
- // "type": "button",
11552
- // "align": "right",
11553
- // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
11554
- // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
11555
- // "tooltipPlacement": "top",
11556
- // "className": "bg-white p-2 rounded text-gray-500",
11557
- // "label": "",
11558
- // "icon": "fa fa-sync",
11559
- // "visibleOn": "${!showFieldsFilter}",
11560
- // "onEvent": {
11561
- // "click": {
11562
- // "actions": [
11563
- // {
11564
- // "actionType": "custom",
11565
- // "script": onReloadScript
11566
- // }
11567
- // ]
11568
- // }
11569
- // },
11570
- // };
11559
+ const onReloadScript = `
11560
+ // const scope = event.context.scoped;
11561
+ // var listView = scope.parent.getComponents().find(function(n){
11562
+ // return n.props.type === "crud";
11563
+ // });
11564
+ // listView.handleChangePage(1);
11571
11565
 
11572
- // 后续如果换成加载更多按钮的翻页模式的话,不可以直接使用下面的reload,需要换成上面的自定义脚本模式
11573
- toolbarReloadButton = {
11574
- "type": "reload",
11575
- "align": "right",
11576
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
11577
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
11578
- "tooltip":"",
11579
- "tooltipPlacement": "top",
11580
- "className": "bg-white p-2 rounded text-gray-500"
11581
- };
11582
- }
11583
- else {
11584
- toolbarReloadButton = {
11585
- "type": "reload",
11586
- "align": "right",
11587
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
11588
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
11589
- "tooltip":"",
11590
- "tooltipPlacement": "top",
11591
- "className": "bg-white p-2 rounded text-gray-500"
11592
- };
11593
- }
11566
+
11567
+ // 触发搜索,而不是reload,因为使用search-box可以在amissdk是3.6.3-patch.8+实现快速搜索输入框中过滤条件变更时再点刷新可以自动跳转到第一页面
11568
+ const scope = event.context.scoped;
11569
+ const sb = SteedosUI.getClosestAmisComponentByType(scope, "search-box");
11570
+ sb.handleSearch();
11571
+ `;
11572
+ toolbarReloadButton = {
11573
+ // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页,这在加载更多按钮的翻页模式下会有问题
11574
+ "type": "button",
11575
+ "align": "right",
11576
+ //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
11577
+ // "tooltip": i18next.t('frontend_button_reload_tooltip'),
11578
+ "tooltipPlacement": "top",
11579
+ "className": "bg-white p-2 rounded text-gray-500",
11580
+ "label": "",
11581
+ "icon": "fa fa-sync",
11582
+ // "visibleOn": "${!showFieldsFilter}",
11583
+ "onEvent": {
11584
+ "click": {
11585
+ "actions": [
11586
+ {
11587
+ "actionType": "custom",
11588
+ "script": onReloadScript
11589
+ }
11590
+ ]
11591
+ }
11592
+ },
11593
+ };
11594
+ // if(formFactor === 'SMALL'){
11595
+ // // 后续如果换成加载更多按钮的翻页模式的话,不可以直接使用下面的reload,需要换成上面的自定义脚本模式
11596
+ // toolbarReloadButton = {
11597
+ // "type": "reload",
11598
+ // "align": "right",
11599
+ // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
11600
+ // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
11601
+ // "tooltip":"",
11602
+ // "tooltipPlacement": "top",
11603
+ // "className": "bg-white p-2 rounded text-gray-500"
11604
+ // };
11605
+ // }
11606
+ // else{
11607
+ // toolbarReloadButton = {
11608
+ // "type": "reload",
11609
+ // "align": "right",
11610
+ // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
11611
+ // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
11612
+ // "tooltip":"",
11613
+ // "tooltipPlacement": "top",
11614
+ // "className": "bg-white p-2 rounded text-gray-500"
11615
+ // };
11616
+ // }
11594
11617
  let toolbarFilter;
11595
11618
  if(filterVisible){
11596
11619
  toolbarFilter ={
@@ -14429,6 +14452,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
14429
14452
  }
14430
14453
  }
14431
14454
 
14455
+ // amis@3.6.3和6.3.0如果不配置 trackExpression监听当前字段值变化,那么当前lookup字段(比如T)作为其它lookup字段(比如F)autoFill自动填充的目标字段的话,
14456
+ // F字段值变更后,虽然会自动填充值到T字段中,但是并不会触发T字段的source接口重新请求,这会造成T字段被填充后,可能会显示为字段id而不是label了,见issue:https://github.com/steedos/steedos-platform/issues/6601
14457
+ // amis@6.2.2不需要配置trackExpression不会有#6601所示问题,但是更高版本6.3.0也会有,所以这里只能加上trackExpression避开相关bug。
14458
+ source.trackExpression = `\${${field.name}}`;
14459
+
14432
14460
  source.data.$term = "$term";
14433
14461
  source.data.$self = "$$";
14434
14462
 
@@ -15618,7 +15646,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15618
15646
  if(_$1__namespace.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
15619
15647
  return;
15620
15648
  }
15621
- const baseData = {name: ctx.fieldNamePrefix ? `${ctx.fieldNamePrefix}${field.name}` : field.name, label: field.label, labelRemark: field.inlineHelpText, required: _$1__namespace.has(ctx, 'required') ? ctx.required : field.required};
15649
+ const baseData = {name: ctx.fieldNamePrefix ? `${ctx.fieldNamePrefix}${field.name}` : field.name, label: field.label, labelRemark: field.inlineHelpText, description: field.description, required: _$1__namespace.has(ctx, 'required') ? ctx.required : field.required};
15622
15650
  let convertData = {
15623
15651
  };
15624
15652
  // if(_.includes(OMIT_FIELDS, field.name)){