Compare commits

...

2 Commits

Author SHA1 Message Date
dong
63200d1a27 调整已加入仿真提示功能 2023-05-08 17:31:00 +08:00
dong
527d16a6df Squashed commit of the following:
commit 4af4e7ea9c440cdf1a7dba0f6ed6b4774910b2ee
Author: dong <58670809@qq.com>
Date:   Sat May 6 18:11:16 2023 +0800

    登录时判断用户已经加入的仿真
2023-05-08 15:43:16 +08:00
4 changed files with 91 additions and 12 deletions

View File

@ -101,7 +101,7 @@ export function getOrgList() {
return request({
url: '/api/orgProject/list',
method: 'get'
})
});
}
/**
@ -111,5 +111,15 @@ export function selectOrgnization(orgId) {
return request({
url: `/api/orgProject/signIn/${orgId}`,
method: 'put'
})
});
}
/**
* 获取用户已经加入的仿真
*/
export function getSimulationJoined() {
return request({
url: '/simulation/joined/by/me',
method: 'get'
});
}

View File

@ -111,11 +111,11 @@ export default {
this.$store.dispatch('trainingNew/clearStepOverCount');
this.$store.dispatch('trainingNew/trainingEnd');
this.$store.dispatch('trainingNew/changeTeachMode', '');
if (this.$store.state.training.simulationCreator) {
destroySimulationByAdmin(this.group);
} else {
exitSimulation(this.group);
}
// if (this.$store.state.training.simulationCreator) {
// destroySimulationByAdmin(this.group);
// } else {
// exitSimulation(this.group);
// }
this.$store.dispatch('socket/resetRailCtcRunplanInitMsg'); //
this.$store.dispatch('socket/clearDispatchCommandMsg'); //
this.$store.dispatch('map/setLinkSwitchMap', {});

View File

@ -32,7 +32,7 @@ import ExamPanel from '../exam/examPanel';
import getErrorTip from '@/scripts/errorTip';
import DeviceManage from './deviceManage';
import { SimulationUserType } from '@/scripts/ConstDic';
import { destroySimulationByAdmin, ranAsPlan} from '@/api/simulation';
import { destroySimulationByAdmin, exitSimulation, ranAsPlan} from '@/api/simulation';
import { EventBus } from '@/scripts/event-bus';
import SimulationControl from './simulationControl';
import SimulationId from '../simulationId';
@ -193,10 +193,15 @@ export default {
});
},
back() {
if (this.$store.state.training.simulationCreator) {
destroySimulationByAdmin(this.group);
} else {
exitSimulation(this.group);
}
if (this.projectDevice && this.$store.state.training.simulationCreator) {
destroySimulationByAdmin(this.group).then(() => {
this.logout();
});
// destroySimulationByAdmin(this.group).then(() => {
this.logout();
// });
} else if (this.$route.query.third) {
if (this.$route.query.project === 'cgy' || this.$route.query.project === 'drts') {
window.parent.postMessage('back', '*');

View File

@ -55,9 +55,10 @@ import { getMapIdPermisson } from '@/api/userRulesManage';
import { queryMapFunctionList } from '@/api/trainingPlatform';
import selectRole from './selectRole/list';
import { launchFullscreen } from '@/utils/screen';
import { createSimulation } from '@/api/simulation';
import { createSimulation, destroySimulationByAdmin, exitSimulation } from '@/api/simulation';
import { getSessionStorage } from '@/utils/auth';
import { jointSimulationByPermission } from '@/api/jointSimulation';
import { getSimulationJoined } from '@/api/login';
export default {
name: 'Simulation',
components: {
@ -233,10 +234,66 @@ export default {
}
},
mounted() {
this.getJoinedSimulation();
this.loadInitData();
this.initMapSystem();
},
methods: {
// 仿
getJoinedSimulation(system) {
return new Promise((resolve, reject) => {
getSimulationJoined().then(res => {
const data = res.data;
if (data) {
const h = this.$createElement;
const msgData = [h('p', null, '存在未完成的仿真:'), h('p', null, `线路:${data.map.name}`), h('p', null, `功能:${data.mapFunctionVO.name}`)];
this.$confirm('', '警告', {
message: h('div', null, msgData),
confirmButtonText: '继续仿真',
cancelButtonText: system ? '退出并新建仿真' : '退出仿真',
type: 'warning',
// showClose: false, // x
distinguishCancelAndClose: true, // closecancel
closeOnClickModal: false //
}).then(() => {
const path = '/display/demon';
const query = {
lineCode: data.map.lineCode,
group: data.group,
mapId: data.map.id,
simType: data.paramVO.type,
project: this.$route.query.project || 'login'
};
if (data.paramVO && data.paramVO.domConfig && data.paramVO.domConfig.client) {
query.client = data.paramVO.domConfig.client;
}
if (data.paramVO && data.paramVO.domConfig && data.paramVO.domConfig.singleClient) {
query.singleClient = data.paramVO.domConfig.singleClient;
}
if (this.loadingProjectList.includes(query.project)) {
this.$store.dispatch('app/transitionAnimations');
}
this.$router.push({ path, query });
launchFullscreen();
}).catch((e) => {
if (e == 'cancel') {
if (data.creator.id == this.$store.state.user.id) {
destroySimulationByAdmin(data.group);
} else {
exitSimulation(data.group);
}
if (system) {
this.createNewSimulation(system);
}
}
});
}
resolve(data);
}).catch(err => {
reject(err);
});
});
},
getAbilityList(list) {
const arr = [];
list && list.forEach(item => {
@ -284,6 +341,13 @@ export default {
}
},
enterSimulation(system) {
this.getJoinedSimulation(system).then(res => {
if (!res) {
this.createNewSimulation(system);
}
});
},
createNewSimulation(system) {
createSimulation(system.id).then(resp => {
const query = {
lineCode: this.$route.query.lineCode,