index.jsx 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. class AddAssistCheck extends React.Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. show: false,
  12. date: false,
  13. dateTime: "",
  14. active: '',
  15. visible: false,
  16. id: null
  17. }
  18. this.handleShowDate = this.handleShowDate.bind(this)
  19. this.getCurrentDate = this.getCurrentDate.bind(this)
  20. this.getSearchList = this.getSearchList.bind(this)
  21. this.getAssistLabel = this.getAssistLabel.bind(this)
  22. this.handleDelClick = this.handleDelClick.bind(this)
  23. this.delConfirm = this.delConfirm.bind(this)
  24. this.handleCancel = this.handleCancel.bind(this)
  25. }
  26. handleDelClick(id) {
  27. this.setState({
  28. visible: true,
  29. id: id
  30. })
  31. }
  32. delConfirm() {
  33. const { handleDelAssist, handlePush } = this.props;
  34. const { id } = this.state;
  35. handleDelAssist && handleDelAssist(id);
  36. handlePush && handlePush(); //右侧推送
  37. this.setState({
  38. visible: false,
  39. id: null
  40. })
  41. Notify.success("删除成功");
  42. }
  43. handleCancel() {
  44. this.setState({
  45. visible: false,
  46. id: null
  47. })
  48. }
  49. componentDidMount() {
  50. $(document).click((event) => {
  51. let _con = $('#searchWrapAssist'); // 设置目标区域
  52. let _cons = $('#datePick'); // 设置目标区域
  53. if (_con && searchWrapAssist != event.target && !_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1
  54. this.setState({ show: false });
  55. }
  56. if (!_cons.is(event.target) && _cons.has(event.target).length === 0) { // Mark 1
  57. this.setState({ date: false });
  58. }
  59. });
  60. this.getCurrentDate();
  61. }
  62. handleSearchShow(e) {
  63. let tmpShow = this.state.show;
  64. this.setState({ show: !tmpShow })
  65. // e.stopPropagation();
  66. }
  67. handleShowDate(idx) {
  68. this.setState({
  69. date: !this.state.date,
  70. active: idx
  71. })
  72. }
  73. getCurrentDate() {
  74. let myDate = new Date();
  75. let year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  76. let mon = myDate.getMonth() - 0 + 1; //获取当前月份(0-11,0代表1月)
  77. let day = myDate.getDate(); //获取当前日(1-31)
  78. let date = year + '-' + (mon < 10 ? '0' + mon : mon) + '-' + (day < 10 ? '0' + day : day);
  79. this.setState({ dateTime: date })
  80. }
  81. getSearchList(list) { //搜索列表
  82. const { handleSign } = this.props;
  83. return <ul className={styles.searchLiUl}>
  84. {
  85. list && list.map((item, idx) => {
  86. return <li key={item.id}
  87. className={styles.searchLi}
  88. title={item.name}
  89. onClick={() => {
  90. handleSign(item.questionId, idx,'search');
  91. this.setState({ show: false })
  92. }}
  93. >
  94. {item.name}{item.name == item.retrievalName ? null : '(' + item.retrievalName + ')'}
  95. </li>
  96. })
  97. }
  98. </ul>
  99. }
  100. getCommonList() { //常用列表
  101. const { handleSign,assistList } = this.props;
  102. return <ul className={styles.searchLiUl}>
  103. {
  104. assistList && assistList.map((item, idx) => {
  105. return <li key={item.id}
  106. className={styles.searchLi}
  107. title={item.name}
  108. onClick={() => {
  109. handleSign(item.questionId, idx,'common');
  110. this.setState({ show: false })
  111. }}
  112. >
  113. {item.name}
  114. </li>
  115. })
  116. }
  117. </ul>
  118. }
  119. getAssistLabel() {
  120. const { assistLabel, handleChangeAssistValue, handleChangeDate, isRead, handlePush, winWidth,getInfomation } = this.props;
  121. return <ul className={styles.labelWrap} id="datePick">
  122. {
  123. assistLabel.map((item, idx) => {
  124. return (<li key={item.id} className={styles.assistLists}>
  125. <span className={styles.assistName} style={{ width: winWidth < 1200 ? '120px' : 'auto' }}>
  126. <span className={styles.tagSpan}>
  127. {item.name}:
  128. <span className={styles.imgInfo} onClick={()=>getInfomation(item.questionId,item.name)}></span>
  129. </span>
  130. </span>
  131. <div className={styles.textareaWrap}>
  132. <Textarea value={item.value} handlePush={handlePush} isRead={isRead} handleChangeAssistValue={handleChangeAssistValue} idx={idx}></Textarea>
  133. </div>
  134. <div className={styles.pointerFinger}>
  135. <p onClick={() => this.handleShowDate(idx)}>报告日期:<span>{item.time || this.state.dateTime}</span></p>
  136. <i onClick={() => this.handleShowDate(idx)}></i>
  137. <a href="javascript:void(0);" onClick={() => { this.handleDelClick(idx) }}><img src={close} alt="" /></a>
  138. <div style={{ display: this.state.date && idx == this.state.active ? "block" : "none", position: "relative" }}>
  139. <Calendar isShow={true} handleChange={(info) => { handleChangeDate(info, idx); this.setState({ date: false }) }}></Calendar>
  140. </div>
  141. </div>
  142. </li>)
  143. })
  144. }
  145. </ul>
  146. }
  147. render() {
  148. const { handleChangeValue, list } = this.props;
  149. const { visible } = this.state;
  150. return (
  151. <div className={styles.wrapper}>
  152. {this.getAssistLabel()}
  153. <div id="searchWrapAssist" style={{ position: "relative", clear: 'both' }}>
  154. <Add showText="添加辅检项" handleClick={(e) => this.handleSearchShow(e)} id="assistCheck" />
  155. {this.state.show ? <SearchOption handleChangeValue={handleChangeValue} visible={true}>
  156. {list && list.length>0?this.getSearchList(list):''}
  157. {
  158. list && list.length>0?'':<div>
  159. <p style={{padding:'5px 30px',color:'#bfbfbf'}}>常用辅检项</p>
  160. {
  161. this.getCommonList()
  162. }
  163. </div>
  164. }
  165. </SearchOption> : ''}
  166. </div>
  167. <ConfirmModal
  168. visible={visible}
  169. confirm={this.delConfirm}
  170. close={this.handleCancel}
  171. cancel={this.handleCancel}
  172. okText="删除"
  173. cancelText='取消'
  174. okBorderColor={'#3B9ED0'}
  175. okColor={'#fff'}
  176. oKBg={'#3B9ED0'}
  177. >
  178. <p className={styles['center']}>是否删除该辅检项?</p>
  179. </ConfirmModal>
  180. </div>
  181. )
  182. }
  183. }
  184. export default AddAssistCheck;