@steedos-widgets/amis-object 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.
@@ -3794,9 +3794,10 @@ async function getFieldTpl (field, options){
3794
3794
  }
3795
3795
  }
3796
3796
 
3797
- async function getFieldsTemplate(fields, expand){
3798
- if(expand != false){
3799
- expand = true;
3797
+ async function getFieldsTemplate(fields, display){
3798
+ let expandFields = [];
3799
+ if(display != false){
3800
+ display = true;
3800
3801
  }
3801
3802
  let fieldsName = ['_id'];
3802
3803
  let displayFields = [];
@@ -3808,33 +3809,43 @@ async function getFieldsTemplate(fields, expand){
3808
3809
  }
3809
3810
  for (const field of fieldsArr) {
3810
3811
  //graphql 的 ui\display 中使用的字段需要先在query中查询. 否则会返回null
3811
- if(field.name.indexOf('.') < 0){
3812
- if(expand && (field.type == 'lookup' || field.type == 'master_detail')){
3813
- fieldsName.push(`${field.name}`);
3814
- displayFields.push(`${field.name}`);
3812
+ if(field.expand){
3813
+ expandFields.push(field);
3814
+ }else {
3815
+ if(field.name.indexOf('.') < 0){
3816
+ if(display && (field.type == 'lookup' || field.type == 'master_detail')){
3817
+ fieldsName.push(`${field.name}`);
3818
+ displayFields.push(`${field.name}`);
3819
+ }else {
3820
+ fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
3821
+ }
3822
+ if(___default.includes(['time','date','datetime','boolean','number','currency'], field.type)){
3823
+ fieldsName.push(`${field.name}`);
3824
+ }
3825
+ if(___default.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
3826
+ displayFields.push(`${field.name}`);
3827
+ }
3815
3828
  }else {
3816
- fieldsName.push( field.alias ? `${field.alias}:${field.name}` : field.name);
3817
- }
3818
- if(___default.includes(['time','date','datetime','boolean','number','currency'], field.type)){
3819
- fieldsName.push(`${field.name}`);
3820
- }
3821
- if(___default.includes(['percent','time','filesize','date','datetime','boolean','number','currency', 'select', 'file', 'image', 'avatar', 'formula', 'summary', 'object', 'grid'], field.type)){
3822
- displayFields.push(`${field.name}`);
3829
+ objectFieldName = field.name.split('.')[0];
3830
+ fieldsName.push(objectFieldName);
3831
+ displayFields.push(objectFieldName);
3823
3832
  }
3824
- }else {
3825
- objectFieldName = field.name.split('.')[0];
3826
- fieldsName.push(objectFieldName);
3827
- displayFields.push(objectFieldName);
3828
3833
  }
3829
3834
  }
3830
3835
 
3831
3836
  displayFields = ___default__namespace.uniq(displayFields);
3832
3837
  fieldsName = ___default__namespace.uniq(fieldsName);
3838
+ let expandFieldsQuery = "";
3839
+ if(expandFields.length > 0){
3840
+ ___default__namespace.each(expandFields, function(field){
3841
+ expandFieldsQuery = expandFieldsQuery + `${field.expandInfo.fieldName}:${field.expandInfo.fieldName}__expand{${field.expandInfo.displayName}}`;
3842
+ });
3843
+ }
3833
3844
 
3834
3845
  if(displayFields.length > 0){
3835
- return `${fieldsName.join(',')},_display:_ui{${displayFields.join(',')}}`;
3846
+ return `${fieldsName.join(',')},${expandFieldsQuery},_display:_ui{${displayFields.join(',')}}`;
3836
3847
  }
3837
- return `${fieldsName.join(' ')}`
3848
+ return `${fieldsName.join(' ')},${expandFieldsQuery}`
3838
3849
  }
3839
3850
 
3840
3851
  function getRecordPermissionsTemplate(){
@@ -13530,8 +13541,8 @@ async function getRelatedListSchema(
13530
13541
  /*
13531
13542
  * @Author: baozhoutao@steedos.com
13532
13543
  * @Date: 2022-07-05 15:55:39
13533
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13534
- * @LastEditTime: 2023-06-04 17:36:49
13544
+ * @LastEditors: baozhoutao@steedos.com
13545
+ * @LastEditTime: 2023-07-29 13:58:07
13535
13546
  * @Description:
13536
13547
  */
13537
13548
 
@@ -13865,6 +13876,7 @@ async function getListSchema(
13865
13876
  "filterVisible": ctx.filterVisible,
13866
13877
  "rowClassNameExpr": ctx.rowClassNameExpr
13867
13878
  };
13879
+ // console.log(`getListSchema===>`,amisSchema)
13868
13880
  return {
13869
13881
  uiSchema,
13870
13882
  amisSchema,
@@ -13878,7 +13890,7 @@ async function getTableSchema(
13878
13890
  columns,
13879
13891
  ctx = {}
13880
13892
  ) {
13881
- // console.time('getTableSchema');
13893
+ // console.time('getTableSchema', columns);
13882
13894
  const uiSchema = await getUISchema(objectName);
13883
13895
 
13884
13896
  let sort = ctx.sort;
@@ -13892,19 +13904,52 @@ async function getTableSchema(
13892
13904
  }
13893
13905
 
13894
13906
  let fields = [];
13895
- ___default.each(columns, function (column) {
13896
- if (___default.isString(column) && uiSchema.fields[column]) {
13897
- fields.push(uiSchema.fields[column]);
13898
- } else if (___default.isObject(column) && uiSchema.fields[column.field]) {
13899
- fields.push(
13900
- Object.assign({}, uiSchema.fields[column.field], {
13901
- width: column.width,
13902
- wrap: column.wrap, // wrap = true 是没效果的
13903
- amis: column.amis
13904
- })
13905
- );
13907
+ for(const column of columns){
13908
+ if (___default.isString(column)) {
13909
+ if(column.indexOf('.') > 0){
13910
+ const fieldName = column.split('.')[0];
13911
+ const displayName = column.split('.')[1];
13912
+ const filedInfo = uiSchema.fields[fieldName];
13913
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && ___default.isString(filedInfo.reference_to) ){
13914
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
13915
+ const rfFieldInfo = rfUiSchema.fields[displayName];
13916
+ fields.push(Object.assign({}, rfFieldInfo, {name: column, expand: true, expandInfo: {fieldName, displayName}}));
13917
+ }
13918
+ }else {
13919
+ if(uiSchema.fields[column]){
13920
+ fields.push(uiSchema.fields[column]);
13921
+ }
13922
+ }
13923
+ } else if (___default.isObject(column)) {
13924
+ if(column.field.indexOf('.') > 0){
13925
+ const fieldName = column.field.split('.')[0];
13926
+ const displayName = column.field.split('.')[1];
13927
+ const filedInfo = uiSchema.fields[fieldName];
13928
+ if(filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && ___default.isString(filedInfo.reference_to) ){
13929
+ const rfUiSchema = await getUISchema(filedInfo.reference_to);
13930
+ const rfFieldInfo = rfUiSchema.fields[displayName];
13931
+ fields.push(Object.assign({}, rfFieldInfo,
13932
+ {name: column.field, expand: true, expandInfo: {fieldName, displayName}},
13933
+ {
13934
+ width: column.width,
13935
+ wrap: column.wrap, // wrap = true 是没效果的
13936
+ amis: column.amis
13937
+ }
13938
+ ));
13939
+ }
13940
+ }else {
13941
+ if(uiSchema.fields[column.field]){
13942
+ fields.push(
13943
+ Object.assign({}, uiSchema.fields[column.field], {
13944
+ width: column.width,
13945
+ wrap: column.wrap, // wrap = true 是没效果的
13946
+ amis: column.amis
13947
+ })
13948
+ );
13949
+ }
13950
+ }
13906
13951
  }
13907
- });
13952
+ }
13908
13953
 
13909
13954
  const extraColumns = ctx.extraColumns;
13910
13955