index.jsx 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import React, { Component } from "react";
  2. import styles from "./index.less";
  3. import { normalVal,getArrow,timestampToTime,getDomUpDown,getPageCoordinate,setPosition,setFontColorSize } from '@utils/tools';
  4. import { InspectCommon, Notify,DelToast} from '@commonComp';
  5. import slideUp from "@common/images/slide-up.png";
  6. import slideDown from "@common/images/slide-down.png";
  7. import $ from 'jquery';
  8. import checkOff from '@common/images/check_off.png';
  9. import checkOn from '@common/images/check_on.png';
  10. import ScrollArea from 'react-scrollbar';
  11. import InspectName from '../InspectName';
  12. import up from '@images/up.png';
  13. import down from '@images/down.png';
  14. class SlidePic extends Component {
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. show:false,
  19. activeInd:false,
  20. activeName:'',
  21. canEdit:true,
  22. style:'',
  23. };
  24. this.toTime = this.toTime.bind(this);
  25. this.handleSlide = this.handleSlide.bind(this);
  26. this.handleDel = this.handleDel.bind(this);
  27. this.handleCancel = this.handleCancel.bind(this);
  28. this.delConfirm = this.delConfirm.bind(this);
  29. this.timeSure = this.timeSure.bind(this);
  30. this.setEdit = this.setEdit.bind(this);
  31. this.handleLabelSub = this.handleLabelSub.bind(this);
  32. this.handleBlur = this.handleBlur.bind(this);
  33. this.checkOnOff = this.checkOnOff.bind(this);
  34. }
  35. handleChangeDate(date) {
  36. // console.log(date,'外')
  37. }
  38. componentDidMount() {
  39. const {item} = this.props;
  40. $(document).click((event) => {
  41. if($(event.target).attr("id")!='addClose'&&$(event.target).attr("id")!='delTit'){
  42. this.setState({
  43. activeInd:false
  44. })
  45. }
  46. });
  47. let type = getArrow(item.minValue,item.maxValue,item.value||null)
  48. this.setState({style:type,value:item.value,time:item.time})
  49. const that = this;
  50. document.addEventListener('mousedown',function(e){
  51. //onMousedown的目标为滚动条时,标签填写单不关闭
  52. if(e.target.className=='scrollbar'){
  53. that.isBar = true;
  54. }else{
  55. that.isBar = false;
  56. }
  57. });
  58. // this.setState({ dateTime: getCurrentDate(1) })
  59. }
  60. toTime(time){
  61. let tmpTim = time.split(',').join('')-0
  62. if(time && tmpTim.toString() != 'NaN'){
  63. let date = new Date('1900-01-01');
  64. let dateTim = date.getTime();
  65. let times = (tmpTim-2)*24*60*60*1000;
  66. let result = timestampToTime(dateTim+times).split(' ')[0]
  67. return result;
  68. }else{
  69. return time;
  70. }
  71. }
  72. handleSlide(){
  73. let tmpShow = this.state.show
  74. this.setState({
  75. show:!tmpShow
  76. })
  77. }
  78. handleDel(time){
  79. const {handleDelClick,item} = this.props;
  80. this.setState({
  81. activeInd:true,
  82. activeName:item.uniqueName,
  83. })
  84. handleDelClick&&handleDelClick(1,time);
  85. }
  86. handleCancel(){
  87. this.setState({
  88. activeInd:false,
  89. activeName:''
  90. })
  91. }
  92. delConfirm(item){
  93. const {handleDelConfirm,handlePush} = this.props;
  94. handleDelConfirm&&handleDelConfirm(item);
  95. Notify.success("删除成功");
  96. handlePush && handlePush({mode:8}); //右侧推送
  97. this.setState({
  98. activeInd:false,
  99. activeName:''
  100. })
  101. }
  102. timeSure(date){
  103. const {handleChangeDate} = this.props;
  104. handleChangeDate&&handleChangeDate(date)
  105. }
  106. handleLabelSub(e,questionId,idx){
  107. const {handleLabelSub,handleFillShow,setHighter,refreshScroller} = this.props;
  108. handleLabelSub(e,questionId,idx);
  109. handleFillShow(e,idx);
  110. //弹窗高度超出屏幕,增加页面高度
  111. setPosition(e,"#inspectFill",setHighter);
  112. /*setTimeout(function(){//如果检验下面有很多数据,则会跳过头
  113. refreshScroller()&&refreshScroller().scrollYTo(290);
  114. })*/
  115. }
  116. handleInput(e,item,sign){
  117. const {setTipValue} = this.props
  118. setTipValue(item,e.target.value,sign)
  119. }
  120. handleBlur(){
  121. const {handlePush} = this.props;
  122. $('.canEdit').attr('disabled','disabled')
  123. handlePush && handlePush({mode:8}); //右侧推送
  124. }
  125. checkOnOff(item){
  126. const {checkOnOff,handlePush} = this.props
  127. checkOnOff(item)
  128. handlePush && handlePush({mode:8}); //右侧推送
  129. }
  130. setEdit(e){
  131. $('.canEdit').blur().attr('disabled','disabled')
  132. $(e.target).removeAttr('disabled').focus()
  133. }
  134. render() {
  135. const {item,time} = this.props;
  136. const {canEdit,activeInd,activeName,value,style} = this.state;
  137. return (
  138. <li key={item.time} className={`${styles.slideLi} clearfix`}>
  139. <img className={styles.imgCheck} src={item.check?checkOn:checkOff} onClick={()=>this.checkOnOff(item)} alt=""/>
  140. <span className={styles.bigname}>{item.name}</span>
  141. <span className={styles.smallname}>{item.flg == 5?'药品':'手术/操作'}</span>
  142. <span className={styles.edit}>
  143. {
  144. item.flg == 5?
  145. <input disabled='disabled' type="text"
  146. class="canEdit"
  147. onDoubleClick={(e)=>this.setEdit(e)}
  148. style={{color:style==2||style==4?'red':style==1?'#D949FF':'#333'}}
  149. placeholder='(填写用法计量)'
  150. autoComplete="off"
  151. value={item.value}
  152. onInput={(e)=>{this.handleInput(e,item,2)}}
  153. onBlur={()=>{this.handleBlur()}}
  154. />:null
  155. }
  156. </span>
  157. <span className={styles.pass}>
  158. <input disabled="disabled" type="text"
  159. class="canEdit"
  160. onDoubleClick={(e)=>this.setEdit(e)}
  161. style={{color:'#333'}}
  162. placeholder='时间'
  163. autoComplete="off"
  164. value={item.time}
  165. onInput={(e)=>{this.handleInput(e,item,1)}}
  166. onBlur={()=>{this.handleBlur()}}
  167. />
  168. </span>
  169. <span id="addClose" className={styles.partDel} onClick={()=>{this.handleDel(item.time)}}></span>
  170. <DelToast show={time==item.time&&activeInd?true:false}
  171. name={activeName}
  172. right={'-34px'}
  173. top={'30px'}
  174. cancel={this.handleCancel}
  175. confirm={()=>{this.delConfirm(item)}}/>
  176. </li>
  177. );
  178. }
  179. }
  180. export default SlidePic;