index.jsx 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import React from 'react';
  2. import { SearchOption, Calendar ,ConfirmModal,Notify,Add} from '@commonComp';
  3. import styles from './index.less';
  4. import $ from 'jquery';
  5. import Textarea from './Textarea';
  6. import close from './img/close.png';
  7. import more from '@common/images/addItem1.png';
  8. class AddAssistCheck extends React.Component {
  9. constructor(props) {
  10. super(props);
  11. this.state = {
  12. show: false,
  13. date: false,
  14. dateTime:"",
  15. active:'',
  16. }
  17. this.handleShowDate = this.handleShowDate.bind(this)
  18. this.getCurrentDate = this.getCurrentDate.bind(this)
  19. this.getSearchList = this.getSearchList.bind(this)
  20. this.getAssistLabel = this.getAssistLabel.bind(this)
  21. }
  22. componentDidMount() {
  23. $(document).click((event) => {
  24. let _con = $('#searchWrapAssist'); // 设置目标区域
  25. let _cons = $('#datePick'); // 设置目标区域
  26. if (searchWrapAssist != event.target && !_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1
  27. this.setState({ show: false });
  28. }
  29. if (!_cons.is(event.target) && _cons.has(event.target).length === 0) { // Mark 1
  30. this.setState({ date: false });
  31. }
  32. });
  33. this.getCurrentDate();
  34. }
  35. handleSearchShow(e) {
  36. let tmpShow = this.state.show;
  37. this.setState({ show: !tmpShow })
  38. e.stopPropagation();
  39. }
  40. handleShowDate(idx){
  41. this.setState({
  42. date:!this.state.date,
  43. active:idx
  44. })
  45. }
  46. getCurrentDate(){
  47. let myDate = new Date();
  48. let year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  49. let mon = myDate.getMonth()-0+1; //获取当前月份(0-11,0代表1月)
  50. let day = myDate.getDate(); //获取当前日(1-31)
  51. let date = year+'-'+(mon<10?'0'+mon:mon)+'-'+(day<10?'0'+day:day);
  52. this.setState({dateTime:date})
  53. }
  54. getSearchList(list){ //搜索列表
  55. const {handleSign} = this.props;
  56. return <ul>
  57. {
  58. list && list.map((item) => {
  59. return <li key={item.id}
  60. className={styles.searchLi}
  61. title={item.name}
  62. onClick={() => {
  63. handleSign(item.questionId);
  64. this.setState({ show: false })
  65. }}
  66. >
  67. {item.name}{item.name == item.retrievalName?null:'('+item.retrievalName+')'}
  68. </li>
  69. })
  70. }
  71. </ul>
  72. }
  73. getAssistLabel(){
  74. const {assistLabel,handleDelAssist,handleChangeAssistValue,handleChangeDate,isRead} = this.props;
  75. return <ul className={styles.labelWrap} id="datePick">
  76. {
  77. assistLabel.map((item,idx) => {
  78. return (<li key={item.id}>
  79. <span style={{float:"left"}}>{item.name}:</span>
  80. <p style={{float:"none",overflow:"hidden",marginRight:"215px",paddingLeft:'8px'}}>
  81. {/* <textarea
  82. className={styles.divTextarea}
  83. onChange={(e)=>{
  84. handleChangeAssistValue(e.target.value,idx,e)
  85. if(e.target.value.trim() == '') {
  86. e.target.style.height = '18px';
  87. return;
  88. }
  89. e.target.style.height = e.targetv.scrollHeight+'px';
  90. }}
  91. value={item.value}
  92. // onFocus={(e)=>{e.target.style.height = e.target.scrollHeight+'px';}}
  93. onKeyUp={(e)=>{handleChangeAssistValue(e.target.value,idx,e)}}
  94. placeholder="报告描述或意见"
  95. ></textarea> */}
  96. <Textarea value={item.value} isRead={isRead} handleChangeAssistValue={handleChangeAssistValue} idx={idx}></Textarea>
  97. </p>
  98. <div className={styles.pointerFinger}>
  99. <p onClick={()=>this.handleShowDate(idx)}>报告日期:<span>{item.time || this.state.dateTime}</span></p>
  100. <i onClick={()=>this.handleShowDate(idx)}></i>
  101. <a href="javascript:void(0);" onClick={()=>{handleDelAssist(idx)}}><img src={close} alt=""/></a>
  102. <div style={{display:this.state.date && idx == this.state.active?"block":"none",position:"relative"}}>
  103. <Calendar isShow={true} handleChange={(info)=>{handleChangeDate(info,idx);this.setState({date:false})}}></Calendar>
  104. </div>
  105. </div>
  106. {/* <p className={styles.iptWrap}> */}
  107. {/* <input type="text" onChange={(e)=>{handleChangeAssistValue(e.target.value,idx)}} placeholder={"报告描述或意见"}/> */}
  108. {/* </p> */}
  109. </li>)
  110. })
  111. }
  112. </ul>
  113. }
  114. render() {
  115. const { handleChangeValue, list } = this.props;
  116. return (
  117. <div className={styles.wrapper}>
  118. {this.getAssistLabel()}
  119. <div id="searchWrapAssist" style={{position:"relative"}}>
  120. <Add showText="添加辅检项" handleClick={(e) => this.handleSearchShow(e)} id="assistCheck"/>
  121. <SearchOption handleChangeValue={handleChangeValue} visible={this.state.show}>
  122. {this.getSearchList(list)}
  123. </SearchOption>
  124. </div>
  125. </div>
  126. )
  127. }
  128. }
  129. export default AddAssistCheck;