소스 검색

火狐时间选择器兼容

liucf 5 년 전
부모
커밋
e2202d737e
4개의 변경된 파일18개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 0
      src/components/MainSuit/index.jsx
  2. 3 1
      src/components/RadioInpDrop/index.jsx
  3. 9 3
      src/components/TimeInterval/index.jsx
  4. 5 4
      src/utils/tools.js

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

@@ -163,6 +163,7 @@ class MainSuit extends Component{
       }
       ev.target.blur();
       ev.target.innerText?(ev.target.innerText = data.substr(0,config.limited)):(ev.target.innerHTML = data.substr(0,config.limited));  //输入法内输入多个字再按enter的情况
+      console.log(333,data,ev)
       // ev.target.blur();
       this.setState({
         inpText:data.substr(0,config.limited),

+ 3 - 1
src/components/RadioInpDrop/index.jsx

@@ -196,11 +196,12 @@ class RadioInpDrop extends Component{
     if(!show&&tmpDom){
       $(tmpDom).parent().parent().prev().attr({"contentEditable":true})
     }
+    // 移除双击编辑 onDoubleClick={hideTag?null:this.handledbClick}
     return <div className={style['container']} ref = {this.$cont}>
       <div className={this.getClass()}
            onBlur={this.handleEditLabel}
            contentEditable={this.state.editable}
-           onDoubleClick={hideTag?null:this.handledbClick}
+           
            onClick={(e)=>this.handleShow(e,true)}
            onKeyDown={handleEnter}>
         {vals?this.parseInputDom():<span>{placeholder}</span>}
@@ -231,6 +232,7 @@ class InputComp extends Component{
       const inp = this.$inp.current;
       const value = this.props.value;
       setTimeout(function(){
+        inp.innerText?(inp.innerText = ''):(inp.innerHTML = '');
         inp.innerText?(inp.innerText = value):(inp.innerHTML = value);
       })
     }

+ 9 - 3
src/components/TimeInterval/index.jsx

@@ -60,8 +60,11 @@ class TimeInterval extends React.Component {
     const { getStartTime, getEndTime } = this.props;
     if (this.state.flg == 1) {
       let time = getCalendarDate(date, true);
-      let dateBegin = (new Date(time)).getTime()
-      let dateEnd = (new Date(this.state.endTime)).getTime()
+      let dateBegin = (new Date(time)).getTime();
+      let arr = this.state.endTime.replace(/ |:/g, '-').split('-');
+      let date11 = new Date(Date.UTC(arr[0], arr[1], arr[2], arr[3],arr[4]));
+      // let dateEnd = (new Date(this.state.endTime)).getTime()
+      let dateEnd = date11.getTime()
       let dateDes = (dateEnd - dateBegin)/(24 * 3600 * 1000)
       if(dateEnd < dateBegin){
         Notify.info("终止时间不能早于起始时间");
@@ -79,7 +82,10 @@ class TimeInterval extends React.Component {
 
     } else if (this.state.flg == 2) {
       let time = getCalendarDate(date, true);
-      let dateBegin = (new Date(this.state.startTime)).getTime()
+      // let dateBegin = (new Date(this.state.startTime)).getTime()
+      let arr = this.state.endTime.replace(/ |:/g, '-').split('-');
+      let date11 = new Date(Date.UTC(arr[0], arr[1], arr[2], arr[3],arr[4]));
+      let dateBegin = date11.getTime()
       let dateEnd = (new Date(time)).getTime()
       let dateDes = (dateEnd - dateBegin)/(24 * 3600 * 1000)
       if(dateEnd < dateBegin){

+ 5 - 4
src/utils/tools.js

@@ -1179,11 +1179,12 @@ function getCalendarDate(info,flg,con) {
   let date = '';
   let time = flg?flg:false;
   let conect = con?con:'-';
-  if(time){
+  //FF26和IE不兼容padStart
+  /*if(time){
     date = info.year + conect + (info.month).toString().padStart(2,'0') + conect + (info.day).toString().padStart(2,'0') + ' '+(info.hour).toString().padStart(2,'0')+':'+(info.minute).toString().padStart(2,'0')+':'+(info.second).toString().padStart(2,'0');
-  }else{
-    date = info.year + conect + (info.month < 10 ? '0' + info.month : info.month) + conect + (info.day < 10 ? '0' + info.day : info.day);
-  }
+  }else{*/
+    date = info.year + conect + (info.month < 10 ? '0' + info.month : info.month) + conect + (info.day < 10 ? '0' + info.day : info.day) + ' '+ (info.hour < 10 ? '0' + info.hour : info.hour)+':'+ (info.minute < 10 ? '0' + info.minute : info.minute)+':'+ (info.second < 10 ? '0' + info.second : info.second);
+  // }
   return date;
 }