@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.cjs.js CHANGED
@@ -1077,6 +1077,7 @@ var frontend_message_modification_failed$1 = "Modification failed!";
1077
1077
  var frontend_objects_related_alert_start$1 = "No related table fields associated with the related list object";
1078
1078
  var frontend_objects_related_alert_end$1 = "were found.";
1079
1079
  var frontend_no_records_found$1 = "No records found.";
1080
+ var frontend_records_no_allowedit$1 = "You do not have edit permission for this record";
1080
1081
  var en_us = {
1081
1082
  frontend_field_group_generalization: frontend_field_group_generalization$1,
1082
1083
  frontend_download: frontend_download$1,
@@ -1159,7 +1160,8 @@ var en_us = {
1159
1160
  frontend_message_modification_failed: frontend_message_modification_failed$1,
1160
1161
  frontend_objects_related_alert_start: frontend_objects_related_alert_start$1,
1161
1162
  frontend_objects_related_alert_end: frontend_objects_related_alert_end$1,
1162
- frontend_no_records_found: frontend_no_records_found$1
1163
+ frontend_no_records_found: frontend_no_records_found$1,
1164
+ frontend_records_no_allowedit: frontend_records_no_allowedit$1
1163
1165
  };
1164
1166
 
1165
1167
  var frontend_field_group_generalization = "通用";
@@ -1183,7 +1185,7 @@ var frontend_display_type_is_split = "分栏视图";
1183
1185
  var frontend_display_as = "显示为";
1184
1186
  var frontend_record_sum = "个项目";
1185
1187
  var frontend_button_reload_tooltip = "刷新";
1186
- var frontend_button_search_tooltip = "搜索";
1188
+ var frontend_button_search_tooltip = "查询";
1187
1189
  var frontend_fields_filter_button_search = "搜索";
1188
1190
  var frontend_fields_filter_button_settings = "设置搜索项";
1189
1191
  var frontend_button_listview_control_tooltip = "列表视图控制";
@@ -1245,6 +1247,7 @@ var frontend_message_modification_failed = "修改失败!";
1245
1247
  var frontend_objects_related_alert_start = "未找到与相关列表对象";
1246
1248
  var frontend_objects_related_alert_end = "关联的相关表字段";
1247
1249
  var frontend_no_records_found = "无法找到记录";
1250
+ var frontend_records_no_allowedit = "您对这条记录没有编辑权限";
1248
1251
  var zh_cn = {
1249
1252
  frontend_field_group_generalization: frontend_field_group_generalization,
1250
1253
  frontend_download: frontend_download,
@@ -1328,7 +1331,8 @@ var zh_cn = {
1328
1331
  frontend_message_modification_failed: frontend_message_modification_failed,
1329
1332
  frontend_objects_related_alert_start: frontend_objects_related_alert_start,
1330
1333
  frontend_objects_related_alert_end: frontend_objects_related_alert_end,
1331
- frontend_no_records_found: frontend_no_records_found
1334
+ frontend_no_records_found: frontend_no_records_found,
1335
+ frontend_records_no_allowedit: frontend_records_no_allowedit
1332
1336
  };
1333
1337
 
1334
1338
  const resources = {
@@ -3382,12 +3386,14 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3382
3386
  if(!event.data.isLookup){
3383
3387
  // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
3384
3388
  const listName = event.data.listName;
3385
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3389
+ const listViewPropsStoreKey = location.pathname + "/crud";
3386
3390
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3387
3391
  if(localListViewProps){
3388
3392
  localListViewProps = JSON.parse(localListViewProps);
3389
3393
  for(var k in localListViewProps){
3390
- removedValues[k] = null;
3394
+ if(k !== "__keywords"){
3395
+ removedValues[k] = null;
3396
+ }
3391
3397
  }
3392
3398
  }
3393
3399
  }
@@ -3409,12 +3415,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3409
3415
  const objectName = data.objectName;
3410
3416
  const isLookup = data.isLookup;
3411
3417
  const listName = data.listName;
3412
- let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
3418
+ let searchableFieldsStoreKey = location.pathname + "/searchable_fields";
3413
3419
  if(isLookup){
3414
- searchableFieldsStoreKey += "lookup/" + objectName;
3415
- }
3416
- else{
3417
- searchableFieldsStoreKey += (listName || "");
3420
+ searchableFieldsStoreKey += "/lookup/" + objectName;
3418
3421
  }
3419
3422
  let defaultSearchableFields = sessionStorage.getItem(searchableFieldsStoreKey);
3420
3423
  if(defaultSearchableFields){
@@ -3441,7 +3444,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3441
3444
  setData({ showFieldsFilter: false });
3442
3445
  }
3443
3446
  else{
3444
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3447
+ const listViewPropsStoreKey = location.pathname + "/crud";
3445
3448
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3446
3449
  if(localListViewProps){
3447
3450
  localListViewProps = JSON.parse(localListViewProps);
@@ -3481,12 +3484,9 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3481
3484
  return n.props.type === "service";
3482
3485
  });
3483
3486
  filterService.setData({ filterFormSearchableFields: value });
3484
- let searchableFieldsStoreKey = location.pathname + "/searchable_fields/";
3487
+ let searchableFieldsStoreKey = location.pathname + "/searchable_fields";
3485
3488
  if(isLookup){
3486
- searchableFieldsStoreKey += "lookup/" + objectName;
3487
- }
3488
- else{
3489
- searchableFieldsStoreKey += (listName || "");
3489
+ searchableFieldsStoreKey += "/lookup/" + objectName;
3490
3490
  }
3491
3491
  sessionStorage.setItem(searchableFieldsStoreKey, value);
3492
3492
 
@@ -3544,7 +3544,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3544
3544
  }
3545
3545
 
3546
3546
  // 列表视图crud支持本地缓存,所以需要进一步清除浏览器本地缓存里面用户在可搜索项中移除的字段值
3547
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
3547
+ const listViewPropsStoreKey = location.pathname + "/crud";
3548
3548
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
3549
3549
  if(localListViewProps){
3550
3550
  localListViewProps = JSON.parse(localListViewProps);
@@ -5265,9 +5265,23 @@ crudService && crudService.setData({showFieldsFilter: toShowFieldsFilter});
5265
5265
  `;
5266
5266
 
5267
5267
 
5268
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
5268
+ function getObjectHeaderToolbar(mainObject, fields, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
5269
5269
  // console.log(`getObjectHeaderToolbar====>`, filterVisible)
5270
- console.log(`getObjectHeaderToolbar`, mainObject);
5270
+ // console.log(`getObjectHeaderToolbar`, mainObject)
5271
+ const searchableFieldsLabel = [];
5272
+ _.each(fields, function (field) {
5273
+ if (field.searchable) {
5274
+ searchableFieldsLabel.push(field.label);
5275
+ }
5276
+ });
5277
+ const listViewPropsStoreKey = location.pathname + "/crud";
5278
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
5279
+ let crudKeywords = "";
5280
+ if(localListViewProps){
5281
+ localListViewProps = JSON.parse(localListViewProps);
5282
+ crudKeywords = (localListViewProps && localListViewProps.__keywords) || "";
5283
+ }
5284
+
5271
5285
  const isMobile = window.innerWidth < 768;
5272
5286
  if(isMobile){
5273
5287
  showDisplayAs = false;
@@ -5357,21 +5371,9 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5357
5371
  "type": "tpl",
5358
5372
  "tpl": "${count} " + i18next__default["default"].t('frontend_record_sum')
5359
5373
  },
5360
- {
5361
- "type": "reload",
5362
- "align": "right",
5363
- //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5364
- // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5365
- "tooltip":"",
5366
- "tooltipPlacement": "top",
5367
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5368
- },
5369
- // getExportExcelToolbarButtonSchema(),
5370
- mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
5371
- getDisplayAsButton(mainObject?.name),
5372
5374
  filterVisible ? {
5373
5375
  "label": i18next__default["default"].t('frontend_button_search_tooltip'),
5374
- "icon": "fa fa-search",
5376
+ "icon": "fa fa-filter",
5375
5377
  //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5376
5378
  // "tooltip": i18next.t('frontend_button_search_tooltip'),
5377
5379
  // "tooltipPlacement": "top",
@@ -5397,14 +5399,39 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5397
5399
  ]
5398
5400
  }
5399
5401
  }
5400
- } : {}
5401
- // {
5402
- // "type": "search-box",
5403
- // "align": "right",
5404
- // "name": "__keywords",
5405
- // "placeholder": "请输入关键字",
5406
- // "mini": true
5407
- // },
5402
+ } : {},
5403
+ {
5404
+ "type": "reload",
5405
+ "align": "right",
5406
+ //TODO: dropdown-button只支持在按钮上方配置提示,对于上方按钮的点击会有影响,为保持统一,暂时去除,等待amis优化,https://github.com/baidu/amis/issues/7330
5407
+ // "tooltip": i18next.t('frontend_button_reload_tooltip'),
5408
+ "tooltip":"",
5409
+ "tooltipPlacement": "top",
5410
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
5411
+ },
5412
+ // getExportExcelToolbarButtonSchema(),
5413
+ mainObject?.permissions?.allowCreateListViews ? getSettingListviewToolbarButtonSchema() : {},
5414
+ getDisplayAsButton(mainObject?.name),
5415
+ {
5416
+ "type": "tooltip-wrapper",
5417
+ "align": "right",
5418
+ "title": "",
5419
+ "content": "可模糊搜索字段:" + searchableFieldsLabel.join(","),
5420
+ "placement": "bottom",
5421
+ "tooltipTheme": "dark",
5422
+ "trigger": "click",
5423
+ "className": "mr-1",
5424
+ "body": [
5425
+ {
5426
+ "type": "search-box",
5427
+ "name": "__keywords",
5428
+ "placeholder": "请输入关键字",
5429
+ "value": crudKeywords,
5430
+ "clearable": true,
5431
+ "clearAndSubmit": true
5432
+ }
5433
+ ]
5434
+ },
5408
5435
  // {
5409
5436
  // "type": "drag-toggler",
5410
5437
  // "align": "right"
@@ -5420,18 +5447,27 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
5420
5447
 
5421
5448
  }
5422
5449
 
5423
- function getObjectFooterToolbar(mainObject, formFactor) {
5450
+ function getObjectFooterToolbar(mainObject, formFactor, options) {
5424
5451
  if (formFactor === 'SMALL') {
5425
5452
  return [
5426
5453
  "load-more",
5427
5454
  ]
5428
5455
  }
5429
5456
  else {
5430
- return [
5431
- "switch-per-page",
5432
- "statistics",
5433
- "pagination"
5434
- ]
5457
+ if(options && options.isRelated){
5458
+ return [
5459
+ "statistics",
5460
+ "pagination"
5461
+ ]
5462
+
5463
+ }
5464
+ else {
5465
+ return [
5466
+ "switch-per-page",
5467
+ "statistics",
5468
+ "pagination"
5469
+ ]
5470
+ }
5435
5471
  }
5436
5472
  }
5437
5473
 
@@ -5739,16 +5775,17 @@ function getLookupSapceUserTreeSchema(){
5739
5775
  "autoCheckChildren": false,
5740
5776
  "searchable": true,
5741
5777
  "searchConfig": {
5742
- "sticky": true
5778
+ "sticky": true,
5779
+ "placeholder": "查找部门"
5743
5780
  },
5744
5781
  "unfoldedLevel": 2,
5745
5782
  "style": {
5746
5783
  "max-height": "100%",
5747
5784
  "position": "absolute",
5748
- "left": "-200px",
5749
- "width": "190px",
5785
+ "left": "-220px",
5786
+ "width": "210px",
5750
5787
  "bottom": 0,
5751
- "top": "2px",
5788
+ "top": "0",
5752
5789
  "overflow": "auto",
5753
5790
  "min-height":"300px"
5754
5791
  },
@@ -5767,7 +5804,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5767
5804
  ctx.idFieldName = refObjectConfig.idFieldName;
5768
5805
  ctx.objectName = refObjectConfig.name;
5769
5806
 
5770
- const tableFields = [];
5807
+ let tableFields = [];
5771
5808
  let i = 0;
5772
5809
  const searchableFields = [];
5773
5810
 
@@ -5896,16 +5933,31 @@ async function lookupToAmisPicker(field, readonly, ctx){
5896
5933
  }
5897
5934
  }
5898
5935
 
5899
-
5900
5936
  if(allowSearchFields){
5901
5937
  allowSearchFields.forEach(function(key){
5902
5938
  const keyValue = selfData[key];
5903
- if(keyValue){
5939
+ if(_.isString(keyValue)){
5904
5940
  filters.push([key, "contains", keyValue]);
5941
+ }else if(_.isArray(keyValue) || _.isBoolean(keyValue) || keyValue){
5942
+ filters.push([key, "=", keyValue]);
5905
5943
  }
5906
5944
  })
5907
5945
  }
5908
5946
 
5947
+ if(selfData.__keywords && allowSearchFields){
5948
+ const keywordsFilters = [];
5949
+ allowSearchFields.forEach(function(key, index){
5950
+ const keyValue = selfData.__keywords;
5951
+ if(keyValue){
5952
+ keywordsFilters.push([key, "contains", keyValue]);
5953
+ if(index < allowSearchFields.length - 1){
5954
+ keywordsFilters.push('or');
5955
+ }
5956
+ }
5957
+ })
5958
+ filters.push(keywordsFilters);
5959
+ };
5960
+
5909
5961
  var fieldFilters = ${JSON.stringify(field.filters)};
5910
5962
  if(fieldFilters && fieldFilters.length){
5911
5963
  filters.push(fieldFilters);
@@ -5994,6 +6046,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5994
6046
  if(refObjectConfig.paging && refObjectConfig.paging.enabled === false){
5995
6047
  top = 1000;
5996
6048
  }
6049
+
5997
6050
  let pickerSchema = null;
5998
6051
  if(ctx.formFactor === 'SMALL'){
5999
6052
  pickerSchema = await getListSchema$1(tableFields, {
@@ -6015,7 +6068,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
6015
6068
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
6016
6069
  headerToolbarItems = getLookupSapceUserTreeSchema();
6017
6070
  pickerSchema["style"] = {
6018
- "margin-left":"200px",
6071
+ "margin-left":"220px",
6019
6072
  "min-height": "300px"
6020
6073
  };
6021
6074
  pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
@@ -6026,7 +6079,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
6026
6079
  if (isAllowCreate) {
6027
6080
  const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
6028
6081
  new_button.align = "right";
6029
- pickerSchema.headerToolbar.push(new_button);
6082
+ // 保持快速搜索放在最左侧,新建按钮往里插,而不是push到最后
6083
+ pickerSchema.headerToolbar.splice(pickerSchema.headerToolbar.length - 1, 0, new_button);
6030
6084
  }
6031
6085
  pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
6032
6086
  if (ctx.filterVisible !== false) {
@@ -7716,7 +7770,71 @@ async function getQuickEditSchema(field, options){
7716
7770
  `;
7717
7771
  break;
7718
7772
  }
7719
-
7773
+ quickEditSchema.body[0].visibleOn = "${quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}";
7774
+ quickEditSchema.body.push({
7775
+ "type":"service",
7776
+ "body":[
7777
+ {
7778
+ "type": "tpl",
7779
+ "tpl": i18next__default["default"].t('frontend_records_no_allowedit'),
7780
+ "visibleOn": "${!quickedit_record_permissions.allowEdit && quickedit_record_permissions_loading == false}"
7781
+ },
7782
+ {
7783
+ "type": "spinner",
7784
+ "showOn": "${quickedit_record_permissions_loading}"
7785
+ }
7786
+ ],
7787
+ "onEvent":{
7788
+ "init":{
7789
+ "actions":[
7790
+ {
7791
+ "actionType": "setValue",
7792
+ "componentId": `service_listview_${options.objectName}`,
7793
+ "args": {
7794
+ "value":{
7795
+ "quickedit_record_permissions_loading": true
7796
+ }
7797
+ }
7798
+ },
7799
+ {
7800
+ "actionType": "ajax",
7801
+ "args": {
7802
+ "api": {
7803
+ "url": "${context.rootUrl}/service/api/@\${objectName}/recordPermissions/${_id}",
7804
+ "method": "get",
7805
+ "headers": {
7806
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7807
+ },
7808
+ "cache": 30000,
7809
+ "messages": {
7810
+ "failed": "失败了呢。。"
7811
+ }
7812
+ }
7813
+ }
7814
+ },
7815
+ {
7816
+ "actionType": "setValue",
7817
+ "componentId": `service_listview_${options.objectName}`,
7818
+ "args": {
7819
+ "value":{
7820
+ "quickedit_record_permissions_loading": false
7821
+ }
7822
+ }
7823
+ },
7824
+ {
7825
+ "actionType": "setValue",
7826
+ "componentId": `service_listview_${options.objectName}`,
7827
+ "args": {
7828
+ "value":{
7829
+ "quickedit_record_permissions": "${event.data}"
7830
+ }
7831
+ }
7832
+ }
7833
+ ]
7834
+ }
7835
+ }
7836
+
7837
+ });
7720
7838
  } else {
7721
7839
  quickEditSchema = false;
7722
7840
  }
@@ -7749,7 +7867,7 @@ function getFieldWidth(width){
7749
7867
 
7750
7868
  async function getTableColumns(fields, options){
7751
7869
  const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
7752
- const allowEdit = options.permissions?.allowEdit && options.permissions?.modifyAllRecords && !options.isLookup && options.enable_inline_edit != false;
7870
+ const allowEdit = options.permissions?.allowEdit && !options.isLookup && options.enable_inline_edit != false;
7753
7871
 
7754
7872
  for (const field of fields) {
7755
7873
  //增加quickEdit属性,实现快速编辑
@@ -8287,7 +8405,7 @@ async function getTableApi(mainObject, fields, options){
8287
8405
  try{
8288
8406
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8289
8407
  const listName = api.data.listName;
8290
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
8408
+ const listViewPropsStoreKey = location.pathname + "/crud";
8291
8409
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
8292
8410
  if(localListViewProps){
8293
8411
  localListViewProps = JSON.parse(localListViewProps);
@@ -8488,7 +8606,7 @@ async function getTableApi(mainObject, fields, options){
8488
8606
  try{
8489
8607
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8490
8608
  const listName = api.body.listName;
8491
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
8609
+ const listViewPropsStoreKey = location.pathname + "/crud";
8492
8610
  /**
8493
8611
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
8494
8612
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -9653,6 +9771,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9653
9771
  // headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
9654
9772
  headerToolbarClassName: "px-4 py-2 border-gray-300 bg-gray-100 border-solid border-b",
9655
9773
  footerToolbar: getObjectFooterToolbar(objectSchema, options.formFactor, {
9774
+ ...options,
9656
9775
  disableStatistics: options.queryCount === false
9657
9776
  }),
9658
9777
  filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
@@ -9677,7 +9796,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9677
9796
  }
9678
9797
  }
9679
9798
  // console.log(`getObjectHeaderToolbar====2===>`, options.filterVisible)
9680
- bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {
9799
+ bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, fields, options.formFactor, {
9681
9800
  showDisplayAs,
9682
9801
  hiddenCount: options.queryCount === false,
9683
9802
  headerToolbarItems: options.headerToolbarItems,
@@ -9802,6 +9921,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9802
9921
  return {
9803
9922
  type: 'service',
9804
9923
  className: '',
9924
+ //目前crud的service层id不认用户自定义id,只支持默认规则id
9805
9925
  id: `service_${id}`,
9806
9926
  name: `page`,
9807
9927
  data: {