数据
const setQa = [{
"color": "#d62036",
"name": "疑似点状出血",
"zone": {
"L": {
"macular": {
"num": 1,
"area": "0.008",
"zoneName": "黄斑区"
},
"disc": {
"num": -1,
"area": "0.009",
"zoneName": "视盘区"
},
"other": {
"num": 0,
"area": "0",
"zoneName": "后极部视网膜区"
}
},
"R": {
"macular": {
"zoneName": "黄斑区",
"num": 0,
"area": 0
},
"disc": {
"zoneName": "视盘区",
"num": 0,
"area": 0
},
"other": {
"zoneName": "后极部视网膜区",
"num": 0,
"area": 0
}
}
}
}, {
"color": "#9013fe",
"name": "疑似片状出血",
"zone": {
"L": {
"macular": {
"zoneName": "黄斑区",
"num": 0,
"area": 0
},
"disc": {
"zoneName": "视盘区",
"num": 0,
"area": 0
},
"other": {
"zoneName": "后极部视网膜区",
"num": 0,
"area": 0
}
},
"R": {
"macular": {
"zoneName": "黄斑区",
"num": 0,
"area": 0
},
"disc": {
"zoneName": "视盘区",
"num": 0,
"area": 0
},
"other": {
"zoneName": "后极部视网膜区",
"num": 0,
"area": 0
}
}
}
}, {
"color": "#f8e829",
"name": "疑似硬渗或玻璃膜疣",
"zone": {
"L": {
"macular": {
"zoneName": "黄斑区",
"num": 0,
"area": 0
},
"disc": {
"zoneName": "视盘区",
"num": 0,
"area": 0
},
"other": {
"zoneName": "后极部视网膜区",
"num": 0,
"area": 0
}
},
"R": {
"macular": {
"zoneName": "黄斑区",
"num": 0,
"area": 0
},
"disc": {
"zoneName": "视盘区",
"num": 0,
"area": 0
},
"other": {
"zoneName": "后极部视网膜区",
"num": 0,
"area": 0
}
}
}
}, {
"color": "#f5a623",
"name": "疑似软渗或玻璃膜疣",
"zone": {
"L": {
"macular": {
"zoneName": "黄斑区",
"num": 0,
"area": 0
},
"disc": {
"zoneName": "视盘区",
"num": 0,
"area": 0
},
"other": {
"zoneName": "后极部视网膜区",
"num": 0,
"area": 0
}
},
"R": {
"macular": {
"zoneName": "黄斑区",
"num": 0,
"area": 0
},
"disc": {
"zoneName": "视盘区",
"num": 0,
"area": 0
},
"other": {
"zoneName": "后极部视网膜区",
"num": 0,
"area": 0
}
}
}
}, {
"color": "#00f",
"name": "疑似其他异常",
"zone": {
"L": {
"macular": {
"zoneName": "黄斑区",
"num": 0,
"area": 0
},
"disc": {
"zoneName": "视盘区",
"num": 0,
"area": 0
},
"other": {
"zoneName": "后极部视网膜区",
"num": 0,
"area": 0
}
},
"R": {
"macular": {
"num": 0,
"area": "0",
"zoneName": "黄斑区"
},
"disc": {
"num": 0,
"area": "0",
"zoneName": "视盘区"
},
"other": {
"num": 2,
"area": "0.016",
"zoneName": "后极部视网膜区"
}
}
}
}]
封装的函数方法
// 限制值只能是正整数
check_num: function () {
this.flg = true;
this.setQa.forEach((item) => {
let obj1 = item.zone;
for (const key in obj1) {
if (Object.hasOwnProperty.call(obj1, key)) {
for (const mkey in obj1[key]) {
if (Object.hasOwnProperty.call(obj1[key], mkey)) {
if (obj1[key][mkey].num < 0) {
this.flg = false;
}
}
}
}
}
});
},
必须满足所有的数据都是正整数,否则就返回false