diff --git a/src/api/simulation.js b/src/api/simulation.js index 7cb030123..c8abdd7a5 100644 --- a/src/api/simulation.js +++ b/src/api/simulation.js @@ -544,3 +544,11 @@ export function createSimulation(id) { method: 'post' }); } + +/** 根据地图ID和功能ID获取仿真GroupId */ +export function getGroupByMapAndFunction(mapId, functionId) { + return request({ + url: `/simulation/new/map/${mapId}/function/${functionId}`, + method: 'get' + }); +} diff --git a/src/views/login/normalLogin.vue b/src/views/login/normalLogin.vue index 738e8d892..a6b9aedd6 100644 --- a/src/views/login/normalLogin.vue +++ b/src/views/login/normalLogin.vue @@ -82,7 +82,7 @@ import md5 from 'js-md5'; import Cookies from 'js-cookie'; // getLoginWmurl, checkLoginStatus, import { getOrgList, selectOrgnization } from '@/api/login'; -import { createSimulation, getSimulationInfoNew } from '@/api/simulation'; +import { createSimulation, getSimulationInfoNew, getGroupByMapAndFunction } from '@/api/simulation'; import { getBackProjectConfigByCode } from '@/api/projectConfig'; import { assignUsersPlayRoles } from '@/api/jointSimulation'; export default { @@ -144,7 +144,7 @@ export default { return this.$route.query.projectDevice; }, role() { - return this.$route.query.role; + return this.$route.query.roleCode; } }, watch: { @@ -180,7 +180,6 @@ export default { this.checkOrgnizationInfo(); }) .catch(error => { - debugger; console.log(error); // if (error.code === '30001') { // this.tipsMsg = this.$t('login.accountOrPasswordIsIncorrect'); @@ -244,22 +243,37 @@ export default { if (res.data) { const {mapId, functionId} = res.data; if (functionId && mapId) { - createSimulation(functionId).then(resp => { - const group = resp.data; - if (this.role) { - assignUsersPlayRoles(this.role, group).then(() => { + if (params.type == 'IM') { + createSimulation(functionId).then(resp => { + const group = resp.data; + if (this.role) { + const data = [{userId: this.$store.state.user.id, memberId:this.role}]; + assignUsersPlayRoles(data, group).then(() => { + this.enterSimulation(group, mapId); + }); + } else { this.enterSimulation(group, mapId); - }); - } else { - this.enterSimulation(group, mapId); - } - }).catch(error=>{ - if (error.code == 10003) { - this.$messageBox(this.$t('error.createSimulationFailed') + ':您的仿真权限不足!'); - } else { - this.$messageBox(this.$t('error.createSimulationFailed') + error.message); - } - }); + } + }).catch(error=>{ + if (error.code == 10003) { + this.$messageBox(this.$t('error.createSimulationFailed') + ':您的仿真权限不足!'); + } else { + this.$messageBox(this.$t('error.createSimulationFailed') + error.message); + } + }); + } else { + getGroupByMapAndFunction(mapId, functionId).then(resp => { + const group = resp.data; + if (this.role) { + const data = [{userId: this.$store.state.user.id, memberId:this.role}]; + assignUsersPlayRoles(data, group).then(() => { + this.enterSimulation(group, mapId); + }); + } else { + this.enterSimulation(group, mapId); + } + }); + } } else { this.$message.error('请先配置项目信息'); } diff --git a/src/views/system/deviceManage/index.vue b/src/views/system/deviceManage/index.vue index babd13998..9d8327e14 100644 --- a/src/views/system/deviceManage/index.vue +++ b/src/views/system/deviceManage/index.vue @@ -11,7 +11,7 @@