Przeglądaj źródła

Merge remote-tracking branch 'origin/dev/otherHis' into dev/new1

# Conflicts:
#	src/utils/tools.js
zhouna 6 lat temu
rodzic
commit
a01a46f147

+ 20 - 14
src/common/js/func.js

@@ -82,7 +82,8 @@ function notTextLabel(label){
 * 入参:arr源数组,
 *       noPre是否不添加前置文本标签,默认false即添加
 *       noEnd是否不添加后置文本标签,默认false即添加
-*       ifEmpty是否添加空标签,默认true即添加,传false添加逗号,如查体
+*       ifEmpty是否添加空标签,默认true即添加,传false添加逗号,如查体,
+*       showInCheck是否默认在查体中展开
 * */
 export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
   let newArr =[],
@@ -92,19 +93,22 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
       notText = true,
       saveText=[],
       tempText = '',
-      value = '';
+      value = '',
+      item={},
+      checkHiddenDefault=false;
   arr.map((it,i)=>{
     notText = notTextLabel(it);
     value = it.value||'';
-    textLabel = JSON.parse(config.textLabel);
-    _textLabel = JSON.parse(config._textLabel);
+    textLabel = !ifEmpty&&i==0?Object.assign({},JSON.parse(config.textLabel),{showInCheck:true}):JSON.parse(config.textLabel);
+    _textLabel = !ifEmpty&&i<config.showCheckNum+1?Object.assign({},JSON.parse(config._textLabel),{showInCheck:true}):JSON.parse(config._textLabel);
     if(i===0){
       //第一个标签不是文本标签时在前面添加文本标签
       if(!noPre&&notText){
         newArr.push(textLabel);
         saveText.push('');
       }
-      newArr.push(it);
+      item = ifEmpty?it:Object.assign({},it,{showInCheck:true});
+      newArr.push(item);
       if(it.tagType != 3){
         tempText = value?it.labelPrefix+value+it.labelSuffix:'';
         tempText = notText?tempText:it.value||it.name;
@@ -114,23 +118,25 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
       saveText.push(tempText);
     }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);
-          ifEmpty?newArr.push(textLabel,it):newArr.push(_textLabel,it);
+          ifEmpty?newArr.push(textLabel,it):newArr.push(_textLabel,item);
           if(it.tagType != 3) {
             tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
           }else{
             tempText = getSaveText(it);
           }
-          saveText.push("",tempText); 
-        //最后一个非文本标签,后面添加一个文本标签
-        /*if(!noEnd&&i===arr.length-1){
-          newArr.push(textLabel);
-          saveText.push("");
-        }*/
+          saveText.push("",tempText);
       }else{    //本身是或者前面是文本标签时,前面不添加文本标签
-        newArr.push(it);
+        newArr.push(item);
         if(it.tagType != 3) {
           tempText = value ? it.labelPrefix + value + it.labelSuffix : '';
           // tempText = notText?tempText:it.value||it.name;
@@ -147,7 +153,7 @@ export const fullfillText = (arr,noPre=false,noEnd=false,ifEmpty=true)=>{
       }
     }
   });
-  return {newArr,saveText};
+  return {newArr,saveText,checkHiddenDefault};
 };
 
 

+ 16 - 4
src/components/CheckBody/index.jsx

@@ -31,9 +31,13 @@ class CheckBody extends Component{
   }
   getLabels(){
     const {data,showArr,saveText,selecteds} = this.props;
-    let arr = [],list=[];
+    let arr = [],list=[];//console.log(data,saveText)
     const {boxMark,showAll} = this.state;
-    const showData = showAll?[...data]:[...data].splice(0,config.showCheckNum*2+1);
+    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);
     if(showData){
       list = showData;
       arr = list.map((it,i)=>{
@@ -89,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(){
@@ -107,8 +119,8 @@ class CheckBody extends Component{
     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 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}>

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

@@ -97,7 +97,6 @@ class NumberDrop extends Component{
   }
   handleNumClick(e){     //数字框不可编辑的状态时点击事件,点击将数字框变为可输入且下拉不再显示直到失焦后再次聚集
     const {show,handleShow,ikey,id,patId,handleHide,value} = this.props;
-    this.$span.current.focus();
     if(show) {
       handleHide && handleHide();
       return;
@@ -111,6 +110,7 @@ class NumberDrop extends Component{
       clearTimeout(that.state.timer);
       const timer = setTimeout(function(){
         //只有弹窗关闭则点击数字键盘会清空当前数据
+        that.$span.current.focus();
         that.setState({
           hasSelect:false
         });
@@ -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 - 1
src/components/SpreadDrop/index.jsx

@@ -228,7 +228,7 @@ class SpreadDrop extends Component{
       const tIndex= exists.findIndex((it)=>it.questionId===item.questionId);
       const bIndex= withs.findIndex((it)=>it.questionId===item.questionId);
       if(tIndex!=-1){
-        exists.splice(tIndex,1,item);
+        exists.splice(tIndex,1,Object.assign({},item,{name}));    //修改单选列连接字符不显示bug
         this.setState({
           exists,
         })

+ 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,

+ 11 - 3
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;
@@ -254,11 +256,17 @@ export function setSearchData(state,action){
 //插入标签数据-搜索
 export function insertLabelData(state,action){
   let res = Object.assign({},state);
-  const text = Object.assign({},JSON.parse(config.textLabel));
   const searchStr = res.searchStr;
   const {index,data,isReplace,span,searchInEnd}=action;
   const showText = res.saveText[index];
-  const spreadLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
+  let tempLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
+  //查体中,默认显示区域搜索出来的标签要默认显示,隐藏区域搜索出的默认隐藏
+  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});
+  let spreadLabels =tempLabels.map((it)=>{
+    return Object.assign({},it,{showInCheck:index>hideAreaIndex?false:true});
+  });
   let reg = searchInEnd?new RegExp(searchStr+"$"):new RegExp("^"+searchStr);
   const newText=showText.replace(reg,'')||'';
   if(!isReplace){

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

@@ -5,6 +5,7 @@ import {SET_MAINSUIT} from '@store/types/mainSuit';
 import config from '@config/index.js';
 import store from '@store';
 import {fullfillText} from '@common/js/func';
+import {formatContinueDots} from '@utils/tools';
 import {getOtherHisRecord,getInitData} from '@store/async-actions/fetchModules.js';
 import {initHistoryDetails} from '@store/async-actions/patInfo';
 
@@ -18,7 +19,7 @@ function modulesParseJson(data){
   data.map((it)=>{
     moduleName[config.moduleCP[it.id]] = it.name;//添加病情变化/病程变化子模板需要使用模板名称
     obj = fullfillText(it.moduleDetailDTOList);
-    json[config.moduleCP[it.id]] = obj.newArr;
+    json[config.moduleCP[it.id]] = formatContinueDots(obj.newArr);
     saveTextJson[config.moduleCP[it.id]] = obj.saveText;
   });
   return {json,saveTextJson,moduleName};

+ 11 - 64
src/utils/tools.js

@@ -561,6 +561,16 @@ function trimDots(str){
   }).replace(/^[,,.。::"“??”;;、!!]+/,'');
 }
 
+//标签间连续标点只保留一个,保留前面一个
+function formatContinueDots(data){
+  let arr=data.filter((it,i)=>{
+    if(!(it.name==','&&data[i-1].name==',')){
+      return it;
+    }
+  });
+  return arr;
+}
+
 // 取消默认行为
 function preventDefault(event) {
     if (event.preventDefault) {
@@ -694,70 +704,6 @@ function timestampToTime(timestamp) {     //excel导入2019年5月1日会转换
   var s = date.getSeconds();
   return Y+M+D+h+m+s;
 }
-function getPageLength(event) {     //兼容ie8获取页面距离左和上的距离,包括滚动距离
-  let e = event || window.event;
-  let scrollX = document.documentElement.scrollLeft || document.body.scrollLeft; 
-  let scrollY = document.documentElement.scrollTop || document.body.scrollTop; 
-  let x = e.pageX || e.clientX + scrollX; 
-  let y = e.pageY || e.clientY + scrollY;
-  let page = {
-    pageX:x,
-    pageY:y
-  }
-  return page;
-}
-function dragBox(domWrap,domDrag){
-  let wrap = document.getElementById(domWrap);//呗拖拽的元素
-  let drag = document.getElementById(domDrag);//拖拽区域
-  let width = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;//屏幕宽度
-  let height = window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;//屏幕高度
-  let mouseX = 0,mouseY = 0,dragX = 0,dragY = 0,isDrag = false,isMove = false;
-  let maxDragX = width - wrap.offsetWidth;//最大可推拽x方向距离
-  let maxDragY = height - wrap.offsetHeight;//最大可拖拽y方向距离
-  windowEventHandler('mousedown',(event)=>{    //鼠标位置获取,计算点击位置到拖拽元素左边的距离
-    wrap = document.getElementById(domWrap);
-    drag = document.getElementById(domDrag);
-    let page = getPageLength(event);
-    mouseX = page.pageX - wrap.offsetLeft      //鼠标到拖拽元素的左边界的距离
-    mouseY = page.pageY - wrap.offsetTop       //鼠标到拖拽元素的上边界的距离
-    isDrag = true
-  },drag)
-  // windowEventHandler('mousemove',handleMove,document)
-  windowEventHandler('mousemove',(event)=>{      //移动的
-    let page = getPageLength(event);
-    if(isDrag){
-      dragX = page.pageX - mouseX          //鼠标可拖拽到左边的最大距离
-      dragY = page.pageY - mouseY          //鼠标可拖拽到上边的最大距离
-      if(dragX < 0){      //不能超出左边界
-        dragX = 0
-      }
-      if(dragY < 0){      //不能超出上边界
-        dragY = 0
-      }
-      if(width-dragX < wrap.offsetWidth){    //不能超出右边界
-        dragX = maxDragX
-      } 
-      if(height-dragY < wrap.offsetHeight){     //不能超出下边界
-        dragY = maxDragY
-      }
-      isMove = true
-      wrap.style.left = dragX + 'px'
-      wrap.style.marginLeft = 0 + 'px'
-      wrap.style.top = dragY + 'px'
-    }
-  },document)
-  windowEventHandler('mouseup',(event)=>{
-    if(isMove){ //有move就设置位置没有移动就不处理
-      wrap.style.left = dragX + 'px'
-      wrap.style.top = dragY + 'px'
-    }
-    isDrag = false
-    return false
-  },document)
-}
-// function handleMove(event,mouseX){
-//     console.log(event)
-// }
 module.exports = {
     checkType: Type.checkType,
     regexp,
@@ -788,4 +734,5 @@ module.exports = {
     timestampToTime,
     getPageLength,
     dragBox,
+    formatContinueDots
 };