rt-sim-training-client/src/views/newMap/displayNew/index.vue

756 lines
26 KiB
Vue
Raw Normal View History

<template>
2020-06-12 16:12:33 +08:00
<!-- -->
<div class="main" :style="{width: canvasWidth+'px'}">
<div v-show="panelShow" :panelShow="panelShow">
<transition name="el-zoom-in-bottom">
<map-system-draft ref="mapCanvas" @back="back" />
</transition>
2020-05-22 18:41:23 +08:00
<status-icon v-if="$route.query.lineCode == '11' || $route.query.lineCode == '10'" ref="statusIcon" />
<menu-exam
v-if="isExam"
ref="menuExam"
:offset="offset"
2020-05-09 20:24:59 +08:00
:data-error="dataError"
:offset-bottom="offsetBottom"
:group="group"
:show-station="showStation"
:station-list="stationList"
:show-select-station="showSelectStation"
@switchStationMode="switchStationMode"
/>
<menu-lesson
v-if="isLesson"
ref="lessonMenu"
:offset="offset"
2020-05-09 20:24:59 +08:00
:data-error="dataError"
:offset-bottom="offsetBottom"
:tip-bottom="tipBottom"
:group="group"
:training-obj="trainingObj"
:show-station="showStation"
:station-list="stationList"
:show-select-station="showSelectStation"
@switchStationMode="switchStationMode"
/>
<menu-demon
v-if="isDemon"
ref="menuDemon"
:offset="offset"
2020-05-09 20:24:59 +08:00
:data-error="dataError"
2020-03-31 09:27:02 +08:00
:offset-bottom="offsetBottom"
:group="group"
:quest-id="questId"
2020-04-09 17:37:27 +08:00
:show-station="showStation"
2020-05-28 13:21:51 +08:00
:user-role="userRole"
@tryTime="tryTime"
@hidepanel="hidepanel"
2020-02-17 09:41:18 +08:00
@passflow="passflow"
@jl3dstation="jl3dstation"
@devicemodel="devicemodel"
@quitQuest="quitQuest"
@showScheduling="showScheduling"
/>
2020-06-19 18:58:55 +08:00
<menu-script v-if="isScript" ref="menuScript" :offset-bottom="offsetBottom" :group="group" :data-error="dataError" @script3ddriveshow="script3ddriveshow" />
<menu-practice
v-if="isPractice"
ref="menuPractice"
:group="group"
:offset="offset"
:offset-bottom="offsetBottom"
:show-station="showStation"
:station-list="stationList"
:show-select-station="showSelectStation"
:data-error="dataError"
@switchMode="switchMode"
@switchStationMode="switchStationMode"
/>
2020-04-01 12:53:58 +08:00
<menu-train-list v-if="isDemon" @setCenter="setCenter" />
<menu-schema
2020-01-06 14:43:08 +08:00
v-if="isDemon || isScript "
ref="menuSchema"
:offset="offset"
2020-05-09 20:24:59 +08:00
:data-error="dataError"
:offset-bottom="offsetBottom"
:group="group"
2020-03-25 15:22:52 +08:00
:show-station="showStation"
:station-list="stationList"
:show-select-station="showSelectStation"
@switchMode="switchMode"
@selectQuest="selectQuest"
2020-03-25 15:22:52 +08:00
@switchStationMode="switchStationMode"
/>
<menu-system-time ref="menuSystemTime" :offset="offset" :right="right" :group="group" />
</div>
<!-- <Jl3d-Simulation v-show="simulationShow" ref="Jl3dSimulation" :panel-show="simulationShow" @showpanel="showpanel" /> -->
2020-04-14 14:51:14 +08:00
<left-slider v-if="isShowLeftSlider" :offset-bottom="offsetBottom" @overallTranslation="overallTranslation" />
<Jl3d-Device
v-if="deviceShow"
ref="Jl3dDevice"
:panel-show="deviceShow"
@closedevice3dview="devicemodel"
/>
<Jl3d-Drive v-show="drivingShow" ref="Jl3dDrive" :panel-show="drivingShow" @showdriving="showdriving" />
<scheduling v-if="isShowScheduling" ref="scheduling" :group="group" />
</div>
</template>
<script>
import MapSystemDraft from '@/views/newMap/mapsystemNew/index';
2019-12-30 09:00:16 +08:00
import MenuExam from '@/views/newMap/displayNew/menuExam';
import MenuLesson from '@/views/newMap/displayNew/menuLesson';
import MenuDemon from '@/views/newMap/displayNew/menuDemon';
import MenuSchema from '@/views/newMap/displayNew/menuSchema';
import MenuSystemTime from '@/views/newMap/displayNew/menuSystemTime';
import MenuScript from '@/views/newMap/displayNew/menuScript';
import MenuPractice from '@/views/newMap/displayNew/menuPractice';
import Scheduling from './demon/scheduling';
import { mapGetters } from 'vuex';
2020-03-26 18:42:01 +08:00
import { getTrainingStepsDetailNew, getTrainingDetailNew } from '@/api/jmap/training';
import { setGoodsTryUse } from '@/api/management/goods';
2020-05-14 17:24:47 +08:00
import { clearSimulation, loadScriptNew, getSimulationInfoNew, scriptExecuteNew } from '@/api/simulation';
import { OperateMode, TrainingMode } from '@/scripts/ConstDic';
import { checkLoginLine } from '@/api/login';
2019-12-30 09:00:16 +08:00
import { loadNewMapDataByGroup } from '@/utils/loaddata';
import { EventBus } from '@/scripts/event-bus';
import Vue from 'vue';
2019-12-31 14:30:23 +08:00
import LeftSlider from '@/views/newMap/displayNew/LeftSlider';
2020-01-14 16:19:36 +08:00
import { getSessionStorage } from '@/utils/auth';
import MenuTrainList from '@/views/newMap/displayNew/menuTrainList';
2020-05-22 18:41:23 +08:00
import StatusIcon from '@/views/components/StatusIcon/statusIcon';
// 三维
// import Jl3dSimulation from '@/views/jlmap3d/simulation/jl3dsimulation';
import Jl3dDrive from '@/views/jlmap3d/drive/jl3ddrive';
import Jl3dDevice from '@/views/jlmap3d/device/jl3ddevice';
import { getToken } from '@/utils/auth';
2020-02-24 17:04:39 +08:00
import { timeFormat } from '@/utils/date';
export default {
name: 'DisplayDraft',
components: {
MenuExam,
MenuLesson,
MapSystemDraft,
MenuDemon,
MenuScript,
MenuSchema,
MenuSystemTime,
MenuTrainList,
MenuPractice,
// Jl3dSimulation,
Jl3dDrive,
Jl3dDevice,
2019-12-31 13:15:28 +08:00
Scheduling,
2020-05-22 18:41:23 +08:00
LeftSlider,
StatusIcon
},
props: {
size: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
mode: '',
trainingObj: {},
timeDemonNum: 0,
checkLine: null,
offset: 15,
offsetBottom: 15,
tipBottom: 0,
mouseNum: 1,
ierval: null,
mouseNumTime: 0,
// mapBox: null,
mapBoxP: null,
panelShow: true,
simulationShow: false,
drivingShow: false,
deviceShow: false,
questId: 0, // 加载任务的Id
2020-03-25 15:22:52 +08:00
showStation: '',
2020-04-01 15:01:08 +08:00
stationList: [],
2020-06-19 18:58:55 +08:00
grouper:'',
2020-04-07 14:40:24 +08:00
showSelectStation: false, // 是否展示现地选择设备集中站select
prdTypeMap: {
'01': '01', // 现地 => 现地
'02': '02', // 行调 => 行调
'04': '02', // 司机 => 行调
'05': '' // 派班 => null
},
2020-06-01 11:21:10 +08:00
dataError: false,
planRunning:false
};
},
computed: {
...mapGetters([
'canvasWidth'
]),
...mapGetters('map', [
'map'
]),
...mapGetters('training', [
'offsetStationCode'
]),
...mapGetters('config', [
'canvasId'
]),
width() {
return this.$store.state.app.width;
},
height() {
return this.$store.state.app.height;
},
right() {
return this.$store.state.config.width / 2 - 55;
},
trainingId() {
return this.$route.query.trainingId;
},
mapId() {
return this.$route.query.mapId;
},
prdType() {
return this.$route.query.prdType;
},
skinCode() {
return this.$route.query.skinCode;
},
isLesson() {
2020-05-09 20:24:59 +08:00
return (this.mode === 'teach' || this.mode === 'manage');
},
2020-03-27 14:01:57 +08:00
isShowLeftSlider() {
return (this.mode === 'teach' || this.mode === 'manage') && (this.$route.query.lessonId != '0');
},
isExam() {
return this.mode === 'exam';
},
isDemon() {
return this.mode === 'demon';
},
isScript() {
return this.mode === 'script';
},
isPractice() {
return this.mode === 'practice';
},
isDrive() {
return this.prdType == '04';
},
isShowScheduling() {
return this.$route.query.prdType == '05';
2020-04-01 16:24:03 +08:00
},
project() {
return getSessionStorage('project');
2020-05-28 13:21:51 +08:00
},
group() {
return this.$route.query.group;
},
2020-05-28 13:21:51 +08:00
userRole() {
if (this.$route.query.prdType == '02') {
return 'DISPATCHER';
} else if (this.$route.query.prdType == '01') {
return 'STATION_SUPERVISOR';
} else if (this.$route.query.prdType == '04') {
return 'DRIVER';
} else {
return 'AUDIENCE';
}
}
},
watch: {
'$store.state.config.menuBarLoadedCount': function (val) {
this.setPosition();
},
'$store.state.training.prdType': function (val) { // 根据权限类型计算高度
this.setPosition();
},
'$store.state.map.mapViewLoadedCount': function (val) { // 地图视图加载完成标识 开始加载默认状态
this.mapBoxP = document.getElementById(this.canvasId).children[0];
this.mapBoxP.style.cursor = '';
// this.mapBox = document.getElementsByTagName('canvas');
2020-06-01 11:21:10 +08:00
if (this.planRunning) {
this.$store.dispatch('training/simulationStart');
}
if (this.trainingId) {
2020-03-26 18:42:01 +08:00
getTrainingStepsDetailNew(this.trainingId, { group: this.group }).then(resp => {
this.trainingObj = resp.data;
this.$store.dispatch('training/setTrainingData', this.trainingObj);
2020-06-01 11:21:10 +08:00
2020-03-27 14:37:28 +08:00
}).catch(error => {
this.$messageBox(`初始化失败实训内容失败: ${error.message}`);
});
}
2020-04-07 14:40:24 +08:00
this.switchStationMode(this.showStation);
},
'$store.state.training.centerStationCode': function(code) {
if (code) {
this.showStation = code;
}
},
'$store.state.map.mousemove': function (val) {
this.mousemove();
},
'$store.state.socket.permissionOver': function () {
this.$alert('用户权限已被收回', '提示', {
confirmButtonText: '确定',
callback: action => {
this.back();
}
});
},
'size.width': function(val) {
this.setWindowSize();
},
2020-06-12 16:12:33 +08:00
'size.height': function(val) {
this.setWindowSize();
},
'$store.state.app.windowSizeCount': function() {
this.setWindowSize();
},
$route() {
this.$nextTick(() => {
this.initLoadData();
});
2020-03-25 15:22:52 +08:00
},
'$store.state.map.map': function (val) {
this.showSelectStation = val.skinVO.code === '06' && this.$store.state.training.prdType === '01';
this.showSelectStation && this.setStationList(val);
2020-06-19 18:58:55 +08:00
},
'group':function(group) {
this.grouper = group;
}
},
async created() {
this.mode = this.$route.params.mode;
},
async mounted() {
EventBus.$on('clearCheckLogin', () => {
this.clearCheckLogin();
});
2020-06-19 18:58:55 +08:00
this.grouper = this.group;
await this.setWindowSize();
await this.initLoadData();
},
2020-06-19 18:58:55 +08:00
beforeDestroy() {
this.quit(this.grouper);
this.clearAllTimer();
this.$store.dispatch('training/reset');
this.$store.dispatch('map/mapClear');
EventBus.$off('clearCheckLogin');
},
methods: {
// 清除检查在线定时器
clearAllTimer() {
if (this.ierval) {
clearTimeout(this.ierval);
this.ierval = null;
}
if (this.checkLine) {
clearTimeout(this.checkLine);
this.checkLine = null;
}
},
// 设置检查在线定时器
checkLoginLineTimer() {
if (this.checkLine) {
clearTimeout(this.checkLine);
}
this.checkLine = setInterval(() => {
checkLoginLine();
}, 5000 * 60);
},
// 设置手标显示状态
checkMouseStatusTimer() {
if (this.ierval) {
clearTimeout(this.ierval);
}
this.ierval = setInterval(() => {
if (this.mouseNum) {
this.mouseNum = 0;
this.mouseNumTime = 0;
2020-04-29 14:05:50 +08:00
if (this.mapBoxP) {
this.mapBoxP.style.cursor = this.mapBoxP.style.cursor != 'none' ? this.mapBoxP.style.cursor : '';
}
} else {
this.mouseNumTime += 1;
}
if (this.mapBoxP) {
if (this.mouseNumTime >= 12) {
this.mapBoxP.style.cursor = 'none';
}
}
}, 1000);
},
mousemove() {
this.mouseNum = 1;
},
setPosition() {
this.$nextTick(() => {
let offset = 15;
let offsetBottom = 15;
const menuBar = document.getElementById('menuBar');
const menuTool = document.getElementById('menuTool');
const menuBottom = document.getElementById('menuButton');
const menuButtonsBox = document.getElementById('menuButtons_box');
if (menuBar) {
offset += (menuBar.offsetHeight || 0);
}
if (menuTool) {
offset += (menuTool.offsetHeight || 0);
}
if (menuBottom) {
offsetBottom += (menuBottom.offsetHeight || 0);
}
if (menuButtonsBox) {
this.tipBottom = menuButtonsBox.offsetHeight + 15 || 0;
}
if (this.offset != offset) {
this.offset = offset;
}
if (this.offsetBottom != offsetBottom) {
this.offsetBottom = offsetBottom;
}
});
},
2020-04-01 12:53:58 +08:00
setCenter(code) {
this.$refs.mapCanvas.setCenter(code);
},
// 结束加载状态
endViewLoading(isSuccess) {
if (!isSuccess) {
this.$store.dispatch('map/mapClear');
}
this.$nextTick(() => {
EventBus.$emit('viewLoading', false);
});
},
// 加载仿真信息
async loadSimulationInfo() {
this.dataError = false;
2019-12-30 09:00:16 +08:00
const resp = await getSimulationInfoNew(this.group);
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;
2020-05-25 10:32:14 +08:00
this.$store.dispatch('training/setInitTime', +new Date(`${new Date().toLocaleDateString()} ${timeFormat(resp.data.systemTime)}`));
if (resp.data.planRunning) {
2020-06-01 11:21:10 +08:00
this.planRunning = resp.data.planRunning;
} else {
this.$store.dispatch('training/over');
}
if (this.isDemon) {
this.$refs.menuDemon.initPlannedDriving(resp.data.planRunning);
} else if (this.isScript) {
this.$refs.menuScript.initPlannedDriving(resp.data.planRunning);
}
} else if (resp && resp.code == 200 && resp.data && resp.data.dataError) {
this.dataError = true;
2020-05-09 20:24:59 +08:00
this.$messageBox('此地图数据正在维护中,无法运行!');
}
},
// 加载地图数据
async initLoadData() {
this.$store.dispatch('training/reset');
try {
await this.loadSimulationInfo();
if (this.isDemon) {
await this.initLoadDemonData();
} else if (this.isScript) {
await this.initLoadTaskData();
} else if (this.isPractice) {
await this.initPracticeData();
} else {
await this.initLoadLessonOrExamData();
}
this.checkLoginLineTimer();
this.checkMouseStatusTimer();
} catch (error) {
this.$messageBox(`初始化失败: ${error.message}`);
this.endViewLoading();
}
},
// 课程和考试系统
async initLoadLessonOrExamData() {
this.$store.dispatch('training/end', null);
this.$store.dispatch('training/changeOperateMode', { mode: OperateMode.NORMAL }); // 默认为正常模式
if (parseInt(this.trainingId)) {
// 设置地图数据
// 设置实训数据
2020-03-26 18:42:01 +08:00
const resp = await getTrainingDetailNew(this.trainingId);
if (resp && resp.code == 200) {
const detail = resp.data;
await this.$store.dispatch('training/setPrdType', this.prdTypeMap[detail.prdType]);
2020-03-27 13:52:14 +08:00
await this.loadNewMapDataByGroup(this.group);
} else {
this.$messageBox(`获取实训步骤数据失败`);
this.endViewLoading();
}
} else {
this.endViewLoading();
}
},
// 仿真系统
async initLoadDemonData() {
this.$store.dispatch('training/end', TrainingMode.NORMAL);
this.$store.dispatch('training/changeOperateMode', { mode: OperateMode.NORMAL }); // 默认为正常模式
this.$store.dispatch('training/setPrdType', this.prdTypeMap[this.prdType]);
if (parseInt(this.mapId)) {
2019-12-30 09:00:16 +08:00
await this.loadNewMapDataByGroup(this.group);
} else {
this.endViewLoading();
}
},
// 任务录制系统
async initLoadTaskData() {
this.$store.dispatch('training/end', TrainingMode.NORMAL);
this.$store.dispatch('training/changeOperateMode', { mode: OperateMode.NORMAL }); // 默认为正常模式
this.switchMode('01');
if (parseInt(this.mapId)) {
2019-12-30 09:00:16 +08:00
await this.loadNewMapDataByGroup(this.group);
} else {
this.endViewLoading();
}
},
// 加载实操地图数据
async initPracticeData() {
this.$store.dispatch('training/end', TrainingMode.NORMAL);
this.$store.dispatch('training/changeOperateMode', { mode: OperateMode.NORMAL }); // 默认为正常模式
this.switchMode('01');
if (parseInt(this.mapId)) {
await this.loadNewMapDataByGroup(this.group);
} else {
this.endViewLoading();
}
},
// 选择脚本
async selectQuest(row, id, mapLocation, roleName) {
try {
2020-05-14 17:24:47 +08:00
const res = await loadScriptNew(row.id, id, this.group);
if (res && res.code == 200) {
this.questId = parseInt(row.id);
if (mapLocation) {
const newMapLocation = {'offsetX': mapLocation.x, 'offsetY': mapLocation.y, 'scaleRate': mapLocation.scale};
Vue.prototype.$jlmap.setOptions(newMapLocation);
}
2020-05-14 17:24:47 +08:00
scriptExecuteNew(this.group).then(data=>{
}).catch(error=>{
console.log(error);
});
}
if (this.$refs.menuDemon) {
await this.$refs.menuDemon.initLoadPage();
}
if (this.$refs.menuScript) {
await this.$refs.menuScript.initLoadPage();
}
} catch (error) {
this.$messageBox(error.message);
}
},
// 退出脚本
async quitQuest() {
this.questId = 0;
this.$store.dispatch('scriptRecord/updateSimulationPause', false);
},
// 通过id加载地图数据
2019-12-30 09:00:16 +08:00
async loadNewMapDataByGroup(group) {
try {
2019-12-30 09:00:16 +08:00
await loadNewMapDataByGroup(group);
await this.$store.dispatch('training/setMapDefaultState');
} catch (error) {
this.$messageBox(`获取地图数据失败: ${error.message}`);
this.endViewLoading();
}
},
// 销毁仿真
2020-06-19 18:58:55 +08:00
quit(group) {
clearSimulation(group);
this.$store.dispatch('training/over');
},
// 仿真错误时,被动退出时调用
async back() {
if (this.isExam) {
await this.$refs.menuExam.back();
} else if (this.isLesson) {
await this.$refs.lessonMenu.back();
} else if (this.isDemon) {
await this.$refs.menuDemon.back();
} else if (this.isScript) {
await this.$refs.menuScript.back();
}
},
// 设置使用时间
async tryTime(param) {
const data = {
goodsId: param.goodsId,
time: param.time
};
if (data.goodsId) {
await setGoodsTryUse(data);
}
},
switchMode(prdType) {
this.$store.dispatch('training/setPrdType', prdType);
},
hidepanel() {
if (this.isDrive) {
this.panelShow = false;
this.drivingShow = true;
this.$refs.Jl3dDrive.show(this.mapId, this.group);
} else {
const routeData = this.$router.resolve({
path:'/jlmap3d/sandbox',
query:{
mapid:this.mapId,
group:this.group,
2020-01-14 16:19:36 +08:00
token:getToken(),
2020-04-01 16:24:03 +08:00
project: this.project
}
});
window.open(routeData.href, '_blank', 'noopener noreferrer');
}
},
2020-06-19 18:58:55 +08:00
script3ddriveshow() {
this.panelShow = false;
this.drivingShow = true;
this.$refs.Jl3dDrive.show(this.mapId, this.group);
},
2020-04-01 12:53:58 +08:00
passflow() {
const routeData = this.$router.resolve({
path:'/jlmap3d/passengerflow',
query:{
2020-04-01 16:24:03 +08:00
mapid:this.mapId,
2020-06-02 16:57:38 +08:00
group:this.group,
2020-04-01 16:24:03 +08:00
project: this.project
2020-04-01 12:53:58 +08:00
}
});
window.open(routeData.href, '_blank', 'noopener noreferrer');
},
jl3dstation() {
const routeData = this.$router.resolve({
path:'/jlmap3d/jl3dstation',
query:{
mapid:this.mapId,
project: this.project
}
});
window.open(routeData.href, '_blank', 'noopener noreferrer');
},
devicemodel() {
2020-05-14 17:24:47 +08:00
if (this.deviceShow == false) {
this.deviceShow = true;
} else {
this.deviceShow = false;
}
},
showScheduling() {
this.$refs.scheduling.doShow();
},
showpanel() {
this.panelShow = true;
this.simulationShow = false;
},
showdriving() {
this.panelShow = true;
this.drivingShow = false;
},
setWindowSize() {
// this.$nextTick(() => {
const width = this.size ? this.size.width : this.width;
const height = this.size ? this.size.height : this.height;
this.$store.dispatch('config/resize', { width, height });
this.$store.dispatch('training/updateOffsetStationCode', { offsetStationCode: this.offsetStationCode });
// });
2019-12-31 13:15:28 +08:00
},
overallTranslation(flag) {
2020-04-14 14:51:14 +08:00
const panel = document.getElementById('leftSlider');
2019-12-31 13:15:28 +08:00
this.$refs.lessonMenu.handelGroupButtonTranslate(flag);
if (flag) {
2020-04-14 14:51:14 +08:00
panel.style.transform = 'translateX(400px)';
2019-12-31 13:15:28 +08:00
} else {
2020-04-14 14:51:14 +08:00
panel.style.transform = '';
2019-12-31 13:15:28 +08:00
}
2020-03-25 15:22:52 +08:00
},
2020-04-07 14:40:24 +08:00
switchStationMode(val) {
2020-05-19 09:45:15 +08:00
if (this.stationList.length > 0) {
if (val == null) {
this.showStation = this.stationList[0].value;
} else {
this.showStation = val;
}
2020-06-12 16:28:52 +08:00
const nameList = Object.keys(this.$store.state.map.map);
let list = [];
nameList.forEach(item => {
if (this.$store.state.map.map[item] && this.$store.state.map.map[item].constructor === Array) {
if (item === 'trainList') {
this.$store.state.map.map[item].forEach(elem => {
elem && list.push(elem);
});
} else {
list = [...list, ...this.$store.state.map.map[item]];
}
}
});
this.$jlmap.updateShowStation(list, this.showStation);
this.setCenter(this.showStation);
// this.$store.dispatch('map/setShowCentralizedStationCode', this.showStation);
// this.$store.dispatch('map/setShowCentralizedStationNum');
2020-05-19 09:45:15 +08:00
}
2020-03-25 15:22:52 +08:00
},
setStationList(val) {
this.stationList = [];
(val.stationList || []).forEach(item => {
if (item.centralized) {
this.stationList.push({value: item.code, name: item.name});
}
});
if (this.stationList.length) {
this.showStation = this.stationList[0].value;
}
}
}
};
</script>
<style>
.main {
z-index: 10;
display: block;
width: 100%;
height: 100%;
overflow: hidden;
-moz-user-select: none;
-o-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>