@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.cjs.js CHANGED
@@ -2013,9 +2013,9 @@ function getFieldWidth(width){
2013
2013
  const defaultWidth = "unset";//用于使table内的td标签下生成div,实现将快速编辑按钮固定在右侧的效果,并不是为了unset效果
2014
2014
  if(typeof width == 'string'){
2015
2015
  if(isNaN(width)){
2016
- return width;
2016
+ return width || defaultWidth;
2017
2017
  }else {
2018
- return Number(width);
2018
+ return Number(width) || defaultWidth;
2019
2019
  }
2020
2020
  }else if(typeof width == 'number'){
2021
2021
  return width;
@@ -2116,6 +2116,7 @@ async function getTableColumns(fields, options){
2116
2116
  width: getFieldWidth(field.width),
2117
2117
  toggled: field.toggled,
2118
2118
  className,
2119
+ inputClassName: "inline",
2119
2120
  static: true,
2120
2121
  }, field.amis, {name: field.name});
2121
2122
  }
@@ -2153,6 +2154,7 @@ async function getTableColumns(fields, options){
2153
2154
  tpl: tpl,
2154
2155
  toggled: field.toggled,
2155
2156
  className,
2157
+ inputClassName: "inline",
2156
2158
  static: true,
2157
2159
  options: field.type === 'html' ? {html: true} : null
2158
2160
  // toggled: true
@@ -2174,8 +2176,8 @@ async function getTableColumns(fields, options){
2174
2176
  const href = Router.getObjectDetailPath({
2175
2177
  ...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
2176
2178
  });
2177
- columns[0].type = "tpl";
2178
- columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
2179
+ columns[1].type = "tpl";
2180
+ columns[1].tpl = `<a href="${href}">\${${columns[1].name}}</a>`;
2179
2181
  }
2180
2182
  return columns;
2181
2183
  }
@@ -2871,7 +2873,25 @@ async function getTableApi(mainObject, fields, options){
2871
2873
  if(enable_tree){
2872
2874
  const records = payload.data.rows || [];
2873
2875
  const getTreeOptions = SteedosUI.getTreeOptions
2874
- payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2876
+ let isTreeOptionsComputed = false;
2877
+ if(records.length === 1 && records[0].children){
2878
+ isTreeOptionsComputed = true;
2879
+ }
2880
+ if(!isTreeOptionsComputed){
2881
+ // 如果api接口设置在缓存,缓存期间并不会重新请求接口,payload.data.rows是上次计算后的结果
2882
+ payload.data.rows = getTreeOptions(records,{"valueField":"_id"});
2883
+ }
2884
+ try{
2885
+ setTimeout(() => {
2886
+ let expandBtn = $('.steedos-object-listview-content .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn');
2887
+ if(expandBtn && expandBtn.length > 0 && !expandBtn.hasClass("is-active")){
2888
+ expandBtn[0].click();
2889
+ }
2890
+ }, 600);
2891
+ }
2892
+ catch(ex){
2893
+ console.error("tree数据格式展开异常:", ex);
2894
+ }
2875
2895
  }
2876
2896
 
2877
2897
 
@@ -6178,12 +6198,13 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
6178
6198
  */
6179
6199
  function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
6180
6200
  const { icon, label } = objectSchema;
6201
+ const disabled_list_views = objectSchema.permissions.disabled_list_views;
6181
6202
  const listViewButtonOptions = [];
6182
6203
  _$1.each(
6183
6204
  objectSchema.list_views,
6184
6205
  (listView, name) => {
6185
- if(name === "lookup"){
6186
- // 内置lookup为弹出选择专用视图,不显示在列表切换区域
6206
+ if(name === "lookup" || (disabled_list_views && disabled_list_views.indexOf(listView._id)>-1)){
6207
+ // 内置lookup为弹出选择专用视图,根据用户权限被禁用的视图,不显示在列表切换区域
6187
6208
  return;
6188
6209
  }
6189
6210
  listViewButtonOptions.push({
@@ -6735,78 +6756,97 @@ function fields$1(){
6735
6756
 
6736
6757
  function fieldsExtend$4(){
6737
6758
  return {
6759
+ "group": "",
6738
6760
  "label": {
6739
6761
  "is_wide": true
6740
6762
  },
6741
6763
  "name": {
6764
+ "group": "",
6742
6765
  "amis": {
6743
6766
  "hidden": true,
6744
6767
  "required": false
6745
6768
  }
6746
6769
  },
6747
6770
  "object_name": {
6771
+ "group": "",
6748
6772
  "amis": {
6749
6773
  "hidden": true
6750
6774
  }
6751
6775
  },
6752
6776
  "filter_scope": {
6777
+ "group": "",
6753
6778
  "amis": {
6754
6779
  "hidden": true,
6755
6780
  "required": false
6756
6781
  }
6757
6782
  },
6758
6783
  "columns": {
6784
+ "group": "",
6759
6785
  "amis": {
6760
6786
  "hidden": true,
6761
6787
  "required": false
6762
6788
  }
6763
6789
  },
6764
6790
  "mobile_columns":{
6791
+ "group": "",
6765
6792
  "amis": {
6766
6793
  "hidden": true,
6767
6794
  "required": false
6768
6795
  }
6769
6796
  },
6770
6797
  "searchable_fields":{
6798
+ "group": "",
6771
6799
  "amis": {
6772
6800
  "hidden": true,
6773
6801
  "required": false
6774
6802
  }
6775
6803
  },
6776
6804
  "filter_fields": {
6805
+ "group": "",
6777
6806
  "amis": {
6778
6807
  "hidden": true,
6779
6808
  "required": false
6780
6809
  }
6781
6810
  },
6782
6811
  "scrolling_mode": {
6812
+ "group": "",
6783
6813
  "amis": {
6784
6814
  "hidden": true,
6785
6815
  "required": false
6786
6816
  }
6787
6817
  },
6788
6818
  "sort": {
6819
+ "group": "",
6789
6820
  "amis": {
6790
6821
  "hidden": true,
6791
6822
  "required": false
6792
6823
  }
6793
6824
  },
6794
6825
  "show_count": {
6826
+ "group": "",
6795
6827
  "amis": {
6796
6828
  "hidden": true,
6797
6829
  "required": false
6798
6830
  }
6799
6831
  },
6800
6832
  "type": {
6833
+ "group": "",
6801
6834
  "amis": {
6802
6835
  "hidden": true,
6803
6836
  "required": false
6804
6837
  }
6805
6838
  },
6806
6839
  "shared": {
6840
+ "group": "",
6807
6841
  "amis": {
6808
6842
  "visibleOn": "${global.user.is_space_admin}"
6809
6843
  }
6844
+ },
6845
+ "filters": {
6846
+ "group": "",
6847
+ "amis": {
6848
+ "hidden": true
6849
+ }
6810
6850
  }
6811
6851
  }
6812
6852
  }
@@ -6953,6 +6993,12 @@ function fieldsExtend$3(){
6953
6993
  "amis": {
6954
6994
  "visibleOn": "${global.user.is_space_admin}"
6955
6995
  }
6996
+ },
6997
+ "filters": {
6998
+ "group": "",
6999
+ "amis": {
7000
+ "hidden": true
7001
+ }
6956
7002
  }
6957
7003
  }
6958
7004
  }
@@ -7291,7 +7337,6 @@ function fieldsExtend$1(){
7291
7337
  }
7292
7338
  },
7293
7339
  "mobile_columns": {
7294
- "group": i18next__default["default"].t('frontend_listview_control_columns_mobile_group'),
7295
7340
  "amis": {
7296
7341
  "type": "transfer",
7297
7342
  "sortable": true,
@@ -8243,7 +8288,15 @@ async function getObjectCRUD(objectSchema, fields, options){
8243
8288
  hiddenOn: options.tableHiddenOn,
8244
8289
  autoFillHeight,
8245
8290
  className: `flex-auto ${crudClassName || ""}`,
8246
- bodyClassName: "bg-white",
8291
+ // 这里不可以用动态className,因为它会把样式类加到.antd-Crud和.antd-Table.antd-Crud-body这两层div中,而子表列表中crudClassName中有hidden样式类会造成所有子表都不显示的bug
8292
+ // className: {
8293
+ // [`flex-auto ${crudClassName || ""}`]: "true",
8294
+ // "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8295
+ // },
8296
+ bodyClassName: {
8297
+ "bg-white": "true",
8298
+ "is-steedos-crud-data-empty": "${!items || COUNT(items) == 0}"
8299
+ },
8247
8300
  crudClassName: crudClassName,
8248
8301
  quickSaveApi: {
8249
8302
  url: `\${context.rootUrl}/graphql`,
@@ -10134,8 +10187,6 @@ async function lookupToAmisTreeSelect(field, readonly, ctx) {
10134
10187
  return amisSchema;
10135
10188
  }
10136
10189
 
10137
- const keywordsSearchBoxName = `__keywords_lookup`;
10138
-
10139
10190
  const getReferenceToFieldSchema = (field, refObjectConfig)=>{
10140
10191
  let referenceTo = field.reference_to;
10141
10192
  if(!referenceTo){
@@ -10394,7 +10445,10 @@ async function lookupToAmisPicker(field, readonly, ctx){
10394
10445
 
10395
10446
  source.data.$term = "$term";
10396
10447
  source.data.$self = "$$";
10397
-
10448
+
10449
+ // field.name可能是带点的名称,比如审批王中子表字段'instances.instances_submitter',如果不替换掉点,会造成审批王表单中新建子表行时报错
10450
+ let keywordsSearchBoxName = `__keywords_lookup__${field.name.replace(/\./g, "_")}__to__${refObjectConfig.name}`;
10451
+
10398
10452
  source.requestAdaptor = `
10399
10453
  let __changedFilterFormValues = api.data.$self.__changedFilterFormValues || {};
10400
10454
  let __changedSearchBoxValues = api.data.$self.__changedSearchBoxValues || {};
@@ -10537,6 +10591,14 @@ async function lookupToAmisPicker(field, readonly, ctx){
10537
10591
  }
10538
10592
  });
10539
10593
  payload.data.rows = treeRecords;
10594
+ try{
10595
+ setTimeout(() => {
10596
+ $('.amis-dialog-widget.antd-Modal .antd-Table-content .antd-Table-table thead .antd-Table-expandBtn')[0]?.click();
10597
+ }, 600);
10598
+ }
10599
+ catch(ex){
10600
+ console.error("tree数据格式展开异常:", ex);
10601
+ }
10540
10602
  }
10541
10603
  return payload;
10542
10604
  `;
@@ -10709,6 +10771,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
10709
10771
 
10710
10772
  async function lookupToAmisSelect(field, readonly, ctx){
10711
10773
  let referenceTo = await getReferenceTo(field);
10774
+ const isMobile = window.innerWidth <= 768;
10712
10775
  const valueFieldKey = referenceTo && referenceTo.valueField?.name || '_id' ;
10713
10776
  // const labelFieldKey = referenceTo && referenceTo.labelField?.name || 'name';
10714
10777
 
@@ -10889,7 +10952,11 @@ async function lookupToAmisSelect(field, readonly, ctx){
10889
10952
  </span>
10890
10953
  <span class='pl-1.5'>\${label}</span>
10891
10954
  </span>`;
10892
- data.menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
10955
+ const menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
10956
+ // TODO: 待amis修复了此bug, 就可以撤销添加menuTpl的判断。
10957
+ if(!(isMobile && field.multiple)){
10958
+ data.menuTpl = menuTpl;
10959
+ }
10893
10960
  if(field.multiple){
10894
10961
  data.multiple = true;
10895
10962
  data.extractValue = true;
@@ -11397,6 +11464,8 @@ function getSelectFieldOptions(field){
11397
11464
  }
11398
11465
 
11399
11466
  async function convertSFieldToAmisField(field, readonly, ctx) {
11467
+ // console.log('convertSFieldToAmisField====>', field, readonly, ctx)
11468
+ const isMobile = window.innerWidth <= 768;
11400
11469
  // 创建人和修改人、创建时间和修改时间不显示
11401
11470
  if(___namespace.includes(OMIT_FIELDS, field.name) && ctx.showSystemFields != true){
11402
11471
  return;
@@ -11459,7 +11528,11 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
11459
11528
  </span>
11460
11529
  <span class='pl-1.5'>\${label}</span>
11461
11530
  </span>`;
11462
- convertData.menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
11531
+ const menuTpl = "${icon ? `"+select_menuTpl+"` : label}";
11532
+ // TODO: 待amis修复了此bug, 就可以撤销添加menuTpl的判断。
11533
+ if(!(isMobile && field.multiple)){
11534
+ convertData.menuTpl = menuTpl;
11535
+ }
11463
11536
  if(field.multiple){
11464
11537
  convertData.multiple = true;
11465
11538
  convertData.extractValue = true;
@@ -12320,7 +12393,7 @@ async function getFormBody(permissionFields, formFields, ctx){
12320
12393
  * @Author: 殷亮辉 yinlianghui@hotoa.com
12321
12394
  * @Date: 2023-11-15 09:50:22
12322
12395
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
12323
- * @LastEditTime: 2023-11-29 17:48:02
12396
+ * @LastEditTime: 2023-12-04 17:36:50
12324
12397
  */
12325
12398
 
12326
12399
  /**
@@ -12650,11 +12723,20 @@ const getAmisInputTableSchema = async (props, readonly) => {
12650
12723
  ],
12651
12724
  "className": props.className
12652
12725
  };
12726
+ let footerToolbar = _$1.clone(props.footerToolbar || []); //这里不clone的话,会造成死循环,应该是因为props属性变更会让组件重新渲染
12653
12727
  if (props.addable) {
12654
12728
  let buttonNewSchema = await getButtonNew(props);
12655
- schema.body.push(buttonNewSchema);
12729
+ footerToolbar.unshift(buttonNewSchema);
12730
+ }
12731
+ if (footerToolbar.length) {
12732
+ schema.body.push({
12733
+ "type": "wrapper",
12734
+ "size": "none",
12735
+ "body": footerToolbar
12736
+ });
12656
12737
  }
12657
12738
  if (props.amis) {
12739
+ delete props.amis.id;
12658
12740
  Object.assign(schema.body[0], props.amis);
12659
12741
  }
12660
12742
  return schema;