rt-sim-training-client/src/views/lesson/home.vue
2019-09-30 13:24:47 +08:00

167 lines
6.4 KiB
Vue

<template>
<div style="height: 100%; overflow: hidden">
<el-card>
<div class="button_group">
<el-button size="mini" @click="trainingRecord">实训录制</el-button>
<el-button size="mini" @click="trainingManage">实训管理</el-button>
<el-button size="mini" @click="taskManage">任务管理</el-button>
<el-button size="mini" @click="operationManage">操作定义</el-button>
<el-button size="mini" type="primary" @click="lessonCreateByPublish">从发布课程新建</el-button>
<el-button size="mini" type="primary" @click="lessonCreate">新建</el-button>
<el-button size="mini" type="primary" >查询</el-button>
</div>
</el-card>
<el-card v-loading="loading">
<el-table
:data="tableData"
row-key="id"
border
default-expand-all
:tree-props="{children: 'children', hasChildren: 'hasChildren'}">
<el-table-column
prop="name"
border
label="课程">
</el-table-column>
<el-table-column
label="操作">
<template slot-scope="scope">
<el-button
size="mini"
type="primary"
v-if="scope.row.type === 'lesson'"
@click="createChapter(scope.row)"
>创建章节</el-button>
<el-button
size="mini"
type="primary" plain
v-if="scope.row.type === 'lesson'"
@click="treeSort(scope.row)"
>内容排序</el-button>
<el-button size="mini"
type="info"
@click="editLesson(scope.row,scope)"
>{{ scope.row.type==='lesson'? '编辑课程':'更新章节' }}</el-button>
<el-button size="mini"
type="primary"
v-if="scope.row.type === 'lesson'"
@click="publish(scope.row)"
>{{$t('global.release')}}</el-button>
<el-button size="mini"
type="danger"
v-if="scope.row.type === 'lesson'"
@click="deleteLesson(scope.row)"
>{{$t('global.delete')}}</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
<publish-create ref="publishCreate" />
<publish-lesson ref="publishLesson" />
</div>
</template>
<script>
import { getDraftLesson } from '@/api/designPlatform';
import { UrlConfig } from '@/router/index';
import PublishCreate from './lessoncategory/edit/create';
import PublishLesson from './lessoncategory/edit/lesson/publish';
import { delLesson } from '@/api/jmap/lessondraft';
export default {
name: 'LessonHome',
components: {
PublishCreate,
PublishLesson
},
computed: {
mapId() {
return this.$route.params.mapId;
}
},
data() {
return {
tableData: [],
loading: false,
showEdit: false
};
},
mounted() {
this.loading = true;
this.loadInitData();
},
methods: {
loadInitData() {
getDraftLesson({},this.mapId).then(response=> {
response.data.forEach(elem => {
if (elem.children) {
elem.children.forEach( it => {
it.parentId = elem.id;
} )
}
});
this.tableData = response.data;
this.loading = false;
});
},
editLesson(row,scope) {
if (row.type === 'lesson') {
this.$router.push( {path: `${UrlConfig.design.lessonEdit}/lessonEdit`, query: {id: row.id, skinCode: row.code}} )
} else if (row.type === 'chapter') {
this.$router.push( {path: `${UrlConfig.design.lessonEdit}/chapterEdit`,query: {id: row.id, lessonId: row.parentId}} )
}
},
lessonCreate() {
this.$router.push({ path: `${UrlConfig.design.lessonEdit}/lessonCreate`,query: {skinCode: this.$route.params.skinCode} })
},
lessonCreateByPublish() {
this.$nextTick(() => {
this.$refs.publishCreate.doShow();
});
},
publish(row) {
row.skinCode = this.$route.params.skinCode;
this.$refs.publishLesson.doShow(row);
},
deleteLesson(row) {
delLesson(row).then(response => {
this.$message.success(this.$t('tip.successfullyDelete'));
}).catch(error => {
this.$messageBox(this.$t('tip.failDelete'))
});
},
createChapter(row) {
this.$router.push({path: `${UrlConfig.design.lessonEdit}/chapterCreate`, query: {lessonId: row.id}});
},
treeSort(row){
this.$router.push({path: `${UrlConfig.design.lessonEdit}/treeSort`, query: {id: row.id}});
},
trainingRecord() {
},
taskManage() {
this.$router.push({path: `${UrlConfig.design.taskManage}`})
},
trainingManage() {
this.$router.push({path: `${UrlConfig.design.trainingManage}`})
},
operationManage() {
this.$router.push({path: `${UrlConfig.design.trainingRule}`})
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.draft {
width: 400px;
text-align: center;
margin: 20px auto;
}
.button_group {
float: right;
margin: 20px 10px;
}
</style>