@steedos-widgets/amis-lib 1.3.17 → 1.3.19

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
 
@@ -6151,12 +6171,13 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6151
6171
  */
6152
6172
  function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
6153
6173
  const { icon, label } = objectSchema;
6174
+ const disabled_list_views = objectSchema.permissions.disabled_list_views;
6154
6175
  const listViewButtonOptions = [];
6155
6176
  each(
6156
6177
  objectSchema.list_views,
6157
6178
  (listView, name) => {
6158
- if(name === "lookup"){
6159
- // 内置lookup为弹出选择专用视图,不显示在列表切换区域
6179
+ if(name === "lookup" || (disabled_list_views && disabled_list_views.indexOf(listView._id)>-1)){
6180
+ // 内置lookup为弹出选择专用视图,根据用户权限被禁用的视图,不显示在列表切换区域
6160
6181
  return;
6161
6182
  }
6162
6183
  listViewButtonOptions.push({
@@ -6708,78 +6729,97 @@ function fields$1(){
6708
6729
 
6709
6730
  function fieldsExtend$4(){
6710
6731
  return {
6732
+ "group": "",
6711
6733
  "label": {
6712
6734
  "is_wide": true
6713
6735
  },
6714
6736
  "name": {
6737
+ "group": "",
6715
6738
  "amis": {
6716
6739
  "hidden": true,
6717
6740
  "required": false
6718
6741
  }
6719
6742
  },
6720
6743
  "object_name": {
6744
+ "group": "",
6721
6745
  "amis": {
6722
6746
  "hidden": true
6723
6747
  }
6724
6748
  },
6725
6749
  "filter_scope": {
6750
+ "group": "",
6726
6751
  "amis": {
6727
6752
  "hidden": true,
6728
6753
  "required": false
6729
6754
  }
6730
6755
  },
6731
6756
  "columns": {
6757
+ "group": "",
6732
6758
  "amis": {
6733
6759
  "hidden": true,
6734
6760
  "required": false
6735
6761
  }
6736
6762
  },
6737
6763
  "mobile_columns":{
6764
+ "group": "",
6738
6765
  "amis": {
6739
6766
  "hidden": true,
6740
6767
  "required": false
6741
6768
  }
6742
6769
  },
6743
6770
  "searchable_fields":{
6771
+ "group": "",
6744
6772
  "amis": {
6745
6773
  "hidden": true,
6746
6774
  "required": false
6747
6775
  }
6748
6776
  },
6749
6777
  "filter_fields": {
6778
+ "group": "",
6750
6779
  "amis": {
6751
6780
  "hidden": true,
6752
6781
  "required": false
6753
6782
  }
6754
6783
  },
6755
6784
  "scrolling_mode": {
6785
+ "group": "",
6756
6786
  "amis": {
6757
6787
  "hidden": true,
6758
6788
  "required": false
6759
6789
  }
6760
6790
  },
6761
6791
  "sort": {
6792
+ "group": "",
6762
6793
  "amis": {
6763
6794
  "hidden": true,
6764
6795
  "required": false
6765
6796
  }
6766
6797
  },
6767
6798
  "show_count": {
6799
+ "group": "",
6768
6800
  "amis": {
6769
6801
  "hidden": true,
6770
6802
  "required": false
6771
6803
  }
6772
6804
  },
6773
6805
  "type": {
6806
+ "group": "",
6774
6807
  "amis": {
6775
6808
  "hidden": true,
6776
6809
  "required": false
6777
6810
  }
6778
6811
  },
6779
6812
  "shared": {
6813
+ "group": "",
6780
6814
  "amis": {
6781
6815
  "visibleOn": "${global.user.is_space_admin}"
6782
6816
  }
6817
+ },
6818
+ "filters": {
6819
+ "group": "",
6820
+ "amis": {
6821
+ "hidden": true
6822
+ }
6783
6823
  }
6784
6824
  }
6785
6825
  }
@@ -6926,6 +6966,12 @@ function fieldsExtend$3(){
6926
6966
  "amis": {
6927
6967
  "visibleOn": "${global.user.is_space_admin}"
6928
6968
  }
6969
+ },
6970
+ "filters": {
6971
+ "group": "",
6972
+ "amis": {
6973
+ "hidden": true
6974
+ }
6929
6975
  }
6930
6976
  }
6931
6977
  }
@@ -7264,7 +7310,6 @@ function fieldsExtend$1(){
7264
7310
  }
7265
7311
  },
7266
7312
  "mobile_columns": {
7267
- "group": i18next.t('frontend_listview_control_columns_mobile_group'),
7268
7313
  "amis": {
7269
7314
  "type": "transfer",
7270
7315
  "sortable": true,
@@ -8216,7 +8261,15 @@ async function getObjectCRUD(objectSchema, fields, options){
8216
8261
  hiddenOn: options.tableHiddenOn,
8217
8262
  autoFillHeight,
8218
8263
  className: `flex-auto ${crudClassName || ""}`,
8219
- bodyClassName: "bg-white",
8264
+ // 这里不可以用动态className,因为它会把样式类加到.antd-Crud和.antd-Table.antd-Crud-body这两层div中,而子表列表中crudClassName中有hidden样式类会造成所有子表都不显示的bug
8265
+ // className: {
8266
+ // [`flex-auto ${crudClassName || ""}`]: "true",
8267
+ // "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8268
+ // },
8269
+ bodyClassName: {
8270
+ "bg-white": "true",
8271
+ "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8272
+ },
8220
8273
  crudClassName: crudClassName,
8221
8274
  quickSaveApi: {
8222
8275
  url: `\${context.rootUrl}/graphql`,
@@ -10107,8 +10160,6 @@ async function lookupToAmisTreeSelect(field, readonly, ctx) {
10107
10160
  return amisSchema;
10108
10161
  }
10109
10162
 
10110
- const keywordsSearchBoxName = `__keywords_lookup`;
10111
-
10112
10163
  const getReferenceToFieldSchema = (field, refObjectConfig)=>{
10113
10164
  let referenceTo = field.reference_to;
10114
10165
  if(!referenceTo){
@@ -10367,7 +10418,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
10367
10418
 
10368
10419
  source.data.$term = "$term";
10369
10420
  source.data.$self = "$$";
10370
-
10421
+
10422
+ // field.name可能是带点的名称,比如审批王中子表字段'instances.instances_submitter',如果不替换掉点,会造成审批王表单中新建子表行时报错
10423
+ let keywordsSearchBoxName = `__keywords_lookup__${field.name.replace(/\./g, "_")}__to__${refObjectConfig.name}`;
10424
+
10371
10425
  source.requestAdaptor = `
10372
10426
  let __changedFilterFormValues = api.data.$self.__changedFilterFormValues || {};
10373
10427
  let __changedSearchBoxValues = api.data.$self.__changedSearchBoxValues || {};
@@ -10510,6 +10564,14 @@ async function lookupToAmisPicker(field, readonly, ctx){
10510
10564
  }
10511
10565
  });
10512
10566
  payload.data.rows = treeRecords;
10567
+ try{
10568
+ setTimeout(() => {
10569
+ $('.amis-dialog-widget.antd-Modal .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn')[0]?.click();
10570
+ }, 600);
10571
+ }
10572
+ catch(ex){
10573
+ console.error("tree数据格式展开异常:", ex);
10574
+ }
10513
10575
  }
10514
10576
  return payload;
10515
10577
  `;
@@ -10682,6 +10744,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10682
10744
 
10683
10745
  async function lookupToAmisSelect(field, readonly, ctx){
10684
10746
  let referenceTo = await getReferenceTo(field);
10747
+ const isMobile = window.innerWidth <= 768;
10685
10748
  const valueFieldKey = referenceTo && referenceTo.valueField?.name || '_id' ;
10686
10749
  // const labelFieldKey = referenceTo && referenceTo.labelField?.name || 'name';
10687
10750
 
@@ -10862,7 +10925,11 @@ async function lookupToAmisSelect(field, readonly, ctx){
10862
10925
  </span>
10863
10926
  <span class='pl-1.5'>\${label}</span>
10864
10927
  </span>`;
10865
- data.menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
10928
+ const menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
10929
+ // TODO: 待amis修复了此bug, 就可以撤销添加menuTpl的判断。
10930
+ if(!(isMobile && field.multiple)){
10931
+ data.menuTpl = menuTpl;
10932
+ }
10866
10933
  if(field.multiple){
10867
10934
  data.multiple = true;
10868
10935
  data.extractValue = true;
@@ -11370,6 +11437,8 @@ function getSelectFieldOptions(field){
11370
11437
  }
11371
11438
 
11372
11439
  async function convertSFieldToAmisField(field, readonly, ctx) {
11440
+ // console.log('convertSFieldToAmisField====>', field, readonly, ctx)
11441
+ const isMobile = window.innerWidth <= 768;
11373
11442
  // 创建人和修改人、创建时间和修改时间不显示
11374
11443
  if(_$1.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
11375
11444
  return;
@@ -11432,7 +11501,11 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11432
11501
  </span>
11433
11502
  <span class='pl-1.5'>\${label}</span>
11434
11503
  </span>`;
11435
- convertData.menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
11504
+ const menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
11505
+ // TODO: 待amis修复了此bug, 就可以撤销添加menuTpl的判断。
11506
+ if(!(isMobile && field.multiple)){
11507
+ convertData.menuTpl = menuTpl;
11508
+ }
11436
11509
  if(field.multiple){
11437
11510
  convertData.multiple = true;
11438
11511
  convertData.extractValue = true;
@@ -12293,7 +12366,7 @@ async function getFormBody(permissionFields, formFields, ctx){
12293
12366
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12294
12367
  * @Date: 2023-11-15 09:50:22
12295
12368
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12296
- * @LastEditTime: 2023-11-29 17:48:02
12369
+ * @LastEditTime: 2023-12-04 17:36:50
12297
12370
  */
12298
12371
 
12299
12372
  /**
@@ -12623,11 +12696,20 @@ const getAmisInputTableSchema = async (props, readonly) => {
12623
12696
  ],
12624
12697
  "className": props.className
12625
12698
  };
12699
+ let footerToolbar = clone(props.footerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
12626
12700
  if (props.addable) {
12627
12701
  let buttonNewSchema = await getButtonNew(props);
12628
- schema.body.push(buttonNewSchema);
12702
+ footerToolbar.unshift(buttonNewSchema);
12703
+ }
12704
+ if (footerToolbar.length) {
12705
+ schema.body.push({
12706
+ "type": "wrapper",
12707
+ "size": "none",
12708
+ "body": footerToolbar
12709
+ });
12629
12710
  }
12630
12711
  if (props.amis) {
12712
+ delete props.amis.id;
12631
12713
  Object.assign(schema.body[0], props.amis);
12632
12714
  }
12633
12715
  return schema;