设备登录代码调整

This commit is contained in:
joylink_cuiweidong 2022-12-21 10:56:23 +08:00
parent c4d21c6e24
commit 2031f30666
2 changed files with 40 additions and 5 deletions

View File

@ -272,21 +272,32 @@ export default {
getLoginInfo(getToken()).then(resp => {
const deviceVO = resp.data.deviceVO;
if (deviceVO) {
const config = JSON.parse(deviceVO.config);
const config = JSON.parse(deviceVO.config || '{}');
if (config && config.roleCode) {
const params = [{userId: res.id, memberId:config.roleCode}];
assignUsersPlayRoles(params, group).then(() => {
this.enterSimulation(group, mapId, config);
}).catch(res=>{
this.$message.error('切换角色失败');
this.$store.dispatch('LogOut');
});
}
}
}).catch(res=>{
this.$message.error('获取用户信息失败');
this.$store.dispatch('LogOut');
});
}).catch(res=>{
this.$store.dispatch('LogOut');
});
} else {
this.$message.error('请先配置项目信息');
this.$store.dispatch('LogOut');
}
}
}).catch(res=>{
this.$message.error('获取项目信息失败');
this.$store.dispatch('LogOut');
});
},
enterSimulation(group, mapId, config) {
@ -317,6 +328,8 @@ export default {
// if (config.client) { query.client = config.client; }
}
this.$router.push({ path: `/display/demon`, query: query });
}).catch(res=>{
this.$store.dispatch('LogOut');
});
}
}

View File

@ -245,24 +245,35 @@ export default {
createSimulation(functionId).then(resp => {
const group = resp.data;
this.assignUser(group, mapId);
}).catch(error=>{
if (error.code == 10003) {
this.$messageBox(this.$t('error.createSimulationFailed') + ':您的仿真权限不足!');
this.$store.dispatch('LogOut').then(() => {
location.reload(); // vue-router bug
});
} else {
this.$messageBox(this.$t('error.createSimulationFailed') + error.message);
this.$store.dispatch('LogOut').then(() => {
location.reload(); // vue-router bug
});
}
});
} else {
getGroupByMapAndFunction(mapId, functionId).then(resp => {
const group = resp.data;
this.assignUser(group, mapId);
}).catch(res=>{
this.$store.dispatch('LogOut');
});
}
} else {
this.$message.error('请先配置项目信息');
this.$store.dispatch('LogOut');
}
}
}).catch(res=>{
this.$message.error('获取项目信息失败');
this.$store.dispatch('LogOut');
});
},
assignUser(group, mapId) {
@ -270,17 +281,25 @@ export default {
getLoginInfo(getToken()).then(resp => {
const deviceVO = resp.data.deviceVO;
if (deviceVO) {
const config = JSON.parse(deviceVO.config || {});
const config = JSON.parse(deviceVO.config || '{}');
if (config && config.roleCode) {
const params = [{userId: res.id, memberId:config.roleCode}];
assignUsersPlayRoles(params, group).then(() => {
this.enterSimulation(group, mapId, config);
}).catch(res=>{
this.$message.error('切换角色失败');
this.$store.dispatch('LogOut');
});
} else {
this.$message.error('请先配置设备相关信息');
this.$store.dispatch('LogOut');
}
} else {
this.enterSimulation(group, mapId);
}
}).catch(res=>{
this.$message.error('获取用户信息失败');
this.$store.dispatch('LogOut');
});
});
},
@ -301,6 +320,9 @@ export default {
// if (config.client) { query.client = config.client; }
}
this.$router.push({ path: `/display/demon`, query: query });
}).catch(res=>{
this.$message.error('进入仿真失败');
this.$store.dispatch('LogOut');
});
},
//