123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- import {post,getUrlArgObject} from './promise.js';
- $(function(){
- // 从地址栏获取参数,请求量表内容
- function GetQueryString(name){
- var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if(r!=null)return unescape(r[2]); return null;
- }
- var scaleInfo;
- 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)
- // 用GetQueryString方法从地址栏获取参数,暂时写死
- var params = {
- "age": getUrlArgObject('age') || 28,
- "featureType": getUrlArgObject('featureType') ||'21',
- "scaleId": getUrlArgObject('scaleId') ||40744,
- "scaleName": getUrlArgObject('scaleName') || "密西根糖尿病周围神经病评分(MDNS)",
- "sex": getUrlArgObject('sex') || 1,
- "diag": getUrlArgObject('diag') || "肺结核(复诊); ",
- "lis": getUrlArgObject('lis')?JSON.parse(getUrlArgObject('lis')) : []
- // "age": 28,
- // "featureType": '21',
- // "scaleId": id,
- // "scaleName": name,
- // "sex": 1,
- // "diag": "肺结核(复诊); ",
- // "lis": []
-
- }
- if(id){
- post(url, params).then((res) => {
- const data = res.data.data
- if(res.data.code==0){
- scaleInfo = data.scale;
- // console.log('量表数据为:',scaleInfo);
- for (var i = 0; i < scaleInfo.length; i++) {
- if( scaleInfo[i].type == 1) {
- var scaleList = JSON.parse(scaleInfo[i].content)
- console.log('scaleList', scaleList)
- renderCalcu(scaleList)
-
- } else {
- $('.content').append(scaleInfo[i].content)
- }
-
- $('input').on('change', function(e) {
- var indexList = $(this).attr('data-index').split(',')
- for (var i = 0; i < scaleList.group[indexList[0]].rows[indexList[1]].row[indexList[2]].details.length; i++) {
- 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().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() {
- // console.log('scaleList', scaleList)
- let allSelect = true
- for (let i = 0; i < scaleList.group.length; i++) {
- for (let j = 0; j < scaleList.group[i].rows.length; j++) {
- 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).addClass('noSelect')
- }
- }
-
- }
- }
- if(allSelect) {
- getCalcuResult(scaleList)
- }
- })
-
- }
- }
- })
-
- }
- })
- function renderCalcu(scaleList) {
- console.log(scaleList)
- $("h1").html(scaleList.scaleName);
- var str = ''
- for(var j = 0; j < scaleList.group.length; j++) {
- str += '<div class="groupBox"> <div class="groupName">' + scaleList.group[j].groupName + '</div>';
- for (var x = 0; x < scaleList.group[j].rows.length; x++) {
- 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='+ 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="'+ 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 '+ 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>'
- }
-
- }
- if(scaleList.group[j].groupCalculate.isShow == 1) {
- str += '<div class="calcu">记分:'+ scaleList.group[j].groupCalculate.result.value +' '+ scaleList.group[j].groupCalculate.result.text +'</div>'
- }
- str += '</div>'
-
- }
- var calcuStr = '<div class="allCalcuBox"><span class="allCalcu">总分:'
- if(scaleList.calculate && scaleList.calculate.result) {
- calcuStr += scaleList.calculate.result.value + ' ' + scaleList.calculate.result.text
- }
- calcuStr += '</span><span class="calcuBtn">计算<span></div>'
- var allStr = '<div class="calcuWrapper">' + str + calcuStr + '</div>'
- $('.content').append(allStr)
- }
- function parseUrlParams(){
- // var url = 'http://localhost:8082/scale.html?age=28&featureType=21&scaleId=40744&scaleName=密西根糖尿病周围神经病评分(MDNS)&sex=1&diag=肺结核(复诊);&lis=[{detailName: "HGB*3/HCT",maxValue: "",minValue: "",name: "血常规",otherValue: "",source: "0",time: "2019-05-07 17:11",uniqueName: "血常规-HGB*3/HCT",units: "",value: "4"}]'
- var url = window.location.search;
- var params = url.substring(url.indexOf('?')+1).split("&");
- var tmp = '',obj = {},it={};
- for(var i=0;i<params.length;i++) {
- it = params[i];
- tmp = it.split("=");
- if (tmp[0] && tmp[1]) {
- obj[tmp[0]] = tmp[1];
- }
- }
- return obj;
- // var obj={};
- // url.replace(/([^?&=]+)=([^&]+)/g,(_,k,v)=>q[k]=v);
- // return obj;
- }
- function getCalcuResult(data) {
- var url = "http://192.168.2.236:5050/api/icss/calc/calculate";
- const param = {
- type: 1,
- data: data
- }
- post(url, param).then((res) => {
- const data = res.data.data
- if (res.data.code == 0) {
- data.calculate.result = data.calcalculate.result
- for(let i = 0; i < data.group.length; i++) {
- for(let j = 0; j < data.group.length; j++) {
- if (data.group[i].groupName == data.group[j].groupName) {
- data.group[j].groupCalculate.result = 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)
- }
- })
- }
|