doway-coms 1.1.52 → 1.1.55
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/lib/doway-coms.common.js +1506 -53
- package/lib/doway-coms.umd.js +1506 -53
- package/node_modules/vxe-table/package.json +1 -1
- package/package.json +13 -4
- package/packages/BaseCheckbox/index.js +8 -0
- package/packages/BaseCheckbox/src/index.vue +123 -0
- package/packages/BaseDate/index.js +8 -0
- package/packages/BaseDate/src/index.vue +145 -0
- package/packages/BaseDateWeek/index.js +8 -0
- package/packages/BaseDateWeek/src/index.vue +115 -0
- package/packages/BaseDatetime/index.js +8 -0
- package/packages/BaseDatetime/src/index.vue +143 -0
- package/packages/BaseForm/index.js +8 -0
- package/packages/BaseForm/src/index.vue +631 -0
- package/packages/BaseGrid/index.js +10 -0
- package/packages/BaseGrid/src/index.vue +2375 -0
- package/packages/BaseInput/index.js +8 -0
- package/packages/BaseInput/src/index.vue +122 -0
- package/packages/BaseIntervalInput/index.js +8 -0
- package/packages/BaseIntervalInput/src/index.vue +275 -0
- package/packages/BaseNumberInput/index.js +8 -0
- package/packages/BaseNumberInput/src/index.vue +216 -0
- package/packages/BasePagination/index.js +8 -0
- package/packages/BasePagination/src/index.vue +74 -0
- package/packages/BasePictureCard/index.js +8 -0
- package/packages/BasePictureCard/src/index.vue +580 -0
- package/packages/BasePulldown/index.js +8 -0
- package/packages/BasePulldown/src/index.vue +817 -0
- package/packages/BaseSelect/index.js +8 -0
- package/packages/BaseSelect/src/index.vue +141 -0
- package/packages/BaseSelectMulti/index.js +8 -0
- package/packages/BaseSelectMulti/src/index.vue +135 -0
- package/packages/BaseTextArea/index.js +8 -0
- package/packages/BaseTextArea/src/index.vue +138 -0
- package/packages/BaseTime/index.js +8 -0
- package/packages/BaseTime/src/index.vue +117 -0
- package/packages/BaseTool/index.js +8 -0
- package/packages/BaseTool/src/index.vue +350 -0
- package/packages/BaseToolStatus/index.js +8 -0
- package/packages/BaseToolStatus/src/index.vue +384 -0
- package/packages/index.js +138 -0
- package/packages/styles/default.less +79 -0
- package/packages/utils/api.js +35 -0
- package/packages/utils/auth.js +38 -0
- package/packages/utils/common.js +259 -0
- package/packages/utils/dom.js +181 -0
- package/packages/utils/enum.js +81 -0
- package/packages/utils/filters.js +459 -0
- package/packages/utils/msg.js +17 -0
- package/packages/utils/patchFiles.js +45 -0
- package/packages/utils/request.js +80 -0
- package/packages/utils/store.js +117 -0
|
@@ -0,0 +1,459 @@
|
|
|
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
|
+
|
|
457
|
+
}
|
|
458
|
+
return displayValue
|
|
459
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {notification,Modal } from 'ant-design-vue'
|
|
2
|
+
export function successMsg(msg, desc){
|
|
3
|
+
notification['success']({ message: msg, description: desc })
|
|
4
|
+
}
|
|
5
|
+
export function warningMsg(msg, desc){
|
|
6
|
+
notification['warning']({ message: msg, description: desc })
|
|
7
|
+
}
|
|
8
|
+
export function errorMsg(msg, desc){
|
|
9
|
+
notification['error']({ message: msg, description: desc })
|
|
10
|
+
}
|
|
11
|
+
export function infoMsg(dataInfo){
|
|
12
|
+
notification['info'](dataInfo)
|
|
13
|
+
}
|
|
14
|
+
export function closeMsg(key){
|
|
15
|
+
notification.close(key)
|
|
16
|
+
}
|
|
17
|
+
export const confirmMsg = Modal.confirm
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const chalk = require('chalk')
|
|
5
|
+
|
|
6
|
+
// 解决 node_modules 修改源码,导致重新装包而要手动替换源码的重复操作。
|
|
7
|
+
// 将 new_node_modules 内的文件 覆盖 真正的 node_modules
|
|
8
|
+
|
|
9
|
+
const REAL_NODE_MODULES = path.resolve('./node_modules') // 旧node_modules
|
|
10
|
+
|
|
11
|
+
const MY_NODE_MODULES = path.resolve('new_node_modules') // 新node_modules
|
|
12
|
+
|
|
13
|
+
copy(MY_NODE_MODULES, REAL_NODE_MODULES)
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
|
|
17
|
+
*复制目录中的所有文件包括子目录
|
|
18
|
+
*@param{string}需要复制的目录、文件
|
|
19
|
+
*@param{string}复制到指定的目录、文件
|
|
20
|
+
*@param{function}每次复制前,都会经过一次filterFn,若返回true,则复制。
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function copy(origin, target, filterFn = () => true) {
|
|
25
|
+
if (fs.statSync(origin).isDirectory()) {
|
|
26
|
+
// 来源是个文件夹,那目标也整一个文件夹
|
|
27
|
+
|
|
28
|
+
if (!fs.existsSync(target)) {
|
|
29
|
+
fs.mkdirSync(target)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fs.readdirSync(origin).forEach(originName => {
|
|
33
|
+
const originFilePath = path.resolve(origin, originName)
|
|
34
|
+
|
|
35
|
+
const targetFilePath = path.resolve(target, originName)
|
|
36
|
+
|
|
37
|
+
copy(originFilePath, targetFilePath, filterFn)
|
|
38
|
+
})
|
|
39
|
+
} else if (filterFn(origin, target)) {
|
|
40
|
+
console.info(chalk.blue('已被覆盖的文件:', target))
|
|
41
|
+
fs.copyFileSync(origin, target)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.info(chalk.bold.yellow('💡💡💡 以上的文件已被rewrite_node_modules中的文件替换,升级版本后请注意检查!!!'))
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
import { notification } from 'ant-design-vue'
|
|
3
|
+
import Vue from 'vue'
|
|
4
|
+
import store from './store'
|
|
5
|
+
import moment from 'moment'
|
|
6
|
+
// create an axios instance
|
|
7
|
+
const service = axios.create({
|
|
8
|
+
// baseURL: process.env.BASE_API, // api的base_url
|
|
9
|
+
timeout: 1000 * 60 * 5 // request timeout
|
|
10
|
+
})
|
|
11
|
+
// request interceptor
|
|
12
|
+
service.interceptors.request.use(
|
|
13
|
+
config => {
|
|
14
|
+
// Do something before request is sent
|
|
15
|
+
let tempToken = store.state.token
|
|
16
|
+
if (tempToken) {
|
|
17
|
+
config.headers.Authorization = `Bearer ${tempToken}`
|
|
18
|
+
}
|
|
19
|
+
// config.headers.Accept = 'application/json,Date, text/plain, */*'
|
|
20
|
+
return config
|
|
21
|
+
},
|
|
22
|
+
error => {
|
|
23
|
+
// Do something with request error
|
|
24
|
+
Promise.reject(error)
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
// respone interceptor
|
|
29
|
+
service.interceptors.response.use(
|
|
30
|
+
response => {
|
|
31
|
+
// store.dispatch(
|
|
32
|
+
// "setLastRequireTime",
|
|
33
|
+
// moment().format("YYYY-MM-DD HH:mm:ss")
|
|
34
|
+
// );
|
|
35
|
+
|
|
36
|
+
const res = response.data
|
|
37
|
+
if (res.status === 200 || res.code === 200) {
|
|
38
|
+
return response.data
|
|
39
|
+
}
|
|
40
|
+
if (res.status === undefined && res.code === undefined) {
|
|
41
|
+
return response.data
|
|
42
|
+
}
|
|
43
|
+
if (res.code === 401) {
|
|
44
|
+
store.dispatch('logOut')
|
|
45
|
+
return Promise.reject(res.msg)
|
|
46
|
+
}
|
|
47
|
+
notification.error({
|
|
48
|
+
message: '错误信息',
|
|
49
|
+
description: h => {
|
|
50
|
+
return h('div', null, [
|
|
51
|
+
h('p', { domProps: { innerHTML: res.msg } }, null)
|
|
52
|
+
])
|
|
53
|
+
}
|
|
54
|
+
// description:parseContent.content
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// notification['error']({ message: '错误信息', description: res.msg })
|
|
58
|
+
return Promise.reject(res.msg)
|
|
59
|
+
},
|
|
60
|
+
error => {
|
|
61
|
+
if (error.response && error.response.status === 401) {
|
|
62
|
+
store.dispatch('logOut').then(() => {})
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
let errorMsg = ''
|
|
66
|
+
if (error.response && error.response.data && error.response.data.error) {
|
|
67
|
+
if (error.response.data.error_description) {
|
|
68
|
+
errorMsg = error.response.data.error_description
|
|
69
|
+
} else {
|
|
70
|
+
errorMsg = error.response.data.error
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
errorMsg = error.msg
|
|
74
|
+
}
|
|
75
|
+
notification['error']({ message: '错误信息', description: errorMsg })
|
|
76
|
+
return Promise.reject(error)
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
export default service
|