@steedos-widgets/amis-lib 1.2.37 → 1.2.39-beta.1

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
@@ -1074,6 +1074,7 @@
1074
1074
  var frontend_objects_related_alert_start$1 = "No related table fields associated with the related list object";
1075
1075
  var frontend_objects_related_alert_end$1 = "were found.";
1076
1076
  var frontend_no_records_found$1 = "No records found.";
1077
+ var frontend_records_no_allowedit$1 = "You do not have edit permission for this record";
1077
1078
  var en_us = {
1078
1079
  frontend_field_group_generalization: frontend_field_group_generalization$1,
1079
1080
  frontend_download: frontend_download$1,
@@ -1156,7 +1157,8 @@
1156
1157
  frontend_message_modification_failed: frontend_message_modification_failed$1,
1157
1158
  frontend_objects_related_alert_start: frontend_objects_related_alert_start$1,
1158
1159
  frontend_objects_related_alert_end: frontend_objects_related_alert_end$1,
1159
- frontend_no_records_found: frontend_no_records_found$1
1160
+ frontend_no_records_found: frontend_no_records_found$1,
1161
+ frontend_records_no_allowedit: frontend_records_no_allowedit$1
1160
1162
  };
1161
1163
 
1162
1164
  var frontend_field_group_generalization = "通用";
@@ -1180,7 +1182,7 @@
1180
1182
  var frontend_display_as = "显示为";
1181
1183
  var frontend_record_sum = "个项目";
1182
1184
  var frontend_button_reload_tooltip = "刷新";
1183
- var frontend_button_search_tooltip = "搜索";
1185
+ var frontend_button_search_tooltip = "查询";
1184
1186
  var frontend_fields_filter_button_search = "搜索";
1185
1187
  var frontend_fields_filter_button_settings = "设置搜索项";
1186
1188
  var frontend_button_listview_control_tooltip = "列表视图控制";
@@ -1242,6 +1244,7 @@
1242
1244
  var frontend_objects_related_alert_start = "未找到与相关列表对象";
1243
1245
  var frontend_objects_related_alert_end = "关联的相关表字段";
1244
1246
  var frontend_no_records_found = "无法找到记录";
1247
+ var frontend_records_no_allowedit = "您对这条记录没有编辑权限";
1245
1248
  var zh_cn = {
1246
1249
  frontend_field_group_generalization: frontend_field_group_generalization,
1247
1250
  frontend_download: frontend_download,
@@ -1325,7 +1328,8 @@
1325
1328
  frontend_message_modification_failed: frontend_message_modification_failed,
1326
1329
  frontend_objects_related_alert_start: frontend_objects_related_alert_start,
1327
1330
  frontend_objects_related_alert_end: frontend_objects_related_alert_end,
1328
- frontend_no_records_found: frontend_no_records_found
1331
+ frontend_no_records_found: frontend_no_records_found,
1332
+ frontend_records_no_allowedit: frontend_records_no_allowedit
1329
1333
  };
1330
1334
 
1331
1335
  const resources = {
@@ -3379,12 +3383,14 @@
3379
3383
  if(!event.data.isLookup){
3380
3384
  // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
3381
3385
  const listName = event.data.listName;
3382
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3386
+ const listViewPropsStoreKey = location.pathname + "/crud";
3383
3387
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3384
3388
  if(localListViewProps){
3385
3389
  localListViewProps = JSON.parse(localListViewProps);
3386
3390
  for(var k in localListViewProps){
3387
- removedValues[k] = null;
3391
+ if(k !== "__keywords"){
3392
+ removedValues[k] = null;
3393
+ }
3388
3394
  }
3389
3395
  }
3390
3396
  }
@@ -3406,12 +3412,9 @@
3406
3412
  const objectName = data.objectName;
3407
3413
  const isLookup = data.isLookup;
3408
3414
  const listName = data.listName;
3409
- let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
3415
+ let searchableFieldsStoreKey = location.pathname + "/searchable_fields";
3410
3416
  if(isLookup){
3411
- searchableFieldsStoreKey += "lookup/" + objectName;
3412
- }
3413
- else{
3414
- searchableFieldsStoreKey += (listName || "");
3417
+ searchableFieldsStoreKey += "/lookup/" + objectName;
3415
3418
  }
3416
3419
  let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
3417
3420
  if(defaultSearchableFields){
@@ -3438,7 +3441,7 @@
3438
3441
  setData({ showFieldsFilter: false });
3439
3442
  }
3440
3443
  else{
3441
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3444
+ const listViewPropsStoreKey = location.pathname + "/crud";
3442
3445
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3443
3446
  if(localListViewProps){
3444
3447
  localListViewProps = JSON.parse(localListViewProps);
@@ -3478,12 +3481,9 @@
3478
3481
  return n.props.type === "service";
3479
3482
  });
3480
3483
  filterService.setData({ filterFormSearchableFields: value });
3481
- let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
3484
+ let searchableFieldsStoreKey = location.pathname + "/searchable_fields";
3482
3485
  if(isLookup){
3483
- searchableFieldsStoreKey += "lookup/" + objectName;
3484
- }
3485
- else{
3486
- searchableFieldsStoreKey += (listName || "");
3486
+ searchableFieldsStoreKey += "/lookup/" + objectName;
3487
3487
  }
3488
3488
  sessionStorage.setItem(searchableFieldsStoreKey, value);
3489
3489
 
@@ -3541,7 +3541,7 @@
3541
3541
  }
3542
3542
 
3543
3543
  // 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
3544
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3544
+ const listViewPropsStoreKey = location.pathname + "/crud";
3545
3545
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3546
3546
  if(localListViewProps){
3547
3547
  localListViewProps = JSON.parse(localListViewProps);
@@ -5262,9 +5262,23 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5262
5262
  `;
5263
5263
 
5264
5264
 
5265
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
5265
+ function getObjectHeaderToolbar(mainObject, fields, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
5266
5266
  // console.log(`getObjectHeaderToolbar====>`, filterVisible)
5267
- console.log(`getObjectHeaderToolbar`, mainObject);
5267
+ // console.log(`getObjectHeaderToolbar`, mainObject)
5268
+ const searchableFieldsLabel = [];
5269
+ _.each(fields, function (field) {
5270
+ if (field.searchable) {
5271
+ searchableFieldsLabel.push(field.label);
5272
+ }
5273
+ });
5274
+ const listViewPropsStoreKey = location.pathname + "/crud";
5275
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
5276
+ let crudKeywords = "";
5277
+ if(localListViewProps){
5278
+ localListViewProps = JSON.parse(localListViewProps);
5279
+ crudKeywords = (localListViewProps && localListViewProps.__keywords) || "";
5280
+ }
5281
+
5268
5282
  const isMobile = window.innerWidth < 768;
5269
5283
  if(isMobile){
5270
5284
  showDisplayAs = false;
@@ -5354,21 +5368,9 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5354
5368
  "type": "tpl",
5355
5369
  "tpl": "${count} " + i18next__default["default"].t('frontend_record_sum')
5356
5370
  },
5357
- {
5358
- "type": "reload",
5359
- "align": "right",
5360
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5361
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5362
- "tooltip":"",
5363
- "tooltipPlacement": "top",
5364
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5365
- },
5366
- // getExportExcelToolbarButtonSchema(),
5367
- mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
5368
- getDisplayAsButton(mainObject?.name),
5369
5371
  filterVisible ? {
5370
5372
  "label": i18next__default["default"].t('frontend_button_search_tooltip'),
5371
- "icon": "fa fa-search",
5373
+ "icon": "fa fa-filter",
5372
5374
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5373
5375
  // "tooltip": i18next.t('frontend_button_search_tooltip'),
5374
5376
  // "tooltipPlacement": "top",
@@ -5394,14 +5396,39 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5394
5396
  ]
5395
5397
  }
5396
5398
  }
5397
- } : {}
5398
- // {
5399
- // "type": "search-box",
5400
- // "align": "right",
5401
- // "name": "__keywords",
5402
- // "placeholder": "请输入关键字",
5403
- // "mini": true
5404
- // },
5399
+ } : {},
5400
+ {
5401
+ "type": "reload",
5402
+ "align": "right",
5403
+ //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5404
+ // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5405
+ "tooltip":"",
5406
+ "tooltipPlacement": "top",
5407
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5408
+ },
5409
+ // getExportExcelToolbarButtonSchema(),
5410
+ mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
5411
+ getDisplayAsButton(mainObject?.name),
5412
+ {
5413
+ "type": "tooltip-wrapper",
5414
+ "align": "right",
5415
+ "title": "",
5416
+ "content": "可模糊搜索字段:" + searchableFieldsLabel.join(","),
5417
+ "placement": "bottom",
5418
+ "tooltipTheme": "dark",
5419
+ "trigger": "click",
5420
+ "className": "mr-1",
5421
+ "body": [
5422
+ {
5423
+ "type": "search-box",
5424
+ "name": "__keywords",
5425
+ "placeholder": "请输入关键字",
5426
+ "value": crudKeywords,
5427
+ "clearable": true,
5428
+ "clearAndSubmit": true
5429
+ }
5430
+ ]
5431
+ },
5405
5432
  // {
5406
5433
  // "type": "drag-toggler",
5407
5434
  // "align": "right"
@@ -5417,18 +5444,27 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5417
5444
 
5418
5445
  }
5419
5446
 
5420
- function getObjectFooterToolbar(mainObject, formFactor) {
5447
+ function getObjectFooterToolbar(mainObject, formFactor, options) {
5421
5448
  if (formFactor === 'SMALL') {
5422
5449
  return [
5423
5450
  "load-more",
5424
5451
  ]
5425
5452
  }
5426
5453
  else {
5427
- return [
5428
- "switch-per-page",
5429
- "statistics",
5430
- "pagination"
5431
- ]
5454
+ if(options && options.isRelated){
5455
+ return [
5456
+ "statistics",
5457
+ "pagination"
5458
+ ]
5459
+
5460
+ }
5461
+ else {
5462
+ return [
5463
+ "switch-per-page",
5464
+ "statistics",
5465
+ "pagination"
5466
+ ]
5467
+ }
5432
5468
  }
5433
5469
  }
5434
5470
 
@@ -5736,16 +5772,17 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5736
5772
  "autoCheckChildren": false,
5737
5773
  "searchable": true,
5738
5774
  "searchConfig": {
5739
- "sticky": true
5775
+ "sticky": true,
5776
+ "placeholder": "查找部门"
5740
5777
  },
5741
5778
  "unfoldedLevel": 2,
5742
5779
  "style": {
5743
5780
  "max-height": "100%",
5744
5781
  "position": "absolute",
5745
- "left": "-200px",
5746
- "width": "190px",
5782
+ "left": "-220px",
5783
+ "width": "210px",
5747
5784
  "bottom": 0,
5748
- "top": "2px",
5785
+ "top": "0",
5749
5786
  "overflow": "auto",
5750
5787
  "min-height":"300px"
5751
5788
  },
@@ -5764,7 +5801,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5764
5801
  ctx.idFieldName = refObjectConfig.idFieldName;
5765
5802
  ctx.objectName = refObjectConfig.name;
5766
5803
 
5767
- const tableFields = [];
5804
+ let tableFields = [];
5768
5805
  let i = 0;
5769
5806
  const searchableFields = [];
5770
5807
 
@@ -5893,16 +5930,31 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5893
5930
  }
5894
5931
  }
5895
5932
 
5896
-
5897
5933
  if(allowSearchFields){
5898
5934
  allowSearchFields.forEach(function(key){
5899
5935
  const keyValue = selfData[key];
5900
- if(keyValue){
5936
+ if(_.isString(keyValue)){
5901
5937
  filters.push([key, "contains", keyValue]);
5938
+ }else if(_.isArray(keyValue) || _.isBoolean(keyValue) || keyValue){
5939
+ filters.push([key, "=", keyValue]);
5902
5940
  }
5903
5941
  })
5904
5942
  }
5905
5943
 
5944
+ if(selfData.__keywords && allowSearchFields){
5945
+ const keywordsFilters = [];
5946
+ allowSearchFields.forEach(function(key, index){
5947
+ const keyValue = selfData.__keywords;
5948
+ if(keyValue){
5949
+ keywordsFilters.push([key, "contains", keyValue]);
5950
+ if(index < allowSearchFields.length - 1){
5951
+ keywordsFilters.push('or');
5952
+ }
5953
+ }
5954
+ })
5955
+ filters.push(keywordsFilters);
5956
+ };
5957
+
5906
5958
  var fieldFilters = ${JSON.stringify(field.filters)};
5907
5959
  if(fieldFilters && fieldFilters.length){
5908
5960
  filters.push(fieldFilters);
@@ -5991,6 +6043,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5991
6043
  if(refObjectConfig.paging && refObjectConfig.paging.enabled === false){
5992
6044
  top = 1000;
5993
6045
  }
6046
+
5994
6047
  let pickerSchema = null;
5995
6048
  if(ctx.formFactor === 'SMALL'){
5996
6049
  pickerSchema = await getListSchema$1(tableFields, {
@@ -6012,7 +6065,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
6012
6065
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
6013
6066
  headerToolbarItems = getLookupSapceUserTreeSchema();
6014
6067
  pickerSchema["style"] = {
6015
- "margin-left":"200px",
6068
+ "margin-left":"220px",
6016
6069
  "min-height": "300px"
6017
6070
  };
6018
6071
  pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
@@ -6023,7 +6076,8 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
6023
6076
  if (isAllowCreate) {
6024
6077
  const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
6025
6078
  new_button.align = "right";
6026
- pickerSchema.headerToolbar.push(new_button);
6079
+ // 保持快速搜索放在最左侧,新建按钮往里插,而不是push到最后
6080
+ pickerSchema.headerToolbar.splice(pickerSchema.headerToolbar.length - 1, 0, new_button);
6027
6081
  }
6028
6082
  pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
6029
6083
  if (ctx.filterVisible !== false) {
@@ -7713,7 +7767,71 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7713
7767
  `;
7714
7768
  break;
7715
7769
  }
7716
-
7770
+ quickEditSchema.body[0].visibleOn = "${quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}";
7771
+ quickEditSchema.body.push({
7772
+ "type":"service",
7773
+ "body":[
7774
+ {
7775
+ "type": "tpl",
7776
+ "tpl": i18next__default["default"].t('frontend_records_no_allowedit'),
7777
+ "visibleOn": "${!quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}"
7778
+ },
7779
+ {
7780
+ "type": "spinner",
7781
+ "showOn": "${quickedit_record_permissions_loading}"
7782
+ }
7783
+ ],
7784
+ "onEvent":{
7785
+ "init":{
7786
+ "actions":[
7787
+ {
7788
+ "actionType": "setValue",
7789
+ "componentId": `service_listview_${options.objectName}`,
7790
+ "args": {
7791
+ "value":{
7792
+ "quickedit_record_permissions_loading": true
7793
+ }
7794
+ }
7795
+ },
7796
+ {
7797
+ "actionType": "ajax",
7798
+ "args": {
7799
+ "api": {
7800
+ "url": "${context.rootUrl}/service/api/@\${objectName}/recordPermissions/${_id}",
7801
+ "method": "get",
7802
+ "headers": {
7803
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7804
+ },
7805
+ "cache": 30000,
7806
+ "messages": {
7807
+ "failed": "失败了呢。。"
7808
+ }
7809
+ }
7810
+ }
7811
+ },
7812
+ {
7813
+ "actionType": "setValue",
7814
+ "componentId": `service_listview_${options.objectName}`,
7815
+ "args": {
7816
+ "value":{
7817
+ "quickedit_record_permissions_loading": false
7818
+ }
7819
+ }
7820
+ },
7821
+ {
7822
+ "actionType": "setValue",
7823
+ "componentId": `service_listview_${options.objectName}`,
7824
+ "args": {
7825
+ "value":{
7826
+ "quickedit_record_permissions": "${event.data}"
7827
+ }
7828
+ }
7829
+ }
7830
+ ]
7831
+ }
7832
+ }
7833
+
7834
+ });
7717
7835
  } else {
7718
7836
  quickEditSchema = false;
7719
7837
  }
@@ -7746,7 +7864,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
7746
7864
 
7747
7865
  async function getTableColumns(fields, options){
7748
7866
  const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
7749
- const allowEdit = options.permissions?.allowEdit && options.permissions?.modifyAllRecords && !options.isLookup && options.enable_inline_edit != false;
7867
+ const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
7750
7868
 
7751
7869
  for (const field of fields) {
7752
7870
  //增加quickEdit属性,实现快速编辑
@@ -8284,7 +8402,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8284
8402
  try{
8285
8403
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8286
8404
  const listName = api.data.listName;
8287
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
8405
+ const listViewPropsStoreKey = location.pathname + "/crud";
8288
8406
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
8289
8407
  if(localListViewProps){
8290
8408
  localListViewProps = JSON.parse(localListViewProps);
@@ -8485,7 +8603,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
8485
8603
  try{
8486
8604
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8487
8605
  const listName = api.body.listName;
8488
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
8606
+ const listViewPropsStoreKey = location.pathname + "/crud";
8489
8607
  /**
8490
8608
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
8491
8609
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -9650,6 +9768,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
9650
9768
  // headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
9651
9769
  headerToolbarClassName: "px-4 py-2 border-gray-300 bg-gray-100 border-solid border-b",
9652
9770
  footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
9771
+ ...options,
9653
9772
  disableStatistics: options.queryCount === false
9654
9773
  }),
9655
9774
  filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
@@ -9674,7 +9793,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
9674
9793
  }
9675
9794
  }
9676
9795
  // console.log(`getObjectHeaderToolbar====2===>`, options.filterVisible)
9677
- bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {
9796
+ bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, fields, options.formFactor, {
9678
9797
  showDisplayAs,
9679
9798
  hiddenCount: options.queryCount === false,
9680
9799
  headerToolbarItems: options.headerToolbarItems,
@@ -9799,6 +9918,7 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
9799
9918
  return {
9800
9919
  type: 'service',
9801
9920
  className: '',
9921
+ //目前crud的service层id不认用户自定义id,只支持默认规则id
9802
9922
  id: `service_${id}`,
9803
9923
  name: `page`,
9804
9924
  data: {