@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.esm.js CHANGED
@@ -1363,8 +1363,8 @@ var config = {
1363
1363
  /*
1364
1364
  * @Author: baozhoutao@steedos.com
1365
1365
  * @Date: 2022-11-01 15:51:00
1366
- * @LastEditors: Please set LastEditors
1367
- * @LastEditTime: 2023-04-11 13:58:24
1366
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
1367
+ * @LastEditTime: 2023-04-16 17:04:16
1368
1368
  * @Description:
1369
1369
  */
1370
1370
 
@@ -1442,6 +1442,7 @@ const getSchema$4 = async (uiSchema, ctx) => {
1442
1442
  "context": "${context}",
1443
1443
  "global": "${global}",
1444
1444
  "listViewId": "${listViewId}",
1445
+ "displayAs": "${displayAs}",
1445
1446
  "uiSchema": "${uiSchema}",
1446
1447
  "isLookup": "${isLookup}",
1447
1448
  "listName": "${listName}"
@@ -1585,8 +1586,8 @@ const getSchema$3 = async (uiSchema, ctx) => {
1585
1586
  /*
1586
1587
  * @Author: 殷亮辉 yinlianghui@hotoa.com
1587
1588
  * @Date: 2023-03-22 09:31:21
1588
- * @LastEditors: baozhoutao@steedos.com
1589
- * @LastEditTime: 2023-04-06 16:04:20
1589
+ * @LastEditors: Please set LastEditors
1590
+ * @LastEditTime: 2023-04-12 10:35:36
1590
1591
  */
1591
1592
  const getSchema$2 = (uiSchema)=>{
1592
1593
  return {
@@ -1641,7 +1642,8 @@ const getSchema$2 = (uiSchema)=>{
1641
1642
  "eventName": "@data.changed.${_master.objectName}"
1642
1643
  },
1643
1644
  "data": {
1644
- "objectName": "${_master.objectName}"
1645
+ "objectName": "${_master.objectName}",
1646
+ "_isRelated": "${_isRelated}"
1645
1647
  },
1646
1648
  "expression": `\${_master.objectName != '${uiSchema.name}' && _master.objectName}`
1647
1649
  }
@@ -3357,6 +3359,9 @@ const getDisplayAsButton = function(objectName, showDisplayAs){
3357
3359
  };
3358
3360
  };
3359
3361
 
3362
+
3363
+
3364
+
3360
3365
  const onFieldsFilterToggleScript = `
3361
3366
  const scope = event.context.scoped;
3362
3367
  const filterForm = scope.getComponents().find(function(n){
@@ -3374,7 +3379,6 @@ setTimeout(()=>{
3374
3379
 
3375
3380
  function getExportApiRequestAdaptorScript(){
3376
3381
  return `
3377
- console.log(api.url);
3378
3382
  // 获取列表视图的属性
3379
3383
  let uiSchema = api.body.uiSchema;
3380
3384
  let list_views = uiSchema.list_views;
@@ -3423,12 +3427,12 @@ function getExportApiRequestAdaptorScript(){
3423
3427
  if (filters && filters.length > 0) {
3424
3428
  api.url = api.url + "&filters=" + JSON.stringify(filters);
3425
3429
  }
3426
- console.log(api.url);
3427
3430
  return api;
3428
3431
  `
3429
3432
  }
3430
3433
 
3431
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems} = {}){
3434
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
3435
+ // console.log(`getObjectHeaderToolbar====>`, filterVisible)
3432
3436
  const isMobile = window.innerWidth < 768;
3433
3437
  if(isMobile){
3434
3438
  showDisplayAs = false;
@@ -3465,7 +3469,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3465
3469
  }
3466
3470
  },
3467
3471
  },
3468
- {
3472
+ filterVisible ? {
3469
3473
  "label": "",
3470
3474
  "icon": "fa fa-search",
3471
3475
  "type": "button",
@@ -3481,7 +3485,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3481
3485
  ]
3482
3486
  }
3483
3487
  }
3484
- },
3488
+ } : {},
3485
3489
  showDisplayAs? getDisplayAsButton(mainObject?.name) : {}
3486
3490
  ]
3487
3491
  }else {
@@ -3497,10 +3501,6 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3497
3501
  // "type": "columns-toggler",
3498
3502
  // "className": "mr-2"
3499
3503
  // },
3500
- // {
3501
- // "type": "export-excel",
3502
- // "align": "right"
3503
- // },
3504
3504
  hiddenCount ? {} : {
3505
3505
  "type": "tpl",
3506
3506
  "tpl": "${count} 个项目"
@@ -3546,7 +3546,7 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3546
3546
  }
3547
3547
  }
3548
3548
  },
3549
- {
3549
+ filterVisible ? {
3550
3550
  "label": "",
3551
3551
  "icon": "fa fa-search",
3552
3552
  "type": "button",
@@ -3562,8 +3562,524 @@ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false,
3562
3562
  ]
3563
3563
  }
3564
3564
  }
3565
+ } : {},
3566
+ {
3567
+ "type": "dropdown-button",
3568
+ "trigger": "click",
3569
+ "icon": "fa fa-cog",
3570
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3571
+ "align": "right",
3572
+ "visibleOn": "${!isLookup}",
3573
+ "buttons": [
3574
+ {
3575
+ "label": "列表视图操作",
3576
+ "children": [
3577
+ {
3578
+ "type": "button",
3579
+ "label": "新建",
3580
+ "onEvent": {
3581
+ "click": {
3582
+ "weight": 0,
3583
+ "actions": [
3584
+ {
3585
+ "dialog": {
3586
+ "type": "dialog",
3587
+ "title": "新建 列表视图",
3588
+ "data": {
3589
+ "&": "$$",
3590
+ "all": "${uiSchema.list_views.all}",
3591
+ "list_view": "${uiSchema.list_views[listName]}",
3592
+ "appId": "${appId}",
3593
+ "global": "${global}",
3594
+ "objectName": "${objectName}",
3595
+ },
3596
+ "body": [
3597
+ {
3598
+ "type": "steedos-object-form",
3599
+ "label": "对象表单",
3600
+ "objectApiName": "object_listviews",
3601
+ "recordId": "",
3602
+ "mode": "edit",
3603
+ "defaultData": {
3604
+ "&": "${list_view}",
3605
+ "name":"",
3606
+ "label":"",
3607
+ "filters":"",
3608
+ "shared":false
3609
+ },
3610
+ "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}",
3611
+ "fields": [
3612
+ "label",
3613
+ "name",
3614
+ "object_name",
3615
+ "filter_scope",
3616
+ "show_count",
3617
+ "columns.$.field",
3618
+ "columns.$.width",
3619
+ "sort.$.field_name",
3620
+ "sort.$.order",
3621
+ "filters",
3622
+ "mobile_columns.$.field",
3623
+ "searchable_fields.$.field",
3624
+ "is_system",
3625
+ "shared"
3626
+ ],
3627
+ "onEvent": {
3628
+ "submitSucc": {
3629
+ "weight": 0,
3630
+ "actions": [
3631
+ {
3632
+ "args": {
3633
+ // 直接使用recordId不能拿到数据,只能通过result里面拿数据
3634
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3635
+ "blank": false
3636
+ },
3637
+ "actionType": "url",
3638
+ }
3639
+ ]
3640
+ }
3641
+ },
3642
+ "messages": {
3643
+ "success": "成功",
3644
+ "failed": "失败"
3645
+ },
3646
+ }
3647
+ ],
3648
+ "showCloseButton": true,
3649
+ "showErrorMsg": true,
3650
+ "showLoading": true,
3651
+ "closeOnEsc": false,
3652
+ "dataMapSwitch": false,
3653
+ "size": "lg"
3654
+ },
3655
+ "actionType": "dialog"
3656
+ }
3657
+ ]
3658
+ }
3659
+ }
3660
+ },
3661
+ {
3662
+ "type": "button",
3663
+ "label": "复制",
3664
+ "onEvent": {
3665
+ "click": {
3666
+ "weight": 0,
3667
+ "actions": [
3668
+ {
3669
+ "dialog": {
3670
+ "type": "dialog",
3671
+ "title": "复制 列表视图",
3672
+ "data": {
3673
+ "&": "$$",
3674
+ "listName": "${listName}",
3675
+ "objectName": "${objectName}",
3676
+ "list_view": "${uiSchema.list_views[listName]}",
3677
+ "appId": "${appId}",
3678
+ "global": "${global}"
3679
+ },
3680
+ "body": [
3681
+ {
3682
+ "type": "steedos-object-form",
3683
+ "label": "对象表单",
3684
+ "objectApiName": "object_listviews",
3685
+ "recordId": "",
3686
+ "mode": "edit",
3687
+ "fields": [
3688
+ ],
3689
+ "defaultData": {
3690
+ "&": "${list_view}",
3691
+ "name":"",
3692
+ "label": "${list_view.label}的副本",
3693
+ "shared":false
3694
+ },
3695
+ "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}",
3696
+ "fields": [
3697
+ "label",
3698
+ "name",
3699
+ "object_name",
3700
+ "filter_scope",
3701
+ "show_count",
3702
+ "columns.$.field",
3703
+ "columns.$.width",
3704
+ "sort.$.field_name",
3705
+ "sort.$.order",
3706
+ "filters",
3707
+ "mobile_columns.$.field",
3708
+ "searchable_fields.$.field",
3709
+ "is_system",
3710
+ "shared"
3711
+ ],
3712
+ "onEvent": {
3713
+ "submitSucc": {
3714
+ "weight": 0,
3715
+ "actions": [
3716
+ {
3717
+ "args": {
3718
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/listview_${result.data.recordId|lowerCase}",
3719
+ "blank": false
3720
+ },
3721
+ "actionType": "url",
3722
+ }
3723
+ ]
3724
+ }
3725
+ }
3726
+ }
3727
+ ],
3728
+ "showCloseButton": true,
3729
+ "showErrorMsg": true,
3730
+ "showLoading": true,
3731
+ "closeOnEsc": false,
3732
+ "dataMapSwitch": false,
3733
+ "size": "lg"
3734
+ },
3735
+ "actionType": "dialog"
3736
+ }
3737
+ ]
3738
+ }
3739
+ }
3740
+ },
3741
+ {
3742
+ "type": "button",
3743
+ "label": "重命名",
3744
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3745
+ "onEvent": {
3746
+ "click": {
3747
+ "weight": 0,
3748
+ "actions": [
3749
+ {
3750
+ "dialog": {
3751
+ "type": "dialog",
3752
+ "title": "重命名 列表视图",
3753
+ "data": {
3754
+ "objectName": "${objectName}",
3755
+ "recordId": "${uiSchema.list_views[listName]._id}",
3756
+ "appId": "${appId}"
3757
+ },
3758
+ "body": [
3759
+ {
3760
+ "type": "steedos-object-form",
3761
+ "label": "对象表单",
3762
+ "objectApiName": "object_listviews",
3763
+ "recordId": "${recordId}",
3764
+ "mode": "edit",
3765
+ "fields": [
3766
+ "label"
3767
+ ],
3768
+ "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
3769
+ "onEvent": {
3770
+ "submitSucc": {
3771
+ "weight": 0,
3772
+ "actions": [
3773
+ {
3774
+ "args": {
3775
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${name}",
3776
+ "blank": false
3777
+ },
3778
+ "actionType": "url",
3779
+ },
3780
+ ]
3781
+ }
3782
+ }
3783
+ }
3784
+ ],
3785
+ "showCloseButton": true,
3786
+ "showErrorMsg": true,
3787
+ "showLoading": true,
3788
+ "size": "lg"
3789
+ },
3790
+ "actionType": "dialog"
3791
+ }
3792
+ ]
3793
+ }
3794
+ }
3795
+ },
3796
+ {
3797
+ "type": "button",
3798
+ "label": "共享设置",
3799
+ "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
3800
+ "onEvent": {
3801
+ "click": {
3802
+ "weight": 0,
3803
+ "actions": [
3804
+ {
3805
+ "dialog": {
3806
+ "type": "dialog",
3807
+ "title": "共享设置",
3808
+ "data": {
3809
+ "recordId": "${uiSchema.list_views[listName]._id}",
3810
+ },
3811
+ "body": [
3812
+ {
3813
+ "type": "steedos-object-form",
3814
+ "label": "对象表单",
3815
+ "objectApiName": "object_listviews",
3816
+ "recordId": "${recordId}",
3817
+ "mode": "edit",
3818
+ "fields": [
3819
+ "shared"
3820
+ ]
3821
+ }
3822
+ ],
3823
+ "showCloseButton": true,
3824
+ "showErrorMsg": true,
3825
+ "showLoading": true,
3826
+ "closeOnEsc": false,
3827
+ "dataMapSwitch": false,
3828
+ "size": "md"
3829
+ },
3830
+ "actionType": "dialog"
3831
+ }
3832
+ ]
3833
+ }
3834
+ }
3835
+ },
3836
+ {
3837
+ "type": "button",
3838
+ "label": "过滤设置",
3839
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3840
+ "onEvent": {
3841
+ "click": {
3842
+ "weight": 0,
3843
+ "actions": [
3844
+ {
3845
+ "dialog": {
3846
+ "type": "dialog",
3847
+ "title": "过滤设置",
3848
+ "data": {
3849
+ "objectName": "${objectName}",
3850
+ "recordId": "${uiSchema.list_views[listName]._id}",
3851
+ "listName": "${listName}",
3852
+ "appId": "${appId}"
3853
+ },
3854
+ "body": [
3855
+ {
3856
+ "type": "steedos-object-form",
3857
+ "label": "对象表单",
3858
+ "objectApiName": "object_listviews",
3859
+ "recordId": "${recordId}",
3860
+ "mode": "edit",
3861
+ "initApiAdaptor": "",
3862
+ "fields": [
3863
+ "filters"
3864
+ ],
3865
+ "initApiRequestAdaptor": "",
3866
+ "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;",
3867
+ "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",
3868
+ "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}",
3869
+ "onEvent": {
3870
+ "submitSucc": {
3871
+ "weight": 0,
3872
+ "actions": [
3873
+ {
3874
+ "args": {
3875
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
3876
+ "blank": false
3877
+ },
3878
+ "actionType": "url",
3879
+ }
3880
+ ]
3881
+ }
3882
+ }
3883
+ }
3884
+ ],
3885
+ "showCloseButton": true,
3886
+ "showErrorMsg": true,
3887
+ "showLoading": true,
3888
+ "closeOnEsc": false,
3889
+ "dataMapSwitch": false,
3890
+ "size": "lg"
3891
+ },
3892
+ "actionType": "dialog"
3893
+ }
3894
+ ]
3895
+ }
3896
+ }
3897
+ },
3898
+ {
3899
+ "type": "button",
3900
+ "label": "显示的列",
3901
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3902
+ "onEvent": {
3903
+ "click": {
3904
+ "weight": 0,
3905
+ "actions": [
3906
+ {
3907
+ "args": {},
3908
+ "dialog": {
3909
+ "type": "dialog",
3910
+ "title": "显示的列",
3911
+ "data": {
3912
+ "&": "$$",
3913
+ "objectName": "${objectName}",
3914
+ "recordId": "${uiSchema.list_views[listName]._id}",
3915
+ "listName": "${listName}",
3916
+ "appId": "${appId}"
3917
+ },
3918
+ "body": [
3919
+ {
3920
+ "type": "steedos-object-form",
3921
+ "label": "对象表单",
3922
+ "objectApiName": "object_listviews",
3923
+ "recordId": "${recordId}",
3924
+ "mode": "edit",
3925
+ "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}",
3926
+ "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;",
3927
+ "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;",
3928
+ "fields": [
3929
+ "columns",
3930
+ "mobile_columns"
3931
+ ],
3932
+ "onEvent": {
3933
+ "submitSucc": {
3934
+ "weight": 0,
3935
+ "actions": [
3936
+ {
3937
+ "args": {
3938
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
3939
+ "blank": false
3940
+ },
3941
+ "actionType": "url"
3942
+ }
3943
+ ]
3944
+ }
3945
+ }
3946
+ }
3947
+ ],
3948
+ "searchable": true,
3949
+ "showCloseButton": true,
3950
+ "showErrorMsg": true,
3951
+ "showLoading": true,
3952
+ "size": "lg"
3953
+ },
3954
+ "actionType": "dialog"
3955
+ }
3956
+ ]
3957
+ }
3958
+ }
3959
+ },
3960
+ {
3961
+ "type": "button",
3962
+ "label": "默认排序规则",
3963
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
3964
+ "onEvent": {
3965
+ "click": {
3966
+ "weight": 0,
3967
+ "actions": [
3968
+ {
3969
+ "dialog": {
3970
+ "type": "dialog",
3971
+ "title": "弹框标题",
3972
+ "data": {
3973
+ "&": "$$",
3974
+ "objectName": "${objectName}",
3975
+ "recordId": "${uiSchema.list_views[listName]._id}",
3976
+ "listName": "${listName}",
3977
+ "appId": "${appId}"
3978
+ },
3979
+ "body": [
3980
+ {
3981
+ "type": "steedos-object-form",
3982
+ "label": "对象表单",
3983
+ "objectApiName": "object_listviews",
3984
+ "recordId": "${recordId}",
3985
+ "className": "",
3986
+ "id": "u:061f158b4c5a",
3987
+ "mode": "edit",
3988
+ "fields": [
3989
+ "sort",
3990
+ "sort.$.field_name",
3991
+ "sort.$.order"
3992
+ ],
3993
+ "onEvent": {
3994
+ "submitSucc": {
3995
+ "weight": 0,
3996
+ "actions": [
3997
+ {
3998
+ "args": {
3999
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/${listName}",
4000
+ "blank": false
4001
+ },
4002
+ "actionType": "url"
4003
+ }
4004
+ ]
4005
+ }
4006
+ },
4007
+ "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}",
4008
+ "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;",
4009
+ "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"
4010
+ }
4011
+ ],
4012
+ "showCloseButton": true,
4013
+ "showErrorMsg": true,
4014
+ "showLoading": true,
4015
+ "id": "u:d3f6947b6acf",
4016
+ "size": "lg"
4017
+ },
4018
+ "actionType": "dialog"
4019
+ }
4020
+ ]
4021
+ }
4022
+ }
4023
+ },
4024
+ {
4025
+ "type": "button",
4026
+ "label": "删除",
4027
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4028
+ "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4029
+ "onEvent": {
4030
+ "click": {
4031
+ "actions": [
4032
+ {
4033
+ "actionType": "ajax",
4034
+ "args": {
4035
+ "api": {
4036
+ "url": "${context.rootUrl}/graphql",
4037
+ "method": "post",
4038
+ "headers": {
4039
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4040
+ },
4041
+ "data": {
4042
+ "&": "$$",
4043
+ "uiSchema": "${uiSchema}",
4044
+ "recordId": "${uiSchema.list_views[listName]._id}"
4045
+ },
4046
+ "messages": {
4047
+ "success": "删除成功"
4048
+ },
4049
+ "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",
4050
+ "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n}\nreturn payload;",
4051
+ }
4052
+ }
4053
+ },
4054
+ {
4055
+ "actionType": "url",
4056
+ "args": {
4057
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4058
+ "blank": false
4059
+ },
4060
+ "expression": "data.delete == 1"
4061
+ }
4062
+ ]
4063
+ }
4064
+ }
4065
+ },
4066
+ {
4067
+ "type": "button",
4068
+ "visibleOn": "${false}",
4069
+ "label": "保存宽度(todo)"
4070
+ },
4071
+ // {
4072
+ // type: 'steedos-object-button',
4073
+ // name: 'standard_delete',
4074
+ // objectName: 'test0321__c',
4075
+ // // visibleOn: getButtonVisibleOn(button),
4076
+ // className: 'antd-Button--default'
4077
+ // }
4078
+ ]
4079
+ }
4080
+ ]
3565
4081
  },
3566
- showDisplayAs? getDisplayAsButton(showDisplayAs) : {}
4082
+ showDisplayAs ? getDisplayAsButton(showDisplayAs) : {}
3567
4083
  // {
3568
4084
  // "type": "search-box",
3569
4085
  // "align": "right",
@@ -3846,6 +4362,7 @@ function getLookupSapceUserTreeSchema(){
3846
4362
  const tree = [{
3847
4363
  "type": "input-tree",
3848
4364
  "className": "",
4365
+ "inputClassName": "pl-0",
3849
4366
  "id": "u:7fd77b7915b0",
3850
4367
  "source": {
3851
4368
  "method": "post",
@@ -3868,7 +4385,6 @@ function getLookupSapceUserTreeSchema(){
3868
4385
  {
3869
4386
  "actionType": "custom",
3870
4387
  "script": `
3871
- debugger;
3872
4388
  const scope = event.context.scoped;
3873
4389
  //TODO: 将form中的value一同加入筛选内
3874
4390
  // var filterForm = scope.parent.parent.getComponents().find(function(n){
@@ -3915,10 +4431,10 @@ function getLookupSapceUserTreeSchema(){
3915
4431
  "style": {
3916
4432
  "max-height": "100%",
3917
4433
  "position": "absolute",
3918
- "left": "-190px",
4434
+ "left": "-200px",
3919
4435
  "width": "190px",
3920
4436
  "bottom": 0,
3921
- "top": "0",
4437
+ "top": "-14px",
3922
4438
  "overflow": "auto",
3923
4439
  "min-height":"300px"
3924
4440
  },
@@ -5352,7 +5868,7 @@ var index = /*#__PURE__*/Object.freeze({
5352
5868
 
5353
5869
  const API_CACHE = 100;
5354
5870
 
5355
- function getReadonlyFormAdaptor(fields){
5871
+ function getReadonlyFormAdaptor(object, fields){
5356
5872
  let scriptStr = '';
5357
5873
  const selectFields = _$1.filter(fields, function(field){return field.name.indexOf('.') < 0 && ((field.type == 'select' && field.options) || ((field.type == 'lookup' || field.type == 'master_detail') && !field.reference_to))});
5358
5874
  const gridAndObjectFieldsName = _$1.map(_$1.filter(fields, function(field){return field.name.indexOf('.') < 0 && (field.type === 'object' || field.type === 'grid')}), 'name');
@@ -5411,6 +5927,7 @@ function getReadonlyFormAdaptor(fields){
5411
5927
  console.error(e)
5412
5928
  }
5413
5929
  payload.data = data;
5930
+ payload.data.__objectName = "${object.name}";
5414
5931
  payload.data.__record = record;
5415
5932
  window.postMessage(Object.assign({type: "record.loaded"}, {record: record}), "*")
5416
5933
  }
@@ -5428,7 +5945,7 @@ async function getReadonlyFormInitApi(object, recordId, fields, options){
5428
5945
  url: getApi$2()+"&recordId=${recordId}",
5429
5946
  cache: API_CACHE,
5430
5947
  // requestAdaptor: "console.log('getReadonlyFormInitApi requestAdaptor', api);return api;",
5431
- adaptor: getReadonlyFormAdaptor(fields),
5948
+ adaptor: getReadonlyFormAdaptor(object, fields),
5432
5949
  data: await getFindOneQuery$1(object, recordId, fields, options),
5433
5950
  headers: {
5434
5951
  Authorization: "Bearer ${context.tenantId},${context.authToken}"
@@ -5826,11 +6343,11 @@ function getBulkActions(objectSchema){
5826
6343
  }
5827
6344
 
5828
6345
  async function getObjectCRUD(objectSchema, fields, options){
6346
+ // console.time('getObjectCRUD');
5829
6347
  const { top, perPage, showDisplayAs = false, displayAs, crudClassName = "" } = options;
5830
6348
  const nonpaged = objectSchema.paging && objectSchema.paging.enabled === false;
5831
6349
  const isTreeObject = objectSchema.enable_tree;
5832
6350
  const bulkActions = getBulkActions(objectSchema);
5833
-
5834
6351
  const bodyProps = {
5835
6352
  // toolbar: getToolbar(),
5836
6353
  // headerToolbar: getObjectHeaderToolbar(objectSchema, options.formFactor, {showDisplayAs}),
@@ -5859,11 +6376,12 @@ async function getObjectCRUD(objectSchema, fields, options){
5859
6376
  options.queryCount = false;
5860
6377
  }
5861
6378
  }
5862
-
6379
+ // console.log(`getObjectHeaderToolbar====2===>`, options.filterVisible)
5863
6380
  bodyProps.headerToolbar = getObjectHeaderToolbar(objectSchema, options.formFactor, {
5864
6381
  showDisplayAs,
5865
6382
  hiddenCount: options.queryCount === false,
5866
- headerToolbarItems: options.headerToolbarItems
6383
+ headerToolbarItems: options.headerToolbarItems,
6384
+ filterVisible: options.filterVisible
5867
6385
  });
5868
6386
 
5869
6387
 
@@ -5938,7 +6456,7 @@ async function getObjectCRUD(objectSchema, fields, options){
5938
6456
  body = wrappedBody;
5939
6457
  }
5940
6458
  }
5941
-
6459
+ // console.timeEnd('getObjectCRUD');
5942
6460
  // TODO: data应该只留loaded,其他属性都改为从上层传递下来
5943
6461
  return {
5944
6462
  type: 'service',
@@ -6060,7 +6578,8 @@ async function getObjectForm(objectSchema, ctx){
6060
6578
  "eventName": "@data.changed.${_master.objectName}"
6061
6579
  },
6062
6580
  "data": {
6063
- "objectName": "${_master.objectName}"
6581
+ "objectName": "${_master.objectName}",
6582
+ "_isRelated": "${_isRelated || _master._isRelated}"
6064
6583
  },
6065
6584
  "expression": `\${_master.objectName != '${objectSchema.name}' && _master.objectName}`
6066
6585
  },
@@ -6144,6 +6663,7 @@ async function getObjectDetail(objectSchema, recordId, ctx){
6144
6663
  eventName: "recordLoaded"
6145
6664
  },
6146
6665
  data: {
6666
+ objectName: "${event.data.__objectName}",
6147
6667
  record: "${event.data.__record}"
6148
6668
  }
6149
6669
  },
@@ -6580,7 +7100,7 @@ async function getTableApi(mainObject, fields, options){
6580
7100
  const api = await getApi(mainObject, null, fields, {count: options.queryCount, alias: 'rows', limit: top, queryOptions: `filters: {__filters}, top: {__top}, skip: {__skip}, sort: "{__sort}"`});
6581
7101
 
6582
7102
  if(options.isRelated){
6583
- api.url += "&recordId=${recordId}";
7103
+ api.url += "&recordId=${_master.recordId}";
6584
7104
  }
6585
7105
 
6586
7106
  api.data.$term = "$term";
@@ -7825,7 +8345,7 @@ async function getRelatedListSchema(
7825
8345
  * @Author: baozhoutao@steedos.com
7826
8346
  * @Date: 2022-07-05 15:55:39
7827
8347
  * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
7828
- * @LastEditTime: 2023-04-11 11:28:11
8348
+ * @LastEditTime: 2023-04-14 11:10:07
7829
8349
  * @Description:
7830
8350
  */
7831
8351
 
@@ -8125,7 +8645,8 @@ async function getListSchema(
8125
8645
  "ctx": ctx,
8126
8646
  "requestAdaptor": listView.requestAdaptor,
8127
8647
  "adaptor": listView.adaptor,
8128
- "headerToolbarItems": ctx.headerToolbarItems
8648
+ "headerToolbarItems": ctx.headerToolbarItems,
8649
+ "filterVisible": ctx.filterVisible
8129
8650
  };
8130
8651
  return {
8131
8652
  uiSchema,
@@ -8140,6 +8661,7 @@ async function getTableSchema(
8140
8661
  columns,
8141
8662
  ctx = {}
8142
8663
  ) {
8664
+ // console.time('getTableSchema');
8143
8665
  const uiSchema = await getUISchema(objectName);
8144
8666
 
8145
8667
  let sort = ctx.sort;
@@ -8190,6 +8712,7 @@ async function getTableSchema(
8190
8712
  buttons: await getListViewItemButtons(uiSchema, ctx)
8191
8713
  });
8192
8714
  // console.log('getTableSchema====>amisSchema', amisSchema)
8715
+ // console.timeEnd('getTableSchema');
8193
8716
  return {
8194
8717
  uiSchema,
8195
8718
  amisSchema,
@@ -8308,6 +8831,41 @@ async function getRecordDetailSchema(objectName, appId, props = {}){
8308
8831
  }
8309
8832
  }
8310
8833
 
8834
+ async function getRecordServiceSchema(objectName, appId, props = {}) {
8835
+ const uiSchema = await getUISchema(objectName);
8836
+ return {
8837
+ uiSchema,
8838
+ amisSchema: {
8839
+ "type": "service",
8840
+ "body": [],
8841
+ data: {
8842
+ "_master.objectName": "${objectName}",
8843
+ "_master.recordId": "${recordId}"
8844
+ },
8845
+ "style": {
8846
+ "padding": "var(--Page-body-padding)",
8847
+ ...props.style
8848
+ },
8849
+ onEvent: {
8850
+ "recordLoaded": {
8851
+ "actions": [
8852
+ {
8853
+ "actionType": "reload",
8854
+ "data": {
8855
+ "name": `\${record.${uiSchema.NAME_FIELD_KEY || 'name'}}`,
8856
+ "_master.record": `\${record}`,
8857
+ // 不清楚reload 如何给对象下的某个key复制, 所以此处重复设置_master的objectName、recordId
8858
+ "_master.objectName": "${objectName}",
8859
+ "_master.recordId": "${recordId}"
8860
+ }
8861
+ }
8862
+ ]
8863
+ },
8864
+ ...props.onEvent
8865
+ }
8866
+ }
8867
+ }
8868
+ }
8311
8869
 
8312
8870
  // 获取单个相关表
8313
8871
  async function getObjectRelated(
@@ -11157,5 +11715,5 @@ const getInstanceInfo = async ({ instanceId, box }) => {
11157
11715
  };
11158
11716
  };
11159
11717
 
11160
- 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, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, getObjectRecordDetailHeader, getObjectRecordDetailRelatedListHeader, getObjectRelated, getObjectRelatedList, getObjectRelatedListButtons, getObjectRelatedListHeader, getPage, getRecord, getRecordDetailHeaderSchema, getRecordDetailRelatedListSchema, getRecordDetailSchema, getRecordPageInitSchema, getRecordPermissions, 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 };
11718
+ 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, getObjectDetailMoreButtons, getObjectFieldsFilterBarSchema, getObjectFieldsFilterButtonSchema, getObjectFieldsFilterFormSchema, getObjectListHeader$1 as getObjectListHeader, getObjectListHeaderFieldsFilterBar, getObjectListHeaderFirstLine, getObjectListHeaderSecordLine, 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 };
11161
11719
  //# sourceMappingURL=index.esm.js.map