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
| /**
| * 验证设备类型
| *
| * @param {[String, Number]} dev_id 设备id
| * @param {[String,Array]} type 设备类型
| *
| * @return {[type]} 验证结果
| */
| function regEquipType(dev_id, type) {
| let patterns = {
| LD9: /^40190/,
| equip61850: /^61850/,
| BTS:/^(9100)|(9600)|(9616)/,
| BTSSreen: /^9611/,
| equip4016:/^4016/
| };
| let effectPtns = [];
| // 数据类型为字符串
| if(typeof type == 'string') {
| if(patterns[type]) {
| effectPtns.push(patterns[type]);
| }
| }else { // 为数组时
| type.forEach(item=>{
| if(patterns[item]) {
| effectPtns.push(patterns[item]);
| }
| });
| }
|
| let result = false; // 定义返回结果,默认为false
| // 遍历所有的形参
| for(let i=0; i<effectPtns.length;i++) {
| if(effectPtns[i].test(dev_id)) {
| result = true;
| break;
| }
| }
| return result;
| }
|
| export default regEquipType;
|
|