فهرست منبع

添加必填项

zhangxc 6 سال پیش
والد
کامیت
51bc277f0a
2فایلهای تغییر یافته به همراه39 افزوده شده و 58 حذف شده
  1. 8 0
      src/html/scale.html
  2. 31 58
      src/js/scale.js

+ 8 - 0
src/html/scale.html

@@ -46,10 +46,12 @@
         }
         .groupRowBox {
           line-height: 30px;
+          padding-left: 30px;
         }
         .groupRowRadio {
           margin: 0 20px 0 0;
           vertical-align: middle;
+          display: inline-block;
         }
         .groupRowRecommend {
           color: #267FD7;
@@ -86,6 +88,12 @@
         .groupRowWrapper {
           margin-top: 15px;
         }
+        .groupRowIndex {
+          display: inline-block;
+          width: 25px;
+          text-align: right;
+          margin-right: 5px;
+        }
         .noSelect {
           border: 1px solid red;  
           box-sizing: border-box;

+ 31 - 58
src/js/scale.js

@@ -8,11 +8,11 @@ $(function(){
     }
 
     var scaleInfo;
-    var id = GetQueryString('id') || 40744;
-    var name = GetQueryString('name') || "密西根糖尿病周围神经病评分(MDNS)";
+    var id = GetQueryString('id') || 40743;
+    var name = GetQueryString('name') || "危重病人APACHEII评分表";
     var url = "http://192.168.2.236:5050/api/icss/push/pushInner";
     var urlParam = parseUrlParams(); //参数
-    console.log('urlParam', urlParam.lis)
+    // console.log('urlParam', urlParam.lis)
     // 用GetQueryString方法从地址栏获取参数,暂时写死
     var params = {
     //   "age": parseInt(urlParam.age) || 28,
@@ -43,7 +43,7 @@ $(function(){
                 for (var i = 0; i < scaleInfo.length; i++) {
                     if( scaleInfo[i].type == 1) {
                         var scaleList = JSON.parse(scaleInfo[i].content)
-                        // console.log('scaleList', scaleList)
+                        console.log('scaleList', scaleList)
                         renderCalcu(scaleList)
                        
                     } else {
@@ -56,8 +56,15 @@ $(function(){
                             scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details[i].select = 0
                         }
                         scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details[indexList[3]].select = 1
-                        // console.log('this',$(this).parent().parent().parent())
-                        $(this).parent().parent().parent().removeClass('noSelect')
+                        // console.log('this',$(this).parent().parent().parent().attr('class'))
+                        const className = $(this).parent().parent().parent().attr('data-group')
+                        for(let i = 0; i < $('.'+className).length; i++) {
+                            $('.'+className).eq(i).removeClass('noSelect')
+                        }
+                        // for(let i = 0; i < $(this).parent().parent().parent().parent().find(className).length; i++) {
+                        //     $(this).parent().parent().parent().parent().find(className).eq(i).removeClass('noSelect')
+                        // }
+                        // $(this).parent().parent().parent().removeClass('noSelect')
                     })
     
                     $('.calcuBtn').on('click', function() {
@@ -65,19 +72,23 @@ $(function(){
                         let allSelect = true
                         for (let i = 0; i < scaleList.group.length; i++) {
                             for (let j = 0; j < scaleList.group[i].rows.length; j++) {
-                                for (let x = 0; x < scaleList.group[i].rows[j].row.length; x++) {
-                                    let itemSelect = false 
-                                    // console.log('scaleList.group[i].rows[j].row[x].details', scaleList.group[i].rows[j].row[x].details)
-                                    for (let y = 0; y < scaleList.group[i].rows[j].row[x].details.length; y++) {
-                                        if (scaleList.group[i].rows[j].row[x].details[y].select == 1) {
-                                            itemSelect = true
+                                if(scaleList.group[i].rows[j].required == 1) {
+                                    let itemSelect = false
+                                    for (let x = 0; x < scaleList.group[i].rows[j].row.length; x++) {
+                                        
+                                        // console.log('scaleList.group[i].rows[j].row[x].details', scaleList.group[i].rows[j].row[x].details)
+                                        for (let y = 0; y < scaleList.group[i].rows[j].row[x].details.length; y++) {
+                                            if (scaleList.group[i].rows[j].row[x].details[y].select == 1) {
+                                                itemSelect = true
+                                            }
                                         }
                                     }
                                     if(!itemSelect) {
                                         allSelect = false
-                                        $('#' + i + j + x).addClass('noSelect')
+                                        $('.' + i + j).addClass('noSelect')
                                     }
                                 }
+                                
                             }
                         }
                         if(allSelect) {
@@ -104,17 +115,21 @@ function renderCalcu(scaleList) {
             for (var y = 0; y < scaleList.group[j].rows[x].row.length; y++) {
                 var str2 = ''
                 for(var z = 0; z < scaleList.group[j].rows[x].row[y].details.length; z++) {
-                    str2 += '<span class="groupRowRadio"><input  type=radio data-index='+ j +',' + x+',' + y +',' + z +'  name='+scaleList.group[j].rows[x].row[y].name +' id='+scaleList.group[j].rows[x].row[y].name+scaleList.group[j].rows[x].row[y].details[z].detailName
+                    str2 += '<span class="groupRowRadio"><input  type=radio data-index='+ j +',' + x+',' + y +',' + z +'  name='+ j + x + y +' id=' + j + x + y + z
                     if (scaleList.group[j].rows[x].row[y].details[z].select == 1) {
                         str2 += ' checked="checked"'
                     }
-                    str2 += ' />'+'<label for="'+scaleList.group[j].rows[x].row[y].name+scaleList.group[j].rows[x].row[y].details[z].detailName+'">' + scaleList.group[j].rows[x].row[y].details[z].detailName + '('+scaleList.group[j].rows[x].row[y].details[z].score +')'+'</label>'
+                    str2 += ' />'+'<label for="'+ j + x + y + z+'">' + scaleList.group[j].rows[x].row[y].details[z].detailName + '('+scaleList.group[j].rows[x].row[y].details[z].score +')'+'</label>'
                     if (scaleList.group[j].rows[x].row[y].name+scaleList.group[j].rows[x].row[y].details[z].state == 1) {
                         str2 += '<span class="groupRowRecommend">智能推荐</span>'
                     }
                     str2 += '</span>'
                 }
-                str +='<div class="groupRowWrapper" id="'+ j+ x + y +'"><div class="groupRowName">'+  (x+1) + ' ' +scaleList.group[j].rows[x].row[y].name  + '</div><div class="groupRowBox">' + str2 + '</div>' + '</div>'
+                str +='<div class="groupRowWrapper '+ j + x +'" data-group='+ j + x +' id="'+ j + x + y +'"><div class="groupRowName"> <span class="groupRowIndex">'  
+                if(y==0) {
+                    str += (x+1)+'.'  
+                }
+                str +='</span>' +scaleList.group[j].rows[x].row[y].name  + '</div><div class="groupRowBox">' + str2 + '</div>' + '</div>'
             }
             
         }
@@ -186,46 +201,4 @@ function parseUrlParams(){
             alert(res.msg)
         }
     })
-    // $.ajax({
-    //     type: 'post',
-    //     url: url,
-    //     headers: {
-    //         // 'Accept': 'application/json, text/plain, */*',
-    //         'Content-Type':'application/json; charset=utf-8'
-    //     },
-    //     data: JSON.stringify(param),
-    //     success: function(res) {
-    //         // console.log('calcaRes', res, data)
-    //         if (res.code == 0) {
-
-    //             data.calculate.result = res.data.calcalculate.result
-    //             for(let i = 0; i < res.data.group.length; i++) {
-    //                 for(let j = 0; j < data.group.length; j++) {
-    //                     if (res.data.group[i].groupName == data.group[j].groupName) {
-    //                         data.group[j].groupCalculate.result = res.data.group[i].groupCalculate.result
-    //                     }
-    //                 }
-    //             }
-    //             if($('.calcu')) {
-    //                 for (let i = 0; i < $('.calcu').length; i++) {
-    //                     let calcuItemName  = $('.calcu').eq(i).prev().find('.groupName').html();
-    //                     let calcuItem = data.group.filter(function(item) {
-    //                         return item.groupName == calcuItemName
-    //                     })[0]
-    //                     $('.calcu').eq(i).html('记分:' + calcuItem.groupCalculate.result.value +  ' ' +  calcuItem.groupCalculate.result.text)
-    //                 }
-    //             }
-    //             $('.allCalcu').eq(0).html('总分:' + data.calculate.result.value +  ' ' + data.calculate.result.text)
-
-
-    //         } else {
-    //             alert(res.msg)
-    //         }
-           
-            
-    //     },
-    //     error: function(error) {
-    //         console.log(error)
-    //     }
-    // })
 }