浏览代码

Merge branch 'dynamicScale0609' into testNew

# Conflicts:
#	src/css/informationOut.less
#	src/js/informationOut.js
wyq 4 年之前
父节点
当前提交
f43efb57de
共有 5 个文件被更改,包括 179 次插入87 次删除
  1. 23 4
      src/css/informationOut.less
  2. 2 1
      src/css/staticInfo.less
  3. 2 1
      src/css/staticInfoOut.less
  4. 139 63
      src/js/informationOut.js
  5. 13 18
      src/js/staticInfo.js

+ 23 - 4
src/css/informationOut.less

@@ -346,6 +346,7 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
   background: url("../images/link.png") 0 -2px no-repeat;
   background-size: 25px 25px;
 }
+<<<<<<< HEAD
 .footer{
   width: 100%;
   height: 52px;
@@ -385,6 +386,8 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
   background: #f0f2f5;
   opacity: .2;
 }
+=======
+>>>>>>> dynamicScale0609
 
 .scaletitle{
   font-size: 20px;
@@ -403,7 +406,11 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
   margin-bottom: 6px;
   .item-list{
     padding: 0 21px;
+<<<<<<< HEAD
     .item-title{
+=======
+    .item-title,.item-titles{
+>>>>>>> dynamicScale0609
       font-size: 14px;
       font-weight: 400;
       color: #333333;
@@ -453,6 +460,10 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
     font-size: 16px;
     font-weight: 400;
     color: #2A9BD5;
+<<<<<<< HEAD
+=======
+    margin-right: 9px;
+>>>>>>> dynamicScale0609
   }
   .score{
     font-size: 16px;
@@ -469,12 +480,12 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
   font-weight: 500;
   color: #333333;
   display: none;
-  margin: 0 6.5%;
+  margin: 0 75px;
+  text-align: center;
   .result_box{
     display: flex;
-    align-items: center;
     justify-content: center;
-    padding: 20px;
+    padding:25px 56px;
     .hel{
       width: 21px;
       height: 21px;
@@ -503,13 +514,15 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
     .printing{
       display: flex;
       align-items: center;
-      justify-content: space-around;
       width: 94px;
       height: 32px;
       background: #FFFFFF;
       border-radius: 4px;
       border: 1px solid #333333;
       cursor: pointer;
+      & img{
+        margin: 0 12px 0 14px;
+      }
     }
     .printing:hover{
       background: #2C96E5;
@@ -538,6 +551,9 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
 #inputs{
   position: absolute;top: 0;left: 0;opacity: 0;z-index: -10;
 }
+#Print{
+  overflow-x: hidden;
+}
 .scale{
   .infos-box{
     border: 1px solid #E6E6E6;
@@ -549,4 +565,7 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
       padding-right: 75px;
     }
   }
+}
+.chColor{
+  color: red!important;
 }

+ 2 - 1
src/css/staticInfo.less

@@ -399,6 +399,7 @@
     font-size: 16px;
     font-weight: 400;
     color: #2A9BD5;
+    margin-right: 9px;
   }
   .score{
     font-size: 16px;
@@ -415,7 +416,7 @@
   font-weight: 500;
   color: #333333;
   display: none;
-  margin: 0 6.5%;
+  margin: 0 75px;
   text-align: center;
   .result_box{
     display: flex;

+ 2 - 1
src/css/staticInfoOut.less

@@ -443,6 +443,7 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
     font-size: 16px;
     font-weight: 400;
     color: #2A9BD5;
+    margin-right: 9px;
   }
   .score{
     font-size: 16px;
@@ -459,7 +460,7 @@ div,li,span,i,p,h1,h2,h3,h4,h5,pre{
   font-weight: 500;
   color: #333333;
   display: none;
-  margin: 0 6.5%;
+  margin: 0 75px;
   .result_box{
     display: flex;
     justify-content: center;

+ 139 - 63
src/js/informationOut.js

@@ -174,15 +174,15 @@ function renderContent(list, contentWrapClassName){
 
 function renderContentscale(list, contentWrapClassName, name) {
   var pushInfo = []
-  anchors = '<li><i></i><a href="#' + contentWrapClassName +
-    '">' + name + '</a></li><li class="anchor-line"></li>';
-  str = '<p class="scaletitle">' + name + '</p>'
-  $(`.${contentWrapClassName} .infos .infos-box`).append(str);
-  $(`.${contentWrapClassName} .anchors ul`).append(anchors);
+  var textType = []
   for (var i = 0; i < list[0].detailList.length; i++) {
     var item = list[0].detailList[i];
-    console.log(item)
+    console.log(item.resultType)
+    textType.push(item.textType)
     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 +
         '">'
@@ -190,18 +190,18 @@ function renderContentscale(list, contentWrapClassName, name) {
       str += '</h2></div>'
       str = `<div class="infoWrapper">${str}</div>`
       $(`.${contentWrapClassName} .infos .infos-box`).append(str);
+      $(`.${contentWrapClassName} .anchors ul`).append(anchors);
       for (var j = 0; j < item.subList.length; j++) {
         var items = item.subList[j];
         for (var k = 0; k < items.detailList.length; k++) {
           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">';
-          if (it.selectType == 1) {
+          str = '<div class="contentList" data-id="' + it.parentId + '-' + it.groupNum + '"><div class="item-list">';
+          if (it.selectType == 21) {
             str += '<p class="item-title">' + it.content + '</p>'
-          } else if (it.selectType == 2) {
+          } else if (it.selectType == 22) {
             str += '<p class="item-titles">' + it.content + '</p>'
           }
-
           str += '<div class="item-content" data-id="' + it.id + '">'
           str += '</div></div></div>'
           $(".scale .infos .infos-box .infoWrapper .infoBox[data-id=" + it.parentId + "]").append(str);
@@ -209,21 +209,21 @@ function renderContentscale(list, contentWrapClassName, name) {
             var its = it.subList[0].detailList[l];
             its.content = its.content && its.content.replace(/{imageUrlPrefix}/g, imageUrlPrefix);
             str = '<div class="radio" name="scale' + its.parentId + '" value="' + its.score + '">';
-            if (it.selectType == 1 && item.resultType == 1) {
-              str += '<label><input class="radio_type" type="checkbox" name="scale' + its.parentId + '" value="' + its.score + '"/>'
-            } else if (it.selectType == 2 && item.resultType == 1) {
-              str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.score + '" />'
-            } else if (it.selectType == 1 && item.resultType == 2) {
+            if (it.selectType == 21 && item.resultType == 1) {
+              str += '<label><input class="radio_type" type="radio" name="scale' + its.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 + '"/>'
+            } 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="' + its.result + '"/>'
-            } else if (it.selectType == 2 && item.resultType == 2) {
-              str += '<label><input class="radio_type" name="scale' + its.parentId + '" type="radio" value="' + its.result + '" data_obj="' + its.result + '"/>'
             }
             str += its.content
             if (item.resultType == 1) {
               str += '<span class="num">' + '(' + its.score + ')' + '</span>'
             }
             str += '</label>'
-            str += `${item.match ? `<img class="recommend" src=${recommend} />` : ``}</div>`
+            str += `${its.match == 1 ? `<img class="recommend" src=${recommend} />` : ``}</div>`
             $(".scale .infos .infos-box .infoWrapper .infoBox[data-id=" + it.parentId + "] .contentList .item-content[data-id=" + its.parentId + "]").append(str);
           }
         }
@@ -245,7 +245,7 @@ function renderContentscale(list, contentWrapClassName, name) {
   str = '<div class="scalebot">'
   str += '<p class="score"></p>'
   str += '<button class="but">结果</button></div>'
-  str += '<div class="result"><div class="result_box"><p class="hel">?</p><span>结果:</span><p id="result_title" class="result_title"></p><textarea id="inputs"></textarea></div></div>'
+  str += `<div class="result"><div class="result_box"><img src=${hel} class="hel"/><span>结果:</span><p id="result_title" class="result_title"></p><textarea id="inputs"></textarea></div></div>`
   str += `<div class="foot"><div class="foot_box"><div class="printing"><img src=${printing} class="slideImg"/>打印</div><div class="copy">确认并复制结果</div></div></div>`
   $(`.${contentWrapClassName} .infos .infos-box`).append(str);
   // str = `<div class="foot"><div class="foot_box"><div class="printing"><img src=${printing} class="slideImg"/>打印</div><div class="copy">确认并复制结果</div></div></div>`
@@ -267,53 +267,94 @@ function renderContentscale(list, contentWrapClassName, name) {
   adjustHeight();
   adjustWidth()
   getcheck()
-  getResult(pushInfo)
-  copy()
+  getResult(pushInfo, textType)
+  copy(name)
   getprinting()
 }
 
 function getprinting() {
   $('.printing').click(function () {
     $('.foot').hide()
-    $('.hel').hide()
+    // $('.hel').hide()
     $('#Print').css({
       'height': 'auto', //高度自动
     }).jqprint();
     $('.foot').show()
-    $('.hel').show()
-
+    // $('.hel').show()
   })
-
 }
 
 function getcheck() {
   $('input:radio').click(function () {
-    var domName = $(this).attr('name');
-    var $radio = $(this);
+    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);
+      if (isclick) {
+        getchecks()
+        $(".score").html('');
+        $(".result_title").html('');
+        $(".result").css('display', 'none')
+        $(".foot").css('display', 'none')
+      }
     } 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);
+      if (isclick) {
+        getchecks()
+        $(".score").html('');
+        $(".result_title").html('');
+        $(".result").css('display', 'none')
+        $(".foot").css('display', 'none')
+      }
     }
-    console.log("选中状态:", $(this).prop("checked"));
-    console.log($("input:radio[name='" + domName + "']:checked").val());
+  });
+  $('input:checkbox').click(function () {
+    const domName = $(this).attr('name');
+    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) {
+        $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", false);
+        if (isclick) {
+          getchecks()
+          $(".score").html('');
+          $(".result_title").html('');
+          $(".result").css('display', 'none')
+          $(".foot").css('display', 'none')
+        }
+      } else {
+        $radio.parents('.contentList').siblings(".contentList[data-id='" + id + "']").find('.radio_type').attr("disabled", true);
+        if (isclick) {
+          getchecks()
+          $(".score").html('');
+          $(".result_title").html('');
+          $(".result").css('display', 'none')
+          $(".foot").css('display', 'none')
+        }
+      }
+    })
   });
 }
 
-function copy() {
+function copy(name) {
   $(".copy").click(function () {
     var texts = document.getElementById("result_title").innerText;
     if (texts == '') {
+      Toast('结果为空,无法复制', 500, 'warn')
       return
     }
     var inputs = document.getElementById("inputs");
-    inputs.value = texts; // 修改文本框的内容(赋值内容)
+    inputs.value = name + '结果为:' + texts; // 修改文本框的内容(赋值内容)
+    console.log(inputs.value)
     inputs.select(); // 选中文本
     document.execCommand("copy"); // 执行浏览器复制命令
-    Toast('复制成功', 500)
+    Toast('复制成功', 500, 'success')
     setTimeout(() => {
       window.close()
     }, 500)
@@ -321,71 +362,106 @@ function copy() {
   })
 
 }
+function getchecks() {
+  $(".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');
+    } else {
+      $(this).find(".item-title").removeClass('chColor');
+    }
+    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');
+    }
+  });
+}
 
-function getResult(pushInfo) {
+function getResult(pushInfo, textType) {
   $(".but").click(function () {
     let arr = [];
+    let multarr = []
+    let multname
     let num = 0
     let result
     let key = false
+    let proposal = ''
+    isclick = true
     $(".contentList").each(function (i) {
-      if ($(this).find('input[type="radio"]:checked').val() == undefined) {
-        $(this).find(".item-titles").addClass('chColor');
-      } else {
-        $(this).find(".item-titles").removeClass('chColor');
-      }
-      if ($(this).find('input[type="checkbox"]: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 && $(this).find('.radio_type').attr('disabled') == undefined) {
+        $(this).find(".item-titles").addClass('chColor');
+      } else {
+        $(this).find(".item-titles").removeClass('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())) {
+        if (!isNaN($(this).val())) {
           num += parseFloat($(this).val())
         } else {
           arr.push($(this).attr("data_obj"))
         }
       });
       $('input[type="checkbox"]:checkbox:checked').each(function () {
-        if (Number($(this).val())) {
+        if (!isNaN($(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"))
         }
       });
-      tmp = arr.join(",");
+
+      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 >= pushInfo[i].content.min) {
-            if (tmp) {
-              result = pushInfo[i].result + ';' + tmp
-            } else {
-              result = pushInfo[i].result
-            }
+          if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min && !tmp) {
+            result = pushInfo[i].result + '(' + num + '分' + ')'
+            proposal = pushInfo[i].pushInfo
+            break
+          } else if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min && tmp) {
+            result = pushInfo[i].result + '(' + num + '分' + ')' + ';' + tmp
+            proposal = pushInfo[i].pushInfo
+            break
+          } else {
+            result = tmp
           }
         }
       } else {
         result = tmp
       }
 
-      $(".result_title").attr({
-        "title": result
-      });
-      $(".hel").attr({
-        "title": result
-      });
-      $(".result_title").html(result);
-      $(".score").html('总分:' + num + '分');
-      $(".score").css('display', 'block')
-      $(".result").css('display', 'block')
-      $(".foot").css('display', 'block')
+      if (result == undefined) {
+        if ($.inArray(13, textType) > 0) {
+          $(".score").html('总分:' + num + '分');
+        }
+        $(".score").css('display', 'block')
+        $(".copy").css('display', 'none')
+        $(".foot").css('display', 'block')
+      } else {
+        $(".hel").attr({
+          "title": proposal
+        });
+        $(".result_title").html(result);
+        if ($.inArray(13, textType) > 0) {
+          $(".score").html('总分:' + num + '分');
+        }
+        $(".result").css('display', 'block')
+        $(".score").css('display', 'block')
+        $(".copy").css('display', 'block')
+        $(".foot").css('display', 'block')
+      }
     } else {
-      Toast('温馨提示:必填选项不能为空~', 500)
+      Toast('温馨提示:必填选项不能为空~', 50000000, 'warn')
     }
   })
-
   $(".printing").hover(
     function () {
       $(".slideImg").attr("src", printing2);

+ 13 - 18
src/js/staticInfo.js

@@ -294,10 +294,10 @@ function copy(name) {
     console.log(inputs.value)
     inputs.select(); // 选中文本
     document.execCommand("copy"); // 执行浏览器复制命令
-    Toast('复制成功', 500000000, 'success')
-    // setTimeout(() => {
-    //   window.close()
-    // }, 500)
+    Toast('复制成功', 500, 'success')
+    setTimeout(() => {
+      window.close()
+    }, 500)
 
   })
 
@@ -359,24 +359,19 @@ function getResult(pushInfo, textType) {
       if (multarr.join("、")){
         arr.push(multname + multarr.join("、"))
       }
-      console.log(arr)
       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) {
-              result = pushInfo[i].result + '(' + num + '分' + ')' + ';' + tmp
-              proposal = pushInfo[i].pushInfo
-            } else {
-              result = pushInfo[i].result + '(' + num + '分' + ')'
-              proposal = pushInfo[i].pushInfo
-            }
+          if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min && !tmp) {
+            result = pushInfo[i].result + '(' + num + '分' + ')'
+            proposal = pushInfo[i].pushInfo
+            break
+          } else if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min && tmp){
+            result = pushInfo[i].result + '(' + num + '分' + ')' + ';' + tmp
+            proposal = pushInfo[i].pushInfo
+            break
           } else {
-            if (tmp) {
-              console.log(123)
-              result = tmp
-            }
+            result = tmp
           }
         }
       } else {