2019-10-22 13:40:42 +08:00
|
|
|
<template>
|
|
|
|
<div style="height: 100%; padding-bottom: 20px">
|
|
|
|
<el-card>
|
|
|
|
<div slot="header" style="text-align: center;">
|
2019-10-23 13:33:09 +08:00
|
|
|
<b>{{ $t('global.examSystem') }}</b>
|
2019-10-22 13:40:42 +08:00
|
|
|
</div>
|
|
|
|
</el-card>
|
|
|
|
<el-card v-loading="loading">
|
2019-11-01 18:08:05 +08:00
|
|
|
<el-table :data="tableData" border style="width: 100%">
|
|
|
|
<el-table-column prop="name" :label="this.$t('exam.courseName')" />
|
2020-05-15 18:48:10 +08:00
|
|
|
<el-table-column prop="classNames" label="所属班级">
|
|
|
|
<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>
|
2019-11-01 18:08:05 +08:00
|
|
|
<el-table-column prop="remarks" show-overflow-tooltip :label="this.$t('exam.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)">
|
2019-10-23 13:33:09 +08:00
|
|
|
{{ $t('exam.enterTheExam') }}
|
2019-10-22 13:40:42 +08:00
|
|
|
</el-button>
|
2020-05-15 18:48:10 +08:00
|
|
|
<el-button v-if="project.endsWith('gzb') && isTeacher && userId === scope.row.creatorId" size="mini" type="danger" @click="handleDelete(scope.row)">
|
2020-05-15 16:26:21 +08:00
|
|
|
删除课程
|
|
|
|
</el-button>
|
2019-10-22 13:40:42 +08:00
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</el-card>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { getSubSystemDetail } from '@/api/trainingPlatform';
|
2020-03-30 13:07:11 +08:00
|
|
|
import { UrlConfig } from '@/scripts/ConstDic';
|
2020-05-15 18:48:10 +08:00
|
|
|
import { forceDeleteLesson } from '@/api/jmap/lesson';
|
2020-05-15 16:26:21 +08:00
|
|
|
import { getSessionStorage } from '@/utils/auth';
|
|
|
|
import { lessonCreater } from '@/router/index_APP_TARGET';
|
2019-10-22 18:49:46 +08:00
|
|
|
import localStore from 'storejs';
|
2019-10-22 13:40:42 +08:00
|
|
|
|
|
|
|
export default {
|
2019-10-31 17:30:24 +08:00
|
|
|
name: 'ExamHome',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
tableData: [],
|
2020-05-15 16:26:21 +08:00
|
|
|
loading: false,
|
|
|
|
project: '',
|
2020-05-15 18:48:10 +08:00
|
|
|
isTeacher: false,
|
|
|
|
userId: ''
|
2019-10-31 17:30:24 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$route.params.subSystem': function(newVal) {
|
|
|
|
this.loadInitPage();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.loadInitPage();
|
2020-05-15 16:26:21 +08:00
|
|
|
this.project = getSessionStorage('project');
|
|
|
|
this.isTeacher = this.$store.state.user.roles.includes(lessonCreater);
|
2020-05-15 18:48:10 +08:00
|
|
|
this.userId = this.$store.state.user.id;
|
2019-10-31 17:30:24 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
loadInitPage() {
|
|
|
|
if (this.$route.params.subSystem) {
|
|
|
|
getSubSystemDetail(this.$route.params.subSystem).then(resp =>{
|
|
|
|
if (resp.data) {
|
|
|
|
this.tableData = resp.data.lessonList;
|
2020-06-30 14:42:56 +08:00
|
|
|
} else {
|
|
|
|
this.tableData = [];
|
2019-10-31 17:30:24 +08:00
|
|
|
}
|
2020-05-12 10:13:27 +08:00
|
|
|
}).catch((error)=>{
|
|
|
|
if (error.code == 30001) {
|
|
|
|
const url = localStore.get('orignalTrainingPlatformRoute' + this.$store.state.user.id);
|
|
|
|
if (url) {
|
|
|
|
this.$router.push(url);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.$messageBox(this.$t('error.obtainCourseInformationFailed'));
|
|
|
|
}
|
2019-10-31 17:30:24 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
goLesson(row) {
|
|
|
|
localStore.set('examDetail' + this.$route.params.subSystem, `${UrlConfig.trainingPlatform.course}/${this.$route.params.subSystem}?lessonId=${row.id}`);
|
|
|
|
this.$router.push({ path: `${UrlConfig.trainingPlatform.course}/${this.$route.params.subSystem}`, query: {lessonId: row.id}});
|
2020-05-15 16:26:21 +08:00
|
|
|
},
|
|
|
|
handleDelete(row) {
|
2020-05-15 18:48:10 +08:00
|
|
|
this.$confirm('此操作将删除课程及所有对应的试卷,且无法恢复,是否继续?', this.$t('global.tips'), {
|
2020-05-15 16:26:21 +08:00
|
|
|
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 => {
|
2020-05-15 16:26:21 +08:00
|
|
|
this.$message.success(this.$t('publish.deleteSuccess'));
|
|
|
|
this.loadInitPage();
|
|
|
|
}).catch((error) => {
|
|
|
|
this.loadInitPage();
|
|
|
|
this.$messageBox(this.$t('error.deleteFailed') + ':' + error.message);
|
|
|
|
});
|
|
|
|
}).catch(() => { });
|
2019-10-31 17:30:24 +08:00
|
|
|
}
|
|
|
|
}
|
2019-10-22 13:40:42 +08:00
|
|
|
};
|
|
|
|
</script>
|