<template>
|
<div class="app-container">
|
<!-- <el-form :model="queryParam" ref="queryForm" :inline="true">-->
|
<!-- <el-form-item label="题目ID:">-->
|
<!-- <el-input v-model="queryParam.id" clearable></el-input>-->
|
<!-- </el-form-item>-->
|
<!-- <el-form-item label="部门:">-->
|
<!-- <el-select v-model="queryParam.level" placeholder="部门" @change="levelChange" clearable>-->
|
<!-- <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option>-->
|
<!-- </el-select>-->
|
<!-- </el-form-item>-->
|
<!-- <el-form-item label="课目:" >-->
|
<!-- <el-select v-model="queryParam.subjectId" clearable>-->
|
<!-- <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-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 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" :rules="rules">
|
<el-form-item label="考生:" prop="menuIds" required>
|
<el-cascader v-model="form.menuIds" :options="options" :props="{ multiple: true }" clearable collapse-tags></el-cascader>
|
</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'
|
|
export default {
|
components: { Pagination },
|
data () {
|
return {
|
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
|
},
|
methods: {
|
missExam(item) {
|
this.form = {
|
menuIds: [],
|
userIds: [],
|
id: null,
|
limitDateTime: []
|
}
|
this.examPaper = item;
|
departmentApi.getDepartmentUserByTemplateId(item.id).then(res => {
|
this.options = res.response.map(x=>{return{value:x.department.id,label:x.department.name,children:x.userList.map(xx=>{return{value: xx.id,label: xx.realName}})}})
|
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>
|