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