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