doway-coms 2.11.96 → 2.11.97
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.
- package/.browserslistrc +2 -2
- package/README.md +28 -28
- package/package.json +63 -63
- package/packages/AuditsList/index.js +7 -7
- package/packages/AuditsList/src/index.vue +314 -314
- package/packages/BaseButton/index.js +7 -7
- package/packages/BaseButton/src/index.vue +242 -242
- package/packages/BaseCheckbox/index.js +7 -7
- package/packages/BaseCheckbox/src/index.vue +134 -134
- package/packages/BaseDate/index.js +7 -7
- package/packages/BaseDate/src/index.vue +233 -233
- package/packages/BaseDateMonth/index.js +7 -7
- package/packages/BaseDateMonth/src/index.vue +163 -163
- package/packages/BaseDateWeek/index.js +7 -7
- package/packages/BaseDateWeek/src/index.vue +163 -163
- package/packages/BaseDatetime/index.js +7 -7
- package/packages/BaseDatetime/src/index.vue +196 -196
- package/packages/BaseFileGroup/index.js +7 -7
- package/packages/BaseFileGroup/src/index.vue +778 -778
- package/packages/BaseForm/index.js +7 -7
- package/packages/BaseForm/src/index.vue +913 -913
- package/packages/BaseGantt/index.js +9 -9
- package/packages/BaseGantt/src/index.vue +617 -617
- package/packages/BaseGrid/index.js +9 -9
- package/packages/BaseGrid/src/exportCmp.vue +105 -105
- package/packages/BaseGrid/src/gridApi.js +32 -32
- package/packages/BaseGrid/src/index.vue +4762 -4762
- package/packages/BaseGridAdjust/index.js +9 -9
- package/packages/BaseGridAdjust/src/index.vue +482 -482
- package/packages/BaseInput/index.js +7 -7
- package/packages/BaseInput/src/index.vue +207 -207
- package/packages/BaseIntervalInput/index.js +7 -7
- package/packages/BaseIntervalInput/src/index.vue +316 -316
- package/packages/BaseKanbanEmpty/index.js +7 -7
- package/packages/BaseKanbanEmpty/src/index.vue +176 -176
- package/packages/BaseNumberInput/index.js +7 -7
- package/packages/BaseNumberInput/src/index.vue +278 -278
- package/packages/BasePagination/index.js +7 -7
- package/packages/BasePagination/src/index.vue +90 -90
- package/packages/BasePictureCard/index.js +7 -7
- package/packages/BasePictureCard/src/index.vue +671 -671
- package/packages/BasePrintPreview/index.js +7 -7
- package/packages/BasePrintPreview/src/index.vue +214 -214
- package/packages/BasePulldown/index.js +7 -7
- package/packages/BasePulldown/src/index.vue +1406 -1406
- package/packages/BaseSearch/index.js +7 -7
- package/packages/BaseSearch/src/index.vue +935 -935
- package/packages/BaseSelect/index.js +7 -7
- package/packages/BaseSelect/src/index.vue +169 -169
- package/packages/BaseSelectMulti/index.js +7 -7
- package/packages/BaseSelectMulti/src/index.vue +148 -148
- package/packages/BaseTextArea/index.js +7 -7
- package/packages/BaseTextArea/src/index.vue +197 -197
- package/packages/BaseTime/index.js +7 -7
- package/packages/BaseTime/src/index.vue +166 -166
- package/packages/BaseTool/index.js +7 -7
- package/packages/BaseTool/src/index.vue +353 -353
- package/packages/BaseToolStatus/index.js +7 -7
- package/packages/BaseToolStatus/src/ApprovalPersonsGroup.vue +41 -41
- package/packages/BaseToolStatus/src/index.vue +439 -439
- package/packages/BaseTreeSelect/index.js +8 -8
- package/packages/BaseTreeSelect/src/index.vue +437 -437
- package/packages/HistoryModal/index.js +8 -8
- package/packages/HistoryModal/src/index.vue +161 -161
- package/packages/LeaveAMessage/index.js +7 -7
- package/packages/LeaveAMessage/src/index.vue +601 -601
- package/packages/directive/clickoutside.js +44 -44
- package/packages/index.js +197 -197
- package/packages/styles/default.css +78 -78
- package/packages/styles/default.less +91 -91
- package/packages/styles/hps/default.less +73 -73
- package/packages/utils/api.js +134 -134
- package/packages/utils/auth.js +38 -38
- package/packages/utils/common.js +728 -728
- package/packages/utils/dom.js +181 -181
- package/packages/utils/enum.js +87 -87
- package/packages/utils/filters.js +542 -542
- package/packages/utils/gridFormat.js +66 -66
- package/packages/utils/msg.js +105 -105
- package/packages/utils/patchFiles.js +44 -44
- package/packages/utils/request.js +181 -181
- package/packages/utils/store.js +405 -396
- package/packages/utils/tscPrinter.js +101 -101
- package/sync.bash +6 -6
- package/vue.config.js +59 -59
- package/dist/css/chunk-vendors.7f83d8f9.css +0 -8
- package/dist/css/index.7946d50b.css +0 -1
- package/dist/favicon.ico +0 -0
- package/dist/js/chunk-vendors.28fda91d.js +0 -340
- package/dist/js/index.49bc6add.js +0 -2
- package/lib/doway-coms.common.js +0 -120397
- package/lib/doway-coms.css +0 -1
- package/lib/doway-coms.umd.js +0 -120407
- package/lib/doway-coms.umd.min.js +0 -328
|
@@ -1,543 +1,543 @@
|
|
|
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
|
-
|
|
446
|
-
//获取全局配置,数字是否显示小数点补零
|
|
447
|
-
let girdNumberPointZero = 0
|
|
448
|
-
if(store.getters.baseSetting && store.getters.baseSetting.pointZero){
|
|
449
|
-
girdNumberPointZero = XEUtils.toInteger(store.getters.baseSetting.pointZero)
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
let colControlType = colInfo.params.controlType
|
|
454
|
-
let displayValue = rowInfo[colInfo.field]
|
|
455
|
-
if(displayValue===null || displayValue===undefined){
|
|
456
|
-
return ''
|
|
457
|
-
}
|
|
458
|
-
switch(colControlType){
|
|
459
|
-
case controlType.checkbox:
|
|
460
|
-
displayValue = displayValue===true?'是':'否'
|
|
461
|
-
break
|
|
462
|
-
case controlType.select:
|
|
463
|
-
const item = colInfo.params.dataSource.find(
|
|
464
|
-
item => item.value === displayValue
|
|
465
|
-
)
|
|
466
|
-
displayValue = item ? item.caption :displayValue
|
|
467
|
-
break
|
|
468
|
-
case controlType.multiSelect:
|
|
469
|
-
displayValue = XEUtils.map(displayValue, item => {
|
|
470
|
-
return XEUtils.find(colInfo.params.dataSource, loop => loop.value === item).caption
|
|
471
|
-
})
|
|
472
|
-
displayValue = displayValue.join(',')
|
|
473
|
-
break
|
|
474
|
-
case controlType.number:
|
|
475
|
-
if(colInfo.params&&colInfo.params.formatMethod){
|
|
476
|
-
displayValue = colInfo.params.formatMethod(displayValue)
|
|
477
|
-
}else{
|
|
478
|
-
if(colInfo.params.doRound){
|
|
479
|
-
displayValue=XEUtils.round(displayValue,colInfo.params.precision)
|
|
480
|
-
}
|
|
481
|
-
if(colInfo.params.percent){
|
|
482
|
-
displayValue=XEUtils.round(displayValue*100,colInfo.params.precision)
|
|
483
|
-
if(colInfo.params.thousandDigit===true){
|
|
484
|
-
displayValue = displayValue.toLocaleString('en-US',{ maximumFractionDigits: 10 })
|
|
485
|
-
}
|
|
486
|
-
//查看是否小数点补零位数
|
|
487
|
-
if(girdNumberPointZero>0){
|
|
488
|
-
girdNumberPointZero = girdNumberPointZero>XEUtils.toInteger(colInfo.params.precision)?
|
|
489
|
-
girdNumberPointZero:XEUtils.toInteger(colInfo.params.precision)
|
|
490
|
-
displayValue = setNumberZero(displayValue,girdNumberPointZero)
|
|
491
|
-
}
|
|
492
|
-
displayValue = displayValue+'%'
|
|
493
|
-
}else{
|
|
494
|
-
if(colInfo.params.thousandDigit===true){
|
|
495
|
-
displayValue = displayValue.toLocaleString('en-US',{ maximumFractionDigits: 10 })
|
|
496
|
-
}
|
|
497
|
-
//查看是否小数点补零位数
|
|
498
|
-
if(girdNumberPointZero>0){
|
|
499
|
-
girdNumberPointZero = girdNumberPointZero>XEUtils.toInteger(colInfo.params.precision)?
|
|
500
|
-
girdNumberPointZero:XEUtils.toInteger(colInfo.params.precision)
|
|
501
|
-
displayValue = setNumberZero(displayValue,girdNumberPointZero)
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
break
|
|
507
|
-
case controlType.date:
|
|
508
|
-
if(colInfo.params&&colInfo.params.formatMethod){
|
|
509
|
-
displayValue=colInfo.params.formatMethod(displayValue)
|
|
510
|
-
}else{
|
|
511
|
-
displayValue=moment(displayValue).format(colInfo.params.format?colInfo.params.format:'YYYY-MM-DD')
|
|
512
|
-
}
|
|
513
|
-
break
|
|
514
|
-
}
|
|
515
|
-
return displayValue
|
|
516
|
-
}
|
|
517
|
-
export function setNumberZero(value,numberPointZero){
|
|
518
|
-
//转成字符串,防止是数字
|
|
519
|
-
// 转成字符串,防止是数字
|
|
520
|
-
//判断是否存在小数点,如果不存在就直接补小数点和对应的0,如果存在就判断小数点后面存在几个字符,如果小于设定的字符数就补零
|
|
521
|
-
let strValue = value + '';
|
|
522
|
-
|
|
523
|
-
// 判断是否存在小数点
|
|
524
|
-
const decimalIndex = strValue.indexOf('.');
|
|
525
|
-
|
|
526
|
-
if (decimalIndex === -1) {
|
|
527
|
-
// 不存在小数点,直接补小数点和对应的0
|
|
528
|
-
if (numberPointZero > 0) {
|
|
529
|
-
strValue += '.' + '0'.repeat(numberPointZero);
|
|
530
|
-
}
|
|
531
|
-
} else {
|
|
532
|
-
// 存在小数点,判断小数点后的位数
|
|
533
|
-
const decimalPart = strValue.substring(decimalIndex + 1);
|
|
534
|
-
const decimalLength = decimalPart.length;
|
|
535
|
-
|
|
536
|
-
if (decimalLength < numberPointZero) {
|
|
537
|
-
// 不足位数则补零
|
|
538
|
-
strValue += '0'.repeat(numberPointZero - decimalLength);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
return strValue;
|
|
542
|
-
|
|
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
|
+
|
|
446
|
+
//获取全局配置,数字是否显示小数点补零
|
|
447
|
+
let girdNumberPointZero = 0
|
|
448
|
+
if(store.getters.baseSetting && store.getters.baseSetting.pointZero){
|
|
449
|
+
girdNumberPointZero = XEUtils.toInteger(store.getters.baseSetting.pointZero)
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
let colControlType = colInfo.params.controlType
|
|
454
|
+
let displayValue = rowInfo[colInfo.field]
|
|
455
|
+
if(displayValue===null || displayValue===undefined){
|
|
456
|
+
return ''
|
|
457
|
+
}
|
|
458
|
+
switch(colControlType){
|
|
459
|
+
case controlType.checkbox:
|
|
460
|
+
displayValue = displayValue===true?'是':'否'
|
|
461
|
+
break
|
|
462
|
+
case controlType.select:
|
|
463
|
+
const item = colInfo.params.dataSource.find(
|
|
464
|
+
item => item.value === displayValue
|
|
465
|
+
)
|
|
466
|
+
displayValue = item ? item.caption :displayValue
|
|
467
|
+
break
|
|
468
|
+
case controlType.multiSelect:
|
|
469
|
+
displayValue = XEUtils.map(displayValue, item => {
|
|
470
|
+
return XEUtils.find(colInfo.params.dataSource, loop => loop.value === item).caption
|
|
471
|
+
})
|
|
472
|
+
displayValue = displayValue.join(',')
|
|
473
|
+
break
|
|
474
|
+
case controlType.number:
|
|
475
|
+
if(colInfo.params&&colInfo.params.formatMethod){
|
|
476
|
+
displayValue = colInfo.params.formatMethod(displayValue)
|
|
477
|
+
}else{
|
|
478
|
+
if(colInfo.params.doRound){
|
|
479
|
+
displayValue=XEUtils.round(displayValue,colInfo.params.precision)
|
|
480
|
+
}
|
|
481
|
+
if(colInfo.params.percent){
|
|
482
|
+
displayValue=XEUtils.round(displayValue*100,colInfo.params.precision)
|
|
483
|
+
if(colInfo.params.thousandDigit===true){
|
|
484
|
+
displayValue = displayValue.toLocaleString('en-US',{ maximumFractionDigits: 10 })
|
|
485
|
+
}
|
|
486
|
+
//查看是否小数点补零位数
|
|
487
|
+
if(girdNumberPointZero>0){
|
|
488
|
+
girdNumberPointZero = girdNumberPointZero>XEUtils.toInteger(colInfo.params.precision)?
|
|
489
|
+
girdNumberPointZero:XEUtils.toInteger(colInfo.params.precision)
|
|
490
|
+
displayValue = setNumberZero(displayValue,girdNumberPointZero)
|
|
491
|
+
}
|
|
492
|
+
displayValue = displayValue+'%'
|
|
493
|
+
}else{
|
|
494
|
+
if(colInfo.params.thousandDigit===true){
|
|
495
|
+
displayValue = displayValue.toLocaleString('en-US',{ maximumFractionDigits: 10 })
|
|
496
|
+
}
|
|
497
|
+
//查看是否小数点补零位数
|
|
498
|
+
if(girdNumberPointZero>0){
|
|
499
|
+
girdNumberPointZero = girdNumberPointZero>XEUtils.toInteger(colInfo.params.precision)?
|
|
500
|
+
girdNumberPointZero:XEUtils.toInteger(colInfo.params.precision)
|
|
501
|
+
displayValue = setNumberZero(displayValue,girdNumberPointZero)
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
break
|
|
507
|
+
case controlType.date:
|
|
508
|
+
if(colInfo.params&&colInfo.params.formatMethod){
|
|
509
|
+
displayValue=colInfo.params.formatMethod(displayValue)
|
|
510
|
+
}else{
|
|
511
|
+
displayValue=moment(displayValue).format(colInfo.params.format?colInfo.params.format:'YYYY-MM-DD')
|
|
512
|
+
}
|
|
513
|
+
break
|
|
514
|
+
}
|
|
515
|
+
return displayValue
|
|
516
|
+
}
|
|
517
|
+
export function setNumberZero(value,numberPointZero){
|
|
518
|
+
//转成字符串,防止是数字
|
|
519
|
+
// 转成字符串,防止是数字
|
|
520
|
+
//判断是否存在小数点,如果不存在就直接补小数点和对应的0,如果存在就判断小数点后面存在几个字符,如果小于设定的字符数就补零
|
|
521
|
+
let strValue = value + '';
|
|
522
|
+
|
|
523
|
+
// 判断是否存在小数点
|
|
524
|
+
const decimalIndex = strValue.indexOf('.');
|
|
525
|
+
|
|
526
|
+
if (decimalIndex === -1) {
|
|
527
|
+
// 不存在小数点,直接补小数点和对应的0
|
|
528
|
+
if (numberPointZero > 0) {
|
|
529
|
+
strValue += '.' + '0'.repeat(numberPointZero);
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
// 存在小数点,判断小数点后的位数
|
|
533
|
+
const decimalPart = strValue.substring(decimalIndex + 1);
|
|
534
|
+
const decimalLength = decimalPart.length;
|
|
535
|
+
|
|
536
|
+
if (decimalLength < numberPointZero) {
|
|
537
|
+
// 不足位数则补零
|
|
538
|
+
strValue += '0'.repeat(numberPointZero - decimalLength);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
return strValue;
|
|
542
|
+
|
|
543
543
|
}
|