From 3b73c554682286e7184795f23a3acaa168b2047c Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 11 六月 2024 14:55:18 +0800
Subject: [PATCH] 考试管理、bug处理

---
 src/views/Exam/ExamManage.vue |  135 +++++++++++++++++++++++++++++++-------------
 1 files changed, 95 insertions(+), 40 deletions(-)

diff --git a/src/views/Exam/ExamManage.vue b/src/views/Exam/ExamManage.vue
index 5b58e00..93f505b 100644
--- a/src/views/Exam/ExamManage.vue
+++ b/src/views/Exam/ExamManage.vue
@@ -13,12 +13,11 @@
           <div>
             <el-form :inline="true" :model="searchForm" class="demo-form-inline">
               <el-form-item label="鑰冭瘯鍚嶇О">
-                <el-input v-model="searchForm.className" size="small" clearable @clear="page" placeholder="鐝骇鍚嶇О"></el-input>
+                <el-input v-model="searchForm.examName" @input="page" clearable size="small" clearable @clear="page" placeholder="鐝骇鍚嶇О"></el-input>
               </el-form-item>
-              <el-form-item label="鑰冭瘯鐝骇">
-                <el-select v-model="searchForm.classesId" size="small" clearable @change="page" placeholder="鐝骇鐘舵��">
-                  <el-option label="姝e父" value="normal"></el-option>
-                  <el-option label="瑙f暎" value="dissolution"></el-option>
+              <el-form-item label="鍙傝�冪彮绾�">
+                <el-select v-model="searchForm.classesId" @change="page" clearable @clear="page">
+                  <el-option v-for="classes in classesList" :key="classes.id" :value="classes.id" :label="classes.className"/>
                 </el-select>
               </el-form-item>
               <el-form-item>
@@ -33,11 +32,11 @@
                 ></el-table-column>
                 <el-table-column
                   label="鑰冭瘯璇曞嵎"
-                  prop="examName"
+                  prop="examPaperName"
                 ></el-table-column>
                 <el-table-column
                   label="鍙傝�冪彮绾�"
-                  prop="examClasses"
+                  prop="className"
                 ></el-table-column>
                 <el-table-column
                   label="鐝骇浜烘暟"
@@ -45,25 +44,38 @@
                 ></el-table-column>
                 <el-table-column
                   label="鑰冭瘯鍦扮偣"
-                  prop="site"
+                  prop="examPlace"
                 ></el-table-column>
                 <el-table-column
-                  label="鑰冭瘯绉戠洰"
-                  prop="subject"
+                  label="鑰冭瘯鐘舵��"
+                  prop="status"
+                  :formatter="statusFormatter"
                 ></el-table-column>
-                <el-table-column label="鐘舵��" prop="type" :formatter="formatterType">
-                </el-table-column>
+                <el-table-column
+                  label="鍒涘缓鏃堕棿"
+                  width="150px"
+                  prop="createTime"
+                ></el-table-column>
                 <el-table-column
                   label="鑰冭瘯鏃堕棿"
-                  prop="ctime"
-                ></el-table-column>
-                <el-table-column label="鎿嶄綔">
+                  width="200px"
+                  algin="center"
+                >
+                  <template slot-scope="scope">
+                    <div>{{scope.row.startTime}}</div>
+                    <div>鑷�</div>
+                    <div>{{scope.row.endTime}}</div>
+                  </template>
+                </el-table-column>
+                <el-table-column label="鎿嶄綔" fiexd="right" width="150px">
                   <template slot-scope="scope">
                     <el-button
-                      class="deepBlue"
-                      colorType="blue"
+                      type="primary"
+                      size="small"
+                      @click="handlerEdit(scope.row)"
                     >淇敼
                     </el-button>
+                    <el-button type="danger" size="small" @click="deleteExam(scope.row.id)">鍒犻櫎</el-button>
                   </template>
                 </el-table-column>
               </el-table>
@@ -82,29 +94,40 @@
     </div>
 
 
-    <el-dialog width="35%" :title="title" @close="closeHandler" :visible.sync="open" :destroy-on-close="true"
+    <el-dialog width="500px" :title="title" @close="closeHandler" :visible.sync="open" :destroy-on-close="true"
                :append-to-body="true" :close-on-click-modal="false">
       <el-form :model="examForm" :rules="examRules" ref="examForm">
         <el-form-item label="鑰冭瘯鍚嶇О" :label-width="formLabelWidth" prop="examName">
           <el-input v-model="examForm.examName" autocomplete="off"></el-input>
         </el-form-item>
         <el-form-item label="鍙傝�冪彮绾�" :label-width="formLabelWidth" prop="classesId">
-          <el-input v-model="examForm.classesId" autocomplete="off"></el-input>
+          <el-select v-model="examForm.classesId">
+            <el-option v-for="classes in classesList" :key="classes.id" :value="classes.id" :label="classes.className"/>
+          </el-select>
         </el-form-item>
         <el-form-item label="璇曞嵎绫诲瀷" :label-width="formLabelWidth" prop="examPaperType">
-          <el-input v-model="examForm.examPaperType" autocomplete="off"></el-input>
+          <el-select v-model="examForm.examPaperType" @change="getMyExamPaperList">
+            <el-option label="鍥哄畾璇曞嵎" :value="1"></el-option>
+            <el-option label="闅忔満璇曞嵎" :value="2"></el-option>
+            <el-option label="闅忓簭璇曞嵎" :value="3"></el-option>
+          </el-select>
         </el-form-item>
         <el-form-item label="鑰冭瘯璇曞嵎" :label-width="formLabelWidth" prop="examPaperId">
-          <el-input v-model="examForm.examPaperId" autocomplete="off"></el-input>
+          <el-select v-model="examForm.examPaperId" :disabled="!examForm.examPaperType" placeholder="璇峰厛閫夋嫨璇曞嵎绫诲瀷">
+            <el-option v-for="examPaper in examPaperList" :key="examPaper.id" :value="examPaper.id" :label="examPaper.name"/>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="寮�濮嬫椂闂�" :label-width="formLabelWidth" prop="time">
+          <el-date-picker
+            v-model="examForm.time"
+            type="daterange"
+            range-separator="鑷�"
+            start-placeholder="寮�濮嬫棩鏈�"
+            end-placeholder="缁撴潫鏃ユ湡">
+          </el-date-picker>
         </el-form-item>
         <el-form-item label="鑰冭瘯鍦扮偣" :label-width="formLabelWidth" prop="examPlace">
           <el-input v-model="examForm.examPlace" autocomplete="off"></el-input>
-        </el-form-item>
-        <el-form-item label="寮�濮嬫椂闂�" :label-width="formLabelWidth" prop="startTime">
-          <el-input v-model="examForm.startTime" autocomplete="off"></el-input>
-        </el-form-item>
-        <el-form-item label="缁撴潫鏃堕棿" :label-width="formLabelWidth" prop="endTime">
-          <el-input v-model="examForm.endTime" autocomplete="off"></el-input>
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -119,7 +142,7 @@
 import Pagination from "@/components/Pagination"
 import { getExams, addExam, editExam, deleteExamById } from "@/api/exam"
 import { myClasses } from "@/api/classes"
-import { myExamPaperList } from "@/api/examPaper"
+import examPaperAPI from "@/api/examPaper"
 export default {
   components: { Pagination },
   data() {
@@ -132,11 +155,12 @@
         examName: "",
         examPaperId: "",
         classesId: "",
-        examPaperType: "",
+        examPaperType: null,
         examPlace: "",
         status: "",
         startTime: "",
         endTime: "",
+        time: [],
       },
       examRules: {
         examName: [
@@ -154,11 +178,8 @@
         examPlace: [
           { required: true, message: '璇疯緭鍏ヨ�冭瘯鍦扮偣', trigger: 'blur' }
         ],
-        startTime: [
-          { required: true, message: '璇烽�夋嫨寮�濮嬫椂闂�', trigger: 'change' }
-        ],
-        endTime: [
-          { required: true, message: '璇烽�夋嫨缁撴潫鏃堕棿', trigger: 'change' }
+        time: [
+          { required: true, message: '璇烽�夋嫨鑰冭瘯鏃堕棿', trigger: 'change' }
         ],
       },
       total: 0,
@@ -176,18 +197,36 @@
   },
   mounted() {
     this.page();
+    this.getMyClasses()
+    this.MyExamPaperList()
   },
   methods: {
+    timeFormatter(row) {
+      return row.startTime + "鑷�" + row.endTime
+    },
+    statusFormatter(row) {
+      if (row.status === "ing") {
+        return "杩涜涓�"
+      } else if (row.status === "not_start") {
+        return "鏈紑濮�"
+      } else if (row.status === "finished") {
+        return "宸茬粨鏉�"
+      }
+    },
+    MyExamPaperList() {
+      let param = {
+        "paperType": this.examForm.examPaperType
+      }
+      examPaperAPI.myExamPaperList(param).then(res => {
+        this.examForm.examPaperId = null
+        this.examPaperList = res.data
+      })
+    },
     getMyExamPaperList() {
       if (! this.examForm.examPaperType) {
         return
       }
-      let param = {
-        "paperType": this.examForm.examPaperType
-      }
-      myExamPaperList(param).then(res => {
-        this.examPaperList = res.data
-      })
+      this.MyExamPaperList()
     },
     getMyClasses() {
       myClasses().then(res => {
@@ -197,18 +236,33 @@
     deleteExam(id) {
       deleteExamById(id).then(res => {
         this.$message.success("鍒犻櫎鎴愬姛")
+        this.page()
       })
+    },
+    handlerEdit(row) {
+      this.examForm = row
+      this.examForm.time = [row.startTime, row.endTime]
+      this.title = "淇敼鑰冭瘯"
+      this.open = true
     },
     addOrEditExam() {
       this.$refs['examForm'].validate((valid) => {
         if (valid) {
+          this.examForm.startTime = this.examForm.time[0]
+          this.examForm.endTime = this.examForm.time[1]
           if (this.examForm.id) {
             editExam(this.examForm).then(res => {
+              this.open = false
+              this.clearForm()
               this.$message.success("鎿嶄綔鎴愬姛")
+              this.page()
             })
           } else {
             addExam(this.examForm).then(res => {
+              this.open = false
+              this.clearForm()
               this.$message.success("鎿嶄綔鎴愬姛")
+              this.page()
             })
           }
         }
@@ -240,6 +294,7 @@
     page() {
       getExams(this.searchForm).then(res => {
         this.tableData = res.data.data
+        this.total = res.data.total
       })
     },
     routerTo(url) {

--
Gitblit v1.8.0