lsc 1 year ago
parent
commit
d194136b83
1 changed files with 32 additions and 17 deletions
  1. 32 17
      src/components/pages/testStudent/view/component/choice.vue

+ 32 - 17
src/components/pages/testStudent/view/component/choice.vue

@@ -6,26 +6,31 @@
             <div class="c_title">
                 <div class="title" style="display: flex;">
                     <!-- + `(${option[checkJson.type].name})` -->
-                <span style="min-width: fit-content;">{{ tindex + 1 + "、" }}</span>
-                <span>{{ checkJson.title }}</span>
-                <!-- {{ tindex + 1 + "、" + `(${option[checkJson.type].name})` + checkJson.title }} -->
-                <span style="min-width: fit-content;" v-if="checkJson.type == 2">{{ `(${option[checkJson.type].name})` }}</span>
-                <span style="color: #efa030;min-width: fit-content;" v-if="checkJson.score">({{ '分值:' + checkJson.score + '分' }})</span></div>
+                    <span style="min-width: fit-content;">{{ tindex + 1 + "、" }}</span>
+                    <span>{{ checkJson.title }}</span>
+                    <!-- {{ tindex + 1 + "、" + `(${option[checkJson.type].name})` + checkJson.title }} -->
+                    <span style="min-width: fit-content;" v-if="checkJson.type == 2">{{
+            `(${option[checkJson.type].name})` }}</span>
+                    <span style="color: #efa030;min-width: fit-content;" v-if="checkJson.score">({{ '分值:' +
+            checkJson.score + '分' }})</span>
+                </div>
                 <div class="p_box" v-if="isTeacher == 1 && checkJson.score">
-                    <el-input v-model="score2" class="c_input" disabled></el-input><span style="margin: 0 10px;">/</span><span>{{ checkJson.score }}分</span>
+                    <el-input v-model="score2" class="c_input" disabled></el-input><span
+                        style="margin: 0 10px;">/</span><span>{{ checkJson.score }}分</span>
                 </div>
                 <div class="p_box" v-if="isTeacher == 2 && checkJson.score2">
-                    <span>{{ checkJson.score2 }}分</span><span style="margin: 0 10px;">/</span><span>{{ checkJson.score }}分</span>
+                    <span>{{ checkJson.score2 }}分</span><span style="margin: 0 10px;">/</span><span>{{ checkJson.score
+                        }}分</span>
                 </div>
             </div>
             <div class="choices">
                 <div class="choice" v-for="(item, index) in checkJson.array" :key="index">
-                    <div class="choice_c" v-if="checkJson.type == 2"><el-checkbox v-model="checkJson.answer2" :label="index"
-                            :disabled="checktype == 2"></el-checkbox><span
+                    <div class="choice_c" v-if="checkJson.type == 2"><el-checkbox v-model="checkJson.answer2"
+                            :label="index" :disabled="checktype == 2" @change="changeJson"></el-checkbox><span
                             :class="{ right: see && cJson.answer.indexOf(index) != -1 }"
                             @click="check(checkJson.type, index)">{{ item.option }}</span></div>
-                    <div class="choice_c" v-if="checkJson.type == 1"><el-radio v-model="checkJson.answer2[0]" :label="index"
-                            :disabled="checktype == 2"></el-radio><span
+                    <div class="choice_c" v-if="checkJson.type == 1"><el-radio v-model="checkJson.answer2[0]"
+                            :label="index" :disabled="checktype == 2" @change="changeJson"></el-radio><span
                             :class="{ right: see && cJson.answer.indexOf(index) != -1 }"
                             @click="check(checkJson.type, index)">{{ item.option }}</span></div>
                 </div>
@@ -37,7 +42,7 @@
 <script>
 export default {
     props: {
-        tindex:{
+        tindex: {
             type: Number
         },
         cJson: {
@@ -77,13 +82,15 @@ export default {
     watch: {
         checkJson: {
             handler(newValue) {
+                console.log(1);
                 this.$emit('update:cJson', newValue)
+                this.$forceUpdate()
             },
             deep: true
         },
         cJson: {
             handler(newValue) {
-                if(JSON.stringify(newValue.answer2) !== JSON.stringify(this.checkJson.answer2)){
+                if (JSON.stringify(newValue.answer2) !== JSON.stringify(this.checkJson.answer2)) {
                     this.checkJson = this.depthCopy(newValue)
                     this.$forceUpdate()
                 }
@@ -92,6 +99,12 @@ export default {
         },
     },
     methods: {
+        changeJson() {
+            console.log(1);
+            this.$forceUpdate()
+            this.$emit('update:cJson', this.checkJson)
+            this.$forceUpdate()
+        },
         depthCopy(s) {
             return JSON.parse(JSON.stringify(s));
         },
@@ -108,6 +121,8 @@ export default {
             } else if (type == 1) {
                 this.checkJson.answer2[0] = index
             }
+            console.log(1);
+            this.$emit('update:cJson', this.checkJson)
             this.$forceUpdate()
         }
     },
@@ -134,18 +149,18 @@ export default {
     white-space: pre-line;
 }
 
-.choice_box> .c_title .title {
+.choice_box>.c_title .title {
     font-weight: bold;
     width: 100%;
     word-break: break-all;
 }
 
-.choice_box> .c_title {
+.choice_box>.c_title {
     display: flex;
     justify-content: space-between;
 }
 
-.choice_box> .c_title .p_box{
+.choice_box>.c_title .p_box {
     margin-left: 5px;
     min-width: fit-content;
     display: flex;
@@ -222,7 +237,7 @@ export default {
     width: 90px;
 }
 
-.c_input >>> .el-input__inner{
+.c_input>>>.el-input__inner {
     padding: 0 5px;
     text-align: right;
 }