Forráskód Böngészése

静态知识搜索

zhouna 6 éve
szülő
commit
4742892f6b

+ 29 - 28
src/components/MedicalInfo/index.jsx

@@ -1,44 +1,45 @@
 import React, { Component } from 'react';
 import style from './index.less';
-import { SearchOption } from '@commonComp';
 import {windowEventHandler,getCurrentDate,getWindowInnerHeight} from '@utils/tools'
 
 class MedicalInfo extends Component {
     constructor(props) {
-        super(props)
-        this.$cont = React.createRef();
+        super(props);
+        this.$inp = React.createRef();
+        this.search = this.search.bind(this);
     }
-    
-    componentDidMount() {
-        const height = getWindowInnerHeight() - 200;
-        this.$cont.current.style.height = height + "px";
-    
-        windowEventHandler('resize', ()=>{
-          const height = getWindowInnerHeight() - 200;
-          this.$cont.current.style.height = height + "px";
-        });
+    getSearchList() {
+        const { getAllConceptDetail,searchResult } = this.props;
+        return searchResult && searchResult.map((item) => {
+                return <li key={item.conceptId} onClick={() =>getAllConceptDetail({name: item.name, type: item.type})}>
+                            <span>{item.name}</span>
+                            <i>( {item.libTypeName} )</i>
+                            <button>查看</button>
+                        </li>;
+            });
     }
-
-    getSearchList(searchResult) {
-        const { getAllConceptDetail } = this.props
-        return <div className={style['search-result']}>
-            {
-            searchResult && searchResult.map((item) => {
-                return (<div key={item.conceptId} className={style['search-result-item']} onClick={() =>getAllConceptDetail({name: item.name, type: item.type})}>{item.name + '('+ item.libTypeName + ')'}</div>)
-            })
-            }
-        </div>
+    search(){
+      const {handleChangeValue} = this.props;
+      const val = this.$inp.current.value;
+      handleChangeValue&&handleChangeValue(val);
     }
     render() {
-        const {searchResult, handleChangeValue,pageTop,windowHeight } = this.props
+        const {searchResult} = this.props;
         return (
         <div className={style['mefical-info-wrapper']}> 
-            <div ref={this.$cont}>
-                <SearchOption handleChangeValue={handleChangeValue} pageTop={pageTop} windowHeight={windowHeight} height={180} visible={true}>
-                    {this.getSearchList(searchResult)}
-                </SearchOption>
+            <div className={style['search-cont']}>
+                <p className={style['title']}>医学知识搜索</p>
+                <p>
+                  <input type="text" className={style['input']} ref={this.$inp}/>
+                  <button onClick={this.search}>搜索</button>
+                </p>
+              {searchResult&&searchResult.length>0?<div className={style['result']}>
+                    <p className={style['title']}>查询内容</p>
+                    <ul>
+                      {this.getSearchList()}
+                    </ul>
+              </div>:<p className={style['no-data']}>暂无搜索结果!</p>}
              </div>
-
         </div>
         
         )

+ 60 - 0
src/components/MedicalInfo/index.less

@@ -5,4 +5,64 @@
     width: @push-width;
     overflow: hidden;
     position: relative;
+}
+.search-cont{
+    .title{
+        font-size: 12px;
+        color:#979797;
+        margin-bottom: 10px;
+    }
+    .input{
+        display: inline-block;
+        width: 300px;
+        height: 34px;
+        padding: 5px;
+        border:1px #CECECE solid;
+        vertical-align: top
+    }
+    button{
+        display: inline-block;
+        width: 80px;
+        height: 34px;
+        line-height: 34px;
+        color: #fff;
+        background: #2A9BD5;
+        border:1px #2A9BD5 solid;
+        text-align: center;
+        border: none;
+    }
+    .result{
+        margin-top: 15px;
+        li{
+            border-bottom:1px #CECECE solid;
+            line-height: 42px;
+            span{
+                font-size: 14px;
+                color: #000;
+            }
+            i{
+                font-size: 12px;
+                color: #2A9BD5;
+            }
+            button{
+                float: right;
+                border:1px #2A9BD5 solid;
+                text-align: center;
+                width: 56px;
+                height: 26px;
+                line-height: 26px;
+                color: #2A9BD5;
+                border-radius: 3px;
+                background: none;
+                margin-top: 8px;
+                outline: none;
+            }
+        }
+    }
+    .no-data{
+        width: 380px;
+        color:#979797;
+        text-align: center;
+        line-height: 40px;
+    }
 }

+ 4 - 4
src/components/PushContainer/index.jsx

@@ -24,9 +24,9 @@ class PushContainer extends Component {
             }, {
                 title: '模板',
             },
-            // {
-            //     title: '医学知识',
-            // }
+            {
+                title: '医学知识',
+            }
             ],
             visible:false,
             message:'',                 //提示的内容
@@ -255,7 +255,7 @@ class PushContainer extends Component {
                         handleMangerTemplate={this.handleMangerTemplate}
                         handleAllCheckbox={this.handleAllCheckbox}
                     ></TemplateItems>
-                    {/* <MedicalInfoContainer></MedicalInfoContainer> */}
+                    <MedicalInfoContainer></MedicalInfoContainer>
                 </TemplateContainer>
             </Tab>
             <ConfirmModal 

+ 0 - 1
src/containers/MedicalInfoContainer.js

@@ -6,7 +6,6 @@ import {getAllConceptDetail} from '../store/async-actions/pushMessage';
 
 function mapStateToProps(state) {
     return{
-        searchValue: state.medicalInfo.searchValue,
         searchResult: state.medicalInfo.searchResult,
     }
 }

+ 0 - 10
src/store/actions/medicalInfo.js

@@ -12,16 +12,6 @@ export const setSearchValue = (state,action) => {
 
 export const getSearchResult= (state, action) => {
     const res = Object.assign({},state);
-    // let searchResult = []
-    // action.searchResult && action.searchResult.map((item, index) =>{
-    //     let searchResultItem = {}
-    //     searchResultItem.id = item.questionId
-    //     searchResultItem.name = item.name
-    //     searchResultItem.showType = item.showType
-    //     searchResultItem.retrievalName = item.retrievalName
-    //     searchResultItem.conceptId = item.conceptId
-    //     searchResult.push(searchResultItem)
-    // }) 
     res.searchResult = action.searchResult;
     return res;
 }

+ 1 - 2
src/store/async-actions/medicalInfo.js

@@ -12,10 +12,9 @@ export const getSearchList = (val) => {
     }
    
     return (dispatch, getState) => {
-        const state = getState();
-        
         json('/retrieval/getStaticKnowledge',{
             inputStr:val,
+            inputIds:[]
         })
         .then((res)=>{
             const data = res.data.data;