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

157 lines
5.1 KiB
Vue
Raw Normal View History

2019-12-31 13:15:28 +08:00
<template>
<div id="leftSlider" class="left-slider">
<div class="tip-title">
<span>
2020-01-06 14:43:08 +08:00
{{ $t('display.lesson.coursePracticeList') }}
2019-12-31 13:15:28 +08:00
</span>
</div>
<div class="handleShow">
2020-01-06 14:43:08 +08:00
<span v-if="show" class="el-icon-arrow-right" @click="handleSliderShow(true)">{{ $t('display.lesson.unfold') }}</span>
<span v-else class="el-icon-arrow-left" @click="handleSliderShow(false)">{{ $t('display.lesson.fold') }}</span>
2019-12-31 13:15:28 +08:00
</div>
<div class="slider-tree">
2020-04-14 14:51:14 +08:00
<el-scrollbar wrap-class="scrollbar-wrapper" style="background: #fff;">
2019-12-31 13:15:28 +08:00
<el-tree
ref="tree"
style="margin-top: 10px"
:data="treeList"
node-key="id"
:props="defaultProps"
:filter-node-method="filterNode"
highlight-current
:span="22"
default-expand-all
@node-click="clickEvent"
>
<span slot-scope="{ node }">
<span v-if="node.data.type === 'Training'" class="el-icon-goods" />
<span v-if="node.data.id === trainingId" :style="{color: 'red'}">&nbsp;{{ node.data.name }}</span>
<span v-else-if="node.data.valid" :style="{color: 'green'}">&nbsp;{{ node.data.name }}</span>
<span v-else>&nbsp;{{ node.data.name }}</span>
</span>
</el-tree>
</el-scrollbar>
</div>
</div>
</template>
<script>
import { getPublishLessonTree } from '@/api/jmap/lesson';
2020-03-27 10:51:49 +08:00
import { trainingNotifyNew } from '@/api/simulation';
2019-12-31 13:15:28 +08:00
import { launchFullscreen } from '@/utils/screen';
import { UrlConfig } from '@/scripts/ConstDic';
2019-12-31 13:15:28 +08:00
export default {
name: 'LeftSlider',
2020-04-14 14:51:14 +08:00
props:{
offsetBottom:{
type: Number,
required: true
}
},
2019-12-31 13:15:28 +08:00
data() {
return {
show: true,
treeList: []
};
},
computed: {
trainingId () {
return this.$route.query.trainingId;
}
},
mounted() {
this.initLoadPage();
2020-04-14 14:51:14 +08:00
// this.$nextTick(() => {
// document.querySelector('.left-slider').style.height = document.querySelector('.left-slider').offsetHeight - this.offsetBottom + 'px';
// });
2019-12-31 13:15:28 +08:00
},
methods: {
initLoadPage() {
getPublishLessonTree(this.$route.query.lessonId).then(response => {
if (response.data.tree && response.data.tree.length > 0) {
this.treeList = response.data.tree;
}
}).catch(error => {
this.$message.error(this.$t('tip.failedCourse') + ':' + error.message);
});
},
handleSliderShow(flag) {
this.$emit('overallTranslation', flag);
const slider = document.getElementById('leftSlider');
if (flag) {
2020-04-14 14:51:14 +08:00
slider.style.transform = 'translateX(0)';
2019-12-31 13:15:28 +08:00
this.show = false;
} else {
2020-04-14 14:51:14 +08:00
slider.style.transform = '';
2019-12-31 13:15:28 +08:00
this.show = true;
}
},
clickEvent(obj, node, ele) {
if (obj && obj.type === 'Training') {
if (obj.valid) {
this.disabled = true;
2020-03-27 10:51:49 +08:00
trainingNotifyNew({ trainingId: obj.id }).then(resp => {
2019-12-31 13:15:28 +08:00
const query = {
2020-04-14 14:51:14 +08:00
group: resp.data, trainingId: obj.id, lessonId: this.$route.query.lessonId, mapId: this.$route.query.mapId, lineCode:this.$route.query.lineCode
2019-12-31 13:15:28 +08:00
};
2020-04-14 14:51:14 +08:00
this.$router.replace({ path: `${UrlConfig.displayNew}/teach`, query: query });
2019-12-31 13:15:28 +08:00
launchFullscreen();
}).catch(error => {
this.$messageBox(`${this.$t('tip.createSimulationFaild')} : ${error.message}`);
this.disabled = false;
});
} else {
this.$confirm(this.$t('tip.accessCourseNo'), this.$t('tip.hint'), {
confirmButtonText: this.$t('tip.confirm'),
cancelButtonText: this.$t('tip.cancel')
}).then(() => {
// this.buy();
}).catch(() => { });
}
}
}
}
};
</script>
<style scoped>
.left-slider{
z-index: 10;
width: 400px;
height: 100%;
position: absolute;
left: 0;
top: 0;
transform: translateX(-400px);
}
.slider-tree{
height: calc(100% - 40px);
border: 2px solid #409EFF;
}
.handleShow{
position: absolute;
left: 400px;
top: 50%;
2020-04-14 14:51:14 +08:00
background: #fff;
color: #000;
border-radius: 3px;
box-shadow: 3px 1px 5px #000;
padding: 3px;
2019-12-31 13:15:28 +08:00
}
.tip-title {
width: 100%;
overflow: hidden;
height: 40px;
display: flex;
align-items: center;
flex-direction: row-reverse;
background-color: #409EFF;
border-radius: 5px 5px 0 0;
justify-content: center;
padding: 0 10px;
color: #fff;
font-size: 18px;
text-align: center;
}
</style>