From 1cfd2dea036eeab43b1d4b6db60bc79d957b8111 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Thu, 05 Aug 2021 14:15:32 +0800
Subject: [PATCH] 考试题目修改

---
 src/views/exam/addsubject.vue |  107 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 94 insertions(+), 13 deletions(-)

diff --git a/src/views/exam/addsubject.vue b/src/views/exam/addsubject.vue
index b1eb01c..48789b9 100644
--- a/src/views/exam/addsubject.vue
+++ b/src/views/exam/addsubject.vue
@@ -1,18 +1,19 @@
 <template>
     <el-dialog
-      :title="this.id?'新增':'修改'"
+      :title="this.id?'修改':'新增'"
       width="60%"
       modal-append-to-body='false'
       append-to-body='true'
       :close-on-click-model="true"
       :visible.sync="visible"
+      @close='closeDialog'
     >
         <el-row style="margin-left:60px;margin-bottom:40px">
           <el-radio-group v-model="choicesType">
             <el-radio label="0">单选题</el-radio>
             <el-radio label="1">多选题</el-radio>
             <el-radio label="2">判断题</el-radio>
-            <el-radio label="3">填空题</el-radio>
+            <el-radio label="3">实操题</el-radio>
           </el-radio-group>
         </el-row>
         <avue-form ref="form" :option="option" v-model="form" @submit="submit" v-if="choicesType=='0'"></avue-form>
@@ -31,22 +32,15 @@
                   <el-button type="danger" class="optionContent-botton" icon="el-icon-delete" circle @click="deleteRows(index)"></el-button>
                 </div>
               </div> -->
-              <!-- <el-row :span="24">
-                <el-col :span="6">
-                  值:{{arrContent}}<br />
-                  <avue-array v-model="arrContent" placeholder="请输入内容"></avue-array>
-                </el-col>
-              </el-row> -->
           </template>
         </avue-form>
-
-        
     </el-dialog>
 </template>
 
 <script>
 import { mapState } from 'vuex'
 import {saveSubjectChoicesAndOption} from "@/api/examapi/examSubjects";
+import {getSubjectAnswer} from "@/api/exam/subject";
 
 export default {
   name: "add",
@@ -55,6 +49,10 @@
       inputs:{
         input1: 1,
       },
+      optionContentAId:null,
+      optionContentBId:null,
+      optionContentCId:null,
+      optionContentDId:null,
       arrContent:["1"],
       list:[
         {
@@ -67,7 +65,6 @@
           data:1
         },
       ],
-      id:1,
       // index:1,
       visible:false,
       choicesType:"0",
@@ -101,6 +98,7 @@
                 trigger: "blur",
               },
             ],
+            span:24
           },
           {
             label: "类型",
@@ -128,6 +126,7 @@
                 trigger: "blur",
               },
             ],
+            span:24
           },
           {
             label: "选项",
@@ -270,6 +269,7 @@
                 trigger: "blur",
               },
             ],
+            span:24
           },
           {
             label: "类型",
@@ -297,6 +297,7 @@
                 trigger: "blur",
               },
             ],
+            span:24
           },
           {
             label: "选项",
@@ -439,6 +440,7 @@
                 trigger: "blur",
               },
             ],
+            span:24
           },
           {
             label: "类型",
@@ -466,6 +468,7 @@
                 trigger: "blur",
               },
             ],
+            span:24
           },
           // {
           //   label: "选项",
@@ -561,6 +564,7 @@
                 trigger: "blur",
               },
             ],
+            span:24
           },
           {
             label: "类型",
@@ -588,6 +592,7 @@
                 trigger: "blur",
               },
             ],
+            span:24
           },
           {
             label: "选项",
@@ -687,9 +692,61 @@
   methods: {
     //初始化
     inits(id) {
-      this.id = id || 1;
+      this.id = id || 0;
       this.visible = true;
       this.list = [{data:1}]
+      if(this.id){
+        //查询题目信息
+        this.getSubjectInfo(id);
+      }
+    },
+    //查询题目信息
+    getSubjectInfo(id){
+      var that = this;
+      var param = {
+        id:id
+      }
+      getSubjectAnswer((param)).then(res => {
+        var data = res.data.data;
+        that.choicesType = data.choicesType.toString();
+        //单选题
+        if(data.choicesType==0){
+           that.form = data;
+           that.optionContentAId = data.examSubjectOptions[0].id;
+           that.optionContentBId = data.examSubjectOptions[1].id;
+           that.optionContentCId = data.examSubjectOptions[2].id;
+           that.optionContentDId = data.examSubjectOptions[3].id;
+           that.form.optionContentA = data.examSubjectOptions[0].optionContent;
+           that.form.optionContentB = data.examSubjectOptions[1].optionContent;
+           that.form.optionContentC = data.examSubjectOptions[2].optionContent;
+           that.form.optionContentD = data.examSubjectOptions[3].optionContent;
+        }
+        //多选题
+        if(data.choicesType==1){
+           that.formCheckbox = data;
+           that.optionContentAId = data.examSubjectOptions[0].id;
+           that.optionContentBId = data.examSubjectOptions[1].id;
+           that.optionContentCId = data.examSubjectOptions[2].id;
+           that.optionContentDId = data.examSubjectOptions[3].id;
+           that.formCheckbox.optionContentA = data.examSubjectOptions[0].optionContent;
+           that.formCheckbox.optionContentB = data.examSubjectOptions[1].optionContent;
+           that.formCheckbox.optionContentC = data.examSubjectOptions[2].optionContent;
+           that.formCheckbox.optionContentD = data.examSubjectOptions[3].optionContent;
+        }
+        //判断题
+        if(data.choicesType==2){
+           that.formJudge = data;
+        }
+        //实操题
+        if(data.choicesType==3){
+           that.formFill = data;
+           that.formFill.optionContent1 = data.examSubjectOptions[0].optionContent;
+           that.formFill.optionContent2 = data.examSubjectOptions[1].optionContent;
+           that.formFill.optionContent3 = data.examSubjectOptions[2].optionContent;
+           that.formFill.optionContent4 = data.examSubjectOptions[3].optionContent;
+           that.formFill.optionContent5 = data.examSubjectOptions[4].optionContent;
+        }
+      });
     },
     //加一行
     addRows(){
@@ -723,21 +780,25 @@
       //选项信息
       const examSubjectOptions = [
         {
+         id:that.optionContentAId,
          optionName:"A",
          optionContent:row.optionContentA,
          creator:this.userInfo.user_name,
         },
         {
+         id:that.optionContentBId,
          optionName:"B",
          optionContent:row.optionContentB,
          creator:this.userInfo.user_name,
         },
         {
+         id:that.optionContentCId,
          optionName:"C",
          optionContent:row.optionContentC,
          creator:this.userInfo.user_name,
         },
         {
+         id:that.optionContentDId,
          optionName:"D",
          optionContent:row.optionContentD,
          creator:this.userInfo.user_name,
@@ -770,21 +831,25 @@
       //选项信息
       const examSubjectOptions = [
         {
+         id:that.optionContentAId,
          optionName:"A",
          optionContent:row.optionContentA,
          creator:this.userInfo.user_name,
         },
         {
+         id:that.optionContentBId,
          optionName:"B",
          optionContent:row.optionContentB,
          creator:this.userInfo.user_name,
         },
         {
+         id:that.optionContentCId,
          optionName:"C",
          optionContent:row.optionContentC,
          creator:this.userInfo.user_name,
         },
         {
+         id:that.optionContentDId,
          optionName:"D",
          optionContent:row.optionContentD,
          creator:this.userInfo.user_name,
@@ -889,8 +954,24 @@
         }
       );
     },
+    //关闭窗口清除数据
+    closeDialog(){
+      if(this.choicesType==0){
+          this.$refs.form.resetFields();
+      }
+      
+      if(this.choicesType==1){
+        this.$refs.formCheckbox.resetFields();
+      }
 
-    
+      if(this.choicesType==2){
+        this.$refs.formJudge.resetFields();
+      }
+
+      if(this.choicesType==3){
+        this.$refs.formFill.resetFields();
+      }
+    }
   },
 };
 </script>

--
Gitblit v1.9.3