Browse Source

结果限制小数保留一位

wyq 3 years ago
parent
commit
183bf00126
3 changed files with 39 additions and 22 deletions
  1. 8 7
      src/js/informationOut.js
  2. 1 1
      src/js/promise.js
  3. 30 14
      src/js/staticInfo.js

+ 8 - 7
src/js/informationOut.js

@@ -22,7 +22,7 @@ const print = require("../js/jQuery.print")
 let printing = require('./../images/printing.png');
 let printing2 = require('./../images/printing2.png');
 let hel = require('./../images/icon-hel.png');
-let showName, noticeName, clinicalPathwayName, showLis = [], selectedDrop = 0, selectedTab = 0, isclick, num
+let showName, noticeName, clinicalPathwayName, showLis = [], selectedDrop = 0, selectedTab = 0, isclick, num, top = 0
 
 //如果是子窗口,隐藏网页查看按钮
 function myBrowser() {
@@ -415,6 +415,9 @@ function getchecks() {
     }
   });
 }
+$('#Print').on('scroll', function () {
+  top = $('#Print').scrollTop()
+})
 function getResult(pushInfo, textType, constant) {
   $(".but").click(function () {
     let arr = [];
@@ -455,7 +458,7 @@ function getResult(pushInfo, textType, constant) {
       }
     }
     if (v) {
-      $(`.scale .infos`).scrollTop(v.top + 346)
+      $(`.scale .infos`).scrollTop(v.top + top - 160)
     }
     if (!$(".contentList").find(".item-title").hasClass('chColor') && !$(".contentList").find(".item-titles").hasClass('chColor')) {
       $('input[type="radio"]:checked').each(function () {
@@ -502,16 +505,14 @@ function getResult(pushInfo, textType, constant) {
         result = tmp
         proposal = proposals.join(";");
       }
-      console.log(constant)
-      // num = num+constant
-      console.log(num)
+      num = num+constant
       if (result) {
         $(".hel").attr({
           "title": proposal
         });
         $(".result_title").html('结果:' + result);
         if (num >= 0 && numType) {
-          $(".score").html('总分:' + num + '分');
+          $(".score").html('总分:' + num.toFixed(1) + '分');
         }
         $(".result").css('display', 'block')
         $(".score").css('display', 'block')
@@ -519,7 +520,7 @@ function getResult(pushInfo, textType, constant) {
         $(".foot").css('display', 'block')
       } else {
         if (num >= 0 && numType) {
-          $(".score").html('总分:' + num + '分');
+          $(".score").html('总分:' + num.toFixed(1) + '分');
         }
         $(".score").css('display', 'block')
         $(".copy").css('display', 'none')

+ 1 - 1
src/js/promise.js

@@ -153,7 +153,7 @@ const newinConf = {
 const newWindowLocationTcm = `width=800, height=600, left=${newinConf.left}, top=${newinConf.top},resizable=yes, scrollbars=yes`
 const newWindowLocation = `width=${newinConf.width}, height=${newinConf.height}, left=${newinConf.left}, top=${newinConf.top},resizable=yes, scrollbars=yes`
 const openNewWin = function (url, isTcm) {
-  window.open(url, newinConf.openMode, isTcm ? newWindowLocationTcm : newWindowLocation, "width=300,height=200")
+  window.open(url, newinConf.openMode, isTcm ? newWindowLocationTcm : newWindowLocation)
 }
 
 //判断浏览器是否为Ie8

+ 30 - 14
src/js/staticInfo.js

@@ -26,7 +26,7 @@ let printing2 = require('./../images/printing2.png');
 let recommend = require('./../images/recommend.png');
 let hel = require('./../images/icon-hel.png');
 
-let showName, noticeName, clinicalPathwayName, isclick
+let showName, noticeName, clinicalPathwayName, isclick,top = 0
 function myBrowser() {
   var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
   var isOpera = userAgent.indexOf("Opera") > -1;
@@ -132,7 +132,7 @@ function renderContentscale(list, contentWrapClassName, name) {
     if (item.resultType == 1) {
       constant += parseFloat(item.constant)
     }
-    if (item.textType == 11) { 
+    if (item.textType == 11) {
       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 +
         '">'
@@ -244,12 +244,20 @@ function getprinting() {
     $('.scalebot').hide()
     $('#Print').css({
       'height': 'auto', //高度自动
-    }).print();
+    }).print({
+      globalStyles: true,
+      mediaPrint: false,
+      iframe: false,
+      noPrintSelector: ".avoid-this",
+      prepend: "",
+      append: "",
+      deferred: $.Deferred().done(function () { $("title").html("合同预览") })
+    });
     $('.foot').show()
     $('.scalebot').show()
     $('#Print').css({
       'height': '100%', //高度自动
-    }); 
+    });
   })
 }
 
@@ -318,7 +326,9 @@ function getcheck() {
     })
   });
 }
-
+$('#Print').on('scroll', function () {
+  top = $('#Print').scrollTop()
+})
 function copy(name) {
   $(".copy").click(function () {
     var texts = document.getElementById("result_title").innerText;
@@ -380,15 +390,14 @@ function getResult(pushInfo, textType, constant) {
       }
       scrollTop.push($(this).eq(0).find(".chColor").offset())
     });
-
     for (var i = 0; i < scrollTop.length; i++) {
-      if (scrollTop[i] != undefined){
+      if (scrollTop[i] != undefined) {
         v = scrollTop[i]
         break
       }
     }
     if (v) {
-      $(`.scale .infos`).scrollTop(v.top + 346)
+      $(`.scale .infos`).scrollTop(v.top + top-160)
     }
     if (!$(".contentList").find(".item-title").hasClass('chColor') && !$(".contentList").find(".item-titles").hasClass('chColor')) {
       $('input[type="radio"]:checked').each(function () {
@@ -405,16 +414,25 @@ function getResult(pushInfo, textType, constant) {
         } else {
           arr.push($(this).attr("data_obj"))
           proposals.push($(this).attr("proposal"))
-        } 
+        }
       });
+      num = num + constant
+      var dot = JSON.stringify(num).indexOf(".");
+      if (dot != -1) {
+        var dotCnt = JSON.stringify(num).substring(dot + 1, num.length);
+        if (dotCnt.length > 1) {
+          num = parseFloat(num).toFixed(1)
+        }
+      }
+
       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 && !tmp) {
             result = pushInfo[i].result + '(' + num + '分' + ')'
-            if (proposals.join(";")){
+            if (proposals.join(";")) {
               proposal = pushInfo[i].pushInfo + ';' + proposals.join(";");
-            }else{
+            } else {
               proposal = pushInfo[i].pushInfo
             }
             break
@@ -435,9 +453,7 @@ function getResult(pushInfo, textType, constant) {
         result = tmp
         proposal = proposals.join(";");
       }
-      console.log(constant)
-      // num = num+constant
-      console.log(num)
+      
       if (result) {
         $(".hel").attr({
           "title": proposal