const $ = require("jquery"); const { openNewWin, isIe8 } = require('./promise.js'); const { bindTipsEvent } = require('./popupEdit.js'); let showImg = require('./../images/show.png') let collapseImg = require('./../images/collapse.png') const is8Ie = isIe8() //判断是否为IE8 if(is8Ie) { let reg = /undefined/g showImg = showImg.replace(reg, '') collapseImg = collapseImg.replace(reg, '') } //推荐诊断等单种类型的 function renderRecommendInfo(icon, className,title,data, hasInfo, type, position) { const str = `

${title}:

` $('.push').append(str) let childrenNodeStr = '' if(hasInfo) { for (let i = 0; i < data.length; i++) { childrenNodeStr += ` ${data[i].name} ` } } else { for (let i = 0; i < data.length; i++) { childrenNodeStr += ` ${data[i].name} ` } } if(!childrenNodeStr) { childrenNodeStr = '暂无推荐' } $('.'+className + 'box').append(childrenNodeStr) let childrenNodeStrAll = `

${title}:

${childrenNodeStr}
` $('.push').append(childrenNodeStrAll) $('.'+className + 'box' +' .infoMsg').on('click', function(){ const infoMsgName = $(this).attr('data-name') openNewWin(`information.html?type=${type}&position=${position}&name=${infoMsgName}`) }) $('.'+className + 'boxAll' +' .infoMsg').on('click', function(){ const infoMsgName = $(this).attr('data-name') openNewWin(`information.html?type=${type}&position=${position}&name=${infoMsgName}`) }) slideToggle("."+className+"box") } //化验和辅检等多种类型 function renderMultRecommendInfo(icon, className,title,data, hasInfo, type, position) { const str = `

${title}:

` $('.push').append(str) for(let i = 0; i < data.length; i++) { let childrenNodeBoxStr = `
` let childrenNodeStr = `${data[i].title}` let childrenNodeItemStrAll = '' //更多展开框中的字符串 for(let j = 0; j < data[i].data.length; j++) { childrenNodeStr += `${data[i].data[j].name}` childrenNodeItemStrAll += `${data[i].data[j].name}` } if(data[i].data.length == 0) { childrenNodeStr +='暂无推荐' } $('.'+className + 'box').append(childrenNodeBoxStr) $('.'+data[i].className+'box').append(childrenNodeStr) let childrenNodeStrAll = `

${data[i].title}:

${childrenNodeItemStrAll}
` $('.push').append(childrenNodeStrAll) slideToggle("."+data[i].className+"box") } } function renderTreat(icon, className,title, data) { const str = `

${title}:${msg.diag}

` $('.treat').append(str) const commonTreatmentInfo = data.commonTreatment&&data.commonTreatment.content || "" const treatmentList = data.treatment || [] renderTreatText('commonTreatment', '一般治疗', commonTreatmentInfo, className+'box') renderTreatDrug('drugTreatment', '药物治疗', treatmentList, className+'box') } function renderTreatText(className,title,data, parentNode) { const childrenNodeBoxStr = `

${title}:

` $('.' + parentNode).append(childrenNodeBoxStr) if(!data) { data = '暂无推荐' } $('.' + className+'Info').html(data) var commonTreatHeight = $(".commonTreatmentInfo").height() if(commonTreatHeight > 75){ $(".treatTextBox").append('更多') } $(".treat .treatTextBox").on('click',".more",function(){ openNewWin(`treatplan.html?age=${msg.age}&sex=${msg.sex}&symptomJson=${msg.symptom}&vitalJson=${msg.vital}&lisJson=${msg.lis}&pacsJson=${msg.pacs}&diagJson=${msg.diag}&otherJson=${msg.other}&hospitalCode=${msg.hosCode}`) }) } function renderTreatDrug(className,title,data, parentNode) { const childrenNodeBoxStr = `

${title}:

` $('.' + parentNode).append(childrenNodeBoxStr) if(data.length ==0) { $('.' + className+'Info').append('暂无推荐') } for(let i = 0; i < data.length; i++) { let childrenNodeStr = `

${i+1}.${data[i].bigdrugsName}(${data[i].subdrugsName}):` for (let j = 0; j < data[i].medicitionsList.length; j++) { childrenNodeStr += `${data[i].medicitionsList[j].medicitionName}` if(data[i].medicitionsList[j].drugsForbidden == '1') { childrenNodeStr += `慎用` } else if(data[i].medicitionsList[j].drugsForbidden == '2') { childrenNodeStr += `禁用` } childrenNodeStr += `,` childrenNodeStr += `使用率${data[i].medicitionsList[j].rate}` if(j === data[i].medicitionsList.length-1) { childrenNodeStr += ';' } else { childrenNodeStr += ',' } } childrenNodeStr += `

` $('.' + className+'Info').append(childrenNodeStr) } $('.' + className+'Info'+ ' .infoMsg').on('click', function(){ const infoMsgName = $(this).attr('data-name') openNewWin(`information.html?type=8&position=5&name=${infoMsgName}`) }) var drugTreatmentHeight = $(".drugTreatmentInfo").height() if(drugTreatmentHeight > 75){ $(".treatDrugBox").append('更多') } else if(drugTreatmentHeight > 30) { $(".drugTreatmentInfo").append('更多') } $(".treat .drugTreatmentbox").on('click',".more",function(){ openNewWin(`treatplan.html?age=${msg.age}&sex=${msg.sex}&symptomJson=${msg.symptom}&vitalJson=${msg.vital}&lisJson=${msg.lis}&pacsJson=${msg.pacs}&diagJson=${msg.diag}&otherJson=${msg.other}&hospitalCode=${msg.hosCode}`) }) var treatList = $(".drugTreatmentInfo").find(".drugTreatmentInfoItemBox") // for(var h = 0;h < treatList.length;h++){ // if($(treatList[h]).height() > 25){ // $(treatList[h]).addClass('recommendInfoItemBoxLimit').append('更多 ') // } // $(".drugTreatmentInfo").on('click',".slideDown",function(){ // $(this).parents(".drugTreatmentInfoItemBox ").removeClass("recommendInfoItemBoxLimit").append('收起 ') // $(this).remove() // }) // $(".drugTreatmentInfo").on('click',".slideup",function(){ // $(this).parents(".drugTreatmentInfoItemBox ").addClass("recommendInfoItemBoxLimit").append('更多 ') // $(this).remove() // }) // } } function renderRecommendConditTips(icon, className,title,data) { const str = `

${title}:

` $('.push').append(str) if(data.length == 0) { $("."+className+"box").append('暂无推荐') } for(var k = 0;k < data.length;k++){ var tmpBq = data[k] var tmpBqStr = '

患者可能有 '+tmpBq.name+' :

' var tmpBqStr = `

患者可能有 ${tmpBq.name}:

` var tmpBqDetailStr = '' for(var m = 0;m < tmpBq.details.length;m++){ var tmpBqDetail = tmpBq.details[m] if(tmpBqDetail.type == 1){ tmpBqDetailStr+=`【${tmpBqDetail.content.name}】` } } $("."+className+"box").append('
'+tmpBqStr+'
'+tmpBqDetailStr+'
更多
') } $('.mayIllness .infoMsg').on('click', function(){ const infoMsgName = $(this).attr('data-name') openNewWin(`information.html?type=22&position=2&name=${infoMsgName}`) }) $('.alertModal .illnessTable').on('click', function(){ const infoMsgUrl = $(this).attr('data-url') openNewWin(infoMsgUrl) }) $(".conditTipsbox").on('click',".more",function(){ openNewWin(`illness.html?age=${msg.age}&sex=${msg.sex}&symptomJson=${msg.symptom}&vitalJson=${msg.vital}&lisJson=${msg.lis}&pacsJson=${msg.pacs}&diagJson=${msg.diag}&otherJson=${msg.other}&hospitalCode=${msg.hosCode}`) }) bindTipsEvent() } function slideToggle(className){//展开收起 const domName = $(className) const domNameBoxAll = $(className+'All') if(domName.height() > 20){ domName.append(``) } domName.on('click',".slideDown",function(){ $(".itemAllBox").css('display', 'none') $(domNameBoxAll).css('display', 'block') }) domNameBoxAll.on('click',".slideup",function(){ $(domNameBoxAll).css('display', 'none') }) } $(".disclaimer").on("click",function() { openNewWin("disclaimer.html") }) module.exports = { renderRecommendInfo, renderMultRecommendInfo, renderTreat, renderRecommendConditTips }