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

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
@@ -2536,6 +2536,7 @@ async function getTableColumns(object, fields, options){
2536
2536
  type: "lookup",
2537
2537
  reference_to: field.reference_to,
2538
2538
  name: field.name,
2539
+ is_name: field.is_name,
2539
2540
  label: null,
2540
2541
  multiple: field.multiple,
2541
2542
  amis: Object.assign({}, fieldAmis, { label: null })
@@ -12506,7 +12507,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
12506
12507
  {
12507
12508
  "actionType": "custom",
12508
12509
  "script": `
12509
- const masterRecord = event.data._master && event.data._master.record;
12510
+ // lookup字段弹出列表,点击新建按钮,新建记录成功后,触发@data.changed.xxx,
12511
+ // 此时context.props.data值是lookup字段所在表单数据,经测试多层lookup弹出列表新建记录成功后context.props.data始终取的是最近一层的lookup字段所在表单数据,符合预期
12512
+ const masterRecord = context.props.data;//event.data._master && event.data._master.record;
12510
12513
  const fieldConfig = ${JSON.stringify(field)};
12511
12514
  let reference_to = fieldConfig.reference_to;
12512
12515
  let saveValue;
@@ -12516,7 +12519,6 @@ async function lookupToAmisPicker(field, readonly, ctx){
12516
12519
  }
12517
12520
  const saveField = fieldConfig.reference_to_field || '_id';
12518
12521
  const saveFieldValue = newRecord[saveField];
12519
-
12520
12522
  if( fieldConfig._reference_to && (_.isArray(fieldConfig._reference_to) || _.isFunction(fieldConfig._reference_to) || fieldConfig._reference_to.startsWith('function') ) ){
12521
12523
 
12522
12524
  const fieldValue = masterRecord ? masterRecord[fieldConfig.name] : {o: reference_to, ids: []};
@@ -12536,8 +12538,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
12536
12538
 
12537
12539
  }else{
12538
12540
  if(fieldConfig.multiple){
12539
- // TODO: 连续新建多个记录时,因为获取的主记录不是实时的,所以只会勾选最后一个新建的记录。
12540
- const fieldValue = (masterRecord && masterRecord[fieldConfig.name]) || [];
12541
+ // const fieldValue = (masterRecord && masterRecord[fieldConfig.name]) || [];
12542
+ // 连续新建多个记录时,因为masterRecord获取的主记录不是实时的,所以只会勾选最后一个新建的记录
12543
+ // 而下面context.context.component指向的是lookup picker组件,可以直接取到用户实时勾选的记录。
12544
+ const fieldValue = context.context.component.props.store.toJSON().selectedItems
12541
12545
  saveValue = fieldValue.concat(saveFieldValue);
12542
12546
  }else{
12543
12547
  saveValue = saveFieldValue;