@steedos-widgets/amis-object 3.6.2-beta.16 → 3.6.2-beta.17

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.
@@ -5309,7 +5309,7 @@ async function getTableColumns$1(fields, options){
5309
5309
  var data = event.data;
5310
5310
  var file_name = data.versions ? data.name : "${field.label}";
5311
5311
  var file_id = data._id;
5312
- SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
5312
+ window.previewFile && window.previewFile({file_name, file_id});
5313
5313
  `;
5314
5314
  columnItem = {
5315
5315
  "type": "button",
@@ -5338,7 +5338,7 @@ async function getTableColumns$1(fields, options){
5338
5338
  "actionType": "custom",
5339
5339
  "script": previewFileScript,
5340
5340
  // "expression": "!!window?.nw?.require" //PC客户端预览附件
5341
- "expression": "!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
5341
+ "expression": "!!(window && window.nw && window.nw.require)"//PC客户端预览附件
5342
5342
  }
5343
5343
  ]
5344
5344
  }
@@ -6121,6 +6121,18 @@ async function getTableApi(mainObject, fields, options){
6121
6121
  return api;
6122
6122
  `;
6123
6123
  api.adaptor = `
6124
+ let fields = ${JSON.stringify(_$1__namespace.map(fields, 'name'))};
6125
+ // 这里把行数据中所有为空的字段值配置为空字符串,是因为amis有bug:crud的columns中的列如果type为static-前缀的话,行数据中该字段为空的话会显示为父作用域中同名变量值,见:https://github.com/baidu/amis/issues/9556
6126
+ (payload.data.rows || []).forEach((itemRow) => {
6127
+ (fields || []).forEach((itemField) => {
6128
+ if(itemField && (itemRow[itemField] === undefined || itemRow[itemField] === null)){
6129
+ // 这里itemRow中不存在 itemField 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
6130
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
6131
+ itemRow[itemField] = "";
6132
+ }
6133
+ });
6134
+ });
6135
+
6124
6136
  if(api.body.listName == "recent"){
6125
6137
  payload.data.rows = _.sortBy(payload.data.rows, function(item){
6126
6138
  return _.indexOf(api.body._ids, item._id)
@@ -11848,7 +11860,6 @@ async function getObjectCRUD(objectSchema, fields, options){
11848
11860
  payload.status = 2;
11849
11861
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
11850
11862
  }
11851
- debugger;
11852
11863
  var scope = SteedosUI.getRef(context.scopeId);
11853
11864
  var scopeParent = scope && scope.parent;
11854
11865
  var crudScoped = scopeParent.getComponentById('${body.id}');
@@ -15564,6 +15575,36 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
15564
15575
  convertData = {
15565
15576
  type: 'static-text'
15566
15577
  };
15578
+ }else if(field.autonumber_enable_modify){
15579
+ convertData = {
15580
+ "type": "input-group",
15581
+ "body": [
15582
+ {
15583
+ "type": "input-text",
15584
+ "name": field.name
15585
+ },
15586
+ {
15587
+ "type": "button",
15588
+ "label": "自动获取",
15589
+ "actionType": "ajax",
15590
+ "api": {
15591
+ "url": `\${context.rootUrl}/api/autonumber/generator/\${objectName}/${field.name}`,
15592
+ "method": "post",
15593
+ "headers": {
15594
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
15595
+ },
15596
+ "adaptor": `
15597
+ payload.data["${field.name}"] = payload.data && payload.data.autonumber;
15598
+ delete payload.data.autonumber;
15599
+ return payload;
15600
+ `
15601
+ },
15602
+ "messages": {
15603
+ "success": "获取成功"
15604
+ }
15605
+ }
15606
+ ]
15607
+ };
15567
15608
  }
15568
15609
  break;
15569
15610
  case 'url':