293 lines
9.7 KiB
Python
293 lines
9.7 KiB
Python
<template>
|
|
<div class="app-container">
|
|
<div style="margin-top:10px">
|
|
<el-select
|
|
v-model="listQuery.is_pass"
|
|
placeholder="是否通过"
|
|
clearable
|
|
style="width: 200px"
|
|
class="filter-item"
|
|
@change="handleFilter"
|
|
>
|
|
<el-option
|
|
v-for="item in passOptions"
|
|
:key="item.key"
|
|
:label="item.label"
|
|
:value="item.value"
|
|
/>
|
|
</el-select>
|
|
<el-date-picker
|
|
v-model="value"
|
|
type="daterange"
|
|
align="right"
|
|
unlink-panels
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期"
|
|
:picker-options="pickerOptions">
|
|
</el-date-picker>
|
|
<el-input
|
|
v-model="listQuery.search"
|
|
placeholder="输入用户名或用户单位名搜索"
|
|
style="width: 200px;"
|
|
class="filter-item"
|
|
@keyup.enter.native="handleFilter"
|
|
/>
|
|
<el-button
|
|
class="filter-item"
|
|
type="primary"
|
|
icon="el-icon-refresh-left"
|
|
@click="resetFilter"
|
|
>刷新重置</el-button>
|
|
<el-button type="primary" icon="el-icon-download" @click="exportTest" >导出Excel</el-button>
|
|
<div style="margin-top:10px">
|
|
</div>
|
|
</div>
|
|
<el-table
|
|
:data="tableData.results"
|
|
style="width: 100%;margin-top:10px;"
|
|
border
|
|
stripe
|
|
fit
|
|
v-loading="listLoading"
|
|
highlight-current-row
|
|
max-height="600"
|
|
@sort-change="changeSort"
|
|
>
|
|
<el-table-column type="index" width="50"></el-table-column>
|
|
<!-- <el-table-column align="left" label="类型">
|
|
<template slot-scope="scope">{{ scope.row.type }}</template>
|
|
</el-table-column> -->
|
|
<el-table-column align="left" label="考试名称">
|
|
<template slot-scope="scope">{{ scope.row.exam_name }}</template>
|
|
</el-table-column>
|
|
<el-table-column align="left" label="用户">
|
|
<template slot-scope="scope">{{ scope.row.create_by_name}}</template>
|
|
</el-table-column>
|
|
<!-- <el-table-column align="left" label="所属部门">
|
|
<template slot-scope="scope">{{ scope.row.dept_name }}</template>
|
|
</el-table-column> -->
|
|
<el-table-column align="left" label="是否通过">
|
|
<template slot-scope="scope">
|
|
<el-tag v-if="scope.row.is_pass" type="success">是</el-tag>
|
|
<el-tag v-else type="danger">否</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="left" label="得分" sortable='custom' prop="score">
|
|
<template slot-scope="scope">{{ scope.row.score }}</template>
|
|
</el-table-column>
|
|
<el-table-column align="left" label="总分">
|
|
<template slot-scope="scope">{{ scope.row.total_score }}</template>
|
|
</el-table-column>
|
|
<el-table-column align="left" label="耗时(时分秒)" sortable='custom' prop="took">
|
|
<template slot-scope="scope">{{ scope.row.took_format }}</template>
|
|
</el-table-column>
|
|
<el-table-column align="left" label="答题时间">
|
|
<template slot-scope="scope">{{ scope.row.start_time }}</template>
|
|
</el-table-column>
|
|
<el-table-column align="left" label="证书路径" prop="cert_path">
|
|
<template slot-scope="scope">
|
|
<img v-if="scope.row.cert_path" :src="scope.row.cert_path" @click="handlePictureCardPreview(scope.row.cert_path)" alt="图片" height="30" width="50"/>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="left" label="单位名称">
|
|
<template slot-scope="scope">{{ scope.row.blong_dept_name }}</template>
|
|
</el-table-column>
|
|
<el-table-column align="left" label="考试时间">
|
|
<template slot-scope="scope">{{ scope.row.create_time }}</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column align="center" label="操作" fixed="right">
|
|
<template slot-scope="scope">
|
|
<!-- <el-button
|
|
v-if="scope.row.type=='正式考试'"
|
|
type="primary"
|
|
size="small"
|
|
@click="handleExport(scope)"
|
|
>生成Word</el-button> -->
|
|
<!-- <el-button
|
|
v-if="scope.row.type=='正式考试'"
|
|
type="warning"
|
|
size="small"
|
|
@click="handleExport2(scope)"
|
|
>重新生成</el-button> -->
|
|
<el-button
|
|
v-if="scope.row.type=='正式考试'"
|
|
type="danger"
|
|
size="small"
|
|
@click="handleDelete(scope)"
|
|
>删除</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<pagination
|
|
v-show="tableData.count>0"
|
|
:total="tableData.count"
|
|
:page.sync="listQuery.page"
|
|
:limit.sync="listQuery.limit"
|
|
@pagination="getList"
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { getExamRecordList, exportRecord, exportwTest, deleteExamRecord,issue } from "@/api/exam";
|
|
import checkPermission from "@/utils/permission";
|
|
import Pagination from "@/components/Pagination";
|
|
|
|
const listQuery = {
|
|
page: 1,
|
|
limit: 20,
|
|
search:''
|
|
};
|
|
export default {
|
|
components: { Pagination },
|
|
data() {
|
|
return {
|
|
listQuery: Object.assign({}, listQuery),
|
|
tableData: {
|
|
count:0,
|
|
results:[],
|
|
},
|
|
listLoading: true,
|
|
typeOptions: [
|
|
{ key: "自助模考", label: "自助模考", value: "自助模考" },
|
|
{ key: "押卷模考", label: "押卷模考", value: "押卷模考"},
|
|
{ key: "正式考试", label: "正式考试", value: "正式考试"},
|
|
],
|
|
passOptions: [
|
|
{ key: true, label: "通过", value: true },
|
|
{ key: false, label: "未通过", value: false},
|
|
],
|
|
pickerOptions: {
|
|
shortcuts: [{
|
|
text: '最近一天',
|
|
onClick(picker) {
|
|
const end = new Date();
|
|
const start = new Date();
|
|
start.setTime(start.getTime() - 3600 * 1000 * 24);
|
|
picker.$emit('pick', [start, end]);
|
|
}
|
|
}, {
|
|
text: '最近一周',
|
|
onClick(picker) {
|
|
const end = new Date();
|
|
const start = new Date();
|
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
|
|
picker.$emit('pick', [start, end]);
|
|
}
|
|
}, {
|
|
text: '最近一个月',
|
|
onClick(picker) {
|
|
const end = new Date();
|
|
const start = new Date();
|
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
|
|
picker.$emit('pick', [start, end]);
|
|
}
|
|
}, {
|
|
text: '最近三个月',
|
|
onClick(picker) {
|
|
const end = new Date();
|
|
const start = new Date();
|
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
|
|
picker.$emit('pick', [start, end]);
|
|
}
|
|
}]
|
|
},
|
|
value: '',
|
|
};
|
|
},
|
|
computed: {},
|
|
watch:{
|
|
value:'setTimeRange',
|
|
},
|
|
created() {
|
|
this.getQuery();
|
|
},
|
|
methods: {
|
|
checkPermission,
|
|
getQuery() {
|
|
if(this.$route.query.exam){
|
|
this.listQuery.exam = this.$route.query.exam;
|
|
}
|
|
this.getList()
|
|
},
|
|
handlePictureCardPreview(url){
|
|
window.open(url);
|
|
},
|
|
getList() {
|
|
this.listLoading = true;
|
|
getExamRecordList(this.listQuery).then(response => {
|
|
this.tableData = response.data;
|
|
this.listLoading = false;
|
|
});
|
|
},
|
|
handleFilter() {
|
|
this.listQuery.page = 1;
|
|
this.getList();
|
|
},
|
|
resetFilter() {
|
|
this.listQuery = {
|
|
page: 1,
|
|
limit: 20,
|
|
search:'',
|
|
};
|
|
this.value = []
|
|
// this.getList();
|
|
},
|
|
handleExport(scope) {
|
|
const loading = this.$loading({text: '正在生成word...',});
|
|
exportwTest(scope.row.id).then(res=>{
|
|
loading.close()
|
|
window.open(res.data.path, "_blank");
|
|
}).catch(e=>{loading.close()})
|
|
},
|
|
handleDelete(scope){
|
|
this.$confirm("确认删除该考试记录吗?将丢失数据!", "警告", {
|
|
confirmButtonText: "确认",
|
|
cancelButtonText: "取消",
|
|
type: "error"
|
|
})
|
|
.then(async () => {
|
|
await deleteExamRecord(scope.row.id);
|
|
this.getList()
|
|
this.$message({
|
|
type: "success",
|
|
message: "成功删除!"
|
|
});
|
|
})
|
|
.catch(err => {
|
|
console.error(err);
|
|
});
|
|
},
|
|
handleExport2(scope) {
|
|
const loading = this.$loading({text: '正在重新生成word...',});
|
|
exportwTest(scope.row.id, {anew:true}).then(res=>{
|
|
loading.close()
|
|
window.open(res.data.path, "_blank");
|
|
}).catch(e=>{loading.close()})
|
|
},
|
|
exportTest() {
|
|
const loading = this.$loading();
|
|
exportRecord(this.listQuery).then(res=>{
|
|
loading.close()
|
|
window.open(res.data.path, "_blank");
|
|
}).catch(e=>{loading.close()})
|
|
},
|
|
setTimeRange(){
|
|
this.listQuery.start = this.value[0],
|
|
this.listQuery.end = this.value[1],
|
|
this.getList()
|
|
},
|
|
changeSort (val) {
|
|
if(val.order == 'ascending'){
|
|
this.listQuery.ordering = val.prop
|
|
}else{
|
|
this.listQuery.ordering = '-' + val.prop
|
|
}
|
|
this.getList()
|
|
},
|
|
}
|
|
};
|
|
</script>
|
|
|