2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
2019-08-02 10:36:17 +08:00
|
|
|
<div>
|
|
|
|
<div class="display-draft">
|
|
|
|
<!-- <el-button-group>
|
2019-07-26 13:32:43 +08:00
|
|
|
<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> -->
|
2019-08-02 10:36:17 +08:00
|
|
|
<el-button-group>
|
|
|
|
<el-button type="success" :disabled="isDisable" @click="selectBeginTime">按计划行车</el-button>
|
2019-08-16 17:15:20 +08:00
|
|
|
<!-- <el-button type="danger" :disabled="!isDisable" @click="end">退出计划</el-button> -->
|
2019-08-02 10:36:17 +08:00
|
|
|
<el-button type="primary" @click="back">返回</el-button>
|
|
|
|
</el-button-group>
|
2019-07-26 13:32:43 +08:00
|
|
|
</div>
|
2019-08-02 10:36:17 +08:00
|
|
|
<set-time ref="setTime" @ConfirmSelectBeginTime="start" />
|
|
|
|
</div>
|
2019-07-26 13:32:43 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<!-- 单人仿真 -->
|
|
|
|
<script>
|
2019-08-02 10:36:17 +08:00
|
|
|
import SetTime from './demon/setTime';
|
2019-08-06 10:11:32 +08:00
|
|
|
// import { mapGetters } from 'vuex';
|
2019-08-02 10:36:17 +08:00
|
|
|
import { Notification } from 'element-ui';
|
2019-08-06 10:11:32 +08:00
|
|
|
import { runDiagramStart, runDiagramOver, runDiagramGetTime } from '@/api/simulation';
|
|
|
|
// import { OperateMode, PermissionType } from '@/scripts/ConstDic';
|
2019-08-02 10:36:17 +08:00
|
|
|
import { exitFullscreen } from '@/utils/screen';
|
2019-08-06 10:11:32 +08:00
|
|
|
// import { getCountTime } from '@/utils/index';
|
|
|
|
// import { loadMapData } from '@/utils/loaddata';
|
|
|
|
import { runDiagramIsStart } from '@/api/simulation';
|
2019-08-02 10:36:17 +08:00
|
|
|
import { timeFormat } from '@/utils/date';
|
2019-08-02 10:58:28 +08:00
|
|
|
import { EventBus } from '@/scripts/event-bus';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-08-02 10:36:17 +08:00
|
|
|
export default {
|
|
|
|
name: 'MenuTask',
|
|
|
|
components: {
|
2019-08-30 19:19:48 +08:00
|
|
|
SetTime
|
2019-08-02 10:36:17 +08:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
group: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
offset: {
|
2019-08-20 12:47:39 +08:00
|
|
|
type: Number,
|
|
|
|
required: true
|
2019-08-02 10:36:17 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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 () {
|
2019-08-06 10:11:32 +08:00
|
|
|
this.group && this.initLoadPage();
|
2019-08-02 10:36:17 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
if (this.time) {
|
|
|
|
this.setTryTime();
|
|
|
|
clearTimeout(this.time);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2019-08-06 10:11:32 +08:00
|
|
|
async initLoadPage() {
|
2019-08-02 10:36:17 +08:00
|
|
|
try {
|
|
|
|
const resp = await runDiagramIsStart(this.group);
|
|
|
|
if (resp && resp.data) {
|
|
|
|
this.isDisable = true;
|
|
|
|
this.$store.dispatch('training/simulationStart');
|
|
|
|
} else {
|
|
|
|
this.isDisable = false;
|
|
|
|
this.$store.dispatch('training/over');
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-08-02 10:36:17 +08:00
|
|
|
await this.loadSystemTime();
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
selectBeginTime() {
|
|
|
|
this.$refs.setTime.doShow();
|
|
|
|
},
|
2019-08-20 12:47:39 +08:00
|
|
|
resetBeginTime() {
|
2019-08-19 19:37:52 +08:00
|
|
|
this.isDisable = false;
|
|
|
|
},
|
2019-08-02 10:36:17 +08:00
|
|
|
start(model) {
|
|
|
|
this.isDisable = true;
|
|
|
|
runDiagramStart(model, this.group).then(res => {
|
|
|
|
this.$store.dispatch('training/simulationStart').then(() => {
|
|
|
|
this.$store.dispatch('training/setInitTime', +new Date(`${new Date().getFullYear()} ${model.initTime}`));
|
|
|
|
});
|
|
|
|
}).catch(() => {
|
|
|
|
this.isDisable = false;
|
|
|
|
this.$messageBox('开始仿真失败,请返回重试');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
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();
|
|
|
|
exitFullscreen();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
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)}`));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2019-07-26 13:32:43 +08:00
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
@import "src/styles/mixin.scss";
|
|
|
|
|
|
|
|
.display-card {
|
|
|
|
z-index: 9;
|
2019-07-26 15:52:50 +08:00
|
|
|
display: inline-block;
|
2019-07-26 13:32:43 +08:00
|
|
|
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;
|
|
|
|
}
|
2019-08-02 10:36:17 +08:00
|
|
|
</style>
|