index.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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 AssistName from './AssistName';
  7. import { getPageCoordinate,getCurrentDate,setPosition } from '@utils/tools';
  8. import ScrollArea from 'react-scrollbar';
  9. class AddAssistCheck extends React.Component {
  10. constructor(props) {
  11. super(props);
  12. this.state = {
  13. show: false,
  14. date: false,
  15. dateTime: "",
  16. active: '',
  17. visible: false,
  18. pageTop:'',
  19. id: null,
  20. activeName:''
  21. }
  22. this.handleShowDate = this.handleShowDate.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. this.timeSure = this.timeSure.bind(this)
  29. }
  30. componentDidMount() {
  31. $(document).click((event) => {
  32. let _con = $('#searchWrapAssist'); // 设置目标区域
  33. let _cons = $('#datePick'); // 设置目标区域
  34. // let _conClick = $('#assistCheck'); // 点击的按钮
  35. let _del = document.getElementById("delBox"); // 删除弹窗
  36. let _close = document.getElementById("assiClose"); // 删除icon
  37. let _closeTil = $('#delTit')[0]; // 弹窗标题
  38. if(!this.isBar) {//onMousedown的目标为滚动条时,子项弹窗不关闭)
  39. if (_con && searchWrapAssist != event.target && !_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1
  40. if (this.state.show) {
  41. this.props.setHighter(48)
  42. }
  43. this.setState({show: false});
  44. }
  45. if (!_cons.is(event.target) && _cons.has(event.target).length === 0 || event.target.isEqualNode(_close)) { // Mark 1
  46. this.setState({date: false});
  47. }
  48. if($(event.target).attr("contenteditable")||event.target.textContent == '报告描述或意见'){
  49. this.setState({date: false});
  50. }
  51. if(_del){
  52. if($(event.target).attr('id') != 'assiClose' &&!event.target.isEqualNode(_close) && !event.target.isEqualNode(_del) && event.target.parentNode != _del && !event.target.isEqualNode(_closeTil)){
  53. this.setState({
  54. visible: false,
  55. id: null,
  56. activeName:''
  57. })
  58. }
  59. }
  60. }
  61. });
  62. const that = this;
  63. document.addEventListener('mousedown',function(e){
  64. //onMousedown的目标为滚动条时,标签填写单不关闭
  65. if(e.target.className=='scrollbar'){
  66. that.isBar = true;
  67. }else{
  68. that.isBar = false;
  69. }
  70. });
  71. getCurrentDate(1);
  72. }
  73. handleDelClick(id,item) {
  74. this.setState({
  75. visible: true,
  76. id: id,
  77. activeName:item.name
  78. })
  79. }
  80. delConfirm(type) {
  81. const { handleDelAssist, handlePush } = this.props;
  82. const { id,activeName } = this.state;
  83. $(".TextareaRsize").css({marginTop:0});
  84. handleDelAssist && handleDelAssist(id,activeName,type);
  85. handlePush && handlePush(); //右侧推送
  86. this.setState({
  87. visible: false,
  88. id: null,
  89. activeName:''
  90. })
  91. Notify.success("删除成功");
  92. }
  93. handleCancel() {
  94. this.setState({
  95. visible: false,
  96. id: null,
  97. activeName:''
  98. })
  99. }
  100. handleSearchShow(e) {
  101. let tmpShow = this.state.show;
  102. this.setState({ show: !tmpShow,pageTop:getPageCoordinate(e).boxTop })
  103. // e.stopPropagation();
  104. if(tmpShow){
  105. this.props.setHighter(48)
  106. }else{
  107. setPosition(e,"#searchOption",this.props.setHighter)
  108. }
  109. }
  110. handleShowDate(idx) {
  111. this.setState({
  112. date: !this.state.date,
  113. active: idx
  114. })
  115. }
  116. getSearchList(list) { //搜索列表
  117. const { handleSign } = this.props;
  118. const contStyle={
  119. opacity:'0.4',
  120. right:'0',
  121. top:'1px',
  122. zIndex:'15',
  123. width:'14px',
  124. background:'#f1f1f1'};
  125. const barStyle={background:'#777',width:'100%'};
  126. return <ScrollArea speed={0.8}
  127. horizontal={false}
  128. stopScrollPropagation={list.length>6?true:false}
  129. style={{height:'225px'}}
  130. className={styles["area"]}
  131. verticalContainerStyle={contStyle}
  132. verticalScrollbarStyle={barStyle}
  133. contentClassName="content">
  134. <ul className={styles.searchLiUl}>
  135. {
  136. list && list.map((item, idx) => {
  137. return <li key={item.id}
  138. className={styles.searchLi}
  139. title={(item.name == item.retrievalName || !item.retrievalName) ? null : '(' + item.retrievalName + ')'}
  140. onClick={() => {
  141. this.props.setHighter(48)
  142. handleSign(item.conceptId,idx,'search');
  143. this.setState({ show: false })
  144. }}
  145. >
  146. {item.name}{(item.name == item.retrievalName || !item.retrievalName) ? null : '(' + item.retrievalName + ')'}
  147. </li>
  148. })
  149. }
  150. </ul></ScrollArea>;
  151. }
  152. getCommonList() { //常用列表
  153. const { handleSign,assistList } = this.props;
  154. return <ul className={styles.searchLiUl}>
  155. {
  156. assistList && assistList.map((item, idx) => {
  157. return <li key={item.id}
  158. className={styles.searchLi}
  159. title={item.name}
  160. onClick={() => {
  161. this.props.setHighter(48)
  162. handleSign(item.conceptId, idx,'common');
  163. this.setState({ show: false })
  164. }}
  165. >
  166. {item.name}
  167. </li>
  168. })
  169. }
  170. </ul>
  171. }
  172. handleChangeDate(){}
  173. timeSure(date,idx){
  174. this.props.handleChangeDate(date,idx)
  175. this.setState({ date: false })
  176. }
  177. getAssistLabel() {
  178. const { assistLabel,checkedListImport, handleChangeAssistValue, handleChangeDate, isRead, handlePush, winWidth,getInfomation,assistList } = this.props;
  179. const { visible,activeName,id,date } = this.state;
  180. //出现滚动条时阻止滚动冒泡,未出现时不阻止,否则外部滚动条滚不动
  181. const showedBar = $("#datePick .scrollbar-container").length===1;
  182. const contStyle={
  183. opacity:'0.4',
  184. right:'0',
  185. top:'1px',
  186. zIndex:'1',
  187. width:'8px',
  188. background:'#f1f1f1'};
  189. const barStyle={background:'#777',width:'100%'};
  190. return <React.Fragment>
  191. {
  192. checkedListImport.map((part,index)=>{
  193. return <ul className={`${styles.labelWrap} ${styles.labelWrapSpec} ${styles.labelWrapSpecs}`}>
  194. {
  195. part.map((item, idx) => {
  196. return (<li className={`${styles.assistLists} ${styles.clearfix}`}>
  197. {/* <span className={styles.assistName} style={{ width: winWidth<1200?'120px':'auto' }}>
  198. <span className={styles.tagSpan}>
  199. {item.name}:
  200. <span className={styles.imgInfo} title='点击i图标可查看详细说明' onClick={()=>getInfomation({name: item.name, position: 1, type: 6})}></span>
  201. </span>
  202. </span> */}
  203. <AssistName name={item.name} winWidth={winWidth} getInfomation={getInfomation}></AssistName>
  204. <div className={styles.textareaWrap}>
  205. <ScrollArea speed={0.8}
  206. horizontal={false}
  207. stopScrollPropagation={showedBar?true:false}
  208. style={{maxHeight:'100px'}}
  209. className={styles["area"]}
  210. verticalContainerStyle={contStyle}
  211. verticalScrollbarStyle={barStyle}
  212. contentClassName="content">
  213. <Textarea value={item.value} disabled={item.disabled} handlePush={handlePush} isRead={isRead} handleChangeAssistValue={handleChangeAssistValue} idx={idx}></Textarea>
  214. </ScrollArea>
  215. </div>
  216. <div className={styles.pointerFinger}>
  217. <p>报告日期:<span>{item.time || this.state.dateTime}</span></p>
  218. </div>
  219. </li>)
  220. })
  221. }
  222. <DelToast show={index==id&&part.name==activeName?visible:false}
  223. name="该导入项"
  224. right={'-34px'}
  225. top={'22px'}
  226. cancel={this.handleCancel}
  227. confirm={()=>this.delConfirm(0)}/>
  228. <span className={`${styles.closeIcon} ${styles.closeIcons}`} id="assiClose" onClick={()=>{ this.handleDelClick(index,part)}}></span>
  229. </ul>
  230. })
  231. }
  232. <ul className={styles.labelWrap} id="datePick">
  233. {
  234. assistLabel.map((item, idx) => {
  235. let staticTime = {}
  236. if(item.time){
  237. let tmp1 = (item.time).split(' ')[0].split('-')
  238. let tmp2 = (item.time).split(' ').length>1&&(item.time).split(' ')[1].split(':')
  239. staticTime = {
  240. year: tmp1[0]-0,
  241. month: tmp1[1]-0,
  242. day: tmp1[2]-0,
  243. hour: tmp2[0],
  244. minute: tmp2[1],
  245. second: tmp2[2]
  246. }
  247. }
  248. return (item.disabled?null:<li className={`${styles.assistLists} ${styles.clearfix}`}>
  249. {/* <span className={styles.assistName} style={{ width: winWidth<1200?'120px':(winWidth-987)+'px' }}> */}
  250. {/* <span className={styles.assistName} style={{ width: winWidth<1200?'120px':'auto' }}>
  251. <span className={styles.tagSpan}>
  252. {item.name}:
  253. <span className={styles.imgInfo} title='点击i图标可查看详细说明' onClick={()=>getInfomation({name: item.name, position: 1, type: 6})}></span>
  254. </span>
  255. </span> */}
  256. <AssistName name={item.name} winWidth={winWidth} getInfomation={getInfomation}></AssistName>
  257. <div className={styles.textareaWrap}>
  258. <ScrollArea speed={0.8}
  259. horizontal={false}
  260. stopScrollPropagation={showedBar?true:false}
  261. style={{maxHeight:'100px'}}
  262. className={styles["area"]}
  263. verticalContainerStyle={contStyle}
  264. verticalScrollbarStyle={barStyle}
  265. contentClassName="content TextareaRsize">
  266. <Textarea value={item.value} disabled={item.disabled} handlePush={handlePush} isRead={isRead} handleChangeAssistValue={handleChangeAssistValue} idx={idx}></Textarea>
  267. </ScrollArea>
  268. </div>
  269. <div className={styles.pointerFinger}>
  270. <p onClick={() => this.handleShowDate(idx)}>报告日期:<span>{item.time || this.state.dateTime}</span></p>
  271. <i onClick={() => this.handleShowDate(idx)}></i>
  272. {/*<a href="javascript:void(0);" onClick={() => { this.handleDelClick(idx,item) }}><img src={close} alt="" /></a>*/}
  273. <span className={styles.closeIcon} id="assiClose" onClick={() => { this.handleDelClick(idx,item) }}></span>
  274. {
  275. this.state.date && idx == this.state.active ?<Calendar timeLis={staticTime} isShow={true} timeSure={(date)=>this.timeSure(date,idx)} needTime={true} sure={true} handleChange={(info) => { this.handleChangeDate(info, idx) }} top={30}></Calendar>:null
  276. }
  277. </div>
  278. <DelToast show={idx==id&&item.name==activeName?visible:false}
  279. name={activeName}
  280. right={'-34px'}
  281. top={'40px'}
  282. cancel={this.handleCancel}
  283. confirm={()=>this.delConfirm(1)}/>
  284. {/* {
  285. id == null?null:<DelToast show={idx==id&&item.name==activeName?visible:false}
  286. name={activeName}
  287. cancel={this.handleCancel}
  288. confirm={this.delConfirm}/>
  289. } */}
  290. </li>)
  291. })
  292. }
  293. </ul>
  294. </React.Fragment>
  295. }
  296. render() {
  297. const { handleChangeValue, list,assistVal,windowHeight,assistList, refreshScroller } = this.props;
  298. const { visible,pageTop } = this.state;
  299. const contStyle={
  300. opacity:'0.4',
  301. right:'0',
  302. top:'1px',
  303. zIndex:'15',
  304. width:'14px',
  305. background:'#f1f1f1'};
  306. const barStyle={background:'#777',width:'100%'};
  307. return (
  308. <div className={styles.wrapper}>
  309. {this.getAssistLabel()}
  310. <div id="searchWrapAssist" style={{ position: "relative", clear: 'both' }}>
  311. <Add showText="添加辅检项" handleClick={(e) => this.handleSearchShow(e)} id="assistCheck" />
  312. {this.state.show ? <SearchOption windowHeight={windowHeight} refreshScroller={refreshScroller } pageTop={pageTop} height={280} handleChangeValue={handleChangeValue} visible={true}>
  313. {list && list.length>0?this.getSearchList(list):(assistVal == ''?'':<p style={{padding:'5px 30px',color:'#bfbfbf'}}>暂无筛选项</p>)}
  314. {
  315. (list && list.length>0) || (assistVal != '') || (assistList&&assistList.length==0)?'':<div>
  316. <p style={{padding:'5px 30px',color:'#bfbfbf'}}>常用辅检项</p>
  317. <ScrollArea speed={0.8}
  318. horizontal={false}
  319. stopScrollPropagation={assistList.length>6?true:false}
  320. style={{height:'225px'}}
  321. className={styles["area"]}
  322. verticalContainerStyle={contStyle}
  323. verticalScrollbarStyle={barStyle}
  324. contentClassName="content">
  325. {
  326. this.getCommonList()
  327. }
  328. </ScrollArea>
  329. </div>
  330. }
  331. </SearchOption> : ''}
  332. </div>
  333. </div>
  334. )
  335. }
  336. }
  337. export default AddAssistCheck;