@steedos/service-plugin-amis 2.5.16 → 2.5.17-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.
|
@@ -1,42 +1,304 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"fieldsExtend": "{\n \"tab_items\": {\n \"amis\": {\n \"name\": \"tab_items\",\n \"type\": \"crud\",\n \"source\": \"\\${tab_items}\",\n \"strictMode\": true,\n \"affixHeader\": false,\n \"editable\": true,\n \"addable\": false,\n \"removable\": true,\n \"draggable\": false,\n \"headerToolbarClassName\": \"px-1 pb-3\",\n \"columns\": [\n {\n \"name\": \"index\",\n \"label\": \"\\${'apps.apps_form.tab_number'| t}\",\n \"type\": \"tpl\",\n \"tpl\": \"\\${index+1}\",\n \"className\": \"w-10\",\n \"id\": \"u:c59784421c37\"\n },\n {\n \"name\": \"tab_name_label\",\n \"label\": \"\\${'apps.apps_form.tab' | t}\",\n \"type\": \"tpl\",\n \"id\": \"u:b95c69a1cd84\",\n \"tpl\": \"\\${tabs_options|filter:value:equals:tab_name|pick:label}\"\n },\n {\n \"name\": \"group\",\n \"label\": \"\\${'apps.apps_form.tab_grouping' | t}\",\n \"id\": \"u:e532b1949676\",\n \"quickEdit\": {\n \"type\": \"select\",\n \"name\": \"group\",\n \"className\": \"m-0\",\n \"onEvent\": {\n \"change\": {\n \"actions\": [\n {\n \"actionType\": \"custom\",\n \"script\": \"const tabGroupKey = \\\"group\\\";const getTabsSortFun = function (groupNames) { return function (m, n) { var tempM = !!m[tabGroupKey] ? 1 : 0; var tempN = !!n[tabGroupKey] ? 1 : 0; if (!m[tabGroupKey] || !n[tabGroupKey]) { return tempM - tempN; } return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]); };};const quickEidtSaveForTab = function (input, prop_name) { const currentPropValue = input.value; const rowValue = input.__super; const formValue = input.__super.__super.__super; const tab_name = rowValue.tab_name; rowValue[prop_name] = currentPropValue; delete rowValue.index; let newTabs = formValue.tab_items.map(function (item) { if (item.tab_name == tab_name) { return Object.assign({}, item, rowValue); } else { return item; } }); const tabGroups = input.__super.__super.tab_groups; const groupNames = _.compact(_.map(tabGroups, \\\"group_name\\\")); if (groupNames && groupNames.length) { newTabs.sort(getTabsSortFun(groupNames)); } return { tab_items: newTabs }};const eventData = event.data;const newTabTtemsProp = quickEidtSaveForTab(eventData, \\\"group\\\");setTimeout(function () { doAction({ actionType: 'setValue', componentId: \\\"object_form\\\", args: { value: newTabTtemsProp } });},300);\"\n }\n ]\n }\n },\n \"source\": \"\\${tab_groups|pick:group_name}\",\n \"checkAll\": false,\n \"selectFirst\": false,\n \"searchable\": true,\n \"clearable\": true,\n \"id\": \"u:8b3d6979e884\",\n \"multiple\": false,\n \"mode\": \"inline\"\n },\n \"placeholder\": \"-\"\n },\n {\n \"name\": \"tab_name_desktop\",\n \"label\": \"\\${'apps.apps_form.tab_desktop' | t}\",\n \"type\": \"tpl\",\n \"id\": \"u:b95c69a1cd84\",\n \"tpl\": \"\\${tabs_options|filter:value:equals:tab_name|first|pick:desktop|isTrue:'✔':'✘'}\",\n \"placeholder\": \"-\",\n \"remark\": \"\\${'apps.apps_form.tab_desktop_remark' | t}\"\n },\n {\n \"name\": \"tab_name_mobile\",\n \"label\": \"\\${'apps.apps_form.tab_mobile' | t}\",\n \"type\": \"tpl\",\n \"id\": \"u:b95c69a1cd84\",\n \"tpl\": \"\\${tabs_options|filter:value:equals:tab_name|first|pick:mobile|isTrue:'✔':'✘'}\",\n \"placeholder\": \"-\",\n \"remark\": \"\\${'apps.apps_form.tab_mobile_remark' | t}\"\n }\n ],\n \"headerToolbar\": [\n {\n \"type\": \"service\",\n \"id\": \"tabs-options-service\",\n \"body\": [\n {\n \"type\": \"button\",\n \"id\": \"u:a35a2276145d\",\n \"label\": \"${'apps.apps_form.tab_generate' | t}\",\n \"onEvent\": {\n \"click\": {\n \"actions\": [\n {\n \"script\": \"const appId = null; const page = Steedos.Page.getPage('app', appId, null, null, 'generate_object_tabs'); if (page && page.schema) { const pageSchema = JSON.parse(page.schema); let formSchema = pageSchema.body[0]; formSchema.canAccessSuperData = false; formSchema.wrapWithPanel = false; formSchema.className = 'steedos-amis-form'; const title = t('apps.apps_form.tab_generate_title'); doAction({ 'actionType': 'dialog', 'dialog': { 'type': 'dialog', 'title': title, 'body': formSchema, 'size': 'lg' } }); }\",\n \"actionType\": \"custom\"\n }\n ],\n \"weight\": 0\n }\n },\n \"tpl\": \"内容\"\n },\n {\n \"type\": \"button\",\n \"label\": \"${'apps.apps_form.tab_set' | t}\",\n \"id\": \"u:853b890ab524\",\n \"actionType\": \"dialog\",\n \"dialog\": {\n \"type\": \"dialog\",\n \"title\": \"${'apps.apps_form.tab_set' | t}\",\n \"body\": [\n {\n \"type\": \"transfer\",\n \"name\": \"picked_tabs\",\n \"value\": \"\\${tab_items|pick:tab_name}\",\n \"sortable\": true,\n \"source\": \"\\${tabs_options}\",\n \"searchable\": true,\n \"id\": \"u:f2d36873abd1\"\n }\n ],\n \"onEvent\": {\n \"confirm\": {\n \"actions\": [\n {\n \"actionType\": \"custom\",\n \"script\": \"const tabGroupKey = 'group';const getTabsSortFun = function (groupNames) { return function (m, n) { var tempM = !!m[tabGroupKey] ? 1 : 0; var tempN = !!n[tabGroupKey] ? 1 : 0; if (!m[tabGroupKey] || !n[tabGroupKey]) { return tempM - tempN; } return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]); };};const clearTabs = function (input) { return { tab_items: [] }};const convertDataForTabs = function (input) { let pickedTabs = input.picked_tabs || []; const superTabs = _.keyBy(input.__super.__super.tab_items, 'tab_name'); if (typeof pickedTabs === 'string') { pickedTabs = pickedTabs.split(','); } const tabOptions = _.keyBy(input.__super.tabs_options, 'value'); const convertedTabs = pickedTabs.map(function (tab_name) { const superTab = superTabs[tab_name]; if (superTab) { return superTab; } else { const tabOption = tabOptions[tab_name]; return { tab_name: tab_name, group: tabOption.group } } }); const tabGroups = input.__super.__super.tab_groups; const groupNames = _.compact(_.map(tabGroups, 'group_name')); if (groupNames && groupNames.length) { convertedTabs.sort(getTabsSortFun(groupNames)); } return { tab_items: convertedTabs }};const eventData = event.data;doAction({ actionType: 'setValue', componentId: 'object_form', args: { value: convertDataForTabs(eventData) }});doAction({ actionType: 'setValue', componentId: 'tabs-options-service', args: { value: convertDataForTabs(eventData) }});\"\n }\n ]\n }\n },\n \"size\": \"lg\",\n \"id\": \"u:9c93896a73cf\",\n \"closeOnEsc\": false,\n \"closeOnOutside\": false,\n \"showCloseButton\": true,\n \"showErrorMsg\": true,\n \"showLoading\": true,\n \"dataMapSwitch\": false\n }\n },\n {\n \"type\": \"button\",\n \"label\": \"${'apps.apps_form.tab_grouping_set' | t}\",\n \"actionType\": \"dialog\",\n \"dialog\": {\n \"title\": \"${'apps.apps_form.tab_grouping_set' | t}\",\n \"body\": [\n {\n \"type\": \"input-table\",\n \"name\": \"setting_groups\",\n \"value\": \"\\${tab_groups}\",\n \"addable\": true,\n \"draggable\": true,\n \"editable\": true,\n \"needConfirm\": false,\n \"columns\": [\n {\n \"name\": \"group_name\",\n \"label\": \"${'apps.apps_form.tab_grouping_name' | t}\",\n \"id\": \"u:383c7744b499\"\n },\n {\n \"name\": \"default_open\",\n \"label\": \"${'apps.apps_form.tab_grouping_open' | t}\",\n \"id\": \"u:7a243c84ed66\",\n \"type\": \"checkbox\",\n \"value\": true\n }\n ],\n \"removable\": true,\n \"id\": \"setting_groups\"\n }\n ],\n \"onEvent\": {\n \"confirm\": {\n \"actions\": [\n {\n \"actionType\": \"custom\",\n \"script\": \"const tabGroupKey = 'group';const getTabsSortFun = function (groupNames) { return function (m, n) { var tempM = !!m[tabGroupKey] ? 1 : 0; var tempN = !!n[tabGroupKey] ? 1 : 0; if (!m[tabGroupKey] || !n[tabGroupKey]) { return tempM - tempN; } return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]); };};const clearTabs = function (input) { return { tab_items: [] }};const convertDataForGroups = function(input) { const settingGroups = input.setting_groups || []; const convertedGroups = _.uniqBy(settingGroups.map(function (item) { return { group_name: item.group_name, default_open: item.default_open } }), 'group_name'); const groupNames = _.compact(_.map(convertedGroups, 'group_name')); const tab_items = input.tab_items; tab_items?.sort(getTabsSortFun(groupNames)); return { tab_groups: convertedGroups, tab_items: tab_items }};const eventData = event.data;doAction({ actionType: 'setValue', componentId: 'object_form', args: { value: convertDataForGroups(eventData) }});\"\n }\n ]\n }\n },\n \"type\": \"dialog\",\n \"size\": \"lg\",\n \"id\": \"setting_groups\",\n \"closeOnEsc\": false,\n \"closeOnOutside\": false,\n \"showCloseButton\": true,\n \"showErrorMsg\": true,\n \"showLoading\": true,\n \"dataMapSwitch\": false\n },\n \"id\": \"u:111b043b193c\"\n }\n ],\n \"messages\": \"\",\n \"api\": {\n \"method\": \"post\",\n \"url\": \"\\${context.rootUrl}/graphql\",\n \"adaptor\": \" let data = payload.data; data.tabs_options = []; if (data.options && data.options.length) { data.tabs_options = data.options.map(function (option) { option.label = option.label + '(' + option.value + ')'; return option; }); } if (!api.body.recordId) { const defaultValues = { is_creator: true, mobile: true, visible: true, sort: 9100 } ;data = Object.assign({}, data, defaultValues); } delete data.options ;payload.data = data; return payload; \",\n \"data\": {\n \"query\": \"{options:tabs{_id label:label value:name,type,object,desktop,mobile}}\",\n \"recordId\": \"\\${recordId}\"\n },\n \"headers\": {\n \"Authorization\": \"Bearer \\${context.tenantId},\\${context.authToken}\"\n }\n }\n }\n ]\n }\n },\n \"objects\": {\n \"amis\": {\n \"name\": \"objects\",\n \"type\": \"select\",\n \"className\": \"m-0\",\n \"labelClassName\": \"text-left\",\n \"id\": \"u:4e5047e44905\",\n \"joinValues\": false,\n \"extractValue\": true,\n \"labelField\": \"label\",\n \"valueField\": \"value\",\n \"multiple\": true,\n \"checkAll\": false,\n \"searchable\": true,\n \"menuTpl\": \"\",\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/options\",\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n },\n \"autoComplete\": \"\"\n }\n },\n \"mobile_objects\": {\n \"amis\": {\n \"name\": \"mobile_objects\",\n \"type\": \"select\",\n \"className\": \"m-0\",\n \"labelClassName\": \"text-left\",\n \"id\": \"u:cfaeb2f857a8\",\n \"joinValues\": false,\n \"extractValue\": true,\n \"labelField\": \"label\",\n \"valueField\": \"value\",\n \"multiple\": true,\n \"checkAll\": false,\n \"searchable\": true,\n \"menuTpl\": \"\",\n \"source\": {\n \"method\": \"get\",\n \"url\": \"${context.rootUrl}/service/api/amis-metadata-objects/objects/options\",\n \"messages\": {},\n \"headers\": {\n \"Authorization\": \"Bearer ${context.tenantId},${context.authToken}\"\n }\n },\n \"autoComplete\": \"\"\n }\n }\n}",
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
"type": "page",
|
|
3
|
+
"title": "Welcome to Steedos",
|
|
4
|
+
"body": [
|
|
5
|
+
{
|
|
6
|
+
"type": "steedos-object-form",
|
|
7
|
+
"className": "sm:border sm:rounded sm:border-gray-300 bg-white p-4",
|
|
8
|
+
"label": "对象表单",
|
|
9
|
+
"objectApiName": "apps",
|
|
10
|
+
"recordId": "${recordId}",
|
|
11
|
+
"mode": "edit",
|
|
12
|
+
"fieldsExtend": {
|
|
13
|
+
"tab_items": {
|
|
14
|
+
"amis": {
|
|
15
|
+
"name": "tab_items",
|
|
16
|
+
"type": "crud",
|
|
17
|
+
"source": "${tab_items}",
|
|
18
|
+
"strictMode": true,
|
|
19
|
+
"affixHeader": false,
|
|
20
|
+
"editable": true,
|
|
21
|
+
"addable": false,
|
|
22
|
+
"removable": true,
|
|
23
|
+
"draggable": false,
|
|
24
|
+
"headerToolbarClassName": "px-1 pb-3",
|
|
25
|
+
"columns": [
|
|
26
|
+
{
|
|
27
|
+
"name": "index",
|
|
28
|
+
"label": "${'apps.apps_form.tab_number'| t}",
|
|
29
|
+
"type": "tpl",
|
|
30
|
+
"tpl": "${index+1}",
|
|
31
|
+
"className": "w-10",
|
|
32
|
+
"id": "u:c59784421c37"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "tab_name_label",
|
|
36
|
+
"label": "${'apps.apps_form.tab' | t}",
|
|
37
|
+
"type": "tpl",
|
|
38
|
+
"id": "u:b95c69a1cd84",
|
|
39
|
+
"tpl": "${tabs_options|filter:value:equals:tab_name|pick:label}"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "group",
|
|
43
|
+
"label": "${'apps.apps_form.tab_grouping' | t}",
|
|
44
|
+
"id": "u:e532b1949676",
|
|
45
|
+
"quickEdit": {
|
|
46
|
+
"type": "select",
|
|
47
|
+
"name": "group",
|
|
48
|
+
"className": "m-0",
|
|
49
|
+
"onEvent": {
|
|
50
|
+
"change": {
|
|
51
|
+
"actions": [
|
|
52
|
+
{
|
|
53
|
+
"actionType": "custom",
|
|
54
|
+
"script": "const tabGroupKey = \"group\";const getTabsSortFun = function (groupNames) { return function (m, n) { var tempM = !!m[tabGroupKey] ? 1 : 0; var tempN = !!n[tabGroupKey] ? 1 : 0; if (!m[tabGroupKey] || !n[tabGroupKey]) { return tempM - tempN; } return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]); };};const quickEidtSaveForTab = function (input, prop_name) { const currentPropValue = input.value; const rowValue = input.__super; const formValue = input.__super.__super.__super; const tab_name = rowValue.tab_name; rowValue[prop_name] = currentPropValue; delete rowValue.index; let newTabs = formValue.tab_items.map(function (item) { if (item.tab_name == tab_name) { return Object.assign({}, item, rowValue); } else { return item; } }); const tabGroups = input.__super.__super.tab_groups; const groupNames = _.compact(_.map(tabGroups, \"group_name\")); if (groupNames && groupNames.length) { newTabs.sort(getTabsSortFun(groupNames)); } return { tab_items: newTabs }};const eventData = event.data;const newTabTtemsProp = quickEidtSaveForTab(eventData, \"group\");setTimeout(function () { doAction({ actionType: 'setValue', componentId: \"object_form\", args: { value: newTabTtemsProp } });},300);"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"source": "${tab_groups|pick:group_name}",
|
|
60
|
+
"checkAll": false,
|
|
61
|
+
"selectFirst": false,
|
|
62
|
+
"searchable": true,
|
|
63
|
+
"clearable": true,
|
|
64
|
+
"id": "u:8b3d6979e884",
|
|
65
|
+
"multiple": false,
|
|
66
|
+
"mode": "inline"
|
|
67
|
+
},
|
|
68
|
+
"placeholder": "-"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "tab_name_desktop",
|
|
72
|
+
"label": "${'apps.apps_form.tab_desktop' | t}",
|
|
73
|
+
"type": "tpl",
|
|
74
|
+
"id": "u:b95c69a1cd84",
|
|
75
|
+
"tpl": "${tabs_options|filter:value:equals:tab_name|first|pick:desktop|isTrue:'✔':'✘'}",
|
|
76
|
+
"placeholder": "-",
|
|
77
|
+
"remark": "${'apps.apps_form.tab_desktop_remark' | t}"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "tab_name_mobile",
|
|
81
|
+
"label": "${'apps.apps_form.tab_mobile' | t}",
|
|
82
|
+
"type": "tpl",
|
|
83
|
+
"id": "u:b95c69a1cd84",
|
|
84
|
+
"tpl": "${tabs_options|filter:value:equals:tab_name|first|pick:mobile|isTrue:'✔':'✘'}",
|
|
85
|
+
"placeholder": "-",
|
|
86
|
+
"remark": "${'apps.apps_form.tab_mobile_remark' | t}"
|
|
87
|
+
}
|
|
88
|
+
],
|
|
89
|
+
"headerToolbar": [
|
|
90
|
+
{
|
|
91
|
+
"type": "service",
|
|
92
|
+
"id": "tabs-options-service",
|
|
93
|
+
"body": [
|
|
94
|
+
{
|
|
95
|
+
"type": "button",
|
|
96
|
+
"id": "u:a35a2276145d",
|
|
97
|
+
"label": "${'apps.apps_form.tab_generate' | t}",
|
|
98
|
+
"onEvent": {
|
|
99
|
+
"click": {
|
|
100
|
+
"actions": [
|
|
101
|
+
{
|
|
102
|
+
"script": "const appId = null; const page = Steedos.Page.getPage('app', appId, null, null, 'generate_object_tabs'); if (page && page.schema) { const pageSchema = JSON.parse(page.schema); let formSchema = pageSchema.body[0]; formSchema.canAccessSuperData = false; formSchema.wrapWithPanel = false; formSchema.className = 'steedos-amis-form'; const title = t('apps.apps_form.tab_generate_title'); doAction({ 'actionType': 'dialog', 'dialog': { 'type': 'dialog', 'title': title, 'body': formSchema, 'size': 'lg' } }); }",
|
|
103
|
+
"actionType": "custom"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"weight": 0
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"tpl": "内容"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"type": "button",
|
|
113
|
+
"label": "${'apps.apps_form.tab_set' | t}",
|
|
114
|
+
"id": "u:853b890ab524",
|
|
115
|
+
"actionType": "dialog",
|
|
116
|
+
"dialog": {
|
|
117
|
+
"type": "dialog",
|
|
118
|
+
"title": "${'apps.apps_form.tab_set' | t}",
|
|
119
|
+
"body": [
|
|
120
|
+
{
|
|
121
|
+
"type": "transfer",
|
|
122
|
+
"name": "picked_tabs",
|
|
123
|
+
"value": "${tab_items|pick:tab_name}",
|
|
124
|
+
"sortable": true,
|
|
125
|
+
"source": "${tabs_options}",
|
|
126
|
+
"searchable": true,
|
|
127
|
+
"id": "u:f2d36873abd1"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"onEvent": {
|
|
131
|
+
"confirm": {
|
|
132
|
+
"actions": [
|
|
133
|
+
{
|
|
134
|
+
"actionType": "custom",
|
|
135
|
+
"script": "const tabGroupKey = 'group';const getTabsSortFun = function (groupNames) { return function (m, n) { var tempM = !!m[tabGroupKey] ? 1 : 0; var tempN = !!n[tabGroupKey] ? 1 : 0; if (!m[tabGroupKey] || !n[tabGroupKey]) { return tempM - tempN; } return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]); };};const clearTabs = function (input) { return { tab_items: [] }};const convertDataForTabs = function (input) { let pickedTabs = input.picked_tabs || []; const superTabs = _.keyBy(input.__super.__super.tab_items, 'tab_name'); if (typeof pickedTabs === 'string') { pickedTabs = pickedTabs.split(','); } const tabOptions = _.keyBy(input.__super.tabs_options, 'value'); const convertedTabs = pickedTabs.map(function (tab_name) { const superTab = superTabs[tab_name]; if (superTab) { return superTab; } else { const tabOption = tabOptions[tab_name]; return { tab_name: tab_name, group: tabOption.group } } }); const tabGroups = input.__super.__super.tab_groups; const groupNames = _.compact(_.map(tabGroups, 'group_name')); if (groupNames && groupNames.length) { convertedTabs.sort(getTabsSortFun(groupNames)); } return { tab_items: convertedTabs }};const eventData = event.data;doAction({ actionType: 'setValue', componentId: 'object_form', args: { value: convertDataForTabs(eventData) }});doAction({ actionType: 'setValue', componentId: 'tabs-options-service', args: { value: convertDataForTabs(eventData) }});"
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"size": "lg",
|
|
141
|
+
"id": "u:9c93896a73cf",
|
|
142
|
+
"closeOnEsc": false,
|
|
143
|
+
"closeOnOutside": false,
|
|
144
|
+
"showCloseButton": true,
|
|
145
|
+
"showErrorMsg": true,
|
|
146
|
+
"showLoading": true,
|
|
147
|
+
"dataMapSwitch": false
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"type": "button",
|
|
152
|
+
"label": "${'apps.apps_form.tab_grouping_set' | t}",
|
|
153
|
+
"actionType": "dialog",
|
|
154
|
+
"dialog": {
|
|
155
|
+
"title": "${'apps.apps_form.tab_grouping_set' | t}",
|
|
156
|
+
"body": [
|
|
157
|
+
{
|
|
158
|
+
"type": "input-table",
|
|
159
|
+
"name": "setting_groups",
|
|
160
|
+
"value": "${tab_groups}",
|
|
161
|
+
"addable": true,
|
|
162
|
+
"draggable": true,
|
|
163
|
+
"editable": true,
|
|
164
|
+
"needConfirm": false,
|
|
165
|
+
"columns": [
|
|
166
|
+
{
|
|
167
|
+
"name": "group_name",
|
|
168
|
+
"label": "${'apps.apps_form.tab_grouping_name' | t}",
|
|
169
|
+
"id": "u:383c7744b499"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"name": "default_open",
|
|
173
|
+
"label": "${'apps.apps_form.tab_grouping_open' | t}",
|
|
174
|
+
"id": "u:7a243c84ed66",
|
|
175
|
+
"type": "checkbox",
|
|
176
|
+
"value": true
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
"removable": true,
|
|
180
|
+
"id": "setting_groups"
|
|
181
|
+
}
|
|
182
|
+
],
|
|
183
|
+
"onEvent": {
|
|
184
|
+
"confirm": {
|
|
185
|
+
"actions": [
|
|
186
|
+
{
|
|
187
|
+
"actionType": "custom",
|
|
188
|
+
"script": "const tabGroupKey = 'group';const getTabsSortFun = function (groupNames) { return function (m, n) { var tempM = !!m[tabGroupKey] ? 1 : 0; var tempN = !!n[tabGroupKey] ? 1 : 0; if (!m[tabGroupKey] || !n[tabGroupKey]) { return tempM - tempN; } return groupNames.indexOf(m[tabGroupKey]) - groupNames.indexOf(n[tabGroupKey]); };};const clearTabs = function (input) { return { tab_items: [] }};const convertDataForGroups = function(input) { const settingGroups = input.setting_groups || []; const convertedGroups = _.uniqBy(settingGroups.map(function (item) { return { group_name: item.group_name, default_open: item.default_open } }), 'group_name'); const groupNames = _.compact(_.map(convertedGroups, 'group_name')); const tab_items = input.tab_items; tab_items?.sort(getTabsSortFun(groupNames)); return { tab_groups: convertedGroups, tab_items: tab_items }};const eventData = event.data;doAction({ actionType: 'setValue', componentId: 'object_form', args: { value: convertDataForGroups(eventData) }});"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
"type": "dialog",
|
|
194
|
+
"size": "lg",
|
|
195
|
+
"id": "setting_groups",
|
|
196
|
+
"closeOnEsc": false,
|
|
197
|
+
"closeOnOutside": false,
|
|
198
|
+
"showCloseButton": true,
|
|
199
|
+
"showErrorMsg": true,
|
|
200
|
+
"showLoading": true,
|
|
201
|
+
"dataMapSwitch": false
|
|
202
|
+
},
|
|
203
|
+
"id": "u:111b043b193c"
|
|
204
|
+
}
|
|
205
|
+
],
|
|
206
|
+
"messages": "",
|
|
207
|
+
"api": {
|
|
208
|
+
"method": "post",
|
|
209
|
+
"url": "${context.rootUrl}/graphql",
|
|
210
|
+
"adaptor": " let data = payload.data; data.tabs_options = []; if (data.options && data.options.length) { data.tabs_options = data.options.map(function (option) { option.label = option.label + '(' + option.value + ')'; return option; }); } if (!api.body.recordId) { const defaultValues = { is_creator: true, mobile: true, visible: true, sort: 9100 } ;data = Object.assign({}, data, defaultValues); } delete data.options ;payload.data = data; return payload; ",
|
|
211
|
+
"data": {
|
|
212
|
+
"query": "{options:tabs{_id label:label value:name,type,object,desktop,mobile}}",
|
|
213
|
+
"recordId": "${recordId}"
|
|
214
|
+
},
|
|
215
|
+
"headers": {
|
|
216
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
]
|
|
221
|
+
}
|
|
21
222
|
},
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
223
|
+
"objects": {
|
|
224
|
+
"amis": {
|
|
225
|
+
"name": "objects",
|
|
226
|
+
"type": "select",
|
|
227
|
+
"className": "m-0",
|
|
228
|
+
"labelClassName": "text-left",
|
|
229
|
+
"id": "u:4e5047e44905",
|
|
230
|
+
"joinValues": false,
|
|
231
|
+
"extractValue": true,
|
|
232
|
+
"labelField": "label",
|
|
233
|
+
"valueField": "value",
|
|
234
|
+
"multiple": true,
|
|
235
|
+
"checkAll": false,
|
|
236
|
+
"searchable": true,
|
|
237
|
+
"menuTpl": "",
|
|
238
|
+
"source": {
|
|
239
|
+
"method": "get",
|
|
240
|
+
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/options",
|
|
241
|
+
"headers": {
|
|
242
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
"autoComplete": ""
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
"mobile_objects": {
|
|
249
|
+
"amis": {
|
|
250
|
+
"name": "mobile_objects",
|
|
251
|
+
"type": "select",
|
|
252
|
+
"className": "m-0",
|
|
253
|
+
"labelClassName": "text-left",
|
|
254
|
+
"id": "u:cfaeb2f857a8",
|
|
255
|
+
"joinValues": false,
|
|
256
|
+
"extractValue": true,
|
|
257
|
+
"labelField": "label",
|
|
258
|
+
"valueField": "value",
|
|
259
|
+
"multiple": true,
|
|
260
|
+
"checkAll": false,
|
|
261
|
+
"searchable": true,
|
|
262
|
+
"menuTpl": "",
|
|
263
|
+
"source": {
|
|
264
|
+
"method": "get",
|
|
265
|
+
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/options",
|
|
266
|
+
"messages": {},
|
|
267
|
+
"headers": {
|
|
268
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
"autoComplete": ""
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"enableTabs": true,
|
|
276
|
+
"debug": false,
|
|
277
|
+
"initApiRequestAdaptor": "",
|
|
278
|
+
"initApiAdaptor": "var data = payload.data;\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}\nif (data._id && !data.tab_items) {\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 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属性的默认值中\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 data.tab_items = tabItems;\n}\n\npayload.data = data;\ndelete payload.extensions;\nreturn payload;\n ",
|
|
279
|
+
"apiRequestAdaptor": "delete formData.tabs_options;\nconst recordId = formData.recordId;\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\n/*\ntab_items存储为:\ntab_items: {\n test1:{\n group:\"xxx\"\n },\n test3:{\n group:\"yyy\"\n }\n}\n而不是:\ntab_items: [\n {\n \"index\":1,\n \"group\":\"xxx\"\n },\n {\n \"index\":2,\n \"group\":\"yyy\"\n }\n]\n*/\nif (formData.tab_items) { \n formData.tab_items = _.keyBy(formData.tab_items, \"tab_name\")\n let tempIndex = 0;\n _.each(formData.tab_items, function (n, k) {\n tempIndex++;\n n.index = tempIndex;\n delete n.tab_name;\n });\n}\n\nquery = `mutation{record: ${objectName}__insert(doc: {__saveData}){_id}}`;\nif(recordId){\n query = `mutation{record: ${objectName}__update(id: \"${recordId}\", doc: {__saveData}){_id}}`;\n};\n__saveData = JSON.stringify(JSON.stringify(formData));\n\napi.data = {query: query.replace('{__saveData}', __saveData)};\nreturn api;\n",
|
|
280
|
+
"apiAdaptor": "",
|
|
281
|
+
"form": {
|
|
282
|
+
"id": "object_form"
|
|
31
283
|
},
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
284
|
+
"id": "u:e1c1a841d373",
|
|
285
|
+
"tabsMode": "line"
|
|
286
|
+
}
|
|
287
|
+
],
|
|
288
|
+
"regions": [
|
|
289
|
+
"body"
|
|
290
|
+
],
|
|
291
|
+
"data": {
|
|
292
|
+
"objectName": "apps",
|
|
293
|
+
"initialValues": {},
|
|
294
|
+
"appId": "builder",
|
|
295
|
+
"title": "",
|
|
296
|
+
"context": {
|
|
297
|
+
"rootUrl": "http://127.0.0.1:5800",
|
|
298
|
+
"tenantId": "64a4d6dd7fe9acaf8c330a37",
|
|
299
|
+
"userId": "683e09cd-8482-4034-bd29-5a30643e6c0f",
|
|
300
|
+
"authToken": "2906ff4353c25cfe291352f899ba3446aa5577f3de7ad60e1aa500c60dee7ca6fb446412f1c9693775b4cc"
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
"id": "u:de840f3523f2"
|
|
304
|
+
}
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"name": "name",
|
|
59
59
|
"label": "API 名称",
|
|
60
60
|
"labelRemark": "API 名称只能包含小写字母、数字,必须以字母开头,不能以下划线字符结尾或包含两个连续的下划线字符",
|
|
61
|
-
"
|
|
61
|
+
"requiredOn": "${!!recordId}",
|
|
62
62
|
"type": "input-text",
|
|
63
63
|
"className": "m-0",
|
|
64
64
|
"labelClassName": "text-left",
|
|
@@ -170,6 +170,31 @@
|
|
|
170
170
|
},
|
|
171
171
|
"id": "u:25a6ee957503"
|
|
172
172
|
},
|
|
173
|
+
{
|
|
174
|
+
"label": "显示模式",
|
|
175
|
+
"name": "crud_mode",
|
|
176
|
+
"type": "select",
|
|
177
|
+
"value": "table",
|
|
178
|
+
"en-US": {
|
|
179
|
+
"label": "Crud Mode"
|
|
180
|
+
},
|
|
181
|
+
"options": [
|
|
182
|
+
{
|
|
183
|
+
"label": "表格",
|
|
184
|
+
"value": "table",
|
|
185
|
+
"en-US": {
|
|
186
|
+
"label": "Table"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
"label": "卡片",
|
|
191
|
+
"value": "cards",
|
|
192
|
+
"en-US": {
|
|
193
|
+
"label": "Cards"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
},
|
|
173
198
|
{
|
|
174
199
|
"label": "显示的列",
|
|
175
200
|
"type": "transfer",
|
|
@@ -541,7 +566,7 @@
|
|
|
541
566
|
"data": {
|
|
542
567
|
"recordId": "${recordId}",
|
|
543
568
|
"defaultData": "${defaultData}",
|
|
544
|
-
"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}}}"
|
|
569
|
+
"query": "{data:object_listviews(filters:[\"_id\", \"=\", \"${recordId}\"]){_id,label,name,object_name,requestAdaptor,adaptor,filter_scope,crud_mode,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}}}"
|
|
545
570
|
},
|
|
546
571
|
"replaceData": false,
|
|
547
572
|
"responseData": {
|
|
@@ -121,20 +121,34 @@ module.exports = {
|
|
|
121
121
|
const fieldsOptions = await this.getObjectFieldsOptions(ctx);
|
|
122
122
|
const userSession = ctx.meta.user;
|
|
123
123
|
const lng = userSession.language || "zh-CN";
|
|
124
|
+
const objectName = ctx.params.objectName;
|
|
125
|
+
const object = await objectql.getSteedosSchema().getObject(objectName);
|
|
126
|
+
const objectConfig = object.toConfig();
|
|
127
|
+
const fields = objectConfig.fields;
|
|
128
|
+
|
|
129
|
+
// image、file、lookup、master_detail、select 不参与排序
|
|
130
|
+
let ascChildren = [];
|
|
131
|
+
_.forEach(fieldsOptions, (opt)=>{
|
|
132
|
+
if(["image","file","lookup","master_detail","select"].indexOf(fields[opt.value].type)<0){
|
|
133
|
+
ascChildren.push({label: `${opt.label}(${steedosI18n.t('asc', {}, lng)})`, value: `${opt.value}:asc`})
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
let descChildren = [];
|
|
137
|
+
_.forEach(fieldsOptions, (opt)=>{
|
|
138
|
+
if(["image","file","lookup","master_detail","select"].indexOf(fields[opt.value].type)<0){
|
|
139
|
+
descChildren.push({label: `${opt.label}(${steedosI18n.t('desc', {}, lng)})`, value: `${opt.value}:desc`})
|
|
140
|
+
}
|
|
141
|
+
})
|
|
124
142
|
const options = [
|
|
125
143
|
{
|
|
126
144
|
label: steedosI18n.t('asc', {}, lng),
|
|
127
145
|
searchable: true,
|
|
128
|
-
children:
|
|
129
|
-
return {label: `${opt.label}(${steedosI18n.t('asc', {}, lng)})`, value: `${opt.value}:asc`}
|
|
130
|
-
})
|
|
146
|
+
children: ascChildren
|
|
131
147
|
},
|
|
132
148
|
{
|
|
133
149
|
label: steedosI18n.t('desc', {}, lng),
|
|
134
150
|
searchable: true,
|
|
135
|
-
children:
|
|
136
|
-
return {label: `${opt.label}(${steedosI18n.t('desc', {}, lng)})`, value: `${opt.value}:desc`}
|
|
137
|
-
})
|
|
151
|
+
children: descChildren
|
|
138
152
|
}
|
|
139
153
|
];
|
|
140
154
|
|
|
@@ -236,7 +250,7 @@ module.exports = {
|
|
|
236
250
|
|
|
237
251
|
let output = [];
|
|
238
252
|
output = _.uniq(_.compact(_.map(_.sortBy(fieldsArr, "sort_no"), (field)=>{
|
|
239
|
-
if((include_hide || !field.hidden) && !_.includes(["grid", "object", "[Object]", "[object]", "Object", "markdown"
|
|
253
|
+
if((include_hide || !field.hidden) && !_.includes(["grid", "object", "[Object]", "[object]", "Object", "markdown"], field.type)){
|
|
240
254
|
// 隐藏的字段 和 字段类型 判断
|
|
241
255
|
return {
|
|
242
256
|
value: field.name,
|
|
@@ -342,7 +356,7 @@ module.exports = {
|
|
|
342
356
|
})
|
|
343
357
|
let relatedOptions = [];
|
|
344
358
|
relatedOptions = _.uniq(_.compact(_.map(_.sortBy(fieldsArr, "sort_no"), (field) => {
|
|
345
|
-
if ((!field.hidden) && !_.includes(["grid", "object", "[Object]", "[object]", "Object", "markdown"
|
|
359
|
+
if ((!field.hidden) && !_.includes(["grid", "object", "[Object]", "[object]", "Object", "markdown"], field.type)) {
|
|
346
360
|
return {
|
|
347
361
|
'value': field.name,
|
|
348
362
|
'label': field.label || field.name
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-plugin-amis",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.17-beta.10",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "yarn build:tailwind-base && yarn build:tailwind",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "d4a1c8b4938c6b7853b4890902ec7b9ea60a1a70",
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"tailwindcss": "3.2.4"
|
|
19
19
|
}
|
|
@@ -112,6 +112,10 @@
|
|
|
112
112
|
margin-top: 0.5rem
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
.mr-4 {
|
|
116
|
+
margin-right: 1rem
|
|
117
|
+
}
|
|
118
|
+
|
|
115
119
|
.-mt-3 {
|
|
116
120
|
margin-top: -0.75rem
|
|
117
121
|
}
|
|
@@ -292,14 +296,14 @@
|
|
|
292
296
|
border-color: rgb(229 231 235 / var(--tw-border-opacity))
|
|
293
297
|
}
|
|
294
298
|
|
|
295
|
-
.bg-
|
|
299
|
+
.bg-white {
|
|
296
300
|
--tw-bg-opacity: 1;
|
|
297
|
-
background-color: rgb(
|
|
301
|
+
background-color: rgb(255 255 255 / var(--tw-bg-opacity))
|
|
298
302
|
}
|
|
299
303
|
|
|
300
|
-
.bg-
|
|
304
|
+
.bg-green-300 {
|
|
301
305
|
--tw-bg-opacity: 1;
|
|
302
|
-
background-color: rgb(
|
|
306
|
+
background-color: rgb(134 239 172 / var(--tw-bg-opacity))
|
|
303
307
|
}
|
|
304
308
|
|
|
305
309
|
.bg-gray-100 {
|
|
@@ -319,16 +323,6 @@
|
|
|
319
323
|
padding: 0.5rem
|
|
320
324
|
}
|
|
321
325
|
|
|
322
|
-
.px-0 {
|
|
323
|
-
padding-left: 0px;
|
|
324
|
-
padding-right: 0px
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
.py-4 {
|
|
328
|
-
padding-top: 1rem;
|
|
329
|
-
padding-bottom: 1rem
|
|
330
|
-
}
|
|
331
|
-
|
|
332
326
|
.px-2 {
|
|
333
327
|
padding-left: 0.5rem;
|
|
334
328
|
padding-right: 0.5rem
|
|
@@ -359,6 +353,11 @@
|
|
|
359
353
|
padding-bottom: 0.5rem
|
|
360
354
|
}
|
|
361
355
|
|
|
356
|
+
.px-0 {
|
|
357
|
+
padding-left: 0px;
|
|
358
|
+
padding-right: 0px
|
|
359
|
+
}
|
|
360
|
+
|
|
362
361
|
.py-1 {
|
|
363
362
|
padding-top: 0.25rem;
|
|
364
363
|
padding-bottom: 0.25rem
|
|
@@ -396,11 +395,6 @@
|
|
|
396
395
|
line-height: 1
|
|
397
396
|
}
|
|
398
397
|
|
|
399
|
-
.text-white {
|
|
400
|
-
--tw-text-opacity: 1;
|
|
401
|
-
color: rgb(255 255 255 / var(--tw-text-opacity))
|
|
402
|
-
}
|
|
403
|
-
|
|
404
398
|
.text-gray-600 {
|
|
405
399
|
--tw-text-opacity: 1;
|
|
406
400
|
color: rgb(75 85 99 / var(--tw-text-opacity))
|