From fcb89656200d844f706736cd885b4fe6115eed8a Mon Sep 17 00:00:00 2001
From: lohir <3399054449@qq.com>
Date: 星期三, 16 十月 2024 11:43:01 +0800
Subject: [PATCH] bug
---
src/views/exam/question/list.vue | 47 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/src/views/exam/question/list.vue b/src/views/exam/question/list.vue
index 512f167..0f44ddc 100644
--- a/src/views/exam/question/list.vue
+++ b/src/views/exam/question/list.vue
@@ -2,7 +2,7 @@
<div class="app-container">
<el-form :model="queryParam" ref="queryForm" :inline="true">
<el-form-item>
- <el-input v-model="queryParam.content" placeholder="璇疯緭鍏ラ鐩�" clearable></el-input>
+ <el-input v-model="queryParam.content" placeholder="璇疯緭鍏ラ鐩�" clearable @input="search"></el-input>
</el-form-item>
<el-form-item>
<el-select v-model="queryParam.subjectId" placeholder="璇烽�夋嫨绉戠洰" clearable multiple @change="search">
@@ -21,13 +21,25 @@
</el-select>
</el-form-item>
<el-form-item>
- <el-button type="primary" @click="search">鏌ヨ</el-button>
+ <el-button type="primary" @click="search" size="small">鏌ヨ</el-button>
<el-popover placement="bottom" trigger="click">
<el-button type="warning" size="mini" v-for="item in editUrlEnum" :key="item.key"
@click="$router.push({ path: item.value })">{{ item.name }}
</el-button>
- <el-button slot="reference" type="primary" class="link-left">娣诲姞</el-button>
+ <el-button slot="reference" type="primary" class="link-left" size="small">娣诲姞</el-button>
</el-popover>
+ <el-button class="link-left" type="danger" @click="downloadImportTemplate" size="small">涓嬭浇妯℃澘</el-button>
+ <el-upload
+ style="display: inline;"
+ class="op-item link-left"
+ action="/api/admin/question/import"
+ :with-credentials="true"
+ :on-success="handlePreview"
+ accept=".xls,.xlsx"
+ :show-file-list="false"
+ :before-upload="beforeAvatarUpload">
+ <el-button v-loading="importLoading" type="primary" size="small">瀵煎叆</el-button>
+ </el-upload>
</el-form-item>
</el-form>
<el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%">
@@ -73,11 +85,13 @@
import Pagination from '@/components/Pagination'
import QuestionShow from './components/Show'
import questionApi from '@/api/question'
+import { downloadExcel } from '@/utils/download'
export default {
components: { Pagination, QuestionShow },
data() {
return {
+ importLoading: '',
queryParam: {
id: null,
questionType: null,
@@ -103,6 +117,33 @@
this.search()
},
methods: {
+ handlePreview (e) {
+ this.importLoading = false
+ if (e.code === 1) {
+ this.search()
+ this.$message.success(e.message)
+ } else {
+ this.$message.error(e.message)
+ }
+ },
+ beforeAvatarUpload (file) {
+ this.importLoading = true
+ let legalName = ['xlsx', 'xls']
+ // 鎷垮埌鍚庣紑鍚�
+ let name = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length)
+ if (legalName.includes(name)) {
+ // console.log(legalName.includes(name));
+ } else {
+ this.$message.warning('璇蜂笂浼爔ls銆亁lsx鏂囦欢')
+ return false
+ }
+ },
+ // 涓嬭浇瀵煎叆妯℃澘
+ downloadImportTemplate() {
+ questionApi.downloadImportTemplate().then(res => {
+ downloadExcel(res, '棰樼洰瀵煎叆妯℃澘')
+ })
+ },
statusQuestion(row) {
let question = {
id: row.id,
--
Gitblit v1.8.0