index.jsx 5.5 KB

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