index.jsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import React, { Component } from "react";
  2. import styles from "./index.less";
  3. import { Notify,DelToast} from '@commonComp';
  4. import $ from 'jquery';
  5. import checkOff from '@common/images/check_off.png';
  6. import checkOn from '@common/images/check_on.png';
  7. import SlideIpt from '../SlideIpt';
  8. class SlidePic extends Component {
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. show:false,
  13. activeInd:false,
  14. activeName:'',
  15. canEdit:true,
  16. style:''
  17. };
  18. this.handleDel = this.handleDel.bind(this);
  19. this.handleCancel = this.handleCancel.bind(this);
  20. this.delConfirm = this.delConfirm.bind(this);
  21. this.setEdit = this.setEdit.bind(this);
  22. this.handleBlur = this.handleBlur.bind(this);
  23. this.checkOnOff = this.checkOnOff.bind(this);
  24. }
  25. componentDidMount() {
  26. $(document).click((event) => {
  27. if($(event.target).attr("id")!='addClose'&&$(event.target).attr("id")!='delTit'){
  28. this.setState({
  29. activeInd:false
  30. })
  31. }
  32. });
  33. }
  34. handleDel(time){
  35. const {handleDelClick,item} = this.props;
  36. this.setState({
  37. activeInd:true,
  38. activeName:item.uniqueName,
  39. })
  40. handleDelClick&&handleDelClick(1,time);
  41. }
  42. handleCancel(){
  43. this.setState({
  44. activeInd:false,
  45. activeName:''
  46. })
  47. }
  48. delConfirm(item,idx){
  49. const {handleDelConfirm,handlePush} = this.props;
  50. handleDelConfirm&&handleDelConfirm(item,idx);
  51. Notify.success("删除成功");
  52. handlePush && handlePush({mode:8}); //右侧推送
  53. this.setState({
  54. activeInd:false,
  55. activeName:''
  56. })
  57. }
  58. handleInput(e,item,sign){
  59. e.stopPropagation();
  60. const {setTipValue} = this.props
  61. setTipValue(item,e.target.value,sign)
  62. }
  63. handleBlur(){
  64. const {handlePush} = this.props;
  65. $('.canEdit').attr('disabled','disabled')
  66. handlePush && handlePush({mode:8}); //右侧推送
  67. }
  68. checkOnOff(item,idx){
  69. const {checkOnOff,handlePush} = this.props
  70. checkOnOff(item,idx)
  71. handlePush && handlePush({mode:8}); //右侧推送
  72. }
  73. setEdit(e){
  74. // $('.canEdit').blur().attr('disabled','disabled')
  75. $(e.target).removeAttr('disabled').focus()
  76. }
  77. render() {
  78. const {item,time,setTipValue,idx,handlePush} = this.props;
  79. const {canEdit,activeInd,activeName,value,style} = this.state;
  80. return (
  81. <li key={item.time} className={`${styles.slideLi} clearfix`}>
  82. <img className={styles.imgCheck} src={item.check?checkOn:checkOff} onClick={()=>this.checkOnOff(item,idx)} alt=""/>
  83. <span className={styles.bigname}>{item.name}</span>
  84. <span className={styles.smallname}>{item.flg == 5?'药品':item.flg == 6?'手术/操作':'输血'}</span>
  85. <span className={styles.edit}>
  86. {
  87. item.flg == 5||item.flg == 8?
  88. <input disabled='disabled' type="text"
  89. class="canEdit"
  90. onDoubleClick={(e)=>this.setEdit(e)}
  91. style={{color:'#333'}}
  92. placeholder={item.flg == 5?'(填写用法计量)':'(填写用量)'}
  93. autoComplete="off"
  94. value={item.value}
  95. onInput={(e)=>{this.handleInput(e,item,2,idx)}}
  96. onBlur={()=>{this.handleBlur()}}
  97. />:null
  98. }
  99. </span>
  100. <span className={styles.pass}>
  101. <SlideIpt item={item} setTipValue={setTipValue} handlePush={handlePush} idx={idx}/>
  102. </span>
  103. <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item.time)}}></span>
  104. <DelToast show={time==item.time&&activeInd?true:false}
  105. name={activeName}
  106. right={'-34px'}
  107. top={'30px'}
  108. cancel={this.handleCancel}
  109. confirm={()=>{this.delConfirm(item,idx)}}/>
  110. </li>
  111. );
  112. }
  113. }
  114. export default SlidePic;