فهرست منبع

查体隐藏的项目中有填值不能收起

zhouna 6 سال پیش
والد
کامیت
4e06af3513
1فایلهای تغییر یافته به همراه13 افزوده شده و 3 حذف شده
  1. 13 3
      src/components/CheckBody/index.jsx

+ 13 - 3
src/components/CheckBody/index.jsx

@@ -3,7 +3,7 @@ import style from './index.less';
 import {Button,InlineTag,ItemBox,EditableSpan,Notify} from '@commonComp';
 import chooseType from '@containers/eleType.js';
 import SearchDrop from '@components/SearchDrop';
-import {getPageCoordinate,windowEventHandler,isIE} from '@utils/tools';
+import {getPageCoordinate,windowEventHandler,isIE,filterDataArr} from '@utils/tools';
 import $ from "jquery";
 import showImg from "../../common/images/show.png";
 import hideImg from "../../common/images/close.png";
@@ -96,14 +96,24 @@ class CheckBody extends Component{
       showAll:!this.state.showAll
     });
   }
+  componentWillUpdate(next){
+    if(!this.props.isEmpty&&next.isEmpty){
+      this.setState({
+        showAll:false
+      })
+    }
+  }
   render(){
-    const {searchData,totalHide,data,boxLeft,boxTop} = this.props;
+    const {searchData,totalHide,data,boxLeft,boxTop,saveText} = this.props;
     const {showAll} = this.state;
+    const moreNum =config.showCheckNum*2+1;
+    const moreText = filterDataArr([...saveText].splice(moreNum));
     const more = showAll?<span className={style['more']} onClick={this.showHide}>收起<img src={hideImg} /></span>:<span className={style['more']} onClick={this.showHide}>展开<img src={showImg} /></span>;
+    const showMoreBtn = data.length>moreNum&&!moreText;
     return  <div className={style['container']}>
       <ItemBox title='查体' handleClick={this.handleClick}>
         {this.getLabels()}
-        {data.length>1?more:''}
+        {showMoreBtn?more:''}
         {searchData && searchData.length>0?<SearchDrop data={searchData} show={!totalHide} left={boxLeft} top={boxTop} onSelect={this.handleSearchSelect}></SearchDrop>:''}
       </ItemBox>
     </div>