index.jsx 6.0 KB

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