From 6c7e308453d1955506db6f24dd9b1e65caadfdaf Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 11 六月 2024 18:04:59 +0800
Subject: [PATCH] 阅卷

---
 src/views/Manage/TestPaper/PaperTemplate.vue |   58 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/src/views/Manage/TestPaper/PaperTemplate.vue b/src/views/Manage/TestPaper/PaperTemplate.vue
index cc587a3..14d8482 100644
--- a/src/views/Manage/TestPaper/PaperTemplate.vue
+++ b/src/views/Manage/TestPaper/PaperTemplate.vue
@@ -88,8 +88,8 @@
             >
               <template slot-scope="scope">
                 <el-button type="text">棰勮</el-button>
-                <el-button type="text">缂栬緫</el-button>
-                <el-button type="text" @click="deletePaper(scope.row)" class="link-left">鍒犻櫎</el-button>
+                <el-button type="text" @click="handleUpdate(scope.row)">缂栬緫</el-button>
+                <el-button type="text" @click="deleteTemplate(scope.row)" class="link-left">鍒犻櫎</el-button>
               </template>
             </el-table-column>
           </el-table>
@@ -123,6 +123,10 @@
             <el-form-item label="鑰冭瘯鏃堕暱(鍒嗛挓)" prop="suggestTime">
               <el-input-number v-model="form.suggestTime" placeholder="璇疯緭鍏ヨ�冭瘯鏃堕暱"/>
             </el-form-item>
+            <el-form-item label="鏉冮檺" prop="visibility">
+              <el-radio v-model="form.visibility" :label="'1'">绉佹湁</el-radio>
+              <el-radio v-model="form.visibility" :label="'2'">鍏紑</el-radio>
+            </el-form-item>
             <el-form-item label="澶氶�夐寰楀垎绫诲瀷" prop="deductType" v-show="addedQuestionTypes.includes(2)"><!-- 鏈夊閫夋墠鍑虹幇 -->
               <div>
                 <el-select v-model="form.deductType" placeholder="璇烽�夋嫨澶氶�夐寰楀垎绫诲瀷" style="width: 200px;margin-right: 30px">
@@ -133,7 +137,7 @@
                     :value="item.value"
                   />
                 </el-select>
-                <el-input-number v-model="form.score" placeholder="璇疯緭鍏ュ閫夊緱鍒嗗垎鏁�"
+                <el-input-number v-model="form.deductTypeScore" placeholder="璇疯緭鍏ュ閫夎瘎鍒�"
                                  v-show="form.deductType === 2 || form.deductType === 3"/>
               </div>
             </el-form-item>
@@ -188,6 +192,7 @@
             <el-button @click="cancel">鍙� 娑�</el-button>
           </div>
         </el-dialog>
+
         <!-- 娣诲姞棰樼洰瀵硅瘽妗� -->
         <el-dialog :title="questionTitle" :visible.sync="questionOpen" width="400px" append-to-body>
           <el-form ref="questionForm" :model="questionForm" :rules="questionRules">
@@ -228,13 +233,14 @@
 } from '@/api/examTemplate'
 import subjectApi from '@/api/subject'
 import Pagination from "@/components/Pagination"
+import question from "../../../api/question";
 
 export default {
   components: {Pagination},
   data() {
     var validateDeductType = (rule, value, callback) => {
       const index = this.addedQuestionTypes.findIndex(item => item.questionType === 2)
-      if (index && (!value || value === '')) {
+      if (index !== -1 && (!value || value === '')) {
         callback(new Error('璇烽�夋嫨澶氶�夐寰楀垎鏂瑰紡'));
       } else {
         callback();
@@ -255,7 +261,9 @@
         currentPage: 1,
         pageSize: 10
       },
-      form: {},
+      form: {
+        visibility: 1
+      },
       questionForm: {},
       tableData: [],
       subjects: [],
@@ -393,6 +401,9 @@
         name: null,
         subjectId: null,
         suggestTime: null,
+        deductType: null,
+        deductTypeScore: null,
+        visibility: 1
       };
       this.addedQuestionTypes = []
       this.questionList = []
@@ -412,6 +423,7 @@
     //鏂板妯℃澘
     addTemplate() {
       this.reset();
+      this.questionReset();
       this.title = "鏂板妯℃澘"
       this.open = true;
     },
@@ -421,15 +433,28 @@
       this.questionTitle = "娣诲姞棰樼洰"
       this.questionOpen = true;
     },
-    deletePaper(row) {
+    //鍒犻櫎妯℃澘
+    deleteTemplate(row) {
       deleteExamTemplateById(row.id).then(re => {
-        if (re.code === 1) {
+        if (re.data.code === 1) {
           this.getPage()
           this.$message.success("鍒犻櫎鎴愬姛")
         } else {
-          this.$message.error(re.message)
+          this.$message.error(re.data.message)
         }
       })
+    },
+    //缂栬緫妯℃澘
+    handleUpdate(row) {
+      this.reset();
+      this.questionReset();
+      this.form = row;
+      this.questionList = row.questionList;
+      if (this.questionList && this.questionList.length > 0) {
+        this.addedQuestionTypes = this.questionList.map(question => question.questionType);
+      }
+      this.title="缂栬緫妯℃澘"
+      this.open = true;
     },
     getPage() {
       this.listLoading = true
@@ -474,25 +499,22 @@
     submitForm() {
       this.$refs['form'].validate(valid => {
         if (valid) {
-          if (this.form.deptId && this.form.deptId.length > 0) {
-            this.form.deptId = this.form.deptId[this.form.deptId.length - 1]
-          }
           let temp = {
             ...this.form,
-            category: parseInt(this.form.category)
           };
+          temp.questionList = this.questionList
           if (temp.id != null) {
-            updatePoint(temp).then(response => {
-              this.$modal.msgSuccess("淇敼鎴愬姛");
+            editExamTemplate(temp).then(response => {
+              this.$message.success("淇敼鎴愬姛");
               this.open = false;
-              this.getList();
+              this.getPage();
             });
           } else {
-            addPoint(temp).then(response => {
-              this.$modal.msgSuccess("鏂板鎴愬姛");
+            addExamTemplate(temp).then(response => {
+              this.$message.success("鏂板鎴愬姛");
               this.open = false;
               this.reset()
-              this.getList();
+              this.getPage();
             });
           }
         } else {

--
Gitblit v1.8.0