@steedos-widgets/amis-lib 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1389,8 +1389,8 @@
1389
1389
  /*
1390
1390
  * @Author: baozhoutao@steedos.com
1391
1391
  * @Date: 2022-11-01 15:51:00
1392
- * @LastEditors: Please set LastEditors
1393
- * @LastEditTime: 2023-04-11 13:58:24
1392
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1393
+ * @LastEditTime: 2023-04-16 17:04:16
1394
1394
  * @Description:
1395
1395
  */
1396
1396
 
@@ -1468,6 +1468,7 @@
1468
1468
  "context": "${context}",
1469
1469
  "global": "${global}",
1470
1470
  "listViewId": "${listViewId}",
1471
+ "displayAs": "${displayAs}",
1471
1472
  "uiSchema": "${uiSchema}",
1472
1473
  "isLookup": "${isLookup}",
1473
1474
  "listName": "${listName}"
@@ -1611,8 +1612,8 @@
1611
1612
  /*
1612
1613
  * @Author: 殷亮辉 yinlianghui@hotoa.com
1613
1614
  * @Date: 2023-03-22 09:31:21
1614
- * @LastEditors: baozhoutao@steedos.com
1615
- * @LastEditTime: 2023-04-06 16:04:20
1615
+ * @LastEditors: Please set LastEditors
1616
+ * @LastEditTime: 2023-04-12 10:35:36
1616
1617
  */
1617
1618
  const getSchema$2 = (uiSchema)=>{
1618
1619
  return {
@@ -1667,7 +1668,8 @@
1667
1668
  "eventName": "@data.changed.${_master.objectName}"
1668
1669
  },
1669
1670
  "data": {
1670
- "objectName": "${_master.objectName}"
1671
+ "objectName": "${_master.objectName}",
1672
+ "_isRelated": "${_isRelated}"
1671
1673
  },
1672
1674
  "expression": `\${_master.objectName != '${uiSchema.name}' && _master.objectName}`
1673
1675
  }
@@ -3383,6 +3385,9 @@
3383
3385
  };
3384
3386
  };
3385
3387
 
3388
+
3389
+
3390
+
3386
3391
  const onFieldsFilterToggleScript = `
3387
3392
  const scope = event.context.scoped;
3388
3393
  const filterForm = scope.getComponents().find(function(n){
@@ -3400,7 +3405,6 @@ setTimeout(()=>{
3400
3405
 
3401
3406
  function getExportApiRequestAdaptorScript(){
3402
3407
  return `
3403
- console.log(api.url);
3404
3408
  // 获取列表视图的属性
3405
3409
  let uiSchema = api.body.uiSchema;
3406
3410
  let list_views = uiSchema.list_views;
@@ -3449,12 +3453,12 @@ setTimeout(()=>{
3449
3453
  if (filters && filters.length > 0) {
3450
3454
  api.url = api.url + "&filters=" + JSON.stringify(filters);
3451
3455
  }
3452
- console.log(api.url);
3453
3456
  return api;
3454
3457
  `
3455
3458
  }
3456
3459
 
3457
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems} = {}){
3460
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
3461
+ // console.log(`getObjectHeaderToolbar====>`, filterVisible)
3458
3462
  const isMobile = window.innerWidth < 768;
3459
3463
  if(isMobile){
3460
3464
  showDisplayAs = false;
@@ -3491,7 +3495,7 @@ setTimeout(()=>{
3491
3495
  }
3492
3496
  },
3493
3497
  },
3494
- {
3498
+ filterVisible ? {
3495
3499
  "label": "",
3496
3500
  "icon": "fa fa-search",
3497
3501
  "type": "button",
@@ -3507,7 +3511,7 @@ setTimeout(()=>{
3507
3511
  ]
3508
3512
  }
3509
3513
  }
3510
- },
3514
+ } : {},
3511
3515
  showDisplayAs? getDisplayAsButton(mainObject?.name) : {}
3512
3516
  ]
3513
3517
  }else {
@@ -3523,10 +3527,6 @@ setTimeout(()=>{
3523
3527
  // "type": "columns-toggler",
3524
3528
  // "className": "mr-2"
3525
3529
  // },
3526
- // {
3527
- // "type": "export-excel",
3528
- // "align": "right"
3529
- // },
3530
3530
  hiddenCount ? {} : {
3531
3531
  "type": "tpl",
3532
3532
  "tpl": "${count} 个项目"
@@ -3572,7 +3572,7 @@ setTimeout(()=>{
3572
3572
  }
3573
3573
  }
3574
3574
  },
3575
- {
3575
+ filterVisible ? {
3576
3576
  "label": "",
3577
3577
  "icon": "fa fa-search",
3578
3578
  "type": "button",
@@ -3588,8 +3588,524 @@ setTimeout(()=>{
3588
3588
  ]
3589
3589
  }
3590
3590
  }
3591
+ } : {},
3592
+ {
3593
+ "type": "dropdown-button",
3594
+ "trigger": "click",
3595
+ "icon": "fa fa-cog",
3596
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3597
+ "align": "right",
3598
+ "visibleOn": "${!isLookup}",
3599
+ "buttons": [
3600
+ {
3601
+ "label": "列表视图操作",
3602
+ "children": [
3603
+ {
3604
+ "type": "button",
3605
+ "label": "新建",
3606
+ "onEvent": {
3607
+ "click": {
3608
+ "weight": 0,
3609
+ "actions": [
3610
+ {
3611
+ "dialog": {
3612
+ "type": "dialog",
3613
+ "title": "新建 列表视图",
3614
+ "data": {
3615
+ "&": "$$",
3616
+ "all": "${uiSchema.list_views.all}",
3617
+ "list_view": "${uiSchema.list_views[listName]}",
3618
+ "appId": "${appId}",
3619
+ "global": "${global}",
3620
+ "objectName": "${objectName}",
3621
+ },
3622
+ "body": [
3623
+ {
3624
+ "type": "steedos-object-form",
3625
+ "label": "对象表单",
3626
+ "objectApiName": "object_listviews",
3627
+ "recordId": "",
3628
+ "mode": "edit",
3629
+ "defaultData": {
3630
+ "&": "${list_view}",
3631
+ "name":"",
3632
+ "label":"",
3633
+ "filters":"",
3634
+ "shared":false
3635
+ },
3636
+ "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}",
3637
+ "fields": [
3638
+ "label",
3639
+ "name",
3640
+ "object_name",
3641
+ "filter_scope",
3642
+ "show_count",
3643
+ "columns.$.field",
3644
+ "columns.$.width",
3645
+ "sort.$.field_name",
3646
+ "sort.$.order",
3647
+ "filters",
3648
+ "mobile_columns.$.field",
3649
+ "searchable_fields.$.field",
3650
+ "is_system",
3651
+ "shared"
3652
+ ],
3653
+ "onEvent": {
3654
+ "submitSucc": {
3655
+ "weight": 0,
3656
+ "actions": [
3657
+ {
3658
+ "args": {
3659
+ // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3660
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3661
+ "blank": false
3662
+ },
3663
+ "actionType": "url",
3664
+ }
3665
+ ]
3666
+ }
3667
+ },
3668
+ "messages": {
3669
+ "success": "成功",
3670
+ "failed": "失败"
3671
+ },
3672
+ }
3673
+ ],
3674
+ "showCloseButton": true,
3675
+ "showErrorMsg": true,
3676
+ "showLoading": true,
3677
+ "closeOnEsc": false,
3678
+ "dataMapSwitch": false,
3679
+ "size": "lg"
3680
+ },
3681
+ "actionType": "dialog"
3682
+ }
3683
+ ]
3684
+ }
3685
+ }
3686
+ },
3687
+ {
3688
+ "type": "button",
3689
+ "label": "复制",
3690
+ "onEvent": {
3691
+ "click": {
3692
+ "weight": 0,
3693
+ "actions": [
3694
+ {
3695
+ "dialog": {
3696
+ "type": "dialog",
3697
+ "title": "复制 列表视图",
3698
+ "data": {
3699
+ "&": "$$",
3700
+ "listName": "${listName}",
3701
+ "objectName": "${objectName}",
3702
+ "list_view": "${uiSchema.list_views[listName]}",
3703
+ "appId": "${appId}",
3704
+ "global": "${global}"
3705
+ },
3706
+ "body": [
3707
+ {
3708
+ "type": "steedos-object-form",
3709
+ "label": "对象表单",
3710
+ "objectApiName": "object_listviews",
3711
+ "recordId": "",
3712
+ "mode": "edit",
3713
+ "fields": [
3714
+ ],
3715
+ "defaultData": {
3716
+ "&": "${list_view}",
3717
+ "name":"",
3718
+ "label": "${list_view.label}的副本",
3719
+ "shared":false
3720
+ },
3721
+ "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}",
3722
+ "fields": [
3723
+ "label",
3724
+ "name",
3725
+ "object_name",
3726
+ "filter_scope",
3727
+ "show_count",
3728
+ "columns.$.field",
3729
+ "columns.$.width",
3730
+ "sort.$.field_name",
3731
+ "sort.$.order",
3732
+ "filters",
3733
+ "mobile_columns.$.field",
3734
+ "searchable_fields.$.field",
3735
+ "is_system",
3736
+ "shared"
3737
+ ],
3738
+ "onEvent": {
3739
+ "submitSucc": {
3740
+ "weight": 0,
3741
+ "actions": [
3742
+ {
3743
+ "args": {
3744
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3745
+ "blank": false
3746
+ },
3747
+ "actionType": "url",
3748
+ }
3749
+ ]
3750
+ }
3751
+ }
3752
+ }
3753
+ ],
3754
+ "showCloseButton": true,
3755
+ "showErrorMsg": true,
3756
+ "showLoading": true,
3757
+ "closeOnEsc": false,
3758
+ "dataMapSwitch": false,
3759
+ "size": "lg"
3760
+ },
3761
+ "actionType": "dialog"
3762
+ }
3763
+ ]
3764
+ }
3765
+ }
3766
+ },
3767
+ {
3768
+ "type": "button",
3769
+ "label": "重命名",
3770
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3771
+ "onEvent": {
3772
+ "click": {
3773
+ "weight": 0,
3774
+ "actions": [
3775
+ {
3776
+ "dialog": {
3777
+ "type": "dialog",
3778
+ "title": "重命名 列表视图",
3779
+ "data": {
3780
+ "objectName": "${objectName}",
3781
+ "recordId": "${uiSchema.list_views[listName]._id}",
3782
+ "appId": "${appId}"
3783
+ },
3784
+ "body": [
3785
+ {
3786
+ "type": "steedos-object-form",
3787
+ "label": "对象表单",
3788
+ "objectApiName": "object_listviews",
3789
+ "recordId": "${recordId}",
3790
+ "mode": "edit",
3791
+ "fields": [
3792
+ "label"
3793
+ ],
3794
+ "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
3795
+ "onEvent": {
3796
+ "submitSucc": {
3797
+ "weight": 0,
3798
+ "actions": [
3799
+ {
3800
+ "args": {
3801
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${name}",
3802
+ "blank": false
3803
+ },
3804
+ "actionType": "url",
3805
+ },
3806
+ ]
3807
+ }
3808
+ }
3809
+ }
3810
+ ],
3811
+ "showCloseButton": true,
3812
+ "showErrorMsg": true,
3813
+ "showLoading": true,
3814
+ "size": "lg"
3815
+ },
3816
+ "actionType": "dialog"
3817
+ }
3818
+ ]
3819
+ }
3820
+ }
3821
+ },
3822
+ {
3823
+ "type": "button",
3824
+ "label": "共享设置",
3825
+ "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
3826
+ "onEvent": {
3827
+ "click": {
3828
+ "weight": 0,
3829
+ "actions": [
3830
+ {
3831
+ "dialog": {
3832
+ "type": "dialog",
3833
+ "title": "共享设置",
3834
+ "data": {
3835
+ "recordId": "${uiSchema.list_views[listName]._id}",
3836
+ },
3837
+ "body": [
3838
+ {
3839
+ "type": "steedos-object-form",
3840
+ "label": "对象表单",
3841
+ "objectApiName": "object_listviews",
3842
+ "recordId": "${recordId}",
3843
+ "mode": "edit",
3844
+ "fields": [
3845
+ "shared"
3846
+ ]
3847
+ }
3848
+ ],
3849
+ "showCloseButton": true,
3850
+ "showErrorMsg": true,
3851
+ "showLoading": true,
3852
+ "closeOnEsc": false,
3853
+ "dataMapSwitch": false,
3854
+ "size": "md"
3855
+ },
3856
+ "actionType": "dialog"
3857
+ }
3858
+ ]
3859
+ }
3860
+ }
3861
+ },
3862
+ {
3863
+ "type": "button",
3864
+ "label": "过滤设置",
3865
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3866
+ "onEvent": {
3867
+ "click": {
3868
+ "weight": 0,
3869
+ "actions": [
3870
+ {
3871
+ "dialog": {
3872
+ "type": "dialog",
3873
+ "title": "过滤设置",
3874
+ "data": {
3875
+ "objectName": "${objectName}",
3876
+ "recordId": "${uiSchema.list_views[listName]._id}",
3877
+ "listName": "${listName}",
3878
+ "appId": "${appId}"
3879
+ },
3880
+ "body": [
3881
+ {
3882
+ "type": "steedos-object-form",
3883
+ "label": "对象表单",
3884
+ "objectApiName": "object_listviews",
3885
+ "recordId": "${recordId}",
3886
+ "mode": "edit",
3887
+ "initApiAdaptor": "",
3888
+ "fields": [
3889
+ "filters"
3890
+ ],
3891
+ "initApiRequestAdaptor": "",
3892
+ "initApiAdaptor": "const recordId_tmp = api.body.recordId;\nlet data_tmp;\nif (recordId_tmp) {\n data_tmp = payload.data.initialValues;\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.initialValues = Object.assign(payload.data.initialValues, data_tmp);\ndelete payload.extensions;",
3893
+ "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",
3894
+ "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}",
3895
+ "onEvent": {
3896
+ "submitSucc": {
3897
+ "weight": 0,
3898
+ "actions": [
3899
+ {
3900
+ "args": {
3901
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
3902
+ "blank": false
3903
+ },
3904
+ "actionType": "url",
3905
+ }
3906
+ ]
3907
+ }
3908
+ }
3909
+ }
3910
+ ],
3911
+ "showCloseButton": true,
3912
+ "showErrorMsg": true,
3913
+ "showLoading": true,
3914
+ "closeOnEsc": false,
3915
+ "dataMapSwitch": false,
3916
+ "size": "lg"
3917
+ },
3918
+ "actionType": "dialog"
3919
+ }
3920
+ ]
3921
+ }
3922
+ }
3923
+ },
3924
+ {
3925
+ "type": "button",
3926
+ "label": "显示的列",
3927
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3928
+ "onEvent": {
3929
+ "click": {
3930
+ "weight": 0,
3931
+ "actions": [
3932
+ {
3933
+ "args": {},
3934
+ "dialog": {
3935
+ "type": "dialog",
3936
+ "title": "显示的列",
3937
+ "data": {
3938
+ "&": "$$",
3939
+ "objectName": "${objectName}",
3940
+ "recordId": "${uiSchema.list_views[listName]._id}",
3941
+ "listName": "${listName}",
3942
+ "appId": "${appId}"
3943
+ },
3944
+ "body": [
3945
+ {
3946
+ "type": "steedos-object-form",
3947
+ "label": "对象表单",
3948
+ "objectApiName": "object_listviews",
3949
+ "recordId": "${recordId}",
3950
+ "mode": "edit",
3951
+ "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}",
3952
+ "initApiAdaptor": "const recordId_tmp = api.body.recordId;\nlet columns_tmp = {}, mobile_columns_tmp = {};\nif (recordId_tmp) {\n columns_tmp = payload.data.initialValues.columns;\n mobile_columns_tmp = payload.data.initialValues.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.initialValues.columns = columns_tmp;\npayload.data.initialValues.mobile_columns = mobile_columns_tmp;\n\ndelete payload.extensions;\nreturn payload;",
3953
+ "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;",
3954
+ "fields": [
3955
+ "columns",
3956
+ "mobile_columns"
3957
+ ],
3958
+ "onEvent": {
3959
+ "submitSucc": {
3960
+ "weight": 0,
3961
+ "actions": [
3962
+ {
3963
+ "args": {
3964
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
3965
+ "blank": false
3966
+ },
3967
+ "actionType": "url"
3968
+ }
3969
+ ]
3970
+ }
3971
+ }
3972
+ }
3973
+ ],
3974
+ "searchable": true,
3975
+ "showCloseButton": true,
3976
+ "showErrorMsg": true,
3977
+ "showLoading": true,
3978
+ "size": "lg"
3979
+ },
3980
+ "actionType": "dialog"
3981
+ }
3982
+ ]
3983
+ }
3984
+ }
3985
+ },
3986
+ {
3987
+ "type": "button",
3988
+ "label": "默认排序规则",
3989
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3990
+ "onEvent": {
3991
+ "click": {
3992
+ "weight": 0,
3993
+ "actions": [
3994
+ {
3995
+ "dialog": {
3996
+ "type": "dialog",
3997
+ "title": "弹框标题",
3998
+ "data": {
3999
+ "&": "$$",
4000
+ "objectName": "${objectName}",
4001
+ "recordId": "${uiSchema.list_views[listName]._id}",
4002
+ "listName": "${listName}",
4003
+ "appId": "${appId}"
4004
+ },
4005
+ "body": [
4006
+ {
4007
+ "type": "steedos-object-form",
4008
+ "label": "对象表单",
4009
+ "objectApiName": "object_listviews",
4010
+ "recordId": "${recordId}",
4011
+ "className": "",
4012
+ "id": "u:061f158b4c5a",
4013
+ "mode": "edit",
4014
+ "fields": [
4015
+ "sort",
4016
+ "sort.$.field_name",
4017
+ "sort.$.order"
4018
+ ],
4019
+ "onEvent": {
4020
+ "submitSucc": {
4021
+ "weight": 0,
4022
+ "actions": [
4023
+ {
4024
+ "args": {
4025
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4026
+ "blank": false
4027
+ },
4028
+ "actionType": "url"
4029
+ }
4030
+ ]
4031
+ }
4032
+ },
4033
+ "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}",
4034
+ "initApiAdaptor": "let sort;\nif (recordId) {\n sort = payload.data.initialValues.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.initialValues.sort = sort;\ndelete payload.extensions;",
4035
+ "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"
4036
+ }
4037
+ ],
4038
+ "showCloseButton": true,
4039
+ "showErrorMsg": true,
4040
+ "showLoading": true,
4041
+ "id": "u:d3f6947b6acf",
4042
+ "size": "lg"
4043
+ },
4044
+ "actionType": "dialog"
4045
+ }
4046
+ ]
4047
+ }
4048
+ }
4049
+ },
4050
+ {
4051
+ "type": "button",
4052
+ "label": "删除",
4053
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4054
+ "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4055
+ "onEvent": {
4056
+ "click": {
4057
+ "actions": [
4058
+ {
4059
+ "actionType": "ajax",
4060
+ "args": {
4061
+ "api": {
4062
+ "url": "${context.rootUrl}/graphql",
4063
+ "method": "post",
4064
+ "headers": {
4065
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4066
+ },
4067
+ "data": {
4068
+ "&": "$$",
4069
+ "uiSchema": "${uiSchema}",
4070
+ "recordId": "${uiSchema.list_views[listName]._id}"
4071
+ },
4072
+ "messages": {
4073
+ "success": "删除成功"
4074
+ },
4075
+ "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",
4076
+ "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n}\nreturn payload;",
4077
+ }
4078
+ }
4079
+ },
4080
+ {
4081
+ "actionType": "url",
4082
+ "args": {
4083
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4084
+ "blank": false
4085
+ },
4086
+ "expression": "data.delete == 1"
4087
+ }
4088
+ ]
4089
+ }
4090
+ }
4091
+ },
4092
+ {
4093
+ "type": "button",
4094
+ "visibleOn": "${false}",
4095
+ "label": "保存宽度(todo)"
4096
+ },
4097
+ // {
4098
+ // type: 'steedos-object-button',
4099
+ // name: 'standard_delete',
4100
+ // objectName: 'test0321__c',
4101
+ // // visibleOn: getButtonVisibleOn(button),
4102
+ // className: 'antd-Button--default'
4103
+ // }
4104
+ ]
4105
+ }
4106
+ ]
3591
4107
  },
3592
- showDisplayAs? getDisplayAsButton(showDisplayAs) : {}
4108
+ showDisplayAs ? getDisplayAsButton(showDisplayAs) : {}
3593
4109
  // {
3594
4110
  // "type": "search-box",
3595
4111
  // "align": "right",
@@ -3872,6 +4388,7 @@ setTimeout(()=>{
3872
4388
  const tree = [{
3873
4389
  "type": "input-tree",
3874
4390
  "className": "",
4391
+ "inputClassName": "pl-0",
3875
4392
  "id": "u:7fd77b7915b0",
3876
4393
  "source": {
3877
4394
  "method": "post",
@@ -3894,7 +4411,6 @@ setTimeout(()=>{
3894
4411
  {
3895
4412
  "actionType": "custom",
3896
4413
  "script": `
3897
- debugger;
3898
4414
  const scope = event.context.scoped;
3899
4415
  //TODO: 将form中的value一同加入筛选内
3900
4416
  // var filterForm = scope.parent.parent.getComponents().find(function(n){
@@ -3941,10 +4457,10 @@ setTimeout(()=>{
3941
4457
  "style": {
3942
4458
  "max-height": "100%",
3943
4459
  "position": "absolute",
3944
- "left": "-190px",
4460
+ "left": "-200px",
3945
4461
  "width": "190px",
3946
4462
  "bottom": 0,
3947
- "top": "0",
4463
+ "top": "-14px",
3948
4464
  "overflow": "auto",
3949
4465
  "min-height":"300px"
3950
4466
  },
@@ -5378,7 +5894,7 @@ setTimeout(()=>{
5378
5894
 
5379
5895
  const API_CACHE = 100;
5380
5896
 
5381
- function getReadonlyFormAdaptor(fields){
5897
+ function getReadonlyFormAdaptor(object, fields){
5382
5898
  let scriptStr = '';
5383
5899
  const selectFields = ___namespace.filter(fields, function(field){return field.name.indexOf('.') < 0 && ((field.type == 'select' && field.options) || ((field.type == 'lookup' || field.type == 'master_detail') && !field.reference_to))});
5384
5900
  const gridAndObjectFieldsName = ___namespace.map(___namespace.filter(fields, function(field){return field.name.indexOf('.') < 0 && (field.type === 'object' || field.type === 'grid')}), 'name');
@@ -5437,6 +5953,7 @@ setTimeout(()=>{
5437
5953
  console.error(e)
5438
5954
  }
5439
5955
  payload.data = data;
5956
+ payload.data.__objectName = "${object.name}";
5440
5957
  payload.data.__record = record;
5441
5958
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
5442
5959
  }
@@ -5454,7 +5971,7 @@ setTimeout(()=>{
5454
5971
  url: getApi$2()+"&recordId=${recordId}",
5455
5972
  cache: API_CACHE,
5456
5973
  // requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
5457
- adaptor: getReadonlyFormAdaptor(fields),
5974
+ adaptor: getReadonlyFormAdaptor(object, fields),
5458
5975
  data: await getFindOneQuery$1(object, recordId, fields, options),
5459
5976
  headers: {
5460
5977
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
@@ -5852,11 +6369,11 @@ setTimeout(()=>{
5852
6369
  }
5853
6370
 
5854
6371
  async function getObjectCRUD(objectSchema, fields, options){
6372
+ // console.time('getObjectCRUD');
5855
6373
  const { top, perPage, showDisplayAs = false, displayAs, crudClassName = "" } = options;
5856
6374
  const nonpaged = objectSchema.paging && objectSchema.paging.enabled === false;
5857
6375
  const isTreeObject = objectSchema.enable_tree;
5858
6376
  const bulkActions = getBulkActions(objectSchema);
5859
-
5860
6377
  const bodyProps = {
5861
6378
  // toolbar: getToolbar(),
5862
6379
  // headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
@@ -5885,11 +6402,12 @@ setTimeout(()=>{
5885
6402
  options.queryCount = false;
5886
6403
  }
5887
6404
  }
5888
-
6405
+ // console.log(`getObjectHeaderToolbar====2===>`, options.filterVisible)
5889
6406
  bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {
5890
6407
  showDisplayAs,
5891
6408
  hiddenCount: options.queryCount === false,
5892
- headerToolbarItems: options.headerToolbarItems
6409
+ headerToolbarItems: options.headerToolbarItems,
6410
+ filterVisible: options.filterVisible
5893
6411
  });
5894
6412
 
5895
6413
 
@@ -5964,7 +6482,7 @@ setTimeout(()=>{
5964
6482
  body = wrappedBody;
5965
6483
  }
5966
6484
  }
5967
-
6485
+ // console.timeEnd('getObjectCRUD');
5968
6486
  // TODO: data应该只留loaded,其他属性都改为从上层传递下来
5969
6487
  return {
5970
6488
  type: 'service',
@@ -6086,7 +6604,8 @@ setTimeout(()=>{
6086
6604
  "eventName": "@data.changed.${_master.objectName}"
6087
6605
  },
6088
6606
  "data": {
6089
- "objectName": "${_master.objectName}"
6607
+ "objectName": "${_master.objectName}",
6608
+ "_isRelated": "${_isRelated || _master._isRelated}"
6090
6609
  },
6091
6610
  "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
6092
6611
  },
@@ -6170,6 +6689,7 @@ setTimeout(()=>{
6170
6689
  eventName: "recordLoaded"
6171
6690
  },
6172
6691
  data: {
6692
+ objectName: "${event.data.__objectName}",
6173
6693
  record: "${event.data.__record}"
6174
6694
  }
6175
6695
  },
@@ -6606,7 +7126,7 @@ setTimeout(()=>{
6606
7126
  const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
6607
7127
 
6608
7128
  if(options.isRelated){
6609
- api.url += "&recordId=${recordId}";
7129
+ api.url += "&recordId=${_master.recordId}";
6610
7130
  }
6611
7131
 
6612
7132
  api.data.$term = "$term";
@@ -7851,7 +8371,7 @@ setTimeout(()=>{
7851
8371
  * @Author: baozhoutao@steedos.com
7852
8372
  * @Date: 2022-07-05 15:55:39
7853
8373
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
7854
- * @LastEditTime: 2023-04-11 11:28:11
8374
+ * @LastEditTime: 2023-04-14 11:10:07
7855
8375
  * @Description:
7856
8376
  */
7857
8377
 
@@ -8151,7 +8671,8 @@ setTimeout(()=>{
8151
8671
  "ctx": ctx,
8152
8672
  "requestAdaptor": listView.requestAdaptor,
8153
8673
  "adaptor": listView.adaptor,
8154
- "headerToolbarItems": ctx.headerToolbarItems
8674
+ "headerToolbarItems": ctx.headerToolbarItems,
8675
+ "filterVisible": ctx.filterVisible
8155
8676
  };
8156
8677
  return {
8157
8678
  uiSchema,
@@ -8166,6 +8687,7 @@ setTimeout(()=>{
8166
8687
  columns,
8167
8688
  ctx = {}
8168
8689
  ) {
8690
+ // console.time('getTableSchema');
8169
8691
  const uiSchema = await getUISchema(objectName);
8170
8692
 
8171
8693
  let sort = ctx.sort;
@@ -8216,6 +8738,7 @@ setTimeout(()=>{
8216
8738
  buttons: await getListViewItemButtons(uiSchema, ctx)
8217
8739
  });
8218
8740
  // console.log('getTableSchema====>amisSchema', amisSchema)
8741
+ // console.timeEnd('getTableSchema');
8219
8742
  return {
8220
8743
  uiSchema,
8221
8744
  amisSchema,
@@ -8334,6 +8857,41 @@ setTimeout(()=>{
8334
8857
  }
8335
8858
  }
8336
8859
 
8860
+ async function getRecordServiceSchema(objectName, appId, props = {}) {
8861
+ const uiSchema = await getUISchema(objectName);
8862
+ return {
8863
+ uiSchema,
8864
+ amisSchema: {
8865
+ "type": "service",
8866
+ "body": [],
8867
+ data: {
8868
+ "_master.objectName": "${objectName}",
8869
+ "_master.recordId": "${recordId}"
8870
+ },
8871
+ "style": {
8872
+ "padding": "var(--Page-body-padding)",
8873
+ ...props.style
8874
+ },
8875
+ onEvent: {
8876
+ "recordLoaded": {
8877
+ "actions": [
8878
+ {
8879
+ "actionType": "reload",
8880
+ "data": {
8881
+ "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
8882
+ "_master.record": `\${record}`,
8883
+ // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
8884
+ "_master.objectName": "${objectName}",
8885
+ "_master.recordId": "${recordId}"
8886
+ }
8887
+ }
8888
+ ]
8889
+ },
8890
+ ...props.onEvent
8891
+ }
8892
+ }
8893
+ }
8894
+ }
8337
8895
 
8338
8896
  // 获取单个相关表
8339
8897
  async function getObjectRelated(
@@ -11251,6 +11809,7 @@ setTimeout(()=>{
11251
11809
  exports.getRecordDetailSchema = getRecordDetailSchema;
11252
11810
  exports.getRecordPageInitSchema = getRecordPageInitSchema;
11253
11811
  exports.getRecordPermissions = getRecordPermissions;
11812
+ exports.getRecordServiceSchema = getRecordServiceSchema;
11254
11813
  exports.getRelatedFieldValue = getRelatedFieldValue;
11255
11814
  exports.getRelatedListSchema = getRelatedListSchema;
11256
11815
  exports.getRelatedsCount = getRelatedsCount;