| | |
| | | import { post, download } from '@/utils/request' |
| | | import { post, download, downloadPost } from '@/utils/request' |
| | | |
| | | export default { |
| | | pageList: query => post('/api/admin/question/page', 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'), |
| | | exportQuestion: query => download('/api/admin/question/question/export', query) |
| | | exportQuestion: query => downloadPost('/api/admin/question/question/export', query) |
| | | } |
| | |
| | | return request(false, query) |
| | | } |
| | | |
| | | const downloadPost = function (url, params) { |
| | | const query = { |
| | | baseURL: process.env.VUE_APP_URL, |
| | | url: url, |
| | | method: 'post', |
| | | withCredentials: true, |
| | | timeout: 300000, |
| | | data: params, |
| | | responseType: 'blob' // 关键 |
| | | } |
| | | return request(false, query) |
| | | } |
| | | |
| | | export const down = function (url, params) { |
| | | const query = { |
| | | baseURL: process.env.VUE_APP_URL, |
| | |
| | | postWithOutLoadTip, |
| | | get, |
| | | form, |
| | | download |
| | | download, |
| | | downloadPost |
| | | } |
| | |
| | | <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-form-item label="课目:"> |
| | | <el-select v-model="exportForm.subjectIds" clearable filterable multiple> |
| | | <el-option v-for="item in subjectIdList" :key="item.id" :value="item.id" :label="item.name"></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-form-item> |
| | | <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> |
| | |
| | | import Pagination from '@/components/Pagination' |
| | | import QuestionShow from './components/Show' |
| | | import questionApi from '@/api/question' |
| | | import SubjectApi from '@/api/subject' |
| | | import { downloadExcel } from '@/utils/download' |
| | | |
| | | export default { |
| | | components: { Pagination, QuestionShow }, |
| | | data () { |
| | | return { |
| | | subjectIdList: [], |
| | | timeRange: [], |
| | | exportForm: { |
| | | questionType: null, |
| | | start: null, |
| | | end: null |
| | | subjectIds: [], |
| | | }, |
| | | upLoadUrl: '/api/admin/question/import', |
| | | fileList: [], |
| | |
| | | created () { |
| | | this.initSubject() |
| | | this.search() |
| | | this.getSubjectIds() |
| | | this.queryParam.subjectId = null |
| | | 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, '题目导出') |
| | | }) |
| | |
| | | this.$message.warning('文件格式不对,仅限xls和xlsx') |
| | | return false |
| | | } |
| | | // console.log(file) |
| | | // const isJPG = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; |
| | | // // const isLt2M = file.size / 1024 / 1024 < 2; |
| | | // |
| | | // if (!isJPG) { |
| | | // this.$message.error('上传文件只能是Excel!'); |
| | | // } |
| | | // // if (!isLt2M) { |
| | | // // this.$message.error('上传头像图片大小不能超过 2MB!'); |
| | | // // } |
| | | // return isJPG ; |
| | | }, |
| | | submitForm () { |
| | | this.queryParam.pageIndex = 1 |
| | |
| | | _this.questionShow.question = re.response |
| | | _this.questionShow.loading = false |
| | | }) |
| | | }, |
| | | getSubjectIds() { |
| | | SubjectApi.list().then(res => { |
| | | this.subjectIdList = res.response |
| | | }); |
| | | }, |
| | | editQuestion (row) { |
| | | let url = this.enumFormat(this.editUrlEnum, row.questionType) |
| | |
| | | ...mapActions('exam', { initSubject: 'initSubject' }) |
| | | }, |
| | | computed: { |
| | | |
| | | headers: function () { |
| | | // console.log(store.getters.Admin-Token) |
| | | // const tenantId = store.getters.userInfo.tenantId |