@steedos-widgets/amis-lib 6.3.13-beta.8 → 6.3.13

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
@@ -2347,7 +2347,7 @@ async function getColumnItemOnClick(field, options){
2347
2347
  "_inDrawer": true, // 用于判断是否在抽屉中
2348
2348
  "recordLoaded": false, // 重置数据加载状态
2349
2349
  "recordId": `\${${options.idFieldName}}`,//审批微页面依赖了作用域中的recordId
2350
- "_tableObjectName": options.objectName
2350
+ "_lookupObjectName": options.objectName
2351
2351
  }
2352
2352
  }) : {
2353
2353
  "type": "steedos-record-detail",
@@ -2358,7 +2358,7 @@ async function getColumnItemOnClick(field, options){
2358
2358
  "data": {
2359
2359
  "_inDrawer": true, // 用于判断是否在抽屉中
2360
2360
  "recordLoaded": false, // 重置数据加载状态
2361
- "_tableObjectName": options.objectName
2361
+ "_lookupObjectName": options.objectName
2362
2362
  }
2363
2363
  };
2364
2364
 
@@ -2531,7 +2531,7 @@ async function getTableColumns(object, fields, options){
2531
2531
  body: {
2532
2532
  type: "steedos-field",
2533
2533
  static: true,
2534
- tableObjectName: options.objectName,
2534
+ isLookupInTable: true,
2535
2535
  config: {
2536
2536
  type: "lookup",
2537
2537
  reference_to: field.reference_to,
@@ -3305,6 +3305,16 @@ async function getTableApi(mainObject, fields, options){
3305
3305
  return api;
3306
3306
  `;
3307
3307
  api.adaptor = `
3308
+
3309
+ if(payload.errors && payload.errors.length > 0){
3310
+ return {
3311
+ status: 500,
3312
+ msg: payload.errors[0].message,
3313
+ data: {}
3314
+ }
3315
+ }
3316
+
3317
+
3308
3318
  let fields = ${JSON.stringify(_$1.map(fields, 'name'))};
3309
3319
  // 这里把行数据中所有为空的字段值配置为空字符串,是因为amis有bug:crud的columns中的列如果type为static-前缀的话,行数据中该字段为空的话会显示为父作用域中同名变量值,见:https://github.com/baidu/amis/issues/9556
3310
3320
  (payload.data.rows || []).forEach((itemRow) => {
@@ -3347,10 +3357,13 @@ async function getTableApi(mainObject, fields, options){
3347
3357
  // item[key] = value
3348
3358
  // PC客户端附件子表列表点击标题预览附件功能依赖了_id,所以这里拼出来
3349
3359
  let itemKeyValue = item[key];
3350
- item[key] = value.map(function(item, index){
3351
- item._id = typeof itemKeyValue == 'string' ? itemKeyValue : itemKeyValue[index];
3352
- item.value = typeof itemKeyValue == 'string' ? itemKeyValue : itemKeyValue[index];
3353
- return item;
3360
+ item[key] = value.map(function(curValue, index){
3361
+ let fileId = typeof itemKeyValue == 'string' ? itemKeyValue : itemKeyValue[index];
3362
+ // 克隆一份对象,避免下方value递归污染curValue
3363
+ let result = _.clone(curValue);
3364
+ result._id = fileId;
3365
+ result.value = fileId;
3366
+ return result;
3354
3367
  });
3355
3368
  }else{
3356
3369
  item[key] = _.map(value, (item)=>{
@@ -3596,6 +3609,11 @@ function getReadonlyFormAdaptor(object, fields, options){
3596
3609
  objectName: "${object.name}",
3597
3610
  recordId: record._id
3598
3611
  }
3612
+ if(window.location.pathname.endsWith("/"+record._id)){
3613
+ payload.data.mainRecord= {
3614
+ record
3615
+ };
3616
+ }
3599
3617
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
3600
3618
  }
3601
3619
  if(payload.errors){
@@ -4864,8 +4882,8 @@ const parseSingleExpression = function (func, formData, dataPath, global, userSe
4864
4882
  /*
4865
4883
  * @Author: baozhoutao@steedos.com
4866
4884
  * @Date: 2022-11-01 15:51:00
4867
- * @LastEditors: baozhoutao@steedos.com
4868
- * @LastEditTime: 2024-12-26 20:28:43
4885
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
4886
+ * @LastEditTime: 2025-07-22 14:49:16
4869
4887
  * @Description:
4870
4888
  */
4871
4889
 
@@ -4940,7 +4958,8 @@ const getSchema$5 = async (uiSchema, ctx) => {
4940
4958
  }
4941
4959
  const uiSchema = event.data.uiSchema;
4942
4960
  const objectName = event.data.objectName;
4943
- const listViewRef = event.context.scoped.getComponentById("listview_" + objectName);
4961
+ const crudId = event.data.crudId || "listview_" + objectName;
4962
+ const listViewRef = event.context.scoped.getComponentById(crudId);
4944
4963
  const selectedItems = listViewRef && listViewRef.props.store.toJSON().selectedItems || [];
4945
4964
  event.data.selectedIds = _.map(selectedItems, uiSchema.idFieldName || '_id');
4946
4965
  `;
@@ -5062,8 +5081,8 @@ const getSchema$5 = async (uiSchema, ctx) => {
5062
5081
  /*
5063
5082
  * @Author: baozhoutao@steedos.com
5064
5083
  * @Date: 2022-11-01 15:49:58
5065
- * @LastEditors: yinlianghui@hotoa.com yinlianghui@hotoa.com
5066
- * @LastEditTime: 2024-05-19 10:01:07
5084
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5085
+ * @LastEditTime: 2025-07-14 15:52:24
5067
5086
  * @Description:
5068
5087
  */
5069
5088
 
@@ -5093,6 +5112,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
5093
5112
  : page.schema;
5094
5113
  }
5095
5114
 
5115
+ // console.log('formSchema====>', formSchema);
5096
5116
 
5097
5117
  return {
5098
5118
  type: "service",
@@ -5117,7 +5137,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
5117
5137
  showCloseButton: true,
5118
5138
  "data": {
5119
5139
  "&": "$$",
5120
- "_master": "${_master}",
5140
+ "_master": "${mainRecord}",
5121
5141
  "_master._isRelated": "${_isRelated}",
5122
5142
  "_master.relatedKey": "${relatedKey}"
5123
5143
  },
@@ -5218,12 +5238,12 @@ const getSchema$3 = (uiSchema)=>{
5218
5238
  {
5219
5239
  "actionType": "broadcast",
5220
5240
  "args": {
5221
- "eventName": "@data.changed.${_tableObjectName}"
5241
+ "eventName": "@data.changed.${_lookupObjectName}"
5222
5242
  },
5223
5243
  "data": {
5224
- "objectName": "${_tableObjectName}"
5244
+ "objectName": "${_lookupObjectName}"
5225
5245
  },
5226
- "expression": `\${_tableObjectName != '${uiSchema.name}' && _tableObjectName}`
5246
+ "expression": `\${_lookupObjectName != '${uiSchema.name}' && _lookupObjectName}`
5227
5247
  }
5228
5248
  ]
5229
5249
  }
@@ -5482,8 +5502,8 @@ const getSchema = async (uiSchema, ctx) => {
5482
5502
  /*
5483
5503
  * @Author: baozhoutao@steedos.com
5484
5504
  * @Date: 2022-11-01 15:53:07
5485
- * @LastEditors: baozhoutao@steedos.com
5486
- * @LastEditTime: 2023-02-28 17:06:22
5505
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
5506
+ * @LastEditTime: 2025-07-22 14:49:34
5487
5507
  * @Description:
5488
5508
  */
5489
5509
 
@@ -5513,12 +5533,13 @@ const StandardButtons = {
5513
5533
  const {
5514
5534
  appId,
5515
5535
  objectName,
5516
- uiSchema
5536
+ uiSchema,
5537
+ record
5517
5538
  } = this;
5518
5539
  const scopeId = this.scopeId || `amis-${appId}-${objectName}-listview`;
5519
5540
  const scope = this.scope || SteedosUI?.getRef(scopeId);
5520
- //https://github.com/baidu/amis/pull/6807 .parent的改动是为适应3.2getComponentById的规则改动,不影响2.9
5521
- const listViewRef = scope.parent?.getComponentById(`listview_${uiSchema.name}`);
5541
+ const crudId = record?.crudId || `listview_${uiSchema.name}`;
5542
+ const listViewRef = scope.parent?.getComponentById(crudId);
5522
5543
  if(_.isEmpty(listViewRef.props.store.toJSON().selectedItems)){
5523
5544
  listViewRef.handleAction({}, {
5524
5545
  "actionType": "toast",
@@ -9958,16 +9979,16 @@ async function getObjectForm(objectSchema, ctx){
9958
9979
  },
9959
9980
  "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
9960
9981
  },
9961
- // 列表视图、对象表格组件上的lookup字段,点开右侧弹出drawer窗口,修改记录后刷新列表
9982
+ // 列表视图、对象表格、对象表单组件上的lookup字段,点开右侧弹出drawer窗口,修改记录后刷新列表
9962
9983
  {
9963
9984
  "actionType": "broadcast",
9964
9985
  "args": {
9965
- "eventName": "@data.changed.${_tableObjectName}"
9986
+ "eventName": "@data.changed.${_lookupObjectName}"
9966
9987
  },
9967
9988
  "data": {
9968
- "objectName": "${_tableObjectName}"
9989
+ "objectName": "${_lookupObjectName}"
9969
9990
  },
9970
- "expression": `\${_tableObjectName != '${objectSchema.name}' && _tableObjectName}`
9991
+ "expression": `\${_lookupObjectName != '${objectSchema.name}' && _lookupObjectName}`
9971
9992
  },
9972
9993
  ...submitSuccActions,
9973
9994
  // {
@@ -12491,7 +12512,13 @@ async function lookupToAmisPicker(field, readonly, ctx){
12491
12512
  "__lookupField": {
12492
12513
  "name": field.name,
12493
12514
  "reference_to": refObjectConfig.name,
12494
- "reference_to_field": field.reference_to_field
12515
+ "reference_to_field": field.reference_to_field,
12516
+ "filters": field.filters,
12517
+ "filtersFunction": field.filtersFunction,
12518
+ "_filtersFunction": field._filtersFunction,
12519
+ "inFilterForm": ctx.inFilterForm,
12520
+ "listviewFilter": listviewFilter,
12521
+ "listviewFiltersFunction": listviewFiltersFunction
12495
12522
  }
12496
12523
  });
12497
12524
 
@@ -14168,7 +14195,8 @@ async function getFieldSearchable(perField, permissionFields, ctx){
14168
14195
  _field.removable = false;
14169
14196
  _field.value = [null,null];
14170
14197
  _field.items = {
14171
- type: "input-number"
14198
+ type: "input-number",
14199
+ clearValueOnEmpty: true
14172
14200
  };
14173
14201
  _field.is_wide = true;
14174
14202
  fieldNamePrefix = `${fieldNamePrefix}between__`;
@@ -14216,6 +14244,10 @@ async function getFieldSearchable(perField, permissionFields, ctx){
14216
14244
  delete _field.amis.hidden;
14217
14245
  delete _field.amis.hiddenOn;
14218
14246
  delete _field.amis.autoFill;
14247
+ if(_field.type.indexOf("-range") > -1 || _field.type === 'input-array'){
14248
+ // 范围类型不允许变更type,否则会因为某些属性兼容性问题报错页面奔溃,比如input-date-range类型有shortcuts属性,改为input-date后其shortcuts属性有兼容性问题
14249
+ delete _field.amis.type;
14250
+ }
14219
14251
  }
14220
14252
 
14221
14253
  const amisField = await convertSFieldToAmisField(_field, false, Object.assign({}, ctx, {fieldNamePrefix: fieldNamePrefix, required: false, showSystemFields: true, inFilterForm: true}));