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: [
|
|
|
|
{
|
2019-10-23 13:33:09 +08:00
|
|
|
label: this.$t('lesson.updateChapter'),
|
2019-10-22 17:24:41 +08:00
|
|
|
handler: this.updateChapter
|
2019-10-22 19:23:01 +08:00
|
|
|
},
|
|
|
|
{
|
2019-10-23 13:33:09 +08:00
|
|
|
label: this.$t('lesson.createChapter'),
|
2019-10-22 19:49:37 +08:00
|
|
|
handler: this.createChapterInChapter
|
2019-10-22 17:24:41 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
menuLesson: [
|
|
|
|
{
|
2019-10-23 13:33:09 +08:00
|
|
|
label: this.$t('lesson.editCourse'),
|
|
|
|
handler: this.editLesson
|
2019-10-22 17:24:41 +08:00
|
|
|
},
|
|
|
|
{
|
2019-10-23 13:33:09 +08:00
|
|
|
label: this.$t('lesson.createChapter'),
|
|
|
|
handler: this.createChapter
|
2019-10-22 17:24:41 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
},
|
|
|
|
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});
|
|
|
|
},
|
|
|
|
createChapter() {
|
|
|
|
this.$emit('changeRouter', {event: '02', node: this.node});
|
|
|
|
},
|
|
|
|
editLesson() {
|
|
|
|
this.$emit('changeRouter', {event: '01', node: this.node});
|
|
|
|
},
|
2019-10-22 19:49:37 +08:00
|
|
|
createChapterInChapter() {
|
|
|
|
this.$emit('changeRouter', {event: '04', node: this.node});
|
|
|
|
},
|
2019-10-22 17:24:41 +08:00
|
|
|
refresh(filterSelect) {
|
|
|
|
this.$emit('refresh', filterSelect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|