@steedos-widgets/amis-object 1.2.11 → 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 {
@@ -2227,7 +2227,23 @@ const getSchema$1 = (uiSchema) => {
2227
2227
  {
2228
2228
  name: "template_url",
2229
2229
  label: "导入模板",
2230
- type: "markdown",
2230
+ type: "button-group",
2231
+ buttons: [
2232
+ {
2233
+ type: "button",
2234
+ label: "下载",
2235
+ visibleOn: "${template_url}",
2236
+ level: "link",
2237
+ actionType: "download",
2238
+ api:{
2239
+ url: "${template_url}",
2240
+ method: "get",
2241
+ headers: {
2242
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
2243
+ }
2244
+ }
2245
+ }
2246
+ ],
2231
2247
  options: {
2232
2248
  html: true
2233
2249
  },
@@ -2775,7 +2791,14 @@ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
2775
2791
  className: `button_${button.name}`
2776
2792
  }
2777
2793
  });
2778
- let dropdownButtons = ___default__default.map(moreButtons, (button) => {
2794
+ let moreButtonsVisibleOn = '';
2795
+ let dropdownButtons = ___default__default.map(moreButtons, (button, index) => {
2796
+ if(index === 0){
2797
+ moreButtonsVisibleOn = getButtonVisibleOn$1(button);
2798
+ }else {
2799
+ moreButtonsVisibleOn = moreButtonsVisibleOn + ' || ' +getButtonVisibleOn$1(button);
2800
+ }
2801
+
2779
2802
  return {
2780
2803
  type: 'steedos-object-button',
2781
2804
  name: button.name,
@@ -2785,12 +2808,13 @@ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
2785
2808
  });
2786
2809
  return {
2787
2810
  buttons: amisButtonsSchema,
2788
- moreButtons: dropdownButtons
2811
+ moreButtons: dropdownButtons,
2812
+ moreButtonsVisibleOn
2789
2813
  };
2790
2814
  };
2791
2815
 
2792
2816
  const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2793
- const { buttons, moreButtons } = getObjectDetailHeaderButtons(objectSchema, recordId);
2817
+ const { buttons, moreButtons, moreButtonsVisibleOn } = getObjectDetailHeaderButtons(objectSchema, recordId);
2794
2818
  if(ctx.formFactor === 'SMALL'){
2795
2819
  return {
2796
2820
  "type": "button",
@@ -2845,7 +2869,8 @@ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2845
2869
  type: "steedos-dropdown-button",
2846
2870
  label: "",
2847
2871
  buttons: moreButtons,
2848
- className: 'slds-icon'
2872
+ className: 'slds-icon',
2873
+ visibleOn: moreButtonsVisibleOn
2849
2874
  };
2850
2875
  buttons.push(dropdownButtonsSchema);
2851
2876
  }
@@ -4978,12 +5003,13 @@ const getSettingListviewToolbarButtonSchema = ()=>{
4978
5003
  "type": "dropdown-button",
4979
5004
  "trigger": "click",
4980
5005
  "icon": "fa fa-cog",
5006
+ "tooltip": "列表视图控制",
4981
5007
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4982
5008
  "align": "right",
4983
5009
  "visibleOn": "${!isLookup}",
4984
5010
  "buttons": [
4985
5011
  {
4986
- "label": "列表视图操作",
5012
+ "label": "列表视图控制",
4987
5013
  "children": [
4988
5014
  getNewListviewButtonSchema(),
4989
5015
  getCopyListviewButtonSchema(),
@@ -5017,9 +5043,11 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
5017
5043
  "rightIconClassName": "m-l-sm"
5018
5044
  }
5019
5045
  ];
5046
+ const displayAsLabel = displayAs === 'split'? "分栏视图" : "表格";
5020
5047
  return {
5021
5048
  "type": "dropdown-button",
5022
5049
  "icon": "fa fa-table-columns",
5050
+ "tooltip": `显示为 ${displayAsLabel}`,
5023
5051
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
5024
5052
  "align": "right",
5025
5053
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
@@ -5099,6 +5127,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5099
5127
  // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
5100
5128
  "type": "button",
5101
5129
  "align": "right",
5130
+ "tooltip": "刷新",
5102
5131
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5103
5132
  "label": "",
5104
5133
  "icon": "fa fa-sync",
@@ -5118,6 +5147,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5118
5147
  "label": "",
5119
5148
  "icon": "fa fa-search",
5120
5149
  "type": "button",
5150
+ "tooltip": "搜索",
5121
5151
  "badge": {
5122
5152
  "offset": [
5123
5153
  -5,
@@ -5162,6 +5192,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5162
5192
  {
5163
5193
  "type": "reload",
5164
5194
  "align": "right",
5195
+ "tooltip": "刷新",
5165
5196
  "tooltipPlacement": "bottom",
5166
5197
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5167
5198
  },
@@ -5169,6 +5200,8 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5169
5200
  filterVisible ? {
5170
5201
  "label": "",
5171
5202
  "icon": "fa fa-search",
5203
+ "tooltip": "搜索",
5204
+ "tooltipPlacement": "bottom",
5172
5205
  "type": "button",
5173
5206
  "align": "right",
5174
5207
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
@@ -6193,8 +6226,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
6193
6226
  /*
6194
6227
  * @Author: baozhoutao@steedos.com
6195
6228
  * @Date: 2023-01-13 17:27:54
6196
- * @LastEditors: baozhoutao@steedos.com
6197
- * @LastEditTime: 2023-01-16 10:36:27
6229
+ * @LastEditors: Please set LastEditors
6230
+ * @LastEditTime: 2023-05-31 13:34:22
6198
6231
  * @Description:
6199
6232
  */
6200
6233
 
@@ -6236,8 +6269,12 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
6236
6269
  const getHtmlFieldSchema = (field, readonly, ctx)=>{
6237
6270
  if(readonly){
6238
6271
  return {
6239
- "type": "html",
6240
- "name": field.name
6272
+ "type": "control",
6273
+ "label": field.label,
6274
+ "body": {
6275
+ "type": "html",
6276
+ "name": field.name
6277
+ }
6241
6278
  }
6242
6279
  }else {
6243
6280
  return {
@@ -6264,8 +6301,8 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
6264
6301
  /*
6265
6302
  * @Author: baozhoutao@steedos.com
6266
6303
  * @Date: 2022-10-28 14:52:55
6267
- * @LastEditors: baozhoutao@steedos.com
6268
- * @LastEditTime: 2022-10-28 14:53:02
6304
+ * @LastEditors: Please set LastEditors
6305
+ * @LastEditTime: 2023-05-31 13:25:53
6269
6306
  * @Description:
6270
6307
  */
6271
6308
 
@@ -6814,8 +6851,19 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6814
6851
  break;
6815
6852
  case 'url':
6816
6853
  convertData = {
6817
- type: getAmisStaticFieldType('url', readonly)
6854
+ type: getAmisStaticFieldType('url', readonly, field)
6818
6855
  };
6856
+ if(readonly && field.show_as_qr){
6857
+ convertData = {
6858
+ type: "control",
6859
+ label: field.label,
6860
+ body: {
6861
+ type: "qr-code",
6862
+ codeSize: 128,
6863
+ name: field.name
6864
+ }
6865
+ };
6866
+ }
6819
6867
  break;
6820
6868
  case 'email':
6821
6869
  convertData = {
@@ -6850,6 +6898,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6850
6898
  case 'code':
6851
6899
  convertData = {
6852
6900
  type: "editor",
6901
+ disabled: readonly ? true : false,
6853
6902
  language: field.language,
6854
6903
  editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
6855
6904
  };
@@ -7507,12 +7556,43 @@ const getSections = async (permissionFields, formFields, ctx) => {
7507
7556
  const fieldSchemaArray = getFieldSchemaArray(formFields);
7508
7557
  const _sections = ___default.groupBy(fieldSchemaArray, 'group');
7509
7558
  const sections = [];
7559
+ var sectionHeaderVisibleOn=[];
7510
7560
  for (const key in _sections) {
7511
7561
  const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
7512
7562
  if(section.body.length > 0){
7563
+ if(section.visibleOn){
7564
+ sectionHeaderVisibleOn.push(section.visibleOn);
7565
+ }
7513
7566
  sections.push(section);
7514
7567
  }
7515
7568
  }
7569
+ /*
7570
+ 为了实现只有一个分组时隐藏该分组标题,需要分三种情况(分组如果没有visibleon属性就代表一定显示,有visibleon需要进行判断)
7571
+ 1.所有分组中只有一个分组没有visibleon,还需要判断其他有visibleon的分组是否显示,只有其他都不显示时,才需要隐藏标题;反之,有任何一个显示,就不需要隐藏标题
7572
+ 2.所有分组都有visibleon
7573
+ 2.1 当前分组为隐藏时,标题就设置为隐藏
7574
+ 2.2 当前分组为显示时,其他分组只要有一个是显示,就显示该分组标题
7575
+ 2.3 当前分组为显示时,其他分组都隐藏,就隐藏该分组标题
7576
+ 3.所有分组中有两个以上的分组没有visibleon(这种情况不用处理)
7577
+ */
7578
+ if(ctx.mode == "edit"){
7579
+ if (sections.length - sectionHeaderVisibleOn.length == 1) {
7580
+ sections.forEach((section) => {
7581
+ section.headingClassName = {
7582
+ "hidden": `!(${sectionHeaderVisibleOn.join(" || ") || 'false'})`
7583
+ };
7584
+ });
7585
+ } else if (sections.length == sectionHeaderVisibleOn.length) {
7586
+ sections.forEach((section, index) => {
7587
+ var tempSectionHeaderVisibleOn = sectionHeaderVisibleOn.slice();
7588
+ tempSectionHeaderVisibleOn.splice(index, 1);
7589
+ section.headingClassName = {
7590
+ "hidden": `!((${tempSectionHeaderVisibleOn.join(" || ") || 'false'}) && ${sectionHeaderVisibleOn[index]})`
7591
+ };
7592
+ });
7593
+ }
7594
+ }
7595
+
7516
7596
  return sections;
7517
7597
  };
7518
7598
 
@@ -7883,11 +7963,12 @@ async function getObjectDetail(objectSchema, recordId, ctx){
7883
7963
  "expression": "this.__deletedRecord != true"
7884
7964
  },
7885
7965
  {
7886
- "args": {
7887
- "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
7888
- "blank": false
7889
- },
7890
- "actionType": "link",
7966
+ // "args": {
7967
+ // "url": "/app/${appId}/${objectName}/grid/${side_listview_id}",
7968
+ // "blank": false
7969
+ // },
7970
+ "actionType": "custom",
7971
+ "script": "Steedos.goBack()",
7891
7972
  "expression": "this.__deletedRecord === true"
7892
7973
  }
7893
7974
  ]
@@ -8026,6 +8107,8 @@ async function getTableColumns$1(fields, options){
8026
8107
  type = 'tpl';
8027
8108
  }else if(field.type === 'html'){
8028
8109
  type = 'markdown';
8110
+ }else if(field.type === 'url' && field.show_as_qr){
8111
+ type = 'qr-code';
8029
8112
  }
8030
8113
  let className = "";
8031
8114
  if(field.type === 'textarea'){
@@ -8053,7 +8136,13 @@ async function getTableColumns$1(fields, options){
8053
8136
 
8054
8137
  }
8055
8138
  // columns.push(getOperation(fields));
8056
-
8139
+ if(!___default.some(columns, { name: options.labelFieldName })){
8140
+ const href = Router$1.getObjectDetailPath({
8141
+ ...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
8142
+ });
8143
+ columns[0].type = "tpl";
8144
+ columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
8145
+ }
8057
8146
  return columns;
8058
8147
  }
8059
8148
 
@@ -8419,6 +8508,8 @@ async function getTableApi(mainObject, fields, options){
8419
8508
 
8420
8509
  const fileFields = {};
8421
8510
  const fileFieldsKeys = [];
8511
+ // 含有optionsFunction属性, 无reference_to属性的lookup字段
8512
+ const lookupFields = {};
8422
8513
  fields.forEach((item)=>{
8423
8514
  if(___default.includes(['image','avatar','file'], item.type)){
8424
8515
  fileFieldsKeys.push(item.name);
@@ -8428,6 +8519,9 @@ async function getTableApi(mainObject, fields, options){
8428
8519
  multiple: item.multiple
8429
8520
  };
8430
8521
  }
8522
+ if(___default.includes(['lookup'], item.type) && !item.reference_to ){
8523
+ lookupFields[item.name] = item;
8524
+ }
8431
8525
  });
8432
8526
 
8433
8527
  let valueField = mainObject.key_field || '_id';
@@ -8444,6 +8538,7 @@ async function getTableApi(mainObject, fields, options){
8444
8538
  api.data.filter = "$filter";
8445
8539
  api.data.loaded = "${loaded}";
8446
8540
  api.data.listViewId = "${listViewId}";
8541
+ api.data.listName = "${listName}";
8447
8542
  api.requestAdaptor = `
8448
8543
  // selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
8449
8544
  let selfData = JSON.parse(JSON.stringify(api.data.$self));
@@ -8474,9 +8569,13 @@ async function getTableApi(mainObject, fields, options){
8474
8569
  console.error("本地存储中crud参数解析异常:", ex);
8475
8570
  }
8476
8571
  ${baseFilters ? `var systemFilters = ${JSON.stringify(baseFilters)};` : 'var systemFilters = [];'}
8572
+ var _ids = []
8477
8573
  const filtersFunction = ${filtersFunction};
8478
8574
  if(filtersFunction){
8479
8575
  const _filters = filtersFunction(systemFilters, api.data.$self);
8576
+ if(api.data.listName == "recent"){
8577
+ _ids = _filters[2]
8578
+ }
8480
8579
  if(_filters && _filters.length > 0){
8481
8580
  if(_.isEmpty(systemFilters)){
8482
8581
  systemFilters = _filters || [];
@@ -8588,6 +8687,7 @@ async function getTableApi(mainObject, fields, options){
8588
8687
  filters = [filters, 'and', userFilters]
8589
8688
  }
8590
8689
  }
8690
+ api.data._ids = _ids;
8591
8691
  api.data = {
8592
8692
  query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
8593
8693
  }
@@ -8595,6 +8695,11 @@ async function getTableApi(mainObject, fields, options){
8595
8695
  return api;
8596
8696
  `;
8597
8697
  api.adaptor = `
8698
+ if(api.body.listName == "recent"){
8699
+ payload.data.rows = _.sortBy(payload.data.rows, function(item){
8700
+ return _.indexOf(api.body._ids, item._id)
8701
+ });
8702
+ }
8598
8703
  const enable_tree = ${mainObject.enable_tree};
8599
8704
  if(!enable_tree){
8600
8705
  _.each(payload.data.rows, function(item, index){
@@ -8605,9 +8710,10 @@ async function getTableApi(mainObject, fields, options){
8605
8710
  }
8606
8711
  window.postMessage(Object.assign({type: "listview.loaded"}), "*");
8607
8712
  let fileFields = ${JSON.stringify(fileFields)};
8713
+ let lookupFields = ${JSON.stringify(lookupFields)};
8608
8714
  _.each(payload.data.rows, function(item, index){
8609
8715
  _.each(fileFields , (field, key)=>{
8610
- if(item[key] && item._display && item._display [key]){
8716
+ if(item[key] && item._display && item._display[key]){
8611
8717
  let value = item._display[key];
8612
8718
  if(!_.isArray(value)){
8613
8719
  value = [value]
@@ -8619,6 +8725,14 @@ async function getTableApi(mainObject, fields, options){
8619
8725
  }
8620
8726
  }
8621
8727
  })
8728
+ _.each(lookupFields , (field, key)=>{
8729
+ if(item[key]){
8730
+ if(field._optionsFunction){
8731
+ const optionsFunction = eval("(" + field._optionsFunction+ ")")(item);
8732
+ item[key + '__label'] = _.map(_.filter(optionsFunction, function(option){return _.includes(item[key], option.value)}), 'label').join(' ');
8733
+ }
8734
+ }
8735
+ })
8622
8736
  })
8623
8737
 
8624
8738
  if(enable_tree){
@@ -9948,6 +10062,24 @@ async function getListSchema(
9948
10062
 
9949
10063
  ctx.defaults = defaults;
9950
10064
 
10065
+ if (listViewName == "recent") {
10066
+ listview_filters = `
10067
+ function(filters, data) {
10068
+ var result = Steedos.authRequest('/graphql', {
10069
+ type: 'POST',
10070
+ async: false,
10071
+ data: JSON.stringify({
10072
+ query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
10073
+ }),
10074
+ });
10075
+ var _ids = []
10076
+ result.data.object_recent_viewed.forEach(function (item) {
10077
+ _ids = _ids.concat(item.record.ids)
10078
+ })
10079
+ return ["_id", "=", _ids];
10080
+ }
10081
+ `;
10082
+ }
9951
10083
  const amisSchema = {
9952
10084
  "type": "steedos-object-table",
9953
10085
  "objectApiName": objectName,
@@ -13683,6 +13815,7 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
13683
13815
  // className不传入crud组件,crud单独识别crudClassName属性
13684
13816
  listSchema.className = crudClassName;
13685
13817
  listSchema.onEvent = {}; // 为啥要将一个内置event放在此处?
13818
+ // 下面expression中_isRelated参数判断的是列表视图分栏模式下,新建、编辑、删除相关子表记录时不应该刷新左侧(主表)列表视图组件
13686
13819
  listSchema.onEvent["@data.changed.".concat(objectApiName)] = {
13687
13820
  "actions": [
13688
13821
  {
@@ -15262,7 +15395,7 @@ var getSelectFlowSchema = function (id, props) {
15262
15395
  "method": "post",
15263
15396
  "url": "${context.rootUrl}/graphql?keywords=${keywords}",
15264
15397
  "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 "),
15265
- "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 ",
15398
+ "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 ",
15266
15399
  "headers": {
15267
15400
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
15268
15401
  }