Jelajahi Sumber

治疗方案同类药物

zhangxc 5 tahun lalu
induk
melakukan
baadec0e1c

+ 3 - 3
src/components/Treat/DrugTreat/index.jsx

@@ -48,10 +48,10 @@ class DrugTreat extends Component {
             hasEnterImg: false
         })
     }
-    setOtherRecommend(item, index) {
+    setOtherRecommend( position) {
         this.showTreatDesc();
         const { setOtherRecommend } = this.props;
-        setOtherRecommend && setOtherRecommend(item, index);
+        setOtherRecommend && setOtherRecommend(position);
     }
     setDrugInfo(item) {
         const { setDrugInfo } = this.props;
@@ -110,7 +110,7 @@ class DrugTreat extends Component {
 
                                             })}
                                         </div>
-                                        {<div className={style['drug-more']} onClick={() =>this.setOtherRecommend(item, index)} ><img className={style['info-img-more']} src={more} />更多同类药</div> }
+                                        {<div className={style['drug-more']} onClick={this.setOtherRecommend.bind(this, [index0,index1,index2])} ><img className={style['info-img-more']} src={more} />更多同类药</div> }
                                 </div>)
                             })}
 

+ 1 - 1
src/components/Treat/index.jsx

@@ -119,7 +119,7 @@ class Treat extends Component {
                     <div className={style['bottom']}>
                         <span className={style['prescription-btn']} onClick={this.handlePrescription}>开处方</span> <span className={style['determine-btn']} onClick={this.handleDetermine}>确定</span>
                     </div>
-                    {treatDesc && <TreatDesc 
+                    {<TreatDesc 
                     treatment={treatment} 
                     treatDesc={treatDesc} 
                     selectDrug={selectDrug} 

+ 27 - 36
src/components/TreatDesc/index.jsx

@@ -7,6 +7,7 @@ import info1 from './img/info1.png';
 import info2 from './img/info2.png';
 import info3 from './img/info3.png';
 import packUp from './img/packUp.png';
+import HasInfoItem from '@common/components/HasInfoItem'
 
 class TreatDesc extends Component {
     constructor(props){
@@ -21,6 +22,7 @@ class TreatDesc extends Component {
         this.handleMouseLeaveDrug = this.handleMouseLeaveDrug.bind(this)
         this.handleMouseEnterImg = this.handleMouseEnterImg.bind(this)
         this.handleMouseLeaveImg = this.handleMouseLeaveImg.bind(this)
+        this.getPosition = this.getPosition.bind(this)
 
     }
 
@@ -51,21 +53,33 @@ class TreatDesc extends Component {
             hasEnterImg: false
         })
     }
-    handleSelect(index,ii) {
+    handleSelect(position) {
+
         const { selectDrug } = this.props;
-        selectDrug && selectDrug(index,ii);
+        selectDrug && selectDrug(position);
     }
     hideTreatDesc() {
         $('#treatDescBox').css({'display': 'none'});
         $('#treatDescBox').animate({'display': 'none'}, 500);
         $('#dragModalWrap').animate({'margin-left': '-340px','left':'50%'}, 500);
     }
+    getPosition(index) {
+        const {position} =this.props.treatDesc
+       const newPos = position.slice()
+       newPos.push(index)
+        return newPos
+    }
 
     render(){
         const  { treatment, treatDesc, setDrugInfo} = this.props
-        const { title, basic, otherDrugIndex, drugDesc} = treatDesc
+        const { title, basic, position, drugDesc} = treatDesc
         const { currentIndex, hasEnterImg } = this.state
+        let treatmentItem
+        if(position) {
+           treatmentItem = treatment[position[0]].meditionDetails[position[1]].treatment[position[2]]
+        }
         return (treatment && treatment.length >0 && <div  className={style['treat-desc-box']+" "+"clearfix" }>
+
             {title && title === '药品推荐' ? <div className={style['similar-drug-box']} id='treatDescBox'>
                 {/* { basic && basic.length > 0 && <div> //推荐依据不需要展示
                     <h3 className={style['recommend-title']}>推荐依据</h3>
@@ -74,41 +88,18 @@ class TreatDesc extends Component {
                         </div>)
                     })}
                 </div> } */}
-                { otherDrugIndex > -1 && <div  className={style['similar-drug-wrapper'] +" "+"clearfix" }>
-                        <h3 className={style['drug-desc-title']}><span className={style['drug-desc-class-title']} title={'同类药物(' + treatment[otherDrugIndex].bigdrugsName + ')'}>同类药物({treatment[otherDrugIndex].bigdrugsName})</span>  <img src={packUp} onClick={this.hideTreatDesc} className={style['close-drug-desc']} /></h3>
+                {position&&<div  className={style['similar-drug-wrapper'] +" "+"clearfix" }>
+                        <h3 className={style['drug-desc-title']}><span className={style['drug-desc-class-title']} title={'同类药物(' + treatmentItem.bigdrugsName + ')'}>同类药物({treatmentItem.bigdrugsName})</span>  <img src={packUp} onClick={this.hideTreatDesc} className={style['close-drug-desc']} /></h3>
                         <div  className={style['similar-drug'] +" "+"clearfix" }>
-                        {treatment[otherDrugIndex].medicitionsList.map((item, index) =>{
-                            return (<span className={style['drug-name-box']}
-                                onMouseEnter={this.handleMouseEnterDrug.bind(this, index, item )}
-                                onMouseLeave = {this.handleMouseLeaveDrug}
-                                id={item.medicitionName}
-                            >
-                                <span className={style['drug-name']} 
-                                    // onDoubleClick={() =>{setDrugInfo(item);showDrugInfo();}} 
-                                    onClick={()=>{item.forbidden === '2' ? '' : this.handleSelect(otherDrugIndex,index)}} 
-                                    style={item.forbidden === '2' ? {opacity: '0.3', filter:'alpha(opacity=30)',filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=30)'} : item.selected ? {color: '#3B9ED0'}:''}
-                                    >
-                                    {item.medicitionName}
-                                </span>
-                                {<img className={style['info-img']}  
-                                    title='点击i图标可查看详细说明'
-                                    style ={currentIndex === index ? {display: "inline-block"} : {display: "none"}}
-                                    src={currentIndex === index ?  (hasEnterImg ? info3 : info2) : info2} 
-                                    onMouseEnter={this.handleMouseEnterImg.bind(this, index)}
-                                    onMouseLeave = {this.handleMouseLeaveImg}
-                                    onClick={() =>{setDrugInfo({name: item.medicitionName, type: 8, position: 5})}}
-                                    />}
+                        {treatmentItem.medicitionsList.map((item, index) =>{
+                            return  <HasInfoItem 
+                            item = {item}
+                            setDrugInfo = {this.setDrugInfo}
+                            position = {this.getPosition(index)}
+                            handleSelect = {this.handleSelect}
+                        >
 
-                            {/* {<img className={style['info-img']}
-                                title='点击i图标可查看详细说明'
-                                src={currentIndex === index ? info1 : info}
-                                onMouseEnter={this.handleMouseEnterImg.bind(this, index)}
-                                onMouseLeave = {this.handleMouseLeaveImg}
-                                onClick={() =>{setDrugInfo(item,8,5);showDrugInfo();}}/>} */}
-                            {item.forbidden === '1' ? <span className={style['info-flag']} style={{border: '1px solid #F4C051', background: '#F4C051',marginLeft: '5px'}}>慎用</span>: item.forbidden === '2' ? <span className={style['info-flag']} style={{opacity: '0.3', filter:'alpha(opacity=30)',filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=30)',border: '1px solid #000',marginLeft: '5px'}}>禁用</span> : ''}
-                            {/*<span  style={item.forbidden === '2' ? {opacity: '0.3', filter:'alpha(opacity=30)',filter:'progid:DXImageTransform.Microsoft.Alpha(opacity=30)'} : ''}> 使用率{item.rate}</span>*/}
-                            
-                        </span>)
+                        </HasInfoItem>
                         })}
                     </div> 
                 </div>}

+ 1 - 1
src/components/TreatDesc/index.less

@@ -38,7 +38,6 @@
 }
 .similar-drug-wrapper {
     position: absolute;
-    
     width: 260px;
     left: 680px;
     height: 100%;
@@ -46,6 +45,7 @@
     background: #fff;
     padding: 40px  0px 20px 20px;
     box-shadow: 2px 0px 5px -2px #7d7c7c;
+    line-height: 36px;
 }
 .similar-drug {
     padding: 20px 20px 0 0;

+ 2 - 3
src/containers/Treat.js

@@ -41,11 +41,10 @@ function mapDispatchToProps(dispatch) {
                 indexList: position,
             })
         },
-        setOtherRecommend: (item, index) => {
+        setOtherRecommend: (position) => {
             dispatch ({
                 type: SET_OTHER_DRUG,
-                item: item,
-                index: index,
+                position
             })
             //推荐依据不展示
             // dispatch(getRecommendBasic(item))

+ 4 - 1
src/store/actions/treat.js

@@ -17,10 +17,12 @@ export const clearTreat = (state, action) => {
     res.generalTreat = '';
     res.surgeryTreat = '';
     res.drugHistory = {};
+    res.treatDesc = {title: "药品推荐"}
     res.treatment = [];
     res.adversReactionList=[];
     res.hasFollowUp = false;
     res.followUp = '';
+    console.log('res', res)
     return res
 }
 
@@ -32,6 +34,7 @@ export const clearAllTreat = (state, action) => {
     res.drugHistory = {};
     res.treatment = [];
     res.adversReactionList=[];
+    res.treatDesc = {title: "药品推荐"}
     res.hasFollowUp = false;
     res.followUp = '';
     res.followUpList = [];
@@ -67,7 +70,7 @@ export const setOtherDrug = (state, action) => {
     const res = JSON.parse(JSON.stringify(state));
     res.treatDesc = {};
     res.treatDesc.title = '药品推荐';
-    res.treatDesc.otherDrugIndex = action.index;
+    res.treatDesc.position = action.position;
     return res
 }