代码调整&socket重连前进行初始化
This commit is contained in:
parent
d313348a41
commit
e561f77c12
@ -21,9 +21,9 @@ class TransformHandle {
|
||||
view.show();
|
||||
} else {
|
||||
view.hide();
|
||||
}
|
||||
}
|
||||
|
||||
view.dirty();
|
||||
view.dirty();
|
||||
}
|
||||
|
||||
// 视图进行缩放/平移
|
||||
|
@ -59,3 +59,26 @@ export function formatDuring(mss) {
|
||||
export function prefixIntrger(num, length) {
|
||||
return (Array(length).join('0') + num).slice(-length);
|
||||
}
|
||||
/** 根据秒计算时间hh:mm:ss */
|
||||
export function computationTime(time) {
|
||||
let hours = Math.floor(time / 3600);
|
||||
const newTime = time % 3600;
|
||||
let minutes = Math.floor(newTime / 60) + '';
|
||||
let seconds = newTime % 60;
|
||||
if (hours < 0) {
|
||||
hours = '00';
|
||||
} else if (hours < 10) {
|
||||
hours = '0' + hours;
|
||||
}
|
||||
if (minutes < 0) {
|
||||
minutes = '00';
|
||||
} else if (minutes < 10) {
|
||||
minutes = '0' + minutes;
|
||||
}
|
||||
if (seconds < 0) {
|
||||
seconds = '00';
|
||||
} else if (seconds < 10) {
|
||||
seconds = '0' + seconds;
|
||||
}
|
||||
return hours + ':' + minutes + ':' + seconds;
|
||||
}
|
||||
|
@ -47,11 +47,13 @@ StompClient.prototype = {
|
||||
that.subscribeMap.forEach((subscribe) => {
|
||||
that.subscribe(subscribe.dest, subscribe.handler);
|
||||
});
|
||||
}, ()=> {
|
||||
}, (e)=> {
|
||||
console.log('socket连接错误:' + e);
|
||||
this.status = false;
|
||||
});
|
||||
// sock断开回调
|
||||
that.clientIns.ws.onclose = () => {
|
||||
that.status = false;
|
||||
console.info(`通信连接已断开!`);
|
||||
checkLoginLine().then((resp) => {
|
||||
if (resp.code == 200) {
|
||||
@ -83,6 +85,14 @@ StompClient.prototype = {
|
||||
console.info(`尝试第${count || 1}次连接.`);
|
||||
// Message.warning(`正在尝试第${count || 1}次通讯连接。`);
|
||||
const that = this;
|
||||
if (this.clientIns) { // 初始化stomp和websocket
|
||||
if (this.clientIns.connected) {
|
||||
this.clientIns.disconnect();
|
||||
}
|
||||
this.websocket.close();
|
||||
this.websocket = null;
|
||||
this.clientIns = null;
|
||||
}
|
||||
setTimeout(() => {
|
||||
that.connect();
|
||||
}, reconnectInterval[that.count] || reconnectInterval[reconnectInterval.length - 1] );
|
||||
|
@ -30,6 +30,7 @@
|
||||
import Question from './question';
|
||||
import localStore from 'storejs';
|
||||
import { postCompetitionTheory, getTheoryQuestion, quitCurrentRace } from '@/api/competition';
|
||||
import { computationTime } from '@/utils/date';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -125,7 +126,7 @@ export default {
|
||||
const storeValue = new Date().getTime();
|
||||
localStore.set(storeKey, storeValue);
|
||||
}
|
||||
this.countdownTime = this.computationTime(this.theoryExamTime);
|
||||
this.countdownTime = computationTime(this.theoryExamTime);
|
||||
|
||||
this.countdown = setInterval(() => {
|
||||
if (this.theoryExamTime <= 0) {
|
||||
@ -135,7 +136,7 @@ export default {
|
||||
this.commit();
|
||||
}
|
||||
this.theoryExamTime--;
|
||||
this.countdownTime = this.computationTime(this.theoryExamTime);
|
||||
this.countdownTime = computationTime(this.theoryExamTime);
|
||||
}, 1000);
|
||||
}
|
||||
}).catch(error => { this.$message.error(`加载考试详情失败:${error.message}`); });
|
||||
@ -199,28 +200,6 @@ export default {
|
||||
const storeKey = this.$store.state.user.id + '' + this.$route.query.raceId + 'theoryAnswers';
|
||||
localStore.set(storeKey, this.theoryAnswersMap);
|
||||
|
||||
},
|
||||
computationTime(time) {
|
||||
let hours = Math.floor(time / 3600);
|
||||
const newTime = time % 3600;
|
||||
let minutes = Math.floor(newTime / 60) + '';
|
||||
let seconds = newTime % 60;
|
||||
if (hours < 0) {
|
||||
hours = '00';
|
||||
} else if (hours < 10) {
|
||||
hours = '0' + hours;
|
||||
}
|
||||
if (minutes < 0) {
|
||||
minutes = '00';
|
||||
} else if (minutes < 10) {
|
||||
minutes = '0' + minutes;
|
||||
}
|
||||
if (seconds < 0) {
|
||||
seconds = '00';
|
||||
} else if (seconds < 10) {
|
||||
seconds = '0' + seconds;
|
||||
}
|
||||
return hours + ':' + minutes + ':' + seconds;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -85,6 +85,7 @@ import Vue from 'vue';
|
||||
import localStore from 'storejs';
|
||||
import MembersManage from './memberManage/membersManage';
|
||||
import AddMember from './memberManage/addMember';
|
||||
import { computationTime } from '@/utils/date';
|
||||
|
||||
export default {
|
||||
name: 'JointTrainingDraft',
|
||||
@ -389,11 +390,12 @@ export default {
|
||||
this.deviceShow = false;
|
||||
}
|
||||
},
|
||||
/* 设置仿真初始时间以及运行状态 */
|
||||
async loadSimulationInfo() {
|
||||
const resp = await getSimulationInfoNew(this.group);
|
||||
debugger;
|
||||
if (resp && resp.code == 200 && resp.data && !resp.data.dataError) {
|
||||
this.$store.dispatch('scriptRecord/updateSimulationPause', resp.data.pause);
|
||||
this.questId = Number(resp.data.questId) || 0;
|
||||
this.$store.dispatch('training/setInitTime', +new Date(`${new Date().toLocaleDateString()} ${timeFormat(resp.data.systemTime)}`));
|
||||
this.$store.dispatch('map/setRunPlanStatus', resp.data.planRunning);
|
||||
if (resp.data.planRunning) {
|
||||
@ -406,6 +408,7 @@ export default {
|
||||
this.$messageBox('此地图数据正在维护中,无法运行!');
|
||||
}
|
||||
},
|
||||
/* 获取个人仿真信息*/
|
||||
async getUserRole() {
|
||||
const res = await getSimulationUserInfo(this.group);
|
||||
const data = res.data || {};
|
||||
@ -446,7 +449,7 @@ export default {
|
||||
} else {
|
||||
this.practicalTime = this.practicalExamTime * 60;
|
||||
}
|
||||
this.countdownTime = this.computationTime(this.practicalTime);
|
||||
this.countdownTime = computationTime(this.practicalTime);
|
||||
paperResp.data.practicalQuestions.forEach(elem => {
|
||||
this.questionList.push({name: elem.question.name, description:elem.question.description});
|
||||
});
|
||||
@ -469,7 +472,6 @@ export default {
|
||||
setSimulationPrdType(swch) {
|
||||
// Admin 管理员 Dispatcher 行调 STATION_SUPERVISOR 车站 Audience 观众 Driver 司机 MAINTAINER 通号 IBP:IBP盘
|
||||
switch (this.userRole) {
|
||||
// case 'ADMIN': this.$store.dispatch('training/setPrdType', '02'); this.$store.dispatch('training/setRoles', 'ADMIN'); this.hideIbp(); break;
|
||||
case 'DISPATCHER':
|
||||
this.$store.dispatch('training/setPrdType', '02');
|
||||
this.$store.dispatch('training/setRoles', 'DISPATCHER');
|
||||
@ -499,6 +501,7 @@ export default {
|
||||
break;
|
||||
}
|
||||
},
|
||||
/* 竞赛系统倒计时 */
|
||||
startCounting() {
|
||||
const storeKey = this.$store.state.user.id + '' + this.$route.query.raceId + 'practical';
|
||||
const startTime = localStore.get(storeKey);
|
||||
@ -514,7 +517,7 @@ export default {
|
||||
this.$refs.demonMenu.submit();
|
||||
}
|
||||
this.practicalTime--;
|
||||
this.countdownTime = this.computationTime(this.practicalTime);
|
||||
this.countdownTime = computationTime(this.practicalTime);
|
||||
}, 1000);
|
||||
},
|
||||
async getTrainDetail() {
|
||||
@ -541,28 +544,6 @@ export default {
|
||||
faultChooseShow() { // 故障列表加载
|
||||
this.$refs.faultChoose.doShow();
|
||||
},
|
||||
computationTime(time) {
|
||||
let hours = Math.floor(time / 3600);
|
||||
const newTime = time % 3600;
|
||||
let minutes = Math.floor(newTime / 60) + '';
|
||||
let seconds = newTime % 60;
|
||||
if (hours < 0) {
|
||||
hours = '00';
|
||||
} else if (hours < 10) {
|
||||
hours = '0' + hours;
|
||||
}
|
||||
if (minutes < 0) {
|
||||
minutes = '00';
|
||||
} else if (minutes < 10) {
|
||||
minutes = '0' + minutes;
|
||||
}
|
||||
if (seconds < 0) {
|
||||
seconds = '00';
|
||||
} else if (seconds < 10) {
|
||||
seconds = '0' + seconds;
|
||||
}
|
||||
return hours + ':' + minutes + ':' + seconds;
|
||||
},
|
||||
showdriving() {
|
||||
this.panelShow = true;
|
||||
this.drivingShow = false;
|
||||
|
@ -32,7 +32,6 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import { OperateMode } from '@/scripts/ConstDic';
|
||||
// import { getStationList } from '@/api/runplan';
|
||||
import { getByGroupStationList } from '@/api/jmap/map';
|
||||
import { getEveryDayRunPlanNew } from '@/api/simulation';
|
||||
|
||||
@ -92,12 +91,6 @@ export default {
|
||||
chiShowStation: '',
|
||||
kmRangeCoordMap: {},
|
||||
runPlanData: {},
|
||||
swch: '02',
|
||||
swchList: [
|
||||
{ value: '01', name: this.$t('joinTraining.local') },
|
||||
{ value: '02', name: this.$t('joinTraining.lineAdjustment') },
|
||||
{ value: '07', name: '大屏'}
|
||||
],
|
||||
runing: false,
|
||||
userId: ''
|
||||
};
|
||||
|
@ -8,7 +8,6 @@
|
||||
import MapCommon from './common/index';
|
||||
import { getToken } from '@/utils/auth';
|
||||
import { creatSubscribe, clearSubscribe, displayTopic} from '@/utils/stomp';
|
||||
import { getSessionStorage } from '@/utils/auth';
|
||||
|
||||
export default {
|
||||
name: 'MapSystemDraft',
|
||||
@ -21,7 +20,6 @@ export default {
|
||||
stomp: null,
|
||||
currentMap: null,
|
||||
mode: '',
|
||||
isDesignPlatform: false,
|
||||
group: ''
|
||||
};
|
||||
},
|
||||
@ -44,11 +42,6 @@ export default {
|
||||
this.simulationError(val);
|
||||
}
|
||||
}
|
||||
// '$store.state.socket.simulationReset': function (val) {
|
||||
// if (val) {
|
||||
// this.simulationReset(val);
|
||||
// }
|
||||
// }
|
||||
},
|
||||
mounted() {
|
||||
window.onbeforeunload = this.clearSubscribe;
|
||||
@ -60,7 +53,6 @@ export default {
|
||||
this.$store.dispatch('config/resetCanvasOffset');
|
||||
}, 100);
|
||||
});
|
||||
this.isDesignPlatform = getSessionStorage('project').startsWith('design');
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.clearSubscribe();
|
||||
@ -91,14 +83,6 @@ export default {
|
||||
}).catch(() => {
|
||||
});
|
||||
},
|
||||
// async simulationReset() {
|
||||
// await this.$store.dispatch('map/clearJlmapTrainView');
|
||||
// await this.$store.dispatch('map/setTrainWindowShow', false);
|
||||
// await this.$store.dispatch('training/over');
|
||||
// await this.$store.dispatch('socket/setSimulationReset'); // 清空
|
||||
// await this.$store.dispatch('socket/setSimulationStart');
|
||||
// await this.$store.dispatch('training/setMapDefaultState');
|
||||
// },
|
||||
async subscribe() {
|
||||
this.clearSubscribe();
|
||||
const header = { group: this.group || '', 'X-Token': getToken() };
|
||||
|
Loading…
Reference in New Issue
Block a user