@steedos-widgets/amis-lib 3.6.11-beta.4 → 3.6.11-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/index.cjs.js CHANGED
@@ -8282,6 +8282,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8282
8282
  }
8283
8283
 
8284
8284
  const onChangeScript = `
8285
+ // console.log("==search=onChangeScript===");
8285
8286
  const scope = event.context.scoped;
8286
8287
  let crud = SteedosUI.getClosestAmisComponentByType(scope, "crud");
8287
8288
  // let crudService = crud && SteedosUI.getClosestAmisComponentByType(crud.context, "service");
@@ -8297,14 +8298,14 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8297
8298
  }
8298
8299
  `;
8299
8300
 
8300
- // onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
8301
+ // 之前onSearchScript中加上了onChangeScript中的脚本,是因为amis 3.2不能用change事件执行onChangeScript
8301
8302
  // 而点击回车按键又不会触发blur事件,所以只能每次回车事件中额外再执行一次onChangeScript
8302
8303
  // 等升级到amis 3.4+,blur事件换成change事件执行onChangeScript,就可以不用在onSearchScript中执行onChangeScript了
8304
+ // 基于amis3.6,已经不再用blur事件触发onChangeScript,所以这里把之前加上的onChangeScript去掉了,如果以后还要换blur来触发onChangeScript脚本的话,这里又要加回onChangeScript脚本
8303
8305
  const onSearchScript = `
8304
- ${onChangeScript}
8305
-
8306
+ // console.log("==search=onSearchScript===");
8306
8307
  // 下面的脚本只为解决点击搜索表单取消按钮,再重新在其中输入过滤条件但是不点击搜索按钮或回车按键触发搜索,此时在快速搜索框输入过滤条件按回车按键会把搜索表单中的过滤条件清空的问题
8307
- // const scope = event.context.scoped;
8308
+ const scope = event.context.scoped;
8308
8309
  // 如果点击过顶部搜索栏表单的取消按钮,会把此处event.data.__super.__super.__super中的搜索表单项的所有字段设置为null
8309
8310
  // 点击取消按钮后继续在表单项中输入过滤条件且最后没有点击回车按键或点击表单项搜索按钮的话,在快速搜索中点击回车按钮提交搜索会所顶部搜索表单中的字段值清空
8310
8311
  let isLookup = event.data.isLookup;
@@ -8323,6 +8324,14 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8323
8324
  }, 500);
8324
8325
  `;
8325
8326
 
8327
+ const onBlurScript = `
8328
+ // console.log("==search=onBlurScript===");
8329
+ // 失去焦点事件触发搜索
8330
+ const scope = event.context.scoped;
8331
+ const sb = SteedosUI.getClosestAmisComponentByType(scope, "search-box");
8332
+ sb.handleSearch();
8333
+ `;
8334
+
8326
8335
  return {
8327
8336
  "type": "tooltip-wrapper",
8328
8337
  "id": "steedos_crud_toolbar_quick_search",
@@ -8340,7 +8349,7 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8340
8349
  "name": keywordsSearchBoxName,
8341
8350
  "placeholder": "快捷搜索",
8342
8351
  "value": crudKeywords,
8343
- // "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
8352
+ "clearable": true,//因为清除并不会触发失去焦点事件,只有禁用,但是它会触发change事件,所以等升级到amis 3.4+后可以重新放开
8344
8353
  "clearAndSubmit": true,
8345
8354
  "searchImediately": false,
8346
8355
  "onEvent": {
@@ -8352,13 +8361,21 @@ function getObjectHeaderQuickSearchBox(mainObject, fields, formFactor, { isLooku
8352
8361
  }
8353
8362
  ]
8354
8363
  },
8355
- "blur": { //这里把change事件换成blur是因为amis 3.2change事件中setData会卡,升级到3.4+后就可以换回change事件
8364
+ "change": { //amis 3.2change事件中setData会卡,升级到amis 3.4+应该不会再卡了,所以这里换回change事件,如果还是会卡就要考虑重新换成blur事件
8356
8365
  "actions": [
8357
8366
  {
8358
8367
  "actionType": "custom",
8359
8368
  "script": onChangeScript
8360
8369
  },
8361
8370
  ]
8371
+ },
8372
+ "blur": {
8373
+ "actions": [
8374
+ {
8375
+ "actionType": "custom",
8376
+ "script": onBlurScript
8377
+ },
8378
+ ]
8362
8379
  }
8363
8380
  }
8364
8381
  }
@@ -8384,59 +8401,67 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8384
8401
  };
8385
8402
  }
8386
8403
  let toolbarReloadButton;
8387
- if(formFactor === 'SMALL'){
8388
- // const onReloadScript = `
8389
- // const scope = event.context.scoped;
8390
- // var listView = scope.parent.getComponents().find(function(n){
8391
- // return n.props.type === "crud";
8392
- // });
8393
- // listView.handleChangePage(1);
8394
- // `;
8395
- // toolbarReloadButton = {
8396
- // // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页,这在加载更多按钮的翻页模式下会有问题
8397
- // "type": "button",
8398
- // "align": "right",
8399
- // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8400
- // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8401
- // "tooltipPlacement": "top",
8402
- // "className": "bg-white p-2 rounded text-gray-500",
8403
- // "label": "",
8404
- // "icon": "fa fa-sync",
8405
- // "visibleOn": "${!showFieldsFilter}",
8406
- // "onEvent": {
8407
- // "click": {
8408
- // "actions": [
8409
- // {
8410
- // "actionType": "custom",
8411
- // "script": onReloadScript
8412
- // }
8413
- // ]
8414
- // }
8415
- // },
8416
- // };
8404
+ const onReloadScript = `
8405
+ // const scope = event.context.scoped;
8406
+ // var listView = scope.parent.getComponents().find(function(n){
8407
+ // return n.props.type === "crud";
8408
+ // });
8409
+ // listView.handleChangePage(1);
8417
8410
 
8418
- // 后续如果换成加载更多按钮的翻页模式的话,不可以直接使用下面的reload,需要换成上面的自定义脚本模式
8419
- toolbarReloadButton = {
8420
- "type": "reload",
8421
- "align": "right",
8422
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8423
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8424
- "tooltip":"",
8425
- "tooltipPlacement": "top",
8426
- "className": "bg-white p-2 rounded text-gray-500"
8427
- };
8428
- }
8429
- else {
8430
- toolbarReloadButton = {
8431
- "type": "reload",
8432
- "align": "right",
8433
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8434
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8435
- "tooltip":"",
8436
- "tooltipPlacement": "top",
8437
- "className": "bg-white p-2 rounded text-gray-500"
8438
- };
8439
- }
8411
+
8412
+ // 触发搜索,而不是reload,因为快速搜索输入框失去焦点已经会触发搜索了,这里用reload的话,会有bug
8413
+ // 不加setTimeout的话,快速搜索输入框失去焦点再触发此脚本还是有问题
8414
+ setTimeout(function(){
8415
+ const scope = event.context.scoped;
8416
+ const sb = SteedosUI.getClosestAmisComponentByType(scope, "search-box");
8417
+ sb.handleSearch();
8418
+ }, 500);
8419
+ `;
8420
+ toolbarReloadButton = {
8421
+ // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页,这在加载更多按钮的翻页模式下会有问题
8422
+ "type": "button",
8423
+ "align": "right",
8424
+ //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8425
+ // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8426
+ "tooltipPlacement": "top",
8427
+ "className": "bg-white p-2 rounded text-gray-500",
8428
+ "label": "",
8429
+ "icon": "fa fa-sync",
8430
+ // "visibleOn": "${!showFieldsFilter}",
8431
+ "onEvent": {
8432
+ "click": {
8433
+ "actions": [
8434
+ {
8435
+ "actionType": "custom",
8436
+ "script": onReloadScript
8437
+ }
8438
+ ]
8439
+ }
8440
+ },
8441
+ };
8442
+ // if(formFactor === 'SMALL'){
8443
+ // // 后续如果换成加载更多按钮的翻页模式的话,不可以直接使用下面的reload,需要换成上面的自定义脚本模式
8444
+ // toolbarReloadButton = {
8445
+ // "type": "reload",
8446
+ // "align": "right",
8447
+ // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8448
+ // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8449
+ // "tooltip":"",
8450
+ // "tooltipPlacement": "top",
8451
+ // "className": "bg-white p-2 rounded text-gray-500"
8452
+ // };
8453
+ // }
8454
+ // else{
8455
+ // toolbarReloadButton = {
8456
+ // "type": "reload",
8457
+ // "align": "right",
8458
+ // //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
8459
+ // // "tooltip": i18next.t('frontend_button_reload_tooltip'),
8460
+ // "tooltip":"",
8461
+ // "tooltipPlacement": "top",
8462
+ // "className": "bg-white p-2 rounded text-gray-500"
8463
+ // };
8464
+ // }
8440
8465
  let toolbarFilter;
8441
8466
  if(filterVisible){
8442
8467
  toolbarFilter ={
@@ -11275,6 +11300,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
11275
11300
  }
11276
11301
  }
11277
11302
 
11303
+ // amis@3.6.3和6.3.0如果不配置 trackExpression监听当前字段值变化,那么当前lookup字段(比如T)作为其它lookup字段(比如F)autoFill自动填充的目标字段的话,
11304
+ // F字段值变更后,虽然会自动填充值到T字段中,但是并不会触发T字段的source接口重新请求,这会造成T字段被填充后,可能会显示为字段id而不是label了,见issue:https://github.com/steedos/steedos-platform/issues/6601
11305
+ // amis@6.2.2不需要配置trackExpression不会有#6601所示问题,但是更高版本6.3.0也会有,所以这里只能加上trackExpression避开相关bug。
11306
+ source.trackExpression = `\${${field.name}}`;
11307
+
11278
11308
  source.data.$term = "$term";
11279
11309
  source.data.$self = "$$";
11280
11310
 
@@ -12163,8 +12193,8 @@ if(typeof window != 'undefined'){
12163
12193
  /*
12164
12194
  * @Author: baozhoutao@steedos.com
12165
12195
  * @Date: 2023-01-13 17:27:54
12166
- * @LastEditors: liaodaxue
12167
- * @LastEditTime: 2024-02-04 17:29:54
12196
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12197
+ * @LastEditTime: 2024-04-11 14:14:43
12168
12198
  * @Description:
12169
12199
  */
12170
12200
 
@@ -12240,12 +12270,12 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
12240
12270
  "receiver": "${context.rootUrl}/s3/images",
12241
12271
  "name": field.name,
12242
12272
  "options": {
12243
- "menu": {
12244
- "insert": {
12245
- "title": "Insert",
12246
- "items": "image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"
12247
- }
12248
- },
12273
+ // "menu": {
12274
+ // "insert": {
12275
+ // "title": "Insert",
12276
+ // "items": "image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"
12277
+ // }
12278
+ // },
12249
12279
  "plugins": [
12250
12280
  "autoresize"
12251
12281
  ],
@@ -12261,13 +12291,14 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
12261
12291
  "type": "input-rich-text",
12262
12292
  "receiver": "${context.rootUrl}/s3/images",
12263
12293
  "options":{
12264
- "menu": {
12265
- "insert": {
12266
- "title": "Insert",
12267
- "items": "image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"
12268
- }
12269
- },
12270
- "statusbar": false
12294
+ // "menu": {
12295
+ // "insert": {
12296
+ // "title": "Insert",
12297
+ // "items": "image link media addcomment pageembed codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"
12298
+ // }
12299
+ // },
12300
+ "statusbar": false,
12301
+ "menubar": false
12271
12302
  },
12272
12303
  "name": field.name
12273
12304
  }
@@ -12463,7 +12494,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12463
12494
  if(___namespace.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
12464
12495
  return;
12465
12496
  }
12466
- const baseData = {name: ctx.fieldNamePrefix ? `${ctx.fieldNamePrefix}${field.name}` : field.name, label: field.label, labelRemark: field.inlineHelpText, required: ___namespace.has(ctx, 'required') ? ctx.required : field.required};
12497
+ const baseData = {name: ctx.fieldNamePrefix ? `${ctx.fieldNamePrefix}${field.name}` : field.name, label: field.label, labelRemark: field.inlineHelpText, description: field.description, required: ___namespace.has(ctx, 'required') ? ctx.required : field.required};
12467
12498
  let convertData = {
12468
12499
  };
12469
12500
  // if(_.includes(OMIT_FIELDS, field.name)){