@steedos-widgets/amis-lib 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.
package/dist/index.esm.js CHANGED
@@ -2128,7 +2128,7 @@ async function getTableColumns(fields, options){
2128
2128
  var data = event.data;
2129
2129
  var file_name = data.versions ? data.name : "${field.label}";
2130
2130
  var file_id = data._id;
2131
- SteedosUI.previewFile && SteedosUI.previewFile({file_name, file_id});
2131
+ window.previewFile && window.previewFile({file_name, file_id});
2132
2132
  `;
2133
2133
  columnItem = {
2134
2134
  "type": "button",
@@ -2157,7 +2157,7 @@ async function getTableColumns(fields, options){
2157
2157
  "actionType": "custom",
2158
2158
  "script": previewFileScript,
2159
2159
  // "expression": "!!window?.nw?.require" //PC客户端预览附件
2160
- "expression": "!!!(window && window.nw && window.nw.require)"//PC客户端预览附件
2160
+ "expression": "!!(window && window.nw && window.nw.require)"//PC客户端预览附件
2161
2161
  }
2162
2162
  ]
2163
2163
  }
@@ -2940,6 +2940,18 @@ async function getTableApi(mainObject, fields, options){
2940
2940
  return api;
2941
2941
  `;
2942
2942
  api.adaptor = `
2943
+ let fields = ${JSON.stringify(_$1.map(fields, 'name'))};
2944
+ // 这里把行数据中所有为空的字段值配置为空字符串,是因为amis有bug:crud的columns中的列如果type为static-前缀的话,行数据中该字段为空的话会显示为父作用域中同名变量值,见:https://github.com/baidu/amis/issues/9556
2945
+ (payload.data.rows || []).forEach((itemRow) => {
2946
+ (fields || []).forEach((itemField) => {
2947
+ if(itemField && (itemRow[itemField] === undefined || itemRow[itemField] === null)){
2948
+ // 这里itemRow中不存在 itemField 属性,或者值为null时都会有“显示为父作用域中的同名变量值”的问题,所以null和undefined都要重置为空字符串
2949
+ // 实测数字、下拉框、多选lookup等字段类型重置为空字符串都不会有问题,而且实测amis from组件的清空表单字段值功能就是把表单中的各种字段类型设置为空字符串,所以看起来也符合amis规范
2950
+ itemRow[itemField] = "";
2951
+ }
2952
+ });
2953
+ });
2954
+
2943
2955
  if(api.body.listName == "recent"){
2944
2956
  payload.data.rows = _.sortBy(payload.data.rows, function(item){
2945
2957
  return _.indexOf(api.body._ids, item._id)
@@ -8667,7 +8679,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8667
8679
  payload.status = 2;
8668
8680
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
8669
8681
  }
8670
- debugger;
8671
8682
  var scope = SteedosUI.getRef(context.scopeId);
8672
8683
  var scopeParent = scope && scope.parent;
8673
8684
  var crudScoped = scopeParent.getComponentById('${body.id}');
@@ -12383,6 +12394,36 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
12383
12394
  convertData = {
12384
12395
  type: 'static-text'
12385
12396
  };
12397
+ }else if(field.autonumber_enable_modify){
12398
+ convertData = {
12399
+ "type": "input-group",
12400
+ "body": [
12401
+ {
12402
+ "type": "input-text",
12403
+ "name": field.name
12404
+ },
12405
+ {
12406
+ "type": "button",
12407
+ "label": "自动获取",
12408
+ "actionType": "ajax",
12409
+ "api": {
12410
+ "url": `\${context.rootUrl}/api/autonumber/generator/\${objectName}/${field.name}`,
12411
+ "method": "post",
12412
+ "headers": {
12413
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
12414
+ },
12415
+ "adaptor": `
12416
+ payload.data["${field.name}"] = payload.data && payload.data.autonumber;
12417
+ delete payload.data.autonumber;
12418
+ return payload;
12419
+ `
12420
+ },
12421
+ "messages": {
12422
+ "success": "获取成功"
12423
+ }
12424
+ }
12425
+ ]
12426
+ };
12386
12427
  }
12387
12428
  break;
12388
12429
  case 'url':