xs-common-plugins 1.2.3 → 1.2.5

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 (188) hide show
  1. package/README.md +298 -298
  2. package/common.js +110 -110
  3. package/index.js +1 -1
  4. package/package.json +16 -16
  5. package/src/App.vue +12 -12
  6. package/src/common/common.js +551 -549
  7. package/src/common/createMenuId.js +7 -7
  8. package/src/common/uploadImgToBase64.js +12 -12
  9. package/src/common/utils.js +95 -95
  10. package/src/components/Breadcrumb/index.vue +81 -81
  11. package/src/components/CheckBox_Cmp/index.vue +62 -62
  12. package/src/components/Col_TableCell/data.js +4 -4
  13. package/src/components/Col_TableCell/index.scss +77 -77
  14. package/src/components/Col_TableCell/index.vue +43 -43
  15. package/src/components/Col_TableCell/methods.js +19 -19
  16. package/src/components/FormItem/index.vue +92 -92
  17. package/src/components/Hamburger/index.vue +44 -44
  18. package/src/components/ReportCmp/data.js +3 -3
  19. package/src/components/ReportCmp/index.scss +29 -29
  20. package/src/components/ReportCmp/index.vue +76 -76
  21. package/src/components/ReportCmp/methods.js +30 -30
  22. package/src/components/Search/cascader/data.js +3 -3
  23. package/src/components/Search/cascader/index.scss +17 -17
  24. package/src/components/Search/cascader/index.vue +96 -96
  25. package/src/components/Search/cascader/methods.js +41 -41
  26. package/src/components/Search/data.js +5 -5
  27. package/src/components/Search/hk_cascader/index.vue +104 -104
  28. package/src/components/Search/hk_cascader_qudao/index.vue +94 -94
  29. package/src/components/Search/index.scss +219 -219
  30. package/src/components/Search/index.vue +410 -410
  31. package/src/components/Search/methods.js +86 -86
  32. package/src/components/Search/product_option/data.js +3 -3
  33. package/src/components/Search/product_option/index.scss +68 -68
  34. package/src/components/Search/product_option/index.vue +412 -412
  35. package/src/components/Search/product_option/methods.js +58 -58
  36. package/src/components/Search/select/data.js +3 -3
  37. package/src/components/Search/select/index.scss +2 -2
  38. package/src/components/Search/select/index.vue +114 -114
  39. package/src/components/Search/select/methods.js +51 -51
  40. package/src/components/Search_filter/data.js +5 -5
  41. package/src/components/Search_filter/index.scss +104 -104
  42. package/src/components/Search_filter/index.vue +88 -88
  43. package/src/components/Search_filter/methods.js +43 -43
  44. package/src/components/TableCmp/data.js +3 -3
  45. package/src/components/TableCmp/index.scss +22 -22
  46. package/src/components/TableCmp/index.vue +98 -98
  47. package/src/components/TableCmp/methods.js +35 -35
  48. package/src/components/TableItem/TableItem.vue +55 -55
  49. package/src/components/TextOVer/index.vue +55 -55
  50. package/src/components/UploadImg/index.vue +177 -177
  51. package/src/components/home/BarChart.vue +118 -118
  52. package/src/components/home/LineChart.vue +146 -146
  53. package/src/components/home/Panel.vue +135 -135
  54. package/src/components/home/PanelGroup.vue +146 -146
  55. package/src/components/home/PieChart.vue +81 -81
  56. package/src/components/home/RaddarChart.vue +119 -119
  57. package/src/components/home/TabLayout.vue +88 -88
  58. package/src/components/home/TableList.vue +158 -158
  59. package/src/components/home/Teng.vue +248 -248
  60. package/src/components/home/TransactionTable.vue +49 -49
  61. package/src/components/home/mixins/resize.js +55 -55
  62. package/src/components/im/index.vue +155 -155
  63. package/src/components/im/methods.js +25 -25
  64. package/src/components/im/pages/chatList/index.vue +45 -45
  65. package/src/components/im/pages/chatRoom/index.vue +159 -159
  66. package/src/components/image-singleUpload/data.js +3 -3
  67. package/src/components/image-singleUpload/index.scss +26 -26
  68. package/src/components/image-singleUpload/index.vue +56 -56
  69. package/src/components/image-singleUpload/methods.js +30 -30
  70. package/src/components/image-upload/data.js +7 -7
  71. package/src/components/image-upload/index.vue +41 -41
  72. package/src/components/image-upload/methods.js +80 -80
  73. package/src/components/multiple-image-upload/data.js +11 -11
  74. package/src/components/multiple-image-upload/index.scss +8 -8
  75. package/src/components/multiple-image-upload/index.vue +63 -63
  76. package/src/components/multiple-image-upload/methods.js +45 -45
  77. package/src/components/pro-upload/data.js +3 -3
  78. package/src/components/pro-upload/index.scss +4 -4
  79. package/src/components/pro-upload/index.vue +89 -89
  80. package/src/components/pro-upload/methods.js +86 -86
  81. package/src/components/report_set/index.scss +44 -44
  82. package/src/components/report_set/index.vue +153 -153
  83. package/src/components/search-page/src/index.scss +5 -5
  84. package/src/components/search-page/src/index.vue +76 -76
  85. package/src/components/search-page/src/methods.js +36 -36
  86. package/src/components/xsSelect/index.vue +125 -125
  87. package/src/mixin/dialog.js +31 -31
  88. package/src/mixin/dlg.js +46 -46
  89. package/src/mixin/keepAlive.js +53 -52
  90. package/src/mixin/newDialog.js +19 -19
  91. package/src/mixin/report.js +82 -82
  92. package/src/mixin/table.js +93 -93
  93. package/src/mixin/tableCell/colTableCell_analysis.js +103 -103
  94. package/src/mixin/upload.js +22 -22
  95. package/src/mixin/vmodel.js +26 -26
  96. package/src/plugins/im/components/chat/index.scss +163 -163
  97. package/src/plugins/im/components/chat/index.vue +144 -144
  98. package/src/plugins/im/components/chat/methods.js +149 -149
  99. package/src/plugins/im/components/conversation-list/index.css +91 -91
  100. package/src/plugins/im/components/conversation-list/index.json +3 -3
  101. package/src/plugins/im/components/conversation-list/index.vue +89 -89
  102. package/src/plugins/im/components/loading/loading.css +69 -69
  103. package/src/plugins/im/components/loading/loading.json +3 -3
  104. package/src/plugins/im/components/loading/loading.vue +14 -14
  105. package/src/plugins/im/components/msg-image/index.json +3 -3
  106. package/src/plugins/im/components/msg-image/index.vue +40 -40
  107. package/src/plugins/im/components/msg-text/index.json +3 -3
  108. package/src/plugins/im/components/msg-text/index.vue +24 -24
  109. package/src/plugins/im/components/send-msg/index.scss +164 -164
  110. package/src/plugins/im/components/send-msg/index.vue +107 -107
  111. package/src/plugins/im/components/send-msg/methods.js +125 -125
  112. package/src/plugins/im/components/template-message/index.vue +76 -76
  113. package/src/plugins/im/components/without.vue +19 -19
  114. package/src/plugins/im/im-plug-in/Protobuf-2.3.7.min.js +1 -1
  115. package/src/plugins/im/im-plug-in/RongCallLib-3.1.5.min.js +74 -74
  116. package/src/plugins/im/im-plug-in/RongIMLib-4.1.0.js +17420 -17420
  117. package/src/plugins/im/im-plug-in/init.js +216 -216
  118. package/src/plugins/im/im-plug-in/qiniu.js +266 -266
  119. package/src/plugins/im/im-plug-in/send-data.js +431 -431
  120. package/src/plugins/im/im-plug-in/upload.js +232 -232
  121. package/src/plugins/im/index.js +31 -31
  122. package/src/plugins/im/lib/RongIMEmoji-2.2.6.js +332 -332
  123. package/src/plugins/im/lib/RongIMLib-3.0.7.2-dev.js +11635 -11635
  124. package/src/plugins/im/lib/RongIMLib-3.0.7.2-dev.min.js +6 -6
  125. package/src/plugins/im/utils/services.js +625 -625
  126. package/src/plugins/im/utils/underscore-1.8.3.js +1531 -1531
  127. package/src/plugins/im/utils/utils.js +149 -149
  128. package/src/plugins/index.js +60 -60
  129. package/src/plugins/row-col-cmp/colCmp/data.js +3 -3
  130. package/src/plugins/row-col-cmp/colCmp/index.scss +50 -50
  131. package/src/plugins/row-col-cmp/colCmp/index.vue +53 -53
  132. package/src/plugins/row-col-cmp/colCmp/methods.js +25 -25
  133. package/src/plugins/row-col-cmp/index.js +20 -20
  134. package/src/plugins/row-col-cmp/rowCmp/data.js +3 -3
  135. package/src/plugins/row-col-cmp/rowCmp/index.scss +3 -3
  136. package/src/plugins/row-col-cmp/rowCmp/index.vue +43 -43
  137. package/src/plugins/row-col-cmp/rowCmp/methods.js +29 -29
  138. package/src/router/index.js +58 -58
  139. package/src/router/permission.js +126 -126
  140. package/src/store/getters.js +13 -13
  141. package/src/store/index.js +60 -60
  142. package/src/store/modules/app.js +55 -55
  143. package/src/store/modules/dic.js +74 -74
  144. package/src/store/modules/oss.js +40 -40
  145. package/src/store/modules/settings.js +28 -28
  146. package/src/store/modules/tagsView.js +160 -160
  147. package/src/store/modules/user.js +94 -94
  148. package/src/store/modules/widgetdata.js +42 -42
  149. package/src/styles/element-ui.scss +49 -49
  150. package/src/styles/index.scss +91 -91
  151. package/src/styles/mixin.scss +28 -28
  152. package/src/styles/sidebar.scss +210 -210
  153. package/src/styles/table.scss +90 -90
  154. package/src/styles/transition.scss +48 -48
  155. package/src/styles/variables.scss +25 -25
  156. package/src/utils/api.js +54 -54
  157. package/src/utils/auth.js +38 -38
  158. package/src/utils/concat_batch_btns.js +88 -88
  159. package/src/utils/enum.js +150 -150
  160. package/src/utils/filter.js +5 -5
  161. package/src/utils/filterRules.js +55 -55
  162. package/src/utils/get-page-title.js +10 -10
  163. package/src/utils/getMenu.js +82 -82
  164. package/src/utils/global-config.js +15 -15
  165. package/src/utils/global_directive.js +10 -10
  166. package/src/utils/index.js +332 -332
  167. package/src/utils/localStorage.js +21 -21
  168. package/src/utils/ossService.js +55 -55
  169. package/src/utils/prototype.js +46 -46
  170. package/src/utils/search.js +33 -33
  171. package/src/utils/signalR.js +24 -24
  172. package/src/utils/validate.js +20 -20
  173. package/src/views/callback/index.vue +35 -35
  174. package/src/views/home/index.vue +25 -25
  175. package/src/views/layout/components/AllSearch/index.vue +44 -44
  176. package/src/views/layout/components/AppMain.vue +66 -66
  177. package/src/views/layout/components/Sidebar/FixiOSBug.js +26 -26
  178. package/src/views/layout/components/Sidebar/Item.vue +28 -28
  179. package/src/views/layout/components/Sidebar/Link.vue +34 -34
  180. package/src/views/layout/components/Sidebar/Logo.vue +79 -79
  181. package/src/views/layout/components/Sidebar/SidebarItem.vue +67 -67
  182. package/src/views/layout/components/Sidebar/index.vue +114 -114
  183. package/src/views/layout/components/TagsView/ScrollPane.vue +94 -94
  184. package/src/views/layout/components/TagsView/index.vue +330 -330
  185. package/src/views/layout/components/index.js +3 -3
  186. package/src/views/layout/index.vue +107 -107
  187. package/src/views/redirect/index.vue +12 -12
  188. package/src/views/slienceAuth/index.vue +42 -42
@@ -1,332 +1,332 @@
1
- import Store from '@/store'
2
- import {requestApi as http } from 'xs-request'
3
- import { isArray } from '@/common/utils'
4
- import moment from 'moment'
5
- import Vue from 'vue'
6
- import { checkedBoxRe } from '@/common/utils'
7
- import {Message} from 'element-ui'
8
- /**
9
- * Parse the time to string
10
- * @param {(Object|string|number)} time
11
- * @param {string} cFormat
12
- * @returns {string | null}
13
- */
14
- export function parseTime(time, cFormat) {
15
- if (arguments.length === 0) {
16
- return null
17
- }
18
- const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
19
- let date
20
- if (typeof time === 'object') {
21
- date = time
22
- } else {
23
- if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
24
- time = parseInt(time)
25
- }
26
- if ((typeof time === 'number') && (time.toString().length === 10)) {
27
- time = time * 1000
28
- }
29
- date = new Date(time)
30
- }
31
- const formatObj = {
32
- y: date.getFullYear(),
33
- m: date.getMonth() + 1,
34
- d: date.getDate(),
35
- h: date.getHours(),
36
- i: date.getMinutes(),
37
- s: date.getSeconds(),
38
- a: date.getDay()
39
- }
40
- const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
41
- const value = formatObj[key]
42
- // Note: getDay() returns 0 on Sunday
43
- if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
44
- return value.toString().padStart(2, '0')
45
- })
46
- return time_str
47
- }
48
-
49
- /**
50
- * @param {number} time
51
- * @param {string} option
52
- * @returns {string}
53
- */
54
- export function formatTime(time, option) {
55
- if (('' + time).length === 10) {
56
- time = parseInt(time) * 1000
57
- } else {
58
- time = +time
59
- }
60
- const d = new Date(time)
61
- const now = Date.now()
62
-
63
- const diff = (now - d) / 1000
64
-
65
- if (diff < 30) {
66
- return '刚刚'
67
- } else if (diff < 3600) {
68
- // less 1 hour
69
- return Math.ceil(diff / 60) + '分钟前'
70
- } else if (diff < 3600 * 24) {
71
- return Math.ceil(diff / 3600) + '小时前'
72
- } else if (diff < 3600 * 24 * 2) {
73
- return '1天前'
74
- }
75
- if (option) {
76
- return parseTime(time, option)
77
- } else {
78
- return (
79
- d.getMonth() +
80
- 1 +
81
- '月' +
82
- d.getDate() +
83
- '日' +
84
- d.getHours() +
85
- '时' +
86
- d.getMinutes() +
87
- '分'
88
- )
89
- }
90
- }
91
-
92
- /**
93
- * @param {string} url
94
- * @returns {Object}
95
- */
96
- export function param2Obj(url) {
97
- const search = url.split('?')[1]
98
- if (!search) {
99
- return {}
100
- }
101
- return JSON.parse(
102
- '{"' +
103
- decodeURIComponent(search)
104
- .replace(/"/g, '\\"')
105
- .replace(/&/g, '","')
106
- .replace(/=/g, '":"')
107
- .replace(/\+/g, ' ') +
108
- '"}'
109
- )
110
- }
111
- /**
112
- * @param {Function} func
113
- * @param {number} wait
114
- * @param {boolean} immediate
115
- * @return {*}
116
- */
117
- export function debounce(func, wait, immediate) {
118
- let timeout, args, context, timestamp, result
119
-
120
- const later = function () {
121
- // 据上一次触发时间间隔
122
- const last = +new Date() - timestamp
123
-
124
- // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
125
- if (last < wait && last > 0) {
126
- timeout = setTimeout(later, wait - last)
127
- } else {
128
- timeout = null
129
- // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
130
- if (!immediate) {
131
- result = func.apply(context, args)
132
- if (!timeout) context = args = null
133
- }
134
- }
135
- }
136
-
137
- return function (...args) {
138
- context = this
139
- timestamp = +new Date()
140
- const callNow = immediate && !timeout
141
- // 如果延时不存在,重新设定延时
142
- if (!timeout) timeout = setTimeout(later, wait)
143
- if (callNow) {
144
- result = func.apply(context, args)
145
- context = args = null
146
- }
147
- return result
148
- }
149
- }
150
-
151
- export function loadTableData (url, black) {
152
- Store.commit('setLoading', true)
153
- const that = this
154
- const search_query = {}
155
- if (!black) black = []
156
- let datapicName = ''
157
-
158
- for (var elKey in this.query) {
159
- if (elKey === 'data') continue // 判断返回数据
160
- if (black.findIndex((x) => x == elKey) != -1) continue
161
-
162
- if (elKey.startsWith('datepic')) {
163
- datapicName = elKey.replace('datepic', '')
164
-
165
- const dateIsNull = this.query[elKey] && this.query[elKey].length > 0
166
- if (datapicName) {
167
- search_query[datapicName + 'GreaterEqual'] = dateIsNull ? this.query[elKey][0] : null
168
- search_query[datapicName + 'LessEqual'] = dateIsNull ? this.query[elKey][1] : null
169
- search_query[datapicName + 'Greater'] = dateIsNull ? this.query[elKey][0] : null
170
- search_query[datapicName + 'Less'] = dateIsNull ? this.query[elKey][1] : null
171
- } else {
172
- search_query[datapicName + 'startTime'] = dateIsNull ? this.query[elKey][0] : null
173
- search_query[datapicName + 'endTime'] = dateIsNull ? this.query[elKey][1] : null
174
- }
175
- continue
176
- }
177
- search_query[elKey] = this.query[elKey]
178
- }
179
-
180
- return new Promise((resolve, reject) => {
181
- http.post(url, search_query).then(res => {
182
- Store.commit('setLoading', false)
183
- let result = res.data
184
- // 兼容非分页
185
- if (isArray(res.data) && !res.data.hasOwnProperty('data')) {
186
- result = {
187
- data: res.data
188
- }
189
- }
190
- let datapicName = ''
191
- const keyArray = ['GreaterEqual', 'Less', 'Greater', 'LessEqual', 'startTime', 'endTime']
192
- for (const key in result) {
193
- keyArray.forEach((el, elIndex) => {
194
- if (key.endsWith(el)) {
195
- datapicName = key.replace(el, '')
196
- datapicName = datapicName.charAt(0).toUpperCase() + datapicName.slice(1)
197
- if (!result['datepic' + datapicName]) {
198
- result['datepic' + datapicName] = ['', '']
199
- }
200
- result['datepic' + datapicName][elIndex % 2] = result[key]
201
- delete result[key]
202
- }
203
- })
204
- }
205
- that.query = result
206
- resolve()
207
- }, err => {
208
- reject()
209
- })
210
- })
211
- }
212
-
213
- export function loadReportData (url, black) {
214
- Store.commit('setLoading', true)
215
- const that = this
216
- const search_query = {}
217
- if (!black) black = []
218
- let datapicName = ''
219
-
220
- for (var elKey in this.query) {
221
- if (elKey === 'data') continue // 判断返回数据
222
- if (black.findIndex((x) => x == elKey) != -1) continue
223
-
224
- if (elKey.startsWith('datepic')) {
225
- datapicName = elKey.replace('datepic', '')
226
-
227
- const dateIsNull = this.query[elKey].length > 0
228
-
229
- if (datapicName) {
230
- search_query[datapicName + 'GreaterEqual'] = dateIsNull ? this.query[elKey][0] : ''
231
- search_query[datapicName + 'LessEqual'] = dateIsNull ? this.query[elKey][1] : ''
232
- search_query[datapicName + 'Greater'] = dateIsNull ? this.query[elKey][0] : ''
233
- search_query[datapicName + 'Less'] = dateIsNull ? this.query[elKey][1] : ''
234
- } else {
235
- search_query[datapicName + 'startTime'] = dateIsNull ? this.query[elKey][0] : ''
236
- search_query[datapicName + 'endTime'] = dateIsNull ? this.query[elKey][1] : ''
237
- }
238
- continue
239
- }
240
- search_query[elKey] = this.query[elKey]
241
- }
242
-
243
- return new Promise((resolve) => {
244
- http.post(url, search_query).then(res => {
245
- Store.commit('setLoading', false)
246
- if (!res) return;
247
- const result = res.data
248
-
249
- let datapicName = ''
250
- const keyArray = ['GreaterEqual', 'Less', 'Greater', 'LessEqual', 'startTime', 'endTime']
251
- for (const key in result) {
252
- keyArray.forEach((el, elIndex) => {
253
- if (key.endsWith(el)) {
254
- datapicName = key.replace(el, '')
255
- datapicName = datapicName.charAt(0).toUpperCase() + datapicName.slice(1)
256
- if (!result['datepic' + datapicName]) {
257
- result['datepic' + datapicName] = ['', '']
258
- }
259
- result['datepic' + datapicName][elIndex % 2] = result[key]
260
- delete result[key]
261
- }
262
- })
263
- }
264
- that.query = result
265
- resolve()
266
- })
267
- })
268
- }
269
-
270
- export function msg (res) {
271
- Message({
272
- message: res.message,
273
- type: res.code === 0 ? 'success' : 'warning'
274
- });
275
- }
276
-
277
- export function countDownSetColor (startTime, endTime) {
278
- if (endTime === '1970-01-01T00:00:00') endTime = moment()
279
- const doneTime = moment(endTime, 'YYYY-MM-DD HH:mm:ss')
280
- const beginTime = moment(startTime, 'YYYY-MM-DD HH:mm:ss')
281
- const time = moment.duration(doneTime.diff(beginTime))
282
- const res = time.asHours()
283
- return res
284
- }
285
-
286
- export function dateFormat (dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
287
- const defaultDate = ['0001-01-01T00:00:00', '1970-01-01T00:00:00']
288
- if (defaultDate.indexOf(dataStr) > -1) return '/'
289
- return moment(dataStr).format(pattern)
290
- }
291
-
292
- export function diff (start, done){
293
- const defaultDate = ['0001-01-01T00:00:00', '1970-01-01T00:00:00']
294
- if (defaultDate.indexOf(done) > -1) done = moment()
295
- const doneTime = moment(done, 'YYYY-MM-DD HH:mm:ss')
296
- const beginTime = moment(start, 'YYYY-MM-DD HH:mm:ss')
297
- const time = moment.duration(doneTime.diff(beginTime))
298
-
299
- const res = time.format('d天h时m分s秒')
300
-
301
- if (time.days() > 0) {
302
- return time.format('d天h时')
303
- } else if (time.hours() > 0) {
304
- return time.format('h时m分')
305
- } else if (time.minutes()) {
306
- return time.format('m分s秒')
307
- }
308
- return res && res.startsWith('-') ? '' : res
309
- }
310
-
311
- export function checkedBoxRes (val, enumName, Vues = Vue) {
312
- return checkedBoxRe(val, enumName, Vue)
313
- }
314
-
315
-
316
- export function showDlg(Component, props) {
317
- const vm = new Vue(
318
- Object.assign({}, vucfg, {
319
- render: (h) =>
320
- h(Component, {
321
- props
322
- })
323
- })).$mount()
324
- document.body.appendChild(vm.$el)
325
- const ele = vm.$children[0]
326
- ele.destroy = function() {
327
- vm.$el.remove()
328
- ele.$destroy()
329
- vm.$destroy()
330
- }
331
- return ele
332
- }
1
+ import Store from '@/store'
2
+ import {requestApi as http } from 'xs-request'
3
+ import { isArray } from '@/common/utils'
4
+ import moment from 'moment'
5
+ import Vue from 'vue'
6
+ import { checkedBoxRe } from '@/common/utils'
7
+ import {Message} from 'element-ui'
8
+ /**
9
+ * Parse the time to string
10
+ * @param {(Object|string|number)} time
11
+ * @param {string} cFormat
12
+ * @returns {string | null}
13
+ */
14
+ export function parseTime(time, cFormat) {
15
+ if (arguments.length === 0) {
16
+ return null
17
+ }
18
+ const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
19
+ let date
20
+ if (typeof time === 'object') {
21
+ date = time
22
+ } else {
23
+ if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
24
+ time = parseInt(time)
25
+ }
26
+ if ((typeof time === 'number') && (time.toString().length === 10)) {
27
+ time = time * 1000
28
+ }
29
+ date = new Date(time)
30
+ }
31
+ const formatObj = {
32
+ y: date.getFullYear(),
33
+ m: date.getMonth() + 1,
34
+ d: date.getDate(),
35
+ h: date.getHours(),
36
+ i: date.getMinutes(),
37
+ s: date.getSeconds(),
38
+ a: date.getDay()
39
+ }
40
+ const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
41
+ const value = formatObj[key]
42
+ // Note: getDay() returns 0 on Sunday
43
+ if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
44
+ return value.toString().padStart(2, '0')
45
+ })
46
+ return time_str
47
+ }
48
+
49
+ /**
50
+ * @param {number} time
51
+ * @param {string} option
52
+ * @returns {string}
53
+ */
54
+ export function formatTime(time, option) {
55
+ if (('' + time).length === 10) {
56
+ time = parseInt(time) * 1000
57
+ } else {
58
+ time = +time
59
+ }
60
+ const d = new Date(time)
61
+ const now = Date.now()
62
+
63
+ const diff = (now - d) / 1000
64
+
65
+ if (diff < 30) {
66
+ return '刚刚'
67
+ } else if (diff < 3600) {
68
+ // less 1 hour
69
+ return Math.ceil(diff / 60) + '分钟前'
70
+ } else if (diff < 3600 * 24) {
71
+ return Math.ceil(diff / 3600) + '小时前'
72
+ } else if (diff < 3600 * 24 * 2) {
73
+ return '1天前'
74
+ }
75
+ if (option) {
76
+ return parseTime(time, option)
77
+ } else {
78
+ return (
79
+ d.getMonth() +
80
+ 1 +
81
+ '月' +
82
+ d.getDate() +
83
+ '日' +
84
+ d.getHours() +
85
+ '时' +
86
+ d.getMinutes() +
87
+ '分'
88
+ )
89
+ }
90
+ }
91
+
92
+ /**
93
+ * @param {string} url
94
+ * @returns {Object}
95
+ */
96
+ export function param2Obj(url) {
97
+ const search = url.split('?')[1]
98
+ if (!search) {
99
+ return {}
100
+ }
101
+ return JSON.parse(
102
+ '{"' +
103
+ decodeURIComponent(search)
104
+ .replace(/"/g, '\\"')
105
+ .replace(/&/g, '","')
106
+ .replace(/=/g, '":"')
107
+ .replace(/\+/g, ' ') +
108
+ '"}'
109
+ )
110
+ }
111
+ /**
112
+ * @param {Function} func
113
+ * @param {number} wait
114
+ * @param {boolean} immediate
115
+ * @return {*}
116
+ */
117
+ export function debounce(func, wait, immediate) {
118
+ let timeout, args, context, timestamp, result
119
+
120
+ const later = function () {
121
+ // 据上一次触发时间间隔
122
+ const last = +new Date() - timestamp
123
+
124
+ // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
125
+ if (last < wait && last > 0) {
126
+ timeout = setTimeout(later, wait - last)
127
+ } else {
128
+ timeout = null
129
+ // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
130
+ if (!immediate) {
131
+ result = func.apply(context, args)
132
+ if (!timeout) context = args = null
133
+ }
134
+ }
135
+ }
136
+
137
+ return function (...args) {
138
+ context = this
139
+ timestamp = +new Date()
140
+ const callNow = immediate && !timeout
141
+ // 如果延时不存在,重新设定延时
142
+ if (!timeout) timeout = setTimeout(later, wait)
143
+ if (callNow) {
144
+ result = func.apply(context, args)
145
+ context = args = null
146
+ }
147
+ return result
148
+ }
149
+ }
150
+
151
+ export function loadTableData (url, black) {
152
+ Store.commit('setLoading', true)
153
+ const that = this
154
+ const search_query = {}
155
+ if (!black) black = []
156
+ let datapicName = ''
157
+
158
+ for (var elKey in this.query) {
159
+ if (elKey === 'data') continue // 判断返回数据
160
+ if (black.findIndex((x) => x == elKey) != -1) continue
161
+
162
+ if (elKey.startsWith('datepic')) {
163
+ datapicName = elKey.replace('datepic', '')
164
+
165
+ const dateIsNull = this.query[elKey] && this.query[elKey].length > 0
166
+ if (datapicName) {
167
+ search_query[datapicName + 'GreaterEqual'] = dateIsNull ? this.query[elKey][0] : null
168
+ search_query[datapicName + 'LessEqual'] = dateIsNull ? this.query[elKey][1] : null
169
+ search_query[datapicName + 'Greater'] = dateIsNull ? this.query[elKey][0] : null
170
+ search_query[datapicName + 'Less'] = dateIsNull ? this.query[elKey][1] : null
171
+ } else {
172
+ search_query[datapicName + 'startTime'] = dateIsNull ? this.query[elKey][0] : null
173
+ search_query[datapicName + 'endTime'] = dateIsNull ? this.query[elKey][1] : null
174
+ }
175
+ continue
176
+ }
177
+ search_query[elKey] = this.query[elKey]
178
+ }
179
+
180
+ return new Promise((resolve, reject) => {
181
+ http.post(url, search_query).then(res => {
182
+ Store.commit('setLoading', false)
183
+ let result = res.data
184
+ // 兼容非分页
185
+ if (isArray(res.data) && !res.data.hasOwnProperty('data')) {
186
+ result = {
187
+ data: res.data
188
+ }
189
+ }
190
+ let datapicName = ''
191
+ const keyArray = ['GreaterEqual', 'Less', 'Greater', 'LessEqual', 'startTime', 'endTime']
192
+ for (const key in result) {
193
+ keyArray.forEach((el, elIndex) => {
194
+ if (key.endsWith(el)) {
195
+ datapicName = key.replace(el, '')
196
+ datapicName = datapicName.charAt(0).toUpperCase() + datapicName.slice(1)
197
+ if (!result['datepic' + datapicName]) {
198
+ result['datepic' + datapicName] = ['', '']
199
+ }
200
+ result['datepic' + datapicName][elIndex % 2] = result[key]
201
+ delete result[key]
202
+ }
203
+ })
204
+ }
205
+ that.query = result
206
+ resolve()
207
+ }, err => {
208
+ reject()
209
+ })
210
+ })
211
+ }
212
+
213
+ export function loadReportData (url, black) {
214
+ Store.commit('setLoading', true)
215
+ const that = this
216
+ const search_query = {}
217
+ if (!black) black = []
218
+ let datapicName = ''
219
+
220
+ for (var elKey in this.query) {
221
+ if (elKey === 'data') continue // 判断返回数据
222
+ if (black.findIndex((x) => x == elKey) != -1) continue
223
+
224
+ if (elKey.startsWith('datepic')) {
225
+ datapicName = elKey.replace('datepic', '')
226
+
227
+ const dateIsNull = this.query[elKey].length > 0
228
+
229
+ if (datapicName) {
230
+ search_query[datapicName + 'GreaterEqual'] = dateIsNull ? this.query[elKey][0] : ''
231
+ search_query[datapicName + 'LessEqual'] = dateIsNull ? this.query[elKey][1] : ''
232
+ search_query[datapicName + 'Greater'] = dateIsNull ? this.query[elKey][0] : ''
233
+ search_query[datapicName + 'Less'] = dateIsNull ? this.query[elKey][1] : ''
234
+ } else {
235
+ search_query[datapicName + 'startTime'] = dateIsNull ? this.query[elKey][0] : ''
236
+ search_query[datapicName + 'endTime'] = dateIsNull ? this.query[elKey][1] : ''
237
+ }
238
+ continue
239
+ }
240
+ search_query[elKey] = this.query[elKey]
241
+ }
242
+
243
+ return new Promise((resolve) => {
244
+ http.post(url, search_query).then(res => {
245
+ Store.commit('setLoading', false)
246
+ if (!res) return;
247
+ const result = res.data
248
+
249
+ let datapicName = ''
250
+ const keyArray = ['GreaterEqual', 'Less', 'Greater', 'LessEqual', 'startTime', 'endTime']
251
+ for (const key in result) {
252
+ keyArray.forEach((el, elIndex) => {
253
+ if (key.endsWith(el)) {
254
+ datapicName = key.replace(el, '')
255
+ datapicName = datapicName.charAt(0).toUpperCase() + datapicName.slice(1)
256
+ if (!result['datepic' + datapicName]) {
257
+ result['datepic' + datapicName] = ['', '']
258
+ }
259
+ result['datepic' + datapicName][elIndex % 2] = result[key]
260
+ delete result[key]
261
+ }
262
+ })
263
+ }
264
+ that.query = result
265
+ resolve()
266
+ })
267
+ })
268
+ }
269
+
270
+ export function msg (res) {
271
+ Message({
272
+ message: res.message,
273
+ type: res.code === 0 ? 'success' : 'warning'
274
+ });
275
+ }
276
+
277
+ export function countDownSetColor (startTime, endTime) {
278
+ if (endTime === '1970-01-01T00:00:00') endTime = moment()
279
+ const doneTime = moment(endTime, 'YYYY-MM-DD HH:mm:ss')
280
+ const beginTime = moment(startTime, 'YYYY-MM-DD HH:mm:ss')
281
+ const time = moment.duration(doneTime.diff(beginTime))
282
+ const res = time.asHours()
283
+ return res
284
+ }
285
+
286
+ export function dateFormat (dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
287
+ const defaultDate = ['0001-01-01T00:00:00', '1970-01-01T00:00:00']
288
+ if (defaultDate.indexOf(dataStr) > -1) return '/'
289
+ return moment(dataStr).format(pattern)
290
+ }
291
+
292
+ export function diff (start, done){
293
+ const defaultDate = ['0001-01-01T00:00:00', '1970-01-01T00:00:00']
294
+ if (defaultDate.indexOf(done) > -1) done = moment()
295
+ const doneTime = moment(done, 'YYYY-MM-DD HH:mm:ss')
296
+ const beginTime = moment(start, 'YYYY-MM-DD HH:mm:ss')
297
+ const time = moment.duration(doneTime.diff(beginTime))
298
+
299
+ const res = time.format('d天h时m分s秒')
300
+
301
+ if (time.days() > 0) {
302
+ return time.format('d天h时')
303
+ } else if (time.hours() > 0) {
304
+ return time.format('h时m分')
305
+ } else if (time.minutes()) {
306
+ return time.format('m分s秒')
307
+ }
308
+ return res && res.startsWith('-') ? '' : res
309
+ }
310
+
311
+ export function checkedBoxRes (val, enumName, Vues = Vue) {
312
+ return checkedBoxRe(val, enumName, Vue)
313
+ }
314
+
315
+
316
+ export function showDlg(Component, props) {
317
+ const vm = new Vue(
318
+ Object.assign({}, vucfg, {
319
+ render: (h) =>
320
+ h(Component, {
321
+ props
322
+ })
323
+ })).$mount()
324
+ document.body.appendChild(vm.$el)
325
+ const ele = vm.$children[0]
326
+ ele.destroy = function() {
327
+ vm.$el.remove()
328
+ ele.$destroy()
329
+ vm.$destroy()
330
+ }
331
+ return ele
332
+ }