From 68b8ed3b4b7ddbb5fe113c1d7df3aa909dc66fb6 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期三, 03 七月 2024 18:37:29 +0800
Subject: [PATCH] feat:新增随机时间题目配置

---
 src/views/exam/question/list.vue |   85 ++++++++++++++++++++++++++----------------
 1 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/src/views/exam/question/list.vue b/src/views/exam/question/list.vue
index aa4f035..bc0b9bb 100644
--- a/src/views/exam/question/list.vue
+++ b/src/views/exam/question/list.vue
@@ -26,6 +26,24 @@
           <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.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>
+              <el-button type="primary" @click="exportQuestion" v-loading="exportLoading">瀵煎嚭</el-button>
+            </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"
@@ -36,7 +54,7 @@
           :show-file-list="false"
           :file-list="fileList"
           :before-upload="beforeAvatarUpload">
-          <el-button type="primary">瀵煎叆</el-button>
+          <el-button v-loading="importLoading" type="primary">瀵煎叆</el-button>
           <!--          <div slot="tip" class="el-upload__tip">鍙兘涓婁紶Excel鏂囦欢</div>-->
         </el-upload>
       </div>
@@ -45,12 +63,7 @@
     </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">-->
-<!--&lt;!&ndash;          <span>{{this.subjectIdFormatte}}</span>&ndash;&gt;-->
-<!--          <span>{{scope.row.questionSubjects.forEach(item=>{ return item.subName})}}</span>-->
-<!--        </template>-->
-<!--      </el-table-column>-->
+      <el-table-column prop="deptNames" label="鎵�灞為儴闂�" width="150px"/>
       <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 +90,21 @@
 import Pagination from '@/components/Pagination'
 import QuestionShow from './components/Show'
 import questionApi from '@/api/question'
-import {downloadExcel} from '@/utils/download'
-
-import Cookies from 'js-cookie'
+import SubjectApi from '@/api/subject'
+import { downloadExcel } from '@/utils/download'
 export default {
   components: { Pagination, QuestionShow },
   data () {
     return {
-      upLoadUrl:'/api/admin/question/import',
-      fileList:[],
+      importLoading: false,
+      exportLoading: false,
+      subjectIdList: [],
+      timeRange: [],
+      exportForm: {
+        subjectIds: [],
+      },
+      upLoadUrl: '/api/admin/question/import',
+      fileList: [],
       queryParam: {
         id: null,
         questionType: null,
@@ -110,18 +129,27 @@
   created () {
     this.initSubject()
     this.search()
+    this.getSubjectIds()
     this.queryParam.subjectId = null
     this.subjectFilter = this.subjects
   },
   methods: {
+    // 瀵煎嚭棰樼洰
+    exportQuestion () {
+      this.exportLoading = true
+      questionApi.exportQuestion(this.exportForm).then(res => {
+        downloadExcel(res, '棰樼洰瀵煎嚭')
+        this.exportLoading = false
+      })
+    },
     // 涓嬭浇瀵煎叆妯℃澘
     downloadImportTemplate () {
       questionApi.downloadImportTemplate().then(res => {
-        downloadExcel(res, '棰樼洰瀵煎嚭')
+        downloadExcel(res, '棰樼洰瀵煎叆妯℃澘')
       })
     },
     handlePreview (e) {
-      console.log(e)
+      this.importLoading = false
       if (e.code === 1) {
         this.search()
         this.$message.success(e.message)
@@ -130,6 +158,7 @@
       }
     },
     beforeAvatarUpload (file) {
+      this.importLoading = true
       let legalName = ['xlsx', 'xls']
       // 鎷垮埌鍚庣紑鍚�
       let name = file.name.substring(file.name.lastIndexOf('.') + 1, file.name.length)
@@ -139,17 +168,6 @@
         this.$message.warning('鏂囦欢鏍煎紡涓嶅锛屼粎闄恱ls鍜寈lsx')
         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('涓婁紶鏂囦欢鍙兘鏄疎xcel!');
-      // }
-      // // if (!isLt2M) {
-      // //   this.$message.error('涓婁紶澶村儚鍥剧墖澶у皬涓嶈兘瓒呰繃 2MB!');
-      // // }
-      // return isJPG ;
     },
     submitForm () {
       this.queryParam.pageIndex = 1
@@ -182,6 +200,11 @@
         _this.questionShow.loading = false
       })
     },
+    getSubjectIds() {
+       SubjectApi.list().then(res => {
+         this.subjectIdList = res.response
+      });
+    },
     editQuestion (row) {
       let url = this.enumFormat(this.editUrlEnum, row.questionType)
       this.$router.push({ path: url, query: { id: row.id } })
@@ -200,13 +223,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)
@@ -214,14 +237,12 @@
     ...mapActions('exam', { initSubject: 'initSubject' })
   },
   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