Prechádzať zdrojové kódy

查体隐藏区域有默认选中默认全部显示

zhouna 6 rokov pred
rodič
commit
91bbb09b55

+ 10 - 8
src/common/js/func.js

@@ -94,7 +94,8 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
       saveText=[],
       tempText = '',
       value = '',
-      item={};
+      item={},
+      checkHiddenDefault=false;
   arr.map((it,i)=>{
     notText = notTextLabel(it);
     value = it.value||'';
@@ -118,6 +119,12 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
     }else{
       pre = arr[i-1];
       item = !ifEmpty&&i<config.showCheckNum?Object.assign({},it,{showInCheck:true}):it;
+      //判断单选项是否有默认选中,位置在隐藏区域时,查体所有标签展示
+      if(!ifEmpty&&!checkHiddenDefault&&i>config.showCheckNum&&+it.tagType===1&&(+it.controlType===0||+it.controlType===1)){
+        if(it.questionDetailList.find((it)=>it.defaultSelect=='1')){
+          checkHiddenDefault=true;
+        }
+      }
       //如果本身不是文本标签且前面一个也不是文本标签,该标签前面添加文本标签
       if(notTextLabel(pre)&&notText){
           // newArr.push(textLabel,it);
@@ -127,12 +134,7 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
           }else{
             tempText = getSaveText(it);
           }
-          saveText.push("",tempText); 
-        //最后一个非文本标签,后面添加一个文本标签
-        /*if(!noEnd&&i===arr.length-1){
-          newArr.push(textLabel);
-          saveText.push("");
-        }*/
+          saveText.push("",tempText);
       }else{    //本身是或者前面是文本标签时,前面不添加文本标签
         newArr.push(item);
         if(it.tagType != 3) {
@@ -151,7 +153,7 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
       }
     }
   });
-  return {newArr,saveText};
+  return {newArr,saveText,checkHiddenDefault};
 };
 
 

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

@@ -37,7 +37,7 @@ class CheckBody extends Component{
       if(it.showInCheck)
         return it;
     });
-    const showData = showAll?[...data]:showArray;//[...data].splice(0,config.showCheckNum*2+1);
+    const showData = this.props.showAll||showAll?[...data]:showArray;//[...data].splice(0,config.showCheckNum*2+1);
     if(showData){
       list = showData;
       arr = list.map((it,i)=>{
@@ -93,6 +93,14 @@ class CheckBody extends Component{
     //有主诉时且本身无数据,第一次点击获取数据,(不论获取成功与否)再点击不获取(直到刷新成空白页或清空)
     if(hasMain&&isEmpty!=false){
       this.props.getInit();
+      //隐藏区域有默认选中项,默认全部展开-有延迟,弃用
+      /*const that = this;
+      setTimeout(function(){
+        that.props.showAll&&that.setState({
+          showAll:true
+        });
+      },900)*/
+
     }
   }
   showHide(){
@@ -112,7 +120,7 @@ class CheckBody extends Component{
     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 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}>

+ 1 - 0
src/components/NumberDrop/index.jsx

@@ -138,6 +138,7 @@ class NumberDrop extends Component{
     if(show){      //修改清空后第一次点击键盘不触发click事件bug
       return;
     }
+    //输入超出合理范围提示且清空
     const txt = e.target.innerText.replace(/^\s*/,'');
     if(max!=undefined&&!isNaN(+txt)&&(min>+txt||max<+txt)){
       this.beyondArea();

+ 1 - 0
src/containers/CheckBody.js

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

+ 3 - 1
src/store/actions/checkBody.js

@@ -4,8 +4,10 @@ import {getLabelIndex,fullfillText} from '@common/js/func.js';
 export function set(state,action){
   let res = Object.assign({},state);
   const {data} = action;
+  const obj = fullfillText(data,false,false,false);
   res.data = [...data];
-  res.saveText = fullfillText(res.data).saveText;//存逗号
+  res.saveText = obj.saveText;//存逗号
+  res.showAll = obj.checkHiddenDefault;
   res.update = Math.random();
   res.isEmpty = action.isEmpty;
   return res;