2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
2019-09-02 15:37:57 +08:00
|
|
|
<div class="mainContext">
|
2019-10-29 17:33:11 +08:00
|
|
|
<div v-if="lessonShow" class="box">
|
|
|
|
<lesson-edit ref="lesson" @refresh="refresh" />
|
|
|
|
</div>
|
|
|
|
<div v-if="chapterShow" class="box">
|
|
|
|
<chapter-edit ref="chapter" @refresh="refresh" />
|
|
|
|
</div>
|
2020-06-28 13:44:04 +08:00
|
|
|
<div v-if="sortTreeShow" class="box">
|
2019-10-29 17:33:11 +08:00
|
|
|
<sort-tree ref="sortTree" @refresh="refresh" />
|
2019-09-02 15:37:57 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-07-26 13:32:43 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-09-02 15:37:57 +08:00
|
|
|
import LessonEdit from './edit/lesson/index';
|
|
|
|
import ChapterEdit from './edit/chapter/index';
|
|
|
|
import SortTree from './edit/sorttree/index';
|
2019-10-10 16:18:31 +08:00
|
|
|
import localStore from 'storejs';
|
2019-07-26 13:32:43 +08:00
|
|
|
|
2019-09-02 15:37:57 +08:00
|
|
|
export default {
|
2019-10-29 17:33:11 +08:00
|
|
|
name: 'LessonDraft',
|
|
|
|
components: {
|
|
|
|
LessonEdit,
|
|
|
|
ChapterEdit,
|
|
|
|
SortTree
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isNew: true,
|
|
|
|
lessonShow: true,
|
|
|
|
chapterShow: false,
|
2020-06-28 13:44:04 +08:00
|
|
|
sortTreeShow: false,
|
2019-10-29 17:33:11 +08:00
|
|
|
menuoper: {},
|
|
|
|
demoObj: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
width() {
|
|
|
|
return this.$store.state.app.width - localStore.get('LeftWidth');
|
|
|
|
},
|
|
|
|
height() {
|
|
|
|
return this.$store.state.app.height - 125;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route() {
|
2020-06-28 13:44:04 +08:00
|
|
|
this.initData();
|
2019-10-29 17:33:11 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2020-06-28 13:44:04 +08:00
|
|
|
this.initData();
|
2019-10-29 17:33:11 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2020-06-28 13:44:04 +08:00
|
|
|
initData() {
|
|
|
|
const data = this.$route.query;
|
|
|
|
this.runFunc(this.$route.params.type, data);
|
|
|
|
},
|
2019-10-29 17:33:11 +08:00
|
|
|
exchangeShow(model) {
|
2020-06-28 13:44:04 +08:00
|
|
|
['lessonShow', 'chapterShow', 'sortTreeShow'].forEach(elem => {
|
2019-10-29 17:33:11 +08:00
|
|
|
if (model[elem]) {
|
|
|
|
this[elem] = true;
|
|
|
|
} else {
|
|
|
|
this[elem] = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2020-06-28 13:44:04 +08:00
|
|
|
runFunc(func, data) {
|
|
|
|
// 策略模式
|
|
|
|
return this[func](data);
|
|
|
|
},
|
|
|
|
toNextPage(type, isCreate, data) {
|
|
|
|
this.isNew = isCreate;
|
|
|
|
const typeShow = {};
|
|
|
|
typeShow[type + 'Show'] = true;
|
|
|
|
this.exchangeShow(typeShow);
|
2019-10-29 17:33:11 +08:00
|
|
|
this.$nextTick(() => {
|
2020-06-28 13:44:04 +08:00
|
|
|
if (type != 'sortTree') {
|
|
|
|
this.$refs[type].initData(isCreate, data);
|
|
|
|
} else {
|
|
|
|
this.$refs[type].initData(data);
|
|
|
|
}
|
2019-10-29 17:33:11 +08:00
|
|
|
});
|
|
|
|
},
|
2020-06-28 13:44:04 +08:00
|
|
|
lessonCreate(data) {
|
|
|
|
this.toNextPage('lesson', true, data);
|
|
|
|
},
|
2019-10-29 17:33:11 +08:00
|
|
|
lessonEdit(data) {
|
2020-06-28 13:44:04 +08:00
|
|
|
this.toNextPage('lesson', false, data);
|
2019-10-29 17:33:11 +08:00
|
|
|
},
|
|
|
|
chapterCreate(data) {
|
2020-06-28 13:44:04 +08:00
|
|
|
this.toNextPage('chapter', true, data);
|
2019-10-29 17:33:11 +08:00
|
|
|
},
|
|
|
|
chapterEdit(data) {
|
2020-06-28 13:44:04 +08:00
|
|
|
this.toNextPage('chapter', false, data);
|
2019-10-29 17:33:11 +08:00
|
|
|
},
|
|
|
|
treeSort(data) {
|
2020-06-28 13:44:04 +08:00
|
|
|
this.toNextPage('sortTree', false, data);
|
2019-10-29 17:33:11 +08:00
|
|
|
},
|
|
|
|
refresh(filterSelect) {
|
|
|
|
this.$emit('refresh');
|
|
|
|
}
|
|
|
|
}
|
2019-09-02 15:37:57 +08:00
|
|
|
};
|
2019-07-26 13:32:43 +08:00
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
@import "src/styles/mixin.scss";
|
2019-10-29 17:33:11 +08:00
|
|
|
.mainContext{
|
2019-10-29 17:36:48 +08:00
|
|
|
display: -webkit-box;
|
2019-10-29 18:55:10 +08:00
|
|
|
height: 100%;
|
2019-10-29 17:33:11 +08:00
|
|
|
overflow-y: auto;
|
|
|
|
.box{
|
2019-10-29 18:55:10 +08:00
|
|
|
height: 100%;
|
|
|
|
display: -webkit-box;
|
2019-10-31 15:44:43 +08:00
|
|
|
width: 100%;
|
2019-10-29 17:33:11 +08:00
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
2019-09-02 15:37:57 +08:00
|
|
|
</style>
|