index.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. import React from 'react';
  2. import { SearchOption, InspectCommon, Calendar, Notify, ConfirmModal, Add, DelToast } from '@commonComp';
  3. import SlideExcel from './SlideExcel';
  4. import SlidePic from './SlidePic';
  5. import { deepClone, getPageCoordinate, getStatusImg,getDomUpDown ,getCurrentDate,setPosition,getCalendarDate} from '@utils/tools';
  6. import styles from './index.less';
  7. import ScrollArea from 'react-scrollbar';
  8. import store from '@store';
  9. import $ from 'jquery';
  10. class AddNewInspect extends React.Component {
  11. constructor(props) {
  12. super(props);
  13. this.state = {
  14. show: false,
  15. showFill: false,
  16. date: false,
  17. currentIdx: '',
  18. dateTime: "",
  19. currentData: {},
  20. numPlus: 0, //判断是否所有的填写单都是空
  21. num: 0, //暂存数据,获取一次,不能每次都是新的数据
  22. type: null,
  23. time: null,
  24. pageTop: '',
  25. // tmpIds: [], //内层外层
  26. impId: null
  27. }
  28. this.$ul = React.createRef();
  29. this.handleChangeDate = this.handleChangeDate.bind(this)
  30. this.handleShowDate = this.handleShowDate.bind(this)
  31. this.getItemList = this.getItemList.bind(this)
  32. this.getSearchList = this.getSearchList.bind(this)
  33. this.getCommonList = this.getCommonList.bind(this)
  34. this.changeActivePart = this.changeActivePart.bind(this)
  35. this.showDetails = this.showDetails.bind(this)
  36. this.handleDelConfirm = this.handleDelConfirm.bind(this)
  37. this.handleCancel = this.handleCancel.bind(this)
  38. this.handleSearchAdvice = this.handleSearchAdvice.bind(this)
  39. this.changeShowFill = this.changeShowFill.bind(this)
  40. this.handleFillShow = this.handleFillShow.bind(this)
  41. this.handleDelClick = this.handleDelClick.bind(this)
  42. }
  43. handleDelConfirm() {//弹窗确定
  44. const { delPartItem, handleCloseExcel, handlePush } = this.props;
  45. const { type, id, impId } = this.state;
  46. if (type == 1) {
  47. delPartItem(id)
  48. } else if (type == 2) {
  49. handleCloseExcel(impId)
  50. }
  51. Notify.success("删除成功");
  52. handlePush && handlePush({mode:8}); //右侧推送
  53. }
  54. handleDelClick(type, time) {
  55. if (type == 2) {
  56. this.setState({
  57. impId: idx,
  58. type: type,
  59. id: null
  60. })
  61. } else {
  62. this.setState({
  63. type: type,
  64. time: time,
  65. impId: null
  66. })
  67. }
  68. }
  69. handleCancel() {
  70. this.setState({
  71. type: null,
  72. id: null,
  73. impId: null
  74. })
  75. }
  76. componentDidMount() {
  77. $(document).click((event) => {
  78. let searchWrap = document.getElementById("searchWrapAdvice"); // 搜索按钮
  79. let searchOption = document.getElementById("searchOption"); // 搜索列表
  80. let inspectFill = document.getElementById("inspectFill"); // 公共填写单
  81. const {refreshScroller} = this.props
  82. refreshScroller()&&refreshScroller().refresh(); //点开搜索弹窗更新滚动条,
  83. let _del = $('#delBox')[0]; // 删除弹窗
  84. let _impClose = $('#impClose')[0]; // 导入删除按钮
  85. let _addClose = $('#addClose')[0]; // 添加删除按钮
  86. let _closeTil = $('#delTit')[0]; // 弹窗标题
  87. if (searchOption&&!this.isBar) {//onMousedown的目标为滚动条时,添加弹窗不关闭
  88. if (searchOption != event.target && searchWrap != event.target && searchWrap != event.target.parentNode && !$.contains(searchOption, event.target)) { // Mark 1
  89. this.setState({ show: false },()=>{
  90. this.props.setHighter(48)
  91. setTimeout(function(){
  92. refreshScroller()&&refreshScroller().scrollBottom();
  93. },100);
  94. });
  95. }
  96. }
  97. if (inspectFill&&!this.isBar) {//onMousedown的目标为滚动条时,子项弹窗不关闭
  98. if ($(event.target).attr('id') != "getSureTime"&&event.target.getAttribute('data-flg') != 'current' && inspectFill != event.target && !$.contains(inspectFill, event.target)) { // Mark 1
  99. if(this.state.showFill){
  100. this.props.setHighter(48)
  101. }
  102. this.setState({ showFill: false, date: false });
  103. }
  104. }
  105. if (_del&&!this.isBar) {//onMousedown的目标为滚动条时,删除弹窗不关闭
  106. if (!event.target.isEqualNode(_impClose) && !event.target.isEqualNode(_addClose) && !event.target.isEqualNode(_del) && event.target.parentNode != _del && !event.target.isEqualNode(_closeTil)) {
  107. this.setState({
  108. id: null,
  109. impId: null
  110. })
  111. }
  112. }
  113. });
  114. const that = this;
  115. document.addEventListener('mousedown',function(e){
  116. //onMousedown的目标为滚动条时,标签填写单不关闭
  117. if(e.target.className=='scrollbar'){
  118. that.isBar = true;
  119. }else{
  120. that.isBar = false;
  121. }
  122. });
  123. // this.setState({ dateTime: getCurrentDate(1) })
  124. }
  125. componentWillReceiveProps(nextProps) {
  126. if (nextProps.fillActive.name != this.props.fillActive.name) {
  127. this.setState({ num: 0 })
  128. }
  129. }
  130. changeShowFill() {
  131. this.setState({ showFill: false })
  132. this.props.setHighter(48)
  133. }
  134. handleChangeDate(info) {
  135. let date = getCalendarDate(info);
  136. this.setState({ dateTime: date, date: false })
  137. }
  138. handleSearchAdvice(e) {
  139. const {refreshScroller}=this.props
  140. let tmpShow = this.state.show;
  141. this.setState({ show: !tmpShow, pageTop: getPageCoordinate(e).boxTop })
  142. // e.stopPropagation();
  143. if(tmpShow){
  144. this.props.setHighter(48)
  145. }else{
  146. this.props.detailClick(5)
  147. setPosition(e,"#searchOption",this.props.setHighter)
  148. }
  149. }
  150. handleFillShow(e, idx) {
  151. let tmpShow = this.state.showFill;
  152. let baseList = store.getState().inspect.fillActive;
  153. this.setState({
  154. showFill: !tmpShow,
  155. currentIdx: idx,
  156. currentData: baseList,
  157. dateTime: baseList.time ? baseList.time : getCurrentDate(1)
  158. })
  159. // e.stopPropagation();
  160. }
  161. handleShowDate() {
  162. this.setState({
  163. date: !this.state.date
  164. })
  165. }
  166. changeActivePart(idx, val, clear) {
  167. let nums = this.state.num;
  168. let fillActive;
  169. if (nums == 0) {
  170. fillActive = this.props.fillActive;
  171. } else {
  172. fillActive = this.state.currentData;
  173. }
  174. ++nums;
  175. this.setState({ num: nums });
  176. let tempArr = deepClone(fillActive);
  177. if (clear) { //点击清空按钮,至清初输入的数字
  178. for (let i = 0; i < tempArr.details.length; i++) {
  179. tempArr.details[i].value = ''
  180. tempArr.show = false;
  181. }
  182. tempArr.time = getCurrentDate(1);
  183. this.setState({ currentData: tempArr })
  184. return;
  185. } else {
  186. let tempNumPlus = 0;
  187. for (let i = 0; i < tempArr.details.length; i++) {
  188. if (i == idx) {
  189. tempArr.details[i].value = val
  190. }
  191. if (tempArr.details[i].value != undefined && tempArr.details[i].value != '') {
  192. tempArr.show = true;
  193. } else {
  194. ++tempNumPlus;
  195. if (tempNumPlus == tempArr.details.length) {
  196. tempArr.show = false;
  197. }
  198. }
  199. }
  200. tempArr.time = this.state.dateTime;
  201. this.setState({ currentData: tempArr })
  202. }
  203. }
  204. getItemList() { //填写单展示
  205. let number = this.state.num;
  206. let fillActive;
  207. if (number == 0) {
  208. fillActive = this.props.fillActive;
  209. } else {
  210. fillActive = this.state.currentData;
  211. }
  212. return <ul className={styles.searchLis} ref={this.$ul}>
  213. {
  214. fillActive && fillActive.details && fillActive.details.map((item, idx) => {
  215. if (item.controlType == 1) {
  216. return (
  217. <li className={`${styles.itemPart} ${fillActive.details.length > 1 ? '' : styles.itemPartOne}`}>
  218. <span className={styles.itemPartL}>{item.name}</span>
  219. <span className={styles.itemPartT}>
  220. <select className={styles.itemPartR} onChange={(e) => {
  221. if (e.target.value == '请选择') {
  222. this.changeActivePart(idx, '')
  223. return;
  224. }
  225. this.changeActivePart(idx, e.target.value);
  226. }}
  227. >
  228. <option value="请选择">请选择</option>
  229. {
  230. (item.questionDetailList).map((val) => {
  231. return <option value={val.name}
  232. selected={val.name == item.value ? true : false}
  233. >{val.name}</option>
  234. })
  235. }
  236. </select>
  237. </span>
  238. </li>
  239. )
  240. } else if (item.controlType == 6) {
  241. return (
  242. <li className={`${styles.itemPart} ${fillActive.details.length > 1 ? '' : styles.itemPartOne}`}>
  243. <span className={styles.itemPartL} title={item.name}>{item.name}</span>
  244. <span className={styles.itemPartT}>
  245. <input type="text"
  246. placeholder="(填写)"
  247. value={item.value}
  248. onKeyUp={(e) => { this.changeActivePart(idx, e.target.value.trim()) }}
  249. />
  250. <p className={styles.unit} title={item.labelSuffix}>{item.labelSuffix}</p>
  251. </span>
  252. </li>
  253. )
  254. }
  255. })
  256. }
  257. </ul>
  258. }
  259. handleSign(item,idx){
  260. const { handleSign,handlePush } = this.props;
  261. handleSign(item,idx)
  262. handlePush && handlePush({mode:8}); //右侧推送
  263. }
  264. getSearchList(list) {//搜索列表
  265. const { handleSign } = this.props;
  266. const contStyle={
  267. opacity:'0.4',
  268. right:'0',
  269. top:'1px',
  270. zIndex:'15',
  271. width:'14px',
  272. background:'#f1f1f1'};
  273. const barStyle={background:'#777',width:'100%'};
  274. return <ScrollArea speed={0.8}
  275. horizontal={false}
  276. stopScrollPropagation={list.length>6?true:false}
  277. style={{'max-height':'205px'}}
  278. className={styles["area"]}
  279. verticalContainerStyle={contStyle}
  280. verticalScrollbarStyle={barStyle}
  281. contentClassName="content">
  282. <ul className={`${styles.searchLiUl} ${styles.searchIsp}`}>
  283. {
  284. list && list.map((item, idx) => {
  285. return <li key={idx}
  286. className={styles.searchLi}
  287. title={item.uniqueName}
  288. onClick={() => {
  289. this.props.setHighter(48)
  290. this.handleSign(item, idx, 'search');
  291. this.setState({ show: false })
  292. }}
  293. >
  294. {item.uniqueName}
  295. </li>
  296. })
  297. }
  298. </ul></ScrollArea>;
  299. }
  300. getCommonList() {//常用列表
  301. const { handleSign, inspectList } = this.props;
  302. return <ul className={styles.searchLiUl}>
  303. {
  304. inspectList && inspectList.map((item, idx) => {
  305. return <li key={idx}
  306. className={styles.searchLi}
  307. title={item.name}
  308. onClick={() => {
  309. this.props.setHighter(48)
  310. handleSign(item.questionId, idx, 'common');
  311. this.setState({ show: false })
  312. }}
  313. >
  314. {item.name}
  315. </li>
  316. })
  317. }
  318. </ul>
  319. }
  320. showDetails(val) {
  321. let min = val.minValue, max = val.maxValue, value = val.value, dom = '';
  322. dom = getDomUpDown(min,max,value)
  323. if (val.questionDetailList.length > 0) {
  324. return val.questionDetailList.map((item) => {
  325. if (val.value == item.name) {
  326. return <td style={{ width: '20%' }} className={item.abnormal != '0' ? "red" : ''}>{val.value}</td>
  327. }
  328. })
  329. } else {
  330. // return <td style={{ width: '20%' }}><span className={(val.value - 0).toString() == 'NaN' ? "red" : (val.maxValue || val.minValue) ? (val.value > val.maxValue || val.value < val.minValue ? "red" : '') : ''}>{val.value}</span> {val.labelSuffix}</td>
  331. return <td style={{ width: '20%' }}>{dom} {val.labelSuffix}</td>
  332. }
  333. }
  334. render() {
  335. const {setHighter,refreshScroller,checkOnOff, getInfomation,setTipValue, handleChangeValue,labelListSmall,inspectList, inspectVal, list, labelListBig, windowHeight, windowWidth,detailClick, handleLabelSub, handleClear, handleConfirm, fillActive, getExcelDataList, handleCloseExcel, handlePush,handleDelConfirm } = this.props;
  336. const { tmpId, tmpIdx, time, pageTop, impId } = this.state;
  337. const contStyle={
  338. opacity:'0.4',
  339. right:'0',
  340. top:'1px',
  341. zIndex:'15',
  342. width:'14px',
  343. background:'#f1f1f1'};
  344. const barStyle={background:'#777',width:'100%'};
  345. return (
  346. <div className={styles.wrapper}>
  347. <div className={styles.check}>
  348. <ul className={styles.labelWrap} >
  349. {
  350. labelListBig && labelListBig.map((item, idx) => {
  351. return <SlidePic
  352. item={item}
  353. checkOnOff={checkOnOff}
  354. time={time}
  355. handlePush={handlePush}
  356. handleDelClick={this.handleDelClick}
  357. setTipValue={setTipValue}
  358. handleDelConfirm={handleDelConfirm}
  359. ></SlidePic>
  360. })
  361. }
  362. {
  363. labelListSmall && labelListSmall.map((item, idx) => {
  364. return <SlidePic
  365. item={item}
  366. checkOnOff={checkOnOff}
  367. time={time}
  368. handlePush={handlePush}
  369. handleDelClick={this.handleDelClick}
  370. setTipValue={setTipValue}
  371. handleDelConfirm={handleDelConfirm}
  372. ></SlidePic>
  373. })
  374. }
  375. </ul>
  376. </div>
  377. <div style={{ position: "relative", clear: "both", top: "5px" }}>
  378. <Add showText="添加医嘱" handleClick={(e) => this.handleSearchAdvice(e)} id="searchWrapAdvice" />
  379. {this.state.show ? <SearchOption searchType="2" detailClick={detailClick} windowHeight={windowHeight} height={280} refreshScroller={refreshScroller} pageTop={pageTop} handleChangeValue={handleChangeValue} visible={true}>
  380. {list && list.length > 0 ? this.getSearchList(list) : (inspectVal == '' ? '' : <p style={{ padding: '5px 136px', color: '#bfbfbf' }}>暂无筛选项</p>)}
  381. {/* {
  382. (list && list.length > 0) || (inspectVal != '') || (inspectList&&inspectList.length==0) ? '' : <div>
  383. <p style={{ padding: '5px 30px', color: '#bfbfbf' }}>常用检验项</p>
  384. <ScrollArea speed={0.8}
  385. horizontal={false}
  386. stopScrollPropagation={true}
  387. style={{height:'225px'}}
  388. className={styles["area"]}
  389. verticalContainerStyle={contStyle}
  390. verticalScrollbarStyle={barStyle}
  391. contentClassName="content">
  392. {
  393. this.getCommonList()
  394. }
  395. </ScrollArea>
  396. </div>
  397. } */}
  398. </SearchOption> : ''}
  399. </div>
  400. </div>
  401. )
  402. }
  403. }
  404. export default AddNewInspect;