@steedos-widgets/amis-lib 1.1.6 → 1.1.8

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.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('lodash/isPlainObject'), require('@steedos-widgets/amis-lib')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'lodash', 'lodash/isPlainObject', '@steedos-widgets/amis-lib'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["amis-lib"] = {}, global._$1, global.isPlainObject, global.amisLib));
5
- })(this, (function (exports, _$1, isPlainObject, amisLib) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash'), require('@steedos-widgets/amis-lib'), require('lodash/isPlainObject')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'lodash', '@steedos-widgets/amis-lib', 'lodash/isPlainObject'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["amis-lib"] = {}, global._$1, global.amisLib, global.isPlainObject));
5
+ })(this, (function (exports, _$1, amisLib, isPlainObject) {
6
6
  const global = window;
7
7
 
8
8
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -1574,8 +1574,8 @@
1574
1574
  /*
1575
1575
  * @Author: 殷亮辉 yinlianghui@hotoa.com
1576
1576
  * @Date: 2023-03-22 09:31:21
1577
- * @LastEditors: Please set LastEditors
1578
- * @LastEditTime: 2023-03-28 14:06:47
1577
+ * @LastEditors: baozhoutao@steedos.com
1578
+ * @LastEditTime: 2023-04-06 16:04:20
1579
1579
  */
1580
1580
  const getSchema$2 = (uiSchema)=>{
1581
1581
  return {
@@ -1605,15 +1605,11 @@
1605
1605
  },
1606
1606
  "adaptor": `
1607
1607
  if(payload.errors){
1608
- payload.status = 2;
1609
- payload.msg = payload.errors[0].message;
1608
+ payload.status = 2;
1609
+ payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
1610
1610
  }
1611
1611
  return payload;
1612
1612
  `,
1613
- },
1614
- "messages": {
1615
- "success": "删除成功",
1616
- "failed": "删除失败"
1617
1613
  }
1618
1614
  },
1619
1615
  "actionType": "ajax"
@@ -3320,17 +3316,22 @@
3320
3316
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
3321
3317
  }
3322
3318
 
3323
- const getDisplayAsButton = function(showDisplayAs){
3319
+ const getDisplayAsButton = function(objectName, showDisplayAs){
3320
+ let displayAs = amisLib.Router.getTabDisplayAs(objectName);
3324
3321
  let buttons = [
3325
3322
  {
3326
3323
  "type": "button",
3327
3324
  "label": "表格",
3328
- "onClick": "const url = document.location.pathname + '?display=grid'; props.env.jumpTo(url);"
3325
+ "onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
3326
+ "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
3327
+ "rightIconClassName": "m-l-sm"
3329
3328
  },
3330
3329
  {
3331
3330
  "type": "button",
3332
3331
  "label": "分栏视图",
3333
- "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);"
3332
+ "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
3333
+ "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
3334
+ "rightIconClassName": "m-l-sm"
3334
3335
  }
3335
3336
  ];
3336
3337
  return {
@@ -3418,7 +3419,7 @@ setTimeout(()=>{
3418
3419
  `
3419
3420
  }
3420
3421
 
3421
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false} = {}){
3422
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems} = {}){
3422
3423
  const isMobile = window.innerWidth < 768;
3423
3424
  if(isMobile){
3424
3425
  showDisplayAs = false;
@@ -3472,11 +3473,12 @@ setTimeout(()=>{
3472
3473
  }
3473
3474
  }
3474
3475
  },
3475
- showDisplayAs? getDisplayAsButton() : {}
3476
+ showDisplayAs? getDisplayAsButton(mainObject?.name) : {}
3476
3477
  ]
3477
3478
  }else {
3478
3479
  return [
3479
3480
  // "filter-toggler",
3481
+ ...(headerToolbarItems || []),
3480
3482
  "bulkActions",
3481
3483
  {
3482
3484
  "type": "columns-toggler",
@@ -3552,7 +3554,7 @@ setTimeout(()=>{
3552
3554
  }
3553
3555
  }
3554
3556
  },
3555
- showDisplayAs? getDisplayAsButton() : {}
3557
+ showDisplayAs? getDisplayAsButton(showDisplayAs) : {}
3556
3558
  // {
3557
3559
  // "type": "search-box",
3558
3560
  // "align": "right",
@@ -4144,20 +4146,20 @@ setTimeout(()=>{
4144
4146
 
4145
4147
  if(referenceTo){
4146
4148
  // 字段值单独走一个请求合并到source的同一个GraphQL接口中
4147
- const defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, {
4148
- [referenceTo.labelField.name]: Object.assign({}, referenceTo.labelField, {alias: 'label'}),
4149
- [referenceTo.valueField.name]: Object.assign({}, referenceTo.valueField, {alias: 'value'})
4150
- }, {
4149
+ const defaultValueOptionsQueryData = await getFindQuery({ name: referenceTo.objectName }, null, [
4150
+ Object.assign({}, referenceTo.labelField, {alias: 'label'}),
4151
+ Object.assign({}, referenceTo.valueField, {alias: 'value'})
4152
+ ], {
4151
4153
  alias: "defaultValueOptions",
4152
4154
  filters: "{__options_filters}",
4153
4155
  count: false
4154
4156
  });
4155
4157
  apiInfo = await getApi$1({
4156
4158
  name: referenceTo.objectName
4157
- }, null, {
4158
- [referenceTo.labelField.name]: Object.assign({}, referenceTo.labelField, {alias: 'label'}),
4159
- [referenceTo.valueField.name]: Object.assign({}, referenceTo.valueField, {alias: 'value'})
4160
- }, {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`, moreQueries: [defaultValueOptionsQueryData.query]});
4159
+ }, null, [
4160
+ Object.assign({}, referenceTo.labelField, {alias: 'label'}),
4161
+ Object.assign({}, referenceTo.valueField, {alias: 'value'})
4162
+ ], {expand: false, alias: 'options', queryOptions: `filters: {__filters}, top: {__top}, sort: "{__sort}"`, moreQueries: [defaultValueOptionsQueryData.query]});
4161
4163
 
4162
4164
  apiInfo.adaptor = `
4163
4165
  const data = payload.data;
@@ -4973,13 +4975,19 @@ setTimeout(()=>{
4973
4975
  };
4974
4976
  break;
4975
4977
  case 'percent':
4976
- //TODO
4977
- convertData = {
4978
- type: getAmisStaticFieldType('number', readonly),
4979
- min: field.min,
4980
- max: field.max,
4981
- precision: field.scale
4982
- };
4978
+ if(readonly){
4979
+ convertData = {
4980
+ type: 'static-tpl',
4981
+ tpl: getUiFieldTpl(field)
4982
+ };
4983
+ }else {
4984
+ convertData = {
4985
+ type: getAmisStaticFieldType('number', readonly),
4986
+ min: field.min,
4987
+ max: field.max,
4988
+ precision: field.scale
4989
+ };
4990
+ }
4983
4991
  break;
4984
4992
  case 'password':
4985
4993
  convertData = {
@@ -5021,12 +5029,18 @@ setTimeout(()=>{
5021
5029
  break;
5022
5030
  case 'formula':
5023
5031
  if(readonly){
5024
- convertData.type = getAmisStaticFieldType(field.data_type, readonly);
5032
+ convertData = {
5033
+ type: 'static-tpl',
5034
+ tpl: getUiFieldTpl(field)
5035
+ };
5025
5036
  }
5026
5037
  break;
5027
5038
  case 'summary':
5028
5039
  if(readonly){
5029
- convertData.type = getAmisStaticFieldType(field.data_type, readonly);
5040
+ convertData = {
5041
+ type: 'static-tpl',
5042
+ tpl: getUiFieldTpl(field)
5043
+ };
5030
5044
  }
5031
5045
  break;
5032
5046
  case 'code':
@@ -5739,7 +5753,11 @@ setTimeout(()=>{
5739
5753
  }
5740
5754
  }
5741
5755
 
5742
- bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs, hiddenCount: options.queryCount === false});
5756
+ bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {
5757
+ showDisplayAs,
5758
+ hiddenCount: options.queryCount === false,
5759
+ headerToolbarItems: options.headerToolbarItems
5760
+ });
5743
5761
 
5744
5762
 
5745
5763
  let body = null;
@@ -5778,7 +5796,7 @@ setTimeout(()=>{
5778
5796
  keepItemSelectionOnPageChange: true,
5779
5797
  api: await getTableApi(objectSchema, fields, options),
5780
5798
  hiddenOn: options.tableHiddenOn,
5781
- autoFillHeight: true,
5799
+ autoFillHeight: options.isRelated ? false : true,
5782
5800
  className: `flex-auto ${crudClassName || ""}`,
5783
5801
  crudClassName: crudClassName,
5784
5802
  },
@@ -5938,6 +5956,10 @@ setTimeout(()=>{
5938
5956
  "objectName": "${_master.objectName}"
5939
5957
  },
5940
5958
  "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
5959
+ },
5960
+ {
5961
+ "args": {},
5962
+ "actionType": "closeDialog"
5941
5963
  }
5942
5964
  ]
5943
5965
  }
@@ -7973,7 +7995,8 @@ setTimeout(()=>{
7973
7995
  "sort": sort,
7974
7996
  "ctx": ctx,
7975
7997
  "requestAdaptor": listView.requestAdaptor,
7976
- "adaptor": listView.adaptor
7998
+ "adaptor": listView.adaptor,
7999
+ "headerToolbarItems": ctx.headerToolbarItems
7977
8000
  };
7978
8001
  return {
7979
8002
  uiSchema,
@@ -8034,6 +8057,7 @@ setTimeout(()=>{
8034
8057
  ...ctx,
8035
8058
  filter: ctx.filters,
8036
8059
  sort,
8060
+ headerToolbarItems: ctx.headerToolbarItems,
8037
8061
  buttons: await getListViewItemButtons(uiSchema, ctx)
8038
8062
  });
8039
8063
  return {