rt-sim-training-client/src/views/lesson/details.vue

148 lines
3.9 KiB
Vue
Raw Normal View History

2019-10-22 13:40:42 +08:00
<template>
2019-10-22 16:05:58 +08:00
<el-card>
<div slot="header" style="text-align: center;">
<b>{{ $t('lesson.courseName') + ': '+ name }}</b>
</div>
<div style="display: flex;align-items:flex-start">
<div class="tree_box">
2019-10-23 15:01:25 +08:00
<div style="border: 2px dashed #B0C4DE">
<p>{{ this.$t('lesson.courseTree') }}</p>
<el-scrollbar wrap-class="scrollbar-wrapper" :style="{ height: (height-80) +'px' }">
<el-tree
ref="tree"
style="width: 370px"
:data="treeList"
node-key="id"
:props="defaultProps"
default-expand-all
highlight-current
:span="22"
:filter-node-method="filterNode"
:default-expanded-keys="expandList"
@node-contextmenu="showContextMenu"
@node-click="clickEvent"
/>
</el-scrollbar>
</div>
2019-10-22 16:05:58 +08:00
</div>
<transition>
2019-10-22 17:24:41 +08:00
<router-view @refresh="refresh" />
2019-10-22 16:05:58 +08:00
</transition>
</div>
2019-10-22 17:24:41 +08:00
<operate-menu ref="menu" :point="point" :node="node" @refresh="refresh" @changeRouter="changeRouter" />
2019-10-22 16:05:58 +08:00
</el-card>
2019-10-22 13:40:42 +08:00
</template>
<script>
2019-10-22 14:28:22 +08:00
import { getLessonTree } from '@/api/jmap/lessondraft';
2019-10-22 16:05:58 +08:00
import { DeviceMenu } from '@/scripts/ConstDic';
2019-10-22 17:24:41 +08:00
import OperateMenu from './operateMenu';
2019-10-22 13:40:42 +08:00
export default {
name: 'LessonDetail',
2019-10-22 17:24:41 +08:00
components: {
OperateMenu
},
2019-10-22 13:40:42 +08:00
data() {
return {
2019-10-22 16:05:58 +08:00
treeList: [],
defaultProps: {
children: 'children',
2019-10-22 17:24:41 +08:00
label: 'name'
2019-10-22 16:05:58 +08:00
},
name: '',
lessonId: '',
2019-10-22 17:24:41 +08:00
expandList: [],
point: {
x: 0,
y: 0
},
node: {
}
2019-10-22 13:40:42 +08:00
};
},
2019-10-22 14:28:22 +08:00
computed: {
width() {
return this.$store.state.app.width - 481 - this.widthLeft;
},
height() {
2019-10-22 16:05:58 +08:00
return this.$store.state.app.height - 120;
2019-10-22 14:28:22 +08:00
}
},
mounted() {
this.initPageData();
},
2019-10-22 13:40:42 +08:00
methods: {
2019-10-22 14:28:22 +08:00
initPageData() {
2019-10-22 16:05:58 +08:00
getLessonTree(this.$route.query.lessonId || this.$route.query.id).then(resp => {
if (resp.data && resp.data[0]) {
this.name = resp.data[0].name;
this.lessonId = resp.data[0].id;
this.treeList = resp.data;
}
this.editLesson();
});
},
clickEvent(obj, node, ele) {
},
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
},
editLesson() {
2019-10-22 17:24:41 +08:00
this.$router.push( {path: `/design/lesson/details/edit/lessonEdit`, query: {id: this.lessonId, skinCode: this.$route.query.skinCode, cityCode: this.$route.query.cityCode, mapId: this.$route.query.mapId}} );
},
2019-10-22 19:23:01 +08:00
createChapte(node) {
this.$router.push({path: `/design/lesson/details/edit/chapterCreate`, query: {id: node.data.id, lessonId: this.lessonId, skinCode: this.$route.query.skinCode, cityCode: this.$route.query.cityCode, mapId: this.$route.query.mapId}});
2019-10-22 16:05:58 +08:00
},
2019-10-22 17:24:41 +08:00
updateChapte(node) {
this.$router.push( {path: `/design/lesson/details/edit/chapterEdit`, query: {id: node.data.id, skinCode: this.$route.query.skinCode, lessonId: this.lessonId, cityCode: this.$route.query.cityCode, mapId: this.$route.query.mapId}});
2019-10-22 16:05:58 +08:00
},
showContextMenu(e, obj, node, vueElem) {
2019-10-22 17:24:41 +08:00
if (obj && obj.type === 'Lesson' || obj.type === 'Chapter') {
2019-10-22 16:05:58 +08:00
e.preventDefault();
this.point = {
x: e.clientX,
y: e.clientY
};
this.node = node;
2019-10-22 17:24:41 +08:00
const menu = DeviceMenu.Lesson;
2019-10-22 16:05:58 +08:00
this.$store.dispatch('menuOperation/setPopMenu', { position: this.point, menu: menu });
}
2019-10-22 17:24:41 +08:00
},
changeRouter(params) {
switch (params.event) {
case '01':
this.editLesson();
break;
case '02':
2019-10-22 19:23:01 +08:00
this.createChapte(params.node);
2019-10-22 17:24:41 +08:00
break;
case '03':
this.updateChapte(params.node);
break;
2019-10-22 19:49:37 +08:00
case '04':
this.createChapte(params.node);
break;
2019-10-22 17:24:41 +08:00
}
},
refresh() {
this.initPageData();
2019-10-22 14:28:22 +08:00
}
2019-10-22 13:40:42 +08:00
}
};
</script>
2019-10-22 16:05:58 +08:00
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.tree_box{
position: relative;
left: 10px;
width: 400px;
2019-10-23 15:01:25 +08:00
padding-right: 20px;
padding-top: 20px;
2019-10-22 16:05:58 +08:00
}
.right_box{
}
</style>