代码调整

This commit is contained in:
joylink_cuiweidong 2022-11-28 18:34:08 +08:00
parent fd99287e10
commit f4fb2d7cbf
3 changed files with 66 additions and 32 deletions

View File

@ -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'
});
}

View File

@ -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,10 +243,12 @@ export default {
if (res.data) {
const {mapId, functionId} = res.data;
if (functionId && mapId) {
if (params.type == 'IM') {
createSimulation(functionId).then(resp => {
const group = resp.data;
if (this.role) {
assignUsersPlayRoles(this.role, group).then(() => {
const data = [{userId: this.$store.state.user.id, memberId:this.role}];
assignUsersPlayRoles(data, group).then(() => {
this.enterSimulation(group, mapId);
});
} else {
@ -260,6 +261,19 @@ export default {
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('请先配置项目信息');
}

View File

@ -11,7 +11,7 @@
</template>
<script>
import { getProjectDeviceList, deleteProjectDevice } from '@/api/project';
import { getProjectDeviceList, deleteProjectDevice, getDeviceDetail } from '@/api/project';
import DeviceAdd from './add';
import EditConfigGateway from './editConfigGateway';
import EditConfig from './editConfig';
@ -203,8 +203,18 @@ export default {
this.queryList.reload();
},
getPath(index, row) {
getDeviceDetail(row.id).then(res=>{
if (res.data) {
let roleCode = '';
if (res.data.type == 'LW') {
const config = JSON.parse(res.data.config);
roleCode = config.roleCode;
}
let url = '';
url = `${window.location.protocol}//${window.location.host}/cbtc/login?project=${row.project.toLowerCase().replace(/_/, '')}&projectDevice=${row.code}&type=${row.type}`;
if (roleCode) {
url += '&roleCode=' + roleCode;
}
this.url = url;
this.$messageBox();
this.$confirm(`登录路径:${url}`, '登录路径', {
@ -218,6 +228,8 @@ export default {
this.$message.success('登录路径已经复制到粘贴板');
});
}
});
}
}
};
</script>