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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _$1 from 'lodash';
2
- import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, includes, get, map, toArray, mergeWith, forEach, isBoolean, omitBy, isNil, isString, union, has, slice, defaultsDeep as defaultsDeep$1, isObject as isObject$1, filter, startsWith } from 'lodash';
2
+ import ___default, { isEmpty, isArray, each, find, endsWith, cloneDeep, forEach, includes, get, toArray, mergeWith, map, 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
 
@@ -382,11 +382,28 @@ const Router = {
382
382
 
383
383
  };
384
384
 
385
+ /*
386
+ * @Author: baozhoutao@steedos.com
387
+ * @Date: 2022-07-20 16:29:22
388
+ * @LastEditors: Please set LastEditors
389
+ * @LastEditTime: 2023-05-18 15:22:51
390
+ * @Description:
391
+ */
392
+
393
+ function getContrastColor(bgColor) {
394
+ var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
395
+ var r = parseInt(backgroundColor.substr(0, 2), 16);
396
+ var g = parseInt(backgroundColor.substr(2, 2), 16);
397
+ var b = parseInt(backgroundColor.substr(4, 2), 16);
398
+ var brightness = (r * 299 + g * 587 + b * 114) / 1000;
399
+ return brightness < 128 ? "#ffffff" : "#000000";
400
+ }
401
+
385
402
  /*
386
403
  * @Author: baozhoutao@steedos.com
387
404
  * @Date: 2022-05-23 09:53:08
388
- * @LastEditors: baozhoutao@steedos.com
389
- * @LastEditTime: 2023-04-10 11:22:54
405
+ * @LastEditors: Please set LastEditors
406
+ * @LastEditTime: 2023-05-18 16:34:39
390
407
  * @Description:
391
408
  */
392
409
 
@@ -439,6 +456,21 @@ async function getRefObjectNameFieldName(field){
439
456
  function getSelectTpl(field){
440
457
  return `<div>\${_display.${field.name}}</div>`
441
458
  }
459
+ function getSelectMap(selectOptions){
460
+ let map = {};
461
+ forEach(selectOptions,(option)=>{
462
+ const optionValue = option.value + '';
463
+ if(option.color){
464
+ const background = option.color.charAt(0) === '#' ? option.color : '#'+option.color;
465
+ const color = getContrastColor(background);
466
+ const optionColorStyle = 'background:'+background+';color:'+color;
467
+ map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
468
+ }else {
469
+ map[optionValue] = option.label;
470
+ }
471
+ });
472
+ return map;
473
+ }
442
474
 
443
475
  function getNameTplUrl(field, ctx){
444
476
  if(ctx.objectName === 'cms_files'){
@@ -2238,7 +2270,7 @@ const getListViewItemButtons = async (uiSchema, ctx)=>{
2238
2270
  return listButtons;
2239
2271
  };
2240
2272
 
2241
- const getObjectRelatedListButtons = async (uiSchema, ctx)=>{
2273
+ const getObjectRelatedListButtons = (uiSchema, ctx)=>{
2242
2274
  // const buttons = getButtons(uiSchema, ctx);
2243
2275
  // const relatedListButtons = _.filter(buttons, (button) => {
2244
2276
  // if(button.objectName === 'cms_files'){
@@ -2525,6 +2557,67 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
2525
2557
  }
2526
2558
  };
2527
2559
 
2560
+ const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
2561
+ const buttons = getObjectRelatedListButtons(objectSchema, ctx);
2562
+ if(ctx.formFactor === 'SMALL'){
2563
+ return {
2564
+ "type": "button",
2565
+ "icon": "fa fa-angle-down",
2566
+ "onEvent": {
2567
+ "click": {
2568
+ "actions": [
2569
+ {
2570
+ "actionType": "drawer",
2571
+ "drawer": {
2572
+ "type": "drawer",
2573
+ "title": "操作",
2574
+ "body": [
2575
+ {
2576
+ "type": "button-group",
2577
+ "vertical": true,
2578
+ "tiled": true,
2579
+ "buttons": [
2580
+ ...___default.map(buttons, (button)=>{
2581
+ return {
2582
+ type: 'steedos-object-button',
2583
+ name: button.name,
2584
+ objectName: button.objectName,
2585
+ visibleOn: getButtonVisibleOn$1(button),
2586
+ className: `button_${button.name} w-full`
2587
+ }
2588
+ })
2589
+ ],
2590
+ "btnLevel": "enhance",
2591
+ "className": "w-full",
2592
+ "btnClassName": "w-full",
2593
+ "size": "lg"
2594
+ }
2595
+ ],
2596
+ "position": "bottom",
2597
+ "closeOnOutside": true,
2598
+ "resizable": false,
2599
+ "className": "buttons-drawer",
2600
+ "bodyClassName": "m-none p-none",
2601
+ "actions": []
2602
+ }
2603
+ }
2604
+ ]
2605
+ }
2606
+ }
2607
+ }
2608
+ }else {
2609
+ return ___default.map(buttons, (button) => {
2610
+ return {
2611
+ type: 'steedos-object-button',
2612
+ name: button.name,
2613
+ objectName: button.objectName,
2614
+ visibleOn: getButtonVisibleOn$1(button),
2615
+ className: `button_${button.name}`
2616
+ }
2617
+ });
2618
+ }
2619
+ };
2620
+
2528
2621
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2529
2622
  // const amisListViewId = `listview_${objectSchema.name}`;
2530
2623
  return {
@@ -2693,6 +2786,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
2693
2786
  }
2694
2787
  }
2695
2788
  }
2789
+ filterForm.reset();
2696
2790
  listView.handleFilterSubmit(removedValues);
2697
2791
  const filterService = filterForm.context.getComponents().find(function(n){
2698
2792
  return n.props.type === "service";
@@ -3138,6 +3232,7 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
3138
3232
  "rightIcon": "fa fa-caret-down",
3139
3233
  "size": "sm",
3140
3234
  "hideCaret": true,
3235
+ "closeOnClick": true,
3141
3236
  "btnClassName": "!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none",
3142
3237
  "buttons": listViewButtonOptions
3143
3238
  }
@@ -3322,12 +3417,47 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3322
3417
  "type": "grid",
3323
3418
  "columns": [
3324
3419
  {
3325
- "body": {
3420
+ "body": [{
3421
+ "type": "service",
3422
+ "onEvent": {
3423
+ "@history_paths.changed": {
3424
+ "actions": [
3425
+ {
3426
+ "actionType": "reload"
3427
+ }
3428
+ ]
3429
+ }
3430
+ },
3431
+ "body":[{
3432
+ "type": "button",
3433
+ "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
3434
+ "className":"flex mr-4",
3435
+ "onEvent": {
3436
+ "click": {
3437
+ "actions": [
3438
+ {
3439
+ "actionType": "custom",
3440
+ "script": "Steedos.goBack()"
3441
+ }
3442
+ ]
3443
+ }
3444
+ },
3445
+ "body": [
3446
+ {
3447
+ "type": "steedos-icon",
3448
+ "category": "utility",
3449
+ "name": "back",
3450
+ "colorVariant": "default",
3451
+ "className": "slds-button_icon slds-global-header__icon w-4"
3452
+ }
3453
+ ]
3454
+ }]
3455
+ },{
3326
3456
  "type": "tpl",
3327
3457
  "className": "block",
3328
3458
  // "tpl": `<img class='slds-icon slds-icon_container slds-icon-standard-${standardIcon}' src='\${context.rootUrl}/unpkg.com/@salesforce-ux/design-system/assets/icons/standard/${icon}.svg'>`
3329
3459
  "tpl":`<svg class="slds-icon slds-icon_container slds-icon-standard-${standardIcon} slds-page-header__icon" aria-hidden="true"><use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#${icon}"></use></svg>`
3330
- },
3460
+ }],
3331
3461
  "md": "auto",
3332
3462
  "className": "",
3333
3463
  "columnClassName": "flex justify-center items-center"
@@ -3414,18 +3544,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3414
3544
  * @param {*} relatedObjectSchema 相关对象UISchema
3415
3545
  * @returns amisSchema
3416
3546
  */
3417
- async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel) {
3547
+ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel, ctx) {
3418
3548
  const { icon, label } = relatedObjectSchema;
3419
- const buttons = await getObjectRelatedListButtons(relatedObjectSchema, {});
3420
- let amisButtonsSchema = map(buttons, (button) => {
3421
- return {
3422
- type: 'steedos-object-button',
3423
- name: button.name,
3424
- objectName: button.objectName,
3425
- visibleOn: getButtonVisibleOn$1(button),
3426
- className: `button_${button.name}`
3427
- }
3428
- });
3549
+ let amisButtonsSchema = getObjectRecordDetailRelatedListButtonsSchemas(relatedObjectSchema, {formFactor: ctx.formFactor});
3429
3550
  const reg = new RegExp('_', 'g');
3430
3551
  const standardIcon = icon && icon.replace(reg, '-');
3431
3552
  const recordRelatedListHeader = {
@@ -3498,83 +3619,44 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
3498
3619
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
3499
3620
  }
3500
3621
 
3501
- const getDisplayAsButton = function(objectName, showDisplayAs){
3502
- let displayAs = Router$1.getTabDisplayAs(objectName);
3503
- let buttons = [
3504
- {
3505
- "type": "button",
3506
- "label": "表格",
3507
- "onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
3508
- "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
3509
- "rightIconClassName": "m-l-sm"
3510
- },
3511
- {
3512
- "type": "button",
3513
- "label": "分栏视图",
3514
- "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
3515
- "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
3516
- "rightIconClassName": "m-l-sm"
3622
+ const getExportExcelToolbarButtonSchema = ()=>{
3623
+ return {
3624
+ "type": "button",
3625
+ "icon": "fa fa-download",
3626
+ "align": "right",
3627
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3628
+ "tooltipPlacement": "bottom",
3629
+ "visibleOn": "${!isLookup && global.user.is_space_admin}",
3630
+ "tooltip": "导出Excel",
3631
+ "onEvent": {
3632
+ "click": {
3633
+ "weight": 0,
3634
+ "actions": [
3635
+ {
3636
+ "args": {
3637
+ "api": {
3638
+ "url": "${context.rootUrl}/api/record/export/${objectName}",
3639
+ "method": "get",
3640
+ "messages": {},
3641
+ "requestAdaptor": `${requestAdaptor$1()}`,
3642
+ "data": {
3643
+ "uiSchema": "${uiSchema}",
3644
+ "listName": "${listName}"
3645
+ },
3646
+ "headers": {
3647
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
3648
+ }
3649
+ }
3650
+ },
3651
+ "actionType": "download"
3652
+ }
3653
+ ]
3654
+ }
3655
+ }
3517
3656
  }
3518
- ];
3519
- return {
3520
- "type": "dropdown-button",
3521
- "icon": "fa fa-table-columns",
3522
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3523
- "align": "right",
3524
- "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
3525
- "buttons": [
3526
- {
3527
- "label": "显示为",
3528
- "children": buttons
3529
- }
3530
- ]
3531
- };
3532
3657
  };
3533
3658
 
3534
-
3535
-
3536
-
3537
- const onFieldsFilterToggleScript = `
3538
- const scope = event.context.scoped;
3539
- const filterForm = scope.getComponents().find(function(n){
3540
- return n.props.type === "form";
3541
- });
3542
- const filterService = filterForm.context.getComponents().find(function(n){
3543
- return n.props.type === "service";
3544
- });
3545
- // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
3546
- let resizeWindow = function(){
3547
- //触发amis crud 高度重算
3548
- setTimeout(()=>{
3549
- window.dispatchEvent(new Event("resize"))
3550
- }, 500);
3551
- }
3552
- let isMobile = Steedos.isMobile();
3553
- if(filterService.props.data.showFieldsFilter){
3554
- if(isMobile){
3555
- // 手机上只能通过取消按钮来关闭搜索栏
3556
- return;
3557
- }
3558
- let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
3559
- direction: "down",
3560
- name: "btn_filter_form_cancel"
3561
- });
3562
- buttonCancel.props.dispatchEvent('click', {}).then(function(){
3563
- resizeWindow();
3564
- });
3565
- }
3566
- else{
3567
- filterService.setData({showFieldsFilter: true});
3568
- resizeWindow();
3569
- if(isMobile){
3570
- // 手机端在显示搜索栏时隐藏刷新按钮
3571
- let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
3572
- crudService && crudService.setData({showFieldsFilter: true});
3573
- }
3574
- }
3575
- `;
3576
-
3577
- function getExportApiRequestAdaptorScript(){
3659
+ function requestAdaptor$1(){
3578
3660
  return `
3579
3661
  // 获取列表视图的属性
3580
3662
  let uiSchema = api.body.uiSchema;
@@ -3628,667 +3710,1101 @@ function getExportApiRequestAdaptorScript(){
3628
3710
  `
3629
3711
  }
3630
3712
 
3631
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
3632
- // console.log(`getObjectHeaderToolbar====>`, filterVisible)
3633
- const isMobile = window.innerWidth < 768;
3634
- if(isMobile){
3635
- showDisplayAs = false;
3636
- }
3637
- if(formFactor === 'SMALL'){
3638
- const onReloadScript = `
3639
- const scope = event.context.scoped;
3640
- var listView = scope.parent.getComponents().find(function(n){
3641
- return n.props.type === "crud";
3642
- });
3643
- listView.handleChangePage(1);
3644
- `;
3645
- return [
3646
- // "bulkActions",
3647
- ...(headerToolbarItems || []),
3648
- hiddenCount ? {} :{
3649
- "type": "tpl",
3650
- "tpl": "${count} 个项目"
3651
- },
3652
- {
3653
- // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
3713
+ const getNewListviewButtonSchema = ()=>{
3714
+ return {
3654
3715
  "type": "button",
3655
- "align": "right",
3656
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3657
- "label": "",
3658
- "icon": "fa fa-sync",
3659
- "visibleOn": "${!showFieldsFilter}",
3716
+ "label": "新建",
3660
3717
  "onEvent": {
3661
3718
  "click": {
3719
+ "weight": 0,
3662
3720
  "actions": [
3663
3721
  {
3664
- "actionType": "custom",
3665
- "script": onReloadScript
3666
- }
3667
- ]
3668
- }
3669
- },
3670
- },
3671
- filterVisible ? {
3672
- "label": "",
3673
- "icon": "fa fa-search",
3674
- "type": "button",
3675
- "badge": {
3676
- "offset": [
3677
- -5,
3678
- 1
3679
- ],
3680
- "size":8,
3681
- "animation": true,
3682
- "visibleOn": "${isFieldsFilterEmpty == false}"
3683
- },
3684
- "align": "right",
3685
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3722
+ "dialog": {
3723
+ "type": "dialog",
3724
+ "title": "新建 列表视图",
3725
+ "data": {
3726
+ "&": "$$",
3727
+ "all": "${uiSchema.list_views.all}",
3728
+ "list_view": "${uiSchema.list_views[listName]}",
3729
+ "appId": "${appId}",
3730
+ "global": "${global}",
3731
+ "targetObjectName": "${objectName}",
3732
+ },
3733
+ "body": [
3734
+ {
3735
+ "type": "steedos-object-form",
3736
+ "label": "对象表单",
3737
+ "objectApiName": "object_listviews",
3738
+ "recordId": "",
3739
+ "mode": "edit",
3740
+ "defaultData": {
3741
+ "&": "${list_view}",
3742
+ "name":"",
3743
+ "label":"",
3744
+ "filters":"",
3745
+ "shared":false
3746
+ },
3747
+ "fieldsExtend": fieldsExtend$4(),
3748
+ "fields": fields$1(),
3749
+ "onEvent": {
3750
+ "submitSucc": {
3751
+ "weight": 0,
3752
+ "actions": [
3753
+ {
3754
+ "args": {
3755
+ // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3756
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3757
+ "blank": false
3758
+ },
3759
+ "actionType": "url",
3760
+ }
3761
+ ]
3762
+ }
3763
+ },
3764
+ "messages": {
3765
+ "success": "成功",
3766
+ "failed": "失败"
3767
+ },
3768
+ }
3769
+ ],
3770
+ "showCloseButton": true,
3771
+ "showErrorMsg": true,
3772
+ "showLoading": true,
3773
+ "closeOnEsc": false,
3774
+ "dataMapSwitch": false,
3775
+ "size": "lg"
3776
+ },
3777
+ "actionType": "dialog"
3778
+ }
3779
+ ]
3780
+ }
3781
+ }
3782
+ }
3783
+ };
3784
+
3785
+ function fields$1(){
3786
+ return [
3787
+ "label",
3788
+ "name",
3789
+ "object_name",
3790
+ "filter_scope",
3791
+ "show_count",
3792
+ "columns.$.field",
3793
+ "columns.$.width",
3794
+ "sort.$.field_name",
3795
+ "sort.$.order",
3796
+ "filters",
3797
+ "mobile_columns.$.field",
3798
+ "searchable_fields.$.field",
3799
+ "is_system",
3800
+ "shared"
3801
+ ]
3802
+ }
3803
+
3804
+ function fieldsExtend$4(){
3805
+ return {
3806
+ "label": {
3807
+ "is_wide": true
3808
+ },
3809
+ "name": {
3810
+ "amis": {
3811
+ "hidden": true
3812
+ }
3813
+ },
3814
+ "object_name": {
3815
+ "amis": {
3816
+ "hidden": true
3817
+ }
3818
+ },
3819
+ "filter_scope": {
3820
+ "amis": {
3821
+ "hidden": true
3822
+ }
3823
+ },
3824
+ "columns": {
3825
+ "amis": {
3826
+ "hidden": true
3827
+ }
3828
+ },
3829
+ "filter_fields": {
3830
+ "amis": {
3831
+ "hidden": true
3832
+ }
3833
+ },
3834
+ "scrolling_mode": {
3835
+ "amis": {
3836
+ "hidden": true
3837
+ }
3838
+ },
3839
+ "sort": {
3840
+ "amis": {
3841
+ "hidden": true
3842
+ }
3843
+ },
3844
+ "show_count": {
3845
+ "amis": {
3846
+ "hidden": true
3847
+ }
3848
+ },
3849
+ "type": {
3850
+ "amis": {
3851
+ "hidden": true
3852
+ }
3853
+ },
3854
+ "shared": {
3855
+ "amis": {
3856
+ "visibleOn": "${global.user.is_space_admin}"
3857
+ }
3858
+ }
3859
+ }
3860
+ }
3861
+
3862
+ const getCopyListviewButtonSchema = ()=>{
3863
+ return {
3864
+ "type": "button",
3865
+ "label": "复制",
3686
3866
  "onEvent": {
3687
3867
  "click": {
3868
+ "weight": 0,
3688
3869
  "actions": [
3689
3870
  {
3690
- "actionType": "custom",
3691
- "script": onFieldsFilterToggleScript
3871
+ "dialog": {
3872
+ "type": "dialog",
3873
+ "title": "复制 列表视图",
3874
+ "data": {
3875
+ "&": "$$",
3876
+ "listName": "${listName}",
3877
+ "targetObjectName": "${objectName}",
3878
+ "list_view": "${uiSchema.list_views[listName]}",
3879
+ "appId": "${appId}",
3880
+ "global": "${global}"
3881
+ },
3882
+ "body": [
3883
+ {
3884
+ "type": "steedos-object-form",
3885
+ "label": "对象表单",
3886
+ "objectApiName": "object_listviews",
3887
+ "recordId": "",
3888
+ "mode": "edit",
3889
+ "defaultData": {
3890
+ "&": "${list_view}",
3891
+ "name":"",
3892
+ "label": "${list_view.label} 的副本",
3893
+ "shared":false
3894
+ },
3895
+ "fieldsExtend": fieldsExtend$3(),
3896
+ "fields": fields(),
3897
+ "onEvent": {
3898
+ "submitSucc": {
3899
+ "weight": 0,
3900
+ "actions": [
3901
+ {
3902
+ "args": {
3903
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3904
+ "blank": false
3905
+ },
3906
+ "actionType": "url",
3907
+ }
3908
+ ]
3909
+ }
3910
+ }
3911
+ }
3912
+ ],
3913
+ "showCloseButton": true,
3914
+ "showErrorMsg": true,
3915
+ "showLoading": true,
3916
+ "closeOnEsc": false,
3917
+ "dataMapSwitch": false,
3918
+ "size": "lg"
3919
+ },
3920
+ "actionType": "dialog"
3692
3921
  }
3693
3922
  ]
3694
3923
  }
3695
3924
  }
3696
- } : {},
3697
- getDisplayAsButton(mainObject?.name)
3925
+ }
3926
+ };
3927
+
3928
+ function fields(){
3929
+ return [
3930
+ "label",
3931
+ "name",
3932
+ "object_name",
3933
+ "filter_scope",
3934
+ "show_count",
3935
+ "columns.$.field",
3936
+ "columns.$.width",
3937
+ "sort.$.field_name",
3938
+ "sort.$.order",
3939
+ "filters",
3940
+ "mobile_columns.$.field",
3941
+ "searchable_fields.$.field",
3942
+ "is_system",
3943
+ "shared"
3698
3944
  ]
3699
- }else {
3700
- return [
3701
- // "filter-toggler",
3702
- ...(headerToolbarItems || []),
3703
- "bulkActions",
3704
- {
3705
- "type": "columns-toggler",
3706
- "className": "hidden"
3707
- },
3708
- // {
3709
- // "type": "columns-toggler",
3710
- // "className": "mr-2"
3711
- // },
3712
- hiddenCount ? {} : {
3713
- "type": "tpl",
3714
- "tpl": "${count} 个项目"
3715
- },
3716
- {
3717
- "type": "reload",
3718
- "align": "right",
3719
- "tooltipPlacement": "bottom",
3720
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
3721
- },
3722
- {
3945
+ }
3946
+
3947
+ function fieldsExtend$3(){
3948
+ return {
3949
+ "label": {
3950
+ "is_wide": true
3951
+ },
3952
+ "name": {
3953
+ "is_wide": true,
3954
+ "amis": {
3955
+ "hidden": true
3956
+ }
3957
+ },
3958
+ "object_name": {
3959
+ "amis": {
3960
+ "hidden": true
3961
+ }
3962
+ },
3963
+ "filter_scope": {
3964
+ "amis": {
3965
+ "hidden": true
3966
+ }
3967
+ },
3968
+ "columns": {
3969
+ "amis": {
3970
+ "hidden": true
3971
+ }
3972
+ },
3973
+ "filter_fields": {
3974
+ "amis": {
3975
+ "hidden": true
3976
+ }
3977
+ },
3978
+ "scrolling_mode": {
3979
+ "amis": {
3980
+ "hidden": true
3981
+ }
3982
+ },
3983
+ "sort": {
3984
+ "amis": {
3985
+ "hidden": true
3986
+ }
3987
+ },
3988
+ "show_count": {
3989
+ "amis": {
3990
+ "hidden": true
3991
+ }
3992
+ },
3993
+ "type": {
3994
+ "amis": {
3995
+ "hidden": true
3996
+ }
3997
+ },
3998
+ "shared": {
3999
+ "amis": {
4000
+ "visibleOn": "${global.user.is_space_admin}"
4001
+ }
4002
+ }
4003
+ }
4004
+ }
4005
+
4006
+ const getRenameListviewButtonSchema = ()=>{
4007
+ return {
3723
4008
  "type": "button",
3724
- "label": "",
3725
- "icon": "fa fa-download",
3726
- "align": "right",
3727
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3728
- "tooltipPlacement": "bottom",
3729
- "visibleOn": "${!isLookup && global.user.is_space_admin}",
3730
- "tooltip": "导出Excel",
4009
+ "label": "重命名",
4010
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3731
4011
  "onEvent": {
3732
4012
  "click": {
3733
4013
  "weight": 0,
3734
4014
  "actions": [
3735
4015
  {
3736
- "args": {
3737
- "api": {
3738
- "url": "${context.rootUrl}/api/record/export/${objectName}",
3739
- "method": "get",
3740
- "messages": {},
3741
- "requestAdaptor": `${getExportApiRequestAdaptorScript()}`,
3742
- "data": {
3743
- "uiSchema": "${uiSchema}",
3744
- "listName": "${listName}"
3745
- },
3746
- "headers": {
3747
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4016
+ "dialog": {
4017
+ "type": "dialog",
4018
+ "title": "重命名 列表视图",
4019
+ "data": {
4020
+ "targetObjectName": "${objectName}",
4021
+ "recordId": "${uiSchema.list_views[listName]._id}",
4022
+ "appId": "${appId}"
4023
+ },
4024
+ "body": [
4025
+ {
4026
+ "type": "steedos-object-form",
4027
+ "label": "对象表单",
4028
+ "objectApiName": "object_listviews",
4029
+ "recordId": "${recordId}",
4030
+ "mode": "edit",
4031
+ "fields": [
4032
+ "label"
4033
+ ],
4034
+ "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
4035
+ "onEvent": {
4036
+ "submitSucc": {
4037
+ "weight": 0,
4038
+ "actions": [
4039
+ {
4040
+ "args": {
4041
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
4042
+ "blank": false
4043
+ },
4044
+ "actionType": "url",
4045
+ },
4046
+ ]
4047
+ }
4048
+ }
3748
4049
  }
3749
- }
4050
+ ],
4051
+ "showCloseButton": true,
4052
+ "showErrorMsg": true,
4053
+ "showLoading": true,
4054
+ "size": "lg"
3750
4055
  },
3751
- "actionType": "download"
4056
+ "actionType": "dialog"
3752
4057
  }
3753
4058
  ]
3754
4059
  }
3755
4060
  }
3756
- },
3757
- filterVisible ? {
3758
- "label": "",
3759
- "icon": "fa fa-search",
4061
+ }
4062
+ };
4063
+
4064
+ const getSetListviewShareButtonSchema = ()=>{
4065
+ return {
3760
4066
  "type": "button",
3761
- "align": "right",
3762
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4067
+ "label": "共享设置",
4068
+ "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
3763
4069
  "onEvent": {
3764
4070
  "click": {
4071
+ "weight": 0,
3765
4072
  "actions": [
3766
4073
  {
3767
- "actionType": "custom",
3768
- "script": onFieldsFilterToggleScript
4074
+ "dialog": {
4075
+ "type": "dialog",
4076
+ "title": "共享设置",
4077
+ "data": {
4078
+ "recordId": "${uiSchema.list_views[listName]._id}",
4079
+ },
4080
+ "body": [
4081
+ {
4082
+ "type": "steedos-object-form",
4083
+ "label": "对象表单",
4084
+ "objectApiName": "object_listviews",
4085
+ "recordId": "${recordId}",
4086
+ "mode": "edit",
4087
+ "fields": [
4088
+ "shared"
4089
+ ]
4090
+ }
4091
+ ],
4092
+ "showCloseButton": true,
4093
+ "showErrorMsg": true,
4094
+ "showLoading": true,
4095
+ "closeOnEsc": false,
4096
+ "dataMapSwitch": false,
4097
+ "size": "md"
4098
+ },
4099
+ "actionType": "dialog"
3769
4100
  }
3770
4101
  ]
3771
4102
  }
3772
4103
  }
3773
- } : {},
3774
- {
3775
- "type": "dropdown-button",
3776
- "trigger": "click",
3777
- "icon": "fa fa-cog",
3778
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3779
- "align": "right",
3780
- "visibleOn": "${!isLookup}",
3781
- "buttons": [
3782
- {
3783
- "label": "列表视图操作",
3784
- "children": [
4104
+ }
4105
+ };
4106
+
4107
+ const getSetListviewFiltersButtonSchema = ()=>{
4108
+ return {
4109
+ "type": "button",
4110
+ "label": "过滤设置",
4111
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4112
+ "onEvent": {
4113
+ "click": {
4114
+ "weight": 0,
4115
+ "actions": [
3785
4116
  {
3786
- "type": "button",
3787
- "label": "新建",
3788
- "onEvent": {
3789
- "click": {
3790
- "weight": 0,
3791
- "actions": [
3792
- {
3793
- "dialog": {
3794
- "type": "dialog",
3795
- "title": "新建 列表视图",
3796
- "data": {
3797
- "&": "$$",
3798
- "all": "${uiSchema.list_views.all}",
3799
- "list_view": "${uiSchema.list_views[listName]}",
3800
- "appId": "${appId}",
3801
- "global": "${global}",
3802
- "targetObjectName": "${objectName}",
3803
- },
3804
- "body": [
4117
+ "dialog": {
4118
+ "type": "dialog",
4119
+ "title": "过滤设置",
4120
+ "data": {
4121
+ "targetObjectName": "${objectName}",
4122
+ "recordId": "${uiSchema.list_views[listName]._id}",
4123
+ "listName": "${listName}",
4124
+ "appId": "${appId}"
4125
+ },
4126
+ "body": [
4127
+ {
4128
+ "type": "steedos-object-form",
4129
+ "label": "对象表单",
4130
+ "objectApiName": "object_listviews",
4131
+ "recordId": "${recordId}",
4132
+ "mode": "edit",
4133
+ "fields": [
4134
+ "filters"
4135
+ ],
4136
+ "initApiAdaptor": initApiAdaptor$2(),
4137
+ "apiRequestAdaptor": apiRequestAdaptor$2(),
4138
+ "fieldsExtend": fieldsExtend$2(),
4139
+ "onEvent": {
4140
+ "submitSucc": {
4141
+ "weight": 0,
4142
+ "actions": [
3805
4143
  {
3806
- "type": "steedos-object-form",
3807
- "label": "对象表单",
3808
- "objectApiName": "object_listviews",
3809
- "recordId": "",
3810
- "mode": "edit",
3811
- "defaultData": {
3812
- "&": "${list_view}",
3813
- "name":"",
3814
- "label":"",
3815
- "filters":"",
3816
- "shared":false
3817
- },
3818
- "fieldsExtend": "{\n \"label\": {\n \"is_wide\": true\n },\n \"name\": {\n \"is_wide\": true,\n \"amis\": {\n \"hidden\": true\n }\n },\n \"object_name\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"filter_scope\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"columns\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"filter_fields\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"scrolling_mode\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"sort\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"show_count\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"type\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"shared\":{\n \"amis\":{\n \"visibleOn\":\"${global.user.is_space_admin}\"\n }\n}\n}",
3819
- "fields": [
3820
- "label",
3821
- "name",
3822
- "object_name",
3823
- "filter_scope",
3824
- "show_count",
3825
- "columns.$.field",
3826
- "columns.$.width",
3827
- "sort.$.field_name",
3828
- "sort.$.order",
3829
- "filters",
3830
- "mobile_columns.$.field",
3831
- "searchable_fields.$.field",
3832
- "is_system",
3833
- "shared"
3834
- ],
3835
- "onEvent": {
3836
- "submitSucc": {
3837
- "weight": 0,
3838
- "actions": [
3839
- {
3840
- "args": {
3841
- // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3842
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3843
- "blank": false
3844
- },
3845
- "actionType": "url",
3846
- }
3847
- ]
3848
- }
3849
- },
3850
- "messages": {
3851
- "success": "成功",
3852
- "failed": "失败"
4144
+ "args": {
4145
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4146
+ "blank": false
3853
4147
  },
4148
+ "actionType": "url",
3854
4149
  }
3855
- ],
3856
- "showCloseButton": true,
3857
- "showErrorMsg": true,
3858
- "showLoading": true,
3859
- "closeOnEsc": false,
3860
- "dataMapSwitch": false,
3861
- "size": "lg"
3862
- },
3863
- "actionType": "dialog"
4150
+ ]
4151
+ }
3864
4152
  }
3865
- ]
3866
- }
3867
- }
3868
- },
4153
+ }
4154
+ ],
4155
+ "showCloseButton": true,
4156
+ "showErrorMsg": true,
4157
+ "showLoading": true,
4158
+ "closeOnEsc": false,
4159
+ "dataMapSwitch": false,
4160
+ "size": "lg"
4161
+ },
4162
+ "actionType": "dialog"
4163
+ }
4164
+ ]
4165
+ }
4166
+ }
4167
+ }
4168
+ };
4169
+
4170
+
4171
+ function initApiAdaptor$2(){
4172
+ return `
4173
+ const recordId_tmp = api.body.recordId;
4174
+ let data_tmp;
4175
+ if (recordId_tmp) {
4176
+ data_tmp = payload.data;
4177
+ // 数据格式转换
4178
+ if (data_tmp) {
4179
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4180
+ try {
4181
+ data_tmp.filters = JSON.parse(data_tmp.filters);
4182
+ } catch (e) { }
4183
+ }
4184
+
4185
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4186
+ data_tmp._filters_type_controller = 'function';
4187
+ } else {
4188
+ data_tmp._filters_type_controller = 'conditions'
4189
+ }
4190
+
4191
+ if (data_tmp._filters_type_controller === 'conditions') {
4192
+ data_tmp._filters_conditions = window.amisConvert.filtersToConditions(data_tmp.filters || []);
4193
+ data_tmp.filters = data_tmp._filters_conditions;
4194
+ } else {
4195
+ data_tmp._filters_function = data_tmp.filters;
4196
+ }
4197
+ }
4198
+ }
4199
+ for (key in data_tmp) {
4200
+ if (data_tmp[key] === null) {
4201
+ delete data_tmp[key];
4202
+ }
4203
+ }
4204
+ payload.data = Object.assign(payload.data, data_tmp);
4205
+ delete payload.extensions;
4206
+ return payload;
4207
+ `
4208
+ }
4209
+
4210
+ function apiRequestAdaptor$2(){
4211
+ return `
4212
+ const recordId = api.body.recordId;
4213
+ if (formData._filters_type_controller === 'conditions' && formData._filters_conditions) {
4214
+ formData.filters = window.amisConvert.conditionsToFilters(formData.filters);
4215
+ } else {
4216
+ formData.filters = formData._filters_function || null;
4217
+ }
4218
+
4219
+ delete formData._filters_type_controller;
4220
+ delete formData._filters_conditions;
4221
+ delete formData._filters_function;
4222
+
4223
+ query = 'mutation{record: ' + objectName + '__insert(doc: {__saveData}){_id}}';
4224
+ if (api.body.recordId) {
4225
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4226
+ };
4227
+ __saveData = JSON.stringify(JSON.stringify(formData));
4228
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4229
+ return api;
4230
+ `
4231
+ }
4232
+
4233
+ function fieldsExtend$2(){
4234
+ return {
4235
+ "filters": {
4236
+ "visible_on": "true",
4237
+ "amis": {
4238
+ "type": "condition-builder",
4239
+ "label": "条件组件1",
4240
+ "source": {
4241
+ "method": "get",
4242
+ "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${targetObjectName}",
4243
+ "dataType": "json",
4244
+ "headers": {
4245
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4246
+ }
4247
+ }
4248
+ }
4249
+ }
4250
+ }
4251
+ }
4252
+
4253
+ const getSetListviewColumnsButtonSchema = ()=>{
4254
+ return {
4255
+ "type": "button",
4256
+ "label": "显示的列",
4257
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4258
+ "onEvent": {
4259
+ "click": {
4260
+ "weight": 0,
4261
+ "actions": [
3869
4262
  {
3870
- "type": "button",
3871
- "label": "复制",
3872
- "onEvent": {
3873
- "click": {
3874
- "weight": 0,
3875
- "actions": [
3876
- {
3877
- "dialog": {
3878
- "type": "dialog",
3879
- "title": "复制 列表视图",
3880
- "data": {
3881
- "&": "$$",
3882
- "listName": "${listName}",
3883
- "targetObjectName": "${objectName}",
3884
- "list_view": "${uiSchema.list_views[listName]}",
3885
- "appId": "${appId}",
3886
- "global": "${global}"
3887
- },
3888
- "body": [
4263
+ "args": {},
4264
+ "dialog": {
4265
+ "type": "dialog",
4266
+ "title": "显示的列",
4267
+ "data": {
4268
+ "&": "$$",
4269
+ "targetObjectName": "${objectName}",
4270
+ "recordId": "${uiSchema.list_views[listName]._id}",
4271
+ "listName": "${listName}",
4272
+ "appId": "${appId}"
4273
+ },
4274
+ "body": [
4275
+ {
4276
+ "type": "steedos-object-form",
4277
+ "label": "对象表单",
4278
+ "objectApiName": "object_listviews",
4279
+ "recordId": "${recordId}",
4280
+ "mode": "edit",
4281
+ "fieldsExtend": fieldsExtend$1(),
4282
+ "initApiAdaptor": initApiAdaptor$1(),
4283
+ "apiRequestAdaptor": apiRequestAdaptor$1(),
4284
+ "fields": [
4285
+ "columns",
4286
+ "mobile_columns"
4287
+ ],
4288
+ "onEvent": {
4289
+ "submitSucc": {
4290
+ "weight": 0,
4291
+ "actions": [
3889
4292
  {
3890
- "type": "steedos-object-form",
3891
- "label": "对象表单",
3892
- "objectApiName": "object_listviews",
3893
- "recordId": "",
3894
- "mode": "edit",
3895
- "fields": [
3896
- ],
3897
- "defaultData": {
3898
- "&": "${list_view}",
3899
- "name":"",
3900
- "label": "${list_view.label}的副本",
3901
- "shared":false
4293
+ "args": {
4294
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4295
+ "blank": false
3902
4296
  },
3903
- "fieldsExtend": "{\n \"label\": {\n \"is_wide\": true\n },\n \"name\": {\n \"is_wide\": true,\n \"amis\": {\n \"hidden\": true\n }\n },\n \"object_name\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"filter_scope\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"columns\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"filter_fields\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"scrolling_mode\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"sort\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"show_count\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"type\": {\n \"amis\": {\n \"hidden\": true\n }\n },\n \"shared\":{\n \"amis\":{\n \"visibleOn\":\"${global.user.is_space_admin}\"\n }\n}\n}",
3904
- "fields": [
3905
- "label",
3906
- "name",
3907
- "object_name",
3908
- "filter_scope",
3909
- "show_count",
3910
- "columns.$.field",
3911
- "columns.$.width",
3912
- "sort.$.field_name",
3913
- "sort.$.order",
3914
- "filters",
3915
- "mobile_columns.$.field",
3916
- "searchable_fields.$.field",
3917
- "is_system",
3918
- "shared"
3919
- ],
3920
- "onEvent": {
3921
- "submitSucc": {
3922
- "weight": 0,
3923
- "actions": [
3924
- {
3925
- "args": {
3926
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
3927
- "blank": false
3928
- },
3929
- "actionType": "url",
3930
- }
3931
- ]
3932
- }
3933
- }
3934
- }
3935
- ],
3936
- "showCloseButton": true,
3937
- "showErrorMsg": true,
3938
- "showLoading": true,
3939
- "closeOnEsc": false,
3940
- "dataMapSwitch": false,
3941
- "size": "lg"
3942
- },
3943
- "actionType": "dialog"
3944
- }
3945
- ]
3946
- }
3947
- }
3948
- },
3949
- {
3950
- "type": "button",
3951
- "label": "重命名",
3952
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3953
- "onEvent": {
3954
- "click": {
3955
- "weight": 0,
3956
- "actions": [
3957
- {
3958
- "dialog": {
3959
- "type": "dialog",
3960
- "title": "重命名 列表视图",
3961
- "data": {
3962
- "targetObjectName": "${objectName}",
3963
- "recordId": "${uiSchema.list_views[listName]._id}",
3964
- "appId": "${appId}"
3965
- },
3966
- "body": [
3967
- {
3968
- "type": "steedos-object-form",
3969
- "label": "对象表单",
3970
- "objectApiName": "object_listviews",
3971
- "recordId": "${recordId}",
3972
- "mode": "edit",
3973
- "fields": [
3974
- "label"
3975
- ],
3976
- "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
3977
- "onEvent": {
3978
- "submitSucc": {
3979
- "weight": 0,
3980
- "actions": [
3981
- {
3982
- "args": {
3983
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
3984
- "blank": false
3985
- },
3986
- "actionType": "url",
3987
- },
3988
- ]
3989
- }
3990
- }
3991
- }
3992
- ],
3993
- "showCloseButton": true,
3994
- "showErrorMsg": true,
3995
- "showLoading": true,
3996
- "size": "lg"
3997
- },
3998
- "actionType": "dialog"
3999
- }
4000
- ]
4001
- }
4002
- }
4003
- },
4004
- {
4005
- "type": "button",
4006
- "label": "共享设置",
4007
- "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
4008
- "onEvent": {
4009
- "click": {
4010
- "weight": 0,
4011
- "actions": [
4012
- {
4013
- "dialog": {
4014
- "type": "dialog",
4015
- "title": "共享设置",
4016
- "data": {
4017
- "recordId": "${uiSchema.list_views[listName]._id}",
4018
- },
4019
- "body": [
4020
- {
4021
- "type": "steedos-object-form",
4022
- "label": "对象表单",
4023
- "objectApiName": "object_listviews",
4024
- "recordId": "${recordId}",
4025
- "mode": "edit",
4026
- "fields": [
4027
- "shared"
4028
- ]
4029
- }
4030
- ],
4031
- "showCloseButton": true,
4032
- "showErrorMsg": true,
4033
- "showLoading": true,
4034
- "closeOnEsc": false,
4035
- "dataMapSwitch": false,
4036
- "size": "md"
4037
- },
4038
- "actionType": "dialog"
4039
- }
4040
- ]
4041
- }
4042
- }
4043
- },
4044
- {
4045
- "type": "button",
4046
- "label": "过滤设置",
4047
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4048
- "onEvent": {
4049
- "click": {
4050
- "weight": 0,
4051
- "actions": [
4052
- {
4053
- "dialog": {
4054
- "type": "dialog",
4055
- "title": "过滤设置",
4056
- "data": {
4057
- "targetObjectName": "${objectName}",
4058
- "objectName": "${objectName}",
4059
- "recordId": "${uiSchema.list_views[listName]._id}",
4060
- "listName": "${listName}",
4061
- "appId": "${appId}"
4062
- },
4063
- "body": [
4064
- {
4065
- "type": "steedos-object-form",
4066
- "label": "对象表单",
4067
- "objectApiName": "object_listviews",
4068
- "recordId": "${recordId}",
4069
- "mode": "edit",
4070
- "fields": [
4071
- "filters"
4072
- ],
4073
- "initApiRequestAdaptor": "",
4074
- "initApiAdaptor": "const recordId_tmp = api.body.recordId;\nlet data_tmp;\nif (recordId_tmp) {\n data_tmp = payload.data;\n // 数据格式转换\n if (data_tmp) {\n if (data_tmp.filters && lodash.isString(data_tmp.filters)) {\n try {\n data_tmp.filters = JSON.parse(data_tmp.filters);\n } catch (e) { }\n }\n\n if (data_tmp.filters && lodash.isString(data_tmp.filters)) {\n data_tmp._filters_type_controller = 'function';\n } else {\n data_tmp._filters_type_controller = 'conditions'\n }\n\n if (data_tmp._filters_type_controller === 'conditions') {\n data_tmp._filters_conditions = window.amisConvert.filtersToConditions(data_tmp.filters || []);\n data_tmp.filters = data_tmp._filters_conditions;\n } else {\n data_tmp._filters_function = data_tmp.filters;\n }\n }\n}\nfor (key in data_tmp) {\n if (data_tmp[key] === null) {\n delete data_tmp[key];\n }\n}\npayload.data = Object.assign(payload.data, data_tmp);\ndelete payload.extensions;",
4075
- "apiRequestAdaptor": "const recordId = api.body.recordId;\nif (formData._filters_type_controller === 'conditions' && formData._filters_conditions) {\n formData.filters = window.amisConvert.conditionsToFilters(formData.filters);\n} else {\n formData.filters = formData._filters_function || null;\n}\n\ndelete formData._filters_type_controller;\ndelete formData._filters_conditions;\ndelete formData._filters_function;\n// 字符串拼接(不支持ES6``语法)\nquery = 'mutation{record: ' + objectName + '__insert(doc: {__saveData}){_id}}';\nif (api.body.recordId) {\n query = 'mutation{record: ' + objectName + '__update(id: \"' + recordId + '\", doc: {__saveData}){_id}}';\n};\n__saveData = JSON.stringify(JSON.stringify(formData));\napi.data = { query: query.replace('{__saveData}', __saveData) };\n",
4076
- "fieldsExtend": "{\"filters\": {\n \"visible_on\": \"true\",\n \"amis\": {\n \"type\": \"condition-builder\",\n \"label\": \"条件组件\",\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${objectName}\",\n \"dataType\": \"json\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n }\n}",
4077
- "onEvent": {
4078
- "submitSucc": {
4079
- "weight": 0,
4080
- "actions": [
4081
- {
4082
- "args": {
4083
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4084
- "blank": false
4085
- },
4086
- "actionType": "url",
4087
- }
4088
- ]
4089
- }
4090
- }
4091
- }
4092
- ],
4093
- "showCloseButton": true,
4094
- "showErrorMsg": true,
4095
- "showLoading": true,
4096
- "closeOnEsc": false,
4097
- "dataMapSwitch": false,
4098
- "size": "lg"
4099
- },
4100
- "actionType": "dialog"
4101
- }
4102
- ]
4103
- }
4104
- }
4105
- },
4106
- {
4107
- "type": "button",
4108
- "label": "显示的列",
4109
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4110
- "onEvent": {
4111
- "click": {
4112
- "weight": 0,
4113
- "actions": [
4114
- {
4115
- "args": {},
4116
- "dialog": {
4117
- "type": "dialog",
4118
- "title": "显示的列",
4119
- "data": {
4120
- "&": "$$",
4121
- "targetObjectName": "${objectName}",
4122
- "objectName": "${objectName}",
4123
- "recordId": "${uiSchema.list_views[listName]._id}",
4124
- "listName": "${listName}",
4125
- "appId": "${appId}"
4126
- },
4127
- "body": [
4128
- {
4129
- "type": "steedos-object-form",
4130
- "label": "对象表单",
4131
- "objectApiName": "object_listviews",
4132
- "recordId": "${recordId}",
4133
- "mode": "edit",
4134
- "fieldsExtend": "{\n \"columns\": {\n \"amis\": {\n \"type\": \"transfer\",\n \"sortable\": true,\n \"searchable\": true,\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/fields/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n },\n \"mobile_columns\": {\n \"group\": \"手机端\",\n \"amis\": {\n \"type\": \"transfer\",\n \"sortable\": true,\n \"searchable\": true,\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/fields/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n }\n}",
4135
- "initApiAdaptor": "const recordId_tmp = api.body.recordId;\nlet columns_tmp = {}, mobile_columns_tmp = {};\nif (recordId_tmp) {\n columns_tmp = payload.data.columns;\n mobile_columns_tmp = payload.data.mobile_columns;\n if (columns_tmp) {\n columns_tmp = lodash.map(columns_tmp, 'field');\n }\n if (mobile_columns_tmp) {\n mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');\n }\n}\npayload.data.columns = columns_tmp;\npayload.data.mobile_columns = mobile_columns_tmp;\n\ndelete payload.extensions;\nreturn payload;",
4136
- "apiRequestAdaptor": "const formData_tmp = api.body.$;\nconst objectName_tmp = api.body.objectName;\nconst recordId_tmp = api.body.recordId;\n\nif (typeof formData_tmp.columns == 'string') {\n formData_tmp.columns = formData_tmp.columns?.split(',');\n}\nif (typeof formData_tmp.mobile_columns == 'string') {\n formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');\n}\n\n// 数据格式转换\nformData_tmp.columns = lodash.map(formData_tmp.columns, (item) => {\n return { field: item };\n});\nformData.mobile_columns = lodash.map(formData.mobile_columns, (item) => {\n return { field: item };\n});\n\n// 字符串拼接(不支持ES6语法)\nlet query_tmp = 'mutation{record: ' + objectName_tmp + '__insert(doc: {__saveData}){_id}}';\nif (api.body.recordId) {\n query_tmp = 'mutation{record: ' + objectName_tmp + '__update(id: \"' + recordId_tmp +'\", doc: {__saveData}){_id}}';\n};\ndelete formData_tmp._id;\nlet __saveData_tmp = JSON.stringify(JSON.stringify(formData_tmp));\napi.data = { query: query_tmp.replace('{__saveData}', __saveData_tmp) };\n\nreturn api;",
4137
- "fields": [
4138
- "columns",
4139
- "mobile_columns"
4140
- ],
4141
- "onEvent": {
4142
- "submitSucc": {
4143
- "weight": 0,
4144
- "actions": [
4145
- {
4146
- "args": {
4147
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4148
- "blank": false
4149
- },
4150
- "actionType": "url"
4151
- }
4152
- ]
4153
- }
4154
- }
4297
+ "actionType": "url"
4155
4298
  }
4156
- ],
4157
- "searchable": true,
4158
- "showCloseButton": true,
4159
- "showErrorMsg": true,
4160
- "showLoading": true,
4161
- "size": "lg"
4162
- },
4163
- "actionType": "dialog"
4299
+ ]
4300
+ }
4164
4301
  }
4165
- ]
4166
- }
4167
- }
4168
- },
4302
+ }
4303
+ ],
4304
+ "searchable": true,
4305
+ "showCloseButton": true,
4306
+ "showErrorMsg": true,
4307
+ "showLoading": true,
4308
+ "size": "lg"
4309
+ },
4310
+ "actionType": "dialog"
4311
+ }
4312
+ ]
4313
+ }
4314
+ }
4315
+ }
4316
+ };
4317
+
4318
+ function fieldsExtend$1(){
4319
+ return {
4320
+ "columns": {
4321
+ "amis": {
4322
+ "type": "transfer",
4323
+ "sortable": true,
4324
+ "searchable": true,
4325
+ "source": {
4326
+ "method": "get",
4327
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4328
+ "headers": {
4329
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4330
+ }
4331
+ }
4332
+ }
4333
+ },
4334
+ "mobile_columns": {
4335
+ "group": "手机端",
4336
+ "amis": {
4337
+ "type": "transfer",
4338
+ "sortable": true,
4339
+ "searchable": true,
4340
+ "source": {
4341
+ "method": "get",
4342
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4343
+ "headers": {
4344
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4345
+ }
4346
+ }
4347
+ }
4348
+ }
4349
+ }
4350
+ }
4351
+
4352
+ function initApiAdaptor$1(){
4353
+ return `
4354
+ const recordId_tmp = api.body.recordId;
4355
+ let columns_tmp = {}, mobile_columns_tmp = {};
4356
+ if (recordId_tmp) {
4357
+ columns_tmp = payload.data.columns;
4358
+ mobile_columns_tmp = payload.data.mobile_columns;
4359
+ if (columns_tmp) {
4360
+ columns_tmp = lodash.map(columns_tmp, 'field');
4361
+ }
4362
+ if (mobile_columns_tmp) {
4363
+ mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');
4364
+ }
4365
+ }
4366
+ payload.data.columns = columns_tmp;
4367
+ payload.data.mobile_columns = mobile_columns_tmp;
4368
+
4369
+ delete payload.extensions;
4370
+ return payload;
4371
+ `
4372
+ }
4373
+
4374
+ function apiRequestAdaptor$1(){
4375
+ return `
4376
+ const formData_tmp = api.body.$;
4377
+ const objectName_tmp = api.body.objectName;
4378
+ const recordId_tmp = api.body.recordId;
4379
+
4380
+ if (typeof formData_tmp.columns == 'string') {
4381
+ formData_tmp.columns = formData_tmp.columns?.split(',');
4382
+ }
4383
+ if (typeof formData_tmp.mobile_columns == 'string') {
4384
+ formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');
4385
+ }
4386
+
4387
+ // 数据格式转换
4388
+ formData_tmp.columns = lodash.map(formData_tmp.columns, (item) => {
4389
+ return { field: item };
4390
+ });
4391
+ formData.mobile_columns = lodash.map(formData.mobile_columns, (item) => {
4392
+ return { field: item };
4393
+ });
4394
+
4395
+ let query_tmp = 'mutation{record: ' + objectName_tmp + '__insert(doc: {__saveData}){_id}}';
4396
+ if (api.body.recordId) {
4397
+ query_tmp = 'mutation{record: ' + objectName_tmp + '__update(id: "' + recordId_tmp +'", doc: {__saveData}){_id}}';
4398
+ };
4399
+ delete formData_tmp._id;
4400
+ let __saveData_tmp = JSON.stringify(JSON.stringify(formData_tmp));
4401
+ api.data = { query: query_tmp.replace('{__saveData}', __saveData_tmp) };
4402
+
4403
+ return api;
4404
+ `
4405
+ }
4406
+
4407
+ const getSetListviewSortButtonSchema = ()=>{
4408
+ return {
4409
+ "type": "button",
4410
+ "label": "默认排序规则",
4411
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4412
+ "onEvent": {
4413
+ "click": {
4414
+ "weight": 0,
4415
+ "actions": [
4169
4416
  {
4170
- "type": "button",
4171
- "label": "默认排序规则",
4172
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4173
- "onEvent": {
4174
- "click": {
4175
- "weight": 0,
4176
- "actions": [
4177
- {
4178
- "dialog": {
4179
- "type": "dialog",
4180
- "title": "弹框标题",
4181
- "data": {
4182
- "&": "$$",
4183
- "targetObjectName": "${objectName}",
4184
- "objectName": "${objectName}",
4185
- "recordId": "${uiSchema.list_views[listName]._id}",
4186
- "listName": "${listName}",
4187
- "appId": "${appId}"
4188
- },
4189
- "body": [
4417
+ "dialog": {
4418
+ "type": "dialog",
4419
+ "title": "默认排序规则",
4420
+ "data": {
4421
+ "&": "$$",
4422
+ "targetObjectName": "${objectName}",
4423
+ "recordId": "${uiSchema.list_views[listName]._id}",
4424
+ "listName": "${listName}",
4425
+ "appId": "${appId}"
4426
+ },
4427
+ "body": [
4428
+ {
4429
+ "type": "steedos-object-form",
4430
+ "label": "对象表单",
4431
+ "objectApiName": "object_listviews",
4432
+ "recordId": "${recordId}",
4433
+ "className": "",
4434
+ "id": "u:061f158b4c5a",
4435
+ "mode": "edit",
4436
+ "fields": [
4437
+ "sort",
4438
+ "sort.$.field_name",
4439
+ "sort.$.order"
4440
+ ],
4441
+ "onEvent": {
4442
+ "submitSucc": {
4443
+ "weight": 0,
4444
+ "actions": [
4190
4445
  {
4191
- "type": "steedos-object-form",
4192
- "label": "对象表单",
4193
- "objectApiName": "object_listviews",
4194
- "recordId": "${recordId}",
4195
- "className": "",
4196
- "id": "u:061f158b4c5a",
4197
- "mode": "edit",
4198
- "fields": [
4199
- "sort",
4200
- "sort.$.field_name",
4201
- "sort.$.order"
4202
- ],
4203
- "onEvent": {
4204
- "submitSucc": {
4205
- "weight": 0,
4206
- "actions": [
4207
- {
4208
- "args": {
4209
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4210
- "blank": false
4211
- },
4212
- "actionType": "url"
4213
- }
4214
- ]
4215
- }
4446
+ "args": {
4447
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4448
+ "blank": false
4216
4449
  },
4217
- "fieldsExtend": "{\n \"sort\": {\n \"amis\": {\n \"type\": \"tabs-transfer\",\n \"sortable\": true,\n \"searchable\": true,\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/${objectName}/sortFields/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n }\n }\n }\n}",
4218
- "initApiAdaptor": "let sort;\nif (recordId) {\n sort = payload.data.sort;\n //数据格式转换\n if (sort instanceof Array) {\n sort = lodash.map(sort, (item) => {\n return item.field_name + ':' + (item.order || 'asc')\n });\n }\n}\npayload.data.sort = sort;\ndelete payload.extensions;",
4219
- "apiRequestAdaptor": "const recordId = api.body.recordId;\n//数据格式转换\nif (typeof formData.sort == 'string') {\n formData.sort = formData.sort?.split(',');\n}\nformData.sort = lodash.map(formData.sort, (item) => {\n const arr = item.split(':');\n return { field_name: arr[0], order: arr[1] };\n});\nif (recordId) {\n query = 'mutation{record: ' + objectName + '__update(id: \"' + recordId + '\", doc: {__saveData}){_id}}';\n}\n__saveData = JSON.stringify(JSON.stringify(formData));\napi.data = { query: query.replace('{__saveData}', __saveData) };\n"
4450
+ "actionType": "url"
4220
4451
  }
4221
- ],
4222
- "showCloseButton": true,
4223
- "showErrorMsg": true,
4224
- "showLoading": true,
4225
- "id": "u:d3f6947b6acf",
4226
- "size": "lg"
4227
- },
4228
- "actionType": "dialog"
4229
- }
4230
- ]
4231
- }
4232
- }
4233
- },
4234
- {
4235
- "type": "button",
4236
- "label": "删除",
4237
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4238
- "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4239
- "onEvent": {
4240
- "click": {
4241
- "actions": [
4242
- {
4243
- "actionType": "ajax",
4244
- "args": {
4245
- "api": {
4246
- "url": "${context.rootUrl}/graphql",
4247
- "method": "post",
4248
- "headers": {
4249
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4250
- },
4251
- "data": {
4252
- "&": "$$",
4253
- "uiSchema": "${uiSchema}",
4254
- "recordId": "${uiSchema.list_views[listName]._id}"
4255
- },
4256
- "messages": {
4257
- "success": "删除成功"
4258
- },
4259
- "requestAdaptor": "const { recordId } = api.body;\nvar deleteArray = [];\nif (recordId) { deleteArray.push(`delete:object_listviews__delete(id: \"${recordId}\")`); }\napi.data = { query: `mutation{${deleteArray.join(',')}}` };\n return api;\n",
4260
- "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n}\nreturn payload;",
4261
- }
4452
+ ]
4262
4453
  }
4263
4454
  },
4264
- {
4265
- "actionType": "url",
4266
- "args": {
4267
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4268
- "blank": false
4269
- },
4270
- "expression": "data.delete == 1"
4271
- }
4272
- ]
4455
+ "fieldsExtend": fieldsExtend(),
4456
+ "initApiAdaptor": initApiAdaptor(),
4457
+ "apiRequestAdaptor": apiRequestAdaptor()
4458
+ }
4459
+ ],
4460
+ "showCloseButton": true,
4461
+ "showErrorMsg": true,
4462
+ "showLoading": true,
4463
+ "id": "u:d3f6947b6acf",
4464
+ "size": "lg"
4465
+ },
4466
+ "actionType": "dialog"
4467
+ }
4468
+ ]
4469
+ }
4470
+ }
4471
+ }
4472
+ };
4473
+
4474
+ function fieldsExtend(){
4475
+ return {
4476
+ "sort": {
4477
+ "amis": {
4478
+ "type": "tabs-transfer",
4479
+ "sortable": true,
4480
+ "searchable": true,
4481
+ "source": {
4482
+ "method": "get",
4483
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/sortFields/options",
4484
+ "headers": {
4485
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4486
+ }
4487
+ }
4488
+ }
4489
+ }
4490
+ }
4491
+ }
4492
+
4493
+ function initApiAdaptor(){
4494
+ return `
4495
+ let sort;
4496
+ if (recordId) {
4497
+ sort = payload.data.sort;
4498
+ //数据格式转换
4499
+ if (sort instanceof Array) {
4500
+ sort = lodash.map(sort, (item) => {
4501
+ return item.field_name + ':' + (item.order || 'asc')
4502
+ });
4503
+ }
4504
+ }
4505
+ payload.data.sort = sort;
4506
+ delete payload.extensions;
4507
+ return payload;
4508
+ `
4509
+ }
4510
+
4511
+ function apiRequestAdaptor(){
4512
+ return `
4513
+ const recordId = api.body.recordId;
4514
+ //数据格式转换
4515
+ if (typeof formData.sort == 'string') {
4516
+ formData.sort = formData.sort?.split(',');
4517
+ }
4518
+ formData.sort = lodash.map(formData.sort, (item) => {
4519
+ const arr = item.split(':');
4520
+ return { field_name: arr[0], order: arr[1] };
4521
+ });
4522
+ if (recordId) {
4523
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4524
+ }
4525
+ __saveData = JSON.stringify(JSON.stringify(formData));
4526
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4527
+ return api;
4528
+ `
4529
+ }
4530
+
4531
+ const getDeleteListviewButtonSchema = ()=>{
4532
+ return {
4533
+ "type": "button",
4534
+ "label": "删除",
4535
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4536
+ "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4537
+ "onEvent": {
4538
+ "click": {
4539
+ "actions": [
4540
+ {
4541
+ "actionType": "ajax",
4542
+ "args": {
4543
+ "api": {
4544
+ "url": "${context.rootUrl}/graphql",
4545
+ "method": "post",
4546
+ "headers": {
4547
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4548
+ },
4549
+ "data": {
4550
+ "&": "$$",
4551
+ "uiSchema": "${uiSchema}",
4552
+ "recordId": "${uiSchema.list_views[listName]._id}"
4553
+ },
4554
+ "messages": {
4555
+ "success": "删除成功"
4556
+ },
4557
+ "requestAdaptor": requestAdaptor(),
4558
+ "adaptor": adaptor(),
4273
4559
  }
4274
4560
  }
4275
4561
  },
4276
- {
4277
- "type": "button",
4278
- "visibleOn": "${false}",
4279
- "label": "保存宽度(todo)"
4280
- },
4281
- // {
4282
- // type: 'steedos-object-button',
4283
- // name: 'standard_delete',
4284
- // objectName: 'test0321__c',
4285
- // // visibleOn: getButtonVisibleOn(button),
4286
- // className: 'antd-Button--default'
4287
- // }
4562
+ {
4563
+ "actionType": "url",
4564
+ "args": {
4565
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4566
+ "blank": false
4567
+ },
4568
+ "expression": "data.delete == 1"
4569
+ }
4570
+ ]
4571
+ }
4572
+ }
4573
+ }
4574
+ };
4575
+
4576
+
4577
+ function requestAdaptor(){
4578
+ return `
4579
+ const { recordId } = api.body;
4580
+ var deleteArray = [];
4581
+ if (recordId) { deleteArray.push(\`delete:object_listviews__delete(id: "\${recordId}")\`); }
4582
+ api.data = { query: \`mutation{\${deleteArray.join(',')}}\` };
4583
+ return api;
4584
+ `
4585
+ }
4586
+
4587
+ function adaptor(){
4588
+ return `
4589
+ if (payload.errors) {
4590
+ payload.status = 2;
4591
+ payload.msg = payload.errors[0].message;
4592
+ }
4593
+ return payload;
4594
+ `
4595
+ }
4596
+
4597
+ const getSettingListviewToolbarButtonSchema = ()=>{
4598
+ return {
4599
+ "type": "dropdown-button",
4600
+ "trigger": "click",
4601
+ "icon": "fa fa-cog",
4602
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4603
+ "align": "right",
4604
+ "visibleOn": "${!isLookup}",
4605
+ "buttons": [
4606
+ {
4607
+ "label": "列表视图操作",
4608
+ "children": [
4609
+ getNewListviewButtonSchema(),
4610
+ getCopyListviewButtonSchema(),
4611
+ getRenameListviewButtonSchema(),
4612
+ getSetListviewShareButtonSchema(),
4613
+ getSetListviewFiltersButtonSchema(),
4614
+ getSetListviewColumnsButtonSchema(),
4615
+ getSetListviewSortButtonSchema(),
4616
+ getDeleteListviewButtonSchema()
4288
4617
  ]
4289
4618
  }
4290
4619
  ]
4620
+ }
4621
+ };
4622
+
4623
+ const getDisplayAsButton = function(objectName, showDisplayAs){
4624
+ let displayAs = Router$1.getTabDisplayAs(objectName);
4625
+ let buttons = [
4626
+ {
4627
+ "type": "button",
4628
+ "label": "表格",
4629
+ "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');",
4630
+ "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
4631
+ "rightIconClassName": "m-l-sm"
4632
+ },
4633
+ {
4634
+ "type": "button",
4635
+ "label": "分栏视图",
4636
+ "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
4637
+ "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
4638
+ "rightIconClassName": "m-l-sm"
4639
+ }
4640
+ ];
4641
+ return {
4642
+ "type": "dropdown-button",
4643
+ "icon": "fa fa-table-columns",
4644
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4645
+ "align": "right",
4646
+ "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
4647
+ "buttons": [
4648
+ {
4649
+ "label": "显示为",
4650
+ "children": buttons
4651
+ }
4652
+ ]
4653
+ };
4654
+ };
4655
+
4656
+
4657
+ const onFieldsFilterToggleScript = `
4658
+ const scope = event.context.scoped;
4659
+ const filterForm = scope.getComponents().find(function(n){
4660
+ return n.props.type === "form";
4661
+ });
4662
+ const filterService = filterForm.context.getComponents().find(function(n){
4663
+ return n.props.type === "service";
4664
+ });
4665
+ // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
4666
+ let resizeWindow = function(){
4667
+ //触发amis crud 高度重算
4668
+ setTimeout(()=>{
4669
+ window.dispatchEvent(new Event("resize"))
4670
+ }, 500);
4671
+ }
4672
+ let isMobile = Steedos.isMobile();
4673
+ if(filterService.props.data.showFieldsFilter){
4674
+ if(isMobile){
4675
+ // 手机上只能通过取消按钮来关闭搜索栏
4676
+ return;
4677
+ }
4678
+ let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
4679
+ direction: "down",
4680
+ name: "btn_filter_form_cancel"
4681
+ });
4682
+ buttonCancel.props.dispatchEvent('click', {}).then(function(){
4683
+ resizeWindow();
4684
+ });
4685
+ }
4686
+ else{
4687
+ filterService.setData({showFieldsFilter: true});
4688
+ resizeWindow();
4689
+ if(isMobile){
4690
+ // 手机端在显示搜索栏时隐藏刷新按钮
4691
+ let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
4692
+ crudService && crudService.setData({showFieldsFilter: true});
4693
+ }
4694
+ }
4695
+ `;
4696
+
4697
+
4698
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
4699
+ // console.log(`getObjectHeaderToolbar====>`, filterVisible)
4700
+ const isMobile = window.innerWidth < 768;
4701
+ if(isMobile){
4702
+ showDisplayAs = false;
4703
+ }
4704
+ if(formFactor === 'SMALL'){
4705
+ const onReloadScript = `
4706
+ const scope = event.context.scoped;
4707
+ var listView = scope.parent.getComponents().find(function(n){
4708
+ return n.props.type === "crud";
4709
+ });
4710
+ listView.handleChangePage(1);
4711
+ `;
4712
+ return [
4713
+ // "bulkActions",
4714
+ ...(headerToolbarItems || []),
4715
+ hiddenCount ? {} :{
4716
+ "type": "tpl",
4717
+ "tpl": "${count} 个项目"
4718
+ },
4719
+ {
4720
+ // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
4721
+ "type": "button",
4722
+ "align": "right",
4723
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4724
+ "label": "",
4725
+ "icon": "fa fa-sync",
4726
+ "visibleOn": "${!showFieldsFilter}",
4727
+ "onEvent": {
4728
+ "click": {
4729
+ "actions": [
4730
+ {
4731
+ "actionType": "custom",
4732
+ "script": onReloadScript
4733
+ }
4734
+ ]
4735
+ }
4736
+ },
4737
+ },
4738
+ filterVisible ? {
4739
+ "label": "",
4740
+ "icon": "fa fa-search",
4741
+ "type": "button",
4742
+ "badge": {
4743
+ "offset": [
4744
+ -5,
4745
+ 1
4746
+ ],
4747
+ "size":8,
4748
+ "animation": true,
4749
+ "visibleOn": "${isFieldsFilterEmpty == false}"
4750
+ },
4751
+ "align": "right",
4752
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4753
+ "onEvent": {
4754
+ "click": {
4755
+ "actions": [
4756
+ {
4757
+ "actionType": "custom",
4758
+ "script": onFieldsFilterToggleScript
4759
+ }
4760
+ ]
4761
+ }
4762
+ }
4763
+ } : {},
4764
+ getDisplayAsButton(mainObject?.name)
4765
+ ]
4766
+ }else {
4767
+ return [
4768
+ // "filter-toggler",
4769
+ ...(headerToolbarItems || []),
4770
+ "bulkActions",
4771
+ {
4772
+ "type": "columns-toggler",
4773
+ "className": "hidden"
4774
+ },
4775
+ // {
4776
+ // "type": "columns-toggler",
4777
+ // "className": "mr-2"
4778
+ // },
4779
+ hiddenCount ? {} : {
4780
+ "type": "tpl",
4781
+ "tpl": "${count} 个项目"
4782
+ },
4783
+ {
4784
+ "type": "reload",
4785
+ "align": "right",
4786
+ "tooltipPlacement": "bottom",
4787
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
4291
4788
  },
4789
+ getExportExcelToolbarButtonSchema(),
4790
+ filterVisible ? {
4791
+ "label": "",
4792
+ "icon": "fa fa-search",
4793
+ "type": "button",
4794
+ "align": "right",
4795
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4796
+ "onEvent": {
4797
+ "click": {
4798
+ "actions": [
4799
+ {
4800
+ "actionType": "custom",
4801
+ "script": onFieldsFilterToggleScript
4802
+ }
4803
+ ]
4804
+ }
4805
+ }
4806
+ } : {},
4807
+ getSettingListviewToolbarButtonSchema(),
4292
4808
  getDisplayAsButton(showDisplayAs)
4293
4809
  // {
4294
4810
  // "type": "search-box",
@@ -4767,20 +5283,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
4767
5283
  }
4768
5284
  }
4769
5285
 
4770
- var searchableFilter = [];
4771
- _.each(selfData, (value, key)=>{
4772
- if(!_.isEmpty(value) || _.isBoolean(value)){
4773
- if(_.startsWith(key, '__searchable__between__')){
4774
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
4775
- }else if(_.startsWith(key, '__searchable__')){
4776
- if(_.isString(value)){
4777
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
4778
- }else{
4779
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
4780
- }
4781
- }
4782
- }
4783
- });
5286
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
4784
5287
 
4785
5288
  if(searchableFilter.length > 0){
4786
5289
  if(filters.length > 0 ){
@@ -5513,23 +6016,6 @@ const getAmisFileSchema = (steedosField, readonly)=>{
5513
6016
  return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
5514
6017
  };
5515
6018
 
5516
- /*
5517
- * @Author: baozhoutao@steedos.com
5518
- * @Date: 2022-07-20 16:29:22
5519
- * @LastEditors: Please set LastEditors
5520
- * @LastEditTime: 2023-05-11 11:19:54
5521
- * @Description:
5522
- */
5523
-
5524
- function getContrastColor(bgColor) {
5525
- var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
5526
- var r = parseInt(backgroundColor.substr(0, 2), 16);
5527
- var g = parseInt(backgroundColor.substr(2, 2), 16);
5528
- var b = parseInt(backgroundColor.substr(4, 2), 16);
5529
- var brightness = (r * 299 + g * 587 + b * 114) / 1000;
5530
- return brightness >= 128 ? "#000000" : "#ffffff";
5531
- }
5532
-
5533
6019
  const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
5534
6020
  // const Lookup = require('./lookup');
5535
6021
 
@@ -5720,19 +6206,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
5720
6206
  // break;
5721
6207
  case 'select':
5722
6208
  if(readonly){
5723
- const selectOptions = field.options;
5724
- let map = {};
5725
- _$1.forEach(selectOptions,(option)=>{
5726
- const optionValue = option.value + '';
5727
- if(option.color){
5728
- const background = '#'+option.color;
5729
- const color = getContrastColor(background);
5730
- const optionColorStyle = 'background:'+background+';color:'+color;
5731
- map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
5732
- }else {
5733
- map[optionValue] = option.label;
5734
- }
5735
- });
6209
+ const map = getSelectMap(field.options);
5736
6210
  convertData = {
5737
6211
  type: "static-mapping",
5738
6212
  name: field.name,
@@ -6431,7 +6905,8 @@ async function getEditFormInitApi(object, recordId, fields, options){
6431
6905
  data.global = "${global}";
6432
6906
  data.context = "${context}";
6433
6907
  data.defaultData = "${defaultData}";
6434
-
6908
+ data._master = "${_master}";
6909
+
6435
6910
  return {
6436
6911
  method: "post",
6437
6912
  url: getApi$2() + '&objectName=${objectName}' ,
@@ -6497,7 +6972,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
6497
6972
  formInitialValuesFun = new Function("return " + formInitialValuesFun)();
6498
6973
  }
6499
6974
  if(typeof formInitialValuesFun === "function"){
6500
- initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global})
6975
+ initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global, master: api.body._master })
6501
6976
  }
6502
6977
  }
6503
6978
  catch(ex){
@@ -6848,7 +7323,7 @@ async function getObjectCRUD(objectSchema, fields, options){
6848
7323
  id: `service_${id}`,
6849
7324
  name: `page`,
6850
7325
  data: {
6851
- // objectName: objectSchema.name,
7326
+ objectName: objectSchema.name,
6852
7327
  // _id: null,
6853
7328
  recordPermissions: objectSchema.permissions,
6854
7329
  uiSchema: objectSchema,
@@ -7153,19 +7628,7 @@ async function getTableColumns(fields, options){
7153
7628
  }, field.amis, {name: field.name}));
7154
7629
  }
7155
7630
  else if(field.type === 'select'){
7156
- const selectOptions = field.options;
7157
- let map = {};
7158
- forEach(selectOptions,(option)=>{
7159
- const optionValue = option.value + '';
7160
- if(option.color){
7161
- const background = '#'+option.color;
7162
- const color = getContrastColor(background);
7163
- const optionColorStyle = 'background:'+background+';color:'+color;
7164
- map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
7165
- }else {
7166
- map[optionValue] = option.label;
7167
- }
7168
- });
7631
+ const map = getSelectMap(field.options);
7169
7632
  columns.push(Object.assign({}, {
7170
7633
  type: "mapping",
7171
7634
  name: field.name,
@@ -7666,20 +8129,8 @@ async function getTableApi(mainObject, fields, options){
7666
8129
  }else if(selfData.op === 'loadOptions' && selfData.value){
7667
8130
  userFilters = [["${valueField.name}", "=", selfData.value]];
7668
8131
  }
7669
- var searchableFilter = [];
7670
- _.each(selfData, (value, key)=>{
7671
- if(!_.isEmpty(value) || _.isBoolean(value)){
7672
- if(_.startsWith(key, '__searchable__between__')){
7673
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
7674
- }else if(_.startsWith(key, '__searchable__')){
7675
- if(_.isString(value)){
7676
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
7677
- }else{
7678
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
7679
- }
7680
- }
7681
- }
7682
- });
8132
+
8133
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
7683
8134
 
7684
8135
  if(searchableFilter.length > 0){
7685
8136
  if(userFilters.length > 0 ){
@@ -7730,11 +8181,10 @@ async function getTableApi(mainObject, fields, options){
7730
8181
  if(api.data.$self._isRelated){
7731
8182
  const self = api.data.$self;
7732
8183
  const relatedKey = self.relatedKey;
7733
- const recordId = self.recordId;
7734
8184
  const refField = self.uiSchema.fields[relatedKey];
7735
8185
  const masterRecord = self._master.record;
7736
8186
  const masterObjectName = self._master.objectName;
7737
- let relatedValue = recordId;
8187
+ let relatedValue = self._master.recordId;
7738
8188
  if(refField.reference_to_field && refField.reference_to_field != '_id'){
7739
8189
  relatedValue = masterRecord[refField.reference_to_field]
7740
8190
  }
@@ -7950,20 +8400,7 @@ async function getCalendarApi(mainObject, fields, options) {
7950
8400
  }else if(selfData.op === 'loadOptions' && selfData.value){
7951
8401
  filters = [["${valueField.name}", "=", selfData.value]];
7952
8402
  }
7953
- var searchableFilter = [];
7954
- _.each(selfData, (value, key)=>{
7955
- if(!_.isEmpty(value) || _.isBoolean(value)){
7956
- if(_.startsWith(key, '__searchable__between__')){
7957
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
7958
- }else if(_.startsWith(key, '__searchable__')){
7959
- if(_.isString(value)){
7960
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
7961
- }else{
7962
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
7963
- }
7964
- }
7965
- }
7966
- });
8403
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
7967
8404
 
7968
8405
  if(searchableFilter.length > 0){
7969
8406
  if(filters.length > 0 ){
@@ -8489,7 +8926,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
8489
8926
  * @Author: baozhoutao@steedos.com
8490
8927
  * @Date: 2022-07-05 15:55:39
8491
8928
  * @LastEditors: Please set LastEditors
8492
- * @LastEditTime: 2023-05-08 16:34:25
8929
+ * @LastEditTime: 2023-05-17 09:09:33
8493
8930
  * @Description:
8494
8931
  */
8495
8932
 
@@ -8629,7 +9066,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
8629
9066
  // } else {
8630
9067
  // globalFilter = [`${relatedKey}`, "=", relatedValue];
8631
9068
  // }
8632
- const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
9069
+ const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
8633
9070
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
8634
9071
  const options = {
8635
9072
  globalFilter,
@@ -12218,5 +12655,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
12218
12655
  };
12219
12656
  };
12220
12657
 
12221
- export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
12658
+ export { index as Field, Router, absoluteUrl, amisRender, amisRootClick, cloneObject, conditionsToFilters, createObject, defaultsDeep, deleteVariable, execute, executeButton, extendObject, fetchAPI, filtersToConditions, getApp, getApps, getAuthToken, getAuthorization, getButton, getButtonVisible, getButtonVisibleOn$1 as getButtonVisibleOn, getButtons, getCalendarSchema, getDefaultRenderData, getEnv, getEnvs, getEvn, getField, getFileSrc, getFlowFormSchema, getFormPageInitSchema, getFormSchema, getIdsPickerSchema, getImageSrc, getInstanceInfo, getListPageInitSchema, getListSchema, getListViewButtons, getListViewColumns, getListViewFilter, getListViewItemButtons, getListViewSort, getListviewInitSchema, getLookupSapceUserTreeSchema, getNotifications, getObjectDetailButtons, getObjectDetailButtonsSchemas, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectListViewButtonsSchemas, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListButtonsSchemas, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, getRecordServiceSchema, getRelatedFieldValue, getRelatedListSchema, getRelatedsCount, getRootUrl, getSelectUserSchema, getSpaceUsersPickerAmisSchema, getSpaceUsersPickerSchema, getSteedosAuth, getTableSchema, getTenantId, getUISchema, getUISchemaSync, getUserId, getViewSchema, isExpression, isObject, lookupToAmis, lookupToAmisIdsPicker, lookupToAmisPicker, lookupToAmisSelect, lookupToAmisSelectUser, markReadAll, parseSingleExpression, registerRemoteAssets, registerRenders, setEnv, setEnvs, setRootUrl, setSteedosAuth, setUISchemaFunction, setVariable, standardButtonsTodo };
12222
12659
  //# sourceMappingURL=index.esm.js.map