@steedos/service-plugin-amis 2.3.0-beta.11 → 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.
- package/main/default/client/amis.render.client.js +48 -10
- package/main/default/pages/apps_form.page.amis.json +540 -0
- package/main/default/pages/apps_form.page.yml +14 -0
- package/main/default/pages/generate_object_tabs.page.amis.json +99 -0
- package/main/default/pages/generate_object_tabs.page.yml +7 -0
- package/main/default/pages/object_layouts.page.amis.json +4 -7
- package/main/default/services/metadata/objects.service.js +131 -0
- package/package.json +2 -2
- package/public/amis/amis.css +1 -1
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
|
|
44
44
|
// 加载Amis SDK: 如果直接放到body中会导致meteor 编译后的 cordova.js 加载报错
|
|
45
45
|
let amisSDKScript = document.createElement("script");
|
|
46
|
-
amisSDKScript.setAttribute("src", Steedos.absoluteUrl('/unpkg.com
|
|
46
|
+
amisSDKScript.setAttribute("src", Steedos.absoluteUrl('/unpkg.com/amis/sdk/sdk.js'));
|
|
47
47
|
document.getElementsByTagName("head")[0].appendChild(amisSDKScript);
|
|
48
48
|
} catch (error) {
|
|
49
49
|
console.error(error)
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const getAmisLng = ()=>{
|
|
53
|
-
locale = Creator.USER_CONTEXT
|
|
53
|
+
locale = Creator.USER_CONTEXT?.user?.language
|
|
54
54
|
if(locale){
|
|
55
55
|
locale = locale.replace('_', '-');
|
|
56
56
|
locale = locale === 'en' ? 'en-US' : locale;
|
|
@@ -63,12 +63,10 @@
|
|
|
63
63
|
|
|
64
64
|
// 此处不能使用import, client js 编译时会将import 转为require, 导致加载失败
|
|
65
65
|
// import('/unpkg.com/@steedos-ui/amis/dist/amis-sdk.umd.min.js').then(() => {
|
|
66
|
-
|
|
67
66
|
Promise.all([
|
|
68
67
|
waitForThing(window, 'assetsLoaded'),
|
|
69
|
-
waitForThing(window, '
|
|
68
|
+
waitForThing(window, 'amis'),
|
|
70
69
|
]).then(()=>{
|
|
71
|
-
|
|
72
70
|
const AmisRenderers = [];
|
|
73
71
|
|
|
74
72
|
const amisComps = lodash.filter(Builder.registry['meta-components'], function(item){ return item.componentName && item.amis?.render});
|
|
@@ -77,14 +75,33 @@
|
|
|
77
75
|
const Component = Builder.components.find(item => item.name === comp.componentName);
|
|
78
76
|
if (Component && !AmisRenderers.includes(comp.amis?.render.type)){
|
|
79
77
|
try {
|
|
78
|
+
let AmisWrapper = Component.class
|
|
80
79
|
AmisRenderers.push(comp.amis?.render.type);
|
|
81
|
-
|
|
80
|
+
if(comp.componentType === 'amisSchema'){
|
|
81
|
+
let amisReact = amisRequire('react');
|
|
82
|
+
AmisWrapper = function(props){
|
|
83
|
+
const { body, render } = props
|
|
84
|
+
const [schema, setSchema] = amisReact.useState(null);
|
|
85
|
+
amisReact.useEffect(()=>{
|
|
86
|
+
const result = Component.class(props);
|
|
87
|
+
if(result.then && typeof result.then === 'function'){
|
|
88
|
+
result.then((data)=>{
|
|
89
|
+
setSchema(data);
|
|
90
|
+
})
|
|
91
|
+
}else{
|
|
92
|
+
setSchema(result)
|
|
93
|
+
}
|
|
94
|
+
}, [])
|
|
95
|
+
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) : ''));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
amisRequire("amis").Renderer(
|
|
82
99
|
{
|
|
83
100
|
type: comp.amis?.render.type,
|
|
84
101
|
weight: comp.amis?.render.weight,
|
|
85
102
|
autoVar: true,
|
|
86
103
|
}
|
|
87
|
-
)(
|
|
104
|
+
)(AmisWrapper);
|
|
88
105
|
} catch(e){console.error(e)}
|
|
89
106
|
}
|
|
90
107
|
});
|
|
@@ -178,7 +195,29 @@
|
|
|
178
195
|
}
|
|
179
196
|
}, env);
|
|
180
197
|
}
|
|
181
|
-
|
|
198
|
+
schema.scopeRef = (ref) => {
|
|
199
|
+
try {
|
|
200
|
+
if(!window.amisScopes){
|
|
201
|
+
window.amisScopes = {};
|
|
202
|
+
}
|
|
203
|
+
if(name){
|
|
204
|
+
window.amisScopes[name] = ref;
|
|
205
|
+
}
|
|
206
|
+
} catch (error) {
|
|
207
|
+
console.error('error', error)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return scoped = ref
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
React.useEffect(()=>{
|
|
214
|
+
amisRequire('amis/embed').embed(`.steedos-amis-render-scope-${name}`,schema, {data, name, locale: getAmisLng()}, Object.assign({}, AmisEnv, env))
|
|
215
|
+
}, [])
|
|
216
|
+
return React.createElement("div", {
|
|
217
|
+
className: "amis-scope"
|
|
218
|
+
}, React.createElement("div", {
|
|
219
|
+
className: `steedos-amis-render-scope-${name}`
|
|
220
|
+
}));
|
|
182
221
|
};
|
|
183
222
|
|
|
184
223
|
const initMonaco = ()=>{
|
|
@@ -199,14 +238,13 @@
|
|
|
199
238
|
return Builder.initMonaco()
|
|
200
239
|
}
|
|
201
240
|
}
|
|
202
|
-
|
|
203
241
|
//Amis SDK 中已清理了monaco, 所以这里需要提前注册,否则会导致amis code类型报错
|
|
204
242
|
initMonaco().catch((err)=>{
|
|
205
243
|
console.error(`Builder.initMonaco error: ${err}`);
|
|
206
244
|
}).finally(()=>{
|
|
207
245
|
const language = getAmisLng()
|
|
208
246
|
axios.get(`/translations/amis/${language}.json`).then((res)=>{
|
|
209
|
-
|
|
247
|
+
amisRequire("amis").registerLocale(`${language}`, res.data)
|
|
210
248
|
Builder.registerComponent(AmisRender, {
|
|
211
249
|
name: 'Amis',
|
|
212
250
|
inputs: [
|
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "page",
|
|
3
|
+
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "service",
|
|
6
|
+
"className": "col-span-2 m-0",
|
|
7
|
+
"id": "tabs-options-service",
|
|
8
|
+
"affixFooter": false,
|
|
9
|
+
"api": {
|
|
10
|
+
"method": "get",
|
|
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 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
|
+
"data": {
|
|
14
|
+
"query": "{options:tabs{_id label:label value:name,type,object,desktop,mobile}}"
|
|
15
|
+
},
|
|
16
|
+
"sendOn": ""
|
|
17
|
+
},
|
|
18
|
+
"messages": {},
|
|
19
|
+
"placeholder": "-",
|
|
20
|
+
"body": [
|
|
21
|
+
{
|
|
22
|
+
"className": "steedos-amis-form",
|
|
23
|
+
"id": "apps-form",
|
|
24
|
+
"type": "form",
|
|
25
|
+
"mode": "normal",
|
|
26
|
+
"persistData": false,
|
|
27
|
+
"promptPageLeave": true,
|
|
28
|
+
"name": "form_edit_${recordId}",
|
|
29
|
+
"title": "",
|
|
30
|
+
"api": {
|
|
31
|
+
"method": "post",
|
|
32
|
+
"url": "${context.rootUrl}/graphql",
|
|
33
|
+
"data": {
|
|
34
|
+
"$": "$$",
|
|
35
|
+
"recordId": "${recordId}",
|
|
36
|
+
"modalName": "${modalName}",
|
|
37
|
+
"objectName": "${objectName}"
|
|
38
|
+
},
|
|
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",
|
|
40
|
+
"responseData": {
|
|
41
|
+
"recordId": "${record._id}"
|
|
42
|
+
},
|
|
43
|
+
"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 "
|
|
44
|
+
},
|
|
45
|
+
"initApi": {
|
|
46
|
+
"method": "post",
|
|
47
|
+
"url": "${context.rootUrl}/graphql",
|
|
48
|
+
"sendOn": "!!this.recordId",
|
|
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 ",
|
|
50
|
+
"data": {
|
|
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}}}"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"initFetch": true,
|
|
55
|
+
"body": [
|
|
56
|
+
{
|
|
57
|
+
"type": "tabs",
|
|
58
|
+
"id": "u:430a42f742ee",
|
|
59
|
+
"tabs": [
|
|
60
|
+
{
|
|
61
|
+
"title": "基本信息",
|
|
62
|
+
"body": [
|
|
63
|
+
{
|
|
64
|
+
"type": "wrapper",
|
|
65
|
+
"className": "form-content",
|
|
66
|
+
"body": [
|
|
67
|
+
{
|
|
68
|
+
"type": "input-text",
|
|
69
|
+
"id": "u:9677ac1cc3c5",
|
|
70
|
+
"name": "name",
|
|
71
|
+
"label": "名称",
|
|
72
|
+
"required": true,
|
|
73
|
+
"className": "m-0",
|
|
74
|
+
"labelClassName": "text-left",
|
|
75
|
+
"labelRemark": "",
|
|
76
|
+
"hidden": false
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "code",
|
|
80
|
+
"label": "API 名称",
|
|
81
|
+
"required": true,
|
|
82
|
+
"type": "input-text",
|
|
83
|
+
"className": "m-0",
|
|
84
|
+
"labelClassName": "text-left",
|
|
85
|
+
"id": "u:784ac1e92fbf"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "icon_slds",
|
|
89
|
+
"label": "图标",
|
|
90
|
+
"type": "select",
|
|
91
|
+
"className": "m-0",
|
|
92
|
+
"labelClassName": "text-left",
|
|
93
|
+
"id": "u:d0724fe17aa7",
|
|
94
|
+
"required": true,
|
|
95
|
+
"joinValues": false,
|
|
96
|
+
"extractValue": true,
|
|
97
|
+
"labelField": "label",
|
|
98
|
+
"valueField": "value",
|
|
99
|
+
"multiple": false,
|
|
100
|
+
"source": {
|
|
101
|
+
"method": "post",
|
|
102
|
+
"url": "${context.rootUrl}/graphql",
|
|
103
|
+
"data": {
|
|
104
|
+
"query": "{objects(filters: [\"_id\", \"=\", \"-1\"]){_id}}",
|
|
105
|
+
"$": "$$",
|
|
106
|
+
"$term": "$term",
|
|
107
|
+
"$value": "$icon_slds._id",
|
|
108
|
+
"rfield": "${object_name}"
|
|
109
|
+
},
|
|
110
|
+
"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 ",
|
|
111
|
+
"adaptor": "\npayload.data.options = eval(function anonymous() {\n\n var options;\n options = [];\n if (!window.Creator) { \n return options;\n }\n _.forEach(Creator.resources.sldsIcons.standard, function (svg) {\n return options.push({\n value: svg,\n label: svg,\n icon: svg\n });\n });\n\n return options;\n\n})(api.data);\n\nreturn payload;\n ",
|
|
112
|
+
"messages": {}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"name": "sort",
|
|
117
|
+
"label": "排序",
|
|
118
|
+
"type": "input-number",
|
|
119
|
+
"className": "m-0",
|
|
120
|
+
"labelClassName": "text-left",
|
|
121
|
+
"id": "u:fc07a5376a46"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "objects",
|
|
125
|
+
"label": "桌面主菜单(已作废)",
|
|
126
|
+
"type": "select",
|
|
127
|
+
"className": "m-0",
|
|
128
|
+
"labelClassName": "text-left",
|
|
129
|
+
"id": "u:4e5047e44905",
|
|
130
|
+
"joinValues": false,
|
|
131
|
+
"extractValue": true,
|
|
132
|
+
"labelField": "label",
|
|
133
|
+
"valueField": "value",
|
|
134
|
+
"multiple": true,
|
|
135
|
+
"checkAll": false,
|
|
136
|
+
"searchable": true,
|
|
137
|
+
"source": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/options"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"name": "mobile_objects",
|
|
141
|
+
"label": "手机主菜单(已作废)",
|
|
142
|
+
"type": "select",
|
|
143
|
+
"className": "m-0",
|
|
144
|
+
"labelClassName": "text-left",
|
|
145
|
+
"id": "u:cfaeb2f857a8",
|
|
146
|
+
"joinValues": false,
|
|
147
|
+
"extractValue": true,
|
|
148
|
+
"labelField": "label",
|
|
149
|
+
"valueField": "value",
|
|
150
|
+
"multiple": true,
|
|
151
|
+
"checkAll": false,
|
|
152
|
+
"searchable": true,
|
|
153
|
+
"source": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/options"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "description",
|
|
157
|
+
"label": "描述",
|
|
158
|
+
"type": "textarea",
|
|
159
|
+
"className": "col-span-2 m-0",
|
|
160
|
+
"labelClassName": "text-left",
|
|
161
|
+
"id": "u:40d99f2da55a",
|
|
162
|
+
"tpl": "<b><%=data.description%></b>"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "is_creator",
|
|
166
|
+
"label": "显示在桌面菜单中",
|
|
167
|
+
"type": "checkbox",
|
|
168
|
+
"className": "m-0",
|
|
169
|
+
"labelClassName": "text-left",
|
|
170
|
+
"id": "u:8dc6d3e8521d",
|
|
171
|
+
"tpl": null
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "mobile",
|
|
175
|
+
"label": "显示在手机菜单中",
|
|
176
|
+
"type": "checkbox",
|
|
177
|
+
"className": "m-0",
|
|
178
|
+
"labelClassName": "text-left",
|
|
179
|
+
"id": "u:c9ffb7fd0610",
|
|
180
|
+
"tpl": null
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "visible",
|
|
184
|
+
"label": "启用",
|
|
185
|
+
"type": "checkbox",
|
|
186
|
+
"tpl": null,
|
|
187
|
+
"className": "m-0",
|
|
188
|
+
"labelClassName": "text-left",
|
|
189
|
+
"id": "u:07a8a4c5f875"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"id": "u:0b870f195836",
|
|
193
|
+
"size": "none"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"id": "u:b5b8d4915890"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"title": "选项卡",
|
|
200
|
+
"body": [
|
|
201
|
+
{
|
|
202
|
+
"type": "wrapper",
|
|
203
|
+
"body": [
|
|
204
|
+
{
|
|
205
|
+
"name": "tab_items",
|
|
206
|
+
"required": true,
|
|
207
|
+
"type": "crud",
|
|
208
|
+
"strictMode": true,
|
|
209
|
+
"affixHeader": false,
|
|
210
|
+
"editable": true,
|
|
211
|
+
"addable": false,
|
|
212
|
+
"removable": true,
|
|
213
|
+
"draggable": false,
|
|
214
|
+
"columns": [
|
|
215
|
+
{
|
|
216
|
+
"name": "index",
|
|
217
|
+
"label": "序号",
|
|
218
|
+
"type": "static",
|
|
219
|
+
"id": "u:c59784421c37",
|
|
220
|
+
"value": "${index + 1}",
|
|
221
|
+
"className": "w-10"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "tab_name_label",
|
|
225
|
+
"label": "选项卡",
|
|
226
|
+
"id": "u:b95c69a1cd84",
|
|
227
|
+
"type": "tpl",
|
|
228
|
+
"tpl": "${tabs_options|filter:value:equals:tab_name|pick:label}"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "group",
|
|
232
|
+
"label": "分组",
|
|
233
|
+
"id": "u:e532b1949676",
|
|
234
|
+
"quickEdit": {
|
|
235
|
+
"type": "select",
|
|
236
|
+
"className": "m-0",
|
|
237
|
+
"onEvent": {
|
|
238
|
+
"change": {
|
|
239
|
+
"actions": [
|
|
240
|
+
{
|
|
241
|
+
"actionType": "setValue",
|
|
242
|
+
"args": {
|
|
243
|
+
"value": "${event.data|clearTabs}"
|
|
244
|
+
},
|
|
245
|
+
"componentId": "apps-form"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"actionType": "setValue",
|
|
249
|
+
"args": {
|
|
250
|
+
"value": "${event.data|quickEidtSaveForTab:group}"
|
|
251
|
+
},
|
|
252
|
+
"componentId": "apps-form"
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"source": "${tab_groups|pick:group_name}",
|
|
258
|
+
"checkAll": false,
|
|
259
|
+
"selectFirst": false,
|
|
260
|
+
"searchable": true,
|
|
261
|
+
"clearable": true
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"name": "tab_name_desktop",
|
|
266
|
+
"label": "桌面",
|
|
267
|
+
"type": "tpl",
|
|
268
|
+
"id": "u:b95c69a1cd84",
|
|
269
|
+
"tpl": "${tabs_options|filter:value:equals:tab_name|pick:desktop|isTrue:'✔':'✘'}",
|
|
270
|
+
"placeholder": "-",
|
|
271
|
+
"remark": "显示在桌面菜单中"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"name": "tab_name_mobile",
|
|
275
|
+
"label": "手机",
|
|
276
|
+
"type": "tpl",
|
|
277
|
+
"id": "u:b95c69a1cd84",
|
|
278
|
+
"tpl": "${tabs_options|filter:value:equals:tab_name|pick:mobile|isTrue:'✔':'✘'}",
|
|
279
|
+
"placeholder": "-",
|
|
280
|
+
"remark": "显示在手机菜单中"
|
|
281
|
+
}
|
|
282
|
+
],
|
|
283
|
+
"className": "col-span-2 m-0",
|
|
284
|
+
"labelClassName": "text-left",
|
|
285
|
+
"source": "${tab_items}",
|
|
286
|
+
"footable": false,
|
|
287
|
+
"headerToolbar": [
|
|
288
|
+
{
|
|
289
|
+
"type": "button",
|
|
290
|
+
"label": "生成选项卡",
|
|
291
|
+
"id": "u:a35a2276145d",
|
|
292
|
+
"tpl": "内容",
|
|
293
|
+
"actionType": "custom",
|
|
294
|
+
"onEvent": {
|
|
295
|
+
"click": {
|
|
296
|
+
"actions": [
|
|
297
|
+
{
|
|
298
|
+
"actionType": "custom",
|
|
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}"
|
|
300
|
+
}
|
|
301
|
+
],
|
|
302
|
+
"weight": 0
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"type": "button",
|
|
308
|
+
"actionType": "dialog",
|
|
309
|
+
"dialog": {
|
|
310
|
+
"title": "设置选项卡",
|
|
311
|
+
"body": [
|
|
312
|
+
{
|
|
313
|
+
"type": "transfer",
|
|
314
|
+
"name": "picked_tabs",
|
|
315
|
+
"value": "${tab_items|pick:tab_name}",
|
|
316
|
+
"sortable": true,
|
|
317
|
+
"source": "${tabs_options}",
|
|
318
|
+
"searchable": true
|
|
319
|
+
}
|
|
320
|
+
],
|
|
321
|
+
"onEvent": {
|
|
322
|
+
"confirm": {
|
|
323
|
+
"actions": [
|
|
324
|
+
{
|
|
325
|
+
"actionType": "setValue",
|
|
326
|
+
"args": {
|
|
327
|
+
"value": "${event.data|clearTabs}"
|
|
328
|
+
},
|
|
329
|
+
"componentId": "apps-form"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"actionType": "setValue",
|
|
333
|
+
"args": {
|
|
334
|
+
"value": "${event.data|convertDataForTabs}"
|
|
335
|
+
},
|
|
336
|
+
"componentId": "apps-form"
|
|
337
|
+
}
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
"size": "lg"
|
|
342
|
+
},
|
|
343
|
+
"label": "设置选项卡",
|
|
344
|
+
"id": "u:853b890ab524"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
"type": "button",
|
|
348
|
+
"id": "u:ec9931ea883c",
|
|
349
|
+
"label": "设置分组",
|
|
350
|
+
"actionType": "dialog",
|
|
351
|
+
"dialog": {
|
|
352
|
+
"title": "设置分组",
|
|
353
|
+
"body": [
|
|
354
|
+
{
|
|
355
|
+
"type": "input-table",
|
|
356
|
+
"name": "setting_groups",
|
|
357
|
+
"addable": true,
|
|
358
|
+
"draggable": true,
|
|
359
|
+
"editable": true,
|
|
360
|
+
"columns": [
|
|
361
|
+
{
|
|
362
|
+
"name": "group_name",
|
|
363
|
+
"label": "名称"
|
|
364
|
+
}
|
|
365
|
+
],
|
|
366
|
+
"value": "${tab_groups}",
|
|
367
|
+
"removable": true
|
|
368
|
+
}
|
|
369
|
+
],
|
|
370
|
+
"onEvent": {
|
|
371
|
+
"confirm": {
|
|
372
|
+
"actions": [
|
|
373
|
+
{
|
|
374
|
+
"actionType": "setValue",
|
|
375
|
+
"args": {
|
|
376
|
+
"value": "${event.data|clearTabs}"
|
|
377
|
+
},
|
|
378
|
+
"componentId": "apps-form"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"actionType": "setValue",
|
|
382
|
+
"args": {
|
|
383
|
+
"value": "${event.data|convertDataForGroups}"
|
|
384
|
+
},
|
|
385
|
+
"componentId": "apps-form"
|
|
386
|
+
}
|
|
387
|
+
]
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
"type": "dialog",
|
|
391
|
+
"size": "lg"
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
],
|
|
395
|
+
"id": "u:22121edc42b1",
|
|
396
|
+
"perPageAvailable": [
|
|
397
|
+
10
|
|
398
|
+
],
|
|
399
|
+
"messages": {},
|
|
400
|
+
"visible": "typeof this.visibleOn === \"string\" ? 2 : 1",
|
|
401
|
+
"visibleOn": " !!this.tabs_options"
|
|
402
|
+
}
|
|
403
|
+
],
|
|
404
|
+
"id": "u:d5b736e2a2f5",
|
|
405
|
+
"size": "none"
|
|
406
|
+
}
|
|
407
|
+
],
|
|
408
|
+
"id": "u:989a6aa9b805"
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"title": "外接应用",
|
|
412
|
+
"body": [
|
|
413
|
+
{
|
|
414
|
+
"type": "wrapper",
|
|
415
|
+
"className": "form-content",
|
|
416
|
+
"body": [
|
|
417
|
+
{
|
|
418
|
+
"name": "url",
|
|
419
|
+
"label": "外部链接",
|
|
420
|
+
"type": "input-url",
|
|
421
|
+
"className": "m-0",
|
|
422
|
+
"labelClassName": "text-left",
|
|
423
|
+
"id": "u:d7116a113670"
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
"name": "is_use_ie",
|
|
427
|
+
"label": "使用IE打开(需使用Steedos桌面客户端)",
|
|
428
|
+
"type": "checkbox",
|
|
429
|
+
"tpl": null,
|
|
430
|
+
"className": "m-0",
|
|
431
|
+
"labelClassName": "text-left",
|
|
432
|
+
"id": "u:44fa8ee006c1"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"name": "is_use_iframe",
|
|
436
|
+
"label": "使用iframe打开",
|
|
437
|
+
"type": "checkbox",
|
|
438
|
+
"tpl": null,
|
|
439
|
+
"className": "m-0",
|
|
440
|
+
"labelClassName": "text-left",
|
|
441
|
+
"id": "u:ba806048fa36"
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"name": "is_new_window",
|
|
445
|
+
"label": "在新窗口打开",
|
|
446
|
+
"type": "checkbox",
|
|
447
|
+
"tpl": null,
|
|
448
|
+
"className": "m-0",
|
|
449
|
+
"labelClassName": "text-left",
|
|
450
|
+
"id": "u:150163f04699"
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"name": "on_click",
|
|
454
|
+
"label": "链接脚本",
|
|
455
|
+
"type": "textarea",
|
|
456
|
+
"tpl": "<b><%=data.on_click%></b>",
|
|
457
|
+
"className": "col-span-2 m-0",
|
|
458
|
+
"labelClassName": "text-left",
|
|
459
|
+
"id": "u:0fe6df9cc818"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"name": "auth_name",
|
|
463
|
+
"label": "验证域名",
|
|
464
|
+
"type": "input-text",
|
|
465
|
+
"className": "m-0",
|
|
466
|
+
"labelClassName": "text-left",
|
|
467
|
+
"id": "u:b084c94a8219"
|
|
468
|
+
},
|
|
469
|
+
{
|
|
470
|
+
"name": "secret",
|
|
471
|
+
"label": "API 密钥",
|
|
472
|
+
"type": "input-text",
|
|
473
|
+
"className": "m-0",
|
|
474
|
+
"labelClassName": "text-left",
|
|
475
|
+
"id": "u:8a56de0be5bb"
|
|
476
|
+
}
|
|
477
|
+
],
|
|
478
|
+
"size": "none",
|
|
479
|
+
"id": "u:09713a014209"
|
|
480
|
+
}
|
|
481
|
+
],
|
|
482
|
+
"id": "u:17ecc1ec4435"
|
|
483
|
+
}
|
|
484
|
+
],
|
|
485
|
+
"tabsMode": "line",
|
|
486
|
+
"className": "",
|
|
487
|
+
"contentClassName": ""
|
|
488
|
+
}
|
|
489
|
+
],
|
|
490
|
+
"panelClassName": "m-0 -mt-3",
|
|
491
|
+
"actions": [
|
|
492
|
+
{
|
|
493
|
+
"type": "button",
|
|
494
|
+
"label": "取消",
|
|
495
|
+
"actionType": "",
|
|
496
|
+
"level": "default",
|
|
497
|
+
"block": false,
|
|
498
|
+
"onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
|
|
499
|
+
"id": "u:f2208dc2b4cd"
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
"type": "button",
|
|
503
|
+
"label": "保存",
|
|
504
|
+
"actionType": "submit",
|
|
505
|
+
"level": "info",
|
|
506
|
+
"id": "u:207386fce204"
|
|
507
|
+
}
|
|
508
|
+
],
|
|
509
|
+
"actionsClassName": "p-sm b-t b-light text-center",
|
|
510
|
+
"affixFooter": false,
|
|
511
|
+
"debug": false,
|
|
512
|
+
"onEvent": {
|
|
513
|
+
"inited": {
|
|
514
|
+
"actions": [
|
|
515
|
+
{
|
|
516
|
+
"actionType": "custom",
|
|
517
|
+
"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});"
|
|
518
|
+
}
|
|
519
|
+
]
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
]
|
|
524
|
+
}
|
|
525
|
+
],
|
|
526
|
+
"regions": [
|
|
527
|
+
"body"
|
|
528
|
+
],
|
|
529
|
+
"data": {
|
|
530
|
+
"objectName": "apps",
|
|
531
|
+
"context": {
|
|
532
|
+
"rootUrl": "http://127.0.0.1:5800"
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
"id": "u:953fda4052b6",
|
|
536
|
+
"bodyClassName": "p-0",
|
|
537
|
+
"name": "page_edit_${recordId}",
|
|
538
|
+
"initApi": null,
|
|
539
|
+
"initFetch": null
|
|
540
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
is_active: true
|
|
5
|
+
label: 应用程序表单
|
|
6
|
+
object_name: apps
|
|
7
|
+
pageAssignments:
|
|
8
|
+
- desktop: true
|
|
9
|
+
mobile: true
|
|
10
|
+
page: apps_form
|
|
11
|
+
type: orgDefault
|
|
12
|
+
render_engine: amis
|
|
13
|
+
type: form
|
|
14
|
+
widgets: []
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "page",
|
|
3
|
+
"body": [
|
|
4
|
+
{
|
|
5
|
+
"type": "form",
|
|
6
|
+
"mode": "normal",
|
|
7
|
+
"persistData": false,
|
|
8
|
+
"promptPageLeave": true,
|
|
9
|
+
"name": "form_edit_${recordId}",
|
|
10
|
+
"title": "",
|
|
11
|
+
"api": {
|
|
12
|
+
"method": "post",
|
|
13
|
+
"url": "${context.rootUrl}/service/api/amis-metadata-objects/objects/generate/tabs",
|
|
14
|
+
"data": {
|
|
15
|
+
"objects": "${objects}",
|
|
16
|
+
"modalName": "${modalName}",
|
|
17
|
+
"objectName": "${objectName}",
|
|
18
|
+
"$": "$$",
|
|
19
|
+
"recordId": "${recordId}"
|
|
20
|
+
},
|
|
21
|
+
"requestAdaptor": "const formData = api.data.$;\napi.data = { objects: formData.objects };\nreturn api;",
|
|
22
|
+
"responseData": null,
|
|
23
|
+
"adaptor": "\nSteedosUI.getRef(api.body.modalName).close();\nif (api.body.objectName === \"tabs\") {\n // 在tabs列表操作”对象选项卡“按钮,保存后需要刷新主列表\n refreshGrid && refreshGrid();\n}\nreturn payload;\n ",
|
|
24
|
+
"headers": {
|
|
25
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"initApi": "",
|
|
29
|
+
"initFetch": true,
|
|
30
|
+
"body": [
|
|
31
|
+
{
|
|
32
|
+
"label": "",
|
|
33
|
+
"type": "transfer",
|
|
34
|
+
"name": "objects",
|
|
35
|
+
"options": [],
|
|
36
|
+
"id": "u:e224b24aa867",
|
|
37
|
+
"searchable": true,
|
|
38
|
+
"source": "get:${context.rootUrl}/service/api/amis-metadata-objects/objects/generate_tabs_options",
|
|
39
|
+
"headers": {
|
|
40
|
+
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"panelClassName": "m-0",
|
|
45
|
+
"bodyClassName": "p-4",
|
|
46
|
+
"actions": [
|
|
47
|
+
{
|
|
48
|
+
"type": "button",
|
|
49
|
+
"label": "取消",
|
|
50
|
+
"actionType": "",
|
|
51
|
+
"level": "default",
|
|
52
|
+
"block": false,
|
|
53
|
+
"onClick": "SteedosUI.getRef(props.data.__super.modalName).close();",
|
|
54
|
+
"id": "u:bf2587b53d64"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"type": "button",
|
|
58
|
+
"label": "确定",
|
|
59
|
+
"actionType": "submit",
|
|
60
|
+
"level": "info",
|
|
61
|
+
"id": "u:08afd6e53cab"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"actionsClassName": "p-sm b-t b-light text-center",
|
|
65
|
+
"className": "steedos-amis-form -mt-3",
|
|
66
|
+
"checkAll": false,
|
|
67
|
+
"id": "object-layout-form",
|
|
68
|
+
"debug": false,
|
|
69
|
+
"messages": {
|
|
70
|
+
"fetchFailed": "初始化失败",
|
|
71
|
+
"saveFailed": "保存失败"
|
|
72
|
+
},
|
|
73
|
+
"onEvent": {
|
|
74
|
+
"submitSucc": {
|
|
75
|
+
"actions": [
|
|
76
|
+
{
|
|
77
|
+
"actionType": "custom",
|
|
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}"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"regions": [
|
|
86
|
+
"body"
|
|
87
|
+
],
|
|
88
|
+
"data": {
|
|
89
|
+
"context": {
|
|
90
|
+
"rootUrl": "http://127.0.0.1:5800"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"id": "u:3b0de7e88def",
|
|
94
|
+
"bodyClassName": "p-0",
|
|
95
|
+
"name": "page_edit_${recordId}",
|
|
96
|
+
"initApi": null,
|
|
97
|
+
"initFetch": null,
|
|
98
|
+
"className": "page-form-object_layouts"
|
|
99
|
+
}
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
"api": {
|
|
222
222
|
"method": "get",
|
|
223
223
|
"url": "/service/api/amis-metadata-objects/objects/${object_name}/actions/options",
|
|
224
|
-
"adaptor": "// 把”选择按钮“弹出窗口中设置的按钮转为主表单buttons字段值格式\
|
|
224
|
+
"adaptor": "const amisRegisterFilter = amisRequire('amis').registerFilter;\n// 把”选择按钮“弹出窗口中设置的按钮转为主表单buttons字段值格式\namisRegisterFilter('convertDataForButtons', function (input) {\n let pickedButtons = input.picked_buttons || [];\n const superButtons = _.keyBy(input.__super.buttons, 'button_name');\n if (typeof pickedButtons === \"string\") {\n pickedButtons = pickedButtons.split(\",\");\n }\n const convertedButtons = pickedButtons.map(function (key) {\n return superButtons[key] || {\n button_name: key\n }\n });\n return {\n buttons: convertedButtons\n }\n});\n\n// 按钮列表每一列数据变量时立即同步值到表单中\namisRegisterFilter('quickEidtSaveForButton', function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input.__super;\n const formValue = input.__super.__super.__super;\n const button_name = rowValue.button_name;\n rowValue[prop_name] = currentPropValue;\n let newButtons = formValue.buttons.map(function (item) {\n if (item.button_name == button_name) {\n return Object.assign({}, item, rowValue);\n }\n else {\n return item;\n }\n });\n return {\n buttons: newButtons\n }\n});\n\n// 清空主表单buttons字段值\namisRegisterFilter('clearButtons', function (input) {\n return {\n buttons: []\n }\n});\n\n\n// 新建页面布局时初始化buttons默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\namisRegisterFilter('initDefaultButtons', function (input) {\n const superValues = this.data.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n buttons: superValues.buttons,\n }\n});\n\nlet data = payload.data;\ndata.buttons_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n",
|
|
225
225
|
"sendOn": "!!this.object_name"
|
|
226
226
|
},
|
|
227
227
|
"className": "col-span-2 m-0",
|
|
@@ -481,7 +481,7 @@
|
|
|
481
481
|
"api": {
|
|
482
482
|
"method": "get",
|
|
483
483
|
"url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/layout_options",
|
|
484
|
-
"adaptor": "const fieldGroupKey = \"group\";\nconst getFieldsSortFun = function(groupNames){\n return function(m,n){\n var tempM = !!m[fieldGroupKey] ? 1 : 0;\n var tempN = !!n[fieldGroupKey] ? 1 : 0;\n if(!m[fieldGroupKey] || !n[fieldGroupKey]){\n // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[fieldGroupKey]) - groupNames.indexOf(n[fieldGroupKey]);\n };\n}\n\n// 把”选择字段“弹出窗口中设置的字段转为主表单fields字段值格式\
|
|
484
|
+
"adaptor": "const amisRegisterFilter = amisRequire('amis').registerFilter;\nconst fieldGroupKey = \"group\";\nconst getFieldsSortFun = function(groupNames){\n return function(m,n){\n var tempM = !!m[fieldGroupKey] ? 1 : 0;\n var tempN = !!n[fieldGroupKey] ? 1 : 0;\n if(!m[fieldGroupKey] || !n[fieldGroupKey]){\n // 没有配置group属性的字段排在前面\n return tempM - tempN;\n }\n // 字段所属分组不在groupNames时排在前面,其他字段按其所属分组在groupNames中的排序先后顺序排序,所属分组相同的字段排在一起。\n return groupNames.indexOf(m[fieldGroupKey]) - groupNames.indexOf(n[fieldGroupKey]);\n };\n}\n\n// 把”选择字段“弹出窗口中设置的字段转为主表单fields字段值格式\namisRegisterFilter('convertDataForFields', function (input) {\n let pickedFields = input.picked_fields || [];\n const superFields = _.keyBy(input.__super.fields, 'field_name');\n if(typeof pickedFields === \"string\"){\n pickedFields = pickedFields.split(\",\");\n }\n const fieldOptions = lodash.keyBy(this.data.__super.__super.__super.__super.__super.fields_options, \"value\");\n const convertedFields = pickedFields.map(function (field_name) {\n const superField = superFields[field_name];\n if (superField) {\n return superField;\n }\n else {\n const fieldOption = fieldOptions[field_name];\n return {\n field_name: field_name,\n is_readonly: fieldOption.readonly,\n is_required: fieldOption.required,\n group: fieldOption.group\n }\n }\n });\n const fieldGroups = this.data.__super.__super.__super.__super.__super.field_groups;\n const groupNames = lodash.compact(lodash.map(fieldGroups,\"group_name\"));\n // fields重新按分组排序\n convertedFields.sort(getFieldsSortFun(groupNames));\n return {\n fields: convertedFields\n }\n});\n\n// 字段列表每一列数据变量时立即同步值到表单中\namisRegisterFilter('quickEidtSaveForField', function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = input.__super;\n const formValue = input.__super.__super.__super;\n const field_name = rowValue.field_name;\n rowValue[prop_name] = currentPropValue;\n let newFields = formValue.fields.map(function (item) {\n if (item.field_name == field_name) {\n return Object.assign({}, item, rowValue);\n }\n else { \n return item;\n }\n });\n const fieldGroups = this.data.__super.__super.field_groups;\n const groupNames = lodash.compact(lodash.map(fieldGroups,\"group_name\"));\n // fields重新按分组排序\n newFields.sort(getFieldsSortFun(groupNames));\n return {\n fields: newFields\n }\n});\n\n// 清空主表单fields字段值\namisRegisterFilter('clearFields', function (input) {\n return {\n fields: []\n }\n});\n\n// 把”设置分组“弹出窗口中设置的分组转为主表单groups字段值格式\n// 同时根据新的groups排序重新设置fields属性的字段先后次序\n// 因为直接设置fields值有bug,即新值老值会串,所以需要先执行上面的clearFields清除原来的值\namisRegisterFilter('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 fields = this.data.__super.__super.items;\n // fields重新按分组排序\n fields.sort(getFieldsSortFun(groupNames));\n\n return {\n field_groups: convertedGroups, \n fields: fields\n }\n});\n\n// 把字段中配置的group属性加到主表field_groups属性中\namisRegisterFilter('mixingGroupsFromFields', function (input) {\n const groupsOptions = input.field_groups_options;\n const groups = this.data.field_groups || [];\n const groupsForMixing = groupsOptions.map(function (item) {\n return {\n group_name: item\n }\n });\n const mixedGroups = lodash.unionBy(groups, groupsForMixing, \"group_name\");\n return {\n field_groups: mixedGroups\n }\n});\n\n// 新建页面布局时初始化fields默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\namisRegisterFilter('initDefaultFields', function (input) {\n const superValues = this.data.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n fields: superValues.fields,\n }\n});\n\nlet data = payload.data;\ndata.fields_options = data.options;\ndata.field_groups_options = lodash.uniq(lodash.compact(lodash.map(data.options, \"group\"))) || [];\ndelete data.options\npayload.data = data;\nreturn payload;\n",
|
|
485
485
|
"sendOn": "!!this.object_name",
|
|
486
486
|
"data": null
|
|
487
487
|
},
|
|
@@ -794,7 +794,7 @@
|
|
|
794
794
|
"method": "get",
|
|
795
795
|
"url": "/service/api/amis-metadata-objects/objects/${object_name}/relatedLists/options",
|
|
796
796
|
"sendOn": "!!this.object_name",
|
|
797
|
-
"adaptor": "// 把”选择子表“弹出窗口中设置的子表转为主表单related_lists字段值格式\
|
|
797
|
+
"adaptor": "const amisRegisterFilter = amisRequire('amis').registerFilter;\n// 把”选择子表“弹出窗口中设置的子表转为主表单related_lists字段值格式\namisRegisterFilter('convertDataForRelatedLists', function (input) {\n let pickedRelateds = input.picked_related_lists || [];\n const superRelateds = _.keyBy(input.__super.related_lists, 'related_field_fullname');\n if (typeof pickedRelateds === \"string\") {\n pickedRelateds = pickedRelateds.split(\",\");\n }\n const convertedRelateds = pickedRelateds.map(function (key) {\n return superRelateds[key] || {\n related_field_fullname: key,\n sort_order: \"asc\"\n }\n });\n return {\n related_lists: convertedRelateds\n }\n});\n\n// 字段列表每一列数据变量时立即同步值到表单中\namisRegisterFilter('quickEidtSaveForRelatedList', function (input, prop_name) {\n const currentPropValue = input.value;\n const rowValue = this.data;\n delete rowValue.event;\n const formValue = rowValue.__super.__super;\n const related_field_fullname = rowValue.related_field_fullname;\n rowValue[prop_name] = currentPropValue;\n let newRelatedLists = formValue.related_lists.map(function (item) {\n if (item.related_field_fullname == related_field_fullname) {\n if (prop_name === \"related_field_fullname\") {\n // 直接在表格上变更子表选项的话,清除其他属性值\n return {\n related_field_fullname: currentPropValue,\n sort_order: \"asc\"\n }\n }\n else {\n return Object.assign({}, item, rowValue);\n }\n }\n else {\n return item;\n }\n });\n const newFormDoc = {\n related_lists: newRelatedLists\n };\n if (prop_name === \"field_names\" || prop_name === \"sort_field_name\") { \n // 修改子表显示字段和排序字段时把变更后的字段值显示为label\n const currentOptions = {};\n currentOptions[related_field_fullname] = input.options;\n newFormDoc.related_object_fields_options = Object.assign({}, formValue.related_object_fields_options, currentOptions);\n }\n return newFormDoc;\n});\n\n// 清空主表单fields字段值\namisRegisterFilter('clearRelatedLists', function (input) {\n return {\n related_lists: []\n }\n});\n\n// 新建页面布局时初始化related_lists默认值,字段值是CRUD表格控件渲染,新建页面布局时,不会自动填充到form中,需要手动填充\namisRegisterFilter('initDefaultRelatedLists', function (input) {\n const superValues = this.data.__super || {};\n if (superValues.recordId) {\n // 编辑记录本来就会初始化相关字段值,不需要再初始化\n return;\n }\n return {\n related_lists: superValues.related_lists,\n }\n});\n\nlet data = payload.data;\ndata.related_lists_options = data.options;\ndelete data.options\npayload.data = data;\nreturn payload;\n"
|
|
798
798
|
},
|
|
799
799
|
"className": "col-span-2 m-0",
|
|
800
800
|
"affixFooter": false
|
|
@@ -871,10 +871,7 @@
|
|
|
871
871
|
"data": {
|
|
872
872
|
"objectName": "object_layouts",
|
|
873
873
|
"context": {
|
|
874
|
-
"rootUrl": "http://127.0.0.1:5800"
|
|
875
|
-
"tenantId": "hKdnwE55WcnWveYxS",
|
|
876
|
-
"userId": "62ede4f62161e377e35de58c",
|
|
877
|
-
"authToken": "20ec4d08e58513a09df7a5a5f2f5fb40d52e3e1722de92970a16be9d3db27dc50be21a5c8e9cab1caa7932"
|
|
874
|
+
"rootUrl": "http://127.0.0.1:5800"
|
|
878
875
|
}
|
|
879
876
|
},
|
|
880
877
|
"bodyClassName": "p-0",
|
|
@@ -127,6 +127,26 @@ module.exports = {
|
|
|
127
127
|
|
|
128
128
|
return { status: 0, data: { options } }
|
|
129
129
|
},
|
|
130
|
+
},
|
|
131
|
+
getObjectsForGenerateTabsOptions: {
|
|
132
|
+
rest: {
|
|
133
|
+
method: "GET",
|
|
134
|
+
path: "/objects/generate_tabs_options"
|
|
135
|
+
},
|
|
136
|
+
async handler(ctx) {
|
|
137
|
+
const options = await this.getObjectsGenerateTabsOptions(ctx);
|
|
138
|
+
return { status: 0, data: { options } }
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
generateTabs: {
|
|
142
|
+
rest: {
|
|
143
|
+
method: "POST",
|
|
144
|
+
path: "/objects/generate/tabs"
|
|
145
|
+
},
|
|
146
|
+
async handler(ctx) {
|
|
147
|
+
const result = await this.generateTabs(ctx);
|
|
148
|
+
return { status: 0, data: result }
|
|
149
|
+
}
|
|
130
150
|
}
|
|
131
151
|
},
|
|
132
152
|
|
|
@@ -357,6 +377,117 @@ module.exports = {
|
|
|
357
377
|
})
|
|
358
378
|
return options;
|
|
359
379
|
}
|
|
380
|
+
},
|
|
381
|
+
getObjectsGenerateTabsOptions: {
|
|
382
|
+
async handler(ctx) {
|
|
383
|
+
const userSession = ctx.meta.user;
|
|
384
|
+
const lng = userSession.language || 'zh-CN';
|
|
385
|
+
const spaceId = userSession.spaceId;
|
|
386
|
+
const objectTabs = await objectql.getObject('tabs').find({filters: [['type', '=', "object"]]});
|
|
387
|
+
const tabObjects = _.map(objectTabs, "object");
|
|
388
|
+
const allMetadataObjects = await objectql.getSteedosSchema().getAllObject();
|
|
389
|
+
const allObjects = _.map(clone(allMetadataObjects), 'metadata');
|
|
390
|
+
const query = {
|
|
391
|
+
filters: [['hidden', '!=', true], ['name', '<>', tabObjects]],
|
|
392
|
+
projection: {
|
|
393
|
+
name: 1,
|
|
394
|
+
label: 1
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
// 只列出未找到tabs记录的对象清单
|
|
398
|
+
const objects = objectql.getSteedosSchema().metadataDriver.find(allObjects, query, spaceId);
|
|
399
|
+
|
|
400
|
+
_.each(objects, (object)=>{
|
|
401
|
+
if(object && object.name){
|
|
402
|
+
steedosI18n.translationObject(lng, object.name, object)
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
return _.map(objects, (object)=>{
|
|
406
|
+
return {
|
|
407
|
+
value: object.name,
|
|
408
|
+
label: object.label || object.name
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
generateTabs: {
|
|
414
|
+
async handler(ctx) {
|
|
415
|
+
let selectedObjects = ctx.params && ctx.params.objects && ctx.params.objects.split(",");
|
|
416
|
+
const userSession = ctx.meta.user;
|
|
417
|
+
const lng = userSession.language || 'zh-CN';
|
|
418
|
+
const spaceId = userSession.spaceId;
|
|
419
|
+
const userId = userSession.userId;
|
|
420
|
+
const companyId = userSession.company_id;
|
|
421
|
+
const companyIds = userSession.company_ids;
|
|
422
|
+
const allMetadataObjects = await objectql.getSteedosSchema().getAllObject();
|
|
423
|
+
const allObjects = _.map(clone(allMetadataObjects), 'metadata');
|
|
424
|
+
const query = {
|
|
425
|
+
filters: [['name', 'in', selectedObjects]], //['hidden', '!=', true] ,
|
|
426
|
+
projection: {
|
|
427
|
+
name: 1,
|
|
428
|
+
label: 1
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
const objects = objectql.getSteedosSchema().metadataDriver.find(allObjects, query, spaceId);
|
|
433
|
+
|
|
434
|
+
_.each(objects, (object) => {
|
|
435
|
+
if (object && object.name) {
|
|
436
|
+
steedosI18n.translationObject(lng, object.name, object)
|
|
437
|
+
}
|
|
438
|
+
})
|
|
439
|
+
const errors = [];
|
|
440
|
+
let doneCount = 0;
|
|
441
|
+
for(let i = 0;i < objects.length; i++) {
|
|
442
|
+
const object = objects[i];
|
|
443
|
+
try{
|
|
444
|
+
const existCount = await objectql.getObject('tabs').count({filters: [['object', '=', object.name]]});
|
|
445
|
+
if(existCount > 0){
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
const tabLabel = object.label || object.name;
|
|
449
|
+
const tabName = "object_" + object.name.replace(/__c$/, "");
|
|
450
|
+
const now = new Date();
|
|
451
|
+
const doc = {
|
|
452
|
+
label: tabLabel,
|
|
453
|
+
name: tabName,
|
|
454
|
+
icon: object.icon,
|
|
455
|
+
type: "object",
|
|
456
|
+
mobile: true,
|
|
457
|
+
desktop: true,
|
|
458
|
+
object: object.name,
|
|
459
|
+
space: spaceId,
|
|
460
|
+
owner: userId,
|
|
461
|
+
created_by: userId,
|
|
462
|
+
created: now,
|
|
463
|
+
modified_by: userId,
|
|
464
|
+
modified: now,
|
|
465
|
+
company_id: companyId,
|
|
466
|
+
company_ids: companyIds
|
|
467
|
+
};
|
|
468
|
+
const tab = await objectql.getObject('tabs').insert(doc);
|
|
469
|
+
if(tab && tab._id){
|
|
470
|
+
doneCount++;
|
|
471
|
+
}
|
|
472
|
+
else{
|
|
473
|
+
errors.push({
|
|
474
|
+
object: (object.label || object.name) + `(${object.name})`,
|
|
475
|
+
message: ""
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
catch(ex){
|
|
480
|
+
errors.push({
|
|
481
|
+
object: (object.label || object.name) + `(${object.name})`,
|
|
482
|
+
message: ex.message
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
return {
|
|
487
|
+
doneCount:doneCount,
|
|
488
|
+
errors: errors
|
|
489
|
+
}
|
|
490
|
+
}
|
|
360
491
|
}
|
|
361
492
|
}
|
|
362
493
|
};
|
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
|
}
|
package/public/amis/amis.css
CHANGED
|
@@ -52,7 +52,7 @@ body{
|
|
|
52
52
|
min-width: 100px;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.steedos-amis-form .antd-Collapse .antd-Form--normal{
|
|
55
|
+
.steedos-amis-form .antd-Collapse .antd-Form--normal, .antd-Form--normal .antd-Tabs .antd-Tabs-content .antd-Tabs-pane .form-content{
|
|
56
56
|
display: grid!important;
|
|
57
57
|
grid-template-columns: repeat(2,minmax(0,1fr))!important;
|
|
58
58
|
grid-row-gap: 1rem!important;
|