@steedos/service-plugin-amis 2.3.0-beta.13 → 2.3.0-beta.16

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.
@@ -2,55 +2,55 @@
2
2
  "type": "page",
3
3
  "body": [
4
4
  {
5
- "type": "service",
6
- "className": "col-span-2 m-0",
7
- "id": "u:ac5b7818b88f",
8
- "affixFooter": false,
5
+ "className": "steedos-amis-form",
6
+ "type": "form",
7
+ "mode": "normal",
8
+ "persistData": false,
9
+ "promptPageLeave": true,
10
+ "name": "form_edit_${recordId}",
11
+ "title": "",
9
12
  "api": {
10
- "method": "get",
13
+ "method": "post",
11
14
  "url": "${context.rootUrl}/graphql",
12
- "adaptor": "const registerFilter = amisRequire('amis').registerFilter;\nconst tabGroupKey = \"group\";\nconst getTabsSortFun = function(groupNames){\n return function(m,n){\n var tempM = !!m[tabGroupKey] ? 1 : 0;\n var tempN = !!n[tabGroupKey] ? 1 : 0;\n if(!m[tabGroupKey] || !n[tabGroupKey]){\n // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\n// 把”选择字段“弹出窗口中设置的字段转为主表单tabs字段值格式\nregisterFilter('convertDataForTabs', function (input) {\n let pickedTabs = input.picked_tabs || [];\n const superTabs = _.keyBy(input.__super.tab_items, 'tab_name');\n if(typeof pickedTabs === \"string\"){\n pickedTabs = pickedTabs.split(\",\");\n }\n const tabOptions = lodash.keyBy(this.data.__super.__super.__super.__super.__super.tabs_options, \"value\");\n const convertedTabs = pickedTabs.map(function (tab_name) {\n const superTab = superTabs[tab_name];\n if (superTab) {\n return superTab;\n }\n else {\n const tabOption = tabOptions[tab_name];\n return {\n tab_name: tab_name,\n group: tabOption.group\n }\n }\n });\n const tabGroups = this.data.__super.__super.__super.__super.__super.tab_groups;\n const groupNames = lodash.compact(lodash.map(tabGroups,\"group_name\"));\n // tabs重新按分组排序\n convertedTabs.sort(getTabsSortFun(groupNames));\n return {\n tab_items: convertedTabs\n }\n});\n\n// 字段列表每一列数据变量时立即同步值到表单中\nregisterFilter('quickEidtSaveForTab', function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input.__super;\n const formValue = input.__super.__super.__super;\n const tab_name = rowValue.tab_name;\n rowValue[prop_name] = currentPropValue;\n let newTabs = formValue.tab_items.map(function (item) {\n if (item.tab_name == tab_name) {\n return Object.assign({}, item, rowValue);\n }\n else { \n return item;\n }\n });\n const tabGroups = this.data.__super.__super.tab_groups;\n const groupNames = lodash.compact(lodash.map(tabGroups,\"group_name\"));\n // tabs重新按分组排序\n newTabs.sort(getTabsSortFun(groupNames));\n return {\n tab_items: newTabs\n }\n});\n\n// 清空主表单tabs字段值\nregisterFilter('clearTabs', function (input) {\n return {\n tab_items: []\n }\n});\n\n// 把”设置分组“弹出窗口中设置的分组转为主表单groups字段值格式\n// 同时根据新的groups排序重新设置tabs属性的字段先后次序\n// 因为直接设置tabs值有bug,即新值老值会串,所以需要先执行上面的clearTabs清除原来的值\nregisterFilter('convertDataForGroups', function (input) {\n const settingGroups = input.setting_groups || [];\n const convertedGroups = lodash.uniqBy(settingGroups.map(function (item) {\n return {\n group_name: item.group_name\n }\n }), \"group_name\");\n\n const groupNames = lodash.compact(lodash.map(convertedGroups,\"group_name\"));\n const tab_items = this.data.__super.__super.items;\n // tabs重新按分组排序\n tab_items.sort(getTabsSortFun(groupNames));\n\n return {\n tab_groups: convertedGroups,\n tab_items: tab_items\n }\n});\n\nlet data = payload.data;\ndata.tabs_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
13
15
  "data": {
14
- "query": "{options:tabs{_id label:label value:name,type,object,desktop,mobile}}"
16
+ "$": "$$",
17
+ "recordId": "${recordId}",
18
+ "modalName": "${modalName}",
19
+ "objectName": "${objectName}"
20
+ },
21
+ "requestAdaptor": "\nconst formData = api.data.$;\nfor (key in formData){\n // image、select等字段清空值后保存的空字符串转换为null。\n if(formData[key] === ''){\n formData[key] = null;\n }\n}\nconst objectName = api.data.objectName;\nconst fieldsName = Object.keys(formData);\ndelete formData.created;\ndelete formData.created_by;\ndelete formData.modified;\ndelete formData.modified_by;\ndelete formData._display;\ndelete formData.tabs_options;\ndelete formData.tab_groups_options;\n\n// 新加字段tab_items,值同步回传到老字段tabs中兼容老UI界面\nformData.tabs = [];\nif (formData.tab_items && formData.tab_items.length) { \n formData.tabs = formData.tab_items.map(function (item) { return item.tab_name; });\n}\n\nlet query = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\nif(formData.recordId){\n query = `mutation{record: ${objectName}__update(id: \"${formData.recordId}\", doc: {__saveData}){_id}}`;\n};\ndelete formData._id;\nlet __saveData = JSON.stringify(JSON.stringify(formData));\n\napi.data = {query: query.replace('{__saveData}', __saveData)};\nreturn api;\n",
22
+ "responseData": {
23
+ "recordId": "${record._id}"
15
24
  },
16
- "sendOn": ""
25
+ "adaptor": "\n SteedosUI.getRef(api.body.modalName).close();\n SteedosUI.router.go({objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit': 'new'});\n return payload;\n "
26
+ },
27
+ "initApi": {
28
+ "method": "post",
29
+ "url": "${context.rootUrl}/graphql",
30
+ "sendOn": "!!this.recordId",
31
+ "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};\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n ",
32
+ "data": {
33
+ "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}}}"
34
+ }
17
35
  },
36
+ "initFetch": true,
18
37
  "body": [
19
38
  {
20
- "className": "steedos-amis-form",
21
- "id": "apps-form",
22
- "type": "form",
23
- "mode": "normal",
24
- "persistData": false,
25
- "promptPageLeave": true,
26
- "name": "form_edit_${recordId}",
27
- "title": "",
39
+ "type": "service",
40
+ "className": "col-span-2 m-0",
41
+ "id": "tabs-options-service",
42
+ "affixFooter": false,
28
43
  "api": {
29
44
  "method": "post",
30
45
  "url": "${context.rootUrl}/graphql",
46
+ "adaptor": "let data = payload.data;\ndata.tabs_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
31
47
  "data": {
32
- "objectName": "${objectName}",
33
- "$": "$$",
34
- "recordId": "${recordId}",
35
- "modalName": "${modalName}"
36
- },
37
- "requestAdaptor": "\nconst formData = api.data.$;\nfor (key in formData){\n // image、select等字段清空值后保存的空字符串转换为null。\n if(formData[key] === ''){\n formData[key] = null;\n }\n}\nconst objectName = api.data.objectName;\nconst fieldsName = Object.keys(formData);\ndelete formData.created;\ndelete formData.created_by;\ndelete formData.modified;\ndelete formData.modified_by;\ndelete formData._display;\ndelete formData.tabs_options;\ndelete formData.tab_groups_options;\n\n// 新加字段tab_items,值同步回传到老字段tabs中兼容老UI界面\nformData.tabs = [];\nif (formData.tab_items && formData.tab_items.length) { \n formData.tabs = formData.tab_items.map(function (item) { return item.tab_name; });\n}\n\nlet query = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\nif(formData.recordId){\n query = `mutation{record: ${objectName}__update(id: \"${formData.recordId}\", doc: {__saveData}){_id}}`;\n};\ndelete formData._id;\nlet __saveData = JSON.stringify(JSON.stringify(formData));\n\napi.data = {query: query.replace('{__saveData}', __saveData)};\nreturn api;\n",
38
- "responseData": {
39
- "recordId": "${record._id}"
48
+ "query": "{options:tabs{_id label:label value:name,type,object,desktop,mobile}}"
40
49
  },
41
- "adaptor": "\n SteedosUI.getRef(api.body.modalName).close();\n SteedosUI.router.go({objectName: api.body.objectName, recordId: payload.data.record._id, type: api.body.recordId ? 'edit': 'new'});\n return payload;\n "
42
- },
43
- "initApi": {
44
- "method": "post",
45
- "url": "${context.rootUrl}/graphql",
46
- "sendOn": "!!this.recordId",
47
- "cache": 100,
48
- "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 // if (!data.tab_items) {\n // debugger;\n // const tabOptions = data.tabs_options || [];\n // const tabItems = [];\n // // 把应用中原来tabs属性值添加到新的tab_items属性的默认值中\n // if (data.tabs && data.tabs.length) { \n // data.tabs.forEach(function (item) {\n // tabItems.push({ tab_name: item });\n // });\n // }\n // const pushObjectsToTabItems = function (objects) {\n // objects.forEach(function (item) {\n // // 已经有绑定到指定对象的选项卡就不添加\n // let existObjectItem = !!tabItems.find(function (tabItem) {\n // return !!tabOptions.find(function (option) {\n // return 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属性的默认值中\n // if (data.objects && data.objects.length) {\n // pushObjectsToTabItems(data.objects);\n // }\n // // 把应用中原来mobile_objects属性值添加到新的tab_items属性的默认值中\n // if (data.mobile_objects && data.mobile_objects.length) {\n // pushObjectsToTabItems(data.mobile_objects);\n // }\n // console.log(\"===tabItems==\", tabItems);\n // data.tab_items = tabItems;\n // }\n};\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n ",
49
- "data": {
50
- "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}}}"
51
- }
50
+ "sendOn": ""
52
51
  },
53
- "initFetch": true,
52
+ "messages": {},
53
+ "placeholder": "-",
54
54
  "body": [
55
55
  {
56
56
  "type": "tabs",
@@ -133,7 +133,7 @@
133
133
  "multiple": true,
134
134
  "checkAll": false,
135
135
  "searchable": true,
136
- "autoComplete": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/options"
136
+ "source": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/options"
137
137
  },
138
138
  {
139
139
  "name": "mobile_objects",
@@ -149,7 +149,7 @@
149
149
  "multiple": true,
150
150
  "checkAll": false,
151
151
  "searchable": true,
152
- "autoComplete": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/options"
152
+ "source": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/options"
153
153
  },
154
154
  {
155
155
  "name": "description",
@@ -162,7 +162,7 @@
162
162
  },
163
163
  {
164
164
  "name": "is_creator",
165
- "label": "显示在桌面菜单中",
165
+ "label": "在桌面中显示此应用",
166
166
  "type": "checkbox",
167
167
  "className": "m-0",
168
168
  "labelClassName": "text-left",
@@ -171,7 +171,7 @@
171
171
  },
172
172
  {
173
173
  "name": "mobile",
174
- "label": "显示在手机菜单中",
174
+ "label": "在手机上显示此应用",
175
175
  "type": "checkbox",
176
176
  "className": "m-0",
177
177
  "labelClassName": "text-left",
@@ -211,6 +211,14 @@
211
211
  "removable": true,
212
212
  "draggable": false,
213
213
  "columns": [
214
+ {
215
+ "name": "index",
216
+ "label": "序号",
217
+ "type": "static",
218
+ "value": "${index + 1}",
219
+ "className": "w-10",
220
+ "id": "u:c59784421c37"
221
+ },
214
222
  {
215
223
  "name": "tab_name_label",
216
224
  "label": "选项卡",
@@ -224,23 +232,14 @@
224
232
  "id": "u:e532b1949676",
225
233
  "quickEdit": {
226
234
  "type": "select",
235
+ "name": "group",
227
236
  "className": "m-0",
228
237
  "onEvent": {
229
238
  "change": {
230
239
  "actions": [
231
240
  {
232
- "actionType": "setValue",
233
- "args": {
234
- "value": "${event.data|clearTabs}"
235
- },
236
- "componentId": "apps-form"
237
- },
238
- {
239
- "actionType": "setValue",
240
- "args": {
241
- "value": "${event.data|quickEidtSaveForTab:group}"
242
- },
243
- "componentId": "apps-form"
241
+ "actionType": "custom",
242
+ "script": "const tabGroupKey = \"group\";\nconst getTabsSortFun = function (groupNames) {\n return function (m, n) {\n var tempM = !!m[tabGroupKey] ? 1 : 0;\n var tempN = !!n[tabGroupKey] ? 1 : 0;\n if (!m[tabGroupKey] || !n[tabGroupKey]) {\n // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) {\n return {\n tab_items: []\n }\n}\n\n// 字段列表每一列数据变量时立即同步值到表单中\nconst quickEidtSaveForTab = function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input.__super;\n const formValue = input.__super.__super.__super;\n const tab_name = rowValue.tab_name;\n rowValue[prop_name] = currentPropValue;\n delete rowValue.index;\n let newTabs = formValue.tab_items.map(function (item) {\n if (item.tab_name == tab_name) {\n return Object.assign({}, item, rowValue);\n }\n else {\n return item;\n }\n });\n const tabGroups = input.__super.__super.tab_groups;\n const groupNames = lodash.compact(lodash.map(tabGroups, \"group_name\"));\n if (groupNames && groupNames.length) {\n // tabs重新按分组排序\n newTabs.sort(getTabsSortFun(groupNames));\n }\n return {\n tab_items: newTabs\n }\n}\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: clearTabs()\n }\n});\n\nconst newTabTtemsProp = quickEidtSaveForTab(eventData, \"group\");\n\nsetTimeout(function () { \n // 不加延时会显示异常\n doAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: newTabTtemsProp\n }\n });\n},300);"
244
243
  }
245
244
  ]
246
245
  }
@@ -249,8 +248,12 @@
249
248
  "checkAll": false,
250
249
  "selectFirst": false,
251
250
  "searchable": true,
252
- "clearable": true
253
- }
251
+ "clearable": true,
252
+ "id": "u:8b3d6979e884",
253
+ "multiple": false,
254
+ "mode": "popOver"
255
+ },
256
+ "placeholder": "-"
254
257
  },
255
258
  {
256
259
  "name": "tab_name_desktop",
@@ -281,13 +284,12 @@
281
284
  "label": "生成选项卡",
282
285
  "id": "u:a35a2276145d",
283
286
  "tpl": "内容",
284
- "actionType": "custom",
285
287
  "onEvent": {
286
288
  "click": {
287
289
  "actions": [
288
290
  {
289
291
  "actionType": "custom",
290
- "script": "const appId = null;\nconst page = Steedos.Page.getPage('app', appId, null, null, \"generate_object_tabs\");\nconst title = \"选择需要生成选项卡的对象\";\nif (page && page.schema) {\n Steedos.Page.render(SteedosUI.Modal, page, Object.assign({}, {\n appId: null,\n objectName: null,\n title: title\n }));\n}"
292
+ "script": "const appId = null;\nconst page = Steedos.Page.getPage('app', appId, null, null, \"generate_object_tabs\");\nconst title = \"选择需要生成选项卡的对象\";\nif (page && page.schema) {\n Steedos.Page.render(SteedosUI.Modal, page, Object.assign({}, {\n appId: null,\n objectName: \"apps\",\n title: title\n }));\n}"
291
293
  }
292
294
  ],
293
295
  "weight": 0
@@ -296,8 +298,11 @@
296
298
  },
297
299
  {
298
300
  "type": "button",
301
+ "label": "设置选项卡",
302
+ "id": "u:853b890ab524",
299
303
  "actionType": "dialog",
300
304
  "dialog": {
305
+ "type": "dialog",
301
306
  "title": "设置选项卡",
302
307
  "body": [
303
308
  {
@@ -306,32 +311,26 @@
306
311
  "value": "${tab_items|pick:tab_name}",
307
312
  "sortable": true,
308
313
  "source": "${tabs_options}",
309
- "searchable": true
314
+ "searchable": true,
315
+ "id": "u:f2d36873abd1"
310
316
  }
311
317
  ],
312
318
  "onEvent": {
313
319
  "confirm": {
314
320
  "actions": [
315
321
  {
316
- "actionType": "setValue",
317
- "args": {
318
- "value": "${event.data|clearTabs}"
319
- },
320
- "componentId": "apps-form"
321
- },
322
- {
323
- "actionType": "setValue",
324
- "args": {
325
- "value": "${event.data|convertDataForTabs}"
326
- },
327
- "componentId": "apps-form"
322
+ "actionType": "custom",
323
+ "script": "const tabGroupKey = \"group\";\nconst getTabsSortFun = function (groupNames) {\n return function (m, n) {\n var tempM = !!m[tabGroupKey] ? 1 : 0;\n var tempN = !!n[tabGroupKey] ? 1 : 0;\n if (!m[tabGroupKey] || !n[tabGroupKey]) {\n // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) { \n return {\n tab_items: []\n }\n}\n\nconst convertDataForTabs = function (input) { \n let pickedTabs = input.picked_tabs || [];\n const superTabs = _.keyBy(input.__super.tab_items, 'tab_name');\n if (typeof pickedTabs === \"string\") {\n pickedTabs = pickedTabs.split(\",\");\n }\n const tabOptions = lodash.keyBy(input.__super.__super.__super.__super.__super.tabs_options, \"value\");\n const convertedTabs = pickedTabs.map(function (tab_name) {\n const superTab = superTabs[tab_name];\n if (superTab) {\n return superTab;\n }\n else {\n const tabOption = tabOptions[tab_name];\n return {\n tab_name: tab_name,\n group: tabOption.group\n }\n }\n });\n const tabGroups = input.__super.__super.__super.__super.__super.tab_groups;\n const groupNames = lodash.compact(lodash.map(tabGroups, \"group_name\"));\n // tabs重新按分组排序\n if (groupNames && groupNames.length) { \n convertedTabs.sort(getTabsSortFun(groupNames));\n }\n return {\n tab_items: convertedTabs\n }\n}\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: clearTabs()\n }\n});\n\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: convertDataForTabs(eventData)\n }\n});\n\n"
328
324
  }
329
325
  ]
330
326
  }
331
- }
332
- },
333
- "label": "设置选项卡",
334
- "id": "u:853b890ab524"
327
+ },
328
+ "size": "lg",
329
+ "id": "u:9c93896a73cf",
330
+ "closeOnEsc": false,
331
+ "closeOnOutside": false,
332
+ "showCloseButton": true
333
+ }
335
334
  },
336
335
  {
337
336
  "type": "button",
@@ -344,48 +343,47 @@
344
343
  {
345
344
  "type": "input-table",
346
345
  "name": "setting_groups",
346
+ "value": "${tab_groups}",
347
347
  "addable": true,
348
348
  "draggable": true,
349
349
  "editable": true,
350
350
  "columns": [
351
351
  {
352
352
  "name": "group_name",
353
- "label": "名称"
353
+ "label": "名称",
354
+ "id": "u:383c7744b499"
354
355
  }
355
356
  ],
356
- "value": "${tab_groups}",
357
- "removable": true
357
+ "removable": true,
358
+ "id": "u:06bbf5c4dc98"
358
359
  }
359
360
  ],
360
361
  "onEvent": {
361
362
  "confirm": {
362
363
  "actions": [
363
364
  {
364
- "actionType": "setValue",
365
- "args": {
366
- "value": "${event.data|clearTabs}"
367
- },
368
- "componentId": "apps-form"
369
- },
370
- {
371
- "actionType": "setValue",
372
- "args": {
373
- "value": "${event.data|convertDataForGroups}"
374
- },
375
- "componentId": "apps-form"
365
+ "actionType": "custom",
366
+ "script": "const tabGroupKey = \"group\";\nconst getTabsSortFun = function (groupNames) {\n return function (m, n) {\n var tempM = !!m[tabGroupKey] ? 1 : 0;\n var tempN = !!n[tabGroupKey] ? 1 : 0;\n if (!m[tabGroupKey] || !n[tabGroupKey]) {\n // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]);\n };\n}\n\nconst clearTabs = function (input) {\n return {\n tab_items: []\n }\n}\n\n// 把”设置分组“弹出窗口中设置的分组转为主表单groups字段值格式\n// 同时根据新的groups排序重新设置tabs属性的字段先后次序\n// 因为直接设置tabs值有bug,即新值老值会串,所以需要先执行上面的clearTabs清除原来的值\nconst convertDataForGroups = function(input) {\n const settingGroups = input.setting_groups || [];\n const convertedGroups = lodash.uniqBy(settingGroups.map(function (item) {\n return {\n group_name: item.group_name\n }\n }), \"group_name\");\n\n const groupNames = lodash.compact(lodash.map(convertedGroups, \"group_name\"));\n const tab_items = input.__super.__super.items;\n // tabs重新按分组排序\n tab_items.sort(getTabsSortFun(groupNames));\n\n return {\n tab_groups: convertedGroups,\n tab_items: tab_items\n }\n};\n\nconst eventData = event.data;\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: clearTabs()\n }\n});\n\ndoAction({\n actionType: 'setValue',\n componentId: \"apps-form\",\n args: {\n value: convertDataForGroups(eventData)\n }\n});\n\n"
376
367
  }
377
368
  ]
378
369
  }
379
370
  },
380
- "type": "dialog"
371
+ "type": "dialog",
372
+ "size": "lg",
373
+ "id": "u:55db530e3f86",
374
+ "closeOnEsc": false,
375
+ "closeOnOutside": false,
376
+ "showCloseButton": true
381
377
  }
382
378
  }
383
379
  ],
384
- "id": "u:22121edc42b1",
380
+ "id": "crud_tab_items",
385
381
  "perPageAvailable": [
386
382
  10
387
383
  ],
388
- "messages": {}
384
+ "messages": {},
385
+ "visible": "typeof this.visibleOn === \"string\" ? 2 : 1",
386
+ "visibleOn": " !!this.tabs_options"
389
387
  }
390
388
  ],
391
389
  "id": "u:d5b736e2a2f5",
@@ -473,43 +471,42 @@
473
471
  "className": "",
474
472
  "contentClassName": ""
475
473
  }
476
- ],
477
- "panelClassName": "m-0 -mt-3",
474
+ ]
475
+ }
476
+ ],
477
+ "panelClassName": "m-0 -mt-3",
478
+ "actions": [
479
+ {
480
+ "type": "button",
481
+ "label": "取消",
482
+ "actionType": "",
483
+ "level": "default",
484
+ "block": false,
485
+ "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
486
+ "id": "u:f2208dc2b4cd"
487
+ },
488
+ {
489
+ "type": "button",
490
+ "label": "保存",
491
+ "actionType": "submit",
492
+ "level": "info",
493
+ "id": "u:207386fce204"
494
+ }
495
+ ],
496
+ "actionsClassName": "p-sm b-t b-light text-center",
497
+ "affixFooter": false,
498
+ "debug": false,
499
+ "onEvent": {
500
+ "inited": {
478
501
  "actions": [
479
502
  {
480
- "type": "button",
481
- "label": "取消",
482
- "actionType": "",
483
- "level": "default",
484
- "block": false,
485
- "onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
486
- "id": "u:f2208dc2b4cd"
487
- },
488
- {
489
- "type": "button",
490
- "label": "保存",
491
- "actionType": "submit",
492
- "level": "info",
493
- "id": "u:207386fce204"
503
+ "actionType": "custom",
504
+ "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});"
494
505
  }
495
- ],
496
- "actionsClassName": "p-sm b-t b-light text-center",
497
- "affixFooter": false,
498
- "debug": false,
499
- "onEvent": {
500
- "inited": {
501
- "actions": [
502
- {
503
- "actionType": "custom",
504
- "script": "const data = context.props.data;\nconst superData = data.__super;\nif (!data._id) { \n return;\n}\nif (data.tab_items) {\n return;\n}\n\ndebugger;\nconst tabOptions = superData.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}\nconsole.log(\"===tabItems==\", tabItems);\n// data.tab_items = tabItems;\n\ndoAction({\n actionType: 'setValue',\n args: {\n \"value\": { tab_items: tabItems }\n }\n});"
505
- }
506
- ]
507
- }
508
- }
506
+ ]
509
507
  }
510
- ],
511
- "messages": {},
512
- "placeholder": "-"
508
+ },
509
+ "id": "apps-form"
513
510
  }
514
511
  ],
515
512
  "regions": [
@@ -13,11 +13,14 @@
13
13
  "url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/generate/tabs",
14
14
  "data": {
15
15
  "objects": "${objects}",
16
- "modalName": "${modalName}"
16
+ "modalName": "${modalName}",
17
+ "objectName": "${objectName}",
18
+ "$": "$$",
19
+ "recordId": "${recordId}"
17
20
  },
18
- "requestAdaptor": "",
21
+ "requestAdaptor": "const formData = api.data.$;\napi.data = { objects: formData.objects };\nreturn api;",
19
22
  "responseData": null,
20
- "adaptor": "SteedosUI.getRef(api.body.modalName).close();\nrefreshGrid && refreshGrid();\nreturn payload;\n ",
23
+ "adaptor": "\nSteedosUI.getRef(api.body.modalName).close();\nif (api.body.objectName === \"tabs\") {\n // 在tabs列表操作”对象选项卡“按钮,保存后需要刷新主列表\n refreshGrid && refreshGrid();\n}\nreturn payload;\n ",
21
24
  "headers": {
22
25
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
23
26
  }
@@ -35,7 +38,10 @@
35
38
  "source": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/generate_tabs_options",
36
39
  "headers": {
37
40
  "Authorization": "Bearer ${context.tenantId},${context.authToken}"
38
- }
41
+ },
42
+ "validations": {},
43
+ "validationErrors": {},
44
+ "required": true
39
45
  }
40
46
  ],
41
47
  "panelClassName": "m-0",
@@ -65,14 +71,15 @@
65
71
  "debug": false,
66
72
  "messages": {
67
73
  "fetchFailed": "初始化失败",
68
- "saveFailed": "保存失败"
74
+ "saveFailed": "保存失败",
75
+ "validateFailed": "请先选择需要生成选项卡的对象!"
69
76
  },
70
77
  "onEvent": {
71
78
  "submitSucc": {
72
79
  "actions": [
73
80
  {
74
81
  "actionType": "custom",
75
- "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}"
82
+ "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}"
76
83
  }
77
84
  ]
78
85
  }