@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 {
@@ -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
  },
@@ -4987,12 +5003,13 @@ const getSettingListviewToolbarButtonSchema = ()=>{
4987
5003
  "type": "dropdown-button",
4988
5004
  "trigger": "click",
4989
5005
  "icon": "fa fa-cog",
5006
+ "tooltip": "列表视图控制",
4990
5007
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4991
5008
  "align": "right",
4992
5009
  "visibleOn": "${!isLookup}",
4993
5010
  "buttons": [
4994
5011
  {
4995
- "label": "列表视图操作",
5012
+ "label": "列表视图控制",
4996
5013
  "children": [
4997
5014
  getNewListviewButtonSchema(),
4998
5015
  getCopyListviewButtonSchema(),
@@ -5026,9 +5043,11 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
5026
5043
  "rightIconClassName": "m-l-sm"
5027
5044
  }
5028
5045
  ];
5046
+ const displayAsLabel = displayAs === 'split'? "分栏视图" : "表格";
5029
5047
  return {
5030
5048
  "type": "dropdown-button",
5031
5049
  "icon": "fa fa-table-columns",
5050
+ "tooltip": `显示为 ${displayAsLabel}`,
5032
5051
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
5033
5052
  "align": "right",
5034
5053
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
@@ -5108,6 +5127,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5108
5127
  // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
5109
5128
  "type": "button",
5110
5129
  "align": "right",
5130
+ "tooltip": "刷新",
5111
5131
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5112
5132
  "label": "",
5113
5133
  "icon": "fa fa-sync",
@@ -5127,6 +5147,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5127
5147
  "label": "",
5128
5148
  "icon": "fa fa-search",
5129
5149
  "type": "button",
5150
+ "tooltip": "搜索",
5130
5151
  "badge": {
5131
5152
  "offset": [
5132
5153
  -5,
@@ -5171,6 +5192,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5171
5192
  {
5172
5193
  "type": "reload",
5173
5194
  "align": "right",
5195
+ "tooltip": "刷新",
5174
5196
  "tooltipPlacement": "bottom",
5175
5197
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5176
5198
  },
@@ -5178,6 +5200,8 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5178
5200
  filterVisible ? {
5179
5201
  "label": "",
5180
5202
  "icon": "fa fa-search",
5203
+ "tooltip": "搜索",
5204
+ "tooltipPlacement": "bottom",
5181
5205
  "type": "button",
5182
5206
  "align": "right",
5183
5207
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
@@ -6202,8 +6226,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
6202
6226
  /*
6203
6227
  * @Author: baozhoutao@steedos.com
6204
6228
  * @Date: 2023-01-13 17:27:54
6205
- * @LastEditors: baozhoutao@steedos.com
6206
- * @LastEditTime: 2023-01-16 10:36:27
6229
+ * @LastEditors: Please set LastEditors
6230
+ * @LastEditTime: 2023-05-31 13:34:22
6207
6231
  * @Description:
6208
6232
  */
6209
6233
 
@@ -6245,8 +6269,12 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
6245
6269
  const getHtmlFieldSchema = (field, readonly, ctx)=>{
6246
6270
  if(readonly){
6247
6271
  return {
6248
- "type": "html",
6249
- "name": field.name
6272
+ "type": "control",
6273
+ "label": field.label,
6274
+ "body": {
6275
+ "type": "html",
6276
+ "name": field.name
6277
+ }
6250
6278
  }
6251
6279
  }else {
6252
6280
  return {
@@ -6273,8 +6301,8 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
6273
6301
  /*
6274
6302
  * @Author: baozhoutao@steedos.com
6275
6303
  * @Date: 2022-10-28 14:52:55
6276
- * @LastEditors: baozhoutao@steedos.com
6277
- * @LastEditTime: 2022-10-28 14:53:02
6304
+ * @LastEditors: Please set LastEditors
6305
+ * @LastEditTime: 2023-05-31 13:25:53
6278
6306
  * @Description:
6279
6307
  */
6280
6308
 
@@ -6823,8 +6851,19 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6823
6851
  break;
6824
6852
  case 'url':
6825
6853
  convertData = {
6826
- type: getAmisStaticFieldType('url', readonly)
6854
+ type: getAmisStaticFieldType('url', readonly, field)
6827
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
+ }
6828
6867
  break;
6829
6868
  case 'email':
6830
6869
  convertData = {
@@ -6859,6 +6898,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6859
6898
  case 'code':
6860
6899
  convertData = {
6861
6900
  type: "editor",
6901
+ disabled: readonly ? true : false,
6862
6902
  language: field.language,
6863
6903
  editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
6864
6904
  };
@@ -7516,12 +7556,43 @@ const getSections = async (permissionFields, formFields, ctx) => {
7516
7556
  const fieldSchemaArray = getFieldSchemaArray(formFields);
7517
7557
  const _sections = ___default.groupBy(fieldSchemaArray, 'group');
7518
7558
  const sections = [];
7559
+ var sectionHeaderVisibleOn=[];
7519
7560
  for (const key in _sections) {
7520
7561
  const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
7521
7562
  if(section.body.length > 0){
7563
+ if(section.visibleOn){
7564
+ sectionHeaderVisibleOn.push(section.visibleOn);
7565
+ }
7522
7566
  sections.push(section);
7523
7567
  }
7524
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
+
7525
7596
  return sections;
7526
7597
  };
7527
7598
 
@@ -8036,6 +8107,8 @@ async function getTableColumns$1(fields, options){
8036
8107
  type = 'tpl';
8037
8108
  }else if(field.type === 'html'){
8038
8109
  type = 'markdown';
8110
+ }else if(field.type === 'url' && field.show_as_qr){
8111
+ type = 'qr-code';
8039
8112
  }
8040
8113
  let className = "";
8041
8114
  if(field.type === 'textarea'){
@@ -8063,7 +8136,13 @@ async function getTableColumns$1(fields, options){
8063
8136
 
8064
8137
  }
8065
8138
  // columns.push(getOperation(fields));
8066
-
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
+ }
8067
8146
  return columns;
8068
8147
  }
8069
8148
 
@@ -8429,6 +8508,8 @@ async function getTableApi(mainObject, fields, options){
8429
8508
 
8430
8509
  const fileFields = {};
8431
8510
  const fileFieldsKeys = [];
8511
+ // 含有optionsFunction属性, 无reference_to属性的lookup字段
8512
+ const lookupFields = {};
8432
8513
  fields.forEach((item)=>{
8433
8514
  if(___default.includes(['image','avatar','file'], item.type)){
8434
8515
  fileFieldsKeys.push(item.name);
@@ -8438,6 +8519,9 @@ async function getTableApi(mainObject, fields, options){
8438
8519
  multiple: item.multiple
8439
8520
  };
8440
8521
  }
8522
+ if(___default.includes(['lookup'], item.type) && !item.reference_to ){
8523
+ lookupFields[item.name] = item;
8524
+ }
8441
8525
  });
8442
8526
 
8443
8527
  let valueField = mainObject.key_field || '_id';
@@ -8454,6 +8538,7 @@ async function getTableApi(mainObject, fields, options){
8454
8538
  api.data.filter = "$filter";
8455
8539
  api.data.loaded = "${loaded}";
8456
8540
  api.data.listViewId = "${listViewId}";
8541
+ api.data.listName = "${listName}";
8457
8542
  api.requestAdaptor = `
8458
8543
  // selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
8459
8544
  let selfData = JSON.parse(JSON.stringify(api.data.$self));
@@ -8484,9 +8569,13 @@ async function getTableApi(mainObject, fields, options){
8484
8569
  console.error("本地存储中crud参数解析异常:", ex);
8485
8570
  }
8486
8571
  ${baseFilters ? `var systemFilters = ${JSON.stringify(baseFilters)};` : 'var systemFilters = [];'}
8572
+ var _ids = []
8487
8573
  const filtersFunction = ${filtersFunction};
8488
8574
  if(filtersFunction){
8489
8575
  const _filters = filtersFunction(systemFilters, api.data.$self);
8576
+ if(api.data.listName == "recent"){
8577
+ _ids = _filters[2]
8578
+ }
8490
8579
  if(_filters && _filters.length > 0){
8491
8580
  if(_.isEmpty(systemFilters)){
8492
8581
  systemFilters = _filters || [];
@@ -8598,6 +8687,7 @@ async function getTableApi(mainObject, fields, options){
8598
8687
  filters = [filters, 'and', userFilters]
8599
8688
  }
8600
8689
  }
8690
+ api.data._ids = _ids;
8601
8691
  api.data = {
8602
8692
  query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
8603
8693
  }
@@ -8605,6 +8695,11 @@ async function getTableApi(mainObject, fields, options){
8605
8695
  return api;
8606
8696
  `;
8607
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
+ }
8608
8703
  const enable_tree = ${mainObject.enable_tree};
8609
8704
  if(!enable_tree){
8610
8705
  _.each(payload.data.rows, function(item, index){
@@ -8615,9 +8710,10 @@ async function getTableApi(mainObject, fields, options){
8615
8710
  }
8616
8711
  window.postMessage(Object.assign({type: "listview.loaded"}), "*");
8617
8712
  let fileFields = ${JSON.stringify(fileFields)};
8713
+ let lookupFields = ${JSON.stringify(lookupFields)};
8618
8714
  _.each(payload.data.rows, function(item, index){
8619
8715
  _.each(fileFields , (field, key)=>{
8620
- if(item[key] && item._display && item._display [key]){
8716
+ if(item[key] && item._display && item._display[key]){
8621
8717
  let value = item._display[key];
8622
8718
  if(!_.isArray(value)){
8623
8719
  value = [value]
@@ -8629,6 +8725,14 @@ async function getTableApi(mainObject, fields, options){
8629
8725
  }
8630
8726
  }
8631
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
+ })
8632
8736
  })
8633
8737
 
8634
8738
  if(enable_tree){
@@ -9958,6 +10062,24 @@ async function getListSchema(
9958
10062
 
9959
10063
  ctx.defaults = defaults;
9960
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
+ }
9961
10083
  const amisSchema = {
9962
10084
  "type": "steedos-object-table",
9963
10085
  "objectApiName": objectName,
@@ -13693,6 +13815,7 @@ var AmisObjectListView = function (props) { return __awaiter(void 0, void 0, voi
13693
13815
  // className不传入crud组件,crud单独识别crudClassName属性
13694
13816
  listSchema.className = crudClassName;
13695
13817
  listSchema.onEvent = {}; // 为啥要将一个内置event放在此处?
13818
+ // 下面expression中_isRelated参数判断的是列表视图分栏模式下,新建、编辑、删除相关子表记录时不应该刷新左侧(主表)列表视图组件
13696
13819
  listSchema.onEvent["@data.changed.".concat(objectApiName)] = {
13697
13820
  "actions": [
13698
13821
  {
@@ -15272,7 +15395,7 @@ var getSelectFlowSchema = function (id, props) {
15272
15395
  "method": "post",
15273
15396
  "url": "${context.rootUrl}/graphql?keywords=${keywords}",
15274
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 "),
15275
- "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 ",
15276
15399
  "headers": {
15277
15400
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
15278
15401
  }