From 49e5e59e00628d1a216f52de5c1a299d695cf6c0 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期五, 29 三月 2024 13:52:19 +0800
Subject: [PATCH] 题目导出
---
src/utils/request.js | 14 +++---
src/views/exam/question/list.vue | 69 ++++++++++++++++++++++++++--------
src/api/question.js | 3 +
3 files changed, 61 insertions(+), 25 deletions(-)
diff --git a/src/api/question.js b/src/api/question.js
index a57710b..7d983a9 100644
--- a/src/api/question.js
+++ b/src/api/question.js
@@ -5,5 +5,6 @@
edit: query => post('/api/admin/question/edit', query),
select: id => post('/api/admin/question/select/' + id),
deleteQuestion: id => post('/api/admin/question/delete/' + id),
- downloadImportTemplate: () => download('/api/admin/question/download/question/import/temp')
+ downloadImportTemplate: () => download('/api/admin/question/download/question/import/temp'),
+ exportQuestion: query => download('/api/admin/question/question/export', query)
}
diff --git a/src/utils/request.js b/src/utils/request.js
index c6a596c..9c397ae 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -99,8 +99,8 @@
withCredentials: true,
timeout: 30000,
data: params,
- responseType: 'blob',//鍏抽敭
- headers: {'Content-Type': 'application/vnd.ms-excel',}//绫诲瀷淇敼涓篹xcel
+ responseType: 'blob', // 鍏抽敭
+ headers: { 'Content-Type': 'application/vnd.ms-excel' }// 绫诲瀷淇敼涓篹xcel
}
return request(false, query)
}
@@ -111,10 +111,10 @@
url: url,
method: 'get',
withCredentials: true,
- timeout: 30000,
- data: params,
- responseType: 'blob',//鍏抽敭
- headers: {'Content-Type': 'application/vnd.ms-excel',}//绫诲瀷淇敼涓篹xcel
+ timeout: 300000,
+ params: params,
+ responseType: 'blob', // 鍏抽敭
+ headers: { 'Content-Type': 'application/vnd.ms-excel' }// 绫诲瀷淇敼涓篹xcel
}
return request(false, query)
}
@@ -127,7 +127,7 @@
withCredentials: true,
timeout: 30000,
data: params,
- headers: { responseType: 'blob', 'Content-Type': 'multipart/form-data', 'request-ajax': true}
+ headers: { responseType: 'blob', 'Content-Type': 'multipart/form-data', 'request-ajax': true }
}
return request(false, query)
}
diff --git a/src/views/exam/question/list.vue b/src/views/exam/question/list.vue
index aa4f035..bb4d189 100644
--- a/src/views/exam/question/list.vue
+++ b/src/views/exam/question/list.vue
@@ -26,6 +26,33 @@
<el-button slot="reference" type="primary">娣诲姞</el-button>
</el-popover>
+ <el-popover
+ placement="right"
+ width="400"
+ trigger="click">
+ <el-form
+ label-position="top"
+ >
+ <el-form-item label="棰樺瀷锛�">
+ <el-select v-model="exportForm.questionType" clearable>
+ <el-option v-for="item in questionType" :key="item.key" :value="item.key" :label="item.value"></el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鍒涘缓鏃堕棿锛�">
+ <el-date-picker
+ v-model="timeRange"
+ type="daterange"
+ range-separator="鑷�"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡">
+ </el-date-picker>
+ <el-form-item style="text-align: center;margin-top: 5px">
+ <el-button type="primary" @click="exportQuestion">瀵煎嚭</el-button>
+ </el-form-item>
+ </el-form-item>
+ </el-form>
+ <el-button slot="reference" class="op-item" type="success">瀵煎嚭</el-button>
+ </el-popover>
<el-button class="op-item" type="danger" @click="downloadImportTemplate">涓嬭浇瀵煎叆妯℃澘</el-button>
<el-upload
class="op-item"
@@ -45,12 +72,6 @@
</el-form>
<el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%">
<el-table-column prop="subjectId" label="璇剧洰" :formatter="subjectIdFormatte" width="120px"/>
-<!-- <el-table-column prop="subjectId" label="璇剧洰">-->
-<!-- <template slot-scope="scope">-->
-<!--<!– <span>{{this.subjectIdFormatte}}</span>–>-->
-<!-- <span>{{scope.row.questionSubjects.forEach(item=>{ return item.subName})}}</span>-->
-<!-- </template>-->
-<!-- </el-table-column>-->
<el-table-column prop="questionType" label="棰樺瀷" :formatter="questionTypeFormatter" width="70px"/>
<el-table-column prop="shortTitle" label="棰樺共" show-overflow-tooltip/>
<el-table-column prop="score" label="鍒嗘暟" width="60px"/>
@@ -77,15 +98,20 @@
import Pagination from '@/components/Pagination'
import QuestionShow from './components/Show'
import questionApi from '@/api/question'
-import {downloadExcel} from '@/utils/download'
+import { downloadExcel } from '@/utils/download'
-import Cookies from 'js-cookie'
export default {
components: { Pagination, QuestionShow },
data () {
return {
- upLoadUrl:'/api/admin/question/import',
- fileList:[],
+ timeRange: [],
+ exportForm: {
+ questionType: null,
+ start: null,
+ end: null
+ },
+ upLoadUrl: '/api/admin/question/import',
+ fileList: [],
queryParam: {
id: null,
questionType: null,
@@ -114,10 +140,20 @@
this.subjectFilter = this.subjects
},
methods: {
+ // 瀵煎嚭棰樼洰
+ exportQuestion () {
+ if (this.timeRange && this.timeRange.length > 1) {
+ this.exportForm.startStr = this.timeRange[0]
+ this.exportForm.endStr = this.timeRange[1]
+ }
+ questionApi.exportQuestion(this.exportForm).then(res => {
+ downloadExcel(res, '棰樼洰瀵煎嚭')
+ })
+ },
// 涓嬭浇瀵煎叆妯℃澘
downloadImportTemplate () {
questionApi.downloadImportTemplate().then(res => {
- downloadExcel(res, '棰樼洰瀵煎嚭')
+ downloadExcel(res, '棰樼洰瀵煎叆妯℃澘')
})
},
handlePreview (e) {
@@ -200,13 +236,13 @@
questionTypeFormatter (row, column, cellValue, index) {
return this.enumFormat(this.questionType, cellValue)
},
- subjectIdFormatte(row, column, cellValue, index){
+ subjectIdFormatte (row, column, cellValue, index) {
console.log(row, column, cellValue, index)
let str = ''
- row.questionSubjects.forEach(item=>{
- str+=item.subName+','
+ row.questionSubjects.forEach(item => {
+ str += item.subName + ','
})
- return str = str.slice(0,str.length-1)
+ return str = str.slice(0, str.length - 1)
},
subjectFormatter (row, column, cellValue, index) {
return this.subjectEnumFormat(cellValue)
@@ -216,12 +252,11 @@
computed: {
headers: function () {
- console.log( Cookies.get('adminUserName'),)
// console.log(store.getters.Admin-Token)
// const tenantId = store.getters.userInfo.tenantId
return {
// 'Authorization': "Bearer " + store.getters.Admin-Token,
- "Cookie":"JSESSIONID=shpHmjIK1ysHPDyAQB4-M-N3WytgJ3UIwYrfcA2t; adminUserName=admin"
+ 'Cookie': 'JSESSIONID=shpHmjIK1ysHPDyAQB4-M-N3WytgJ3UIwYrfcA2t; adminUserName=admin'
}
},
...mapGetters('enumItem', ['enumFormat']),
--
Gitblit v1.8.0