Browse Source

结果显示

wyq 4 years ago
parent
commit
1bf9e14e66
1 changed files with 26 additions and 28 deletions
  1. 26 28
      src/js/staticInfo.js

+ 26 - 28
src/js/staticInfo.js

@@ -127,7 +127,7 @@ function renderContentscale(list, contentWrapClassName, name) {
     if (item.textType == 11) {
       anchors = '<li><i></i><a href="#' + contentWrapClassName + i +
         '">' + item.content + '</a></li><li class="anchor-line"></li>';
-      
+
       item.content = item.content && item.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
       str = '<div class="infoBox scaleBox" data-id="' + item.id + '"><div class="title"> <h2 class="titleH2" id="' + contentWrapClassName + i +
         '">'
@@ -142,7 +142,6 @@ function renderContentscale(list, contentWrapClassName, name) {
           var it = items.detailList[k];
           it.content = it.content && it.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
           str = '<div class="contentList" data-id="' + it.parentId + '"><div class="item-list">';
-          console.log(it)
           if (it.selectType == 21) {
             str += '<p class="item-title">' + it.content + '</p>'
           } else if (it.selectType == 22) {
@@ -156,13 +155,13 @@ function renderContentscale(list, contentWrapClassName, name) {
             its.content = its.content && its.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
             str = '<div class="radio" name="scale' + its.parentId + '" value="' + its.score + '">';
             if (it.selectType == 21 && item.resultType == 1) {
-              str += '<label><input class="radio_type" type="radio" name="scale' + its.parentId + '" value="' + its.score + '"/>'
+              str += '<label><input class="radio_type" type="radio" name="scale' + it.parentId + '" value="' + its.score + '"/>'
             } else if (it.selectType == 22 && item.resultType == 1) {
-              str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="checkbox" value="' + its.score + '" />'
+              str += '<label><input class="radio_type" name="scale' + it.parentId + '" type="checkbox" value="' + its.score + '" />'
             } 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="' + its.result + '"/>'
+              str += '<label><input class="radio_type" name="scale' + it.parentId + '" type="radio" value="' + its.result + '" data_obj="' + 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="' + its.result + '"/>'
+              str += '<label><input class="radio_type" name="scale' + it.parentId + '" type="checkbox" value="' + its.result + '" data_obj="' + its.result + '"/>'
             }
             str += its.content
             if (item.resultType == 1) {
@@ -234,28 +233,28 @@ function getcheck() {
   $('input:radio').click(function () {
     const domName = $(this).attr('name');
     const $radio = $(this);
+    const id = $(this).parents('.contentList').data("id");
     if ($radio.data('waschecked') == true) {
       $radio.prop('checked', false);
       $("input:radio[name='" + domName + "']").data('waschecked', false);
+      // $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", false);
     } else {
       $radio.prop('checked', true);
       $("input:radio[name='" + domName + "']").data('waschecked', false);
       $radio.data('waschecked', true);
+      // $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", true);
     }
   });
-  $('input:checkbox').click(function () {
-    const domName = $(this).attr('name');
-    const $radio = $(this);
-
-    if ($radio.data('waschecked') == true) {
-      $radio.prop('checked', false);
-      $("input:checkbox[name='" + domName + "']").data('waschecked', false);
-    } else {
-      $radio.prop('checked', true);
-      $("input:checkbox[name='" + domName + "']").data('waschecked', false);
-      $radio.data('waschecked', true);
-    }
-  });
+  // $('input:checkbox').click(function () {
+  //   const domName = $(this).attr('name');
+  //   const $radio = $(this);
+  //   const id = $(this).parents('.contentList').data("id");
+  //   if ($radio.data('waschecked') == true) {
+  //     $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", false);
+  //   } else {
+  //     $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", true);
+  //   }
+  // });
 }
 
 function copy(name) {
@@ -265,7 +264,7 @@ function copy(name) {
       return
     }
     var inputs = document.getElementById("inputs");
-    inputs.value = name+'量表结果为:'+texts; // 修改文本框的内容(赋值内容)
+    inputs.value = name + '量表结果为:' + texts; // 修改文本框的内容(赋值内容)
     console.log(inputs.value)
     inputs.select(); // 选中文本
     document.execCommand("copy"); // 执行浏览器复制命令
@@ -285,19 +284,18 @@ function getResult(pushInfo, textType) {
     let result
     let key = false
     $(".contentList").each(function (i) {
-      if ($(this).find('input[type="radio"]:checked').val() == undefined) {
+      if ($(this).find('input[type="radio"]:checked').val() == undefined && $(this).find('.radio_type').attr('disabled') == undefined) {
         $(this).find(".item-title").addClass('chColor');
       } else {
         $(this).find(".item-title").removeClass('chColor');
       }
-      if ($(this).find('input[type="checkbox"]:checked').val() == undefined) {
+      if ($(this).find('input[type="checkbox"]:checked').val() == undefined && $(this).find('.radio_type').attr('disabled') == undefined) {
         $(this).find(".item-titles").addClass('chColor');
       } else {
         $(this).find(".item-titles").removeClass('chColor');
       }
     });
-    console.log(!$(".contentList").find(".item-title").hasClass('chColor'))
-    if (!$(".contentList").find(".item-title").hasClass('chColor')) {
+    if (!$(".contentList").find(".item-title").hasClass('chColor') && !$(".contentList").find(".item-titles").hasClass('chColor')) {
       $('input[type="radio"]:checked').each(function () {
         if (Number($(this).val())) {
           num += parseFloat($(this).val())
@@ -317,9 +315,9 @@ function getResult(pushInfo, textType) {
         for (var i = 0; i < pushInfo.length; i++) {
           if (pushInfo[i].content.max >= num >= pushInfo[i].content.min) {
             if (tmp) {
-              result = pushInfo[i].result + ';' + tmp
+              result = pushInfo[i].result + '(' + num + ')' + ';' + tmp
             } else {
-              result = pushInfo[i].result
+              result = pushInfo[i].result + '(' + num + ')'
             }
           }
         }
@@ -333,8 +331,8 @@ function getResult(pushInfo, textType) {
       $(".hel").attr({
         "title": result
       });
-      $(".result_title").html(result +'('+ num +')');
-      if ($.inArray(13, textType)>0){
+      $(".result_title").html(result);
+      if ($.inArray(13, textType) > 0) {
         $(".score").html('总分:' + num + '分');
       }
       $(".score").css('display', 'block')