@steedos-widgets/amis-lib 3.6.15 → 6.3.0-beta.11

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
@@ -570,10 +570,23 @@ function getNameTpl(field, ctx){
570
570
  if(ctx && ctx.isLookup){
571
571
  linkTarget = "target='_blank'";
572
572
  }
573
+ let nameLabel = field.name;
574
+ //若字段类型是lookup,则按照相关表tpl的label规则显示;若是其它类型,则显示_display或字段本身的值
575
+ if (field.type == "lookup") {
576
+ if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
577
+ if(!field.isTableField){
578
+ nameLabel = `\${${field.name}__label}`;
579
+ }
580
+ } else {
581
+ nameLabel = `\${_display.${field.name}.label}`;
582
+ }
583
+ } else {
584
+ nameLabel = `\${_display.${field.name} || ${field.name}}`;
585
+ }
573
586
  if(ctx.isRelated && window.innerWidth >= 768){
574
- return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
587
+ return `<a href="${href}" ${linkTarget} onclick="return false;">\${${nameLabel} | raw}</a>`
575
588
  }else {
576
- return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
589
+ return `<a href="${href}" ${linkTarget}>\${${nameLabel} | raw}</a>`
577
590
  }
578
591
  }
579
592
 
@@ -698,7 +711,7 @@ function getLocationTpl(field){
698
711
  }
699
712
 
700
713
  async function getFieldTpl (field, options){
701
- if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
714
+ if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel && field.multiple !== true){
702
715
  return getNameTpl(field, options)
703
716
  }
704
717
  switch (field.type) {
@@ -739,7 +752,7 @@ async function getFieldsTemplate(fields, display){
739
752
  if(display != false){
740
753
  display = true;
741
754
  }
742
- let fieldsName = ['_id'];
755
+ let fieldsName = ['_id', 'space'];
743
756
  let displayFields = [];
744
757
  let fieldsArr = [];
745
758
  if(_$1.isArray(fields)){
@@ -1660,6 +1673,29 @@ i18next
1660
1673
  }
1661
1674
  });
1662
1675
 
1676
+ /*
1677
+ * @Author: baozhoutao@steedos.com
1678
+ * @Date: 2022-07-13 15:18:03
1679
+ * @LastEditors: baozhoutao@steedos.com
1680
+ * @LastEditTime: 2023-04-11 10:34:26
1681
+ * @Description:
1682
+ */
1683
+
1684
+ async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
1685
+ const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
1686
+ const page = await fetchAPI(api);
1687
+ if (page && page.schema) {
1688
+ page.schema = JSON.parse(page.schema);
1689
+ if(page.schema.data){
1690
+ delete page.schema.data.recordId;
1691
+ delete page.schema.data.objectName;
1692
+ delete page.schema.data.context;
1693
+ delete page.schema.data.global;
1694
+ }
1695
+ return page;
1696
+ }
1697
+ }
1698
+
1663
1699
  async function getQuickEditSchema(object, columnField, options){
1664
1700
  let field = object.fields[columnField.name];
1665
1701
  //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
@@ -2294,20 +2330,26 @@ async function getTableColumns(object, fields, options){
2294
2330
  }
2295
2331
 
2296
2332
  if(window.innerWidth >= 768 && ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && _$1.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2297
-
2298
- const drawerRecordDetailSchema = {
2333
+ const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });
2334
+ const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
2335
+ "recordId": `\${${options.idFieldName}}`,
2336
+ "data": {
2337
+ ...recordPage.schema.data,
2338
+ "_inDrawer": true, // 用于判断是否在抽屉中
2339
+ "recordLoaded": false, // 重置数据加载状态
2340
+ }
2341
+ }) : {
2299
2342
  "type": "steedos-record-detail",
2300
2343
  "objectApiName": "${objectName}",
2301
2344
  "recordId": `\${${options.idFieldName}}`,
2302
2345
  "showBackButton": false,
2303
2346
  "showButtons": true,
2304
2347
  "data": {
2305
- "_inDrawer": true, // 用于判断是否在抽屉中
2306
- "recordLoaded": false, // 重置数据加载状态
2348
+ "_inDrawer": true, // 用于判断是否在抽屉中
2349
+ "recordLoaded": false, // 重置数据加载状态
2307
2350
  }
2308
2351
  };
2309
2352
 
2310
-
2311
2353
  if(!(field.is_name || field.name === options.labelFieldName)){
2312
2354
  drawerRecordDetailSchema.objectApiName = field.reference_to;
2313
2355
  drawerRecordDetailSchema.recordId = `\${_display.${field.name}.value}`;
@@ -2323,7 +2365,7 @@ async function getTableColumns(object, fields, options){
2323
2365
  "title": "&nbsp;",
2324
2366
  "headerClassName": "hidden",
2325
2367
  "size": "lg",
2326
- "bodyClassName": "p-0 m-0",
2368
+ "bodyClassName": "p-0 m-0 bg-gray-100",
2327
2369
  "closeOnEsc": true,
2328
2370
  "closeOnOutside": true,
2329
2371
  "resizable": true,
@@ -3259,6 +3301,19 @@ function getReadonlyFormAdaptor(object, fields, options){
3259
3301
  // })
3260
3302
 
3261
3303
  var fieldNames = _$1.map(fields, function(n){return n.name});
3304
+ var nameField = object.fields[object.NAME_FIELD_KEY];
3305
+ let nameLabel = nameField && nameField.name;
3306
+ if (nameField && nameField.type == "lookup") {
3307
+ if(!nameField.reference_to && (nameField.optionsFunction || nameField._optionsFunction || nameField.options)){
3308
+ if(!nameField.isTableField){
3309
+ nameLabel = `record.${nameField.name}__label`;
3310
+ }
3311
+ } else {
3312
+ nameLabel = `record._display.${nameField.name}.label`;
3313
+ }
3314
+ } else if (nameField){
3315
+ nameLabel = `record._display.${nameField.name} || record.${nameField.name}`;
3316
+ }
3262
3317
  return `
3263
3318
  if(payload.data.data.length === 0){
3264
3319
  var isEditor = !!${options && options.isEditor};
@@ -3300,8 +3355,7 @@ function getReadonlyFormAdaptor(object, fields, options){
3300
3355
  payload.data = data;
3301
3356
  payload.data.__objectName = "${object.name}";
3302
3357
  payload.data.record = record;
3303
-
3304
- payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
3358
+ payload.data.NAME_FIELD_VALUE = ${nameLabel} || record.name;
3305
3359
  payload.data._master = {
3306
3360
  record: record,
3307
3361
  objectName: "${object.name}",
@@ -4768,7 +4822,8 @@ const getSchema$5 = async (uiSchema, ctx) => {
4768
4822
  type: 'button',
4769
4823
  actionType: 'confirm',
4770
4824
  label: i18next.t('frontend_form_save'),
4771
- primary: true
4825
+ primary: true,
4826
+ close: `object_actions_drawer_${uiSchema.name}`
4772
4827
  },
4773
4828
  ]
4774
4829
  }
@@ -4786,29 +4841,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
4786
4841
  }
4787
4842
  };
4788
4843
 
4789
- /*
4790
- * @Author: baozhoutao@steedos.com
4791
- * @Date: 2022-07-13 15:18:03
4792
- * @LastEditors: baozhoutao@steedos.com
4793
- * @LastEditTime: 2023-04-11 10:34:26
4794
- * @Description:
4795
- */
4796
-
4797
- async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
4798
- const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
4799
- const page = await fetchAPI(api);
4800
- if (page && page.schema) {
4801
- page.schema = JSON.parse(page.schema);
4802
- if(page.schema.data){
4803
- delete page.schema.data.recordId;
4804
- delete page.schema.data.objectName;
4805
- delete page.schema.data.context;
4806
- delete page.schema.data.global;
4807
- }
4808
- return page;
4809
- }
4810
- }
4811
-
4812
4844
  /*
4813
4845
  * @Author: baozhoutao@steedos.com
4814
4846
  * @Date: 2022-11-01 15:49:58
@@ -4887,6 +4919,20 @@ const getSchema$4 = async (uiSchema, ctx) => {
4887
4919
  ]
4888
4920
  }
4889
4921
  },
4922
+ "actions": [
4923
+ {
4924
+ type: 'button',
4925
+ actionType: 'cancel',
4926
+ label: i18next.t('frontend_form_cancel')
4927
+ },
4928
+ {
4929
+ type: 'button',
4930
+ actionType: 'confirm',
4931
+ label: i18next.t('frontend_form_save'),
4932
+ primary: true,
4933
+ close: `object_actions_drawer_${uiSchema.name}`
4934
+ },
4935
+ ]
4890
4936
  },
4891
4937
  },
4892
4938
  ],
@@ -4968,7 +5014,8 @@ const getSchema$3 = (uiSchema)=>{
4968
5014
  }
4969
5015
  ]
4970
5016
  }
4971
- }
5017
+ },
5018
+ "close": `object_actions_drawer_${uiSchema.name}`
4972
5019
  }
4973
5020
  ],
4974
5021
  "regions": [
@@ -8903,10 +8950,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8903
8950
  }
8904
8951
  }
8905
8952
  `;
8906
- let autoFillHeight = true;
8907
- if(options.isRelated || window.innerWidth < 768){
8908
- autoFillHeight = false;
8909
- }
8910
8953
 
8911
8954
  body = Object.assign({}, table, {
8912
8955
  type: 'crud',
@@ -8917,7 +8960,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8917
8960
  keepItemSelectionOnPageChange: true,
8918
8961
  api: await getTableApi(objectSchema, fields, options),
8919
8962
  hiddenOn: options.tableHiddenOn,
8920
- autoFillHeight,
8963
+ // autoFillHeight,//autoFillHeight按amis规范默认为false,需要配置此属性时在各个组件层配置,比如列表视图组件那边传入此属性为true
8921
8964
  className: `flex-auto ${crudClassName || ""}`,
8922
8965
  // 这里不可以用动态className,因为它会把样式类加到.antd-Crud和.antd-Table.antd-Crud-body这两层div中,而子表列表中crudClassName中有hidden样式类会造成所有子表都不显示的bug
8923
8966
  // className: {
@@ -9090,6 +9133,10 @@ async function getFormSchemaWithDataFilter(form, options = {}){
9090
9133
  async function getObjectForm(objectSchema, ctx){
9091
9134
  const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
9092
9135
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
9136
+ //优先识别组件上的enableTabs属性,若不存在,则识别对象上定义的
9137
+ if (typeof ctx.enableTabs !== 'boolean') {
9138
+ ctx.enableTabs = objectSchema.enable_form_tabs;
9139
+ }
9093
9140
  const fields = ___default.values(objectSchema.fields);
9094
9141
  const formFields = getFormFields$1(objectSchema, ctx);
9095
9142
  const formSchema = defaults && defaults.formSchema || {};
@@ -9183,7 +9230,7 @@ async function getObjectForm(objectSchema, ctx){
9183
9230
 
9184
9231
  async function getObjectDetail(objectSchema, recordId, ctx){
9185
9232
  const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
9186
- formDataFilter, onFormDataFilter, amisData, env } = ctx;
9233
+ formDataFilter, onFormDataFilter, amisData, env, enableInitApi } = ctx;
9187
9234
  const fields = ___default.values(objectSchema.fields);
9188
9235
  const formFields = getFormFields$1(objectSchema, ctx);
9189
9236
  const serviceId = `service_detail_page`;
@@ -9250,6 +9297,16 @@ async function getObjectDetail(objectSchema, recordId, ctx){
9250
9297
  // }
9251
9298
  };
9252
9299
 
9300
+ if(enableInitApi){
9301
+ amisSchema.api = await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx);
9302
+ // 开启初始化api请求时,如果不把recordLoaded默认设置为false,recordLoaded值会取RecordServic组件中的recordLoaded值
9303
+ // 这会造成表单内steedos field组件lookup字段中props.data取到的是RecordServic组件
9304
+ amisSchema.data = {
9305
+ ...amisSchema.data,
9306
+ recordLoaded: false
9307
+ };
9308
+ }
9309
+
9253
9310
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
9254
9311
  // console.log('getObjectDetail=====>', amisSchema);
9255
9312
  return amisSchema;
@@ -9741,7 +9798,7 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
9741
9798
  * @Author: baozhoutao@steedos.com
9742
9799
  * @Date: 2022-07-05 15:55:39
9743
9800
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
9744
- * @LastEditTime: 2024-02-23 16:37:06
9801
+ * @LastEditTime: 2024-04-26 16:46:44
9745
9802
  * @Description:
9746
9803
  */
9747
9804
 
@@ -10006,37 +10063,44 @@ async function getListSchema(
10006
10063
  * 本次存储代码段
10007
10064
  */
10008
10065
  try {
10009
- const listViewPropsStoreKey = location.pathname + "/crud";
10010
- let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10011
- /**
10012
- * localListViewProps规范来自crud请求api中api.data.$self参数值的。
10013
- * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
10014
- * __searchable__...:顶部放大镜搜索条件
10015
- * filter:右侧过滤器
10016
- * perPage:每页条数
10017
- * page:当前页码
10018
- * orderBy:排序字段
10019
- * orderDir:排序方向
10020
- */
10021
- if (localListViewProps) {
10022
- localListViewProps = JSON.parse(localListViewProps);
10023
- // localListViewProps.perPage = 3;
10024
- let listSchema = {};
10025
- if(localListViewProps.orderBy){
10026
- listSchema.orderBy = localListViewProps.orderBy;
10027
- }
10028
- if(localListViewProps.orderDir){
10029
- listSchema.orderDir = localListViewProps.orderDir;
10030
- }
10066
+ const listViewPropsStoreKey = location.pathname + "/crud";
10067
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10068
+ /**
10069
+ * localListViewProps规范来自crud请求api中api.data.$self参数值的。
10070
+ * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
10071
+ * __searchable__...:顶部放大镜搜索条件
10072
+ * filter:右侧过滤器
10073
+ * perPage:每页条数
10074
+ * page:当前页码
10075
+ * orderBy:排序字段
10076
+ * orderDir:排序方向
10077
+ */
10078
+ if (localListViewProps) {
10079
+ localListViewProps = JSON.parse(localListViewProps);
10080
+ // localListViewProps.perPage = 3;
10081
+ let listSchema = {};
10082
+ if (localListViewProps.orderBy) {
10083
+ listSchema.orderBy = localListViewProps.orderBy;
10084
+ }
10085
+ if (localListViewProps.orderDir) {
10086
+ listSchema.orderDir = localListViewProps.orderDir;
10087
+ }
10031
10088
 
10032
- if(localListViewProps.perPage){
10033
- listSchema.perPage = localListViewProps.perPage;
10089
+ if (localListViewProps.perPage) {
10090
+ listSchema.perPage = localListViewProps.perPage;
10091
+ }
10092
+ defaults.listSchema = defaultsDeep$1({}, listSchema, defaults.listSchema || {});
10034
10093
  }
10035
- defaults.listSchema = defaultsDeep$1({}, listSchema, defaults.listSchema || {});
10036
- }
10037
10094
  }
10038
10095
  catch (ex) {
10039
- console.error("本地存储中crud参数解析异常:", ex);
10096
+ console.error("本地存储中crud参数解析异常:", ex);
10097
+ }
10098
+
10099
+ if (window.innerWidth > 768) {
10100
+ // 列表视图组件PC端高度自动计算实现满屏效果,手机端不需要满屏效果,所以不用autofillheight,且允许重写微页面中重新组件autoFillHeight属性
10101
+ defaults.listSchema = defaultsDeep$1({}, defaults.listSchema || {}, {
10102
+ autoFillHeight: true
10103
+ });
10040
10104
  }
10041
10105
 
10042
10106
  ctx.defaults = defaults;
@@ -10086,15 +10150,15 @@ async function getListSchema(
10086
10150
  async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10087
10151
  let fields = [];
10088
10152
  for (const column of columns) {
10153
+ let columnField, fieldName, displayName, filedInfo, rfUiSchema, rfFieldInfo;
10089
10154
  if (isString(column)) {
10090
- let columnField;
10091
10155
  if (column.indexOf('.') > 0) {
10092
- const fieldName = column.split('.')[0];
10093
- const displayName = column.split('.')[1];
10094
- const filedInfo = uiSchema.fields[fieldName];
10156
+ fieldName = column.split('.')[0];
10157
+ displayName = column.split('.')[1];
10158
+ filedInfo = uiSchema.fields[fieldName];
10095
10159
  if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)) {
10096
- const rfUiSchema = await getUISchema(filedInfo.reference_to);
10097
- const rfFieldInfo = rfUiSchema.fields[displayName];
10160
+ rfUiSchema = await getUISchema(filedInfo.reference_to);
10161
+ rfFieldInfo = rfUiSchema.fields[displayName];
10098
10162
  columnField = Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx);
10099
10163
  }else if(filedInfo && filedInfo.type === 'object'){
10100
10164
  columnField = uiSchema.fields[column];
@@ -10118,14 +10182,13 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10118
10182
  }
10119
10183
 
10120
10184
  } else if (isObject$1(column)) {
10121
- let columnField;
10122
10185
  if (column.field.indexOf('.') > 0) {
10123
- const fieldName = column.field.split('.')[0];
10124
- const displayName = column.field.split('.')[1];
10125
- const filedInfo = uiSchema.fields[fieldName];
10186
+ fieldName = column.field.split('.')[0];
10187
+ displayName = column.field.split('.')[1];
10188
+ filedInfo = uiSchema.fields[fieldName];
10126
10189
  if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)) {
10127
- const rfUiSchema = await getUISchema(filedInfo.reference_to);
10128
- const rfFieldInfo = rfUiSchema.fields[displayName];
10190
+ rfUiSchema = await getUISchema(filedInfo.reference_to);
10191
+ rfFieldInfo = rfUiSchema.fields[displayName];
10129
10192
  columnField = Object.assign({}, rfFieldInfo, ctx,
10130
10193
  { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } },
10131
10194
  {
@@ -10133,6 +10196,8 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10133
10196
  wrap: column.wrap // wrap = true 是没效果的
10134
10197
  }
10135
10198
  );
10199
+ } else if (filedInfo && filedInfo.type === 'object') {
10200
+ columnField = uiSchema.fields[column.field];
10136
10201
  }
10137
10202
  } else {
10138
10203
  if (uiSchema.fields[column.field]) {
@@ -10267,7 +10332,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
10267
10332
  };
10268
10333
  const content = {
10269
10334
  "type": "tabs",
10270
- "className": "steedos-record-tabs bg-white p-4 mt-2",
10335
+ "className": "steedos-record-tabs bg-white p-4 m-2 border rounded",
10271
10336
  "contentClassName": "bg-none",
10272
10337
  "tabs": [
10273
10338
  detailed
@@ -10343,6 +10408,10 @@ async function getRecordServiceSchema(objectName, appId, props = {}, body) {
10343
10408
  data: {
10344
10409
  "_master.objectName": "${objectName}",
10345
10410
  "_master.recordId": "${recordId}",
10411
+ // 微页面设计器中用RecordServic组件包裹一个ObjectForm只读组件时,如果这里不把recordLoaded默认设置为false
10412
+ // recordLoaded值会取父作用域中已经被设置为true的值(比如父级有RecordServic组件,在加载完数据后,父作用域中recordLoaded值为true)
10413
+ // 这会造成表单内steedos field组件lookup字段中props.data取到的是父作用域中的数据
10414
+ "recordLoaded": false,
10346
10415
  ...(props.data || {})
10347
10416
  },
10348
10417
  "style": {
@@ -11231,7 +11300,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
11231
11300
  });
11232
11301
 
11233
11302
  // 把自动填充规则中依赖的字段也加到api请求中
11234
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
11303
+ let autoFillMapping = field.auto_fill_mapping;
11235
11304
  if (autoFillMapping && autoFillMapping.length) {
11236
11305
  autoFillMapping.forEach(function (item) {
11237
11306
  if(!_$1.find(tableFields, function(f){
@@ -11381,7 +11450,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
11381
11450
  // 如果当前元素不是数组,则处理该元素
11382
11451
  // 下面正则用于匹配amis公式\${}
11383
11452
  if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
11384
- arr[i] = currentAmis.evaluate(arr[i], api.data.$);
11453
+ try{
11454
+ arr[i] = currentAmis.evaluate(arr[i], api.context);
11455
+ }catch(ex){
11456
+ console.error("运行lookup过滤公式时出现错误:",ex);
11457
+ }
11385
11458
  }
11386
11459
  }
11387
11460
  }
@@ -11703,7 +11776,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11703
11776
  ];
11704
11777
 
11705
11778
  // 把自动填充规则中依赖的字段也加到api请求中
11706
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
11779
+ let autoFillMapping = field.auto_fill_mapping;
11707
11780
  if (autoFillMapping && autoFillMapping.length) {
11708
11781
  autoFillMapping.forEach(function (item) {
11709
11782
  queryFields.push(refObjectConfig.fields[item.from]);
@@ -11789,6 +11862,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11789
11862
  var fieldFilters = ${JSON.stringify(field.filters)};
11790
11863
  var currentAmis = amisRequire('amis');
11791
11864
  //递归fieldFilters数组,检查每一个元素,判断若是公式,就仅把它解析
11865
+ debugger;
11792
11866
  function traverseNestedArray(arr) {
11793
11867
  for (let i = 0; i < arr.length; i++) {
11794
11868
  if (Array.isArray(arr[i])) {
@@ -11798,7 +11872,11 @@ async function lookupToAmisSelect(field, readonly, ctx){
11798
11872
  // 如果当前元素不是数组,则处理该元素
11799
11873
  // 下面正则用于匹配amis公式\${}
11800
11874
  if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
11801
- arr[i] = currentAmis.evaluate(arr[i], api.data.$);
11875
+ try{
11876
+ arr[i] = currentAmis.evaluate(arr[i], api.context);
11877
+ }catch(ex){
11878
+ console.error("运行lookup过滤公式时出现错误:",ex);
11879
+ }
11802
11880
  }
11803
11881
  }
11804
11882
  }
@@ -11945,14 +12023,25 @@ async function getApi(object, recordId, fields, options){
11945
12023
  }
11946
12024
 
11947
12025
  async function getAutoFill(field, refObject) {
11948
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
12026
+ let autoFillMapping = field.auto_fill_mapping;
11949
12027
  if (autoFillMapping && autoFillMapping.length) {
11950
12028
  let fillMapping = {};
12029
+ if (field.multiple) {
12030
+ autoFillMapping.forEach(function (item) {
12031
+ //from的字段类型为lookup、master_detail、select时,需要保留数组格式;其他类型需要转变为字符串格式
12032
+ if (_$1.includes(["lookup","master_detail","select"], refObject.fields[item.from].type)) {
12033
+ fillMapping[item.to] = `\${items | pick:${item.from}}`;
12034
+ } else {
12035
+ fillMapping[item.to] = `\${items | pick:${item.from} | join}`;
12036
+ }
12037
+ });
12038
+ }else {
12039
+ autoFillMapping.forEach(function (item) {
12040
+ fillMapping[item.to] = `\${${item.from}}`;
12041
+ });
12042
+ }
11951
12043
  // let fieldsForApi = [];
11952
- autoFillMapping.forEach(function (item) {
11953
- fillMapping[item.to] = `\${${item.from}}`;
11954
- // fieldsForApi.push(item.from);
11955
- });
12044
+ // fieldsForApi.push(item.from);
11956
12045
  // let api = {
11957
12046
  // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
11958
12047
  // "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
@@ -12054,7 +12143,7 @@ async function lookupToAmis(field, readonly, ctx){
12054
12143
  amisSchema = _$1.defaultsDeep({}, pageAmisSchema, amisSchema);
12055
12144
  }
12056
12145
  }
12057
- const autoFill = await getAutoFill(field);
12146
+ const autoFill = await getAutoFill(field, refObject);
12058
12147
  if(autoFill){
12059
12148
  amisSchema.autoFill = autoFill;
12060
12149
  // 这里不配置initAutoFill值,按amis规则initAutoFill默认值为fillIfNotSet处理--需要amis sdk 版本 > 3.6.3-patch.6(不包括)版本