2019-09-26 15:08:53 +08:00
|
|
|
<template>
|
2019-09-29 15:55:01 +08:00
|
|
|
<div style="height: 100%; overflow: hidden">
|
|
|
|
<el-card>
|
|
|
|
<div class="button_group">
|
2019-10-10 13:02:43 +08:00
|
|
|
<el-button size="mini" v-if="hasRelease" @click="trainingManage">{{$t('lesson.trainingManage')}}</el-button>
|
|
|
|
<el-button size="mini" v-if="hasRelease" @click="taskManage">{{$t('lesson.taskManage')}}</el-button>
|
|
|
|
<el-button size="mini" v-if="hasRelease" @click="operationManage">{{$t('lesson.trainingRule')}}</el-button>
|
|
|
|
<el-button size="mini" type="primary" @click="lessonCreateByPublish">{{$t('lesson.createNewCoursesFromRelease')}}</el-button>
|
|
|
|
<el-button size="mini" type="primary" @click="lessonCreate">{{$t('lesson.newConstruction')}}</el-button>
|
2019-09-29 15:55:01 +08:00
|
|
|
</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
|
2019-10-10 13:02:43 +08:00
|
|
|
:label="this.$t('lesson.lesson')">
|
2019-09-29 15:55:01 +08:00
|
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
2019-10-10 13:02:43 +08:00
|
|
|
:label="this.$t('global.operate')">
|
2019-09-29 15:55:01 +08:00
|
|
|
<template slot-scope="scope">
|
|
|
|
<el-button
|
|
|
|
size="mini"
|
|
|
|
type="primary"
|
2019-09-30 13:24:47 +08:00
|
|
|
@click="createChapter(scope.row)"
|
2019-10-10 13:02:43 +08:00
|
|
|
>{{ scope.row.type==='lesson'? $t('lesson.createChapter'):$t('lesson.updateChapter')}}</el-button>
|
2019-09-29 15:55:01 +08:00
|
|
|
<el-button
|
|
|
|
size="mini"
|
|
|
|
type="primary" plain
|
|
|
|
v-if="scope.row.type === 'lesson'"
|
2019-09-30 13:24:47 +08:00
|
|
|
@click="treeSort(scope.row)"
|
2019-10-10 13:02:43 +08:00
|
|
|
>{{$t('lesson.contentSorting')}}</el-button>
|
2019-09-29 15:55:01 +08:00
|
|
|
<el-button size="mini"
|
|
|
|
type="info"
|
2019-09-30 16:20:31 +08:00
|
|
|
v-if="scope.row.type === 'lesson'"
|
|
|
|
@click="editLesson(scope.row)"
|
2019-10-10 13:02:43 +08:00
|
|
|
>{{$t('lesson.editCourse')}}</el-button>
|
2019-09-30 13:24:47 +08:00
|
|
|
<el-button size="mini"
|
|
|
|
type="primary"
|
|
|
|
v-if="scope.row.type === 'lesson'"
|
|
|
|
@click="publish(scope.row)"
|
2019-10-10 13:02:43 +08:00
|
|
|
>{{hasRelease?$t('global.release'):$t('lesson.applicationForRelease')}}</el-button>
|
2019-09-30 13:24:47 +08:00
|
|
|
<el-button size="mini"
|
|
|
|
type="danger"
|
|
|
|
v-if="scope.row.type === 'lesson'"
|
|
|
|
@click="deleteLesson(scope.row)"
|
|
|
|
>{{$t('global.delete')}}</el-button>
|
2019-09-29 15:55:01 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</el-card>
|
2019-09-30 16:20:31 +08:00
|
|
|
<publish-create @refresh="refresh" ref="publishCreate" />
|
2019-09-30 13:24:47 +08:00
|
|
|
<publish-lesson ref="publishLesson" />
|
2019-09-29 14:27:58 +08:00
|
|
|
</div>
|
2019-09-26 15:08:53 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-09-29 14:27:58 +08:00
|
|
|
import { getDraftLesson } from '@/api/designPlatform';
|
2019-09-30 13:24:47 +08:00
|
|
|
import { UrlConfig } from '@/router/index';
|
|
|
|
import PublishCreate from './lessoncategory/edit/create';
|
|
|
|
import PublishLesson from './lessoncategory/edit/lesson/publish';
|
|
|
|
import { delLesson } from '@/api/jmap/lessondraft';
|
|
|
|
|
2019-09-26 15:08:53 +08:00
|
|
|
|
|
|
|
export default {
|
2019-09-29 14:27:58 +08:00
|
|
|
name: 'LessonHome',
|
2019-09-26 15:08:53 +08:00
|
|
|
components: {
|
2019-09-30 13:24:47 +08:00
|
|
|
PublishCreate,
|
|
|
|
PublishLesson
|
2019-09-26 15:08:53 +08:00
|
|
|
},
|
|
|
|
computed: {
|
2019-09-29 14:27:58 +08:00
|
|
|
mapId() {
|
|
|
|
return this.$route.params.mapId;
|
2019-10-10 13:02:43 +08:00
|
|
|
},
|
|
|
|
hasRelease() {
|
|
|
|
return this.$store.state.user.roles.includes('04') ||
|
|
|
|
this.$store.state.user.roles.includes('05');
|
2019-09-26 15:08:53 +08:00
|
|
|
}
|
|
|
|
},
|
2019-09-29 14:27:58 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2019-09-29 15:55:01 +08:00
|
|
|
tableData: [],
|
2019-09-30 13:24:47 +08:00
|
|
|
loading: false,
|
|
|
|
showEdit: false
|
2019-09-29 14:27:58 +08:00
|
|
|
};
|
2019-09-26 15:08:53 +08:00
|
|
|
},
|
2019-09-30 17:56:16 +08:00
|
|
|
watch: {
|
|
|
|
$route() {
|
|
|
|
this.refresh();
|
|
|
|
}
|
|
|
|
},
|
2019-09-26 15:08:53 +08:00
|
|
|
mounted() {
|
2019-09-29 15:55:01 +08:00
|
|
|
this.loading = true;
|
2019-09-29 14:27:58 +08:00
|
|
|
this.loadInitData();
|
2019-09-26 15:08:53 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2019-09-29 14:27:58 +08:00
|
|
|
loadInitData() {
|
|
|
|
getDraftLesson({},this.mapId).then(response=> {
|
2019-09-30 13:24:47 +08:00
|
|
|
response.data.forEach(elem => {
|
|
|
|
if (elem.children) {
|
|
|
|
elem.children.forEach( it => {
|
|
|
|
it.parentId = elem.id;
|
|
|
|
} )
|
|
|
|
}
|
|
|
|
});
|
2019-09-29 15:55:01 +08:00
|
|
|
this.tableData = response.data;
|
|
|
|
this.loading = false;
|
2019-09-29 14:27:58 +08:00
|
|
|
});
|
2019-09-30 13:24:47 +08:00
|
|
|
},
|
2019-09-30 16:20:31 +08:00
|
|
|
refresh() {
|
|
|
|
this.loading = true;
|
|
|
|
this.loadInitData();
|
|
|
|
},
|
|
|
|
editLesson(row) {
|
|
|
|
this.$router.push( {path: `${UrlConfig.design.lessonEdit}/lessonEdit`, query: {id: row.id, skinCode: row.code}} )
|
2019-09-30 13:24:47 +08:00
|
|
|
},
|
|
|
|
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;
|
2019-10-10 16:07:13 +08:00
|
|
|
row.cityCode = this.$route.query.cityCode;
|
2019-09-30 13:24:47 +08:00
|
|
|
this.$refs.publishLesson.doShow(row);
|
|
|
|
},
|
|
|
|
deleteLesson(row) {
|
|
|
|
delLesson(row).then(response => {
|
|
|
|
this.$message.success(this.$t('tip.successfullyDelete'));
|
2019-09-30 16:20:31 +08:00
|
|
|
this.loading = true;
|
|
|
|
this.loadInitData();
|
2019-09-30 13:24:47 +08:00
|
|
|
}).catch(error => {
|
|
|
|
this.$messageBox(this.$t('tip.failDelete'))
|
|
|
|
});
|
|
|
|
},
|
|
|
|
createChapter(row) {
|
2019-09-30 16:20:31 +08:00
|
|
|
if (row.type === 'lesson') {
|
|
|
|
this.$router.push({path: `${UrlConfig.design.lessonEdit}/chapterCreate`, query: {lessonId: row.id}});
|
|
|
|
} else if (row.type === 'chapter') {
|
|
|
|
this.$router.push( {path: `${UrlConfig.design.lessonEdit}/chapterEdit`,query: {id: row.id, lessonId: row.parentId}} )
|
|
|
|
}
|
2019-09-30 13:24:47 +08:00
|
|
|
},
|
|
|
|
treeSort(row){
|
2019-09-30 16:20:31 +08:00
|
|
|
this.$router.push({path: `${UrlConfig.design.lessonEdit}/treeSort`, query: row});
|
2019-09-30 13:24:47 +08:00
|
|
|
},
|
|
|
|
taskManage() {
|
2019-10-10 09:33:56 +08:00
|
|
|
this.$router.push({path: `${UrlConfig.design.taskManage}`, query: {mapId: this.$route.params.mapId, skinCode: this.$route.params.skinCode}})
|
2019-09-30 13:24:47 +08:00
|
|
|
},
|
|
|
|
trainingManage() {
|
2019-10-09 15:14:00 +08:00
|
|
|
this.$router.push({path: `${UrlConfig.design.trainingManage}/${this.$route.params.skinCode}`, query: {mapId: this.$route.params.mapId}})
|
2019-09-30 13:24:47 +08:00
|
|
|
},
|
|
|
|
operationManage() {
|
2019-10-10 09:33:56 +08:00
|
|
|
this.$router.push({path: `${UrlConfig.design.trainingRule}`, query: {mapId: this.$route.params.mapId, skinCode: this.$route.params.skinCode}})
|
2019-09-26 15:08:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
2019-09-29 14:27:58 +08:00
|
|
|
.draft {
|
|
|
|
width: 400px;
|
2019-09-26 15:08:53 +08:00
|
|
|
text-align: center;
|
2019-09-29 14:27:58 +08:00
|
|
|
margin: 20px auto;
|
2019-09-26 15:08:53 +08:00
|
|
|
}
|
2019-09-29 15:55:01 +08:00
|
|
|
.button_group {
|
|
|
|
float: right;
|
2019-09-30 13:24:47 +08:00
|
|
|
margin: 20px 10px;
|
2019-09-29 15:55:01 +08:00
|
|
|
}
|
2019-09-26 15:08:53 +08:00
|
|
|
</style>
|