Parcourir la source

结果显示优化

wyq il y a 4 ans
Parent
commit
7816947c73
1 fichiers modifiés avec 24 ajouts et 24 suppressions
  1. 24 24
      src/js/staticInfo.js

+ 24 - 24
src/js/staticInfo.js

@@ -156,7 +156,7 @@ function renderContentscale(list, contentWrapClassName, name) {
             } else if (it.selectType == 21 && item.resultType == 2) {
               str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.result + '" data_obj="' + it.content + '问题' + its.result + '"/>'
             } else if (it.selectType == 22 && item.resultType == 2) {
-              str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="checkbox" value="' + its.result + '" data_obj="' + it.content + '问题' + its.result + '"/>'
+              str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="checkbox" value="' + its.result + '" data_obj="' + its.result + '"/>'
             }
             str += its.content
             if (item.resultType == 1) {
@@ -260,7 +260,7 @@ function getcheck() {
     const $radio = $(this);
     const id = $(this).parents('.contentList').data("id");
     $radio.parents('.contentList').each(function (i) {
-      if ($(this).find('input[type="checkbox"]:checked').val() == undefined){
+      if ($(this).find('input[type="checkbox"]:checked').val() == undefined) {
         $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", false);
         if (isclick) {
           getchecks()
@@ -269,7 +269,7 @@ function getcheck() {
           $(".result").css('display', 'none')
           $(".foot").css('display', 'none')
         }
-      }else{
+      } else {
         $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", true);
         if (isclick) {
           getchecks()
@@ -320,10 +320,12 @@ function getchecks() {
 function getResult(pushInfo, textType) {
   $(".but").click(function () {
     let arr = [];
+    let multarr = []
+    let multname
     let num = 0
     let result
     let key = false
-    
+
     $(".contentList").each(function (i) {
       if ($(this).find('input[type="radio"]:checked').val() == undefined && $(this).find('.radio_type').attr('disabled') == undefined) {
         $(this).find(".item-title").addClass('chColor');
@@ -349,18 +351,24 @@ function getResult(pushInfo, textType) {
         if (Number($(this).val())) {
           num += parseFloat($(this).val())
         } else {
-          arr.push($(this).attr("data_obj"))
+          multname = $(this).parents('.item-content').siblings('.item-titles').html()
+          multarr.push($(this).attr("data_obj"))
         }
       });
+      if (multarr.join("、")){
+        arr.push(multname + multarr.join("、"))
+      }
       tmp = arr.join(";");
       if (pushInfo.length > 0) {
         for (var i = 0; i < pushInfo.length; i++) {
           if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min) {
+            console.log(pushInfo[i])
             if (tmp) {
               if (num == 0) {
                 result = pushInfo[i].result + ';' + tmp
               } else {
                 result = pushInfo[i].result + '(' + num + '分' + ')' + ';' + tmp
+                console.log(result)
               }
             } else {
               if (num == 0) {
@@ -369,23 +377,27 @@ function getResult(pushInfo, textType) {
                 result = pushInfo[i].result + '(' + num + '分' + ')'
               }
             }
-          } else{
+          } else {
             if (tmp) {
-              result = tmp
-            } 
-          } 
+              if (num == 0) {
+                console.log(123)
+                result = tmp
+              }
+              
+            }
+          }
         }
       } else {
         result = tmp
       }
-      if (result == undefined){
+      if (result == undefined) {
         if ($.inArray(13, textType) > 0) {
           $(".score").html('总分:' + num + '分');
         }
         $(".score").css('display', 'block')
         $(".copy").css('display', 'none')
         $(".foot").css('display', 'block')
-      }else{
+      } else {
         $(".result_title").attr({
           "title": result
         });
@@ -401,19 +413,7 @@ function getResult(pushInfo, textType) {
         $(".copy").css('display', 'block')
         $(".foot").css('display', 'block')
       }
-      // $(".result_title").attr({
-      //   "title": result
-      // });
-      // $(".hel").attr({
-      //   "title": result
-      // });
-      // $(".result_title").html(result);
-      // if ($.inArray(13, textType) > 0) {
-      //   $(".score").html('总分:' + num + '分');
-      // }
-      // $(".result").css('display', 'block')
-      // $(".score").css('display', 'block')
-      // $(".foot").css('display', 'block')
+
     } else {
       Toast('温馨提示:必填选项不能为空~', 500)
     }