@steedos-widgets/amis-lib 1.2.6-beta.9 → 1.2.6

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
@@ -1350,26 +1350,11 @@ const parseSingleExpression = function (func, formData, dataPath, global, userSe
1350
1350
  }
1351
1351
  };
1352
1352
 
1353
- /*
1354
- * @Author: baozhoutao@steedos.com
1355
- * @Date: 2022-08-04 10:42:49
1356
- * @LastEditors: baozhoutao@steedos.com
1357
- * @LastEditTime: 2022-08-25 10:28:47
1358
- * @Description:
1359
- */
1360
- var config = {
1361
- listView: {
1362
- newRecordMode: 'modal',
1363
- editRecordMode: 'modal',
1364
- perPage: 20
1365
- }
1366
- };
1367
-
1368
1353
  /*
1369
1354
  * @Author: baozhoutao@steedos.com
1370
1355
  * @Date: 2022-11-01 15:51:00
1371
- * @LastEditors: baozhoutao@steedos.com
1372
- * @LastEditTime: 2023-04-19 20:26:27
1356
+ * @LastEditors: Please set LastEditors
1357
+ * @LastEditTime: 2023-04-26 11:52:04
1373
1358
  * @Description:
1374
1359
  */
1375
1360
 
@@ -1461,7 +1446,8 @@ const getSchema$4 = async (uiSchema, ctx) => {
1461
1446
  "schemaApi": {
1462
1447
  "data": {
1463
1448
  "isLookup": "${isLookup}",
1464
- "_master": "${_master}"
1449
+ "_master": "${_master}",
1450
+ "url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}"
1465
1451
  },
1466
1452
  "url": "${context.rootUrl}/api/pageSchema/form?app=${appId}&objectApiName=${objectName}&formFactor=${formFactor}",
1467
1453
  "method": "get",
@@ -1470,7 +1456,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
1470
1456
  "headers": {
1471
1457
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
1472
1458
  },
1473
- "requestAdaptor": "",
1459
+ "requestAdaptor": "return { ...api, url: api.body.url }",
1474
1460
  "adaptor": schemaApiAdaptor
1475
1461
  }
1476
1462
  }
@@ -2379,6 +2365,166 @@ const execute = (button, props) => {
2379
2365
 
2380
2366
  const executeButton = execute;
2381
2367
 
2368
+
2369
+ const getObjectDetailHeaderButtons = (objectSchema, recordId)=>{
2370
+ const { name } = objectSchema;
2371
+ const buttons = getObjectDetailButtons(objectSchema, {});
2372
+ const moreButtons = getObjectDetailMoreButtons(objectSchema, {
2373
+ recordId: recordId,
2374
+ objectName: name
2375
+ });
2376
+ let amisButtonsSchema = ___default.map(buttons, (button) => {
2377
+ return {
2378
+ type: 'steedos-object-button',
2379
+ name: button.name,
2380
+ objectName: button.objectName,
2381
+ visibleOn: getButtonVisibleOn$1(button),
2382
+ className: `button_${button.name}`
2383
+ }
2384
+ });
2385
+ let dropdownButtons = ___default.map(moreButtons, (button) => {
2386
+ return {
2387
+ type: 'steedos-object-button',
2388
+ name: button.name,
2389
+ objectName: button.objectName,
2390
+ visibleOn: getButtonVisibleOn$1(button),
2391
+ }
2392
+ });
2393
+ return {
2394
+ buttons: amisButtonsSchema,
2395
+ moreButtons: dropdownButtons
2396
+ };
2397
+ };
2398
+
2399
+ const getObjectDetailButtonsSchemas = (objectSchema, recordId, ctx)=>{
2400
+ const { buttons, moreButtons } = getObjectDetailHeaderButtons(objectSchema, recordId);
2401
+ if(ctx.formFactor === 'SMALL'){
2402
+ return {
2403
+ "type": "button",
2404
+ "icon": "fa fa-angle-down",
2405
+ "onEvent": {
2406
+ "click": {
2407
+ "actions": [
2408
+ {
2409
+ "actionType": "drawer",
2410
+ "drawer": {
2411
+ "type": "drawer",
2412
+ "title": "操作",
2413
+ "body": [
2414
+ {
2415
+ "type": "button-group",
2416
+ "id": "u:fd837823be5b",
2417
+ "vertical": true,
2418
+ "tiled": true,
2419
+ "buttons": [
2420
+ ...___default.map(buttons, (button)=>{
2421
+ button.className += ' w-full';
2422
+ return button;
2423
+ }),
2424
+ ...___default.map(moreButtons, (button)=>{
2425
+ button.className += ' w-full';
2426
+ return button;
2427
+ })
2428
+ ],
2429
+ "btnLevel": "enhance",
2430
+ "className": "w-full",
2431
+ "btnClassName": "w-full",
2432
+ "size": "lg"
2433
+ }
2434
+ ],
2435
+ "id": "u:9815f7366b9f",
2436
+ "position": "bottom",
2437
+ "closeOnOutside": true,
2438
+ "resizable": false,
2439
+ "className": "buttons-drawer",
2440
+ "bodyClassName": "m-none p-none",
2441
+ "actions": []
2442
+ }
2443
+ }
2444
+ ]
2445
+ }
2446
+ },
2447
+ "id": "u:ee7c7929e6ae"
2448
+ }
2449
+ }else {
2450
+ if(moreButtons.length > 0){
2451
+ const dropdownButtonsSchema = {
2452
+ type: "steedos-dropdown-button",
2453
+ label: "",
2454
+ buttons: moreButtons,
2455
+ className: 'slds-icon'
2456
+ };
2457
+ buttons.push(dropdownButtonsSchema);
2458
+ }
2459
+ return buttons;
2460
+ }
2461
+ };
2462
+
2463
+
2464
+ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
2465
+ const buttons = getListViewButtons(objectSchema, ctx);
2466
+ if(ctx.formFactor === 'SMALL'){
2467
+ return {
2468
+ "type": "button",
2469
+ "icon": "fa fa-angle-down",
2470
+ "onEvent": {
2471
+ "click": {
2472
+ "actions": [
2473
+ {
2474
+ "actionType": "drawer",
2475
+ "drawer": {
2476
+ "type": "drawer",
2477
+ "title": "操作",
2478
+ "body": [
2479
+ {
2480
+ "type": "button-group",
2481
+ "id": "u:fd837823be5b",
2482
+ "vertical": true,
2483
+ "tiled": true,
2484
+ "buttons": [
2485
+ ...___default.map(buttons, (button)=>{
2486
+ return {
2487
+ type: 'steedos-object-button',
2488
+ name: button.name,
2489
+ objectName: button.objectName,
2490
+ visibleOn: getButtonVisibleOn$1(button),
2491
+ className: `button_${button.name} w-full`
2492
+ }
2493
+ })
2494
+ ],
2495
+ "btnLevel": "enhance",
2496
+ "className": "w-full",
2497
+ "btnClassName": "w-full",
2498
+ "size": "lg"
2499
+ }
2500
+ ],
2501
+ "id": "u:9815f7366b9f",
2502
+ "position": "bottom",
2503
+ "closeOnOutside": true,
2504
+ "resizable": false,
2505
+ "className": "buttons-drawer",
2506
+ "bodyClassName": "m-none p-none",
2507
+ "actions": []
2508
+ }
2509
+ }
2510
+ ]
2511
+ }
2512
+ },
2513
+ "id": "u:ee7c7929e6ae"
2514
+ }
2515
+ }else {
2516
+ return ___default.map(buttons, (button) => {
2517
+ return {
2518
+ type: 'steedos-object-button',
2519
+ name: button.name,
2520
+ objectName: button.objectName,
2521
+ visibleOn: getButtonVisibleOn$1(button),
2522
+ className: `button_${button.name}`
2523
+ }
2524
+ });
2525
+ }
2526
+ };
2527
+
2382
2528
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2383
2529
  // const amisListViewId = `listview_${objectSchema.name}`;
2384
2530
  return {
@@ -2512,6 +2658,35 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2512
2658
  // }
2513
2659
  // listView.handleFilterSubmit(Object.assign({}, removedValues, filterFormValues));
2514
2660
  `;
2661
+ const onResetScript = `
2662
+ const scope = event.context.scoped;
2663
+ var filterForm = scope.parent.parent.getComponents().find(function(n){
2664
+ return n.props.type === "form";
2665
+ });
2666
+ var filterFormValues = filterForm.getValues();
2667
+ var listView = scope.parent.parent.parent.getComponents().find(function(n){
2668
+ return n.props.type === "crud";
2669
+ });
2670
+ const removedValues = {};
2671
+ for(var k in filterFormValues){
2672
+ if(/^__searchable__/.test(k)){
2673
+ removedValues[k] = "";
2674
+ }
2675
+ }
2676
+ if(!event.data.isLookup){
2677
+ // 刷新浏览器后,filterFormValues值是空的,只能从本地存储中取出并重置为空值
2678
+ const listViewId = event.data.listViewId;
2679
+ const listViewPropsStoreKey = location.pathname + "/crud/" + listViewId ;
2680
+ let localListViewProps = sessionStorage.getItem(listViewPropsStoreKey);
2681
+ if(localListViewProps){
2682
+ localListViewProps = JSON.parse(localListViewProps);
2683
+ for(var k in localListViewProps){
2684
+ removedValues[k] = "";
2685
+ }
2686
+ }
2687
+ }
2688
+ listView.handleFilterSubmit(removedValues);
2689
+ `;
2515
2690
  const dataProviderInited = `
2516
2691
  const objectName = data.objectName;
2517
2692
  const isLookup = data.isLookup;
@@ -2705,6 +2880,21 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2705
2880
  }
2706
2881
  }
2707
2882
  },
2883
+ {
2884
+ "type": "button",
2885
+ "label": "重置",
2886
+ "visibleOn": "this.filterFormSearchableFields && this.filterFormSearchableFields.length",
2887
+ "onEvent": {
2888
+ "click": {
2889
+ "actions": [
2890
+ {
2891
+ "actionType": "custom",
2892
+ "script": onResetScript
2893
+ }
2894
+ ]
2895
+ }
2896
+ }
2897
+ },
2708
2898
  {
2709
2899
  "type": "button",
2710
2900
  "label": "设置搜索项",
@@ -2861,17 +3051,7 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
2861
3051
  }
2862
3052
  );
2863
3053
 
2864
- const buttons = getListViewButtons(objectSchema, {});
2865
- let amisButtonsSchema = map(buttons, (button) => {
2866
- return {
2867
- type: 'steedos-object-button',
2868
- name: button.name,
2869
- objectName: button.objectName,
2870
- visibleOn: getButtonVisibleOn$1(button),
2871
- className: `button_${button.name}`
2872
- }
2873
- });
2874
-
3054
+ let amisButtonsSchema = getObjectListViewButtonsSchemas(objectSchema, {formFactor: ctx.formFactor});
2875
3055
  const reg = new RegExp('_', 'g');
2876
3056
  const standardIcon = icon && icon.replace(reg, '-');
2877
3057
  return {
@@ -2904,8 +3084,8 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
2904
3084
  },
2905
3085
  {
2906
3086
  "type": "dropdown-button",
2907
- "className": "",
2908
- "label": "\${uiSchema.list_views[listName].label}",
3087
+ "className": "",
3088
+ "label": "\${listName ? uiSchema.list_views[listName].label : uiSchema.list_views[defaultListName].label}",
2909
3089
  "rightIcon": "fa fa-caret-down",
2910
3090
  "size": "sm",
2911
3091
  "hideCaret": true,
@@ -3053,7 +3233,10 @@ async function getObjectListHeaderFieldsFilterBar(objectSchema, listViewName, ct
3053
3233
  * @returns amisSchema
3054
3234
  */
3055
3235
  function getObjectListHeader$1(objectSchema, listViewName, ctx) {
3056
- let firstLineSchema = getObjectListHeaderFirstLine(objectSchema);
3236
+ if (!ctx) {
3237
+ ctx = {};
3238
+ }
3239
+ let firstLineSchema = getObjectListHeaderFirstLine(objectSchema, listViewName, ctx);
3057
3240
  let body = [firstLineSchema];
3058
3241
  let headerSchema = [{
3059
3242
  "type": "wrapper",
@@ -3074,35 +3257,11 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3074
3257
  const { showRecordTitle = true } = options || {};
3075
3258
  // console.log('getObjectRecordDetailHeader==>', objectSchema, recordId)
3076
3259
  const { name, label, icon, NAME_FIELD_KEY } = objectSchema;
3077
- const buttons = getObjectDetailButtons(objectSchema, {});
3078
- const moreButtons = getObjectDetailMoreButtons(objectSchema, {
3079
- recordId: recordId,
3080
- objectName: name
3081
- });
3082
- let amisButtonsSchema = map(buttons, (button) => {
3083
- return {
3084
- type: 'steedos-object-button',
3085
- name: button.name,
3086
- objectName: button.objectName,
3087
- visibleOn: getButtonVisibleOn$1(button),
3088
- className: `button_${button.name}`
3089
- }
3090
- });
3091
- let dropdownButtons = map(moreButtons, (button) => {
3092
- return {
3093
- type: 'steedos-object-button',
3094
- name: button.name,
3095
- objectName: button.objectName,
3096
- visibleOn: getButtonVisibleOn$1(button),
3097
- }
3098
- });
3099
- const dropdownButtonsSchema = {
3100
- type: "steedos-dropdown-button",
3101
- label: "",
3102
- buttons: dropdownButtons,
3103
- className: 'slds-icon'
3104
- };
3105
- amisButtonsSchema.push(dropdownButtonsSchema);
3260
+
3261
+ let amisButtonsSchema = getObjectDetailButtonsSchemas(objectSchema, recordId, options);
3262
+
3263
+ // console.log(`getObjectRecordDetailHeader==>`, amisButtonsSchema)
3264
+
3106
3265
  const reg = new RegExp('_', 'g');
3107
3266
  const standardIcon = icon && icon.replace(reg, '-');
3108
3267
 
@@ -3313,8 +3472,8 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
3313
3472
  "icon": "fa fa-table-columns",
3314
3473
  "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3315
3474
  "align": "right",
3316
- "visibleOn": "${formFactor !== 'SMALL'}",
3317
- "buttons": [
3475
+ "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
3476
+ "buttons": [
3318
3477
  {
3319
3478
  "label": "显示为",
3320
3479
  "children": buttons
@@ -3411,6 +3570,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3411
3570
  `;
3412
3571
  return [
3413
3572
  // "bulkActions",
3573
+ ...(headerToolbarItems || []),
3414
3574
  hiddenCount ? {} :{
3415
3575
  "type": "tpl",
3416
3576
  "tpl": "${count} 个项目"
@@ -3555,7 +3715,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3555
3715
  "list_view": "${uiSchema.list_views[listName]}",
3556
3716
  "appId": "${appId}",
3557
3717
  "global": "${global}",
3558
- "objectName": "${objectName}",
3718
+ "targetObjectName": "${objectName}",
3559
3719
  },
3560
3720
  "body": [
3561
3721
  {
@@ -3595,7 +3755,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3595
3755
  {
3596
3756
  "args": {
3597
3757
  // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3598
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3758
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3599
3759
  "blank": false
3600
3760
  },
3601
3761
  "actionType": "url",
@@ -3636,7 +3796,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3636
3796
  "data": {
3637
3797
  "&": "$$",
3638
3798
  "listName": "${listName}",
3639
- "objectName": "${objectName}",
3799
+ "targetObjectName": "${objectName}",
3640
3800
  "list_view": "${uiSchema.list_views[listName]}",
3641
3801
  "appId": "${appId}",
3642
3802
  "global": "${global}"
@@ -3679,7 +3839,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3679
3839
  "actions": [
3680
3840
  {
3681
3841
  "args": {
3682
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3842
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3683
3843
  "blank": false
3684
3844
  },
3685
3845
  "actionType": "url",
@@ -3715,7 +3875,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3715
3875
  "type": "dialog",
3716
3876
  "title": "重命名 列表视图",
3717
3877
  "data": {
3718
- "objectName": "${objectName}",
3878
+ "targetObjectName": "${objectName}",
3719
3879
  "recordId": "${uiSchema.list_views[listName]._id}",
3720
3880
  "appId": "${appId}"
3721
3881
  },
@@ -3736,7 +3896,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3736
3896
  "actions": [
3737
3897
  {
3738
3898
  "args": {
3739
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${name}",
3899
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
3740
3900
  "blank": false
3741
3901
  },
3742
3902
  "actionType": "url",
@@ -3810,6 +3970,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3810
3970
  "type": "dialog",
3811
3971
  "title": "过滤设置",
3812
3972
  "data": {
3973
+ "targetObjectName": "${objectName}",
3813
3974
  "objectName": "${objectName}",
3814
3975
  "recordId": "${uiSchema.list_views[listName]._id}",
3815
3976
  "listName": "${listName}",
@@ -3835,7 +3996,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3835
3996
  "actions": [
3836
3997
  {
3837
3998
  "args": {
3838
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
3999
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
3839
4000
  "blank": false
3840
4001
  },
3841
4002
  "actionType": "url",
@@ -3873,6 +4034,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3873
4034
  "title": "显示的列",
3874
4035
  "data": {
3875
4036
  "&": "$$",
4037
+ "targetObjectName": "${objectName}",
3876
4038
  "objectName": "${objectName}",
3877
4039
  "recordId": "${uiSchema.list_views[listName]._id}",
3878
4040
  "listName": "${listName}",
@@ -3898,7 +4060,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3898
4060
  "actions": [
3899
4061
  {
3900
4062
  "args": {
3901
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4063
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
3902
4064
  "blank": false
3903
4065
  },
3904
4066
  "actionType": "url"
@@ -3934,6 +4096,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3934
4096
  "title": "弹框标题",
3935
4097
  "data": {
3936
4098
  "&": "$$",
4099
+ "targetObjectName": "${objectName}",
3937
4100
  "objectName": "${objectName}",
3938
4101
  "recordId": "${uiSchema.list_views[listName]._id}",
3939
4102
  "listName": "${listName}",
@@ -3959,7 +4122,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3959
4122
  "actions": [
3960
4123
  {
3961
4124
  "args": {
3962
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4125
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
3963
4126
  "blank": false
3964
4127
  },
3965
4128
  "actionType": "url"
@@ -4507,13 +4670,16 @@ async function lookupToAmisPicker(field, readonly, ctx){
4507
4670
  var sort = orderBy + ' ' + orderDir;
4508
4671
  sort = orderBy ? sort : "${sort}";
4509
4672
  var allowSearchFields = ${JSON.stringify(searchableFields)};
4673
+ let fieldValue;
4510
4674
  if(api.data.$term){
4511
4675
  filters = [["name", "contains", "'+ api.data.$term +'"]];
4512
4676
  }else if(selfData.op === 'loadOptions' && selfData.value){
4513
4677
  if(selfData.value?.indexOf(',') > 0){
4514
- filters = [["${referenceTo.valueField.name}", "=", selfData.value.split(',')]];
4678
+ fieldValue = selfData.value.split(',');
4679
+ filters = [["${referenceTo.valueField.name}", "=", fieldValue]];
4515
4680
  }else{
4516
- filters = [["${referenceTo.valueField.name}", "=", selfData.value]];
4681
+ fieldValue = selfData.value;
4682
+ filters = [["${referenceTo.valueField.name}", "=", fieldValue]];
4517
4683
  }
4518
4684
  }
4519
4685
 
@@ -4567,6 +4733,9 @@ async function lookupToAmisPicker(field, readonly, ctx){
4567
4733
  if(enable_tree){
4568
4734
  pageSize = 10000;
4569
4735
  }
4736
+ if(fieldValue && _.isArray(fieldValue) && fieldValue.length > pageSize){
4737
+ pageSize = fieldValue.length;
4738
+ }
4570
4739
  api.data.query = api.data.query.replace(/{__filters}/g, JSON.stringify(filters)).replace('{__top}', pageSize).replace('{__skip}', skip).replace('{__sort}', sort.trim());
4571
4740
  return api;
4572
4741
  `;
@@ -4647,6 +4816,8 @@ async function lookupToAmisPicker(field, readonly, ctx){
4647
4816
  ...ctx
4648
4817
  });
4649
4818
 
4819
+ pickerSchema.affixHeader = false;
4820
+
4650
4821
  var headerToolbarItems = [];
4651
4822
  const isMobile = window.innerWidth < 768;
4652
4823
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user" && !isMobile){
@@ -4664,14 +4835,11 @@ async function lookupToAmisPicker(field, readonly, ctx){
4664
4835
  pickerSchema.headerToolbar.push(new_button);
4665
4836
  }
4666
4837
  pickerSchema.footerToolbar = refObjectConfig.enable_tree ? [] : getObjectFooterToolbar();
4667
- //TODO: 等待放大镜bug修复,if会去掉,始终显示放大镜
4668
- if(referenceTo.objectName != "space_users" || field.reference_to_field != "user"){
4669
- if (ctx.filterVisible !== false) {
4670
- pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
4671
- isLookup: true,
4672
- ...ctx
4673
- });
4674
- }
4838
+ if (ctx.filterVisible !== false) {
4839
+ pickerSchema.filter = await getObjectFilter(refObjectConfig, fields, {
4840
+ isLookup: true,
4841
+ ...ctx
4842
+ });
4675
4843
  }
4676
4844
  pickerSchema.data = Object.assign({}, pickerSchema.data, {
4677
4845
  "&": "$$",
@@ -4855,11 +5023,12 @@ async function lookupToAmisSelect(field, readonly, ctx){
4855
5023
  autoComplete: apiInfo,
4856
5024
  searchable: true,
4857
5025
  };
5026
+ //删除xlink:href中的rootUrl前缀,解决客户端svg为空的问题
4858
5027
  const select_menuTpl = `<span class='flex items-center mt-0.5'>
4859
5028
  <span role='img' aria-label='smile' class='anticon anticon-smile'>
4860
5029
  <span class='slds-icon_container slds-icon-standard-\${REPLACE(icon,'_','-')}'>
4861
5030
  <svg class='slds-icon slds-icon_x-small' aria-hidden='true'>
4862
- <use xlink:href='\${context.rootUrl}/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
5031
+ <use xlink:href='/assets/icons/standard-sprite/svg/symbols.svg#\${icon}'></use>
4863
5032
  </svg>
4864
5033
  </span>
4865
5034
  </span>
@@ -4917,8 +5086,10 @@ async function lookupToAmis(field, readonly, ctx){
4917
5086
 
4918
5087
  if(referenceTo.objectName === "space_users" && field.reference_to_field === "user"){
4919
5088
  if(ctx.idsDependOn || field.amis){
5089
+ // ids人员点选模式
4920
5090
  return await lookupToAmisIdsPicker(field, readonly, ctx);
4921
5091
  }
5092
+ // 左侧树右侧人员列表的下拉框模式,不再支持,而是执行下面的lookupToAmisPicker函数弹出选人窗口
4922
5093
  // return await lookupToAmisSelectUser(field, readonly, ctx);
4923
5094
  }
4924
5095
 
@@ -5019,6 +5190,9 @@ async function getIdsPickerSchema(field, readonly, ctx){
5019
5190
  top: top,
5020
5191
  ...ctx
5021
5192
  });
5193
+
5194
+ pickerSchema.affixHeader = false;
5195
+
5022
5196
  }
5023
5197
 
5024
5198
  const data = {
@@ -5048,7 +5222,6 @@ async function getIdsPickerSchema(field, readonly, ctx){
5048
5222
  if(readonly){
5049
5223
  data.tpl = await getLookupTpl(field, ctx);
5050
5224
  }
5051
-
5052
5225
  return data;
5053
5226
  }
5054
5227
 
@@ -5627,7 +5800,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
5627
5800
  convertData = {
5628
5801
  type: "editor",
5629
5802
  language: field.language,
5630
- // value: field.defaultValue || ''
5803
+ editorDidMount: new Function('editor', 'monaco', field.editorDidMount)
5631
5804
  };
5632
5805
  break;
5633
5806
  case 'toggle':
@@ -5648,7 +5821,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
5648
5821
  columnsTogglable: false,
5649
5822
  strictMode:false,
5650
5823
  affixHeader: false, // 是否固定表头, 不固定表头, 否则form有y轴滚动条时, 表头会跟随滚动条滚动.
5651
- // needConfirm: true, 此属性设置为false后,导致table不能编辑。
5824
+ needConfirm: false,
5652
5825
  editable: !readonly,
5653
5826
  addable: !readonly,
5654
5827
  removable: !readonly,
@@ -5878,6 +6051,12 @@ function getReadonlyFormAdaptor(object, fields){
5878
6051
  // })
5879
6052
 
5880
6053
  return `
6054
+ if(payload.data.data.length === 0){
6055
+ return {
6056
+ status: 2,
6057
+ msg: "无法找到记录"
6058
+ }
6059
+ }
5881
6060
  if(payload.data.data){
5882
6061
  var data = payload.data.data[0];
5883
6062
  var gridAndObjectFieldsName = ${JSON.stringify(gridAndObjectFieldsName)};
@@ -6002,12 +6181,12 @@ function getScriptForRewriteValueForFileFields(fields){
6002
6181
  });
6003
6182
  }
6004
6183
  }else{
6005
- data[item] = {
6184
+ data[item] = [{
6006
6185
  value: fileFieldValue,
6007
6186
  name: fileFieldDisplayValue.name,
6008
6187
  url: fileFieldDisplayValue.url + "?download=true",
6009
6188
  state: "uploaded"
6010
- };
6189
+ }];
6011
6190
  }
6012
6191
  }
6013
6192
  })
@@ -6025,7 +6204,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
6025
6204
 
6026
6205
  return {
6027
6206
  method: "post",
6028
- url: getApi$2(),
6207
+ url: getApi$2() + '&objectName=${objectName}' ,
6029
6208
  // sendOn: "!!this.recordId",
6030
6209
  cache: API_CACHE,
6031
6210
  requestAdaptor: `
@@ -6331,7 +6510,7 @@ async function getObjectCRUD(objectSchema, fields, options){
6331
6510
  }),
6332
6511
  filter: options.filterVisible !== false && await getObjectFilter(objectSchema, fields, options),
6333
6512
  };
6334
- if(options.formFactor !== 'SMALL'){
6513
+ if(options.formFactor !== 'SMALL' || ["split"].indexOf(options.displayAs) == -1){
6335
6514
  Object.assign(bodyProps, {
6336
6515
  bulkActions: options.bulkActions != false ? bulkActions : false
6337
6516
  });
@@ -6545,7 +6724,8 @@ async function getObjectForm(objectSchema, ctx){
6545
6724
  "eventName": `@data.changed.${objectSchema.name}`
6546
6725
  },
6547
6726
  "data": {
6548
- "objectName": `${objectSchema.name}`
6727
+ "objectName": `${objectSchema.name}`,
6728
+ "displayAs": "${displayAs}"
6549
6729
  }
6550
6730
  },
6551
6731
  {
@@ -6645,7 +6825,8 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6645
6825
  data: {
6646
6826
  objectName: "${event.data.__objectName}",
6647
6827
  record: "${event.data.__record}"
6648
- }
6828
+ },
6829
+ expression: "${event.data.__response.error != true}"
6649
6830
  },
6650
6831
  {
6651
6832
  "actionType": "setValue",
@@ -6653,7 +6834,8 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6653
6834
  value: {
6654
6835
  "recordLoaded": true,
6655
6836
  }
6656
- }
6837
+ },
6838
+ expression: "${event.data.__response.error != true}"
6657
6839
  }
6658
6840
  ]
6659
6841
  }
@@ -6661,6 +6843,21 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6661
6843
  }
6662
6844
  }
6663
6845
 
6846
+ /*
6847
+ * @Author: baozhoutao@steedos.com
6848
+ * @Date: 2022-08-04 10:42:49
6849
+ * @LastEditors: baozhoutao@steedos.com
6850
+ * @LastEditTime: 2022-08-25 10:28:47
6851
+ * @Description:
6852
+ */
6853
+ var config = {
6854
+ listView: {
6855
+ newRecordMode: 'modal',
6856
+ editRecordMode: 'modal',
6857
+ perPage: 20
6858
+ }
6859
+ };
6860
+
6664
6861
  async function getTableColumns(fields, options){
6665
6862
  const columns = [{name: '_index',type: 'text', width: 32, placeholder: ""}];
6666
6863
  for (const field of fields) {
@@ -6734,6 +6931,13 @@ async function getTableColumns(fields, options){
6734
6931
  }else if(field.type === 'html'){
6735
6932
  type = 'markdown';
6736
6933
  }
6934
+ let className = "";
6935
+ if(field.type === 'textarea'){
6936
+ className = 'min-w-56';
6937
+ }
6938
+ if(field.wrap === false){
6939
+ className += " whitespace-nowrap";
6940
+ }
6737
6941
  if(!field.hidden && !field.extra){
6738
6942
  columns.push(Object.assign({}, {
6739
6943
  name: field.name,
@@ -6744,7 +6948,7 @@ async function getTableColumns(fields, options){
6744
6948
  type: type,
6745
6949
  tpl: tpl,
6746
6950
  toggled: field.toggled,
6747
- className: field.type === 'textarea' ? 'min-w-56 whitespace-pre-wrap textarea' : "whitespace-nowrap",
6951
+ className,
6748
6952
  html: field.type === 'html' ? true : null
6749
6953
  // toggled: true
6750
6954
  }, field.amis, {name: field.name}));
@@ -6869,8 +7073,9 @@ async function getMobileTableColumns(fields, options){
6869
7073
  const url = getNameTplUrl(nameField, options);
6870
7074
 
6871
7075
  const columnLines = getMobileLines(tpls);
6872
-
6873
- columns.push({
7076
+
7077
+
7078
+ let column = {
6874
7079
  name: nameField.name,
6875
7080
  label: nameField.label,
6876
7081
  sortable: nameField.sortable,
@@ -6879,13 +7084,66 @@ async function getMobileTableColumns(fields, options){
6879
7084
  actionType: "link",
6880
7085
  link: url,
6881
7086
  innerClassName: "steedos-listview-item block text-gray-500",
6882
- body:{
7087
+ body: {
6883
7088
  "type": "wrapper",
6884
7089
  "body": columnLines,
6885
7090
  "size": "none",
6886
7091
  "className": "p-1"
6887
7092
  }
6888
- });
7093
+ };
7094
+
7095
+ if(options.objectName === 'cms_files'){
7096
+ if(window.Meteor?.isCordova){
7097
+ column = {
7098
+ ...column,
7099
+ actionType: "",
7100
+ link: "",
7101
+ onEvent: {
7102
+ "click": {
7103
+ "actions": [
7104
+ {
7105
+ "script": `
7106
+ let cms_url = "/api/files/files/"+event.data.versions[0]+"?download=true"
7107
+ Steedos.cordovaDownload(encodeURI(Steedos.absoluteUrl(cms_url)), event.data.name);
7108
+ `,
7109
+ "actionType": "custom"
7110
+ }
7111
+ ],
7112
+ "weight": 0
7113
+ }
7114
+ }
7115
+ };
7116
+ }else {
7117
+ column = {
7118
+ ...column,
7119
+ actionType: "",
7120
+ link: "",
7121
+ onEvent: {
7122
+ "click": {
7123
+ "actions": [
7124
+ {
7125
+ "args": {
7126
+ "api": {
7127
+ "url": url,
7128
+ "method": "get",
7129
+ "headers": {
7130
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
7131
+ }
7132
+ }
7133
+ },
7134
+ "actionType": "download"
7135
+ }
7136
+ ],
7137
+ "weight": 0
7138
+ }
7139
+ }
7140
+ };
7141
+ }
7142
+
7143
+ }
7144
+
7145
+ columns.push(column);
7146
+
6889
7147
 
6890
7148
  return columns;
6891
7149
  }
@@ -7004,7 +7262,7 @@ async function getTableSchema$1(fields, options){
7004
7262
  options = {};
7005
7263
  }
7006
7264
  let columns = [];
7007
- if(options.formFactor === 'SMALL'){
7265
+ if(options.formFactor === 'SMALL' || ["split"].indexOf(options.displayAs) > -1){
7008
7266
  columns = await getMobileTableColumns(fields, options);
7009
7267
  }
7010
7268
  else {
@@ -7207,7 +7465,11 @@ async function getTableApi(mainObject, fields, options){
7207
7465
  filters = systemFilters;
7208
7466
  };
7209
7467
  if(api.data.$self.additionalFilters){
7210
- userFilters.push(api.data.$self.additionalFilters)
7468
+ if(_.isString(api.data.$self.additionalFilters)){
7469
+ userFilters.push(eval(api.data.$self.additionalFilters))
7470
+ }else{
7471
+ userFilters.push(api.data.$self.additionalFilters)
7472
+ }
7211
7473
  }
7212
7474
 
7213
7475
  if(api.data.$self._isRelated){
@@ -7240,8 +7502,7 @@ async function getTableApi(mainObject, fields, options){
7240
7502
  if(_.isEmpty(filters)){
7241
7503
  filters = userFilters;
7242
7504
  }else{
7243
- filters.push('and');
7244
- filters.push(userFilters)
7505
+ filters = [filters, 'and', userFilters]
7245
7506
  }
7246
7507
  }
7247
7508
  api.data = {
@@ -7668,7 +7929,6 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7668
7929
  // ObjectForm会认作用域下的变量值
7669
7930
  // TODO: 待组件支持initValues属性后应该改掉,不应该通过data直接传值
7670
7931
  // TODO: 全天事件属性传入doc了但是没有生效,需要手动在ObjectForm中勾选全天事件
7671
- event.data = doc;
7672
7932
  const title = "新建 ${objectSchema.label}";
7673
7933
  doAction(
7674
7934
  {
@@ -7681,6 +7941,7 @@ async function getObjectCalendar(objectSchema, calendarOptions, options) {
7681
7941
  "type": "steedos-object-form",
7682
7942
  "objectApiName": "\${objectName}",
7683
7943
  "mode": "edit",
7944
+ "defaultData": doc,
7684
7945
  "onEvent": {
7685
7946
  "submitSucc": {
7686
7947
  "weight": 0,
@@ -7973,7 +8234,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
7973
8234
  * @Author: baozhoutao@steedos.com
7974
8235
  * @Date: 2022-07-05 15:55:39
7975
8236
  * @LastEditors: Please set LastEditors
7976
- * @LastEditTime: 2023-04-20 11:43:14
8237
+ * @LastEditTime: 2023-05-08 16:34:25
7977
8238
  * @Description:
7978
8239
  */
7979
8240
 
@@ -8227,7 +8488,7 @@ function getDefaultRelatedListProps(uiSchema, listName, ctx) {
8227
8488
  }
8228
8489
  function getRelatedListProps(uiSchema, listViewName, ctx) {
8229
8490
  if (ctx.columns) {
8230
- const sort = getListViewSort(ctx.sort);
8491
+ const sort = getListViewSort({sort: ctx.sort});
8231
8492
  let { filters , filtersFunction} = ctx;
8232
8493
  if(!filtersFunction && filters){
8233
8494
  filtersFunction = str2function(
@@ -8316,7 +8577,7 @@ async function getRelatedListSchema(
8316
8577
  * @Author: baozhoutao@steedos.com
8317
8578
  * @Date: 2022-07-05 15:55:39
8318
8579
  * @LastEditors: baozhoutao@steedos.com
8319
- * @LastEditTime: 2023-04-17 15:26:17
8580
+ * @LastEditTime: 2023-04-28 11:11:29
8320
8581
  * @Description:
8321
8582
  */
8322
8583
 
@@ -8514,6 +8775,9 @@ async function getListSchema(
8514
8775
  ctx = {}
8515
8776
  ) {
8516
8777
  const uiSchema = await getUISchema(objectName);
8778
+ if(!uiSchema){
8779
+ return {}
8780
+ }
8517
8781
  const listView = find(
8518
8782
  uiSchema.list_views,
8519
8783
  (listView, name) => {
@@ -9067,7 +9331,10 @@ async function getListviewInitSchema(objectApiName, listViewName, ctx) {
9067
9331
  const defaults = ctx.defaults || {};
9068
9332
  if(!defaults.headerSchema){
9069
9333
  //传入isListviewInit是区别于对象列表类型的微页面,即getListPageInitSchema函数中该属性为false
9070
- const headerSchema = await getObjectListHeader$1(uiSchema);
9334
+ const headerSchema = await getObjectListHeader$1(uiSchema, listViewName, {
9335
+ onlySecordLine: true,
9336
+ isListviewInit: true
9337
+ });
9071
9338
  defaults.headerSchema = headerSchema;
9072
9339
  }
9073
9340
  ctx.defaults = defaults;
@@ -11696,5 +11963,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
11696
11963
  };
11697
11964
  };
11698
11965
 
11699
- export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
11966
+ export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
11700
11967
  //# sourceMappingURL=index.esm.js.map