@steedos-widgets/amis-lib 1.2.9-beta.1 → 1.2.9

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
@@ -1,5 +1,5 @@
1
1
  import * as _$1 from 'lodash';
2
- import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, toArray, mergeWith, forEach, isBoolean, omitBy, isNil, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, toArray, mergeWith, map, forEach, isBoolean, omitBy, isNil, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
3
3
  import { Router as Router$1, getSteedosAuth as getSteedosAuth$1, lookupToAmis as lookupToAmis$1, fetchAPI as fetchAPI$1 } from '@steedos-widgets/amis-lib';
4
4
  import isPlainObject from 'lodash/isPlainObject';
5
5
 
@@ -2238,7 +2238,7 @@ const getListViewItemButtons = async (uiSchema, ctx)=>{
2238
2238
  return listButtons;
2239
2239
  };
2240
2240
 
2241
- const getObjectRelatedListButtons = async (uiSchema, ctx)=>{
2241
+ const getObjectRelatedListButtons = (uiSchema, ctx)=>{
2242
2242
  // const buttons = getButtons(uiSchema, ctx);
2243
2243
  // const relatedListButtons = _.filter(buttons, (button) => {
2244
2244
  // if(button.objectName === 'cms_files'){
@@ -2525,6 +2525,67 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
2525
2525
  }
2526
2526
  };
2527
2527
 
2528
+ const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
2529
+ const buttons = getObjectRelatedListButtons(objectSchema, ctx);
2530
+ if(ctx.formFactor === 'SMALL'){
2531
+ return {
2532
+ "type": "button",
2533
+ "icon": "fa fa-angle-down",
2534
+ "onEvent": {
2535
+ "click": {
2536
+ "actions": [
2537
+ {
2538
+ "actionType": "drawer",
2539
+ "drawer": {
2540
+ "type": "drawer",
2541
+ "title": "操作",
2542
+ "body": [
2543
+ {
2544
+ "type": "button-group",
2545
+ "vertical": true,
2546
+ "tiled": true,
2547
+ "buttons": [
2548
+ ...___default.map(buttons, (button)=>{
2549
+ return {
2550
+ type: 'steedos-object-button',
2551
+ name: button.name,
2552
+ objectName: button.objectName,
2553
+ visibleOn: getButtonVisibleOn$1(button),
2554
+ className: `button_${button.name} w-full`
2555
+ }
2556
+ })
2557
+ ],
2558
+ "btnLevel": "enhance",
2559
+ "className": "w-full",
2560
+ "btnClassName": "w-full",
2561
+ "size": "lg"
2562
+ }
2563
+ ],
2564
+ "position": "bottom",
2565
+ "closeOnOutside": true,
2566
+ "resizable": false,
2567
+ "className": "buttons-drawer",
2568
+ "bodyClassName": "m-none p-none",
2569
+ "actions": []
2570
+ }
2571
+ }
2572
+ ]
2573
+ }
2574
+ }
2575
+ }
2576
+ }else {
2577
+ return ___default.map(buttons, (button) => {
2578
+ return {
2579
+ type: 'steedos-object-button',
2580
+ name: button.name,
2581
+ objectName: button.objectName,
2582
+ visibleOn: getButtonVisibleOn$1(button),
2583
+ className: `button_${button.name}`
2584
+ }
2585
+ });
2586
+ }
2587
+ };
2588
+
2528
2589
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2529
2590
  // const amisListViewId = `listview_${objectSchema.name}`;
2530
2591
  return {
@@ -2693,6 +2754,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2693
2754
  }
2694
2755
  }
2695
2756
  }
2757
+ filterForm.reset();
2696
2758
  listView.handleFilterSubmit(removedValues);
2697
2759
  const filterService = filterForm.context.getComponents().find(function(n){
2698
2760
  return n.props.type === "service";
@@ -3138,6 +3200,7 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
3138
3200
  "rightIcon": "fa fa-caret-down",
3139
3201
  "size": "sm",
3140
3202
  "hideCaret": true,
3203
+ "closeOnClick": true,
3141
3204
  "btnClassName": "!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none",
3142
3205
  "buttons": listViewButtonOptions
3143
3206
  }
@@ -3322,12 +3385,47 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3322
3385
  "type": "grid",
3323
3386
  "columns": [
3324
3387
  {
3325
- "body": {
3388
+ "body": [{
3389
+ "type": "service",
3390
+ "onEvent": {
3391
+ "@history_paths.changed": {
3392
+ "actions": [
3393
+ {
3394
+ "actionType": "reload"
3395
+ }
3396
+ ]
3397
+ }
3398
+ },
3399
+ "body":[{
3400
+ "type": "button",
3401
+ "visibleOn": "${window:innerWidth > 768 && window:historyPaths.length > 1}",
3402
+ "className":"flex mr-2",
3403
+ "onEvent": {
3404
+ "click": {
3405
+ "actions": [
3406
+ {
3407
+ "actionType": "custom",
3408
+ "script": "Steedos.goBack()"
3409
+ }
3410
+ ]
3411
+ }
3412
+ },
3413
+ "body": [
3414
+ {
3415
+ "type": "steedos-icon",
3416
+ "category": "utility",
3417
+ "name": "back",
3418
+ "colorVariant": "default",
3419
+ "className": "slds-button_icon slds-global-header__icon"
3420
+ }
3421
+ ]
3422
+ }]
3423
+ },{
3326
3424
  "type": "tpl",
3327
3425
  "className": "block",
3328
3426
  // "tpl": `<img class='slds-icon slds-icon_container slds-icon-standard-${standardIcon}' src='\${context.rootUrl}/unpkg.com/@salesforce-ux/design-system/assets/icons/standard/${icon}.svg'>`
3329
3427
  "tpl":`<svg class="slds-icon slds-icon_container slds-icon-standard-${standardIcon} slds-page-header__icon" aria-hidden="true"><use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#${icon}"></use></svg>`
3330
- },
3428
+ }],
3331
3429
  "md": "auto",
3332
3430
  "className": "",
3333
3431
  "columnClassName": "flex justify-center items-center"
@@ -3414,18 +3512,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3414
3512
  * @param {*} relatedObjectSchema 相关对象UISchema
3415
3513
  * @returns amisSchema
3416
3514
  */
3417
- async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel) {
3515
+ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel, ctx) {
3418
3516
  const { icon, label } = relatedObjectSchema;
3419
- const buttons = await getObjectRelatedListButtons(relatedObjectSchema, {});
3420
- let amisButtonsSchema = map(buttons, (button) => {
3421
- return {
3422
- type: 'steedos-object-button',
3423
- name: button.name,
3424
- objectName: button.objectName,
3425
- visibleOn: getButtonVisibleOn$1(button),
3426
- className: `button_${button.name}`
3427
- }
3428
- });
3517
+ let amisButtonsSchema = getObjectRecordDetailRelatedListButtonsSchemas(relatedObjectSchema, {formFactor: ctx.formFactor});
3429
3518
  const reg = new RegExp('_', 'g');
3430
3519
  const standardIcon = icon && icon.replace(reg, '-');
3431
3520
  const recordRelatedListHeader = {
@@ -3498,83 +3587,44 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
3498
3587
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
3499
3588
  }
3500
3589
 
3501
- const getDisplayAsButton = function(objectName, showDisplayAs){
3502
- let displayAs = Router$1.getTabDisplayAs(objectName);
3503
- let buttons = [
3504
- {
3505
- "type": "button",
3506
- "label": "表格",
3507
- "onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
3508
- "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
3509
- "rightIconClassName": "m-l-sm"
3510
- },
3511
- {
3512
- "type": "button",
3513
- "label": "分栏视图",
3514
- "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
3515
- "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
3516
- "rightIconClassName": "m-l-sm"
3590
+ const getExportExcelToolbarButtonSchema = ()=>{
3591
+ return {
3592
+ "type": "button",
3593
+ "icon": "fa fa-download",
3594
+ "align": "right",
3595
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3596
+ "tooltipPlacement": "bottom",
3597
+ "visibleOn": "${!isLookup && global.user.is_space_admin}",
3598
+ "tooltip": "导出Excel",
3599
+ "onEvent": {
3600
+ "click": {
3601
+ "weight": 0,
3602
+ "actions": [
3603
+ {
3604
+ "args": {
3605
+ "api": {
3606
+ "url": "${context.rootUrl}/api/record/export/${objectName}",
3607
+ "method": "get",
3608
+ "messages": {},
3609
+ "requestAdaptor": `${requestAdaptor$1()}`,
3610
+ "data": {
3611
+ "uiSchema": "${uiSchema}",
3612
+ "listName": "${listName}"
3613
+ },
3614
+ "headers": {
3615
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
3616
+ }
3617
+ }
3618
+ },
3619
+ "actionType": "download"
3620
+ }
3621
+ ]
3622
+ }
3623
+ }
3517
3624
  }
3518
- ];
3519
- return {
3520
- "type": "dropdown-button",
3521
- "icon": "fa fa-table-columns",
3522
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3523
- "align": "right",
3524
- "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
3525
- "buttons": [
3526
- {
3527
- "label": "显示为",
3528
- "children": buttons
3529
- }
3530
- ]
3531
- };
3532
3625
  };
3533
3626
 
3534
-
3535
-
3536
-
3537
- const onFieldsFilterToggleScript = `
3538
- const scope = event.context.scoped;
3539
- const filterForm = scope.getComponents().find(function(n){
3540
- return n.props.type === "form";
3541
- });
3542
- const filterService = filterForm.context.getComponents().find(function(n){
3543
- return n.props.type === "service";
3544
- });
3545
- // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
3546
- let resizeWindow = function(){
3547
- //触发amis crud 高度重算
3548
- setTimeout(()=>{
3549
- window.dispatchEvent(new Event("resize"))
3550
- }, 500);
3551
- }
3552
- let isMobile = Steedos.isMobile();
3553
- if(filterService.props.data.showFieldsFilter){
3554
- if(isMobile){
3555
- // 手机上只能通过取消按钮来关闭搜索栏
3556
- return;
3557
- }
3558
- let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
3559
- direction: "down",
3560
- name: "btn_filter_form_cancel"
3561
- });
3562
- buttonCancel.props.dispatchEvent('click', {}).then(function(){
3563
- resizeWindow();
3564
- });
3565
- }
3566
- else{
3567
- filterService.setData({showFieldsFilter: true});
3568
- resizeWindow();
3569
- if(isMobile){
3570
- // 手机端在显示搜索栏时隐藏刷新按钮
3571
- let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
3572
- crudService && crudService.setData({showFieldsFilter: true});
3573
- }
3574
- }
3575
- `;
3576
-
3577
- function getExportApiRequestAdaptorScript(){
3627
+ function requestAdaptor$1(){
3578
3628
  return `
3579
3629
  // 获取列表视图的属性
3580
3630
  let uiSchema = api.body.uiSchema;
@@ -3628,667 +3678,1101 @@ function getExportApiRequestAdaptorScript(){
3628
3678
  `
3629
3679
  }
3630
3680
 
3631
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
3632
- // console.log(`getObjectHeaderToolbar====>`, filterVisible)
3633
- const isMobile = window.innerWidth < 768;
3634
- if(isMobile){
3635
- showDisplayAs = false;
3636
- }
3637
- if(formFactor === 'SMALL'){
3638
- const onReloadScript = `
3639
- const scope = event.context.scoped;
3640
- var listView = scope.parent.getComponents().find(function(n){
3641
- return n.props.type === "crud";
3642
- });
3643
- listView.handleChangePage(1);
3644
- `;
3645
- return [
3646
- // "bulkActions",
3647
- ...(headerToolbarItems || []),
3648
- hiddenCount ? {} :{
3649
- "type": "tpl",
3650
- "tpl": "${count} 个项目"
3651
- },
3652
- {
3653
- // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
3681
+ const getNewListviewButtonSchema = ()=>{
3682
+ return {
3654
3683
  "type": "button",
3655
- "align": "right",
3656
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3657
- "label": "",
3658
- "icon": "fa fa-sync",
3659
- "visibleOn": "${!showFieldsFilter}",
3684
+ "label": "新建",
3660
3685
  "onEvent": {
3661
3686
  "click": {
3687
+ "weight": 0,
3662
3688
  "actions": [
3663
3689
  {
3664
- "actionType": "custom",
3665
- "script": onReloadScript
3690
+ "dialog": {
3691
+ "type": "dialog",
3692
+ "title": "新建 列表视图",
3693
+ "data": {
3694
+ "&": "$$",
3695
+ "all": "${uiSchema.list_views.all}",
3696
+ "list_view": "${uiSchema.list_views[listName]}",
3697
+ "appId": "${appId}",
3698
+ "global": "${global}",
3699
+ "targetObjectName": "${objectName}",
3700
+ },
3701
+ "body": [
3702
+ {
3703
+ "type": "steedos-object-form",
3704
+ "label": "对象表单",
3705
+ "objectApiName": "object_listviews",
3706
+ "recordId": "",
3707
+ "mode": "edit",
3708
+ "defaultData": {
3709
+ "&": "${list_view}",
3710
+ "name":"",
3711
+ "label":"",
3712
+ "filters":"",
3713
+ "shared":false
3714
+ },
3715
+ "fieldsExtend": fieldsExtend$4(),
3716
+ "fields": fields$1(),
3717
+ "onEvent": {
3718
+ "submitSucc": {
3719
+ "weight": 0,
3720
+ "actions": [
3721
+ {
3722
+ "args": {
3723
+ // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3724
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3725
+ "blank": false
3726
+ },
3727
+ "actionType": "url",
3728
+ }
3729
+ ]
3730
+ }
3731
+ },
3732
+ "messages": {
3733
+ "success": "成功",
3734
+ "failed": "失败"
3735
+ },
3736
+ }
3737
+ ],
3738
+ "showCloseButton": true,
3739
+ "showErrorMsg": true,
3740
+ "showLoading": true,
3741
+ "closeOnEsc": false,
3742
+ "dataMapSwitch": false,
3743
+ "size": "lg"
3744
+ },
3745
+ "actionType": "dialog"
3666
3746
  }
3667
3747
  ]
3668
3748
  }
3669
- },
3670
- },
3671
- filterVisible ? {
3672
- "label": "",
3673
- "icon": "fa fa-search",
3674
- "type": "button",
3675
- "badge": {
3676
- "offset": [
3677
- -5,
3678
- 1
3679
- ],
3680
- "size":8,
3681
- "animation": true,
3682
- "visibleOn": "${isFieldsFilterEmpty == false}"
3683
- },
3684
- "align": "right",
3685
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3686
- "onEvent": {
3687
- "click": {
3749
+ }
3750
+ }
3751
+ };
3752
+
3753
+ function fields$1(){
3754
+ return [
3755
+ "label",
3756
+ "name",
3757
+ "object_name",
3758
+ "filter_scope",
3759
+ "show_count",
3760
+ "columns.$.field",
3761
+ "columns.$.width",
3762
+ "sort.$.field_name",
3763
+ "sort.$.order",
3764
+ "filters",
3765
+ "mobile_columns.$.field",
3766
+ "searchable_fields.$.field",
3767
+ "is_system",
3768
+ "shared"
3769
+ ]
3770
+ }
3771
+
3772
+ function fieldsExtend$4(){
3773
+ return {
3774
+ "label": {
3775
+ "is_wide": true
3776
+ },
3777
+ "name": {
3778
+ "amis": {
3779
+ "hidden": true
3780
+ }
3781
+ },
3782
+ "object_name": {
3783
+ "amis": {
3784
+ "hidden": true
3785
+ }
3786
+ },
3787
+ "filter_scope": {
3788
+ "amis": {
3789
+ "hidden": true
3790
+ }
3791
+ },
3792
+ "columns": {
3793
+ "amis": {
3794
+ "hidden": true
3795
+ }
3796
+ },
3797
+ "filter_fields": {
3798
+ "amis": {
3799
+ "hidden": true
3800
+ }
3801
+ },
3802
+ "scrolling_mode": {
3803
+ "amis": {
3804
+ "hidden": true
3805
+ }
3806
+ },
3807
+ "sort": {
3808
+ "amis": {
3809
+ "hidden": true
3810
+ }
3811
+ },
3812
+ "show_count": {
3813
+ "amis": {
3814
+ "hidden": true
3815
+ }
3816
+ },
3817
+ "type": {
3818
+ "amis": {
3819
+ "hidden": true
3820
+ }
3821
+ },
3822
+ "shared": {
3823
+ "amis": {
3824
+ "visibleOn": "${global.user.is_space_admin}"
3825
+ }
3826
+ }
3827
+ }
3828
+ }
3829
+
3830
+ const getCopyListviewButtonSchema = ()=>{
3831
+ return {
3832
+ "type": "button",
3833
+ "label": "复制",
3834
+ "onEvent": {
3835
+ "click": {
3836
+ "weight": 0,
3688
3837
  "actions": [
3689
3838
  {
3690
- "actionType": "custom",
3691
- "script": onFieldsFilterToggleScript
3839
+ "dialog": {
3840
+ "type": "dialog",
3841
+ "title": "复制 列表视图",
3842
+ "data": {
3843
+ "&": "$$",
3844
+ "listName": "${listName}",
3845
+ "targetObjectName": "${objectName}",
3846
+ "list_view": "${uiSchema.list_views[listName]}",
3847
+ "appId": "${appId}",
3848
+ "global": "${global}"
3849
+ },
3850
+ "body": [
3851
+ {
3852
+ "type": "steedos-object-form",
3853
+ "label": "对象表单",
3854
+ "objectApiName": "object_listviews",
3855
+ "recordId": "",
3856
+ "mode": "edit",
3857
+ "defaultData": {
3858
+ "&": "${list_view}",
3859
+ "name":"",
3860
+ "label": "${list_view.label} 的副本",
3861
+ "shared":false
3862
+ },
3863
+ "fieldsExtend": fieldsExtend$3(),
3864
+ "fields": fields(),
3865
+ "onEvent": {
3866
+ "submitSucc": {
3867
+ "weight": 0,
3868
+ "actions": [
3869
+ {
3870
+ "args": {
3871
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3872
+ "blank": false
3873
+ },
3874
+ "actionType": "url",
3875
+ }
3876
+ ]
3877
+ }
3878
+ }
3879
+ }
3880
+ ],
3881
+ "showCloseButton": true,
3882
+ "showErrorMsg": true,
3883
+ "showLoading": true,
3884
+ "closeOnEsc": false,
3885
+ "dataMapSwitch": false,
3886
+ "size": "lg"
3887
+ },
3888
+ "actionType": "dialog"
3692
3889
  }
3693
3890
  ]
3694
3891
  }
3695
3892
  }
3696
- } : {},
3697
- getDisplayAsButton(mainObject?.name)
3893
+ }
3894
+ };
3895
+
3896
+ function fields(){
3897
+ return [
3898
+ "label",
3899
+ "name",
3900
+ "object_name",
3901
+ "filter_scope",
3902
+ "show_count",
3903
+ "columns.$.field",
3904
+ "columns.$.width",
3905
+ "sort.$.field_name",
3906
+ "sort.$.order",
3907
+ "filters",
3908
+ "mobile_columns.$.field",
3909
+ "searchable_fields.$.field",
3910
+ "is_system",
3911
+ "shared"
3698
3912
  ]
3699
- }else {
3700
- return [
3701
- // "filter-toggler",
3702
- ...(headerToolbarItems || []),
3703
- "bulkActions",
3704
- {
3705
- "type": "columns-toggler",
3706
- "className": "hidden"
3707
- },
3708
- // {
3709
- // "type": "columns-toggler",
3710
- // "className": "mr-2"
3711
- // },
3712
- hiddenCount ? {} : {
3713
- "type": "tpl",
3714
- "tpl": "${count} 个项目"
3715
- },
3716
- {
3717
- "type": "reload",
3718
- "align": "right",
3719
- "tooltipPlacement": "bottom",
3720
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
3721
- },
3722
- {
3913
+ }
3914
+
3915
+ function fieldsExtend$3(){
3916
+ return {
3917
+ "label": {
3918
+ "is_wide": true
3919
+ },
3920
+ "name": {
3921
+ "is_wide": true,
3922
+ "amis": {
3923
+ "hidden": true
3924
+ }
3925
+ },
3926
+ "object_name": {
3927
+ "amis": {
3928
+ "hidden": true
3929
+ }
3930
+ },
3931
+ "filter_scope": {
3932
+ "amis": {
3933
+ "hidden": true
3934
+ }
3935
+ },
3936
+ "columns": {
3937
+ "amis": {
3938
+ "hidden": true
3939
+ }
3940
+ },
3941
+ "filter_fields": {
3942
+ "amis": {
3943
+ "hidden": true
3944
+ }
3945
+ },
3946
+ "scrolling_mode": {
3947
+ "amis": {
3948
+ "hidden": true
3949
+ }
3950
+ },
3951
+ "sort": {
3952
+ "amis": {
3953
+ "hidden": true
3954
+ }
3955
+ },
3956
+ "show_count": {
3957
+ "amis": {
3958
+ "hidden": true
3959
+ }
3960
+ },
3961
+ "type": {
3962
+ "amis": {
3963
+ "hidden": true
3964
+ }
3965
+ },
3966
+ "shared": {
3967
+ "amis": {
3968
+ "visibleOn": "${global.user.is_space_admin}"
3969
+ }
3970
+ }
3971
+ }
3972
+ }
3973
+
3974
+ const getRenameListviewButtonSchema = ()=>{
3975
+ return {
3723
3976
  "type": "button",
3724
- "label": "",
3725
- "icon": "fa fa-download",
3726
- "align": "right",
3727
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3728
- "tooltipPlacement": "bottom",
3729
- "visibleOn": "${!isLookup && global.user.is_space_admin}",
3730
- "tooltip": "导出Excel",
3977
+ "label": "重命名",
3978
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3731
3979
  "onEvent": {
3732
3980
  "click": {
3733
3981
  "weight": 0,
3734
3982
  "actions": [
3735
3983
  {
3736
- "args": {
3737
- "api": {
3738
- "url": "${context.rootUrl}/api/record/export/${objectName}",
3739
- "method": "get",
3740
- "messages": {},
3741
- "requestAdaptor": `${getExportApiRequestAdaptorScript()}`,
3742
- "data": {
3743
- "uiSchema": "${uiSchema}",
3744
- "listName": "${listName}"
3745
- },
3746
- "headers": {
3747
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
3984
+ "dialog": {
3985
+ "type": "dialog",
3986
+ "title": "重命名 列表视图",
3987
+ "data": {
3988
+ "targetObjectName": "${objectName}",
3989
+ "recordId": "${uiSchema.list_views[listName]._id}",
3990
+ "appId": "${appId}"
3991
+ },
3992
+ "body": [
3993
+ {
3994
+ "type": "steedos-object-form",
3995
+ "label": "对象表单",
3996
+ "objectApiName": "object_listviews",
3997
+ "recordId": "${recordId}",
3998
+ "mode": "edit",
3999
+ "fields": [
4000
+ "label"
4001
+ ],
4002
+ "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
4003
+ "onEvent": {
4004
+ "submitSucc": {
4005
+ "weight": 0,
4006
+ "actions": [
4007
+ {
4008
+ "args": {
4009
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
4010
+ "blank": false
4011
+ },
4012
+ "actionType": "url",
4013
+ },
4014
+ ]
4015
+ }
4016
+ }
3748
4017
  }
3749
- }
4018
+ ],
4019
+ "showCloseButton": true,
4020
+ "showErrorMsg": true,
4021
+ "showLoading": true,
4022
+ "size": "lg"
3750
4023
  },
3751
- "actionType": "download"
4024
+ "actionType": "dialog"
3752
4025
  }
3753
4026
  ]
3754
4027
  }
3755
4028
  }
3756
- },
3757
- filterVisible ? {
3758
- "label": "",
3759
- "icon": "fa fa-search",
4029
+ }
4030
+ };
4031
+
4032
+ const getSetListviewShareButtonSchema = ()=>{
4033
+ return {
3760
4034
  "type": "button",
3761
- "align": "right",
3762
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4035
+ "label": "共享设置",
4036
+ "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
3763
4037
  "onEvent": {
3764
4038
  "click": {
4039
+ "weight": 0,
3765
4040
  "actions": [
3766
4041
  {
3767
- "actionType": "custom",
3768
- "script": onFieldsFilterToggleScript
4042
+ "dialog": {
4043
+ "type": "dialog",
4044
+ "title": "共享设置",
4045
+ "data": {
4046
+ "recordId": "${uiSchema.list_views[listName]._id}",
4047
+ },
4048
+ "body": [
4049
+ {
4050
+ "type": "steedos-object-form",
4051
+ "label": "对象表单",
4052
+ "objectApiName": "object_listviews",
4053
+ "recordId": "${recordId}",
4054
+ "mode": "edit",
4055
+ "fields": [
4056
+ "shared"
4057
+ ]
4058
+ }
4059
+ ],
4060
+ "showCloseButton": true,
4061
+ "showErrorMsg": true,
4062
+ "showLoading": true,
4063
+ "closeOnEsc": false,
4064
+ "dataMapSwitch": false,
4065
+ "size": "md"
4066
+ },
4067
+ "actionType": "dialog"
3769
4068
  }
3770
4069
  ]
3771
4070
  }
3772
4071
  }
3773
- } : {},
3774
- {
3775
- "type": "dropdown-button",
3776
- "trigger": "click",
3777
- "icon": "fa fa-cog",
3778
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3779
- "align": "right",
3780
- "visibleOn": "${!isLookup}",
3781
- "buttons": [
3782
- {
3783
- "label": "列表视图操作",
3784
- "children": [
4072
+ }
4073
+ };
4074
+
4075
+ const getSetListviewFiltersButtonSchema = ()=>{
4076
+ return {
4077
+ "type": "button",
4078
+ "label": "过滤设置",
4079
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4080
+ "onEvent": {
4081
+ "click": {
4082
+ "weight": 0,
4083
+ "actions": [
3785
4084
  {
3786
- "type": "button",
3787
- "label": "新建",
3788
- "onEvent": {
3789
- "click": {
3790
- "weight": 0,
3791
- "actions": [
3792
- {
3793
- "dialog": {
3794
- "type": "dialog",
3795
- "title": "新建 列表视图",
3796
- "data": {
3797
- "&": "$$",
3798
- "all": "${uiSchema.list_views.all}",
3799
- "list_view": "${uiSchema.list_views[listName]}",
3800
- "appId": "${appId}",
3801
- "global": "${global}",
3802
- "targetObjectName": "${objectName}",
3803
- },
3804
- "body": [
4085
+ "dialog": {
4086
+ "type": "dialog",
4087
+ "title": "过滤设置",
4088
+ "data": {
4089
+ "targetObjectName": "${objectName}",
4090
+ "recordId": "${uiSchema.list_views[listName]._id}",
4091
+ "listName": "${listName}",
4092
+ "appId": "${appId}"
4093
+ },
4094
+ "body": [
4095
+ {
4096
+ "type": "steedos-object-form",
4097
+ "label": "对象表单",
4098
+ "objectApiName": "object_listviews",
4099
+ "recordId": "${recordId}",
4100
+ "mode": "edit",
4101
+ "fields": [
4102
+ "filters"
4103
+ ],
4104
+ "initApiAdaptor": initApiAdaptor$2(),
4105
+ "apiRequestAdaptor": apiRequestAdaptor$2(),
4106
+ "fieldsExtend": fieldsExtend$2(),
4107
+ "onEvent": {
4108
+ "submitSucc": {
4109
+ "weight": 0,
4110
+ "actions": [
3805
4111
  {
3806
- "type": "steedos-object-form",
3807
- "label": "对象表单",
3808
- "objectApiName": "object_listviews",
3809
- "recordId": "",
3810
- "mode": "edit",
3811
- "defaultData": {
3812
- "&": "${list_view}",
3813
- "name":"",
3814
- "label":"",
3815
- "filters":"",
3816
- "shared":false
3817
- },
3818
- "fieldsExtend": "{\n \"label\": {\n \"is_wide\": true\n },\n \"name\": {\n \"is_wide\": true,\n \"amis\": {\n \"hidden\": true\n }\n },\n \"object_name\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"filter_scope\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"columns\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"filter_fields\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"scrolling_mode\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"sort\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"show_count\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"type\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"shared\":{\n \"amis\":{\n \"visibleOn\":\"${global.user.is_space_admin}\"\n }\n}\n}",
3819
- "fields": [
3820
- "label",
3821
- "name",
3822
- "object_name",
3823
- "filter_scope",
3824
- "show_count",
3825
- "columns.$.field",
3826
- "columns.$.width",
3827
- "sort.$.field_name",
3828
- "sort.$.order",
3829
- "filters",
3830
- "mobile_columns.$.field",
3831
- "searchable_fields.$.field",
3832
- "is_system",
3833
- "shared"
3834
- ],
3835
- "onEvent": {
3836
- "submitSucc": {
3837
- "weight": 0,
3838
- "actions": [
3839
- {
3840
- "args": {
3841
- // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3842
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3843
- "blank": false
3844
- },
3845
- "actionType": "url",
3846
- }
3847
- ]
3848
- }
3849
- },
3850
- "messages": {
3851
- "success": "成功",
3852
- "failed": "失败"
4112
+ "args": {
4113
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4114
+ "blank": false
3853
4115
  },
4116
+ "actionType": "url",
3854
4117
  }
3855
- ],
3856
- "showCloseButton": true,
3857
- "showErrorMsg": true,
3858
- "showLoading": true,
3859
- "closeOnEsc": false,
3860
- "dataMapSwitch": false,
3861
- "size": "lg"
3862
- },
3863
- "actionType": "dialog"
4118
+ ]
4119
+ }
3864
4120
  }
3865
- ]
3866
- }
3867
- }
3868
- },
3869
- {
3870
- "type": "button",
3871
- "label": "复制",
3872
- "onEvent": {
3873
- "click": {
3874
- "weight": 0,
3875
- "actions": [
3876
- {
3877
- "dialog": {
3878
- "type": "dialog",
3879
- "title": "复制 列表视图",
3880
- "data": {
3881
- "&": "$$",
3882
- "listName": "${listName}",
3883
- "targetObjectName": "${objectName}",
3884
- "list_view": "${uiSchema.list_views[listName]}",
3885
- "appId": "${appId}",
3886
- "global": "${global}"
3887
- },
3888
- "body": [
3889
- {
3890
- "type": "steedos-object-form",
3891
- "label": "对象表单",
3892
- "objectApiName": "object_listviews",
3893
- "recordId": "",
3894
- "mode": "edit",
3895
- "fields": [
3896
- ],
3897
- "defaultData": {
3898
- "&": "${list_view}",
3899
- "name":"",
3900
- "label": "${list_view.label}的副本",
3901
- "shared":false
3902
- },
3903
- "fieldsExtend": "{\n \"label\": {\n \"is_wide\": true\n },\n \"name\": {\n \"is_wide\": true,\n \"amis\": {\n \"hidden\": true\n }\n },\n \"object_name\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"filter_scope\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"columns\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"filter_fields\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"scrolling_mode\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"sort\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"show_count\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"type\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"shared\":{\n \"amis\":{\n \"visibleOn\":\"${global.user.is_space_admin}\"\n }\n}\n}",
3904
- "fields": [
3905
- "label",
3906
- "name",
3907
- "object_name",
3908
- "filter_scope",
3909
- "show_count",
3910
- "columns.$.field",
3911
- "columns.$.width",
3912
- "sort.$.field_name",
3913
- "sort.$.order",
3914
- "filters",
3915
- "mobile_columns.$.field",
3916
- "searchable_fields.$.field",
3917
- "is_system",
3918
- "shared"
3919
- ],
3920
- "onEvent": {
3921
- "submitSucc": {
3922
- "weight": 0,
3923
- "actions": [
3924
- {
3925
- "args": {
3926
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3927
- "blank": false
3928
- },
3929
- "actionType": "url",
3930
- }
3931
- ]
3932
- }
3933
- }
3934
- }
3935
- ],
3936
- "showCloseButton": true,
3937
- "showErrorMsg": true,
3938
- "showLoading": true,
3939
- "closeOnEsc": false,
3940
- "dataMapSwitch": false,
3941
- "size": "lg"
3942
- },
3943
- "actionType": "dialog"
3944
- }
3945
- ]
3946
- }
3947
- }
3948
- },
3949
- {
3950
- "type": "button",
3951
- "label": "重命名",
3952
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3953
- "onEvent": {
3954
- "click": {
3955
- "weight": 0,
3956
- "actions": [
3957
- {
3958
- "dialog": {
3959
- "type": "dialog",
3960
- "title": "重命名 列表视图",
3961
- "data": {
3962
- "targetObjectName": "${objectName}",
3963
- "recordId": "${uiSchema.list_views[listName]._id}",
3964
- "appId": "${appId}"
3965
- },
3966
- "body": [
3967
- {
3968
- "type": "steedos-object-form",
3969
- "label": "对象表单",
3970
- "objectApiName": "object_listviews",
3971
- "recordId": "${recordId}",
3972
- "mode": "edit",
3973
- "fields": [
3974
- "label"
3975
- ],
3976
- "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
3977
- "onEvent": {
3978
- "submitSucc": {
3979
- "weight": 0,
3980
- "actions": [
3981
- {
3982
- "args": {
3983
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
3984
- "blank": false
3985
- },
3986
- "actionType": "url",
3987
- },
3988
- ]
3989
- }
3990
- }
3991
- }
3992
- ],
3993
- "showCloseButton": true,
3994
- "showErrorMsg": true,
3995
- "showLoading": true,
3996
- "size": "lg"
3997
- },
3998
- "actionType": "dialog"
3999
- }
4000
- ]
4001
- }
4002
- }
4003
- },
4004
- {
4005
- "type": "button",
4006
- "label": "共享设置",
4007
- "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
4008
- "onEvent": {
4009
- "click": {
4010
- "weight": 0,
4011
- "actions": [
4012
- {
4013
- "dialog": {
4014
- "type": "dialog",
4015
- "title": "共享设置",
4016
- "data": {
4017
- "recordId": "${uiSchema.list_views[listName]._id}",
4018
- },
4019
- "body": [
4020
- {
4021
- "type": "steedos-object-form",
4022
- "label": "对象表单",
4023
- "objectApiName": "object_listviews",
4024
- "recordId": "${recordId}",
4025
- "mode": "edit",
4026
- "fields": [
4027
- "shared"
4028
- ]
4029
- }
4030
- ],
4031
- "showCloseButton": true,
4032
- "showErrorMsg": true,
4033
- "showLoading": true,
4034
- "closeOnEsc": false,
4035
- "dataMapSwitch": false,
4036
- "size": "md"
4037
- },
4038
- "actionType": "dialog"
4039
- }
4040
- ]
4041
- }
4042
- }
4043
- },
4044
- {
4045
- "type": "button",
4046
- "label": "过滤设置",
4047
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4048
- "onEvent": {
4049
- "click": {
4050
- "weight": 0,
4051
- "actions": [
4052
- {
4053
- "dialog": {
4054
- "type": "dialog",
4055
- "title": "过滤设置",
4056
- "data": {
4057
- "targetObjectName": "${objectName}",
4058
- "objectName": "${objectName}",
4059
- "recordId": "${uiSchema.list_views[listName]._id}",
4060
- "listName": "${listName}",
4061
- "appId": "${appId}"
4062
- },
4063
- "body": [
4064
- {
4065
- "type": "steedos-object-form",
4066
- "label": "对象表单",
4067
- "objectApiName": "object_listviews",
4068
- "recordId": "${recordId}",
4069
- "mode": "edit",
4070
- "fields": [
4071
- "filters"
4072
- ],
4073
- "initApiRequestAdaptor": "",
4074
- "initApiAdaptor": "const recordId_tmp = api.body.recordId;\nlet data_tmp;\nif (recordId_tmp) {\n data_tmp = payload.data;\n // 数据格式转换\n if (data_tmp) {\n if (data_tmp.filters && lodash.isString(data_tmp.filters)) {\n try {\n data_tmp.filters = JSON.parse(data_tmp.filters);\n } catch (e) { }\n }\n\n if (data_tmp.filters && lodash.isString(data_tmp.filters)) {\n data_tmp._filters_type_controller = 'function';\n } else {\n data_tmp._filters_type_controller = 'conditions'\n }\n\n if (data_tmp._filters_type_controller === 'conditions') {\n data_tmp._filters_conditions = window.amisConvert.filtersToConditions(data_tmp.filters || []);\n data_tmp.filters = data_tmp._filters_conditions;\n } else {\n data_tmp._filters_function = data_tmp.filters;\n }\n }\n}\nfor (key in data_tmp) {\n if (data_tmp[key] === null) {\n delete data_tmp[key];\n }\n}\npayload.data = Object.assign(payload.data, data_tmp);\ndelete payload.extensions;",
4075
- "apiRequestAdaptor": "const recordId = api.body.recordId;\nif (formData._filters_type_controller === 'conditions' && formData._filters_conditions) {\n formData.filters = window.amisConvert.conditionsToFilters(formData.filters);\n} else {\n formData.filters = formData._filters_function || null;\n}\n\ndelete formData._filters_type_controller;\ndelete formData._filters_conditions;\ndelete formData._filters_function;\n// 字符串拼接(不支持ES6``语法)\nquery = 'mutation{record: ' + objectName + '__insert(doc: {__saveData}){_id}}';\nif (api.body.recordId) {\n query = 'mutation{record: ' + objectName + '__update(id: \"' + recordId + '\", doc: {__saveData}){_id}}';\n};\n__saveData = JSON.stringify(JSON.stringify(formData));\napi.data = { query: query.replace('{__saveData}', __saveData) };\n",
4076
- "fieldsExtend": "{\"filters\": {\n \"visible_on\": \"true\",\n \"amis\": {\n \"type\": \"condition-builder\",\n \"label\": \"条件组件\",\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${objectName}\",\n \"dataType\": \"json\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n }\n}",
4077
- "onEvent": {
4078
- "submitSucc": {
4079
- "weight": 0,
4080
- "actions": [
4081
- {
4082
- "args": {
4083
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4084
- "blank": false
4085
- },
4086
- "actionType": "url",
4087
- }
4088
- ]
4089
- }
4090
- }
4091
- }
4092
- ],
4093
- "showCloseButton": true,
4094
- "showErrorMsg": true,
4095
- "showLoading": true,
4096
- "closeOnEsc": false,
4097
- "dataMapSwitch": false,
4098
- "size": "lg"
4099
- },
4100
- "actionType": "dialog"
4101
- }
4102
- ]
4103
- }
4104
- }
4105
- },
4121
+ }
4122
+ ],
4123
+ "showCloseButton": true,
4124
+ "showErrorMsg": true,
4125
+ "showLoading": true,
4126
+ "closeOnEsc": false,
4127
+ "dataMapSwitch": false,
4128
+ "size": "lg"
4129
+ },
4130
+ "actionType": "dialog"
4131
+ }
4132
+ ]
4133
+ }
4134
+ }
4135
+ }
4136
+ };
4137
+
4138
+
4139
+ function initApiAdaptor$2(){
4140
+ return `
4141
+ const recordId_tmp = api.body.recordId;
4142
+ let data_tmp;
4143
+ if (recordId_tmp) {
4144
+ data_tmp = payload.data;
4145
+ // 数据格式转换
4146
+ if (data_tmp) {
4147
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4148
+ try {
4149
+ data_tmp.filters = JSON.parse(data_tmp.filters);
4150
+ } catch (e) { }
4151
+ }
4152
+
4153
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4154
+ data_tmp._filters_type_controller = 'function';
4155
+ } else {
4156
+ data_tmp._filters_type_controller = 'conditions'
4157
+ }
4158
+
4159
+ if (data_tmp._filters_type_controller === 'conditions') {
4160
+ data_tmp._filters_conditions = window.amisConvert.filtersToConditions(data_tmp.filters || []);
4161
+ data_tmp.filters = data_tmp._filters_conditions;
4162
+ } else {
4163
+ data_tmp._filters_function = data_tmp.filters;
4164
+ }
4165
+ }
4166
+ }
4167
+ for (key in data_tmp) {
4168
+ if (data_tmp[key] === null) {
4169
+ delete data_tmp[key];
4170
+ }
4171
+ }
4172
+ payload.data = Object.assign(payload.data, data_tmp);
4173
+ delete payload.extensions;
4174
+ return payload;
4175
+ `
4176
+ }
4177
+
4178
+ function apiRequestAdaptor$2(){
4179
+ return `
4180
+ const recordId = api.body.recordId;
4181
+ if (formData._filters_type_controller === 'conditions' && formData._filters_conditions) {
4182
+ formData.filters = window.amisConvert.conditionsToFilters(formData.filters);
4183
+ } else {
4184
+ formData.filters = formData._filters_function || null;
4185
+ }
4186
+
4187
+ delete formData._filters_type_controller;
4188
+ delete formData._filters_conditions;
4189
+ delete formData._filters_function;
4190
+
4191
+ query = 'mutation{record: ' + objectName + '__insert(doc: {__saveData}){_id}}';
4192
+ if (api.body.recordId) {
4193
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4194
+ };
4195
+ __saveData = JSON.stringify(JSON.stringify(formData));
4196
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4197
+ return api;
4198
+ `
4199
+ }
4200
+
4201
+ function fieldsExtend$2(){
4202
+ return {
4203
+ "filters": {
4204
+ "visible_on": "true",
4205
+ "amis": {
4206
+ "type": "condition-builder",
4207
+ "label": "条件组件1",
4208
+ "source": {
4209
+ "method": "get",
4210
+ "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${targetObjectName}",
4211
+ "dataType": "json",
4212
+ "headers": {
4213
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4214
+ }
4215
+ }
4216
+ }
4217
+ }
4218
+ }
4219
+ }
4220
+
4221
+ const getSetListviewColumnsButtonSchema = ()=>{
4222
+ return {
4223
+ "type": "button",
4224
+ "label": "显示的列",
4225
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4226
+ "onEvent": {
4227
+ "click": {
4228
+ "weight": 0,
4229
+ "actions": [
4106
4230
  {
4107
- "type": "button",
4108
- "label": "显示的列",
4109
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4110
- "onEvent": {
4111
- "click": {
4112
- "weight": 0,
4113
- "actions": [
4114
- {
4115
- "args": {},
4116
- "dialog": {
4117
- "type": "dialog",
4118
- "title": "显示的列",
4119
- "data": {
4120
- "&": "$$",
4121
- "targetObjectName": "${objectName}",
4122
- "objectName": "${objectName}",
4123
- "recordId": "${uiSchema.list_views[listName]._id}",
4124
- "listName": "${listName}",
4125
- "appId": "${appId}"
4126
- },
4127
- "body": [
4231
+ "args": {},
4232
+ "dialog": {
4233
+ "type": "dialog",
4234
+ "title": "显示的列",
4235
+ "data": {
4236
+ "&": "$$",
4237
+ "targetObjectName": "${objectName}",
4238
+ "recordId": "${uiSchema.list_views[listName]._id}",
4239
+ "listName": "${listName}",
4240
+ "appId": "${appId}"
4241
+ },
4242
+ "body": [
4243
+ {
4244
+ "type": "steedos-object-form",
4245
+ "label": "对象表单",
4246
+ "objectApiName": "object_listviews",
4247
+ "recordId": "${recordId}",
4248
+ "mode": "edit",
4249
+ "fieldsExtend": fieldsExtend$1(),
4250
+ "initApiAdaptor": initApiAdaptor$1(),
4251
+ "apiRequestAdaptor": apiRequestAdaptor$1(),
4252
+ "fields": [
4253
+ "columns",
4254
+ "mobile_columns"
4255
+ ],
4256
+ "onEvent": {
4257
+ "submitSucc": {
4258
+ "weight": 0,
4259
+ "actions": [
4128
4260
  {
4129
- "type": "steedos-object-form",
4130
- "label": "对象表单",
4131
- "objectApiName": "object_listviews",
4132
- "recordId": "${recordId}",
4133
- "mode": "edit",
4134
- "fieldsExtend": "{\n \"columns\": {\n \"amis\": {\n \"type\": \"transfer\",\n \"sortable\": true,\n \"searchable\": true,\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/fields/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n },\n \"mobile_columns\": {\n \"group\": \"手机端\",\n \"amis\": {\n \"type\": \"transfer\",\n \"sortable\": true,\n \"searchable\": true,\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/fields/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n }\n}",
4135
- "initApiAdaptor": "const recordId_tmp = api.body.recordId;\nlet columns_tmp = {}, mobile_columns_tmp = {};\nif (recordId_tmp) {\n columns_tmp = payload.data.columns;\n mobile_columns_tmp = payload.data.mobile_columns;\n if (columns_tmp) {\n columns_tmp = lodash.map(columns_tmp, 'field');\n }\n if (mobile_columns_tmp) {\n mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');\n }\n}\npayload.data.columns = columns_tmp;\npayload.data.mobile_columns = mobile_columns_tmp;\n\ndelete payload.extensions;\nreturn payload;",
4136
- "apiRequestAdaptor": "const formData_tmp = api.body.$;\nconst objectName_tmp = api.body.objectName;\nconst recordId_tmp = api.body.recordId;\n\nif (typeof formData_tmp.columns == 'string') {\n formData_tmp.columns = formData_tmp.columns?.split(',');\n}\nif (typeof formData_tmp.mobile_columns == 'string') {\n formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');\n}\n\n// 数据格式转换\nformData_tmp.columns = lodash.map(formData_tmp.columns, (item) => {\n return { field: item };\n});\nformData.mobile_columns = lodash.map(formData.mobile_columns, (item) => {\n return { field: item };\n});\n\n// 字符串拼接(不支持ES6语法)\nlet query_tmp = 'mutation{record: ' + objectName_tmp + '__insert(doc: {__saveData}){_id}}';\nif (api.body.recordId) {\n query_tmp = 'mutation{record: ' + objectName_tmp + '__update(id: \"' + recordId_tmp +'\", doc: {__saveData}){_id}}';\n};\ndelete formData_tmp._id;\nlet __saveData_tmp = JSON.stringify(JSON.stringify(formData_tmp));\napi.data = { query: query_tmp.replace('{__saveData}', __saveData_tmp) };\n\nreturn api;",
4137
- "fields": [
4138
- "columns",
4139
- "mobile_columns"
4140
- ],
4141
- "onEvent": {
4142
- "submitSucc": {
4143
- "weight": 0,
4144
- "actions": [
4145
- {
4146
- "args": {
4147
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4148
- "blank": false
4149
- },
4150
- "actionType": "url"
4151
- }
4152
- ]
4153
- }
4154
- }
4261
+ "args": {
4262
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4263
+ "blank": false
4264
+ },
4265
+ "actionType": "url"
4155
4266
  }
4156
- ],
4157
- "searchable": true,
4158
- "showCloseButton": true,
4159
- "showErrorMsg": true,
4160
- "showLoading": true,
4161
- "size": "lg"
4162
- },
4163
- "actionType": "dialog"
4267
+ ]
4268
+ }
4164
4269
  }
4165
- ]
4166
- }
4167
- }
4168
- },
4270
+ }
4271
+ ],
4272
+ "searchable": true,
4273
+ "showCloseButton": true,
4274
+ "showErrorMsg": true,
4275
+ "showLoading": true,
4276
+ "size": "lg"
4277
+ },
4278
+ "actionType": "dialog"
4279
+ }
4280
+ ]
4281
+ }
4282
+ }
4283
+ }
4284
+ };
4285
+
4286
+ function fieldsExtend$1(){
4287
+ return {
4288
+ "columns": {
4289
+ "amis": {
4290
+ "type": "transfer",
4291
+ "sortable": true,
4292
+ "searchable": true,
4293
+ "source": {
4294
+ "method": "get",
4295
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4296
+ "headers": {
4297
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4298
+ }
4299
+ }
4300
+ }
4301
+ },
4302
+ "mobile_columns": {
4303
+ "group": "手机端",
4304
+ "amis": {
4305
+ "type": "transfer",
4306
+ "sortable": true,
4307
+ "searchable": true,
4308
+ "source": {
4309
+ "method": "get",
4310
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4311
+ "headers": {
4312
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4313
+ }
4314
+ }
4315
+ }
4316
+ }
4317
+ }
4318
+ }
4319
+
4320
+ function initApiAdaptor$1(){
4321
+ return `
4322
+ const recordId_tmp = api.body.recordId;
4323
+ let columns_tmp = {}, mobile_columns_tmp = {};
4324
+ if (recordId_tmp) {
4325
+ columns_tmp = payload.data.columns;
4326
+ mobile_columns_tmp = payload.data.mobile_columns;
4327
+ if (columns_tmp) {
4328
+ columns_tmp = lodash.map(columns_tmp, 'field');
4329
+ }
4330
+ if (mobile_columns_tmp) {
4331
+ mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');
4332
+ }
4333
+ }
4334
+ payload.data.columns = columns_tmp;
4335
+ payload.data.mobile_columns = mobile_columns_tmp;
4336
+
4337
+ delete payload.extensions;
4338
+ return payload;
4339
+ `
4340
+ }
4341
+
4342
+ function apiRequestAdaptor$1(){
4343
+ return `
4344
+ const formData_tmp = api.body.$;
4345
+ const objectName_tmp = api.body.objectName;
4346
+ const recordId_tmp = api.body.recordId;
4347
+
4348
+ if (typeof formData_tmp.columns == 'string') {
4349
+ formData_tmp.columns = formData_tmp.columns?.split(',');
4350
+ }
4351
+ if (typeof formData_tmp.mobile_columns == 'string') {
4352
+ formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');
4353
+ }
4354
+
4355
+ // 数据格式转换
4356
+ formData_tmp.columns = lodash.map(formData_tmp.columns, (item) => {
4357
+ return { field: item };
4358
+ });
4359
+ formData.mobile_columns = lodash.map(formData.mobile_columns, (item) => {
4360
+ return { field: item };
4361
+ });
4362
+
4363
+ let query_tmp = 'mutation{record: ' + objectName_tmp + '__insert(doc: {__saveData}){_id}}';
4364
+ if (api.body.recordId) {
4365
+ query_tmp = 'mutation{record: ' + objectName_tmp + '__update(id: "' + recordId_tmp +'", doc: {__saveData}){_id}}';
4366
+ };
4367
+ delete formData_tmp._id;
4368
+ let __saveData_tmp = JSON.stringify(JSON.stringify(formData_tmp));
4369
+ api.data = { query: query_tmp.replace('{__saveData}', __saveData_tmp) };
4370
+
4371
+ return api;
4372
+ `
4373
+ }
4374
+
4375
+ const getSetListviewSortButtonSchema = ()=>{
4376
+ return {
4377
+ "type": "button",
4378
+ "label": "默认排序规则",
4379
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4380
+ "onEvent": {
4381
+ "click": {
4382
+ "weight": 0,
4383
+ "actions": [
4169
4384
  {
4170
- "type": "button",
4171
- "label": "默认排序规则",
4172
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4173
- "onEvent": {
4174
- "click": {
4175
- "weight": 0,
4176
- "actions": [
4177
- {
4178
- "dialog": {
4179
- "type": "dialog",
4180
- "title": "弹框标题",
4181
- "data": {
4182
- "&": "$$",
4183
- "targetObjectName": "${objectName}",
4184
- "objectName": "${objectName}",
4185
- "recordId": "${uiSchema.list_views[listName]._id}",
4186
- "listName": "${listName}",
4187
- "appId": "${appId}"
4188
- },
4189
- "body": [
4385
+ "dialog": {
4386
+ "type": "dialog",
4387
+ "title": "弹框标题",
4388
+ "data": {
4389
+ "&": "$$",
4390
+ "targetObjectName": "${objectName}",
4391
+ "recordId": "${uiSchema.list_views[listName]._id}",
4392
+ "listName": "${listName}",
4393
+ "appId": "${appId}"
4394
+ },
4395
+ "body": [
4396
+ {
4397
+ "type": "steedos-object-form",
4398
+ "label": "对象表单",
4399
+ "objectApiName": "object_listviews",
4400
+ "recordId": "${recordId}",
4401
+ "className": "",
4402
+ "id": "u:061f158b4c5a",
4403
+ "mode": "edit",
4404
+ "fields": [
4405
+ "sort",
4406
+ "sort.$.field_name",
4407
+ "sort.$.order"
4408
+ ],
4409
+ "onEvent": {
4410
+ "submitSucc": {
4411
+ "weight": 0,
4412
+ "actions": [
4190
4413
  {
4191
- "type": "steedos-object-form",
4192
- "label": "对象表单",
4193
- "objectApiName": "object_listviews",
4194
- "recordId": "${recordId}",
4195
- "className": "",
4196
- "id": "u:061f158b4c5a",
4197
- "mode": "edit",
4198
- "fields": [
4199
- "sort",
4200
- "sort.$.field_name",
4201
- "sort.$.order"
4202
- ],
4203
- "onEvent": {
4204
- "submitSucc": {
4205
- "weight": 0,
4206
- "actions": [
4207
- {
4208
- "args": {
4209
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4210
- "blank": false
4211
- },
4212
- "actionType": "url"
4213
- }
4214
- ]
4215
- }
4414
+ "args": {
4415
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4416
+ "blank": false
4216
4417
  },
4217
- "fieldsExtend": "{\n \"sort\": {\n \"amis\": {\n \"type\": \"tabs-transfer\",\n \"sortable\": true,\n \"searchable\": true,\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/sortFields/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n }\n}",
4218
- "initApiAdaptor": "let sort;\nif (recordId) {\n sort = payload.data.sort;\n //数据格式转换\n if (sort instanceof Array) {\n sort = lodash.map(sort, (item) => {\n return item.field_name + ':' + (item.order || 'asc')\n });\n }\n}\npayload.data.sort = sort;\ndelete payload.extensions;",
4219
- "apiRequestAdaptor": "const recordId = api.body.recordId;\n//数据格式转换\nif (typeof formData.sort == 'string') {\n formData.sort = formData.sort?.split(',');\n}\nformData.sort = lodash.map(formData.sort, (item) => {\n const arr = item.split(':');\n return { field_name: arr[0], order: arr[1] };\n});\nif (recordId) {\n query = 'mutation{record: ' + objectName + '__update(id: \"' + recordId + '\", doc: {__saveData}){_id}}';\n}\n__saveData = JSON.stringify(JSON.stringify(formData));\napi.data = { query: query.replace('{__saveData}', __saveData) };\n"
4418
+ "actionType": "url"
4220
4419
  }
4221
- ],
4222
- "showCloseButton": true,
4223
- "showErrorMsg": true,
4224
- "showLoading": true,
4225
- "id": "u:d3f6947b6acf",
4226
- "size": "lg"
4227
- },
4228
- "actionType": "dialog"
4229
- }
4230
- ]
4231
- }
4232
- }
4233
- },
4234
- {
4235
- "type": "button",
4236
- "label": "删除",
4237
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4238
- "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4239
- "onEvent": {
4240
- "click": {
4241
- "actions": [
4242
- {
4243
- "actionType": "ajax",
4244
- "args": {
4245
- "api": {
4246
- "url": "${context.rootUrl}/graphql",
4247
- "method": "post",
4248
- "headers": {
4249
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4250
- },
4251
- "data": {
4252
- "&": "$$",
4253
- "uiSchema": "${uiSchema}",
4254
- "recordId": "${uiSchema.list_views[listName]._id}"
4255
- },
4256
- "messages": {
4257
- "success": "删除成功"
4258
- },
4259
- "requestAdaptor": "const { recordId } = api.body;\nvar deleteArray = [];\nif (recordId) { deleteArray.push(`delete:object_listviews__delete(id: \"${recordId}\")`); }\napi.data = { query: `mutation{${deleteArray.join(',')}}` };\n return api;\n",
4260
- "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n}\nreturn payload;",
4261
- }
4420
+ ]
4262
4421
  }
4263
4422
  },
4264
- {
4265
- "actionType": "url",
4266
- "args": {
4267
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4268
- "blank": false
4269
- },
4270
- "expression": "data.delete == 1"
4271
- }
4272
- ]
4423
+ "fieldsExtend": fieldsExtend(),
4424
+ "initApiAdaptor": initApiAdaptor(),
4425
+ "apiRequestAdaptor": apiRequestAdaptor()
4426
+ }
4427
+ ],
4428
+ "showCloseButton": true,
4429
+ "showErrorMsg": true,
4430
+ "showLoading": true,
4431
+ "id": "u:d3f6947b6acf",
4432
+ "size": "lg"
4433
+ },
4434
+ "actionType": "dialog"
4435
+ }
4436
+ ]
4437
+ }
4438
+ }
4439
+ }
4440
+ };
4441
+
4442
+ function fieldsExtend(){
4443
+ return {
4444
+ "sort": {
4445
+ "amis": {
4446
+ "type": "tabs-transfer",
4447
+ "sortable": true,
4448
+ "searchable": true,
4449
+ "source": {
4450
+ "method": "get",
4451
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/sortFields/options",
4452
+ "headers": {
4453
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4454
+ }
4455
+ }
4456
+ }
4457
+ }
4458
+ }
4459
+ }
4460
+
4461
+ function initApiAdaptor(){
4462
+ return `
4463
+ let sort;
4464
+ if (recordId) {
4465
+ sort = payload.data.sort;
4466
+ //数据格式转换
4467
+ if (sort instanceof Array) {
4468
+ sort = lodash.map(sort, (item) => {
4469
+ return item.field_name + ':' + (item.order || 'asc')
4470
+ });
4471
+ }
4472
+ }
4473
+ payload.data.sort = sort;
4474
+ delete payload.extensions;
4475
+ return payload;
4476
+ `
4477
+ }
4478
+
4479
+ function apiRequestAdaptor(){
4480
+ return `
4481
+ const recordId = api.body.recordId;
4482
+ //数据格式转换
4483
+ if (typeof formData.sort == 'string') {
4484
+ formData.sort = formData.sort?.split(',');
4485
+ }
4486
+ formData.sort = lodash.map(formData.sort, (item) => {
4487
+ const arr = item.split(':');
4488
+ return { field_name: arr[0], order: arr[1] };
4489
+ });
4490
+ if (recordId) {
4491
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4492
+ }
4493
+ __saveData = JSON.stringify(JSON.stringify(formData));
4494
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4495
+ return api;
4496
+ `
4497
+ }
4498
+
4499
+ const getDeleteListviewButtonSchema = ()=>{
4500
+ return {
4501
+ "type": "button",
4502
+ "label": "删除",
4503
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4504
+ "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4505
+ "onEvent": {
4506
+ "click": {
4507
+ "actions": [
4508
+ {
4509
+ "actionType": "ajax",
4510
+ "args": {
4511
+ "api": {
4512
+ "url": "${context.rootUrl}/graphql",
4513
+ "method": "post",
4514
+ "headers": {
4515
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4516
+ },
4517
+ "data": {
4518
+ "&": "$$",
4519
+ "uiSchema": "${uiSchema}",
4520
+ "recordId": "${uiSchema.list_views[listName]._id}"
4521
+ },
4522
+ "messages": {
4523
+ "success": "删除成功"
4524
+ },
4525
+ "requestAdaptor": requestAdaptor(),
4526
+ "adaptor": adaptor(),
4273
4527
  }
4274
4528
  }
4275
4529
  },
4276
4530
  {
4277
- "type": "button",
4278
- "visibleOn": "${false}",
4279
- "label": "保存宽度(todo)"
4280
- },
4281
- // {
4282
- // type: 'steedos-object-button',
4283
- // name: 'standard_delete',
4284
- // objectName: 'test0321__c',
4285
- // // visibleOn: getButtonVisibleOn(button),
4286
- // className: 'antd-Button--default'
4287
- // }
4531
+ "actionType": "url",
4532
+ "args": {
4533
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4534
+ "blank": false
4535
+ },
4536
+ "expression": "data.delete == 1"
4537
+ }
4538
+ ]
4539
+ }
4540
+ }
4541
+ }
4542
+ };
4543
+
4544
+
4545
+ function requestAdaptor(){
4546
+ return `
4547
+ const { recordId } = api.body;
4548
+ var deleteArray = [];
4549
+ if (recordId) { deleteArray.push(\`delete:object_listviews__delete(id: "\${recordId}")\`); }
4550
+ api.data = { query: \`mutation{\${deleteArray.join(',')}}\` };
4551
+ return api;
4552
+ `
4553
+ }
4554
+
4555
+ function adaptor(){
4556
+ return `
4557
+ if (payload.errors) {
4558
+ payload.status = 2;
4559
+ payload.msg = payload.errors[0].message;
4560
+ }
4561
+ return payload;
4562
+ `
4563
+ }
4564
+
4565
+ const getSettingListviewToolbarButtonSchema = ()=>{
4566
+ return {
4567
+ "type": "dropdown-button",
4568
+ "trigger": "click",
4569
+ "icon": "fa fa-cog",
4570
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4571
+ "align": "right",
4572
+ "visibleOn": "${!isLookup}",
4573
+ "buttons": [
4574
+ {
4575
+ "label": "列表视图操作",
4576
+ "children": [
4577
+ getNewListviewButtonSchema(),
4578
+ getCopyListviewButtonSchema(),
4579
+ getRenameListviewButtonSchema(),
4580
+ getSetListviewShareButtonSchema(),
4581
+ getSetListviewFiltersButtonSchema(),
4582
+ getSetListviewColumnsButtonSchema(),
4583
+ getSetListviewSortButtonSchema(),
4584
+ getDeleteListviewButtonSchema()
4288
4585
  ]
4289
4586
  }
4290
4587
  ]
4588
+ }
4589
+ };
4590
+
4591
+ const getDisplayAsButton = function(objectName, showDisplayAs){
4592
+ let displayAs = Router$1.getTabDisplayAs(objectName);
4593
+ let buttons = [
4594
+ {
4595
+ "type": "button",
4596
+ "label": "表格",
4597
+ "onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
4598
+ "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
4599
+ "rightIconClassName": "m-l-sm"
4600
+ },
4601
+ {
4602
+ "type": "button",
4603
+ "label": "分栏视图",
4604
+ "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
4605
+ "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
4606
+ "rightIconClassName": "m-l-sm"
4607
+ }
4608
+ ];
4609
+ return {
4610
+ "type": "dropdown-button",
4611
+ "icon": "fa fa-table-columns",
4612
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4613
+ "align": "right",
4614
+ "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
4615
+ "buttons": [
4616
+ {
4617
+ "label": "显示为",
4618
+ "children": buttons
4619
+ }
4620
+ ]
4621
+ };
4622
+ };
4623
+
4624
+
4625
+ const onFieldsFilterToggleScript = `
4626
+ const scope = event.context.scoped;
4627
+ const filterForm = scope.getComponents().find(function(n){
4628
+ return n.props.type === "form";
4629
+ });
4630
+ const filterService = filterForm.context.getComponents().find(function(n){
4631
+ return n.props.type === "service";
4632
+ });
4633
+ // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
4634
+ let resizeWindow = function(){
4635
+ //触发amis crud 高度重算
4636
+ setTimeout(()=>{
4637
+ window.dispatchEvent(new Event("resize"))
4638
+ }, 500);
4639
+ }
4640
+ let isMobile = Steedos.isMobile();
4641
+ if(filterService.props.data.showFieldsFilter){
4642
+ if(isMobile){
4643
+ // 手机上只能通过取消按钮来关闭搜索栏
4644
+ return;
4645
+ }
4646
+ let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
4647
+ direction: "down",
4648
+ name: "btn_filter_form_cancel"
4649
+ });
4650
+ buttonCancel.props.dispatchEvent('click', {}).then(function(){
4651
+ resizeWindow();
4652
+ });
4653
+ }
4654
+ else{
4655
+ filterService.setData({showFieldsFilter: true});
4656
+ resizeWindow();
4657
+ if(isMobile){
4658
+ // 手机端在显示搜索栏时隐藏刷新按钮
4659
+ let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
4660
+ crudService && crudService.setData({showFieldsFilter: true});
4661
+ }
4662
+ }
4663
+ `;
4664
+
4665
+
4666
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
4667
+ // console.log(`getObjectHeaderToolbar====>`, filterVisible)
4668
+ const isMobile = window.innerWidth < 768;
4669
+ if(isMobile){
4670
+ showDisplayAs = false;
4671
+ }
4672
+ if(formFactor === 'SMALL'){
4673
+ const onReloadScript = `
4674
+ const scope = event.context.scoped;
4675
+ var listView = scope.parent.getComponents().find(function(n){
4676
+ return n.props.type === "crud";
4677
+ });
4678
+ listView.handleChangePage(1);
4679
+ `;
4680
+ return [
4681
+ // "bulkActions",
4682
+ ...(headerToolbarItems || []),
4683
+ hiddenCount ? {} :{
4684
+ "type": "tpl",
4685
+ "tpl": "${count} 个项目"
4686
+ },
4687
+ {
4688
+ // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
4689
+ "type": "button",
4690
+ "align": "right",
4691
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4692
+ "label": "",
4693
+ "icon": "fa fa-sync",
4694
+ "visibleOn": "${!showFieldsFilter}",
4695
+ "onEvent": {
4696
+ "click": {
4697
+ "actions": [
4698
+ {
4699
+ "actionType": "custom",
4700
+ "script": onReloadScript
4701
+ }
4702
+ ]
4703
+ }
4704
+ },
4705
+ },
4706
+ filterVisible ? {
4707
+ "label": "",
4708
+ "icon": "fa fa-search",
4709
+ "type": "button",
4710
+ "badge": {
4711
+ "offset": [
4712
+ -5,
4713
+ 1
4714
+ ],
4715
+ "size":8,
4716
+ "animation": true,
4717
+ "visibleOn": "${isFieldsFilterEmpty == false}"
4718
+ },
4719
+ "align": "right",
4720
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4721
+ "onEvent": {
4722
+ "click": {
4723
+ "actions": [
4724
+ {
4725
+ "actionType": "custom",
4726
+ "script": onFieldsFilterToggleScript
4727
+ }
4728
+ ]
4729
+ }
4730
+ }
4731
+ } : {},
4732
+ getDisplayAsButton(mainObject?.name)
4733
+ ]
4734
+ }else {
4735
+ return [
4736
+ // "filter-toggler",
4737
+ ...(headerToolbarItems || []),
4738
+ "bulkActions",
4739
+ {
4740
+ "type": "columns-toggler",
4741
+ "className": "hidden"
4742
+ },
4743
+ // {
4744
+ // "type": "columns-toggler",
4745
+ // "className": "mr-2"
4746
+ // },
4747
+ hiddenCount ? {} : {
4748
+ "type": "tpl",
4749
+ "tpl": "${count} 个项目"
4750
+ },
4751
+ {
4752
+ "type": "reload",
4753
+ "align": "right",
4754
+ "tooltipPlacement": "bottom",
4755
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
4291
4756
  },
4757
+ getExportExcelToolbarButtonSchema(),
4758
+ filterVisible ? {
4759
+ "label": "",
4760
+ "icon": "fa fa-search",
4761
+ "type": "button",
4762
+ "align": "right",
4763
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4764
+ "onEvent": {
4765
+ "click": {
4766
+ "actions": [
4767
+ {
4768
+ "actionType": "custom",
4769
+ "script": onFieldsFilterToggleScript
4770
+ }
4771
+ ]
4772
+ }
4773
+ }
4774
+ } : {},
4775
+ getSettingListviewToolbarButtonSchema(),
4292
4776
  getDisplayAsButton(showDisplayAs)
4293
4777
  // {
4294
4778
  // "type": "search-box",
@@ -4767,20 +5251,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
4767
5251
  }
4768
5252
  }
4769
5253
 
4770
- var searchableFilter = [];
4771
- _.each(selfData, (value, key)=>{
4772
- if(!_.isEmpty(value) || _.isBoolean(value)){
4773
- if(_.startsWith(key, '__searchable__between__')){
4774
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
4775
- }else if(_.startsWith(key, '__searchable__')){
4776
- if(_.isString(value)){
4777
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
4778
- }else{
4779
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
4780
- }
4781
- }
4782
- }
4783
- });
5254
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
4784
5255
 
4785
5256
  if(searchableFilter.length > 0){
4786
5257
  if(filters.length > 0 ){
@@ -6848,7 +7319,7 @@ async function getObjectCRUD(objectSchema, fields, options){
6848
7319
  id: `service_${id}`,
6849
7320
  name: `page`,
6850
7321
  data: {
6851
- // objectName: objectSchema.name,
7322
+ objectName: objectSchema.name,
6852
7323
  // _id: null,
6853
7324
  recordPermissions: objectSchema.permissions,
6854
7325
  uiSchema: objectSchema,
@@ -7666,20 +8137,8 @@ async function getTableApi(mainObject, fields, options){
7666
8137
  }else if(selfData.op === 'loadOptions' && selfData.value){
7667
8138
  userFilters = [["${valueField.name}", "=", selfData.value]];
7668
8139
  }
7669
- var searchableFilter = [];
7670
- _.each(selfData, (value, key)=>{
7671
- if(!_.isEmpty(value) || _.isBoolean(value)){
7672
- if(_.startsWith(key, '__searchable__between__')){
7673
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
7674
- }else if(_.startsWith(key, '__searchable__')){
7675
- if(_.isString(value)){
7676
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
7677
- }else{
7678
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
7679
- }
7680
- }
7681
- }
7682
- });
8140
+
8141
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
7683
8142
 
7684
8143
  if(searchableFilter.length > 0){
7685
8144
  if(userFilters.length > 0 ){
@@ -7950,20 +8409,7 @@ async function getCalendarApi(mainObject, fields, options) {
7950
8409
  }else if(selfData.op === 'loadOptions' && selfData.value){
7951
8410
  filters = [["${valueField.name}", "=", selfData.value]];
7952
8411
  }
7953
- var searchableFilter = [];
7954
- _.each(selfData, (value, key)=>{
7955
- if(!_.isEmpty(value) || _.isBoolean(value)){
7956
- if(_.startsWith(key, '__searchable__between__')){
7957
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
7958
- }else if(_.startsWith(key, '__searchable__')){
7959
- if(_.isString(value)){
7960
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
7961
- }else{
7962
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
7963
- }
7964
- }
7965
- }
7966
- });
8412
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
7967
8413
 
7968
8414
  if(searchableFilter.length > 0){
7969
8415
  if(filters.length > 0 ){
@@ -8489,7 +8935,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
8489
8935
  * @Author: baozhoutao@steedos.com
8490
8936
  * @Date: 2022-07-05 15:55:39
8491
8937
  * @LastEditors: Please set LastEditors
8492
- * @LastEditTime: 2023-05-08 16:34:25
8938
+ * @LastEditTime: 2023-05-17 09:09:33
8493
8939
  * @Description:
8494
8940
  */
8495
8941
 
@@ -8629,7 +9075,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
8629
9075
  // } else {
8630
9076
  // globalFilter = [`${relatedKey}`, "=", relatedValue];
8631
9077
  // }
8632
- const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
9078
+ const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
8633
9079
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
8634
9080
  const options = {
8635
9081
  globalFilter,
@@ -12218,5 +12664,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
12218
12664
  };
12219
12665
  };
12220
12666
 
12221
- 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 };
12667
+ 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, getObjectRecordDetailRelatedListButtonsSchemas, 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 };
12222
12668
  //# sourceMappingURL=index.esm.js.map