Browse Source

Merge branch 'dev/byll' into dev/new1

Luolei 6 years ago
parent
commit
9318dc7304
2 changed files with 21 additions and 11 deletions
  1. 18 10
      src/common/components/SearchOption/index.jsx
  2. 3 1
      src/components/PreviewBody/index.jsx

+ 18 - 10
src/common/components/SearchOption/index.jsx

@@ -18,6 +18,8 @@ class SearchOption extends React.Component {
         }
         this.textInput = React.createRef();
         this.handleClearVal = this.handleClearVal.bind(this);
+        this.handleFocus = this.handleFocus.bind(this);
+        this.handleBlur = this.handleBlur.bind(this);
     }
     
     /*componentWillReceiveProps(nextProps){
@@ -47,19 +49,31 @@ class SearchOption extends React.Component {
         handleChangeValue('');
     }
     handleInput(e){
+      const { handleChangeValue } = this.props;
       if((e.target.value).trim() != ''){
-          this.props.handleChangeValue(e.target.value);
+          handleChangeValue(e.target.value);
           this.setState({
               val:e.target.value,
               show:true
           })
       }else{
-          this.handleClearVal()
+          // this.handleClearVal()
           this.setState({
               show:false
           })
+          return;
       }
     }
+    handleFocus(){
+      if(this.state.val.trim() != ''){
+        return;
+      }else{
+          this.setState({border:true})
+      }
+    }
+    handleBlur(){
+      this.setState({border:false,val:''})
+    }
     render() {
         const { children,visible } = this.props;
         const { show } = this.state;
@@ -72,14 +86,8 @@ class SearchOption extends React.Component {
                     type="text"
                     maxLength="30"
                     ref={this.textInput}
-                    onFocus={()=>{
-                        if(this.state.val.trim() != ''){
-                            
-                        }else{
-                            this.setState({border:true})
-                        }
-                    }}
-                    onBlur={()=>{this.setState({border:false,val:''})}}
+                    onFocus={this.handleFocus}
+                    onBlur={this.handleBlur}
                     onInput={(e) => { 
                         this.handleInput(e)
                     }}

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

@@ -289,7 +289,9 @@ class PreviewBody extends Component {
                 background: '#3B9ED0',
                 color: '#fff',
                 borderRadius: '4px',
-                cursor: 'pointer'
+                cursor: 'pointer',
+                position:'absolute',
+                right:'40px'
             }}>打印</div>
         </div>
     }