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

125 lines
4.8 KiB
Vue
Raw Normal View History

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">
2021-03-30 18:07:45 +08:00
<el-row style="padding: 10px;display: flex;align-items: center;justify-content: flex-end;">
<div style="font-size: 14px;color: #000;">试卷名称</div>
<el-input v-model="inputName" size="small" style="width: 200px;margin-right: 50px;margin-left: 10px;" placeholder="请输入筛选的名称" @change="changeInput" />
<el-button size="small" type="primary" @click="goToFilter">查找</el-button>
</el-row>
<el-table ref="filterTable" :data="filterTableData" border style="width: 100%" height="calc(100vh - 150px)">
2021-03-29 15:01:43 +08:00
<el-table-column prop="name" label="试卷名称" />
2020-07-07 18:33:43 +08:00
<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>
2021-03-29 15:01:43 +08:00
<el-table-column prop="duration" label="考试时长(分钟)">
<template slot-scope="scope">
<span>{{ Number(scope.row.duration) / 60 }}</span>
</template>
</el-table-column>
<el-table-column prop="fullPoint" label="总分" />
<el-table-column prop="remarks" show-overflow-tooltip label="试卷说明" />
2019-11-01 18:08:05 +08:00
<el-table-column :label="this.$t('global.operate')">
2019-10-22 13:40:42 +08:00
<template slot-scope="scope">
2021-03-29 15:01:43 +08:00
<el-button size="mini" type="primary" @click="goExamDetail(scope.row)">
考试详情
</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';
import { UrlConfig } from '@/scripts/ConstDic';
import { getSessionStorage } from '@/utils/auth';
import { lessonCreater } from '@/router/index';
2019-10-22 18:49:46 +08:00
import localStore from 'storejs';
2019-10-22 13:40:42 +08:00
export default {
name: 'ExamHome',
data() {
return {
tableData: [],
2021-03-30 18:07:45 +08:00
filterTableData: [],
loading: false,
project: '',
2020-05-15 18:48:10 +08:00
isTeacher: false,
2021-03-30 18:07:45 +08:00
userId: '',
inputName: ''
};
},
2020-07-07 18:33:43 +08:00
computed: {
isGzbShow() {
return getSessionStorage('project').startsWith('gzb');
}
},
watch: {
'$route.params.subSystem': function(newVal) {
this.loadInitPage();
}
},
mounted() {
this.loadInitPage();
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;
},
methods: {
loadInitPage() {
if (this.$route.params.subSystem) {
getSubSystemDetail(this.$route.params.subSystem).then(resp =>{
if (resp.data) {
2021-03-29 15:01:43 +08:00
this.tableData = resp.data.examList;
} else {
this.tableData = [];
}
2021-03-30 18:07:45 +08:00
this.inputName = localStore.get(this.$route.path) || '';
this.goToFilter();
}).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'));
}
});
}
},
2021-03-29 15:01:43 +08:00
goExamDetail(row) {
const path = `${this.$route.path.match(/(\/.*)\/examHome/)[1]}${UrlConfig.examDetail}`;
if (path.includes('device')) {
this.$router.replace({ path: `${path}/${row.id}`, query: { subSystem: this.$route.params.subSystem, mapId: row.mapId, noPreLogout: this.$route.query.noPreLogout }});
} else {
this.$router.push({ path: `${path}/${row.id}`, query: { subSystem: this.$route.params.subSystem, mapId: row.mapId, noPreLogout: this.$route.query.noPreLogout }});
}
2021-03-30 18:07:45 +08:00
},
changeInput(val) {
localStore.set(this.$route.path, val);
},
goToFilter() {
if (!this.inputName) {
this.filterTableData = [...this.tableData];
} else {
this.filterTableData = [];
this.tableData.forEach(item => {
if (item.name.includes(this.inputName)) {
this.filterTableData.push(item);
}
});
}
}
}
2019-10-22 13:40:42 +08:00
};
</script>