@steedos/service-plugin-amis 2.3.0-beta.13 → 2.3.0-beta.14
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.
|
@@ -4,17 +4,19 @@
|
|
|
4
4
|
{
|
|
5
5
|
"type": "service",
|
|
6
6
|
"className": "col-span-2 m-0",
|
|
7
|
-
"id": "
|
|
7
|
+
"id": "tabs-options-service",
|
|
8
8
|
"affixFooter": false,
|
|
9
9
|
"api": {
|
|
10
10
|
"method": "get",
|
|
11
11
|
"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",
|
|
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 debugger;\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 console.log(\"===convertDataForTabs===\", convertedTabs);\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
13
|
"data": {
|
|
14
14
|
"query": "{options:tabs{_id label:label value:name,type,object,desktop,mobile}}"
|
|
15
15
|
},
|
|
16
16
|
"sendOn": ""
|
|
17
17
|
},
|
|
18
|
+
"messages": {},
|
|
19
|
+
"placeholder": "-",
|
|
18
20
|
"body": [
|
|
19
21
|
{
|
|
20
22
|
"className": "steedos-amis-form",
|
|
@@ -29,10 +31,10 @@
|
|
|
29
31
|
"method": "post",
|
|
30
32
|
"url": "${context.rootUrl}/graphql",
|
|
31
33
|
"data": {
|
|
32
|
-
"objectName": "${objectName}",
|
|
33
34
|
"$": "$$",
|
|
34
35
|
"recordId": "${recordId}",
|
|
35
|
-
"modalName": "${modalName}"
|
|
36
|
+
"modalName": "${modalName}",
|
|
37
|
+
"objectName": "${objectName}"
|
|
36
38
|
},
|
|
37
39
|
"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
40
|
"responseData": {
|
|
@@ -44,7 +46,6 @@
|
|
|
44
46
|
"method": "post",
|
|
45
47
|
"url": "${context.rootUrl}/graphql",
|
|
46
48
|
"sendOn": "!!this.recordId",
|
|
47
|
-
"cache": 100,
|
|
48
49
|
"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
50
|
"data": {
|
|
50
51
|
"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}}}"
|
|
@@ -133,7 +134,7 @@
|
|
|
133
134
|
"multiple": true,
|
|
134
135
|
"checkAll": false,
|
|
135
136
|
"searchable": true,
|
|
136
|
-
"
|
|
137
|
+
"source": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/options"
|
|
137
138
|
},
|
|
138
139
|
{
|
|
139
140
|
"name": "mobile_objects",
|
|
@@ -149,7 +150,7 @@
|
|
|
149
150
|
"multiple": true,
|
|
150
151
|
"checkAll": false,
|
|
151
152
|
"searchable": true,
|
|
152
|
-
"
|
|
153
|
+
"source": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/options"
|
|
153
154
|
},
|
|
154
155
|
{
|
|
155
156
|
"name": "description",
|
|
@@ -211,11 +212,19 @@
|
|
|
211
212
|
"removable": true,
|
|
212
213
|
"draggable": false,
|
|
213
214
|
"columns": [
|
|
215
|
+
{
|
|
216
|
+
"name": "index",
|
|
217
|
+
"label": "序号",
|
|
218
|
+
"type": "static",
|
|
219
|
+
"id": "u:c59784421c37",
|
|
220
|
+
"value": "${index + 1}",
|
|
221
|
+
"className": "w-10"
|
|
222
|
+
},
|
|
214
223
|
{
|
|
215
224
|
"name": "tab_name_label",
|
|
216
225
|
"label": "选项卡",
|
|
217
|
-
"type": "tpl",
|
|
218
226
|
"id": "u:b95c69a1cd84",
|
|
227
|
+
"type": "tpl",
|
|
219
228
|
"tpl": "${tabs_options|filter:value:equals:tab_name|pick:label}"
|
|
220
229
|
},
|
|
221
230
|
{
|
|
@@ -287,7 +296,7 @@
|
|
|
287
296
|
"actions": [
|
|
288
297
|
{
|
|
289
298
|
"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:
|
|
299
|
+
"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
300
|
}
|
|
292
301
|
],
|
|
293
302
|
"weight": 0
|
|
@@ -328,7 +337,8 @@
|
|
|
328
337
|
}
|
|
329
338
|
]
|
|
330
339
|
}
|
|
331
|
-
}
|
|
340
|
+
},
|
|
341
|
+
"size": "lg"
|
|
332
342
|
},
|
|
333
343
|
"label": "设置选项卡",
|
|
334
344
|
"id": "u:853b890ab524"
|
|
@@ -377,7 +387,8 @@
|
|
|
377
387
|
]
|
|
378
388
|
}
|
|
379
389
|
},
|
|
380
|
-
"type": "dialog"
|
|
390
|
+
"type": "dialog",
|
|
391
|
+
"size": "lg"
|
|
381
392
|
}
|
|
382
393
|
}
|
|
383
394
|
],
|
|
@@ -385,7 +396,9 @@
|
|
|
385
396
|
"perPageAvailable": [
|
|
386
397
|
10
|
|
387
398
|
],
|
|
388
|
-
"messages": {}
|
|
399
|
+
"messages": {},
|
|
400
|
+
"visible": "typeof this.visibleOn === \"string\" ? 2 : 1",
|
|
401
|
+
"visibleOn": " !!this.tabs_options"
|
|
389
402
|
}
|
|
390
403
|
],
|
|
391
404
|
"id": "u:d5b736e2a2f5",
|
|
@@ -507,9 +520,7 @@
|
|
|
507
520
|
}
|
|
508
521
|
}
|
|
509
522
|
}
|
|
510
|
-
]
|
|
511
|
-
"messages": {},
|
|
512
|
-
"placeholder": "-"
|
|
523
|
+
]
|
|
513
524
|
}
|
|
514
525
|
],
|
|
515
526
|
"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": "
|
|
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
|
}
|
|
@@ -72,7 +75,7 @@
|
|
|
72
75
|
"actions": [
|
|
73
76
|
{
|
|
74
77
|
"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}"
|
|
78
|
+
"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
79
|
}
|
|
77
80
|
]
|
|
78
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-plugin-amis",
|
|
3
|
-
"version": "2.3.0-beta.
|
|
3
|
+
"version": "2.3.0-beta.14",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node .scripts/build.tailwind.js"
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "2b116bbb0dd1709328c789357aacdabf6bb53dff"
|
|
14
14
|
}
|