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

121 lines
3.3 KiB
Vue
Raw Normal View History

2019-10-22 17:24:41 +08:00
<template>
<div>
<pop-menu ref="popMenu" :menu="menu" />
</div>
</template>
<script>
import { DeviceMenu } from '@/scripts/ConstDic';
import PopMenu from '@/components/PopMenu';
export default {
name: 'TrainingOperateMenu',
components: {
PopMenu
},
props: {
point: {
type: Object,
required: true
},
node: {
type: Object,
required: true
}
},
data() {
return {
menuShow: false,
menu: [],
menuChapte: [
{
label: this.$t('lesson.updateChapter'),
handler: this.updateChapter
},
{
label: this.$t('lesson.createChapter'),
handler: this.createChapterInChapter
2020-05-18 15:47:55 +08:00
},
{
label: '删除章节',
handler: this.deleteChapter
}
],
menuLesson: [
{
label: this.$t('lesson.editCourse'),
handler: this.editLesson
},
{
label: this.$t('lesson.createChapter'),
handler: this.createChapter
}
]
};
},
watch: {
node: function (val, old) {
if (val && val.data) {
switch (val.data.type) {
case 'Lesson':
this.menu = this.menuLesson;
break;
case 'Chapter':
this.menu = this.menuChapte;
break;
}
}
},
'$store.state.menuOperation.menuCount': function (val) {
if (this.$store.getters['menuOperation/checkDialogIsOpen'](DeviceMenu.Lesson)) {
this.doShow(this.$store.state.menuOperation.menuPosition);
} else {
this.doClose();
}
}
},
mounted() {
this.closeEvent();
},
methods: {
closeEvent() {
const self = this;
window.onclick = function (e) {
self.doClose();
};
},
doShow(point) {
this.closeEvent();
if (this.$refs && this.$refs.popMenu) {
this.$refs.popMenu.resetShowPosition(point);
}
this.menuShow = true;
},
doClose() {
if (this.$refs && this.$refs.popMenu) {
this.$refs.popMenu.close();
}
this.menuShow = false;
},
updateChapter() {
this.$emit('changeRouter', {event: '03', node: this.node});
},
2020-05-18 15:47:55 +08:00
deleteChapter() {
this.$emit('changeRouter', {event: '05', node: this.node});
},
createChapter() {
this.$emit('changeRouter', {event: '02', node: this.node});
},
editLesson() {
this.$emit('changeRouter', {event: '01', node: this.node});
},
createChapterInChapter() {
this.$emit('changeRouter', {event: '04', node: this.node});
},
refresh(filterSelect) {
this.$emit('refresh', filterSelect);
}
}
2019-10-22 17:24:41 +08:00
};
</script>