提交 de4abf1f authored 作者: 王鹏飞's avatar 王鹏飞

feat: 考试列表新增导出

上级 31fd42d6
<template> <template>
<app-card> <app-card>
<app-list v-bind="tableOptions" ref="list"> <app-list v-bind="tableOptions" ref="list" @selection-change="handleSelectionChange">
<template #header-aside> <template #header-aside>
<el-button type="primary" icon="el-icon-plus" @click="handleCreatePaper" v-permission="'admin_exam_exam_create'" <el-button type="primary" icon="el-icon-plus" @click="handleCreatePaper" v-permission="'admin_exam_exam_create'"
>新建考试</el-button >新建考试</el-button
> >
</template> </template>
<template #footer>
<el-button
type="primary"
:disabled="!multipleSelection.length"
@click="handleExport"
v-permission="'admin_exam_exam_download_details'"
>导出</el-button
>
</template>
<template v-slot:table-x="{ row }"> <template v-slot:table-x="{ row }">
<router-link :to="{ path: 'examDetail', query: { exam_id: row.exam_id } }" target="_blank"> <router-link :to="{ path: 'examDetail', query: { exam_id: row.exam_id } }" target="_blank">
<el-button type="text" v-permission="'admin_exam_exam_view'">查看详情</el-button> <el-button type="text" v-permission="'admin_exam_exam_view'">查看详情</el-button>
...@@ -17,7 +26,7 @@ ...@@ -17,7 +26,7 @@
</template> </template>
<script> <script>
import { getExamList, delExamPaper } from '../api' import { getExamList, delExamPaper, downloadExamData } from '../api'
const status = [ const status = [
{ value: '0', label: '未开始' }, { value: '0', label: '未开始' },
{ value: '1', label: '进行中' }, { value: '1', label: '进行中' },
...@@ -61,6 +70,7 @@ export default { ...@@ -61,6 +70,7 @@ export default {
} }
], ],
columns: [ columns: [
{ type: 'selection' },
{ label: '考试ID', prop: 'exam_id' }, { label: '考试ID', prop: 'exam_id' },
{ label: '考试名称', prop: 'name' }, { label: '考试名称', prop: 'name' },
{ {
...@@ -105,7 +115,6 @@ export default { ...@@ -105,7 +115,6 @@ export default {
} }
}) })
}, },
// 单个删除 // 单个删除
handleDelete(row) { handleDelete(row) {
this.$confirm('确认删除该考试吗?删除后不可恢复').then(_ => { this.$confirm('确认删除该考试吗?删除后不可恢复').then(_ => {
...@@ -117,6 +126,28 @@ export default { ...@@ -117,6 +126,28 @@ export default {
this.$refs.list.refetch() this.$refs.list.refetch()
}) })
}) })
},
// 获取选中项
handleSelectionChange(val) {
this.multipleSelection = val
},
// 导出
handleExport() {
const ids = this.multipleSelection.map(item => item.exam_id)
const params = { id: ids.join(',') }
downloadExamData(params).then(r => {
const blob = new Blob([r], { type: 'application/vnd.ms-excel' })
if ('download' in document.createElement('a')) {
const elink = document.createElement('a')
elink.download = '学员数据.xlsx'
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href)
document.body.removeChild(elink)
}
})
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论