@steedos/service-plugin-amis 2.6.1-beta.6 → 2.6.2-beta.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.
@@ -60,8 +60,8 @@
60
60
  // window.ReactDOM = window.__ReactDOM;
61
61
  const AmisRenderers = [];
62
62
  let amisLib = amisRequire('amis');
63
- amisLib.registerFilter('t', function (key) {
64
- return typeof key === 'string' ? window.t(key) : key;
63
+ amisLib.registerFilter('t', function (key,param) {
64
+ return typeof key === 'string' ? window.t(key,param) : key;
65
65
  });
66
66
  const registerMap = {
67
67
  renderer: amisLib.Renderer,
@@ -69,14 +69,18 @@
69
69
  options: amisLib.OptionsControl,
70
70
  };
71
71
 
72
- const amisComps = lodash.filter(Builder.registry['meta-components'], function(item){ return item.componentName && item.amis?.render});
72
+ const amisComps = lodash.filter(Builder.registry['meta-components'], function(item){ return item.componentName && item.amis && item.amis.render});
73
73
 
74
74
  lodash.each(amisComps,(comp)=>{
75
75
  const Component = Builder.components.find(item => item.name === comp.componentName);
76
- if (Component && !AmisRenderers.includes(comp.amis?.render.type)){
76
+ var type = null;
77
+ if(comp.amis){
78
+ type = comp.amis.render.type
79
+ }
80
+ if (Component && !AmisRenderers.includes(type)){
77
81
  try {
78
82
  let AmisWrapper = Component.class
79
- AmisRenderers.push(comp.amis?.render.type);
83
+ AmisRenderers.push(type);
80
84
  if(comp.componentType === 'amisSchema'){
81
85
  let amisReact = amisRequire('react');
82
86
  AmisWrapper = function(props){
@@ -98,17 +102,18 @@
98
102
  }, [JSON.stringify($schema)]) //, JSON.stringify(props.data)
99
103
 
100
104
  if (!schema)
101
- return render('body', {
102
- "type": "wrapper",
103
- "className": "h-full flex items-center justify-center",
104
- "body": {
105
- "type": "spinner",
106
- "show": true
107
- }
108
- })
105
+ return;
106
+ // return render('body', {
107
+ // "type": "wrapper",
108
+ // "className": "h-full flex items-center justify-center",
109
+ // "body": {
110
+ // "type": "spinner",
111
+ // "show": true
112
+ // }
113
+ // })
109
114
 
110
115
  if (props.env.enableAMISDebug && schema) {
111
- console.groupCollapsed(`[steedos render ${comp.amis?.render.type}]`);
116
+ console.groupCollapsed(`[steedos render ${type}]`);
112
117
  console.trace('Component: ', props, 'Generated Amis Schema: ', schema);
113
118
  console.groupEnd();
114
119
  }
@@ -221,6 +226,17 @@
221
226
  // }
222
227
  // return div;
223
228
  // },
229
+ // 如果这里不配置env.notify,那么会走amis 默认的env.notify,它会造成随机把toast组件dom插入到不同的scope容器内(应该是插入到最后一个加载的scope),这在苹果手机上可能会造成弹出的通知z-index不生效的情况,出现通知被档住的问题
230
+ notify: (type, msg)=>{
231
+ var tpl = msg.props && msg.props.schema.tpl;
232
+ if(tpl){
233
+ SteedosUI.message[type](tpl)
234
+ }else if(typeof msg == 'string'){
235
+ SteedosUI.message[type](msg)
236
+ }else{
237
+ console.warn('notify', type, msg)
238
+ }
239
+ },
224
240
  jumpTo: (to, action) => {
225
241
  if (to === 'goBack') {
226
242
  return window.history.back();
@@ -235,8 +251,13 @@
235
251
 
236
252
  // 主要是支持 nav 中的跳转
237
253
  if (action && to && action.target) {
238
- window.open(to, action.target);
239
- return;
254
+ if(Meteor.isCordova && to.indexOf('http') != 0){
255
+ window.open(Steedos.absoluteUrl(to), action.target);
256
+ return;
257
+ }else{
258
+ window.open(to, action.target);
259
+ return;
260
+ }
240
261
  }
241
262
 
242
263
  if (/^https?:\/\//.test(to)) {
@@ -247,6 +268,34 @@
247
268
  },
248
269
  theme: 'antd',
249
270
  isCurrentUrl: isCurrentUrl,
271
+ requestAdaptor: (config)=>{
272
+ // url是相对路径
273
+ if(config.url && (!/^http[s]?:\/\//i.test(config.url))){
274
+ if(Meteor.isCordova){
275
+ config.url = Meteor.absoluteUrl(config.url)
276
+ }
277
+
278
+ if(!config.headers){
279
+ config.headers = {}
280
+ }
281
+
282
+ if(!config.headers.Authorization && Builder.settings.context && Builder.settings.context.tenantId && Builder.settings.context.authToken){
283
+ config.headers.Authorization = `Bearer ${Builder.settings.context.tenantId},${Builder.settings.context.authToken}`;
284
+ }
285
+ }else if(config.url && Meteor.isCordova && Builder.settings.context && Builder.settings.context.rootUrl && config.url.startsWith(Builder.settings.context.rootUrl)){
286
+ // 是绝对路径,且是cordova环境, 且以root url开头, 则自动处理认证
287
+ if(Meteor.isCordova){
288
+ if(!config.headers){
289
+ config.headers = {}
290
+ }
291
+
292
+ if(!config.headers.Authorization && Builder.settings.context && Builder.settings.context.tenantId && Builder.settings.context.authToken){
293
+ config.headers.Authorization = `Bearer ${Builder.settings.context.tenantId},${Builder.settings.context.authToken}`;
294
+ }
295
+ }
296
+ }
297
+ return config;
298
+ }
250
299
  };
251
300
  // 已弃用
252
301
  const AmisRender = function (props) {
@@ -306,6 +355,8 @@
306
355
  };
307
356
 
308
357
  window.renderAmis = function (root, schema, data, env) {
358
+ // console.log("===window.renderAmis===root, env===", root, env);
359
+ // console.log("===window.renderAmis===data===", data);
309
360
  const refName = schema.name || schema.id;
310
361
  if(SteedosUI.refs[refName]){
311
362
  if(SteedosUI.refs[refName].unmount){
@@ -2,7 +2,7 @@
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-05-20 17:42:20
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2022-10-28 11:01:51
5
+ * @LastEditTime: 2023-08-22 22:36:38
6
6
  * @Description: 提供辅助函数
7
7
  */
8
8
  (function(){
@@ -97,7 +97,7 @@
97
97
  [
98
98
  React17.createElement(SteedosUI.components.Button, {
99
99
  onClick: function(){
100
- SteedosUI.getRef(pageName)?.close();
100
+ SteedosUI.getRef(pageName) && SteedosUI.getRef(pageName).close();
101
101
  }
102
102
  } , t('cancel')),
103
103
  React17.createElement(SteedosUI.components.Button, {
@@ -132,7 +132,7 @@
132
132
  if (error) {
133
133
  return console.log("error", error);
134
134
  } else if (result) {
135
- SteedosUI.getRef(pageName)?.close();
135
+ SteedosUI.getRef(pageName) && SteedosUI.getRef(pageName).close();
136
136
  return Session.set("filter_items", filter_items);
137
137
  }
138
138
  });
@@ -141,7 +141,7 @@
141
141
  const formValues = window.amisScopes[pageName].getComponentByName("filtersForm").getValues();
142
142
  const filters = window.amisConvert.conditionsToFilters(formValues.filters);
143
143
  Session.set("filter_items", filters);
144
- SteedosUI.getRef(pageName)?.close();
144
+ SteedosUI.getRef(pageName) && SteedosUI.getRef(pageName).close();
145
145
  },
146
146
  type: 'primary'
147
147
  } , canSave ? t('save'): t('apply'))
@@ -27,12 +27,12 @@
27
27
  {
28
28
  "type": "fieldSet",
29
29
  "id": "u:3ce1d050bcac",
30
- "title": "通用",
30
+ "title": "",
31
31
  "collapsable": true,
32
32
  "body": [
33
33
  {
34
34
  "name": "name",
35
- "label": "API 名称",
35
+ "label": "${'action_field_updates.action_field_updates_form.api_name' | t}",
36
36
  "required": true,
37
37
  "type": "input-text",
38
38
  "className": "m-1",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  {
45
45
  "name": "label",
46
- "label": "显示名称",
46
+ "label": "${'action_field_updates.action_field_updates_form.display_name' | t}",
47
47
  "required": true,
48
48
  "type": "input-text",
49
49
  "className": "m-1",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  {
56
56
  "name": "object_name",
57
- "label": "对象",
57
+ "label": "${'action_field_updates.action_field_updates_form.object_name' | t}",
58
58
  "required": false,
59
59
  "type": "select",
60
60
  "joinValues": false,
@@ -88,7 +88,7 @@
88
88
  },
89
89
  {
90
90
  "name": "target_object",
91
- "label": "要更新的对象",
91
+ "label": "${'action_field_updates.action_field_updates_form.update_object' | t}",
92
92
  "required": false,
93
93
  "type": "select",
94
94
  "joinValues": false,
@@ -106,7 +106,7 @@
106
106
  },
107
107
  {
108
108
  "name": "field_name",
109
- "label": "要更新的字段",
109
+ "label": "${'action_field_updates.action_field_updates_form.update_name' | t}",
110
110
  "required": false,
111
111
  "type": "select",
112
112
  "joinValues": false,
@@ -124,7 +124,7 @@
124
124
  },
125
125
  {
126
126
  "name": "operation",
127
- "label": "新字段值类型",
127
+ "label": "${'action_field_updates.action_field_updates_form.new_field_value_type' | t}",
128
128
  "required": false,
129
129
  "type": "select",
130
130
  "joinValues": false,
@@ -142,7 +142,7 @@
142
142
  },
143
143
  {
144
144
  "name": "formula",
145
- "label": "公式",
145
+ "label": "${'action_field_updates.action_field_updates_form.formula' | t}",
146
146
  "required": false,
147
147
  "type": "textarea",
148
148
  "tpl": "<b><%=data.formula%></b>",
@@ -168,7 +168,7 @@
168
168
  },
169
169
  {
170
170
  "name": "description",
171
- "label": "描述",
171
+ "label": "${'action_field_updates.action_field_updates_form.description' | t}",
172
172
  "required": false,
173
173
  "type": "textarea",
174
174
  "tpl": "<b><%=data.description%></b>",
@@ -180,7 +180,7 @@
180
180
  },
181
181
  {
182
182
  "name": "reevaluate_on_change",
183
- "label": "字段更改后重新评估工作流规则",
183
+ "label": "${'action_field_updates.action_field_updates_form.reevaluate_on_change' | t}",
184
184
  "required": false,
185
185
  "type": "checkbox",
186
186
  "tpl": null,
@@ -192,7 +192,7 @@
192
192
  },
193
193
  {
194
194
  "name": "undirect",
195
- "label": "触发对象触发器、工作流规则、字段验证规则",
195
+ "label": "${'action_field_updates.action_field_updates_form.undirect' | t}",
196
196
  "required": false,
197
197
  "type": "checkbox",
198
198
  "tpl": null,
@@ -231,7 +231,7 @@
231
231
  }
232
232
  },
233
233
  "initFetch": true,
234
- "panelClassName": "m-0 sm:rounded-lg shadow-none",
234
+ "panelClassName": "m-0 sm:rounded-lg shadow-none no-border",
235
235
  "bodyClassName": "p-0",
236
236
  "className": "steedos-amis-form",
237
237
  "onEvent": {
@@ -245,7 +245,7 @@
245
245
  },
246
246
  {
247
247
  "actionType": "custom",
248
- "script": "\n const { recordId, listViewId } = context.props.data;\n const data = event.data;\n const appId = data.appId;\n const objectName = data.objectName;\n // 在记录详细界面时isRecordDetail为true\n // TODO: isRecordDetail这个判断需要优化\n const isRecordDetail = data._isRelated;\n if(recordId){\n // 编辑记录时,刷新主表单\n doAction({\n componentId: `detail_${recordId}`,\n actionType: \"reload\",\n expression: `!${listViewId}`\n });\n }\n else if(!isRecordDetail){\n // 在列表视图界面新建记录时跳转到详细页面\n const jumpTo = event.context.env && event.context.env.jumpTo;\n if(jumpTo){\n const newRecordId = data.result.data?.recordId;\n jumpTo(\"/app/\" + appId + \"/\" + objectName + \"/view/\" + newRecordId);\n }\n }\n "
248
+ "script": "\n const { recordId, listViewId } = context.props.data;\n const data = event.data;\n const appId = data.appId;\n const objectName = data.objectName;\n // 在记录详细界面时isRecordDetail为true\n // TODO: isRecordDetail这个判断需要优化\n const isRecordDetail = data._isRelated;\n if(recordId){\n // 编辑记录时,刷新主表单\n doAction({\n componentId: `detail_${recordId}`,\n actionType: \"reload\",\n expression: `!${listViewId}`\n });\n }\n else if(!isRecordDetail){\n // 在列表视图界面新建记录时跳转到详细页面\n const jumpTo = event.context.env && event.context.env.jumpTo;\n if(jumpTo){\n var _data$result$data;const newRecordId = (_data$result$data = data.result.data) === null || _data$result$data === void 0 ? void 0 : _data$result$data.recordId;\n jumpTo(\"/app/\" + appId + \"/\" + objectName + \"/view/\" + newRecordId);\n }\n }\n "
249
249
  }
250
250
  ]
251
251
  }
@@ -262,5 +262,5 @@
262
262
  "regions": [
263
263
  "body"
264
264
  ],
265
- "bodyClassName": ""
265
+ "bodyClassName": "p-0"
266
266
  }
@@ -1,4 +1,4 @@
1
- name: action_field_updates
1
+ name: action_field_updates_form
2
2
  is_active: true
3
3
  label: 字段更新表单
4
4
  object_name: action_field_updates