@steedos-widgets/amis-lib 1.2.13 → 1.2.14

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
@@ -5492,6 +5492,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
5492
5492
  };
5493
5493
  }
5494
5494
 
5495
+ if(field.pickerSchema){
5496
+ pickerSchema = Object.assign({}, pickerSchema, field.pickerSchema);
5497
+ }
5498
+
5495
5499
  const data = {
5496
5500
  type: getAmisStaticFieldType('picker', readonly),
5497
5501
  labelField: referenceTo.labelField.name,
@@ -7122,12 +7126,12 @@ function getBatchDelete(objectName){
7122
7126
  /*
7123
7127
  * @Author: baozhoutao@steedos.com
7124
7128
  * @Date: 2022-05-26 16:02:08
7125
- * @LastEditors: baozhoutao@steedos.com
7126
- * @LastEditTime: 2023-03-13 16:01:40
7129
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
7130
+ * @LastEditTime: 2023-06-02 16:54:41
7127
7131
  * @Description:
7128
7132
  */
7129
7133
 
7130
- const getFieldSchemaArray = (formFields)=>{
7134
+ const getFieldSchemaArray = (formFields) => {
7131
7135
  let fieldSchemaArray = [];
7132
7136
  fieldSchemaArray.length = 0;
7133
7137
 
@@ -7140,10 +7144,10 @@ const getFieldSchemaArray = (formFields)=>{
7140
7144
  // field.group = field.label
7141
7145
  field.is_wide = true;
7142
7146
  }
7143
-
7144
- if (!isObjectField){
7145
- if(!field.hidden){
7146
- fieldSchemaArray.push(Object.assign({name: fieldName}, field, {permission: {allowEdit: true}}));
7147
+
7148
+ if (!isObjectField) {
7149
+ if (!field.hidden) {
7150
+ fieldSchemaArray.push(Object.assign({ name: fieldName }, field, { permission: { allowEdit: true } }));
7147
7151
  }
7148
7152
  }
7149
7153
  });
@@ -7151,89 +7155,104 @@ const getFieldSchemaArray = (formFields)=>{
7151
7155
  };
7152
7156
 
7153
7157
  const getSection = async (formFields, permissionFields, fieldSchemaArray, sectionName, ctx) => {
7158
+ if (!ctx) {
7159
+ ctx = {};
7160
+ }
7154
7161
  const sectionFields = _$1.filter(fieldSchemaArray, { 'group': sectionName });
7155
- if(sectionFields.length == _$1.filter(sectionFields, ['hidden', true]).length){
7156
- return ;
7162
+ if (sectionFields.length == _$1.filter(sectionFields, ['hidden', true]).length) {
7163
+ return;
7157
7164
  }
7158
7165
 
7159
7166
  const fieldSetBody = [];
7160
7167
 
7161
7168
  for (const perField of sectionFields) {
7162
7169
  let field = perField;
7163
- if(perField.type === 'grid'){
7164
- field = await getGridFieldSubFields(perField, formFields);
7165
- // console.log(`perField.type grid ===> field`, field)
7166
- }else if(perField.type === 'object'){
7167
- field = await getObjectFieldSubFields(perField, formFields);
7168
- // console.log(`perField.type object ===> field`, field)
7169
- }
7170
- if(field.name.indexOf(".") < 0){
7171
- ctx.__formFields = formFields;
7172
- const amisField = await convertSFieldToAmisField(field, field.readonly, ctx);
7173
- // console.log(`${field.name} amisField`, field, amisField)
7174
- if(amisField){
7175
- fieldSetBody.push(amisField);
7176
- }
7170
+ if (perField.type === 'grid') {
7171
+ field = await getGridFieldSubFields(perField, formFields);
7172
+ // console.log(`perField.type grid ===> field`, field)
7173
+ } else if (perField.type === 'object') {
7174
+ field = await getObjectFieldSubFields(perField, formFields);
7175
+ // console.log(`perField.type object ===> field`, field)
7176
+ }
7177
+ if (field.name.indexOf(".") < 0) {
7178
+ ctx.__formFields = formFields;
7179
+ const amisField = await convertSFieldToAmisField(field, field.readonly, ctx);
7180
+ // console.log(`${field.name} amisField`, field, amisField)
7181
+ if (amisField) {
7182
+ fieldSetBody.push(amisField);
7177
7183
  }
7184
+ }
7178
7185
  }
7179
7186
 
7180
7187
  // fieldSet 已支持显隐控制
7181
- const sectionFieldsVisibleOn = _$1.map(_$1.compact(_$1.map(fieldSetBody, 'visibleOn')) , (visibleOn)=>{
7188
+ const sectionFieldsVisibleOn = _$1.map(_$1.compact(_$1.map(fieldSetBody, 'visibleOn')), (visibleOn) => {
7182
7189
  return visibleOn;
7183
7190
  });
7184
- const section = {
7191
+
7192
+ let section = {
7185
7193
  "type": "fieldSet",
7186
7194
  "title": sectionName,
7187
7195
  "collapsable": true,
7188
7196
  "body": fieldSetBody,
7189
7197
  };
7190
- if(sectionFieldsVisibleOn.length > 0 && fieldSetBody.length === sectionFieldsVisibleOn.length){
7198
+
7199
+ if (ctx.enableTabs) {
7200
+ section = {
7201
+ "title": sectionName,
7202
+ "body": fieldSetBody,
7203
+ };
7204
+ }
7205
+
7206
+ if (sectionFieldsVisibleOn.length > 0 && fieldSetBody.length === sectionFieldsVisibleOn.length) {
7191
7207
  section.visibleOn = `${sectionFieldsVisibleOn.join(" || ")}`;
7192
7208
  }
7193
7209
  return section
7194
7210
  };
7195
7211
 
7196
7212
  const getSections = async (permissionFields, formFields, ctx) => {
7213
+ if (!ctx) {
7214
+ ctx = {};
7215
+ }
7197
7216
  const fieldSchemaArray = getFieldSchemaArray(formFields);
7198
7217
  const _sections = _$1.groupBy(fieldSchemaArray, 'group');
7199
7218
  const sections = [];
7200
- var sectionHeaderVisibleOn=[];
7219
+ var sectionVisibleOns = [];
7201
7220
  for (const key in _sections) {
7202
7221
  const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
7203
- if(section.body.length > 0){
7204
- if(section.visibleOn){
7205
- sectionHeaderVisibleOn.push(section.visibleOn);
7222
+ if (section.body.length > 0) {
7223
+ if (section.visibleOn) {
7224
+ sectionVisibleOns.push(section.visibleOn);
7225
+ }
7226
+ else {
7227
+ sectionVisibleOns.push("true");
7206
7228
  }
7207
7229
  sections.push(section);
7208
7230
  }
7209
7231
  }
7210
7232
  /*
7211
7233
  为了实现只有一个分组时隐藏该分组标题,需要分三种情况(分组如果没有visibleon属性就代表一定显示,有visibleon需要进行判断)
7212
- 1.所有分组中只有一个分组没有visibleon,还需要判断其他有visibleon的分组是否显示,只有其他都不显示时,才需要隐藏标题;反之,有任何一个显示,就不需要隐藏标题
7213
- 2.所有分组都有visibleon
7214
- 2.1 当前分组为隐藏时,标题就设置为隐藏
7215
- 2.2 当前分组为显示时,其他分组只要有一个是显示,就显示该分组标题
7216
- 2.3 当前分组为显示时,其他分组都隐藏,就隐藏该分组标题
7217
- 3.所有分组中有两个以上的分组没有visibleon(这种情况不用处理)
7234
+ 1 当前分组为隐藏时,标题就设置为隐藏
7235
+ 2 当前分组为显示时,其他分组只要有一个是显示,就显示该分组标题
7236
+ 3 当前分组为显示时,其他分组都隐藏,就隐藏该分组标题
7218
7237
  */
7219
- if(ctx.mode == "edit"){
7220
- if (sections.length - sectionHeaderVisibleOn.length == 1) {
7221
- sections.forEach((section) => {
7222
- section.headingClassName = {
7223
- "hidden": `!(${sectionHeaderVisibleOn.join(" || ") || 'false'})`
7224
- };
7225
- });
7226
- } else if (sections.length == sectionHeaderVisibleOn.length) {
7227
- sections.forEach((section, index) => {
7228
- var tempSectionHeaderVisibleOn = sectionHeaderVisibleOn.slice();
7229
- tempSectionHeaderVisibleOn.splice(index, 1);
7230
- section.headingClassName = {
7231
- "hidden": `!((${tempSectionHeaderVisibleOn.join(" || ") || 'false'}) && ${sectionHeaderVisibleOn[index]})`
7232
- };
7233
- });
7234
- }
7235
- }
7236
-
7238
+ sections.forEach((section, index) => {
7239
+ var tempSectionVisibleOns = sectionVisibleOns.slice();
7240
+ tempSectionVisibleOns.splice(index, 1);
7241
+ section.headingClassName = {
7242
+ "hidden": `!((${tempSectionVisibleOns.join(" || ") || 'false'}) && ${sectionVisibleOns[index]})`
7243
+ };
7244
+ });
7245
+
7246
+ if (ctx.enableTabs) {
7247
+ return [
7248
+ {
7249
+ "type": "tabs",
7250
+ "tabs": sections,
7251
+ "tabsMode": ctx.tabsMode
7252
+ }
7253
+ ]
7254
+ }
7255
+
7237
7256
  return sections;
7238
7257
  };
7239
7258