@lambo-design/shared 1.0.0-beta.31 → 1.0.0-beta.310

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.
Files changed (235) hide show
  1. package/config/config.js +20 -3
  2. package/config/index.js +7 -2
  3. package/config/locale.js +61 -0
  4. package/config/themes/atrovirens/atrovirens.css +589 -0
  5. package/config/themes/atrovirens/atrovirens.css.map +1 -0
  6. package/config/themes/atrovirens/atrovirens.less +680 -0
  7. package/config/themes/atrovirens/var.less +688 -0
  8. package/config/themes/blue/blue.css +589 -0
  9. package/config/themes/blue/blue.css.map +1 -0
  10. package/config/themes/blue/blue.less +683 -0
  11. package/config/themes/blue/var.less +691 -0
  12. package/config/themes/blue-white/blue-white.css +589 -0
  13. package/config/themes/blue-white/blue-white.css.map +1 -0
  14. package/config/themes/blue-white/blue-white.less +684 -0
  15. package/config/themes/blue-white/var.less +690 -0
  16. package/config/themes/blue-white-big/blue-white-big.css +589 -0
  17. package/config/themes/blue-white-big/blue-white-big.css.map +1 -0
  18. package/config/themes/blue-white-big/blue-white-big.less +684 -0
  19. package/config/themes/blue-white-big/var.less +690 -0
  20. package/config/themes/blue-white-tight/blue-white-tight.css +590 -0
  21. package/config/themes/blue-white-tight/blue-white-tight.css.map +1 -0
  22. package/config/themes/blue-white-tight/blue-white-tight.less +684 -0
  23. package/config/themes/blue-white-tight/var.less +692 -0
  24. package/config/themes/canglan/canglan.css +588 -0
  25. package/config/themes/canglan/canglan.css.map +1 -0
  26. package/config/themes/canglan/canglan.less +681 -0
  27. package/config/themes/canglan/var.less +692 -0
  28. package/config/themes/cuiwei/cuiwei.css +589 -0
  29. package/config/themes/cuiwei/cuiwei.css.map +1 -0
  30. package/config/themes/cuiwei/cuiwei.less +681 -0
  31. package/config/themes/cuiwei/var.less +690 -0
  32. package/config/themes/danqing/danqing.css +589 -0
  33. package/config/themes/danqing/danqing.css.map +1 -0
  34. package/config/themes/danqing/danqing.less +681 -0
  35. package/config/themes/danqing/danqing.wxss +576 -0
  36. package/config/themes/danqing/var.less +695 -0
  37. package/config/themes/deep/deep.css +589 -0
  38. package/config/themes/deep/deep.css.map +1 -0
  39. package/config/themes/deep/deep.less +681 -0
  40. package/config/themes/deep/var.less +693 -0
  41. package/config/themes/default/default.css +403 -57
  42. package/config/themes/default/default.css.map +1 -1
  43. package/config/themes/default/default.less +380 -16
  44. package/config/themes/default/var.less +389 -11
  45. package/config/themes/eap/eap.css +589 -0
  46. package/config/themes/eap/eap.css.map +1 -0
  47. package/config/themes/eap/eap.less +684 -0
  48. package/config/themes/eap/var.less +692 -0
  49. package/config/themes/gold/gold.css +589 -0
  50. package/config/themes/gold/gold.css.map +1 -0
  51. package/config/themes/gold/gold.less +684 -0
  52. package/config/themes/gold/var.less +385 -5
  53. package/config/themes/index.js +26 -4
  54. package/config/themes/lime/lime.css +589 -0
  55. package/config/themes/lime/lime.css.map +1 -0
  56. package/config/themes/lime/lime.less +684 -0
  57. package/config/themes/lime/var.less +384 -5
  58. package/config/themes/orange/orange.css +353 -7
  59. package/config/themes/orange/orange.css.map +1 -1
  60. package/config/themes/orange/orange.less +365 -0
  61. package/config/themes/orange/var.less +385 -5
  62. package/config/themes/red/red.css +353 -7
  63. package/config/themes/red/red.css.map +1 -1
  64. package/config/themes/red/red.less +365 -0
  65. package/config/themes/red/var.less +385 -5
  66. package/config/themes/sichuan/sichuan.css +589 -0
  67. package/config/themes/sichuan/sichuan.css.map +1 -0
  68. package/config/themes/sichuan/sichuan.less +684 -0
  69. package/config/themes/sichuan/var.less +690 -0
  70. package/config/themes/theme-atrovirens.js +571 -0
  71. package/config/themes/theme-blue.js +571 -0
  72. package/config/themes/theme-bw.js +571 -0
  73. package/config/themes/theme-bwb.js +571 -0
  74. package/config/themes/theme-bwt.js +572 -0
  75. package/config/themes/theme-canglan.js +573 -0
  76. package/config/themes/theme-cuiwei.js +573 -0
  77. package/config/themes/theme-danqing.js +574 -0
  78. package/config/themes/theme-deep.js +571 -0
  79. package/config/themes/theme-default.js +378 -60
  80. package/config/themes/theme-eap.js +571 -0
  81. package/config/themes/theme-gold.js +326 -8
  82. package/config/themes/theme-lime.js +326 -8
  83. package/config/themes/theme-orange.js +560 -29
  84. package/config/themes/theme-red.js +563 -33
  85. package/config/themes/theme-sichuan.js +571 -0
  86. package/config/themes/theme-white.js +571 -0
  87. package/config/themes/white/var.less +691 -0
  88. package/config/themes/white/white.css +589 -0
  89. package/config/themes/white/white.css.map +1 -0
  90. package/config/themes/white/white.less +684 -0
  91. package/directives/module/print.js +1 -0
  92. package/directives/module/vue-print-nb/README.md +63 -0
  93. package/directives/module/vue-print-nb/print.js +94 -0
  94. package/directives/module/vue-print-nb/printarea.js +532 -0
  95. package/index.js +7 -1
  96. package/nstyles/common.less +197 -0
  97. package/nstyles/components/404.less +46 -0
  98. package/nstyles/components/button.less +34 -0
  99. package/nstyles/components/date-picker.less +41 -0
  100. package/nstyles/components/drawer.less +20 -0
  101. package/nstyles/components/dropdown.less +18 -0
  102. package/nstyles/components/excel-flow.less +72 -0
  103. package/nstyles/components/form.less +313 -0
  104. package/nstyles/components/index.less +23 -0
  105. package/nstyles/components/layout/collect.less +10 -0
  106. package/nstyles/components/layout/detail-view.less +107 -0
  107. package/nstyles/components/layout/full-screen.less +7 -0
  108. package/nstyles/components/layout/index.less +7 -0
  109. package/nstyles/components/layout/other-menu.less +142 -0
  110. package/nstyles/components/layout/page-view.less +101 -0
  111. package/nstyles/components/layout/sider-trigger.less +41 -0
  112. package/nstyles/components/layout/tags-nav.less +113 -0
  113. package/nstyles/components/modal.less +90 -0
  114. package/nstyles/components/n-button.less +131 -0
  115. package/nstyles/components/n-image-preview.less +131 -0
  116. package/nstyles/components/n-model/index.less +19 -0
  117. package/nstyles/components/n-model/report-index.less +43 -0
  118. package/nstyles/components/n-panel.less +41 -0
  119. package/nstyles/components/n-picker.less +37 -0
  120. package/nstyles/components/n-sign.less +17 -0
  121. package/nstyles/components/n-tooltip.less +10 -0
  122. package/nstyles/components/panel.less +31 -0
  123. package/nstyles/components/select.less +3 -0
  124. package/nstyles/components/sign.less +27 -0
  125. package/nstyles/components/table.less +412 -0
  126. package/nstyles/components/tree.less +166 -0
  127. package/nstyles/components/upload.less +174 -0
  128. package/nstyles/index.less +5 -0
  129. package/nstyles/reset.less +73 -0
  130. package/nstyles/third/ag.less +206 -0
  131. package/nstyles/third/icons/sort-desc.svg +1 -0
  132. package/nstyles/third/icons/sort-up.svg +1 -0
  133. package/nstyles/third/icons/sorting.svg +1 -0
  134. package/nstyles/third/index.less +11 -0
  135. package/nstyles/third/view-design.less +378 -0
  136. package/nstyles/variables/base.less +143 -0
  137. package/nstyles/variables/index.less +4 -0
  138. package/nstyles/variables/theme/default/button.less +7 -0
  139. package/nstyles/variables/theme/default/common.less +60 -0
  140. package/nstyles/variables/theme/default/index.less +7 -0
  141. package/nstyles/variables/theme/default/layout.less +40 -0
  142. package/nstyles/variables/theme/default/table.less +37 -0
  143. package/nstyles/variables/theme/default/tag.less +3 -0
  144. package/nstyles/variables/theme/default/upload.less +3 -0
  145. package/nstyles/variables/theme/index.less +13 -0
  146. package/nstyles/variables/theme/lsv/button.less +7 -0
  147. package/nstyles/variables/theme/lsv/common.less +39 -0
  148. package/nstyles/variables/theme/lsv/index.less +5 -0
  149. package/nstyles/variables/theme/lsv/layout.less +21 -0
  150. package/nstyles/variables/theme/lsv/table.less +20 -0
  151. package/nstyles/variables/theme/lsv/tag.less +3 -0
  152. package/nstyles/variables/theme/small/button.less +7 -0
  153. package/nstyles/variables/theme/small/common.less +41 -0
  154. package/nstyles/variables/theme/small/index.less +5 -0
  155. package/nstyles/variables/theme/small/layout.less +21 -0
  156. package/nstyles/variables/theme/small/table.less +17 -0
  157. package/nstyles/variables/theme/small/tag.less +3 -0
  158. package/package.json +28 -7
  159. package/plugin/index.js +12 -0
  160. package/plugin/module/date-format.js +30 -0
  161. package/plugin/module/loading.js +26 -0
  162. package/plugin/module/warn-handler.js +11 -0
  163. package/styles/image/indicator-card-header.png +0 -0
  164. package/styles/image/inspur.png +0 -0
  165. package/styles/image/lan_navigator.png +0 -0
  166. package/styles/image/layout-header-bg-canglan.png +0 -0
  167. package/styles/image/layout-header-bg-cuiwei.png +0 -0
  168. package/styles/image/lv_navigator.png +0 -0
  169. package/utils/ajax/abort-controller.js +68 -0
  170. package/utils/ajax/cancel-token.js +69 -0
  171. package/utils/ajax/content-type.js +30 -0
  172. package/utils/ajax/headers.js +11 -0
  173. package/utils/ajax/interceptors.js +30 -5
  174. package/utils/ajax/sseFetchUtil.js +118 -0
  175. package/utils/ajax/throttle.js +46 -0
  176. package/utils/assist.js +155 -27
  177. package/utils/base64.js +126 -0
  178. package/utils/blob.js +47 -0
  179. package/utils/context-menu.js +65 -0
  180. package/utils/crypto/aes.js +23 -0
  181. package/utils/crypto/index.js +10 -0
  182. package/utils/crypto/rsa.js +23 -0
  183. package/utils/date.js +334 -305
  184. package/utils/dict/built-in-dict.js +20 -0
  185. package/utils/dict/index.js +191 -0
  186. package/utils/event.js +72 -0
  187. package/utils/excel.js +373 -241
  188. package/utils/file.js +19 -0
  189. package/utils/form/validate.js +29 -0
  190. package/utils/half-year.js +68 -0
  191. package/utils/index.js +37 -0
  192. package/utils/json.js +44 -0
  193. package/utils/locale/en-US.js +172 -0
  194. package/utils/locale/zh-CN.js +172 -0
  195. package/utils/lodop.js +5 -0
  196. package/utils/menu/index.js +292 -15
  197. package/utils/mime_type.js +67 -0
  198. package/utils/modelerUtil.js +4 -1
  199. package/utils/n/api.js +38 -0
  200. package/utils/n/date.js +57 -0
  201. package/utils/n/index.js +10 -0
  202. package/utils/n/is-type.js +176 -0
  203. package/utils/n/number.js +144 -0
  204. package/utils/n/permission-cache.js +11 -0
  205. package/utils/n/reuqest/axiosN.js +17 -0
  206. package/utils/n/reuqest/content-type.js +19 -0
  207. package/utils/n/reuqest/interceptors.js +95 -0
  208. package/utils/n/reuqest/url-params.js +12 -0
  209. package/utils/n/storage.js +51 -0
  210. package/utils/n/token.js +51 -0
  211. package/utils/n/user-cache.js +11 -0
  212. package/utils/n/user.js +34 -0
  213. package/utils/n/uuid.js +16 -0
  214. package/utils/n-generator-routers.js +208 -0
  215. package/utils/n-router.js +205 -0
  216. package/utils/n-theme.js +30 -0
  217. package/utils/number.js +72 -15
  218. package/utils/oss.js +57 -0
  219. package/utils/platform.js +824 -33
  220. package/utils/quarter.js +58 -0
  221. package/utils/storage.js +198 -0
  222. package/utils/style.js +24 -0
  223. package/utils/theme.js +98 -3
  224. package/utils/transfer-queue.js +7 -0
  225. package/utils/transform.js +205 -0
  226. package/utils/type.js +102 -0
  227. package/utils/util.js +795 -0
  228. package/utils/vForm.js +349 -0
  229. package/utils/validator.js +181 -0
  230. package/config/themes/gold/default.css +0 -243
  231. package/config/themes/gold/default.css.map +0 -1
  232. package/config/themes/gold/default.less +0 -320
  233. package/config/themes/lime/default.css +0 -243
  234. package/config/themes/lime/default.css.map +0 -1
  235. package/config/themes/lime/default.less +0 -320
@@ -0,0 +1,58 @@
1
+ // 获取季度汉字
2
+ export function quarter2Chinese(quarterNum) {
3
+ let quarterList = ['一', '二', '三', '四']
4
+ return quarterNum ? quarterList[quarterNum - 1] : ''
5
+ }
6
+
7
+ // 获取季度
8
+ export function getQuarter(date) {
9
+ if (!date || date.length < 6) {
10
+ return ''
11
+ }
12
+
13
+ const year = date.substring(0, 4)
14
+ const month = date.substring(4, 6)
15
+ const quarter = getQuarterNum(parseInt(month))
16
+ return `${year}Q${quarter}`
17
+ }
18
+
19
+ export function getQuarterNum(month) {
20
+ if (typeof month === 'string') {
21
+ if (isNaN(parseInt(month))) return 0
22
+ month = parseInt(month)
23
+ }
24
+
25
+ return Math.ceil(month / 3)
26
+ }
27
+
28
+ export function formatQuarter(quarter) {
29
+ if (!quarter || quarter.length < 6) {
30
+ return quarter
31
+ }
32
+
33
+ const year = quarter.substring(0, 4)
34
+ const quarterNum = parseInt(quarter.substring(5))
35
+ return `${year}第${quarter2Chinese(quarterNum)}季度`
36
+ }
37
+
38
+ export function getQuarterBeginMonth(quarter) {
39
+ if (!quarter || quarter.length < 6) {
40
+ return quarter
41
+ }
42
+ const year = quarter.substring(0, 4)
43
+ const quarterNum = parseInt(quarter.substring(5))
44
+ const beginMonth = quarterNum * 3 - 2
45
+ const monthStr = beginMonth < 10 ? `0${beginMonth}` : `${beginMonth}`
46
+ return `${year}${monthStr}`
47
+ }
48
+
49
+ export function getQuarterEndMonth(quarter) {
50
+ if (!quarter || quarter.length < 6) {
51
+ return quarter
52
+ }
53
+ const year = quarter.substring(0, 4)
54
+ const quarterNum = parseInt(quarter.substring(5))
55
+ const endMonth = quarterNum * 3
56
+ const monthStr = endMonth < 10 ? `0${endMonth}` : `${endMonth}`
57
+ return `${year}${monthStr}`
58
+ }
@@ -0,0 +1,198 @@
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
+ /* \
19
+ |*|
20
+ |*| :: cookies.js ::
21
+ |*|
22
+ |*| A complete cookies reader/writer framework with full unicode support.
23
+ |*|
24
+ |*| https://developer.mozilla.org/en-US/docs/DOM/document.cookie
25
+ |*|
26
+ |*| This framework is released under the GNU Public License, version 3 or later.
27
+ |*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
28
+ |*|
29
+ |*| Syntaxes:
30
+ |*|
31
+ |*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
32
+ |*| * docCookies.getItem(name)
33
+ |*| * docCookies.removeItem(name[, path], domain)
34
+ |*| * docCookies.hasItem(name)
35
+ |*| * docCookies.keys()
36
+ |*|
37
+ \ */
38
+
39
+ let docCookies = {
40
+ getItem: function(sKey) {
41
+ return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
42
+ },
43
+ setItem: function(sKey, sValue, vEnd, sPath, sDomain, bSecure) {
44
+ if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) {
45
+ return false;
46
+ }
47
+ let sExpires = '';
48
+ if (vEnd) {
49
+ switch (vEnd.constructor) {
50
+ case Number:
51
+ sExpires = vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : '; max-age=' + vEnd;
52
+ break;
53
+ case String:
54
+ sExpires = '; expires=' + vEnd;
55
+ break;
56
+ case Date:
57
+ sExpires = '; expires=' + vEnd.toUTCString();
58
+ break;
59
+ }
60
+ }
61
+ document.cookie = encodeURIComponent(sKey) + '=' + encodeURIComponent(sValue) + sExpires + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '') + (bSecure ? '; secure' : '');
62
+ return true;
63
+ },
64
+ removeItem: function(sKey, sPath, sDomain) {
65
+ if (!sKey || !this.hasItem(sKey)) {
66
+ return false;
67
+ }
68
+ document.cookie = encodeURIComponent(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT' + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '');
69
+ return true;
70
+ },
71
+ hasItem: function(sKey) {
72
+ return (new RegExp('(?:^|;\\s*)' + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, '\\$&') + '\\s*\\=')).test(document.cookie);
73
+ },
74
+ keys: /* optional method: you can safely remove it! */ function() {
75
+ let aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, '').split(/\s*(?:\=[^;]*)?;\s*/);
76
+ for (let nIdx = 0; nIdx < aKeys.length; nIdx++) {
77
+ aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]);
78
+ }
79
+ return aKeys;
80
+ },
81
+ };
82
+
83
+ /**
84
+ * 操作cookie、sessionStorage、localStorage、缓存
85
+ */
86
+
87
+ const
88
+ SESSION = 'session';
89
+
90
+ const LOCAL = 'local';
91
+
92
+ const COOKIE = 'cookie';
93
+
94
+ export default {
95
+ set: function(key, value, category = SESSION, expired) {
96
+ let { storage, isWebStorage = true } = this._map(category);
97
+
98
+ if (isWebStorage) {
99
+ storageManager.set(key, value, storage);
100
+ } else {
101
+ cookieManager.set(key, value, expired);
102
+ }
103
+ },
104
+ get: function(key, category = SESSION) {
105
+ let { storage, isWebStorage = true } = this._map(category);
106
+
107
+ if (isWebStorage) {
108
+ return storageManager.get(key, storage);
109
+ } else {
110
+ return cookieManager.get(key);
111
+ }
112
+ },
113
+ clear: function(category = SESSION) {
114
+ let { storage, isWebStorage = true } = this._map(category);
115
+
116
+ if (isWebStorage) {
117
+ storageManager.clear(storage);
118
+ } else {
119
+ cookieManager.clear();
120
+ }
121
+ },
122
+ remove: function(key, category = SESSION) {
123
+ let { storage, isWebStorage = true } = this._map(category);
124
+
125
+ if (isWebStorage) {
126
+ storageManager.remove(key, storage);
127
+ } else {
128
+ cookieManager.remove(key);
129
+ }
130
+ },
131
+ _map: function(category) {
132
+ let isWebStorage = true; let storage;
133
+
134
+ switch (true) {
135
+ case category === SESSION:
136
+ storage = 'sessionStorage';
137
+ break;
138
+ case category === LOCAL:
139
+ storage = 'localStorage';
140
+ break;
141
+ case category === COOKIE:
142
+ storage = 'cookie';
143
+ isWebStorage = false;
144
+ break;
145
+ default:
146
+ storage = 'sessionStorage';
147
+ }
148
+
149
+ return { isWebStorage, storage };
150
+ },
151
+ };
152
+
153
+ let isProd = process.env.NODE_ENV === 'production';
154
+
155
+ export const storageManager = {
156
+ set: function(key, value, storage) {
157
+ try {
158
+ window[storage].setItem(key, JSON.stringify(value));
159
+ } catch (e) {
160
+ !isProd && console.error(e);
161
+ }
162
+ },
163
+ get: function(key, storage) {
164
+ try {
165
+ if (window[storage].getItem(key)) {
166
+ return JSON.parse(window[storage].getItem(key));
167
+ } else {
168
+ return window[storage].getItem(key);
169
+ }
170
+ } catch (e) {
171
+ !isProd && console.error(e, key);
172
+ }
173
+ },
174
+ clear: function(storage) {
175
+ window[storage].clear();
176
+ },
177
+ remove: function(key, storage) {
178
+ window[storage].removeItem(key);
179
+ },
180
+ };
181
+
182
+ export const cookieManager = {
183
+ set: function(key, value, expired) {
184
+ if (expired) docCookies.setItem(key, value, expired);
185
+ else docCookies.setItem(key, value);
186
+ },
187
+ get: function(key) {
188
+ return docCookies.getItem(key);
189
+ },
190
+ clear: function() {
191
+ docCookies.keys().forEach((key) => {
192
+ docCookies.removeItem(key);
193
+ });
194
+ },
195
+ remove: function(key) {
196
+ docCookies.removeItem(key);
197
+ },
198
+ };
package/utils/style.js ADDED
@@ -0,0 +1,24 @@
1
+ const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g
2
+ const MOZ_HACK_REGEXP = /^moz([A-Z])/
3
+
4
+ function camelCase(name) {
5
+ return name
6
+ .replace(SPECIAL_CHARS_REGEXP, function (_, separator, letter, offset) {
7
+ return offset ? letter.toUpperCase() : letter
8
+ })
9
+ .replace(MOZ_HACK_REGEXP, 'Moz$1')
10
+ }
11
+ // getStyle
12
+ export function getStyle(element, styleName) {
13
+ if (!element || !styleName) return null
14
+ styleName = camelCase(styleName)
15
+ if (styleName === 'float') {
16
+ styleName = 'cssFloat'
17
+ }
18
+ try {
19
+ const computed = document.defaultView.getComputedStyle(element, '')
20
+ return element.style[styleName] || computed ? computed[styleName] : null
21
+ } catch (e) {
22
+ return element.style[styleName]
23
+ }
24
+ }
package/utils/theme.js CHANGED
@@ -1,19 +1,35 @@
1
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
+
2
9
  const changeByThemeKey = (themeKey) => {
3
10
  if (themeKey) {
4
11
  themes.forEach((theme) => {
5
12
  if (theme.key === themeKey) {
6
13
  changeByTheme(theme);
7
- localStorage.setItem("theme", themeKey);
14
+ if (typeof window !== 'undefined') {
15
+ localStorage.setItem("theme", themeKey);
16
+ localStorage.setItem('themeInStyle', '1');
17
+ }
8
18
  }
9
19
  });
10
20
  } else {
11
- themeKey = localStorage.getItem("theme");
21
+ if (typeof window !== 'undefined') {
22
+ themeKey = localStorage.getItem("theme");
23
+ }
12
24
  if (!themeKey) {
13
25
  themeKey = themes[0].key;
14
26
  }
15
27
  changeByThemeKey(themeKey);
16
28
  }
29
+ cssVars({
30
+ rootElement: document, // default
31
+ include: 'link[rel=stylesheet],style'
32
+ });
17
33
  return themeKey;
18
34
  };
19
35
 
@@ -40,4 +56,83 @@ const changeByTheme = (theme) => {
40
56
  }
41
57
  };
42
58
 
43
- export { changeByThemeKey, changeByTheme };
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,7 @@
1
+ let transferIndex = 1000
2
+
3
+ function transferIncrease() {
4
+ transferIndex++
5
+ }
6
+
7
+ export { transferIndex, transferIncrease }
@@ -0,0 +1,205 @@
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
+ * 4. 对于每个 basicFormField:
15
+ * - 生成唯一的 ID。
16
+ * - 添加 formItemFlag 属性并设置为 true。
17
+ * - 添加 options 对象,其中 name 字段值来自 basicFormField.formKey。
18
+ * - options 对象还包括其他默认配置项。
19
+ * @param {*} sources
20
+ * @returns
21
+ */
22
+ export function transformToNew(sources) {
23
+ // 创建一个新的target对象
24
+ const target = {
25
+ widgetList: [
26
+ {
27
+ id: "grid-id-1", // 默认值
28
+ type: "grid",
29
+ category: "container",
30
+ icon: "grid",
31
+ cols: [],
32
+ options: {
33
+ name: "grid-name-1", // 默认值
34
+ hidden: false,
35
+ gutter: 12
36
+ }
37
+ }
38
+ ],
39
+ formConfig: {},
40
+ workFlow: {} // 新增workFlow属性
41
+ };
42
+
43
+ // 计算每列的span值
44
+ const defaultSpan = 24 / sources.gridColumns;
45
+ const specialTypes = ['textarea', 'imgUpload', 'imgListUpload', 'fileUpload', 'videoUpload'];
46
+
47
+ // 动态生成cols
48
+ sources.basicFormFields.forEach((field, index) => {
49
+ const span = specialTypes.includes(field.type) ? 24 : defaultSpan;
50
+
51
+ // 为每个field增加id和options
52
+ const uniqueFieldId = `form-filed-${index}`;
53
+ field.id = uniqueFieldId;
54
+ field.formItemFlag = true;
55
+ field.options = {
56
+ name: field.formKey,
57
+ customClass: "",
58
+ hidden: false,
59
+ defaultValue: "",
60
+ validation: "",
61
+ validationHint: "",
62
+ onCreated: "",
63
+ onMounted: "",
64
+ onInput: "",
65
+ onChange: "",
66
+ onFocus: "",
67
+ onBlur: "",
68
+ onValidate: "",
69
+ onAppendButtonClick: ""
70
+ };
71
+
72
+ target.widgetList[0].cols.push({
73
+ id: `default-col-id-${index + 1}`, // 默认值
74
+ type: "grid-col",
75
+ category: "container",
76
+ icon: "grid-col",
77
+ internal: true,
78
+ widgetList: [field],
79
+ options: {
80
+ name: `col-name-${index + 1}`, // 默认值
81
+ hidden: false,
82
+ span: span, // 根据规则2计算span值
83
+ offset: 0,
84
+ push: 0,
85
+ pull: 0,
86
+ md: span,
87
+ sm: span,
88
+ xs: span,
89
+ responsive: false,
90
+ customClass: ""
91
+ }
92
+ });
93
+ });
94
+
95
+ // 将sources中的属性(除了gridColumns和workFlow)复制到target的formConfig中
96
+ for (let key in sources) {
97
+ if (key !== 'gridColumns' && key !== 'workFlow' && key !== 'basicFormFields') {
98
+ target.formConfig[key] = sources[key];
99
+ }
100
+ }
101
+
102
+ // 将sources中的workFlow复制到target的workFlow中
103
+ target.workFlow = sources.workFlow;
104
+
105
+ return target;
106
+ }
107
+
108
+ // // 示例调用
109
+ // const sources = {
110
+ // validValue: "true",
111
+ // formName: "测试",
112
+ // gridColumns: 3,
113
+ // labelWidth: 100,
114
+ // labelPosition: "left",
115
+ // saveWay: "0",
116
+ // businessKey: [],
117
+ // apiId: 74,
118
+ // detailUrl: "/ibp-upms-server/manage/demoUser/get",
119
+ // createUrl: "/ibp-upms-server/manage/demoUser/create",
120
+ // updateUrl: "/ibp-upms-server/manage/demoUser/update",
121
+ // customButton: false,
122
+ // customMethod: "",
123
+ // select: {
124
+ // apiId: 74,
125
+ // isGetFromApi: true
126
+ // },
127
+ // basicFormFields: [
128
+ // {
129
+ // formKey: "userId",
130
+ // title: "用户编码",
131
+ // required: false,
132
+ // type: "input",
133
+ // customComponentName: "",
134
+ // customComponentMethod: "",
135
+ // orders: 1,
136
+ // enumType: "code",
137
+ // enumKey: "",
138
+ // enumList: [],
139
+ // props: {
140
+ // maxlength: 1024,
141
+ // clearable: false,
142
+ // limitFileNum: 5,
143
+ // limitImgNum: 5
144
+ // },
145
+ // validate: {
146
+ // way: "default",
147
+ // type: "",
148
+ // trigger: "",
149
+ // validator: "",
150
+ // customMethod: "",
151
+ // customUrl: ""
152
+ // },
153
+ // condition: "",
154
+ // onChange: "",
155
+ // defaultValue: ""
156
+ // },
157
+ // {
158
+ // formKey: "userName",
159
+ // title: "用户名",
160
+ // required: true,
161
+ // type: "input",
162
+ // customComponentName: "",
163
+ // customComponentMethod: "",
164
+ // orders: 2,
165
+ // enumType: "code",
166
+ // enumKey: "",
167
+ // enumList: [],
168
+ // props: {
169
+ // maxlength: 1024,
170
+ // clearable: true,
171
+ // limitFileNum: 5,
172
+ // limitImgNum: 5
173
+ // },
174
+ // validate: {
175
+ // way: "default",
176
+ // type: "string",
177
+ // trigger: "blur",
178
+ // validator: "",
179
+ // customMethod: "",
180
+ // customUrl: ""
181
+ // },
182
+ // condition: "",
183
+ // onChange: "",
184
+ // defaultValue: ""
185
+ // }
186
+ // ],
187
+ // workFlow: {
188
+ // procId: "",
189
+ // applyId: "",
190
+ // taskNode: "",
191
+ // title: "流程办理",
192
+ // smartFlowServerContext: "",
193
+ // upmsServerContext: "",
194
+ // width: 400,
195
+ // executionCompleted: "",
196
+ // businessFormSave: "",
197
+ // required: false,
198
+ // isUseWorkflow: false,
199
+ // isProcessCallbacks: false,
200
+ // callbackUrl: ""
201
+ // }
202
+ // };
203
+ // console.log("old json:"+JSON.stringify(sources, null, 2));
204
+ // const transformedTarget = transformToNew(sources);
205
+ // console.log("new json:"+JSON.stringify(transformedTarget, null, 2));