rt-sim-training-client/src/views/lesson/lessoncategory/index.vue

119 lines
3.0 KiB
Vue
Raw Normal View History

2019-07-26 13:32:43 +08:00
<template>
<div class="mainContext">
<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">
<sort-tree ref="sortTree" @refresh="refresh" />
</div>
</div>
2019-07-26 13:32:43 +08:00
</template>
<script>
import LessonEdit from './edit/lesson/index';
import ChapterEdit from './edit/chapter/index';
import SortTree from './edit/sorttree/index';
import localStore from 'storejs';
2019-07-26 13:32:43 +08:00
export default {
name: 'LessonDraft',
components: {
LessonEdit,
ChapterEdit,
SortTree
},
data() {
return {
isNew: true,
lessonShow: true,
chapterShow: false,
2020-06-28 13:44:04 +08:00
sortTreeShow: false,
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();
}
},
mounted() {
2020-06-28 13:44:04 +08:00
this.initData();
},
methods: {
2020-06-28 13:44:04 +08:00
initData() {
const data = this.$route.query;
this.runFunc(this.$route.params.type, data);
},
exchangeShow(model) {
2020-06-28 13:44:04 +08:00
['lessonShow', 'chapterShow', 'sortTreeShow'].forEach(elem => {
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);
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);
}
});
},
2020-06-28 13:44:04 +08:00
lessonCreate(data) {
this.toNextPage('lesson', true, data);
},
lessonEdit(data) {
2020-06-28 13:44:04 +08:00
this.toNextPage('lesson', false, data);
},
chapterCreate(data) {
2020-06-28 13:44:04 +08:00
this.toNextPage('chapter', true, data);
},
chapterEdit(data) {
2020-06-28 13:44:04 +08:00
this.toNextPage('chapter', false, data);
},
treeSort(data) {
2020-06-28 13:44:04 +08:00
this.toNextPage('sortTree', false, data);
},
refresh(filterSelect) {
this.$emit('refresh');
}
}
};
2019-07-26 13:32:43 +08:00
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.mainContext{
display: -webkit-box;
2019-10-29 18:55:10 +08:00
height: 100%;
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-07-26 13:32:43 +08:00
}
</style>