index.jsx 13 KB

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