@steedos-widgets/amis-lib 1.3.17 → 1.3.18

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
@@ -1,5 +1,5 @@
1
1
  import * as _$1 from 'lodash';
2
- import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, clone, filter, startsWith } from 'lodash';
3
3
  import i18next from 'i18next';
4
4
  export { default as i18next } from 'i18next';
5
5
  import { initReactI18next } from 'react-i18next';
@@ -1986,9 +1986,9 @@ function getFieldWidth(width){
1986
1986
  const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
1987
1987
  if(typeof width == 'string'){
1988
1988
  if(isNaN(width)){
1989
- return width;
1989
+ return width || defaultWidth;
1990
1990
  }else {
1991
- return Number(width);
1991
+ return Number(width) || defaultWidth;
1992
1992
  }
1993
1993
  }else if(typeof width == 'number'){
1994
1994
  return width;
@@ -2089,6 +2089,7 @@ async function getTableColumns(fields, options){
2089
2089
  width: getFieldWidth(field.width),
2090
2090
  toggled: field.toggled,
2091
2091
  className,
2092
+ inputClassName: "inline",
2092
2093
  static: true,
2093
2094
  }, field.amis, {name: field.name});
2094
2095
  }
@@ -2126,6 +2127,7 @@ async function getTableColumns(fields, options){
2126
2127
  tpl: tpl,
2127
2128
  toggled: field.toggled,
2128
2129
  className,
2130
+ inputClassName: "inline",
2129
2131
  static: true,
2130
2132
  options: field.type === 'html' ? {html: true} : null
2131
2133
  // toggled: true
@@ -2147,8 +2149,8 @@ async function getTableColumns(fields, options){
2147
2149
  const href = Router.getObjectDetailPath({
2148
2150
  ...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
2149
2151
  });
2150
- columns[0].type = "tpl";
2151
- columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
2152
+ columns[1].type = "tpl";
2153
+ columns[1].tpl = `<a href="${href}">\${${columns[1].name}}</a>`;
2152
2154
  }
2153
2155
  return columns;
2154
2156
  }
@@ -2844,7 +2846,25 @@ async function getTableApi(mainObject, fields, options){
2844
2846
  if(enable_tree){
2845
2847
  const records = payload.data.rows || [];
2846
2848
  const getTreeOptions = SteedosUI.getTreeOptions
2847
- payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2849
+ let isTreeOptionsComputed = false;
2850
+ if(records.length === 1 && records[0].children){
2851
+ isTreeOptionsComputed = true;
2852
+ }
2853
+ if(!isTreeOptionsComputed){
2854
+ // 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
2855
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2856
+ }
2857
+ try{
2858
+ setTimeout(() => {
2859
+ let expandBtn = $('.steedos-object-listview-content .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn');
2860
+ if(expandBtn && expandBtn.length > 0 && !expandBtn.hasClass("is-active")){
2861
+ expandBtn[0].click();
2862
+ }
2863
+ }, 600);
2864
+ }
2865
+ catch(ex){
2866
+ console.error("tree数据格式展开异常:", ex);
2867
+ }
2848
2868
  }
2849
2869
 
2850
2870
 
@@ -6708,78 +6728,97 @@ function fields$1(){
6708
6728
 
6709
6729
  function fieldsExtend$4(){
6710
6730
  return {
6731
+ "group": "",
6711
6732
  "label": {
6712
6733
  "is_wide": true
6713
6734
  },
6714
6735
  "name": {
6736
+ "group": "",
6715
6737
  "amis": {
6716
6738
  "hidden": true,
6717
6739
  "required": false
6718
6740
  }
6719
6741
  },
6720
6742
  "object_name": {
6743
+ "group": "",
6721
6744
  "amis": {
6722
6745
  "hidden": true
6723
6746
  }
6724
6747
  },
6725
6748
  "filter_scope": {
6749
+ "group": "",
6726
6750
  "amis": {
6727
6751
  "hidden": true,
6728
6752
  "required": false
6729
6753
  }
6730
6754
  },
6731
6755
  "columns": {
6756
+ "group": "",
6732
6757
  "amis": {
6733
6758
  "hidden": true,
6734
6759
  "required": false
6735
6760
  }
6736
6761
  },
6737
6762
  "mobile_columns":{
6763
+ "group": "",
6738
6764
  "amis": {
6739
6765
  "hidden": true,
6740
6766
  "required": false
6741
6767
  }
6742
6768
  },
6743
6769
  "searchable_fields":{
6770
+ "group": "",
6744
6771
  "amis": {
6745
6772
  "hidden": true,
6746
6773
  "required": false
6747
6774
  }
6748
6775
  },
6749
6776
  "filter_fields": {
6777
+ "group": "",
6750
6778
  "amis": {
6751
6779
  "hidden": true,
6752
6780
  "required": false
6753
6781
  }
6754
6782
  },
6755
6783
  "scrolling_mode": {
6784
+ "group": "",
6756
6785
  "amis": {
6757
6786
  "hidden": true,
6758
6787
  "required": false
6759
6788
  }
6760
6789
  },
6761
6790
  "sort": {
6791
+ "group": "",
6762
6792
  "amis": {
6763
6793
  "hidden": true,
6764
6794
  "required": false
6765
6795
  }
6766
6796
  },
6767
6797
  "show_count": {
6798
+ "group": "",
6768
6799
  "amis": {
6769
6800
  "hidden": true,
6770
6801
  "required": false
6771
6802
  }
6772
6803
  },
6773
6804
  "type": {
6805
+ "group": "",
6774
6806
  "amis": {
6775
6807
  "hidden": true,
6776
6808
  "required": false
6777
6809
  }
6778
6810
  },
6779
6811
  "shared": {
6812
+ "group": "",
6780
6813
  "amis": {
6781
6814
  "visibleOn": "${global.user.is_space_admin}"
6782
6815
  }
6816
+ },
6817
+ "filters": {
6818
+ "group": "",
6819
+ "amis": {
6820
+ "hidden": true
6821
+ }
6783
6822
  }
6784
6823
  }
6785
6824
  }
@@ -6926,6 +6965,12 @@ function fieldsExtend$3(){
6926
6965
  "amis": {
6927
6966
  "visibleOn": "${global.user.is_space_admin}"
6928
6967
  }
6968
+ },
6969
+ "filters": {
6970
+ "group": "",
6971
+ "amis": {
6972
+ "hidden": true
6973
+ }
6929
6974
  }
6930
6975
  }
6931
6976
  }
@@ -7264,7 +7309,6 @@ function fieldsExtend$1(){
7264
7309
  }
7265
7310
  },
7266
7311
  "mobile_columns": {
7267
- "group": i18next.t('frontend_listview_control_columns_mobile_group'),
7268
7312
  "amis": {
7269
7313
  "type": "transfer",
7270
7314
  "sortable": true,
@@ -8216,7 +8260,12 @@ async function getObjectCRUD(objectSchema, fields, options){
8216
8260
  hiddenOn: options.tableHiddenOn,
8217
8261
  autoFillHeight,
8218
8262
  className: `flex-auto ${crudClassName || ""}`,
8219
- bodyClassName: "bg-white",
8263
+ // 这里不可以用动态className,因为它会把样式类加到.antd-Crud和.antd-Table.antd-Crud-body这两层div中,而子表列表中crudClassName中有hidden样式类会造成所有子表都不显示的bug
8264
+ // className: {
8265
+ // [`flex-auto ${crudClassName || ""}`]: "true",
8266
+ // "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8267
+ // },
8268
+ bodyClassName: "bg-white",//上面className写成动态的class变量对象的话,bodyClassName不会生效,会被上面的className值覆盖
8220
8269
  crudClassName: crudClassName,
8221
8270
  quickSaveApi: {
8222
8271
  url: `\${context.rootUrl}/graphql`,
@@ -10107,8 +10156,6 @@ async function lookupToAmisTreeSelect(field, readonly, ctx) {
10107
10156
  return amisSchema;
10108
10157
  }
10109
10158
 
10110
- const keywordsSearchBoxName = `__keywords_lookup`;
10111
-
10112
10159
  const getReferenceToFieldSchema = (field, refObjectConfig)=>{
10113
10160
  let referenceTo = field.reference_to;
10114
10161
  if(!referenceTo){
@@ -10367,7 +10414,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
10367
10414
 
10368
10415
  source.data.$term = "$term";
10369
10416
  source.data.$self = "$$";
10370
-
10417
+
10418
+ // field.name可能是带点的名称,比如审批王中子表字段'instances.instances_submitter',如果不替换掉点,会造成审批王表单中新建子表行时报错
10419
+ let keywordsSearchBoxName = `__keywords_lookup__${field.name.replace(/\./g, "_")}__to__${refObjectConfig.name}`;
10420
+
10371
10421
  source.requestAdaptor = `
10372
10422
  let __changedFilterFormValues = api.data.$self.__changedFilterFormValues || {};
10373
10423
  let __changedSearchBoxValues = api.data.$self.__changedSearchBoxValues || {};
@@ -10510,6 +10560,14 @@ async function lookupToAmisPicker(field, readonly, ctx){
10510
10560
  }
10511
10561
  });
10512
10562
  payload.data.rows = treeRecords;
10563
+ try{
10564
+ setTimeout(() => {
10565
+ $('.amis-dialog-widget.antd-Modal .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn')[0]?.click();
10566
+ }, 600);
10567
+ }
10568
+ catch(ex){
10569
+ console.error("tree数据格式展开异常:", ex);
10570
+ }
10513
10571
  }
10514
10572
  return payload;
10515
10573
  `;
@@ -10682,6 +10740,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10682
10740
 
10683
10741
  async function lookupToAmisSelect(field, readonly, ctx){
10684
10742
  let referenceTo = await getReferenceTo(field);
10743
+ const isMobile = window.innerWidth <= 768;
10685
10744
  const valueFieldKey = referenceTo && referenceTo.valueField?.name || '_id' ;
10686
10745
  // const labelFieldKey = referenceTo && referenceTo.labelField?.name || 'name';
10687
10746
 
@@ -10862,7 +10921,11 @@ async function lookupToAmisSelect(field, readonly, ctx){
10862
10921
  </span>
10863
10922
  <span class='pl-1.5'>\${label}</span>
10864
10923
  </span>`;
10865
- data.menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
10924
+ const menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
10925
+ // TODO: 待amis修复了此bug, 就可以撤销添加menuTpl的判断。
10926
+ if(!(isMobile && field.multiple)){
10927
+ data.menuTpl = menuTpl;
10928
+ }
10866
10929
  if(field.multiple){
10867
10930
  data.multiple = true;
10868
10931
  data.extractValue = true;
@@ -11370,6 +11433,8 @@ function getSelectFieldOptions(field){
11370
11433
  }
11371
11434
 
11372
11435
  async function convertSFieldToAmisField(field, readonly, ctx) {
11436
+ // console.log('convertSFieldToAmisField====>', field, readonly, ctx)
11437
+ const isMobile = window.innerWidth <= 768;
11373
11438
  // 创建人和修改人、创建时间和修改时间不显示
11374
11439
  if(_$1.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
11375
11440
  return;
@@ -11432,7 +11497,11 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11432
11497
  </span>
11433
11498
  <span class='pl-1.5'>\${label}</span>
11434
11499
  </span>`;
11435
- convertData.menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
11500
+ const menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
11501
+ // TODO: 待amis修复了此bug, 就可以撤销添加menuTpl的判断。
11502
+ if(!(isMobile && field.multiple)){
11503
+ convertData.menuTpl = menuTpl;
11504
+ }
11436
11505
  if(field.multiple){
11437
11506
  convertData.multiple = true;
11438
11507
  convertData.extractValue = true;
@@ -12293,7 +12362,7 @@ async function getFormBody(permissionFields, formFields, ctx){
12293
12362
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12294
12363
  * @Date: 2023-11-15 09:50:22
12295
12364
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12296
- * @LastEditTime: 2023-11-29 17:48:02
12365
+ * @LastEditTime: 2023-12-04 17:36:50
12297
12366
  */
12298
12367
 
12299
12368
  /**
@@ -12623,11 +12692,20 @@ const getAmisInputTableSchema = async (props, readonly) => {
12623
12692
  ],
12624
12693
  "className": props.className
12625
12694
  };
12695
+ let footerToolbar = clone(props.footerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
12626
12696
  if (props.addable) {
12627
12697
  let buttonNewSchema = await getButtonNew(props);
12628
- schema.body.push(buttonNewSchema);
12698
+ footerToolbar.unshift(buttonNewSchema);
12699
+ }
12700
+ if (footerToolbar.length) {
12701
+ schema.body.push({
12702
+ "type": "wrapper",
12703
+ "size": "none",
12704
+ "body": footerToolbar
12705
+ });
12629
12706
  }
12630
12707
  if (props.amis) {
12708
+ delete props.amis.id;
12631
12709
  Object.assign(schema.body[0], props.amis);
12632
12710
  }
12633
12711
  return schema;