@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.umd.js CHANGED
@@ -2264,7 +2264,7 @@
2264
2264
  return listButtons;
2265
2265
  };
2266
2266
 
2267
- const getObjectRelatedListButtons = async (uiSchema, ctx)=>{
2267
+ const getObjectRelatedListButtons = (uiSchema, ctx)=>{
2268
2268
  // const buttons = getButtons(uiSchema, ctx);
2269
2269
  // const relatedListButtons = _.filter(buttons, (button) => {
2270
2270
  // if(button.objectName === 'cms_files'){
@@ -2551,6 +2551,67 @@
2551
2551
  }
2552
2552
  };
2553
2553
 
2554
+ const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
2555
+ const buttons = getObjectRelatedListButtons(objectSchema, ctx);
2556
+ if(ctx.formFactor === 'SMALL'){
2557
+ return {
2558
+ "type": "button",
2559
+ "icon": "fa fa-angle-down",
2560
+ "onEvent": {
2561
+ "click": {
2562
+ "actions": [
2563
+ {
2564
+ "actionType": "drawer",
2565
+ "drawer": {
2566
+ "type": "drawer",
2567
+ "title": "操作",
2568
+ "body": [
2569
+ {
2570
+ "type": "button-group",
2571
+ "vertical": true,
2572
+ "tiled": true,
2573
+ "buttons": [
2574
+ ...___default["default"].map(buttons, (button)=>{
2575
+ return {
2576
+ type: 'steedos-object-button',
2577
+ name: button.name,
2578
+ objectName: button.objectName,
2579
+ visibleOn: getButtonVisibleOn$1(button),
2580
+ className: `button_${button.name} w-full`
2581
+ }
2582
+ })
2583
+ ],
2584
+ "btnLevel": "enhance",
2585
+ "className": "w-full",
2586
+ "btnClassName": "w-full",
2587
+ "size": "lg"
2588
+ }
2589
+ ],
2590
+ "position": "bottom",
2591
+ "closeOnOutside": true,
2592
+ "resizable": false,
2593
+ "className": "buttons-drawer",
2594
+ "bodyClassName": "m-none p-none",
2595
+ "actions": []
2596
+ }
2597
+ }
2598
+ ]
2599
+ }
2600
+ }
2601
+ }
2602
+ }else {
2603
+ return ___default["default"].map(buttons, (button) => {
2604
+ return {
2605
+ type: 'steedos-object-button',
2606
+ name: button.name,
2607
+ objectName: button.objectName,
2608
+ visibleOn: getButtonVisibleOn$1(button),
2609
+ className: `button_${button.name}`
2610
+ }
2611
+ });
2612
+ }
2613
+ };
2614
+
2554
2615
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2555
2616
  // const amisListViewId = `listview_${objectSchema.name}`;
2556
2617
  return {
@@ -2719,6 +2780,7 @@
2719
2780
  }
2720
2781
  }
2721
2782
  }
2783
+ filterForm.reset();
2722
2784
  listView.handleFilterSubmit(removedValues);
2723
2785
  const filterService = filterForm.context.getComponents().find(function(n){
2724
2786
  return n.props.type === "service";
@@ -3164,6 +3226,7 @@
3164
3226
  "rightIcon": "fa fa-caret-down",
3165
3227
  "size": "sm",
3166
3228
  "hideCaret": true,
3229
+ "closeOnClick": true,
3167
3230
  "btnClassName": "!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none",
3168
3231
  "buttons": listViewButtonOptions
3169
3232
  }
@@ -3348,12 +3411,47 @@
3348
3411
  "type": "grid",
3349
3412
  "columns": [
3350
3413
  {
3351
- "body": {
3414
+ "body": [{
3415
+ "type": "service",
3416
+ "onEvent": {
3417
+ "@history_paths.changed": {
3418
+ "actions": [
3419
+ {
3420
+ "actionType": "reload"
3421
+ }
3422
+ ]
3423
+ }
3424
+ },
3425
+ "body":[{
3426
+ "type": "button",
3427
+ "visibleOn": "${window:innerWidth > 768 && window:historyPaths.length > 1}",
3428
+ "className":"flex mr-2",
3429
+ "onEvent": {
3430
+ "click": {
3431
+ "actions": [
3432
+ {
3433
+ "actionType": "custom",
3434
+ "script": "Steedos.goBack()"
3435
+ }
3436
+ ]
3437
+ }
3438
+ },
3439
+ "body": [
3440
+ {
3441
+ "type": "steedos-icon",
3442
+ "category": "utility",
3443
+ "name": "back",
3444
+ "colorVariant": "default",
3445
+ "className": "slds-button_icon slds-global-header__icon"
3446
+ }
3447
+ ]
3448
+ }]
3449
+ },{
3352
3450
  "type": "tpl",
3353
3451
  "className": "block",
3354
3452
  // "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'>`
3355
3453
  "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>`
3356
- },
3454
+ }],
3357
3455
  "md": "auto",
3358
3456
  "className": "",
3359
3457
  "columnClassName": "flex justify-center items-center"
@@ -3440,18 +3538,9 @@
3440
3538
  * @param {*} relatedObjectSchema 相关对象UISchema
3441
3539
  * @returns amisSchema
3442
3540
  */
3443
- async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel) {
3541
+ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel, ctx) {
3444
3542
  const { icon, label } = relatedObjectSchema;
3445
- const buttons = await getObjectRelatedListButtons(relatedObjectSchema, {});
3446
- let amisButtonsSchema = _$1.map(buttons, (button) => {
3447
- return {
3448
- type: 'steedos-object-button',
3449
- name: button.name,
3450
- objectName: button.objectName,
3451
- visibleOn: getButtonVisibleOn$1(button),
3452
- className: `button_${button.name}`
3453
- }
3454
- });
3543
+ let amisButtonsSchema = getObjectRecordDetailRelatedListButtonsSchemas(relatedObjectSchema, {formFactor: ctx.formFactor});
3455
3544
  const reg = new RegExp('_', 'g');
3456
3545
  const standardIcon = icon && icon.replace(reg, '-');
3457
3546
  const recordRelatedListHeader = {
@@ -3524,83 +3613,44 @@
3524
3613
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
3525
3614
  }
3526
3615
 
3527
- const getDisplayAsButton = function(objectName, showDisplayAs){
3528
- let displayAs = amisLib.Router.getTabDisplayAs(objectName);
3529
- let buttons = [
3530
- {
3531
- "type": "button",
3532
- "label": "表格",
3533
- "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');",
3534
- "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
3535
- "rightIconClassName": "m-l-sm"
3536
- },
3537
- {
3538
- "type": "button",
3539
- "label": "分栏视图",
3540
- "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
3541
- "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
3542
- "rightIconClassName": "m-l-sm"
3616
+ const getExportExcelToolbarButtonSchema = ()=>{
3617
+ return {
3618
+ "type": "button",
3619
+ "icon": "fa fa-download",
3620
+ "align": "right",
3621
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3622
+ "tooltipPlacement": "bottom",
3623
+ "visibleOn": "${!isLookup && global.user.is_space_admin}",
3624
+ "tooltip": "导出Excel",
3625
+ "onEvent": {
3626
+ "click": {
3627
+ "weight": 0,
3628
+ "actions": [
3629
+ {
3630
+ "args": {
3631
+ "api": {
3632
+ "url": "${context.rootUrl}/api/record/export/${objectName}",
3633
+ "method": "get",
3634
+ "messages": {},
3635
+ "requestAdaptor": `${requestAdaptor$1()}`,
3636
+ "data": {
3637
+ "uiSchema": "${uiSchema}",
3638
+ "listName": "${listName}"
3639
+ },
3640
+ "headers": {
3641
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
3642
+ }
3643
+ }
3644
+ },
3645
+ "actionType": "download"
3646
+ }
3647
+ ]
3648
+ }
3649
+ }
3543
3650
  }
3544
- ];
3545
- return {
3546
- "type": "dropdown-button",
3547
- "icon": "fa fa-table-columns",
3548
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3549
- "align": "right",
3550
- "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
3551
- "buttons": [
3552
- {
3553
- "label": "显示为",
3554
- "children": buttons
3555
- }
3556
- ]
3557
- };
3558
3651
  };
3559
3652
 
3560
-
3561
-
3562
-
3563
- const onFieldsFilterToggleScript = `
3564
- const scope = event.context.scoped;
3565
- const filterForm = scope.getComponents().find(function(n){
3566
- return n.props.type === "form";
3567
- });
3568
- const filterService = filterForm.context.getComponents().find(function(n){
3569
- return n.props.type === "service";
3570
- });
3571
- // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
3572
- let resizeWindow = function(){
3573
- //触发amis crud 高度重算
3574
- setTimeout(()=>{
3575
- window.dispatchEvent(new Event("resize"))
3576
- }, 500);
3577
- }
3578
- let isMobile = Steedos.isMobile();
3579
- if(filterService.props.data.showFieldsFilter){
3580
- if(isMobile){
3581
- // 手机上只能通过取消按钮来关闭搜索栏
3582
- return;
3583
- }
3584
- let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
3585
- direction: "down",
3586
- name: "btn_filter_form_cancel"
3587
- });
3588
- buttonCancel.props.dispatchEvent('click', {}).then(function(){
3589
- resizeWindow();
3590
- });
3591
- }
3592
- else{
3593
- filterService.setData({showFieldsFilter: true});
3594
- resizeWindow();
3595
- if(isMobile){
3596
- // 手机端在显示搜索栏时隐藏刷新按钮
3597
- let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
3598
- crudService && crudService.setData({showFieldsFilter: true});
3599
- }
3600
- }
3601
- `;
3602
-
3603
- function getExportApiRequestAdaptorScript(){
3653
+ function requestAdaptor$1(){
3604
3654
  return `
3605
3655
  // 获取列表视图的属性
3606
3656
  let uiSchema = api.body.uiSchema;
@@ -3654,667 +3704,1101 @@ else{
3654
3704
  `
3655
3705
  }
3656
3706
 
3657
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
3658
- // console.log(`getObjectHeaderToolbar====>`, filterVisible)
3659
- const isMobile = window.innerWidth < 768;
3660
- if(isMobile){
3661
- showDisplayAs = false;
3662
- }
3663
- if(formFactor === 'SMALL'){
3664
- const onReloadScript = `
3665
- const scope = event.context.scoped;
3666
- var listView = scope.parent.getComponents().find(function(n){
3667
- return n.props.type === "crud";
3668
- });
3669
- listView.handleChangePage(1);
3670
- `;
3671
- return [
3672
- // "bulkActions",
3673
- ...(headerToolbarItems || []),
3674
- hiddenCount ? {} :{
3675
- "type": "tpl",
3676
- "tpl": "${count} 个项目"
3677
- },
3678
- {
3679
- // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
3707
+ const getNewListviewButtonSchema = ()=>{
3708
+ return {
3680
3709
  "type": "button",
3681
- "align": "right",
3682
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3683
- "label": "",
3684
- "icon": "fa fa-sync",
3685
- "visibleOn": "${!showFieldsFilter}",
3710
+ "label": "新建",
3686
3711
  "onEvent": {
3687
3712
  "click": {
3713
+ "weight": 0,
3688
3714
  "actions": [
3689
3715
  {
3690
- "actionType": "custom",
3691
- "script": onReloadScript
3716
+ "dialog": {
3717
+ "type": "dialog",
3718
+ "title": "新建 列表视图",
3719
+ "data": {
3720
+ "&": "$$",
3721
+ "all": "${uiSchema.list_views.all}",
3722
+ "list_view": "${uiSchema.list_views[listName]}",
3723
+ "appId": "${appId}",
3724
+ "global": "${global}",
3725
+ "targetObjectName": "${objectName}",
3726
+ },
3727
+ "body": [
3728
+ {
3729
+ "type": "steedos-object-form",
3730
+ "label": "对象表单",
3731
+ "objectApiName": "object_listviews",
3732
+ "recordId": "",
3733
+ "mode": "edit",
3734
+ "defaultData": {
3735
+ "&": "${list_view}",
3736
+ "name":"",
3737
+ "label":"",
3738
+ "filters":"",
3739
+ "shared":false
3740
+ },
3741
+ "fieldsExtend": fieldsExtend$4(),
3742
+ "fields": fields$1(),
3743
+ "onEvent": {
3744
+ "submitSucc": {
3745
+ "weight": 0,
3746
+ "actions": [
3747
+ {
3748
+ "args": {
3749
+ // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3750
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3751
+ "blank": false
3752
+ },
3753
+ "actionType": "url",
3754
+ }
3755
+ ]
3756
+ }
3757
+ },
3758
+ "messages": {
3759
+ "success": "成功",
3760
+ "failed": "失败"
3761
+ },
3762
+ }
3763
+ ],
3764
+ "showCloseButton": true,
3765
+ "showErrorMsg": true,
3766
+ "showLoading": true,
3767
+ "closeOnEsc": false,
3768
+ "dataMapSwitch": false,
3769
+ "size": "lg"
3770
+ },
3771
+ "actionType": "dialog"
3692
3772
  }
3693
3773
  ]
3694
3774
  }
3695
- },
3696
- },
3697
- filterVisible ? {
3698
- "label": "",
3699
- "icon": "fa fa-search",
3700
- "type": "button",
3701
- "badge": {
3702
- "offset": [
3703
- -5,
3704
- 1
3705
- ],
3706
- "size":8,
3707
- "animation": true,
3708
- "visibleOn": "${isFieldsFilterEmpty == false}"
3709
- },
3710
- "align": "right",
3711
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3712
- "onEvent": {
3713
- "click": {
3714
- "actions": [
3715
- {
3716
- "actionType": "custom",
3717
- "script": onFieldsFilterToggleScript
3775
+ }
3776
+ }
3777
+ };
3778
+
3779
+ function fields$1(){
3780
+ return [
3781
+ "label",
3782
+ "name",
3783
+ "object_name",
3784
+ "filter_scope",
3785
+ "show_count",
3786
+ "columns.$.field",
3787
+ "columns.$.width",
3788
+ "sort.$.field_name",
3789
+ "sort.$.order",
3790
+ "filters",
3791
+ "mobile_columns.$.field",
3792
+ "searchable_fields.$.field",
3793
+ "is_system",
3794
+ "shared"
3795
+ ]
3796
+ }
3797
+
3798
+ function fieldsExtend$4(){
3799
+ return {
3800
+ "label": {
3801
+ "is_wide": true
3802
+ },
3803
+ "name": {
3804
+ "amis": {
3805
+ "hidden": true
3806
+ }
3807
+ },
3808
+ "object_name": {
3809
+ "amis": {
3810
+ "hidden": true
3811
+ }
3812
+ },
3813
+ "filter_scope": {
3814
+ "amis": {
3815
+ "hidden": true
3816
+ }
3817
+ },
3818
+ "columns": {
3819
+ "amis": {
3820
+ "hidden": true
3821
+ }
3822
+ },
3823
+ "filter_fields": {
3824
+ "amis": {
3825
+ "hidden": true
3826
+ }
3827
+ },
3828
+ "scrolling_mode": {
3829
+ "amis": {
3830
+ "hidden": true
3831
+ }
3832
+ },
3833
+ "sort": {
3834
+ "amis": {
3835
+ "hidden": true
3836
+ }
3837
+ },
3838
+ "show_count": {
3839
+ "amis": {
3840
+ "hidden": true
3841
+ }
3842
+ },
3843
+ "type": {
3844
+ "amis": {
3845
+ "hidden": true
3846
+ }
3847
+ },
3848
+ "shared": {
3849
+ "amis": {
3850
+ "visibleOn": "${global.user.is_space_admin}"
3851
+ }
3852
+ }
3853
+ }
3854
+ }
3855
+
3856
+ const getCopyListviewButtonSchema = ()=>{
3857
+ return {
3858
+ "type": "button",
3859
+ "label": "复制",
3860
+ "onEvent": {
3861
+ "click": {
3862
+ "weight": 0,
3863
+ "actions": [
3864
+ {
3865
+ "dialog": {
3866
+ "type": "dialog",
3867
+ "title": "复制 列表视图",
3868
+ "data": {
3869
+ "&": "$$",
3870
+ "listName": "${listName}",
3871
+ "targetObjectName": "${objectName}",
3872
+ "list_view": "${uiSchema.list_views[listName]}",
3873
+ "appId": "${appId}",
3874
+ "global": "${global}"
3875
+ },
3876
+ "body": [
3877
+ {
3878
+ "type": "steedos-object-form",
3879
+ "label": "对象表单",
3880
+ "objectApiName": "object_listviews",
3881
+ "recordId": "",
3882
+ "mode": "edit",
3883
+ "defaultData": {
3884
+ "&": "${list_view}",
3885
+ "name":"",
3886
+ "label": "${list_view.label} 的副本",
3887
+ "shared":false
3888
+ },
3889
+ "fieldsExtend": fieldsExtend$3(),
3890
+ "fields": fields(),
3891
+ "onEvent": {
3892
+ "submitSucc": {
3893
+ "weight": 0,
3894
+ "actions": [
3895
+ {
3896
+ "args": {
3897
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3898
+ "blank": false
3899
+ },
3900
+ "actionType": "url",
3901
+ }
3902
+ ]
3903
+ }
3904
+ }
3905
+ }
3906
+ ],
3907
+ "showCloseButton": true,
3908
+ "showErrorMsg": true,
3909
+ "showLoading": true,
3910
+ "closeOnEsc": false,
3911
+ "dataMapSwitch": false,
3912
+ "size": "lg"
3913
+ },
3914
+ "actionType": "dialog"
3718
3915
  }
3719
3916
  ]
3720
3917
  }
3721
3918
  }
3722
- } : {},
3723
- getDisplayAsButton(mainObject?.name)
3919
+ }
3920
+ };
3921
+
3922
+ function fields(){
3923
+ return [
3924
+ "label",
3925
+ "name",
3926
+ "object_name",
3927
+ "filter_scope",
3928
+ "show_count",
3929
+ "columns.$.field",
3930
+ "columns.$.width",
3931
+ "sort.$.field_name",
3932
+ "sort.$.order",
3933
+ "filters",
3934
+ "mobile_columns.$.field",
3935
+ "searchable_fields.$.field",
3936
+ "is_system",
3937
+ "shared"
3724
3938
  ]
3725
- }else {
3726
- return [
3727
- // "filter-toggler",
3728
- ...(headerToolbarItems || []),
3729
- "bulkActions",
3730
- {
3731
- "type": "columns-toggler",
3732
- "className": "hidden"
3733
- },
3734
- // {
3735
- // "type": "columns-toggler",
3736
- // "className": "mr-2"
3737
- // },
3738
- hiddenCount ? {} : {
3739
- "type": "tpl",
3740
- "tpl": "${count} 个项目"
3741
- },
3742
- {
3743
- "type": "reload",
3744
- "align": "right",
3745
- "tooltipPlacement": "bottom",
3746
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
3747
- },
3748
- {
3939
+ }
3940
+
3941
+ function fieldsExtend$3(){
3942
+ return {
3943
+ "label": {
3944
+ "is_wide": true
3945
+ },
3946
+ "name": {
3947
+ "is_wide": true,
3948
+ "amis": {
3949
+ "hidden": true
3950
+ }
3951
+ },
3952
+ "object_name": {
3953
+ "amis": {
3954
+ "hidden": true
3955
+ }
3956
+ },
3957
+ "filter_scope": {
3958
+ "amis": {
3959
+ "hidden": true
3960
+ }
3961
+ },
3962
+ "columns": {
3963
+ "amis": {
3964
+ "hidden": true
3965
+ }
3966
+ },
3967
+ "filter_fields": {
3968
+ "amis": {
3969
+ "hidden": true
3970
+ }
3971
+ },
3972
+ "scrolling_mode": {
3973
+ "amis": {
3974
+ "hidden": true
3975
+ }
3976
+ },
3977
+ "sort": {
3978
+ "amis": {
3979
+ "hidden": true
3980
+ }
3981
+ },
3982
+ "show_count": {
3983
+ "amis": {
3984
+ "hidden": true
3985
+ }
3986
+ },
3987
+ "type": {
3988
+ "amis": {
3989
+ "hidden": true
3990
+ }
3991
+ },
3992
+ "shared": {
3993
+ "amis": {
3994
+ "visibleOn": "${global.user.is_space_admin}"
3995
+ }
3996
+ }
3997
+ }
3998
+ }
3999
+
4000
+ const getRenameListviewButtonSchema = ()=>{
4001
+ return {
3749
4002
  "type": "button",
3750
- "label": "",
3751
- "icon": "fa fa-download",
3752
- "align": "right",
3753
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3754
- "tooltipPlacement": "bottom",
3755
- "visibleOn": "${!isLookup && global.user.is_space_admin}",
3756
- "tooltip": "导出Excel",
4003
+ "label": "重命名",
4004
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3757
4005
  "onEvent": {
3758
4006
  "click": {
3759
4007
  "weight": 0,
3760
4008
  "actions": [
3761
4009
  {
3762
- "args": {
3763
- "api": {
3764
- "url": "${context.rootUrl}/api/record/export/${objectName}",
3765
- "method": "get",
3766
- "messages": {},
3767
- "requestAdaptor": `${getExportApiRequestAdaptorScript()}`,
3768
- "data": {
3769
- "uiSchema": "${uiSchema}",
3770
- "listName": "${listName}"
3771
- },
3772
- "headers": {
3773
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4010
+ "dialog": {
4011
+ "type": "dialog",
4012
+ "title": "重命名 列表视图",
4013
+ "data": {
4014
+ "targetObjectName": "${objectName}",
4015
+ "recordId": "${uiSchema.list_views[listName]._id}",
4016
+ "appId": "${appId}"
4017
+ },
4018
+ "body": [
4019
+ {
4020
+ "type": "steedos-object-form",
4021
+ "label": "对象表单",
4022
+ "objectApiName": "object_listviews",
4023
+ "recordId": "${recordId}",
4024
+ "mode": "edit",
4025
+ "fields": [
4026
+ "label"
4027
+ ],
4028
+ "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
4029
+ "onEvent": {
4030
+ "submitSucc": {
4031
+ "weight": 0,
4032
+ "actions": [
4033
+ {
4034
+ "args": {
4035
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
4036
+ "blank": false
4037
+ },
4038
+ "actionType": "url",
4039
+ },
4040
+ ]
4041
+ }
4042
+ }
3774
4043
  }
3775
- }
4044
+ ],
4045
+ "showCloseButton": true,
4046
+ "showErrorMsg": true,
4047
+ "showLoading": true,
4048
+ "size": "lg"
3776
4049
  },
3777
- "actionType": "download"
4050
+ "actionType": "dialog"
3778
4051
  }
3779
4052
  ]
3780
4053
  }
3781
4054
  }
3782
- },
3783
- filterVisible ? {
3784
- "label": "",
3785
- "icon": "fa fa-search",
4055
+ }
4056
+ };
4057
+
4058
+ const getSetListviewShareButtonSchema = ()=>{
4059
+ return {
3786
4060
  "type": "button",
3787
- "align": "right",
3788
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4061
+ "label": "共享设置",
4062
+ "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
3789
4063
  "onEvent": {
3790
4064
  "click": {
4065
+ "weight": 0,
3791
4066
  "actions": [
3792
4067
  {
3793
- "actionType": "custom",
3794
- "script": onFieldsFilterToggleScript
4068
+ "dialog": {
4069
+ "type": "dialog",
4070
+ "title": "共享设置",
4071
+ "data": {
4072
+ "recordId": "${uiSchema.list_views[listName]._id}",
4073
+ },
4074
+ "body": [
4075
+ {
4076
+ "type": "steedos-object-form",
4077
+ "label": "对象表单",
4078
+ "objectApiName": "object_listviews",
4079
+ "recordId": "${recordId}",
4080
+ "mode": "edit",
4081
+ "fields": [
4082
+ "shared"
4083
+ ]
4084
+ }
4085
+ ],
4086
+ "showCloseButton": true,
4087
+ "showErrorMsg": true,
4088
+ "showLoading": true,
4089
+ "closeOnEsc": false,
4090
+ "dataMapSwitch": false,
4091
+ "size": "md"
4092
+ },
4093
+ "actionType": "dialog"
3795
4094
  }
3796
4095
  ]
3797
4096
  }
3798
4097
  }
3799
- } : {},
3800
- {
3801
- "type": "dropdown-button",
3802
- "trigger": "click",
3803
- "icon": "fa fa-cog",
3804
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3805
- "align": "right",
3806
- "visibleOn": "${!isLookup}",
3807
- "buttons": [
3808
- {
3809
- "label": "列表视图操作",
3810
- "children": [
4098
+ }
4099
+ };
4100
+
4101
+ const getSetListviewFiltersButtonSchema = ()=>{
4102
+ return {
4103
+ "type": "button",
4104
+ "label": "过滤设置",
4105
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4106
+ "onEvent": {
4107
+ "click": {
4108
+ "weight": 0,
4109
+ "actions": [
3811
4110
  {
3812
- "type": "button",
3813
- "label": "新建",
3814
- "onEvent": {
3815
- "click": {
3816
- "weight": 0,
3817
- "actions": [
3818
- {
3819
- "dialog": {
3820
- "type": "dialog",
3821
- "title": "新建 列表视图",
3822
- "data": {
3823
- "&": "$$",
3824
- "all": "${uiSchema.list_views.all}",
3825
- "list_view": "${uiSchema.list_views[listName]}",
3826
- "appId": "${appId}",
3827
- "global": "${global}",
3828
- "targetObjectName": "${objectName}",
3829
- },
3830
- "body": [
4111
+ "dialog": {
4112
+ "type": "dialog",
4113
+ "title": "过滤设置",
4114
+ "data": {
4115
+ "targetObjectName": "${objectName}",
4116
+ "recordId": "${uiSchema.list_views[listName]._id}",
4117
+ "listName": "${listName}",
4118
+ "appId": "${appId}"
4119
+ },
4120
+ "body": [
4121
+ {
4122
+ "type": "steedos-object-form",
4123
+ "label": "对象表单",
4124
+ "objectApiName": "object_listviews",
4125
+ "recordId": "${recordId}",
4126
+ "mode": "edit",
4127
+ "fields": [
4128
+ "filters"
4129
+ ],
4130
+ "initApiAdaptor": initApiAdaptor$2(),
4131
+ "apiRequestAdaptor": apiRequestAdaptor$2(),
4132
+ "fieldsExtend": fieldsExtend$2(),
4133
+ "onEvent": {
4134
+ "submitSucc": {
4135
+ "weight": 0,
4136
+ "actions": [
3831
4137
  {
3832
- "type": "steedos-object-form",
3833
- "label": "对象表单",
3834
- "objectApiName": "object_listviews",
3835
- "recordId": "",
3836
- "mode": "edit",
3837
- "defaultData": {
3838
- "&": "${list_view}",
3839
- "name":"",
3840
- "label":"",
3841
- "filters":"",
3842
- "shared":false
3843
- },
3844
- "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}",
3845
- "fields": [
3846
- "label",
3847
- "name",
3848
- "object_name",
3849
- "filter_scope",
3850
- "show_count",
3851
- "columns.$.field",
3852
- "columns.$.width",
3853
- "sort.$.field_name",
3854
- "sort.$.order",
3855
- "filters",
3856
- "mobile_columns.$.field",
3857
- "searchable_fields.$.field",
3858
- "is_system",
3859
- "shared"
3860
- ],
3861
- "onEvent": {
3862
- "submitSucc": {
3863
- "weight": 0,
3864
- "actions": [
3865
- {
3866
- "args": {
3867
- // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3868
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3869
- "blank": false
3870
- },
3871
- "actionType": "url",
3872
- }
3873
- ]
3874
- }
3875
- },
3876
- "messages": {
3877
- "success": "成功",
3878
- "failed": "失败"
4138
+ "args": {
4139
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4140
+ "blank": false
3879
4141
  },
4142
+ "actionType": "url",
3880
4143
  }
3881
- ],
3882
- "showCloseButton": true,
3883
- "showErrorMsg": true,
3884
- "showLoading": true,
3885
- "closeOnEsc": false,
3886
- "dataMapSwitch": false,
3887
- "size": "lg"
3888
- },
3889
- "actionType": "dialog"
4144
+ ]
4145
+ }
3890
4146
  }
3891
- ]
3892
- }
3893
- }
3894
- },
3895
- {
3896
- "type": "button",
3897
- "label": "复制",
3898
- "onEvent": {
3899
- "click": {
3900
- "weight": 0,
3901
- "actions": [
3902
- {
3903
- "dialog": {
3904
- "type": "dialog",
3905
- "title": "复制 列表视图",
3906
- "data": {
3907
- "&": "$$",
3908
- "listName": "${listName}",
3909
- "targetObjectName": "${objectName}",
3910
- "list_view": "${uiSchema.list_views[listName]}",
3911
- "appId": "${appId}",
3912
- "global": "${global}"
3913
- },
3914
- "body": [
3915
- {
3916
- "type": "steedos-object-form",
3917
- "label": "对象表单",
3918
- "objectApiName": "object_listviews",
3919
- "recordId": "",
3920
- "mode": "edit",
3921
- "fields": [
3922
- ],
3923
- "defaultData": {
3924
- "&": "${list_view}",
3925
- "name":"",
3926
- "label": "${list_view.label}的副本",
3927
- "shared":false
3928
- },
3929
- "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}",
3930
- "fields": [
3931
- "label",
3932
- "name",
3933
- "object_name",
3934
- "filter_scope",
3935
- "show_count",
3936
- "columns.$.field",
3937
- "columns.$.width",
3938
- "sort.$.field_name",
3939
- "sort.$.order",
3940
- "filters",
3941
- "mobile_columns.$.field",
3942
- "searchable_fields.$.field",
3943
- "is_system",
3944
- "shared"
3945
- ],
3946
- "onEvent": {
3947
- "submitSucc": {
3948
- "weight": 0,
3949
- "actions": [
3950
- {
3951
- "args": {
3952
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3953
- "blank": false
3954
- },
3955
- "actionType": "url",
3956
- }
3957
- ]
3958
- }
3959
- }
3960
- }
3961
- ],
3962
- "showCloseButton": true,
3963
- "showErrorMsg": true,
3964
- "showLoading": true,
3965
- "closeOnEsc": false,
3966
- "dataMapSwitch": false,
3967
- "size": "lg"
3968
- },
3969
- "actionType": "dialog"
3970
- }
3971
- ]
3972
- }
3973
- }
3974
- },
3975
- {
3976
- "type": "button",
3977
- "label": "重命名",
3978
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3979
- "onEvent": {
3980
- "click": {
3981
- "weight": 0,
3982
- "actions": [
3983
- {
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
- }
4017
- }
4018
- ],
4019
- "showCloseButton": true,
4020
- "showErrorMsg": true,
4021
- "showLoading": true,
4022
- "size": "lg"
4023
- },
4024
- "actionType": "dialog"
4025
- }
4026
- ]
4027
- }
4028
- }
4029
- },
4030
- {
4031
- "type": "button",
4032
- "label": "共享设置",
4033
- "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
4034
- "onEvent": {
4035
- "click": {
4036
- "weight": 0,
4037
- "actions": [
4038
- {
4039
- "dialog": {
4040
- "type": "dialog",
4041
- "title": "共享设置",
4042
- "data": {
4043
- "recordId": "${uiSchema.list_views[listName]._id}",
4044
- },
4045
- "body": [
4046
- {
4047
- "type": "steedos-object-form",
4048
- "label": "对象表单",
4049
- "objectApiName": "object_listviews",
4050
- "recordId": "${recordId}",
4051
- "mode": "edit",
4052
- "fields": [
4053
- "shared"
4054
- ]
4055
- }
4056
- ],
4057
- "showCloseButton": true,
4058
- "showErrorMsg": true,
4059
- "showLoading": true,
4060
- "closeOnEsc": false,
4061
- "dataMapSwitch": false,
4062
- "size": "md"
4063
- },
4064
- "actionType": "dialog"
4065
- }
4066
- ]
4067
- }
4068
- }
4069
- },
4070
- {
4071
- "type": "button",
4072
- "label": "过滤设置",
4073
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4074
- "onEvent": {
4075
- "click": {
4076
- "weight": 0,
4077
- "actions": [
4078
- {
4079
- "dialog": {
4080
- "type": "dialog",
4081
- "title": "过滤设置",
4082
- "data": {
4083
- "targetObjectName": "${objectName}",
4084
- "objectName": "${objectName}",
4085
- "recordId": "${uiSchema.list_views[listName]._id}",
4086
- "listName": "${listName}",
4087
- "appId": "${appId}"
4088
- },
4089
- "body": [
4090
- {
4091
- "type": "steedos-object-form",
4092
- "label": "对象表单",
4093
- "objectApiName": "object_listviews",
4094
- "recordId": "${recordId}",
4095
- "mode": "edit",
4096
- "fields": [
4097
- "filters"
4098
- ],
4099
- "initApiRequestAdaptor": "",
4100
- "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;",
4101
- "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",
4102
- "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}",
4103
- "onEvent": {
4104
- "submitSucc": {
4105
- "weight": 0,
4106
- "actions": [
4107
- {
4108
- "args": {
4109
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4110
- "blank": false
4111
- },
4112
- "actionType": "url",
4113
- }
4114
- ]
4115
- }
4116
- }
4117
- }
4118
- ],
4119
- "showCloseButton": true,
4120
- "showErrorMsg": true,
4121
- "showLoading": true,
4122
- "closeOnEsc": false,
4123
- "dataMapSwitch": false,
4124
- "size": "lg"
4125
- },
4126
- "actionType": "dialog"
4127
- }
4128
- ]
4129
- }
4130
- }
4131
- },
4147
+ }
4148
+ ],
4149
+ "showCloseButton": true,
4150
+ "showErrorMsg": true,
4151
+ "showLoading": true,
4152
+ "closeOnEsc": false,
4153
+ "dataMapSwitch": false,
4154
+ "size": "lg"
4155
+ },
4156
+ "actionType": "dialog"
4157
+ }
4158
+ ]
4159
+ }
4160
+ }
4161
+ }
4162
+ };
4163
+
4164
+
4165
+ function initApiAdaptor$2(){
4166
+ return `
4167
+ const recordId_tmp = api.body.recordId;
4168
+ let data_tmp;
4169
+ if (recordId_tmp) {
4170
+ data_tmp = payload.data;
4171
+ // 数据格式转换
4172
+ if (data_tmp) {
4173
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4174
+ try {
4175
+ data_tmp.filters = JSON.parse(data_tmp.filters);
4176
+ } catch (e) { }
4177
+ }
4178
+
4179
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4180
+ data_tmp._filters_type_controller = 'function';
4181
+ } else {
4182
+ data_tmp._filters_type_controller = 'conditions'
4183
+ }
4184
+
4185
+ if (data_tmp._filters_type_controller === 'conditions') {
4186
+ data_tmp._filters_conditions = window.amisConvert.filtersToConditions(data_tmp.filters || []);
4187
+ data_tmp.filters = data_tmp._filters_conditions;
4188
+ } else {
4189
+ data_tmp._filters_function = data_tmp.filters;
4190
+ }
4191
+ }
4192
+ }
4193
+ for (key in data_tmp) {
4194
+ if (data_tmp[key] === null) {
4195
+ delete data_tmp[key];
4196
+ }
4197
+ }
4198
+ payload.data = Object.assign(payload.data, data_tmp);
4199
+ delete payload.extensions;
4200
+ return payload;
4201
+ `
4202
+ }
4203
+
4204
+ function apiRequestAdaptor$2(){
4205
+ return `
4206
+ const recordId = api.body.recordId;
4207
+ if (formData._filters_type_controller === 'conditions' && formData._filters_conditions) {
4208
+ formData.filters = window.amisConvert.conditionsToFilters(formData.filters);
4209
+ } else {
4210
+ formData.filters = formData._filters_function || null;
4211
+ }
4212
+
4213
+ delete formData._filters_type_controller;
4214
+ delete formData._filters_conditions;
4215
+ delete formData._filters_function;
4216
+
4217
+ query = 'mutation{record: ' + objectName + '__insert(doc: {__saveData}){_id}}';
4218
+ if (api.body.recordId) {
4219
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4220
+ };
4221
+ __saveData = JSON.stringify(JSON.stringify(formData));
4222
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4223
+ return api;
4224
+ `
4225
+ }
4226
+
4227
+ function fieldsExtend$2(){
4228
+ return {
4229
+ "filters": {
4230
+ "visible_on": "true",
4231
+ "amis": {
4232
+ "type": "condition-builder",
4233
+ "label": "条件组件1",
4234
+ "source": {
4235
+ "method": "get",
4236
+ "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${targetObjectName}",
4237
+ "dataType": "json",
4238
+ "headers": {
4239
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4240
+ }
4241
+ }
4242
+ }
4243
+ }
4244
+ }
4245
+ }
4246
+
4247
+ const getSetListviewColumnsButtonSchema = ()=>{
4248
+ return {
4249
+ "type": "button",
4250
+ "label": "显示的列",
4251
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4252
+ "onEvent": {
4253
+ "click": {
4254
+ "weight": 0,
4255
+ "actions": [
4132
4256
  {
4133
- "type": "button",
4134
- "label": "显示的列",
4135
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4136
- "onEvent": {
4137
- "click": {
4138
- "weight": 0,
4139
- "actions": [
4140
- {
4141
- "args": {},
4142
- "dialog": {
4143
- "type": "dialog",
4144
- "title": "显示的列",
4145
- "data": {
4146
- "&": "$$",
4147
- "targetObjectName": "${objectName}",
4148
- "objectName": "${objectName}",
4149
- "recordId": "${uiSchema.list_views[listName]._id}",
4150
- "listName": "${listName}",
4151
- "appId": "${appId}"
4152
- },
4153
- "body": [
4257
+ "args": {},
4258
+ "dialog": {
4259
+ "type": "dialog",
4260
+ "title": "显示的列",
4261
+ "data": {
4262
+ "&": "$$",
4263
+ "targetObjectName": "${objectName}",
4264
+ "recordId": "${uiSchema.list_views[listName]._id}",
4265
+ "listName": "${listName}",
4266
+ "appId": "${appId}"
4267
+ },
4268
+ "body": [
4269
+ {
4270
+ "type": "steedos-object-form",
4271
+ "label": "对象表单",
4272
+ "objectApiName": "object_listviews",
4273
+ "recordId": "${recordId}",
4274
+ "mode": "edit",
4275
+ "fieldsExtend": fieldsExtend$1(),
4276
+ "initApiAdaptor": initApiAdaptor$1(),
4277
+ "apiRequestAdaptor": apiRequestAdaptor$1(),
4278
+ "fields": [
4279
+ "columns",
4280
+ "mobile_columns"
4281
+ ],
4282
+ "onEvent": {
4283
+ "submitSucc": {
4284
+ "weight": 0,
4285
+ "actions": [
4154
4286
  {
4155
- "type": "steedos-object-form",
4156
- "label": "对象表单",
4157
- "objectApiName": "object_listviews",
4158
- "recordId": "${recordId}",
4159
- "mode": "edit",
4160
- "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}",
4161
- "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;",
4162
- "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;",
4163
- "fields": [
4164
- "columns",
4165
- "mobile_columns"
4166
- ],
4167
- "onEvent": {
4168
- "submitSucc": {
4169
- "weight": 0,
4170
- "actions": [
4171
- {
4172
- "args": {
4173
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4174
- "blank": false
4175
- },
4176
- "actionType": "url"
4177
- }
4178
- ]
4179
- }
4180
- }
4287
+ "args": {
4288
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4289
+ "blank": false
4290
+ },
4291
+ "actionType": "url"
4181
4292
  }
4182
- ],
4183
- "searchable": true,
4184
- "showCloseButton": true,
4185
- "showErrorMsg": true,
4186
- "showLoading": true,
4187
- "size": "lg"
4188
- },
4189
- "actionType": "dialog"
4293
+ ]
4294
+ }
4190
4295
  }
4191
- ]
4192
- }
4193
- }
4194
- },
4296
+ }
4297
+ ],
4298
+ "searchable": true,
4299
+ "showCloseButton": true,
4300
+ "showErrorMsg": true,
4301
+ "showLoading": true,
4302
+ "size": "lg"
4303
+ },
4304
+ "actionType": "dialog"
4305
+ }
4306
+ ]
4307
+ }
4308
+ }
4309
+ }
4310
+ };
4311
+
4312
+ function fieldsExtend$1(){
4313
+ return {
4314
+ "columns": {
4315
+ "amis": {
4316
+ "type": "transfer",
4317
+ "sortable": true,
4318
+ "searchable": true,
4319
+ "source": {
4320
+ "method": "get",
4321
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4322
+ "headers": {
4323
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4324
+ }
4325
+ }
4326
+ }
4327
+ },
4328
+ "mobile_columns": {
4329
+ "group": "手机端",
4330
+ "amis": {
4331
+ "type": "transfer",
4332
+ "sortable": true,
4333
+ "searchable": true,
4334
+ "source": {
4335
+ "method": "get",
4336
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4337
+ "headers": {
4338
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4339
+ }
4340
+ }
4341
+ }
4342
+ }
4343
+ }
4344
+ }
4345
+
4346
+ function initApiAdaptor$1(){
4347
+ return `
4348
+ const recordId_tmp = api.body.recordId;
4349
+ let columns_tmp = {}, mobile_columns_tmp = {};
4350
+ if (recordId_tmp) {
4351
+ columns_tmp = payload.data.columns;
4352
+ mobile_columns_tmp = payload.data.mobile_columns;
4353
+ if (columns_tmp) {
4354
+ columns_tmp = lodash.map(columns_tmp, 'field');
4355
+ }
4356
+ if (mobile_columns_tmp) {
4357
+ mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');
4358
+ }
4359
+ }
4360
+ payload.data.columns = columns_tmp;
4361
+ payload.data.mobile_columns = mobile_columns_tmp;
4362
+
4363
+ delete payload.extensions;
4364
+ return payload;
4365
+ `
4366
+ }
4367
+
4368
+ function apiRequestAdaptor$1(){
4369
+ return `
4370
+ const formData_tmp = api.body.$;
4371
+ const objectName_tmp = api.body.objectName;
4372
+ const recordId_tmp = api.body.recordId;
4373
+
4374
+ if (typeof formData_tmp.columns == 'string') {
4375
+ formData_tmp.columns = formData_tmp.columns?.split(',');
4376
+ }
4377
+ if (typeof formData_tmp.mobile_columns == 'string') {
4378
+ formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');
4379
+ }
4380
+
4381
+ // 数据格式转换
4382
+ formData_tmp.columns = lodash.map(formData_tmp.columns, (item) => {
4383
+ return { field: item };
4384
+ });
4385
+ formData.mobile_columns = lodash.map(formData.mobile_columns, (item) => {
4386
+ return { field: item };
4387
+ });
4388
+
4389
+ let query_tmp = 'mutation{record: ' + objectName_tmp + '__insert(doc: {__saveData}){_id}}';
4390
+ if (api.body.recordId) {
4391
+ query_tmp = 'mutation{record: ' + objectName_tmp + '__update(id: "' + recordId_tmp +'", doc: {__saveData}){_id}}';
4392
+ };
4393
+ delete formData_tmp._id;
4394
+ let __saveData_tmp = JSON.stringify(JSON.stringify(formData_tmp));
4395
+ api.data = { query: query_tmp.replace('{__saveData}', __saveData_tmp) };
4396
+
4397
+ return api;
4398
+ `
4399
+ }
4400
+
4401
+ const getSetListviewSortButtonSchema = ()=>{
4402
+ return {
4403
+ "type": "button",
4404
+ "label": "默认排序规则",
4405
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4406
+ "onEvent": {
4407
+ "click": {
4408
+ "weight": 0,
4409
+ "actions": [
4195
4410
  {
4196
- "type": "button",
4197
- "label": "默认排序规则",
4198
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4199
- "onEvent": {
4200
- "click": {
4201
- "weight": 0,
4202
- "actions": [
4203
- {
4204
- "dialog": {
4205
- "type": "dialog",
4206
- "title": "弹框标题",
4207
- "data": {
4208
- "&": "$$",
4209
- "targetObjectName": "${objectName}",
4210
- "objectName": "${objectName}",
4211
- "recordId": "${uiSchema.list_views[listName]._id}",
4212
- "listName": "${listName}",
4213
- "appId": "${appId}"
4214
- },
4215
- "body": [
4411
+ "dialog": {
4412
+ "type": "dialog",
4413
+ "title": "弹框标题",
4414
+ "data": {
4415
+ "&": "$$",
4416
+ "targetObjectName": "${objectName}",
4417
+ "recordId": "${uiSchema.list_views[listName]._id}",
4418
+ "listName": "${listName}",
4419
+ "appId": "${appId}"
4420
+ },
4421
+ "body": [
4422
+ {
4423
+ "type": "steedos-object-form",
4424
+ "label": "对象表单",
4425
+ "objectApiName": "object_listviews",
4426
+ "recordId": "${recordId}",
4427
+ "className": "",
4428
+ "id": "u:061f158b4c5a",
4429
+ "mode": "edit",
4430
+ "fields": [
4431
+ "sort",
4432
+ "sort.$.field_name",
4433
+ "sort.$.order"
4434
+ ],
4435
+ "onEvent": {
4436
+ "submitSucc": {
4437
+ "weight": 0,
4438
+ "actions": [
4216
4439
  {
4217
- "type": "steedos-object-form",
4218
- "label": "对象表单",
4219
- "objectApiName": "object_listviews",
4220
- "recordId": "${recordId}",
4221
- "className": "",
4222
- "id": "u:061f158b4c5a",
4223
- "mode": "edit",
4224
- "fields": [
4225
- "sort",
4226
- "sort.$.field_name",
4227
- "sort.$.order"
4228
- ],
4229
- "onEvent": {
4230
- "submitSucc": {
4231
- "weight": 0,
4232
- "actions": [
4233
- {
4234
- "args": {
4235
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4236
- "blank": false
4237
- },
4238
- "actionType": "url"
4239
- }
4240
- ]
4241
- }
4440
+ "args": {
4441
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4442
+ "blank": false
4242
4443
  },
4243
- "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}",
4244
- "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;",
4245
- "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"
4444
+ "actionType": "url"
4246
4445
  }
4247
- ],
4248
- "showCloseButton": true,
4249
- "showErrorMsg": true,
4250
- "showLoading": true,
4251
- "id": "u:d3f6947b6acf",
4252
- "size": "lg"
4253
- },
4254
- "actionType": "dialog"
4255
- }
4256
- ]
4257
- }
4258
- }
4259
- },
4260
- {
4261
- "type": "button",
4262
- "label": "删除",
4263
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4264
- "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4265
- "onEvent": {
4266
- "click": {
4267
- "actions": [
4268
- {
4269
- "actionType": "ajax",
4270
- "args": {
4271
- "api": {
4272
- "url": "${context.rootUrl}/graphql",
4273
- "method": "post",
4274
- "headers": {
4275
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4276
- },
4277
- "data": {
4278
- "&": "$$",
4279
- "uiSchema": "${uiSchema}",
4280
- "recordId": "${uiSchema.list_views[listName]._id}"
4281
- },
4282
- "messages": {
4283
- "success": "删除成功"
4284
- },
4285
- "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",
4286
- "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n}\nreturn payload;",
4287
- }
4446
+ ]
4288
4447
  }
4289
4448
  },
4290
- {
4291
- "actionType": "url",
4292
- "args": {
4293
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4294
- "blank": false
4295
- },
4296
- "expression": "data.delete == 1"
4297
- }
4298
- ]
4449
+ "fieldsExtend": fieldsExtend(),
4450
+ "initApiAdaptor": initApiAdaptor(),
4451
+ "apiRequestAdaptor": apiRequestAdaptor()
4452
+ }
4453
+ ],
4454
+ "showCloseButton": true,
4455
+ "showErrorMsg": true,
4456
+ "showLoading": true,
4457
+ "id": "u:d3f6947b6acf",
4458
+ "size": "lg"
4459
+ },
4460
+ "actionType": "dialog"
4461
+ }
4462
+ ]
4463
+ }
4464
+ }
4465
+ }
4466
+ };
4467
+
4468
+ function fieldsExtend(){
4469
+ return {
4470
+ "sort": {
4471
+ "amis": {
4472
+ "type": "tabs-transfer",
4473
+ "sortable": true,
4474
+ "searchable": true,
4475
+ "source": {
4476
+ "method": "get",
4477
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/sortFields/options",
4478
+ "headers": {
4479
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4480
+ }
4481
+ }
4482
+ }
4483
+ }
4484
+ }
4485
+ }
4486
+
4487
+ function initApiAdaptor(){
4488
+ return `
4489
+ let sort;
4490
+ if (recordId) {
4491
+ sort = payload.data.sort;
4492
+ //数据格式转换
4493
+ if (sort instanceof Array) {
4494
+ sort = lodash.map(sort, (item) => {
4495
+ return item.field_name + ':' + (item.order || 'asc')
4496
+ });
4497
+ }
4498
+ }
4499
+ payload.data.sort = sort;
4500
+ delete payload.extensions;
4501
+ return payload;
4502
+ `
4503
+ }
4504
+
4505
+ function apiRequestAdaptor(){
4506
+ return `
4507
+ const recordId = api.body.recordId;
4508
+ //数据格式转换
4509
+ if (typeof formData.sort == 'string') {
4510
+ formData.sort = formData.sort?.split(',');
4511
+ }
4512
+ formData.sort = lodash.map(formData.sort, (item) => {
4513
+ const arr = item.split(':');
4514
+ return { field_name: arr[0], order: arr[1] };
4515
+ });
4516
+ if (recordId) {
4517
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4518
+ }
4519
+ __saveData = JSON.stringify(JSON.stringify(formData));
4520
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4521
+ return api;
4522
+ `
4523
+ }
4524
+
4525
+ const getDeleteListviewButtonSchema = ()=>{
4526
+ return {
4527
+ "type": "button",
4528
+ "label": "删除",
4529
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4530
+ "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4531
+ "onEvent": {
4532
+ "click": {
4533
+ "actions": [
4534
+ {
4535
+ "actionType": "ajax",
4536
+ "args": {
4537
+ "api": {
4538
+ "url": "${context.rootUrl}/graphql",
4539
+ "method": "post",
4540
+ "headers": {
4541
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4542
+ },
4543
+ "data": {
4544
+ "&": "$$",
4545
+ "uiSchema": "${uiSchema}",
4546
+ "recordId": "${uiSchema.list_views[listName]._id}"
4547
+ },
4548
+ "messages": {
4549
+ "success": "删除成功"
4550
+ },
4551
+ "requestAdaptor": requestAdaptor(),
4552
+ "adaptor": adaptor(),
4299
4553
  }
4300
4554
  }
4301
4555
  },
4302
4556
  {
4303
- "type": "button",
4304
- "visibleOn": "${false}",
4305
- "label": "保存宽度(todo)"
4306
- },
4307
- // {
4308
- // type: 'steedos-object-button',
4309
- // name: 'standard_delete',
4310
- // objectName: 'test0321__c',
4311
- // // visibleOn: getButtonVisibleOn(button),
4312
- // className: 'antd-Button--default'
4313
- // }
4557
+ "actionType": "url",
4558
+ "args": {
4559
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4560
+ "blank": false
4561
+ },
4562
+ "expression": "data.delete == 1"
4563
+ }
4564
+ ]
4565
+ }
4566
+ }
4567
+ }
4568
+ };
4569
+
4570
+
4571
+ function requestAdaptor(){
4572
+ return `
4573
+ const { recordId } = api.body;
4574
+ var deleteArray = [];
4575
+ if (recordId) { deleteArray.push(\`delete:object_listviews__delete(id: "\${recordId}")\`); }
4576
+ api.data = { query: \`mutation{\${deleteArray.join(',')}}\` };
4577
+ return api;
4578
+ `
4579
+ }
4580
+
4581
+ function adaptor(){
4582
+ return `
4583
+ if (payload.errors) {
4584
+ payload.status = 2;
4585
+ payload.msg = payload.errors[0].message;
4586
+ }
4587
+ return payload;
4588
+ `
4589
+ }
4590
+
4591
+ const getSettingListviewToolbarButtonSchema = ()=>{
4592
+ return {
4593
+ "type": "dropdown-button",
4594
+ "trigger": "click",
4595
+ "icon": "fa fa-cog",
4596
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4597
+ "align": "right",
4598
+ "visibleOn": "${!isLookup}",
4599
+ "buttons": [
4600
+ {
4601
+ "label": "列表视图操作",
4602
+ "children": [
4603
+ getNewListviewButtonSchema(),
4604
+ getCopyListviewButtonSchema(),
4605
+ getRenameListviewButtonSchema(),
4606
+ getSetListviewShareButtonSchema(),
4607
+ getSetListviewFiltersButtonSchema(),
4608
+ getSetListviewColumnsButtonSchema(),
4609
+ getSetListviewSortButtonSchema(),
4610
+ getDeleteListviewButtonSchema()
4314
4611
  ]
4315
4612
  }
4316
4613
  ]
4614
+ }
4615
+ };
4616
+
4617
+ const getDisplayAsButton = function(objectName, showDisplayAs){
4618
+ let displayAs = amisLib.Router.getTabDisplayAs(objectName);
4619
+ let buttons = [
4620
+ {
4621
+ "type": "button",
4622
+ "label": "表格",
4623
+ "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');",
4624
+ "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
4625
+ "rightIconClassName": "m-l-sm"
4626
+ },
4627
+ {
4628
+ "type": "button",
4629
+ "label": "分栏视图",
4630
+ "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
4631
+ "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
4632
+ "rightIconClassName": "m-l-sm"
4633
+ }
4634
+ ];
4635
+ return {
4636
+ "type": "dropdown-button",
4637
+ "icon": "fa fa-table-columns",
4638
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4639
+ "align": "right",
4640
+ "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
4641
+ "buttons": [
4642
+ {
4643
+ "label": "显示为",
4644
+ "children": buttons
4645
+ }
4646
+ ]
4647
+ };
4648
+ };
4649
+
4650
+
4651
+ const onFieldsFilterToggleScript = `
4652
+ const scope = event.context.scoped;
4653
+ const filterForm = scope.getComponents().find(function(n){
4654
+ return n.props.type === "form";
4655
+ });
4656
+ const filterService = filterForm.context.getComponents().find(function(n){
4657
+ return n.props.type === "service";
4658
+ });
4659
+ // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
4660
+ let resizeWindow = function(){
4661
+ //触发amis crud 高度重算
4662
+ setTimeout(()=>{
4663
+ window.dispatchEvent(new Event("resize"))
4664
+ }, 500);
4665
+ }
4666
+ let isMobile = Steedos.isMobile();
4667
+ if(filterService.props.data.showFieldsFilter){
4668
+ if(isMobile){
4669
+ // 手机上只能通过取消按钮来关闭搜索栏
4670
+ return;
4671
+ }
4672
+ let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
4673
+ direction: "down",
4674
+ name: "btn_filter_form_cancel"
4675
+ });
4676
+ buttonCancel.props.dispatchEvent('click', {}).then(function(){
4677
+ resizeWindow();
4678
+ });
4679
+ }
4680
+ else{
4681
+ filterService.setData({showFieldsFilter: true});
4682
+ resizeWindow();
4683
+ if(isMobile){
4684
+ // 手机端在显示搜索栏时隐藏刷新按钮
4685
+ let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
4686
+ crudService && crudService.setData({showFieldsFilter: true});
4687
+ }
4688
+ }
4689
+ `;
4690
+
4691
+
4692
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
4693
+ // console.log(`getObjectHeaderToolbar====>`, filterVisible)
4694
+ const isMobile = window.innerWidth < 768;
4695
+ if(isMobile){
4696
+ showDisplayAs = false;
4697
+ }
4698
+ if(formFactor === 'SMALL'){
4699
+ const onReloadScript = `
4700
+ const scope = event.context.scoped;
4701
+ var listView = scope.parent.getComponents().find(function(n){
4702
+ return n.props.type === "crud";
4703
+ });
4704
+ listView.handleChangePage(1);
4705
+ `;
4706
+ return [
4707
+ // "bulkActions",
4708
+ ...(headerToolbarItems || []),
4709
+ hiddenCount ? {} :{
4710
+ "type": "tpl",
4711
+ "tpl": "${count} 个项目"
4712
+ },
4713
+ {
4714
+ // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
4715
+ "type": "button",
4716
+ "align": "right",
4717
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4718
+ "label": "",
4719
+ "icon": "fa fa-sync",
4720
+ "visibleOn": "${!showFieldsFilter}",
4721
+ "onEvent": {
4722
+ "click": {
4723
+ "actions": [
4724
+ {
4725
+ "actionType": "custom",
4726
+ "script": onReloadScript
4727
+ }
4728
+ ]
4729
+ }
4730
+ },
4731
+ },
4732
+ filterVisible ? {
4733
+ "label": "",
4734
+ "icon": "fa fa-search",
4735
+ "type": "button",
4736
+ "badge": {
4737
+ "offset": [
4738
+ -5,
4739
+ 1
4740
+ ],
4741
+ "size":8,
4742
+ "animation": true,
4743
+ "visibleOn": "${isFieldsFilterEmpty == false}"
4744
+ },
4745
+ "align": "right",
4746
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4747
+ "onEvent": {
4748
+ "click": {
4749
+ "actions": [
4750
+ {
4751
+ "actionType": "custom",
4752
+ "script": onFieldsFilterToggleScript
4753
+ }
4754
+ ]
4755
+ }
4756
+ }
4757
+ } : {},
4758
+ getDisplayAsButton(mainObject?.name)
4759
+ ]
4760
+ }else {
4761
+ return [
4762
+ // "filter-toggler",
4763
+ ...(headerToolbarItems || []),
4764
+ "bulkActions",
4765
+ {
4766
+ "type": "columns-toggler",
4767
+ "className": "hidden"
4768
+ },
4769
+ // {
4770
+ // "type": "columns-toggler",
4771
+ // "className": "mr-2"
4772
+ // },
4773
+ hiddenCount ? {} : {
4774
+ "type": "tpl",
4775
+ "tpl": "${count} 个项目"
4776
+ },
4777
+ {
4778
+ "type": "reload",
4779
+ "align": "right",
4780
+ "tooltipPlacement": "bottom",
4781
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
4317
4782
  },
4783
+ getExportExcelToolbarButtonSchema(),
4784
+ filterVisible ? {
4785
+ "label": "",
4786
+ "icon": "fa fa-search",
4787
+ "type": "button",
4788
+ "align": "right",
4789
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4790
+ "onEvent": {
4791
+ "click": {
4792
+ "actions": [
4793
+ {
4794
+ "actionType": "custom",
4795
+ "script": onFieldsFilterToggleScript
4796
+ }
4797
+ ]
4798
+ }
4799
+ }
4800
+ } : {},
4801
+ getSettingListviewToolbarButtonSchema(),
4318
4802
  getDisplayAsButton(showDisplayAs)
4319
4803
  // {
4320
4804
  // "type": "search-box",
@@ -4793,20 +5277,7 @@ else{
4793
5277
  }
4794
5278
  }
4795
5279
 
4796
- var searchableFilter = [];
4797
- _.each(selfData, (value, key)=>{
4798
- if(!_.isEmpty(value) || _.isBoolean(value)){
4799
- if(_.startsWith(key, '__searchable__between__')){
4800
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
4801
- }else if(_.startsWith(key, '__searchable__')){
4802
- if(_.isString(value)){
4803
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
4804
- }else{
4805
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
4806
- }
4807
- }
4808
- }
4809
- });
5280
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
4810
5281
 
4811
5282
  if(searchableFilter.length > 0){
4812
5283
  if(filters.length > 0 ){
@@ -6874,7 +7345,7 @@ else{
6874
7345
  id: `service_${id}`,
6875
7346
  name: `page`,
6876
7347
  data: {
6877
- // objectName: objectSchema.name,
7348
+ objectName: objectSchema.name,
6878
7349
  // _id: null,
6879
7350
  recordPermissions: objectSchema.permissions,
6880
7351
  uiSchema: objectSchema,
@@ -7692,20 +8163,8 @@ else{
7692
8163
  }else if(selfData.op === 'loadOptions' && selfData.value){
7693
8164
  userFilters = [["${valueField.name}", "=", selfData.value]];
7694
8165
  }
7695
- var searchableFilter = [];
7696
- _.each(selfData, (value, key)=>{
7697
- if(!_.isEmpty(value) || _.isBoolean(value)){
7698
- if(_.startsWith(key, '__searchable__between__')){
7699
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
7700
- }else if(_.startsWith(key, '__searchable__')){
7701
- if(_.isString(value)){
7702
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
7703
- }else{
7704
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
7705
- }
7706
- }
7707
- }
7708
- });
8166
+
8167
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
7709
8168
 
7710
8169
  if(searchableFilter.length > 0){
7711
8170
  if(userFilters.length > 0 ){
@@ -7976,20 +8435,7 @@ else{
7976
8435
  }else if(selfData.op === 'loadOptions' && selfData.value){
7977
8436
  filters = [["${valueField.name}", "=", selfData.value]];
7978
8437
  }
7979
- var searchableFilter = [];
7980
- _.each(selfData, (value, key)=>{
7981
- if(!_.isEmpty(value) || _.isBoolean(value)){
7982
- if(_.startsWith(key, '__searchable__between__')){
7983
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
7984
- }else if(_.startsWith(key, '__searchable__')){
7985
- if(_.isString(value)){
7986
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
7987
- }else{
7988
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
7989
- }
7990
- }
7991
- }
7992
- });
8438
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
7993
8439
 
7994
8440
  if(searchableFilter.length > 0){
7995
8441
  if(filters.length > 0 ){
@@ -8515,7 +8961,7 @@ else{
8515
8961
  * @Author: baozhoutao@steedos.com
8516
8962
  * @Date: 2022-07-05 15:55:39
8517
8963
  * @LastEditors: Please set LastEditors
8518
- * @LastEditTime: 2023-05-08 16:34:25
8964
+ * @LastEditTime: 2023-05-17 09:09:33
8519
8965
  * @Description:
8520
8966
  */
8521
8967
 
@@ -8655,7 +9101,7 @@ else{
8655
9101
  // } else {
8656
9102
  // globalFilter = [`${relatedKey}`, "=", relatedValue];
8657
9103
  // }
8658
- const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
9104
+ const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
8659
9105
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
8660
9106
  const options = {
8661
9107
  globalFilter,
@@ -12302,6 +12748,7 @@ else{
12302
12748
  exports.getObjectListHeaderSecordLine = getObjectListHeaderSecordLine;
12303
12749
  exports.getObjectListViewButtonsSchemas = getObjectListViewButtonsSchemas;
12304
12750
  exports.getObjectRecordDetailHeader = getObjectRecordDetailHeader;
12751
+ exports.getObjectRecordDetailRelatedListButtonsSchemas = getObjectRecordDetailRelatedListButtonsSchemas;
12305
12752
  exports.getObjectRecordDetailRelatedListHeader = getObjectRecordDetailRelatedListHeader;
12306
12753
  exports.getObjectRelated = getObjectRelated;
12307
12754
  exports.getObjectRelatedList = getObjectRelatedList;