201 lines
7.1 KiB
Vue
201 lines
7.1 KiB
Vue
<template>
|
||
<div>
|
||
<div class="display-draft">
|
||
<!-- <el-button-group>
|
||
<el-button type="primary" @click="saveScenesStage" v-if="isSaveStage">保存背景</el-button>
|
||
<el-button type="success" @click="saveScenesData" v-else>保存数据</el-button>
|
||
<el-button type="danger" @click="dumpScenesData">重置剧本</el-button>
|
||
</el-button-group> -->
|
||
<el-button-group>
|
||
<el-button type="success" :disabled="isDisable" @click="selectBeginTime">{{ $t('scriptRecord.drivingByPlan') }}</el-button>
|
||
<!-- <el-button type="danger" :disabled="!isDisable" @click="end">退出计划</el-button> -->
|
||
<el-button type="primary" @click="back">{{ $t('scriptRecord.scriptBack') }}</el-button>
|
||
</el-button-group>
|
||
</div>
|
||
<set-time ref="setTime" @ConfirmSelectBeginTime="start" />
|
||
</div>
|
||
</template>
|
||
|
||
<!-- 单人仿真 -->
|
||
<script>
|
||
import SetTime from './demon/setTime';
|
||
import { Notification } from 'element-ui';
|
||
import { ranAsPlan, runDiagramOver, runDiagramGetTime } from '@/api/simulation';
|
||
import { timeFormat } from '@/utils/date';
|
||
import { EventBus } from '@/scripts/event-bus';
|
||
|
||
export default {
|
||
name: 'MenuTask',
|
||
components: {
|
||
SetTime
|
||
},
|
||
props: {
|
||
group: {
|
||
type: String,
|
||
required: true
|
||
},
|
||
offset: {
|
||
type: Number,
|
||
required: true
|
||
}
|
||
},
|
||
data() {
|
||
return {
|
||
isDisable: false,
|
||
tryTime: 0, // 进入页面多少秒
|
||
timeNow: 0, // 进入页面 相对时间
|
||
time: null, // 定时器
|
||
countTime: 0, // 显示 倒计时
|
||
remainingTime: 0,
|
||
goodsId: this.$route.query.goodsId,
|
||
// isSaveStage: true,
|
||
training: {
|
||
id: '',
|
||
name: '',
|
||
remarks: ''
|
||
}
|
||
};
|
||
},
|
||
computed: {
|
||
scriptId() {
|
||
return this.$route.query.scriptId;
|
||
}
|
||
},
|
||
watch: {
|
||
'$store.state.training.subscribeCount': function () {
|
||
this.group && this.initLoadPage();
|
||
}
|
||
},
|
||
beforeDestroy() {
|
||
if (this.time) {
|
||
this.setTryTime();
|
||
clearTimeout(this.time);
|
||
}
|
||
},
|
||
methods: {
|
||
async initLoadPage() {
|
||
try {
|
||
await this.loadSystemTime();
|
||
} catch (error) {
|
||
console.log(error);
|
||
}
|
||
},
|
||
initPlannedDriving(isDisable) {
|
||
this.isDisable = isDisable;
|
||
},
|
||
selectBeginTime() {
|
||
this.$refs.setTime.doShow();
|
||
},
|
||
resetBeginTime() {
|
||
this.isDisable = false;
|
||
},
|
||
start(model) {
|
||
this.isDisable = true;
|
||
const data = {
|
||
time: model.initTime,
|
||
loadNumber:this.trainList.length
|
||
};
|
||
ranAsPlan(data, this.group).then(res => {
|
||
this.$store.dispatch('training/simulationStart').then(() => {
|
||
this.$store.dispatch('training/setInitTime', +new Date(`${new Date().getFullYear()} ${model.initTime}`));
|
||
});
|
||
}).catch((error) => {
|
||
this.isDisable = false;
|
||
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'));
|
||
}
|
||
});
|
||
},
|
||
end() {
|
||
this.isDisable = false;
|
||
runDiagramOver(this.group).then(() => {
|
||
this.$store.dispatch('training/over').then(() => {
|
||
this.$store.dispatch('training/setMapDefaultState').then(() => {
|
||
this.$store.dispatch('map/clearJlmapTrainView');
|
||
this.$store.dispatch('map/setTrainWindowShow', false);
|
||
});
|
||
});
|
||
}).catch(() => {
|
||
this.isDisable = true;
|
||
this.$messageBox('结束仿真失败,请返回');
|
||
});
|
||
},
|
||
setTryTime() {
|
||
if (this.try) {
|
||
this.$emit('tryTime', { time: this.tryTime, goodsId: this.goodsId });
|
||
}
|
||
},
|
||
back() {
|
||
this.$store.dispatch('training/over').then(() => {
|
||
EventBus.$emit('runPlanStop');
|
||
EventBus.$emit('chatSubscribeStop');
|
||
history.go(-1);
|
||
Notification.closeAll();
|
||
});
|
||
},
|
||
async loadSystemTime() {
|
||
// const rest = await runDiagramGetTime(this.group);
|
||
// if (rest && rest.code == 200) {
|
||
// this.$store.dispatch('training/setInitTime', +new Date(`${new Date().getFullYear()} ${timeFormat(rest.data)}`));
|
||
// }
|
||
}
|
||
}
|
||
};
|
||
</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>
|