@steedos-widgets/amis-lib 3.6.4-beta.3 → 3.6.4-beta.4

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
@@ -1653,7 +1653,8 @@ i18next
1653
1653
  }
1654
1654
  });
1655
1655
 
1656
- async function getQuickEditSchema(field, options){
1656
+ async function getQuickEditSchema(object, columnField, options){
1657
+ let field = object.fields[columnField.name];
1657
1658
  //判断在amis3.2以上环境下,放开批量编辑与lookup的单元格编辑
1658
1659
  let isAmisVersionforBatchEdit = false;
1659
1660
  if(window.amisRequire && window.amisRequire('amis')){
@@ -2121,7 +2122,7 @@ function getFieldWidth(width){
2121
2122
  }
2122
2123
  }
2123
2124
 
2124
- async function getTableColumns(fields, options){
2125
+ async function getTableColumns(object, fields, options){
2125
2126
  const columns = [];
2126
2127
  if(!options.isLookup && !options.isInputTable){
2127
2128
  if(!options.enable_tree){
@@ -2135,7 +2136,7 @@ async function getTableColumns(fields, options){
2135
2136
  continue;
2136
2137
  }
2137
2138
  //增加quickEdit属性,实现快速编辑
2138
- const quickEditSchema = allowEdit ? await getQuickEditSchema(field, options) : allowEdit;
2139
+ const quickEditSchema = allowEdit ? await getQuickEditSchema(object, field, options) : allowEdit;
2139
2140
  let className = "";
2140
2141
  const bowserType = getBowserType();
2141
2142
  if(bowserType === "Safari"){
@@ -2707,7 +2708,7 @@ async function getDefaultCrudCard(columns, options) {
2707
2708
  return card;
2708
2709
  }
2709
2710
 
2710
- async function getTableSchema$1(fields, options){
2711
+ async function getTableSchema$1(object, fields, options){
2711
2712
  if(!options){
2712
2713
  options = {};
2713
2714
  }
@@ -2729,7 +2730,7 @@ async function getTableSchema$1(fields, options){
2729
2730
  columns = await getMobileTableColumns(fields, options);
2730
2731
  }
2731
2732
  else {
2732
- columns = await getTableColumns(fields, options);
2733
+ columns = await getTableColumns(object, fields, options);
2733
2734
 
2734
2735
  if(listSchema.mode === "cards"){
2735
2736
  let card = listSchema.card;
@@ -8817,7 +8818,7 @@ async function getObjectCRUD(objectSchema, fields, options){
8817
8818
  crudId: listSchema.id || id, enable_tree: objectSchema.enable_tree
8818
8819
  }, options);
8819
8820
  tableOptions.amisData = createObject(options.amisData || {}, {});
8820
- const table = await getTableSchema$1(fields, tableOptions);
8821
+ const table = await getTableSchema$1(objectSchema, fields, tableOptions);
8821
8822
  // delete table.mode;
8822
8823
  //image与avatar需要在提交修改时特别处理
8823
8824
  const imageNames = ___default.compact(___default.map(___default.filter(fields, (field) => ["image","avatar"].includes(field.type)), 'name'));
@@ -9084,7 +9085,7 @@ async function getObjectForm(objectSchema, ctx){
9084
9085
  body: {
9085
9086
  type: 'wrapper',
9086
9087
  className: 'p-0 m-0',
9087
- body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups})),
9088
+ body: await getFormBody(fields, formFields, Object.assign({}, ctx, {fieldGroups: objectSchema.field_groups, omitReadonlyFields: true})),
9088
9089
  hiddenOn: "${editFormInited != true}",
9089
9090
  },
9090
9091
  panelClassName:'m-0 sm:rounded-lg shadow-none border-none',
@@ -9692,8 +9693,8 @@ async function getObjectRelatedListsMiniSchema(objectApiName){
9692
9693
  /*
9693
9694
  * @Author: baozhoutao@steedos.com
9694
9695
  * @Date: 2022-07-05 15:55:39
9695
- * @LastEditors: baozhoutao@steedos.com
9696
- * @LastEditTime: 2024-02-18 16:05:21
9696
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
9697
+ * @LastEditTime: 2024-02-23 16:37:06
9697
9698
  * @Description:
9698
9699
  */
9699
9700
 
@@ -10041,6 +10042,7 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10041
10042
  let fields = [];
10042
10043
  for (const column of columns) {
10043
10044
  if (isString(column)) {
10045
+ let columnField;
10044
10046
  if (column.indexOf('.') > 0) {
10045
10047
  const fieldName = column.split('.')[0];
10046
10048
  const displayName = column.split('.')[1];
@@ -10048,23 +10050,30 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10048
10050
  if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)) {
10049
10051
  const rfUiSchema = await getUISchema(filedInfo.reference_to);
10050
10052
  const rfFieldInfo = rfUiSchema.fields[displayName];
10051
- fields.push(Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx));
10053
+ columnField = Object.assign({}, rfFieldInfo, { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } }, ctx);
10052
10054
  }else if(filedInfo && filedInfo.type === 'object'){
10053
- fields.push(uiSchema.fields[column]);
10055
+ columnField = uiSchema.fields[column];
10054
10056
  }
10055
10057
  } else {
10056
10058
  if (uiSchema.fields[column]) {
10057
- fields.push(Object.assign({}, uiSchema.fields[column], ctx));
10059
+ columnField = Object.assign({}, uiSchema.fields[column], ctx);
10058
10060
  }
10059
10061
  else if(ctx.extra){
10060
10062
  // 配置列表视图extra_columns时允许字段是hidden的,hidden的字段在uiSchema.fields中不存在
10061
- fields.push({
10063
+ columnField = {
10062
10064
  extra: true,
10063
10065
  name: column
10064
- });
10066
+ };
10065
10067
  }
10066
10068
  }
10069
+ if(columnField){
10070
+ // 列上的字段不认uiSchema.fields中定义的amis属性
10071
+ columnField = Object.assign({}, columnField, {amis: undefined});
10072
+ fields.push(columnField);
10073
+ }
10074
+
10067
10075
  } else if (isObject$1(column)) {
10076
+ let columnField;
10068
10077
  if (column.field.indexOf('.') > 0) {
10069
10078
  const fieldName = column.field.split('.')[0];
10070
10079
  const displayName = column.field.split('.')[1];
@@ -10072,33 +10081,34 @@ async function convertColumnsToTableFields(columns, uiSchema, ctx = {}) {
10072
10081
  if (filedInfo && (filedInfo.type === 'lookup' || filedInfo.type === 'master_detail') && isString(filedInfo.reference_to)) {
10073
10082
  const rfUiSchema = await getUISchema(filedInfo.reference_to);
10074
10083
  const rfFieldInfo = rfUiSchema.fields[displayName];
10075
- fields.push(Object.assign({}, rfFieldInfo, ctx,
10084
+ columnField = Object.assign({}, rfFieldInfo, ctx,
10076
10085
  { name: `${fieldName}__expand.${displayName}`, expand: true, expandInfo: { fieldName, displayName } },
10077
10086
  {
10078
10087
  width: column.width,
10079
- wrap: column.wrap, // wrap = true 是没效果的
10080
- amis: column.amis
10088
+ wrap: column.wrap // wrap = true 是没效果的
10081
10089
  }
10082
- ));
10090
+ );
10083
10091
  }
10084
10092
  } else {
10085
10093
  if (uiSchema.fields[column.field]) {
10086
- fields.push(
10087
- Object.assign({}, uiSchema.fields[column.field], ctx, {
10088
- width: column.width,
10089
- wrap: column.wrap, // wrap = true 是没效果的
10090
- amis: column.amis
10091
- })
10092
- );
10094
+ columnField = Object.assign({}, uiSchema.fields[column.field], ctx, {
10095
+ width: column.width,
10096
+ wrap: column.wrap // wrap = true 是没效果的
10097
+ });
10093
10098
  }
10094
10099
  else if(ctx.extra){
10095
10100
  // 配置列表视图extra_columns时允许字段是hidden的,hidden的字段在uiSchema.fields中不存在
10096
- fields.push({
10101
+ columnField = {
10097
10102
  extra: true,
10098
10103
  name: column.field
10099
- });
10104
+ };
10100
10105
  }
10101
10106
  }
10107
+ if(columnField){
10108
+ // 列上的字段不认uiSchema.fields中定义的amis属性,用列上配置的amis覆盖
10109
+ columnField = Object.assign({}, columnField, {amis: column.amis});
10110
+ fields.push(columnField);
10111
+ }
10102
10112
  }
10103
10113
  }
10104
10114
  return fields;
@@ -11428,7 +11438,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
11428
11438
  if(refObjectConfig.name === 'organizations'){
11429
11439
  labelFieldName = 'name';
11430
11440
  }
11431
- pickerSchema = await getTableSchema$1(tableFields, {
11441
+ pickerSchema = await getTableSchema$1(refObjectConfig, tableFields, {
11432
11442
  labelFieldName,
11433
11443
  top: top,
11434
11444
  isLookup: true,
@@ -12036,7 +12046,7 @@ async function getIdsPickerSchema(field, readonly, ctx){
12036
12046
  actions: false
12037
12047
  });
12038
12048
  }else {
12039
- pickerSchema = await getTableSchema$1(tableFields, {
12049
+ pickerSchema = await getTableSchema$1(refObjectConfig, tableFields, {
12040
12050
  labelFieldName: refObjectConfig.NAME_FIELD_KEY,
12041
12051
  top: top,
12042
12052
  isLookup: true,
@@ -13183,15 +13193,15 @@ var index = /*#__PURE__*/Object.freeze({
13183
13193
  /*
13184
13194
  * @Author: baozhoutao@steedos.com
13185
13195
  * @Date: 2022-05-26 16:02:08
13186
- * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
13187
- * @LastEditTime: 2023-11-29 17:48:27
13196
+ * @LastEditors: yinlianghui@hotoa.com yinlianghui@hotoa.com
13197
+ * @LastEditTime: 2024-02-25 14:13:10
13188
13198
  * @Description:
13189
13199
  */
13190
13200
 
13191
13201
  const getFieldSchemaArray = (formFields, ctx) => {
13192
13202
  let fieldSchemaArray = [];
13193
13203
  fieldSchemaArray.length = 0;
13194
- const recordId = ctx && ctx.recordId;
13204
+ ctx && ctx.recordId;
13195
13205
 
13196
13206
  _$1.forEach(formFields, (field) => {
13197
13207
  if (!field.group || field.group == 'null' || field.group == '-')
@@ -13204,9 +13214,7 @@ const getFieldSchemaArray = (formFields, ctx) => {
13204
13214
  }
13205
13215
 
13206
13216
  let forceHidden = false;
13207
- if(!recordId && field.readonly && !ctx.isEditor){
13208
- // 新建记录时,只读字段先隐藏,后续支持显示后,即任务:https://github.com/steedos/steedos-platform/issues/3164 完成后再放开
13209
- // 表单只读时所有字段都是readonly,设计器中如果forceHidden会造成整个表单在只读的时候显示为空白了,所以要排除掉
13217
+ if(ctx.omitReadonlyFields && field.readonly){
13210
13218
  forceHidden = true;
13211
13219
  }
13212
13220