This commit is contained in:
zyy 2020-05-15 16:55:14 +08:00
commit dc783bd2a8
2 changed files with 53 additions and 2 deletions

View File

@ -14,6 +14,9 @@
<el-button size="mini" type="primary" @click="goLesson(scope.row)"> <el-button size="mini" type="primary" @click="goLesson(scope.row)">
{{ $t('exam.enterTheExam') }} {{ $t('exam.enterTheExam') }}
</el-button> </el-button>
<el-button v-if="project.endsWith('gzb') && isTeacher" size="mini" type="danger" @click="handleDelete(scope.row)">
删除课程
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -24,6 +27,9 @@
<script> <script>
import { getSubSystemDetail } from '@/api/trainingPlatform'; import { getSubSystemDetail } from '@/api/trainingPlatform';
import { UrlConfig } from '@/scripts/ConstDic'; import { UrlConfig } from '@/scripts/ConstDic';
import { delPublishLesson } from '@/api/jmap/lesson';
import { getSessionStorage } from '@/utils/auth';
import { lessonCreater } from '@/router/index_APP_TARGET';
import localStore from 'storejs'; import localStore from 'storejs';
export default { export default {
@ -31,7 +37,9 @@ export default {
data() { data() {
return { return {
tableData: [], tableData: [],
loading: false loading: false,
project: '',
isTeacher: false
}; };
}, },
watch: { watch: {
@ -41,6 +49,9 @@ export default {
}, },
mounted() { mounted() {
this.loadInitPage(); this.loadInitPage();
this.project = getSessionStorage('project');
this.isTeacher = this.$store.state.user.roles.includes(lessonCreater);
console.log(this.$store.state.user.roles, lessonCreater, this.isTeacher);
}, },
methods: { methods: {
loadInitPage() { loadInitPage() {
@ -64,6 +75,21 @@ export default {
goLesson(row) { goLesson(row) {
localStore.set('examDetail' + this.$route.params.subSystem, `${UrlConfig.trainingPlatform.course}/${this.$route.params.subSystem}?lessonId=${row.id}`); 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}}); this.$router.push({ path: `${UrlConfig.trainingPlatform.course}/${this.$route.params.subSystem}`, query: {lessonId: row.id}});
},
handleDelete(row) {
this.$confirm('此操作将删除该类型, 是否继续?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
delPublishLesson(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(() => { });
} }
} }
}; };

View File

@ -14,6 +14,9 @@
<el-button size="mini" type="primary" @click="goLesson(scope.row)"> <el-button size="mini" type="primary" @click="goLesson(scope.row)">
{{ $t('teach.enterTheCourse') }} {{ $t('teach.enterTheCourse') }}
</el-button> </el-button>
<el-button v-if="project.endsWith('gzb') && isTeacher" size="mini" type="danger" @click="handleDelete(scope.row)">
删除课程
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -24,6 +27,9 @@
<script> <script>
import { getSubSystemDetail } from '@/api/trainingPlatform'; import { getSubSystemDetail } from '@/api/trainingPlatform';
import { UrlConfig } from '@/scripts/ConstDic'; import { UrlConfig } from '@/scripts/ConstDic';
import { delPublishLesson } from '@/api/jmap/lesson';
import { getSessionStorage } from '@/utils/auth';
import { lessonCreater } from '@/router/index_APP_TARGET';
import localStore from 'storejs'; import localStore from 'storejs';
export default { export default {
@ -31,7 +37,9 @@ export default {
data() { data() {
return { return {
tableData: [], tableData: [],
loading: false loading: false,
project: '',
isTeacher: false
}; };
}, },
watch: { watch: {
@ -41,6 +49,8 @@ export default {
}, },
mounted() { mounted() {
this.loadInitPage(); this.loadInitPage();
this.project = getSessionStorage('project');
this.isTeacher = this.$store.state.user.roles.includes(lessonCreater);
}, },
methods: { methods: {
loadInitPage() { loadInitPage() {
@ -66,6 +76,21 @@ export default {
goLesson(row) { goLesson(row) {
localStore.set('teachDetail' + this.$route.params.subSystem, `${UrlConfig.trainingPlatform.teachDetail}/${this.$route.params.subSystem}?lessonId=${row.id}&mapId=${row.mapId}&prdType=${row.prdType}`); localStore.set('teachDetail' + this.$route.params.subSystem, `${UrlConfig.trainingPlatform.teachDetail}/${this.$route.params.subSystem}?lessonId=${row.id}&mapId=${row.mapId}&prdType=${row.prdType}`);
this.$router.push({ path: `${UrlConfig.trainingPlatform.teachDetail}/${this.$route.params.subSystem}`, query: {lessonId: row.id, mapId: row.mapId, prdType: row.prdType}}); this.$router.push({ path: `${UrlConfig.trainingPlatform.teachDetail}/${this.$route.params.subSystem}`, query: {lessonId: row.id, mapId: row.mapId, prdType: row.prdType}});
},
handleDelete(row) {
this.$confirm('此操作将删除该类型, 是否继续?', this.$t('global.tips'), {
confirmButtonText: this.$t('global.confirm'),
cancelButtonText: this.$t('global.cancel'),
type: 'warning'
}).then(() => {
delPublishLesson(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(() => { });
} }
} }
}; };