import React from 'react'; import style from './index.less'; import chronicPic from "../../common/images/chronic.png"; import level1 from "../../common/images/级别1.png"; import tableIcon from '@common/images/table.png'; import allTableIcon from '@common/images/all-table.png'; import checkIcon from '@common/images/check.png'; import up from '@common/images/slide-up.png'; import down from '@common/images/slide-down.png'; import {ComplexModal,ConfirmModal,MiniToast, Radio,CheckBtn,Footer,Notify} from '@commonComp'; import infoShow from '@common/images/info-show.png'; import infoMove from '@common/images/info-move.png'; import ScaleTable from '@containers/ScaleTable'; import {deepClone} from '@utils/tools'; import className from 'classnames'; import $ from 'jquery'; import config from '@config/index'; /*** 慢病右侧推送模块规则: 慢病--显示慢病名称以及管理和评估 普通病--不显示管理和评估和量表按钮 明细--量表-计算公式-核心指标 controlType:0-radio 1-checkbox 2-text 3-dropdownlist **/ class ChronicInfo extends React.Component{ constructor(props){ super(props); this.state = { show:true, showInfo:false, showOption:false, showAssess:false, //评估弹窗 infoId:null, //静态知识 formulaId:null, //计算公式 optionId:null, //可能结果, isAssessConfirm:false, //是否点击评估弹窗确定按钮 radioVal:{}, //可能结果选择内容 possible:{}, //可能结果 formulaParam: {}, //量表计算公式计算入参 isCalculated:false, //是否刚计算过,关闭时值与结果对应 calcuValues:deepClone(props.calcuValues), //计算公式填的值 hasEnterImg: false, //是否移入info currentIndex: -1, //当前index comfirnFlag:false, flag:true, ff:false, timer:null, scaleParam:{}, //加入病例需要的参数 }; this.$result = React.createRef(); this.$content = React.createRef(); this.showInfo = this.showInfo.bind(this); this.closeInfo = this.closeInfo.bind(this); this.showOption = this.showOption.bind(this); this.closeOption = this.closeOption.bind(this); this.showTable = this.showTable.bind(this);//显示量表弹窗 this.closeTable = this.closeTable.bind(this);//关闭量表弹窗 this.showFormula = this.showFormula.bind(this); //打开计算公式 this.handleAddAssessItem = this.handleAddAssessItem.bind(this); //加入病例记录 this.onPrint = this.onPrint.bind(this); this.handleForRadio = this.handleForRadio.bind(this); this.handleSaveCalcu = this.handleSaveCalcu.bind(this); //保存评估修改的计算和可能结果 this.slideToggle = this.slideToggle.bind(this); this.resetComfirnFlag = this.resetComfirnFlag.bind(this); this.slideToggle = this.slideToggle.bind(this); this.comfirnTable = this.comfirnTable.bind(this); this.unscroeClose = this.unscroeClose.bind(this); } onPrint() { const {showHide} = this.props; let dom = showHide&&showHide.showTable?$("#printcontent"):$("#AssistResult"); dom.jqprint({ debug: false, importCSS: true, printContainer: true, operaSupport: false, }); } showInfo(item){ // 静态知识显示在提示信息里(4-18) const {getInfomation} = this.props; const param = { id:item.id, name: item.name, // id:40738, //目前只有“肾功能不全”有数据 type:22, position: 1 } getInfomation&&getInfomation(param); } closeInfo(){//关闭静态知识 this.setState({ infoId:null }) } showOption(id){ this.setState({ optionId:id, formulaId:null //关闭计算公式 }); const {patDom} = this.props; const ht = $(patDom.current).height(); setTimeout(function(){ $(patDom.current).scrollTop(ht+200); }) } closeOption(){ // 关闭-有可能结果则保持与结果一致,没有就保持最新选择的内容 let {possible,radioVal} = this.state; if(JSON.stringify(possible)=='{}'){ this.setState({ optionId:null }) }else{ this.setState({ radioVal:Object.assign({},radioVal,possible), optionId:null, }); } } showTable(it,v,i,j){ const {scaleInfo} = this.props; // 密西根糖尿病周围神经病评分(MDNS), id:40744 const item = { conceptId:it.conceptId, name:it.name }; // 判断:store里已经有该量表就无需重新调接口 if(scaleInfo&&scaleInfo[it.conceptId]){ this.props.hideList({name:'showTable',value:true},it); }else{ this.props.getScaleInfo(item); } this.setState({ formulaId:null, //关闭计算公式和可能结果弹窗 optionId:null, scaleParam:{ v,i,j } }) } // 量表明细-关闭,isClose是否是点击关闭按钮 closeTable(isClose){ const {scaleParam} = this.state; const {showHide} = this.props; if(!showHide.isPop){ //量表结果,判断需要计算并且dom中有值才能加入病例记录 // innerHTML 兼容FF26 const res = this.$result.current&&(this.$result.current.innerText||this.$result.current.innerHTML); if(!isClose&&(this.$result.current&&!res)){ Notify.info("请先计算量表结果!"); return ; } !isClose&&this.handleAddAssessItem(scaleParam.v,scaleParam.i,scaleParam.j); this.setState({ scaleParam:{} }); } this.props.hideList({name:'showTable',value:false}); } // 非计分量表确定-延时关闭->量表存值 unscroeClose(){ let {timer} = this.state; this.setState({ ff:true }) clearTimeout(timer) let _timer = setTimeout(()=>{ this.closeTable(); },200) this.setState({ timer:_timer }) } // 量表明细-确定 comfirnTable(){ const {flag} = this.state; this.setState({ comfirnFlag:true, flag:!flag //触发更新 }) } resetComfirnFlag(){ this.setState({ comfirnFlag:false, ff:false }) } showFormula(id){//计算公式 this.setState({ formulaId:id, optionId:null //关闭可能结果 }); const {patDom} = this.props; const ht = $(patDom.current).height(); setTimeout(function(){ $(patDom.current).scrollTop(ht+200); }) } closeFormula(it){ const {formulaId,isCalculated} =this.state; if(!isCalculated){ //没有计算结果时,保存输入的值 const {calcuResult,calcuValues} = this.props; const cres = calcuResult&&calcuResult[formulaId]||it.content.result; const result = cres&&cres[1]&&cres[1].text; if(result){ this.setState({ calcuValues:deepClone(calcuValues) }); } } this.setState({ formulaId:null, }); } handleAddAssessItem(v,pIndex,i){ const {addAssessItem,showHide,addScaleItems,scaleInfo} = this.props; if(!v){ addScaleItems(scaleInfo[showHide.conceptId],showHide.conceptId); return ; } addAssessItem(v,pIndex,i); } addFormula(it,v,pIndex,i){ const {chronicMagItem, setCalcuInfo} = this.props; this.closeFormula(it); const itCopy = deepClone(it) const vCopy = deepClone(v) setCalcuInfo && setCalcuInfo(v.conceptId,itCopy.content.details,itCopy.content.result) chronicMagItem&&this.handleAddAssessItem(vCopy,pIndex,i); } handleInputformula(id,calcuContent,i,j,idd,cres,e) { // const {calcuValues} = this.state; const {calcuResult,calcuValues,setCalcuInfo,data,setChronicPush} = this.props; const dataCopy = deepClone(data) let obj = deepClone(dataCopy[i].details[j].content.details); let values = deepClone(obj); const txt = e.target.value; values[idd].value = txt.replace(/[\u4e00-\u9fa5]|[^\d.]/g,''); //处理中文输入法的情况 if(/[\u4e00-\u9fa5]|[^\d.]/g.test(txt)){ e.target.value = txt.replace(/[\u4e00-\u9fa5]|[^\d.]/g,''); } dataCopy[i].details[j].content.details = values setChronicPush&&setChronicPush(dataCopy) } handleForRadio(id,calcuContent,i,fidx){//计算公式 const { calcuValues } = this.state; let obj = deepClone(calcuValues); let values = (obj&&obj[id])||deepClone(calcuContent); let details = values[i].details; for(let x=0;x+it.state===1); if(defaulted.length>0){ radioVal[parent.conceptId] = defaulted[0].detailName; } } this.setState({ possible:Object.assign({},possible,radioVal), radioVal:Object.assign({},possible,radioVal),//不设置radioVal只有最近一次选中的值 optionId:null, }); savePossibleResult&&savePossibleResult({possible:Object.assign({},possible,radioVal),radioVal:Object.assign({},possible,radioVal)}) chronicMagItem&&this.handleAddAssessItem(parent,pIndex,i); } handleSaveCalcu(obj){ this.setState({ possible:Object.assign({},obj.possible), radioVal:Object.assign({},obj.radioVal),//不设置radioVal只有最近一次选中的值 }) } calcuFormula(id,it,i,j) { //计算公式计算 const {calcuFormula, data } = this.props; let item = deepClone(it); const calcuValues = item.content.details let allHasInfo = true; for (let i = 0; i < calcuValues.length; i++) { if(calcuValues[i].controlType == 2) { //输入框类型的有没有填值 if(!calcuValues[i].value) { allHasInfo = false; } } else if(calcuValues[i].controlType == 0) { let hasSelect = false; for( let z = 0; z { /*if(this.getCritical(v)&&names.includes(v.name)){ //重复项 return ''; } names.push(v.name);*/ return
{v.name?

{this.getCritical(v) ? '':患者可能有} {v.name} {this.getCritical(v)?'':} {/* */} {this.getCritical(v)?'':':'}

:''} {v.details&&v.details.map((it,j)=>{ if(it.type==1){ return

{'【'+it.content.name+'】'} {formulaResult&&formulaResult[it.content.conceptId]?{'结果:'}{formulaResult[it.content.conceptId].calcalculate&&formulaResult[it.content.conceptId].calcalculate.result.value +' '+ formulaResult[it.content.conceptId].calcalculate.result.text}:''}

}else if(it.type==2){ //如果保存过,则使用保存内容 // const cres = calcuResult&&calcuResult[v.conceptId]||it.content.result; //每次都取最新推送内容 const cres = it.content.result || []; const result = cres&&cres[1]&&cres[1].text; //如果保存过,则使用保存内容 // const details = calcuValues&&calcuValues[v.conceptId]||it.content.details; //每次都取最新推送内容 const details = it.content.details || []; return
计算公式结果: {result?result:'请选择'} {formulaId&&formulaId==v.conceptId&& {details.map((item,idd)=>{ if(item.controlType==0){//单选 return }else if(item.controlType==2){//输入框 return } })}
{item.isShow == '0' ? item.name+':' : '请选择'+item.name+':'} {Array.isArray(item.details)&&item.isShow == '0'&&item.details.map((ii,ind)=>{ return ii.state == 1 &&
{ii.detailName}
})} {Array.isArray(item.details)&&item.isShow != '0'&&item.details.map((ii,ind)=>{ return
})}
{item.isShow == '0' ? item.name+':':'请输入'+item.name+':'} {item.isShow == '0' ? item.value + ' ' +item.uint : } {item.isShow != '0'&&{item.uint}}
计算
{cres && Array.isArray(cres) &&cres.map((itemResult, resultIndex) => { return })}
{itemResult.name+':'} {itemResult.text}
}
}else if(it.type==3){ return
可能结果: {possible[v.conceptId]?possible[v.conceptId]:'请选择'}
{it.content.name?it.content.name+':':''} {it.content.details&&it.content.details.map((lis,ind)=>{ return
{/*{lis.state==1?(智能推荐):''}*/}
})}
} })}
}); return list; } componentWillReceiveProps(next){ //计算公式可能结果弹窗关闭1916 if(!next.data||next.data.length==0){ this.setState({ formulaId:null, optionId:null }); } if(JSON.stringify(next.calcuValues)!=JSON.stringify(this.props.calcuValues)){ this.setState({ calcuValues:next.calcuValues }) } if (JSON.stringify(next.wholeResults.possible) != JSON.stringify(this.props.possible)) { this.setState({ radioVal: next.wholeResults.radioVal, possible: next.wholeResults.possible }) } if(next.slideUp!=this.props.slideUp){ if(next.slideUp){ $(this.$content.current).slideUp(config.slideTime); }else{ $(this.$content.current).slideDown(config.slideTime); } } } slideToggle(){ const {toggleSlide,slideUp} = this.props; toggleSlide&&toggleSlide(!slideUp); } render(){ const {comfirnFlag,flag,ff} = this.state; const {chronicMagItem,chronicDesease,data,showHide,slideUp} = this.props; const scaleFooter =