index.jsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import React, { Component } from "react";
  2. import $ from 'jquery';
  3. class SlideIpt extends Component {
  4. constructor(props) {
  5. super(props);
  6. this.state = {
  7. show:false,
  8. activeInd:false,
  9. activeName:'',
  10. canEdit:true,
  11. style:'',
  12. value:''
  13. };
  14. this.setEdit = this.setEdit.bind(this);
  15. this.handleBlur = this.handleBlur.bind(this);
  16. }
  17. componentDidMount(){
  18. const {item} = this.props
  19. this.setState({value:item.time})
  20. }
  21. handleInput(e,item,sign){
  22. e.stopPropagation();
  23. const {setTipValue} = this.props
  24. setTipValue(item,e.target.value,sign)
  25. }
  26. handleInputTime(e){
  27. this.setState({value:e.target.value})
  28. }
  29. handleBlur(e,item,sign){
  30. const {handlePush,setTipValue} = this.props;
  31. $('.canEdit').attr('disabled','disabled')
  32. setTipValue(item,e.target.value,sign)
  33. handlePush && handlePush({mode:8}); //右侧推送
  34. }
  35. setEdit(e){
  36. // $('.canEdit').blur().attr('disabled','disabled')
  37. $(e.target).removeAttr('disabled').focus()
  38. }
  39. render() {
  40. const {item,idx} = this.props;
  41. return (
  42. <input disabled="disabled" type="text"
  43. class="canEdit"
  44. onDoubleClick={(e)=>this.setEdit(e)}
  45. style={{color:'#333'}}
  46. placeholder='时间'
  47. autoComplete="off"
  48. value={this.state.value}
  49. onInput={(e)=>{this.handleInputTime(e)}}
  50. onBlur={(e)=>{this.handleBlur(e,item,1,idx)}}
  51. />
  52. );
  53. }
  54. }
  55. export default SlideIpt;