index.jsx 5.7 KB

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