javascript
angularJS求助
找大佬求解angular,下面兩個加粗的方法,執行結果是:外層遍歷完畢,才依次執行另一個方法,并且后執行的方法中,對顏色的修改代碼不生效,在外層方法里,內層方法外修改顏色代碼是生效的,如何讓代碼生效或者順序執行?(省略部分無關代碼)
getDevListCom(): void {
this.DevStatusdata = [];
this.devMonitorService.getDevList(this.reqdevlistdata)
.subscribe(_data => {
this.DevStatusdata = _data.data.monitorInfo.devMonitorGroups[0].devList;
this.Ex_totalCount = _data.data.monitorInfo.devMonitorGroups[0].totalCount;
this.Ex_serviceCount = _data.data.monitorInfo.devMonitorGroups[0].serviceCount;
this.Ex_unserviceCount = _data.data.monitorInfo.devMonitorGroups[0].totalCount -
_data.data.monitorInfo.devMonitorGroups[0].serviceCount;
this.page.totalRow = _data.page.totalPage;
this.loading = false;
this.DevStatusdata.forEach(data1 => {
if (data1.devRunStatus == ‘正常’) {
data1.color = ‘dodgerblue’;
} else if (data1.devRunStatus == ‘部分服務’) {
data1.color = ‘#dd3b26’;
} else {
data1.color = ‘gray’;
}
});
//console.log(this.DevStatusdata);
this.runimg_Array = [];
this.DevStatusdata.forEach(data1 => {
if (data1.devRunStatus === ‘正常’) {
this.runimg_Array.push(‘assets/images/operate/allnormal.png’);
} else if (data1.devRunStatus === ‘停止服務’) {
this.runimg_Array.push(‘assets/images/operate/stopservice.png’);
} else if (data1.devRunStatus === ‘部分服務’) {
this.runimg_Array.push(‘assets/images/operate/Partynormal.png’);
} else if (data1.devRunStatus === ‘P通訊故障’) {
this.runimg_Array.push(‘assets/images/operate/communicationfail.png’);
} else if (data1.devRunStatus === ‘維護’) {
this.runimg_Array.push(‘assets/images/operate/maintain.png’);
} else if (data1.devRunStatus === ‘關機’) {
this.runimg_Array.push(‘assets/images/operate/shutdown.png’);
} else if (data1.devRunStatus === ‘停用’) {
this.runimg_Array.push(‘assets/images/operate/outofservice.png’);
} else if (data1.devRunStatus === ‘疑似死機’) {
this.runimg_Array.push(‘assets/images/operate/crash.png’);
} else {
this.runimg_Array.push(‘assets/images/operate/unknownstatus.png’);
}
});
this.modimg_Array = [];
this.DevStatusdata.forEach(data1 => {
if (data1.devModStatus === ‘正常’) {
this.modimg_Array.push(‘assets/images/operate/modnormal.png’);
} else if (data1.devModStatus === ‘故障’) {
this.modimg_Array.push(‘assets/images/operate/modfault.png’);
} else if (data1.devModStatus === ‘警告’) {
this.modimg_Array.push(‘assets/images/operate/modwarning.png’);
} else {
this.modimg_Array.push(‘assets/images/operate/modunknown.png’);
}
});
this.cashimg_Array = [];
this.DevStatusdata.forEach(data1 => {
if (data1.devCashStatus === ‘正常’) {
this.cashimg_Array.push(‘assets/images/operate/cashnormal.png’);
} else if (data1.devCashStatus === ‘缺鈔’) {
this.cashimg_Array.push(‘assets/images/operate/lackofcash.png’);
} else if (data1.devCashStatus === ‘滿鈔’) {
this.cashimg_Array.push(‘assets/images/operate/fullofcash.png’);
} else if (data1.devCashStatus === ‘不足’) {
this.cashimg_Array.push(‘assets/images/operate/nullofcash.png’);
} else {
this.cashimg_Array.push(‘assets/images/operate/unknownofcash.png’);
}
});
this.cardimg_Array = [];this.DevStatusdata.forEach(data1 => {
if (data1.devCardStatus === ‘正常’) {
this.cardimg_Array.push(‘assets/images/operate/cardok.png’);
} else if (data1.devCardStatus === ‘卡少’) {
this.cardimg_Array.push(‘assets/images/operate/cardlow.png’);
} else if (data1.devCardStatus === ‘卡空’) {
this.cardimg_Array.push(‘assets/images/operate/cardempty.png’);
} else {
this.cardimg_Array.push(‘assets/images/operate/cardunknown.png’);
}
});
this.netimg_Array = [];
this.DevStatusdata.forEach(data1 => {
if (data1.devNetStatus === ‘正常’) {
this.netimg_Array.push(‘assets/images/operate/normalnetwork.png’);
} else if (data1.devNetStatus === ‘故障’) {
this.netimg_Array.push(‘assets/images/operate/networkfailure.png’);
data1.color = ‘red’; // 添加內容******************************************************* //
} else {
this.netimg_Array.push(‘assets/images/operate/unknownnetwork.png’);
}
});
this.infoList4matrix = [];
const j = parseInt(this.Ex_totalCount, 10);
//console.log(this.DevStatusdata);
for (let i = 0; i < j; i++) {
if (this.DevStatusdata[i] != undefined) {
const params = {
devNo: this.DevStatusdata[i].no,
};
//console.log(params);
//console.log(this.DevStatusdata);
this.DevStatusdata.forEach(data1 => {
console.log(data1.no)
let f1 = 0;
if(data1.no == this.DevStatusdata[i].no){
console.log(“進入了該方法”)
this.devMonitorService.getDevStatus(params).subscribe(_data =>{
const tmpList = [];
if (_data) {
const temp = _data.data.devStatusInfo.idcCaptureBinCount;
if ( temp == null || temp == ‘’) {
this.idcCaptureBinCount = ‘0’;
} else {
this.idcCaptureBinCount = temp;
}
let tmp = _data.data.devStatusInfo.idcDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘idc’)});
}
tmp = _data.data.devStatusInfo.pinDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘pin’)});
}
tmp = _data.data.devStatusInfo.siuDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘siu’)});
}
tmp = _data.data.devStatusInfo.cimDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘cim’)});
}
tmp = _data.data.devStatusInfo.cdmDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘cdm’)});
}
tmp = _data.data.devStatusInfo.crdDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘crd’)});
}
tmp = _data.data.devStatusInfo.rprDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘rpr’)});
}
tmp = _data.data.devStatusInfo.jprDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘jpr’)});
}
tmp = _data.data.devStatusInfo.depDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘dep’)});
}
tmp = _data.data.devStatusInfo.pbkDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘pbk’)});
}
tmp = _data.data.devStatusInfo.ircDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘irc’)});
}
tmp = _data.data.devStatusInfo.sprDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘spr’)});
}
tmp = _data.data.devStatusInfo.fpiDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘fpi’)});
}
tmp = _data.data.devStatusInfo.iccDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘icc’)});
}
tmp = _data.data.devStatusInfo.camDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘cam’)});
}
tmp = _data.data.devStatusInfo.dprDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘dpr’)});
}
tmp = _data.data.devStatusInfo.upsDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘ups’)});
}
tmp = _data.data.devStatusInfo.chkDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘chk’)});
}
tmp = _data.data.devStatusInfo.ttuDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘ttu’)});
}
tmp = _data.data.devStatusInfo.bcrDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘bcr’)});
}
tmp = _data.data.devStatusInfo.iscDeviceStatus;
if (tmp && tmp != ‘’ && tmp != ‘NO’) {
tmpList.push({status: tmp, name: this.devMonitorService.convert(‘isc’)});
}
}
if (tmpList.length > 0){
for (let i = 0;i < tmpList.length ; i++){
if (‘密碼鍵盤模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status){
data1.color = ‘red’;
console.log(“1”);
}
if (‘存款模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status) {
data1.color = ‘red’;
console.log(“2”);
}
if (‘取款模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status) {
f1 = 1;
//data1.color = ‘red’;
console.log(“3”);
}
if (‘讀卡器模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status) {
data1.color = ‘red’;
console.log(“4”);
}
if (‘憑條打印機模塊’ === tmpList[i].name && ‘故障’ === tmpList[i].status) {
data1.color = ‘yellow’;
console.log(“5”);
}
}
}
console.log(f1+"###")
});
}
});
}
}
}, (error) => {
if (error instanceof HttpResponse) {
this.message.error(error.body.retMsg);
}
});
}
總結
以上是生活随笔為你收集整理的angularJS求助的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数字化园区建设
- 下一篇: 重磅!骂了 10 年,微信这功能终于要来