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

274 lines
9.9 KiB
Vue
Raw Normal View History

2019-12-30 09:00:16 +08:00
<template>
<div>
2020-08-13 16:18:19 +08:00
<div class="display-draft">
<!-- :style="{bottom: offsetBottom + 'px'}" -->
2019-12-30 09:00:16 +08:00
<el-button-group>
2020-05-20 15:29:41 +08:00
<el-button v-if="!isScriptCommand" type="success" :disabled="isDisable || dataError" @click="selectBeginTime">{{ $t('scriptRecord.drivingByPlan') }}</el-button>
<el-button v-if="!isScriptCommand" type="danger" :disabled="dataError" @click="end">初始化</el-button>
2019-12-30 09:00:16 +08:00
<el-button type="primary" @click="back">{{ $t('scriptRecord.scriptBack') }}</el-button>
</el-button-group>
</div>
2020-08-13 16:18:19 +08:00
<div v-if="!dataError" class="display_top_draft" :style="{top: offset+textStatusHeight+'px'}">
<div class="btn_hover" @click="menuClick">菜单</div>
<el-button-group ref="button_group_box" class="button_group_box" :style="`margin-left:-${btnWidth}px`">
<!-- 地图错误判断 -->
<!-- 设备视图 -->
<!-- <el-button v-if="isShow3dmodel && !isShowScheduling" size="small" @click="jumpjlmap3dmodel">{{ jl3dmodel }}</el-button> -->
<!-- 三维视图 -->
<el-button v-if="!isShowScheduling&&!isDriver" size="small" @click="jumpjlmap3d">{{ $t('display.demon.threeDimensionalView') }}</el-button>
2020-08-13 18:07:43 +08:00
<!-- 故障设备视图 -->
<el-button v-if="isStation" size="small" @click="jumpjlmap3dFault">故障设备</el-button>
2020-08-13 16:18:19 +08:00
<!-- cctv视图 -->
<!-- <el-button v-if="!isShowScheduling" size="small" @click="jumpjl3dpassflow">{{ jl3dpassflow }}</el-button> -->
<!-- 司机视角 -->
<el-button v-if="isDriver" size="small" type="jumpjlmap3d" @click="jumpjlmap3dDriver">{{ $t('joinTraining.driverPerspective') }}</el-button>
</el-button-group>
</div>
<script-chat ref="chatbox" :group="group" :user-role="userRole" />
2020-05-20 15:29:41 +08:00
<set-time ref="setTime" @ConfirmSelectBeginTime="start" />
2020-08-13 16:18:19 +08:00
<tip-script-record-new ref="tipTaskRecordNew" :group="group" :offset-bottom="offsetBottom" :offset="offset" />
2019-12-30 09:00:16 +08:00
</div>
</template>
<!-- 单人仿真 -->
<script>
2020-08-13 16:18:19 +08:00
import { getToken } from '@/utils/auth';
import ScriptChat from './scriptChat';
2020-08-03 09:18:27 +08:00
import TipScriptRecordNew from '@/views/scriptManage/tipScriptRecord';
2020-05-20 15:29:41 +08:00
import SetTime from './demon/setTime';
2019-12-30 09:00:16 +08:00
import { Notification } from 'element-ui';
2020-07-30 13:43:00 +08:00
import { ranAsPlan, exitRunPlan } from '@/api/simulation';
2020-05-20 15:29:41 +08:00
import { mapGetters } from 'vuex';
2019-12-30 09:00:16 +08:00
export default {
name: 'MenuTask',
components: {
2020-06-11 18:32:26 +08:00
SetTime,
ScriptChat,
2020-06-11 18:32:26 +08:00
TipScriptRecordNew
2019-12-30 09:00:16 +08:00
},
props: {
offsetBottom: {
2019-12-30 09:00:16 +08:00
type: Number,
required: true
2020-05-09 20:24:59 +08:00
},
dataError: {
type: Boolean,
default() {
return false;
}
2020-08-13 16:18:19 +08:00
},
offset: {
type: Number,
required: true
},
textStatusHeight: {
type: Number,
default() {
return 0;
}
},
project:{
type: String,
default() {
return '';
}
2019-12-30 09:00:16 +08:00
}
},
data() {
return {
isDisable: false,
2020-08-13 16:18:19 +08:00
isScriptCommand:false,
hoverBtn: false,
btnWidth: 0
2019-12-30 09:00:16 +08:00
};
},
2020-08-13 16:18:19 +08:00
2019-12-30 09:00:16 +08:00
computed: {
scriptId() {
return this.$route.query.scriptId;
2020-05-20 15:29:41 +08:00
},
...mapGetters('map', [
'trainList'
2020-06-11 18:32:26 +08:00
]),
2020-06-29 15:55:31 +08:00
group() {
return this.$route.query.group;
},
2020-06-11 18:32:26 +08:00
userRole() {
2020-07-10 10:53:44 +08:00
return this.$store.state.scriptRecord.userRole ? this.$store.state.scriptRecord.userRole : 'ADMIN';
2020-08-13 16:18:19 +08:00
},
isDriver() {
return this.$store.state.scriptRecord.userRole == 'DRIVER';
},
isShowScheduling() {
return this.$store.state.training.prdType == '05';
2020-08-13 18:07:43 +08:00
},
isStation() {
return this.$store.state.training.prdType == '01';
2020-06-11 18:32:26 +08:00
}
2019-12-30 09:00:16 +08:00
},
watch: {
2020-05-20 15:29:41 +08:00
'$store.state.scriptRecord.bgSet':function (val) {
this.isScriptCommand = val;
2019-12-30 09:00:16 +08:00
}
},
beforeDestroy() {
},
2020-05-20 15:29:41 +08:00
mounted() {
2020-06-12 18:29:14 +08:00
// this.$store.state.training.prdType
2020-05-20 15:29:41 +08:00
this.isScriptCommand = this.$store.state.scriptRecord.bgSet;
2020-08-14 10:29:33 +08:00
// if (!this.isScriptCommand) {
// this.$store.dispatch('training/setPrdType', '02');
// }
2020-08-13 16:18:19 +08:00
this.$nextTick(() => {
this.menuClick();
});
2020-05-20 15:29:41 +08:00
},
2019-12-30 09:00:16 +08:00
methods: {
initPlannedDriving(isDisable) {
this.isDisable = isDisable;
},
2019-12-30 09:00:16 +08:00
selectBeginTime() {
this.$refs.setTime.doShow();
},
resetBeginTime() {
this.isDisable = false;
},
2020-08-13 16:18:19 +08:00
menuClick() {
this.hoverBtn = !this.hoverBtn;
if (this.hoverBtn) {
// this.$refs.button_group_box.$el.clientWidth ||
this.btnWidth = 500; // 默认宽度
} else {
// button_group_box
this.btnWidth = 0;
}
},
2019-12-30 09:00:16 +08:00
start(model) {
this.isDisable = true;
2020-01-17 11:31:53 +08:00
const data = {
2020-05-20 15:29:41 +08:00
time: model.initTime
2020-01-17 11:31:53 +08:00
};
ranAsPlan(data, this.group).then(res => {
2019-12-30 09:00:16 +08:00
this.$store.dispatch('training/simulationStart').then(() => {
2020-05-25 10:32:14 +08:00
this.$store.dispatch('training/setInitTime', +new Date(`${new Date().toLocaleDateString()} ${model.initTime}`));
2020-05-20 15:29:41 +08:00
this.$store.dispatch('map/setShowCentralizedStationNum');
2019-12-30 09:00:16 +08:00
});
2020-01-17 11:31:53 +08:00
}).catch((error) => {
2019-12-30 09:00:16 +08:00
this.isDisable = false;
2020-01-17 13:17:12 +08:00
if (error.code == '5001') {
this.$messageBox(this.$t('error.mapDataError') + '' + this.$t('error.startSimulationFailed'));
} else if (error.code == '5002') {
this.$messageBox(this.$t('error.runningChartDataError') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '5003') {
this.$messageBox(this.$t('error.runningChartIsNotLoaded') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '5004') {
this.$messageBox(this.$t('error.runningDataError') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '5000') {
this.$messageBox(this.$t('error.systemError') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4000') {
this.$messageBox(this.$t('error.simulationDoesNotExist') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4001') {
this.$messageBox(this.$t('error.simulationOperationIsNotDefined') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4002') {
this.$messageBox(this.$t('error.simulationOperationProcessingMethodNotFound') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4003') {
this.$messageBox(this.$t('error.simulationOperationFailed') + ',' + this.$t('error.startSimulationFailed'));
} else if (error.code == '4004') {
this.$messageBox(this.$t('error.operationConflict') + ',' + this.$t('error.startSimulationFailed'));
2020-01-17 13:17:12 +08:00
}
2019-12-30 09:00:16 +08:00
});
},
end() {
this.isDisable = false;
2020-05-20 15:29:41 +08:00
exitRunPlan(this.group).then(() => {
2019-12-30 09:00:16 +08:00
this.$store.dispatch('training/over').then(() => {
this.$store.dispatch('training/setMapDefaultState').then(() => {
this.$store.dispatch('map/clearJlmapTrainView');
2020-07-09 16:54:31 +08:00
this.$store.dispatch('map/resetActiveTrainList');
2019-12-30 09:00:16 +08:00
this.$store.dispatch('map/setTrainWindowShow', false);
});
});
}).catch(() => {
this.isDisable = true;
2020-05-20 15:29:41 +08:00
this.$messageBox(this.$t('display.demon.endSimulationFail'));
2019-12-30 09:00:16 +08:00
});
},
back() {
this.$store.dispatch('training/over').then(() => {
2020-07-09 16:54:31 +08:00
this.$store.dispatch('map/resetActiveTrainList');
2019-12-30 09:00:16 +08:00
history.go(-1);
Notification.closeAll();
});
},
2020-08-13 16:18:19 +08:00
jumpjlmap3dDriver() {
2020-06-19 18:58:55 +08:00
this.$emit('script3ddriveshow');
2020-08-13 16:18:19 +08:00
},
jumpjlmap3d() {
const routeData = this.$router.resolve({
path:'/jlmap3d/sandbox',
query:{
mapid:this.$route.query.mapId,
group:this.group,
token:getToken(),
project: this.project,
noPreLogout: true
}
});
window.open(routeData.href, '_blank', 'noopener noreferrer');
2020-08-13 18:07:43 +08:00
},
jumpjlmap3dFault() {
const routeData = this.$router.resolve({
path:'/jlmap3d/maintainer',
query:{
mapid:this.$route.query.mapId,
group:this.group,
token:getToken(),
project: this.project,
noPreLogout: true
}
});
this.openWindow = window.open(routeData.href);
2019-12-30 09:00:16 +08:00
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.display-card {
z-index: 9;
display: inline-block;
position: absolute;
top: 17px;
left: 160px;
height: 32px;
}
.display-card .el-row {
line-height: 32px !important;
}
.display-score {
background-color: black;
display: -moz-inline-box;
display: inline-block;
text-align: left;
height: 32px;
line-height: 24px;
border-radius: 4px;
padding-left: 2px;
margin-left: 10px;
font-family: "Microsoft" !important;
font-size: 18px !important;
color: #fff;
}
.display-draft {
position: absolute;
float: right;
right: 15px;
bottom: 15px;
}
</style>