瀏覽代碼

时间单位组件IE兼容

liucf 6 年之前
父節點
當前提交
caad36f002

+ 3 - 1
src/common/components/NumberPan/index.jsx

@@ -49,7 +49,8 @@ class NumberPan extends Component{
   render(){
     const select = this.handleSelect.bind(this);
     const {show} = this.props;      //table onBlur阻止冒泡是为了修复multSpread中数字键盘点击触发最外层数字组件onBlur事件
-    return <table className={style['pan']} onBlur={(e)=>e.stopPropagation()} style={{display:show?'table':'none'}}>
+    return <div className={style['panBox']} onBlur={(e)=>e.stopPropagation()} style={{display:show?'table':'none'}}>
+    <table className={style['pan']} >
       <tr>
         <td><button onClick={select}>1</button></td>
         <td><button onClick={select}>2</button></td>
@@ -75,6 +76,7 @@ class NumberPan extends Component{
         <td><button onClick={this.handleClose.bind(this)}>确定</button></td>
       </tr>
     </table>
+    </div>
   }
 }
 

+ 4 - 1
src/common/components/NumberPan/index.less

@@ -1,7 +1,10 @@
 @import "~@less/variables.less";
+.panBox{
+  .pop;
+}
 .pan{
   width: 280px;
-  .pop;
+  
   td{
     width: 68px;
     height:44px;

+ 3 - 1
src/common/components/NumberUnitPan/index.jsx

@@ -58,7 +58,8 @@ class NumberUnitPan extends Component{
   render(){
     // const select = this.handleSelect.bind(this);
     const {show} = this.props;      //table onBlur阻止冒泡是为了修复multSpread中数字键盘点击触发最外层数字组件onBlur事件
-    return <table className={style['pan']} onBlur={(e)=>e.stopPropagation()} style={{display:show?'table':'none'}}>
+    return <div className={style['panBox']} onBlur={(e)=>e.stopPropagation()} style={{display:show?'table':'none'}}>
+      <table className={style['pan']} >
       <tr>
         <td><span onClick={this.handleSelect}>1</span></td>
         <td><span onClick={this.handleSelect}>2</span></td>
@@ -94,6 +95,7 @@ class NumberUnitPan extends Component{
         <td><span onClick={this.handleSelect}>{config.timeUnit.year}</span></td>
       </tr>
     </table>
+    </div>
   }
 }
 

+ 4 - 1
src/common/components/NumberUnitPan/index.less

@@ -1,7 +1,10 @@
 @import "~@less/variables.less";
+.panBox{
+  .pop;
+}
 .pan{
   width: 280px;
-  .pop;
+  
   td{
     width: 68px;
     height:44px;

+ 7 - 8
src/components/MainSuit/index.jsx

@@ -35,7 +35,7 @@ class MainSuit extends Component{
     this.handleClick = this.handleClick.bind(this);
     this.handleBlur = this.handleBlur.bind(this);
   }
-  toggleEditable(){console.log("切换编辑状态")
+  toggleEditable(){
     this.setState({
       boxEditable:!this.state.boxEditable
     })
@@ -60,7 +60,7 @@ class MainSuit extends Component{
   handleFocus(e){
     e.stopPropagation();
     const {getCommonSymptoms,datas} = this.props;
-    let innerText = e.target.innerText;console.log("聚焦");
+    let innerText = e.target.innerText;
     if(!isIE()){//IE会触发onfocus和onblur事件
       if(!innerText.trim()){//有内容就走搜索接口
         getCommonSymptoms && getCommonSymptoms();
@@ -74,7 +74,7 @@ class MainSuit extends Component{
         }) 
       }
     }else{
-      if(datas.length==0){
+      if(datas.length==0 && !innerText.trim()){
         getCommonSymptoms && getCommonSymptoms();
         this.setState({
           symptom:true
@@ -93,7 +93,6 @@ class MainSuit extends Component{
   }*/
 
   handleSelect(item){//选中的常见症状
-    console.log("主诉选中下拉",item);
     const {clearCommS,insertMain,getData} = this.props;
     // 获取主诉模板
     getData && getData();
@@ -109,7 +108,7 @@ class MainSuit extends Component{
   }
 
 
-  handleSearchSelect(item){console.log("选中搜索");
+  handleSearchSelect(item){
     const {clearSearch,insertSearch,datas,span} = this.props;
     clearTimeout(this.state.timer);
     if(datas.length==0){//没有使用模板时点击搜索结构要展开模板
@@ -131,7 +130,7 @@ class MainSuit extends Component{
   }
 
 
-  handleClick(e){console.log("主诉框点击事件");//让搜索框跟随鼠标点击移动
+  handleClick(e){//让搜索框跟随鼠标点击移动
     // e.stopPropagation(); //冒泡到最顶层关闭其他下拉
     let boxLeft = e.pageX -32 + 'px';
     // let boxTop = e.pageY - 112 + 'px';
@@ -143,7 +142,7 @@ class MainSuit extends Component{
     })
   }
 
-  handleChange(e){console.log("主诉onchange");
+  handleChange(e){
     const data = e.target.innerText;
     const {getSearchData,searchData,datas,pushMessage,reTotalHide} = this.props;
     const {overFlag,inpText} = this.state;
@@ -196,7 +195,7 @@ class MainSuit extends Component{
   handleBlur(e){//隐藏常见症状下拉、存自由输入的值
     const {freeText,saveText,datas} = this.props;
     const that = this;
-    let data = this.state.inpText;console.log("主诉框失焦",data);
+    let data = this.state.inpText;
     if(!isIE()){
       e.target.innerText="";
       freeText && freeText(data.trim());

+ 33 - 19
src/components/NumberUnitDrop/index.jsx

@@ -3,8 +3,9 @@ import className from 'classnames';
 import {NumberUnitPan} from '@commonComp';
 import style from './index.less';
 import config from '@config/index.js';
-import {filterArr,handleEnter} from '@utils/tools.js';
+import {filterArr,handleEnter,isIE} from '@utils/tools.js';
 import {Notify} from '@commonComp';
+import $ from 'jquery';
 /***
  * 带单位数字组件
  * 接收参数:
@@ -69,37 +70,43 @@ class NumberUnitDrop extends Component{
   //数字框失焦,保存值到store中
   numInpBlur(e){
     e.stopPropagation();
+    const {handleSelect,ikey,suffix,prefix,mainSaveText} = this.props;
+    const {editable} = this.state;
+    if(editable){
+      const text = e.target.innerText;
+      // this.$span.current.innerText='';      //修改生成文字变成输入的2倍bug 
+      handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
+    }
     this.setState({
       isClosed:false,
       numEditable:true,
       hasSelect:false,
       editable:false
     });
-    const text = e.target.innerText;
-    this.$span.current.innerText='';      //修改生成文字变成输入的2倍bug
-    const {handleSelect,ikey,suffix,prefix,mainSaveText} = this.props;
-    handleSelect&&handleSelect({ikey,text,suffix,prefix,mainSaveText});
+    
   }
 
   handleSpanInp(e){ //数字框输入事件
     e.stopPropagation();
     // 主诉字数达到上限时不允许输入
     const {mainSaveText,ikey,type,handleSelect,suffix,prefix,boxMark} = this.props;
-    const {labelVal} = this.state;
+    const {labelVal,editable} = this.state;
     let mainText = filterArr(mainSaveText);//主诉字数
-    let val = e.target.innerText;
-    if(+boxMark==1){
-      if(mainText.length >= config.limited){
-        if(val.length > labelVal.length){
-          e.target.innerText = labelVal;
-          Notify.info(config.limitText);
-          return
-        }else if(val.length == labelVal.length){
-          this.setState({
-            labelVal:val
-          });
-        }else{
-          handleSelect&&handleSelect({ikey,text:val,suffix,prefix,mainSaveText});
+    if(editable){//避免IE中点击标签也会触发
+      let val = e.target.innerText;
+      if(+boxMark==1){
+        if(mainText.length >= config.limited){
+          if(val.length > labelVal.length){
+            e.target.innerText = labelVal;
+            Notify.info(config.limitText);
+            return
+          }else if(val.length == labelVal.length){
+            this.setState({
+              labelVal:val
+            });
+          }else{
+            handleSelect&&handleSelect({ikey,text:val,suffix,prefix,mainSaveText});
+          }
         }
       }
     }
@@ -126,6 +133,13 @@ class NumberUnitDrop extends Component{
       handleDbclick && handleDbclick({id:patId||id});
     }
   }
+  componentDidMount(){
+    if(isIE()){
+      $(this.$span.current).onIe8Input(function(e){
+        this.handleSpanInp(e)
+      },this);
+    }
+  }
 
   render(){
     const {placeholder,prefix,suffix,show,value,handleHide} = this.props;

+ 8 - 2
src/components/RadioDrop/index.jsx

@@ -88,10 +88,16 @@ class RadioDrop extends Component{
   handleEditLabel(e){
     e.stopPropagation();
     const {ikey,boxMark,handleLabelEdit} = this.props;
+    /*const {editable} = this.state;
+    if(editable){
+      // 更改标签的value值
+      let changeVal = e.target.innerText;
+      handleLabelEdit && handleLabelEdit({ikey,changeVal,type:boxMark});
+    }*/
     this.setState({
       editable:false
-    });
-    // 更改标签的value值
+    });  
+   // 更改标签的value值
     let changeVal = e.target.innerText;
     handleLabelEdit && handleLabelEdit({ikey,changeVal,type:boxMark});
   }

+ 29 - 24
src/components/SpreadDrop/index.jsx

@@ -67,12 +67,11 @@ class SpreadDrop extends Component{
 
   }
 
-  changeToEdit(e){console.log("标签双击");//双击
+  changeToEdit(e){//双击
     const {value,id,placeholder,handleDbclick} = this.props;
     let text = e.target.innerText;
     // clearTimeout(this.state.timer);//取消延时的单击事件
     e.stopPropagation();
-    // e.preventDefault();
     if(value&&value.trim()){//有选中值的标签才能双击编辑
       this.setState({
         labelVal:text,
@@ -83,37 +82,43 @@ class SpreadDrop extends Component{
     }
   }
 
-  onChange(e){  console.log("标签输入");
+  onChange(e){  
     const {mainSaveText,ikey,type,handleLabelChange} = this.props;
-    const {labelVal} = this.state;
+    const {labelVal,editable} = this.state;
     let mainText = filterArr(mainSaveText);//主诉字数
-    let val = e.target.innerText;
-    if(+type==1){// 主诉字数达到上限时不允许输入
-      if(mainText.length >= config.limited){
-        if(val.length > labelVal.length){
-          e.target.innerText = labelVal;
-          Notify.info(config.limitText);
-          return
-        }else if(val.length == labelVal.length){
-          this.setState({
-            labelVal:val
-          });
-        }else{
-          handleLabelChange && handleLabelChange({ikey,changeVal:val,type});
+    if(editable){//避免IE中点击标签也会触发
+      let val = e.target.innerText;
+      if(+type==1){// 主诉字数达到上限时不允许输入
+        if(mainText.length >= config.limited){
+          if(val.length > labelVal.length){
+            e.target.innerText = 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();console.log("标签失焦");
+    e.stopPropagation();
     const {ikey,type,handleLabelChange} = this.props;
+    const {editable} = this.state;
+    if(editable){
+      // 更改标签的value值
+      let changeVal = e.target.innerText;
+      handleLabelChange && handleLabelChange({ikey,changeVal,type});
+    }
     this.setState({
       editable:false
     });
-    // 更改标签的value值
-    let changeVal = e.target.innerText;
-    // handleLabelChange && handleLabelChange({ikey,changeVal,type});
+    
 
   }
   setStateInit(){
@@ -148,11 +153,11 @@ class SpreadDrop extends Component{
     });
     this.btnClickFlag = false;
   }
-  handleClear(e){console.log("清空");
+  handleClear(e){
     e.stopPropagation();
     this.clearState();
   }
-  handleConfirm(e){console.log("确定");
+  handleConfirm(e){
     e.stopPropagation();
     const {handleConfirm,ikey,type,tagType,order,mainSaveText,copyType} = this.props;
     const params = Object.assign({},this.state,{ikey,type,tagType,order,mainSaveText,copyType});
@@ -161,7 +166,7 @@ class SpreadDrop extends Component{
     //点确定后隐藏弹窗
     this.props.handleHide();
   }
-  handleSelect(item,isExclu,joint,listIndex,selected){console.log("选中");
+  handleSelect(item,isExclu,joint,listIndex,selected){
     let {withOn,withs,noneOn,exclusion,exists,nowOn,nones,noneIds,ban} = this.state;
     /*if(this.props.selecteds)
     console.log(exists,this.props.selecteds.exists,exists===this.props.selecteds.exists)*/

+ 1 - 1
src/containers/SpreadDrop.js

@@ -15,7 +15,7 @@ import {Notify} from '@commonComp';
 import {filterArr,didPushParamChange} from '@utils/tools.js';
 import config from '@config/index.js';
 
-function mapStateToProps(state) {//console.log(123,state);
+function mapStateToProps(state) {
   return {
     mainSaveText:state.mainSuit.saveText,
   }