@steedos-widgets/amis-object 1.2.8 → 1.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2623,7 +2623,7 @@
2623
2623
  return listButtons;
2624
2624
  };
2625
2625
 
2626
- const getObjectRelatedListButtons = async (uiSchema, ctx)=>{
2626
+ const getObjectRelatedListButtons = (uiSchema, ctx)=>{
2627
2627
  // const buttons = getButtons(uiSchema, ctx);
2628
2628
  // const relatedListButtons = _.filter(buttons, (button) => {
2629
2629
  // if(button.objectName === 'cms_files'){
@@ -2910,6 +2910,67 @@
2910
2910
  }
2911
2911
  };
2912
2912
 
2913
+ const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
2914
+ const buttons = getObjectRelatedListButtons(objectSchema, ctx);
2915
+ if(ctx.formFactor === 'SMALL'){
2916
+ return {
2917
+ "type": "button",
2918
+ "icon": "fa fa-angle-down",
2919
+ "onEvent": {
2920
+ "click": {
2921
+ "actions": [
2922
+ {
2923
+ "actionType": "drawer",
2924
+ "drawer": {
2925
+ "type": "drawer",
2926
+ "title": "操作",
2927
+ "body": [
2928
+ {
2929
+ "type": "button-group",
2930
+ "vertical": true,
2931
+ "tiled": true,
2932
+ "buttons": [
2933
+ ...___default__default["default"].map(buttons, (button)=>{
2934
+ return {
2935
+ type: 'steedos-object-button',
2936
+ name: button.name,
2937
+ objectName: button.objectName,
2938
+ visibleOn: getButtonVisibleOn$1(button),
2939
+ className: `button_${button.name} w-full`
2940
+ }
2941
+ })
2942
+ ],
2943
+ "btnLevel": "enhance",
2944
+ "className": "w-full",
2945
+ "btnClassName": "w-full",
2946
+ "size": "lg"
2947
+ }
2948
+ ],
2949
+ "position": "bottom",
2950
+ "closeOnOutside": true,
2951
+ "resizable": false,
2952
+ "className": "buttons-drawer",
2953
+ "bodyClassName": "m-none p-none",
2954
+ "actions": []
2955
+ }
2956
+ }
2957
+ ]
2958
+ }
2959
+ }
2960
+ }
2961
+ }else {
2962
+ return ___default__default["default"].map(buttons, (button) => {
2963
+ return {
2964
+ type: 'steedos-object-button',
2965
+ name: button.name,
2966
+ objectName: button.objectName,
2967
+ visibleOn: getButtonVisibleOn$1(button),
2968
+ className: `button_${button.name}`
2969
+ }
2970
+ });
2971
+ }
2972
+ };
2973
+
2913
2974
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2914
2975
  // const amisListViewId = `listview_${objectSchema.name}`;
2915
2976
  return {
@@ -2962,11 +3023,11 @@
2962
3023
  payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
2963
3024
  }
2964
3025
  const selfData = api.body.$self;
2965
- const filterFormSearchableFields = selfData.filterFormSearchableFields;
2966
3026
  const uiSchema = selfData.uiSchema;
2967
3027
  const fields = uiSchema.fields;
2968
- const searchableFields = [];
2969
-
3028
+ const filterFormSearchableFields = (selfData.filterFormSearchableFields || []).filter(function(item){
3029
+ return !!fields[item]
3030
+ });
2970
3031
  const resolveAll = function(values){
2971
3032
  payload.data = {
2972
3033
  "body": values
@@ -2981,21 +3042,7 @@
2981
3042
  return Promise.all(filterFormSearchableFields.map(function (item) {
2982
3043
  const field = _.clone(fields[item]);
2983
3044
  if (
2984
- field && !_.includes(
2985
- [
2986
- "grid",
2987
- "avatar",
2988
- "image",
2989
- "object",
2990
- "[object]",
2991
- "[Object]",
2992
- "[grid]",
2993
- "[text]",
2994
- "audio",
2995
- "file",
2996
- ],
2997
- field.type
2998
- )
3045
+ field && window.isFieldTypeSearchable(field.type)
2999
3046
  ) {
3000
3047
  delete field.defaultValue;
3001
3048
  delete field.required;
@@ -3092,6 +3139,7 @@
3092
3139
  }
3093
3140
  }
3094
3141
  }
3142
+ filterForm.reset();
3095
3143
  listView.handleFilterSubmit(removedValues);
3096
3144
  const filterService = filterForm.context.getComponents().find(function(n){
3097
3145
  return n.props.type === "service";
@@ -3354,9 +3402,27 @@
3354
3402
  "headers": {
3355
3403
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
3356
3404
  },
3357
- "data": null,
3405
+ "data": {
3406
+ "$self": "$$"
3407
+ },
3358
3408
  "requestAdaptor": "",
3359
- "adaptor": ""
3409
+ "adaptor": `
3410
+ if(payload.errors){
3411
+ payload.status = 2;
3412
+ payload.msg = window.t ? window.t(payload.errors[0].message) : payload.errors[0].message;
3413
+ }
3414
+ const selfData = api.body.$self;
3415
+ const uiSchema = selfData.uiSchema;
3416
+ const fields = uiSchema.fields;
3417
+ const options = (payload.data?.options || []).filter(function(item){
3418
+ let field = fields[item.value];
3419
+ return !!field && window.isFieldTypeSearchable(field.type)
3420
+ });
3421
+ payload.data = {
3422
+ "options": options
3423
+ };
3424
+ return payload;
3425
+ `
3360
3426
  },
3361
3427
  "options": [],
3362
3428
  "required": true,
@@ -3519,6 +3585,7 @@
3519
3585
  "rightIcon": "fa fa-caret-down",
3520
3586
  "size": "sm",
3521
3587
  "hideCaret": true,
3588
+ "closeOnClick": true,
3522
3589
  "btnClassName": "!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none",
3523
3590
  "buttons": listViewButtonOptions
3524
3591
  }
@@ -3703,12 +3770,47 @@
3703
3770
  "type": "grid",
3704
3771
  "columns": [
3705
3772
  {
3706
- "body": {
3773
+ "body": [{
3774
+ "type": "service",
3775
+ "onEvent": {
3776
+ "@history_paths.changed": {
3777
+ "actions": [
3778
+ {
3779
+ "actionType": "reload"
3780
+ }
3781
+ ]
3782
+ }
3783
+ },
3784
+ "body":[{
3785
+ "type": "button",
3786
+ "visibleOn": "${window:innerWidth > 768 && window:historyPaths.length > 1}",
3787
+ "className":"flex mr-2",
3788
+ "onEvent": {
3789
+ "click": {
3790
+ "actions": [
3791
+ {
3792
+ "actionType": "custom",
3793
+ "script": "Steedos.goBack()"
3794
+ }
3795
+ ]
3796
+ }
3797
+ },
3798
+ "body": [
3799
+ {
3800
+ "type": "steedos-icon",
3801
+ "category": "utility",
3802
+ "name": "back",
3803
+ "colorVariant": "default",
3804
+ "className": "slds-button_icon slds-global-header__icon"
3805
+ }
3806
+ ]
3807
+ }]
3808
+ },{
3707
3809
  "type": "tpl",
3708
3810
  "className": "block",
3709
3811
  // "tpl": `<img class='slds-icon slds-icon_container slds-icon-standard-${standardIcon}' src='\${context.rootUrl}/unpkg.com/@salesforce-ux/design-system/assets/icons/standard/${icon}.svg'>`
3710
3812
  "tpl":`<svg class="slds-icon slds-icon_container slds-icon-standard-${standardIcon} slds-page-header__icon" aria-hidden="true"><use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#${icon}"></use></svg>`
3711
- },
3813
+ }],
3712
3814
  "md": "auto",
3713
3815
  "className": "",
3714
3816
  "columnClassName": "flex justify-center items-center"
@@ -3795,18 +3897,9 @@
3795
3897
  * @param {*} relatedObjectSchema 相关对象UISchema
3796
3898
  * @returns amisSchema
3797
3899
  */
3798
- async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel) {
3900
+ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel, ctx) {
3799
3901
  const { icon, label } = relatedObjectSchema;
3800
- const buttons = await getObjectRelatedListButtons(relatedObjectSchema, {});
3801
- let amisButtonsSchema = ___default.map(buttons, (button) => {
3802
- return {
3803
- type: 'steedos-object-button',
3804
- name: button.name,
3805
- objectName: button.objectName,
3806
- visibleOn: getButtonVisibleOn$1(button),
3807
- className: `button_${button.name}`
3808
- }
3809
- });
3902
+ let amisButtonsSchema = getObjectRecordDetailRelatedListButtonsSchemas(relatedObjectSchema, {formFactor: ctx.formFactor});
3810
3903
  const reg = new RegExp('_', 'g');
3811
3904
  const standardIcon = icon && icon.replace(reg, '-');
3812
3905
  const recordRelatedListHeader = {
@@ -3879,83 +3972,44 @@
3879
3972
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
3880
3973
  }
3881
3974
 
3882
- const getDisplayAsButton = function(objectName, showDisplayAs){
3883
- let displayAs = Router$1.getTabDisplayAs(objectName);
3884
- let buttons = [
3885
- {
3886
- "type": "button",
3887
- "label": "表格",
3888
- "onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
3889
- "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
3890
- "rightIconClassName": "m-l-sm"
3891
- },
3892
- {
3893
- "type": "button",
3894
- "label": "分栏视图",
3895
- "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
3896
- "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
3897
- "rightIconClassName": "m-l-sm"
3975
+ const getExportExcelToolbarButtonSchema = ()=>{
3976
+ return {
3977
+ "type": "button",
3978
+ "icon": "fa fa-download",
3979
+ "align": "right",
3980
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
3981
+ "tooltipPlacement": "bottom",
3982
+ "visibleOn": "${!isLookup && global.user.is_space_admin}",
3983
+ "tooltip": "导出Excel",
3984
+ "onEvent": {
3985
+ "click": {
3986
+ "weight": 0,
3987
+ "actions": [
3988
+ {
3989
+ "args": {
3990
+ "api": {
3991
+ "url": "${context.rootUrl}/api/record/export/${objectName}",
3992
+ "method": "get",
3993
+ "messages": {},
3994
+ "requestAdaptor": `${requestAdaptor$1()}`,
3995
+ "data": {
3996
+ "uiSchema": "${uiSchema}",
3997
+ "listName": "${listName}"
3998
+ },
3999
+ "headers": {
4000
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4001
+ }
4002
+ }
4003
+ },
4004
+ "actionType": "download"
4005
+ }
4006
+ ]
4007
+ }
4008
+ }
3898
4009
  }
3899
- ];
3900
- return {
3901
- "type": "dropdown-button",
3902
- "icon": "fa fa-table-columns",
3903
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3904
- "align": "right",
3905
- "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
3906
- "buttons": [
3907
- {
3908
- "label": "显示为",
3909
- "children": buttons
3910
- }
3911
- ]
3912
- };
3913
4010
  };
3914
4011
 
3915
-
3916
-
3917
-
3918
- const onFieldsFilterToggleScript = `
3919
- const scope = event.context.scoped;
3920
- const filterForm = scope.getComponents().find(function(n){
3921
- return n.props.type === "form";
3922
- });
3923
- const filterService = filterForm.context.getComponents().find(function(n){
3924
- return n.props.type === "service";
3925
- });
3926
- // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
3927
- let resizeWindow = function(){
3928
- //触发amis crud 高度重算
3929
- setTimeout(()=>{
3930
- window.dispatchEvent(new Event("resize"))
3931
- }, 500);
3932
- }
3933
- let isMobile = Steedos.isMobile();
3934
- if(filterService.props.data.showFieldsFilter){
3935
- if(isMobile){
3936
- // 手机上只能通过取消按钮来关闭搜索栏
3937
- return;
3938
- }
3939
- let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
3940
- direction: "down",
3941
- name: "btn_filter_form_cancel"
3942
- });
3943
- buttonCancel.props.dispatchEvent('click', {}).then(function(){
3944
- resizeWindow();
3945
- });
3946
- }
3947
- else{
3948
- filterService.setData({showFieldsFilter: true});
3949
- resizeWindow();
3950
- if(isMobile){
3951
- // 手机端在显示搜索栏时隐藏刷新按钮
3952
- let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
3953
- crudService && crudService.setData({showFieldsFilter: true});
3954
- }
3955
- }
3956
- `;
3957
-
3958
- function getExportApiRequestAdaptorScript(){
4012
+ function requestAdaptor$1(){
3959
4013
  return `
3960
4014
  // 获取列表视图的属性
3961
4015
  let uiSchema = api.body.uiSchema;
@@ -4009,667 +4063,1101 @@ else{
4009
4063
  `
4010
4064
  }
4011
4065
 
4012
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
4013
- // console.log(`getObjectHeaderToolbar====>`, filterVisible)
4014
- const isMobile = window.innerWidth < 768;
4015
- if(isMobile){
4016
- showDisplayAs = false;
4017
- }
4018
- if(formFactor === 'SMALL'){
4019
- const onReloadScript = `
4020
- const scope = event.context.scoped;
4021
- var listView = scope.parent.getComponents().find(function(n){
4022
- return n.props.type === "crud";
4023
- });
4024
- listView.handleChangePage(1);
4025
- `;
4026
- return [
4027
- // "bulkActions",
4028
- ...(headerToolbarItems || []),
4029
- hiddenCount ? {} :{
4030
- "type": "tpl",
4031
- "tpl": "${count} 个项目"
4032
- },
4033
- {
4034
- // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
4066
+ const getNewListviewButtonSchema = ()=>{
4067
+ return {
4035
4068
  "type": "button",
4036
- "align": "right",
4037
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4038
- "label": "",
4039
- "icon": "fa fa-sync",
4040
- "visibleOn": "${!showFieldsFilter}",
4069
+ "label": "新建",
4041
4070
  "onEvent": {
4042
4071
  "click": {
4072
+ "weight": 0,
4043
4073
  "actions": [
4044
4074
  {
4045
- "actionType": "custom",
4046
- "script": onReloadScript
4075
+ "dialog": {
4076
+ "type": "dialog",
4077
+ "title": "新建 列表视图",
4078
+ "data": {
4079
+ "&": "$$",
4080
+ "all": "${uiSchema.list_views.all}",
4081
+ "list_view": "${uiSchema.list_views[listName]}",
4082
+ "appId": "${appId}",
4083
+ "global": "${global}",
4084
+ "targetObjectName": "${objectName}",
4085
+ },
4086
+ "body": [
4087
+ {
4088
+ "type": "steedos-object-form",
4089
+ "label": "对象表单",
4090
+ "objectApiName": "object_listviews",
4091
+ "recordId": "",
4092
+ "mode": "edit",
4093
+ "defaultData": {
4094
+ "&": "${list_view}",
4095
+ "name":"",
4096
+ "label":"",
4097
+ "filters":"",
4098
+ "shared":false
4099
+ },
4100
+ "fieldsExtend": fieldsExtend$4(),
4101
+ "fields": fields$1(),
4102
+ "onEvent": {
4103
+ "submitSucc": {
4104
+ "weight": 0,
4105
+ "actions": [
4106
+ {
4107
+ "args": {
4108
+ // 直接使用recordId不能拿到数据,只能通过result里面拿数据
4109
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
4110
+ "blank": false
4111
+ },
4112
+ "actionType": "url",
4113
+ }
4114
+ ]
4115
+ }
4116
+ },
4117
+ "messages": {
4118
+ "success": "成功",
4119
+ "failed": "失败"
4120
+ },
4121
+ }
4122
+ ],
4123
+ "showCloseButton": true,
4124
+ "showErrorMsg": true,
4125
+ "showLoading": true,
4126
+ "closeOnEsc": false,
4127
+ "dataMapSwitch": false,
4128
+ "size": "lg"
4129
+ },
4130
+ "actionType": "dialog"
4047
4131
  }
4048
4132
  ]
4049
4133
  }
4050
- },
4051
- },
4052
- filterVisible ? {
4053
- "label": "",
4054
- "icon": "fa fa-search",
4055
- "type": "button",
4056
- "badge": {
4057
- "offsetx": [
4058
- -2,
4059
- 2
4060
- ],
4061
- "size":8,
4062
- "animation": true,
4063
- "visibleOn": "${isFieldsFilterEmpty == false}"
4064
- },
4065
- "align": "right",
4066
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4134
+ }
4135
+ }
4136
+ };
4137
+
4138
+ function fields$1(){
4139
+ return [
4140
+ "label",
4141
+ "name",
4142
+ "object_name",
4143
+ "filter_scope",
4144
+ "show_count",
4145
+ "columns.$.field",
4146
+ "columns.$.width",
4147
+ "sort.$.field_name",
4148
+ "sort.$.order",
4149
+ "filters",
4150
+ "mobile_columns.$.field",
4151
+ "searchable_fields.$.field",
4152
+ "is_system",
4153
+ "shared"
4154
+ ]
4155
+ }
4156
+
4157
+ function fieldsExtend$4(){
4158
+ return {
4159
+ "label": {
4160
+ "is_wide": true
4161
+ },
4162
+ "name": {
4163
+ "amis": {
4164
+ "hidden": true
4165
+ }
4166
+ },
4167
+ "object_name": {
4168
+ "amis": {
4169
+ "hidden": true
4170
+ }
4171
+ },
4172
+ "filter_scope": {
4173
+ "amis": {
4174
+ "hidden": true
4175
+ }
4176
+ },
4177
+ "columns": {
4178
+ "amis": {
4179
+ "hidden": true
4180
+ }
4181
+ },
4182
+ "filter_fields": {
4183
+ "amis": {
4184
+ "hidden": true
4185
+ }
4186
+ },
4187
+ "scrolling_mode": {
4188
+ "amis": {
4189
+ "hidden": true
4190
+ }
4191
+ },
4192
+ "sort": {
4193
+ "amis": {
4194
+ "hidden": true
4195
+ }
4196
+ },
4197
+ "show_count": {
4198
+ "amis": {
4199
+ "hidden": true
4200
+ }
4201
+ },
4202
+ "type": {
4203
+ "amis": {
4204
+ "hidden": true
4205
+ }
4206
+ },
4207
+ "shared": {
4208
+ "amis": {
4209
+ "visibleOn": "${global.user.is_space_admin}"
4210
+ }
4211
+ }
4212
+ }
4213
+ }
4214
+
4215
+ const getCopyListviewButtonSchema = ()=>{
4216
+ return {
4217
+ "type": "button",
4218
+ "label": "复制",
4067
4219
  "onEvent": {
4068
4220
  "click": {
4221
+ "weight": 0,
4069
4222
  "actions": [
4070
4223
  {
4071
- "actionType": "custom",
4072
- "script": onFieldsFilterToggleScript
4224
+ "dialog": {
4225
+ "type": "dialog",
4226
+ "title": "复制 列表视图",
4227
+ "data": {
4228
+ "&": "$$",
4229
+ "listName": "${listName}",
4230
+ "targetObjectName": "${objectName}",
4231
+ "list_view": "${uiSchema.list_views[listName]}",
4232
+ "appId": "${appId}",
4233
+ "global": "${global}"
4234
+ },
4235
+ "body": [
4236
+ {
4237
+ "type": "steedos-object-form",
4238
+ "label": "对象表单",
4239
+ "objectApiName": "object_listviews",
4240
+ "recordId": "",
4241
+ "mode": "edit",
4242
+ "defaultData": {
4243
+ "&": "${list_view}",
4244
+ "name":"",
4245
+ "label": "${list_view.label} 的副本",
4246
+ "shared":false
4247
+ },
4248
+ "fieldsExtend": fieldsExtend$3(),
4249
+ "fields": fields(),
4250
+ "onEvent": {
4251
+ "submitSucc": {
4252
+ "weight": 0,
4253
+ "actions": [
4254
+ {
4255
+ "args": {
4256
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
4257
+ "blank": false
4258
+ },
4259
+ "actionType": "url",
4260
+ }
4261
+ ]
4262
+ }
4263
+ }
4264
+ }
4265
+ ],
4266
+ "showCloseButton": true,
4267
+ "showErrorMsg": true,
4268
+ "showLoading": true,
4269
+ "closeOnEsc": false,
4270
+ "dataMapSwitch": false,
4271
+ "size": "lg"
4272
+ },
4273
+ "actionType": "dialog"
4073
4274
  }
4074
4275
  ]
4075
4276
  }
4076
4277
  }
4077
- } : {},
4078
- getDisplayAsButton(mainObject?.name)
4278
+ }
4279
+ };
4280
+
4281
+ function fields(){
4282
+ return [
4283
+ "label",
4284
+ "name",
4285
+ "object_name",
4286
+ "filter_scope",
4287
+ "show_count",
4288
+ "columns.$.field",
4289
+ "columns.$.width",
4290
+ "sort.$.field_name",
4291
+ "sort.$.order",
4292
+ "filters",
4293
+ "mobile_columns.$.field",
4294
+ "searchable_fields.$.field",
4295
+ "is_system",
4296
+ "shared"
4079
4297
  ]
4080
- }else {
4081
- return [
4082
- // "filter-toggler",
4083
- ...(headerToolbarItems || []),
4084
- "bulkActions",
4085
- {
4086
- "type": "columns-toggler",
4087
- "className": "hidden"
4088
- },
4089
- // {
4090
- // "type": "columns-toggler",
4091
- // "className": "mr-2"
4092
- // },
4093
- hiddenCount ? {} : {
4094
- "type": "tpl",
4095
- "tpl": "${count} 个项目"
4096
- },
4097
- {
4098
- "type": "reload",
4099
- "align": "right",
4100
- "tooltipPlacement": "bottom",
4101
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
4102
- },
4103
- {
4298
+ }
4299
+
4300
+ function fieldsExtend$3(){
4301
+ return {
4302
+ "label": {
4303
+ "is_wide": true
4304
+ },
4305
+ "name": {
4306
+ "is_wide": true,
4307
+ "amis": {
4308
+ "hidden": true
4309
+ }
4310
+ },
4311
+ "object_name": {
4312
+ "amis": {
4313
+ "hidden": true
4314
+ }
4315
+ },
4316
+ "filter_scope": {
4317
+ "amis": {
4318
+ "hidden": true
4319
+ }
4320
+ },
4321
+ "columns": {
4322
+ "amis": {
4323
+ "hidden": true
4324
+ }
4325
+ },
4326
+ "filter_fields": {
4327
+ "amis": {
4328
+ "hidden": true
4329
+ }
4330
+ },
4331
+ "scrolling_mode": {
4332
+ "amis": {
4333
+ "hidden": true
4334
+ }
4335
+ },
4336
+ "sort": {
4337
+ "amis": {
4338
+ "hidden": true
4339
+ }
4340
+ },
4341
+ "show_count": {
4342
+ "amis": {
4343
+ "hidden": true
4344
+ }
4345
+ },
4346
+ "type": {
4347
+ "amis": {
4348
+ "hidden": true
4349
+ }
4350
+ },
4351
+ "shared": {
4352
+ "amis": {
4353
+ "visibleOn": "${global.user.is_space_admin}"
4354
+ }
4355
+ }
4356
+ }
4357
+ }
4358
+
4359
+ const getRenameListviewButtonSchema = ()=>{
4360
+ return {
4104
4361
  "type": "button",
4105
- "label": "",
4106
- "icon": "fa fa-download",
4107
- "align": "right",
4108
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4109
- "tooltipPlacement": "bottom",
4110
- "visibleOn": "${!isLookup && global.user.is_space_admin}",
4111
- "tooltip": "导出Excel",
4362
+ "label": "重命名",
4363
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4112
4364
  "onEvent": {
4113
4365
  "click": {
4114
4366
  "weight": 0,
4115
4367
  "actions": [
4116
4368
  {
4117
- "args": {
4118
- "api": {
4119
- "url": "${context.rootUrl}/api/record/export/${objectName}",
4120
- "method": "get",
4121
- "messages": {},
4122
- "requestAdaptor": `${getExportApiRequestAdaptorScript()}`,
4123
- "data": {
4124
- "uiSchema": "${uiSchema}",
4125
- "listName": "${listName}"
4126
- },
4127
- "headers": {
4128
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4369
+ "dialog": {
4370
+ "type": "dialog",
4371
+ "title": "重命名 列表视图",
4372
+ "data": {
4373
+ "targetObjectName": "${objectName}",
4374
+ "recordId": "${uiSchema.list_views[listName]._id}",
4375
+ "appId": "${appId}"
4376
+ },
4377
+ "body": [
4378
+ {
4379
+ "type": "steedos-object-form",
4380
+ "label": "对象表单",
4381
+ "objectApiName": "object_listviews",
4382
+ "recordId": "${recordId}",
4383
+ "mode": "edit",
4384
+ "fields": [
4385
+ "label"
4386
+ ],
4387
+ "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
4388
+ "onEvent": {
4389
+ "submitSucc": {
4390
+ "weight": 0,
4391
+ "actions": [
4392
+ {
4393
+ "args": {
4394
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
4395
+ "blank": false
4396
+ },
4397
+ "actionType": "url",
4398
+ },
4399
+ ]
4400
+ }
4401
+ }
4129
4402
  }
4130
- }
4403
+ ],
4404
+ "showCloseButton": true,
4405
+ "showErrorMsg": true,
4406
+ "showLoading": true,
4407
+ "size": "lg"
4131
4408
  },
4132
- "actionType": "download"
4409
+ "actionType": "dialog"
4133
4410
  }
4134
4411
  ]
4135
4412
  }
4136
4413
  }
4137
- },
4138
- filterVisible ? {
4139
- "label": "",
4140
- "icon": "fa fa-search",
4414
+ }
4415
+ };
4416
+
4417
+ const getSetListviewShareButtonSchema = ()=>{
4418
+ return {
4141
4419
  "type": "button",
4142
- "align": "right",
4143
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4420
+ "label": "共享设置",
4421
+ "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
4144
4422
  "onEvent": {
4145
4423
  "click": {
4424
+ "weight": 0,
4146
4425
  "actions": [
4147
4426
  {
4148
- "actionType": "custom",
4149
- "script": onFieldsFilterToggleScript
4427
+ "dialog": {
4428
+ "type": "dialog",
4429
+ "title": "共享设置",
4430
+ "data": {
4431
+ "recordId": "${uiSchema.list_views[listName]._id}",
4432
+ },
4433
+ "body": [
4434
+ {
4435
+ "type": "steedos-object-form",
4436
+ "label": "对象表单",
4437
+ "objectApiName": "object_listviews",
4438
+ "recordId": "${recordId}",
4439
+ "mode": "edit",
4440
+ "fields": [
4441
+ "shared"
4442
+ ]
4443
+ }
4444
+ ],
4445
+ "showCloseButton": true,
4446
+ "showErrorMsg": true,
4447
+ "showLoading": true,
4448
+ "closeOnEsc": false,
4449
+ "dataMapSwitch": false,
4450
+ "size": "md"
4451
+ },
4452
+ "actionType": "dialog"
4150
4453
  }
4151
4454
  ]
4152
4455
  }
4153
4456
  }
4154
- } : {},
4155
- {
4156
- "type": "dropdown-button",
4157
- "trigger": "click",
4158
- "icon": "fa fa-cog",
4159
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4160
- "align": "right",
4161
- "visibleOn": "${!isLookup}",
4162
- "buttons": [
4163
- {
4164
- "label": "列表视图操作",
4165
- "children": [
4457
+ }
4458
+ };
4459
+
4460
+ const getSetListviewFiltersButtonSchema = ()=>{
4461
+ return {
4462
+ "type": "button",
4463
+ "label": "过滤设置",
4464
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4465
+ "onEvent": {
4466
+ "click": {
4467
+ "weight": 0,
4468
+ "actions": [
4166
4469
  {
4167
- "type": "button",
4168
- "label": "新建",
4169
- "onEvent": {
4170
- "click": {
4171
- "weight": 0,
4172
- "actions": [
4173
- {
4174
- "dialog": {
4175
- "type": "dialog",
4176
- "title": "新建 列表视图",
4177
- "data": {
4178
- "&": "$$",
4179
- "all": "${uiSchema.list_views.all}",
4180
- "list_view": "${uiSchema.list_views[listName]}",
4181
- "appId": "${appId}",
4182
- "global": "${global}",
4183
- "targetObjectName": "${objectName}",
4184
- },
4185
- "body": [
4470
+ "dialog": {
4471
+ "type": "dialog",
4472
+ "title": "过滤设置",
4473
+ "data": {
4474
+ "targetObjectName": "${objectName}",
4475
+ "recordId": "${uiSchema.list_views[listName]._id}",
4476
+ "listName": "${listName}",
4477
+ "appId": "${appId}"
4478
+ },
4479
+ "body": [
4480
+ {
4481
+ "type": "steedos-object-form",
4482
+ "label": "对象表单",
4483
+ "objectApiName": "object_listviews",
4484
+ "recordId": "${recordId}",
4485
+ "mode": "edit",
4486
+ "fields": [
4487
+ "filters"
4488
+ ],
4489
+ "initApiAdaptor": initApiAdaptor$2(),
4490
+ "apiRequestAdaptor": apiRequestAdaptor$2(),
4491
+ "fieldsExtend": fieldsExtend$2(),
4492
+ "onEvent": {
4493
+ "submitSucc": {
4494
+ "weight": 0,
4495
+ "actions": [
4186
4496
  {
4187
- "type": "steedos-object-form",
4188
- "label": "对象表单",
4189
- "objectApiName": "object_listviews",
4190
- "recordId": "",
4191
- "mode": "edit",
4192
- "defaultData": {
4193
- "&": "${list_view}",
4194
- "name":"",
4195
- "label":"",
4196
- "filters":"",
4197
- "shared":false
4198
- },
4199
- "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}",
4200
- "fields": [
4201
- "label",
4202
- "name",
4203
- "object_name",
4204
- "filter_scope",
4205
- "show_count",
4206
- "columns.$.field",
4207
- "columns.$.width",
4208
- "sort.$.field_name",
4209
- "sort.$.order",
4210
- "filters",
4211
- "mobile_columns.$.field",
4212
- "searchable_fields.$.field",
4213
- "is_system",
4214
- "shared"
4215
- ],
4216
- "onEvent": {
4217
- "submitSucc": {
4218
- "weight": 0,
4219
- "actions": [
4220
- {
4221
- "args": {
4222
- // 直接使用recordId不能拿到数据,只能通过result里面拿数据
4223
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
4224
- "blank": false
4225
- },
4226
- "actionType": "url",
4227
- }
4228
- ]
4229
- }
4230
- },
4231
- "messages": {
4232
- "success": "成功",
4233
- "failed": "失败"
4497
+ "args": {
4498
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4499
+ "blank": false
4234
4500
  },
4501
+ "actionType": "url",
4235
4502
  }
4236
- ],
4237
- "showCloseButton": true,
4238
- "showErrorMsg": true,
4239
- "showLoading": true,
4240
- "closeOnEsc": false,
4241
- "dataMapSwitch": false,
4242
- "size": "lg"
4243
- },
4244
- "actionType": "dialog"
4503
+ ]
4504
+ }
4245
4505
  }
4246
- ]
4247
- }
4248
- }
4249
- },
4250
- {
4251
- "type": "button",
4252
- "label": "复制",
4253
- "onEvent": {
4254
- "click": {
4255
- "weight": 0,
4256
- "actions": [
4257
- {
4258
- "dialog": {
4259
- "type": "dialog",
4260
- "title": "复制 列表视图",
4261
- "data": {
4262
- "&": "$$",
4263
- "listName": "${listName}",
4264
- "targetObjectName": "${objectName}",
4265
- "list_view": "${uiSchema.list_views[listName]}",
4266
- "appId": "${appId}",
4267
- "global": "${global}"
4268
- },
4269
- "body": [
4270
- {
4271
- "type": "steedos-object-form",
4272
- "label": "对象表单",
4273
- "objectApiName": "object_listviews",
4274
- "recordId": "",
4275
- "mode": "edit",
4276
- "fields": [
4277
- ],
4278
- "defaultData": {
4279
- "&": "${list_view}",
4280
- "name":"",
4281
- "label": "${list_view.label}的副本",
4282
- "shared":false
4283
- },
4284
- "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}",
4285
- "fields": [
4286
- "label",
4287
- "name",
4288
- "object_name",
4289
- "filter_scope",
4290
- "show_count",
4291
- "columns.$.field",
4292
- "columns.$.width",
4293
- "sort.$.field_name",
4294
- "sort.$.order",
4295
- "filters",
4296
- "mobile_columns.$.field",
4297
- "searchable_fields.$.field",
4298
- "is_system",
4299
- "shared"
4300
- ],
4301
- "onEvent": {
4302
- "submitSucc": {
4303
- "weight": 0,
4304
- "actions": [
4305
- {
4306
- "args": {
4307
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
4308
- "blank": false
4309
- },
4310
- "actionType": "url",
4311
- }
4312
- ]
4313
- }
4314
- }
4315
- }
4316
- ],
4317
- "showCloseButton": true,
4318
- "showErrorMsg": true,
4319
- "showLoading": true,
4320
- "closeOnEsc": false,
4321
- "dataMapSwitch": false,
4322
- "size": "lg"
4323
- },
4324
- "actionType": "dialog"
4325
- }
4326
- ]
4327
- }
4328
- }
4329
- },
4330
- {
4331
- "type": "button",
4332
- "label": "重命名",
4333
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4334
- "onEvent": {
4335
- "click": {
4336
- "weight": 0,
4337
- "actions": [
4338
- {
4339
- "dialog": {
4340
- "type": "dialog",
4341
- "title": "重命名 列表视图",
4342
- "data": {
4343
- "targetObjectName": "${objectName}",
4344
- "recordId": "${uiSchema.list_views[listName]._id}",
4345
- "appId": "${appId}"
4346
- },
4347
- "body": [
4348
- {
4349
- "type": "steedos-object-form",
4350
- "label": "对象表单",
4351
- "objectApiName": "object_listviews",
4352
- "recordId": "${recordId}",
4353
- "mode": "edit",
4354
- "fields": [
4355
- "label"
4356
- ],
4357
- "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
4358
- "onEvent": {
4359
- "submitSucc": {
4360
- "weight": 0,
4361
- "actions": [
4362
- {
4363
- "args": {
4364
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
4365
- "blank": false
4366
- },
4367
- "actionType": "url",
4368
- },
4369
- ]
4370
- }
4371
- }
4372
- }
4373
- ],
4374
- "showCloseButton": true,
4375
- "showErrorMsg": true,
4376
- "showLoading": true,
4377
- "size": "lg"
4378
- },
4379
- "actionType": "dialog"
4380
- }
4381
- ]
4382
- }
4383
- }
4384
- },
4506
+ }
4507
+ ],
4508
+ "showCloseButton": true,
4509
+ "showErrorMsg": true,
4510
+ "showLoading": true,
4511
+ "closeOnEsc": false,
4512
+ "dataMapSwitch": false,
4513
+ "size": "lg"
4514
+ },
4515
+ "actionType": "dialog"
4516
+ }
4517
+ ]
4518
+ }
4519
+ }
4520
+ }
4521
+ };
4522
+
4523
+
4524
+ function initApiAdaptor$2(){
4525
+ return `
4526
+ const recordId_tmp = api.body.recordId;
4527
+ let data_tmp;
4528
+ if (recordId_tmp) {
4529
+ data_tmp = payload.data;
4530
+ // 数据格式转换
4531
+ if (data_tmp) {
4532
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4533
+ try {
4534
+ data_tmp.filters = JSON.parse(data_tmp.filters);
4535
+ } catch (e) { }
4536
+ }
4537
+
4538
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4539
+ data_tmp._filters_type_controller = 'function';
4540
+ } else {
4541
+ data_tmp._filters_type_controller = 'conditions'
4542
+ }
4543
+
4544
+ if (data_tmp._filters_type_controller === 'conditions') {
4545
+ data_tmp._filters_conditions = window.amisConvert.filtersToConditions(data_tmp.filters || []);
4546
+ data_tmp.filters = data_tmp._filters_conditions;
4547
+ } else {
4548
+ data_tmp._filters_function = data_tmp.filters;
4549
+ }
4550
+ }
4551
+ }
4552
+ for (key in data_tmp) {
4553
+ if (data_tmp[key] === null) {
4554
+ delete data_tmp[key];
4555
+ }
4556
+ }
4557
+ payload.data = Object.assign(payload.data, data_tmp);
4558
+ delete payload.extensions;
4559
+ return payload;
4560
+ `
4561
+ }
4562
+
4563
+ function apiRequestAdaptor$2(){
4564
+ return `
4565
+ const recordId = api.body.recordId;
4566
+ if (formData._filters_type_controller === 'conditions' && formData._filters_conditions) {
4567
+ formData.filters = window.amisConvert.conditionsToFilters(formData.filters);
4568
+ } else {
4569
+ formData.filters = formData._filters_function || null;
4570
+ }
4571
+
4572
+ delete formData._filters_type_controller;
4573
+ delete formData._filters_conditions;
4574
+ delete formData._filters_function;
4575
+
4576
+ query = 'mutation{record: ' + objectName + '__insert(doc: {__saveData}){_id}}';
4577
+ if (api.body.recordId) {
4578
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4579
+ };
4580
+ __saveData = JSON.stringify(JSON.stringify(formData));
4581
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4582
+ return api;
4583
+ `
4584
+ }
4585
+
4586
+ function fieldsExtend$2(){
4587
+ return {
4588
+ "filters": {
4589
+ "visible_on": "true",
4590
+ "amis": {
4591
+ "type": "condition-builder",
4592
+ "label": "条件组件1",
4593
+ "source": {
4594
+ "method": "get",
4595
+ "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${targetObjectName}",
4596
+ "dataType": "json",
4597
+ "headers": {
4598
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4599
+ }
4600
+ }
4601
+ }
4602
+ }
4603
+ }
4604
+ }
4605
+
4606
+ const getSetListviewColumnsButtonSchema = ()=>{
4607
+ return {
4608
+ "type": "button",
4609
+ "label": "显示的列",
4610
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4611
+ "onEvent": {
4612
+ "click": {
4613
+ "weight": 0,
4614
+ "actions": [
4385
4615
  {
4386
- "type": "button",
4387
- "label": "共享设置",
4388
- "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
4389
- "onEvent": {
4390
- "click": {
4391
- "weight": 0,
4392
- "actions": [
4393
- {
4394
- "dialog": {
4395
- "type": "dialog",
4396
- "title": "共享设置",
4397
- "data": {
4398
- "recordId": "${uiSchema.list_views[listName]._id}",
4399
- },
4400
- "body": [
4616
+ "args": {},
4617
+ "dialog": {
4618
+ "type": "dialog",
4619
+ "title": "显示的列",
4620
+ "data": {
4621
+ "&": "$$",
4622
+ "targetObjectName": "${objectName}",
4623
+ "recordId": "${uiSchema.list_views[listName]._id}",
4624
+ "listName": "${listName}",
4625
+ "appId": "${appId}"
4626
+ },
4627
+ "body": [
4628
+ {
4629
+ "type": "steedos-object-form",
4630
+ "label": "对象表单",
4631
+ "objectApiName": "object_listviews",
4632
+ "recordId": "${recordId}",
4633
+ "mode": "edit",
4634
+ "fieldsExtend": fieldsExtend$1(),
4635
+ "initApiAdaptor": initApiAdaptor$1(),
4636
+ "apiRequestAdaptor": apiRequestAdaptor$1(),
4637
+ "fields": [
4638
+ "columns",
4639
+ "mobile_columns"
4640
+ ],
4641
+ "onEvent": {
4642
+ "submitSucc": {
4643
+ "weight": 0,
4644
+ "actions": [
4401
4645
  {
4402
- "type": "steedos-object-form",
4403
- "label": "对象表单",
4404
- "objectApiName": "object_listviews",
4405
- "recordId": "${recordId}",
4406
- "mode": "edit",
4407
- "fields": [
4408
- "shared"
4409
- ]
4646
+ "args": {
4647
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4648
+ "blank": false
4649
+ },
4650
+ "actionType": "url"
4410
4651
  }
4411
- ],
4412
- "showCloseButton": true,
4413
- "showErrorMsg": true,
4414
- "showLoading": true,
4415
- "closeOnEsc": false,
4416
- "dataMapSwitch": false,
4417
- "size": "md"
4418
- },
4419
- "actionType": "dialog"
4652
+ ]
4653
+ }
4420
4654
  }
4421
- ]
4422
- }
4423
- }
4424
- },
4655
+ }
4656
+ ],
4657
+ "searchable": true,
4658
+ "showCloseButton": true,
4659
+ "showErrorMsg": true,
4660
+ "showLoading": true,
4661
+ "size": "lg"
4662
+ },
4663
+ "actionType": "dialog"
4664
+ }
4665
+ ]
4666
+ }
4667
+ }
4668
+ }
4669
+ };
4670
+
4671
+ function fieldsExtend$1(){
4672
+ return {
4673
+ "columns": {
4674
+ "amis": {
4675
+ "type": "transfer",
4676
+ "sortable": true,
4677
+ "searchable": true,
4678
+ "source": {
4679
+ "method": "get",
4680
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4681
+ "headers": {
4682
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4683
+ }
4684
+ }
4685
+ }
4686
+ },
4687
+ "mobile_columns": {
4688
+ "group": "手机端",
4689
+ "amis": {
4690
+ "type": "transfer",
4691
+ "sortable": true,
4692
+ "searchable": true,
4693
+ "source": {
4694
+ "method": "get",
4695
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4696
+ "headers": {
4697
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4698
+ }
4699
+ }
4700
+ }
4701
+ }
4702
+ }
4703
+ }
4704
+
4705
+ function initApiAdaptor$1(){
4706
+ return `
4707
+ const recordId_tmp = api.body.recordId;
4708
+ let columns_tmp = {}, mobile_columns_tmp = {};
4709
+ if (recordId_tmp) {
4710
+ columns_tmp = payload.data.columns;
4711
+ mobile_columns_tmp = payload.data.mobile_columns;
4712
+ if (columns_tmp) {
4713
+ columns_tmp = lodash.map(columns_tmp, 'field');
4714
+ }
4715
+ if (mobile_columns_tmp) {
4716
+ mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');
4717
+ }
4718
+ }
4719
+ payload.data.columns = columns_tmp;
4720
+ payload.data.mobile_columns = mobile_columns_tmp;
4721
+
4722
+ delete payload.extensions;
4723
+ return payload;
4724
+ `
4725
+ }
4726
+
4727
+ function apiRequestAdaptor$1(){
4728
+ return `
4729
+ const formData_tmp = api.body.$;
4730
+ const objectName_tmp = api.body.objectName;
4731
+ const recordId_tmp = api.body.recordId;
4732
+
4733
+ if (typeof formData_tmp.columns == 'string') {
4734
+ formData_tmp.columns = formData_tmp.columns?.split(',');
4735
+ }
4736
+ if (typeof formData_tmp.mobile_columns == 'string') {
4737
+ formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');
4738
+ }
4739
+
4740
+ // 数据格式转换
4741
+ formData_tmp.columns = lodash.map(formData_tmp.columns, (item) => {
4742
+ return { field: item };
4743
+ });
4744
+ formData.mobile_columns = lodash.map(formData.mobile_columns, (item) => {
4745
+ return { field: item };
4746
+ });
4747
+
4748
+ let query_tmp = 'mutation{record: ' + objectName_tmp + '__insert(doc: {__saveData}){_id}}';
4749
+ if (api.body.recordId) {
4750
+ query_tmp = 'mutation{record: ' + objectName_tmp + '__update(id: "' + recordId_tmp +'", doc: {__saveData}){_id}}';
4751
+ };
4752
+ delete formData_tmp._id;
4753
+ let __saveData_tmp = JSON.stringify(JSON.stringify(formData_tmp));
4754
+ api.data = { query: query_tmp.replace('{__saveData}', __saveData_tmp) };
4755
+
4756
+ return api;
4757
+ `
4758
+ }
4759
+
4760
+ const getSetListviewSortButtonSchema = ()=>{
4761
+ return {
4762
+ "type": "button",
4763
+ "label": "默认排序规则",
4764
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4765
+ "onEvent": {
4766
+ "click": {
4767
+ "weight": 0,
4768
+ "actions": [
4425
4769
  {
4426
- "type": "button",
4427
- "label": "过滤设置",
4428
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4429
- "onEvent": {
4430
- "click": {
4431
- "weight": 0,
4432
- "actions": [
4433
- {
4434
- "dialog": {
4435
- "type": "dialog",
4436
- "title": "过滤设置",
4437
- "data": {
4438
- "targetObjectName": "${objectName}",
4439
- "objectName": "${objectName}",
4440
- "recordId": "${uiSchema.list_views[listName]._id}",
4441
- "listName": "${listName}",
4442
- "appId": "${appId}"
4443
- },
4444
- "body": [
4770
+ "dialog": {
4771
+ "type": "dialog",
4772
+ "title": "弹框标题",
4773
+ "data": {
4774
+ "&": "$$",
4775
+ "targetObjectName": "${objectName}",
4776
+ "recordId": "${uiSchema.list_views[listName]._id}",
4777
+ "listName": "${listName}",
4778
+ "appId": "${appId}"
4779
+ },
4780
+ "body": [
4781
+ {
4782
+ "type": "steedos-object-form",
4783
+ "label": "对象表单",
4784
+ "objectApiName": "object_listviews",
4785
+ "recordId": "${recordId}",
4786
+ "className": "",
4787
+ "id": "u:061f158b4c5a",
4788
+ "mode": "edit",
4789
+ "fields": [
4790
+ "sort",
4791
+ "sort.$.field_name",
4792
+ "sort.$.order"
4793
+ ],
4794
+ "onEvent": {
4795
+ "submitSucc": {
4796
+ "weight": 0,
4797
+ "actions": [
4445
4798
  {
4446
- "type": "steedos-object-form",
4447
- "label": "对象表单",
4448
- "objectApiName": "object_listviews",
4449
- "recordId": "${recordId}",
4450
- "mode": "edit",
4451
- "fields": [
4452
- "filters"
4453
- ],
4454
- "initApiRequestAdaptor": "",
4455
- "initApiAdaptor": "const recordId_tmp = api.body.recordId;\nlet data_tmp;\nif (recordId_tmp) {\n data_tmp = payload.data;\n // 数据格式转换\n if (data_tmp) {\n if (data_tmp.filters && lodash.isString(data_tmp.filters)) {\n try {\n data_tmp.filters = JSON.parse(data_tmp.filters);\n } catch (e) { }\n }\n\n if (data_tmp.filters && lodash.isString(data_tmp.filters)) {\n data_tmp._filters_type_controller = 'function';\n } else {\n data_tmp._filters_type_controller = 'conditions'\n }\n\n if (data_tmp._filters_type_controller === 'conditions') {\n data_tmp._filters_conditions = window.amisConvert.filtersToConditions(data_tmp.filters || []);\n data_tmp.filters = data_tmp._filters_conditions;\n } else {\n data_tmp._filters_function = data_tmp.filters;\n }\n }\n}\nfor (key in data_tmp) {\n if (data_tmp[key] === null) {\n delete data_tmp[key];\n }\n}\npayload.data = Object.assign(payload.data, data_tmp);\ndelete payload.extensions;",
4456
- "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",
4457
- "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}",
4458
- "onEvent": {
4459
- "submitSucc": {
4460
- "weight": 0,
4461
- "actions": [
4462
- {
4463
- "args": {
4464
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4465
- "blank": false
4466
- },
4467
- "actionType": "url",
4468
- }
4469
- ]
4470
- }
4471
- }
4799
+ "args": {
4800
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4801
+ "blank": false
4802
+ },
4803
+ "actionType": "url"
4472
4804
  }
4473
- ],
4474
- "showCloseButton": true,
4475
- "showErrorMsg": true,
4476
- "showLoading": true,
4477
- "closeOnEsc": false,
4478
- "dataMapSwitch": false,
4479
- "size": "lg"
4480
- },
4481
- "actionType": "dialog"
4482
- }
4483
- ]
4484
- }
4485
- }
4486
- },
4805
+ ]
4806
+ }
4807
+ },
4808
+ "fieldsExtend": fieldsExtend(),
4809
+ "initApiAdaptor": initApiAdaptor(),
4810
+ "apiRequestAdaptor": apiRequestAdaptor()
4811
+ }
4812
+ ],
4813
+ "showCloseButton": true,
4814
+ "showErrorMsg": true,
4815
+ "showLoading": true,
4816
+ "id": "u:d3f6947b6acf",
4817
+ "size": "lg"
4818
+ },
4819
+ "actionType": "dialog"
4820
+ }
4821
+ ]
4822
+ }
4823
+ }
4824
+ }
4825
+ };
4826
+
4827
+ function fieldsExtend(){
4828
+ return {
4829
+ "sort": {
4830
+ "amis": {
4831
+ "type": "tabs-transfer",
4832
+ "sortable": true,
4833
+ "searchable": true,
4834
+ "source": {
4835
+ "method": "get",
4836
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/sortFields/options",
4837
+ "headers": {
4838
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4839
+ }
4840
+ }
4841
+ }
4842
+ }
4843
+ }
4844
+ }
4845
+
4846
+ function initApiAdaptor(){
4847
+ return `
4848
+ let sort;
4849
+ if (recordId) {
4850
+ sort = payload.data.sort;
4851
+ //数据格式转换
4852
+ if (sort instanceof Array) {
4853
+ sort = lodash.map(sort, (item) => {
4854
+ return item.field_name + ':' + (item.order || 'asc')
4855
+ });
4856
+ }
4857
+ }
4858
+ payload.data.sort = sort;
4859
+ delete payload.extensions;
4860
+ return payload;
4861
+ `
4862
+ }
4863
+
4864
+ function apiRequestAdaptor(){
4865
+ return `
4866
+ const recordId = api.body.recordId;
4867
+ //数据格式转换
4868
+ if (typeof formData.sort == 'string') {
4869
+ formData.sort = formData.sort?.split(',');
4870
+ }
4871
+ formData.sort = lodash.map(formData.sort, (item) => {
4872
+ const arr = item.split(':');
4873
+ return { field_name: arr[0], order: arr[1] };
4874
+ });
4875
+ if (recordId) {
4876
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4877
+ }
4878
+ __saveData = JSON.stringify(JSON.stringify(formData));
4879
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4880
+ return api;
4881
+ `
4882
+ }
4883
+
4884
+ const getDeleteListviewButtonSchema = ()=>{
4885
+ return {
4886
+ "type": "button",
4887
+ "label": "删除",
4888
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4889
+ "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4890
+ "onEvent": {
4891
+ "click": {
4892
+ "actions": [
4487
4893
  {
4488
- "type": "button",
4489
- "label": "显示的列",
4490
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4491
- "onEvent": {
4492
- "click": {
4493
- "weight": 0,
4494
- "actions": [
4495
- {
4496
- "args": {},
4497
- "dialog": {
4498
- "type": "dialog",
4499
- "title": "显示的列",
4500
- "data": {
4501
- "&": "$$",
4502
- "targetObjectName": "${objectName}",
4503
- "objectName": "${objectName}",
4504
- "recordId": "${uiSchema.list_views[listName]._id}",
4505
- "listName": "${listName}",
4506
- "appId": "${appId}"
4507
- },
4508
- "body": [
4509
- {
4510
- "type": "steedos-object-form",
4511
- "label": "对象表单",
4512
- "objectApiName": "object_listviews",
4513
- "recordId": "${recordId}",
4514
- "mode": "edit",
4515
- "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}",
4516
- "initApiAdaptor": "const recordId_tmp = api.body.recordId;\nlet columns_tmp = {}, mobile_columns_tmp = {};\nif (recordId_tmp) {\n columns_tmp = payload.data.columns;\n mobile_columns_tmp = payload.data.mobile_columns;\n if (columns_tmp) {\n columns_tmp = lodash.map(columns_tmp, 'field');\n }\n if (mobile_columns_tmp) {\n mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');\n }\n}\npayload.data.columns = columns_tmp;\npayload.data.mobile_columns = mobile_columns_tmp;\n\ndelete payload.extensions;\nreturn payload;",
4517
- "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;",
4518
- "fields": [
4519
- "columns",
4520
- "mobile_columns"
4521
- ],
4522
- "onEvent": {
4523
- "submitSucc": {
4524
- "weight": 0,
4525
- "actions": [
4526
- {
4527
- "args": {
4528
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4529
- "blank": false
4530
- },
4531
- "actionType": "url"
4532
- }
4533
- ]
4534
- }
4535
- }
4536
- }
4537
- ],
4538
- "searchable": true,
4539
- "showCloseButton": true,
4540
- "showErrorMsg": true,
4541
- "showLoading": true,
4542
- "size": "lg"
4543
- },
4544
- "actionType": "dialog"
4545
- }
4546
- ]
4894
+ "actionType": "ajax",
4895
+ "args": {
4896
+ "api": {
4897
+ "url": "${context.rootUrl}/graphql",
4898
+ "method": "post",
4899
+ "headers": {
4900
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4901
+ },
4902
+ "data": {
4903
+ "&": "$$",
4904
+ "uiSchema": "${uiSchema}",
4905
+ "recordId": "${uiSchema.list_views[listName]._id}"
4906
+ },
4907
+ "messages": {
4908
+ "success": "删除成功"
4909
+ },
4910
+ "requestAdaptor": requestAdaptor(),
4911
+ "adaptor": adaptor(),
4547
4912
  }
4548
4913
  }
4549
4914
  },
4550
4915
  {
4551
- "type": "button",
4552
- "label": "默认排序规则",
4553
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4554
- "onEvent": {
4555
- "click": {
4556
- "weight": 0,
4557
- "actions": [
4558
- {
4559
- "dialog": {
4560
- "type": "dialog",
4561
- "title": "弹框标题",
4562
- "data": {
4563
- "&": "$$",
4564
- "targetObjectName": "${objectName}",
4565
- "objectName": "${objectName}",
4566
- "recordId": "${uiSchema.list_views[listName]._id}",
4567
- "listName": "${listName}",
4568
- "appId": "${appId}"
4569
- },
4570
- "body": [
4571
- {
4572
- "type": "steedos-object-form",
4573
- "label": "对象表单",
4574
- "objectApiName": "object_listviews",
4575
- "recordId": "${recordId}",
4576
- "className": "",
4577
- "id": "u:061f158b4c5a",
4578
- "mode": "edit",
4579
- "fields": [
4580
- "sort",
4581
- "sort.$.field_name",
4582
- "sort.$.order"
4583
- ],
4584
- "onEvent": {
4585
- "submitSucc": {
4586
- "weight": 0,
4587
- "actions": [
4588
- {
4589
- "args": {
4590
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4591
- "blank": false
4592
- },
4593
- "actionType": "url"
4594
- }
4595
- ]
4596
- }
4597
- },
4598
- "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}",
4599
- "initApiAdaptor": "let sort;\nif (recordId) {\n sort = payload.data.sort;\n //数据格式转换\n if (sort instanceof Array) {\n sort = lodash.map(sort, (item) => {\n return item.field_name + ':' + (item.order || 'asc')\n });\n }\n}\npayload.data.sort = sort;\ndelete payload.extensions;",
4600
- "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"
4601
- }
4602
- ],
4603
- "showCloseButton": true,
4604
- "showErrorMsg": true,
4605
- "showLoading": true,
4606
- "id": "u:d3f6947b6acf",
4607
- "size": "lg"
4608
- },
4609
- "actionType": "dialog"
4610
- }
4611
- ]
4612
- }
4613
- }
4614
- },
4916
+ "actionType": "url",
4917
+ "args": {
4918
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4919
+ "blank": false
4920
+ },
4921
+ "expression": "data.delete == 1"
4922
+ }
4923
+ ]
4924
+ }
4925
+ }
4926
+ }
4927
+ };
4928
+
4929
+
4930
+ function requestAdaptor(){
4931
+ return `
4932
+ const { recordId } = api.body;
4933
+ var deleteArray = [];
4934
+ if (recordId) { deleteArray.push(\`delete:object_listviews__delete(id: "\${recordId}")\`); }
4935
+ api.data = { query: \`mutation{\${deleteArray.join(',')}}\` };
4936
+ return api;
4937
+ `
4938
+ }
4939
+
4940
+ function adaptor(){
4941
+ return `
4942
+ if (payload.errors) {
4943
+ payload.status = 2;
4944
+ payload.msg = payload.errors[0].message;
4945
+ }
4946
+ return payload;
4947
+ `
4948
+ }
4949
+
4950
+ const getSettingListviewToolbarButtonSchema = ()=>{
4951
+ return {
4952
+ "type": "dropdown-button",
4953
+ "trigger": "click",
4954
+ "icon": "fa fa-cog",
4955
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4956
+ "align": "right",
4957
+ "visibleOn": "${!isLookup}",
4958
+ "buttons": [
4959
+ {
4960
+ "label": "列表视图操作",
4961
+ "children": [
4962
+ getNewListviewButtonSchema(),
4963
+ getCopyListviewButtonSchema(),
4964
+ getRenameListviewButtonSchema(),
4965
+ getSetListviewShareButtonSchema(),
4966
+ getSetListviewFiltersButtonSchema(),
4967
+ getSetListviewColumnsButtonSchema(),
4968
+ getSetListviewSortButtonSchema(),
4969
+ getDeleteListviewButtonSchema()
4970
+ ]
4971
+ }
4972
+ ]
4973
+ }
4974
+ };
4975
+
4976
+ const getDisplayAsButton = function(objectName, showDisplayAs){
4977
+ let displayAs = Router$1.getTabDisplayAs(objectName);
4978
+ let buttons = [
4979
+ {
4980
+ "type": "button",
4981
+ "label": "表格",
4982
+ "onClick": "let url = document.location.pathname; var urlSearch = new URLSearchParams(document.location.search); if(urlSearch.get(\"side_object\") && urlSearch.get(\"side_listview_id\")){url=`/app/${props.data.appId}/${urlSearch.get(\"side_object\")}/grid/${urlSearch.get(\"side_listview_id\")}`;}; props.env.jumpTo(url + '?display=grid');",
4983
+ "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
4984
+ "rightIconClassName": "m-l-sm"
4985
+ },
4986
+ {
4987
+ "type": "button",
4988
+ "label": "分栏视图",
4989
+ "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
4990
+ "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
4991
+ "rightIconClassName": "m-l-sm"
4992
+ }
4993
+ ];
4994
+ return {
4995
+ "type": "dropdown-button",
4996
+ "icon": "fa fa-table-columns",
4997
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4998
+ "align": "right",
4999
+ "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
5000
+ "buttons": [
5001
+ {
5002
+ "label": "显示为",
5003
+ "children": buttons
5004
+ }
5005
+ ]
5006
+ };
5007
+ };
5008
+
5009
+
5010
+ const onFieldsFilterToggleScript = `
5011
+ const scope = event.context.scoped;
5012
+ const filterForm = scope.getComponents().find(function(n){
5013
+ return n.props.type === "form";
5014
+ });
5015
+ const filterService = filterForm.context.getComponents().find(function(n){
5016
+ return n.props.type === "service";
5017
+ });
5018
+ // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
5019
+ let resizeWindow = function(){
5020
+ //触发amis crud 高度重算
5021
+ setTimeout(()=>{
5022
+ window.dispatchEvent(new Event("resize"))
5023
+ }, 500);
5024
+ }
5025
+ let isMobile = Steedos.isMobile();
5026
+ if(filterService.props.data.showFieldsFilter){
5027
+ if(isMobile){
5028
+ // 手机上只能通过取消按钮来关闭搜索栏
5029
+ return;
5030
+ }
5031
+ let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
5032
+ direction: "down",
5033
+ name: "btn_filter_form_cancel"
5034
+ });
5035
+ buttonCancel.props.dispatchEvent('click', {}).then(function(){
5036
+ resizeWindow();
5037
+ });
5038
+ }
5039
+ else{
5040
+ filterService.setData({showFieldsFilter: true});
5041
+ resizeWindow();
5042
+ if(isMobile){
5043
+ // 手机端在显示搜索栏时隐藏刷新按钮
5044
+ let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
5045
+ crudService && crudService.setData({showFieldsFilter: true});
5046
+ }
5047
+ }
5048
+ `;
5049
+
5050
+
5051
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
5052
+ // console.log(`getObjectHeaderToolbar====>`, filterVisible)
5053
+ const isMobile = window.innerWidth < 768;
5054
+ if(isMobile){
5055
+ showDisplayAs = false;
5056
+ }
5057
+ if(formFactor === 'SMALL'){
5058
+ const onReloadScript = `
5059
+ const scope = event.context.scoped;
5060
+ var listView = scope.parent.getComponents().find(function(n){
5061
+ return n.props.type === "crud";
5062
+ });
5063
+ listView.handleChangePage(1);
5064
+ `;
5065
+ return [
5066
+ // "bulkActions",
5067
+ ...(headerToolbarItems || []),
5068
+ hiddenCount ? {} :{
5069
+ "type": "tpl",
5070
+ "tpl": "${count} 个项目"
5071
+ },
5072
+ {
5073
+ // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
5074
+ "type": "button",
5075
+ "align": "right",
5076
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5077
+ "label": "",
5078
+ "icon": "fa fa-sync",
5079
+ "visibleOn": "${!showFieldsFilter}",
5080
+ "onEvent": {
5081
+ "click": {
5082
+ "actions": [
4615
5083
  {
4616
- "type": "button",
4617
- "label": "删除",
4618
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4619
- "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4620
- "onEvent": {
4621
- "click": {
4622
- "actions": [
4623
- {
4624
- "actionType": "ajax",
4625
- "args": {
4626
- "api": {
4627
- "url": "${context.rootUrl}/graphql",
4628
- "method": "post",
4629
- "headers": {
4630
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4631
- },
4632
- "data": {
4633
- "&": "$$",
4634
- "uiSchema": "${uiSchema}",
4635
- "recordId": "${uiSchema.list_views[listName]._id}"
4636
- },
4637
- "messages": {
4638
- "success": "删除成功"
4639
- },
4640
- "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",
4641
- "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n}\nreturn payload;",
4642
- }
4643
- }
4644
- },
4645
- {
4646
- "actionType": "url",
4647
- "args": {
4648
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4649
- "blank": false
4650
- },
4651
- "expression": "data.delete == 1"
4652
- }
4653
- ]
4654
- }
4655
- }
4656
- },
5084
+ "actionType": "custom",
5085
+ "script": onReloadScript
5086
+ }
5087
+ ]
5088
+ }
5089
+ },
5090
+ },
5091
+ filterVisible ? {
5092
+ "label": "",
5093
+ "icon": "fa fa-search",
5094
+ "type": "button",
5095
+ "badge": {
5096
+ "offset": [
5097
+ -5,
5098
+ 1
5099
+ ],
5100
+ "size":8,
5101
+ "animation": true,
5102
+ "visibleOn": "${isFieldsFilterEmpty == false}"
5103
+ },
5104
+ "align": "right",
5105
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5106
+ "onEvent": {
5107
+ "click": {
5108
+ "actions": [
4657
5109
  {
4658
- "type": "button",
4659
- "visibleOn": "${false}",
4660
- "label": "保存宽度(todo)"
4661
- },
4662
- // {
4663
- // type: 'steedos-object-button',
4664
- // name: 'standard_delete',
4665
- // objectName: 'test0321__c',
4666
- // // visibleOn: getButtonVisibleOn(button),
4667
- // className: 'antd-Button--default'
4668
- // }
5110
+ "actionType": "custom",
5111
+ "script": onFieldsFilterToggleScript
5112
+ }
4669
5113
  ]
4670
5114
  }
4671
- ]
5115
+ }
5116
+ } : {},
5117
+ getDisplayAsButton(mainObject?.name)
5118
+ ]
5119
+ }else {
5120
+ return [
5121
+ // "filter-toggler",
5122
+ ...(headerToolbarItems || []),
5123
+ "bulkActions",
5124
+ {
5125
+ "type": "columns-toggler",
5126
+ "className": "hidden"
5127
+ },
5128
+ // {
5129
+ // "type": "columns-toggler",
5130
+ // "className": "mr-2"
5131
+ // },
5132
+ hiddenCount ? {} : {
5133
+ "type": "tpl",
5134
+ "tpl": "${count} 个项目"
5135
+ },
5136
+ {
5137
+ "type": "reload",
5138
+ "align": "right",
5139
+ "tooltipPlacement": "bottom",
5140
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
4672
5141
  },
5142
+ getExportExcelToolbarButtonSchema(),
5143
+ filterVisible ? {
5144
+ "label": "",
5145
+ "icon": "fa fa-search",
5146
+ "type": "button",
5147
+ "align": "right",
5148
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5149
+ "onEvent": {
5150
+ "click": {
5151
+ "actions": [
5152
+ {
5153
+ "actionType": "custom",
5154
+ "script": onFieldsFilterToggleScript
5155
+ }
5156
+ ]
5157
+ }
5158
+ }
5159
+ } : {},
5160
+ getSettingListviewToolbarButtonSchema(),
4673
5161
  getDisplayAsButton(showDisplayAs)
4674
5162
  // {
4675
5163
  // "type": "search-box",
@@ -5148,20 +5636,7 @@ else{
5148
5636
  }
5149
5637
  }
5150
5638
 
5151
- var searchableFilter = [];
5152
- _.each(selfData, (value, key)=>{
5153
- if(!_.isEmpty(value) || _.isBoolean(value)){
5154
- if(_.startsWith(key, '__searchable__between__')){
5155
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
5156
- }else if(_.startsWith(key, '__searchable__')){
5157
- if(_.isString(value)){
5158
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
5159
- }else{
5160
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
5161
- }
5162
- }
5163
- }
5164
- });
5639
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
5165
5640
 
5166
5641
  if(searchableFilter.length > 0){
5167
5642
  if(filters.length > 0 ){
@@ -6583,6 +7058,29 @@ else{
6583
7058
  window.getFieldSearchable = getFieldSearchable;
6584
7059
  }
6585
7060
 
7061
+
7062
+ function isFieldTypeSearchable(fieldType) {
7063
+ return !___default__namespace.includes(
7064
+ [
7065
+ "grid",
7066
+ "avatar",
7067
+ "image",
7068
+ "object",
7069
+ "[object]",
7070
+ "[Object]",
7071
+ "[grid]",
7072
+ "[text]",
7073
+ "audio",
7074
+ "file",
7075
+ ],
7076
+ fieldType
7077
+ )
7078
+ }
7079
+
7080
+ if (typeof window != 'undefined') {
7081
+ window.isFieldTypeSearchable = isFieldTypeSearchable;
7082
+ }
7083
+
6586
7084
  var index = /*#__PURE__*/Object.freeze({
6587
7085
  __proto__: null,
6588
7086
  OMIT_FIELDS: OMIT_FIELDS,
@@ -6594,6 +7092,7 @@ else{
6594
7092
  getSelectFieldOptions: getSelectFieldOptions,
6595
7093
  convertSFieldToAmisField: convertSFieldToAmisField,
6596
7094
  getFieldSearchable: getFieldSearchable,
7095
+ isFieldTypeSearchable: isFieldTypeSearchable,
6597
7096
  getAmisStaticFieldType: getAmisStaticFieldType
6598
7097
  });
6599
7098
 
@@ -7205,7 +7704,7 @@ else{
7205
7704
  id: `service_${id}`,
7206
7705
  name: `page`,
7207
7706
  data: {
7208
- // objectName: objectSchema.name,
7707
+ objectName: objectSchema.name,
7209
7708
  // _id: null,
7210
7709
  recordPermissions: objectSchema.permissions,
7211
7710
  uiSchema: objectSchema,
@@ -8023,20 +8522,8 @@ else{
8023
8522
  }else if(selfData.op === 'loadOptions' && selfData.value){
8024
8523
  userFilters = [["${valueField.name}", "=", selfData.value]];
8025
8524
  }
8026
- var searchableFilter = [];
8027
- _.each(selfData, (value, key)=>{
8028
- if(!_.isEmpty(value) || _.isBoolean(value)){
8029
- if(_.startsWith(key, '__searchable__between__')){
8030
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
8031
- }else if(_.startsWith(key, '__searchable__')){
8032
- if(_.isString(value)){
8033
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
8034
- }else{
8035
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
8036
- }
8037
- }
8038
- }
8039
- });
8525
+
8526
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
8040
8527
 
8041
8528
  if(searchableFilter.length > 0){
8042
8529
  if(userFilters.length > 0 ){
@@ -8307,20 +8794,7 @@ else{
8307
8794
  }else if(selfData.op === 'loadOptions' && selfData.value){
8308
8795
  filters = [["${valueField.name}", "=", selfData.value]];
8309
8796
  }
8310
- var searchableFilter = [];
8311
- _.each(selfData, (value, key)=>{
8312
- if(!_.isEmpty(value) || _.isBoolean(value)){
8313
- if(_.startsWith(key, '__searchable__between__')){
8314
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
8315
- }else if(_.startsWith(key, '__searchable__')){
8316
- if(_.isString(value)){
8317
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
8318
- }else{
8319
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
8320
- }
8321
- }
8322
- }
8323
- });
8797
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
8324
8798
 
8325
8799
  if(searchableFilter.length > 0){
8326
8800
  if(filters.length > 0 ){
@@ -8846,7 +9320,7 @@ else{
8846
9320
  * @Author: baozhoutao@steedos.com
8847
9321
  * @Date: 2022-07-05 15:55:39
8848
9322
  * @LastEditors: Please set LastEditors
8849
- * @LastEditTime: 2023-05-08 16:34:25
9323
+ * @LastEditTime: 2023-05-17 09:09:33
8850
9324
  * @Description:
8851
9325
  */
8852
9326
 
@@ -8986,7 +9460,7 @@ else{
8986
9460
  // } else {
8987
9461
  // globalFilter = [`${relatedKey}`, "=", relatedValue];
8988
9462
  // }
8989
- const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
9463
+ const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
8990
9464
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
8991
9465
  const options = {
8992
9466
  globalFilter,
@@ -12635,6 +13109,7 @@ else{
12635
13109
  getObjectListHeaderSecordLine: getObjectListHeaderSecordLine,
12636
13110
  getObjectListViewButtonsSchemas: getObjectListViewButtonsSchemas,
12637
13111
  getObjectRecordDetailHeader: getObjectRecordDetailHeader,
13112
+ getObjectRecordDetailRelatedListButtonsSchemas: getObjectRecordDetailRelatedListButtonsSchemas,
12638
13113
  getObjectRecordDetailRelatedListHeader: getObjectRecordDetailRelatedListHeader,
12639
13114
  getObjectRelated: getObjectRelated,
12640
13115
  getObjectRelatedList: getObjectRelatedList,
@@ -13532,11 +14007,12 @@ else{
13532
14007
  }); };
13533
14008
 
13534
14009
  var AmisRecordDetailRelatedList = function (props) { return __awaiter(void 0, void 0, void 0, function () {
13535
- var $schema, objectApiName, recordId, relatedObjectApiName, relatedKey, top, perPage, hiddenEmptyTable, appId, relatedLabel, _a, className, columns, sort, filters, visible_on, requestAdaptor, adaptor, formFactor, formData, schema;
13536
- return __generator(this, function (_b) {
13537
- switch (_b.label) {
14010
+ var $schema, objectApiName, recordId, relatedObjectApiName, data, relatedKey, top, perPage, hiddenEmptyTable, appId, relatedLabel, _a, className, columns, sort, filters, visible_on, requestAdaptor, adaptor, formFactor, formData, schema;
14011
+ var _b;
14012
+ return __generator(this, function (_c) {
14013
+ switch (_c.label) {
13538
14014
  case 0:
13539
- $schema = props.$schema, objectApiName = props.objectApiName, recordId = props.recordId, relatedObjectApiName = props.relatedObjectApiName, props.data, relatedKey = props.relatedKey, top = props.top, perPage = props.perPage, hiddenEmptyTable = props.hiddenEmptyTable, appId = props.appId, relatedLabel = props.relatedLabel, _a = props.className, className = _a === void 0 ? '' : _a, columns = props.columns, sort = props.sort, filters = props.filters, visible_on = props.visible_on, requestAdaptor = props.requestAdaptor, adaptor = props.adaptor;
14015
+ $schema = props.$schema, objectApiName = props.objectApiName, recordId = props.recordId, relatedObjectApiName = props.relatedObjectApiName, data = props.data, relatedKey = props.relatedKey, top = props.top, perPage = props.perPage, hiddenEmptyTable = props.hiddenEmptyTable, appId = props.appId, relatedLabel = props.relatedLabel, _a = props.className, className = _a === void 0 ? '' : _a, columns = props.columns, sort = props.sort, filters = props.filters, visible_on = props.visible_on, requestAdaptor = props.requestAdaptor, adaptor = props.adaptor;
13540
14016
  formFactor = props.formFactor;
13541
14017
  if (!formFactor) {
13542
14018
  formFactor = window.innerWidth < 768 ? 'SMALL' : 'LARGE';
@@ -13557,8 +14033,17 @@ else{
13557
14033
  }
13558
14034
  return [4 /*yield*/, getRecordDetailRelatedListSchema(objectApiName, recordId, relatedObjectApiName, relatedKey, { top: top, perPage: perPage, appId: appId, relatedLabel: relatedLabel, className: className, formFactor: formFactor, columns: columns, sort: sort, filters: filters, visible_on: visible_on, isRelated: true, hiddenEmptyTable: hiddenEmptyTable, requestAdaptor: requestAdaptor, adaptor: adaptor })];
13559
14035
  case 1:
13560
- schema = (_b.sent()).amisSchema;
14036
+ schema = (_c.sent()).amisSchema;
13561
14037
  schema.data = Object.assign(schema.data, formData);
14038
+ if (___default.has(props, "recordId") && $schema.recordId !== "${recordId}") {
14039
+ schema.data = Object.assign(schema.data, {
14040
+ _master: {
14041
+ record: (_b = data === null || data === void 0 ? void 0 : data._master) === null || _b === void 0 ? void 0 : _b.record,
14042
+ objectName: objectApiName,
14043
+ recordId: recordId
14044
+ }
14045
+ });
14046
+ }
13562
14047
  return [2 /*return*/, schema];
13563
14048
  }
13564
14049
  });
@@ -14230,7 +14715,16 @@ else{
14230
14715
  },
14231
14716
  "adaptor": "return payload.data"
14232
14717
  },
14233
- "interval": 30000,
14718
+ "onEvent": {
14719
+ "@data.changed.notifications": {
14720
+ "actions": [
14721
+ {
14722
+ "actionType": "reload"
14723
+ }
14724
+ ]
14725
+ }
14726
+ },
14727
+ // "interval": 30000,
14234
14728
  "silentPolling": true
14235
14729
  }
14236
14730
  ],
@@ -14318,6 +14812,15 @@ else{
14318
14812
  },
14319
14813
  ],
14320
14814
  "id": "u:aba521eed5b7",
14815
+ "onEvent": {
14816
+ "@data.changed.notifications": {
14817
+ "actions": [
14818
+ {
14819
+ "actionType": "reload"
14820
+ }
14821
+ ]
14822
+ }
14823
+ },
14321
14824
  "messages": {},
14322
14825
  "api": {
14323
14826
  "method": "post",
@@ -14476,8 +14979,8 @@ else{
14476
14979
  /*
14477
14980
  * @Author: baozhoutao@steedos.com
14478
14981
  * @Date: 2022-09-01 14:44:57
14479
- * @LastEditors: baozhoutao@steedos.com
14480
- * @LastEditTime: 2023-04-11 13:51:50
14982
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
14983
+ * @LastEditTime: 2023-05-17 17:26:22
14481
14984
  * @Description:
14482
14985
  */
14483
14986
  var AmisGlobalHeader = function (props) { return __awaiter(void 0, void 0, void 0, function () {
@@ -14498,8 +15001,17 @@ else{
14498
15001
  "className": 'flex w-full px-4 h-[50px] p-0 justify-between items-center steedos-header-container-line-one',
14499
15002
  "body": [
14500
15003
  {
14501
- type: "wrapper",
15004
+ type: "service",
14502
15005
  className: 'p-0 flex flex-1 items-center',
15006
+ "onEvent": {
15007
+ "@history_paths.changed": {
15008
+ "actions": [
15009
+ {
15010
+ "actionType": "reload"
15011
+ }
15012
+ ]
15013
+ }
15014
+ },
14503
15015
  body: [
14504
15016
  {
14505
15017
  "type": "button",
@@ -14526,10 +15038,35 @@ else{
14526
15038
  }
14527
15039
  ],
14528
15040
  },
15041
+ {
15042
+ "type": "button",
15043
+ "visibleOn": "${window:innerWidth < 768 && window:historyPaths.length > 1}",
15044
+ "className": "flex",
15045
+ "onEvent": {
15046
+ "click": {
15047
+ "actions": [
15048
+ {
15049
+ "actionType": "custom",
15050
+ "script": "Steedos.goBack()"
15051
+ }
15052
+ ]
15053
+ }
15054
+ },
15055
+ "body": [
15056
+ {
15057
+ "type": "steedos-icon",
15058
+ "category": "utility",
15059
+ "name": "chevronleft",
15060
+ "colorVariant": "default",
15061
+ "className": "slds-button_icon slds-global-header__icon"
15062
+ }
15063
+ ]
15064
+ },
14529
15065
  {
14530
15066
  "className": 'block h-10 w-auto mr-4',
14531
15067
  "type": "tpl",
14532
15068
  "tpl": "<a href='/app' class='flex items-center '><img class='block h-10 w-auto' src='".concat(logoSrc, "'></a>"),
15069
+ "hiddenOn": "${window:innerWidth < 768 && window:historyPaths.length > 1}"
14533
15070
  },
14534
15071
  ],
14535
15072
  },
@@ -14748,6 +15285,7 @@ else{
14748
15285
  "method": "post",
14749
15286
  "url": "${context.rootUrl}/graphql?keywords=${keywords}",
14750
15287
  "requestAdaptor": "\n const keywords = api.body.keywords || '';\n const appId = '".concat(data.app_id || '', "';\n api.data = {\n query: `\n {\n options: flows__getList(action: \"").concat(action, "\", keywords: \"${keywords}\", appId: \"${appId}\", distributeInstanceId: \"").concat(distributeInstanceId, "\", distributeStepId: \"").concat(distributeStepId, "\"){\n value:_id\n label:name\n children: flows{\n value: _id,\n label: name\n }\n }\n }\n `\n }\n "),
15288
+ "adaptor": "\n payload.data.options?.forEach(function(item,index) {\n if(!item.children || item.children.length == 0){\n payload.data.options.splice(index)\n }\n })\n return payload;\n ",
14751
15289
  "headers": {
14752
15290
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
14753
15291
  }
@@ -14991,7 +15529,7 @@ else{
14991
15529
  });
14992
15530
  }); };
14993
15531
 
14994
- var __assign=function(){return (__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},StandardObjects={Base:{Actions:{standard_query:{visible:function(e,t,n){return !1}},standard_new:{visible:function(e,t,n){return "cms_files"!==e&&"instances"!==e&&(n?n.allowCreate:void 0)}},standard_edit:{visible:function(e,t,n){if(n)return n.allowEdit}},standard_delete:{visible:function(e,t,n){if(n)return n.allowDelete}},standard_import_data:{visible:function(e,t,n){var r=this.object;if(n)return n.allowCreate&&r.hasImportTemplates}},standard_approve:{visible:function(e,t,n){return !1}},standard_view_instance:{visible:function(e,t,n){return !1}},standard_submit_for_approval:{visible:function(e,t,n){return window.Steedos.ProcessManager.allowSubmit.apply(this,[e,t])},todo:function(e,t){return window.Steedos.ProcessManager.submit.apply(this,[e,t])}},standard_follow:{visible:function(e,t,n){return !1}},standard_delete_many:{visible:function(e,t,n){return !RegExp("\\w+/view/\\w+").test(location.pathname)&&(n?n.allowDelete:void 0)}}}}},authRequest=function(e,t){var i=null;e=Steedos.absoluteUrl(e);try{var n=[{name:"Content-Type",value:"application/json"},{name:"Authorization",value:Steedos.getAuthorization()}],r={type:"get",url:e,dataType:"json",contentType:"application/json",beforeSend:function(t){if(n&&n.length)return n.forEach(function(e){return t.setRequestHeader(e.name,e.value)})},success:function(e){i=e;},error:function(e,t,n){var r,o;e.responseJSON&&e.responseJSON.error?(r=e.responseJSON.error,o=void(i={error:r}),o=r.reason||r.message||r,console.error(o)):console.error(e.responseJSON);}};return $.ajax(Object.assign({},r,t)),i}catch(e){console.error(e);}};function _extends(){return (_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n,r=arguments[t];for(n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n]);}return e}).apply(this,arguments)}const newFunctionComponent=o=>e=>{const[t,n]=React.useState(!0);var r=()=>{n(!1);};return ___default.has(e,"ref")||(window.SteedosUI.refs[e.name]={show:()=>{n(!0);},close:r}),React__default["default"].createElement(o,_extends({visible:t,onCancel:r,onClose:r},{width:"70%",style:{width:"70%",maxWidth:"950px",minWidth:"480px"}},e))},newComponentRender=(n,r)=>(e,t)=>{e.name||(e.name=n+"-"+(e.name||"default")),(t=t||document.getElementById(`steedos-${n}-root-`+e.name))||((t=document.createElement("div")).setAttribute("id",`steedos-${n}-root-`+e.name),document.body.appendChild(t));e=React__default["default"].createElement(newFunctionComponent(r),e);ReactDOM.createRoot(t).render(e);},Modal=___default.assign(newComponentRender("modal",antd.Modal),{info:antd.Modal.info,success:antd.Modal.success,error:antd.Modal.error,warning:antd.Modal.warning,confirm:antd.Modal.confirm}),Drawer=newComponentRender("drawer",antd.Drawer),getGraphqlFieldsQuery=e=>{const t=["_id"];return e.push("record_permissions"),___default.each(e,e=>{-1<e.indexOf(".")&&(e=e.split(".")[0]),t.push(""+e);}),""+t.join(" ")},getFindOneQuery=(e,t,n)=>{e=e.replace(/\./g,"_");n=getGraphqlFieldsQuery(n);let r="";t=[`id: "${t}"`];return `{record:${e}__findOne${r=0<t.length?`(${t.join(",")})`:r}{${n}}}`},SObject={getRecord:async(e,t,n)=>{return (await fetchAPI("/graphql",{method:"post",body:JSON.stringify({query:getFindOneQuery(e,t,n)})})).data.record},getUISchema:async(e,t)=>getUISchema(e,t)},canSaveFilter=e=>!(!e._id||e.owner!==getSteedosAuth()?.userId),ListView={showFilter:(e,{listView:t,data:n})=>{canSaveFilter(t);n.filters&&(n.filters=filtersToConditions(n.filters));},getVisibleFilter:(e,t)=>{return t||(canSaveFilter(e)?e.filters:void 0)},getQueryFilter:(e,t)=>{return canSaveFilter(e)?ListView.getVisibleFilter(e,t):___default.isEmpty(t)?e.filters:[e.filters,"and",t]},getFirstListView:async e=>{e=await window.getUISchema(e);return _.first(_.sortBy(_.values(e.list_views),"sort_no"))}},Router={getAppPath({appId:e}){return "/app/"+e},getPagePath(){},getObjectListViewPath({appId:e,objectName:t,listViewName:n}){return `/app/${e}/${t}/grid/`+n},getObjectDetailPath({appId:e,objectName:t,recordId:n}){return `/app/${e}/${t}/view/`+n},getObjectRelatedViewPath({appId:e,masterObjectName:t,masterRecordId:n,objectName:r,foreignKey:o}){return `/app/${e}/${t}/${n}/${r}/grid?related_field_name=`+o}};var withModalWrap=function(t,e){return function(e){return React.createElement(t,e)}},render=function(e,t,n,r){e=withModalWrap(e),e=React.createElement(e,__assign({},t));return ReactDOM__default["default"].render(e,n)};const safeRunFunction=(t,n,r,o)=>{try{var i=window.Creator;if(!!(!i||!i.getObjectUrl)&&/\bSteedos\b|\bCreator\b|\bMeteor\b|\bSession\b/.test(t))return console.info("调用了Creator|Steedos|Meteor|Session变量的脚本不执行,直接按空值处理。"),"";let e=[];return ___default.isNil(n)||(e=___default.isArray(n)?n:[n]),t.bind(o||{})(...e)}catch(e){return console.log(e),r}};function safeEval(js){try{return eval(js)}catch(e){console.error(e,js);}}const isExpression=function(e){var t,n;return "string"==typeof e&&(t=/^{{(function.+)}}$/,n=/^{{(.+=>.+)}}$/,!("string"!=typeof e||!e.match(/^{{(.+)}}$/)||e.match(t)||e.match(n)))},parseSingleExpression=function(t,e,n,r){var o,i=function(e,t){return "#"!==t&&t?"string"==typeof t?_.get(e,t):void console.error("path has to be a string"):e||{}}(e=void 0===e?{}:e,function(e){return "string"!=typeof e||1===(e=e.split(".")).length?"#":(e.pop(),e.join("."))}(n))||{};if("string"!=typeof t)return t;o="__G_L_O_B_A_L__",e="\n return "+t.substring(2,t.length-2).replace(/\bformData\b/g,JSON.stringify(e).replace(/\bglobal\b/g,o)).replace(/\bglobal\b/g,JSON.stringify(r)).replace(new RegExp("\\b"+o+"\\b","g"),"global").replace(/rootValue/g,JSON.stringify(i));try{return Function(e)()}catch(e){return console.log(e,t,n),t}};var Expression=Object.freeze({__proto__:null,isExpression:isExpression,parseSingleExpression:parseSingleExpression});const getCompatibleDefaultValueExpression=(e,t)=>{let n=e;return /^\{\w+(\.*\w+)*\}$/.test(e)&&(n=-1<e.indexOf("userId")||-1<e.indexOf("spaceId")||-1<e.indexOf("user.")||-1<e.indexOf("now")?`{${e}}`.replace("{{","{{global."):`{${e}}`.replace("{{","{{formData."),t&&(n=n.replace(/\{\{(.+)\}\}/,"{{[$1]}}"))),n},getFieldDefaultValue=(e,t)=>{if(!e)return null;let n=e.defaultValue;e._defaultValue&&(n=safeEval(`(${e._defaultValue})`)),___default.isFunction(n)&&(n=safeRunFunction(n,[],null,{name:e.name})),___default.isString(n)&&(n=getCompatibleDefaultValueExpression(n,e.multiple));var r=isExpression(n);return r&&(n=parseSingleExpression(n,{},"#",t)),"select"===e.type&&(t=e.data_type||"text",!n||r||e.multiple||("text"!==t||___default.isString(n)?"number"!==t||___default.isNumber(n)?"boolean"!==t||___default.isBoolean(n)||(n="true"===n):n=Number(n):n=String(n))),n};function getTreeOptions(t,e){const o=e?.valueField||"value";e?.labelField;const n=e?.unfoldedNum||1,r=[],i=(t,n,r)=>{var e;if(n)return e=_.filter(t,e=>_.includes(n,e[o])),_.each(e,e=>{1<=r?(e.unfolded=!0,e.children&&(e.children=i(t,e.children,r-1))):e.children&&(e.children=i(t,e.children,r));}),e};for(var a=t,s=0;s<a.length;s++)if(a[s].noParent=0,a[s].unfolded=!1,a[s].parent){let e=1;for(var l=0;l<a.length;l++)a[s].parent==a[l][o]&&(e=0);1==e&&(a[s].noParent=1);}else a[s].noParent=1;return _.each(t,e=>{1==e.noParent&&(1<=n?(e.unfolded=!0,r.push(Object.assign({},e,{children:i(t,e.children,n-1)}))):r.push(Object.assign({},e,{children:i(t,e.children,n)})));}),r}function getClosestAmisComponentByType(t,n,r){let o=(r=r||{}).name;var e=r.direction||"up";let i=t.getComponents().find(function(e){return e.props.type===n&&(!o||e.props.name===o)});if(i)return i;if("down"===e){if(t.children&&t.children.length){for(let e=0;e<t.children.length&&!(i=getClosestAmisComponentByType(t.children[e],n,r));e++);return i}}else if("up"===e&&t.parent)return getClosestAmisComponentByType(t.parent,n,r)}function isFilterFormValuesEmpty(e){let t=!0;var e=_.pickBy(e,function(e,t){return /^__searchable__/g.test(t)});return _.isEmpty(e)||(e=_.omitBy(e,function(e){return _.isNil(e)||_.isObject(e)&&_.isEmpty(e)||_.isArray(e)&&_.isEmpty(e.filter(function(e){return !_.isNil(e)}))||_.isString(e)&&0===e.length}),_.isEmpty(e)||(t=!1)),t}const SteedosUI$1=Object.assign({},{render:render,Router:Router,ListView:ListView,Object:SObject,Modal:Modal,Drawer:Drawer,refs:{},getRef(e){return SteedosUI$1.refs[e]},router:{go:(e,t)=>{var n=window.FlowRouter;if(t)return n?n.go(t):window.open(t);n?n.reload():console.warn("暂不支持自动跳转",e);},reload:()=>{console.log("reload");}},message:antd.message,notification:antd.notification,components:{Button:antd.Button,Space:antd.Space},getRefId:({type:e,appId:t,name:n})=>{switch(e){case"listview":return `amis-${t}-${n}-listview`;case"form":return `amis-${t}-${n}-form`;case"detail":return `amis-${t}-${n}-detail`;default:return `amis-${t}-${n}-`+e}},reloadRecord:()=>{if(window.FlowRouter)return window.FlowRouter.reload()},getFieldDefaultValue:getFieldDefaultValue,getTreeOptions:getTreeOptions,getClosestAmisComponentByType:getClosestAmisComponentByType,isFilterFormValuesEmpty:isFilterFormValuesEmpty});var getBuilderContext=function(){return "undefined"==typeof window?{}:Builder.settings.context||Builder.settings},Steedos$1=__assign({getRootUrl:function(e){var t=getBuilderContext();return t.rootUrl||("undefined"!=typeof window?window.localStorage.getItem("steedos:rootUrl"):"")||e},absoluteUrl:function(e){return void 0===e&&(e=""),"".concat(Steedos$1.getRootUrl()).concat(e)},getTenantId:function(){try{var e=getBuilderContext().tenantId;return (e=window.location.search&&!e?new URLSearchParams(window.location.search).get("X-Space-Id"):e)?e:null}catch(e){console.error(e);}},getAuthorization:function(){try{var e=getBuilderContext(),t=e.tenantId,n=e.authToken;return t&&n?"Bearer ".concat(t,",").concat(n):null}catch(e){console.error(e);}},authRequest:authRequest,StandardObjects:StandardObjects},Expression);"undefined"==typeof window||window.Steedos||(window.Steedos=Steedos$1),"undefined"==typeof window||window.SteedosUI||(window.SteedosUI=SteedosUI$1);
15532
+ var __assign=function(){return (__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},StandardObjects={Base:{Actions:{standard_query:{visible:function(e,t,r){return !1}},standard_new:{visible:function(e,t,r){return "cms_files"!==e&&"instances"!==e&&(r?r.allowCreate:void 0)}},standard_edit:{visible:function(e,t,r){if(r)return r.allowEdit}},standard_delete:{visible:function(e,t,r){if(r)return r.allowDelete}},standard_import_data:{visible:function(e,t,r){var n=this.object;if(r)return r.allowCreate&&n.hasImportTemplates}},standard_approve:{visible:function(e,t,r){return !1}},standard_view_instance:{visible:function(e,t,r){return !1}},standard_submit_for_approval:{visible:function(e,t,r){return window.Steedos.ProcessManager.allowSubmit.apply(this,[e,t])},todo:function(e,t){return window.Steedos.ProcessManager.submit.apply(this,[e,t])}},standard_follow:{visible:function(e,t,r){return !1}},standard_delete_many:{visible:function(e,t,r){return !RegExp("\\w+/view/\\w+").test(location.pathname)&&(r?r.allowDelete:void 0)}}}}},authRequest=function(e,t){var i=null;e=Steedos.absoluteUrl(e);try{var r=[{name:"Content-Type",value:"application/json"},{name:"Authorization",value:Steedos.getAuthorization()}],n={type:"get",url:e,dataType:"json",contentType:"application/json",beforeSend:function(t){if(r&&r.length)return r.forEach(function(e){return t.setRequestHeader(e.name,e.value)})},success:function(e){i=e;},error:function(e,t,r){var n,o;e.responseJSON&&e.responseJSON.error?(n=e.responseJSON.error,o=void(i={error:n}),o=n.reason||n.message||n,console.error(o)):console.error(e.responseJSON);}};return $.ajax(Object.assign({},n,t)),i}catch(e){console.error(e);}};function _extends(){return (_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r,n=arguments[t];for(r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);}return e}).apply(this,arguments)}const newFunctionComponent=o=>e=>{const[t,r]=React.useState(!0);var n=()=>{r(!1);};return ___default.has(e,"ref")||(window.SteedosUI.refs[e.name]={show:()=>{r(!0);},close:n}),React__default["default"].createElement(o,_extends({visible:t,onCancel:n,onClose:n},{width:"70%",style:{width:"70%",maxWidth:"950px",minWidth:"480px"}},e))},newComponentRender=(r,n)=>(e,t)=>{e.name||(e.name=r+"-"+(e.name||"default")),(t=t||document.getElementById(`steedos-${r}-root-`+e.name))||((t=document.createElement("div")).setAttribute("id",`steedos-${r}-root-`+e.name),document.body.appendChild(t));e=React__default["default"].createElement(newFunctionComponent(n),e);ReactDOM.createRoot(t).render(e);},Modal=___default.assign(newComponentRender("modal",antd.Modal),{info:antd.Modal.info,success:antd.Modal.success,error:antd.Modal.error,warning:antd.Modal.warning,confirm:antd.Modal.confirm}),Drawer=newComponentRender("drawer",antd.Drawer),getGraphqlFieldsQuery=e=>{const t=["_id"];return e.push("record_permissions"),___default.each(e,e=>{-1<e.indexOf(".")&&(e=e.split(".")[0]),t.push(""+e);}),""+t.join(" ")},getFindOneQuery=(e,t,r)=>{e=e.replace(/\./g,"_");r=getGraphqlFieldsQuery(r);let n="";t=[`id: "${t}"`];return `{record:${e}__findOne${n=0<t.length?`(${t.join(",")})`:n}{${r}}}`},SObject={getRecord:async(e,t,r)=>{return (await fetchAPI("/graphql",{method:"post",body:JSON.stringify({query:getFindOneQuery(e,t,r)})})).data.record},getUISchema:async(e,t)=>getUISchema(e,t)},canSaveFilter=e=>!(!e._id||e.owner!==getSteedosAuth()?.userId),ListView={showFilter:(e,{listView:t,data:r})=>{canSaveFilter(t);r.filters&&(r.filters=filtersToConditions(r.filters));},getVisibleFilter:(e,t)=>{return t||(canSaveFilter(e)?e.filters:void 0)},getQueryFilter:(e,t)=>{return canSaveFilter(e)?ListView.getVisibleFilter(e,t):___default.isEmpty(t)?e.filters:[e.filters,"and",t]},getFirstListView:async e=>{e=await window.getUISchema(e);return _.first(_.sortBy(_.values(e.list_views),"sort_no"))}},Router={getAppPath({appId:e}){return "/app/"+e},getPagePath(){},getObjectListViewPath({appId:e,objectName:t,listViewName:r}){return `/app/${e}/${t}/grid/`+r},getObjectDetailPath({appId:e,objectName:t,recordId:r}){return `/app/${e}/${t}/view/`+r},getObjectRelatedViewPath({appId:e,masterObjectName:t,masterRecordId:r,objectName:n,foreignKey:o}){return `/app/${e}/${t}/${r}/${n}/grid?related_field_name=`+o}};var withModalWrap=function(t,e){return function(e){return React.createElement(t,e)}},render=function(e,t,r,n){e=withModalWrap(e),e=React.createElement(e,__assign({},t));return ReactDOM__default["default"].render(e,r)};const safeRunFunction=(t,r,n,o)=>{try{var i=window.Creator;if(!!(!i||!i.getObjectUrl)&&/\bSteedos\b|\bCreator\b|\bMeteor\b|\bSession\b/.test(t))return console.info("调用了Creator|Steedos|Meteor|Session变量的脚本不执行,直接按空值处理。"),"";let e=[];return ___default.isNil(r)||(e=___default.isArray(r)?r:[r]),t.bind(o||{})(...e)}catch(e){return console.log(e),n}};function safeEval(js){try{return eval(js)}catch(e){console.error(e,js);}}const isExpression=function(e){var t,r;return "string"==typeof e&&(t=/^{{(function.+)}}$/,r=/^{{(.+=>.+)}}$/,!("string"!=typeof e||!e.match(/^{{(.+)}}$/)||e.match(t)||e.match(r)))},parseSingleExpression=function(t,e,r,n){var o,i=function(e,t){return "#"!==t&&t?"string"==typeof t?_.get(e,t):void console.error("path has to be a string"):e||{}}(e=void 0===e?{}:e,function(e){return "string"!=typeof e||1===(e=e.split(".")).length?"#":(e.pop(),e.join("."))}(r))||{};if("string"!=typeof t)return t;o="__G_L_O_B_A_L__",e="\n return "+t.substring(2,t.length-2).replace(/\bformData\b/g,JSON.stringify(e).replace(/\bglobal\b/g,o)).replace(/\bglobal\b/g,JSON.stringify(n)).replace(new RegExp("\\b"+o+"\\b","g"),"global").replace(/rootValue/g,JSON.stringify(i));try{return Function(e)()}catch(e){return console.log(e,t,r),t}};var Expression=Object.freeze({__proto__:null,isExpression:isExpression,parseSingleExpression:parseSingleExpression});const getCompatibleDefaultValueExpression=(e,t)=>{let r=e;return /^\{\w+(\.*\w+)*\}$/.test(e)&&(r=-1<e.indexOf("userId")||-1<e.indexOf("spaceId")||-1<e.indexOf("user.")||-1<e.indexOf("now")?`{${e}}`.replace("{{","{{global."):`{${e}}`.replace("{{","{{formData."),t&&(r=r.replace(/\{\{(.+)\}\}/,"{{[$1]}}"))),r},getFieldDefaultValue=(e,t)=>{if(!e)return null;let r=e.defaultValue;e._defaultValue&&(r=safeEval(`(${e._defaultValue})`)),___default.isFunction(r)&&(r=safeRunFunction(r,[],null,{name:e.name})),___default.isString(r)&&(r=getCompatibleDefaultValueExpression(r,e.multiple));var n=isExpression(r);return n&&(r=parseSingleExpression(r,{},"#",t)),"select"===e.type&&(t=e.data_type||"text",!r||n||e.multiple||("text"!==t||___default.isString(r)?"number"!==t||___default.isNumber(r)?"boolean"!==t||___default.isBoolean(r)||(r="true"===r):r=Number(r):r=String(r))),r};function getTreeOptions(t,e){const o=e?.valueField||"value";e?.labelField;const r=e?.unfoldedNum||1,n=[],i=(t,r,n)=>{var e;if(r)return e=_.filter(t,e=>_.includes(r,e[o])),_.each(e,e=>{1<=n?(e.unfolded=!0,e.children&&(e.children=i(t,e.children,n-1))):e.children&&(e.children=i(t,e.children,n));}),e};for(var a=t,s=0;s<a.length;s++)if(a[s].noParent=0,a[s].unfolded=!1,a[s].parent){let e=1;for(var l=0;l<a.length;l++)a[s].parent==a[l][o]&&(e=0);1==e&&(a[s].noParent=1);}else a[s].noParent=1;return _.each(t,e=>{1==e.noParent&&(1<=r?(e.unfolded=!0,n.push(Object.assign({},e,{children:i(t,e.children,r-1)}))):n.push(Object.assign({},e,{children:i(t,e.children,r)})));}),n}function getClosestAmisComponentByType(t,r,n){let o=(n=n||{}).name;var e=n.direction||"up";let i=t.getComponents().find(function(e){return e.props.type===r&&(!o||e.props.name===o)});if(i)return i;if("down"===e){if(t.children&&t.children.length){for(let e=0;e<t.children.length&&!(i=getClosestAmisComponentByType(t.children[e],r,n));e++);return i}}else if("up"===e&&t.parent)return getClosestAmisComponentByType(t.parent,r,n)}function isFilterFormValuesEmpty(e){let t=!0;var e=_.pickBy(e,function(e,t){return /^__searchable__/g.test(t)});return _.isEmpty(e)||(e=_.omitBy(e,function(e){return _.isNil(e)||_.isObject(e)&&_.isEmpty(e)||_.isArray(e)&&_.isEmpty(e.filter(function(e){return !_.isNil(e)}))||_.isString(e)&&0===e.length}),_.isEmpty(e)||(t=!1)),t}const SteedosUI$1=Object.assign({},{render:render,Router:Router,ListView:ListView,Object:SObject,Modal:Modal,Drawer:Drawer,refs:{},getRef(e){return SteedosUI$1.refs[e]},router:{go:(e,t)=>{var r=window.FlowRouter;if(t)return r?r.go(t):window.open(t);r?r.reload():console.warn("暂不支持自动跳转",e);},reload:()=>{console.log("reload");}},message:antd.message,notification:antd.notification,components:{Button:antd.Button,Space:antd.Space},getRefId:({type:e,appId:t,name:r})=>{switch(e){case"listview":return `amis-${t}-${r}-listview`;case"form":return `amis-${t}-${r}-form`;case"detail":return `amis-${t}-${r}-detail`;default:return `amis-${t}-${r}-`+e}},reloadRecord:()=>{if(window.FlowRouter)return window.FlowRouter.reload()},getFieldDefaultValue:getFieldDefaultValue,getTreeOptions:getTreeOptions,getClosestAmisComponentByType:getClosestAmisComponentByType,isFilterFormValuesEmpty:isFilterFormValuesEmpty,getSearchFilter:e=>{var r=[];return _.each(e,(e,t)=>{_.isEmpty(e)&&!_.isBoolean(e)||(_.startsWith(t,"__searchable__between__")?r.push([""+t.replace("__searchable__between__",""),"between",e]):_.startsWith(t,"__searchable__")&&(_.isString(e)?r.push([""+t.replace("__searchable__",""),"contains",e]):r.push([""+t.replace("__searchable__",""),"=",e])));}),r}});var getBuilderContext=function(){return "undefined"==typeof window?{}:Builder.settings.context||Builder.settings},Steedos$1=__assign({getRootUrl:function(e){var t=getBuilderContext();return t.rootUrl||("undefined"!=typeof window?window.localStorage.getItem("steedos:rootUrl"):"")||e},absoluteUrl:function(e){return void 0===e&&(e=""),"".concat(Steedos$1.getRootUrl()).concat(e)},getTenantId:function(){try{var e=getBuilderContext().tenantId;return (e=window.location.search&&!e?new URLSearchParams(window.location.search).get("X-Space-Id"):e)?e:null}catch(e){console.error(e);}},getAuthorization:function(){try{var e=getBuilderContext(),t=e.tenantId,r=e.authToken;return t&&r?"Bearer ".concat(t,",").concat(r):null}catch(e){console.error(e);}},authRequest:authRequest,StandardObjects:StandardObjects},Expression);"undefined"==typeof window||window.Steedos||(window.Steedos=Steedos$1),"undefined"==typeof window||window.SteedosUI||(window.SteedosUI=SteedosUI$1);
14995
15533
 
14996
15534
  var index_esm = /*#__PURE__*/Object.freeze({
14997
15535
  __proto__: null,