@steedos-widgets/amis-object 1.2.12 → 1.2.13

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.
@@ -1237,6 +1237,9 @@ body {
1237
1237
  -moz-column-gap: 1rem;
1238
1238
  column-gap: 1rem;
1239
1239
  }
1240
+ .steedos-amis-form .antd-Collapse .antd-Collapse-header.hidden {
1241
+ display: none !important;
1242
+ }
1240
1243
 
1241
1244
  @media (max-width: 768px) {
1242
1245
  .record-detail-header-name {
@@ -2253,7 +2253,23 @@
2253
2253
  {
2254
2254
  name: "template_url",
2255
2255
  label: "导入模板",
2256
- type: "markdown",
2256
+ type: "button-group",
2257
+ buttons: [
2258
+ {
2259
+ type: "button",
2260
+ label: "下载",
2261
+ visibleOn: "${template_url}",
2262
+ level: "link",
2263
+ actionType: "download",
2264
+ api:{
2265
+ url: "${template_url}",
2266
+ method: "get",
2267
+ headers: {
2268
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
2269
+ }
2270
+ }
2271
+ }
2272
+ ],
2257
2273
  options: {
2258
2274
  html: true
2259
2275
  },
@@ -5013,12 +5029,13 @@
5013
5029
  "type": "dropdown-button",
5014
5030
  "trigger": "click",
5015
5031
  "icon": "fa fa-cog",
5032
+ "tooltip": "列表视图控制",
5016
5033
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
5017
5034
  "align": "right",
5018
5035
  "visibleOn": "${!isLookup}",
5019
5036
  "buttons": [
5020
5037
  {
5021
- "label": "列表视图操作",
5038
+ "label": "列表视图控制",
5022
5039
  "children": [
5023
5040
  getNewListviewButtonSchema(),
5024
5041
  getCopyListviewButtonSchema(),
@@ -5052,9 +5069,11 @@
5052
5069
  "rightIconClassName": "m-l-sm"
5053
5070
  }
5054
5071
  ];
5072
+ const displayAsLabel = displayAs === 'split'? "分栏视图" : "表格";
5055
5073
  return {
5056
5074
  "type": "dropdown-button",
5057
5075
  "icon": "fa fa-table-columns",
5076
+ "tooltip": `显示为 ${displayAsLabel}`,
5058
5077
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
5059
5078
  "align": "right",
5060
5079
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
@@ -5134,6 +5153,7 @@ else{
5134
5153
  // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
5135
5154
  "type": "button",
5136
5155
  "align": "right",
5156
+ "tooltip": "刷新",
5137
5157
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5138
5158
  "label": "",
5139
5159
  "icon": "fa fa-sync",
@@ -5153,6 +5173,7 @@ else{
5153
5173
  "label": "",
5154
5174
  "icon": "fa fa-search",
5155
5175
  "type": "button",
5176
+ "tooltip": "搜索",
5156
5177
  "badge": {
5157
5178
  "offset": [
5158
5179
  -5,
@@ -5197,6 +5218,7 @@ else{
5197
5218
  {
5198
5219
  "type": "reload",
5199
5220
  "align": "right",
5221
+ "tooltip": "刷新",
5200
5222
  "tooltipPlacement": "bottom",
5201
5223
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5202
5224
  },
@@ -5204,6 +5226,8 @@ else{
5204
5226
  filterVisible ? {
5205
5227
  "label": "",
5206
5228
  "icon": "fa fa-search",
5229
+ "tooltip": "搜索",
5230
+ "tooltipPlacement": "bottom",
5207
5231
  "type": "button",
5208
5232
  "align": "right",
5209
5233
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
@@ -6228,8 +6252,8 @@ else{
6228
6252
  /*
6229
6253
  * @Author: baozhoutao@steedos.com
6230
6254
  * @Date: 2023-01-13 17:27:54
6231
- * @LastEditors: baozhoutao@steedos.com
6232
- * @LastEditTime: 2023-01-16 10:36:27
6255
+ * @LastEditors: Please set LastEditors
6256
+ * @LastEditTime: 2023-05-31 13:34:22
6233
6257
  * @Description:
6234
6258
  */
6235
6259
 
@@ -6271,8 +6295,12 @@ else{
6271
6295
  const getHtmlFieldSchema = (field, readonly, ctx)=>{
6272
6296
  if(readonly){
6273
6297
  return {
6274
- "type": "html",
6275
- "name": field.name
6298
+ "type": "control",
6299
+ "label": field.label,
6300
+ "body": {
6301
+ "type": "html",
6302
+ "name": field.name
6303
+ }
6276
6304
  }
6277
6305
  }else {
6278
6306
  return {
@@ -6299,8 +6327,8 @@ else{
6299
6327
  /*
6300
6328
  * @Author: baozhoutao@steedos.com
6301
6329
  * @Date: 2022-10-28 14:52:55
6302
- * @LastEditors: baozhoutao@steedos.com
6303
- * @LastEditTime: 2022-10-28 14:53:02
6330
+ * @LastEditors: Please set LastEditors
6331
+ * @LastEditTime: 2023-05-31 13:25:53
6304
6332
  * @Description:
6305
6333
  */
6306
6334
 
@@ -6849,8 +6877,19 @@ else{
6849
6877
  break;
6850
6878
  case 'url':
6851
6879
  convertData = {
6852
- type: getAmisStaticFieldType('url', readonly)
6880
+ type: getAmisStaticFieldType('url', readonly, field)
6853
6881
  };
6882
+ if(readonly && field.show_as_qr){
6883
+ convertData = {
6884
+ type: "control",
6885
+ label: field.label,
6886
+ body: {
6887
+ type: "qr-code",
6888
+ codeSize: 128,
6889
+ name: field.name
6890
+ }
6891
+ };
6892
+ }
6854
6893
  break;
6855
6894
  case 'email':
6856
6895
  convertData = {
@@ -6885,6 +6924,7 @@ else{
6885
6924
  case 'code':
6886
6925
  convertData = {
6887
6926
  type: "editor",
6927
+ disabled: readonly ? true : false,
6888
6928
  language: field.language,
6889
6929
  editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
6890
6930
  };
@@ -7542,12 +7582,43 @@ else{
7542
7582
  const fieldSchemaArray = getFieldSchemaArray(formFields);
7543
7583
  const _sections = ___default__namespace.groupBy(fieldSchemaArray, 'group');
7544
7584
  const sections = [];
7585
+ var sectionHeaderVisibleOn=[];
7545
7586
  for (const key in _sections) {
7546
7587
  const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
7547
7588
  if(section.body.length > 0){
7589
+ if(section.visibleOn){
7590
+ sectionHeaderVisibleOn.push(section.visibleOn);
7591
+ }
7548
7592
  sections.push(section);
7549
7593
  }
7550
7594
  }
7595
+ /*
7596
+ 为了实现只有一个分组时隐藏该分组标题,需要分三种情况(分组如果没有visibleon属性就代表一定显示,有visibleon需要进行判断)
7597
+ 1.所有分组中只有一个分组没有visibleon,还需要判断其他有visibleon的分组是否显示,只有其他都不显示时,才需要隐藏标题;反之,有任何一个显示,就不需要隐藏标题
7598
+ 2.所有分组都有visibleon
7599
+ 2.1 当前分组为隐藏时,标题就设置为隐藏
7600
+ 2.2 当前分组为显示时,其他分组只要有一个是显示,就显示该分组标题
7601
+ 2.3 当前分组为显示时,其他分组都隐藏,就隐藏该分组标题
7602
+ 3.所有分组中有两个以上的分组没有visibleon(这种情况不用处理)
7603
+ */
7604
+ if(ctx.mode == "edit"){
7605
+ if (sections.length - sectionHeaderVisibleOn.length == 1) {
7606
+ sections.forEach((section) => {
7607
+ section.headingClassName = {
7608
+ "hidden": `!(${sectionHeaderVisibleOn.join(" || ") || 'false'})`
7609
+ };
7610
+ });
7611
+ } else if (sections.length == sectionHeaderVisibleOn.length) {
7612
+ sections.forEach((section, index) => {
7613
+ var tempSectionHeaderVisibleOn = sectionHeaderVisibleOn.slice();
7614
+ tempSectionHeaderVisibleOn.splice(index, 1);
7615
+ section.headingClassName = {
7616
+ "hidden": `!((${tempSectionHeaderVisibleOn.join(" || ") || 'false'}) && ${sectionHeaderVisibleOn[index]})`
7617
+ };
7618
+ });
7619
+ }
7620
+ }
7621
+
7551
7622
  return sections;
7552
7623
  };
7553
7624
 
@@ -8062,6 +8133,8 @@ else{
8062
8133
  type = 'tpl';
8063
8134
  }else if(field.type === 'html'){
8064
8135
  type = 'markdown';
8136
+ }else if(field.type === 'url' && field.show_as_qr){
8137
+ type = 'qr-code';
8065
8138
  }
8066
8139
  let className = "";
8067
8140
  if(field.type === 'textarea'){
@@ -8089,7 +8162,13 @@ else{
8089
8162
 
8090
8163
  }
8091
8164
  // columns.push(getOperation(fields));
8092
-
8165
+ if(!___default__namespace.some(columns, { name: options.labelFieldName })){
8166
+ const href = Router$1.getObjectDetailPath({
8167
+ ...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
8168
+ });
8169
+ columns[0].type = "tpl";
8170
+ columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
8171
+ }
8093
8172
  return columns;
8094
8173
  }
8095
8174
 
@@ -8455,6 +8534,8 @@ else{
8455
8534
 
8456
8535
  const fileFields = {};
8457
8536
  const fileFieldsKeys = [];
8537
+ // 含有optionsFunction属性, 无reference_to属性的lookup字段
8538
+ const lookupFields = {};
8458
8539
  fields.forEach((item)=>{
8459
8540
  if(___default__namespace.includes(['image','avatar','file'], item.type)){
8460
8541
  fileFieldsKeys.push(item.name);
@@ -8464,6 +8545,9 @@ else{
8464
8545
  multiple: item.multiple
8465
8546
  };
8466
8547
  }
8548
+ if(___default__namespace.includes(['lookup'], item.type) && !item.reference_to ){
8549
+ lookupFields[item.name] = item;
8550
+ }
8467
8551
  });
8468
8552
 
8469
8553
  let valueField = mainObject.key_field || '_id';
@@ -8480,6 +8564,7 @@ else{
8480
8564
  api.data.filter = "$filter";
8481
8565
  api.data.loaded = "${loaded}";
8482
8566
  api.data.listViewId = "${listViewId}";
8567
+ api.data.listName = "${listName}";
8483
8568
  api.requestAdaptor = `
8484
8569
  // selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
8485
8570
  let selfData = JSON.parse(JSON.stringify(api.data.$self));
@@ -8510,9 +8595,13 @@ else{
8510
8595
  console.error("本地存储中crud参数解析异常:", ex);
8511
8596
  }
8512
8597
  ${baseFilters ? `var systemFilters = ${JSON.stringify(baseFilters)};` : 'var systemFilters = [];'}
8598
+ var _ids = []
8513
8599
  const filtersFunction = ${filtersFunction};
8514
8600
  if(filtersFunction){
8515
8601
  const _filters = filtersFunction(systemFilters, api.data.$self);
8602
+ if(api.data.listName == "recent"){
8603
+ _ids = _filters[2]
8604
+ }
8516
8605
  if(_filters && _filters.length > 0){
8517
8606
  if(_.isEmpty(systemFilters)){
8518
8607
  systemFilters = _filters || [];
@@ -8624,6 +8713,7 @@ else{
8624
8713
  filters = [filters, 'and', userFilters]
8625
8714
  }
8626
8715
  }
8716
+ api.data._ids = _ids;
8627
8717
  api.data = {
8628
8718
  query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
8629
8719
  }
@@ -8631,6 +8721,11 @@ else{
8631
8721
  return api;
8632
8722
  `;
8633
8723
  api.adaptor = `
8724
+ if(api.body.listName == "recent"){
8725
+ payload.data.rows = _.sortBy(payload.data.rows, function(item){
8726
+ return _.indexOf(api.body._ids, item._id)
8727
+ });
8728
+ }
8634
8729
  const enable_tree = ${mainObject.enable_tree};
8635
8730
  if(!enable_tree){
8636
8731
  _.each(payload.data.rows, function(item, index){
@@ -8641,9 +8736,10 @@ else{
8641
8736
  }
8642
8737
  window.postMessage(Object.assign({type: "listview.loaded"}), "*");
8643
8738
  let fileFields = ${JSON.stringify(fileFields)};
8739
+ let lookupFields = ${JSON.stringify(lookupFields)};
8644
8740
  _.each(payload.data.rows, function(item, index){
8645
8741
  _.each(fileFields , (field, key)=>{
8646
- if(item[key] && item._display && item._display [key]){
8742
+ if(item[key] && item._display && item._display[key]){
8647
8743
  let value = item._display[key];
8648
8744
  if(!_.isArray(value)){
8649
8745
  value = [value]
@@ -8655,6 +8751,14 @@ else{
8655
8751
  }
8656
8752
  }
8657
8753
  })
8754
+ _.each(lookupFields , (field, key)=>{
8755
+ if(item[key]){
8756
+ if(field._optionsFunction){
8757
+ const optionsFunction = eval("(" + field._optionsFunction+ ")")(item);
8758
+ item[key + '__label'] = _.map(_.filter(optionsFunction, function(option){return _.includes(item[key], option.value)}), 'label').join(' ');
8759
+ }
8760
+ }
8761
+ })
8658
8762
  })
8659
8763
 
8660
8764
  if(enable_tree){
@@ -9984,6 +10088,24 @@ else{
9984
10088
 
9985
10089
  ctx.defaults = defaults;
9986
10090
 
10091
+ if (listViewName == "recent") {
10092
+ listview_filters = `
10093
+ function(filters, data) {
10094
+ var result = Steedos.authRequest('/graphql', {
10095
+ type: 'POST',
10096
+ async: false,
10097
+ data: JSON.stringify({
10098
+ query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
10099
+ }),
10100
+ });
10101
+ var _ids = []
10102
+ result.data.object_recent_viewed.forEach(function (item) {
10103
+ _ids = _ids.concat(item.record.ids)
10104
+ })
10105
+ return ["_id", "=", _ids];
10106
+ }
10107
+ `;
10108
+ }
9987
10109
  const amisSchema = {
9988
10110
  "type": "steedos-object-table",
9989
10111
  "objectApiName": objectName,
@@ -13719,6 +13841,7 @@ else{
13719
13841
  // className不传入crud组件,crud单独识别crudClassName属性
13720
13842
  listSchema.className = crudClassName;
13721
13843
  listSchema.onEvent = {}; // 为啥要将一个内置event放在此处?
13844
+ // 下面expression中_isRelated参数判断的是列表视图分栏模式下,新建、编辑、删除相关子表记录时不应该刷新左侧(主表)列表视图组件
13722
13845
  listSchema.onEvent["@data.changed.".concat(objectApiName)] = {
13723
13846
  "actions": [
13724
13847
  {
@@ -15298,7 +15421,7 @@ else{
15298
15421
  "method": "post",
15299
15422
  "url": "${context.rootUrl}/graphql?keywords=${keywords}",
15300
15423
  "requestAdaptor": "\n const keywords = api.body.keywords || '';\n const appId = '".concat(data.app_id || '', "';\n api.data = {\n query: `\n {\n options: flows__getList(action: \"").concat(action, "\", keywords: \"${keywords}\", appId: \"${appId}\", distributeInstanceId: \"").concat(distributeInstanceId, "\", distributeStepId: \"").concat(distributeStepId, "\"){\n value:_id\n label:name\n children: flows{\n value: _id,\n label: name\n }\n }\n }\n `\n }\n "),
15301
- "adaptor": "\n payload.data.options?.forEach(function(item,index) {\n if(!item.children || item.children.length == 0){\n payload.data.options.splice(index)\n }\n })\n return payload;\n ",
15424
+ "adaptor": "\n payload.data.options?.forEach(function(item,index) {\n if(!item.children || item.children.length == 0){\n payload.data.options.splice(index,1)\n }\n })\n return payload;\n ",
15302
15425
  "headers": {
15303
15426
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
15304
15427
  }