@steedos-widgets/amis-lib 1.2.35-beta.2 → 1.2.36

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.umd.js CHANGED
@@ -423,8 +423,8 @@
423
423
  /*
424
424
  * @Author: baozhoutao@steedos.com
425
425
  * @Date: 2022-05-23 09:53:08
426
- * @LastEditors: liaodaxue
427
- * @LastEditTime: 2023-07-28 16:26:31
426
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
427
+ * @LastEditTime: 2023-08-03 18:07:54
428
428
  * @Description:
429
429
  */
430
430
 
@@ -506,7 +506,11 @@
506
506
 
507
507
  function getNameTpl(field, ctx){
508
508
  const href = getNameTplUrl(field, ctx);
509
- return `<a href="${href}">\${${field.name}}</a>`
509
+ let linkTarget = "";
510
+ if(ctx && ctx.isLookup){
511
+ linkTarget = "target='_blank'";
512
+ }
513
+ return `<a href="${href}" ${linkTarget}>\${${field.name}}</a>`
510
514
  }
511
515
 
512
516
  function getRelatedFieldTpl(field, ctx){
@@ -519,6 +523,11 @@
519
523
  }
520
524
  }
521
525
 
526
+ let linkTarget = "";
527
+ if(ctx && ctx.isLookup){
528
+ linkTarget = "target='_blank'";
529
+ }
530
+
522
531
  const onlyDisplayLabel = ctx.onlyDisplayLabel;
523
532
 
524
533
  let fieldDataStrTpl = `data._display.${field.name}`;
@@ -534,7 +543,7 @@
534
543
  const href = Router.getObjectDetailPath({
535
544
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
536
545
  });
537
- labelTpl = `<a href="${href}"><%=item.label%></a>`;
546
+ labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
538
547
  }
539
548
  tpl = `
540
549
  <% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item,index) { %> <% if(index>0 && index<${fieldDataStrTpl}.length){ %> , <% } %> ${labelTpl} <% }); %><% } %>
@@ -552,7 +561,7 @@
552
561
  const href = Router.getObjectDetailPath({
553
562
  formFactor: ctx.formFactor, appId: "${appId}", objectName: `${objectNameTpl}`, recordId: `${recordIdTpl}`
554
563
  });
555
- labelTpl = `<a href="${href}">${labelTpl}</a>`;
564
+ labelTpl = `<a href="${href}" ${linkTarget}>${labelTpl}</a>`;
556
565
  }
557
566
  tpl = labelTpl;
558
567
  }
@@ -564,7 +573,7 @@
564
573
  const href = Router.getObjectDetailPath({
565
574
  formFactor: ctx.formFactor, appId: "<%=data.appId%>", objectName: `<%=item.objectName%>`, recordId: `<%=item.value%>`, _templateType: "JavaScript"
566
575
  });
567
- labelTpl = `<a href="${href}"><%=item.label%></a>`;
576
+ labelTpl = `<a href="${href}" ${linkTarget}><%=item.label%></a>`;
568
577
  }
569
578
  tpl = `
570
579
  <% if (${fieldDataStrTpl} && ${fieldDataStrTpl}.length) { %><% ${fieldDataStrTpl}.forEach(function(item) { %> ${labelTpl} <% }); %><% } %>
@@ -3275,12 +3284,6 @@
3275
3284
  if (
3276
3285
  field && window.isFieldTypeSearchable(field.type)
3277
3286
  ) {
3278
- delete field.defaultValue;
3279
- delete field.required;
3280
- delete field.is_wide;
3281
- delete field.readonly;
3282
- delete field.hidden;
3283
- delete field.omit;
3284
3287
  var ctx = ${JSON.stringify(ctx)};
3285
3288
  const amisField = window.getFieldSearchable(field, fields, ctx);
3286
3289
  return amisField;
@@ -3376,7 +3379,7 @@
3376
3379
  if(!event.data.isLookup){
3377
3380
  // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
3378
3381
  const listViewId = event.data.listViewId;
3379
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
3382
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
3380
3383
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3381
3384
  if(localListViewProps){
3382
3385
  localListViewProps = JSON.parse(localListViewProps);
@@ -3408,7 +3411,7 @@
3408
3411
  searchableFieldsStoreKey += "lookup/" + objectName;
3409
3412
  }
3410
3413
  else{
3411
- searchableFieldsStoreKey += listViewId;
3414
+ searchableFieldsStoreKey += (listViewId || "");
3412
3415
  }
3413
3416
  let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
3414
3417
  if(defaultSearchableFields){
@@ -3435,7 +3438,7 @@
3435
3438
  setData({ showFieldsFilter: false });
3436
3439
  }
3437
3440
  else{
3438
- const listViewPropsStoreKey = location.pathname + "/crud/" + data.listViewId ;
3441
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (data.listViewId || "");
3439
3442
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3440
3443
  if(localListViewProps){
3441
3444
  localListViewProps = JSON.parse(localListViewProps);
@@ -3481,7 +3484,7 @@
3481
3484
  searchableFieldsStoreKey += "lookup/" + objectName;
3482
3485
  }
3483
3486
  else{
3484
- searchableFieldsStoreKey += listViewId;
3487
+ searchableFieldsStoreKey += (listViewId || "");
3485
3488
  }
3486
3489
  sessionStorage.setItem(searchableFieldsStoreKey, value);
3487
3490
 
@@ -3539,7 +3542,7 @@
3539
3542
  }
3540
3543
 
3541
3544
  // 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
3542
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
3545
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
3543
3546
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3544
3547
  if(localListViewProps){
3545
3548
  localListViewProps = JSON.parse(localListViewProps);
@@ -3658,7 +3661,8 @@
3658
3661
  const fields = uiSchema.fields;
3659
3662
  const options = (payload.data?.options || []).filter(function(item){
3660
3663
  let field = fields[item.value];
3661
- return !!field && window.isFieldTypeSearchable(field.type)
3664
+ // TODO: 暂时禁用location类型字段的列表搜索
3665
+ return !!field && window.isFieldTypeSearchable(field.type) && field.type !== 'location'
3662
3666
  });
3663
3667
  payload.data = {
3664
3668
  "options": options
@@ -5261,6 +5265,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5261
5265
 
5262
5266
  function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
5263
5267
  // console.log(`getObjectHeaderToolbar====>`, filterVisible)
5268
+ console.log(`getObjectHeaderToolbar`, mainObject);
5264
5269
  const isMobile = window.innerWidth < 768;
5265
5270
  if(isMobile){
5266
5271
  showDisplayAs = false;
@@ -5360,7 +5365,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5360
5365
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5361
5366
  },
5362
5367
  // getExportExcelToolbarButtonSchema(),
5363
- getSettingListviewToolbarButtonSchema(),
5368
+ mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
5364
5369
  getDisplayAsButton(mainObject?.name),
5365
5370
  filterVisible ? {
5366
5371
  "label": i18next__default["default"].t('frontend_button_search_tooltip'),
@@ -5756,6 +5761,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5756
5761
  return ;
5757
5762
  }
5758
5763
  const refObjectConfig = await getUISchema(referenceTo.objectName);
5764
+
5765
+ ctx.idFieldName = refObjectConfig.idFieldName;
5766
+ ctx.objectName = refObjectConfig.name;
5767
+
5759
5768
  const tableFields = [];
5760
5769
  let i = 0;
5761
5770
  const searchableFields = [];
@@ -6123,7 +6132,6 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
6123
6132
  if(readonly){
6124
6133
  data.tpl = await getLookupTpl(field, ctx);
6125
6134
  }
6126
-
6127
6135
  return data;
6128
6136
  }
6129
6137
 
@@ -7200,12 +7208,35 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7200
7208
  }
7201
7209
  }
7202
7210
 
7211
+ const coordinatesType = field.coordinatesType || "bd09";
7203
7212
  convertData = {
7204
7213
  type: getAmisStaticFieldType('location', readonly),
7205
7214
  tpl: readonly ? getLocationTpl(field) : null,
7206
7215
  ak,
7207
7216
  vendor,
7208
- label: field.label
7217
+ clearable: true,
7218
+ coordinatesType,
7219
+ label: field.label,
7220
+ pipeOut: (value, oldValue, data) => {
7221
+ if (value) {
7222
+ const lng = value.lng;
7223
+ const lat = value.lat;
7224
+ let coordinates = [lng,lat];
7225
+ if(window.coordtransform){
7226
+ if(coordinatesType.toLowerCase() === 'bd09'){
7227
+ const bd09togcj02 = window.coordtransform.bd09togcj02(lng,lat);
7228
+ coordinates = window.coordtransform.gcj02towgs84(bd09togcj02[0],bd09togcj02[1]);
7229
+ }else if(coordinatesType.toLowerCase() === 'gcj02'){
7230
+ coordinates = window.coordtransform.gcj02towgs84(lng,lat);
7231
+ }
7232
+ }
7233
+ value.wgs84 = {
7234
+ type: "Point",
7235
+ coordinates
7236
+ };
7237
+ return value; // 切换到数字之后的默认值
7238
+ }
7239
+ }
7209
7240
  };
7210
7241
  break;
7211
7242
  case 'avatar':
@@ -7430,6 +7461,24 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7430
7461
  _field.multiple = true;
7431
7462
  _field.is_wide = false;
7432
7463
  _field.defaultValue = undefined;
7464
+ _field.required = false;
7465
+ _field.hidden = false;
7466
+ _field.omit = false;
7467
+
7468
+ if(_field.amis){
7469
+ delete _field.amis.static;
7470
+ delete _field.amis.staticOn;
7471
+ delete _field.amis.disabled;
7472
+ delete _field.amis.disabledOn;
7473
+ delete _field.amis.required;
7474
+ delete _field.amis.requiredOn;
7475
+ delete _field.amis.visible;
7476
+ delete _field.amis.visibleOn;
7477
+ delete _field.amis.hidden;
7478
+ delete _field.amis.hiddenOn;
7479
+ delete _field.amis.autoFill;
7480
+ }
7481
+
7433
7482
  const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));
7434
7483
  if(amisField){
7435
7484
  return amisField;
@@ -7673,6 +7722,10 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7673
7722
  if(field.type == "file" && field.multiple){
7674
7723
  quickEditSchema = false;
7675
7724
  }
7725
+ //TODO:location字段在列表中快速编辑后存在bug,保存时可能会丢失部分数据,暂时禁用
7726
+ if(field.type == "location"){
7727
+ quickEditSchema = false;
7728
+ }
7676
7729
  }
7677
7730
  return quickEditSchema;
7678
7731
  }
@@ -7703,6 +7756,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7703
7756
  if(field.wrap != true){
7704
7757
  className += " whitespace-nowrap";
7705
7758
  }
7759
+ let columnItem;
7706
7760
  if((field.is_name || field.name === options.labelFieldName) && options.objectName === 'cms_files'){
7707
7761
  const previewFileScript = `
7708
7762
  var data = event.data;
@@ -7710,12 +7764,11 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7710
7764
  var file_id = data._id;
7711
7765
  SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
7712
7766
  `;
7713
- columns.push({
7767
+ columnItem = {
7714
7768
  "type": "button",
7715
7769
  "label": `<%=data.versions ? data.name : "${field.label}"%>`,
7716
7770
  className,
7717
7771
  "level": "link",
7718
- "quickEdit": quickEditSchema,
7719
7772
  "onEvent": {
7720
7773
  "click": {
7721
7774
  "actions": [
@@ -7741,9 +7794,9 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7741
7794
  ]
7742
7795
  }
7743
7796
  }
7744
- });
7797
+ };
7745
7798
  }else if(field.type === 'toggle'){
7746
- columns.push(Object.assign({}, {
7799
+ columnItem = Object.assign({}, {
7747
7800
  type: "switch",
7748
7801
  name: field.name,
7749
7802
  label: field.label,
@@ -7751,24 +7804,22 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7751
7804
  toggled: field.toggled,
7752
7805
  static: true,
7753
7806
  className,
7754
- quickEdit: quickEditSchema
7755
- }, field.amis, {name: field.name}));
7807
+ }, field.amis, {name: field.name});
7756
7808
  }else if(field.type === 'avatar' || field.type === 'image' || field.type === 'file'){
7757
- columns.push(Object.assign({}, {
7809
+ columnItem = Object.assign({}, {
7758
7810
  type: "switch",
7759
7811
  name: field.name,
7760
7812
  label: field.label,
7761
7813
  width: getFieldWidth(field.width),
7762
7814
  toggled: field.toggled,
7763
- quickEdit: quickEditSchema,
7764
7815
  static: true,
7765
7816
  className,
7766
7817
  ...getAmisFileReadonlySchema(field)
7767
- }, field.amis, {name: field.name}));
7818
+ }, field.amis, {name: field.name});
7768
7819
  }
7769
7820
  else if(field.type === 'select'){
7770
7821
  const map = getSelectMap(field.options);
7771
- columns.push(Object.assign({}, {
7822
+ columnItem = Object.assign({}, {
7772
7823
  type: "mapping",
7773
7824
  name: field.name,
7774
7825
  label: field.label,
@@ -7778,8 +7829,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7778
7829
  toggled: field.toggled,
7779
7830
  className,
7780
7831
  static: true,
7781
- quickEdit: quickEditSchema
7782
- }, field.amis, {name: field.name}));
7832
+ }, field.amis, {name: field.name});
7783
7833
  }
7784
7834
  else {
7785
7835
  const tpl = await getFieldTpl(field, options);
@@ -7799,7 +7849,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7799
7849
  className += 'min-w-56';
7800
7850
  }
7801
7851
  if(!field.hidden && !field.extra){
7802
- columns.push(Object.assign({}, {
7852
+ columnItem = Object.assign({}, {
7803
7853
  name: field.name,
7804
7854
  label: field.label,
7805
7855
  sortable: field.sortable,
@@ -7810,13 +7860,18 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7810
7860
  toggled: field.toggled,
7811
7861
  className,
7812
7862
  static: true,
7813
- quickEdit: quickEditSchema,
7814
7863
  options: field.type === 'html' ? {html: true} : null
7815
7864
  // toggled: true
7816
- }, field.amis, {name: field.name}));
7865
+ }, field.amis, {name: field.name});
7817
7866
  }
7818
7867
  }
7819
-
7868
+ if(columnItem){
7869
+ if(quickEditSchema){
7870
+ columnItem.quickEdit = quickEditSchema;
7871
+ columnItem.quickEditEnabledOn = "${is_system !== true}";
7872
+ }
7873
+ columns.push(columnItem);
7874
+ }
7820
7875
  }
7821
7876
  // columns.push(getOperation(fields));
7822
7877
  if(!___namespace.some(columns, { name: options.labelFieldName })){
@@ -8122,6 +8177,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8122
8177
  }
8123
8178
 
8124
8179
  async function getTableSchema$1(fields, options){
8180
+ let isLookup = options && options.isLookup;
8125
8181
  if(!options){
8126
8182
  options = {};
8127
8183
  }
@@ -8131,7 +8187,9 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8131
8187
  }
8132
8188
  else {
8133
8189
  columns = await getTableColumns(fields, options);
8134
- columns.push(await getTableOperation(options));
8190
+ if(!isLookup){
8191
+ columns.push(await getTableOperation(options));
8192
+ }
8135
8193
  }
8136
8194
  return {
8137
8195
  mode: "table",
@@ -8227,7 +8285,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8227
8285
  try{
8228
8286
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8229
8287
  const listViewId = api.data.listViewId;
8230
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
8288
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
8231
8289
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
8232
8290
  if(localListViewProps){
8233
8291
  localListViewProps = JSON.parse(localListViewProps);
@@ -8428,7 +8486,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8428
8486
  try{
8429
8487
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8430
8488
  const listViewId = api.body.listViewId;
8431
- const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
8489
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (listViewId || "");
8432
8490
  /**
8433
8491
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
8434
8492
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -10396,8 +10454,8 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
10396
10454
  /*
10397
10455
  * @Author: baozhoutao@steedos.com
10398
10456
  * @Date: 2022-07-05 15:55:39
10399
- * @LastEditors: baozhoutao@steedos.com
10400
- * @LastEditTime: 2023-07-29 13:58:07
10457
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10458
+ * @LastEditTime: 2023-08-01 14:50:23
10401
10459
  * @Description:
10402
10460
  */
10403
10461
 
@@ -10662,7 +10720,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
10662
10720
  * 本次存储代码段
10663
10721
  */
10664
10722
  try {
10665
- const listViewPropsStoreKey = location.pathname + "/crud/" + ctx.listViewId;
10723
+ const listViewPropsStoreKey = location.pathname + "/crud/" + (ctx.listViewId || "");
10666
10724
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10667
10725
  /**
10668
10726
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。