index.jsx 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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, setFontColorSize } 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 ($(event.target).attr('id')=='searchWrapAssist'||_con && _con != 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)&&!_conClick && _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({mode:9}); //右侧推送
  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. const { handlePush } = this.props;
  102. let tmpShow = this.state.show;
  103. this.setState({ show: !tmpShow,pageTop:getPageCoordinate(e).boxTop })
  104. // e.stopPropagation();
  105. if(tmpShow){
  106. this.props.setHighter(48)
  107. }else{
  108. setPosition(e,"#searchOption",this.props.setHighter)
  109. handlePush && handlePush({mode:9}); //右侧推送
  110. }
  111. }
  112. handleShowDate(idx) {
  113. this.setState({
  114. date: !this.state.date,
  115. active: idx
  116. })
  117. }
  118. handleSign(item,idx){
  119. const { handleSign,handlePush } = this.props;
  120. handleSign(item,idx)
  121. handlePush && handlePush({mode:8}); //右侧推送
  122. }
  123. getSearchList(list) { //搜索列表
  124. const contStyle={
  125. opacity:'0.4',
  126. right:'0',
  127. top:'1px',
  128. zIndex:'15',
  129. width:'14px',
  130. background:'#f1f1f1'};
  131. const barStyle={background:'#777',width:'100%'};
  132. return <ul className={`${styles.searchLiUl} ${styles.assistListUl}`} style={{height:'205px',width:'412px',overflow:'auto'}}>
  133. {
  134. list && list.map((item, idx) => {
  135. return <li key={item.id}
  136. className={styles.searchLi}
  137. title={item.name}
  138. onClick={() => {
  139. this.props.setHighter(96)
  140. this.handleSign(item,'search');
  141. this.setState({ show: false })
  142. }}
  143. >
  144. {item.name}
  145. </li>
  146. })
  147. }
  148. </ul>;
  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. this.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. setEdit(e){
  176. // $('.canEdit').blur().attr('disabled','disabled')
  177. $(e.target).removeAttr('disabled').focus()
  178. }
  179. handleBlur(){
  180. const {handlePush} = this.props;
  181. $('.canEdit').attr('disabled','disabled')
  182. handlePush && handlePush({mode:8}); //右侧推送
  183. }
  184. handleInput(e,item,idx){
  185. const {setTipValue} = this.props
  186. setTipValue(item,e.target.value,idx)
  187. }
  188. getAssistLabel() {
  189. const { assistLabel,checkedListImport, handleChangeAssistValue,checkOnOff, handleChangeDate, isRead, handlePush, winWidth,getInfomation,assistList } = this.props;
  190. const { visible,activeName,id,date } = this.state;
  191. //出现滚动条时阻止滚动冒泡,未出现时不阻止,否则外部滚动条滚不动
  192. const showedBar = $("#datePick .scrollbar-container").length===1;
  193. const contStyle={
  194. opacity:'0.4',
  195. right:'0',
  196. top:'1px',
  197. zIndex:'1',
  198. width:'8px',
  199. background:'#f1f1f1'};
  200. const barStyle={background:'#777',width:'100%'};
  201. return <React.Fragment>
  202. <ul className={styles.labelWrap} id="datePick">
  203. {
  204. assistLabel.map((item, idx) => {
  205. let staticTime = {}
  206. if(item.time){
  207. let tmp1 = (item.time).split(' ')[0].split('-')
  208. let tmp2 = (item.time).split(' ').length>1&&(item.time).split(' ')[1].split(':')
  209. staticTime = {
  210. year: tmp1[0]-0,
  211. month: tmp1[1]-0,
  212. day: tmp1[2]-0,
  213. hour: tmp2[0],
  214. minute: tmp2[1],
  215. second: tmp2[2]
  216. }
  217. }
  218. return (item.disabled?null:<li className={`${styles.assistLists} ${styles.clearfix}`}>
  219. {/* <span className={styles.assistName} style={{ width: winWidth<1200?'120px':(winWidth-987)+'px' }}> */}
  220. {/* <span className={styles.assistName} style={{ width: winWidth<1200?'120px':'auto' }}>
  221. <span className={styles.tagSpan}>
  222. {item.name}:
  223. <span className={styles.imgInfo} title='点击i图标可查看详细说明' onClick={()=>getInfomation({name: item.name, position: 1, type: 6})}></span>
  224. </span>
  225. </span> */}
  226. <AssistName item={item} idx={idx} checkOnOff={checkOnOff} name={item.name} winWidth={winWidth} handlePush={handlePush} getInfomation={getInfomation}></AssistName>
  227. <div className={`${styles.textareaWrap} ${setFontColorSize(2,1)}`}>
  228. <ScrollArea speed={0.8}
  229. horizontal={false}
  230. stopScrollPropagation={showedBar?true:false}
  231. style={{maxHeight:'100px'}}
  232. className={styles["area"]}
  233. verticalContainerStyle={contStyle}
  234. verticalScrollbarStyle={barStyle}
  235. contentClassName="content TextareaRsize">
  236. <Textarea value={item.value} disabled={item.disabled} handlePush={handlePush} isRead={isRead} handleChangeAssistValue={handleChangeAssistValue} idx={idx}></Textarea>
  237. </ScrollArea>
  238. </div>
  239. <div className={`${styles.pointerFinger} ${setFontColorSize(2,2)}`}>
  240. <p>报告日期:<span>
  241. <input disabled="disabled" type="text"
  242. class="canEdit"
  243. onDoubleClick={(e)=>this.setEdit(e)}
  244. style={'#333'}
  245. placeholder='时间'
  246. autoComplete="off"
  247. value={item.time}
  248. onInput={(e)=>{this.handleInput(e,item,idx)}}
  249. onBlur={()=>{this.handleBlur()}}
  250. />
  251. </span></p>
  252. <span className={styles.closeIcon} id="assiClose" onClick={() => { this.handleDelClick(idx,item) }}></span>
  253. </div>
  254. <DelToast show={idx==id&&item.name==activeName?visible:false}
  255. name={activeName}
  256. right={'-40px'}
  257. top={'50px'}
  258. cancel={this.handleCancel}
  259. confirm={()=>this.delConfirm(1)}/>
  260. {/* {
  261. id == null?null:<DelToast show={idx==id&&item.name==activeName?visible:false}
  262. name={activeName}
  263. cancel={this.handleCancel}
  264. confirm={this.delConfirm}/>
  265. } */}
  266. </li>)
  267. })
  268. }
  269. </ul>
  270. </React.Fragment>
  271. }
  272. render() {
  273. const { handleChangeValue, list,assistVal,windowHeight,assistList, refreshScroller } = this.props;
  274. const { visible,pageTop } = this.state;
  275. const contStyle={
  276. opacity:'0.4',
  277. right:'0',
  278. top:'1px',
  279. zIndex:'15',
  280. width:'14px',
  281. background:'#f1f1f1'};
  282. const barStyle={background:'#777',width:'100%'};
  283. return (
  284. <div className={styles.wrapper}>
  285. {this.getAssistLabel()}
  286. <div id="searchWrapAssist" style={{ position: "relative", clear: 'both' }}>
  287. <Add showText="添加检查项" handleClick={(e) => this.handleSearchShow(e)} id="assistCheck" />
  288. {this.state.show ? <SearchOption windowHeight={windowHeight} refreshScroller={refreshScroller } pageTop={pageTop} height={280} handleChangeValue={handleChangeValue} visible={true}>
  289. {list && list.length>0?this.getSearchList(list):(assistVal == ''?'':<p style={{padding:'42px 30px',color:'#bfbfbf'}}>暂无筛选项</p>)}
  290. {/* {
  291. (list && list.length>0) || (assistVal != '') || (assistList&&assistList.length==0)?'':<div>
  292. <p style={{padding:'5px 30px',color:'#bfbfbf'}}>常用检查项</p>
  293. {assistList.length>6?<ScrollArea speed={0.8}
  294. horizontal={false}
  295. stopScrollPropagation={true}
  296. style={{height:'225px'}}
  297. className={styles["area"]}
  298. verticalContainerStyle={contStyle}
  299. verticalScrollbarStyle={barStyle}
  300. contentClassName="content">
  301. {
  302. this.getCommonList()
  303. }
  304. </ScrollArea>:this.getCommonList()}
  305. </div>
  306. } */}
  307. </SearchOption> : ''}
  308. </div>
  309. </div>
  310. )
  311. }
  312. }
  313. export default AddAssistCheck;