@steedos-widgets/amis-lib 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.
package/dist/index.esm.js CHANGED
@@ -1868,7 +1868,23 @@ const getSchema$1 = (uiSchema) => {
1868
1868
  {
1869
1869
  name: "template_url",
1870
1870
  label: "导入模板",
1871
- type: "markdown",
1871
+ type: "button-group",
1872
+ buttons: [
1873
+ {
1874
+ type: "button",
1875
+ label: "下载",
1876
+ visibleOn: "${template_url}",
1877
+ level: "link",
1878
+ actionType: "download",
1879
+ api:{
1880
+ url: "${template_url}",
1881
+ method: "get",
1882
+ headers: {
1883
+ Authorization: "Bearer ${context.tenantId},${context.authToken}"
1884
+ }
1885
+ }
1886
+ }
1887
+ ],
1872
1888
  options: {
1873
1889
  html: true
1874
1890
  },
@@ -4628,12 +4644,13 @@ const getSettingListviewToolbarButtonSchema = ()=>{
4628
4644
  "type": "dropdown-button",
4629
4645
  "trigger": "click",
4630
4646
  "icon": "fa fa-cog",
4647
+ "tooltip": "列表视图控制",
4631
4648
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4632
4649
  "align": "right",
4633
4650
  "visibleOn": "${!isLookup}",
4634
4651
  "buttons": [
4635
4652
  {
4636
- "label": "列表视图操作",
4653
+ "label": "列表视图控制",
4637
4654
  "children": [
4638
4655
  getNewListviewButtonSchema(),
4639
4656
  getCopyListviewButtonSchema(),
@@ -4667,9 +4684,11 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
4667
4684
  "rightIconClassName": "m-l-sm"
4668
4685
  }
4669
4686
  ];
4687
+ const displayAsLabel = displayAs === 'split'? "分栏视图" : "表格";
4670
4688
  return {
4671
4689
  "type": "dropdown-button",
4672
4690
  "icon": "fa fa-table-columns",
4691
+ "tooltip": `显示为 ${displayAsLabel}`,
4673
4692
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4674
4693
  "align": "right",
4675
4694
  "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
@@ -4749,6 +4768,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4749
4768
  // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
4750
4769
  "type": "button",
4751
4770
  "align": "right",
4771
+ "tooltip": "刷新",
4752
4772
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4753
4773
  "label": "",
4754
4774
  "icon": "fa fa-sync",
@@ -4768,6 +4788,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4768
4788
  "label": "",
4769
4789
  "icon": "fa fa-search",
4770
4790
  "type": "button",
4791
+ "tooltip": "搜索",
4771
4792
  "badge": {
4772
4793
  "offset": [
4773
4794
  -5,
@@ -4812,6 +4833,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4812
4833
  {
4813
4834
  "type": "reload",
4814
4835
  "align": "right",
4836
+ "tooltip": "刷新",
4815
4837
  "tooltipPlacement": "bottom",
4816
4838
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
4817
4839
  },
@@ -4819,6 +4841,8 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
4819
4841
  filterVisible ? {
4820
4842
  "label": "",
4821
4843
  "icon": "fa fa-search",
4844
+ "tooltip": "搜索",
4845
+ "tooltipPlacement": "bottom",
4822
4846
  "type": "button",
4823
4847
  "align": "right",
4824
4848
  "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
@@ -5843,8 +5867,8 @@ async function getIdsPickerSchema(field, readonly, ctx){
5843
5867
  /*
5844
5868
  * @Author: baozhoutao@steedos.com
5845
5869
  * @Date: 2023-01-13 17:27:54
5846
- * @LastEditors: baozhoutao@steedos.com
5847
- * @LastEditTime: 2023-01-16 10:36:27
5870
+ * @LastEditors: Please set LastEditors
5871
+ * @LastEditTime: 2023-05-31 13:34:22
5848
5872
  * @Description:
5849
5873
  */
5850
5874
 
@@ -5886,8 +5910,12 @@ const getMarkdownFieldSchema = (field, readonly, ctx)=>{
5886
5910
  const getHtmlFieldSchema = (field, readonly, ctx)=>{
5887
5911
  if(readonly){
5888
5912
  return {
5889
- "type": "html",
5890
- "name": field.name
5913
+ "type": "control",
5914
+ "label": field.label,
5915
+ "body": {
5916
+ "type": "html",
5917
+ "name": field.name
5918
+ }
5891
5919
  }
5892
5920
  }else {
5893
5921
  return {
@@ -5914,8 +5942,8 @@ const getHtmlFieldSchema = (field, readonly, ctx)=>{
5914
5942
  /*
5915
5943
  * @Author: baozhoutao@steedos.com
5916
5944
  * @Date: 2022-10-28 14:52:55
5917
- * @LastEditors: baozhoutao@steedos.com
5918
- * @LastEditTime: 2022-10-28 14:53:02
5945
+ * @LastEditors: Please set LastEditors
5946
+ * @LastEditTime: 2023-05-31 13:25:53
5919
5947
  * @Description:
5920
5948
  */
5921
5949
 
@@ -6464,8 +6492,19 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6464
6492
  break;
6465
6493
  case 'url':
6466
6494
  convertData = {
6467
- type: getAmisStaticFieldType('url', readonly)
6495
+ type: getAmisStaticFieldType('url', readonly, field)
6468
6496
  };
6497
+ if(readonly && field.show_as_qr){
6498
+ convertData = {
6499
+ type: "control",
6500
+ label: field.label,
6501
+ body: {
6502
+ type: "qr-code",
6503
+ codeSize: 128,
6504
+ name: field.name
6505
+ }
6506
+ };
6507
+ }
6469
6508
  break;
6470
6509
  case 'email':
6471
6510
  convertData = {
@@ -6500,6 +6539,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6500
6539
  case 'code':
6501
6540
  convertData = {
6502
6541
  type: "editor",
6542
+ disabled: readonly ? true : false,
6503
6543
  language: field.language,
6504
6544
  editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
6505
6545
  };
@@ -7157,12 +7197,43 @@ const getSections = async (permissionFields, formFields, ctx) => {
7157
7197
  const fieldSchemaArray = getFieldSchemaArray(formFields);
7158
7198
  const _sections = _$1.groupBy(fieldSchemaArray, 'group');
7159
7199
  const sections = [];
7200
+ var sectionHeaderVisibleOn=[];
7160
7201
  for (const key in _sections) {
7161
7202
  const section = await getSection(formFields, permissionFields, fieldSchemaArray, key, ctx);
7162
7203
  if(section.body.length > 0){
7204
+ if(section.visibleOn){
7205
+ sectionHeaderVisibleOn.push(section.visibleOn);
7206
+ }
7163
7207
  sections.push(section);
7164
7208
  }
7165
7209
  }
7210
+ /*
7211
+ 为了实现只有一个分组时隐藏该分组标题,需要分三种情况(分组如果没有visibleon属性就代表一定显示,有visibleon需要进行判断)
7212
+ 1.所有分组中只有一个分组没有visibleon,还需要判断其他有visibleon的分组是否显示,只有其他都不显示时,才需要隐藏标题;反之,有任何一个显示,就不需要隐藏标题
7213
+ 2.所有分组都有visibleon
7214
+ 2.1 当前分组为隐藏时,标题就设置为隐藏
7215
+ 2.2 当前分组为显示时,其他分组只要有一个是显示,就显示该分组标题
7216
+ 2.3 当前分组为显示时,其他分组都隐藏,就隐藏该分组标题
7217
+ 3.所有分组中有两个以上的分组没有visibleon(这种情况不用处理)
7218
+ */
7219
+ if(ctx.mode == "edit"){
7220
+ if (sections.length - sectionHeaderVisibleOn.length == 1) {
7221
+ sections.forEach((section) => {
7222
+ section.headingClassName = {
7223
+ "hidden": `!(${sectionHeaderVisibleOn.join(" || ") || 'false'})`
7224
+ };
7225
+ });
7226
+ } else if (sections.length == sectionHeaderVisibleOn.length) {
7227
+ sections.forEach((section, index) => {
7228
+ var tempSectionHeaderVisibleOn = sectionHeaderVisibleOn.slice();
7229
+ tempSectionHeaderVisibleOn.splice(index, 1);
7230
+ section.headingClassName = {
7231
+ "hidden": `!((${tempSectionHeaderVisibleOn.join(" || ") || 'false'}) && ${sectionHeaderVisibleOn[index]})`
7232
+ };
7233
+ });
7234
+ }
7235
+ }
7236
+
7166
7237
  return sections;
7167
7238
  };
7168
7239
 
@@ -7677,6 +7748,8 @@ async function getTableColumns(fields, options){
7677
7748
  type = 'tpl';
7678
7749
  }else if(field.type === 'html'){
7679
7750
  type = 'markdown';
7751
+ }else if(field.type === 'url' && field.show_as_qr){
7752
+ type = 'qr-code';
7680
7753
  }
7681
7754
  let className = "";
7682
7755
  if(field.type === 'textarea'){
@@ -7704,7 +7777,13 @@ async function getTableColumns(fields, options){
7704
7777
 
7705
7778
  }
7706
7779
  // columns.push(getOperation(fields));
7707
-
7780
+ if(!_$1.some(columns, { name: options.labelFieldName })){
7781
+ const href = Router.getObjectDetailPath({
7782
+ ...options, formFactor: options.formFactor, appId: "${appId}", objectName: options.objectName || "${objectName}", recordId: `\${${options.idFieldName}}`
7783
+ });
7784
+ columns[0].type = "tpl";
7785
+ columns[0].tpl = `<a href="${href}">\${${columns[0].name}}</a>`;
7786
+ }
7708
7787
  return columns;
7709
7788
  }
7710
7789
 
@@ -8070,6 +8149,8 @@ async function getTableApi(mainObject, fields, options){
8070
8149
 
8071
8150
  const fileFields = {};
8072
8151
  const fileFieldsKeys = [];
8152
+ // 含有optionsFunction属性, 无reference_to属性的lookup字段
8153
+ const lookupFields = {};
8073
8154
  fields.forEach((item)=>{
8074
8155
  if(_$1.includes(['image','avatar','file'], item.type)){
8075
8156
  fileFieldsKeys.push(item.name);
@@ -8079,6 +8160,9 @@ async function getTableApi(mainObject, fields, options){
8079
8160
  multiple: item.multiple
8080
8161
  };
8081
8162
  }
8163
+ if(_$1.includes(['lookup'], item.type) && !item.reference_to ){
8164
+ lookupFields[item.name] = item;
8165
+ }
8082
8166
  });
8083
8167
 
8084
8168
  let valueField = mainObject.key_field || '_id';
@@ -8095,6 +8179,7 @@ async function getTableApi(mainObject, fields, options){
8095
8179
  api.data.filter = "$filter";
8096
8180
  api.data.loaded = "${loaded}";
8097
8181
  api.data.listViewId = "${listViewId}";
8182
+ api.data.listName = "${listName}";
8098
8183
  api.requestAdaptor = `
8099
8184
  // selfData 中的数据由 CRUD 控制. selfData中,只能获取到 CRUD 给定的data. 无法从数据链中获取数据.
8100
8185
  let selfData = JSON.parse(JSON.stringify(api.data.$self));
@@ -8125,9 +8210,13 @@ async function getTableApi(mainObject, fields, options){
8125
8210
  console.error("本地存储中crud参数解析异常:", ex);
8126
8211
  }
8127
8212
  ${baseFilters ? `var systemFilters = ${JSON.stringify(baseFilters)};` : 'var systemFilters = [];'}
8213
+ var _ids = []
8128
8214
  const filtersFunction = ${filtersFunction};
8129
8215
  if(filtersFunction){
8130
8216
  const _filters = filtersFunction(systemFilters, api.data.$self);
8217
+ if(api.data.listName == "recent"){
8218
+ _ids = _filters[2]
8219
+ }
8131
8220
  if(_filters && _filters.length > 0){
8132
8221
  if(_.isEmpty(systemFilters)){
8133
8222
  systemFilters = _filters || [];
@@ -8239,6 +8328,7 @@ async function getTableApi(mainObject, fields, options){
8239
8328
  filters = [filters, 'and', userFilters]
8240
8329
  }
8241
8330
  }
8331
+ api.data._ids = _ids;
8242
8332
  api.data = {
8243
8333
  query: api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim())
8244
8334
  }
@@ -8246,6 +8336,11 @@ async function getTableApi(mainObject, fields, options){
8246
8336
  return api;
8247
8337
  `;
8248
8338
  api.adaptor = `
8339
+ if(api.body.listName == "recent"){
8340
+ payload.data.rows = _.sortBy(payload.data.rows, function(item){
8341
+ return _.indexOf(api.body._ids, item._id)
8342
+ });
8343
+ }
8249
8344
  const enable_tree = ${mainObject.enable_tree};
8250
8345
  if(!enable_tree){
8251
8346
  _.each(payload.data.rows, function(item, index){
@@ -8256,9 +8351,10 @@ async function getTableApi(mainObject, fields, options){
8256
8351
  }
8257
8352
  window.postMessage(Object.assign({type: "listview.loaded"}), "*");
8258
8353
  let fileFields = ${JSON.stringify(fileFields)};
8354
+ let lookupFields = ${JSON.stringify(lookupFields)};
8259
8355
  _.each(payload.data.rows, function(item, index){
8260
8356
  _.each(fileFields , (field, key)=>{
8261
- if(item[key] && item._display && item._display [key]){
8357
+ if(item[key] && item._display && item._display[key]){
8262
8358
  let value = item._display[key];
8263
8359
  if(!_.isArray(value)){
8264
8360
  value = [value]
@@ -8270,6 +8366,14 @@ async function getTableApi(mainObject, fields, options){
8270
8366
  }
8271
8367
  }
8272
8368
  })
8369
+ _.each(lookupFields , (field, key)=>{
8370
+ if(item[key]){
8371
+ if(field._optionsFunction){
8372
+ const optionsFunction = eval("(" + field._optionsFunction+ ")")(item);
8373
+ item[key + '__label'] = _.map(_.filter(optionsFunction, function(option){return _.includes(item[key], option.value)}), 'label').join(' ');
8374
+ }
8375
+ }
8376
+ })
8273
8377
  })
8274
8378
 
8275
8379
  if(enable_tree){
@@ -9599,6 +9703,24 @@ async function getListSchema(
9599
9703
 
9600
9704
  ctx.defaults = defaults;
9601
9705
 
9706
+ if (listViewName == "recent") {
9707
+ listview_filters = `
9708
+ function(filters, data) {
9709
+ var result = Steedos.authRequest('/graphql', {
9710
+ type: 'POST',
9711
+ async: false,
9712
+ data: JSON.stringify({
9713
+ query: '{object_recent_viewed(filters: [["record.o","=","' + data.objectName + '"],["space","=","' + data.context.tenantId + '"],["owner","=","' + data.context.userId + '"]],sort:"modified desc",top:50){ _id,record} }'
9714
+ }),
9715
+ });
9716
+ var _ids = []
9717
+ result.data.object_recent_viewed.forEach(function (item) {
9718
+ _ids = _ids.concat(item.record.ids)
9719
+ })
9720
+ return ["_id", "=", _ids];
9721
+ }
9722
+ `;
9723
+ }
9602
9724
  const amisSchema = {
9603
9725
  "type": "steedos-object-table",
9604
9726
  "objectApiName": objectName,