<template>
|
<div class="app-container">
|
<el-form :model="queryParam" ref="queryForm" :inline="true">
|
<el-form-item label="名称:">
|
<el-input v-model="queryParam.name" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="部门:">
|
<el-cascader
|
clearable
|
v-model="queryParam.deptId"
|
:options="depts"
|
:props="{ emitPath: false, value: 'id', label: 'name', checkStrictly: true, multiple: true }"
|
></el-cascader>
|
</el-form-item>
|
<el-form-item label="课目:" >
|
<el-select v-model="queryParam.subjectId" clearable multiple>
|
<el-option v-for="item in subjectFilter" :key="item.id" :value="item.id" :label="item.name+' '"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item>
|
<el-date-picker
|
v-model="queryParam.period"
|
type="daterange"
|
unlink-panels
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
:picker-options="pickerOptions">
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item>
|
<el-button type="primary" @click="submitForm">查询</el-button>
|
<!-- <router-link :to="{path:'/exam/personalSimulation/edit'}" class="link-left">
|
<el-button type="primary">添加</el-button>
|
</router-link> -->
|
</el-form-item>
|
</el-form>
|
<router-link :to="{path:'/exam/personalRandomTemplate/edit'}">
|
<el-button type="primary" size="small" style="margin-bottom: 5px">添加</el-button>
|
</router-link>
|
<el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%">
|
<el-table-column prop="subjectNames" label="课目" />
|
<el-table-column prop="name" label="名称" />
|
<el-table-column prop="createDepartment" label="创建部门" />
|
<el-table-column prop="ctime" label="创建时间" />
|
<el-table-column label="操作" align="center" width="360px">
|
<template slot-scope="{row}">
|
<el-button size="small" @click="$router.push({path:'/exam/personalRandomTemplate/edit',query:{id:row.id}})" >编辑</el-button>
|
<el-button size="small" type="primary" @click="missExam(row)">补考</el-button>
|
<el-button size="small" type="danger" @click="deletePaper(row)" class="link-left">删除</el-button>
|
<el-button size="small" type="danger" @click="handleExport(row)" class="link-left">导出</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<pagination v-show="total>0" :total="total" :page.sync="queryParam.pageIndex" :limit.sync="queryParam.pageSize"
|
@pagination="search"/>
|
|
<el-dialog
|
title="补考"
|
:visible.sync="dialogVisible"
|
width="550px">
|
<el-form :model="form" ref="form">
|
<el-form-item label="考生:" prop="menuIds" required>
|
<!-- <el-cascader v-model="form.menuIds" :options="options" :props="{ multiple: true }" clearable collapse-tags></el-cascader> -->
|
<el-select v-model="form.menuIds" multiple clearable placeholder="请选择">
|
<el-option v-for="item in options" :key="item.id" :label="item.realName" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
<span slot="footer" class="dialog-footer">
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
<el-button type="primary" @click="submitUpdate">确 定</el-button>
|
</span>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { mapActions, mapGetters, mapState } from 'vuex'
|
import Pagination from '@/components/Pagination'
|
import examPaperApi from '@/api/examPaper'
|
import departmentApi from '@/api/department'
|
import userApi from '@/api/user'
|
|
export default {
|
components: { Pagination },
|
data () {
|
return {
|
pickerOptions: {
|
shortcuts: [{
|
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]);
|
}
|
}, {
|
text: '最近半年',
|
onClick(picker) {
|
const end = new Date();
|
const start = new Date();
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 183);
|
picker.$emit('pick', [start, end]);
|
}
|
}, {
|
text: '最近一年',
|
onClick(picker) {
|
const end = new Date();
|
const start = new Date();
|
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
|
picker.$emit('pick', [start, end]);
|
}
|
}]
|
},
|
options: [],
|
depts: [],
|
form: {
|
menuIds: [],
|
userIds: [],
|
id: null,
|
limitDateTime: []
|
},
|
examPaper: {},
|
dialogVisible: false,
|
queryParam: {
|
id: null,
|
level: null,
|
subjectId: null,
|
pageIndex: 1,
|
pageSize: 10
|
},
|
subjectFilter: null,
|
listLoading: true,
|
tableData: [],
|
total: 0
|
}
|
},
|
created () {
|
this.initSubject()
|
this.search()
|
this.queryParam.subjectId = null
|
this.subjectFilter = this.subjects
|
departmentApi.getDeptAdmins().then(res => {
|
this.depts = res.response;
|
})
|
},
|
methods: {
|
missExam(item) {
|
this.form = {
|
menuIds: [],
|
userIds: [],
|
id: null,
|
limitDateTime: []
|
}
|
this.examPaper = item;
|
userApi.getFailExamUser(item.id).then(res => {
|
this.options = res.response;
|
this.dialogVisible = true;
|
})
|
},
|
submitUpdate () {
|
this.$refs.form.validate((valid) => {
|
if (valid) {
|
let op = [];
|
for(var ele of this.form.menuIds){
|
op.push(ele[1])
|
};
|
this.form.menuIds = JSON.stringify(this.form.menuIds);
|
this.form.userIds = op;
|
this.form.id = this.examPaper.id;
|
examPaperApi.missExamByTemplateId(this.form).then(re => {
|
if (re.code === 1) {
|
this.$message.success("操作成功")
|
this.dialogVisible = false;
|
}
|
})
|
} else {
|
return false
|
}
|
})
|
},
|
handleExport(row){
|
let fileName = row.name +'.xls'
|
let url ='/api/admin/exam/count/exportRandownTemplatesId/'+row.id
|
var x = new XMLHttpRequest();
|
x.open("GET", url, true);
|
x.responseType = "blob";
|
x.onload = function () {
|
var url = window.URL.createObjectURL(x.response);
|
var a = document.createElement("a");
|
a.href = url;
|
a.download = fileName;
|
a.click();
|
};
|
x.send();
|
|
// examPaperApi.uploadEnrolmentsa(row.id).then(res=> {
|
// console.log(res)
|
|
|
|
// const link = document.createElement('a'); //创建一个a标签
|
// const blob = new Blob([res.data]);//这里res.data根据返回值来定的.data是blob对象
|
// link.style.display = 'none';
|
// link.href = URL.createObjectURL(blob); //将后端返回的数据通过blob转换为一个地址
|
// //设置下载下来后文件的名字以及文件格式
|
// link.setAttribute(
|
// 'download',
|
// `xxx.` + `xlsx`,
|
// );
|
// document.body.appendChild(link);
|
// link.click(); //下载该文件
|
// document.body.removeChild(link);
|
|
// })
|
},
|
handleExport1(row){
|
let fileName = row.name +'.xls'
|
let url ='/api/admin/exam/count/timeOne'
|
var x = new XMLHttpRequest();
|
x.open("GET", url, true);
|
x.responseType = "blob";
|
x.onload = function () {
|
var url = window.URL.createObjectURL(x.response);
|
var a = document.createElement("a");
|
a.href = url;
|
a.download = fileName;
|
a.click();
|
};
|
x.send();
|
},
|
submitForm () {
|
this.queryParam.pageIndex = 1
|
this.search()
|
},
|
search () {
|
this.listLoading = true
|
this.queryParam.status = 0
|
examPaperApi.pageselfList(this.queryParam).then(data => {
|
const re = data.response
|
this.tableData = re.list
|
this.total = re.total
|
this.queryParam.pageIndex = re.pageNum
|
this.listLoading = false
|
})
|
},
|
deletePaper (row) {
|
let _this = this
|
examPaperApi.selfdeletePaper(row.id).then(re => {
|
if (re.code === 1) {
|
_this.search()
|
_this.$message.success(re.message)
|
} else {
|
_this.$message.error(re.message)
|
}
|
})
|
},
|
levelChange () {
|
this.queryParam.subjectId = null
|
this.subjectFilter = this.subjects
|
},
|
subjectFormatter (row, column, cellValue, index) {
|
console.log(row, column, cellValue, index)
|
return this.subjectEnumFormat(cellValue)
|
},
|
...mapActions('exam', { initSubject: 'initSubject' })
|
},
|
computed: {
|
...mapGetters('enumItem', ['enumFormat']),
|
...mapState('enumItem', {
|
levelEnum: state => state.user.levelEnum
|
}),
|
...mapGetters('exam', ['subjectEnumFormat']),
|
...mapState('exam', { subjects: state => state.subjects })
|
}
|
}
|
</script>
|