1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// 数字展示成金额
export function moneyFormat(value, precision = 2) {
//0
let num = value
if (num == 0) {
return num.toLocaleString();
}
if (num) {
num = typeof num == 'string' ? parseFloat(num) : num
num = num.toFixed(precision);
num = parseFloat(num);
num = num.toLocaleString();
return num;
} else {
return num = null;
}
}
export function dateFormatFunc(date) {
if (date != null) {
const pattern = /(\d{4})(\d{2})(\d{2})/
let formatedDate = date.replace(pattern, '$1-$2-$3')
return formatedDate
}
}
export function datetimeFormat(datetime) {
//replace方法需要datetime判空 否则前端error 无法展示查询出的数据
if (datetime != null) {
const pattern = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/
let formatedDatetime = datetime.replace(pattern, '$1-$2-$3 $4:$5:$6')
return formatedDatetime
}
}
export function monthFormat(month) {
if (month != null) {
const pattern = /(\d{4})(\d{2})/
return month.replace(pattern, '$1-$2')
}
}
export function bopcurFormatFunc(value, config) {
var obj = {};
obj = config.find(function (item) {
return item.value === value;
});
if (obj != undefined) {
return obj.label;
} else {
return "";
}
}
export function instFormat(value, config) {
var obj = {};
obj = config.find(function (item) {
return item.instCode === value;
});
if (obj != undefined) {
return obj.instName;
} else {
return "";
}
}