@steedos-widgets/amis-object 6.3.11-beta.7 → 6.3.11-beta.8

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.
@@ -3594,18 +3594,24 @@ const Router$1 = {
3594
3594
  /*
3595
3595
  * @Author: baozhoutao@steedos.com
3596
3596
  * @Date: 2022-07-20 16:29:22
3597
- * @LastEditors: liaodaxue
3598
- * @LastEditTime: 2024-01-25 14:44:17
3597
+ * @LastEditors: baozhoutao@steedos.com
3598
+ * @LastEditTime: 2024-10-14 13:33:27
3599
3599
  * @Description:
3600
3600
  */
3601
3601
 
3602
- function getImageFieldUrl(url) {
3603
- if (window.Meteor && window.Meteor.isCordova != true) {
3604
- // '//'的位置
3605
- const doubleSlashIndex = url.indexOf('//');
3606
- const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
3607
- const rootUrl = url.substring(urlIndex);
3608
- return rootUrl;
3602
+ function getImageFieldUrl(url, readonly) {
3603
+ if (window.Meteor) {
3604
+ if(window.Meteor.isCordova != true){
3605
+ // '//'的位置
3606
+ const doubleSlashIndex = url.indexOf('//');
3607
+ const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
3608
+ const rootUrl = url.substring(urlIndex);
3609
+ return rootUrl;
3610
+ }else {
3611
+ if(readonly || url.startsWith('http')){
3612
+ return `${url}?token=${window.btoa(JSON.stringify({ authToken : Builder.settings.context.authToken }))}`
3613
+ }
3614
+ }
3609
3615
  }
3610
3616
  return url;
3611
3617
  }
@@ -4112,12 +4118,12 @@ function getScriptForRemoveUrlPrefixForImgFields(fields){
4112
4118
  if(imgFieldValue instanceof Array){
4113
4119
  formData[item] = imgFieldValue.map((value)=>{
4114
4120
  let itemValue = value && value.split('/');
4115
- return itemValue[itemValue.length - 1];
4121
+ return itemValue[itemValue.length - 1].split('?')[0];
4116
4122
  });
4117
4123
  }
4118
4124
  }else{
4119
4125
  let imgValue = imgFieldValue.split('/');
4120
- formData[item] = imgValue[imgValue.length - 1];
4126
+ formData[item] = imgValue[imgValue.length - 1].split('?')[0];
4121
4127
  }
4122
4128
  }
4123
4129
  })
@@ -4397,7 +4403,7 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
4397
4403
  * @Author: baozhoutao@steedos.com
4398
4404
  * @Date: 2022-10-28 14:15:09
4399
4405
  * @LastEditors: baozhoutao@steedos.com
4400
- * @LastEditTime: 2024-08-19 16:26:58
4406
+ * @LastEditTime: 2024-10-14 14:01:15
4401
4407
  * @Description:
4402
4408
  */
4403
4409
 
@@ -4495,13 +4501,13 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
4495
4501
  if(type === 'file'){
4496
4502
  return window.Meteor?.isCordova ? {
4497
4503
  "type": "control",
4498
- "body": {
4504
+ "body": steedosField.multiple ? {
4499
4505
  "type": "each",
4500
4506
  "name": "_display." + steedosField.name,
4501
4507
  "items": {
4502
4508
  "type": "tpl",
4503
4509
  "tpl": "${name}",
4504
- "className": "antd-Button--link inline-block",
4510
+ "className": "antd-Button--link inline-block mr-2",
4505
4511
  "onEvent": {
4506
4512
  "click": {
4507
4513
  "actions": [
@@ -4516,6 +4522,24 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
4516
4522
  }
4517
4523
  }
4518
4524
  }
4525
+ } : {
4526
+ "type": "tpl",
4527
+ "tpl": "${_display." + steedosField.name + ".name}",
4528
+ "className": "antd-Button--link inline-block",
4529
+ "onEvent": {
4530
+ "click": {
4531
+ "actions": [
4532
+ {
4533
+ "script": `
4534
+ const data = event.data._display.${steedosField.name};
4535
+ Steedos.cordovaDownload(encodeURI(data.url), data.name);
4536
+ `,
4537
+ "actionType": "custom"
4538
+ }
4539
+ ],
4540
+ "weight": 0
4541
+ }
4542
+ }
4519
4543
  }
4520
4544
  } : {
4521
4545
  // type: amisFieldType,
@@ -6681,7 +6705,7 @@ function getReadonlyFormAdaptor(object, fields, options){
6681
6705
  var gridAndObjectFieldsName = ${JSON.stringify(gridAndObjectFieldsName)};
6682
6706
  try{
6683
6707
  ${scriptStr}
6684
- ${getScriptForAddUrlPrefixForImgFields(fields)}
6708
+ ${getScriptForAddUrlPrefixForImgFields(fields, true)}
6685
6709
  ${getScriptForRewriteValueForFileFields(fields)}
6686
6710
  }catch(e){
6687
6711
  console.error(e)
@@ -6745,7 +6769,7 @@ async function getReadonlyFormInitApi(object, recordId, fields, options){
6745
6769
  /*
6746
6770
  img/avatar字段值添加URL前缀使其在amis中正常显示图片。
6747
6771
  */
6748
- function getScriptForAddUrlPrefixForImgFields(fields){
6772
+ function getScriptForAddUrlPrefixForImgFields(fields, readonly){
6749
6773
  let imgFieldsKeys = [];
6750
6774
  let imgFields = {};
6751
6775
  fields.forEach((item)=>{
@@ -6773,12 +6797,12 @@ function getScriptForAddUrlPrefixForImgFields(fields){
6773
6797
  if(fieldProps.multiple){
6774
6798
  if(imgFieldDisplayValue instanceof Array){
6775
6799
  data[item] = imgFieldDisplayValue.map((i)=>{
6776
- const url = window.getImageFieldUrl(i.url);
6800
+ const url = window.getImageFieldUrl(i.url, ${readonly});
6777
6801
  return url;
6778
6802
  });
6779
6803
  }
6780
6804
  }else{
6781
- const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url);
6805
+ const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url, ${readonly});
6782
6806
  data[item] = url;
6783
6807
  }
6784
6808
  }
@@ -6874,7 +6898,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
6874
6898
  const fieldKeys = uiSchema && _.keys(uiSchema.fields);
6875
6899
 
6876
6900
  if(data){
6877
- ${getScriptForAddUrlPrefixForImgFields(fields)}
6901
+ ${getScriptForAddUrlPrefixForImgFields(fields, false)}
6878
6902
  ${getScriptForRewriteValueForFileFields(fields)}
6879
6903
 
6880
6904
  _.each(dataKeys, function(key){
@@ -27180,6 +27204,10 @@ var AmisSteedosField = function (props) { return __awaiter(void 0, void 0, void
27180
27204
  tpl: '-',
27181
27205
  className: "".concat(fieldBaseProps.className || '', " text-muted !border-b-0"),
27182
27206
  hiddenOn: "${_display.".concat(steedosField.name, "}"),
27207
+ },
27208
+ {
27209
+ type: 'tpl',
27210
+ tpl: "<span class='antd-TplField antd-Form-description'><span>".concat(steedosField.description, "</span></span>")
27183
27211
  }],
27184
27212
  _p)]));
27185
27213
  return [3 /*break*/, 13];