doway-coms 2.3.2 → 2.3.3

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 (82) hide show
  1. package/.browserslistrc +2 -2
  2. package/README.md +28 -28
  3. package/dist/css/chunk-vendors.7f83d8f9.css +8 -0
  4. package/dist/css/index.7946d50b.css +1 -0
  5. package/dist/favicon.ico +0 -0
  6. package/dist/js/chunk-vendors.28fda91d.js +340 -0
  7. package/dist/js/index.49bc6add.js +2 -0
  8. package/lib/doway-coms.common.js +120397 -0
  9. package/lib/doway-coms.css +1 -0
  10. package/lib/doway-coms.umd.js +120407 -0
  11. package/lib/doway-coms.umd.min.js +328 -0
  12. package/package.json +53 -53
  13. package/packages/AuditsList/index.js +7 -7
  14. package/packages/AuditsList/src/index.vue +266 -266
  15. package/packages/BaseButton/index.js +7 -7
  16. package/packages/BaseButton/src/index.vue +241 -241
  17. package/packages/BaseCheckbox/index.js +7 -7
  18. package/packages/BaseCheckbox/src/index.vue +134 -134
  19. package/packages/BaseDate/index.js +7 -7
  20. package/packages/BaseDate/src/index.vue +197 -197
  21. package/packages/BaseDateWeek/index.js +7 -7
  22. package/packages/BaseDateWeek/src/index.vue +163 -163
  23. package/packages/BaseDatetime/index.js +7 -7
  24. package/packages/BaseDatetime/src/index.vue +196 -196
  25. package/packages/BaseForm/index.js +7 -7
  26. package/packages/BaseForm/src/index.vue +730 -730
  27. package/packages/BaseGantt/index.js +9 -9
  28. package/packages/BaseGantt/src/index.vue +617 -617
  29. package/packages/BaseGrid/index.js +9 -9
  30. package/packages/BaseGrid/src/SeqSetting.vue +278 -278
  31. package/packages/BaseGrid/src/index.vue +3616 -3616
  32. package/packages/BaseGridAdjust/index.js +9 -9
  33. package/packages/BaseGridAdjust/src/index.vue +482 -482
  34. package/packages/BaseInput/index.js +7 -7
  35. package/packages/BaseInput/src/index.vue +164 -164
  36. package/packages/BaseIntervalInput/index.js +7 -7
  37. package/packages/BaseIntervalInput/src/index.vue +310 -310
  38. package/packages/BaseKanbanEmpty/index.js +7 -7
  39. package/packages/BaseKanbanEmpty/src/index.vue +176 -176
  40. package/packages/BaseNumberInput/index.js +7 -7
  41. package/packages/BaseNumberInput/src/index.vue +291 -291
  42. package/packages/BasePagination/index.js +7 -7
  43. package/packages/BasePagination/src/index.vue +91 -91
  44. package/packages/BasePictureCard/index.js +7 -7
  45. package/packages/BasePictureCard/src/index.vue +580 -580
  46. package/packages/BasePrintPreview/index.js +7 -7
  47. package/packages/BasePrintPreview/src/index.vue +129 -129
  48. package/packages/BasePulldown/index.js +7 -7
  49. package/packages/BasePulldown/src/index.vue +1321 -1282
  50. package/packages/BaseSearch/index.js +7 -7
  51. package/packages/BaseSearch/src/index.vue +935 -935
  52. package/packages/BaseSelect/index.js +7 -7
  53. package/packages/BaseSelect/src/index.vue +155 -155
  54. package/packages/BaseSelectMulti/index.js +7 -7
  55. package/packages/BaseSelectMulti/src/index.vue +148 -148
  56. package/packages/BaseTextArea/index.js +7 -7
  57. package/packages/BaseTextArea/src/index.vue +178 -178
  58. package/packages/BaseTime/index.js +7 -7
  59. package/packages/BaseTime/src/index.vue +166 -166
  60. package/packages/BaseTool/index.js +7 -7
  61. package/packages/BaseTool/src/index.vue +349 -349
  62. package/packages/BaseToolStatus/index.js +7 -7
  63. package/packages/BaseToolStatus/src/index.vue +388 -388
  64. package/packages/BaseTreeSelect/index.js +8 -8
  65. package/packages/BaseTreeSelect/src/index.vue +437 -437
  66. package/packages/LeaveAMessage/index.js +7 -7
  67. package/packages/LeaveAMessage/src/index.vue +601 -601
  68. package/packages/index.js +191 -191
  69. package/packages/styles/default.css +78 -78
  70. package/packages/styles/default.less +84 -84
  71. package/packages/utils/api.js +107 -107
  72. package/packages/utils/auth.js +38 -38
  73. package/packages/utils/common.js +610 -610
  74. package/packages/utils/dom.js +181 -181
  75. package/packages/utils/enum.js +86 -86
  76. package/packages/utils/filters.js +472 -472
  77. package/packages/utils/gridFormat.js +66 -66
  78. package/packages/utils/msg.js +84 -84
  79. package/packages/utils/patchFiles.js +44 -44
  80. package/packages/utils/request.js +178 -178
  81. package/packages/utils/store.js +305 -309
  82. package/vue.config.js +59 -59
@@ -1,473 +1,473 @@
1
- import moment from 'moment'
2
- import { controlType } from './enum'
3
- import XEUtils from 'xe-utils'
4
- // import { isNumber } from 'util'
5
- // import camelCase from 'lodash/camelCase'
6
- function pluralize(time, label) {
7
- if (time === 1) {
8
- return time + label
9
- }
10
- return time + label + 's'
11
- }
12
-
13
- export function timeAgo(time) {
14
- const between = Date.now() / 1000 - Number(time)
15
- if (between < 3600) {
16
- return pluralize(~~(between / 60), ' minute')
17
- } else if (between < 86400) {
18
- return pluralize(~~(between / 3600), ' hour')
19
- } else {
20
- return pluralize(~~(between / 86400), ' day')
21
- }
22
- }
23
-
24
- export function parseTime(time, cFormat) {
25
- if (arguments.length === 0) {
26
- return null
27
- }
28
-
29
- if ((time + '').length === 10) {
30
- time = +time * 1000
31
- }
32
-
33
- const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
34
- let date
35
- if (typeof time === 'object') {
36
- date = time
37
- } else {
38
- date = new Date(parseInt(time))
39
- }
40
- const formatObj = {
41
- y: date.getFullYear(),
42
- m: date.getMonth() + 1,
43
- d: date.getDate(),
44
- h: date.getHours(),
45
- i: date.getMinutes(),
46
- s: date.getSeconds(),
47
- a: date.getDay()
48
- }
49
- const timeStr = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
50
- let value = formatObj[key]
51
- if (key === 'a')
52
- return ['一', '二', '三', '四', '五', '六', '日'][value - 1]
53
- if (result.length > 0 && value < 10) {
54
- value = '0' + value
55
- }
56
- return value || 0
57
- })
58
- return timeStr
59
- }
60
-
61
- export function formatTime(time, option) {
62
- time = +time * 1000
63
- const d = new Date(time)
64
- const now = Date.now()
65
-
66
- const diff = (now - d) / 1000
67
-
68
- if (diff < 30) {
69
- return '刚刚'
70
- } else if (diff < 3600) {
71
- // less 1 hour
72
- return Math.ceil(diff / 60) + '分钟前'
73
- } else if (diff < 3600 * 24) {
74
- return Math.ceil(diff / 3600) + '小时前'
75
- } else if (diff < 3600 * 24 * 2) {
76
- return '1天前'
77
- }
78
- if (option) {
79
- return parseTime(time, option)
80
- } else {
81
- return (
82
- d.getMonth() +
83
- 1 +
84
- '月' +
85
- d.getDate() +
86
- '日' +
87
- d.getHours() +
88
- '时' +
89
- d.getMinutes() +
90
- '分'
91
- )
92
- }
93
- }
94
-
95
- export function momentTime(time, cFormat) {
96
- return moment(time).format(cFormat)
97
- }
98
- /* 数字 格式化 */
99
- export function nFormatter(num, digits) {
100
- const si = [
101
- { value: 1e18, symbol: 'E' },
102
- { value: 1e15, symbol: 'P' },
103
- { value: 1e12, symbol: 'T' },
104
- { value: 1e9, symbol: 'G' },
105
- { value: 1e6, symbol: 'M' },
106
- { value: 1e3, symbol: 'k' }
107
- ]
108
- for (let i = 0; i < si.length; i++) {
109
- if (num >= si[i].value) {
110
- return (
111
- (num / si[i].value + 0.1)
112
- .toFixed(digits)
113
- .replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + si[i].symbol
114
- )
115
- }
116
- }
117
- return num.toString()
118
- }
119
-
120
- export function html2Text(val) {
121
- const div = document.createElement('div')
122
- div.innerHTML = val
123
- return div.textContent || div.innerText
124
- }
125
-
126
- export function toThousandslsFilter(num) {
127
- return (+num || 0)
128
- .toString()
129
- .replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
130
- }
131
-
132
- export function popupDisplayFilter(value, colInfo) {
133
- let linkField = colInfo.popupCaptionField.split('.')
134
- let returnValue = value
135
- for (let i = 0; i < linkField.length; i++) {
136
- if (
137
- returnValue[linkField[i]] === undefined ||
138
- returnValue[linkField[i]] === null
139
- ) {
140
- return null
141
- }
142
- returnValue = returnValue[linkField[i]]
143
- }
144
- return returnValue
145
- }
146
- export function displayFieldValueFilter(value, field) {
147
- if (value === null) {
148
- return value
149
- }
150
- let linkField = field.split('.')
151
- let returnValue = value
152
- for (let i = 0; i < linkField.length; i++) {
153
- if (
154
- returnValue[linkField[i]] === undefined ||
155
- returnValue[linkField[i]] === null
156
- ) {
157
- return null
158
- }
159
- returnValue = returnValue[linkField[i]]
160
- }
161
- return returnValue
162
- }
163
-
164
- export function displaySelectCaption(value, dataSource) {
165
- let tempItems = dataSource.filter(filterItem => {
166
- return filterItem.value === value
167
- })
168
- if (tempItems.length > 0) {
169
- return tempItems[0].caption
170
- } else {
171
- return value
172
- }
173
- }
174
- export function displaySelectMultiCaption(value, dataSource) {
175
- if (value && value.length > 0) {
176
- let tempValue = ''
177
- for (let i = 0; i < value.length; i++) {
178
- let tempCurrentValue = value[i]
179
- let tempItems = dataSource.filter(filterItem => {
180
- return filterItem.value === tempCurrentValue
181
- })
182
- if (tempItems.length > 0) {
183
- tempCurrentValue = tempItems[0].caption
184
- }
185
- tempValue = tempValue + tempCurrentValue
186
- if (i < value.length - 1) {
187
- tempValue = tempValue + ','
188
- }
189
- }
190
- return tempValue
191
- }
192
- return null
193
- }
194
-
195
- export function displayCaptionFilter(value, colInfo) {
196
- let linkField = colInfo.field.split('.')
197
- let fieldValue = value
198
- for (let i = 0; i < linkField.length; i++) {
199
- if (
200
- fieldValue[linkField[i]] === undefined ||
201
- fieldValue[linkField[i]] === null
202
- ) {
203
- return null
204
- }
205
- fieldValue = fieldValue[linkField[i]]
206
- }
207
- if (colInfo.controlType === controlType.drop) {
208
- let displayValue = colInfo.linkModuleData.dataSource.filter(item => {
209
- return item[colInfo.linkValueField] === fieldValue
210
- })
211
- if (displayValue.length > 0) {
212
- return displayValue[0][colInfo.linkCaptionField]
213
- }
214
- }
215
- if (colInfo.controlType === controlType.checkbox) {
216
- if (fieldValue === true || fieldValue === 'true') {
217
- fieldValue = '是'
218
- } else {
219
- fieldValue = '否'
220
- }
221
- }
222
- if (colInfo.controlType === controlType.date) {
223
- let dateTimeFormat = colInfo.format ? colInfo.format : 'YYYY-MM-DD'
224
- fieldValue = moment(fieldValue).format(dateTimeFormat)
225
- }
226
- if (colInfo.controlType === controlType.datetime) {
227
- let dateTimeFormat = colInfo.format
228
- ? colInfo.format
229
- : 'YYYY-MM-DD HH:mm:ss'
230
- fieldValue = moment(fieldValue).format(dateTimeFormat)
231
- }
232
- if (colInfo.controlType === controlType.time) {
233
- let timeFormat = colInfo.format ? colInfo.format : 'HH:mm:ss'
234
- fieldValue = moment('1970-01-01 ' + fieldValue).format(timeFormat)
235
- }
236
- if (colInfo.controlType === controlType.longtime) {
237
- let tempFieldValue = ''
238
- let tempDays = 0
239
- if (fieldValue.indexOf('.') > 0) {
240
- let arr = fieldValue.split('.')
241
- tempDays = arr[0]
242
- }
243
- //-------------------------
244
- // let tempYears = moment.duration(fieldValue).years()
245
- // if (tempYears > 0) {
246
- // tempFieldValue = tempYears + '年'
247
- // }
248
- // let tempMonths = moment.duration(fieldValue).months()
249
- // if (tempMonths > 0) {
250
- // tempFieldValue += tempMonths + '月'
251
- // }
252
- // let tempDays = moment.duration(fieldValue).days()
253
- //------------------------------
254
- if (tempDays > 0) {
255
- tempFieldValue += tempDays + '天'
256
- }
257
- tempFieldValue =
258
- tempFieldValue +
259
- moment.duration(fieldValue).hours() +
260
- '小时' +
261
- moment.duration(fieldValue).minutes() +
262
- '分钟' +
263
- moment.duration(fieldValue).seconds() +
264
- '秒'
265
- fieldValue = tempFieldValue
266
- }
267
-
268
- if (colInfo.controlType === controlType.dropmulti) {
269
- let returnValue = ''
270
- for (let x = 0; x < colInfo.linkModuleData.dataSource.length; x++) {
271
- if (
272
- fieldValue.indexOf(
273
- colInfo.linkModuleData.dataSource[x][colInfo.linkValueField]
274
- ) >= 0
275
- ) {
276
- returnValue =
277
- returnValue +
278
- colInfo.linkModuleData.dataSource[x][colInfo.linkCaptionField] +
279
- ','
280
- }
281
- }
282
- if (returnValue.length > 0) {
283
- returnValue = returnValue.substr(0, returnValue.length - 1)
284
- }
285
- return returnValue
286
- }
287
-
288
- if (colInfo.controlType === controlType.popup) {
289
- let tempField = colInfo.field
290
- if (colInfo.linkAttrField) {
291
- tempField = colInfo.linkAttrField + '.' + colInfo.linkCaptionField
292
- }
293
- let linkField = tempField.split('.')
294
- let returnValue = value
295
- for (let i = 0; i < linkField.length; i++) {
296
- if (
297
- returnValue[linkField[i]] === undefined ||
298
- returnValue[linkField[i]] === null
299
- ) {
300
- return null
301
- }
302
- returnValue = returnValue[linkField[i]]
303
- }
304
- return returnValue
305
- }
306
-
307
- if (colInfo.displayFormat) {
308
- if (colInfo.displayFormat.indexOf('p') === 0) {
309
- // 百分比显示
310
- let percentNumber = colInfo.displayFormat.substr(1)
311
- return (fieldValue * 100).toFixed(parseInt(percentNumber)) + '%'
312
- }
313
- }
314
-
315
- return fieldValue
316
- }
317
-
318
- export function splitFieldValueFilter(value, field) {
319
- let linkField = field.split('.')
320
- let tempValue = value
321
- for (let i = 0; i < linkField.length; i++) {
322
- tempValue = tempValue[linkField[i]]
323
- if (tempValue === undefined || tempValue === null) {
324
- return null
325
- }
326
- }
327
- return tempValue
328
- }
329
-
330
- export function dropdownDisplayFilter(value, colInfo) {
331
- let linkField = colInfo.field.split('.')
332
- let fieldValue = value
333
- for (let i = 0; i < linkField.length; i++) {
334
- if (
335
- fieldValue[linkField[i]] === undefined ||
336
- fieldValue[linkField[i]] === null
337
- ) {
338
- return null
339
- }
340
- fieldValue = fieldValue[linkField[i]]
341
- }
342
- if (colInfo.controlType === 'Drop') {
343
- let displayValue = colInfo.source.filter(item => {
344
- return item[colInfo.sourceValueField] === fieldValue
345
- })
346
- if (displayValue.length > 0) {
347
- return displayValue[0][colInfo.sourceCaptionField]
348
- }
349
- }
350
- if (colInfo.controlType === 'CheckBox') {
351
- if (fieldValue === true || fieldValue === 'true') {
352
- fieldValue = '是'
353
- } else {
354
- fieldValue = '否'
355
- }
356
- }
357
- if (colInfo.controlType === 'DateTime') {
358
- let dateTimeFormat = colInfo.format ? colInfo.format : 'YYYY-MM-DD'
359
- fieldValue = moment(fieldValue).format(dateTimeFormat)
360
- }
361
- if (colInfo.controlType === 'Time') {
362
- let timeFormat = colInfo.format ? colInfo.format : 'HH:mm:ss'
363
- fieldValue = moment('1970-01-01 ' + fieldValue).format(timeFormat)
364
- }
365
-
366
- if (colInfo.controlType === 'Popup') {
367
- let linkField = colInfo.popupCaptionField.split('.')
368
- let returnValue = value
369
- for (let i = 0; i < linkField.length; i++) {
370
- if (
371
- returnValue[linkField[i]] === undefined ||
372
- returnValue[linkField[i]] === null
373
- ) {
374
- return null
375
- }
376
- returnValue = returnValue[linkField[i]]
377
- }
378
-
379
- return returnValue
380
- }
381
- if (colInfo.controlType === 'PopupLink') {
382
- let linkField = colInfo.popupCaptionField.split('.')
383
- let returnValue = value
384
- for (let i = 0; i < linkField.length; i++) {
385
- if (
386
- returnValue[linkField[i]] === undefined ||
387
- returnValue[linkField[i]] === null
388
- ) {
389
- return null
390
- }
391
- returnValue = returnValue[linkField[i]]
392
- }
393
-
394
- return returnValue
395
- }
396
- return fieldValue
397
- }
398
-
399
- export function dateformat(time, cFormat) {
400
- return moment(time).format(cFormat)
401
- }
402
-
403
- export function secondDisplayTime(value) {
404
- let second = XEUtils.toInteger(value)
405
- let dayValue = XEUtils.floor(XEUtils.divide(second, 24 * 3600))
406
- let hourValue = 0
407
- let minuteValue = 0
408
- let secondValue = 0
409
- second = XEUtils.subtract(second, dayValue * 3600 * 24)
410
- if (second >= 0) {
411
- //设置小时数
412
- hourValue = XEUtils.floor(XEUtils.divide(second, 3600))
413
- //小时之后的剩余秒数
414
- second = XEUtils.subtract(second, hourValue * 3600)
415
- }
416
- if (second >= 0) {
417
- //设置分钟
418
- minuteValue = XEUtils.floor(XEUtils.divide(second, 60))
419
- //小时之后的剩余秒数
420
- second = XEUtils.subtract(second, minuteValue * 60)
421
- }
422
- if (second >= 0) {
423
- //设置秒数
424
- secondValue = second
425
- }
426
-
427
- return (
428
- dayValue +
429
- '天' +
430
- hourValue +
431
- '小时' +
432
- minuteValue +
433
- '分钟' +
434
- secondValue +
435
- '秒'
436
- )
437
- }
438
- /**
439
- * 网格非编辑状态格式化显示值
440
- * @param {*} rowInfo
441
- * @param {*} colInfo
442
- */
443
- export function gridDefaultValueDisplay(rowInfo,colInfo){
444
- let colControlType = colInfo.params.controlType
445
- let displayValue = rowInfo[colInfo.field]
446
- switch(colControlType){
447
- case controlType.checkbox:
448
- displayValue = displayValue===true?'是':'否'
449
- break
450
- case controlType.select:
451
- const item = colInfo.params.dataSource.find(
452
- item => item.value === displayValue
453
- )
454
- displayValue = item ? item.caption :displayValue
455
- break
456
- case controlType.multiSelect:
457
- displayValue = XEUtils.map(displayValue, item => {
458
- return XEUtils.find(colInfo.params.dataSource, loop => loop.value === item).caption
459
- })
460
- displayValue = displayValue.join(',')
461
- break
462
- case controlType.number:
463
- if(colInfo.params.doRound){
464
- displayValue=XEUtils.round(displayValue,colInfo.params.precision)
465
- }
466
- if(colInfo.params.percent){
467
- displayValue=XEUtils.round(displayValue*100,colInfo.params.precision)+'%'
468
- }
469
- break
470
-
471
- }
472
- return displayValue
1
+ import moment from 'moment'
2
+ import { controlType } from './enum'
3
+ import XEUtils from 'xe-utils'
4
+ // import { isNumber } from 'util'
5
+ // import camelCase from 'lodash/camelCase'
6
+ function pluralize(time, label) {
7
+ if (time === 1) {
8
+ return time + label
9
+ }
10
+ return time + label + 's'
11
+ }
12
+
13
+ export function timeAgo(time) {
14
+ const between = Date.now() / 1000 - Number(time)
15
+ if (between < 3600) {
16
+ return pluralize(~~(between / 60), ' minute')
17
+ } else if (between < 86400) {
18
+ return pluralize(~~(between / 3600), ' hour')
19
+ } else {
20
+ return pluralize(~~(between / 86400), ' day')
21
+ }
22
+ }
23
+
24
+ export function parseTime(time, cFormat) {
25
+ if (arguments.length === 0) {
26
+ return null
27
+ }
28
+
29
+ if ((time + '').length === 10) {
30
+ time = +time * 1000
31
+ }
32
+
33
+ const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
34
+ let date
35
+ if (typeof time === 'object') {
36
+ date = time
37
+ } else {
38
+ date = new Date(parseInt(time))
39
+ }
40
+ const formatObj = {
41
+ y: date.getFullYear(),
42
+ m: date.getMonth() + 1,
43
+ d: date.getDate(),
44
+ h: date.getHours(),
45
+ i: date.getMinutes(),
46
+ s: date.getSeconds(),
47
+ a: date.getDay()
48
+ }
49
+ const timeStr = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
50
+ let value = formatObj[key]
51
+ if (key === 'a')
52
+ return ['一', '二', '三', '四', '五', '六', '日'][value - 1]
53
+ if (result.length > 0 && value < 10) {
54
+ value = '0' + value
55
+ }
56
+ return value || 0
57
+ })
58
+ return timeStr
59
+ }
60
+
61
+ export function formatTime(time, option) {
62
+ time = +time * 1000
63
+ const d = new Date(time)
64
+ const now = Date.now()
65
+
66
+ const diff = (now - d) / 1000
67
+
68
+ if (diff < 30) {
69
+ return '刚刚'
70
+ } else if (diff < 3600) {
71
+ // less 1 hour
72
+ return Math.ceil(diff / 60) + '分钟前'
73
+ } else if (diff < 3600 * 24) {
74
+ return Math.ceil(diff / 3600) + '小时前'
75
+ } else if (diff < 3600 * 24 * 2) {
76
+ return '1天前'
77
+ }
78
+ if (option) {
79
+ return parseTime(time, option)
80
+ } else {
81
+ return (
82
+ d.getMonth() +
83
+ 1 +
84
+ '月' +
85
+ d.getDate() +
86
+ '日' +
87
+ d.getHours() +
88
+ '时' +
89
+ d.getMinutes() +
90
+ '分'
91
+ )
92
+ }
93
+ }
94
+
95
+ export function momentTime(time, cFormat) {
96
+ return moment(time).format(cFormat)
97
+ }
98
+ /* 数字 格式化 */
99
+ export function nFormatter(num, digits) {
100
+ const si = [
101
+ { value: 1e18, symbol: 'E' },
102
+ { value: 1e15, symbol: 'P' },
103
+ { value: 1e12, symbol: 'T' },
104
+ { value: 1e9, symbol: 'G' },
105
+ { value: 1e6, symbol: 'M' },
106
+ { value: 1e3, symbol: 'k' }
107
+ ]
108
+ for (let i = 0; i < si.length; i++) {
109
+ if (num >= si[i].value) {
110
+ return (
111
+ (num / si[i].value + 0.1)
112
+ .toFixed(digits)
113
+ .replace(/\.0+$|(\.[0-9]*[1-9])0+$/, '$1') + si[i].symbol
114
+ )
115
+ }
116
+ }
117
+ return num.toString()
118
+ }
119
+
120
+ export function html2Text(val) {
121
+ const div = document.createElement('div')
122
+ div.innerHTML = val
123
+ return div.textContent || div.innerText
124
+ }
125
+
126
+ export function toThousandslsFilter(num) {
127
+ return (+num || 0)
128
+ .toString()
129
+ .replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ','))
130
+ }
131
+
132
+ export function popupDisplayFilter(value, colInfo) {
133
+ let linkField = colInfo.popupCaptionField.split('.')
134
+ let returnValue = value
135
+ for (let i = 0; i < linkField.length; i++) {
136
+ if (
137
+ returnValue[linkField[i]] === undefined ||
138
+ returnValue[linkField[i]] === null
139
+ ) {
140
+ return null
141
+ }
142
+ returnValue = returnValue[linkField[i]]
143
+ }
144
+ return returnValue
145
+ }
146
+ export function displayFieldValueFilter(value, field) {
147
+ if (value === null) {
148
+ return value
149
+ }
150
+ let linkField = field.split('.')
151
+ let returnValue = value
152
+ for (let i = 0; i < linkField.length; i++) {
153
+ if (
154
+ returnValue[linkField[i]] === undefined ||
155
+ returnValue[linkField[i]] === null
156
+ ) {
157
+ return null
158
+ }
159
+ returnValue = returnValue[linkField[i]]
160
+ }
161
+ return returnValue
162
+ }
163
+
164
+ export function displaySelectCaption(value, dataSource) {
165
+ let tempItems = dataSource.filter(filterItem => {
166
+ return filterItem.value === value
167
+ })
168
+ if (tempItems.length > 0) {
169
+ return tempItems[0].caption
170
+ } else {
171
+ return value
172
+ }
173
+ }
174
+ export function displaySelectMultiCaption(value, dataSource) {
175
+ if (value && value.length > 0) {
176
+ let tempValue = ''
177
+ for (let i = 0; i < value.length; i++) {
178
+ let tempCurrentValue = value[i]
179
+ let tempItems = dataSource.filter(filterItem => {
180
+ return filterItem.value === tempCurrentValue
181
+ })
182
+ if (tempItems.length > 0) {
183
+ tempCurrentValue = tempItems[0].caption
184
+ }
185
+ tempValue = tempValue + tempCurrentValue
186
+ if (i < value.length - 1) {
187
+ tempValue = tempValue + ','
188
+ }
189
+ }
190
+ return tempValue
191
+ }
192
+ return null
193
+ }
194
+
195
+ export function displayCaptionFilter(value, colInfo) {
196
+ let linkField = colInfo.field.split('.')
197
+ let fieldValue = value
198
+ for (let i = 0; i < linkField.length; i++) {
199
+ if (
200
+ fieldValue[linkField[i]] === undefined ||
201
+ fieldValue[linkField[i]] === null
202
+ ) {
203
+ return null
204
+ }
205
+ fieldValue = fieldValue[linkField[i]]
206
+ }
207
+ if (colInfo.controlType === controlType.drop) {
208
+ let displayValue = colInfo.linkModuleData.dataSource.filter(item => {
209
+ return item[colInfo.linkValueField] === fieldValue
210
+ })
211
+ if (displayValue.length > 0) {
212
+ return displayValue[0][colInfo.linkCaptionField]
213
+ }
214
+ }
215
+ if (colInfo.controlType === controlType.checkbox) {
216
+ if (fieldValue === true || fieldValue === 'true') {
217
+ fieldValue = '是'
218
+ } else {
219
+ fieldValue = '否'
220
+ }
221
+ }
222
+ if (colInfo.controlType === controlType.date) {
223
+ let dateTimeFormat = colInfo.format ? colInfo.format : 'YYYY-MM-DD'
224
+ fieldValue = moment(fieldValue).format(dateTimeFormat)
225
+ }
226
+ if (colInfo.controlType === controlType.datetime) {
227
+ let dateTimeFormat = colInfo.format
228
+ ? colInfo.format
229
+ : 'YYYY-MM-DD HH:mm:ss'
230
+ fieldValue = moment(fieldValue).format(dateTimeFormat)
231
+ }
232
+ if (colInfo.controlType === controlType.time) {
233
+ let timeFormat = colInfo.format ? colInfo.format : 'HH:mm:ss'
234
+ fieldValue = moment('1970-01-01 ' + fieldValue).format(timeFormat)
235
+ }
236
+ if (colInfo.controlType === controlType.longtime) {
237
+ let tempFieldValue = ''
238
+ let tempDays = 0
239
+ if (fieldValue.indexOf('.') > 0) {
240
+ let arr = fieldValue.split('.')
241
+ tempDays = arr[0]
242
+ }
243
+ //-------------------------
244
+ // let tempYears = moment.duration(fieldValue).years()
245
+ // if (tempYears > 0) {
246
+ // tempFieldValue = tempYears + '年'
247
+ // }
248
+ // let tempMonths = moment.duration(fieldValue).months()
249
+ // if (tempMonths > 0) {
250
+ // tempFieldValue += tempMonths + '月'
251
+ // }
252
+ // let tempDays = moment.duration(fieldValue).days()
253
+ //------------------------------
254
+ if (tempDays > 0) {
255
+ tempFieldValue += tempDays + '天'
256
+ }
257
+ tempFieldValue =
258
+ tempFieldValue +
259
+ moment.duration(fieldValue).hours() +
260
+ '小时' +
261
+ moment.duration(fieldValue).minutes() +
262
+ '分钟' +
263
+ moment.duration(fieldValue).seconds() +
264
+ '秒'
265
+ fieldValue = tempFieldValue
266
+ }
267
+
268
+ if (colInfo.controlType === controlType.dropmulti) {
269
+ let returnValue = ''
270
+ for (let x = 0; x < colInfo.linkModuleData.dataSource.length; x++) {
271
+ if (
272
+ fieldValue.indexOf(
273
+ colInfo.linkModuleData.dataSource[x][colInfo.linkValueField]
274
+ ) >= 0
275
+ ) {
276
+ returnValue =
277
+ returnValue +
278
+ colInfo.linkModuleData.dataSource[x][colInfo.linkCaptionField] +
279
+ ','
280
+ }
281
+ }
282
+ if (returnValue.length > 0) {
283
+ returnValue = returnValue.substr(0, returnValue.length - 1)
284
+ }
285
+ return returnValue
286
+ }
287
+
288
+ if (colInfo.controlType === controlType.popup) {
289
+ let tempField = colInfo.field
290
+ if (colInfo.linkAttrField) {
291
+ tempField = colInfo.linkAttrField + '.' + colInfo.linkCaptionField
292
+ }
293
+ let linkField = tempField.split('.')
294
+ let returnValue = value
295
+ for (let i = 0; i < linkField.length; i++) {
296
+ if (
297
+ returnValue[linkField[i]] === undefined ||
298
+ returnValue[linkField[i]] === null
299
+ ) {
300
+ return null
301
+ }
302
+ returnValue = returnValue[linkField[i]]
303
+ }
304
+ return returnValue
305
+ }
306
+
307
+ if (colInfo.displayFormat) {
308
+ if (colInfo.displayFormat.indexOf('p') === 0) {
309
+ // 百分比显示
310
+ let percentNumber = colInfo.displayFormat.substr(1)
311
+ return (fieldValue * 100).toFixed(parseInt(percentNumber)) + '%'
312
+ }
313
+ }
314
+
315
+ return fieldValue
316
+ }
317
+
318
+ export function splitFieldValueFilter(value, field) {
319
+ let linkField = field.split('.')
320
+ let tempValue = value
321
+ for (let i = 0; i < linkField.length; i++) {
322
+ tempValue = tempValue[linkField[i]]
323
+ if (tempValue === undefined || tempValue === null) {
324
+ return null
325
+ }
326
+ }
327
+ return tempValue
328
+ }
329
+
330
+ export function dropdownDisplayFilter(value, colInfo) {
331
+ let linkField = colInfo.field.split('.')
332
+ let fieldValue = value
333
+ for (let i = 0; i < linkField.length; i++) {
334
+ if (
335
+ fieldValue[linkField[i]] === undefined ||
336
+ fieldValue[linkField[i]] === null
337
+ ) {
338
+ return null
339
+ }
340
+ fieldValue = fieldValue[linkField[i]]
341
+ }
342
+ if (colInfo.controlType === 'Drop') {
343
+ let displayValue = colInfo.source.filter(item => {
344
+ return item[colInfo.sourceValueField] === fieldValue
345
+ })
346
+ if (displayValue.length > 0) {
347
+ return displayValue[0][colInfo.sourceCaptionField]
348
+ }
349
+ }
350
+ if (colInfo.controlType === 'CheckBox') {
351
+ if (fieldValue === true || fieldValue === 'true') {
352
+ fieldValue = '是'
353
+ } else {
354
+ fieldValue = '否'
355
+ }
356
+ }
357
+ if (colInfo.controlType === 'DateTime') {
358
+ let dateTimeFormat = colInfo.format ? colInfo.format : 'YYYY-MM-DD'
359
+ fieldValue = moment(fieldValue).format(dateTimeFormat)
360
+ }
361
+ if (colInfo.controlType === 'Time') {
362
+ let timeFormat = colInfo.format ? colInfo.format : 'HH:mm:ss'
363
+ fieldValue = moment('1970-01-01 ' + fieldValue).format(timeFormat)
364
+ }
365
+
366
+ if (colInfo.controlType === 'Popup') {
367
+ let linkField = colInfo.popupCaptionField.split('.')
368
+ let returnValue = value
369
+ for (let i = 0; i < linkField.length; i++) {
370
+ if (
371
+ returnValue[linkField[i]] === undefined ||
372
+ returnValue[linkField[i]] === null
373
+ ) {
374
+ return null
375
+ }
376
+ returnValue = returnValue[linkField[i]]
377
+ }
378
+
379
+ return returnValue
380
+ }
381
+ if (colInfo.controlType === 'PopupLink') {
382
+ let linkField = colInfo.popupCaptionField.split('.')
383
+ let returnValue = value
384
+ for (let i = 0; i < linkField.length; i++) {
385
+ if (
386
+ returnValue[linkField[i]] === undefined ||
387
+ returnValue[linkField[i]] === null
388
+ ) {
389
+ return null
390
+ }
391
+ returnValue = returnValue[linkField[i]]
392
+ }
393
+
394
+ return returnValue
395
+ }
396
+ return fieldValue
397
+ }
398
+
399
+ export function dateformat(time, cFormat) {
400
+ return moment(time).format(cFormat)
401
+ }
402
+
403
+ export function secondDisplayTime(value) {
404
+ let second = XEUtils.toInteger(value)
405
+ let dayValue = XEUtils.floor(XEUtils.divide(second, 24 * 3600))
406
+ let hourValue = 0
407
+ let minuteValue = 0
408
+ let secondValue = 0
409
+ second = XEUtils.subtract(second, dayValue * 3600 * 24)
410
+ if (second >= 0) {
411
+ //设置小时数
412
+ hourValue = XEUtils.floor(XEUtils.divide(second, 3600))
413
+ //小时之后的剩余秒数
414
+ second = XEUtils.subtract(second, hourValue * 3600)
415
+ }
416
+ if (second >= 0) {
417
+ //设置分钟
418
+ minuteValue = XEUtils.floor(XEUtils.divide(second, 60))
419
+ //小时之后的剩余秒数
420
+ second = XEUtils.subtract(second, minuteValue * 60)
421
+ }
422
+ if (second >= 0) {
423
+ //设置秒数
424
+ secondValue = second
425
+ }
426
+
427
+ return (
428
+ dayValue +
429
+ '天' +
430
+ hourValue +
431
+ '小时' +
432
+ minuteValue +
433
+ '分钟' +
434
+ secondValue +
435
+ '秒'
436
+ )
437
+ }
438
+ /**
439
+ * 网格非编辑状态格式化显示值
440
+ * @param {*} rowInfo
441
+ * @param {*} colInfo
442
+ */
443
+ export function gridDefaultValueDisplay(rowInfo,colInfo){
444
+ let colControlType = colInfo.params.controlType
445
+ let displayValue = rowInfo[colInfo.field]
446
+ switch(colControlType){
447
+ case controlType.checkbox:
448
+ displayValue = displayValue===true?'是':'否'
449
+ break
450
+ case controlType.select:
451
+ const item = colInfo.params.dataSource.find(
452
+ item => item.value === displayValue
453
+ )
454
+ displayValue = item ? item.caption :displayValue
455
+ break
456
+ case controlType.multiSelect:
457
+ displayValue = XEUtils.map(displayValue, item => {
458
+ return XEUtils.find(colInfo.params.dataSource, loop => loop.value === item).caption
459
+ })
460
+ displayValue = displayValue.join(',')
461
+ break
462
+ case controlType.number:
463
+ if(colInfo.params.doRound){
464
+ displayValue=XEUtils.round(displayValue,colInfo.params.precision)
465
+ }
466
+ if(colInfo.params.percent){
467
+ displayValue=XEUtils.round(displayValue*100,colInfo.params.precision)+'%'
468
+ }
469
+ break
470
+
471
+ }
472
+ return displayValue
473
473
  }