eoss-mobiles 0.1.13

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 (285) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +28 -0
  3. package/lib/action-sheet.js +313 -0
  4. package/lib/button-group.js +421 -0
  5. package/lib/button.js +278 -0
  6. package/lib/calendar.js +301 -0
  7. package/lib/cascader.js +336 -0
  8. package/lib/cell.js +366 -0
  9. package/lib/checkbox.js +2170 -0
  10. package/lib/circle.js +299 -0
  11. package/lib/config/api.js +31 -0
  12. package/lib/count-down.js +299 -0
  13. package/lib/date.js +956 -0
  14. package/lib/empty.js +274 -0
  15. package/lib/eoss-mobile.common.js +15072 -0
  16. package/lib/field.js +440 -0
  17. package/lib/flow.js +5664 -0
  18. package/lib/form.js +714 -0
  19. package/lib/grid-item.js +274 -0
  20. package/lib/grid.js +317 -0
  21. package/lib/image-preview.js +325 -0
  22. package/lib/index.js +1 -0
  23. package/lib/list.js +315 -0
  24. package/lib/loading.js +279 -0
  25. package/lib/nav-bar.js +283 -0
  26. package/lib/pagination.js +323 -0
  27. package/lib/picker.js +2714 -0
  28. package/lib/popover.js +306 -0
  29. package/lib/popup.js +297 -0
  30. package/lib/radio.js +2137 -0
  31. package/lib/rate.js +300 -0
  32. package/lib/search.js +316 -0
  33. package/lib/selector.js +3496 -0
  34. package/lib/skeleton.js +277 -0
  35. package/lib/stepper.js +300 -0
  36. package/lib/switch.js +304 -0
  37. package/lib/tab.js +274 -0
  38. package/lib/table-column.js +2991 -0
  39. package/lib/table.js +2652 -0
  40. package/lib/tabs.js +315 -0
  41. package/lib/tag.js +281 -0
  42. package/lib/theme-chalk/action-sheet.css +0 -0
  43. package/lib/theme-chalk/base.css +1 -0
  44. package/lib/theme-chalk/button-group.css +1 -0
  45. package/lib/theme-chalk/button.css +1 -0
  46. package/lib/theme-chalk/calendar.css +1 -0
  47. package/lib/theme-chalk/cascader.css +1 -0
  48. package/lib/theme-chalk/cell.css +1 -0
  49. package/lib/theme-chalk/checkbox.css +1 -0
  50. package/lib/theme-chalk/circle.css +1 -0
  51. package/lib/theme-chalk/count-down.css +0 -0
  52. package/lib/theme-chalk/date.css +0 -0
  53. package/lib/theme-chalk/empty.css +0 -0
  54. package/lib/theme-chalk/field.css +1 -0
  55. package/lib/theme-chalk/flow.css +1 -0
  56. package/lib/theme-chalk/fonts/iconfont.scss +530 -0
  57. package/lib/theme-chalk/fonts/iconfont.ttf +0 -0
  58. package/lib/theme-chalk/fonts/iconfont.woff +0 -0
  59. package/lib/theme-chalk/form.css +0 -0
  60. package/lib/theme-chalk/grid-item.css +1 -0
  61. package/lib/theme-chalk/grid.css +0 -0
  62. package/lib/theme-chalk/icon.css +1 -0
  63. package/lib/theme-chalk/image-preview.css +0 -0
  64. package/lib/theme-chalk/index.css +1 -0
  65. package/lib/theme-chalk/list.css +0 -0
  66. package/lib/theme-chalk/loading.css +0 -0
  67. package/lib/theme-chalk/nav-bar.css +0 -0
  68. package/lib/theme-chalk/navbar.css +1 -0
  69. package/lib/theme-chalk/pagination.css +1 -0
  70. package/lib/theme-chalk/picker.css +1 -0
  71. package/lib/theme-chalk/popover.css +0 -0
  72. package/lib/theme-chalk/popup.css +0 -0
  73. package/lib/theme-chalk/radio.css +1 -0
  74. package/lib/theme-chalk/rate.css +0 -0
  75. package/lib/theme-chalk/search.css +0 -0
  76. package/lib/theme-chalk/selector.css +1 -0
  77. package/lib/theme-chalk/skeleton.css +0 -0
  78. package/lib/theme-chalk/stepper.css +1 -0
  79. package/lib/theme-chalk/switch.css +1 -0
  80. package/lib/theme-chalk/tab.css +0 -0
  81. package/lib/theme-chalk/table-column.css +0 -0
  82. package/lib/theme-chalk/table.css +1 -0
  83. package/lib/theme-chalk/tabs.css +1 -0
  84. package/lib/theme-chalk/tag.css +1 -0
  85. package/lib/theme-chalk/theme.css +0 -0
  86. package/lib/theme-chalk/tree.css +1 -0
  87. package/lib/theme-chalk/uploader.css +0 -0
  88. package/lib/uploader.js +307 -0
  89. package/lib/utils/axios.js +199 -0
  90. package/lib/utils/date-util.js +320 -0
  91. package/lib/utils/http.js +74 -0
  92. package/lib/utils/rules.js +21 -0
  93. package/lib/utils/store.js +24 -0
  94. package/lib/utils/util.js +1315 -0
  95. package/package.json +153 -0
  96. package/packages/action-sheet/index.js +5 -0
  97. package/packages/action-sheet/src/main.vue +32 -0
  98. package/packages/button/index.js +5 -0
  99. package/packages/button/src/main.vue +15 -0
  100. package/packages/button-group/index.js +5 -0
  101. package/packages/button-group/src/main.vue +80 -0
  102. package/packages/calendar/index.js +5 -0
  103. package/packages/calendar/src/main.vue +34 -0
  104. package/packages/cascader/index.js +5 -0
  105. package/packages/cascader/src/main.vue +40 -0
  106. package/packages/cell/index.js +5 -0
  107. package/packages/cell/src/main.vue +72 -0
  108. package/packages/checkbox/index.js +5 -0
  109. package/packages/checkbox/src/main.vue +149 -0
  110. package/packages/circle/index.js +5 -0
  111. package/packages/circle/src/main.vue +27 -0
  112. package/packages/count-down/index.js +5 -0
  113. package/packages/count-down/src/main.vue +27 -0
  114. package/packages/date/index.js +5 -0
  115. package/packages/date/src/date-time.vue +290 -0
  116. package/packages/date/src/main.vue +319 -0
  117. package/packages/empty/index.js +5 -0
  118. package/packages/empty/src/main.vue +16 -0
  119. package/packages/field/index.js +5 -0
  120. package/packages/field/src/main.vue +130 -0
  121. package/packages/flow/index.js +5 -0
  122. package/packages/flow/src/components/Handle.vue +1031 -0
  123. package/packages/flow/src/components/Message.vue +96 -0
  124. package/packages/flow/src/components/Opinion.vue +112 -0
  125. package/packages/flow/src/components/Reject.vue +202 -0
  126. package/packages/flow/src/components/StartFlow.vue +440 -0
  127. package/packages/flow/src/components/TaskRead.vue +237 -0
  128. package/packages/flow/src/main.vue +43 -0
  129. package/packages/form/index.js +5 -0
  130. package/packages/form/src/main.vue +158 -0
  131. package/packages/grid/index.js +5 -0
  132. package/packages/grid/src/main.vue +28 -0
  133. package/packages/grid-item/index.js +5 -0
  134. package/packages/grid-item/src/main.vue +16 -0
  135. package/packages/image-preview/index.js +5 -0
  136. package/packages/image-preview/src/main.vue +34 -0
  137. package/packages/list/index.js +5 -0
  138. package/packages/list/src/main.vue +32 -0
  139. package/packages/loading/index.js +5 -0
  140. package/packages/loading/src/main.vue +20 -0
  141. package/packages/nav-bar/index.js +5 -0
  142. package/packages/nav-bar/src/main.vue +16 -0
  143. package/packages/pagination/index.js +5 -0
  144. package/packages/pagination/src/main.vue +29 -0
  145. package/packages/picker/index.js +5 -0
  146. package/packages/picker/src/main.vue +500 -0
  147. package/packages/popover/index.js +5 -0
  148. package/packages/popover/src/main.vue +32 -0
  149. package/packages/popup/index.js +5 -0
  150. package/packages/popup/src/main.vue +27 -0
  151. package/packages/radio/index.js +5 -0
  152. package/packages/radio/src/main.vue +147 -0
  153. package/packages/rate/index.js +5 -0
  154. package/packages/rate/src/main.vue +27 -0
  155. package/packages/search/index.js +5 -0
  156. package/packages/search/src/main.vue +39 -0
  157. package/packages/selector/index.js +5 -0
  158. package/packages/selector/src/main.vue +77 -0
  159. package/packages/selector/src/selector-field.vue +225 -0
  160. package/packages/selector/src/selector-tree.vue +472 -0
  161. package/packages/selector/src/tree.vue +179 -0
  162. package/packages/skeleton/index.js +5 -0
  163. package/packages/skeleton/src/main.vue +17 -0
  164. package/packages/stepper/index.js +5 -0
  165. package/packages/stepper/src/main.vue +25 -0
  166. package/packages/switch/index.js +5 -0
  167. package/packages/switch/src/main.vue +29 -0
  168. package/packages/tab/index.js +5 -0
  169. package/packages/tab/src/main.vue +16 -0
  170. package/packages/table/index.js +5 -0
  171. package/packages/table/src/main.vue +830 -0
  172. package/packages/table-column/index.js +5 -0
  173. package/packages/table-column/src/main.vue +742 -0
  174. package/packages/table-column/src/mixins/table.js +12 -0
  175. package/packages/tabs/index.js +5 -0
  176. package/packages/tabs/src/main.vue +34 -0
  177. package/packages/tag/index.js +5 -0
  178. package/packages/tag/src/main.vue +16 -0
  179. package/packages/theme-chalk/README.md +33 -0
  180. package/packages/theme-chalk/lib/action-sheet.css +0 -0
  181. package/packages/theme-chalk/lib/base.css +1 -0
  182. package/packages/theme-chalk/lib/button-group.css +1 -0
  183. package/packages/theme-chalk/lib/button.css +1 -0
  184. package/packages/theme-chalk/lib/calendar.css +1 -0
  185. package/packages/theme-chalk/lib/cascader.css +1 -0
  186. package/packages/theme-chalk/lib/cell.css +1 -0
  187. package/packages/theme-chalk/lib/checkbox.css +1 -0
  188. package/packages/theme-chalk/lib/circle.css +1 -0
  189. package/packages/theme-chalk/lib/count-down.css +0 -0
  190. package/packages/theme-chalk/lib/date.css +0 -0
  191. package/packages/theme-chalk/lib/empty.css +0 -0
  192. package/packages/theme-chalk/lib/field.css +1 -0
  193. package/packages/theme-chalk/lib/flow.css +1 -0
  194. package/packages/theme-chalk/lib/fonts/iconfont.scss +530 -0
  195. package/packages/theme-chalk/lib/fonts/iconfont.ttf +0 -0
  196. package/packages/theme-chalk/lib/fonts/iconfont.woff +0 -0
  197. package/packages/theme-chalk/lib/form.css +0 -0
  198. package/packages/theme-chalk/lib/grid-item.css +1 -0
  199. package/packages/theme-chalk/lib/grid.css +0 -0
  200. package/packages/theme-chalk/lib/icon.css +1 -0
  201. package/packages/theme-chalk/lib/image-preview.css +0 -0
  202. package/packages/theme-chalk/lib/index.css +1 -0
  203. package/packages/theme-chalk/lib/list.css +0 -0
  204. package/packages/theme-chalk/lib/loading.css +0 -0
  205. package/packages/theme-chalk/lib/nav-bar.css +0 -0
  206. package/packages/theme-chalk/lib/navbar.css +1 -0
  207. package/packages/theme-chalk/lib/pagination.css +1 -0
  208. package/packages/theme-chalk/lib/picker.css +1 -0
  209. package/packages/theme-chalk/lib/popover.css +0 -0
  210. package/packages/theme-chalk/lib/popup.css +0 -0
  211. package/packages/theme-chalk/lib/radio.css +1 -0
  212. package/packages/theme-chalk/lib/rate.css +0 -0
  213. package/packages/theme-chalk/lib/search.css +0 -0
  214. package/packages/theme-chalk/lib/selector.css +1 -0
  215. package/packages/theme-chalk/lib/skeleton.css +0 -0
  216. package/packages/theme-chalk/lib/stepper.css +1 -0
  217. package/packages/theme-chalk/lib/switch.css +1 -0
  218. package/packages/theme-chalk/lib/tab.css +0 -0
  219. package/packages/theme-chalk/lib/table-column.css +0 -0
  220. package/packages/theme-chalk/lib/table.css +1 -0
  221. package/packages/theme-chalk/lib/tabs.css +1 -0
  222. package/packages/theme-chalk/lib/tag.css +1 -0
  223. package/packages/theme-chalk/lib/theme.css +0 -0
  224. package/packages/theme-chalk/lib/tree.css +1 -0
  225. package/packages/theme-chalk/lib/uploader.css +0 -0
  226. package/packages/theme-chalk/package.json +35 -0
  227. package/packages/theme-chalk/src/action-sheet.scss +0 -0
  228. package/packages/theme-chalk/src/base.scss +182 -0
  229. package/packages/theme-chalk/src/button-group.scss +26 -0
  230. package/packages/theme-chalk/src/button.scss +3 -0
  231. package/packages/theme-chalk/src/calendar.scss +12 -0
  232. package/packages/theme-chalk/src/cascader.scss +12 -0
  233. package/packages/theme-chalk/src/cell.scss +14 -0
  234. package/packages/theme-chalk/src/checkbox.scss +10 -0
  235. package/packages/theme-chalk/src/circle.scss +7 -0
  236. package/packages/theme-chalk/src/common/var.scss +1525 -0
  237. package/packages/theme-chalk/src/count-down.scss +0 -0
  238. package/packages/theme-chalk/src/date.scss +0 -0
  239. package/packages/theme-chalk/src/empty.scss +0 -0
  240. package/packages/theme-chalk/src/field.scss +28 -0
  241. package/packages/theme-chalk/src/flow.scss +542 -0
  242. package/packages/theme-chalk/src/fonts/iconfont.scss +530 -0
  243. package/packages/theme-chalk/src/fonts/iconfont.ttf +0 -0
  244. package/packages/theme-chalk/src/fonts/iconfont.woff +0 -0
  245. package/packages/theme-chalk/src/form.scss +15 -0
  246. package/packages/theme-chalk/src/grid-item.scss +8 -0
  247. package/packages/theme-chalk/src/grid.scss +0 -0
  248. package/packages/theme-chalk/src/icon.scss +1661 -0
  249. package/packages/theme-chalk/src/image-preview.scss +0 -0
  250. package/packages/theme-chalk/src/index.scss +38 -0
  251. package/packages/theme-chalk/src/list.scss +0 -0
  252. package/packages/theme-chalk/src/loading.scss +0 -0
  253. package/packages/theme-chalk/src/mixins/color.scss +117 -0
  254. package/packages/theme-chalk/src/mixins/mixins.scss +25 -0
  255. package/packages/theme-chalk/src/nav-bar.scss +0 -0
  256. package/packages/theme-chalk/src/navbar.scss +6 -0
  257. package/packages/theme-chalk/src/pagination.scss +10 -0
  258. package/packages/theme-chalk/src/picker.scss +27 -0
  259. package/packages/theme-chalk/src/popover.scss +0 -0
  260. package/packages/theme-chalk/src/popup.scss +0 -0
  261. package/packages/theme-chalk/src/radio.scss +7 -0
  262. package/packages/theme-chalk/src/rate.scss +0 -0
  263. package/packages/theme-chalk/src/search.scss +0 -0
  264. package/packages/theme-chalk/src/selector.scss +218 -0
  265. package/packages/theme-chalk/src/skeleton.scss +0 -0
  266. package/packages/theme-chalk/src/stepper.scss +10 -0
  267. package/packages/theme-chalk/src/switch.scss +6 -0
  268. package/packages/theme-chalk/src/tab.scss +0 -0
  269. package/packages/theme-chalk/src/table-column.scss +0 -0
  270. package/packages/theme-chalk/src/table.scss +42 -0
  271. package/packages/theme-chalk/src/tabs.scss +21 -0
  272. package/packages/theme-chalk/src/tag.scss +13 -0
  273. package/packages/theme-chalk/src/theme.scss +2 -0
  274. package/packages/theme-chalk/src/tree.scss +115 -0
  275. package/packages/theme-chalk/src/uploader.scss +0 -0
  276. package/packages/uploader/index.js +5 -0
  277. package/packages/uploader/src/main.vue +31 -0
  278. package/src/config/api.js +29 -0
  279. package/src/index.js +130 -0
  280. package/src/utils/axios.js +198 -0
  281. package/src/utils/date-util.js +312 -0
  282. package/src/utils/http.js +66 -0
  283. package/src/utils/rules.js +18 -0
  284. package/src/utils/store.js +21 -0
  285. package/src/utils/util.js +1346 -0
@@ -0,0 +1,1346 @@
1
+ /* eslint-disable indent */
2
+ // import { authCenter } from '../config/api';
3
+ import { generate } from '@eoss-design/color';
4
+
5
+ const sm2 = require('sm-crypto').sm2;
6
+
7
+ /**
8
+ * esEncrypt
9
+ * @desc:sm2加密
10
+ * @author huangbo
11
+ * @date 2022年5月7日
12
+ * @param {string} [data] - 被加密的字符串
13
+ * @param {string} [key] - 公钥
14
+ **/
15
+ const esEncrypt = function (data, key, mode) {
16
+ const cipherMode = mode ? mode : 1;
17
+ if (!new RegExp('^04').test(key)) {
18
+ key = '04' + key;
19
+ }
20
+ const result = sm2.doEncrypt(data, key, cipherMode);
21
+ return result;
22
+ };
23
+
24
+ /**
25
+ * esDecode
26
+ * @desc:sm2解密
27
+ * @author huangbo
28
+ * @date 2022年5月7日
29
+ * @param {string} [data] - 被解密的加密字符串
30
+ * @param {string} [key] - 私钥
31
+ **/
32
+ const esDecode = function (data, key, mode) {
33
+ const cipherMode = mode ? mode : 1;
34
+ const result = sm2.doDecrypt(data, key, cipherMode);
35
+ return result;
36
+ };
37
+ /**
38
+ * startWith
39
+ * @desc:判断是否以指定字符开头
40
+ * @author huangbo
41
+ * @date 2022年5月7日
42
+ * @param {string} [str] - 被查找的字符串
43
+ * @param {string} [reg] - 指定字符串
44
+ **/
45
+ const startWith = function (str, reg) {
46
+ if (new RegExp('^' + reg).test(str)) {
47
+ return true;
48
+ }
49
+ return false;
50
+ };
51
+ /**
52
+ * jointUrl
53
+ * @desc:判断url地址是否以字符开头,没有则添加
54
+ * @author huangbo
55
+ * @date 2022年5月7日
56
+ * @param {string} [str] - 域名或者路径
57
+ * @param {string} [url] - 地址
58
+ **/
59
+ const jointUrl = function (url, str) {
60
+ if (startWith(url, 'http') || startWith(url, 'blob:') || !str) {
61
+ return url;
62
+ }
63
+ return startWith(url, str) ? url : (str + url);
64
+ };
65
+ /**
66
+ * queryParams
67
+ * @desc:对象转url拼接参数
68
+ * @author huangbo
69
+ * @date 2022年5月7日
70
+ * @param {Object} [obj] - 被转换的对象
71
+ **/
72
+ const queryParams = function (obj) {
73
+ let arry = [];
74
+ for (let i in obj) {
75
+ arry.push(i + '=' + obj[i]);
76
+ }
77
+ if (arry.length) {
78
+ return arry.join('&');
79
+ }
80
+ return false;
81
+ };
82
+ /**
83
+ * queryParams
84
+ * @desc:对象转url拼接参数
85
+ * @author huangbo
86
+ * @date 2022年5月7日
87
+ * @param {Object} [url] - url地址
88
+ * @param {Object} [obj] - 被转换的对象
89
+ **/
90
+ const urlJoinParams = function (url, obj) {
91
+ let arry = decodeURI(url).split('?');
92
+ let params = {};
93
+ if (arry.length > 1) {
94
+ let search = arry[1].split('&');
95
+ search.forEach(item => {
96
+ let items = item.split('=');
97
+ params[items[0]] = items[1];
98
+ });
99
+ }
100
+ params = extend(true, params, obj);
101
+ let str = queryParams(params);
102
+ if (str) {
103
+ return arry[0] + '?' + str;
104
+ }
105
+ return arry[0];
106
+ };
107
+ /**
108
+ * arrUnique
109
+ * @desc:数组元素对象去重
110
+ * @author huangbo
111
+ * @date 2022年5月7日
112
+ * @param {Object} [arr] - 原始数组
113
+ * @param {String} [key] - 对象子元素的属性名
114
+ **/
115
+ const arrUnique = function (arr, key) {
116
+ var newArr = [];
117
+ if (key === undefined) {
118
+ arr.sort();
119
+ newArr = [arr[0]];
120
+ for (let i = 1; i < arr.length; i++) {
121
+ if (arr[i] !== newArr[newArr.length - 1]) {
122
+ newArr.push(arr[i]);
123
+ }
124
+ }
125
+ } else {
126
+ var obj = {};
127
+ for (let i = 0; i < arr.length; i++) {
128
+ if (!obj[arr[i][key]]) {
129
+ newArr.push(arr[i]);
130
+ obj[arr[i][key]] = true;
131
+ }
132
+ }
133
+ }
134
+ return newArr;
135
+ };
136
+ /**
137
+ * isObject
138
+ * @desc:判断是否是对象
139
+ * @author huangbo
140
+ * @date 2022年5月7日
141
+ * @param {Object} [obj] - 对象
142
+ **/
143
+ const isObject = function (obj) {
144
+ let proto;
145
+ let Ctor;
146
+ let hasOwn = {}.hasOwnProperty;
147
+ if (!obj || toString.call(obj) !== '[object Object]') {
148
+ return false;
149
+ }
150
+
151
+ proto = Object.getPrototypeOf(obj);
152
+ if (!proto) {
153
+ return true;
154
+ }
155
+ let fnToString = hasOwn.toString;
156
+ let ObjectFunctionString = fnToString.call(Object);
157
+ Ctor = hasOwn.call(proto, 'constructor') && proto.constructor;
158
+ return (
159
+ typeof Ctor === 'function' && fnToString.call(Ctor) === ObjectFunctionString
160
+ );
161
+ };
162
+ /**
163
+ * isFunction
164
+ * @desc:判断是否是函数
165
+ * @author huangbo
166
+ * @date 2022年5月7日
167
+ * @param {Object} [obj] - 对象
168
+ **/
169
+ const isFunction = function (obj) {
170
+ return (
171
+ typeof obj === 'function' &&
172
+ typeof obj.nodeType !== 'number' &&
173
+ typeof obj.item !== 'function'
174
+ );
175
+ };
176
+ /**
177
+ * extend
178
+ * @desc:对象拷贝
179
+ * @author huangbo
180
+ * @date 2022年5月7日
181
+ * @param {Object} [target] - 被扩展的对象
182
+ * @param {Boolean}} [deep] - 是否深度操作
183
+ **/
184
+ const extend = function () {
185
+ let options;
186
+ let name;
187
+ let src;
188
+ let copy;
189
+ let copyIsArray;
190
+ let clone;
191
+ let target = arguments[0] || {};
192
+ let i = 1;
193
+ let length = arguments.length;
194
+ let deep = false;
195
+ if (typeof target === 'boolean') {
196
+ deep = target;
197
+ target = arguments[i] || {};
198
+ i++;
199
+ }
200
+ if (typeof target !== 'object' && !isFunction(target)) {
201
+ target = {};
202
+ }
203
+ if (i === length) {
204
+ target = this;
205
+ i--;
206
+ }
207
+ for (; i < length; i++) {
208
+ if ((options = arguments[i]) != null) {
209
+ for (name in options) {
210
+ copy = options[name];
211
+ if (name === '__proto__' || target === copy) {
212
+ continue;
213
+ }
214
+ if (
215
+ deep &&
216
+ copy &&
217
+ (isObject(copy) || (copyIsArray = Array.isArray(copy)))
218
+ ) {
219
+ src = target[name];
220
+ if (copyIsArray && !Array.isArray(src)) {
221
+ clone = [];
222
+ } else if (!copyIsArray && !isObject(src)) {
223
+ clone = {};
224
+ } else {
225
+ clone = src;
226
+ }
227
+ copyIsArray = false;
228
+ target[name] = extend(deep, clone, copy);
229
+ } else if (copy !== undefined) {
230
+ target[name] = copy;
231
+ }
232
+ }
233
+ }
234
+ }
235
+ return target;
236
+ };
237
+ /**
238
+ * getObjectType
239
+ * @desc:获取数据类型
240
+ * @author tangdaibing
241
+ * @date 2022年5月7日
242
+ **/
243
+ const getObjectType = function (data) {
244
+ let type = Object.prototype.toString.call(data).toLowerCase();
245
+ const typeFormat = {
246
+ '[object string]': 'string',
247
+ '[object number]': 'number',
248
+ '[object null]': 'null',
249
+ '[object boolean]': 'boolean',
250
+ '[object undefined]': 'undefined',
251
+ '[object object]': 'object',
252
+ '[object array]': 'array',
253
+ '[object function]': 'function',
254
+ '[object date]': 'date'
255
+ };
256
+ return typeFormat[type];
257
+ };
258
+ /**
259
+ * getParams
260
+ * @desc:获取url地址指定参数
261
+ * @author huangbo
262
+ * @date 2022年5月7日
263
+ * @param {String} [name] - 参数名称
264
+ **/
265
+ const getParams = function (name) {
266
+ var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
267
+ var r = window.location.search
268
+ ? decodeURI(window.location.search)
269
+ .substr(1)
270
+ .match(reg)
271
+ : decodeURI(window.location.hash)
272
+ .slice(decodeURI(window.location.hash).indexOf('?') + 1)
273
+ .match(reg);
274
+ if (r != null) {
275
+ return unescape(r[2]);
276
+ } else {
277
+ return null;
278
+ }
279
+ };
280
+ /**
281
+ * getScript
282
+ * @desc:获取js文件并执行
283
+ * @author huangbo
284
+ * @date 2022年5月7日
285
+ * @param {String} [url] - js文件地址
286
+ **/
287
+ const getScript = function (url) {
288
+ // eslint-disable-next-line no-undef
289
+ return new Promise((resolve, reject) => {
290
+ var xmlHttp = null;
291
+ if (window.XMLHttpRequest) {
292
+ xmlHttp = new XMLHttpRequest();
293
+ } else if (window.ActiveXObject) {
294
+ xmlHttp = new window.ActiveXObject('Microsoft.XMLHTTP');
295
+ }
296
+ if (xmlHttp == null) {
297
+ alert('浏览器不支持xmlHttp');
298
+ return;
299
+ }
300
+ xmlHttp.open('GET', url, false);
301
+ xmlHttp.onreadystatechange = () => {
302
+ if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
303
+ let res = xmlHttp.responseText;
304
+ domEval(res);
305
+ resolve(true);
306
+ } else {
307
+ reject(false);
308
+ }
309
+ };
310
+ xmlHttp.send();
311
+ }).catch(function onRejected() { });
312
+ };
313
+ /**
314
+ * domEval
315
+ * @desc:添加js内容
316
+ * @author huangbo
317
+ * @date 2022年5月7日
318
+ * @param {String} [code] - js内容
319
+ **/
320
+ function domEval(code) {
321
+ let script = document.createElement('script');
322
+ script.text = code;
323
+ document.head.appendChild(script).parentNode.removeChild(script);
324
+ }
325
+
326
+ /**
327
+ * indexOfObj
328
+ * @desc:查找数组对象下标
329
+ * @author huangbo
330
+ * @date 2022年5月7日
331
+ * @param {Array} [arry] - 被查找的数组
332
+ * @param {Object} [item] - 目标对象
333
+ * @param {String} [key] - 目标对象的属性名
334
+ **/
335
+ const indexOfObj = function (arry, item, key) {
336
+ for (var i = 0; i < arry.length; i++) {
337
+ if (key) {
338
+ if (typeof item === 'string' && arry[i][key] === item) {
339
+ return i;
340
+ }
341
+ if (item[key] === arry[i][key]) {
342
+ return i;
343
+ }
344
+ } else {
345
+ if (JSON.stringify(item) === JSON.stringify(arry[i])) {
346
+ return i;
347
+ }
348
+ }
349
+ }
350
+ return -1;
351
+ };
352
+
353
+ /**
354
+ * overbrim
355
+ * @desc:判断是否文字溢出
356
+ * @author huangbo
357
+ * @date 2022年5月7日
358
+ * @param {String} [el] - 文字所在的dom
359
+ **/
360
+ const overbrim = function (el) {
361
+ let w = el.offsetWidth;
362
+ var s = el.scrollWidth;
363
+ if (s > w) {
364
+ return true;
365
+ } else {
366
+ return false;
367
+ }
368
+ };
369
+
370
+ /**
371
+ * setStorage
372
+ * @desc:设置本地储存数据
373
+ * @author huangbo
374
+ * @date 2022年5月7日
375
+ * @param {String} [type] - 储存类型
376
+ * @param {String, Array, Object} [key] - 数据的名称,array类型表示多个key保存同一个value,object类型时对象的属性名称作为key属性值作为value
377
+ * @param {String} [value] - 数据的值
378
+ **/
379
+ const setStorage = function (type, key, value) {
380
+ if (type === undefined || type === 'sessionStorage') {
381
+ if (typeof key === 'string') {
382
+ sessionStorage.setItem(key, value);
383
+ } else if (Array.isArray(key)) {
384
+ for (let i in key) {
385
+ sessionStorage.setItem(key[i], value);
386
+ }
387
+ } else {
388
+ for (let i in key) {
389
+ sessionStorage.setItem(i, key[i]);
390
+ }
391
+ }
392
+ } else {
393
+ if (typeof key === 'string') {
394
+ localStorage.setItem(key, value);
395
+ } else if (Array.isArray(key)) {
396
+ for (let i in key) {
397
+ localStorage.setItem(key[i], value);
398
+ }
399
+ } else {
400
+ for (let i in key) {
401
+ localStorage.setItem(i, key[i]);
402
+ }
403
+ }
404
+ }
405
+ };
406
+ /**
407
+ * removeStorage
408
+ * @desc:删除本地储存数据
409
+ * @author huangbo
410
+ * @date 2022年5月7日
411
+ * @param {String, Array} [key] - 获取的名称
412
+ **/
413
+ const removeStorage = function (key) {
414
+ if (Array.isArray(key)) {
415
+ for (let i = 0; i < key.length; i++) {
416
+ sessionStorage.removeItem(key[i]);
417
+ localStorage.removeItem(key[i]);
418
+ }
419
+ } else if (key) {
420
+ sessionStorage.removeItem(key);
421
+ localStorage.removeItem(key);
422
+ } else {
423
+ sessionStorage.clear();
424
+ localStorage.clear();
425
+ }
426
+ };
427
+ /**
428
+ * getStorage
429
+ * @desc:获取本地储存数据
430
+ * @author huangbo
431
+ * @date 2022年5月7日
432
+ * @param {String} [key] - 获取的名称
433
+ **/
434
+ const getStorage = function (key) {
435
+ if (key) {
436
+ let res =
437
+ sessionStorage.getItem(key) || localStorage.getItem(key) || window[key];
438
+ if (key === 'host' && !res) {
439
+ return window.origin;
440
+ }
441
+ return res;
442
+ }
443
+ let defaults = {};
444
+ const token =
445
+ sessionStorage.getItem('token') ||
446
+ localStorage.getItem('token') ||
447
+ window.token;
448
+ const ssId =
449
+ sessionStorage.getItem('ssId') ||
450
+ localStorage.getItem('ssId') ||
451
+ window.ssId;
452
+ const deviceUnique =
453
+ sessionStorage.getItem('deviceUnique') ||
454
+ localStorage.getItem('deviceUnique') ||
455
+ window.deviceUnique;
456
+ if (token) {
457
+ defaults.Authorization = token;
458
+ }
459
+ if (ssId) {
460
+ defaults.ssId = ssId;
461
+ }
462
+ if (deviceUnique) {
463
+ defaults.deviceUnique = deviceUnique;
464
+ }
465
+ return defaults;
466
+ };
467
+ const getValues = function (obj, flag) {
468
+ let val = {};
469
+ obj.forEach(items => {
470
+ if (items.contents) {
471
+ items.contents.forEach(item => {
472
+ if (item.name && item.type !== 'button' && item.type !== 'submit') {
473
+ if (item.type === 'table' && item.form) {
474
+ val[item.name] = item.data;
475
+ } else if (item.name && (!flag && !item.hide)) {
476
+ if (item.value !== undefined && item.value !== '') {
477
+ if (Array.isArray(val)) {
478
+ if (val.length) {
479
+ val[item.name] = item.value;
480
+ }
481
+ } else {
482
+ val[item.name] = item.value;
483
+ }
484
+ }
485
+ }
486
+ }
487
+ });
488
+ } else if (
489
+ items.name &&
490
+ items.type !== 'button' &&
491
+ items.type !== 'submit'
492
+ ) {
493
+ if (items.value !== undefined && items.value !== '') {
494
+ if (Array.isArray(val)) {
495
+ if (val.length) {
496
+ val[items.name] = items.value;
497
+ }
498
+ } else {
499
+ val[items.name] = items.value;
500
+ }
501
+ }
502
+ } else if (items.type === 'table' && items.form) {
503
+ val[items.type] = items.data;
504
+ }
505
+ });
506
+ return val;
507
+ };
508
+
509
+ /**
510
+ * loading 需全局引入element-ui
511
+ * @desc:loading
512
+ * @author huangbo
513
+ * @date 2022年5月7日
514
+ * @param {String} [text] - 显示的文本内容
515
+ **/
516
+ const loading = ($loading, res) => {
517
+ if (isObject(res)) {
518
+ const config = extend(
519
+ {},
520
+ {
521
+ fullscreen: true,
522
+ background: 'rgba(0, 0, 0, 0.65)',
523
+ spinner: 'el-icon-loading',
524
+ text: '加载中...'
525
+ },
526
+ res
527
+ );
528
+ return $loading(config);
529
+ } else {
530
+ window.loading = $loading({
531
+ fullscreen: true,
532
+ background: 'rgba(0, 0, 0, 0.65)',
533
+ spinner: 'el-icon-loading',
534
+ text: res ? res : '加载中...'
535
+ });
536
+ return window.loading;
537
+ }
538
+ };
539
+
540
+ /**
541
+ * formatDate
542
+ * @desc:格式化时间
543
+ * @author huangbo
544
+ * @date 2022年5月7日
545
+ * @param {String, Number} [date] - 时间字符串或时间戳
546
+ * @param {String} [fmt] - 格式
547
+ **/
548
+ const formatDate = function (date, fmt) {
549
+ let obj;
550
+ if (date) {
551
+ obj = new Date(date);
552
+ } else {
553
+ obj = new Date();
554
+ }
555
+ let quarter = ['一', '二', '三', '四'];
556
+ let o = {
557
+ 'b+': Math.ceil((obj.getMonth() + 1) / 6), // 半年
558
+ 'M+': obj.getMonth() + 1, // 月份
559
+ 'd+': obj.getDate(), // 日
560
+ 'H+': obj.getHours(), // 小时
561
+ 'm+': obj.getMinutes(), // 分
562
+ 's+': obj.getSeconds(), // 秒
563
+ 'q+': quarter[Math.ceil((obj.getMonth() + 1) / 3) - 1], // 季度
564
+ S: obj.getMilliseconds() // 毫秒
565
+ };
566
+ if (/(y+)/.test(fmt)) {
567
+ fmt = fmt.replace(
568
+ RegExp.$1,
569
+ (obj.getFullYear() + '').substr(4 - RegExp.$1.length)
570
+ );
571
+ }
572
+ for (let k in o) {
573
+ if (new RegExp('(' + k + ')').test(fmt)) {
574
+ fmt = fmt.replace(
575
+ RegExp.$1,
576
+ RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
577
+ );
578
+ }
579
+ }
580
+ return fmt;
581
+ };
582
+ /**
583
+ * timeFrame
584
+ * @desc:格式化时间
585
+ * @author huangbo
586
+ * @date 2022年5月7日
587
+ * @param {String, Number} [date] - 时间字符串或时间戳
588
+ **/
589
+ const timeFrame = function (date) {
590
+ let obj;
591
+ if (date) {
592
+ obj = new Date(date);
593
+ } else {
594
+ obj = new Date();
595
+ }
596
+ let h = obj.getHours(); // 获取小时
597
+ let period = '';
598
+ h < 12
599
+ ? (period = '上午好!')
600
+ : h < 18
601
+ ? (period = '下午好!')
602
+ : (period = '晚上好!');
603
+ return period;
604
+ };
605
+ /**
606
+ * getStyle
607
+ * @desc:获取元素样式(含非行内样式)
608
+ * @author huangbo
609
+ * @date 2022年5月7日
610
+ * @param {String} [dom] - dom元素
611
+ * @param {String} [attr] - 样式属性名
612
+ **/
613
+
614
+ const getStyle = function (dom, attr) {
615
+ if (dom.style[attr]) {
616
+ return dom.style[attr];
617
+ }
618
+ if (window.getComputedStyle) {
619
+ return getComputedStyle(dom, null)[attr];
620
+ }
621
+ return dom.currentStyle[attr];
622
+ };
623
+
624
+ /**
625
+ * handlerUrl
626
+ * @desc:更新url参数中的时间戳
627
+ * @author huangbo
628
+ * @date 2022年5月7日
629
+ * @param {String} [url] - url地址
630
+ **/
631
+
632
+ const handlerUrl = function (url, host) {
633
+ var arry = url.split('?');
634
+ if (arry.length > 1) {
635
+ if (arry[1].indexOf('_tt') > -1) {
636
+ var search = arry[1].split('&');
637
+ for (var i in search) {
638
+ if (search[i].indexOf('_tt') > -1) {
639
+ search[i] = '_tt=' + new Date().getTime();
640
+ }
641
+ }
642
+ arry[1] = search.join('&');
643
+ } else {
644
+ arry[1] += '&_tt=' + new Date().getTime();
645
+ }
646
+ url = arry.join('?');
647
+ } else {
648
+ url += '?_tt=' + new Date().getTime();
649
+ }
650
+ url = jointUrl(url, host);
651
+ return encodeURI(url);
652
+ };
653
+
654
+ /**
655
+ * getRgb
656
+ * @desc:获取颜色值的rgb值
657
+ * @author huangbo
658
+ * @date 2022年5月7日
659
+ * @param {string} [$color] - 颜色值
660
+ **/
661
+ const getRgb = function ($color) {
662
+ let rgb = [];
663
+ // 16进制颜色值的正则
664
+ let reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
665
+ // 把颜色值变成小写
666
+ $color = $color.toLowerCase();
667
+ if (reg.test($color)) {
668
+ // 如果只有三位的值,需变成六位,如:#fff => #ffffff
669
+ if ($color.length === 4) {
670
+ let colorNew = '#';
671
+ for (let i = 1; i < 4; i++) {
672
+ colorNew += $color.slice(i, i + 1).concat($color.slice(i, i + 1));
673
+ }
674
+ $color = colorNew;
675
+ }
676
+ // 处理六位的颜色值,转为RGB
677
+ for (let i = 1; i < 7; i += 2) {
678
+ rgb.push(parseInt('0x' + $color.slice(i, i + 2), 16));
679
+ }
680
+ } else {
681
+ rgb = $color.replace(/(?:\(|\)|rgb|RGB)*/g, '').split(',');
682
+ }
683
+ return rgb;
684
+ };
685
+
686
+ /**
687
+ * rgbToHsv
688
+ * @desc:rgb转化成hsv
689
+ * @author huangbo
690
+ * @date 2022年5月7日
691
+ * @param {string} [$color] - 颜色值
692
+ **/
693
+ const rgbToHsv = function ($color) {
694
+ let rgb = getRgb($color);
695
+ let $red = rgb[0];
696
+ let $green = rgb[1];
697
+ let $blue = rgb[2];
698
+ let $max = Math.max($red, $green, $blue);
699
+ let $min = Math.min($red, $green, $blue);
700
+ let $diff = $max - $min;
701
+ let $h = 0;
702
+ if ($max === $min) {
703
+ $h = 0;
704
+ } else if ($max === $red) {
705
+ $h = (60 * ($green - $blue)) / $diff + ($green > $blue - 1 ? 0 : 360);
706
+ } else if ($max === $green) {
707
+ $h = (60 * ($blue - $red)) / $diff + 120;
708
+ } else if ($max === $blue) {
709
+ $h = (60 * ($red - $green)) / $diff + 240;
710
+ }
711
+ let $s = $max === 0 ? 0 : $diff / $max;
712
+ let $v = $max / 255;
713
+ return [$h, $s, $v];
714
+ };
715
+ /**
716
+ * hsvTorgb
717
+ * @desc:hsv转化成rgb
718
+ * @author huangbo
719
+ * @date 2022年5月7日
720
+ * @param {string} [$color] - 颜色值
721
+ **/
722
+ function hsvTorgb($h, $s, $v) {
723
+ let $th = Math.floor($h / 60);
724
+ let $t1 = $h / 60 - $th;
725
+ let $t2 = $v * (1 - $s);
726
+ let $t3 = $v * (1 - $t1 * $s);
727
+ let $t4 = $v * (1 - (1 - $t1) * $s);
728
+ let $r = [$v, $t3, $t2, $t2, $t4, $v][$th % 6];
729
+ let $g = [$t4, $v, $v, $t3, $t2, $t2][$th % 6];
730
+ let $b = [$t2, $t2, $t4, $v, $v, $t3][$th % 6];
731
+ // return `rgb(${Math.round($r * 255)}, ${Math.round($g * 255)}, ${Math.round($b * 255)})`;
732
+ let red = Math.round($r * 255);
733
+ let green = Math.round($g * 255);
734
+ let blue = Math.round($b * 255);
735
+ red = red.toString(16);
736
+ green = green.toString(16);
737
+ blue = blue.toString(16);
738
+ red = red.length === 1 ? '0' + red : red;
739
+ green = green.length === 1 ? '0' + green : green;
740
+ blue = blue.length === 1 ? '0' + blue : blue;
741
+ return `#${red}${green}${blue}`;
742
+ }
743
+ /**
744
+ * toFixed
745
+ * @desc:浮点数保留小数位
746
+ * @author huangbo
747
+ * @date 2022年5月7日
748
+ * @param {number} [$float] - 要转换的数值
749
+ * @param {number} [$digits] - 小数位数
750
+ **/
751
+ function toFixed($float, $digits) {
752
+ let $pow = Math.pow(10, $digits);
753
+ return Math.round($float * $pow) / $pow;
754
+ }
755
+
756
+ /**
757
+ * getHue
758
+ * @desc:转换色相
759
+ * @author huangbo
760
+ * @date 2022年5月7日
761
+ **/
762
+ function getHue($h, $i, $isLight) {
763
+ let $hue;
764
+ if ($h >= 60 && $h <= 240) {
765
+ $hue = $isLight ? $h - $hueStep * $i : $h + $hueStep * $i;
766
+ } else {
767
+ $hue = $isLight ? $h + $hueStep * $i : $h - $hueStep * $i;
768
+ }
769
+ $hue = ($hue + 360) % 360;
770
+ return Math.round($hue);
771
+ }
772
+
773
+ /**
774
+ * getSaturation
775
+ * @desc:转换饱和度
776
+ * @author huangbo
777
+ * @date 2022年5月7日
778
+ **/
779
+ function getSaturation($s, $i, $isLight) {
780
+ let $saturation;
781
+ if ($isLight) {
782
+ $saturation = $s - $saturationStep1 * $i;
783
+ } else if ($i === $darkColorCount) {
784
+ $saturation = $s + $saturationStep1;
785
+ } else {
786
+ $saturation = $s + $saturationStep2 * $i;
787
+ }
788
+ $saturation = $saturation < 1 ? $saturation : 1;
789
+
790
+ if ($isLight && $i === $lightColorCount && $saturation > 0.1) {
791
+ $saturation = 0.1;
792
+ }
793
+ $saturation = $saturation > 0.06 ? $saturation : 0.06;
794
+ return toFixed($saturation, 2);
795
+ }
796
+
797
+ /**
798
+ * getValue
799
+ * @desc:转换明度
800
+ * @author huangbo
801
+ * @date 2022年5月7日
802
+ **/
803
+ function getValue($v, $i, $isLight) {
804
+ let $value = $isLight
805
+ ? $v + $brightnessStep1 * $i
806
+ : $v - $brightnessStep2 * $i;
807
+ $value = $value < 1 ? $value : 1;
808
+ return toFixed($value, 2);
809
+ }
810
+ const $hueStep = 2;
811
+ const $saturationStep1 = 0.16;
812
+ const $saturationStep2 = 0.05;
813
+ const $brightnessStep1 = 0.05;
814
+ const $brightnessStep2 = 0.15;
815
+ const $lightColorCount = 5;
816
+ const $darkColorCount = 4;
817
+
818
+ /**
819
+ * getColor
820
+ * @desc:根据颜色和对应的色板位置,计算出对应的色板颜色
821
+ * @author huangbo
822
+ * @date 2022年5月7日
823
+ **/
824
+ function getColor($color, $n) {
825
+ let $isLight = $n < 7;
826
+ let $hsv = rgbToHsv($color);
827
+ // 这里将i转换成以主色为中心,两侧的i值逐渐增大
828
+ let $i = $isLight ? $lightColorCount + 1 - $n : $n - $lightColorCount - 1;
829
+ let color = hsvTorgb(
830
+ getHue($hsv[0], $i, $isLight),
831
+ getSaturation($hsv[1], $i, $isLight),
832
+ getValue($hsv[2], $i, $isLight)
833
+ );
834
+ return color;
835
+ }
836
+ /**
837
+ * mixColor
838
+ * @desc:生成混合色
839
+ * @author huangbo
840
+ * @date 2022年5月7日
841
+ * @param {string} [$color1] - 颜色值
842
+ * @param {string} [$color2] - 颜色值
843
+ * @param {string} [$n] - 百分比 0~1
844
+ **/
845
+ const mixColor = function ($color1, $color2, $n) {
846
+ const rgb1 = getRgb($color1);
847
+ const rgb2 = getRgb($color2);
848
+ const r = rgb1[0] * $n + rgb2[0] * (1 - $n);
849
+ const g = rgb1[1] * $n + rgb2[1] * (1 - $n);
850
+ const b = rgb1[2] * $n + rgb2[2] * (1 - $n);
851
+ return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
852
+ };
853
+ /**
854
+ * updateTheme
855
+ * @desc:更新主题色
856
+ * @author huangbo
857
+ * @date 2022年5月7日
858
+ * @param {string} [$color] - 颜色值
859
+ **/
860
+ const updateTheme = function ($color, send) {
861
+ $color = $color ? $color : '#409eff';
862
+ if (send === undefined) {
863
+ send = true;
864
+ }
865
+ document.documentElement.style.setProperty('--theme-primary', $color);
866
+ for (let i = 1; i < 11; i++) {
867
+ if (i === 6) {
868
+ document.documentElement.style.setProperty(
869
+ '--theme-primary-light-' + i,
870
+ $color
871
+ );
872
+ } else {
873
+ const light = getColor($color, i);
874
+ document.documentElement.style.setProperty(
875
+ '--theme-primary-light-' + i,
876
+ light
877
+ );
878
+ }
879
+ }
880
+ if (send) {
881
+ sendMessage({ data: { type: 'setTheme' } });
882
+ }
883
+ };
884
+ /**
885
+ * sendMessage
886
+ * @desc:向iframe发送信息
887
+ * @author huangbo
888
+ * @date 2022年5月7日
889
+ * @param {object} [data] - 数据---其中type必须表示操作类型
890
+ * @param {string} [url] - 指定的消息发送URI地址
891
+ **/
892
+ const sendMessage = function ({ data = {}, url }) {
893
+ const iframes = document.getElementsByTagName('iframe');
894
+ for (let i = 0; i < iframes.length; i++) {
895
+ if (url !== undefined) {
896
+ if (iframes[i].contentWindow.location.href === url) {
897
+ iframes[i].contentWindow.postMessage(data, url);
898
+ return;
899
+ }
900
+ } else {
901
+ iframes[i].contentWindow.postMessage(data);
902
+ }
903
+ }
904
+ };
905
+
906
+ /**
907
+ * receiveMessage
908
+ * @desc:接收发送信息
909
+ * @author huangbo
910
+ * @date 2022年5月7日
911
+ * @param {object} [data] - 数据---其中type必须表示操作类型
912
+ * @param {string} [url] - 消息源的 URI
913
+ * @param {function} [callback] - 回调函数
914
+ **/
915
+ const receiveMessage = function ({ data = {}, url, callback }) {
916
+ window.addEventListener('message', function (e) {
917
+ if (url !== undefined) {
918
+ if (e.origin !== url) {
919
+ // 验证消息来源地址
920
+ return;
921
+ }
922
+ }
923
+ callback(e.data);
924
+ });
925
+ };
926
+
927
+ /**
928
+ * getTypeName
929
+ * @desc:转换类型文本
930
+ * @author huangbo
931
+ * @date 2022年5月7日
932
+ * @param {string} [type] - 类型
933
+ **/
934
+ const getTypeName = function (type) {
935
+ let typeName = '';
936
+ const sysorgname = getStorage('sysorgname');
937
+ const sysdepname = getStorage('sysdepname');
938
+ if (type === 'enterprise') {
939
+ if (sysorgname) {
940
+ typeName = '[' + sysorgname + ']';
941
+ } else {
942
+ typeName = '[公司]';
943
+ }
944
+ } else if (type === 'department') {
945
+ if (sysdepname) {
946
+ typeName = '[' + sysdepname + ']';
947
+ } else {
948
+ typeName = '[部门]';
949
+ }
950
+ } else if (type === 'role') {
951
+ typeName = '[角色]';
952
+ } else if (type === 'post') {
953
+ typeName = '[岗位]';
954
+ } else if (type === 'otheremployee' || type === 'employee') {
955
+ if (sysdepname) {
956
+ typeName = '[' + sysdepname + '员工]';
957
+ } else {
958
+ typeName = '[部门员工]';
959
+ }
960
+ } else if (type === 'postemployee') {
961
+ typeName = '[岗位员工]';
962
+ } else if (type === 'persongroup') {
963
+ typeName = '[人员群组成员]';
964
+ } else if (type === 'filgroup') {
965
+ if (sysorgname) {
966
+ typeName = '[' + sysorgname + '群组成员]';
967
+ } else {
968
+ typeName = '[公司群组成员]';
969
+ }
970
+ } else if (type === 'depgroup') {
971
+ if (sysdepname) {
972
+ typeName = '[' + sysdepname + '群组成员]';
973
+ } else {
974
+ typeName = '[部门群组成员]';
975
+ }
976
+ } else if (type === 'persongroupobj') {
977
+ typeName = '[人员群组]';
978
+ } else if (type === 'filgroupobj') {
979
+ if (sysorgname) {
980
+ typeName = '[' + sysorgname + '群组]';
981
+ } else {
982
+ typeName = '[公司群组]';
983
+ }
984
+ } else if (type === 'depgroupobj') {
985
+ if (sysdepname) {
986
+ typeName = '[' + sysdepname + '群组]';
987
+ } else {
988
+ typeName = '[部门群组]';
989
+ }
990
+ } else if (
991
+ type === 'otherperson' ||
992
+ type === 'topcontacts' ||
993
+ type === 'person'
994
+ ) {
995
+ typeName = '[人员]';
996
+ } else if (type === 'codetable') {
997
+ typeName = '[代码表]';
998
+ } else if (type === 'organizecentreobj') {
999
+ typeName = '[组织中心]';
1000
+ }
1001
+ return typeName;
1002
+ };
1003
+
1004
+ /**
1005
+ * replenish
1006
+ * @desc:补全小数位数
1007
+ * @author huangbo
1008
+ * @date 2022年5月7日
1009
+ * @param {string、number} [num] - 数字或字符串型数字
1010
+ * @param {number} [precision] - 需要的小数位数
1011
+ **/
1012
+ const replenish = function (num, precision) {
1013
+ if (num && precision && precision > 0) {
1014
+ let power = Math.pow(10, precision);
1015
+ let res = num === 'string' ? Number(num) : num;
1016
+ res = String(Math.round(res * power) / power);
1017
+ let len = res.indexOf('.');
1018
+ if (len < 0) {
1019
+ len = res.length;
1020
+ res += '.';
1021
+ }
1022
+ while (res.length <= len + precision) {
1023
+ res += '0';
1024
+ }
1025
+ return parseFloat(res);
1026
+ }
1027
+ return num;
1028
+ };
1029
+ /**
1030
+ * identical
1031
+ * @desc:form验证两个值是否相同(确认密码)
1032
+ * @author huangbo
1033
+ * @date 2022年5月7日
1034
+ * @param {val} [string] - 当前值
1035
+ * @param {callback} [function] - 回调函数
1036
+ * @param {val} [string] - 被验证的原值
1037
+ **/
1038
+ const identical = function (value, callback, val) {
1039
+ if (value === '' || value === null || value === undefined) {
1040
+ if (val === '' || val === null || val === undefined) {
1041
+ callback();
1042
+ } else {
1043
+ callback(new Error('请再次输入'));
1044
+ }
1045
+ } else if (value !== val) {
1046
+ callback(new Error('两次输入不一致!'));
1047
+ } else {
1048
+ callback();
1049
+ }
1050
+ };
1051
+
1052
+ /**
1053
+ * exportXls
1054
+ * @desc:导出表格数据
1055
+ * @author huangbo
1056
+ * @date 2022年5月7日
1057
+ * @param {thead} [array] - 表单头部
1058
+ * @param {data} [array] - 导出的数据
1059
+ * @param {name} [string] - 导出文件名
1060
+ * @param {numbers} [boolean] - 序号
1061
+ **/
1062
+ const exportXls = function ({ thead = [], data = [], name, numbers }) {
1063
+ let tbody = '';
1064
+ let aligns = [];
1065
+ let fields = [];
1066
+ let alink = document.createElement('a');
1067
+ for (let i = 0; i < thead.length; i++) {
1068
+ tbody += '<tr style="text-align: center;">';
1069
+ if (numbers) {
1070
+ tbody += '<th rowspan="' + thead.length + '"></th>';
1071
+ }
1072
+ const tr = thead[i];
1073
+ for (let x = 0; x < tr.length; x++) {
1074
+ const td = tr[x];
1075
+ tbody += `<th rowspan="${td.rowspan}" colspan="${td.colspan}" align="${td.align}">${td.label}</th>`;
1076
+ if (td.property) {
1077
+ fields.push(td.property);
1078
+ aligns.push(td.align);
1079
+ }
1080
+ }
1081
+ tbody += '</tr>';
1082
+ }
1083
+ for (let i = 0; i < data.length; i++) {
1084
+ tbody += '<tr>';
1085
+ for (var x in fields) {
1086
+ tbody += '<td align="' + aligns[x] + '">' + data[i][fields[x]] + '</td>';
1087
+ }
1088
+ tbody += '</tr>';
1089
+ }
1090
+ if (!name) {
1091
+ name = 'table_' + new Date().getTime();
1092
+ }
1093
+ var uri = 'data:application/vnd.ms-excel;base64,';
1094
+ var template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table style="vnd.ms-excel.numberformat:@">' + tbody + '</table></body></html>';
1095
+ alink.href = uri + window.btoa(unescape(encodeURIComponent(template)));
1096
+ alink.download = name + '.xls';
1097
+ document.body.appendChild(alink);
1098
+ alink.click();
1099
+ document.body.removeChild(alink);
1100
+ };
1101
+ /**
1102
+ * 获取色彩列表的方法
1103
+ * @function themeTools#handlerGetThemeCluster
1104
+ * @param {String} color - 主题色
1105
+ * @param {String} mode - 风格模式light | dark
1106
+ * @param {String} backgroundColor - mode = dark时的页面背景颜色
1107
+ *
1108
+ * @example
1109
+ * ```js
1110
+ * handlerGetThemeCluster('#0e91ef','dark','#000000');
1111
+ * ```
1112
+ * @return {Array} ['#e6f9ff','#0e91ef',...]
1113
+ */
1114
+ const handlerGetThemeCluster = function (color, mode = 'light', backgroundColor = '#000000') {
1115
+ return generate(color, mode === 'dark' ? { theme: 'dark', backgroundColor } : {});
1116
+ };
1117
+
1118
+ /**
1119
+ * H5TokenInvalid
1120
+ * @desc 原生app重新登录
1121
+ * @date 2023年3月2日
1122
+ * @author liufan
1123
+ */
1124
+ const H5TokenInvalid = function() {
1125
+ let u = navigator.userAgent;
1126
+ let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
1127
+ let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
1128
+ if (isAndroid) {
1129
+ window.AndroidWebView.H5TokenInvalid();
1130
+ } else if (isiOS) {
1131
+ let info = {};
1132
+ window.webkit.messageHandlers.H5TokenInvalid.postMessage(info);
1133
+ }
1134
+ };
1135
+ /**
1136
+ * JSCallNativeShowTabbar
1137
+ * @desc:原生app隐藏或显示底部tabbar
1138
+ * @date 2023年3月2日
1139
+ * @author liufan
1140
+ * @param {Boolean} res -是否展示底部导航
1141
+ */
1142
+ const JSCallNativeShowTabbar = function(res) {
1143
+ let u = navigator.userAgent;
1144
+ let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
1145
+ let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
1146
+ let data = {
1147
+ showState: res
1148
+ };
1149
+ if (isAndroid) {
1150
+ window.AndroidWebView.JSCallNativeShowTabbar(JSON.stringify(data));
1151
+ } else if (isiOS) {
1152
+ window.webkit.messageHandlers.JSCallNativeShowTabbar.postMessage(data);
1153
+ }
1154
+ };
1155
+ /**
1156
+ * JSCallNativeShowNaviBar
1157
+ * @desc:原生app隐藏或者显示头部导航栏
1158
+ * @date 2023年3月2日
1159
+ * @author liufan
1160
+ * @param {Boolean} res -是否展示头部导航栏
1161
+ */
1162
+ const JSCallNativeShowNaviBar = function(res) {
1163
+ let u = navigator.userAgent;
1164
+ let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
1165
+ let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
1166
+ if (isAndroid) {
1167
+ let data = {
1168
+ showState: res
1169
+ };
1170
+ window.AndroidWebView.JSCallNativeShowNaviBar(JSON.stringify(data));
1171
+ } else if (isiOS) {
1172
+ window.webkit.messageHandlers.JSCallNativeShowNaviBar({
1173
+ showState: JSON.stringify(res)
1174
+ });
1175
+ }
1176
+ };
1177
+ /**
1178
+ * JSCallNativeOpenUrl
1179
+ * @desc:原生app打开外部链接
1180
+ * @date 2023年3月2日
1181
+ * @author liufan
1182
+ * @param {Object} data -链接参数
1183
+ */
1184
+ const JSCallNativeOpenUrl = function(data) {
1185
+ let u = navigator.userAgent;
1186
+ let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
1187
+ let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
1188
+ if (isAndroid) {
1189
+ window.AndroidWebView.JSCallNativeOpenUrl(JSON.stringify(data));
1190
+ } else if (isiOS) {
1191
+ window.webkit.messageHandlers.JSCallNativeOpenUrl.postMessage(data);
1192
+ }
1193
+ };
1194
+ /**
1195
+ * openMainBodyFile
1196
+ * @desc:原生app打开正文
1197
+ * @date 2023年3月2日
1198
+ * @author liufan
1199
+ * @param {Object} data 正文参数
1200
+ */
1201
+ const openMainBodyFile = function(data) {
1202
+ let u = navigator.userAgent;
1203
+ let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
1204
+ let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
1205
+ if (isAndroid) {
1206
+ window.AndroidWebView.JSCallOpenMainBodyFile(JSON.stringify(data));
1207
+ } else if (isiOS) {
1208
+ window.webkit.messageHandlers.JSCallOpenMainBodyFile.postMessage(data);
1209
+ }
1210
+ };
1211
+ /**
1212
+ * openUrl
1213
+ * @desc 打开外网地址
1214
+ * @date 2023年3月2日
1215
+ * @author liufan
1216
+ * @param {String} url 调整地址
1217
+ */
1218
+ const openUrl = function(url) {
1219
+ let u = navigator.userAgent;
1220
+ let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
1221
+ let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
1222
+ if (isAndroid) {
1223
+ window.open(url);
1224
+ } else if (isiOS) {
1225
+ window.location.href = url;
1226
+ }
1227
+ };
1228
+ /**
1229
+ * openAttachment
1230
+ * @desc:原生app通用打开附件
1231
+ * @date 2023年3月2日
1232
+ * @author liufan
1233
+ * @param {Object} data -附件信息
1234
+ */
1235
+ const openAttachment = function(data) {
1236
+ if (window.isCh) {
1237
+ window.uexPDF.openOther(data);
1238
+ } else {
1239
+ let u = navigator.userAgent;
1240
+ let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; // android终端
1241
+ let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
1242
+ if (isAndroid) {
1243
+ window.AndroidWebView.jsOpenAccessory(JSON.stringify(data));
1244
+ } else if (isiOS) {
1245
+ window.webkit.messageHandlers.jsOpenAccessory.postMessage(data);
1246
+ }
1247
+ }
1248
+ };
1249
+ /**
1250
+ * deepClone
1251
+ * @desc:深拷贝
1252
+ * @date 2023年3月2日
1253
+ * @author liufan
1254
+ * @param {Object、Array} target
1255
+ */
1256
+ const deepClone = (target) => {
1257
+ let result;
1258
+ // 如果当前需要深拷贝的是一个对象的话
1259
+ if (typeof target === 'object') {
1260
+ // 如果是一个数组的话
1261
+ if (Array.isArray(target)) {
1262
+ result = [];
1263
+ for (let i in target) {
1264
+ result.push(deepClone(target[i]));
1265
+ }
1266
+ } else if (target === null) {
1267
+ result = null;
1268
+ } else if (target.constructor === RegExp) {
1269
+ result = target;
1270
+ } else {
1271
+ result = {};
1272
+ for (let i in target) {
1273
+ result[i] = deepClone(target[i]);
1274
+ }
1275
+ }
1276
+ } else {
1277
+ result = target;
1278
+ }
1279
+ return result;
1280
+ };
1281
+
1282
+ /**
1283
+ * 排除属性
1284
+ * @desc:exclAttribute
1285
+ * @author huangbo
1286
+ * @date 2022年5月7日
1287
+ * @param {String/Array} [attrs] - 要排除的属性
1288
+ **/
1289
+ const exclAttribute = ({ attrs = 'value', data }) => {
1290
+ let obj = extend(true, {}, data);
1291
+ if (Array.isArray(attrs)) {
1292
+ attrs.forEach(item => {
1293
+ if (obj[item] !== undefined) {
1294
+ delete obj[item];
1295
+ }
1296
+ });
1297
+ } else {
1298
+ delete obj[attrs];
1299
+ }
1300
+ return obj;
1301
+ };
1302
+ export default {
1303
+ esEncrypt,
1304
+ esDecode,
1305
+ startWith,
1306
+ jointUrl,
1307
+ queryParams,
1308
+ exclAttribute,
1309
+ urlJoinParams,
1310
+ arrUnique,
1311
+ isObject,
1312
+ isFunction,
1313
+ extend,
1314
+ getObjectType,
1315
+ getParams,
1316
+ getScript,
1317
+ indexOfObj,
1318
+ overbrim,
1319
+ deepClone,
1320
+ setStorage,
1321
+ handlerGetThemeCluster,
1322
+ JSCallNativeShowNaviBar,
1323
+ removeStorage,
1324
+ openAttachment,
1325
+ openUrl,
1326
+ JSCallNativeOpenUrl,
1327
+ openMainBodyFile,
1328
+ JSCallNativeShowTabbar,
1329
+ H5TokenInvalid,
1330
+ getStorage,
1331
+ getValues,
1332
+ loading,
1333
+ formatDate,
1334
+ timeFrame,
1335
+ getStyle,
1336
+ handlerUrl,
1337
+ mixColor,
1338
+ getRgb,
1339
+ updateTheme,
1340
+ sendMessage,
1341
+ receiveMessage,
1342
+ getTypeName,
1343
+ replenish,
1344
+ identical,
1345
+ exportXls
1346
+ };