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