Переглянути джерело

诊断搜索添加同义词

zhangxc 6 роки тому
батько
коміт
08da5c25ae

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

@@ -95,7 +95,7 @@ class DiagResultSearch extends Component {
                 <div className={style['search-result']}>
                     {
                         searchResult && searchResult.map((item) => {
-                            return(<div  key={item.id} className={style['search-result-item']}><DiagnosticItem item={item} clearInput={this.clearInput}/></div>)
+                            return(<div  key={item.id} className={style['search-result-item']}><DiagnosticItem title={true} item={item} clearInput={this.clearInput}/></div>)
                         })
                     }
                 </div>

+ 6 - 2
src/components/DiagnosticItem/index.jsx

@@ -55,9 +55,13 @@ class DiagnosticItem extends Component{
 
     render(){
         const { visible } = this.state
-        const { item } = this.props
+        const { item, title } = this.props
         return (<span className={style['diag-item']} >
-                    <span className={style['diag-name']} onClick={() =>{this.chooseDiagodal(item)}}>{item.name} </span>
+                    <span className={style['diag-name']} 
+                          title = {title && item.name + (item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': '')}
+                          onClick={() =>{this.chooseDiagodal(item)}}>
+                        {item.name} {item.showType === 2 || item.showType === 3 ? '('+ item.retrievalName+')': ''}
+                    </span>
                     <ConfirmModal visible={visible} okText='初诊' cancelText='复诊' confirm={this.confirm}  cancel={this.cancel} close={this.close}>
                         <div className={style['confirm-info']}>确定选择“{item.name}”为</div> 
                     </ConfirmModal>

+ 4 - 0
src/components/DiagnosticItem/index.less

@@ -12,4 +12,8 @@
 .diag-name {
     display: inline-block;
     width: 100%;
+    height: 100%;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
 }

+ 2 - 0
src/store/actions/diagnosticSearch.js

@@ -23,6 +23,8 @@ export const getSearchResult= (state, action) => {
         let searchResultItem = {}
         searchResultItem.id = item.questionId
         searchResultItem.name = item.name
+        searchResultItem.showType = item.showType
+        searchResultItem.retrievalName = item.retrievalName
         searchResult.push(searchResultItem)
     }) 
     res.searchResult = searchResult;

+ 22 - 15
src/store/async-actions/diagnosticSearch.js

@@ -29,25 +29,32 @@ export const getSearchResult = (value) =>{
             }
             json(url, param).then((data)=>{
                 const searchRes = data.data.data;
+                console.log('searchRes',searchRes)
                 const diagList = state.diagnosticList.diagnosticList;
                 let searchResult = [];
                 if(searchRes) {
-                    for(let i = 0; i < searchRes.length; i++) {
-                        let repeat = false;
-                        for (let j = 0; j < diagList.length; j++) {
-                            if(searchRes[i].questionId === diagList[j].id) {
-                                repeat = true;
-                            } 
-                        }
-                        if(!repeat) {
-                            searchResult.push(searchRes[i])
-                        }
-                    }
+                    // for(let i = 0; i < searchRes.length; i++) {
+                    //     let repeat = false;
+                    //     for (let j = 0; j < diagList.length; j++) {
+                    //         if(searchRes[i].questionId === diagList[j].id) {
+                    //             repeat = true;
+                    //         } 
+                    //     }
+                    //     if(!repeat) {
+                    //         searchResult.push(searchRes[i])
+                    //     }
+                    // }
+                    dispatch({
+                        type: GET_SEARCH_RESULT,
+                        searchResult: searchRes
+                    })
+                } else {
+                    dispatch({
+                        type: GET_SEARCH_RESULT,
+                        searchResult: []
+                    })
                 }
-                dispatch({
-                    type: GET_SEARCH_RESULT,
-                    searchResult: searchResult
-                })
+               
             }).catch((e)=>{
                 console.log(e)
             })