index.jsx 7.7 KB

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