@steedos-widgets/amis-lib 6.3.3 → 6.3.5

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, clone, filter, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, trimEnd, has, isBoolean, omitBy, isNil, toArray, mergeWith, get, map, isString, union, 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';
@@ -1160,12 +1160,18 @@ function getAmisStaticFieldType(type, readonly, options){
1160
1160
  * @Author: baozhoutao@steedos.com
1161
1161
  * @Date: 2022-07-13 15:18:03
1162
1162
  * @LastEditors: baozhoutao@steedos.com
1163
- * @LastEditTime: 2023-04-11 10:34:26
1163
+ * @LastEditTime: 2024-08-15 12:12:08
1164
1164
  * @Description:
1165
1165
  */
1166
+ let pageCache = {};
1166
1167
 
1167
1168
  async function getPage({type, pageId = '', appId, objectName = '', recordId = '', formFactor = 'LARGE'}){
1168
1169
  const api = `/api/pageSchema/${type}?app=${appId}&objectApiName=${objectName}&recordId=${recordId}&pageId=${pageId}&formFactor=${formFactor}`;
1170
+
1171
+ if(has(pageCache, api)) {
1172
+ return pageCache[api];
1173
+ }
1174
+
1169
1175
  const page = await fetchAPI(api);
1170
1176
  if (page && page.schema) {
1171
1177
  page.schema = JSON.parse(page.schema);
@@ -1175,8 +1181,10 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
1175
1181
  delete page.schema.data.context;
1176
1182
  delete page.schema.data.global;
1177
1183
  }
1178
- return page;
1184
+ pageCache[api] = page;
1185
+ return JSON.parse(JSON.stringify(page)); //clone page;
1179
1186
  }
1187
+ pageCache[api] = null;
1180
1188
  }
1181
1189
 
1182
1190
  /*
@@ -7777,7 +7785,7 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
7777
7785
 
7778
7786
  // console.log('=======================max=========================', max)
7779
7787
 
7780
- if(objectSchema.compactLayouts){
7788
+ if(objectSchema.compactLayouts && objectSchema.compactLayouts.length > 0){
7781
7789
  const details = [];
7782
7790
  _.each(_.slice(_.difference(objectSchema.compactLayouts, [objectSchema.NAME_FIELD_KEY]), 0, max), (fieldName)=>{
7783
7791
  const field = objectSchema.fields[fieldName];
@@ -8727,7 +8735,7 @@ const getSettingListviewToolbarButtonSchema = ()=>{
8727
8735
  // "tooltip": i18next.t('frontend_button_listview_control_tooltip'),
8728
8736
  "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
8729
8737
  "align": "right",
8730
- "visibleOn": "${!isLookup}",
8738
+ "visibleOn": "${!isLookup && !!isObjectListview}",
8731
8739
  "buttons": [
8732
8740
  {
8733
8741
  "label": i18next.t('frontend_button_listview_control_label'),
@@ -8772,7 +8780,7 @@ const getDisplayAsButton = function(objectName, defaultEnableSplit){
8772
8780
  // "tooltip": `${i18next.t('frontend_display_as')} ${displayAsLabel}`,
8773
8781
  "btnClassName": "antd-Button--iconOnly bg-white !p-2 rounded text-gray-500",
8774
8782
  "align": "right",
8775
- "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
8783
+ "visibleOn": "${window:innerWidth > 768 && !!!isLookup && !!isObjectListview}",
8776
8784
  "buttons": [
8777
8785
  {
8778
8786
  "label": i18next.t('frontend_display_as'),
@@ -8973,18 +8981,19 @@ function getObjectHeaderToolbar(mainObject, fields, formFactor, {
8973
8981
  }
8974
8982
  let toolbarReloadButton;
8975
8983
  const onReloadScript = `
8976
- // const scope = event.context.scoped;
8977
- // var listView = scope.parent.getComponents().find(function(n){
8978
- // return n.props.type === "crud";
8979
- // });
8980
- // listView.handleChangePage(1);
8981
-
8982
-
8983
8984
  // 触发搜索,而不是reload,因为使用search-box可以在amissdk是3.6.3-patch.8+实现在非第一页的情况下,快速搜索输入框中过滤条件变更时再点刷新可以自动跳转翻页到第一页
8984
8985
  const scope = event.context.scoped;
8985
8986
  const sb = SteedosUI.getClosestAmisComponentByType(scope, "search-box");
8986
- const sbValue = sb.state.value;
8987
- sb.handleSearch(sbValue);
8987
+ if (sb) {
8988
+ const sbValue = sb.state.value;
8989
+ sb.handleSearch(sbValue);
8990
+ }else{
8991
+ var listView = scope.parent.getComponents().find(function(n){
8992
+ return n.props.type === "crud";
8993
+ });
8994
+ listView.handleChangePage(1);
8995
+ }
8996
+
8988
8997
  `;
8989
8998
  toolbarReloadButton = {
8990
8999
  // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页,这在加载更多按钮的翻页模式下会有问题
@@ -13446,9 +13455,21 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
13446
13455
  break;
13447
13456
  case 'percent':
13448
13457
  if(readonly){
13458
+ // convertData = {
13459
+ // type: 'static-tpl',
13460
+ // tpl: Tpl.getUiFieldTpl(field)
13461
+ // }
13449
13462
  convertData = {
13450
- type: 'static-tpl',
13451
- tpl: getUiFieldTpl(field)
13463
+ "type": "static-progress",
13464
+ "name": "progress",
13465
+ pipeIn: (value, data) => {
13466
+ if(value){
13467
+ // 因为例如 1.11 * 100 的值不是111,所以调整下。
13468
+ const result = value*100;
13469
+ return Number(result.toFixed(field.scale));
13470
+ }
13471
+ return value;
13472
+ }
13452
13473
  };
13453
13474
  }else {
13454
13475
  convertData = {