const $ = require("jquery"); const { openNewWin,imageUrlPrefix } = require('./promise.js'); const { bindTipsEvent } = require('./popupEdit.js'); function renderRecommendInfo(showNum,className,title,data, hasInfo, type, position) { let showNumCopy = showNum || 5 const dataLen = data.length const str = `

${title}

` $('.recommendWrap').append(str) let dataShort if(showNumCopy&& dataLen > showNumCopy) { dataShort = data.slice(0, showNumCopy) } else { dataShort = data } let childrenNodeStrShort = '' let childrenNodeStrLong = '' if(hasInfo) { for (let i = 0; i < dataShort.length; i++) { childrenNodeStrShort += ` ${dataShort[i].name} ` } for (let i = 0; i < data.length; i++) { childrenNodeStrLong += ` ${data[i].name} ` } } else { for (let i = 0; i < dataShort.length; i++) { childrenNodeStrShort += ` ${dataShort[i].name} ` } for (let i = 0; i < data.length; i++) { childrenNodeStrLong += ` ${data[i].name} ` } } if(!childrenNodeStrShort) { childrenNodeStrShort='暂无推荐' } $('.'+className + 'box').append(childrenNodeStrShort) $('.'+className + 'box' +' .infoMsg').on('click', function(){ const infoMsgName = $(this).attr('data-name') openNewWin(`information.html?type=${type}&position=${position}&name=${infoMsgName}`) }) if(dataLen > showNumCopy) { slideToggle($("."+className+"box"), childrenNodeStrShort,childrenNodeStrLong) } } function renderMultRecommendInfo(className,title,data, hasInfo, type, position) { const str = `

${title}

` $('.recommendWrap').append(str) let hasDataNum = 0 for(let i = 0; i < data.length; i++) { const showNum = data[i].showNum || 5 const dataLen = data[i].data.length if(dataLen === 0) { continue } hasDataNum++ if(hasDataNum > 1) { $('.'+className + 'box').append('
') } let childrenNodeBoxStr = `
` let childrenNodeStrShort = `${data[i].title}` let childrenNodeStrLong = `${data[i].title}` let dataShort if(showNum&& dataLen > showNum) { dataShort = data[i].data.slice(0, showNum) } else { dataShort = data[i].data } for(let j = 0; j < dataShort.length; j++) { childrenNodeStrShort += `${dataShort[j].name}` } for(let j = 0; j < data[i].data.length; j++) { childrenNodeStrLong += `${data[i].data[j].name}` } if(data[i].data.length == 0) { childrenNodeStrShort +='暂无推荐' } $('.'+className + 'box').append(childrenNodeBoxStr) $('.'+data[i].className).append(childrenNodeStrShort) if(dataLen > showNum) { slideToggle($("."+data[i].className), childrenNodeStrShort,childrenNodeStrLong) } } } function renderTipsInfo(className,title, data) { const str = `

${title}

` $('.recommendWrap').append(str) if(data.length > 0) { for(let i = 0; i < data.length; i++) { renderTipsInfoMsg('tipsInfo'+i, data[i], data[i].details, className+'box') } } else { // renderTipsInfoMsg('tipsInfo', data.name, data.details, className+'box') $('.' + className+'box').append('

暂无数据

') } } function renderKnowledgeInfo(className,title, data) { const str = `

${title}

` $('.recommendWrap').append(str) $('.' + className+'box').append('

'+data+'

') $('.'+className+' .staticWin' ).on('click', function(){ openNewWin(`staticSearch.html?type=1`) }) } function renderScaleInfo(className,title, data) { const str = `

${title}

` $('.recommendWrap').append(str) $('.' + className+'box').append('

'+data+'

') $('.'+className+' .staticWin' ).on('click', function(){ openNewWin(`staticSearch.html?type=2&msg=${encodeURIComponent(JSON.stringify(msg))}`) }) } function renderTipsInfoMsg(className,item,data, parentNode) { const childrenNodeBoxStr = `

${item.name} 详情

` $('.' + parentNode).append(childrenNodeBoxStr) let dataStr = `` if(data.length === 0) { dataStr += `

暂无数据

` } else { for(let i = 0; i < data.length; i++) { dataStr += `

${data[i].title}

${data[i].content.replace(/{imageUrlPrefix}/g, imageUrlPrefix)} ` } } $('.' + className+'Info').html(dataStr) } function renderTreat(className,title, data) { const str = `

${title}${msg.diseaseName?'('+msg.diseaseName+')':''}

` $('.recommendWrap').append(str) const commonTreatmentInfo = data.commonTreatment&&data.commonTreatment.content || "" const treatmentList = data.treatmentPlan || [] 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){ $(".commonTreatmentInfo").addClass('commonTreatmentInfoLimit').append('更多 ') } $(".treatItemBox").on('click',".slideDown",function(){ openNewWin(`treatplan.html?msg=${encodeURIComponent(JSON.stringify(msg))}`) }) } function renderTreatDrug(className,title,data, parentNode) { const childrenNodeBoxStr = `

${title} ${data.length ==0 ?'':'更多 '}

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

${data[i].title}

` //二级标题暂时不放 // for(let j = 0; j < data[i].meditionDetails.length; j++) { // if(data[i].meditionDetails[j].description) { // childrenNodeStr += `

${data[i].meditionDetails[j].description}

` // } // } childrenNodeStr +=`
` $('.' + className+'Info').append(childrenNodeStr) } $(".treatItemTitle").on('click',".slideDown",function(){ openNewWin(`treatplan.html?msg=${encodeURIComponent(JSON.stringify(msg))}`) }) // for(let i = 0; i < data.length; i++) { // let childrenNodeStr = `

// ${i+1}.${data[i].bigdrugsName}${data[i].subdrugsName&&"("+data[i].subdrugsName+")"}:` // for (let j = 0; j < data[i].medicitionsList.length; j++) { // childrenNodeStr += `${data[i].medicitionsList[j].medicitionName}` // if(data[i].medicitionsList[j].forbidden == '1') { // childrenNodeStr += `慎用` // } else if(data[i].medicitionsList[j].forbidden == '2') { // childrenNodeStr += `禁用` // } // childrenNodeStr += `` // if(j !== data[i].medicitionsList.length-1) { // 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 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(className,title,data) { const str = `

${title}

` $('.recommendWrap').append(str) if(data.length == 0) { $("."+className+"box").append('暂无推荐') }; //let names = []; for(var k = 0;k < data.length;k++){ let tmpBq = data[k]; let hasSritical = false let tmpBqStr; if(tmpBq.details) { for(let i = 0; i < tmpBq.details.length; i++) { if(tmpBq.details[i].type == 4) { hasSritical= true } } } if(hasSritical) { /*if(names.includes(tmpBq.name)){ //name相同去重 tmpBqStr=''; }else{ names.push(tmpBq.name);*/ tmpBqStr = `

${tmpBq.name}

` //} } else { 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}` } if(tmpBqDetail.type == 2){ var deepDetailName = `
${tmpBqDetail.content.name}
` var deepDetailStr = '' var deepDetailResultStr = '' for(var n = 0;n < tmpBqDetail.content.details.length;n++){ var deepDetail = tmpBqDetail.content.details[n] if(deepDetail.controlType == 2){//0-radio,1-checkbox,2-text,3-dropdownlist if(deepDetail.isShow == 0) { deepDetailStr+=`
  • ${deepDetail.name}: ${deepDetail.value} ${deepDetail.uint}
  • ` } else { deepDetailStr+=`
  • 请输入${deepDetail.name}: ${deepDetail.uint}
  • ` } } if(deepDetail.controlType == 0){ let tooDeepDetailStr = '' for(var f = 0;f'+tooDeepDetail.detailName+'' } }else{ tooDeepDetailStr+='
  • '+tooDeepDetail.detailName+''+(tooDeepDetail.state == 1?"(智能推荐)":"")+'
  • ' } } deepDetailStr+=`
  • ${deepDetail.name}:
  • ` } } for(var v = 0;v < tmpBqDetail.content.result.length;v++){ deepDetailResultStr+='

    '+tmpBqDetail.content.result[v].name+':

    ' } tmpBqDetailStr+=`
    计算公式结果: 请选择
    ${deepDetailName}
      ${deepDetailStr}
    计算

    请填写计算公式内容

    ${deepDetailResultStr}
    关闭
    ` } if(tmpBqDetail.type == 3){ var deepDetailName = ''+tmpBqDetail.content.name+': ' var deepDetailStr = '' for(var n = 0;n < tmpBqDetail.content.details.length;n++){ var deepDetail = tmpBqDetail.content.details[n] deepDetailStr+='
  • '+deepDetail.detailName+''+(deepDetail.state == 1?"(智能推荐)":"")+'
  • ' } tmpBqDetailStr+=`
    可能结果: 请选择
    结果选择
    ${deepDetailName}
      ${deepDetailStr}
    确定
    ` } if(tmpBqDetail.type == 4){ // tmpBqDetailStr+=`
    诊断要点:${tmpBqDetail.content.name}
    ` } } if(tmpBqStr != '' || tmpBqDetailStr != ''){ $(".conditionHintTipsNull").css("display","none") } // $(".conditionHintTips").append('
    '+tmpBqStr+'
    '+tmpBqDetailStr+'
    ') $("."+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) }) bindTipsEvent() } function slideToggle(domName,childrenNodeStrShort,childrenNodeStrLong){//展开收起 domName.append('更多 ') domName.on('click',".slideDown",function(){ domName.html(childrenNodeStrLong) domName.append('收起 ') $(this).remove() }) domName.on('click',".slideup",function(){ domName.html(childrenNodeStrShort) domName.append('更多 ') $(this).remove() }) } module.exports = { renderRecommendInfo, renderMultRecommendInfo, renderTreat, renderRecommendConditTips, renderTipsInfo, renderKnowledgeInfo, renderScaleInfo }