2019-12-30 09:00:16 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div class="display-card" :style="{top: offset + 'px'}">
|
|
|
|
<el-row>
|
|
|
|
<el-radio-group v-model="demoMode" class="mode" size="small">
|
|
|
|
<el-radio-button :label="TrainingMode.TEACH">{{ $t('display.lesson.teachingMode') }}</el-radio-button>
|
|
|
|
<el-radio-button :label="TrainingMode.PRACTICE">{{ $t('display.lesson.practiceMode') }}</el-radio-button>
|
|
|
|
<el-radio-button :label="TrainingMode.TEST">{{ $t('display.lesson.testMode') }}</el-radio-button>
|
|
|
|
</el-radio-group>
|
|
|
|
<span class="display-time">{{ formatUsedTime }}</span>
|
|
|
|
<span v-if="demoMode === TrainingMode.TEST" class="display-score">{{ $t('display.lesson.score') }}{{ formatScore }}</span>
|
2020-04-02 14:46:21 +08:00
|
|
|
<el-select v-if="showSelectStation" v-model="showStation" style="width: 100px; position: fixed; right: 10px;" size="small" @change="switchStationMode">
|
|
|
|
<el-option v-for="item in stationList" :key="item.value" :label="item.name" :value="item.value" />
|
|
|
|
</el-select>
|
2019-12-30 09:00:16 +08:00
|
|
|
</el-row>
|
|
|
|
</div>
|
2020-03-30 16:15:35 +08:00
|
|
|
<div id="teachGroupButton" class="display-draft" :style="{bottom: offsetBottom + 'px'}">
|
2019-12-30 09:00:16 +08:00
|
|
|
<el-button-group>
|
2020-05-09 20:24:59 +08:00
|
|
|
<el-button type="success" class="start" :disabled="isDisable || dataError" :loading="startLoading" @click="start">{{ $t('display.startBtn') }}</el-button>
|
|
|
|
<el-button type="danger" class="end" :disabled="!isDisable || dataError" @click="end">{{ $t('display.endBtn') }}</el-button>
|
2019-12-30 09:00:16 +08:00
|
|
|
<el-button type="primary" :disabled="backDisable" class="back" @click="back">{{ $t('display.backBtn') }}</el-button>
|
|
|
|
</el-button-group>
|
|
|
|
</div>
|
2020-06-24 17:37:09 +08:00
|
|
|
<tip-training-detail :training-obj="trainingObj" :offset-bottom="offsetBottom + tipBottom" />
|
2020-06-29 15:55:31 +08:00
|
|
|
<left-slider v-if="isShowLeftSlider" :offset-bottom="offsetBottom" @overallTranslation="overallTranslation" />
|
2019-12-30 09:00:16 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import TipTrainingDetail from './tipTrainingDetail';
|
2020-06-29 15:55:31 +08:00
|
|
|
import LeftSlider from '@/views/newMap/displayNew/LeftSlider';
|
2019-12-30 09:00:16 +08:00
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { Notification } from 'element-ui';
|
2020-03-26 18:42:01 +08:00
|
|
|
import { startTrainingNew, endTrainingNew } from '@/api/jmap/training';
|
2020-03-27 10:51:49 +08:00
|
|
|
import { trainingNotifyNew } from '@/api/simulation';
|
2020-06-11 13:29:06 +08:00
|
|
|
import { TrainingMode, UrlConfig } from '@/scripts/ConstDic';
|
2019-12-30 09:00:16 +08:00
|
|
|
import { timeFormat } from '@/utils/date';
|
2020-06-29 15:55:31 +08:00
|
|
|
import { getTrainingStepsDetailNew } from '@/api/jmap/training';
|
2019-12-30 09:00:16 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'MenuLesson',
|
|
|
|
components: {
|
2020-06-29 15:55:31 +08:00
|
|
|
TipTrainingDetail,
|
|
|
|
LeftSlider
|
2019-12-30 09:00:16 +08:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
offset: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
2020-03-30 16:15:35 +08:00
|
|
|
},
|
|
|
|
offsetBottom: {
|
|
|
|
type: Number,
|
|
|
|
required: true
|
2020-04-02 14:46:21 +08:00
|
|
|
},
|
2020-06-24 17:37:09 +08:00
|
|
|
tipBottom: {
|
|
|
|
type: Number,
|
|
|
|
default: 0
|
|
|
|
},
|
2020-04-02 14:46:21 +08:00
|
|
|
showSelectStation: {
|
|
|
|
type: Boolean,
|
|
|
|
default() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
stationList: {
|
|
|
|
type: Array,
|
|
|
|
default() {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
showStation: {
|
|
|
|
type: String,
|
|
|
|
default() {
|
|
|
|
return '';
|
|
|
|
}
|
2020-05-09 20:24:59 +08:00
|
|
|
},
|
|
|
|
dataError: {
|
|
|
|
type: Boolean,
|
|
|
|
default() {
|
|
|
|
return false;
|
|
|
|
}
|
2019-12-30 09:00:16 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
timeInterval: null,
|
|
|
|
TrainingMode: TrainingMode,
|
2020-06-29 15:55:31 +08:00
|
|
|
trainingObj:{},
|
2019-12-30 09:00:16 +08:00
|
|
|
demoMode: TrainingMode.TEACH,
|
|
|
|
isDisable: false,
|
|
|
|
backDisable: false,
|
|
|
|
startLoading: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters('training', [
|
|
|
|
'score',
|
|
|
|
'started',
|
|
|
|
'usedTime',
|
|
|
|
'basicInfo'
|
|
|
|
]),
|
2020-06-29 15:55:31 +08:00
|
|
|
group() {
|
|
|
|
return this.$route.query.group;
|
|
|
|
},
|
2019-12-30 09:00:16 +08:00
|
|
|
formatScore() {
|
|
|
|
return this.score;
|
|
|
|
},
|
|
|
|
formatUsedTime() {
|
|
|
|
return timeFormat(this.usedTime);
|
2020-06-29 15:55:31 +08:00
|
|
|
},
|
|
|
|
isShowLeftSlider() {
|
|
|
|
return this.$route.query.lessonId != '0';
|
2019-12-30 09:00:16 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
demoMode: function (val) {
|
|
|
|
this.$store.dispatch('training/end', null);
|
|
|
|
this.$store.dispatch('training/reset');
|
|
|
|
this.$store.dispatch('training/emitTipFresh');
|
|
|
|
this.$store.dispatch('menuOperation/setButtonOperation', null);
|
|
|
|
|
|
|
|
this.isDisable = false;
|
|
|
|
},
|
2020-04-14 14:51:14 +08:00
|
|
|
'$store.state.map.mapViewLoadedCount': function (val) {
|
2020-06-29 15:55:31 +08:00
|
|
|
if (this.$route.query.trainingId) {
|
|
|
|
getTrainingStepsDetailNew(this.$route.query.trainingId, { group: this.group }).then(resp => {
|
|
|
|
this.trainingObj = resp.data;
|
|
|
|
this.$store.dispatch('training/setTrainingData', this.trainingObj);
|
|
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`初始化失败实训内容失败: ${error.message}`);
|
|
|
|
});
|
|
|
|
}
|
2020-04-14 14:51:14 +08:00
|
|
|
this.$store.dispatch('training/end', null);
|
|
|
|
this.$store.dispatch('training/reset');
|
|
|
|
this.$store.dispatch('training/emitTipFresh');
|
|
|
|
this.$store.dispatch('menuOperation/setButtonOperation', null);
|
|
|
|
this.isDisable = false;
|
|
|
|
},
|
2019-12-30 09:00:16 +08:00
|
|
|
'$store.state.training.operateErrMsg': function (val) {
|
|
|
|
this.tipInfo({ color: val.color, message: val.errMsg });
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
tipInfo(opt) {
|
|
|
|
if (opt && opt.hasOwnProperty('color') && opt.hasOwnProperty('message')) {
|
|
|
|
const h = this.$createElement;
|
|
|
|
this.$notify({
|
|
|
|
title: this.$t('global.tips'),
|
|
|
|
|
|
|
|
message: h('i', { style: 'color:' + opt.color }, opt.message)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2020-06-29 15:55:31 +08:00
|
|
|
overallTranslation(flag) {
|
|
|
|
const panel = document.getElementById('leftSlider');
|
|
|
|
if (flag) {
|
|
|
|
panel.style.transform = 'translateX(400px)';
|
|
|
|
} else {
|
|
|
|
panel.style.transform = '';
|
|
|
|
}
|
|
|
|
},
|
2019-12-30 09:00:16 +08:00
|
|
|
start() {
|
|
|
|
// 清空按钮操作
|
|
|
|
this.$store.dispatch('menuOperation/setButtonOperation', null);
|
|
|
|
this.startLoading = true;
|
|
|
|
if (this.trainingObj && this.trainingObj.id) {
|
|
|
|
this.isDisable = true;
|
2020-03-26 18:42:01 +08:00
|
|
|
startTrainingNew(this.trainingObj, this.group).then(response => {
|
2019-12-30 09:00:16 +08:00
|
|
|
this.$store.dispatch('map/clearJlmapTrainView').then(() => {
|
|
|
|
this.$store.dispatch('training/teachModeStart', this.demoMode);
|
|
|
|
this.$store.dispatch('training/setMapDefaultState').then(() => {
|
|
|
|
this.$store.dispatch('training/emitTipFresh');
|
|
|
|
this.tipInfo({ color: 'green', message: this.$t('global.pleaseOpearte') });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.startLoading = false;
|
|
|
|
}).catch(() => {
|
|
|
|
this.isDisable = false;
|
|
|
|
this.startLoading = false;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.startLoading = false;
|
|
|
|
this.$messageBox(this.$t('display.lesson.selectTraining'));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
endCommit() {
|
|
|
|
this.$store.dispatch('training/setStopCountTime');
|
|
|
|
const mode = {
|
|
|
|
mode: this.demoMode,
|
|
|
|
id: this.trainingObj.id,
|
|
|
|
lessonId: this.$route.query.lessonId,
|
|
|
|
usedTime: this.usedTime
|
|
|
|
};
|
|
|
|
|
2020-03-26 18:42:01 +08:00
|
|
|
endTrainingNew(mode, this.group).then(response => {
|
2019-12-30 09:00:16 +08:00
|
|
|
const data = response.data;
|
|
|
|
this.$store.dispatch('training/judgeFinish', data).then(rsp => {
|
|
|
|
this.$store.dispatch('training/emitTipFresh');
|
|
|
|
});
|
|
|
|
}).catch(() => {
|
|
|
|
this.$messageBox(this.$t('display.lesson.endTrainingError'));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
end() {
|
|
|
|
// 如果是测试模式需要获取最终的得分
|
|
|
|
if (this.trainingObj && this.trainingObj.id) {
|
|
|
|
if (this.started) {
|
|
|
|
this.isDisable = false;
|
|
|
|
this.$store.dispatch('training/isStepOver').then((rnt) => {
|
|
|
|
if (rnt) {
|
|
|
|
this.endCommit();
|
|
|
|
} else {
|
|
|
|
this.backDisable = true;
|
|
|
|
this.$confirm(this.$t('display.lesson.endTrainingTip'), this.$t('global.tips'), {
|
|
|
|
cancelButtonText: this.$t('global.cancel'),
|
|
|
|
confirmButtonText: this.$t('global.confirm'),
|
|
|
|
type: 'warning',
|
|
|
|
center: true,
|
|
|
|
zIndex: 9999
|
|
|
|
}).then(() => {
|
|
|
|
this.backDisable = false;
|
|
|
|
this.$store.dispatch('training/end', null);
|
|
|
|
this.$store.dispatch('training/setScore', 0);
|
|
|
|
this.$store.dispatch('training/emitTipFresh');
|
|
|
|
}).catch(() => {
|
|
|
|
this.isDisable = true;
|
|
|
|
this.backDisable = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.$messageBox(this.$t('display.lesson.startTrainingTip'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
back() {
|
|
|
|
this.$emit('quit');
|
|
|
|
Notification.closeAll();
|
|
|
|
|
|
|
|
if (this.$route.params.mode == 'record') {
|
|
|
|
/** 如果是演示返回时,需要重新创建仿真*/
|
2020-03-27 10:51:49 +08:00
|
|
|
trainingNotifyNew({ trainingId: this.$route.query.trainingId }).then(resp => {
|
2019-12-30 09:00:16 +08:00
|
|
|
this.$router.push({ path: `${UrlConfig.lesson.record}/${this.$route.query.trainingId}/${this.$route.query.trainingName}`, query: { group: resp.data } });
|
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(`${this.$t('display.lesson.createSimulationError')}: ${error.message}`);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
history.go(-1);
|
|
|
|
}
|
2019-12-31 13:15:28 +08:00
|
|
|
},
|
2020-04-02 14:46:21 +08:00
|
|
|
switchStationMode(val) {
|
|
|
|
this.$emit('switchStationMode', val);
|
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;
|
|
|
|
left: 160px;
|
|
|
|
height: 32px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.display-card .el-row {
|
|
|
|
line-height: 32px !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.display-mode {
|
|
|
|
display: -moz-inline-box;
|
|
|
|
display: inline-block;
|
|
|
|
|
|
|
|
/deep/ .el-radio-button__inner {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.display-time {
|
|
|
|
background-color: white;
|
|
|
|
display: -moz-inline-box;
|
|
|
|
display: inline-block;
|
|
|
|
text-align: center;
|
|
|
|
font-weight: bold;
|
|
|
|
border: 1px solid lightskyblue;
|
|
|
|
width: 100px;
|
|
|
|
height: 32px;
|
|
|
|
line-height: 24px;
|
|
|
|
border-radius: 4px;
|
|
|
|
margin-left: 10px;
|
|
|
|
font-family: "Microsoft" !important;
|
|
|
|
font-size: 18px !important;
|
|
|
|
color: black;
|
|
|
|
}
|
|
|
|
|
|
|
|
.display-score {
|
|
|
|
background-color: black;
|
|
|
|
display: -moz-inline-box;
|
|
|
|
display: inline-block;
|
|
|
|
text-align: left;
|
|
|
|
border: 1px solid lightskyblue;
|
|
|
|
width: 100px;
|
|
|
|
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;
|
|
|
|
|
|
|
|
.back {
|
|
|
|
z-index: 100000;
|
|
|
|
}
|
|
|
|
|
2020-04-14 14:51:14 +08:00
|
|
|
.start,.end{z-index:2}
|
|
|
|
|
2019-12-30 09:00:16 +08:00
|
|
|
/deep/ .el-button {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|