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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -769,11 +769,28 @@ const Router$1 = {
769
769
 
770
770
  };
771
771
 
772
+ /*
773
+ * @Author: baozhoutao@steedos.com
774
+ * @Date: 2022-07-20 16:29:22
775
+ * @LastEditors: Please set LastEditors
776
+ * @LastEditTime: 2023-05-18 15:22:51
777
+ * @Description:
778
+ */
779
+
780
+ function getContrastColor(bgColor) {
781
+ var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
782
+ var r = parseInt(backgroundColor.substr(0, 2), 16);
783
+ var g = parseInt(backgroundColor.substr(2, 2), 16);
784
+ var b = parseInt(backgroundColor.substr(4, 2), 16);
785
+ var brightness = (r * 299 + g * 587 + b * 114) / 1000;
786
+ return brightness < 128 ? "#ffffff" : "#000000";
787
+ }
788
+
772
789
  /*
773
790
  * @Author: baozhoutao@steedos.com
774
791
  * @Date: 2022-05-23 09:53:08
775
- * @LastEditors: baozhoutao@steedos.com
776
- * @LastEditTime: 2023-04-10 11:22:54
792
+ * @LastEditors: Please set LastEditors
793
+ * @LastEditTime: 2023-05-18 16:34:39
777
794
  * @Description:
778
795
  */
779
796
 
@@ -826,6 +843,21 @@ async function getRefObjectNameFieldName(field){
826
843
  function getSelectTpl(field){
827
844
  return `<div>\${_display.${field.name}}</div>`
828
845
  }
846
+ function getSelectMap(selectOptions){
847
+ let map = {};
848
+ ___default.forEach(selectOptions,(option)=>{
849
+ const optionValue = option.value + '';
850
+ if(option.color){
851
+ const background = option.color.charAt(0) === '#' ? option.color : '#'+option.color;
852
+ const color = getContrastColor(background);
853
+ const optionColorStyle = 'background:'+background+';color:'+color;
854
+ map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
855
+ }else {
856
+ map[optionValue] = option.label;
857
+ }
858
+ });
859
+ return map;
860
+ }
829
861
 
830
862
  function getNameTplUrl(field, ctx){
831
863
  if(ctx.objectName === 'cms_files'){
@@ -2625,7 +2657,7 @@ const getListViewItemButtons = async (uiSchema, ctx)=>{
2625
2657
  return listButtons;
2626
2658
  };
2627
2659
 
2628
- const getObjectRelatedListButtons = async (uiSchema, ctx)=>{
2660
+ const getObjectRelatedListButtons = (uiSchema, ctx)=>{
2629
2661
  // const buttons = getButtons(uiSchema, ctx);
2630
2662
  // const relatedListButtons = _.filter(buttons, (button) => {
2631
2663
  // if(button.objectName === 'cms_files'){
@@ -2912,6 +2944,67 @@ const getObjectListViewButtonsSchemas = (objectSchema, ctx)=>{
2912
2944
  }
2913
2945
  };
2914
2946
 
2947
+ const getObjectRecordDetailRelatedListButtonsSchemas = (objectSchema, ctx)=>{
2948
+ const buttons = getObjectRelatedListButtons(objectSchema, ctx);
2949
+ if(ctx.formFactor === 'SMALL'){
2950
+ return {
2951
+ "type": "button",
2952
+ "icon": "fa fa-angle-down",
2953
+ "onEvent": {
2954
+ "click": {
2955
+ "actions": [
2956
+ {
2957
+ "actionType": "drawer",
2958
+ "drawer": {
2959
+ "type": "drawer",
2960
+ "title": "操作",
2961
+ "body": [
2962
+ {
2963
+ "type": "button-group",
2964
+ "vertical": true,
2965
+ "tiled": true,
2966
+ "buttons": [
2967
+ ...___default__default["default"].map(buttons, (button)=>{
2968
+ return {
2969
+ type: 'steedos-object-button',
2970
+ name: button.name,
2971
+ objectName: button.objectName,
2972
+ visibleOn: getButtonVisibleOn$1(button),
2973
+ className: `button_${button.name} w-full`
2974
+ }
2975
+ })
2976
+ ],
2977
+ "btnLevel": "enhance",
2978
+ "className": "w-full",
2979
+ "btnClassName": "w-full",
2980
+ "size": "lg"
2981
+ }
2982
+ ],
2983
+ "position": "bottom",
2984
+ "closeOnOutside": true,
2985
+ "resizable": false,
2986
+ "className": "buttons-drawer",
2987
+ "bodyClassName": "m-none p-none",
2988
+ "actions": []
2989
+ }
2990
+ }
2991
+ ]
2992
+ }
2993
+ }
2994
+ }
2995
+ }else {
2996
+ return ___default__default["default"].map(buttons, (button) => {
2997
+ return {
2998
+ type: 'steedos-object-button',
2999
+ name: button.name,
3000
+ objectName: button.objectName,
3001
+ visibleOn: getButtonVisibleOn$1(button),
3002
+ className: `button_${button.name}`
3003
+ }
3004
+ });
3005
+ }
3006
+ };
3007
+
2915
3008
  async function getObjectFieldsFilterButtonSchema(objectSchema) {
2916
3009
  // const amisListViewId = `listview_${objectSchema.name}`;
2917
3010
  return {
@@ -3080,6 +3173,7 @@ async function getObjectFieldsFilterBarSchema(objectSchema, ctx) {
3080
3173
  }
3081
3174
  }
3082
3175
  }
3176
+ filterForm.reset();
3083
3177
  listView.handleFilterSubmit(removedValues);
3084
3178
  const filterService = filterForm.context.getComponents().find(function(n){
3085
3179
  return n.props.type === "service";
@@ -3525,6 +3619,7 @@ function getObjectListHeaderFirstLine(objectSchema, listViewName, ctx) {
3525
3619
  "rightIcon": "fa fa-caret-down",
3526
3620
  "size": "sm",
3527
3621
  "hideCaret": true,
3622
+ "closeOnClick": true,
3528
3623
  "btnClassName": "!bg-transparent !border-none !hover:border-none text-lg h-5 font-bold p-0 text-black leading-none",
3529
3624
  "buttons": listViewButtonOptions
3530
3625
  }
@@ -3709,12 +3804,47 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3709
3804
  "type": "grid",
3710
3805
  "columns": [
3711
3806
  {
3712
- "body": {
3807
+ "body": [{
3808
+ "type": "service",
3809
+ "onEvent": {
3810
+ "@history_paths.changed": {
3811
+ "actions": [
3812
+ {
3813
+ "actionType": "reload"
3814
+ }
3815
+ ]
3816
+ }
3817
+ },
3818
+ "body":[{
3819
+ "type": "button",
3820
+ "visibleOn": "${window:innerWidth > 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id) && display !== 'split'}",
3821
+ "className":"flex mr-4",
3822
+ "onEvent": {
3823
+ "click": {
3824
+ "actions": [
3825
+ {
3826
+ "actionType": "custom",
3827
+ "script": "Steedos.goBack()"
3828
+ }
3829
+ ]
3830
+ }
3831
+ },
3832
+ "body": [
3833
+ {
3834
+ "type": "steedos-icon",
3835
+ "category": "utility",
3836
+ "name": "back",
3837
+ "colorVariant": "default",
3838
+ "className": "slds-button_icon slds-global-header__icon w-4"
3839
+ }
3840
+ ]
3841
+ }]
3842
+ },{
3713
3843
  "type": "tpl",
3714
3844
  "className": "block",
3715
3845
  // "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'>`
3716
3846
  "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>`
3717
- },
3847
+ }],
3718
3848
  "md": "auto",
3719
3849
  "className": "",
3720
3850
  "columnClassName": "flex justify-center items-center"
@@ -3801,18 +3931,9 @@ async function getObjectRecordDetailHeader(objectSchema, recordId, options) {
3801
3931
  * @param {*} relatedObjectSchema 相关对象UISchema
3802
3932
  * @returns amisSchema
3803
3933
  */
3804
- async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel) {
3934
+ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relatedLabel, ctx) {
3805
3935
  const { icon, label } = relatedObjectSchema;
3806
- const buttons = await getObjectRelatedListButtons(relatedObjectSchema, {});
3807
- let amisButtonsSchema = ___default.map(buttons, (button) => {
3808
- return {
3809
- type: 'steedos-object-button',
3810
- name: button.name,
3811
- objectName: button.objectName,
3812
- visibleOn: getButtonVisibleOn$1(button),
3813
- className: `button_${button.name}`
3814
- }
3815
- });
3936
+ let amisButtonsSchema = getObjectRecordDetailRelatedListButtonsSchemas(relatedObjectSchema, {formFactor: ctx.formFactor});
3816
3937
  const reg = new RegExp('_', 'g');
3817
3938
  const standardIcon = icon && icon.replace(reg, '-');
3818
3939
  const recordRelatedListHeader = {
@@ -3885,83 +4006,44 @@ async function getObjectRecordDetailRelatedListHeader(relatedObjectSchema, relat
3885
4006
  async function getObjectRelatedListHeader(objectSchema, recordId, relatedObjectName) {
3886
4007
  }
3887
4008
 
3888
- const getDisplayAsButton = function(objectName, showDisplayAs){
3889
- let displayAs = Router$1.getTabDisplayAs(objectName);
3890
- let buttons = [
3891
- {
3892
- "type": "button",
3893
- "label": "表格",
3894
- "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');",
3895
- "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
3896
- "rightIconClassName": "m-l-sm"
3897
- },
3898
- {
3899
- "type": "button",
3900
- "label": "分栏视图",
3901
- "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
3902
- "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
3903
- "rightIconClassName": "m-l-sm"
4009
+ const getExportExcelToolbarButtonSchema = ()=>{
4010
+ return {
4011
+ "type": "button",
4012
+ "icon": "fa fa-download",
4013
+ "align": "right",
4014
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4015
+ "tooltipPlacement": "bottom",
4016
+ "visibleOn": "${!isLookup && global.user.is_space_admin}",
4017
+ "tooltip": "导出Excel",
4018
+ "onEvent": {
4019
+ "click": {
4020
+ "weight": 0,
4021
+ "actions": [
4022
+ {
4023
+ "args": {
4024
+ "api": {
4025
+ "url": "${context.rootUrl}/api/record/export/${objectName}",
4026
+ "method": "get",
4027
+ "messages": {},
4028
+ "requestAdaptor": `${requestAdaptor$1()}`,
4029
+ "data": {
4030
+ "uiSchema": "${uiSchema}",
4031
+ "listName": "${listName}"
4032
+ },
4033
+ "headers": {
4034
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4035
+ }
4036
+ }
4037
+ },
4038
+ "actionType": "download"
4039
+ }
4040
+ ]
4041
+ }
4042
+ }
3904
4043
  }
3905
- ];
3906
- return {
3907
- "type": "dropdown-button",
3908
- "icon": "fa fa-table-columns",
3909
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
3910
- "align": "right",
3911
- "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
3912
- "buttons": [
3913
- {
3914
- "label": "显示为",
3915
- "children": buttons
3916
- }
3917
- ]
3918
- };
3919
4044
  };
3920
4045
 
3921
-
3922
-
3923
-
3924
- const onFieldsFilterToggleScript = `
3925
- const scope = event.context.scoped;
3926
- const filterForm = scope.getComponents().find(function(n){
3927
- return n.props.type === "form";
3928
- });
3929
- const filterService = filterForm.context.getComponents().find(function(n){
3930
- return n.props.type === "service";
3931
- });
3932
- // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
3933
- let resizeWindow = function(){
3934
- //触发amis crud 高度重算
3935
- setTimeout(()=>{
3936
- window.dispatchEvent(new Event("resize"))
3937
- }, 500);
3938
- }
3939
- let isMobile = Steedos.isMobile();
3940
- if(filterService.props.data.showFieldsFilter){
3941
- if(isMobile){
3942
- // 手机上只能通过取消按钮来关闭搜索栏
3943
- return;
3944
- }
3945
- let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
3946
- direction: "down",
3947
- name: "btn_filter_form_cancel"
3948
- });
3949
- buttonCancel.props.dispatchEvent('click', {}).then(function(){
3950
- resizeWindow();
3951
- });
3952
- }
3953
- else{
3954
- filterService.setData({showFieldsFilter: true});
3955
- resizeWindow();
3956
- if(isMobile){
3957
- // 手机端在显示搜索栏时隐藏刷新按钮
3958
- let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
3959
- crudService && crudService.setData({showFieldsFilter: true});
3960
- }
3961
- }
3962
- `;
3963
-
3964
- function getExportApiRequestAdaptorScript(){
4046
+ function requestAdaptor$1(){
3965
4047
  return `
3966
4048
  // 获取列表视图的属性
3967
4049
  let uiSchema = api.body.uiSchema;
@@ -4015,667 +4097,1101 @@ function getExportApiRequestAdaptorScript(){
4015
4097
  `
4016
4098
  }
4017
4099
 
4018
- function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
4019
- // console.log(`getObjectHeaderToolbar====>`, filterVisible)
4020
- const isMobile = window.innerWidth < 768;
4021
- if(isMobile){
4022
- showDisplayAs = false;
4023
- }
4024
- if(formFactor === 'SMALL'){
4025
- const onReloadScript = `
4026
- const scope = event.context.scoped;
4027
- var listView = scope.parent.getComponents().find(function(n){
4028
- return n.props.type === "crud";
4029
- });
4030
- listView.handleChangePage(1);
4031
- `;
4032
- return [
4033
- // "bulkActions",
4034
- ...(headerToolbarItems || []),
4035
- hiddenCount ? {} :{
4036
- "type": "tpl",
4037
- "tpl": "${count} 个项目"
4038
- },
4039
- {
4040
- // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
4100
+ const getNewListviewButtonSchema = ()=>{
4101
+ return {
4041
4102
  "type": "button",
4042
- "align": "right",
4043
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4044
- "label": "",
4045
- "icon": "fa fa-sync",
4046
- "visibleOn": "${!showFieldsFilter}",
4103
+ "label": "新建",
4047
4104
  "onEvent": {
4048
4105
  "click": {
4106
+ "weight": 0,
4049
4107
  "actions": [
4050
4108
  {
4051
- "actionType": "custom",
4052
- "script": onReloadScript
4053
- }
4054
- ]
4055
- }
4056
- },
4057
- },
4058
- filterVisible ? {
4059
- "label": "",
4060
- "icon": "fa fa-search",
4061
- "type": "button",
4062
- "badge": {
4063
- "offset": [
4064
- -5,
4065
- 1
4066
- ],
4067
- "size":8,
4068
- "animation": true,
4069
- "visibleOn": "${isFieldsFilterEmpty == false}"
4070
- },
4071
- "align": "right",
4072
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4109
+ "dialog": {
4110
+ "type": "dialog",
4111
+ "title": "新建 列表视图",
4112
+ "data": {
4113
+ "&": "$$",
4114
+ "all": "${uiSchema.list_views.all}",
4115
+ "list_view": "${uiSchema.list_views[listName]}",
4116
+ "appId": "${appId}",
4117
+ "global": "${global}",
4118
+ "targetObjectName": "${objectName}",
4119
+ },
4120
+ "body": [
4121
+ {
4122
+ "type": "steedos-object-form",
4123
+ "label": "对象表单",
4124
+ "objectApiName": "object_listviews",
4125
+ "recordId": "",
4126
+ "mode": "edit",
4127
+ "defaultData": {
4128
+ "&": "${list_view}",
4129
+ "name":"",
4130
+ "label":"",
4131
+ "filters":"",
4132
+ "shared":false
4133
+ },
4134
+ "fieldsExtend": fieldsExtend$4(),
4135
+ "fields": fields$1(),
4136
+ "onEvent": {
4137
+ "submitSucc": {
4138
+ "weight": 0,
4139
+ "actions": [
4140
+ {
4141
+ "args": {
4142
+ // 直接使用recordId不能拿到数据,只能通过result里面拿数据
4143
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
4144
+ "blank": false
4145
+ },
4146
+ "actionType": "url",
4147
+ }
4148
+ ]
4149
+ }
4150
+ },
4151
+ "messages": {
4152
+ "success": "成功",
4153
+ "failed": "失败"
4154
+ },
4155
+ }
4156
+ ],
4157
+ "showCloseButton": true,
4158
+ "showErrorMsg": true,
4159
+ "showLoading": true,
4160
+ "closeOnEsc": false,
4161
+ "dataMapSwitch": false,
4162
+ "size": "lg"
4163
+ },
4164
+ "actionType": "dialog"
4165
+ }
4166
+ ]
4167
+ }
4168
+ }
4169
+ }
4170
+ };
4171
+
4172
+ function fields$1(){
4173
+ return [
4174
+ "label",
4175
+ "name",
4176
+ "object_name",
4177
+ "filter_scope",
4178
+ "show_count",
4179
+ "columns.$.field",
4180
+ "columns.$.width",
4181
+ "sort.$.field_name",
4182
+ "sort.$.order",
4183
+ "filters",
4184
+ "mobile_columns.$.field",
4185
+ "searchable_fields.$.field",
4186
+ "is_system",
4187
+ "shared"
4188
+ ]
4189
+ }
4190
+
4191
+ function fieldsExtend$4(){
4192
+ return {
4193
+ "label": {
4194
+ "is_wide": true
4195
+ },
4196
+ "name": {
4197
+ "amis": {
4198
+ "hidden": true
4199
+ }
4200
+ },
4201
+ "object_name": {
4202
+ "amis": {
4203
+ "hidden": true
4204
+ }
4205
+ },
4206
+ "filter_scope": {
4207
+ "amis": {
4208
+ "hidden": true
4209
+ }
4210
+ },
4211
+ "columns": {
4212
+ "amis": {
4213
+ "hidden": true
4214
+ }
4215
+ },
4216
+ "filter_fields": {
4217
+ "amis": {
4218
+ "hidden": true
4219
+ }
4220
+ },
4221
+ "scrolling_mode": {
4222
+ "amis": {
4223
+ "hidden": true
4224
+ }
4225
+ },
4226
+ "sort": {
4227
+ "amis": {
4228
+ "hidden": true
4229
+ }
4230
+ },
4231
+ "show_count": {
4232
+ "amis": {
4233
+ "hidden": true
4234
+ }
4235
+ },
4236
+ "type": {
4237
+ "amis": {
4238
+ "hidden": true
4239
+ }
4240
+ },
4241
+ "shared": {
4242
+ "amis": {
4243
+ "visibleOn": "${global.user.is_space_admin}"
4244
+ }
4245
+ }
4246
+ }
4247
+ }
4248
+
4249
+ const getCopyListviewButtonSchema = ()=>{
4250
+ return {
4251
+ "type": "button",
4252
+ "label": "复制",
4073
4253
  "onEvent": {
4074
4254
  "click": {
4255
+ "weight": 0,
4075
4256
  "actions": [
4076
4257
  {
4077
- "actionType": "custom",
4078
- "script": onFieldsFilterToggleScript
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
+ "defaultData": {
4277
+ "&": "${list_view}",
4278
+ "name":"",
4279
+ "label": "${list_view.label} 的副本",
4280
+ "shared":false
4281
+ },
4282
+ "fieldsExtend": fieldsExtend$3(),
4283
+ "fields": fields(),
4284
+ "onEvent": {
4285
+ "submitSucc": {
4286
+ "weight": 0,
4287
+ "actions": [
4288
+ {
4289
+ "args": {
4290
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
4291
+ "blank": false
4292
+ },
4293
+ "actionType": "url",
4294
+ }
4295
+ ]
4296
+ }
4297
+ }
4298
+ }
4299
+ ],
4300
+ "showCloseButton": true,
4301
+ "showErrorMsg": true,
4302
+ "showLoading": true,
4303
+ "closeOnEsc": false,
4304
+ "dataMapSwitch": false,
4305
+ "size": "lg"
4306
+ },
4307
+ "actionType": "dialog"
4079
4308
  }
4080
4309
  ]
4081
4310
  }
4082
4311
  }
4083
- } : {},
4084
- getDisplayAsButton(mainObject?.name)
4312
+ }
4313
+ };
4314
+
4315
+ function fields(){
4316
+ return [
4317
+ "label",
4318
+ "name",
4319
+ "object_name",
4320
+ "filter_scope",
4321
+ "show_count",
4322
+ "columns.$.field",
4323
+ "columns.$.width",
4324
+ "sort.$.field_name",
4325
+ "sort.$.order",
4326
+ "filters",
4327
+ "mobile_columns.$.field",
4328
+ "searchable_fields.$.field",
4329
+ "is_system",
4330
+ "shared"
4085
4331
  ]
4086
- }else {
4087
- return [
4088
- // "filter-toggler",
4089
- ...(headerToolbarItems || []),
4090
- "bulkActions",
4091
- {
4092
- "type": "columns-toggler",
4093
- "className": "hidden"
4094
- },
4095
- // {
4096
- // "type": "columns-toggler",
4097
- // "className": "mr-2"
4098
- // },
4099
- hiddenCount ? {} : {
4100
- "type": "tpl",
4101
- "tpl": "${count} 个项目"
4102
- },
4103
- {
4104
- "type": "reload",
4105
- "align": "right",
4106
- "tooltipPlacement": "bottom",
4107
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
4108
- },
4109
- {
4332
+ }
4333
+
4334
+ function fieldsExtend$3(){
4335
+ return {
4336
+ "label": {
4337
+ "is_wide": true
4338
+ },
4339
+ "name": {
4340
+ "is_wide": true,
4341
+ "amis": {
4342
+ "hidden": true
4343
+ }
4344
+ },
4345
+ "object_name": {
4346
+ "amis": {
4347
+ "hidden": true
4348
+ }
4349
+ },
4350
+ "filter_scope": {
4351
+ "amis": {
4352
+ "hidden": true
4353
+ }
4354
+ },
4355
+ "columns": {
4356
+ "amis": {
4357
+ "hidden": true
4358
+ }
4359
+ },
4360
+ "filter_fields": {
4361
+ "amis": {
4362
+ "hidden": true
4363
+ }
4364
+ },
4365
+ "scrolling_mode": {
4366
+ "amis": {
4367
+ "hidden": true
4368
+ }
4369
+ },
4370
+ "sort": {
4371
+ "amis": {
4372
+ "hidden": true
4373
+ }
4374
+ },
4375
+ "show_count": {
4376
+ "amis": {
4377
+ "hidden": true
4378
+ }
4379
+ },
4380
+ "type": {
4381
+ "amis": {
4382
+ "hidden": true
4383
+ }
4384
+ },
4385
+ "shared": {
4386
+ "amis": {
4387
+ "visibleOn": "${global.user.is_space_admin}"
4388
+ }
4389
+ }
4390
+ }
4391
+ }
4392
+
4393
+ const getRenameListviewButtonSchema = ()=>{
4394
+ return {
4110
4395
  "type": "button",
4111
- "label": "",
4112
- "icon": "fa fa-download",
4113
- "align": "right",
4114
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4115
- "tooltipPlacement": "bottom",
4116
- "visibleOn": "${!isLookup && global.user.is_space_admin}",
4117
- "tooltip": "导出Excel",
4396
+ "label": "重命名",
4397
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4118
4398
  "onEvent": {
4119
4399
  "click": {
4120
4400
  "weight": 0,
4121
4401
  "actions": [
4122
4402
  {
4123
- "args": {
4124
- "api": {
4125
- "url": "${context.rootUrl}/api/record/export/${objectName}",
4126
- "method": "get",
4127
- "messages": {},
4128
- "requestAdaptor": `${getExportApiRequestAdaptorScript()}`,
4129
- "data": {
4130
- "uiSchema": "${uiSchema}",
4131
- "listName": "${listName}"
4132
- },
4133
- "headers": {
4134
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4403
+ "dialog": {
4404
+ "type": "dialog",
4405
+ "title": "重命名 列表视图",
4406
+ "data": {
4407
+ "targetObjectName": "${objectName}",
4408
+ "recordId": "${uiSchema.list_views[listName]._id}",
4409
+ "appId": "${appId}"
4410
+ },
4411
+ "body": [
4412
+ {
4413
+ "type": "steedos-object-form",
4414
+ "label": "对象表单",
4415
+ "objectApiName": "object_listviews",
4416
+ "recordId": "${recordId}",
4417
+ "mode": "edit",
4418
+ "fields": [
4419
+ "label"
4420
+ ],
4421
+ "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
4422
+ "onEvent": {
4423
+ "submitSucc": {
4424
+ "weight": 0,
4425
+ "actions": [
4426
+ {
4427
+ "args": {
4428
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
4429
+ "blank": false
4430
+ },
4431
+ "actionType": "url",
4432
+ },
4433
+ ]
4434
+ }
4435
+ }
4135
4436
  }
4136
- }
4437
+ ],
4438
+ "showCloseButton": true,
4439
+ "showErrorMsg": true,
4440
+ "showLoading": true,
4441
+ "size": "lg"
4137
4442
  },
4138
- "actionType": "download"
4443
+ "actionType": "dialog"
4139
4444
  }
4140
4445
  ]
4141
4446
  }
4142
4447
  }
4143
- },
4144
- filterVisible ? {
4145
- "label": "",
4146
- "icon": "fa fa-search",
4448
+ }
4449
+ };
4450
+
4451
+ const getSetListviewShareButtonSchema = ()=>{
4452
+ return {
4147
4453
  "type": "button",
4148
- "align": "right",
4149
- "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
4454
+ "label": "共享设置",
4455
+ "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
4150
4456
  "onEvent": {
4151
4457
  "click": {
4458
+ "weight": 0,
4152
4459
  "actions": [
4153
4460
  {
4154
- "actionType": "custom",
4155
- "script": onFieldsFilterToggleScript
4461
+ "dialog": {
4462
+ "type": "dialog",
4463
+ "title": "共享设置",
4464
+ "data": {
4465
+ "recordId": "${uiSchema.list_views[listName]._id}",
4466
+ },
4467
+ "body": [
4468
+ {
4469
+ "type": "steedos-object-form",
4470
+ "label": "对象表单",
4471
+ "objectApiName": "object_listviews",
4472
+ "recordId": "${recordId}",
4473
+ "mode": "edit",
4474
+ "fields": [
4475
+ "shared"
4476
+ ]
4477
+ }
4478
+ ],
4479
+ "showCloseButton": true,
4480
+ "showErrorMsg": true,
4481
+ "showLoading": true,
4482
+ "closeOnEsc": false,
4483
+ "dataMapSwitch": false,
4484
+ "size": "md"
4485
+ },
4486
+ "actionType": "dialog"
4156
4487
  }
4157
4488
  ]
4158
4489
  }
4159
4490
  }
4160
- } : {},
4161
- {
4162
- "type": "dropdown-button",
4163
- "trigger": "click",
4164
- "icon": "fa fa-cog",
4165
- "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4166
- "align": "right",
4167
- "visibleOn": "${!isLookup}",
4168
- "buttons": [
4169
- {
4170
- "label": "列表视图操作",
4171
- "children": [
4491
+ }
4492
+ };
4493
+
4494
+ const getSetListviewFiltersButtonSchema = ()=>{
4495
+ return {
4496
+ "type": "button",
4497
+ "label": "过滤设置",
4498
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4499
+ "onEvent": {
4500
+ "click": {
4501
+ "weight": 0,
4502
+ "actions": [
4172
4503
  {
4173
- "type": "button",
4174
- "label": "新建",
4175
- "onEvent": {
4176
- "click": {
4177
- "weight": 0,
4178
- "actions": [
4179
- {
4180
- "dialog": {
4181
- "type": "dialog",
4182
- "title": "新建 列表视图",
4183
- "data": {
4184
- "&": "$$",
4185
- "all": "${uiSchema.list_views.all}",
4186
- "list_view": "${uiSchema.list_views[listName]}",
4187
- "appId": "${appId}",
4188
- "global": "${global}",
4189
- "targetObjectName": "${objectName}",
4190
- },
4191
- "body": [
4504
+ "dialog": {
4505
+ "type": "dialog",
4506
+ "title": "过滤设置",
4507
+ "data": {
4508
+ "targetObjectName": "${objectName}",
4509
+ "recordId": "${uiSchema.list_views[listName]._id}",
4510
+ "listName": "${listName}",
4511
+ "appId": "${appId}"
4512
+ },
4513
+ "body": [
4514
+ {
4515
+ "type": "steedos-object-form",
4516
+ "label": "对象表单",
4517
+ "objectApiName": "object_listviews",
4518
+ "recordId": "${recordId}",
4519
+ "mode": "edit",
4520
+ "fields": [
4521
+ "filters"
4522
+ ],
4523
+ "initApiAdaptor": initApiAdaptor$2(),
4524
+ "apiRequestAdaptor": apiRequestAdaptor$2(),
4525
+ "fieldsExtend": fieldsExtend$2(),
4526
+ "onEvent": {
4527
+ "submitSucc": {
4528
+ "weight": 0,
4529
+ "actions": [
4192
4530
  {
4193
- "type": "steedos-object-form",
4194
- "label": "对象表单",
4195
- "objectApiName": "object_listviews",
4196
- "recordId": "",
4197
- "mode": "edit",
4198
- "defaultData": {
4199
- "&": "${list_view}",
4200
- "name":"",
4201
- "label":"",
4202
- "filters":"",
4203
- "shared":false
4204
- },
4205
- "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}",
4206
- "fields": [
4207
- "label",
4208
- "name",
4209
- "object_name",
4210
- "filter_scope",
4211
- "show_count",
4212
- "columns.$.field",
4213
- "columns.$.width",
4214
- "sort.$.field_name",
4215
- "sort.$.order",
4216
- "filters",
4217
- "mobile_columns.$.field",
4218
- "searchable_fields.$.field",
4219
- "is_system",
4220
- "shared"
4221
- ],
4222
- "onEvent": {
4223
- "submitSucc": {
4224
- "weight": 0,
4225
- "actions": [
4226
- {
4227
- "args": {
4228
- // 直接使用recordId不能拿到数据,只能通过result里面拿数据
4229
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
4230
- "blank": false
4231
- },
4232
- "actionType": "url",
4233
- }
4234
- ]
4235
- }
4236
- },
4237
- "messages": {
4238
- "success": "成功",
4239
- "failed": "失败"
4531
+ "args": {
4532
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4533
+ "blank": false
4240
4534
  },
4535
+ "actionType": "url",
4241
4536
  }
4242
- ],
4243
- "showCloseButton": true,
4244
- "showErrorMsg": true,
4245
- "showLoading": true,
4246
- "closeOnEsc": false,
4247
- "dataMapSwitch": false,
4248
- "size": "lg"
4249
- },
4250
- "actionType": "dialog"
4537
+ ]
4538
+ }
4251
4539
  }
4252
- ]
4253
- }
4254
- }
4255
- },
4540
+ }
4541
+ ],
4542
+ "showCloseButton": true,
4543
+ "showErrorMsg": true,
4544
+ "showLoading": true,
4545
+ "closeOnEsc": false,
4546
+ "dataMapSwitch": false,
4547
+ "size": "lg"
4548
+ },
4549
+ "actionType": "dialog"
4550
+ }
4551
+ ]
4552
+ }
4553
+ }
4554
+ }
4555
+ };
4556
+
4557
+
4558
+ function initApiAdaptor$2(){
4559
+ return `
4560
+ const recordId_tmp = api.body.recordId;
4561
+ let data_tmp;
4562
+ if (recordId_tmp) {
4563
+ data_tmp = payload.data;
4564
+ // 数据格式转换
4565
+ if (data_tmp) {
4566
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4567
+ try {
4568
+ data_tmp.filters = JSON.parse(data_tmp.filters);
4569
+ } catch (e) { }
4570
+ }
4571
+
4572
+ if (data_tmp.filters && lodash.isString(data_tmp.filters)) {
4573
+ data_tmp._filters_type_controller = 'function';
4574
+ } else {
4575
+ data_tmp._filters_type_controller = 'conditions'
4576
+ }
4577
+
4578
+ if (data_tmp._filters_type_controller === 'conditions') {
4579
+ data_tmp._filters_conditions = window.amisConvert.filtersToConditions(data_tmp.filters || []);
4580
+ data_tmp.filters = data_tmp._filters_conditions;
4581
+ } else {
4582
+ data_tmp._filters_function = data_tmp.filters;
4583
+ }
4584
+ }
4585
+ }
4586
+ for (key in data_tmp) {
4587
+ if (data_tmp[key] === null) {
4588
+ delete data_tmp[key];
4589
+ }
4590
+ }
4591
+ payload.data = Object.assign(payload.data, data_tmp);
4592
+ delete payload.extensions;
4593
+ return payload;
4594
+ `
4595
+ }
4596
+
4597
+ function apiRequestAdaptor$2(){
4598
+ return `
4599
+ const recordId = api.body.recordId;
4600
+ if (formData._filters_type_controller === 'conditions' && formData._filters_conditions) {
4601
+ formData.filters = window.amisConvert.conditionsToFilters(formData.filters);
4602
+ } else {
4603
+ formData.filters = formData._filters_function || null;
4604
+ }
4605
+
4606
+ delete formData._filters_type_controller;
4607
+ delete formData._filters_conditions;
4608
+ delete formData._filters_function;
4609
+
4610
+ query = 'mutation{record: ' + objectName + '__insert(doc: {__saveData}){_id}}';
4611
+ if (api.body.recordId) {
4612
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4613
+ };
4614
+ __saveData = JSON.stringify(JSON.stringify(formData));
4615
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4616
+ return api;
4617
+ `
4618
+ }
4619
+
4620
+ function fieldsExtend$2(){
4621
+ return {
4622
+ "filters": {
4623
+ "visible_on": "true",
4624
+ "amis": {
4625
+ "type": "condition-builder",
4626
+ "label": "条件组件1",
4627
+ "source": {
4628
+ "method": "get",
4629
+ "url": "${context.rootUrl}/service/api/amis-metadata-listviews/getFilterFields?objectName=${targetObjectName}",
4630
+ "dataType": "json",
4631
+ "headers": {
4632
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4633
+ }
4634
+ }
4635
+ }
4636
+ }
4637
+ }
4638
+ }
4639
+
4640
+ const getSetListviewColumnsButtonSchema = ()=>{
4641
+ return {
4642
+ "type": "button",
4643
+ "label": "显示的列",
4644
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4645
+ "onEvent": {
4646
+ "click": {
4647
+ "weight": 0,
4648
+ "actions": [
4256
4649
  {
4257
- "type": "button",
4258
- "label": "复制",
4259
- "onEvent": {
4260
- "click": {
4261
- "weight": 0,
4262
- "actions": [
4263
- {
4264
- "dialog": {
4265
- "type": "dialog",
4266
- "title": "复制 列表视图",
4267
- "data": {
4268
- "&": "$$",
4269
- "listName": "${listName}",
4270
- "targetObjectName": "${objectName}",
4271
- "list_view": "${uiSchema.list_views[listName]}",
4272
- "appId": "${appId}",
4273
- "global": "${global}"
4274
- },
4275
- "body": [
4650
+ "args": {},
4651
+ "dialog": {
4652
+ "type": "dialog",
4653
+ "title": "显示的列",
4654
+ "data": {
4655
+ "&": "$$",
4656
+ "targetObjectName": "${objectName}",
4657
+ "recordId": "${uiSchema.list_views[listName]._id}",
4658
+ "listName": "${listName}",
4659
+ "appId": "${appId}"
4660
+ },
4661
+ "body": [
4662
+ {
4663
+ "type": "steedos-object-form",
4664
+ "label": "对象表单",
4665
+ "objectApiName": "object_listviews",
4666
+ "recordId": "${recordId}",
4667
+ "mode": "edit",
4668
+ "fieldsExtend": fieldsExtend$1(),
4669
+ "initApiAdaptor": initApiAdaptor$1(),
4670
+ "apiRequestAdaptor": apiRequestAdaptor$1(),
4671
+ "fields": [
4672
+ "columns",
4673
+ "mobile_columns"
4674
+ ],
4675
+ "onEvent": {
4676
+ "submitSucc": {
4677
+ "weight": 0,
4678
+ "actions": [
4276
4679
  {
4277
- "type": "steedos-object-form",
4278
- "label": "对象表单",
4279
- "objectApiName": "object_listviews",
4280
- "recordId": "",
4281
- "mode": "edit",
4282
- "fields": [
4283
- ],
4284
- "defaultData": {
4285
- "&": "${list_view}",
4286
- "name":"",
4287
- "label": "${list_view.label}的副本",
4288
- "shared":false
4680
+ "args": {
4681
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4682
+ "blank": false
4289
4683
  },
4290
- "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}",
4291
- "fields": [
4292
- "label",
4293
- "name",
4294
- "object_name",
4295
- "filter_scope",
4296
- "show_count",
4297
- "columns.$.field",
4298
- "columns.$.width",
4299
- "sort.$.field_name",
4300
- "sort.$.order",
4301
- "filters",
4302
- "mobile_columns.$.field",
4303
- "searchable_fields.$.field",
4304
- "is_system",
4305
- "shared"
4306
- ],
4307
- "onEvent": {
4308
- "submitSucc": {
4309
- "weight": 0,
4310
- "actions": [
4311
- {
4312
- "args": {
4313
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/listview_${result.data.recordId|lowerCase}",
4314
- "blank": false
4315
- },
4316
- "actionType": "url",
4317
- }
4318
- ]
4319
- }
4320
- }
4321
- }
4322
- ],
4323
- "showCloseButton": true,
4324
- "showErrorMsg": true,
4325
- "showLoading": true,
4326
- "closeOnEsc": false,
4327
- "dataMapSwitch": false,
4328
- "size": "lg"
4329
- },
4330
- "actionType": "dialog"
4331
- }
4332
- ]
4333
- }
4334
- }
4335
- },
4336
- {
4337
- "type": "button",
4338
- "label": "重命名",
4339
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4340
- "onEvent": {
4341
- "click": {
4342
- "weight": 0,
4343
- "actions": [
4344
- {
4345
- "dialog": {
4346
- "type": "dialog",
4347
- "title": "重命名 列表视图",
4348
- "data": {
4349
- "targetObjectName": "${objectName}",
4350
- "recordId": "${uiSchema.list_views[listName]._id}",
4351
- "appId": "${appId}"
4352
- },
4353
- "body": [
4354
- {
4355
- "type": "steedos-object-form",
4356
- "label": "对象表单",
4357
- "objectApiName": "object_listviews",
4358
- "recordId": "${recordId}",
4359
- "mode": "edit",
4360
- "fields": [
4361
- "label"
4362
- ],
4363
- "fieldsExtend": "{\n \"label\":{\n \"is_wide\": true\n }\n}",
4364
- "onEvent": {
4365
- "submitSucc": {
4366
- "weight": 0,
4367
- "actions": [
4368
- {
4369
- "args": {
4370
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${name}",
4371
- "blank": false
4372
- },
4373
- "actionType": "url",
4374
- },
4375
- ]
4376
- }
4377
- }
4378
- }
4379
- ],
4380
- "showCloseButton": true,
4381
- "showErrorMsg": true,
4382
- "showLoading": true,
4383
- "size": "lg"
4384
- },
4385
- "actionType": "dialog"
4386
- }
4387
- ]
4388
- }
4389
- }
4390
- },
4391
- {
4392
- "type": "button",
4393
- "label": "共享设置",
4394
- "disabledOn": "!(global.user.is_space_admin && !!uiSchema.list_views[listName].owner)",
4395
- "onEvent": {
4396
- "click": {
4397
- "weight": 0,
4398
- "actions": [
4399
- {
4400
- "dialog": {
4401
- "type": "dialog",
4402
- "title": "共享设置",
4403
- "data": {
4404
- "recordId": "${uiSchema.list_views[listName]._id}",
4405
- },
4406
- "body": [
4407
- {
4408
- "type": "steedos-object-form",
4409
- "label": "对象表单",
4410
- "objectApiName": "object_listviews",
4411
- "recordId": "${recordId}",
4412
- "mode": "edit",
4413
- "fields": [
4414
- "shared"
4415
- ]
4684
+ "actionType": "url"
4416
4685
  }
4417
- ],
4418
- "showCloseButton": true,
4419
- "showErrorMsg": true,
4420
- "showLoading": true,
4421
- "closeOnEsc": false,
4422
- "dataMapSwitch": false,
4423
- "size": "md"
4424
- },
4425
- "actionType": "dialog"
4686
+ ]
4687
+ }
4426
4688
  }
4427
- ]
4428
- }
4429
- }
4430
- },
4689
+ }
4690
+ ],
4691
+ "searchable": true,
4692
+ "showCloseButton": true,
4693
+ "showErrorMsg": true,
4694
+ "showLoading": true,
4695
+ "size": "lg"
4696
+ },
4697
+ "actionType": "dialog"
4698
+ }
4699
+ ]
4700
+ }
4701
+ }
4702
+ }
4703
+ };
4704
+
4705
+ function fieldsExtend$1(){
4706
+ return {
4707
+ "columns": {
4708
+ "amis": {
4709
+ "type": "transfer",
4710
+ "sortable": true,
4711
+ "searchable": true,
4712
+ "source": {
4713
+ "method": "get",
4714
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4715
+ "headers": {
4716
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4717
+ }
4718
+ }
4719
+ }
4720
+ },
4721
+ "mobile_columns": {
4722
+ "group": "手机端",
4723
+ "amis": {
4724
+ "type": "transfer",
4725
+ "sortable": true,
4726
+ "searchable": true,
4727
+ "source": {
4728
+ "method": "get",
4729
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/fields/options",
4730
+ "headers": {
4731
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4732
+ }
4733
+ }
4734
+ }
4735
+ }
4736
+ }
4737
+ }
4738
+
4739
+ function initApiAdaptor$1(){
4740
+ return `
4741
+ const recordId_tmp = api.body.recordId;
4742
+ let columns_tmp = {}, mobile_columns_tmp = {};
4743
+ if (recordId_tmp) {
4744
+ columns_tmp = payload.data.columns;
4745
+ mobile_columns_tmp = payload.data.mobile_columns;
4746
+ if (columns_tmp) {
4747
+ columns_tmp = lodash.map(columns_tmp, 'field');
4748
+ }
4749
+ if (mobile_columns_tmp) {
4750
+ mobile_columns_tmp = lodash.map(mobile_columns_tmp, 'field');
4751
+ }
4752
+ }
4753
+ payload.data.columns = columns_tmp;
4754
+ payload.data.mobile_columns = mobile_columns_tmp;
4755
+
4756
+ delete payload.extensions;
4757
+ return payload;
4758
+ `
4759
+ }
4760
+
4761
+ function apiRequestAdaptor$1(){
4762
+ return `
4763
+ const formData_tmp = api.body.$;
4764
+ const objectName_tmp = api.body.objectName;
4765
+ const recordId_tmp = api.body.recordId;
4766
+
4767
+ if (typeof formData_tmp.columns == 'string') {
4768
+ formData_tmp.columns = formData_tmp.columns?.split(',');
4769
+ }
4770
+ if (typeof formData_tmp.mobile_columns == 'string') {
4771
+ formData_tmp.mobile_columns = formData_tmp.mobile_columns?.split(',');
4772
+ }
4773
+
4774
+ // 数据格式转换
4775
+ formData_tmp.columns = lodash.map(formData_tmp.columns, (item) => {
4776
+ return { field: item };
4777
+ });
4778
+ formData.mobile_columns = lodash.map(formData.mobile_columns, (item) => {
4779
+ return { field: item };
4780
+ });
4781
+
4782
+ let query_tmp = 'mutation{record: ' + objectName_tmp + '__insert(doc: {__saveData}){_id}}';
4783
+ if (api.body.recordId) {
4784
+ query_tmp = 'mutation{record: ' + objectName_tmp + '__update(id: "' + recordId_tmp +'", doc: {__saveData}){_id}}';
4785
+ };
4786
+ delete formData_tmp._id;
4787
+ let __saveData_tmp = JSON.stringify(JSON.stringify(formData_tmp));
4788
+ api.data = { query: query_tmp.replace('{__saveData}', __saveData_tmp) };
4789
+
4790
+ return api;
4791
+ `
4792
+ }
4793
+
4794
+ const getSetListviewSortButtonSchema = ()=>{
4795
+ return {
4796
+ "type": "button",
4797
+ "label": "默认排序规则",
4798
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4799
+ "onEvent": {
4800
+ "click": {
4801
+ "weight": 0,
4802
+ "actions": [
4431
4803
  {
4432
- "type": "button",
4433
- "label": "过滤设置",
4434
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4435
- "onEvent": {
4436
- "click": {
4437
- "weight": 0,
4438
- "actions": [
4439
- {
4440
- "dialog": {
4441
- "type": "dialog",
4442
- "title": "过滤设置",
4443
- "data": {
4444
- "targetObjectName": "${objectName}",
4445
- "objectName": "${objectName}",
4446
- "recordId": "${uiSchema.list_views[listName]._id}",
4447
- "listName": "${listName}",
4448
- "appId": "${appId}"
4449
- },
4450
- "body": [
4804
+ "dialog": {
4805
+ "type": "dialog",
4806
+ "title": "默认排序规则",
4807
+ "data": {
4808
+ "&": "$$",
4809
+ "targetObjectName": "${objectName}",
4810
+ "recordId": "${uiSchema.list_views[listName]._id}",
4811
+ "listName": "${listName}",
4812
+ "appId": "${appId}"
4813
+ },
4814
+ "body": [
4815
+ {
4816
+ "type": "steedos-object-form",
4817
+ "label": "对象表单",
4818
+ "objectApiName": "object_listviews",
4819
+ "recordId": "${recordId}",
4820
+ "className": "",
4821
+ "id": "u:061f158b4c5a",
4822
+ "mode": "edit",
4823
+ "fields": [
4824
+ "sort",
4825
+ "sort.$.field_name",
4826
+ "sort.$.order"
4827
+ ],
4828
+ "onEvent": {
4829
+ "submitSucc": {
4830
+ "weight": 0,
4831
+ "actions": [
4451
4832
  {
4452
- "type": "steedos-object-form",
4453
- "label": "对象表单",
4454
- "objectApiName": "object_listviews",
4455
- "recordId": "${recordId}",
4456
- "mode": "edit",
4457
- "fields": [
4458
- "filters"
4459
- ],
4460
- "initApiRequestAdaptor": "",
4461
- "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;",
4462
- "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",
4463
- "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}",
4464
- "onEvent": {
4465
- "submitSucc": {
4466
- "weight": 0,
4467
- "actions": [
4468
- {
4469
- "args": {
4470
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4471
- "blank": false
4472
- },
4473
- "actionType": "url",
4474
- }
4475
- ]
4476
- }
4477
- }
4833
+ "args": {
4834
+ "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4835
+ "blank": false
4836
+ },
4837
+ "actionType": "url"
4478
4838
  }
4479
- ],
4480
- "showCloseButton": true,
4481
- "showErrorMsg": true,
4482
- "showLoading": true,
4483
- "closeOnEsc": false,
4484
- "dataMapSwitch": false,
4485
- "size": "lg"
4486
- },
4487
- "actionType": "dialog"
4488
- }
4489
- ]
4490
- }
4491
- }
4492
- },
4839
+ ]
4840
+ }
4841
+ },
4842
+ "fieldsExtend": fieldsExtend(),
4843
+ "initApiAdaptor": initApiAdaptor(),
4844
+ "apiRequestAdaptor": apiRequestAdaptor()
4845
+ }
4846
+ ],
4847
+ "showCloseButton": true,
4848
+ "showErrorMsg": true,
4849
+ "showLoading": true,
4850
+ "id": "u:d3f6947b6acf",
4851
+ "size": "lg"
4852
+ },
4853
+ "actionType": "dialog"
4854
+ }
4855
+ ]
4856
+ }
4857
+ }
4858
+ }
4859
+ };
4860
+
4861
+ function fieldsExtend(){
4862
+ return {
4863
+ "sort": {
4864
+ "amis": {
4865
+ "type": "tabs-transfer",
4866
+ "sortable": true,
4867
+ "searchable": true,
4868
+ "source": {
4869
+ "method": "get",
4870
+ "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/${targetObjectName}/sortFields/options",
4871
+ "headers": {
4872
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4873
+ }
4874
+ }
4875
+ }
4876
+ }
4877
+ }
4878
+ }
4879
+
4880
+ function initApiAdaptor(){
4881
+ return `
4882
+ let sort;
4883
+ if (recordId) {
4884
+ sort = payload.data.sort;
4885
+ //数据格式转换
4886
+ if (sort instanceof Array) {
4887
+ sort = lodash.map(sort, (item) => {
4888
+ return item.field_name + ':' + (item.order || 'asc')
4889
+ });
4890
+ }
4891
+ }
4892
+ payload.data.sort = sort;
4893
+ delete payload.extensions;
4894
+ return payload;
4895
+ `
4896
+ }
4897
+
4898
+ function apiRequestAdaptor(){
4899
+ return `
4900
+ const recordId = api.body.recordId;
4901
+ //数据格式转换
4902
+ if (typeof formData.sort == 'string') {
4903
+ formData.sort = formData.sort?.split(',');
4904
+ }
4905
+ formData.sort = lodash.map(formData.sort, (item) => {
4906
+ const arr = item.split(':');
4907
+ return { field_name: arr[0], order: arr[1] };
4908
+ });
4909
+ if (recordId) {
4910
+ query = 'mutation{record: ' + objectName + '__update(id: "' + recordId + '", doc: {__saveData}){_id}}';
4911
+ }
4912
+ __saveData = JSON.stringify(JSON.stringify(formData));
4913
+ api.data = { query: query.replace('{__saveData}', __saveData) };
4914
+ return api;
4915
+ `
4916
+ }
4917
+
4918
+ const getDeleteListviewButtonSchema = ()=>{
4919
+ return {
4920
+ "type": "button",
4921
+ "label": "删除",
4922
+ "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4923
+ "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4924
+ "onEvent": {
4925
+ "click": {
4926
+ "actions": [
4493
4927
  {
4494
- "type": "button",
4495
- "label": "显示的列",
4496
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4497
- "onEvent": {
4498
- "click": {
4499
- "weight": 0,
4500
- "actions": [
4501
- {
4502
- "args": {},
4503
- "dialog": {
4504
- "type": "dialog",
4505
- "title": "显示的列",
4506
- "data": {
4507
- "&": "$$",
4508
- "targetObjectName": "${objectName}",
4509
- "objectName": "${objectName}",
4510
- "recordId": "${uiSchema.list_views[listName]._id}",
4511
- "listName": "${listName}",
4512
- "appId": "${appId}"
4513
- },
4514
- "body": [
4515
- {
4516
- "type": "steedos-object-form",
4517
- "label": "对象表单",
4518
- "objectApiName": "object_listviews",
4519
- "recordId": "${recordId}",
4520
- "mode": "edit",
4521
- "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}",
4522
- "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;",
4523
- "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;",
4524
- "fields": [
4525
- "columns",
4526
- "mobile_columns"
4527
- ],
4528
- "onEvent": {
4529
- "submitSucc": {
4530
- "weight": 0,
4531
- "actions": [
4532
- {
4533
- "args": {
4534
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4535
- "blank": false
4536
- },
4537
- "actionType": "url"
4538
- }
4539
- ]
4540
- }
4541
- }
4542
- }
4543
- ],
4544
- "searchable": true,
4545
- "showCloseButton": true,
4546
- "showErrorMsg": true,
4547
- "showLoading": true,
4548
- "size": "lg"
4549
- },
4550
- "actionType": "dialog"
4551
- }
4552
- ]
4928
+ "actionType": "ajax",
4929
+ "args": {
4930
+ "api": {
4931
+ "url": "${context.rootUrl}/graphql",
4932
+ "method": "post",
4933
+ "headers": {
4934
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4935
+ },
4936
+ "data": {
4937
+ "&": "$$",
4938
+ "uiSchema": "${uiSchema}",
4939
+ "recordId": "${uiSchema.list_views[listName]._id}"
4940
+ },
4941
+ "messages": {
4942
+ "success": "删除成功"
4943
+ },
4944
+ "requestAdaptor": requestAdaptor(),
4945
+ "adaptor": adaptor(),
4553
4946
  }
4554
4947
  }
4555
4948
  },
4556
4949
  {
4557
- "type": "button",
4558
- "label": "默认排序规则",
4559
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4560
- "onEvent": {
4561
- "click": {
4562
- "weight": 0,
4563
- "actions": [
4564
- {
4565
- "dialog": {
4566
- "type": "dialog",
4567
- "title": "弹框标题",
4568
- "data": {
4569
- "&": "$$",
4570
- "targetObjectName": "${objectName}",
4571
- "objectName": "${objectName}",
4572
- "recordId": "${uiSchema.list_views[listName]._id}",
4573
- "listName": "${listName}",
4574
- "appId": "${appId}"
4575
- },
4576
- "body": [
4577
- {
4578
- "type": "steedos-object-form",
4579
- "label": "对象表单",
4580
- "objectApiName": "object_listviews",
4581
- "recordId": "${recordId}",
4582
- "className": "",
4583
- "id": "u:061f158b4c5a",
4584
- "mode": "edit",
4585
- "fields": [
4586
- "sort",
4587
- "sort.$.field_name",
4588
- "sort.$.order"
4589
- ],
4590
- "onEvent": {
4591
- "submitSucc": {
4592
- "weight": 0,
4593
- "actions": [
4594
- {
4595
- "args": {
4596
- "url": "${context.rootUrl}/app/${appId}/${targetObjectName}/grid/${listName}",
4597
- "blank": false
4598
- },
4599
- "actionType": "url"
4600
- }
4601
- ]
4602
- }
4603
- },
4604
- "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}",
4605
- "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;",
4606
- "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"
4607
- }
4608
- ],
4609
- "showCloseButton": true,
4610
- "showErrorMsg": true,
4611
- "showLoading": true,
4612
- "id": "u:d3f6947b6acf",
4613
- "size": "lg"
4614
- },
4615
- "actionType": "dialog"
4616
- }
4617
- ]
4618
- }
4619
- }
4620
- },
4950
+ "actionType": "url",
4951
+ "args": {
4952
+ "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4953
+ "blank": false
4954
+ },
4955
+ "expression": "data.delete == 1"
4956
+ }
4957
+ ]
4958
+ }
4959
+ }
4960
+ }
4961
+ };
4962
+
4963
+
4964
+ function requestAdaptor(){
4965
+ return `
4966
+ const { recordId } = api.body;
4967
+ var deleteArray = [];
4968
+ if (recordId) { deleteArray.push(\`delete:object_listviews__delete(id: "\${recordId}")\`); }
4969
+ api.data = { query: \`mutation{\${deleteArray.join(',')}}\` };
4970
+ return api;
4971
+ `
4972
+ }
4973
+
4974
+ function adaptor(){
4975
+ return `
4976
+ if (payload.errors) {
4977
+ payload.status = 2;
4978
+ payload.msg = payload.errors[0].message;
4979
+ }
4980
+ return payload;
4981
+ `
4982
+ }
4983
+
4984
+ const getSettingListviewToolbarButtonSchema = ()=>{
4985
+ return {
4986
+ "type": "dropdown-button",
4987
+ "trigger": "click",
4988
+ "icon": "fa fa-cog",
4989
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
4990
+ "align": "right",
4991
+ "visibleOn": "${!isLookup}",
4992
+ "buttons": [
4993
+ {
4994
+ "label": "列表视图操作",
4995
+ "children": [
4996
+ getNewListviewButtonSchema(),
4997
+ getCopyListviewButtonSchema(),
4998
+ getRenameListviewButtonSchema(),
4999
+ getSetListviewShareButtonSchema(),
5000
+ getSetListviewFiltersButtonSchema(),
5001
+ getSetListviewColumnsButtonSchema(),
5002
+ getSetListviewSortButtonSchema(),
5003
+ getDeleteListviewButtonSchema()
5004
+ ]
5005
+ }
5006
+ ]
5007
+ }
5008
+ };
5009
+
5010
+ const getDisplayAsButton = function(objectName, showDisplayAs){
5011
+ let displayAs = Router$1.getTabDisplayAs(objectName);
5012
+ let buttons = [
5013
+ {
5014
+ "type": "button",
5015
+ "label": "表格",
5016
+ "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');",
5017
+ "rightIcon": displayAs != 'split' ? "fa fa-check" : null,
5018
+ "rightIconClassName": "m-l-sm"
5019
+ },
5020
+ {
5021
+ "type": "button",
5022
+ "label": "分栏视图",
5023
+ "onClick": "const url = document.location.pathname + '?display=split'; props.env.jumpTo(url);",
5024
+ "rightIcon": displayAs === 'split' ? "fa fa-check" : null,
5025
+ "rightIconClassName": "m-l-sm"
5026
+ }
5027
+ ];
5028
+ return {
5029
+ "type": "dropdown-button",
5030
+ "icon": "fa fa-table-columns",
5031
+ "btnClassName": "antd-Button--iconOnly bg-white p-2 rounded border-gray-300 text-gray-500",
5032
+ "align": "right",
5033
+ "visibleOn": "${window:innerWidth > 768 && !!!isLookup}",
5034
+ "buttons": [
5035
+ {
5036
+ "label": "显示为",
5037
+ "children": buttons
5038
+ }
5039
+ ]
5040
+ };
5041
+ };
5042
+
5043
+
5044
+ const onFieldsFilterToggleScript = `
5045
+ const scope = event.context.scoped;
5046
+ const filterForm = scope.getComponents().find(function(n){
5047
+ return n.props.type === "form";
5048
+ });
5049
+ const filterService = filterForm.context.getComponents().find(function(n){
5050
+ return n.props.type === "service";
5051
+ });
5052
+ // filterService.setData({showFieldsFilter: !!!filterService.props.data.showFieldsFilter});
5053
+ let resizeWindow = function(){
5054
+ //触发amis crud 高度重算
5055
+ setTimeout(()=>{
5056
+ window.dispatchEvent(new Event("resize"))
5057
+ }, 500);
5058
+ }
5059
+ let isMobile = Steedos.isMobile();
5060
+ if(filterService.props.data.showFieldsFilter){
5061
+ if(isMobile){
5062
+ // 手机上只能通过取消按钮来关闭搜索栏
5063
+ return;
5064
+ }
5065
+ let buttonCancel = SteedosUI.getClosestAmisComponentByType(filterForm.context, "button", {
5066
+ direction: "down",
5067
+ name: "btn_filter_form_cancel"
5068
+ });
5069
+ buttonCancel.props.dispatchEvent('click', {}).then(function(){
5070
+ resizeWindow();
5071
+ });
5072
+ }
5073
+ else{
5074
+ filterService.setData({showFieldsFilter: true});
5075
+ resizeWindow();
5076
+ if(isMobile){
5077
+ // 手机端在显示搜索栏时隐藏刷新按钮
5078
+ let crudService = scope.getComponentById("service_listview_" + event.data.objectName);
5079
+ crudService && crudService.setData({showFieldsFilter: true});
5080
+ }
5081
+ }
5082
+ `;
5083
+
5084
+
5085
+ function getObjectHeaderToolbar(mainObject, formFactor, {showDisplayAs = false, hiddenCount = false, headerToolbarItems, filterVisible = true} = {}){
5086
+ // console.log(`getObjectHeaderToolbar====>`, filterVisible)
5087
+ const isMobile = window.innerWidth < 768;
5088
+ if(isMobile){
5089
+ showDisplayAs = false;
5090
+ }
5091
+ if(formFactor === 'SMALL'){
5092
+ const onReloadScript = `
5093
+ const scope = event.context.scoped;
5094
+ var listView = scope.parent.getComponents().find(function(n){
5095
+ return n.props.type === "crud";
5096
+ });
5097
+ listView.handleChangePage(1);
5098
+ `;
5099
+ return [
5100
+ // "bulkActions",
5101
+ ...(headerToolbarItems || []),
5102
+ hiddenCount ? {} :{
5103
+ "type": "tpl",
5104
+ "tpl": "${count} 个项目"
5105
+ },
5106
+ {
5107
+ // "type": "reload",//不可以直接使用reload,因为它不会设置页码到第一页
5108
+ "type": "button",
5109
+ "align": "right",
5110
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5111
+ "label": "",
5112
+ "icon": "fa fa-sync",
5113
+ "visibleOn": "${!showFieldsFilter}",
5114
+ "onEvent": {
5115
+ "click": {
5116
+ "actions": [
4621
5117
  {
4622
- "type": "button",
4623
- "label": "删除",
4624
- "disabledOn": "!((global.user.is_space_admin || global.userId == uiSchema.list_views[listName].owner) && !!uiSchema.list_views[listName].owner)",
4625
- "confirmText": "如果您删除此列表视图,该视图将为所有具备访问权限的用户永久删除。是否确定要删除?",
4626
- "onEvent": {
4627
- "click": {
4628
- "actions": [
4629
- {
4630
- "actionType": "ajax",
4631
- "args": {
4632
- "api": {
4633
- "url": "${context.rootUrl}/graphql",
4634
- "method": "post",
4635
- "headers": {
4636
- "Authorization": "Bearer ${context.tenantId},${context.authToken}"
4637
- },
4638
- "data": {
4639
- "&": "$$",
4640
- "uiSchema": "${uiSchema}",
4641
- "recordId": "${uiSchema.list_views[listName]._id}"
4642
- },
4643
- "messages": {
4644
- "success": "删除成功"
4645
- },
4646
- "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",
4647
- "adaptor": "if (payload.errors) {\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n}\nreturn payload;",
4648
- }
4649
- }
4650
- },
4651
- {
4652
- "actionType": "url",
4653
- "args": {
4654
- "url": "${context.rootUrl}/app/${appId}/${objectName}/grid/all",
4655
- "blank": false
4656
- },
4657
- "expression": "data.delete == 1"
4658
- }
4659
- ]
4660
- }
4661
- }
4662
- },
5118
+ "actionType": "custom",
5119
+ "script": onReloadScript
5120
+ }
5121
+ ]
5122
+ }
5123
+ },
5124
+ },
5125
+ filterVisible ? {
5126
+ "label": "",
5127
+ "icon": "fa fa-search",
5128
+ "type": "button",
5129
+ "badge": {
5130
+ "offset": [
5131
+ -5,
5132
+ 1
5133
+ ],
5134
+ "size":8,
5135
+ "animation": true,
5136
+ "visibleOn": "${isFieldsFilterEmpty == false}"
5137
+ },
5138
+ "align": "right",
5139
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5140
+ "onEvent": {
5141
+ "click": {
5142
+ "actions": [
4663
5143
  {
4664
- "type": "button",
4665
- "visibleOn": "${false}",
4666
- "label": "保存宽度(todo)"
4667
- },
4668
- // {
4669
- // type: 'steedos-object-button',
4670
- // name: 'standard_delete',
4671
- // objectName: 'test0321__c',
4672
- // // visibleOn: getButtonVisibleOn(button),
4673
- // className: 'antd-Button--default'
4674
- // }
5144
+ "actionType": "custom",
5145
+ "script": onFieldsFilterToggleScript
5146
+ }
4675
5147
  ]
4676
5148
  }
4677
- ]
5149
+ }
5150
+ } : {},
5151
+ getDisplayAsButton(mainObject?.name)
5152
+ ]
5153
+ }else {
5154
+ return [
5155
+ // "filter-toggler",
5156
+ ...(headerToolbarItems || []),
5157
+ "bulkActions",
5158
+ {
5159
+ "type": "columns-toggler",
5160
+ "className": "hidden"
5161
+ },
5162
+ // {
5163
+ // "type": "columns-toggler",
5164
+ // "className": "mr-2"
5165
+ // },
5166
+ hiddenCount ? {} : {
5167
+ "type": "tpl",
5168
+ "tpl": "${count} 个项目"
5169
+ },
5170
+ {
5171
+ "type": "reload",
5172
+ "align": "right",
5173
+ "tooltipPlacement": "bottom",
5174
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500"
4678
5175
  },
5176
+ getExportExcelToolbarButtonSchema(),
5177
+ filterVisible ? {
5178
+ "label": "",
5179
+ "icon": "fa fa-search",
5180
+ "type": "button",
5181
+ "align": "right",
5182
+ "className": "bg-white p-2 rounded border-gray-300 text-gray-500",
5183
+ "onEvent": {
5184
+ "click": {
5185
+ "actions": [
5186
+ {
5187
+ "actionType": "custom",
5188
+ "script": onFieldsFilterToggleScript
5189
+ }
5190
+ ]
5191
+ }
5192
+ }
5193
+ } : {},
5194
+ getSettingListviewToolbarButtonSchema(),
4679
5195
  getDisplayAsButton(showDisplayAs)
4680
5196
  // {
4681
5197
  // "type": "search-box",
@@ -5154,20 +5670,7 @@ async function lookupToAmisPicker(field, readonly, ctx){
5154
5670
  }
5155
5671
  }
5156
5672
 
5157
- var searchableFilter = [];
5158
- _.each(selfData, (value, key)=>{
5159
- if(!_.isEmpty(value) || _.isBoolean(value)){
5160
- if(_.startsWith(key, '__searchable__between__')){
5161
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
5162
- }else if(_.startsWith(key, '__searchable__')){
5163
- if(_.isString(value)){
5164
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
5165
- }else{
5166
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
5167
- }
5168
- }
5169
- }
5170
- });
5673
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
5171
5674
 
5172
5675
  if(searchableFilter.length > 0){
5173
5676
  if(filters.length > 0 ){
@@ -5900,23 +6403,6 @@ const getAmisFileSchema = (steedosField, readonly)=>{
5900
6403
  return readonly ? getAmisFileReadonlySchema(steedosField) : getAmisFileEditSchema(steedosField);
5901
6404
  };
5902
6405
 
5903
- /*
5904
- * @Author: baozhoutao@steedos.com
5905
- * @Date: 2022-07-20 16:29:22
5906
- * @LastEditors: Please set LastEditors
5907
- * @LastEditTime: 2023-05-11 11:19:54
5908
- * @Description:
5909
- */
5910
-
5911
- function getContrastColor(bgColor) {
5912
- var backgroundColor = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor;
5913
- var r = parseInt(backgroundColor.substr(0, 2), 16);
5914
- var g = parseInt(backgroundColor.substr(2, 2), 16);
5915
- var b = parseInt(backgroundColor.substr(4, 2), 16);
5916
- var brightness = (r * 299 + g * 587 + b * 114) / 1000;
5917
- return brightness >= 128 ? "#000000" : "#ffffff";
5918
- }
5919
-
5920
6406
  const OMIT_FIELDS = ['created', 'created_by', 'modified', 'modified_by'];
5921
6407
  // const Lookup = require('./lookup');
5922
6408
 
@@ -6107,19 +6593,7 @@ async function convertSFieldToAmisField(field, readonly, ctx) {
6107
6593
  // break;
6108
6594
  case 'select':
6109
6595
  if(readonly){
6110
- const selectOptions = field.options;
6111
- let map = {};
6112
- ___default__namespace.forEach(selectOptions,(option)=>{
6113
- const optionValue = option.value + '';
6114
- if(option.color){
6115
- const background = '#'+option.color;
6116
- const color = getContrastColor(background);
6117
- const optionColorStyle = 'background:'+background+';color:'+color;
6118
- map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
6119
- }else {
6120
- map[optionValue] = option.label;
6121
- }
6122
- });
6596
+ const map = getSelectMap(field.options);
6123
6597
  convertData = {
6124
6598
  type: "static-mapping",
6125
6599
  name: field.name,
@@ -6818,7 +7292,8 @@ async function getEditFormInitApi(object, recordId, fields, options){
6818
7292
  data.global = "${global}";
6819
7293
  data.context = "${context}";
6820
7294
  data.defaultData = "${defaultData}";
6821
-
7295
+ data._master = "${_master}";
7296
+
6822
7297
  return {
6823
7298
  method: "post",
6824
7299
  url: getApi$2() + '&objectName=${objectName}' ,
@@ -6884,7 +7359,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
6884
7359
  formInitialValuesFun = new Function("return " + formInitialValuesFun)();
6885
7360
  }
6886
7361
  if(typeof formInitialValuesFun === "function"){
6887
- initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global})
7362
+ initialValues = formInitialValuesFun.apply({doc: defaultValues || {} , global: api.body.global, master: api.body._master })
6888
7363
  }
6889
7364
  }
6890
7365
  catch(ex){
@@ -7235,7 +7710,7 @@ async function getObjectCRUD(objectSchema, fields, options){
7235
7710
  id: `service_${id}`,
7236
7711
  name: `page`,
7237
7712
  data: {
7238
- // objectName: objectSchema.name,
7713
+ objectName: objectSchema.name,
7239
7714
  // _id: null,
7240
7715
  recordPermissions: objectSchema.permissions,
7241
7716
  uiSchema: objectSchema,
@@ -7540,19 +8015,7 @@ async function getTableColumns$1(fields, options){
7540
8015
  }, field.amis, {name: field.name}));
7541
8016
  }
7542
8017
  else if(field.type === 'select'){
7543
- const selectOptions = field.options;
7544
- let map = {};
7545
- ___default.forEach(selectOptions,(option)=>{
7546
- const optionValue = option.value + '';
7547
- if(option.color){
7548
- const background = '#'+option.color;
7549
- const color = getContrastColor(background);
7550
- const optionColorStyle = 'background:'+background+';color:'+color;
7551
- map[optionValue] = `<span class="rounded-xl px-2 py-1" style='${optionColorStyle}'>${option.label}</span>`;
7552
- }else {
7553
- map[optionValue] = option.label;
7554
- }
7555
- });
8018
+ const map = getSelectMap(field.options);
7556
8019
  columns.push(Object.assign({}, {
7557
8020
  type: "mapping",
7558
8021
  name: field.name,
@@ -8053,20 +8516,8 @@ async function getTableApi(mainObject, fields, options){
8053
8516
  }else if(selfData.op === 'loadOptions' && selfData.value){
8054
8517
  userFilters = [["${valueField.name}", "=", selfData.value]];
8055
8518
  }
8056
- var searchableFilter = [];
8057
- _.each(selfData, (value, key)=>{
8058
- if(!_.isEmpty(value) || _.isBoolean(value)){
8059
- if(_.startsWith(key, '__searchable__between__')){
8060
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
8061
- }else if(_.startsWith(key, '__searchable__')){
8062
- if(_.isString(value)){
8063
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
8064
- }else{
8065
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
8066
- }
8067
- }
8068
- }
8069
- });
8519
+
8520
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
8070
8521
 
8071
8522
  if(searchableFilter.length > 0){
8072
8523
  if(userFilters.length > 0 ){
@@ -8117,11 +8568,10 @@ async function getTableApi(mainObject, fields, options){
8117
8568
  if(api.data.$self._isRelated){
8118
8569
  const self = api.data.$self;
8119
8570
  const relatedKey = self.relatedKey;
8120
- const recordId = self.recordId;
8121
8571
  const refField = self.uiSchema.fields[relatedKey];
8122
8572
  const masterRecord = self._master.record;
8123
8573
  const masterObjectName = self._master.objectName;
8124
- let relatedValue = recordId;
8574
+ let relatedValue = self._master.recordId;
8125
8575
  if(refField.reference_to_field && refField.reference_to_field != '_id'){
8126
8576
  relatedValue = masterRecord[refField.reference_to_field]
8127
8577
  }
@@ -8337,20 +8787,7 @@ async function getCalendarApi(mainObject, fields, options) {
8337
8787
  }else if(selfData.op === 'loadOptions' && selfData.value){
8338
8788
  filters = [["${valueField.name}", "=", selfData.value]];
8339
8789
  }
8340
- var searchableFilter = [];
8341
- _.each(selfData, (value, key)=>{
8342
- if(!_.isEmpty(value) || _.isBoolean(value)){
8343
- if(_.startsWith(key, '__searchable__between__')){
8344
- searchableFilter.push([\`\${key.replace("__searchable__between__", "")}\`, "between", value])
8345
- }else if(_.startsWith(key, '__searchable__')){
8346
- if(_.isString(value)){
8347
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "contains", value])
8348
- }else{
8349
- searchableFilter.push([\`\${key.replace("__searchable__", "")}\`, "=", value])
8350
- }
8351
- }
8352
- }
8353
- });
8790
+ var searchableFilter = SteedosUI.getSearchFilter(selfData) || [];
8354
8791
 
8355
8792
  if(searchableFilter.length > 0){
8356
8793
  if(filters.length > 0 ){
@@ -8876,7 +9313,7 @@ const getRecordPermissions = async (objectName, recordId)=>{
8876
9313
  * @Author: baozhoutao@steedos.com
8877
9314
  * @Date: 2022-07-05 15:55:39
8878
9315
  * @LastEditors: Please set LastEditors
8879
- * @LastEditTime: 2023-05-08 16:34:25
9316
+ * @LastEditTime: 2023-05-17 09:09:33
8880
9317
  * @Description:
8881
9318
  */
8882
9319
 
@@ -9016,7 +9453,7 @@ async function getRecordDetailRelatedListSchema(objectName, recordId, relatedObj
9016
9453
  // } else {
9017
9454
  // globalFilter = [`${relatedKey}`, "=", relatedValue];
9018
9455
  // }
9019
- const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel);
9456
+ const recordRelatedListHeader = await getObjectRecordDetailRelatedListHeader(relatedObjectUiSchema, relatedLabel, ctx);
9020
9457
  const componentId = `steedos-record-related-list-${relatedObjectName}`;
9021
9458
  const options = {
9022
9459
  globalFilter,
@@ -12665,6 +13102,7 @@ var index_esm$1 = /*#__PURE__*/Object.freeze({
12665
13102
  getObjectListHeaderSecordLine: getObjectListHeaderSecordLine,
12666
13103
  getObjectListViewButtonsSchemas: getObjectListViewButtonsSchemas,
12667
13104
  getObjectRecordDetailHeader: getObjectRecordDetailHeader,
13105
+ getObjectRecordDetailRelatedListButtonsSchemas: getObjectRecordDetailRelatedListButtonsSchemas,
12668
13106
  getObjectRecordDetailRelatedListHeader: getObjectRecordDetailRelatedListHeader,
12669
13107
  getObjectRelated: getObjectRelated,
12670
13108
  getObjectRelatedList: getObjectRelatedList,
@@ -14270,7 +14708,16 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
14270
14708
  },
14271
14709
  "adaptor": "return payload.data"
14272
14710
  },
14273
- "interval": 30000,
14711
+ "onEvent": {
14712
+ "@data.changed.notifications": {
14713
+ "actions": [
14714
+ {
14715
+ "actionType": "reload"
14716
+ }
14717
+ ]
14718
+ }
14719
+ },
14720
+ // "interval": 30000,
14274
14721
  "silentPolling": true
14275
14722
  }
14276
14723
  ],
@@ -14358,6 +14805,15 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
14358
14805
  },
14359
14806
  ],
14360
14807
  "id": "u:aba521eed5b7",
14808
+ "onEvent": {
14809
+ "@data.changed.notifications": {
14810
+ "actions": [
14811
+ {
14812
+ "actionType": "reload"
14813
+ }
14814
+ ]
14815
+ }
14816
+ },
14361
14817
  "messages": {},
14362
14818
  "api": {
14363
14819
  "method": "post",
@@ -14516,8 +14972,8 @@ var AmisGlobalHeaderToolbar = function (props) { return __awaiter(void 0, void 0
14516
14972
  /*
14517
14973
  * @Author: baozhoutao@steedos.com
14518
14974
  * @Date: 2022-09-01 14:44:57
14519
- * @LastEditors: baozhoutao@steedos.com
14520
- * @LastEditTime: 2023-04-11 13:51:50
14975
+ * @LastEditors: 殷亮辉 yinlianghui@hotoa.com
14976
+ * @LastEditTime: 2023-05-18 22:39:31
14521
14977
  * @Description:
14522
14978
  */
14523
14979
  var AmisGlobalHeader = function (props) { return __awaiter(void 0, void 0, void 0, function () {
@@ -14538,8 +14994,17 @@ var AmisGlobalHeader = function (props) { return __awaiter(void 0, void 0, void
14538
14994
  "className": 'flex w-full px-4 h-[50px] p-0 justify-between items-center steedos-header-container-line-one',
14539
14995
  "body": [
14540
14996
  {
14541
- type: "wrapper",
14997
+ type: "service",
14542
14998
  className: 'p-0 flex flex-1 items-center',
14999
+ "onEvent": {
15000
+ "@history_paths.changed": {
15001
+ "actions": [
15002
+ {
15003
+ "actionType": "reload"
15004
+ }
15005
+ ]
15006
+ }
15007
+ },
14543
15008
  body: [
14544
15009
  {
14545
15010
  "type": "button",
@@ -14566,10 +15031,35 @@ var AmisGlobalHeader = function (props) { return __awaiter(void 0, void 0, void
14566
15031
  }
14567
15032
  ],
14568
15033
  },
15034
+ {
15035
+ "type": "button",
15036
+ "visibleOn": "${window:innerWidth < 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id)}",
15037
+ "className": "flex",
15038
+ "onEvent": {
15039
+ "click": {
15040
+ "actions": [
15041
+ {
15042
+ "actionType": "custom",
15043
+ "script": "Steedos.goBack()"
15044
+ }
15045
+ ]
15046
+ }
15047
+ },
15048
+ "body": [
15049
+ {
15050
+ "type": "steedos-icon",
15051
+ "category": "utility",
15052
+ "name": "chevronleft",
15053
+ "colorVariant": "default",
15054
+ "className": "slds-button_icon slds-global-header__icon"
15055
+ }
15056
+ ]
15057
+ },
14569
15058
  {
14570
15059
  "className": 'block h-10 w-auto mr-4',
14571
15060
  "type": "tpl",
14572
15061
  "tpl": "<a href='/app' class='flex items-center '><img class='block h-10 w-auto' src='".concat(logoSrc, "'></a>"),
15062
+ "hiddenOn": "${window:innerWidth < 768 && (window:historyPaths.length > 1 || window:historyPaths[0].params.record_id)}"
14573
15063
  },
14574
15064
  ],
14575
15065
  },
@@ -14788,6 +15278,7 @@ var getSelectFlowSchema = function (id, props) {
14788
15278
  "method": "post",
14789
15279
  "url": "${context.rootUrl}/graphql?keywords=${keywords}",
14790
15280
  "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 "),
15281
+ "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 ",
14791
15282
  "headers": {
14792
15283
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
14793
15284
  }
@@ -15031,7 +15522,7 @@ var PageObject = function (props) { return __awaiter(void 0, void 0, void 0, fun
15031
15522
  });
15032
15523
  }); };
15033
15524
 
15034
- 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);
15525
+ 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);
15035
15526
 
15036
15527
  var index_esm = /*#__PURE__*/Object.freeze({
15037
15528
  __proto__: null,