index.jsx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import React, { Component } from "react";
  2. import styles from "./index.less";
  3. import { Notify,DelToast} from '@commonComp';
  4. import config from '@config/index';
  5. import $ from 'jquery';
  6. import checkOff from '@common/images/check_off.png';
  7. import checkOn from '@common/images/check_on.png';
  8. import dowm from '../img/down.png';
  9. import SlideIpt from '../SlideIpt';
  10. import SearchSelect from '../SearchSelect';
  11. import singleB from '../img/singleB.png';
  12. import singleL from '../img/singleL.png';
  13. class SlidePic extends Component {
  14. constructor(props) {
  15. super(props);
  16. this.state = {
  17. show:false,
  18. activeInd:false,
  19. selectShow:false,
  20. activeName:'',
  21. canEdit:true,
  22. style:''
  23. };
  24. this.handleDel = this.handleDel.bind(this);
  25. this.handleCancel = this.handleCancel.bind(this);
  26. this.delConfirm = this.delConfirm.bind(this);
  27. this.setEdit = this.setEdit.bind(this);
  28. this.handleBlur = this.handleBlur.bind(this);
  29. this.checkOnOff = this.checkOnOff.bind(this);
  30. }
  31. componentDidMount() {
  32. $(document).click((event) => {
  33. if($(event.target).attr("id")!='addClose'&&$(event.target).attr("id")!='delTit'){
  34. this.setState({
  35. activeInd:false
  36. })
  37. }
  38. if($(event.target).attr("id")!='selectJiType'&&$(event.target).attr("id")!='selectJiTypeWrap'){
  39. const {handleSelectShow,idx,item} = this.props;
  40. item.flg==5&&handleSelectShow(idx,0)
  41. }
  42. });
  43. }
  44. handleDel(time){
  45. const {handleDelClick,item} = this.props;
  46. this.setState({
  47. activeInd:true,
  48. activeName:item.detailName,
  49. })
  50. handleDelClick&&handleDelClick(1,time);
  51. }
  52. handleCancel(){
  53. this.setState({
  54. activeInd:false,
  55. activeName:''
  56. })
  57. }
  58. delConfirm(item,idx){
  59. const {handleDelConfirm,handlePush} = this.props;
  60. handleDelConfirm&&handleDelConfirm(item,idx);
  61. Notify.success("删除成功");
  62. handlePush && handlePush({mode:8}); //右侧推送
  63. this.setState({
  64. activeInd:false,
  65. activeName:''
  66. })
  67. }
  68. handleInput(e,item,sign,tip){
  69. e.stopPropagation();
  70. const {setTipValue,handlePush} = this.props
  71. setTipValue(item,e.target.value,sign,tip)
  72. //右侧推送--延时推送
  73. const stimer = this.state.timer;
  74. clearTimeout(stimer);
  75. let timer = setTimeout(function(){
  76. handlePush&&handlePush({mode:8});
  77. clearTimeout(stimer);
  78. },config.delayPushTime);
  79. this.setState({timer})
  80. }
  81. handleBlur(){
  82. const {handlePush} = this.props;
  83. $('.canEdit').attr('disabled','disabled')
  84. handlePush && handlePush({mode:8}); //右侧推送
  85. }
  86. checkOnOff(item,idx){
  87. const {checkOnOff,handlePush} = this.props
  88. checkOnOff(item,idx)
  89. handlePush && handlePush({mode:8}); //右侧推送
  90. }
  91. setEdit(e){
  92. // $('.canEdit').blur().attr('disabled','disabled')
  93. $(e.target).removeAttr('disabled').focus()
  94. }
  95. handleFocus(){
  96. const {handlePush} = this.props;
  97. handlePush&&handlePush({mode:8});
  98. }
  99. handleSui(item,idx){
  100. const {handleSuiFang,handlePush} = this.props;
  101. handleSuiFang&&handleSuiFang(item,idx)
  102. handlePush&&handlePush({mode:8});
  103. }
  104. render() {
  105. const {item,time,setTipValue,idx,handlePush,hosId,selectJiType} = this.props;
  106. const {selectShow,activeInd,activeName,value,style} = this.state;
  107. return (
  108. <li key={item.time} className={`${styles.slideLi} clearfix`}>
  109. <img className={styles.imgCheck} src={item.check?checkOn:checkOff} onClick={()=>this.checkOnOff(item,idx)} alt=""/>
  110. <span className={styles.bigname} title={item.detailName}>{item.detailName}</span>
  111. <span className={styles.smallname}>{item.flg == 5?'药品':item.flg == 6?'手术/操作':'输血'}</span>
  112. {hosId===-1?<SearchSelect title='选择剂型' hosId={hosId} selected={item.form} type={15} selectJiType={selectJiType} handlePush={handlePush} idx={idx}></SearchSelect>:''}
  113. <SearchSelect title='选择给药途径' hosId={hosId} selected={item.routeName} type={16} selectJiType={selectJiType} handlePush={handlePush} idx={idx}></SearchSelect>
  114. <span className={styles.edit}>
  115. {
  116. item.flg == 5||item.flg == 8?
  117. <input type="text"
  118. class="canEdit"
  119. style={{color:'#333'}}
  120. placeholder='(填写用量)'
  121. autoComplete="off"
  122. value={item.value}
  123. title={item.value}
  124. onInput={(e)=>{this.handleInput(e,item,2,idx)}}
  125. onFocus={()=>{this.handleFocus()}}
  126. />:<span onClick={()=>this.handleSui(item,idx)} className={styles.suifang}>
  127. <img src={item.hasTreat?singleB:singleL} alt=""/>
  128. 随访计划
  129. </span>
  130. }
  131. </span>
  132. <span className={styles.pass}>
  133. <SlideIpt item={item} setTipValue={setTipValue} handlePush={handlePush} idx={idx}/>
  134. </span>
  135. <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item.time)}}></span>
  136. <DelToast show={time==item.time&&activeInd?true:false}
  137. name={activeName}
  138. right={'-34px'}
  139. top={'30px'}
  140. cancel={this.handleCancel}
  141. confirm={()=>{this.delConfirm(item,idx)}}/>
  142. </li>
  143. );
  144. }
  145. }
  146. export default SlidePic;