@steedos-widgets/amis-lib 1.2.38 → 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"
@@ -5748,16 +5775,17 @@ function getLookupSapceUserTreeSchema(){
5748
5775
  "autoCheckChildren": false,
5749
5776
  "searchable": true,
5750
5777
  "searchConfig": {
5751
- "sticky": true
5778
+ "sticky": true,
5779
+ "placeholder": "查找部门"
5752
5780
  },
5753
5781
  "unfoldedLevel": 2,
5754
5782
  "style": {
5755
5783
  "max-height": "100%",
5756
5784
  "position": "absolute",
5757
- "left": "-200px",
5758
- "width": "190px",
5785
+ "left": "-220px",
5786
+ "width": "210px",
5759
5787
  "bottom": 0,
5760
- "top": "2px",
5788
+ "top": "0",
5761
5789
  "overflow": "auto",
5762
5790
  "min-height":"300px"
5763
5791
  },
@@ -5776,7 +5804,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5776
5804
  ctx.idFieldName = refObjectConfig.idFieldName;
5777
5805
  ctx.objectName = refObjectConfig.name;
5778
5806
 
5779
- const tableFields = [];
5807
+ let tableFields = [];
5780
5808
  let i = 0;
5781
5809
  const searchableFields = [];
5782
5810
 
@@ -5905,16 +5933,31 @@ async function lookupToAmisPicker(field, readonly, ctx){
5905
5933
  }
5906
5934
  }
5907
5935
 
5908
-
5909
5936
  if(allowSearchFields){
5910
5937
  allowSearchFields.forEach(function(key){
5911
5938
  const keyValue = selfData[key];
5912
- if(keyValue){
5939
+ if(_.isString(keyValue)){
5913
5940
  filters.push([key, "contains", keyValue]);
5941
+ }else if(_.isArray(keyValue) || _.isBoolean(keyValue) || keyValue){
5942
+ filters.push([key, "=", keyValue]);
5914
5943
  }
5915
5944
  })
5916
5945
  }
5917
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
+
5918
5961
  var fieldFilters = ${JSON.stringify(field.filters)};
5919
5962
  if(fieldFilters && fieldFilters.length){
5920
5963
  filters.push(fieldFilters);
@@ -6003,6 +6046,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
6003
6046
  if(refObjectConfig.paging && refObjectConfig.paging.enabled === false){
6004
6047
  top = 1000;
6005
6048
  }
6049
+
6006
6050
  let pickerSchema = null;
6007
6051
  if(ctx.formFactor === 'SMALL'){
6008
6052
  pickerSchema = await getListSchema$1(tableFields, {
@@ -6024,7 +6068,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
6024
6068
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
6025
6069
  headerToolbarItems = getLookupSapceUserTreeSchema();
6026
6070
  pickerSchema["style"] = {
6027
- "margin-left":"200px",
6071
+ "margin-left":"220px",
6028
6072
  "min-height": "300px"
6029
6073
  };
6030
6074
  pickerSchema.className = pickerSchema.className || "" + " steedos-select-user";
@@ -6035,7 +6079,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
6035
6079
  if (isAllowCreate) {
6036
6080
  const new_button = await getSchema$5(refObjectConfig, { appId: ctx.appId, objectName: refObjectConfig.name, formFactor: ctx.formFactor });
6037
6081
  new_button.align = "right";
6038
- pickerSchema.headerToolbar.push(new_button);
6082
+ // 保持快速搜索放在最左侧,新建按钮往里插,而不是push到最后
6083
+ pickerSchema.headerToolbar.splice(pickerSchema.headerToolbar.length - 1, 0, new_button);
6039
6084
  }
6040
6085
  pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
6041
6086
  if (ctx.filterVisible !== false) {
@@ -7725,7 +7770,71 @@ async function getQuickEditSchema(field, options){
7725
7770
  `;
7726
7771
  break;
7727
7772
  }
7728
-
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
+ });
7729
7838
  } else {
7730
7839
  quickEditSchema = false;
7731
7840
  }
@@ -7758,7 +7867,7 @@ function getFieldWidth(width){
7758
7867
 
7759
7868
  async function getTableColumns(fields, options){
7760
7869
  const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
7761
- 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;
7762
7871
 
7763
7872
  for (const field of fields) {
7764
7873
  //增加quickEdit属性,实现快速编辑
@@ -8296,7 +8405,7 @@ async function getTableApi(mainObject, fields, options){
8296
8405
  try{
8297
8406
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8298
8407
  const listName = api.data.listName;
8299
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
8408
+ const listViewPropsStoreKey = location.pathname + "/crud";
8300
8409
  let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
8301
8410
  if(localListViewProps){
8302
8411
  localListViewProps = JSON.parse(localListViewProps);
@@ -8497,7 +8606,7 @@ async function getTableApi(mainObject, fields, options){
8497
8606
  try{
8498
8607
  // TODO: 不应该直接在这里取localStorage,应该从外面传入
8499
8608
  const listName = api.body.listName;
8500
- const listViewPropsStoreKey = location.pathname + "/crud/" + (listName || "");
8609
+ const listViewPropsStoreKey = location.pathname + "/crud";
8501
8610
  /**
8502
8611
  * localListViewProps规范来自crud请求api中api.data.$self参数值的。
8503
8612
  * 比如:{"perPage":20,"page":1,"__searchable__name":"7","__searchable__between__n1__c":[null,null],"filter":[["name","contains","a"]]}
@@ -9687,7 +9796,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9687
9796
  }
9688
9797
  }
9689
9798
  // console.log(`getObjectHeaderToolbar====2===>`, options.filterVisible)
9690
- bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {
9799
+ bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, fields, options.formFactor, {
9691
9800
  showDisplayAs,
9692
9801
  hiddenCount: options.queryCount === false,
9693
9802
  headerToolbarItems: options.headerToolbarItems,
@@ -9812,6 +9921,7 @@ async function getObjectCRUD(objectSchema, fields, options){
9812
9921
  return {
9813
9922
  type: 'service',
9814
9923
  className: '',
9924
+ //目前crud的service层id不认用户自定义id,只支持默认规则id
9815
9925
  id: `service_${id}`,
9816
9926
  name: `page`,
9817
9927
  data: {