@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.cjs.js CHANGED
@@ -597,10 +597,23 @@ function getNameTpl(field, ctx){
597
597
  if(ctx && ctx.isLookup){
598
598
  linkTarget = "target='_blank'";
599
599
  }
600
+ let nameLabel = field.name;
601
+ //若字段类型是lookup,则按照相关表tpl的label规则显示;若是其它类型,则显示_display或字段本身的值
602
+ if (field.type == "lookup") {
603
+ if(!field.reference_to && (field.optionsFunction || field._optionsFunction || field.options)){
604
+ if(!field.isTableField){
605
+ nameLabel = `\${${field.name}__label}`;
606
+ }
607
+ } else {
608
+ nameLabel = `\${_display.${field.name}.label}`;
609
+ }
610
+ } else {
611
+ nameLabel = `\${_display.${field.name} || ${field.name}}`;
612
+ }
600
613
  if(ctx.isRelated && window.innerWidth >= 768){
601
- return `<a href="${href}" ${linkTarget} onclick="return false;">\${${field.name} | raw}</a>`
614
+ return `<a href="${href}" ${linkTarget} onclick="return false;">\${${nameLabel} | raw}</a>`
602
615
  }else {
603
- return `<a href="${href}" ${linkTarget}>\${${field.name} | raw}</a>`
616
+ return `<a href="${href}" ${linkTarget}>\${${nameLabel} | raw}</a>`
604
617
  }
605
618
  }
606
619
 
@@ -725,7 +738,7 @@ function getLocationTpl(field){
725
738
  }
726
739
 
727
740
  async function getFieldTpl (field, options){
728
- if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel){
741
+ if((field.is_name || field.name === options.labelFieldName) && !options.onlyDisplayLookLabel && field.multiple !== true){
729
742
  return getNameTpl(field, options)
730
743
  }
731
744
  switch (field.type) {
@@ -766,7 +779,7 @@ async function getFieldsTemplate(fields, display){
766
779
  if(display != false){
767
780
  display = true;
768
781
  }
769
- let fieldsName = ['_id'];
782
+ let fieldsName = ['_id', 'space'];
770
783
  let displayFields = [];
771
784
  let fieldsArr = [];
772
785
  if(___namespace.isArray(fields)){
@@ -1687,6 +1700,29 @@ i18next__default["default"]
1687
1700
  }
1688
1701
  });
1689
1702
 
1703
+ /*
1704
+ * @Author: baozhoutao@steedos.com
1705
+ * @Date: 2022-07-13 15:18:03
1706
+ * @LastEditors: baozhoutao@steedos.com
1707
+ * @LastEditTime: 2023-04-11 10:34:26
1708
+ * @Description:
1709
+ */
1710
+
1711
+ async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
1712
+ const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
1713
+ const page = await fetchAPI(api);
1714
+ if (page && page.schema) {
1715
+ page.schema = JSON.parse(page.schema);
1716
+ if(page.schema.data){
1717
+ delete page.schema.data.recordId;
1718
+ delete page.schema.data.objectName;
1719
+ delete page.schema.data.context;
1720
+ delete page.schema.data.global;
1721
+ }
1722
+ return page;
1723
+ }
1724
+ }
1725
+
1690
1726
  async function getQuickEditSchema(object, columnField, options){
1691
1727
  let field = object.fields[columnField.name];
1692
1728
  //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
@@ -2321,20 +2357,26 @@ async function getTableColumns(object, fields, options){
2321
2357
  }
2322
2358
 
2323
2359
  if(window.innerWidth >= 768 && ((field.is_name || field.name === options.labelFieldName) || ((field.type == 'lookup' || field.type == 'master_detail') && ___namespace.isString(field.reference_to) && field.multiple != true)) && options.isRelated){
2324
-
2325
- const drawerRecordDetailSchema = {
2360
+ const recordPage = await getPage({ type: 'record', appId: options.appId, objectName: options.objectName, formFactor: options.formFactor });
2361
+ const drawerRecordDetailSchema = recordPage ? Object.assign({}, recordPage.schema, {
2362
+ "recordId": `\${${options.idFieldName}}`,
2363
+ "data": {
2364
+ ...recordPage.schema.data,
2365
+ "_inDrawer": true, // 用于判断是否在抽屉中
2366
+ "recordLoaded": false, // 重置数据加载状态
2367
+ }
2368
+ }) : {
2326
2369
  "type": "steedos-record-detail",
2327
2370
  "objectApiName": "${objectName}",
2328
2371
  "recordId": `\${${options.idFieldName}}`,
2329
2372
  "showBackButton": false,
2330
2373
  "showButtons": true,
2331
2374
  "data": {
2332
- "_inDrawer": true, // 用于判断是否在抽屉中
2333
- "recordLoaded": false, // 重置数据加载状态
2375
+ "_inDrawer": true, // 用于判断是否在抽屉中
2376
+ "recordLoaded": false, // 重置数据加载状态
2334
2377
  }
2335
2378
  };
2336
2379
 
2337
-
2338
2380
  if(!(field.is_name || field.name === options.labelFieldName)){
2339
2381
  drawerRecordDetailSchema.objectApiName = field.reference_to;
2340
2382
  drawerRecordDetailSchema.recordId = `\${_display.${field.name}.value}`;
@@ -2350,7 +2392,7 @@ async function getTableColumns(object, fields, options){
2350
2392
  "title": "&nbsp;",
2351
2393
  "headerClassName": "hidden",
2352
2394
  "size": "lg",
2353
- "bodyClassName": "p-0 m-0",
2395
+ "bodyClassName": "p-0 m-0 bg-gray-100",
2354
2396
  "closeOnEsc": true,
2355
2397
  "closeOnOutside": true,
2356
2398
  "resizable": true,
@@ -3286,6 +3328,19 @@ function getReadonlyFormAdaptor(object, fields, options){
3286
3328
  // })
3287
3329
 
3288
3330
  var fieldNames = ___namespace.map(fields, function(n){return n.name});
3331
+ var nameField = object.fields[object.NAME_FIELD_KEY];
3332
+ let nameLabel = nameField && nameField.name;
3333
+ if (nameField && nameField.type == "lookup") {
3334
+ if(!nameField.reference_to && (nameField.optionsFunction || nameField._optionsFunction || nameField.options)){
3335
+ if(!nameField.isTableField){
3336
+ nameLabel = `record.${nameField.name}__label`;
3337
+ }
3338
+ } else {
3339
+ nameLabel = `record._display.${nameField.name}.label`;
3340
+ }
3341
+ } else if (nameField){
3342
+ nameLabel = `record._display.${nameField.name} || record.${nameField.name}`;
3343
+ }
3289
3344
  return `
3290
3345
  if(payload.data.data.length === 0){
3291
3346
  var isEditor = !!${options && options.isEditor};
@@ -3327,8 +3382,7 @@ function getReadonlyFormAdaptor(object, fields, options){
3327
3382
  payload.data = data;
3328
3383
  payload.data.__objectName = "${object.name}";
3329
3384
  payload.data.record = record;
3330
-
3331
- payload.data.NAME_FIELD_VALUE = record.${object.NAME_FIELD_KEY || 'name'};
3385
+ payload.data.NAME_FIELD_VALUE = ${nameLabel} || record.name;
3332
3386
  payload.data._master = {
3333
3387
  record: record,
3334
3388
  objectName: "${object.name}",
@@ -4795,7 +4849,8 @@ const getSchema$5 = async (uiSchema, ctx) => {
4795
4849
  type: 'button',
4796
4850
  actionType: 'confirm',
4797
4851
  label: i18next__default["default"].t('frontend_form_save'),
4798
- primary: true
4852
+ primary: true,
4853
+ close: `object_actions_drawer_${uiSchema.name}`
4799
4854
  },
4800
4855
  ]
4801
4856
  }
@@ -4813,29 +4868,6 @@ const getSchema$5 = async (uiSchema, ctx) => {
4813
4868
  }
4814
4869
  };
4815
4870
 
4816
- /*
4817
- * @Author: baozhoutao@steedos.com
4818
- * @Date: 2022-07-13 15:18:03
4819
- * @LastEditors: baozhoutao@steedos.com
4820
- * @LastEditTime: 2023-04-11 10:34:26
4821
- * @Description:
4822
- */
4823
-
4824
- async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
4825
- const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
4826
- const page = await fetchAPI(api);
4827
- if (page && page.schema) {
4828
- page.schema = JSON.parse(page.schema);
4829
- if(page.schema.data){
4830
- delete page.schema.data.recordId;
4831
- delete page.schema.data.objectName;
4832
- delete page.schema.data.context;
4833
- delete page.schema.data.global;
4834
- }
4835
- return page;
4836
- }
4837
- }
4838
-
4839
4871
  /*
4840
4872
  * @Author: baozhoutao@steedos.com
4841
4873
  * @Date: 2022-11-01 15:49:58
@@ -4914,6 +4946,20 @@ const getSchema$4 = async (uiSchema, ctx) => {
4914
4946
  ]
4915
4947
  }
4916
4948
  },
4949
+ "actions": [
4950
+ {
4951
+ type: 'button',
4952
+ actionType: 'cancel',
4953
+ label: i18next__default["default"].t('frontend_form_cancel')
4954
+ },
4955
+ {
4956
+ type: 'button',
4957
+ actionType: 'confirm',
4958
+ label: i18next__default["default"].t('frontend_form_save'),
4959
+ primary: true,
4960
+ close: `object_actions_drawer_${uiSchema.name}`
4961
+ },
4962
+ ]
4917
4963
  },
4918
4964
  },
4919
4965
  ],
@@ -4995,7 +5041,8 @@ const getSchema$3 = (uiSchema)=>{
4995
5041
  }
4996
5042
  ]
4997
5043
  }
4998
- }
5044
+ },
5045
+ "close": `object_actions_drawer_${uiSchema.name}`
4999
5046
  }
5000
5047
  ],
5001
5048
  "regions": [
@@ -8930,10 +8977,6 @@ async function getObjectCRUD(objectSchema, fields, options){
8930
8977
  }
8931
8978
  }
8932
8979
  `;
8933
- let autoFillHeight = true;
8934
- if(options.isRelated || window.innerWidth < 768){
8935
- autoFillHeight = false;
8936
- }
8937
8980
 
8938
8981
  body = Object.assign({}, table, {
8939
8982
  type: 'crud',
@@ -8944,7 +8987,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8944
8987
  keepItemSelectionOnPageChange: true,
8945
8988
  api: await getTableApi(objectSchema, fields, options),
8946
8989
  hiddenOn: options.tableHiddenOn,
8947
- autoFillHeight,
8990
+ // autoFillHeight,//autoFillHeight按amis规范默认为false,需要配置此属性时在各个组件层配置,比如列表视图组件那边传入此属性为true
8948
8991
  className: `flex-auto ${crudClassName || ""}`,
8949
8992
  // 这里不可以用动态className,因为它会把样式类加到.antd-Crud和.antd-Table.antd-Crud-body这两层div中,而子表列表中crudClassName中有hidden样式类会造成所有子表都不显示的bug
8950
8993
  // className: {
@@ -9117,6 +9160,10 @@ async function getFormSchemaWithDataFilter(form, options = {}){
9117
9160
  async function getObjectForm(objectSchema, ctx){
9118
9161
  const { recordId, formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign, tabId, appId, defaults, submitSuccActions = [],
9119
9162
  formDataFilter, onFormDataFilter, amisData, env } = ctx;
9163
+ //优先识别组件上的enableTabs属性,若不存在,则识别对象上定义的
9164
+ if (typeof ctx.enableTabs !== 'boolean') {
9165
+ ctx.enableTabs = objectSchema.enable_form_tabs;
9166
+ }
9120
9167
  const fields = ___default["default"].values(objectSchema.fields);
9121
9168
  const formFields = getFormFields$1(objectSchema, ctx);
9122
9169
  const formSchema = defaults && defaults.formSchema || {};
@@ -9210,7 +9257,7 @@ async function getObjectForm(objectSchema, ctx){
9210
9257
 
9211
9258
  async function getObjectDetail(objectSchema, recordId, ctx){
9212
9259
  const { formFactor, layout = formFactor === 'SMALL' ? 'normal' : "horizontal", labelAlign,
9213
- formDataFilter, onFormDataFilter, amisData, env } = ctx;
9260
+ formDataFilter, onFormDataFilter, amisData, env, enableInitApi } = ctx;
9214
9261
  const fields = ___default["default"].values(objectSchema.fields);
9215
9262
  const formFields = getFormFields$1(objectSchema, ctx);
9216
9263
  const serviceId = `service_detail_page`;
@@ -9277,6 +9324,16 @@ async function getObjectDetail(objectSchema, recordId, ctx){
9277
9324
  // }
9278
9325
  };
9279
9326
 
9327
+ if(enableInitApi){
9328
+ amisSchema.api = await getReadonlyFormInitApi(objectSchema, recordId, fields, ctx);
9329
+ // 开启初始化api请求时,如果不把recordLoaded默认设置为false,recordLoaded值会取RecordServic组件中的recordLoaded值
9330
+ // 这会造成表单内steedos field组件lookup字段中props.data取到的是RecordServic组件
9331
+ amisSchema.data = {
9332
+ ...amisSchema.data,
9333
+ recordLoaded: false
9334
+ };
9335
+ }
9336
+
9280
9337
  amisSchema.body[0].body = await getFormSchemaWithDataFilter(amisSchema.body[0].body, { formDataFilter, onFormDataFilter, amisData, env });
9281
9338
  // console.log('getObjectDetail=====>', amisSchema);
9282
9339
  return amisSchema;
@@ -9768,7 +9825,7 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
9768
9825
  * @Author: baozhoutao@steedos.com
9769
9826
  * @Date: 2022-07-05 15:55:39
9770
9827
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
9771
- * @LastEditTime: 2024-02-23 16:37:06
9828
+ * @LastEditTime: 2024-04-26 16:46:44
9772
9829
  * @Description:
9773
9830
  */
9774
9831
 
@@ -10033,37 +10090,44 @@ async function getListSchema(
10033
10090
  * 本次存储代码段
10034
10091
  */
10035
10092
  try {
10036
- const listViewPropsStoreKey = location.pathname + "/crud";
10037
- let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10038
- /**
10039
- * localListViewProps规范来自crud请求api中api.data.$self参数值的。
10040
- * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
10041
- * __searchable__...:顶部放大镜搜索条件
10042
- * filter:右侧过滤器
10043
- * perPage:每页条数
10044
- * page:当前页码
10045
- * orderBy:排序字段
10046
- * orderDir:排序方向
10047
- */
10048
- if (localListViewProps) {
10049
- localListViewProps = JSON.parse(localListViewProps);
10050
- // localListViewProps.perPage = 3;
10051
- let listSchema = {};
10052
- if(localListViewProps.orderBy){
10053
- listSchema.orderBy = localListViewProps.orderBy;
10054
- }
10055
- if(localListViewProps.orderDir){
10056
- listSchema.orderDir = localListViewProps.orderDir;
10057
- }
10093
+ const listViewPropsStoreKey = location.pathname + "/crud";
10094
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
10095
+ /**
10096
+ * localListViewProps规范来自crud请求api中api.data.$self参数值的。
10097
+ * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
10098
+ * __searchable__...:顶部放大镜搜索条件
10099
+ * filter:右侧过滤器
10100
+ * perPage:每页条数
10101
+ * page:当前页码
10102
+ * orderBy:排序字段
10103
+ * orderDir:排序方向
10104
+ */
10105
+ if (localListViewProps) {
10106
+ localListViewProps = JSON.parse(localListViewProps);
10107
+ // localListViewProps.perPage = 3;
10108
+ let listSchema = {};
10109
+ if (localListViewProps.orderBy) {
10110
+ listSchema.orderBy = localListViewProps.orderBy;
10111
+ }
10112
+ if (localListViewProps.orderDir) {
10113
+ listSchema.orderDir = localListViewProps.orderDir;
10114
+ }
10058
10115
 
10059
- if(localListViewProps.perPage){
10060
- listSchema.perPage = localListViewProps.perPage;
10116
+ if (localListViewProps.perPage) {
10117
+ listSchema.perPage = localListViewProps.perPage;
10118
+ }
10119
+ defaults.listSchema = _$1.defaultsDeep({}, listSchema, defaults.listSchema || {});
10061
10120
  }
10062
- defaults.listSchema = _$1.defaultsDeep({}, listSchema, defaults.listSchema || {});
10063
- }
10064
10121
  }
10065
10122
  catch (ex) {
10066
- console.error("本地存储中crud参数解析异常:", ex);
10123
+ console.error("本地存储中crud参数解析异常:", ex);
10124
+ }
10125
+
10126
+ if (window.innerWidth > 768) {
10127
+ // 列表视图组件PC端高度自动计算实现满屏效果,手机端不需要满屏效果,所以不用autofillheight,且允许重写微页面中重新组件autoFillHeight属性
10128
+ defaults.listSchema = _$1.defaultsDeep({}, defaults.listSchema || {}, {
10129
+ autoFillHeight: true
10130
+ });
10067
10131
  }
10068
10132
 
10069
10133
  ctx.defaults = defaults;
@@ -10113,15 +10177,15 @@ async function getListSchema(
10113
10177
  async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10114
10178
  let fields = [];
10115
10179
  for (const column of columns) {
10180
+ let columnField, fieldName, displayName, filedInfo, rfUiSchema, rfFieldInfo;
10116
10181
  if (_$1.isString(column)) {
10117
- let columnField;
10118
10182
  if (column.indexOf('.') > 0) {
10119
- const fieldName = column.split('.')[0];
10120
- const displayName = column.split('.')[1];
10121
- const filedInfo = uiSchema.fields[fieldName];
10183
+ fieldName = column.split('.')[0];
10184
+ displayName = column.split('.')[1];
10185
+ filedInfo = uiSchema.fields[fieldName];
10122
10186
  if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to)) {
10123
- const rfUiSchema = await getUISchema(filedInfo.reference_to);
10124
- const rfFieldInfo = rfUiSchema.fields[displayName];
10187
+ rfUiSchema = await getUISchema(filedInfo.reference_to);
10188
+ rfFieldInfo = rfUiSchema.fields[displayName];
10125
10189
  columnField = Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx);
10126
10190
  }else if(filedInfo && filedInfo.type === 'object'){
10127
10191
  columnField = uiSchema.fields[column];
@@ -10145,14 +10209,13 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10145
10209
  }
10146
10210
 
10147
10211
  } else if (_$1.isObject(column)) {
10148
- let columnField;
10149
10212
  if (column.field.indexOf('.') > 0) {
10150
- const fieldName = column.field.split('.')[0];
10151
- const displayName = column.field.split('.')[1];
10152
- const filedInfo = uiSchema.fields[fieldName];
10213
+ fieldName = column.field.split('.')[0];
10214
+ displayName = column.field.split('.')[1];
10215
+ filedInfo = uiSchema.fields[fieldName];
10153
10216
  if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && _$1.isString(filedInfo.reference_to)) {
10154
- const rfUiSchema = await getUISchema(filedInfo.reference_to);
10155
- const rfFieldInfo = rfUiSchema.fields[displayName];
10217
+ rfUiSchema = await getUISchema(filedInfo.reference_to);
10218
+ rfFieldInfo = rfUiSchema.fields[displayName];
10156
10219
  columnField = Object.assign({}, rfFieldInfo, ctx,
10157
10220
  { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } },
10158
10221
  {
@@ -10160,6 +10223,8 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10160
10223
  wrap: column.wrap // wrap = true 是没效果的
10161
10224
  }
10162
10225
  );
10226
+ } else if (filedInfo && filedInfo.type === 'object') {
10227
+ columnField = uiSchema.fields[column.field];
10163
10228
  }
10164
10229
  } else {
10165
10230
  if (uiSchema.fields[column.field]) {
@@ -10294,7 +10359,7 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
10294
10359
  };
10295
10360
  const content = {
10296
10361
  "type": "tabs",
10297
- "className": "steedos-record-tabs bg-white p-4 mt-2",
10362
+ "className": "steedos-record-tabs bg-white p-4 m-2 border rounded",
10298
10363
  "contentClassName": "bg-none",
10299
10364
  "tabs": [
10300
10365
  detailed
@@ -10370,6 +10435,10 @@ async function getRecordServiceSchema(objectName, appId, props = {}, body) {
10370
10435
  data: {
10371
10436
  "_master.objectName": "${objectName}",
10372
10437
  "_master.recordId": "${recordId}",
10438
+ // 微页面设计器中用RecordServic组件包裹一个ObjectForm只读组件时,如果这里不把recordLoaded默认设置为false
10439
+ // recordLoaded值会取父作用域中已经被设置为true的值(比如父级有RecordServic组件,在加载完数据后,父作用域中recordLoaded值为true)
10440
+ // 这会造成表单内steedos field组件lookup字段中props.data取到的是父作用域中的数据
10441
+ "recordLoaded": false,
10373
10442
  ...(props.data || {})
10374
10443
  },
10375
10444
  "style": {
@@ -11258,7 +11327,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
11258
11327
  });
11259
11328
 
11260
11329
  // 把自动填充规则中依赖的字段也加到api请求中
11261
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
11330
+ let autoFillMapping = field.auto_fill_mapping;
11262
11331
  if (autoFillMapping && autoFillMapping.length) {
11263
11332
  autoFillMapping.forEach(function (item) {
11264
11333
  if(!___namespace.find(tableFields, function(f){
@@ -11408,7 +11477,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
11408
11477
  // 如果当前元素不是数组,则处理该元素
11409
11478
  // 下面正则用于匹配amis公式\${}
11410
11479
  if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
11411
- arr[i] = currentAmis.evaluate(arr[i], api.data.$);
11480
+ try{
11481
+ arr[i] = currentAmis.evaluate(arr[i], api.context);
11482
+ }catch(ex){
11483
+ console.error("运行lookup过滤公式时出现错误:",ex);
11484
+ }
11412
11485
  }
11413
11486
  }
11414
11487
  }
@@ -11730,7 +11803,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11730
11803
  ];
11731
11804
 
11732
11805
  // 把自动填充规则中依赖的字段也加到api请求中
11733
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
11806
+ let autoFillMapping = field.auto_fill_mapping;
11734
11807
  if (autoFillMapping && autoFillMapping.length) {
11735
11808
  autoFillMapping.forEach(function (item) {
11736
11809
  queryFields.push(refObjectConfig.fields[item.from]);
@@ -11816,6 +11889,7 @@ async function lookupToAmisSelect(field, readonly, ctx){
11816
11889
  var fieldFilters = ${JSON.stringify(field.filters)};
11817
11890
  var currentAmis = amisRequire('amis');
11818
11891
  //递归fieldFilters数组,检查每一个元素,判断若是公式,就仅把它解析
11892
+ debugger;
11819
11893
  function traverseNestedArray(arr) {
11820
11894
  for (let i = 0; i < arr.length; i++) {
11821
11895
  if (Array.isArray(arr[i])) {
@@ -11825,7 +11899,11 @@ async function lookupToAmisSelect(field, readonly, ctx){
11825
11899
  // 如果当前元素不是数组,则处理该元素
11826
11900
  // 下面正则用于匹配amis公式\${}
11827
11901
  if(/\\\$\\\{([^}]*)\\\}/.test(arr[i])) {
11828
- arr[i] = currentAmis.evaluate(arr[i], api.data.$);
11902
+ try{
11903
+ arr[i] = currentAmis.evaluate(arr[i], api.context);
11904
+ }catch(ex){
11905
+ console.error("运行lookup过滤公式时出现错误:",ex);
11906
+ }
11829
11907
  }
11830
11908
  }
11831
11909
  }
@@ -11972,14 +12050,25 @@ async function getApi(object, recordId, fields, options){
11972
12050
  }
11973
12051
 
11974
12052
  async function getAutoFill(field, refObject) {
11975
- let autoFillMapping = !field.multiple && field.auto_fill_mapping;
12053
+ let autoFillMapping = field.auto_fill_mapping;
11976
12054
  if (autoFillMapping && autoFillMapping.length) {
11977
12055
  let fillMapping = {};
12056
+ if (field.multiple) {
12057
+ autoFillMapping.forEach(function (item) {
12058
+ //from的字段类型为lookup、master_detail、select时,需要保留数组格式;其他类型需要转变为字符串格式
12059
+ if (___namespace.includes(["lookup","master_detail","select"], refObject.fields[item.from].type)) {
12060
+ fillMapping[item.to] = `\${items | pick:${item.from}}`;
12061
+ } else {
12062
+ fillMapping[item.to] = `\${items | pick:${item.from} | join}`;
12063
+ }
12064
+ });
12065
+ }else {
12066
+ autoFillMapping.forEach(function (item) {
12067
+ fillMapping[item.to] = `\${${item.from}}`;
12068
+ });
12069
+ }
11978
12070
  // let fieldsForApi = [];
11979
- autoFillMapping.forEach(function (item) {
11980
- fillMapping[item.to] = `\${${item.from}}`;
11981
- // fieldsForApi.push(item.from);
11982
- });
12071
+ // fieldsForApi.push(item.from);
11983
12072
  // let api = {
11984
12073
  // // "url": "/amis/api/mock2/form/autoUpdate?browser=${browser}&version=${version}",
11985
12074
  // "url": `/api/v1/${refObject.name}/\${${field.name}}?fields=${JSON.stringify(fieldsForApi)}`,
@@ -12081,7 +12170,7 @@ async function lookupToAmis(field, readonly, ctx){
12081
12170
  amisSchema = ___namespace.defaultsDeep({}, pageAmisSchema, amisSchema);
12082
12171
  }
12083
12172
  }
12084
- const autoFill = await getAutoFill(field);
12173
+ const autoFill = await getAutoFill(field, refObject);
12085
12174
  if(autoFill){
12086
12175
  amisSchema.autoFill = autoFill;
12087
12176
  // 这里不配置initAutoFill值,按amis规则initAutoFill默认值为fillIfNotSet处理--需要amis sdk 版本 > 3.6.3-patch.6(不包括)版本