@steedos/service-plugin-amis 2.4.0-beta.3 → 2.4.0-beta.30

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.
@@ -19,8 +19,8 @@
19
19
  };
20
20
  }
21
21
  // loadCss(Steedos.absoluteUrl("/unpkg.com/amis/sdk/sdk.css"))
22
- loadCss(Steedos.absoluteUrl("/unpkg.com/amis/sdk/helper.css"))
23
- loadCss(Steedos.absoluteUrl("/unpkg.com/amis/sdk/iconfont.css"))
22
+ // loadCss(Steedos.absoluteUrl("/unpkg.com/amis/sdk/helper.css"))
23
+ // loadCss(Steedos.absoluteUrl("/unpkg.com/amis/sdk/iconfont.css"))
24
24
  loadCss(Steedos.absoluteUrl("/amis/amis.css"))
25
25
 
26
26
  try {
@@ -48,9 +48,9 @@
48
48
  }
49
49
 
50
50
  // 加载Amis SDK: 如果直接放到body中会导致 meteor 编译后的 cordova.js 加载报错
51
- let amisSDKScript = document.createElement("script");
52
- amisSDKScript.setAttribute("src", Steedos.absoluteUrl('/unpkg.com/amis/sdk/sdk.js'));
53
- document.getElementsByTagName("head")[0].appendChild(amisSDKScript);
51
+ // let amisSDKScript = document.createElement("script");
52
+ // amisSDKScript.setAttribute("src", Steedos.absoluteUrl('/unpkg.com/amis/sdk/sdk.js'));
53
+ // document.getElementsByTagName("head")[0].appendChild(amisSDKScript);
54
54
  } catch (error) {
55
55
  console.error(error)
56
56
  };
@@ -94,7 +94,7 @@
94
94
  if(comp.componentType === 'amisSchema'){
95
95
  let amisReact = amisRequire('react');
96
96
  AmisWrapper = function(props){
97
- const { body, render } = props
97
+ const { $schema, body, render } = props
98
98
  const [schema, setSchema] = amisReact.useState(null);
99
99
  amisReact.useEffect(()=>{
100
100
  const result = Component.class(props);
@@ -105,7 +105,7 @@
105
105
  }else{
106
106
  setSchema(result)
107
107
  }
108
- }, [])
108
+ }, [JSON.stringify($schema)])
109
109
  return amisReact.createElement(amisReact.Fragment, null, amisReact.createElement(amisReact.Fragment, null, schema && render ? render('body', schema) : ''), amisReact.createElement(amisReact.Fragment, null, render ? render('body', body) : ''));
110
110
  }
111
111
  }
@@ -203,7 +203,7 @@
203
203
  console.error(`error`, error)
204
204
  }
205
205
  }
206
- const AmisEnv = {
206
+ AmisEnv = {
207
207
  // getModalContainer: (props)=>{
208
208
  // let div = document.querySelector("#amisModalContainer");
209
209
  // if(!div){
@@ -223,7 +223,7 @@
223
223
  to = normalizeLink(to);
224
224
 
225
225
  if (action && action.actionType === 'url') {
226
- action.blank === false ? (window.location.href = to) : window.open(to);
226
+ action.blank === true ? window.open(to): (window.location.href = to);
227
227
  return;
228
228
  }
229
229
 
@@ -248,10 +248,13 @@
248
248
  const schema = props.schema;
249
249
  const data = props.data;
250
250
  const name = props.name;
251
-
252
- if(SteedosUI.refs[schema.name]){
253
- if(SteedosUI.refs[schema.name].unmount){
254
- SteedosUI.refs[schema.name].unmount()
251
+ const refName = schema.name || schema.id;
252
+ if(SteedosUI.refs[refName]){
253
+ if(SteedosUI.refs[refName].unmount){
254
+ try {
255
+ SteedosUI.refs[refName].unmount()
256
+ } catch (Exception) {
257
+ }
255
258
  }else{
256
259
  console.log(`not find amis scope unmount`)
257
260
  }
@@ -279,19 +282,65 @@
279
282
  return scoped = ref
280
283
  }
281
284
 
282
- React.useEffect(()=>{
285
+
286
+ let amisReact = amisRequire('react');
287
+
288
+ amisReact.useEffect(()=>{
283
289
  const amisScope = amisRequire('amis/embed').embed(`.steedos-amis-render-scope-${name}`,schema, {data, name, locale: getAmisLng()}, Object.assign({}, AmisEnv, env))
284
- if(window.SteedosUI && schema.name){
285
- SteedosUI.refs[schema.name] = amisScope;
290
+ const refName = schema.name || schema.id;
291
+ if(window.SteedosUI && refName){
292
+ SteedosUI.refs[refName] = amisScope;
286
293
  }
287
294
  }, [])
288
- return React.createElement("div", {
295
+ return amisReact.createElement("div", {
289
296
  className: "amis-scope"
290
- }, React.createElement("div", {
297
+ }, amisReact.createElement("div", {
291
298
  className: `steedos-amis-render-scope-${name}`
292
299
  }));
293
300
  };
294
301
 
302
+ window.renderAmis = function (root, schema, data, env) {
303
+ const refName = schema.name || schema.id;
304
+ if(SteedosUI.refs[refName]){
305
+ if(SteedosUI.refs[refName].unmount){
306
+ try {
307
+ SteedosUI.refs[refName].unmount()
308
+ } catch (Exception) {
309
+ }
310
+ }else{
311
+ console.log(`not find amis scope unmount`)
312
+ }
313
+ }
314
+
315
+ // if(props.pageType === 'form'){
316
+ // env = Object.assign({
317
+ // getModalContainer: ()=>{
318
+ // return document.querySelector('.amis-scope');
319
+ // }
320
+ // }, env);
321
+ // }
322
+ schema.scopeRef = (ref) => {
323
+ try {
324
+ if(!window.amisScopes){
325
+ window.amisScopes = {};
326
+ }
327
+ if(name){
328
+ window.amisScopes[name] = ref;
329
+ }
330
+ } catch (error) {
331
+ console.error('error', error)
332
+ }
333
+
334
+ return scoped = ref
335
+ }
336
+
337
+
338
+ const amisScope = amisRequire('amis/embed').embed(root, schema, {data, name, locale: getAmisLng()}, Object.assign({}, AmisEnv, env))
339
+ if(window.SteedosUI && refName){
340
+ SteedosUI.refs[refName] = amisScope;
341
+ }
342
+ };
343
+
295
344
  const initMonaco = ()=>{
296
345
 
297
346
  // const { detect } = require('detect-browser');
@@ -0,0 +1,294 @@
1
+ {
2
+ "type": "page",
3
+ "body": [
4
+ {
5
+ "type": "service",
6
+ "className": "p-0",
7
+ "name": "page_edit_${recordId}",
8
+ "api": {
9
+ "method": "post",
10
+ "url": "${context.rootUrl}/graphql",
11
+ "adaptor": "\n if(payload.data.data){\n var data = payload.data.data[0];\n if(data){\n \n \n //初始化接口返回的字段移除字段值为null的字段\n for (key in data){\n if(data[key] === null){\n delete data[key];\n }\n }\n };\n payload.data = data;\n delete payload.extensions;\n }\n return payload;\n ",
12
+ "data": {
13
+ "query": "{data:action_field_updates(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,label,object_name,target_object,field_name,operation,formula,literal_value,description,reevaluate_on_change,undirect,created,created_by,modified,modified_by,_display:_ui{object_name,target_object,field_name,operation,reevaluate_on_change,undirect,created,created_by,modified,modified_by}, \n recordPermissions: _permissions{\n allowCreate,\n allowCreateFiles,\n allowDelete,\n allowDeleteFiles,\n allowEdit,\n allowEditFiles,\n allowRead,\n allowReadFiles,\n disabled_actions,\n disabled_list_views,\n field_permissions,\n modifyAllFiles,\n modifyAllRecords,\n modifyAssignCompanysRecords,\n modifyCompanyRecords,\n uneditable_fields,\n unreadable_fields,\n unrelated_objects,\n viewAllFiles,\n viewAllRecords,\n viewAssignCompanysRecords,\n viewCompanyRecords,\n }\n }}"
14
+ },
15
+ "headers": {
16
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
17
+ },
18
+ "sendOn": "!!this.recordId",
19
+ "cache": 100
20
+ },
21
+ "initFetch": null,
22
+ "body": [
23
+ {
24
+ "type": "form",
25
+ "title": "",
26
+ "body": [
27
+ {
28
+ "type": "fieldSet",
29
+ "id": "u:3ce1d050bcac",
30
+ "title": "通用",
31
+ "collapsable": true,
32
+ "body": [
33
+ {
34
+ "name": "name",
35
+ "label": "API 名称",
36
+ "required": true,
37
+ "type": "input-text",
38
+ "className": "m-1",
39
+ "labelClassName": "text-left",
40
+ "clearValueOnHidden": true,
41
+ "fieldName": "name",
42
+ "id": "u:8ebca359c714"
43
+ },
44
+ {
45
+ "name": "label",
46
+ "label": "显示名称",
47
+ "required": true,
48
+ "type": "input-text",
49
+ "className": "m-1",
50
+ "labelClassName": "text-left",
51
+ "clearValueOnHidden": true,
52
+ "fieldName": "label",
53
+ "id": "u:124c34a09c5c"
54
+ },
55
+ {
56
+ "name": "object_name",
57
+ "label": "对象",
58
+ "required": false,
59
+ "type": "select",
60
+ "joinValues": false,
61
+ "extractValue": true,
62
+ "autoComplete": {
63
+ "method": "post",
64
+ "url": "${context.rootUrl}/graphql",
65
+ "data": {
66
+ "query": "{objects(filters: [\"_id\", \"=\", \"-1\"]){_id}}",
67
+ "$": "$$",
68
+ "$term": "$term",
69
+ "$value": "$object_name._id",
70
+ "rfield": "${object_name}"
71
+ },
72
+ "requestAdaptor": "\n var filters = '[]';\n var top = 10;\n if(api.data.$term){\n filters = '[\"name\", \"contains\", \"'+ api.data.$term +'\"]';\n }else if(api.data.$value){\n filters = '[\"_id\", \"=\", \"'+ api.data.$value +'\"]';\n }\n api.data.query = api.data.query.replace(/{__filters}/g, filters).replace('{__top}', top);\n return api;\n ",
73
+ "adaptor": "\n payload.data.options = eval(function anonymous(\n) {\n\n return Steedos.getObjectsOptions();\n\n})(api.data);\n return payload;\n "
74
+ },
75
+ "className": "m-1",
76
+ "labelClassName": "text-left",
77
+ "clearValueOnHidden": true,
78
+ "fieldName": "object_name",
79
+ "id": "u:0f2e40f882e2"
80
+ },
81
+ {
82
+ "name": "target_object",
83
+ "label": "要更新的对象",
84
+ "required": false,
85
+ "type": "select",
86
+ "joinValues": false,
87
+ "extractValue": true,
88
+ "autoComplete": {
89
+ "method": "post",
90
+ "url": "${context.rootUrl}/graphql",
91
+ "data": {
92
+ "query": "{objects(filters: [\"_id\", \"=\", \"-1\"]){_id}}",
93
+ "$": "$$",
94
+ "$term": "$term",
95
+ "$value": "$target_object._id",
96
+ "object_name": "$object_name",
97
+ "rfield": "${object_name}"
98
+ },
99
+ "requestAdaptor": "\n var filters = '[]';\n var top = 10;\n if(api.data.$term){\n filters = '[\"name\", \"contains\", \"'+ api.data.$term +'\"]';\n }else if(api.data.$value){\n filters = '[\"_id\", \"=\", \"'+ api.data.$value +'\"]';\n }\n api.data.query = api.data.query.replace(/{__filters}/g, filters).replace('{__top}', top);\n return api;\n ",
100
+ "adaptor": "\n payload.data.options = eval(function anonymous(doc\n) {\n\n var object = Creator.objectsByName[doc.object_name];\n if(object){\n var _options = [{label: object.label, value: object.name}];\n _.forEach(object.fields, function (field, fname) {\n if(field && field.type === 'master_detail' && _.isString(field.reference_to)){\n var referenceToObject = Creator.objectsByName[field.reference_to];\n if(referenceToObject){\n _options.push({\n label: referenceToObject.label,\n value: field.name,\n });\n }\n }\n });\n return _options;\n }\n return [];\n\n})(api.data);\n return payload;\n "
101
+ },
102
+ "className": "m-1",
103
+ "labelClassName": "text-left",
104
+ "clearValueOnHidden": true,
105
+ "fieldName": "target_object",
106
+ "id": "u:dd1c95753238"
107
+ },
108
+ {
109
+ "name": "field_name",
110
+ "label": "要更新的字段",
111
+ "required": false,
112
+ "type": "select",
113
+ "joinValues": false,
114
+ "extractValue": true,
115
+ "autoComplete": {
116
+ "method": "post",
117
+ "url": "${context.rootUrl}/graphql",
118
+ "data": {
119
+ "query": "{objects(filters: [\"_id\", \"=\", \"-1\"]){_id}}",
120
+ "$": "$$",
121
+ "$term": "$term",
122
+ "$value": "$field_name._id",
123
+ "object_name": "$object_name",
124
+ "target_object": "$target_object",
125
+ "rfield": "${object_name}"
126
+ },
127
+ "requestAdaptor": "\n var filters = '[]';\n var top = 10;\n if(api.data.$term){\n filters = '[\"name\", \"contains\", \"'+ api.data.$term +'\"]';\n }else if(api.data.$value){\n filters = '[\"_id\", \"=\", \"'+ api.data.$value +'\"]';\n }\n api.data.query = api.data.query.replace(/{__filters}/g, filters).replace('{__top}', top);\n return api;\n ",
128
+ "adaptor": "\n payload.data.options = eval(function anonymous(doc\n) {\n\n var mainObjectName = null;\n if(doc.target_object && doc.target_object != doc.object_name){\n mainObjectName = Creator.objectsByName[doc.object_name].fields[doc.target_object].reference_to;\n }else{\n mainObjectName = doc.object_name;\n }\n var object = Creator.objectsByName[mainObjectName];\n if(object){\n var _options = [];\n _.forEach(object.fields, function (field, fname) {\n if([\"formula\", \"summary\", \"autonumber\"].indexOf(field.type) < 0){\n /*公式、累计汇总、自动编号三种字段类型是只读的,不允许字段更新来变更其值*/\n _options.push({\n label: field.label,\n value: field.name,\n });\n }\n });\n return _options;\n }\n return [];\n\n})(api.data);\n return payload;\n "
129
+ },
130
+ "className": "m-1",
131
+ "labelClassName": "text-left",
132
+ "clearValueOnHidden": true,
133
+ "fieldName": "field_name",
134
+ "id": "u:204fadb7cef0"
135
+ },
136
+ {
137
+ "name": "operation",
138
+ "label": "新字段值类型",
139
+ "required": false,
140
+ "type": "select",
141
+ "joinValues": false,
142
+ "extractValue": true,
143
+ "autoComplete": {
144
+ "method": "post",
145
+ "url": "${context.rootUrl}/graphql",
146
+ "data": {
147
+ "query": "{objects(filters: [\"_id\", \"=\", \"-1\"]){_id}}",
148
+ "$": "$$",
149
+ "$term": "$term",
150
+ "$value": "$operation._id",
151
+ "field_name": "$field_name",
152
+ "target_object": "$target_object",
153
+ "object_name": "$object_name",
154
+ "rfield": "${object_name}"
155
+ },
156
+ "requestAdaptor": "\n var filters = '[]';\n var top = 10;\n if(api.data.$term){\n filters = '[\"name\", \"contains\", \"'+ api.data.$term +'\"]';\n }else if(api.data.$value){\n filters = '[\"_id\", \"=\", \"'+ api.data.$value +'\"]';\n }\n api.data.query = api.data.query.replace(/{__filters}/g, filters).replace('{__top}', top);\n return api;\n ",
157
+ "adaptor": "\n payload.data.options = eval(function anonymous(doc\n) {\n\n var mainObjectName = null;\n if(doc.target_object && doc.target_object != doc.object_name){\n mainObjectName = Creator.objectsByName[doc.object_name].fields[doc.target_object].reference_to;\n }else{\n mainObjectName = doc.object_name;\n }\n var object = Creator.objectsByName[mainObjectName];\n if(object && doc.field_name){\n var _options = [];\n var field = object.fields[doc.field_name];\n if(field && field.type != 'boolean'){\n _options.push({\n label: TAPi18n.__(\"action_field_updates_field_operation_options_null\"),\n value: 'null',\n }) \n }\n _options.push({\n label: TAPi18n.__(\"action_field_updates_field_operation_options_formula\"),\n value: 'formula',\n });\n _options.push({\n label: TAPi18n.__(\"action_field_updates_field_operation_options_literal\"),\n value: 'literal',\n })\n return _options;\n }\n return [];\n\n})(api.data);\n return payload;\n "
158
+ },
159
+ "className": "m-1",
160
+ "labelClassName": "text-left",
161
+ "clearValueOnHidden": true,
162
+ "fieldName": "operation",
163
+ "id": "u:627e520855b5",
164
+ "multiple": false
165
+ },
166
+ {
167
+ "name": "formula",
168
+ "label": "公式",
169
+ "required": false,
170
+ "type": "textarea",
171
+ "tpl": "<b><%=data.formula%></b>",
172
+ "className": "col-span-2 m-1",
173
+ "labelClassName": "text-left",
174
+ "clearValueOnHidden": true,
175
+ "fieldName": "formula",
176
+ "id": "u:20766a86a9f4",
177
+ "hiddenOn": "this.operation != 'formula'"
178
+ },
179
+ {
180
+ "type": "service",
181
+ "id": "u:d201a629c160",
182
+ "body": [],
183
+ "messages": {},
184
+ "schemaApi": {
185
+ "method": "get",
186
+ "url": "${context.rootUrl}/service/api/@${object_name}/uiSchema?field_name=${field_name}&operation=${operation}",
187
+ "adaptor": "const formData = api.body;\nconst target_field_name = formData.field_name;\nconst target_object_uiSchema = payload;\nconst target_fields = target_object_uiSchema && target_object_uiSchema.fields;\nconst target_field_type = target_fields && target_fields[target_field_name].type;\nlet literal_value_schema = {\n \"type\": \"text\",\n \"name\": \"literal_value\",\n \"label\": \"指定新字段值\",\n \"required\": false,\n \"is_wide\": true,\n \"labelClassName\": \"text-left\"\n}\nif (target_field_type) {\n literal_value_schema = Object.assign({}, target_object_uiSchema.fields[target_field_name], {\n name: \"literal_value\",\n label: \"指定新字段值\",\n disabled: false,\n readonly: false,\n is_wide: true\n });\n}\npayload = {\n \"status\": 0,\n \"msg\": \"\",\n \"data\": {\n \"body\": [\n {\n \"type\": \"steedos-field\",\n \"field\": literal_value_schema,\n \"name\": \"literal_value\",\n \"clearValueOnHidden\": true,\n \"fieldName\": \"literal_value\",\n \"visibleOn\": \"this.operation === 'literal'\"\n }\n ]\n }\n}\nreturn payload;",
188
+ "sendOn": "!!this.object_name && !!this.field_name && this.operation === 'literal'",
189
+ "headers": {
190
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
191
+ },
192
+ "data": {
193
+ "&": "$$"
194
+ }
195
+ }
196
+ },
197
+ {
198
+ "name": "description",
199
+ "label": "描述",
200
+ "required": false,
201
+ "type": "textarea",
202
+ "tpl": "<b><%=data.description%></b>",
203
+ "className": "col-span-2 m-1",
204
+ "labelClassName": "text-left",
205
+ "clearValueOnHidden": true,
206
+ "fieldName": "description",
207
+ "id": "u:16a7ebd835a6"
208
+ },
209
+ {
210
+ "name": "reevaluate_on_change",
211
+ "label": "字段更改后重新评估工作流规则",
212
+ "required": false,
213
+ "type": "checkbox",
214
+ "tpl": null,
215
+ "className": "m-1",
216
+ "labelClassName": "text-left",
217
+ "clearValueOnHidden": true,
218
+ "fieldName": "reevaluate_on_change",
219
+ "id": "u:b9baf683b6b0"
220
+ },
221
+ {
222
+ "name": "undirect",
223
+ "label": "触发对象触发器、工作流规则、字段验证规则",
224
+ "required": false,
225
+ "type": "checkbox",
226
+ "tpl": null,
227
+ "className": "m-1",
228
+ "labelClassName": "text-left",
229
+ "clearValueOnHidden": true,
230
+ "fieldName": "undirect",
231
+ "id": "u:b86f699bbe4f"
232
+ }
233
+ ]
234
+ }
235
+ ],
236
+ "id": "u:f57077c2a95f",
237
+ "mode": "horizontal",
238
+ "persistData": false,
239
+ "promptPageLeave": true,
240
+ "name": "form_edit_${recordId}",
241
+ "debug": false,
242
+ "submitText": "",
243
+ "api": {
244
+ "method": "post",
245
+ "url": "${context.rootUrl}/graphql",
246
+ "data": {
247
+ "objectName": "${objectName}",
248
+ "$": "$$",
249
+ "recordId": "${recordId}",
250
+ "modalName": "${modalName}"
251
+ },
252
+ "requestAdaptor": "\n \n const formData = api.data.$;\n for (key in formData){\n // image、select等字段清空值后保存的空字符串转换为null。\n if(formData[key] === ''){\n formData[key] = null;\n }\n }\n const objectName = api.data.objectName;\n const fieldsName = Object.keys(formData);\n delete formData.created;\n delete formData.created_by;\n delete formData.modified;\n delete formData.modified_by;\n delete formData._display;\n delete formData.created;\r\ndelete formData.created_by;\r\ndelete formData.modified;\r\ndelete formData.modified_by;\n \n \n let query = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\n if(formData.recordId && formData.recordId !='new'){\n query = `mutation{record: ${objectName}__update(id: \"${formData._id}\", doc: {__saveData}){_id}}`;\n };\n delete formData._id;\n let __saveData = JSON.stringify(JSON.stringify(formData));\n \n api.data = {query: query.replace('{__saveData}', __saveData)};\n return api;\n ",
253
+ "responseData": {
254
+ "recordId": "${record._id}"
255
+ },
256
+ "adaptor": "\n if(payload.errors){\n payload.status = 2;\n payload.msg = payload.errors[0].message;\n }\n return payload;\n ",
257
+ "headers": {
258
+ "Authorization": "Bearer ${context.tenantId},${context.authToken}"
259
+ }
260
+ },
261
+ "initFetch": true,
262
+ "panelClassName": "m-0 sm:rounded-lg shadow-none",
263
+ "bodyClassName": "p-0",
264
+ "className": "steedos-amis-form",
265
+ "onEvent": {
266
+ "submitSucc": {
267
+ "weight": 0,
268
+ "actions": [
269
+ {
270
+ "componentId": "listview_action_field_updates",
271
+ "actionType": "reload",
272
+ "expression": "!!listViewId"
273
+ },
274
+ {
275
+ "actionType": "custom",
276
+ "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.$master && data.$master.$master?.recordId;\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 "
277
+ }
278
+ ]
279
+ }
280
+ }
281
+ }
282
+ ],
283
+ "initApi": null
284
+ }
285
+ ],
286
+ "data": {
287
+ "objectName": "action_field_updates",
288
+ "context": {}
289
+ },
290
+ "regions": [
291
+ "body"
292
+ ],
293
+ "bodyClassName": ""
294
+ }
@@ -0,0 +1,12 @@
1
+ name: action_field_updates
2
+ is_active: true
3
+ label: 字段更新表单
4
+ object_name: action_field_updates
5
+ pageAssignments:
6
+ - desktop: true
7
+ mobile: true
8
+ page: action_field_updates
9
+ type: orgDefault
10
+ render_engine: amis
11
+ type: form
12
+ widgets: []
@@ -33,7 +33,7 @@
33
33
  "sendOn": "!!this.recordId",
34
34
  "adaptor": "var data = payload.data.data[0];\nif(data){\n //初始化接口返回的字段移除字段值为null的字段\n for (key in data){\n if(data[key] === null){\n delete data[key];\n }\n }\n};\nif (data.tab_items && !_.isArray(data.tab_items)) {\n // 数据库中存储的是对象格式而不是数组,转换为数组用于界面显示\n let arrTabItems = [];\n _.each(data.tab_items, function (n, k) {\n n.tab_name = k;\n delete n.index;\n arrTabItems.push(n);\n });\n data.tab_items = arrTabItems;\n}\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n ",
35
35
  "data": {
36
- "query": "{data:apps(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,code,icon_slds,visible,description,tabs,tab_items,tab_groups,objects,mobile_objects,is_creator,mobile,sort,url,is_use_ie,is_use_iframe,is_new_window,on_click,auth_name,secret,is_system,from_code_id,instance_state,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},_display{visible,is_creator,mobile,is_use_ie,is_use_iframe,is_new_window,is_system,instance_state,created,modified}}}"
36
+ "query": "{data:apps(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,name,code,icon_slds,visible, showSidebar, description,tabs,tab_items,tab_groups,objects,mobile_objects,is_creator,mobile,sort,url,is_use_ie,is_use_iframe,is_new_window,on_click,auth_name,secret,is_system,from_code_id,instance_state,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},_display{visible,is_creator,mobile,is_use_ie,is_use_iframe,is_new_window,is_system,instance_state,created,modified}}}"
37
37
  },
38
38
  "headers": {
39
39
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
@@ -157,6 +157,15 @@
157
157
  "labelClassName": "text-left",
158
158
  "id": "u:07a8a4c5f875"
159
159
  },
160
+ {
161
+ "name": "showSidebar",
162
+ "label": "菜单显示在左侧",
163
+ "type": "checkbox",
164
+ "tpl": null,
165
+ "className": "m-0",
166
+ "labelClassName": "text-left",
167
+ "id": "u:07a8a4c5f877"
168
+ },
160
169
  {
161
170
  "name": "description",
162
171
  "label": "描述",
@@ -356,6 +365,7 @@
356
365
  }
357
366
  }
358
367
  ],
368
+ "headerToolbarClassName": "px-1 py-3",
359
369
  "id": "crud_tab_items",
360
370
  "perPageAvailable": [
361
371
  10
@@ -524,7 +534,16 @@
524
534
  "script": "const data = context.props.data;\nif (!data._id) { \n return;\n}\nif (data.tab_items) {\n return;\n}\n\nconst tabOptions = data.tabs_options || [];\nconst tabItems = [];\n// 把应用中原来tabs属性值添加到新的tab_items属性的默认值中\nif (data.tabs && data.tabs.length) {\n data.tabs.forEach(function (item) {\n tabItems.push({ tab_name: item });\n });\n}\nconst pushObjectsToTabItems = function (objects) {\n objects.forEach(function (item) {\n // 已经有绑定到指定对象的选项卡就不添加\n let existObjectItem = !!tabItems.find(function (tabItem) {\n return !!tabOptions.find(function (option) {\n return tabItem.tab_name === tabItem.value && option.object === item;\n });\n });\n if (existObjectItem) {\n return;\n }\n // 找到指向指定对象的选项卡\n let tempOption = tabOptions.find(function (option) {\n return option.type === \"object\" && option.object === item;\n });\n if (!tempOption) {\n return;\n }\n // 选项卡名称如果重复了就不添加\n let existTabItem = !!tabItems.find(function (tabItem) {\n return tabItem.tab_name === tempOption.value;\n });\n if (existTabItem) {\n return;\n }\n if (tempOption) {\n tabItems.push({ tab_name: tempOption.value });\n }\n });\n}\n// 把应用中原来objects属性值添加到新的tab_items属性的默认值中\nif (data.objects && data.objects.length) {\n pushObjectsToTabItems(data.objects);\n}\n// 把应用中原来mobile_objects属性值添加到新的tab_items属性的默认值中\nif (data.mobile_objects && data.mobile_objects.length) {\n pushObjectsToTabItems(data.mobile_objects);\n}\n\ndoAction({\n actionType: 'setValue',\n args: {\n \"value\": { tab_items: tabItems }\n }\n});"
525
535
  }
526
536
  ]
527
- }
537
+ },
538
+ "submitSucc": {
539
+ "weight": 0,
540
+ "actions": [
541
+ {
542
+ "componentId": "listview_apps",
543
+ "actionType": "reload"
544
+ }
545
+ ]
546
+ }
528
547
  },
529
548
  "id": "apps-form"
530
549
  }
@@ -1,6 +1,4 @@
1
1
  name: apps_form
2
- __filename: >-
3
- /Users/yinlianghui/Documents/GitHub/steedos-platform2-3/services/service-plugin-amis/main/default/pages/apps_form.page.yml
4
2
  is_active: true
5
3
  label: 应用程序表单
6
4
  object_name: apps
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "requestAdaptor": "const formData = api.data.$;\napi.data = { objects: formData.objects };\nreturn api;",
22
22
  "responseData": null,
23
- "adaptor": "\nif (api.body.objectName === \"tabs\") {\n // 在tabs列表操作”对象选项卡“按钮,保存后需要刷新主列表\n refreshGrid && refreshGrid();\n}\nreturn payload;\n ",
23
+ "adaptor": "\nif (api.body.objectName === \"tabs\") {\n // 在tabs列表操作”对象选项卡“按钮,保存后需要刷新主列表\n}\nreturn payload;\n ",
24
24
  "headers": {
25
25
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
26
26
  }
@@ -63,7 +63,7 @@
63
63
  "actions": [
64
64
  {
65
65
  "actionType": "custom",
66
- "script": "const result = event.data.result;\nconst doneCount = result.data && result.data.doneCount || 0;\nconst myMsg = '已成功生成' + doneCount.toString() + \"条选项卡!\";\ndoAction({\n actionType: 'toast',\n args: {\n msg: myMsg,\n msgType: \"success\"\n }\n});\nconst errors = result.data && result.data.errors || [];\nif (errors && errors.length) { \n console.warn(\"以下对象未能生成选项卡:\");\n console.warn(JSON.stringify(errors));\n}\nconst superData = event.data.__super;\nif (superData && superData.objectName === \"apps\") { \n // 在应用表单中生成选项卡后需要触发选项卡列表组件reload重新刷新列表\n doAction({\n actionType: 'reload',\n componentId: \"tabs-options-service\"\n });\n}"
66
+ "script": "const result = event.data.result;\nconst doneCount = result.data && result.data.doneCount || 0;\nconst myMsg = '已成功生成' + doneCount.toString() + \"条选项卡!\";\ndoAction({\n actionType: 'toast',\n args: {\n msg: myMsg,\n msgType: \"success\"\n }\n});\nconst errors = result.data && result.data.errors || [];\nif (errors && errors.length) { \n console.warn(\"以下对象未能生成选项卡:\");\n console.warn(JSON.stringify(errors));\n}\nconst objectName = event.data.objectName;\nif (objectName === \"apps\") {\n // 在应用表单中生成选项卡后需要触发选项卡列表组件reload重新刷新列表\n doAction({\n actionType: 'reload',\n componentId: \"tabs-options-service\"\n });\n}\nelse {\n // 刷新主列表\n doAction({\n actionType: 'reload',\n componentId: `listview_${objectName}`\n });\n}"
67
67
  }
68
68
  ]
69
69
  }
@@ -75,6 +75,7 @@
75
75
  ],
76
76
  "data": {
77
77
  "context": {
78
+ "rootUrl": "http://127.0.0.1:5800"
78
79
  }
79
80
  },
80
81
  "id": "u:3b0de7e88def",
@@ -33,7 +33,7 @@
33
33
  "cache": 100,
34
34
  "adaptor": "var data = payload.data.data[0] || { _filters_type_controller: 'conditions' };\n//数据格式转换\nif (data) {\n data.columns = lodash.map(data.columns, 'field');\n data.sort = lodash.map(data.sort, (item) => {\n return `${item.field_name}:${item.order || 'asc'}`\n });\n data.mobile_columns = lodash.map(data.mobile_columns, 'field');\n data.searchable_fields = lodash.map(data.searchable_fields, 'field');\n\n if (data.filters && lodash.isString(data.filters)) {\n try {\n data.filters = JSON.parse(data.filters);\n }catch(e){}\n }\n\n if (data.filters && lodash.isString(data.filters)) {\n data._filters_type_controller = 'function';\n } else {\n data._filters_type_controller = 'conditions'\n }\n\n if (data._filters_type_controller === 'conditions') {\n data._filters_conditions = window.amisConvert.filtersToConditions(data.filters || []);\n } else {\n data._filters_function = data.filters;\n }\n}\npayload.data = data;\ndelete payload.extensions;\nreturn payload;",
35
35
  "data": {
36
- "query": "{data:object_listviews(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,label,name,object_name,filter_scope,shared,show_count,columns,filter_fields,sort,filters,filter_logic,mobile_columns,searchable_fields,sort_no,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},enable_amis_schema,amis_schema,_display{shared,show_count,created,modified}}}"
36
+ "query": "{data:object_listviews(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,label,name,object_name,requestAdaptor,adaptor,filter_scope,shared,show_count,columns,filter_fields,sort,filters,filter_logic,mobile_columns,searchable_fields,sort_no,created,created_by:created_by__expand{_id,name},modified,modified_by:modified_by__expand{_id,name},enable_amis_schema,amis_schema,_display{shared,show_count,created,modified}}}"
37
37
  },
38
38
  "sendOn": "!!this.recordId",
39
39
  "replaceData": false,
@@ -442,6 +442,39 @@
442
442
  "title": "searchable"
443
443
  }
444
444
  },
445
+ {
446
+ "type": "fieldSet",
447
+ "title": "数据接口",
448
+ "description": "获取列表数据的 api",
449
+ "collapsable": true,
450
+ "body": [
451
+ {
452
+ "type": "editor",
453
+ "name": "requestAdaptor",
454
+ "label": "发送适配器",
455
+ "required": false,
456
+ "language": "javascript",
457
+ "description": "函数签名:(api) => api, 数据在 api.data 中,修改后返回 api 对象。",
458
+ "className": "col-span-2 m-1",
459
+ "labelClassName": "text-left"
460
+ },
461
+ {
462
+ "type": "editor",
463
+ "name": "adaptor",
464
+ "label": "接收适配器",
465
+ "required": false,
466
+ "language": "javascript",
467
+ "description": "函数签名: (payload, response, api) => payload",
468
+ "className": "col-span-2 m-1",
469
+ "labelClassName": "text-left"
470
+ }
471
+ ],
472
+ "collapsed": true,
473
+ "visibleOn": "!!this.object_name",
474
+ "en-US": {
475
+ "title": "API"
476
+ }
477
+ },
445
478
  {
446
479
  "type": "fieldSet",
447
480
  "title": "高级",
@@ -836,24 +836,7 @@
836
836
  ],
837
837
  "panelClassName": "m-0 -mt-3",
838
838
  "bodyClassName": "p-4",
839
- "actions": [
840
- {
841
- "type": "button",
842
- "label": "取消",
843
- "actionType": "",
844
- "level": "default",
845
- "block": false,
846
- "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
847
- "id": "u:bf2587b53d64"
848
- },
849
- {
850
- "type": "button",
851
- "label": "保存",
852
- "actionType": "submit",
853
- "level": "info",
854
- "id": "u:08afd6e53cab"
855
- }
856
- ],
839
+ "actions": [],
857
840
  "actionsClassName": "p-sm b-t b-light text-center",
858
841
  "className": "steedos-amis-form",
859
842
  "checkAll": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-plugin-amis",
3
- "version": "2.4.0-beta.3",
3
+ "version": "2.4.0-beta.30",
4
4
  "main": "package.service.js",
5
5
  "scripts": {
6
6
  "build": "yarn build:tailwind-base && yarn build:tailwind",
@@ -14,7 +14,10 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@steedos-widgets/amis-lib": "^1.0.10"
17
+ "@steedos-widgets/amis-lib": "^1.0.22"
18
18
  },
19
- "gitHead": "1c901ac5b13f425f28aedf0f1bf61199f0012663"
19
+ "gitHead": "22c0cf80236640dac2c2a85b7a209355ef00e57c",
20
+ "devDependencies": {
21
+ "tailwindcss": "3.2.4"
22
+ }
20
23
  }
@@ -13,10 +13,6 @@
13
13
  vertical-align: initial !important;
14
14
  } */
15
15
 
16
- body{
17
- -webkit-font-smoothing: inherit !important;
18
- }
19
-
20
16
  /* .row-main{
21
17
  border-radius: 0.25rem
22
18
  } */
@@ -52,15 +48,6 @@ body{
52
48
  min-width: 100px;
53
49
  }
54
50
 
55
- .steedos-amis-form .antd-Collapse .antd-Form--normal, .antd-Form--normal .antd-Tabs .antd-Tabs-content .antd-Tabs-pane .form-content{
56
- display: grid!important;
57
- grid-template-columns: repeat(2,minmax(0,1fr))!important;
58
- grid-row-gap: 1rem!important;
59
- row-gap: 1rem!important;
60
- grid-column-gap: 1.5rem!important;
61
- -moz-column-gap: 1.5rem!important;
62
- column-gap: 1.5rem!important;
63
- }
64
51
 
65
52
  /* fix checkbox 隐藏时导致滚动条异常 */
66
53
  .steedos-amis-form .antd-Collapse .antd-Form--normal .antd-Checkbox input{
@@ -76,10 +63,6 @@ body{
76
63
  border-bottom: none;
77
64
  }
78
65
 
79
- .steedos-amis-form .antd-Collapse .antd-Form--normal{
80
- grid-template-columns: none !important;
81
- }
82
-
83
66
  .ant-modal-root .amis-scope .antd-Panel-footerWrap{
84
67
  position: fixed;
85
68
  }
@@ -105,7 +88,3 @@ body{
105
88
  .ant-message{
106
89
  z-index: 2600;
107
90
  }
108
-
109
- .page-list-view-root .amis-scope .antd-Table-headToolbar{
110
- display: none;
111
- }
@@ -54,10 +54,6 @@ body.steedos .absolute {
54
54
  position: absolute
55
55
  }
56
56
 
57
- body.steedos .relative {
58
- position: relative
59
- }
60
-
61
57
  body.steedos .sticky {
62
58
  position: sticky
63
59
  }
@@ -85,12 +81,22 @@ body.steedos .col-span-2 {
85
81
  grid-column: span 2 / span 2
86
82
  }
87
83
 
84
+ body.steedos .m-1 {
85
+ margin: 0.25rem
86
+ }
87
+
88
88
  body.steedos .m-0 {
89
89
  margin: 0px
90
90
  }
91
91
 
92
- body.steedos .m-1 {
93
- margin: 0.25rem
92
+ body.steedos .mx-4 {
93
+ margin-left: 1rem;
94
+ margin-right: 1rem
95
+ }
96
+
97
+ body.steedos .my-2 {
98
+ margin-top: 0.5rem;
99
+ margin-bottom: 0.5rem
94
100
  }
95
101
 
96
102
  body.steedos .mr-4 {
@@ -117,6 +123,10 @@ body.steedos .-mt-3 {
117
123
  margin-top: -0.75rem
118
124
  }
119
125
 
126
+ body.steedos .mt-3 {
127
+ margin-top: 0.75rem
128
+ }
129
+
120
130
  body.steedos .block {
121
131
  display: block
122
132
  }
@@ -149,10 +159,6 @@ body.steedos .h-\[50px\] {
149
159
  height: 50px
150
160
  }
151
161
 
152
- body.steedos .h-7 {
153
- height: 1.75rem
154
- }
155
-
156
162
  body.steedos .h-10 {
157
163
  height: 2.5rem
158
164
  }
@@ -186,20 +192,16 @@ body.steedos .min-w-max {
186
192
  min-width: max-content
187
193
  }
188
194
 
189
- body.steedos .flex-none {
190
- flex: none
191
- }
192
-
193
195
  body.steedos .flex-1 {
194
196
  flex: 1 1 0%
195
197
  }
196
198
 
197
- body.steedos .-translate-x-0 {
198
- --tw-translate-x: -0px;
199
- transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
199
+ body.steedos .flex-none {
200
+ flex: none
200
201
  }
201
202
 
202
- body.steedos .transform {
203
+ body.steedos .-translate-x-0 {
204
+ --tw-translate-x: -0px;
203
205
  transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))
204
206
  }
205
207
 
@@ -228,6 +230,10 @@ body.steedos .gap-x-3 {
228
230
  column-gap: 0.75rem
229
231
  }
230
232
 
233
+ body.steedos .overflow-hidden {
234
+ overflow: hidden
235
+ }
236
+
231
237
  body.steedos .overflow-y-auto {
232
238
  overflow-y: auto
233
239
  }
@@ -240,10 +246,19 @@ body.steedos .border-r {
240
246
  border-right-width: 1px
241
247
  }
242
248
 
249
+ body.steedos .border-b {
250
+ border-bottom-width: 1px
251
+ }
252
+
243
253
  body.steedos .border-solid {
244
254
  border-style: solid
245
255
  }
246
256
 
257
+ body.steedos .border-slate-300 {
258
+ --tw-border-opacity: 1;
259
+ border-color: rgb(203 213 225 / var(--tw-border-opacity))
260
+ }
261
+
247
262
  body.steedos .border-sky-500 {
248
263
  --tw-border-opacity: 1;
249
264
  border-color: rgb(14 165 233 / var(--tw-border-opacity))
@@ -259,10 +274,6 @@ body.steedos .bg-white {
259
274
  background-color: rgb(255 255 255 / var(--tw-bg-opacity))
260
275
  }
261
276
 
262
- body.steedos .p-3 {
263
- padding: 0.75rem
264
- }
265
-
266
277
  body.steedos .p-0 {
267
278
  padding: 0px
268
279
  }
@@ -276,6 +287,21 @@ body.steedos .px-4 {
276
287
  padding-right: 1rem
277
288
  }
278
289
 
290
+ body.steedos .px-0 {
291
+ padding-left: 0px;
292
+ padding-right: 0px
293
+ }
294
+
295
+ body.steedos .px-1 {
296
+ padding-left: 0.25rem;
297
+ padding-right: 0.25rem
298
+ }
299
+
300
+ body.steedos .py-3 {
301
+ padding-top: 0.75rem;
302
+ padding-bottom: 0.75rem
303
+ }
304
+
279
305
  body.steedos .px-10 {
280
306
  padding-left: 2.5rem;
281
307
  padding-right: 2.5rem
@@ -286,6 +312,10 @@ body.steedos .py-2 {
286
312
  padding-bottom: 0.5rem
287
313
  }
288
314
 
315
+ body.steedos .pr-4 {
316
+ padding-right: 1rem
317
+ }
318
+
289
319
  body.steedos .pl-4 {
290
320
  padding-left: 1rem
291
321
  }
@@ -294,8 +324,16 @@ body.steedos .pb-0 {
294
324
  padding-bottom: 0px
295
325
  }
296
326
 
297
- body.steedos .pt-2 {
298
- padding-top: 0.5rem
327
+ body.steedos .pt-4 {
328
+ padding-top: 1rem
329
+ }
330
+
331
+ body.steedos .pb-16 {
332
+ padding-bottom: 4rem
333
+ }
334
+
335
+ body.steedos .pb-4 {
336
+ padding-bottom: 1rem
299
337
  }
300
338
 
301
339
  body.steedos .pl-1\.5 {
@@ -339,6 +377,12 @@ body.steedos .underline {
339
377
  text-decoration-line: underline
340
378
  }
341
379
 
380
+ body.steedos .shadow-none {
381
+ --tw-shadow: 0 0 #0000;
382
+ --tw-shadow-colored: 0 0 #0000;
383
+ box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)
384
+ }
385
+
342
386
  body.steedos .filter {
343
387
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)
344
388
  }
@@ -368,14 +412,34 @@ body.steedos .ease-in-out {
368
412
  }
369
413
 
370
414
  @media (min-width: 640px) {
371
- body.steedos .sm\:flex {
372
- display: flex
415
+ body.steedos .sm\:m-3 {
416
+ margin: 0.75rem
417
+ }
418
+
419
+ body.steedos .sm\:mt-\[90px\] {
420
+ margin-top: 90px
373
421
  }
374
422
 
375
423
  body.steedos .sm\:w-\[220px\] {
376
424
  width: 220px
377
425
  }
378
426
 
427
+ body.steedos .sm\:rounded {
428
+ border-radius: 0.25rem
429
+ }
430
+
431
+ body.steedos .sm\:rounded-lg {
432
+ border-radius: 0.5rem
433
+ }
434
+
435
+ body.steedos .sm\:border {
436
+ border-width: 1px
437
+ }
438
+
439
+ body.steedos .sm\:p-3 {
440
+ padding: 0.75rem
441
+ }
442
+
379
443
  body.steedos .sm\:shadow {
380
444
  --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
381
445
  --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
@@ -282,8 +282,8 @@
282
282
  "Editor.fullscreen": "全屏",
283
283
  "Editor.exitFullscreen": "退出全屏",
284
284
  "Condition.not": "非",
285
- "Condition.and": "并且",
286
- "Condition.or": "或者",
285
+ "Condition.and": "",
286
+ "Condition.or": "",
287
287
  "Condition.add_cond": "添加条件",
288
288
  "Condition.add_cond_group": "添加条件组",
289
289
  "Condition.delete_cond_group": "删除组",
@@ -1,11 +0,0 @@
1
- name: render_engine
2
- type: select
3
- label: 渲染器
4
- defaultValue: amis
5
- options:
6
- - label: Amis
7
- value: amis
8
- - label: Redash
9
- value: redash
10
- required: true
11
- sort_no: 125
@@ -1,2 +0,0 @@
1
- extend: pages
2
- name: pages