@steedos-widgets/amis-lib 1.2.35-beta.1 → 1.2.35-beta.2

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
@@ -625,9 +625,10 @@ async function getFieldTpl (field, options){
625
625
  }
626
626
  }
627
627
 
628
- async function getFieldsTemplate(fields, expand){
629
- if(expand != false){
630
- expand = true;
628
+ async function getFieldsTemplate(fields, display){
629
+ let expandFields = [];
630
+ if(display != false){
631
+ display = true;
631
632
  }
632
633
  let fieldsName = ['_id'];
633
634
  let displayFields = [];
@@ -639,33 +640,43 @@ async function getFieldsTemplate(fields, expand){
639
640
  }
640
641
  for (const field of fieldsArr) {
641
642
  //graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
642
- if(field.name.indexOf('.') < 0){
643
- if(expand && (field.type == 'lookup' || field.type == 'master_detail')){
644
- fieldsName.push(`${field.name}`);
645
- displayFields.push(`${field.name}`);
643
+ if(field.expand){
644
+ expandFields.push(field);
645
+ }else {
646
+ if(field.name.indexOf('.') < 0){
647
+ if(display && (field.type == 'lookup' || field.type == 'master_detail')){
648
+ fieldsName.push(`${field.name}`);
649
+ displayFields.push(`${field.name}`);
650
+ }else {
651
+ fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
652
+ }
653
+ if(includes(['time','date','datetime','boolean','number','currency'], field.type)){
654
+ fieldsName.push(`${field.name}`);
655
+ }
656
+ if(includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
657
+ displayFields.push(`${field.name}`);
658
+ }
646
659
  }else {
647
- fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
648
- }
649
- if(includes(['time','date','datetime','boolean','number','currency'], field.type)){
650
- fieldsName.push(`${field.name}`);
651
- }
652
- if(includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
653
- displayFields.push(`${field.name}`);
660
+ objectFieldName = field.name.split('.')[0];
661
+ fieldsName.push(objectFieldName);
662
+ displayFields.push(objectFieldName);
654
663
  }
655
- }else {
656
- objectFieldName = field.name.split('.')[0];
657
- fieldsName.push(objectFieldName);
658
- displayFields.push(objectFieldName);
659
664
  }
660
665
  }
661
666
 
662
667
  displayFields = _$1.uniq(displayFields);
663
668
  fieldsName = _$1.uniq(fieldsName);
669
+ let expandFieldsQuery = "";
670
+ if(expandFields.length > 0){
671
+ _$1.each(expandFields, function(field){
672
+ expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
673
+ });
674
+ }
664
675
 
665
676
  if(displayFields.length > 0){
666
- return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
677
+ return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
667
678
  }
668
- return `${fieldsName.join(' ')}`
679
+ return `${fieldsName.join(' ')},${expandFieldsQuery}`
669
680
  }
670
681
 
671
682
  function getRecordPermissionsTemplate(){
@@ -10361,8 +10372,8 @@ async function getRelatedListSchema(
10361
10372
  /*
10362
10373
  * @Author: baozhoutao@steedos.com
10363
10374
  * @Date: 2022-07-05 15:55:39
10364
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
10365
- * @LastEditTime: 2023-06-04 17:36:49
10375
+ * @LastEditors: baozhoutao@steedos.com
10376
+ * @LastEditTime: 2023-07-29 13:58:07
10366
10377
  * @Description:
10367
10378
  */
10368
10379
 
@@ -10696,6 +10707,7 @@ async function getListSchema(
10696
10707
  "filterVisible": ctx.filterVisible,
10697
10708
  "rowClassNameExpr": ctx.rowClassNameExpr
10698
10709
  };
10710
+ // console.log(`getListSchema===>`,amisSchema)
10699
10711
  return {
10700
10712
  uiSchema,
10701
10713
  amisSchema,
@@ -10709,7 +10721,7 @@ async function getTableSchema(
10709
10721
  columns,
10710
10722
  ctx = {}
10711
10723
  ) {
10712
- // console.time('getTableSchema');
10724
+ // console.time('getTableSchema', columns);
10713
10725
  const uiSchema = await getUISchema(objectName);
10714
10726
 
10715
10727
  let sort = ctx.sort;
@@ -10723,19 +10735,52 @@ async function getTableSchema(
10723
10735
  }
10724
10736
 
10725
10737
  let fields = [];
10726
- each(columns, function (column) {
10727
- if (isString(column) && uiSchema.fields[column]) {
10728
- fields.push(uiSchema.fields[column]);
10729
- } else if (isObject$1(column) && uiSchema.fields[column.field]) {
10730
- fields.push(
10731
- Object.assign({}, uiSchema.fields[column.field], {
10732
- width: column.width,
10733
- wrap: column.wrap, // wrap = true 是没效果的
10734
- amis: column.amis
10735
- })
10736
- );
10738
+ for(const column of columns){
10739
+ if (isString(column)) {
10740
+ if(column.indexOf('.') > 0){
10741
+ const fieldName = column.split('.')[0];
10742
+ const displayName = column.split('.')[1];
10743
+ const filedInfo = uiSchema.fields[fieldName];
10744
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to) ){
10745
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
10746
+ const rfFieldInfo = rfUiSchema.fields[displayName];
10747
+ fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
10748
+ }
10749
+ }else {
10750
+ if(uiSchema.fields[column]){
10751
+ fields.push(uiSchema.fields[column]);
10752
+ }
10753
+ }
10754
+ } else if (isObject$1(column)) {
10755
+ if(column.field.indexOf('.') > 0){
10756
+ const fieldName = column.field.split('.')[0];
10757
+ const displayName = column.field.split('.')[1];
10758
+ const filedInfo = uiSchema.fields[fieldName];
10759
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to) ){
10760
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
10761
+ const rfFieldInfo = rfUiSchema.fields[displayName];
10762
+ fields.push(Object.assign({}, rfFieldInfo,
10763
+ {name: column.field, expand: true, expandInfo: {fieldName, displayName}},
10764
+ {
10765
+ width: column.width,
10766
+ wrap: column.wrap, // wrap = true 是没效果的
10767
+ amis: column.amis
10768
+ }
10769
+ ));
10770
+ }
10771
+ }else {
10772
+ if(uiSchema.fields[column.field]){
10773
+ fields.push(
10774
+ Object.assign({}, uiSchema.fields[column.field], {
10775
+ width: column.width,
10776
+ wrap: column.wrap, // wrap = true 是没效果的
10777
+ amis: column.amis
10778
+ })
10779
+ );
10780
+ }
10781
+ }
10737
10782
  }
10738
- });
10783
+ }
10739
10784
 
10740
10785
  const extraColumns = ctx.extraColumns;
10741
10786