xs-common-plugins 1.1.2 → 1.1.6

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 (139) hide show
  1. package/README.md +37 -0
  2. package/package.json +1 -1
  3. package/src/App.vue +11 -11
  4. package/src/common/common.js +143 -14
  5. package/src/common/createMenuId.js +7 -7
  6. package/src/common/uploadImgToBase64.js +12 -12
  7. package/src/common/utils.js +95 -95
  8. package/src/components/Breadcrumb/index.vue +81 -81
  9. package/src/components/Col_TableCell/data.js +4 -4
  10. package/src/components/Col_TableCell/index.scss +77 -77
  11. package/src/components/Col_TableCell/index.vue +43 -43
  12. package/src/components/Col_TableCell/methods.js +19 -19
  13. package/src/components/Hamburger/index.vue +44 -44
  14. package/src/components/ReportCmp/data.js +3 -3
  15. package/src/components/ReportCmp/index.scss +29 -29
  16. package/src/components/ReportCmp/index.vue +2 -2
  17. package/src/components/ReportCmp/methods.js +30 -30
  18. package/src/components/Search/cascader/data.js +3 -3
  19. package/src/components/Search/cascader/index.scss +17 -17
  20. package/src/components/Search/cascader/index.vue +96 -96
  21. package/src/components/Search/cascader/methods.js +41 -41
  22. package/src/components/Search/data.js +5 -5
  23. package/src/components/Search/hk_cascader/index.vue +104 -104
  24. package/src/components/Search/hk_cascader_qudao/index.vue +94 -94
  25. package/src/components/Search/methods.js +86 -86
  26. package/src/components/Search/product_option/data.js +3 -3
  27. package/src/components/Search/product_option/index.scss +68 -68
  28. package/src/components/Search/product_option/index.vue +419 -419
  29. package/src/components/Search/product_option/methods.js +46 -46
  30. package/src/components/Search/select/data.js +3 -3
  31. package/src/components/Search/select/index.scss +2 -2
  32. package/src/components/Search/select/index.vue +114 -114
  33. package/src/components/Search/select/methods.js +51 -51
  34. package/src/components/Search_filter/data.js +5 -5
  35. package/src/components/Search_filter/index.vue +88 -88
  36. package/src/components/Search_filter/methods.js +43 -43
  37. package/src/components/TableCmp/data.js +3 -3
  38. package/src/components/TableCmp/index.scss +22 -22
  39. package/src/components/TableCmp/index.vue +98 -98
  40. package/src/components/TableCmp/methods.js +35 -35
  41. package/src/components/home/BarChart.vue +118 -118
  42. package/src/components/home/LineChart.vue +146 -146
  43. package/src/components/home/Panel.vue +135 -135
  44. package/src/components/home/PanelGroup.vue +146 -146
  45. package/src/components/home/PieChart.vue +81 -81
  46. package/src/components/home/RaddarChart.vue +119 -119
  47. package/src/components/home/TabLayout.vue +88 -88
  48. package/src/components/home/TableList.vue +158 -158
  49. package/src/components/home/Teng.vue +248 -248
  50. package/src/components/home/TransactionTable.vue +49 -49
  51. package/src/components/home/mixins/resize.js +55 -55
  52. package/src/components/im/methods.js +25 -25
  53. package/src/components/image-singleUpload/data.js +3 -3
  54. package/src/components/image-singleUpload/index.scss +26 -26
  55. package/src/components/image-singleUpload/index.vue +56 -56
  56. package/src/components/image-singleUpload/methods.js +30 -30
  57. package/src/components/image-upload/data.js +7 -7
  58. package/src/components/image-upload/index.vue +41 -41
  59. package/src/components/image-upload/methods.js +80 -80
  60. package/src/components/multiple-image-upload/data.js +11 -11
  61. package/src/components/multiple-image-upload/index.scss +8 -8
  62. package/src/components/multiple-image-upload/index.vue +63 -63
  63. package/src/components/multiple-image-upload/methods.js +45 -45
  64. package/src/components/pro-upload/data.js +3 -3
  65. package/src/components/pro-upload/index.scss +4 -4
  66. package/src/components/pro-upload/index.vue +89 -89
  67. package/src/components/pro-upload/methods.js +86 -86
  68. package/src/components/report_set/index.scss +44 -44
  69. package/src/components/report_set/index.vue +153 -153
  70. package/src/components/search-page/src/index.scss +5 -5
  71. package/src/components/search-page/src/index.vue +76 -76
  72. package/src/components/search-page/src/methods.js +36 -36
  73. package/src/mixin/dialog.js +31 -31
  74. package/src/mixin/dlg.js +46 -46
  75. package/src/mixin/newDialog.js +19 -19
  76. package/src/mixin/report.js +82 -82
  77. package/src/mixin/table.js +93 -93
  78. package/src/mixin/tableCell/colTableCell_analysis.js +103 -103
  79. package/src/mixin/upload.js +22 -22
  80. package/src/mixin/vmodel.js +26 -26
  81. package/src/plugins/im/components/conversation-list/index.css +91 -91
  82. package/src/plugins/im/components/conversation-list/index.json +3 -3
  83. package/src/plugins/im/components/conversation-list/index.vue +89 -89
  84. package/src/plugins/im/components/loading/loading.css +69 -69
  85. package/src/plugins/im/components/loading/loading.json +3 -3
  86. package/src/plugins/im/components/loading/loading.vue +14 -14
  87. package/src/plugins/im/components/msg-image/index.json +3 -3
  88. package/src/plugins/im/components/msg-text/index.json +3 -3
  89. package/src/plugins/im/components/msg-text/index.vue +24 -24
  90. package/src/plugins/im/im-plug-in/Protobuf-2.3.7.min.js +1 -1
  91. package/src/plugins/im/im-plug-in/RongCallLib-3.1.5.min.js +74 -74
  92. package/src/plugins/im/im-plug-in/RongIMLib-4.1.0.js +17420 -17420
  93. package/src/plugins/im/im-plug-in/init.js +216 -216
  94. package/src/plugins/im/im-plug-in/qiniu.js +266 -266
  95. package/src/plugins/im/im-plug-in/send-data.js +431 -431
  96. package/src/plugins/im/im-plug-in/upload.js +232 -232
  97. package/src/plugins/im/lib/RongIMEmoji-2.2.6.js +332 -332
  98. package/src/plugins/im/lib/RongIMLib-3.0.7.2-dev.js +11635 -11635
  99. package/src/plugins/im/lib/RongIMLib-3.0.7.2-dev.min.js +6 -6
  100. package/src/plugins/im/utils/underscore-1.8.3.js +1531 -1531
  101. package/src/plugins/im/utils/utils.js +149 -149
  102. package/src/plugins/row-col-cmp/colCmp/data.js +3 -3
  103. package/src/plugins/row-col-cmp/colCmp/index.scss +50 -50
  104. package/src/plugins/row-col-cmp/colCmp/index.vue +53 -53
  105. package/src/plugins/row-col-cmp/colCmp/methods.js +25 -25
  106. package/src/plugins/row-col-cmp/rowCmp/data.js +3 -3
  107. package/src/plugins/row-col-cmp/rowCmp/index.scss +3 -3
  108. package/src/plugins/row-col-cmp/rowCmp/index.vue +43 -43
  109. package/src/plugins/row-col-cmp/rowCmp/methods.js +29 -29
  110. package/src/router/index.js +47 -43
  111. package/src/store/getters.js +13 -13
  112. package/src/store/index.js +58 -58
  113. package/src/store/modules/app.js +55 -55
  114. package/src/store/modules/dic.js +1 -1
  115. package/src/store/modules/settings.js +28 -28
  116. package/src/store/modules/user.js +94 -94
  117. package/src/store/modules/widgetdata.js +42 -42
  118. package/src/styles/element-ui.scss +49 -49
  119. package/src/styles/mixin.scss +28 -28
  120. package/src/styles/sidebar.scss +210 -210
  121. package/src/styles/transition.scss +48 -48
  122. package/src/styles/variables.scss +25 -25
  123. package/src/utils/get-page-title.js +10 -10
  124. package/src/utils/getMenu.js +2 -1
  125. package/src/utils/global-config.js +15 -15
  126. package/src/utils/index.js +332 -332
  127. package/src/utils/localStorage.js +21 -21
  128. package/src/utils/validate.js +20 -20
  129. package/src/views/layout/components/AllSearch/index.vue +44 -44
  130. package/src/views/layout/components/AppMain.vue +50 -50
  131. package/src/views/layout/components/Navbar.vue +43 -2
  132. package/src/views/layout/components/Sidebar/FixiOSBug.js +26 -26
  133. package/src/views/layout/components/Sidebar/Item.vue +28 -28
  134. package/src/views/layout/components/Sidebar/Link.vue +34 -34
  135. package/src/views/layout/components/Sidebar/Logo.vue +79 -79
  136. package/src/views/layout/components/Sidebar/SidebarItem.vue +67 -67
  137. package/src/views/layout/components/Sidebar/index.vue +114 -114
  138. package/src/views/layout/components/index.js +3 -3
  139. package/src/views/layout/index.vue +105 -105
@@ -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
+ }