gcs-ui-lib 1.0.1

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 (231) hide show
  1. package/.env.development +5 -0
  2. package/.env.production +7 -0
  3. package/.eslintrc.js +5 -0
  4. package/README.md +97 -0
  5. package/_webpack.config.js +135 -0
  6. package/babel.config.js +16 -0
  7. package/lib/demo.html +10 -0
  8. package/lib/fonts/SIMSUN.5e0c362c.5e0c362c.ttf +0 -0
  9. package/lib/fonts/element-icons.535877f5.535877f5.woff +0 -0
  10. package/lib/fonts/element-icons.732389de.732389de.ttf +0 -0
  11. package/lib/fonts/iconfont.09d221ee.09d221ee.woff +0 -0
  12. package/lib/fonts/iconfont.1c4bfacc.1c4bfacc.ttf +0 -0
  13. package/lib/fonts/iconfont.a6f34dc7.a6f34dc7.woff2 +0 -0
  14. package/lib/fonts/iconfont.f4c32765.f4c32765.ttf +0 -0
  15. package/lib/gcs-ui-lib.common.js +106776 -0
  16. package/lib/gcs-ui-lib.css +3 -0
  17. package/lib/gcs-ui-lib.umd.js +106786 -0
  18. package/lib/gcs-ui-lib.umd.min.js +330 -0
  19. package/lib/img/bankbackground(1).e1f6e40f.jpg +0 -0
  20. package/lib/img/busibackground(2).7e09bf1f.jpg +0 -0
  21. package/lib/img/document.193a282d.svg +8 -0
  22. package/lib/img/folder.8e019792.svg +9 -0
  23. package/lib/img/icon.fc86764f.gif +0 -0
  24. package/npm +1 -0
  25. package/package.json +101 -0
  26. package/packages/AutoFillDetail/index.js +7 -0
  27. package/packages/AutoFillDetail/src/components/fillDetail.vue +188 -0
  28. package/packages/AutoFillDetail/src/demo/index.vue +18 -0
  29. package/packages/AutoFillDetail/src/main.vue +283 -0
  30. package/packages/AutoFillDetection/index.js +7 -0
  31. package/packages/AutoFillDetection/src/components/FillInfo.vue +36 -0
  32. package/packages/AutoFillDetection/src/components/HandEntred.vue +226 -0
  33. package/packages/AutoFillDetection/src/components/RuleHit.vue +105 -0
  34. package/packages/AutoFillDetection/src/components/SelectEntries.vue +192 -0
  35. package/packages/AutoFillDetection/src/components/config.js +359 -0
  36. package/packages/AutoFillDetection/src/demo/index.vue +18 -0
  37. package/packages/AutoFillDetection/src/main.vue +130 -0
  38. package/packages/AutoFillList/index.js +7 -0
  39. package/packages/AutoFillList/src/components/ImportRules.vue +407 -0
  40. package/packages/AutoFillList/src/components/ImportRulesDialog.vue +40 -0
  41. package/packages/AutoFillList/src/components/config.js +616 -0
  42. package/packages/AutoFillList/src/demo/index.vue +28 -0
  43. package/packages/AutoFillList/src/main.vue +559 -0
  44. package/packages/AutoFillRuleHistory/index.js +7 -0
  45. package/packages/AutoFillRuleHistory/src/demo/index.vue +23 -0
  46. package/packages/AutoFillRuleHistory/src/main.vue +422 -0
  47. package/packages/AutoFillService/index.js +7 -0
  48. package/packages/AutoFillService/src/components/BudgetAccountDialogForSetting.vue +588 -0
  49. package/packages/AutoFillService/src/components/BudgetAccountSettingDialog.vue +377 -0
  50. package/packages/AutoFillService/src/components/ConditionGroup.vue +413 -0
  51. package/packages/AutoFillService/src/components/CustomInput.vue +191 -0
  52. package/packages/AutoFillService/src/components/FillComponent.vue +371 -0
  53. package/packages/AutoFillService/src/components/SelectBudgetAccountDialog.vue +161 -0
  54. package/packages/AutoFillService/src/components/SelectDialog.vue +211 -0
  55. package/packages/AutoFillService/src/components/basic.vue +308 -0
  56. package/packages/AutoFillService/src/components/config.js +549 -0
  57. package/packages/AutoFillService/src/components/fillDetail.vue +145 -0
  58. package/packages/AutoFillService/src/components/fillRules.vue +787 -0
  59. package/packages/AutoFillService/src/components/paymentCategory.vue +297 -0
  60. package/packages/AutoFillService/src/components/paymentCategoryT.vue +292 -0
  61. package/packages/AutoFillService/src/customTemplate/FillBigDecimal.vue +50 -0
  62. package/packages/AutoFillService/src/customTemplate/FillDate.vue +54 -0
  63. package/packages/AutoFillService/src/customTemplate/FillInput.vue +33 -0
  64. package/packages/AutoFillService/src/customTemplate/FillMultiSelect.vue +70 -0
  65. package/packages/AutoFillService/src/customTemplate/FillSelect.vue +72 -0
  66. package/packages/AutoFillService/src/demo/index.vue +30 -0
  67. package/packages/AutoFillService/src/main.vue +432 -0
  68. package/packages/Bank/index.js +7 -0
  69. package/packages/Bank/src/demo/index.vue +18 -0
  70. package/packages/Bank/src/main.vue +70 -0
  71. package/packages/BranchBank/index.js +7 -0
  72. package/packages/BranchBank/src/demo/index.vue +18 -0
  73. package/packages/BranchBank/src/main.vue +97 -0
  74. package/packages/ConfigurableForm/index.js +7 -0
  75. package/packages/ConfigurableForm/src/components/config.js +63 -0
  76. package/packages/ConfigurableForm/src/components/detail.vue +158 -0
  77. package/packages/ConfigurableForm/src/demo/index.vue +279 -0
  78. package/packages/ConfigurableForm/src/main.vue +529 -0
  79. package/packages/DynamicForm/index.js +7 -0
  80. package/packages/DynamicForm/src/components/Amount.vue +51 -0
  81. package/packages/DynamicForm/src/components/AmountRange.vue +76 -0
  82. package/packages/DynamicForm/src/components/CheckboxGroup.vue +63 -0
  83. package/packages/DynamicForm/src/components/DMY.vue +126 -0
  84. package/packages/DynamicForm/src/components/Date.vue +51 -0
  85. package/packages/DynamicForm/src/components/DateRange.vue +51 -0
  86. package/packages/DynamicForm/src/components/Dialog.vue +247 -0
  87. package/packages/DynamicForm/src/components/Input.vue +48 -0
  88. package/packages/DynamicForm/src/components/InputNumber.vue +69 -0
  89. package/packages/DynamicForm/src/components/InputNumberRange.vue +47 -0
  90. package/packages/DynamicForm/src/components/LazySelect.vue +311 -0
  91. package/packages/DynamicForm/src/components/RadioGroup.vue +43 -0
  92. package/packages/DynamicForm/src/components/Rate.vue +57 -0
  93. package/packages/DynamicForm/src/components/Select.vue +307 -0
  94. package/packages/DynamicForm/src/components/Switch.vue +32 -0
  95. package/packages/DynamicForm/src/components/Textarea.vue +58 -0
  96. package/packages/DynamicForm/src/components/TimeSelect.vue +61 -0
  97. package/packages/DynamicForm/src/components/unitTreeSelect.vue +141 -0
  98. package/packages/DynamicForm/src/components/urlLinkInput.vue +100 -0
  99. package/packages/DynamicForm/src/demo/index.vue +486 -0
  100. package/packages/DynamicForm/src/fileUpload.js +232 -0
  101. package/packages/DynamicForm/src/formConfig.js +2910 -0
  102. package/packages/DynamicForm/src/helpers.js +18 -0
  103. package/packages/DynamicForm/src/main.vue +1095 -0
  104. package/packages/FileImport/index.js +7 -0
  105. package/packages/FileImport/src/demo/index.vue +29 -0
  106. package/packages/FileImport/src/main.vue +306 -0
  107. package/packages/MultiCurrencyStatistics/index.js +7 -0
  108. package/packages/MultiCurrencyStatistics/src/demo/index.vue +320 -0
  109. package/packages/MultiCurrencyStatistics/src/main.vue +200 -0
  110. package/packages/SelectTicket/index.js +7 -0
  111. package/packages/SelectTicket/src/Tree/index.vue +13 -0
  112. package/packages/SelectTicket/src/demo/index.vue +139 -0
  113. package/packages/SelectTicket/src/header.js +276 -0
  114. package/packages/SelectTicket/src/main.vue +581 -0
  115. package/packages/SelectTicket/src/printDialog/dialogO.vue +116 -0
  116. package/packages/SelectTicket/src/printDialog/index.vue +69 -0
  117. package/packages/SelectTicket/src/ticketDetail/billInformation/README.MD +6 -0
  118. package/packages/SelectTicket/src/ticketDetail/billInformation/mixins/index.js +35 -0
  119. package/packages/SelectTicket/src/ticketDetail/billInformation/obverse.vue +768 -0
  120. package/packages/SelectTicket/src/ticketDetail/billInformation/overview.vue +115 -0
  121. package/packages/SelectTicket/src/ticketDetail/billInformation/printList.vue +127 -0
  122. package/packages/SelectTicket/src/ticketDetail/billInformation/reverse.vue +205 -0
  123. package/packages/SelectTicket/src/ticketDetail/billInformation//351/231/204/345/212/240/344/277/235/350/257/201/344/277/241/346/201/257/345/255/227/346/256/265/345/257/271/347/205/247.md +246 -0
  124. package/packages/SelectTicket/src/ticketDetail/dialog.vue +73 -0
  125. package/packages/SelectTicket/src/ticketDetail/img/bankbackground(1).jpg +0 -0
  126. package/packages/SelectTicket/src/ticketDetail/img/busibackground(2).jpg +0 -0
  127. package/packages/SelectTicket/src/ticketDetail/img/icon.gif +0 -0
  128. package/packages/SelectTicket/src/ticketDetail/img/icon2.png +0 -0
  129. package/packages/SelectTicket/src/ticketDetail/img/noData.png +0 -0
  130. package/packages/SelectTicket/src/ticketDetail/index.vue +188 -0
  131. package/packages/SelectTreeUnit/index.js +7 -0
  132. package/packages/SelectTreeUnit/src/Tree/document.svg +8 -0
  133. package/packages/SelectTreeUnit/src/Tree/folder.svg +9 -0
  134. package/packages/SelectTreeUnit/src/Tree/index.vue +239 -0
  135. package/packages/SelectTreeUnit/src/demo/index.vue +219 -0
  136. package/packages/SelectTreeUnit/src/forEachs.js +16 -0
  137. package/packages/SelectTreeUnit/src/main.vue +1136 -0
  138. package/packages/SelectTreeUnitForm/index.js +7 -0
  139. package/packages/SelectTreeUnitForm/src/Tree/document.svg +8 -0
  140. package/packages/SelectTreeUnitForm/src/Tree/folder.svg +9 -0
  141. package/packages/SelectTreeUnitForm/src/Tree/index.vue +254 -0
  142. package/packages/SelectTreeUnitForm/src/demo/index.vue +230 -0
  143. package/packages/SelectTreeUnitForm/src/forEachs.js +16 -0
  144. package/packages/SelectTreeUnitForm/src/main.vue +1068 -0
  145. package/packages/StreamRefill/index.js +7 -0
  146. package/packages/StreamRefill/src/components/FillBigDecimal.vue +50 -0
  147. package/packages/StreamRefill/src/components/FillDate.vue +56 -0
  148. package/packages/StreamRefill/src/components/FillInput.vue +36 -0
  149. package/packages/StreamRefill/src/components/FillMultiSelect.vue +54 -0
  150. package/packages/StreamRefill/src/components/FillSelect.vue +51 -0
  151. package/packages/StreamRefill/src/demo/index.vue +254 -0
  152. package/packages/StreamRefill/src/main.vue +335 -0
  153. package/packages/Trade/index.js +7 -0
  154. package/packages/Trade/src/components/all/index.vue +913 -0
  155. package/packages/Trade/src/components/dynamicColumnMixin.js +69 -0
  156. package/packages/Trade/src/components/getDCloumn.js +15 -0
  157. package/packages/Trade/src/components/i18n.json +3337 -0
  158. package/packages/Trade/src/components/pendingEvent/index.vue +934 -0
  159. package/packages/Trade/src/components/server-config.js +60 -0
  160. package/packages/Trade/src/components/setUnitName.js +10 -0
  161. package/packages/Trade/src/components/specialHandle.js +171 -0
  162. package/packages/Trade/src/components/topendingTabs.js +21 -0
  163. package/packages/Trade/src/demo/index.vue +43 -0
  164. package/packages/Trade/src/main.vue +86 -0
  165. package/packages/ValidateQuota/index.js +58 -0
  166. package/packages/ValidateQuota/src/demo/index.vue +190 -0
  167. package/packages/ValidateQuota/src/main.vue +71 -0
  168. package/packages/ZipImport/index.js +7 -0
  169. package/packages/ZipImport/src/demo/index.vue +139 -0
  170. package/packages/ZipImport/src/main.vue +330 -0
  171. package/packages/approvel/index.js +8 -0
  172. package/packages/approvel/src/demo/index.vue +28 -0
  173. package/packages/approvel/src/main.vue +26 -0
  174. package/packages/approvel/src/progress.vue +167 -0
  175. package/packages/approvel/src/url.json +29 -0
  176. package/packages/extends/ElSelect.vue +180 -0
  177. package/packages/imgs/list-select.png +0 -0
  178. package/packages/imgs/list-unselect.png +0 -0
  179. package/packages/imgs/list.png +0 -0
  180. package/packages/imgs/tree-select.png +0 -0
  181. package/packages/imgs/tree-unselect.png +0 -0
  182. package/packages/imgs/tree.png +0 -0
  183. package/packages/inputTag/index.js +7 -0
  184. package/packages/inputTag/src/demo/index.vue +355 -0
  185. package/packages/inputTag/src/main.vue +502 -0
  186. package/public/favicon.ico +0 -0
  187. package/public/index.html +19 -0
  188. package/src/App.vue +61 -0
  189. package/src/api/aims.js +8 -0
  190. package/src/api/common.js +254 -0
  191. package/src/api/fileApi.js +33 -0
  192. package/src/api/setting.js +249 -0
  193. package/src/config/appSettings.js +12 -0
  194. package/src/config/favicon.ico +0 -0
  195. package/src/css/autoFill.scss +252 -0
  196. package/src/css/selectTreeUnit.scss +254 -0
  197. package/src/filter/filter.js +1 -0
  198. package/src/filter/index.js +274 -0
  199. package/src/fonts/demo.css +539 -0
  200. package/src/fonts/iconfont.css +21 -0
  201. package/src/fonts/iconfont.js +1 -0
  202. package/src/fonts/iconfont.json +23 -0
  203. package/src/fonts/iconfont.ttf +0 -0
  204. package/src/index.js +161 -0
  205. package/src/locale/format.js +47 -0
  206. package/src/locale/index.js +48 -0
  207. package/src/locale/lang/cn2hk.json +1270 -0
  208. package/src/locale/lang/en.js +73 -0
  209. package/src/locale/lang/es.js +7 -0
  210. package/src/locale/lang/index.js +66 -0
  211. package/src/locale/lang/ja.js +7 -0
  212. package/src/locale/lang/zh.js +74 -0
  213. package/src/locale/lang/zht.js +27 -0
  214. package/src/main.js +49 -0
  215. package/src/preview/page/Aside/index.vue +60 -0
  216. package/src/preview/router.js +107 -0
  217. package/src/utils/auth.js +12 -0
  218. package/src/utils/directive/asciiWidth.js +107 -0
  219. package/src/utils/directive/clickOutside.js +21 -0
  220. package/src/utils/directive/vtitle.js +140 -0
  221. package/src/utils/excel.js +538 -0
  222. package/src/utils/index.js +581 -0
  223. package/src/utils/request.js +157 -0
  224. package/src/utils/requestCache.js +68 -0
  225. package/src/utils/session.js +36 -0
  226. package/src/utils/thems.js +62 -0
  227. package/src/utils/token.js +26 -0
  228. package/src/utils/tools.js +317 -0
  229. package/src/utils/utils.js +513 -0
  230. package/types/favicon.ico +0 -0
  231. package/vue.config.js +49 -0
@@ -0,0 +1,581 @@
1
+ /**
2
+ * Parse the time to string
3
+ * @param {(Object|string|number)} time
4
+ * @param {string} cFormat
5
+ * @returns {string | null}
6
+ */
7
+ import { closeTagsForBackPage } from 'n20-common-lib/src/plugins/CompatibleOld'
8
+ import { linkGo } from 'n20-common-lib'
9
+ export function parseTime(time, cFormat = '{y}-{m}-{d} {h}:{i}:{s}') {
10
+ if (arguments.length === 0 || !time) {
11
+ return null
12
+ }
13
+ const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
14
+ let date
15
+ if (typeof time === 'object') {
16
+ date = time
17
+ } else {
18
+ if ((typeof time === 'string')) {
19
+ if ((/^[0-9]+$/.test(time))) {
20
+ // support "1548221490638"
21
+ time = parseInt(time)
22
+ } else {
23
+ // support safari
24
+ // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
25
+ time = time.replace(new RegExp(/-/gm), '/')
26
+ }
27
+ }
28
+
29
+ if ((typeof time === 'number') && (time.toString().length === 10)) {
30
+ time = time * 1000
31
+ }
32
+ date = new Date(time)
33
+ }
34
+ const formatObj = {
35
+ y: date.getFullYear(),
36
+ m: date.getMonth() + 1,
37
+ d: date.getDate(),
38
+ h: date.getHours(),
39
+ i: date.getMinutes(),
40
+ s: date.getSeconds(),
41
+ a: date.getDay()
42
+ }
43
+ const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
44
+ const value = formatObj[key]
45
+ // Note: getDay() returns 0 on Sunday
46
+ if (key === 'a') {
47
+ return ['日', '一', '二', '三', '四', '五', '六'][value]
48
+ }
49
+ return value.toString().padStart(2, '0')
50
+ })
51
+ return time_str
52
+ }
53
+
54
+ /**
55
+ * @param {number} time
56
+ * @param {string} option
57
+ * @returns {string}
58
+ */
59
+ export function formatTime(time, option) {
60
+ if (('' + time).length === 10) {
61
+ time = parseInt(time) * 1000
62
+ } else {
63
+ time = +time
64
+ }
65
+ const d = new Date(time)
66
+ const now = Date.now()
67
+
68
+ const diff = (now - d) / 1000
69
+
70
+ if (diff < 30) {
71
+ return '刚刚'
72
+ } else if (diff < 3600) {
73
+ // less 1 hour
74
+ return Math.ceil(diff / 60) + '分钟前'
75
+ } else if (diff < 3600 * 24) {
76
+ return Math.ceil(diff / 3600) + '小时前'
77
+ } else if (diff < 3600 * 24 * 2) {
78
+ return '1天前'
79
+ }
80
+ if (option) {
81
+ return parseTime(time, option)
82
+ } else {
83
+ return (
84
+ d.getMonth() +
85
+ 1 +
86
+ '月' +
87
+ d.getDate() +
88
+ '日' +
89
+ d.getHours() +
90
+ '时' +
91
+ d.getMinutes() +
92
+ '分'
93
+ )
94
+ }
95
+ }
96
+ /**
97
+ * 数组去重
98
+ * @param arr 数组
99
+ * @param id 更具什么去重
100
+ */
101
+ export function delistToSame(arr, id) {
102
+ let map = new Map();
103
+ for (let item of arr) {
104
+ if (item[id]) {
105
+ if (!map.has(item[id])) {
106
+ map.set(item[id], item);
107
+ }
108
+ }
109
+
110
+ }
111
+ return [...map.values()];
112
+ }
113
+ /**
114
+ * @param {string} url
115
+ * @returns {Object}
116
+ */
117
+ export function getQueryObject(url) {
118
+ url = url == null ? window.location.href : url
119
+ const search = url.substring(url.lastIndexOf('?') + 1)
120
+ const obj = {}
121
+ const reg = /([^?&=]+)=([^?&=]*)/g
122
+ search.replace(reg, (rs, $1, $2) => {
123
+ const name = decodeURIComponent($1)
124
+ let val = decodeURIComponent($2)
125
+ val = String(val)
126
+ obj[name] = val
127
+ return rs
128
+ })
129
+ return obj
130
+ }
131
+
132
+ /**
133
+ * @param {string} input value
134
+ * @returns {number} output value
135
+ */
136
+ export function byteLength(str) {
137
+ // returns the byte length of an utf8 string
138
+ let s = str.length
139
+ for (var i = str.length - 1; i >= 0; i--) {
140
+ const code = str.charCodeAt(i)
141
+ if (code > 0x7f && code <= 0x7ff) s++
142
+ else if (code > 0x7ff && code <= 0xffff) s += 2
143
+ if (code >= 0xDC00 && code <= 0xDFFF) i--
144
+ }
145
+ return s
146
+ }
147
+
148
+ /**
149
+ * @param {Array} actual
150
+ * @returns {Array}
151
+ */
152
+ export function cleanArray(actual) {
153
+ const newArray = []
154
+ for (let i = 0; i < actual.length; i++) {
155
+ if (actual[i]) {
156
+ newArray.push(actual[i])
157
+ }
158
+ }
159
+ return newArray
160
+ }
161
+
162
+ /**
163
+ * @param {Object} json
164
+ * @returns {Array}
165
+ */
166
+ export function param(json) {
167
+ if (!json) return ''
168
+ return cleanArray(
169
+ Object.keys(json).map(key => {
170
+ if (json[key] === undefined) return ''
171
+ return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
172
+ })
173
+ ).join('&')
174
+ }
175
+
176
+ /**
177
+ * @param {string} url
178
+ * @returns {Object}
179
+ */
180
+ export function param2Obj(url) {
181
+ const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
182
+ if (!search) {
183
+ return {}
184
+ }
185
+ const obj = {}
186
+ const searchArr = search.split('&')
187
+ searchArr.forEach(v => {
188
+ const index = v.indexOf('=')
189
+ if (index !== -1) {
190
+ const name = v.substring(0, index)
191
+ const val = v.substring(index + 1, v.length)
192
+ obj[name] = val
193
+ }
194
+ })
195
+ return obj
196
+ }
197
+
198
+ /**
199
+ * @param {string} val
200
+ * @returns {string}
201
+ */
202
+ export function html2Text(val) {
203
+ const div = document.createElement('div')
204
+ div.innerHTML = val
205
+ return div.textContent || div.innerText
206
+ }
207
+
208
+ /**
209
+ * Merges two objects, giving the last one precedence
210
+ * @param {Object} target
211
+ * @param {(Object|Array)} source
212
+ * @returns {Object}
213
+ */
214
+ export function objectMerge(target, source) {
215
+ if (typeof target !== 'object') {
216
+ target = {}
217
+ }
218
+ if (Array.isArray(source)) {
219
+ return source.slice()
220
+ }
221
+ Object.keys(source).forEach(property => {
222
+ const sourceProperty = source[property]
223
+ if (typeof sourceProperty === 'object') {
224
+ target[property] = objectMerge(target[property], sourceProperty)
225
+ } else {
226
+ target[property] = sourceProperty
227
+ }
228
+ })
229
+ return target
230
+ }
231
+
232
+ /**
233
+ * @param {HTMLElement} element
234
+ * @param {string} className
235
+ */
236
+ export function toggleClass(element, className) {
237
+ if (!element || !className) {
238
+ return
239
+ }
240
+ let classString = element.className
241
+ const nameIndex = classString.indexOf(className)
242
+ if (nameIndex === -1) {
243
+ classString += '' + className
244
+ } else {
245
+ classString =
246
+ classString.substr(0, nameIndex) +
247
+ classString.substr(nameIndex + className.length)
248
+ }
249
+ element.className = classString
250
+ }
251
+
252
+ /**
253
+ * @param {string} type
254
+ * @returns {Date}
255
+ */
256
+ export function getTime(type) {
257
+ if (type === 'start') {
258
+ return new Date().getTime() - 3600 * 1000 * 24 * 90
259
+ } else {
260
+ return new Date(new Date().toDateString())
261
+ }
262
+ }
263
+
264
+ /**
265
+ * @param {Function} func
266
+ * @param {number} wait
267
+ * @param {boolean} immediate
268
+ * @return {*}
269
+ */
270
+ export function debounce(func, wait, immediate) {
271
+ let timeout, args, context, timestamp, result
272
+
273
+ const later = function () {
274
+ // 据上一次触发时间间隔
275
+ const last = +new Date() - timestamp
276
+
277
+ // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
278
+ if (last < wait && last > 0) {
279
+ timeout = setTimeout(later, wait - last)
280
+ } else {
281
+ timeout = null
282
+ // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
283
+ if (!immediate) {
284
+ result = func.apply(context, args)
285
+ if (!timeout) context = args = null
286
+ }
287
+ }
288
+ }
289
+
290
+ return function (...args) {
291
+ context = this
292
+ timestamp = +new Date()
293
+ const callNow = immediate && !timeout
294
+ // 如果延时不存在,重新设定延时
295
+ if (!timeout) timeout = setTimeout(later, wait)
296
+ if (callNow) {
297
+ result = func.apply(context, args)
298
+ context = args = null
299
+ }
300
+
301
+ return result
302
+ }
303
+ }
304
+
305
+ /**
306
+ * This is just a simple version of deep copy
307
+ * Has a lot of edge cases bug
308
+ * If you want to use a perfect deep copy, use lodash's _.cloneDeep
309
+ * @param {Object} source
310
+ * @returns {Object}
311
+ */
312
+ export function deepClone(source) {
313
+ if (!source && typeof source !== 'object') {
314
+ throw new Error('error arguments', 'deepClone')
315
+ }
316
+ const targetObj = source.constructor === Array ? [] : {}
317
+ Object.keys(source).forEach(keys => {
318
+ if (source[keys] && typeof source[keys] === 'object') {
319
+ targetObj[keys] = deepClone(source[keys])
320
+ } else {
321
+ targetObj[keys] = source[keys]
322
+ }
323
+ })
324
+ return targetObj
325
+ }
326
+
327
+ /**
328
+ * @param {Array} arr
329
+ * @returns {Array}
330
+ */
331
+ export function uniqueArr(arr) {
332
+ return Array.from(new Set(arr))
333
+ }
334
+
335
+ /**
336
+ * @returns {string}
337
+ */
338
+ export function createUniqueString() {
339
+ const timestamp = +new Date() + ''
340
+ const randomNum = parseInt((1 + Math.random()) * 65536) + ''
341
+ return (+(randomNum + timestamp)).toString(32)
342
+ }
343
+
344
+ /**
345
+ * Check if an element has a class
346
+ * @param {HTMLElement} elm
347
+ * @param {string} cls
348
+ * @returns {boolean}
349
+ */
350
+ export function hasClass(ele, cls) {
351
+ return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
352
+ }
353
+
354
+ /**
355
+ * Add class to element
356
+ * @param {HTMLElement} elm
357
+ * @param {string} cls
358
+ */
359
+ export function addClass(ele, cls) {
360
+ if (!hasClass(ele, cls)) ele.className += ' ' + cls
361
+ }
362
+
363
+ /**
364
+ * Remove class from element
365
+ * @param {HTMLElement} elm
366
+ * @param {string} cls
367
+ */
368
+ export function removeClass(ele, cls) {
369
+ if (hasClass(ele, cls)) {
370
+ const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
371
+ ele.className = ele.className.replace(reg, ' ')
372
+ }
373
+ }
374
+
375
+ /***
376
+ * 自定义自定义表单数据格式化
377
+ * @param thatVue
378
+ * @param config
379
+ */
380
+ // eslint-disable-next-line no-unused-vars
381
+ export function formCustomDataFormat(thatVue, config) {
382
+
383
+ }
384
+
385
+ function checkMonthAndDay(obj) {
386
+ obj = parseInt(obj);
387
+ if (obj < 10) {
388
+ obj = "0" + obj.toString();
389
+ }
390
+ return obj;
391
+ }
392
+
393
+ /***
394
+ * 更具期限设置时间
395
+ * @param startDate
396
+ * @param termDay
397
+ * @param termDayType
398
+ */
399
+ export function dateProgressive(startDate, termDay, termDayType) {
400
+ let miStart = Date.parse(startDate.replace(/-/g, '/'))
401
+ let dateStart = new Date(miStart)
402
+ let dateTime = ''
403
+ if (termDay != null && termDay !== '') {
404
+ if (termDayType === 3) {
405
+ let year = dateStart.getFullYear() + parseInt(termDay)
406
+ let month = (dateStart.getMonth() + 1).toString()
407
+ let day = (dateStart.getDate()).toString()
408
+ if ((dateStart.getMonth() + 1) === 2) {
409
+ if (dateStart.getDate() > 28) {
410
+ if (year % 4 > 0) {
411
+ day = '28'
412
+ } else {
413
+ day = '29'
414
+ }
415
+ }
416
+ }
417
+ dateTime = year + '-' + checkMonthAndDay(month) + '-' + checkMonthAndDay(day)
418
+ } else if (termDayType === 2) {
419
+ let year = dateStart.getFullYear()
420
+ let month = dateStart.getMonth() + 1 + parseInt(termDay)
421
+ let day = (dateStart.getDate()).toString()
422
+ while (month > 12) {
423
+ year = year + 1
424
+ month = month - 12
425
+ }
426
+ if (dateStart.getDate() === 31) {
427
+ if (dateStart.getMonth() === 4 || dateStart.getMonth() === 6 || dateStart.getMonth() === 9 || dateStart.getMonth() === 11) {
428
+ day = '30'
429
+ }
430
+ }
431
+ if (month === 2) {
432
+ if (dateStart.getDate() > 28) {
433
+ if (year % 4 > 0) {
434
+ day = '28'
435
+ } else {
436
+ day = '29'
437
+ }
438
+ }
439
+ }
440
+ dateTime = year + '-' + checkMonthAndDay(month) + '-' + checkMonthAndDay(day)
441
+ } else {
442
+ let miEnd = new Date(termDay * 1000 * 24 * 3600 + miStart)
443
+ let year = miEnd.getFullYear()
444
+ let month = (miEnd.getMonth() + 1).toString()
445
+ let day = (miEnd.getDate()).toString()
446
+ dateTime = year + '-' + checkMonthAndDay(month) + '-' + checkMonthAndDay(day)
447
+ }
448
+ } else {
449
+ dateTime = ''
450
+ }
451
+ return dateTime
452
+ }
453
+
454
+ /**
455
+ * 随机字串
456
+ */
457
+ export function randomString(num) {
458
+ num = num || 32
459
+ var t = ''
460
+ t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
461
+
462
+ const a = t.length
463
+ let n = ''
464
+ for (let i = 0; i < num; i++) n += t.charAt(Math.floor(Math.random() * a))
465
+ return n
466
+ }
467
+ // export function getValue(val, prop, that) {
468
+ // if (prop.includes("Amount")) {
469
+ // return amountFormat(val[prop], 2, 1);
470
+ // } else if (prop == 'differenceRate') {
471
+ // return parseFloat(val[prop])?.toFixed(2) || '0.00'
472
+ // } else if (prop == 'settlementExchangeRate') {
473
+ // return parseFloat(val[prop])?.toFixed(4) || '0.0000'
474
+ // } else if (prop.includes("Rate") && !prop.includes("Type")) {
475
+ // return parseFloat(val[prop])?.toFixed(6) || '0.000000'
476
+ // } else if (prop == "inoutPlace") {
477
+ // return val[prop] == "IN" ? that.$l("场内") : that.$l("场外");
478
+ // } else if (prop == "inoutTerritory") {
479
+ // return val[prop] == "IN" ? that.$l("境内") : that.$l("境外");
480
+ // } else if (prop == "exchangeRateType") {
481
+ // return val[prop] == "BO" ? that.$l("买入/卖出") : that.$l("卖出/买入");
482
+ // } else if (prop == "termCount") {
483
+ // return (
484
+ // val[prop] +
485
+ // (val["termType"] == "DAY" ?
486
+ // that.$l("天") :
487
+ // val["termType"] == "MONTH" ?
488
+ // that.$l("月") :
489
+ // that.$l("年"))
490
+ // );
491
+ // }
492
+ // return val[prop] + "";
493
+ // }
494
+
495
+
496
+ /**
497
+ * 金额格式化
498
+ * @param num 金额
499
+ * @param len 保留小数位数
500
+ * @param magnitude 数量级 ( 5 代表万 )
501
+ * @returns {*}
502
+ */
503
+ export function amountFormat(num, len = 2, magnitude) {
504
+ if (typeof num === 'number') {
505
+ num = String(num)
506
+ }
507
+ // 已经格式化的数据
508
+ if (String(num).includes(',')) {
509
+ num = num.replace(/\,/g, '')
510
+ }
511
+
512
+ // 非空校验
513
+ if (isNaN(Number(num)) || [null, '', undefined].includes(num)) {
514
+ return '--'
515
+ }
516
+
517
+ const magnitudeObj = {
518
+ 1: { label: '元', value: 1E0 },
519
+ 5: { label: '万元', value: 1E4 },
520
+ 6: { label: '十万元', value: 1E5 },
521
+ 7: { label: '百万元', value: 1E6 },
522
+ 8: { label: '千万元', value: 1E7 },
523
+ 9: { label: '亿元', value: 1E8 }
524
+ }
525
+ let temp = +num
526
+
527
+ if (magnitude) {
528
+ const t = magnitudeObj[magnitude]
529
+
530
+ temp = (temp / (t.value))
531
+ }
532
+
533
+ temp = temp.toFixed(len)
534
+
535
+ // 三点一逗
536
+ function get_thousand_num(num) {
537
+ return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
538
+ return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
539
+ return $1 + ','
540
+ })
541
+ })
542
+ }
543
+
544
+ temp = get_thousand_num(temp)
545
+
546
+ return temp
547
+ }
548
+
549
+ export function flatData(arr, temp) {
550
+ arr.forEach((a) => {
551
+ if (
552
+ a &&
553
+ a.children &&
554
+ Array.isArray(a.children) &&
555
+ a.children.length > 0
556
+ ) {
557
+ flatData(a.children, temp);
558
+ }
559
+ temp.push(a);
560
+
561
+ });
562
+ }
563
+
564
+ /**
565
+ * 统一的页签返回函数
566
+ */
567
+ export function goBackCommon() {
568
+ closeTagsForBackPage()
569
+ linkGo()
570
+ }
571
+
572
+ /**
573
+ * uuid生成
574
+ * @returns {string}
575
+ */
576
+ export function uuid() {
577
+ const temp_url = URL.createObjectURL(new Blob())
578
+ const uuid = temp_url.toString()
579
+ URL.revokeObjectURL(temp_url)
580
+ return uuid.substr(uuid.lastIndexOf('/') + 1)
581
+ }