fliter.js
1.17 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import Vue from "vue";
//定义key-value过滤方法
function createFilter(filterName, dataArray) {
return Vue.filter(filterName, function(val) {
let label = "";
let arr = dataArray;
arr.forEach((item) => {
if (item.value == val) {
return (label = item.label);
}
});
return label;
});
}
//时间格式过滤
Vue.filter("timeFilter", function(timeStr) {
if (timeStr) {
return timeStr.substring(0, 10);
}
});
//数据类型过滤
let bdcLxArray = [
{
label: "宗地",
value: "zd",
},
{
label: "自然幢",
value: "zrz",
},
{
label: "户(预测)",
value: "h0",
},
{
label: "户(实测)",
value: "h1",
},
{
label: "户",
value: "h",
},
{
label: "多幢",
value: "dz",
},
{
label: "构筑物",
value: "gzw",
},
{
label: "逻辑幢",
value: "ljz",
},
{
label: "幢单元",
value: "zdy",
},
];
createFilter("bdcLxFilter", bdcLxArray);
//流程的环节状态过滤
let hjztArray = [
{
label: "未激活",
value: "1",
},
{
label: "激活",
value: "2",
},
{
label: "挂起",
value: "3",
},
{
label: "完成",
value: "4",
},
{
label: "终止",
value: "5",
},
];
createFilter("hjztFilter", hjztArray);