@steedos-widgets/amis-lib 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.
package/dist/index.esm.js CHANGED
@@ -8255,6 +8255,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8255
8255
  }
8256
8256
 
8257
8257
  const onChangeScript = `
8258
+ // console.log("==search=onChangeScript===");
8258
8259
  const scope = event.context.scoped;
8259
8260
  let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
8260
8261
  // let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
@@ -8270,14 +8271,13 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8270
8271
  }
8271
8272
  `;
8272
8273
 
8273
- // onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
8274
+ // 之前onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
8274
8275
  // 而点击回车按键又不会触发blur事件,所以只能每次回车事件中额外再执行一次onChangeScript
8275
8276
  // 等升级到amis 3.4+,blur事件换成change事件执行onChangeScript,就可以不用在onSearchScript中执行onChangeScript了
8277
+ // 基于amis3.6,已经不再用blur事件触发onChangeScript,所以这里把之前加上的onChangeScript去掉了,如果以后还要换blur来触发onChangeScript脚本的话,这里又要加回onChangeScript脚本
8276
8278
  const onSearchScript = `
8277
- ${onChangeScript}
8278
-
8279
8279
  // 下面的脚本只为解决点击搜索表单取消按钮,再重新在其中输入过滤条件但是不点击搜索按钮或回车按键触发搜索,此时在快速搜索框输入过滤条件按回车按键会把搜索表单中的过滤条件清空的问题
8280
- // const scope = event.context.scoped;
8280
+ const scope = event.context.scoped;
8281
8281
  // 如果点击过顶部搜索栏表单的取消按钮,会把此处event.data.__super.__super.__super中的搜索表单项的所有字段设置为null
8282
8282
  // 点击取消按钮后继续在表单项中输入过滤条件且最后没有点击回车按键或点击表单项搜索按钮的话,在快速搜索中点击回车按钮提交搜索会所顶部搜索表单中的字段值清空
8283
8283
  let isLookup = event.data.isLookup;
@@ -8296,6 +8296,16 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8296
8296
  }, 500);
8297
8297
  `;
8298
8298
 
8299
+ // const onBlurScript = `
8300
+ // // 失去焦点事件触发搜索,先去掉,因为会有bug,见:[Bug]: 列表上快速搜索输入框输入内容后点击放大镜界面上列表未显示过滤后的内容 #6742
8301
+ // const value = event.data.value;
8302
+ // setTimeout(function(){
8303
+ // const scope = event.context.scoped;
8304
+ // const sb = SteedosUI.getClosestAmisComponentByType(scope, "search-box");
8305
+ // sb.handleSearch(value);
8306
+ // }, 500);
8307
+ // `;
8308
+
8299
8309
  return {
8300
8310
  "type": "tooltip-wrapper",
8301
8311
  "id": "steedos_crud_toolbar_quick_search",
@@ -8313,7 +8323,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8313
8323
  "name": keywordsSearchBoxName,
8314
8324
  "placeholder": "快捷搜索",
8315
8325
  "value": crudKeywords,
8316
- // "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
8326
+ "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
8317
8327
  "clearAndSubmit": true,
8318
8328
  "searchImediately": false,
8319
8329
  "onEvent": {
@@ -8325,14 +8335,22 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8325
8335
  }
8326
8336
  ]
8327
8337
  },
8328
- "blur": { //这里把change事件换成blur是因为amis 3.2change事件中setData会卡,升级到3.4+后就可以换回change事件
8338
+ "change": { //amis 3.2change事件中setData会卡,升级到amis 3.4+应该不会再卡了,所以这里换回change事件,如果还是会卡就要考虑重新换成blur事件
8329
8339
  "actions": [
8330
8340
  {
8331
8341
  "actionType": "custom",
8332
8342
  "script": onChangeScript
8333
8343
  },
8334
8344
  ]
8335
- }
8345
+ },
8346
+ // "blur": {
8347
+ // "actions": [
8348
+ // {
8349
+ // "actionType": "custom",
8350
+ // "script": onBlurScript
8351
+ // },
8352
+ // ]
8353
+ // }
8336
8354
  }
8337
8355
  }
8338
8356
  ]
@@ -8357,59 +8375,64 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8357
8375
  };
8358
8376
  }
8359
8377
  let toolbarReloadButton;
8360
- if(formFactor === 'SMALL'){
8361
- // const onReloadScript = `
8362
- // const scope = event.context.scoped;
8363
- // var listView = scope.parent.getComponents().find(function(n){
8364
- // return n.props.type === "crud";
8365
- // });
8366
- // listView.handleChangePage(1);
8367
- // `;
8368
- // toolbarReloadButton = {
8369
- // // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页,这在加载更多按钮的翻页模式下会有问题
8370
- // "type": "button",
8371
- // "align": "right",
8372
- // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8373
- // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8374
- // "tooltipPlacement": "top",
8375
- // "className": "bg-white p-2 rounded text-gray-500",
8376
- // "label": "",
8377
- // "icon": "fa fa-sync",
8378
- // "visibleOn": "${!showFieldsFilter}",
8379
- // "onEvent": {
8380
- // "click": {
8381
- // "actions": [
8382
- // {
8383
- // "actionType": "custom",
8384
- // "script": onReloadScript
8385
- // }
8386
- // ]
8387
- // }
8388
- // },
8389
- // };
8378
+ const onReloadScript = `
8379
+ // const scope = event.context.scoped;
8380
+ // var listView = scope.parent.getComponents().find(function(n){
8381
+ // return n.props.type === "crud";
8382
+ // });
8383
+ // listView.handleChangePage(1);
8390
8384
 
8391
- // 后续如果换成加载更多按钮的翻页模式的话,不可以直接使用下面的reload,需要换成上面的自定义脚本模式
8392
- toolbarReloadButton = {
8393
- "type": "reload",
8394
- "align": "right",
8395
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8396
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8397
- "tooltip":"",
8398
- "tooltipPlacement": "top",
8399
- "className": "bg-white p-2 rounded text-gray-500"
8400
- };
8401
- }
8402
- else {
8403
- toolbarReloadButton = {
8404
- "type": "reload",
8405
- "align": "right",
8406
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8407
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8408
- "tooltip":"",
8409
- "tooltipPlacement": "top",
8410
- "className": "bg-white p-2 rounded text-gray-500"
8411
- };
8412
- }
8385
+
8386
+ // 触发搜索,而不是reload,因为使用search-box可以在amissdk是3.6.3-patch.8+实现快速搜索输入框中过滤条件变更时再点刷新可以自动跳转到第一页面
8387
+ const scope = event.context.scoped;
8388
+ const sb = SteedosUI.getClosestAmisComponentByType(scope, "search-box");
8389
+ sb.handleSearch();
8390
+ `;
8391
+ toolbarReloadButton = {
8392
+ // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页,这在加载更多按钮的翻页模式下会有问题
8393
+ "type": "button",
8394
+ "align": "right",
8395
+ //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8396
+ // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8397
+ "tooltipPlacement": "top",
8398
+ "className": "bg-white p-2 rounded text-gray-500",
8399
+ "label": "",
8400
+ "icon": "fa fa-sync",
8401
+ // "visibleOn": "${!showFieldsFilter}",
8402
+ "onEvent": {
8403
+ "click": {
8404
+ "actions": [
8405
+ {
8406
+ "actionType": "custom",
8407
+ "script": onReloadScript
8408
+ }
8409
+ ]
8410
+ }
8411
+ },
8412
+ };
8413
+ // if(formFactor === 'SMALL'){
8414
+ // // 后续如果换成加载更多按钮的翻页模式的话,不可以直接使用下面的reload,需要换成上面的自定义脚本模式
8415
+ // toolbarReloadButton = {
8416
+ // "type": "reload",
8417
+ // "align": "right",
8418
+ // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8419
+ // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8420
+ // "tooltip":"",
8421
+ // "tooltipPlacement": "top",
8422
+ // "className": "bg-white p-2 rounded text-gray-500"
8423
+ // };
8424
+ // }
8425
+ // else{
8426
+ // toolbarReloadButton = {
8427
+ // "type": "reload",
8428
+ // "align": "right",
8429
+ // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8430
+ // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8431
+ // "tooltip":"",
8432
+ // "tooltipPlacement": "top",
8433
+ // "className": "bg-white p-2 rounded text-gray-500"
8434
+ // };
8435
+ // }
8413
8436
  let toolbarFilter;
8414
8437
  if(filterVisible){
8415
8438
  toolbarFilter ={
@@ -11248,6 +11271,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
11248
11271
  }
11249
11272
  }
11250
11273
 
11274
+ // amis@3.6.3和6.3.0如果不配置 trackExpression监听当前字段值变化,那么当前lookup字段(比如T)作为其它lookup字段(比如F)autoFill自动填充的目标字段的话,
11275
+ // F字段值变更后,虽然会自动填充值到T字段中,但是并不会触发T字段的source接口重新请求,这会造成T字段被填充后,可能会显示为字段id而不是label了,见issue:https://github.com/steedos/steedos-platform/issues/6601
11276
+ // amis@6.2.2不需要配置trackExpression不会有#6601所示问题,但是更高版本6.3.0也会有,所以这里只能加上trackExpression避开相关bug。
11277
+ source.trackExpression = `\${${field.name}}`;
11278
+
11251
11279
  source.data.$term = "$term";
11252
11280
  source.data.$self = "$$";
11253
11281
 
@@ -12437,7 +12465,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12437
12465
  if(_$1.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
12438
12466
  return;
12439
12467
  }
12440
- const baseData = {name: ctx.fieldNamePrefix ? `${ctx.fieldNamePrefix}${field.name}` : field.name, label: field.label, labelRemark: field.inlineHelpText, required: _$1.has(ctx, 'required') ? ctx.required : field.required};
12468
+ const baseData = {name: ctx.fieldNamePrefix ? `${ctx.fieldNamePrefix}${field.name}` : field.name, label: field.label, labelRemark: field.inlineHelpText, description: field.description, required: _$1.has(ctx, 'required') ? ctx.required : field.required};
12441
12469
  let convertData = {
12442
12470
  };
12443
12471
  // if(_.includes(OMIT_FIELDS, field.name)){