Browse Source

新增问卷多选功能及修改选择题图片问题

zengyicheng 1 year ago
parent
commit
d45d177287

+ 1 - 1
src/components/components/askStatic2.vue

@@ -418,7 +418,7 @@ export default {
   align-items: center;
 }
 .timuImg {
-  width: 100%;
+  width: 100px;
   margin-right: 10px;
   cursor: pointer;
 }

+ 79 - 35
src/components/noTerminal/studyStudent.vue

@@ -3534,11 +3534,28 @@
             </div>
             <div class="a_add_body">
               <div class="a_add_input">
-                <el-radio-group v-model="radio[index1]">
+                <el-radio-group v-model="radio[index1]" v-if="
+                    askJson.askJson[index1].type == '1' ||
+                    !askJson.askJson[index1].type
+                  ">
                   <el-radio v-for="(item2, checkIndex) in askJson.askJson[index1]
                       .checkList" :key="checkIndex" :label="checkIndex" :disabled="isAnswer" class="redioStyle"><span
                       v-html="item2"></span></el-radio>
                 </el-radio-group>
+                <el-checkbox-group
+                  v-model="radio[index1]"
+                  v-if="askJson.askJson[index1].type == '2'"
+                >
+                  <el-checkbox
+                    v-for="(item2, checkIndex1) in askJson.askJson[index1]
+                      .askItem"
+                    :key="checkIndex1"
+                    :label="checkIndex1"
+                    :disabled="isAnswer"
+                    class="redioStyle"
+                    ><span v-html="item2"></span>
+                  </el-checkbox>
+                </el-checkbox-group>
               </div>
             </div>
           </div>
@@ -6593,7 +6610,7 @@ export default {
               if (i == b[j].tool) {
                 if (data.type == 2 && a[i].tool[0] == 4) {
                   // if(JSON.parse(data.content)[0].anwer){
-                  var checkL = JSON.parse(data.content)[0].anwer.split(",");
+                  var checkL = JSON.parse(data.content)[0].anwer;
                   for (var z = 0; z < checkL.length; z++) {
                     if (!this.checkJson[i][z]) {
                       this.checkJson[i].push({
@@ -6610,27 +6627,50 @@ export default {
                         this.checkJson[i][z].checkCount.push(0);
                       }
                     }
-                    if (
-                      (JSON.parse(data.content)[0].askJson.askJson[z].answer ||
-                        JSON.parse(data.content)[0].askJson.askJson[z].answer ==
-                        0) &&
-                      JSON.parse(data.content)[0].askJson.askJson[z].answer ==
-                      checkL[z]
-                    ) {
-                      this.checkJson[i][z].rightPerson.push(data.name);
+                    if (checkL[z] instanceof Array) {
+                      if (
+                        JSON.parse(data.content)[0].anwer.sort().join(",") ==
+                        checkL[z].sort().join(",")
+                      ) {
+                        this.checkJson[i][z].rightPerson.push(data.name);
+                      }
+                      for (var q = 0; q < checkL[z].length; q++) {
+                        this.checkJson[i][z].checkPerson[parseInt(checkL[z][q])]
+                          ? this.checkJson[i][z].checkPerson[
+                              parseInt(checkL[z][q])
+                            ].push(data.name)
+                          : (this.checkJson[i][z].checkPerson[
+                              parseInt(checkL[z][q])
+                            ] = [data.name]);
+                        this.checkJson[i][z].checkCount[parseInt(checkL[z][q])]
+                          ? this.checkJson[i][z].checkCount[
+                              parseInt(checkL[z][q])
+                            ]++
+                          : (this.checkJson[i][z].checkCount[
+                              parseInt(checkL[z][q])
+                            ] = 1);
+                      }
+                    } else {
+                      if (JSON.parse(data.content)[0].anwer[z] == checkL[z]) {
+                        this.checkJson[i][z].rightPerson.push(data.name);
+                      }
+                      if (parseInt(checkL[z]) || parseInt(checkL[z]) == 0) {
+                        this.checkJson[i][z].checkPerson[parseInt(checkL[z])]
+                          ? this.checkJson[i][z].checkPerson[
+                              parseInt(checkL[z])
+                            ].push(data.name)
+                          : (this.checkJson[i][z].checkPerson[
+                              parseInt(checkL[z])
+                            ] = [data.name]);
+                        this.checkJson[i][z].checkCount[parseInt(checkL[z])]
+                          ? this.checkJson[i][z].checkCount[
+                              parseInt(checkL[z])
+                            ]++
+                          : (this.checkJson[i][z].checkCount[
+                              parseInt(checkL[z])
+                            ] = 1);
+                      }
                     }
-                    this.checkJson[i][z].checkPerson[parseInt(checkL[z])]
-                      ? this.checkJson[i][z].checkPerson[
-                        parseInt(checkL[z])
-                      ].push(data.name)
-                      : (this.checkJson[i][z].checkPerson[parseInt(checkL[z])] =
-                        [data.name]);
-                    this.checkJson[i][z].checkCount[parseInt(checkL[z])]
-                      ? this.checkJson[i][z].checkCount[parseInt(checkL[z])]++
-                      : (this.checkJson[i][z].checkCount[
-                        parseInt(checkL[z])
-                      ] = 1);
-                    // }
                   }
                 } else if (data.type == 8 && a[i].tool[0] == 45) {
                   var checkL = JSON.parse(data.content)[0].anwer;
@@ -9145,12 +9185,15 @@ export default {
         return;
       }
       for (var i = 0; i < this.askJson.askCount; i++) {
-        if (this.radio[i] !== 0 && !this.radio[i]) {
+        if (
+          (this.radio[i] instanceof Array && !this.radio[i].length) ||
+          (this.radio[i] !== 0 && !this.radio[i])
+        ) {
           this.$message.error("请选择选项");
           return;
         }
       }
-      this.askList.push({ askJson: this.askJson, anwer: this.radio.join(",") });
+      this.askList.push({ askJson: this.askJson, anwer: this.radio });
       let params = [
         {
           uid: this.userid,
@@ -9427,16 +9470,9 @@ export default {
       if (t == 4) {
         this.radio = [];
         this.isAnswer = false;
-        for (var i = 0; i < z.length; i++) {
-          let a = z[i];
-          let b = a.anwer.split(",");
-          let d = [];
-          for (var j = 0; j < b.length; j++) {
-            d.push(parseInt(b[j]));
-          }
-          this.radio = d;
-          this.askJson = a.askJson;
-        }
+        let b = z[0].anwer;
+        this.radio = b;
+        this.askJson = z[0].askJson;
         this.isAnswer = true;
         this.dialogVisible5 = true;
       } else if (t == 45) {
@@ -9537,6 +9573,14 @@ export default {
             index
           ].toolChoose[i].askCount;
 
+        for (var k = 0; k < this.askJson.askJson.length; k++) {
+          if (this.askJson.askJson[k].type == "2") {
+            this.radio.push([]);
+          } else {
+            this.radio.push("");
+          }
+        }
+
         this.dialogVisible5 = true;
 
         // window.parent.postMessage({ tools: "4" }, "*");
@@ -14208,7 +14252,7 @@ ol {
 }
 
 .timuImg {
-  width: auto;
+  width: 100px;
   margin: 5px 0;
   cursor: pointer;
 }

File diff suppressed because it is too large
+ 628 - 302
src/components/studyStudent.vue


Some files were not shown because too many files changed in this diff