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 = `

icon${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=${encodeURIComponent(type)}&position=${encodeURIComponent(position)}&name=${encodeURIComponent(infoMsgName)}`) }) if(dataLen > showNumCopy) { slideToggle($("."+className+"box"), childrenNodeStrShort,childrenNodeStrLong) } } function renderMultRecommendInfo(className,title,data, hasInfo, type, position) { const str = `

icon${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 renderRecommendConditTips(className,title,data) { const str = `

icon${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=${encodeURIComponent(infoMsgName)}`) }) $('.alertModal .illnessTable').on('click', function(){ const msg1 = JSON.parse(JSON.stringify(msg)) msg1.scaleName = $(this).attr('data-scaleName') msg1.featureType = 21 openNewWin(`scale.html?msg=${encodeURIComponent(JSON.stringify(msg1))}`) }) bindTipsEvent() } function renderCaseStandard(className,title,data){ const str = `

    icon${title}

    ` let childStr = "" for(let i = 0; i < data.length; i++){ childStr += `

    ${data[i]}

    ` } $('.recommendWrap').append(str) $(`.${className}box`).html(childStr) } function renderWarning(showNum,className,title,data, hasInfo, type, position){ let showNumCopy = showNum || 5 const dataLen = data.length const str = `

    icon${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=${encodeURIComponent(type)}&position=${encodeURIComponent(position)}&name=${encodeURIComponent(infoMsgName)}`) }) if(dataLen > showNumCopy) { slideToggle($("."+className+"box"), childrenNodeStrShort,childrenNodeStrLong) } } 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 ={ renderCaseStandard, renderWarning, renderRecommendInfo, renderMultRecommendInfo, renderRecommendConditTips, }