Browse Source

查体模板引用显示bug

zhouna 6 years ago
parent
commit
08d42b7dfc
3 changed files with 13 additions and 11 deletions
  1. 10 8
      src/components/CheckBody/index.jsx
  2. 1 1
      src/containers/CheckBody.js
  3. 2 2
      src/store/actions/checkBody.js

+ 10 - 8
src/components/CheckBody/index.jsx

@@ -32,18 +32,24 @@ class CheckBody extends Component{
   getLabels(){
     const {data,showArr,saveText,selecteds} = this.props;
     let arr = [],list=[];//console.log(data,saveText)
-    const {boxMark,showAll} = this.state;
+    const {boxMark,showAll} = this.state;//console.log(data)
+    const moreNum =data.length-[...data].reverse().findIndex((it)=>it.showInCheck)-1;//被隐藏的位置
+    console.log(moreNum);
+    const moreText = filterDataArr([...saveText].splice(moreNum));      //被收起的标签中是否有有值得,有则不能再收起showMoreBtn?more:''
+    const more = this.props.defaultShowAll||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;
     let showArray = data.filter((it)=>{
       if(it.showInCheck)
         return it;
     });
-    const showData = this.props.showAll||showAll?[...data]:showArray;//[...data].splice(0,config.showCheckNum*2+1);
+    const showData = moreText||this.props.defaultShowAll||showAll?[...data]:showArray;//[...data].splice(0,config.showCheckNum*2+1);
     if(showData){
       list = showData;
       arr = list.map((it,i)=>{
         return chooseType({item:it,boxMark,i,showArr,saveText,selecteds});
       });
     }
+    showMoreBtn&&arr.push(more);      //是否显示收起展开按钮
     return arr;
   }
   handleClick(e){//让搜索框跟随鼠标点击移动
@@ -117,15 +123,11 @@ class CheckBody extends Component{
   }
   render(){
     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 = this.props.showAll||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()}
-        {showMoreBtn?more:''}
+        {/*{showMoreBtn?more:''}*/}
         {searchData && searchData.length>0?<SearchDrop data={searchData} show={!totalHide} left={boxLeft} top={boxTop} onSelect={this.handleSearchSelect}></SearchDrop>:''}
       </ItemBox>
     </div>

+ 1 - 1
src/containers/CheckBody.js

@@ -11,7 +11,7 @@ function mapStateToProps(state){
   const hasMain = filterDataArr(mainSuit.saveText);//||mainSuit.data.length;
   return {
     data:checkBody.data,
-    showAll:checkBody.showAll,
+    defaultShowAll:checkBody.showAll,
     isEmpty:checkBody.isEmpty,
     update:checkBody.update,   //用于触发更新
     showArr:homePage.showDrop,

+ 2 - 2
src/store/actions/checkBody.js

@@ -211,7 +211,7 @@ export function addLabelItem(state,action){
   res.data.splice(+i+2,0,JSON.parse(data),textLabel);
   res.saveText.splice(+i+2,0,'','');
   res.selecteds.splice(+i+2,0,null,null);
-  res.update = Math.random();console.log(res)
+  res.update = Math.random();
   return res;
 }
 //自由文本
@@ -263,7 +263,7 @@ export function insertLabelData(state,action){
   //查体中,默认显示区域搜索出来的标签要默认显示,隐藏区域搜索出的默认隐藏
   let hideAreaIndex = [...res.data].reverse().findIndex((it)=>it.showInCheck);
   hideAreaIndex = res.data.length-hideAreaIndex-1;        //默认显示的最后一个标签的位置
-  const text = Object.assign({},JSON.parse(config.textLabel),{showInCheck:index>hideAreaIndex?false:true});
+  const text = Object.assign({},JSON.parse(config._textLabel),{showInCheck:index>hideAreaIndex?false:true});
   let spreadLabels =tempLabels.map((it)=>{
     return Object.assign({},it,{showInCheck:index>hideAreaIndex?false:true});
   });