doway-coms 2.11.11 → 2.11.13

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