很多判断进行嵌套,代码看上去很low

if (!this.hasConfigured) {
+
if (this.isKeySubmit) {
+
if (this.selfTransferDevice) {
+
let promise1 = this.putSelfTransDeviceConfig();
+
let promise2 = this.setHPCEvent();
+
Promise.all([promise1, promise2]).then(() => {
+
this.$message({
+
type: 'success',
+
message: i18n.t('hcp_system_save_success')
+
});
+
});
+
} else {
+
this.setHPCEvent().then(()=> {
+
this.$message({
+
type: 'success',
+
message: i18n.t('hcp_system_save_success')
+
});
+
});
+
}
+
}

1、是不是可以用&& 来进行及优化呢
2、使用 if (!this.hasXXX) {return} 的方式 使之形成不了嵌套
3、或者其他的替代方法 switch语句? 或者将条件维护成一个数组,进行数组查找来进行相应的提示
4、网上有很多方法,可以get一下这种小技巧