@steedos-widgets/amis-lib 1.2.8 → 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.
Files changed (25) hide show
  1. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  2. package/dist/index.cjs.js +1228 -753
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.esm.js +1229 -755
  5. package/dist/index.esm.js.map +1 -1
  6. package/dist/index.umd.js +1228 -753
  7. package/dist/index.umd.js.map +1 -1
  8. package/dist/types/lib/buttons.d.ts +44 -1
  9. package/dist/types/lib/converter/amis/fields/index.d.ts +1 -0
  10. package/dist/types/lib/converter/amis/fields_filter.d.ts +3 -1
  11. package/dist/types/lib/converter/amis/header.d.ts +80 -5
  12. package/dist/types/lib/converter/amis/index.d.ts +1 -0
  13. package/dist/types/lib/converter/amis/toolbar.d.ts +3 -1
  14. package/dist/types/lib/converter/amis/toolbars/export_excel.d.ts +32 -0
  15. package/dist/types/lib/converter/amis/toolbars/setting_listview/columns.d.ts +83 -0
  16. package/dist/types/lib/converter/amis/toolbars/setting_listview/copy.d.ts +112 -0
  17. package/dist/types/lib/converter/amis/toolbars/setting_listview/delete.d.ts +43 -0
  18. package/dist/types/lib/converter/amis/toolbars/setting_listview/filters.d.ts +68 -0
  19. package/dist/types/lib/converter/amis/toolbars/setting_listview/new.d.ts +116 -0
  20. package/dist/types/lib/converter/amis/toolbars/setting_listview/rename.d.ts +47 -0
  21. package/dist/types/lib/converter/amis/toolbars/setting_listview/share.d.ts +34 -0
  22. package/dist/types/lib/converter/amis/toolbars/setting_listview/sort.d.ts +69 -0
  23. package/dist/types/lib/converter/amis/toolbars/setting_listview.d.ts +509 -0
  24. package/dist/types/lib/objects.d.ts +36 -2
  25. package/package.json +2 -2
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 {
@@ -2603,11 +2664,11 @@
2603
2664
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
2604
2665
  }
2605
2666
  const selfData = api.body.$self;
2606
- const filterFormSearchableFields = selfData.filterFormSearchableFields;
2607
2667
  const uiSchema = selfData.uiSchema;
2608
2668
  const fields = uiSchema.fields;
2609
- const searchableFields = [];
2610
-
2669
+ const filterFormSearchableFields = (selfData.filterFormSearchableFields || []).filter(function(item){
2670
+ return !!fields[item]
2671
+ });
2611
2672
  const resolveAll = function(values){
2612
2673
  payload.data = {
2613
2674
  "body": values
@@ -2622,21 +2683,7 @@
2622
2683
  return Promise.all(filterFormSearchableFields.map(function (item) {
2623
2684
  const field = _.clone(fields[item]);
2624
2685
  if (
2625
- field && !_.includes(
2626
- [
2627
- "grid",
2628
- "avatar",
2629
- "image",
2630
- "object",
2631
- "[object]",
2632
- "[Object]",
2633
- "[grid]",
2634
- "[text]",
2635
- "audio",
2636
- "file",
2637
- ],
2638
- field.type
2639
- )
2686
+ field && window.isFieldTypeSearchable(field.type)
2640
2687
  ) {
2641
2688
  delete field.defaultValue;
2642
2689
  delete field.required;
@@ -2733,6 +2780,7 @@
2733
2780
  }
2734
2781
  }
2735
2782
  }
2783
+ filterForm.reset();
2736
2784
  listView.handleFilterSubmit(removedValues);
2737
2785
  const filterService = filterForm.context.getComponents().find(function(n){
2738
2786
  return n.props.type === "service";
@@ -2995,9 +3043,27 @@
2995
3043
  "headers": {
2996
3044
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
2997
3045
  },
2998
- "data": null,
3046
+ "data": {
3047
+ "$self": "$$"
3048
+ },
2999
3049
  "requestAdaptor": "",
3000
- "adaptor": ""
3050
+ "adaptor": `
3051
+ if(payload.errors){
3052
+ payload.status = 2;
3053
+ payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
3054
+ }
3055
+ const selfData = api.body.$self;
3056
+ const uiSchema = selfData.uiSchema;
3057
+ const fields = uiSchema.fields;
3058
+ const options = (payload.data?.options || []).filter(function(item){
3059
+ let field = fields[item.value];
3060
+ return !!field && window.isFieldTypeSearchable(field.type)
3061
+ });
3062
+ payload.data = {
3063
+ "options": options
3064
+ };
3065
+ return payload;
3066
+ `
3001
3067
  },
3002
3068
  "options": [],
3003
3069
  "required": true,
@@ -3160,6 +3226,7 @@
3160
3226
  "rightIcon": "fa fa-caret-down",
3161
3227
  "size": "sm",
3162
3228
  "hideCaret": true,
3229
+ "closeOnClick": true,
3163
3230
  "btnClassName": "!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none",
3164
3231
  "buttons": listViewButtonOptions
3165
3232
  }
@@ -3344,12 +3411,47 @@
3344
3411
  "type": "grid",
3345
3412
  "columns": [
3346
3413
  {
3347
- "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
+ },{
3348
3450
  "type": "tpl",
3349
3451
  "className": "block",
3350
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'>`
3351
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>`
3352
- },
3454
+ }],
3353
3455
  "md": "auto",
3354
3456
  "className": "",
3355
3457
  "columnClassName": "flex justify-center items-center"
@@ -3436,18 +3538,9 @@
3436
3538
  * @param {*} relatedObjectSchema 相关对象UISchema
3437
3539
  * @returns amisSchema
3438
3540
  */
3439
- async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel) {
3541
+ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel, ctx) {
3440
3542
  const { icon, label } = relatedObjectSchema;
3441
- const buttons = await getObjectRelatedListButtons(relatedObjectSchema, {});
3442
- let amisButtonsSchema = _$1.map(buttons, (button) => {
3443
- return {
3444
- type: 'steedos-object-button',
3445
- name: button.name,
3446
- objectName: button.objectName,
3447
- visibleOn: getButtonVisibleOn$1(button),
3448
- className: `button_${button.name}`
3449
- }
3450
- });
3543
+ let amisButtonsSchema = getObjectRecordDetailRelatedListButtonsSchemas(relatedObjectSchema, {formFactor: ctx.formFactor});
3451
3544
  const reg = new RegExp('_', 'g');
3452
3545
  const standardIcon = icon && icon.replace(reg, '-');
3453
3546
  const recordRelatedListHeader = {
@@ -3520,83 +3613,44 @@
3520
3613
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
3521
3614
  }
3522
3615
 
3523
- const getDisplayAsButton = function(objectName, showDisplayAs){
3524
- let displayAs = amisLib.Router.getTabDisplayAs(objectName);
3525
- let buttons = [
3526
- {
3527
- "type": "button",
3528
- "label": "表格",
3529
- "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');",
3530
- "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
3531
- "rightIconClassName": "m-l-sm"
3532
- },
3533
- {
3534
- "type": "button",
3535
- "label": "分栏视图",
3536
- "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
3537
- "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
3538
- "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
+ }
3539
3650
  }
3540
- ];
3541
- return {
3542
- "type": "dropdown-button",
3543
- "icon": "fa fa-table-columns",
3544
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3545
- "align": "right",
3546
- "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
3547
- "buttons": [
3548
- {
3549
- "label": "显示为",
3550
- "children": buttons
3551
- }
3552
- ]
3553
- };
3554
3651
  };
3555
3652
 
3556
-
3557
-
3558
-
3559
- const onFieldsFilterToggleScript = `
3560
- const scope = event.context.scoped;
3561
- const filterForm = scope.getComponents().find(function(n){
3562
- return n.props.type === "form";
3563
- });
3564
- const filterService = filterForm.context.getComponents().find(function(n){
3565
- return n.props.type === "service";
3566
- });
3567
- // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
3568
- let resizeWindow = function(){
3569
- //触发amis crud 高度重算
3570
- setTimeout(()=>{
3571
- window.dispatchEvent(new Event("resize"))
3572
- }, 500);
3573
- }
3574
- let isMobile = Steedos.isMobile();
3575
- if(filterService.props.data.showFieldsFilter){
3576
- if(isMobile){
3577
- // 手机上只能通过取消按钮来关闭搜索栏
3578
- return;
3579
- }
3580
- let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
3581
- direction: "down",
3582
- name: "btn_filter_form_cancel"
3583
- });
3584
- buttonCancel.props.dispatchEvent('click', {}).then(function(){
3585
- resizeWindow();
3586
- });
3587
- }
3588
- else{
3589
- filterService.setData({showFieldsFilter: true});
3590
- resizeWindow();
3591
- if(isMobile){
3592
- // 手机端在显示搜索栏时隐藏刷新按钮
3593
- let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
3594
- crudService && crudService.setData({showFieldsFilter: true});
3595
- }
3596
- }
3597
- `;
3598
-
3599
- function getExportApiRequestAdaptorScript(){
3653
+ function requestAdaptor$1(){
3600
3654
  return `
3601
3655
  // 获取列表视图的属性
3602
3656
  let uiSchema = api.body.uiSchema;
@@ -3650,667 +3704,1101 @@ else{
3650
3704
  `
3651
3705
  }
3652
3706
 
3653
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
3654
- // console.log(`getObjectHeaderToolbar====>`, filterVisible)
3655
- const isMobile = window.innerWidth < 768;
3656
- if(isMobile){
3657
- showDisplayAs = false;
3658
- }
3659
- if(formFactor === 'SMALL'){
3660
- const onReloadScript = `
3661
- const scope = event.context.scoped;
3662
- var listView = scope.parent.getComponents().find(function(n){
3663
- return n.props.type === "crud";
3664
- });
3665
- listView.handleChangePage(1);
3666
- `;
3667
- return [
3668
- // "bulkActions",
3669
- ...(headerToolbarItems || []),
3670
- hiddenCount ? {} :{
3671
- "type": "tpl",
3672
- "tpl": "${count} 个项目"
3673
- },
3674
- {
3675
- // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
3707
+ const getNewListviewButtonSchema = ()=>{
3708
+ return {
3676
3709
  "type": "button",
3677
- "align": "right",
3678
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3679
- "label": "",
3680
- "icon": "fa fa-sync",
3681
- "visibleOn": "${!showFieldsFilter}",
3710
+ "label": "新建",
3682
3711
  "onEvent": {
3683
3712
  "click": {
3713
+ "weight": 0,
3684
3714
  "actions": [
3685
3715
  {
3686
- "actionType": "custom",
3687
- "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"
3688
3772
  }
3689
3773
  ]
3690
3774
  }
3691
- },
3692
- },
3693
- filterVisible ? {
3694
- "label": "",
3695
- "icon": "fa fa-search",
3696
- "type": "button",
3697
- "badge": {
3698
- "offsetx": [
3699
- -2,
3700
- 2
3701
- ],
3702
- "size":8,
3703
- "animation": true,
3704
- "visibleOn": "${isFieldsFilterEmpty == false}"
3705
- },
3706
- "align": "right",
3707
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
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": "复制",
3708
3860
  "onEvent": {
3709
3861
  "click": {
3862
+ "weight": 0,
3710
3863
  "actions": [
3711
3864
  {
3712
- "actionType": "custom",
3713
- "script": onFieldsFilterToggleScript
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"
3714
3915
  }
3715
3916
  ]
3716
3917
  }
3717
3918
  }
3718
- } : {},
3719
- 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"
3720
3938
  ]
3721
- }else {
3722
- return [
3723
- // "filter-toggler",
3724
- ...(headerToolbarItems || []),
3725
- "bulkActions",
3726
- {
3727
- "type": "columns-toggler",
3728
- "className": "hidden"
3729
- },
3730
- // {
3731
- // "type": "columns-toggler",
3732
- // "className": "mr-2"
3733
- // },
3734
- hiddenCount ? {} : {
3735
- "type": "tpl",
3736
- "tpl": "${count} 个项目"
3737
- },
3738
- {
3739
- "type": "reload",
3740
- "align": "right",
3741
- "tooltipPlacement": "bottom",
3742
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
3743
- },
3744
- {
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 {
3745
4002
  "type": "button",
3746
- "label": "",
3747
- "icon": "fa fa-download",
3748
- "align": "right",
3749
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3750
- "tooltipPlacement": "bottom",
3751
- "visibleOn": "${!isLookup && global.user.is_space_admin}",
3752
- "tooltip": "导出Excel",
4003
+ "label": "重命名",
4004
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3753
4005
  "onEvent": {
3754
4006
  "click": {
3755
4007
  "weight": 0,
3756
4008
  "actions": [
3757
4009
  {
3758
- "args": {
3759
- "api": {
3760
- "url": "${context.rootUrl}/api/record/export/${objectName}",
3761
- "method": "get",
3762
- "messages": {},
3763
- "requestAdaptor": `${getExportApiRequestAdaptorScript()}`,
3764
- "data": {
3765
- "uiSchema": "${uiSchema}",
3766
- "listName": "${listName}"
3767
- },
3768
- "headers": {
3769
- "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
+ }
3770
4043
  }
3771
- }
4044
+ ],
4045
+ "showCloseButton": true,
4046
+ "showErrorMsg": true,
4047
+ "showLoading": true,
4048
+ "size": "lg"
3772
4049
  },
3773
- "actionType": "download"
4050
+ "actionType": "dialog"
3774
4051
  }
3775
4052
  ]
3776
4053
  }
3777
4054
  }
3778
- },
3779
- filterVisible ? {
3780
- "label": "",
3781
- "icon": "fa fa-search",
4055
+ }
4056
+ };
4057
+
4058
+ const getSetListviewShareButtonSchema = ()=>{
4059
+ return {
3782
4060
  "type": "button",
3783
- "align": "right",
3784
- "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)",
3785
4063
  "onEvent": {
3786
4064
  "click": {
4065
+ "weight": 0,
3787
4066
  "actions": [
3788
4067
  {
3789
- "actionType": "custom",
3790
- "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"
3791
4094
  }
3792
4095
  ]
3793
4096
  }
3794
4097
  }
3795
- } : {},
3796
- {
3797
- "type": "dropdown-button",
3798
- "trigger": "click",
3799
- "icon": "fa fa-cog",
3800
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3801
- "align": "right",
3802
- "visibleOn": "${!isLookup}",
3803
- "buttons": [
3804
- {
3805
- "label": "列表视图操作",
3806
- "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": [
3807
4110
  {
3808
- "type": "button",
3809
- "label": "新建",
3810
- "onEvent": {
3811
- "click": {
3812
- "weight": 0,
3813
- "actions": [
3814
- {
3815
- "dialog": {
3816
- "type": "dialog",
3817
- "title": "新建 列表视图",
3818
- "data": {
3819
- "&": "$$",
3820
- "all": "${uiSchema.list_views.all}",
3821
- "list_view": "${uiSchema.list_views[listName]}",
3822
- "appId": "${appId}",
3823
- "global": "${global}",
3824
- "targetObjectName": "${objectName}",
3825
- },
3826
- "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": [
3827
4137
  {
3828
- "type": "steedos-object-form",
3829
- "label": "对象表单",
3830
- "objectApiName": "object_listviews",
3831
- "recordId": "",
3832
- "mode": "edit",
3833
- "defaultData": {
3834
- "&": "${list_view}",
3835
- "name":"",
3836
- "label":"",
3837
- "filters":"",
3838
- "shared":false
3839
- },
3840
- "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}",
3841
- "fields": [
3842
- "label",
3843
- "name",
3844
- "object_name",
3845
- "filter_scope",
3846
- "show_count",
3847
- "columns.$.field",
3848
- "columns.$.width",
3849
- "sort.$.field_name",
3850
- "sort.$.order",
3851
- "filters",
3852
- "mobile_columns.$.field",
3853
- "searchable_fields.$.field",
3854
- "is_system",
3855
- "shared"
3856
- ],
3857
- "onEvent": {
3858
- "submitSucc": {
3859
- "weight": 0,
3860
- "actions": [
3861
- {
3862
- "args": {
3863
- // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3864
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3865
- "blank": false
3866
- },
3867
- "actionType": "url",
3868
- }
3869
- ]
3870
- }
3871
- },
3872
- "messages": {
3873
- "success": "成功",
3874
- "failed": "失败"
4138
+ "args": {
4139
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4140
+ "blank": false
3875
4141
  },
4142
+ "actionType": "url",
3876
4143
  }
3877
- ],
3878
- "showCloseButton": true,
3879
- "showErrorMsg": true,
3880
- "showLoading": true,
3881
- "closeOnEsc": false,
3882
- "dataMapSwitch": false,
3883
- "size": "lg"
3884
- },
3885
- "actionType": "dialog"
4144
+ ]
4145
+ }
3886
4146
  }
3887
- ]
3888
- }
3889
- }
3890
- },
3891
- {
3892
- "type": "button",
3893
- "label": "复制",
3894
- "onEvent": {
3895
- "click": {
3896
- "weight": 0,
3897
- "actions": [
3898
- {
3899
- "dialog": {
3900
- "type": "dialog",
3901
- "title": "复制 列表视图",
3902
- "data": {
3903
- "&": "$$",
3904
- "listName": "${listName}",
3905
- "targetObjectName": "${objectName}",
3906
- "list_view": "${uiSchema.list_views[listName]}",
3907
- "appId": "${appId}",
3908
- "global": "${global}"
3909
- },
3910
- "body": [
3911
- {
3912
- "type": "steedos-object-form",
3913
- "label": "对象表单",
3914
- "objectApiName": "object_listviews",
3915
- "recordId": "",
3916
- "mode": "edit",
3917
- "fields": [
3918
- ],
3919
- "defaultData": {
3920
- "&": "${list_view}",
3921
- "name":"",
3922
- "label": "${list_view.label}的副本",
3923
- "shared":false
3924
- },
3925
- "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}",
3926
- "fields": [
3927
- "label",
3928
- "name",
3929
- "object_name",
3930
- "filter_scope",
3931
- "show_count",
3932
- "columns.$.field",
3933
- "columns.$.width",
3934
- "sort.$.field_name",
3935
- "sort.$.order",
3936
- "filters",
3937
- "mobile_columns.$.field",
3938
- "searchable_fields.$.field",
3939
- "is_system",
3940
- "shared"
3941
- ],
3942
- "onEvent": {
3943
- "submitSucc": {
3944
- "weight": 0,
3945
- "actions": [
3946
- {
3947
- "args": {
3948
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3949
- "blank": false
3950
- },
3951
- "actionType": "url",
3952
- }
3953
- ]
3954
- }
3955
- }
3956
- }
3957
- ],
3958
- "showCloseButton": true,
3959
- "showErrorMsg": true,
3960
- "showLoading": true,
3961
- "closeOnEsc": false,
3962
- "dataMapSwitch": false,
3963
- "size": "lg"
3964
- },
3965
- "actionType": "dialog"
3966
- }
3967
- ]
3968
- }
3969
- }
3970
- },
3971
- {
3972
- "type": "button",
3973
- "label": "重命名",
3974
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3975
- "onEvent": {
3976
- "click": {
3977
- "weight": 0,
3978
- "actions": [
3979
- {
3980
- "dialog": {
3981
- "type": "dialog",
3982
- "title": "重命名 列表视图",
3983
- "data": {
3984
- "targetObjectName": "${objectName}",
3985
- "recordId": "${uiSchema.list_views[listName]._id}",
3986
- "appId": "${appId}"
3987
- },
3988
- "body": [
3989
- {
3990
- "type": "steedos-object-form",
3991
- "label": "对象表单",
3992
- "objectApiName": "object_listviews",
3993
- "recordId": "${recordId}",
3994
- "mode": "edit",
3995
- "fields": [
3996
- "label"
3997
- ],
3998
- "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
3999
- "onEvent": {
4000
- "submitSucc": {
4001
- "weight": 0,
4002
- "actions": [
4003
- {
4004
- "args": {
4005
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
4006
- "blank": false
4007
- },
4008
- "actionType": "url",
4009
- },
4010
- ]
4011
- }
4012
- }
4013
- }
4014
- ],
4015
- "showCloseButton": true,
4016
- "showErrorMsg": true,
4017
- "showLoading": true,
4018
- "size": "lg"
4019
- },
4020
- "actionType": "dialog"
4021
- }
4022
- ]
4023
- }
4024
- }
4025
- },
4026
- {
4027
- "type": "button",
4028
- "label": "共享设置",
4029
- "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
4030
- "onEvent": {
4031
- "click": {
4032
- "weight": 0,
4033
- "actions": [
4034
- {
4035
- "dialog": {
4036
- "type": "dialog",
4037
- "title": "共享设置",
4038
- "data": {
4039
- "recordId": "${uiSchema.list_views[listName]._id}",
4040
- },
4041
- "body": [
4042
- {
4043
- "type": "steedos-object-form",
4044
- "label": "对象表单",
4045
- "objectApiName": "object_listviews",
4046
- "recordId": "${recordId}",
4047
- "mode": "edit",
4048
- "fields": [
4049
- "shared"
4050
- ]
4051
- }
4052
- ],
4053
- "showCloseButton": true,
4054
- "showErrorMsg": true,
4055
- "showLoading": true,
4056
- "closeOnEsc": false,
4057
- "dataMapSwitch": false,
4058
- "size": "md"
4059
- },
4060
- "actionType": "dialog"
4061
- }
4062
- ]
4063
- }
4064
- }
4065
- },
4066
- {
4067
- "type": "button",
4068
- "label": "过滤设置",
4069
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4070
- "onEvent": {
4071
- "click": {
4072
- "weight": 0,
4073
- "actions": [
4074
- {
4075
- "dialog": {
4076
- "type": "dialog",
4077
- "title": "过滤设置",
4078
- "data": {
4079
- "targetObjectName": "${objectName}",
4080
- "objectName": "${objectName}",
4081
- "recordId": "${uiSchema.list_views[listName]._id}",
4082
- "listName": "${listName}",
4083
- "appId": "${appId}"
4084
- },
4085
- "body": [
4086
- {
4087
- "type": "steedos-object-form",
4088
- "label": "对象表单",
4089
- "objectApiName": "object_listviews",
4090
- "recordId": "${recordId}",
4091
- "mode": "edit",
4092
- "fields": [
4093
- "filters"
4094
- ],
4095
- "initApiRequestAdaptor": "",
4096
- "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;",
4097
- "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",
4098
- "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}",
4099
- "onEvent": {
4100
- "submitSucc": {
4101
- "weight": 0,
4102
- "actions": [
4103
- {
4104
- "args": {
4105
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4106
- "blank": false
4107
- },
4108
- "actionType": "url",
4109
- }
4110
- ]
4111
- }
4112
- }
4113
- }
4114
- ],
4115
- "showCloseButton": true,
4116
- "showErrorMsg": true,
4117
- "showLoading": true,
4118
- "closeOnEsc": false,
4119
- "dataMapSwitch": false,
4120
- "size": "lg"
4121
- },
4122
- "actionType": "dialog"
4123
- }
4124
- ]
4125
- }
4126
- }
4127
- },
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": [
4128
4256
  {
4129
- "type": "button",
4130
- "label": "显示的列",
4131
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4132
- "onEvent": {
4133
- "click": {
4134
- "weight": 0,
4135
- "actions": [
4136
- {
4137
- "args": {},
4138
- "dialog": {
4139
- "type": "dialog",
4140
- "title": "显示的列",
4141
- "data": {
4142
- "&": "$$",
4143
- "targetObjectName": "${objectName}",
4144
- "objectName": "${objectName}",
4145
- "recordId": "${uiSchema.list_views[listName]._id}",
4146
- "listName": "${listName}",
4147
- "appId": "${appId}"
4148
- },
4149
- "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": [
4150
4286
  {
4151
- "type": "steedos-object-form",
4152
- "label": "对象表单",
4153
- "objectApiName": "object_listviews",
4154
- "recordId": "${recordId}",
4155
- "mode": "edit",
4156
- "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}",
4157
- "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;",
4158
- "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;",
4159
- "fields": [
4160
- "columns",
4161
- "mobile_columns"
4162
- ],
4163
- "onEvent": {
4164
- "submitSucc": {
4165
- "weight": 0,
4166
- "actions": [
4167
- {
4168
- "args": {
4169
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4170
- "blank": false
4171
- },
4172
- "actionType": "url"
4173
- }
4174
- ]
4175
- }
4176
- }
4287
+ "args": {
4288
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4289
+ "blank": false
4290
+ },
4291
+ "actionType": "url"
4177
4292
  }
4178
- ],
4179
- "searchable": true,
4180
- "showCloseButton": true,
4181
- "showErrorMsg": true,
4182
- "showLoading": true,
4183
- "size": "lg"
4184
- },
4185
- "actionType": "dialog"
4293
+ ]
4294
+ }
4186
4295
  }
4187
- ]
4188
- }
4189
- }
4190
- },
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": [
4191
4410
  {
4192
- "type": "button",
4193
- "label": "默认排序规则",
4194
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4195
- "onEvent": {
4196
- "click": {
4197
- "weight": 0,
4198
- "actions": [
4199
- {
4200
- "dialog": {
4201
- "type": "dialog",
4202
- "title": "弹框标题",
4203
- "data": {
4204
- "&": "$$",
4205
- "targetObjectName": "${objectName}",
4206
- "objectName": "${objectName}",
4207
- "recordId": "${uiSchema.list_views[listName]._id}",
4208
- "listName": "${listName}",
4209
- "appId": "${appId}"
4210
- },
4211
- "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": [
4212
4439
  {
4213
- "type": "steedos-object-form",
4214
- "label": "对象表单",
4215
- "objectApiName": "object_listviews",
4216
- "recordId": "${recordId}",
4217
- "className": "",
4218
- "id": "u:061f158b4c5a",
4219
- "mode": "edit",
4220
- "fields": [
4221
- "sort",
4222
- "sort.$.field_name",
4223
- "sort.$.order"
4224
- ],
4225
- "onEvent": {
4226
- "submitSucc": {
4227
- "weight": 0,
4228
- "actions": [
4229
- {
4230
- "args": {
4231
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4232
- "blank": false
4233
- },
4234
- "actionType": "url"
4235
- }
4236
- ]
4237
- }
4440
+ "args": {
4441
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4442
+ "blank": false
4238
4443
  },
4239
- "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}",
4240
- "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;",
4241
- "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"
4242
4445
  }
4243
- ],
4244
- "showCloseButton": true,
4245
- "showErrorMsg": true,
4246
- "showLoading": true,
4247
- "id": "u:d3f6947b6acf",
4248
- "size": "lg"
4249
- },
4250
- "actionType": "dialog"
4251
- }
4252
- ]
4253
- }
4254
- }
4255
- },
4256
- {
4257
- "type": "button",
4258
- "label": "删除",
4259
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4260
- "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4261
- "onEvent": {
4262
- "click": {
4263
- "actions": [
4264
- {
4265
- "actionType": "ajax",
4266
- "args": {
4267
- "api": {
4268
- "url": "${context.rootUrl}/graphql",
4269
- "method": "post",
4270
- "headers": {
4271
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4272
- },
4273
- "data": {
4274
- "&": "$$",
4275
- "uiSchema": "${uiSchema}",
4276
- "recordId": "${uiSchema.list_views[listName]._id}"
4277
- },
4278
- "messages": {
4279
- "success": "删除成功"
4280
- },
4281
- "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",
4282
- "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n}\nreturn payload;",
4283
- }
4446
+ ]
4284
4447
  }
4285
4448
  },
4286
- {
4287
- "actionType": "url",
4288
- "args": {
4289
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4290
- "blank": false
4291
- },
4292
- "expression": "data.delete == 1"
4293
- }
4294
- ]
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(),
4295
4553
  }
4296
4554
  }
4297
4555
  },
4298
4556
  {
4299
- "type": "button",
4300
- "visibleOn": "${false}",
4301
- "label": "保存宽度(todo)"
4302
- },
4303
- // {
4304
- // type: 'steedos-object-button',
4305
- // name: 'standard_delete',
4306
- // objectName: 'test0321__c',
4307
- // // visibleOn: getButtonVisibleOn(button),
4308
- // className: 'antd-Button--default'
4309
- // }
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()
4310
4611
  ]
4311
4612
  }
4312
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"
4313
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(),
4314
4802
  getDisplayAsButton(showDisplayAs)
4315
4803
  // {
4316
4804
  // "type": "search-box",
@@ -4789,20 +5277,7 @@ else{
4789
5277
  }
4790
5278
  }
4791
5279
 
4792
- var searchableFilter = [];
4793
- _.each(selfData, (value, key)=>{
4794
- if(!_.isEmpty(value) || _.isBoolean(value)){
4795
- if(_.startsWith(key, '__searchable__between__')){
4796
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
4797
- }else if(_.startsWith(key, '__searchable__')){
4798
- if(_.isString(value)){
4799
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
4800
- }else{
4801
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
4802
- }
4803
- }
4804
- }
4805
- });
5280
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
4806
5281
 
4807
5282
  if(searchableFilter.length > 0){
4808
5283
  if(filters.length > 0 ){
@@ -6224,6 +6699,29 @@ else{
6224
6699
  window.getFieldSearchable = getFieldSearchable;
6225
6700
  }
6226
6701
 
6702
+
6703
+ function isFieldTypeSearchable(fieldType) {
6704
+ return !___namespace.includes(
6705
+ [
6706
+ "grid",
6707
+ "avatar",
6708
+ "image",
6709
+ "object",
6710
+ "[object]",
6711
+ "[Object]",
6712
+ "[grid]",
6713
+ "[text]",
6714
+ "audio",
6715
+ "file",
6716
+ ],
6717
+ fieldType
6718
+ )
6719
+ }
6720
+
6721
+ if (typeof window != 'undefined') {
6722
+ window.isFieldTypeSearchable = isFieldTypeSearchable;
6723
+ }
6724
+
6227
6725
  var index = /*#__PURE__*/Object.freeze({
6228
6726
  __proto__: null,
6229
6727
  OMIT_FIELDS: OMIT_FIELDS,
@@ -6235,6 +6733,7 @@ else{
6235
6733
  getSelectFieldOptions: getSelectFieldOptions,
6236
6734
  convertSFieldToAmisField: convertSFieldToAmisField,
6237
6735
  getFieldSearchable: getFieldSearchable,
6736
+ isFieldTypeSearchable: isFieldTypeSearchable,
6238
6737
  getAmisStaticFieldType: getAmisStaticFieldType
6239
6738
  });
6240
6739
 
@@ -6846,7 +7345,7 @@ else{
6846
7345
  id: `service_${id}`,
6847
7346
  name: `page`,
6848
7347
  data: {
6849
- // objectName: objectSchema.name,
7348
+ objectName: objectSchema.name,
6850
7349
  // _id: null,
6851
7350
  recordPermissions: objectSchema.permissions,
6852
7351
  uiSchema: objectSchema,
@@ -7664,20 +8163,8 @@ else{
7664
8163
  }else if(selfData.op === 'loadOptions' && selfData.value){
7665
8164
  userFilters = [["${valueField.name}", "=", selfData.value]];
7666
8165
  }
7667
- var searchableFilter = [];
7668
- _.each(selfData, (value, key)=>{
7669
- if(!_.isEmpty(value) || _.isBoolean(value)){
7670
- if(_.startsWith(key, '__searchable__between__')){
7671
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
7672
- }else if(_.startsWith(key, '__searchable__')){
7673
- if(_.isString(value)){
7674
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
7675
- }else{
7676
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
7677
- }
7678
- }
7679
- }
7680
- });
8166
+
8167
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
7681
8168
 
7682
8169
  if(searchableFilter.length > 0){
7683
8170
  if(userFilters.length > 0 ){
@@ -7948,20 +8435,7 @@ else{
7948
8435
  }else if(selfData.op === 'loadOptions' && selfData.value){
7949
8436
  filters = [["${valueField.name}", "=", selfData.value]];
7950
8437
  }
7951
- var searchableFilter = [];
7952
- _.each(selfData, (value, key)=>{
7953
- if(!_.isEmpty(value) || _.isBoolean(value)){
7954
- if(_.startsWith(key, '__searchable__between__')){
7955
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
7956
- }else if(_.startsWith(key, '__searchable__')){
7957
- if(_.isString(value)){
7958
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
7959
- }else{
7960
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
7961
- }
7962
- }
7963
- }
7964
- });
8438
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
7965
8439
 
7966
8440
  if(searchableFilter.length > 0){
7967
8441
  if(filters.length > 0 ){
@@ -8487,7 +8961,7 @@ else{
8487
8961
  * @Author: baozhoutao@steedos.com
8488
8962
  * @Date: 2022-07-05 15:55:39
8489
8963
  * @LastEditors: Please set LastEditors
8490
- * @LastEditTime: 2023-05-08 16:34:25
8964
+ * @LastEditTime: 2023-05-17 09:09:33
8491
8965
  * @Description:
8492
8966
  */
8493
8967
 
@@ -8627,7 +9101,7 @@ else{
8627
9101
  // } else {
8628
9102
  // globalFilter = [`${relatedKey}`, "=", relatedValue];
8629
9103
  // }
8630
- const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
9104
+ const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
8631
9105
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
8632
9106
  const options = {
8633
9107
  globalFilter,
@@ -12274,6 +12748,7 @@ else{
12274
12748
  exports.getObjectListHeaderSecordLine = getObjectListHeaderSecordLine;
12275
12749
  exports.getObjectListViewButtonsSchemas = getObjectListViewButtonsSchemas;
12276
12750
  exports.getObjectRecordDetailHeader = getObjectRecordDetailHeader;
12751
+ exports.getObjectRecordDetailRelatedListButtonsSchemas = getObjectRecordDetailRelatedListButtonsSchemas;
12277
12752
  exports.getObjectRecordDetailRelatedListHeader = getObjectRecordDetailRelatedListHeader;
12278
12753
  exports.getObjectRelated = getObjectRelated;
12279
12754
  exports.getObjectRelatedList = getObjectRelatedList;