ソースを参照

Merge branch 'dev/byll' into Chronic-ll

Luolei 6 年 前
コミット
b97a070938

+ 2 - 2
src/common/components/DropList/index.jsx

@@ -43,14 +43,14 @@ class DropList extends Component{
     onSelect&&onSelect(undefined);
   }
   render(){
-    const {data,hideTag} = this.props;
+    const {data,hideTag,boxMark} = this.props;
     const domNode = document.getElementById('root');
     return ReactDom.createPortal(
       <div className={this.getClass()} style={this.getStyle()} contentEditable='false'>
         <ul>
           {data&&data.map((it)=>{
             /*return <li onClick={(e)=>this.handleSelect(e,it)} className={it.selected||(it.selected!==false&&+it.defaultSelect===1)?style['selected']:''}>{it.labelPrefix}{it.questionDetailList&&it.questionDetailList.length>0?it.questionDetailList[0].name:it.name}{it.labelSuffix}</li>*/
-            return <li onClick={(e)=>this.handleSelect(e,it)} className={it.selected||(!hideTag&&it.selected!==false&&+it.defaultSelect===1)?style['selected']:''}>{it.labelPrefix}{it.name}{it.labelSuffix}</li>
+            return <li onClick={(e)=>this.handleSelect(e,it)} className={it.selected||(boxMark!=1&&!hideTag&&it.selected!==false&&+it.defaultSelect===1)?style['selected']:''}>{it.labelPrefix}{it.name}{it.labelSuffix}</li>
           })}
           <li onClick={(e)=>this.handleClear(e)} className='red'>清空选项</li>
         </ul>

+ 1 - 1
src/common/components/InspectCommon/index.less

@@ -6,7 +6,7 @@
     background-color: #fff;
     padding:28px 8px 8px 8px;
     min-width: 300px;
-    max-width: 600px;
+    max-width: 680px;
     box-sizing: border-box;
     margin-bottom: 80px;
     .llStyle;

+ 6 - 1
src/components/AddInspect/index.less

@@ -130,7 +130,7 @@
     // line-height: 28px;
     overflow: hidden;
     padding-top: 0 !important;
-    width: 290px;
+    width: 330px;
     float: left;
     padding: 0 15px;
     box-sizing: border-box;
@@ -154,9 +154,14 @@
         input {
             width: 40px;
             text-align: center;
+            float: left;
         }
         .unit {
             display: inline-block;
+            max-width: 70px;
+            overflow: hidden;
+            text-overflow: ellipsis;
+            white-space: nowrap;
         }
     }
 }

+ 162 - 0
src/components/Multiple/SlideItem/index.jsx

@@ -0,0 +1,162 @@
+import react from "react";
+import style from "./index.less";
+import $ from 'jquery';
+import classNames from 'classnames';
+import {handleEnter,isIE,filterArr,deepClone,filterDataArr} from '@utils/tools.js';
+import {Notify} from '@commonComp';
+import ReactDom from "react-dom";
+import config from '@config/index.js';
+/**
+  单列多选组件(tagtype=1,controlType=2)
+  2019-2-20 By_liucf
+  参数:
+  placeholder:标签名
+  value:标签选中的值
+  show:是否展示下拉
+  data:下拉数据
+  type:标识哪一项数据(1-主诉,2-现病史,3-其他史,4-查体)
+**/
+
+class Multiple extends react.Component{
+  constructor(props){
+    super(props);
+    const {seleData,seleId} = deepClone(props.selecteds||[]);
+    this.state={
+      editable:false,
+      timer:null,
+      labelVal:"",
+      seleData:seleData||"",
+      seleId:seleId||[],
+      boxLeft:null,
+      boxTop:null
+    }
+    this.$div = React.createRef();
+    this.handleSelect = this.handleSelect.bind(this);
+    this.onChange = this.onChange.bind(this);
+    this.handleBlur = this.handleBlur.bind(this);
+    this.handleClear = this.handleClear.bind(this);
+    this.handleComfirn = this.handleComfirn.bind(this);
+  }
+
+  getListClass(){
+    let name = style['text-list'];
+    let isHide = this.props.show?'':style['hide'];
+    return classNames(style['list'],name,isHide);
+  }
+
+  getSeleStyle(id){
+    const {seleId} = this.state;
+    if(seleId.includes(id)){
+      return style['selected'];
+    }
+    return '';
+  }
+
+  handleSelect(e,item){
+    e&&e.stopPropagation();
+    let {seleData,seleId} = this.state;
+    const {name,id} = item;
+    if(seleId.includes(id)){
+      seleId.splice(seleId.indexOf(id),1);
+      seleData = seleData.replace(name,'');
+    }else{
+      seleId.push(id);
+      seleData += name;
+    }
+    this.setState({
+      seleData,
+      seleId
+    })
+  }
+
+  onChange(e){
+    const {mainSaveText,ikey,type,handleLabelChange} = this.props;
+    const {labelVal,editable} = this.state;
+    let mainText = filterDataArr(mainSaveText);//主诉字数
+    if(editable){//避免IE中点击标签也会触发
+      let val = e.target.innerText || e.target.innerHTML;
+      if(+type==1){// 主诉字数达到上限时不允许输入
+        if(mainText.length >= config.limited){
+          if(val.length > labelVal.length){
+            e.target.innerText?(e.target.innerText = labelVal):(e.target.innerHTML = labelVal);
+            Notify.info(config.limitText);
+            return
+          }else if(val.length == labelVal.length){
+            this.setState({
+              labelVal:val
+            });
+          }else{
+            handleLabelChange && handleLabelChange({ikey,changeVal:val,type});
+          }
+        }
+      }
+    }
+  }
+
+  handleBlur(e){//修改存值
+    e.stopPropagation();
+    const {ikey,type,handleLabelChange} = this.props;
+    const {editable} = this.state;
+    const ev = e || window.event;
+    if(editable){
+      // 更改标签的value值
+      let changeVal = ev.target.innerText || e.target.innerHTML;
+      if(!isIE()){
+        e.target.innerText?(e.target.innerText = ''):(e.target.innerHTML='');      //避免出现重复输入值
+      }
+      handleLabelChange && handleLabelChange({ikey,changeVal,type});
+    }
+    this.setState({
+      editable:false
+    });
+  }
+
+  handleClear(e){
+    e&&e.stopPropagation();
+    this.setState({
+      seleData:"",
+      seleId:[]
+    })
+  }
+
+  handleComfirn(e){
+    e&&e.stopPropagation();
+    const {handleConfirm,ikey,order,mainSaveText,value,handleHide,type} = this.props;
+    const params = Object.assign({},this.state,{ikey,order,mainSaveText,value,type});
+    handleConfirm&&handleConfirm(params);
+    handleHide&&handleHide();
+  }
+
+  componentDidMount(){
+    if(isIE()){
+      $(this.$div.current).onIe8Input(function(e){
+        this.onChange(e)
+      },this);
+    }
+  }
+  getStyle(){
+    const {left,top,show} = this.props;
+    return {
+      left:left?left+'px':'0',
+      top:top?top+'px':'0',
+      display:show?'table':'none'        //table onBlur阻止冒泡是为了修复multSpread中数字键盘点击触发最外层数字组件onBlur事件
+    }
+  }
+  render(){
+    const {placeholder,value,show,data} = this.props;
+    const {editable,boxTop,boxLeft} = this.state;
+    const domNode = document.getElementById('root');
+    return ReactDom.createPortal(
+      <div className={this.getListClass()} style={this.getStyle()} contentEditable="false">
+        <ul>
+          {data&&data.map((it)=>{
+          return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getSeleStyle(it.id)} title={it.name.length>8?it.name:''}>{it.name&&it.name.length>8?it.name.slice(0,8)+'...':it.name}</li>
+        })}
+          <li onClick={this.handleClear} className={style['mClear']}>清空选项</li>
+          <li onClick={this.handleComfirn} className={style['mConfirm']}>确定</li>
+        </ul>
+      </div>,domNode)
+  }
+}
+
+export default Multiple;

+ 53 - 0
src/components/Multiple/SlideItem/index.less

@@ -0,0 +1,53 @@
+@import "~@less/mixin.less";
+.container{
+  display: inline-block;
+}
+.selected{
+    .select-li;
+  }
+.tag,.selected-tag{
+  cursor: pointer;
+  line-height: 20px;
+}
+
+.selected-tag{
+  padding: 0;
+  color: @text-color;
+  border-bottom: 1px @border-color solid;
+  line-height: 22px;
+}
+.hide-tag{
+  padding: 0;
+  color: @text-color;
+  line-height: 22px;
+}
+.list{
+  .pop;
+  padding: 0 0 10px;
+  color: @text-color;
+  li{
+    height: 32px;
+    line-height: 32px;
+    border:1px #fff solid;
+    padding: 0 20px;
+    white-space: nowrap;
+    cursor: pointer;
+  }
+  // li:hover,.selected{
+  li:hover{
+    border-color:#3B9ED0;
+  }
+}
+.hide{
+  display: none;
+}
+
+.mClear{
+  color:red;
+}
+.mConfirm{
+  color: #3B9ED0;
+  text-align: center;
+  border: 1px solid #3B9ED0;
+
+}

+ 28 - 24
src/components/Multiple/index.jsx

@@ -2,8 +2,9 @@ import react from "react";
 import style from "./index.less";
 import $ from 'jquery';
 import classNames from 'classnames';
-import {handleEnter,isIE,filterArr,deepClone,filterDataArr} from '@utils/tools.js';
+import {handleEnter,isIE,filterArr,deepClone,filterDataArr,getPageCoordinate} from '@utils/tools.js';
 import {Notify} from '@commonComp';
+import SlideItem from "./SlideItem";
 import config from '@config/index.js';
 /**
   单列多选组件(tagtype=1,controlType=2)
@@ -27,7 +28,9 @@ class Multiple extends react.Component{
       seleData:seleData||"",
       seleId:seleId||[],
       boxLeft:null,
-      boxTop:null
+      boxTop:null,
+      tmpScroll:null,
+      tmpTop:null
     }
     this.$div = React.createRef();
     this.handleShow = this.handleShow.bind(this);
@@ -36,7 +39,6 @@ class Multiple extends react.Component{
     this.onChange = this.onChange.bind(this);
     this.handleBlur = this.handleBlur.bind(this);
     this.handleClear = this.handleClear.bind(this);
-    this.handleComfirn = this.handleComfirn.bind(this);
   }
 
   getClass(){
@@ -73,8 +75,16 @@ class Multiple extends react.Component{
     const ht = e.target.offsetHeight;   //如杂音选中文字有多行时,写死会遮挡
     let boxTop = offsetTop + ht +2 + 'px';
     this.setState({
-      boxLeft:boxLeft,
-      boxTop:boxTop
+      boxLeft:getPageCoordinate(e).boxLeft,
+      boxTop:getPageCoordinate(e).boxTop,
+      tmpScroll: $("#addScrollEvent")[0].scrollTop,
+      tmpTop:getPageCoordinate(e).boxTop
+    })
+    $("#addScrollEvent").scroll(()=>{
+      let scrollYs = $("#addScrollEvent")[0].scrollTop;
+      this.setState({
+        boxTop:this.state.tmpTop - scrollYs + this.state.tmpScroll
+      })
     })
      this.setStateInit();
     const {ikey,handleShow,placeholder,flag,id,value,tagType,type} = this.props;
@@ -181,14 +191,6 @@ class Multiple extends react.Component{
     })
   }
 
-  handleComfirn(e){
-    e&&e.stopPropagation();
-    const {handleConfirm,ikey,order,mainSaveText,value,handleHide,type} = this.props;
-    const params = Object.assign({},this.state,{ikey,order,mainSaveText,value,type});
-    handleConfirm&&handleConfirm(params);
-    handleHide&&handleHide();
-  }
-
   componentDidMount(){
     if(isIE()){
       $(this.$div.current).onIe8Input(function(e){
@@ -196,9 +198,8 @@ class Multiple extends react.Component{
       },this);
     }
   }
-
   render(){
-    const {placeholder,value,show,data} = this.props;
+    const {placeholder,value,show,data,handleConfirm,ikey,order,mainSaveText,handleHide,type} = this.props;
     const {editable,boxTop,boxLeft} = this.state;
     return <div className={style["container"]}>
       <div className={this.getClass()}
@@ -209,15 +210,18 @@ class Multiple extends react.Component{
       onInput={this.onChange}
       onkeydown={handleEnter}
       contentEditable={editable}>{value||placeholder}</div>
-      <div className={this.getListClass()} style={{top:boxTop,left:boxLeft}} contentEditable="false">
-        <ul>
-          {data&&data.map((it)=>{
-          return <li onClick={(e)=>this.handleSelect(e,it)} className={this.getSeleStyle(it.id)} title={it.name.length>8?it.name:''}>{it.name&&it.name.length>8?it.name.slice(0,8)+'...':it.name}</li>
-        })}
-          <li onClick={this.handleClear} className={style['mClear']}>清空选项</li>
-          <li onClick={this.handleComfirn} className={style['mConfirm']}>确定</li>
-        </ul>
-        
+      <div className={this.getListClass()} contentEditable="false">
+        <SlideItem 
+          show={show} 
+          left={boxLeft} 
+          top={boxTop} 
+          data={data} 
+          handleConfirm={handleConfirm} 
+          ikey={ikey}
+          order={order}
+          mainSaveText={mainSaveText}
+          handleHide={handleHide}
+          type={type}></SlideItem>
       </div>
     </div>
   }

+ 4 - 4
src/components/RadioDrop/index.jsx

@@ -101,11 +101,11 @@ class RadioDrop extends Component{
     },$("#addScrollEvent")[0])
   }
   componentDidMount(){    //默认值选中
-    const {data,ikey,handleSelect,hideTag,mainSaveText,value} = this.props;
+    const {data,ikey,handleSelect,hideTag,mainSaveText,value,boxMark} = this.props;
     const selected = data.find((it)=>{
       return it.selected === undefined&&+it.defaultSelect===1;
     });
-    if(!hideTag&&selected){
+    if(boxMark!=1&&!hideTag&&selected){
       // const text = selected.labelPrefix+selected.name+selected.labelSuffix;
       const text = selected.name;
       handleSelect&&handleSelect({ikey,id:selected.id,text,mainSaveText,value});
@@ -144,7 +144,7 @@ class RadioDrop extends Component{
     handleDbclick&&handleDbclick({id:patId||id});
   }
   render(){
-    const {data,prefix,suffix,placeholder,show,value,hideTag} = this.props;
+    const {data,prefix,suffix,placeholder,show,value,hideTag,boxMark} = this.props;
     const {boxLeft,boxTop} = this.state;
     return <div className={style['container']} ref = {this.$cont}>
       {prefix}
@@ -157,7 +157,7 @@ class RadioDrop extends Component{
         {value||placeholder}
       </div>
       {suffix}
-      <DropList onSelect={this.handleSelect} data={data} left={boxLeft} top={boxTop} show={show} hideTag={hideTag}/>
+      <DropList onSelect={this.handleSelect} boxMark={boxMark} data={data} left={boxLeft} top={boxTop} show={show} hideTag={hideTag}/>
     </div>
   }
 }

+ 1 - 2
src/components/TemplateItems/TemplateItem/index.jsx

@@ -148,7 +148,7 @@ class TemplateItem extends React.Component {
                     </span>
                     <img className={style.arrow} src={this.getArrow()} />
                     <img title={'删除模板'} 
-                        className={style.del} 
+                        className={style.del}
                         style={{display:allCheckShow?'none':'block'}}
                         src={this.getDelIcon()} 
                         onMouseEnter={() => this.handleDelIconMouseEnter()}
@@ -172,7 +172,6 @@ class TemplateItem extends React.Component {
                     {
                         previewJson?<DesItem preview={previewJson}></DesItem>:<p>暂无数据</p>
                     }
-                    
                 </div>
             </div>
         )

+ 29 - 31
src/store/actions/currentIll.js

@@ -731,15 +731,21 @@ export function insertLabelData(state,action){
   let focusIndex = res.focusIndex;
   let saveText = res.saveText;
   let banIdx = saveText.indexOf("伴");
-  
+  //伴随展开数据-过滤了连续标点
+  const FilteredDotMapping2=formatContinueDots(data.questionMapping.filter((item)=>{
+    return item.symptomType==0||item.symptomType==2;
+  }));
+  //主症状展开数据-过滤连续了标点
+  const FilteredDotMapping1=formatContinueDots(data.questionMapping.filter((item)=>{
+    return item.symptomType==0||item.symptomType==1;
+  }));
   if(isReplace){
     span.current.innerText?(span.current.innerText = ''):(span.current.innerHTML = '');
     // res.data.splice(focusIndex,1,text,data);
     // 搜索结果展开伴随symptomType==2的尾巴
+
     let resData = JSON.parse(JSON.stringify(res.data));
-    resData.splice(focusIndex,1,text,...(data.questionMapping.filter((item)=>{
-                              return item.symptomType==0||item.symptomType==2;
-                            })));
+    resData.splice(focusIndex,1,text,...(FilteredDotMapping2));
     res.data = fullfillText(resData).newArr;
     res.saveText[focusIndex] = searchData;
   }else{
@@ -753,55 +759,45 @@ export function insertLabelData(state,action){
       res.symptomIds.push(id);
       // 没有伴展开主诉symptomType=0/1的尾巴,有伴一>第一个点选上去的伴为依据,伴前展开主诉,伴后展开伴随;多余的伴以及手动输入的伴不做处理(2-25)
       if(banIdx==-1){
+
         // if(strIndex <= 1){//前
         if(strIndex < 1){//前
-          res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
-                                   return item.symptomType==0||item.symptomType==1;
-                                })),pText);
+          res.data.splice(index,1,text,...(FilteredDotMapping1),pText);
           res.saveText = fullfillText(res.data).saveText;
-          res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
+          res.selecteds.splice(index,1,null,...new Array(FilteredDotMapping1.length).fill(null),null);
         }else{
-          res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
-                                   return item.symptomType==0||item.symptomType==1;
-                                })));
+          res.data.splice(index,1,pText,text,...(FilteredDotMapping1));
           res.saveText = fullfillText(res.data).saveText;
-          res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
+          res.selecteds.splice(index,1,null,null,...new Array(FilteredDotMapping1.length).fill(null));
         }
       }else{
         if(focusIndex > banIdx){//伴后
           if(strIndex < 1){//前
-            res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
-                                   return item.symptomType==0||item.symptomType==2;
-                                })),pText);
+            res.data.splice(index,1,text,...(FilteredDotMapping2),pText);
             res.saveText = fullfillText(res.data).saveText;
-            res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
+            res.selecteds.splice(index,1,null,...new Array(FilteredDotMapping2.length).fill(null),null);
           }else{
-            res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
-                                   return item.symptomType==0||item.symptomType==2;
-                                })));
+            res.data.splice(index,1,pText,text,...(FilteredDotMapping2));
             res.saveText = fullfillText(res.data).saveText;
-            res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
+            res.selecteds.splice(index,1,null,null,...new Array(FilteredDotMapping2.length).fill(null));
           }
         }else{//伴前
           if(strIndex < 1){//前
-            res.data.splice(index,1,text,...(data.questionMapping.filter((item)=>{
-                                   return item.symptomType==0||item.symptomType==1;
-                                })),pText);
+            res.data.splice(index,1,text,...(FilteredDotMapping1),pText);
             res.saveText = fullfillText(res.data).saveText;
-            res.selecteds.splice(index,1,null,...new Array(data.questionMapping.length).fill(null),null);
+            res.selecteds.splice(index,1,null,...new Array(FilteredDotMapping1.length).fill(null),null);
           }else{
-            res.data.splice(index,1,pText,text,...(data.questionMapping.filter((item)=>{
-                                   return item.symptomType==0||item.symptomType==1;
-                                })));
+            res.data.splice(index,1,pText,text,...(FilteredDotMapping1));
             res.saveText = fullfillText(res.data).saveText;
-            res.selecteds.splice(index,1,null,null,...new Array(data.questionMapping.length).fill(null));
+            res.selecteds.splice(index,1,null,null,...new Array(FilteredDotMapping1.length).fill(null));
           }
         }
       }
       res.data = fullfillText(res.data).newArr;
       res.saveText = fullfillText(res.data).saveText;
     }else{//标签
-      const spreadLabels = data.tagType==4?fullfillText(data.questionMapping).newArr:[data];
+      const arr=fullfillText(data.questionMapping).newArr;      //过滤连续标点
+      const spreadLabels = data.tagType==4?formatContinueDots(arr):[data];
       if(strIndex < 1){//前
         // 判断前一个是否为文本标签,是直接插入标签,不是则在前面插入一个空文本标签
         const preItem = res.data[index-1];
@@ -845,10 +841,12 @@ export const clearCurrentEdit = (state,action)=>{
 export function addLabelItem(state,action){
   let res = Object.assign({},state);
   const {data,i} = action;
-  const textLabel = JSON.parse(config.textLabel);
+  const textLabel = Object.assign({},JSON.parse(config._textLabel),{showInCheck:JSON.parse(data).showInCheck});
   //使用Object.assign({},data)拷贝操作时复制项和原项会同步修改
   if(!data) return res;
-  res.data.splice(i+1,0,JSON.parse(data),textLabel);
+  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();
   return res;
 }

+ 4 - 2
src/store/actions/mainSuit.js

@@ -697,10 +697,12 @@ export function setCheckText(state,action) {
 export function addLabelItem(state,action){
   let res = Object.assign({},state);
   const {data,i} = action;
-  const textLabel = JSON.parse(config.textLabel);
+  const textLabel = Object.assign({},JSON.parse(config._textLabel),{showInCheck:JSON.parse(data).showInCheck});
   //使用Object.assign({},data)拷贝操作时复制项和原项会同步修改
   if(!data) return res;
-  res.data.splice(i+1,0,JSON.parse(data),textLabel);
+  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();
   return res;
 }

+ 4 - 2
src/store/actions/otherHistory.js

@@ -409,10 +409,12 @@ export const setTextModeValue = (state,action)=>{
 export function addLabelItem(state,action){
   let res = Object.assign({},state);
   const {data,i} = action;
-  const textLabel = JSON.parse(config.textLabel);
+  const textLabel = Object.assign({},JSON.parse(config._textLabel),{showInCheck:JSON.parse(data).showInCheck});
   //使用Object.assign({},data)拷贝操作时复制项和原项会同步修改
   if(!data) return res;
-  res.data.splice(i+1,0,JSON.parse(data),textLabel);
+  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();
   return res;
 }

+ 1 - 0
src/utils/config.js

@@ -1,3 +1,4 @@
+// const host='http://192.168.3.1:5050';//赵
 // const host='http://192.168.3.100:5050';//王峰
 // const host='http://192.168.2.241:5050';//后端接口访问地址
 const host='http://192.168.2.236:5050';//后端接口访问地址