@lambo-design/shared 1.0.0-beta.237 → 1.0.0-beta.239
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/config/config.js +51 -51
- package/config/env.js +4 -4
- package/config/index.js +7 -7
- package/config/themes/atrovirens/atrovirens.css +575 -575
- package/config/themes/atrovirens/atrovirens.less +667 -667
- package/config/themes/atrovirens/var.less +674 -674
- package/config/themes/blue/blue.css +575 -575
- package/config/themes/blue/blue.less +669 -669
- package/config/themes/blue/var.less +677 -677
- package/config/themes/blue-white/blue-white.css +575 -575
- package/config/themes/blue-white/blue-white.less +669 -669
- package/config/themes/blue-white/var.less +676 -676
- package/config/themes/blue-white-tight/blue-white-tight.css +576 -576
- package/config/themes/blue-white-tight/blue-white-tight.less +672 -672
- package/config/themes/blue-white-tight/var.less +677 -677
- package/config/themes/danqing/danqing.css +576 -575
- package/config/themes/danqing/danqing.css.map +1 -1
- package/config/themes/danqing/danqing.less +668 -668
- package/config/themes/danqing/danqing.wxss +572 -572
- package/config/themes/danqing/var.less +679 -679
- package/config/themes/deep/deep.css +575 -575
- package/config/themes/deep/deep.less +669 -669
- package/config/themes/deep/var.less +677 -677
- package/config/themes/default/default.css +575 -575
- package/config/themes/default/default.less +671 -671
- package/config/themes/default/var.less +677 -677
- package/config/themes/eap/eap.css +575 -575
- package/config/themes/eap/eap.less +671 -671
- package/config/themes/eap/var.less +677 -677
- package/config/themes/gold/gold.css +575 -575
- package/config/themes/gold/gold.less +671 -671
- package/config/themes/gold/var.less +677 -677
- package/config/themes/index.js +28 -28
- package/config/themes/lime/lime.css +575 -575
- package/config/themes/lime/lime.less +671 -671
- package/config/themes/lime/var.less +678 -678
- package/config/themes/orange/orange.css +575 -575
- package/config/themes/orange/orange.less +671 -671
- package/config/themes/orange/var.less +678 -678
- package/config/themes/red/red.css +575 -575
- package/config/themes/red/red.less +671 -671
- package/config/themes/red/var.less +677 -677
- package/config/themes/theme-atrovirens.js +558 -558
- package/config/themes/theme-blue.js +558 -558
- package/config/themes/theme-bw.js +558 -558
- package/config/themes/theme-bwt.js +559 -559
- package/config/themes/theme-danqing.js +558 -558
- package/config/themes/theme-deep.js +558 -558
- package/config/themes/theme-default.js +558 -558
- package/config/themes/theme-eap.js +558 -558
- package/config/themes/theme-gold.js +558 -558
- package/config/themes/theme-lime.js +558 -558
- package/config/themes/theme-orange.js +559 -559
- package/config/themes/theme-red.js +558 -558
- package/config/themes/theme-white.js +557 -557
- package/config/themes/white/var.less +675 -675
- package/config/themes/white/white.css +575 -575
- package/config/themes/white/white.less +668 -668
- package/directives/index.js +23 -23
- package/directives/module/draggable.js +56 -56
- package/directives/module/permission.js +49 -49
- package/directives/module/print.js +1 -1
- package/directives/module/vue-print-nb/README.md +63 -63
- package/directives/module/vue-print-nb/print.js +94 -94
- package/directives/module/vue-print-nb/printarea.js +532 -532
- package/index.js +10 -10
- package/nstyles/common.less +197 -197
- package/nstyles/components/404.less +46 -46
- package/nstyles/components/button.less +34 -34
- package/nstyles/components/date-picker.less +37 -37
- package/nstyles/components/drawer.less +20 -20
- package/nstyles/components/dropdown.less +18 -18
- package/nstyles/components/excel-flow.less +72 -72
- package/nstyles/components/form.less +313 -303
- package/nstyles/components/index.less +23 -23
- package/nstyles/components/layout/collect.less +10 -10
- package/nstyles/components/layout/detail-view.less +107 -107
- package/nstyles/components/layout/full-screen.less +7 -7
- package/nstyles/components/layout/index.less +7 -7
- package/nstyles/components/layout/other-menu.less +142 -142
- package/nstyles/components/layout/page-view.less +101 -101
- package/nstyles/components/layout/sider-trigger.less +41 -41
- package/nstyles/components/layout/tags-nav.less +113 -113
- package/nstyles/components/modal.less +85 -85
- package/nstyles/components/n-button.less +131 -131
- package/nstyles/components/n-image-preview.less +131 -131
- package/nstyles/components/n-model/index.less +19 -19
- package/nstyles/components/n-model/report-index.less +43 -43
- package/nstyles/components/n-panel.less +40 -40
- package/nstyles/components/n-picker.less +37 -37
- package/nstyles/components/n-sign.less +17 -17
- package/nstyles/components/n-tooltip.less +10 -10
- package/nstyles/components/panel.less +31 -31
- package/nstyles/components/select.less +3 -3
- package/nstyles/components/sign.less +27 -27
- package/nstyles/components/table.less +315 -315
- package/nstyles/components/tree.less +158 -158
- package/nstyles/components/upload.less +164 -164
- package/nstyles/index.less +5 -5
- package/nstyles/reset.less +65 -65
- package/nstyles/third/ag.less +174 -174
- package/nstyles/third/index.less +11 -11
- package/nstyles/third/view-design.less +366 -366
- package/nstyles/variables/base.less +143 -143
- package/nstyles/variables/index.less +4 -4
- package/nstyles/variables/theme/default/button.less +7 -7
- package/nstyles/variables/theme/default/common.less +57 -57
- package/nstyles/variables/theme/default/index.less +7 -7
- package/nstyles/variables/theme/default/layout.less +40 -40
- package/nstyles/variables/theme/default/table.less +37 -37
- package/nstyles/variables/theme/default/tag.less +3 -3
- package/nstyles/variables/theme/default/upload.less +3 -3
- package/nstyles/variables/theme/index.less +13 -13
- package/nstyles/variables/theme/small/button.less +7 -7
- package/nstyles/variables/theme/small/common.less +39 -39
- package/nstyles/variables/theme/small/index.less +5 -5
- package/nstyles/variables/theme/small/layout.less +21 -21
- package/nstyles/variables/theme/small/table.less +17 -17
- package/nstyles/variables/theme/small/tag.less +3 -3
- package/package.json +1 -1
- package/plugin/index.js +12 -12
- package/plugin/module/date-format.js +30 -30
- package/plugin/module/loading.js +26 -26
- package/plugin/module/warn-handler.js +11 -11
- package/styles/variables.less +21 -21
- package/utils/ajax/cacheconf.js +19 -19
- package/utils/ajax/content-type.js +30 -30
- package/utils/ajax/index.js +12 -12
- package/utils/ajax/interceptors.js +97 -97
- package/utils/assist.js +147 -147
- package/utils/base64.js +126 -126
- package/utils/blob.js +47 -47
- package/utils/bus.js +3 -3
- package/utils/crypto/index.js +48 -48
- package/utils/crypto/md5.js +152 -152
- package/utils/crypto/sm3.js +235 -235
- package/utils/date.js +381 -381
- package/utils/dict/built-in-dict.js +20 -20
- package/utils/dict/index.js +167 -167
- package/utils/dom.js +38 -38
- package/utils/event.js +72 -72
- package/utils/excel.js +655 -655
- package/utils/file.js +19 -19
- package/utils/form/validate.js +29 -29
- package/utils/half-year.js +68 -68
- package/utils/index.js +41 -41
- package/utils/json.js +29 -29
- package/utils/lodop.js +165 -165
- package/utils/menu/before-close.js +17 -17
- package/utils/menu/index.js +395 -395
- package/utils/mime_type.js +67 -67
- package/utils/modelerUtil.js +227 -227
- package/utils/n/api.js +22 -22
- package/utils/n/date.js +57 -57
- package/utils/n/index.js +9 -9
- package/utils/n/is-type.js +176 -176
- package/utils/n/number.js +144 -144
- package/utils/n/permission-cache.js +11 -11
- package/utils/n/reuqest/axiosN.js +17 -17
- package/utils/n/reuqest/content-type.js +19 -19
- package/utils/n/reuqest/interceptors.js +95 -95
- package/utils/n/reuqest/url-params.js +12 -12
- package/utils/n/storage.js +51 -51
- package/utils/n/token.js +51 -51
- package/utils/n/user-cache.js +11 -11
- package/utils/n/user.js +34 -34
- package/utils/n/uuid.js +16 -16
- package/utils/n-generator-routers.js +208 -208
- package/utils/n-router.js +205 -205
- package/utils/n-theme.js +30 -30
- package/utils/number.js +180 -180
- package/utils/oss.js +57 -57
- package/utils/platform.js +1334 -1334
- package/utils/quarter.js +58 -58
- package/utils/storage.js +198 -198
- package/utils/theme.js +138 -138
- package/utils/transform.js +179 -0
- package/utils/type.js +102 -102
- package/utils/util.js +795 -795
- package/utils/validator.js +181 -181
- package/utils/vxetable/index.js +25 -25
- package/utils/zoomScroll.js +9 -9
package/utils/theme.js
CHANGED
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
import themes from "../config/themes";
|
|
2
|
-
import cssVars from "css-vars-ponyfill";
|
|
3
|
-
import lan_navigator from '../styles/image/lan_navigator.png'
|
|
4
|
-
import lv_navigator from '../styles/image/lv_navigator.png'
|
|
5
|
-
import {handleSystemColor} from "./util";
|
|
6
|
-
import config from "@lambo-design/shared/config/config";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const changeByThemeKey = (themeKey) => {
|
|
10
|
-
if (themeKey) {
|
|
11
|
-
themes.forEach((theme) => {
|
|
12
|
-
if (theme.key === themeKey) {
|
|
13
|
-
changeByTheme(theme);
|
|
14
|
-
if (typeof window !== 'undefined') {
|
|
15
|
-
localStorage.setItem("theme", themeKey);
|
|
16
|
-
localStorage.setItem('themeInStyle', '1');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
} else {
|
|
21
|
-
if (typeof window !== 'undefined') {
|
|
22
|
-
themeKey = localStorage.getItem("theme");
|
|
23
|
-
}
|
|
24
|
-
if (!themeKey) {
|
|
25
|
-
themeKey = themes[0].key;
|
|
26
|
-
}
|
|
27
|
-
changeByThemeKey(themeKey);
|
|
28
|
-
}
|
|
29
|
-
cssVars({
|
|
30
|
-
rootElement: document, // default
|
|
31
|
-
include: 'link[rel=stylesheet],style'
|
|
32
|
-
});
|
|
33
|
-
return themeKey;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const changeByTheme = (theme) => {
|
|
37
|
-
// 加入自定义变量
|
|
38
|
-
let varStyleTag = document.getElementById("customVars");
|
|
39
|
-
if (!varStyleTag) {
|
|
40
|
-
varStyleTag = document.createElement("style");
|
|
41
|
-
varStyleTag.id = "customVars";
|
|
42
|
-
document.body.appendChild(varStyleTag);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
varStyleTag.innerHTML = `:root {${theme["vars"]}}`;
|
|
46
|
-
|
|
47
|
-
// 加入自定义样式
|
|
48
|
-
let styleTag = document.getElementById("customStyle");
|
|
49
|
-
if (!styleTag) {
|
|
50
|
-
styleTag = document.createElement("style");
|
|
51
|
-
styleTag.id = "customStyle";
|
|
52
|
-
document.body.appendChild(styleTag);
|
|
53
|
-
}
|
|
54
|
-
if (theme&&theme.style) {
|
|
55
|
-
styleTag.innerHTML = theme.style;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const changeThemeByThemeId = (themeId, status, filterStatus, systemForm) => {
|
|
60
|
-
// 主题切换方式(区分新旧两种:1-旧 2-新)
|
|
61
|
-
if (typeof window !== 'undefined') {
|
|
62
|
-
localStorage.setItem('themeInStyle', '2')
|
|
63
|
-
}
|
|
64
|
-
// 一键滤镜功能 - 灰度状态;
|
|
65
|
-
let grayscaleVal = '0%'
|
|
66
|
-
if (filterStatus && filterStatus === '1') {
|
|
67
|
-
grayscaleVal = '100%'
|
|
68
|
-
}
|
|
69
|
-
// 记录当前主题
|
|
70
|
-
if (typeof window !== 'undefined') {
|
|
71
|
-
// localStorage.setItem('themeIdCurrent', themeId)
|
|
72
|
-
localStorage.setItem('themeIdCurrent', themeId)
|
|
73
|
-
}
|
|
74
|
-
// 顶部栏背景图处理
|
|
75
|
-
let background_image = config.upmsServerContext + '/anon/oss/file/getImage/' + systemForm.topBkImg + '?height=64&width=1920'
|
|
76
|
-
if (!status || status === '2') {
|
|
77
|
-
if (background_image.includes('lan_navigator')) {
|
|
78
|
-
background_image = 'url(' + lan_navigator + ')'
|
|
79
|
-
} else if (background_image.includes('lv_navigator')) {
|
|
80
|
-
background_image = 'url(' + lv_navigator + ')'
|
|
81
|
-
}
|
|
82
|
-
} else if (status === '1') {
|
|
83
|
-
background_image = 'url(' + background_image + ')'
|
|
84
|
-
}
|
|
85
|
-
handleSystemColor(grayscaleVal, systemForm, background_image)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const getThemeConfig = (themeKey = 'default') =>{
|
|
89
|
-
let result = {};
|
|
90
|
-
themes.forEach((theme) => {
|
|
91
|
-
if (theme.key === themeKey) {
|
|
92
|
-
result = theme;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const getThemeVars = (themeKey = 'default') =>{
|
|
99
|
-
let theme = getThemeConfig(themeKey);
|
|
100
|
-
if (theme) {
|
|
101
|
-
return theme.vars;
|
|
102
|
-
}
|
|
103
|
-
return '';
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const getThemeVarByKey = (themeKey = 'default',varKey) => {
|
|
107
|
-
let value = '';
|
|
108
|
-
if (varKey) {
|
|
109
|
-
let vars = getThemeVars(themeKey)
|
|
110
|
-
if (vars) {
|
|
111
|
-
let startIndexOfChar = vars.indexOf(varKey);
|
|
112
|
-
if (startIndexOfChar > -1) {
|
|
113
|
-
// 从起始字符位置开始,找到下一行的起始位置
|
|
114
|
-
let endIndex = vars.indexOf('\n', startIndexOfChar);
|
|
115
|
-
if (endIndex === -1) {
|
|
116
|
-
// 如果没有找到换行符,则返回从起始字符到字符串末尾的部分
|
|
117
|
-
value = vars.substring(startIndexOfChar);
|
|
118
|
-
} else {
|
|
119
|
-
// 返回从起始字符到换行符之前的部分(不包括换行符)
|
|
120
|
-
value = vars.substring(startIndexOfChar, endIndex);
|
|
121
|
-
}
|
|
122
|
-
if (value) {
|
|
123
|
-
value = value.substring(value.indexOf(":") + 1,value.indexOf(";")).replaceAll(" ","");
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return value;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export {
|
|
132
|
-
changeByThemeKey,
|
|
133
|
-
changeByTheme,
|
|
134
|
-
changeThemeByThemeId,
|
|
135
|
-
getThemeConfig,
|
|
136
|
-
getThemeVars,
|
|
137
|
-
getThemeVarByKey
|
|
138
|
-
};
|
|
1
|
+
import themes from "../config/themes";
|
|
2
|
+
import cssVars from "css-vars-ponyfill";
|
|
3
|
+
import lan_navigator from '../styles/image/lan_navigator.png'
|
|
4
|
+
import lv_navigator from '../styles/image/lv_navigator.png'
|
|
5
|
+
import {handleSystemColor} from "./util";
|
|
6
|
+
import config from "@lambo-design/shared/config/config";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const changeByThemeKey = (themeKey) => {
|
|
10
|
+
if (themeKey) {
|
|
11
|
+
themes.forEach((theme) => {
|
|
12
|
+
if (theme.key === themeKey) {
|
|
13
|
+
changeByTheme(theme);
|
|
14
|
+
if (typeof window !== 'undefined') {
|
|
15
|
+
localStorage.setItem("theme", themeKey);
|
|
16
|
+
localStorage.setItem('themeInStyle', '1');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
if (typeof window !== 'undefined') {
|
|
22
|
+
themeKey = localStorage.getItem("theme");
|
|
23
|
+
}
|
|
24
|
+
if (!themeKey) {
|
|
25
|
+
themeKey = themes[0].key;
|
|
26
|
+
}
|
|
27
|
+
changeByThemeKey(themeKey);
|
|
28
|
+
}
|
|
29
|
+
cssVars({
|
|
30
|
+
rootElement: document, // default
|
|
31
|
+
include: 'link[rel=stylesheet],style'
|
|
32
|
+
});
|
|
33
|
+
return themeKey;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const changeByTheme = (theme) => {
|
|
37
|
+
// 加入自定义变量
|
|
38
|
+
let varStyleTag = document.getElementById("customVars");
|
|
39
|
+
if (!varStyleTag) {
|
|
40
|
+
varStyleTag = document.createElement("style");
|
|
41
|
+
varStyleTag.id = "customVars";
|
|
42
|
+
document.body.appendChild(varStyleTag);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
varStyleTag.innerHTML = `:root {${theme["vars"]}}`;
|
|
46
|
+
|
|
47
|
+
// 加入自定义样式
|
|
48
|
+
let styleTag = document.getElementById("customStyle");
|
|
49
|
+
if (!styleTag) {
|
|
50
|
+
styleTag = document.createElement("style");
|
|
51
|
+
styleTag.id = "customStyle";
|
|
52
|
+
document.body.appendChild(styleTag);
|
|
53
|
+
}
|
|
54
|
+
if (theme&&theme.style) {
|
|
55
|
+
styleTag.innerHTML = theme.style;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const changeThemeByThemeId = (themeId, status, filterStatus, systemForm) => {
|
|
60
|
+
// 主题切换方式(区分新旧两种:1-旧 2-新)
|
|
61
|
+
if (typeof window !== 'undefined') {
|
|
62
|
+
localStorage.setItem('themeInStyle', '2')
|
|
63
|
+
}
|
|
64
|
+
// 一键滤镜功能 - 灰度状态;
|
|
65
|
+
let grayscaleVal = '0%'
|
|
66
|
+
if (filterStatus && filterStatus === '1') {
|
|
67
|
+
grayscaleVal = '100%'
|
|
68
|
+
}
|
|
69
|
+
// 记录当前主题
|
|
70
|
+
if (typeof window !== 'undefined') {
|
|
71
|
+
// localStorage.setItem('themeIdCurrent', themeId)
|
|
72
|
+
localStorage.setItem('themeIdCurrent', themeId)
|
|
73
|
+
}
|
|
74
|
+
// 顶部栏背景图处理
|
|
75
|
+
let background_image = config.upmsServerContext + '/anon/oss/file/getImage/' + systemForm.topBkImg + '?height=64&width=1920'
|
|
76
|
+
if (!status || status === '2') {
|
|
77
|
+
if (background_image.includes('lan_navigator')) {
|
|
78
|
+
background_image = 'url(' + lan_navigator + ')'
|
|
79
|
+
} else if (background_image.includes('lv_navigator')) {
|
|
80
|
+
background_image = 'url(' + lv_navigator + ')'
|
|
81
|
+
}
|
|
82
|
+
} else if (status === '1') {
|
|
83
|
+
background_image = 'url(' + background_image + ')'
|
|
84
|
+
}
|
|
85
|
+
handleSystemColor(grayscaleVal, systemForm, background_image)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const getThemeConfig = (themeKey = 'default') =>{
|
|
89
|
+
let result = {};
|
|
90
|
+
themes.forEach((theme) => {
|
|
91
|
+
if (theme.key === themeKey) {
|
|
92
|
+
result = theme;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const getThemeVars = (themeKey = 'default') =>{
|
|
99
|
+
let theme = getThemeConfig(themeKey);
|
|
100
|
+
if (theme) {
|
|
101
|
+
return theme.vars;
|
|
102
|
+
}
|
|
103
|
+
return '';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const getThemeVarByKey = (themeKey = 'default',varKey) => {
|
|
107
|
+
let value = '';
|
|
108
|
+
if (varKey) {
|
|
109
|
+
let vars = getThemeVars(themeKey)
|
|
110
|
+
if (vars) {
|
|
111
|
+
let startIndexOfChar = vars.indexOf(varKey);
|
|
112
|
+
if (startIndexOfChar > -1) {
|
|
113
|
+
// 从起始字符位置开始,找到下一行的起始位置
|
|
114
|
+
let endIndex = vars.indexOf('\n', startIndexOfChar);
|
|
115
|
+
if (endIndex === -1) {
|
|
116
|
+
// 如果没有找到换行符,则返回从起始字符到字符串末尾的部分
|
|
117
|
+
value = vars.substring(startIndexOfChar);
|
|
118
|
+
} else {
|
|
119
|
+
// 返回从起始字符到换行符之前的部分(不包括换行符)
|
|
120
|
+
value = vars.substring(startIndexOfChar, endIndex);
|
|
121
|
+
}
|
|
122
|
+
if (value) {
|
|
123
|
+
value = value.substring(value.indexOf(":") + 1,value.indexOf(";")).replaceAll(" ","");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
changeByThemeKey,
|
|
133
|
+
changeByTheme,
|
|
134
|
+
changeThemeByThemeId,
|
|
135
|
+
getThemeConfig,
|
|
136
|
+
getThemeVars,
|
|
137
|
+
getThemeVarByKey
|
|
138
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将旧版本json 转换为新版 json
|
|
3
|
+
*
|
|
4
|
+
* 转换规则:
|
|
5
|
+
* 1. 创建 widgetList:
|
|
6
|
+
* - 创建一个 grid 类型的容器,包含 cols 数组。
|
|
7
|
+
* - 每个 basicFormField 生成一个 grid-col,并填充到 cols 数组中。
|
|
8
|
+
* - 每个 grid-col 的 span 值根据 gridColumns 计算,即 24 / gridColumns。
|
|
9
|
+
* - 如果 basicFormField 的 type 是 ['textarea', 'imgUpload', 'imgListUpload', 'fileUpload', 'videoUpload'] 中的一个,则 span 设置为 24。
|
|
10
|
+
* 2. 生成 formConfig:
|
|
11
|
+
* - 将 sources 中除 gridColumns、workFlow 和 basicFormFields 外的所有属性复制到 formConfig 中。
|
|
12
|
+
* 3. 生成 workFlow:
|
|
13
|
+
* - 直接将 sources 中的 workFlow 复制到 target 的 workFlow 中。
|
|
14
|
+
*
|
|
15
|
+
* @param {*} sources
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export function transformToNew(sources) {
|
|
19
|
+
// 创建一个新的target对象
|
|
20
|
+
const target = {
|
|
21
|
+
widgetList: [
|
|
22
|
+
{
|
|
23
|
+
id: "grid-id-1", // 默认值
|
|
24
|
+
type: "grid",
|
|
25
|
+
category: "container",
|
|
26
|
+
icon: "grid",
|
|
27
|
+
cols: [],
|
|
28
|
+
options: {
|
|
29
|
+
name: "grid-name-1", // 默认值
|
|
30
|
+
hidden: false,
|
|
31
|
+
gutter: 12
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
formConfig: {},
|
|
36
|
+
workFlow: {} // 新增workFlow属性
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// 计算每列的span值
|
|
40
|
+
const defaultSpan = 24 / sources.gridColumns;
|
|
41
|
+
const specialTypes = ['textarea', 'imgUpload', 'imgListUpload', 'fileUpload', 'videoUpload'];
|
|
42
|
+
|
|
43
|
+
// 动态生成cols
|
|
44
|
+
sources.basicFormFields.forEach((field, index) => {
|
|
45
|
+
const span = specialTypes.includes(field.type) ? 24 : defaultSpan;
|
|
46
|
+
target.widgetList[0].cols.push({
|
|
47
|
+
id: `default-col-id-${index + 1}`, // 默认值
|
|
48
|
+
type: "grid-col",
|
|
49
|
+
category: "container",
|
|
50
|
+
icon: "grid-col",
|
|
51
|
+
internal: true,
|
|
52
|
+
widgetList: [field],
|
|
53
|
+
options: {
|
|
54
|
+
name: `col-name-${index + 1}`, // 默认值
|
|
55
|
+
hidden: false,
|
|
56
|
+
span: span, // 根据规则2计算span值
|
|
57
|
+
offset: 0,
|
|
58
|
+
push: 0,
|
|
59
|
+
pull: 0,
|
|
60
|
+
md: span,
|
|
61
|
+
sm: span,
|
|
62
|
+
xs: span,
|
|
63
|
+
responsive: false,
|
|
64
|
+
customClass: ""
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// 将sources中的属性(除了gridColumns和workFlow)复制到target的formConfig中
|
|
70
|
+
for (let key in sources) {
|
|
71
|
+
if (key !== 'gridColumns' && key !== 'workFlow' && key !== 'basicFormFields') {
|
|
72
|
+
target.formConfig[key] = sources[key];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 将sources中的workFlow复制到target的workFlow中
|
|
77
|
+
target.workFlow = sources.workFlow;
|
|
78
|
+
|
|
79
|
+
return target;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// // 示例调用
|
|
83
|
+
// const sources = {
|
|
84
|
+
// validValue: "true",
|
|
85
|
+
// formName: "测试",
|
|
86
|
+
// gridColumns: 3,
|
|
87
|
+
// labelWidth: 100,
|
|
88
|
+
// labelPosition: "left",
|
|
89
|
+
// saveWay: "0",
|
|
90
|
+
// businessKey: [],
|
|
91
|
+
// apiId: 74,
|
|
92
|
+
// detailUrl: "/ibp-upms-server/manage/demoUser/get",
|
|
93
|
+
// createUrl: "/ibp-upms-server/manage/demoUser/create",
|
|
94
|
+
// updateUrl: "/ibp-upms-server/manage/demoUser/update",
|
|
95
|
+
// customButton: false,
|
|
96
|
+
// customMethod: "",
|
|
97
|
+
// select: {
|
|
98
|
+
// apiId: 74,
|
|
99
|
+
// isGetFromApi: true
|
|
100
|
+
// },
|
|
101
|
+
// basicFormFields: [
|
|
102
|
+
// {
|
|
103
|
+
// formKey: "userId",
|
|
104
|
+
// title: "用户编码",
|
|
105
|
+
// required: false,
|
|
106
|
+
// type: "input",
|
|
107
|
+
// customComponentName: "",
|
|
108
|
+
// customComponentMethod: "",
|
|
109
|
+
// orders: 1,
|
|
110
|
+
// enumType: "code",
|
|
111
|
+
// enumKey: "",
|
|
112
|
+
// enumList: [],
|
|
113
|
+
// props: {
|
|
114
|
+
// maxlength: 1024,
|
|
115
|
+
// clearable: false,
|
|
116
|
+
// limitFileNum: 5,
|
|
117
|
+
// limitImgNum: 5
|
|
118
|
+
// },
|
|
119
|
+
// validate: {
|
|
120
|
+
// way: "default",
|
|
121
|
+
// type: "",
|
|
122
|
+
// trigger: "",
|
|
123
|
+
// validator: "",
|
|
124
|
+
// customMethod: "",
|
|
125
|
+
// customUrl: ""
|
|
126
|
+
// },
|
|
127
|
+
// condition: "",
|
|
128
|
+
// onChange: "",
|
|
129
|
+
// defaultValue: ""
|
|
130
|
+
// },
|
|
131
|
+
// {
|
|
132
|
+
// formKey: "userName",
|
|
133
|
+
// title: "用户名",
|
|
134
|
+
// required: true,
|
|
135
|
+
// type: "input",
|
|
136
|
+
// customComponentName: "",
|
|
137
|
+
// customComponentMethod: "",
|
|
138
|
+
// orders: 2,
|
|
139
|
+
// enumType: "code",
|
|
140
|
+
// enumKey: "",
|
|
141
|
+
// enumList: [],
|
|
142
|
+
// props: {
|
|
143
|
+
// maxlength: 1024,
|
|
144
|
+
// clearable: true,
|
|
145
|
+
// limitFileNum: 5,
|
|
146
|
+
// limitImgNum: 5
|
|
147
|
+
// },
|
|
148
|
+
// validate: {
|
|
149
|
+
// way: "default",
|
|
150
|
+
// type: "string",
|
|
151
|
+
// trigger: "blur",
|
|
152
|
+
// validator: "",
|
|
153
|
+
// customMethod: "",
|
|
154
|
+
// customUrl: ""
|
|
155
|
+
// },
|
|
156
|
+
// condition: "",
|
|
157
|
+
// onChange: "",
|
|
158
|
+
// defaultValue: ""
|
|
159
|
+
// }
|
|
160
|
+
// ],
|
|
161
|
+
// workFlow: {
|
|
162
|
+
// procId: "",
|
|
163
|
+
// applyId: "",
|
|
164
|
+
// taskNode: "",
|
|
165
|
+
// title: "流程办理",
|
|
166
|
+
// smartFlowServerContext: "",
|
|
167
|
+
// upmsServerContext: "",
|
|
168
|
+
// width: 400,
|
|
169
|
+
// executionCompleted: "",
|
|
170
|
+
// businessFormSave: "",
|
|
171
|
+
// required: false,
|
|
172
|
+
// isUseWorkflow: false,
|
|
173
|
+
// isProcessCallbacks: false,
|
|
174
|
+
// callbackUrl: ""
|
|
175
|
+
// }
|
|
176
|
+
// };
|
|
177
|
+
// console.log("old json:"+JSON.stringify(sources, null, 2));
|
|
178
|
+
// const transformedTarget = transformToNew(sources);
|
|
179
|
+
// console.log("new json:"+JSON.stringify(transformedTarget, null, 2));
|
package/utils/type.js
CHANGED
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2019 WeBank
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const objectToString = Object.prototype.toString;
|
|
19
|
-
const OBJECT_STRING = '[object Object]';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 是否是普通对象
|
|
23
|
-
* @param {any} obj
|
|
24
|
-
* @return {Boolean}
|
|
25
|
-
*/
|
|
26
|
-
export function isPlainObject(obj) {
|
|
27
|
-
return objectToString.call(obj) === OBJECT_STRING;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 是否是数字
|
|
32
|
-
* @param {any} value
|
|
33
|
-
* @return {Boolean}
|
|
34
|
-
*/
|
|
35
|
-
export function isNumber(value) {
|
|
36
|
-
return typeof value === 'number';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 是否是日期
|
|
41
|
-
* @param {any} value
|
|
42
|
-
* @return {Boolean}
|
|
43
|
-
*/
|
|
44
|
-
export function isDate(value) {
|
|
45
|
-
return objectToString.call(value) === '[object Date]';
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 是否是函数
|
|
50
|
-
* @param {any} value
|
|
51
|
-
* @return {Boolean}
|
|
52
|
-
*/
|
|
53
|
-
export function isFunction(value) {
|
|
54
|
-
return typeof value === 'function';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 是否是函数
|
|
59
|
-
* @param {any} value
|
|
60
|
-
* @return {Boolean}
|
|
61
|
-
*/
|
|
62
|
-
export function isObject(value) {
|
|
63
|
-
let type = typeof value;
|
|
64
|
-
return !!value && (type == 'object' || type == 'function');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 是否是数组
|
|
69
|
-
* @param {any} value
|
|
70
|
-
* @return {Boolean}
|
|
71
|
-
*/
|
|
72
|
-
export function isArray(value) {
|
|
73
|
-
return Array.isArray(value);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 是否像对象
|
|
78
|
-
* @param {any} value
|
|
79
|
-
* @return {Boolean}
|
|
80
|
-
*/
|
|
81
|
-
export function isObjectLike(value) {
|
|
82
|
-
return !!value && typeof value == 'object';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 是否是字符串
|
|
87
|
-
* @param {any} value
|
|
88
|
-
* @return {Boolean}
|
|
89
|
-
*/
|
|
90
|
-
export function isString(value) {
|
|
91
|
-
return typeof value == 'string' ||
|
|
92
|
-
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == '[object String]');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* 是否是空的
|
|
97
|
-
* @param {any} value
|
|
98
|
-
* @return {Boolean}
|
|
99
|
-
*/
|
|
100
|
-
export function isNull(value) {
|
|
101
|
-
return value === undefined || value === null || value === '';
|
|
102
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2019 WeBank
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const objectToString = Object.prototype.toString;
|
|
19
|
+
const OBJECT_STRING = '[object Object]';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* 是否是普通对象
|
|
23
|
+
* @param {any} obj
|
|
24
|
+
* @return {Boolean}
|
|
25
|
+
*/
|
|
26
|
+
export function isPlainObject(obj) {
|
|
27
|
+
return objectToString.call(obj) === OBJECT_STRING;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 是否是数字
|
|
32
|
+
* @param {any} value
|
|
33
|
+
* @return {Boolean}
|
|
34
|
+
*/
|
|
35
|
+
export function isNumber(value) {
|
|
36
|
+
return typeof value === 'number';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 是否是日期
|
|
41
|
+
* @param {any} value
|
|
42
|
+
* @return {Boolean}
|
|
43
|
+
*/
|
|
44
|
+
export function isDate(value) {
|
|
45
|
+
return objectToString.call(value) === '[object Date]';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 是否是函数
|
|
50
|
+
* @param {any} value
|
|
51
|
+
* @return {Boolean}
|
|
52
|
+
*/
|
|
53
|
+
export function isFunction(value) {
|
|
54
|
+
return typeof value === 'function';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 是否是函数
|
|
59
|
+
* @param {any} value
|
|
60
|
+
* @return {Boolean}
|
|
61
|
+
*/
|
|
62
|
+
export function isObject(value) {
|
|
63
|
+
let type = typeof value;
|
|
64
|
+
return !!value && (type == 'object' || type == 'function');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 是否是数组
|
|
69
|
+
* @param {any} value
|
|
70
|
+
* @return {Boolean}
|
|
71
|
+
*/
|
|
72
|
+
export function isArray(value) {
|
|
73
|
+
return Array.isArray(value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 是否像对象
|
|
78
|
+
* @param {any} value
|
|
79
|
+
* @return {Boolean}
|
|
80
|
+
*/
|
|
81
|
+
export function isObjectLike(value) {
|
|
82
|
+
return !!value && typeof value == 'object';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 是否是字符串
|
|
87
|
+
* @param {any} value
|
|
88
|
+
* @return {Boolean}
|
|
89
|
+
*/
|
|
90
|
+
export function isString(value) {
|
|
91
|
+
return typeof value == 'string' ||
|
|
92
|
+
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == '[object String]');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 是否是空的
|
|
97
|
+
* @param {any} value
|
|
98
|
+
* @return {Boolean}
|
|
99
|
+
*/
|
|
100
|
+
export function isNull(value) {
|
|
101
|
+
return value === undefined || value === null || value === '';
|
|
102
|
+
}
|