fliter.js
818 Bytes
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
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",
},
];
createFilter("bdcLxFilter", bdcLxArray);