rt-sim-training-client/src/views/teach/index.vue

159 lines
6.7 KiB
Vue
Raw Normal View History

2019-10-22 13:40:42 +08:00
<template>
<div style="height: 100%; padding-bottom: 20px;">
<el-card>
2020-12-04 13:21:41 +08:00
<div slot="header" class="lessonHeader">
{{ $t('global.lessonSystem') }}
2019-10-22 13:40:42 +08:00
</div>
2021-03-16 19:06:25 +08:00
<el-button v-if="isAdmin && project !== 'cgy'" size="mini" type="primary" style="position: absolute;right: 10px;top: 10px;" @click="draftLessonManage">草稿课程管理</el-button>
2019-10-22 13:40:42 +08:00
</el-card>
<el-card v-loading="loading">
<el-table :data="tableData" border style="width: 100%">
<el-table-column prop="name" :label="project === 'cgy'?'项目名称':this.$t('teach.courseName')" />
<el-table-column v-if="isGzbShow" prop="classNames" label="所属班级">
2020-05-15 18:48:10 +08:00
<template slot-scope="scope">
<el-tag v-for="(item, index) in scope.row.classNames" :key="index" type="success">{{ item }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="remarks" show-overflow-tooltip :label="project === 'cgy'?'项目描述':this.$t('teach.courseDescription')" />
<el-table-column :label="this.$t('global.operate')">
2019-10-22 13:40:42 +08:00
<template slot-scope="scope">
<el-button size="mini" type="primary" @click="goLesson(scope.row)">{{ project === 'cgy'?'进入项目':$t('teach.enterTheCourse') }}</el-button>
2021-03-16 19:06:25 +08:00
<el-button v-if="isAdmin && !scope.row.systemFault" size="mini" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
<!--<el-button v-if="((isCompanyAdmin && userId === scope.row.creatorId) || isAdmin) && !scope.row.systemFault" size="mini" type="warning" @click="handleSoldOut(scope.row)">下架</el-button>-->
2021-03-16 19:06:25 +08:00
<el-button v-if="isAdmin && !scope.row.systemFault" size="mini" type="danger" @click="handleDelete(scope.row)">{{ project === 'cgy'?'删除项目':'删除课程' }}</el-button>
2019-10-22 13:40:42 +08:00
</template>
</el-table-column>
</el-table>
</el-card>
2020-12-25 18:07:15 +08:00
<update-operate ref="updateLesson" :title="$t('publish.updateLesson')" @create="handleUpdate" />
2019-10-22 13:40:42 +08:00
</div>
</template>
<script>
import { getSubSystemDetail } from '@/api/trainingPlatform';
import { UrlConfig } from '@/scripts/ConstDic';
2020-05-15 18:48:10 +08:00
import { forceDeleteLesson } from '@/api/jmap/lesson';
import { getSessionStorage } from '@/utils/auth';
import { lessonCreater, superAdmin, admin } from '@/router/index';
2020-12-25 18:07:15 +08:00
import { putLessonOffLine, updatePublishLesson } from '@/api/jmap/lesson';
import UpdateOperate from '@/views/publish/publishLesson/draft.vue';
2019-10-22 14:28:22 +08:00
import localStore from 'storejs';
2019-10-22 13:40:42 +08:00
export default {
2019-10-29 14:41:47 +08:00
name: 'TeachHome',
2020-12-25 18:07:15 +08:00
components:{
UpdateOperate
},
2019-10-29 14:41:47 +08:00
data() {
return {
tableData: [],
loading: false,
2020-12-25 18:07:15 +08:00
mapId: '',
2021-01-12 13:18:52 +08:00
prdType: '',
cityCode: ''
2019-10-29 14:41:47 +08:00
};
},
computed: {
isGzbShow() {
return getSessionStorage('project').startsWith('gzb');
2020-12-25 18:07:15 +08:00
},
project() {
return getSessionStorage('project');
},
2020-12-25 18:07:15 +08:00
userId() {
return this.$store.state.user.id;
},
isAdmin() {
return this.$store.state.user.roles.includes(admin) || this.$store.state.user.roles.includes(superAdmin);
}
},
2019-10-29 14:41:47 +08:00
watch: {
'$route.params.subSystem': function(newVal) {
this.loadInitPage();
}
},
mounted() {
this.loadInitPage();
},
methods: {
loadInitPage() {
if (this.$route.params.subSystem) {
getSubSystemDetail(this.$route.params.subSystem).then(resp =>{
if (resp.data) {
2020-12-25 18:07:15 +08:00
this.mapId = resp.data.mapId;
this.prdType = resp.data.prdType;
2019-10-29 14:41:47 +08:00
this.tableData = resp.data.lessonList;
2021-01-12 13:18:52 +08:00
this.cityCode = resp.data.cityCode;
2019-10-29 14:41:47 +08:00
} else {
this.tableData = [];
}
}).catch((error)=>{
if (error.code == 30001) {
const url = localStore.get('orignalTrainingPlatformRoute' + this.$store.state.user.id + this.project);
if (url) {
this.$router.push(url);
}
} else {
this.$messageBox(this.$t('error.obtainCourseInformationFailed'));
}
2019-10-29 14:41:47 +08:00
});
}
},
goLesson(row) {
this.$router.push({ path: `${UrlConfig.trainingPlatform.teachDetail}/${this.$route.params.subSystem}`, query: {lessonId: row.id, mapId: row.mapId, prdType: row.prdType}});
},
2020-12-25 18:07:15 +08:00
handleSoldOut(row) {
this.$confirm(this.$t('publish.wellSoldOutTraining'), this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
putLessonOffLine(row.id).then(response => {
this.$message.success(this.$t('publish.operationSuccess'));
this.reloadTable();
}).catch(() => {
this.reloadTable();
this.$messageBox(this.$t('error.operationFailure'));
});
}).catch(() => { });
},
handleEdit(row) {
this.$refs.updateLesson.doShow(row);
},
handleUpdate(data) {
updatePublishLesson(data).then(response => {
this.loadInitPage();
this.$message.success(this.$t('publish.updateSuccess'));
}).catch(() => {
this.$messageBox(this.$t('error.updateFailed'));
});
},
draftLessonManage() {
2021-01-12 13:18:52 +08:00
const query = {mapId: this.mapId, prdType: this.prdType, cityCode: this.cityCode};
2020-12-25 18:07:15 +08:00
this.$router.push({ path: `/trainingPlatform/draftTeach/${this.$route.params.subSystem}`, query: query });
},
handleDelete(row) {
2020-05-15 18:48:10 +08:00
this.$confirm('此操作将删除课程及所有对应的试卷,且无法恢复,是否继续?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
2020-05-15 18:48:10 +08:00
forceDeleteLesson(row.id).then(response => {
this.$message.success(this.$t('publish.deleteSuccess'));
this.loadInitPage();
}).catch((error) => {
this.loadInitPage();
this.$messageBox(this.$t('error.deleteFailed') + ':' + error.message);
});
}).catch(() => { });
2019-10-29 14:41:47 +08:00
}
}
2019-10-22 13:40:42 +08:00
};
</script>
2020-12-04 13:21:41 +08:00
<style lang="scss" scoped>
.lessonHeader{
text-align: center;
font-weight: bold;
}
</style>