index.jsx 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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(80)
  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(80)
  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(80)
  133. }
  134. handleChangeDate(info) {
  135. let date = getCalendarDate(info);
  136. this.setState({ dateTime: date, date: false })
  137. }
  138. handleSearchAdvice(e) {
  139. let tmpShow = this.state.show;
  140. const { handlePush } = this.props;
  141. this.setState({ show: !tmpShow, pageTop: getPageCoordinate(e).boxTop })
  142. // e.stopPropagation();
  143. if(tmpShow){
  144. this.props.setHighter(80)
  145. }else{
  146. this.props.detailClick(5)
  147. handlePush && handlePush({mode:8}); //右侧推送
  148. setPosition(e,"#searchOption",this.props.setHighter)
  149. }
  150. }
  151. handleFillShow(e, idx) {
  152. let tmpShow = this.state.showFill;
  153. let baseList = store.getState().inspect.fillActive;
  154. this.setState({
  155. showFill: !tmpShow,
  156. currentIdx: idx,
  157. currentData: baseList,
  158. dateTime: baseList.time ? baseList.time : getCurrentDate(1)
  159. })
  160. // e.stopPropagation();
  161. }
  162. handleShowDate() {
  163. this.setState({
  164. date: !this.state.date
  165. })
  166. }
  167. changeActivePart(idx, val, clear) {
  168. let nums = this.state.num;
  169. let fillActive;
  170. if (nums == 0) {
  171. fillActive = this.props.fillActive;
  172. } else {
  173. fillActive = this.state.currentData;
  174. }
  175. ++nums;
  176. this.setState({ num: nums });
  177. let tempArr = deepClone(fillActive);
  178. if (clear) { //点击清空按钮,至清初输入的数字
  179. for (let i = 0; i < tempArr.details.length; i++) {
  180. tempArr.details[i].value = ''
  181. tempArr.show = false;
  182. }
  183. tempArr.time = getCurrentDate(1);
  184. this.setState({ currentData: tempArr })
  185. return;
  186. } else {
  187. let tempNumPlus = 0;
  188. for (let i = 0; i < tempArr.details.length; i++) {
  189. if (i == idx) {
  190. tempArr.details[i].value = val
  191. }
  192. if (tempArr.details[i].value != undefined && tempArr.details[i].value != '') {
  193. tempArr.show = true;
  194. } else {
  195. ++tempNumPlus;
  196. if (tempNumPlus == tempArr.details.length) {
  197. tempArr.show = false;
  198. }
  199. }
  200. }
  201. tempArr.time = this.state.dateTime;
  202. this.setState({ currentData: tempArr })
  203. }
  204. }
  205. getItemList() { //填写单展示
  206. let number = this.state.num;
  207. let fillActive;
  208. if (number == 0) {
  209. fillActive = this.props.fillActive;
  210. } else {
  211. fillActive = this.state.currentData;
  212. }
  213. return <ul className={styles.searchLis} ref={this.$ul}>
  214. {
  215. fillActive && fillActive.details && fillActive.details.map((item, idx) => {
  216. if (item.controlType == 1) {
  217. return (
  218. <li className={`${styles.itemPart} ${fillActive.details.length > 1 ? '' : styles.itemPartOne}`}>
  219. <span className={styles.itemPartL}>{item.name}</span>
  220. <span className={styles.itemPartT}>
  221. <select className={styles.itemPartR} onChange={(e) => {
  222. if (e.target.value == '请选择') {
  223. this.changeActivePart(idx, '')
  224. return;
  225. }
  226. this.changeActivePart(idx, e.target.value);
  227. }}
  228. >
  229. <option value="请选择">请选择</option>
  230. {
  231. (item.questionDetailList).map((val) => {
  232. return <option value={val.name}
  233. selected={val.name == item.value ? true : false}
  234. >{val.name}</option>
  235. })
  236. }
  237. </select>
  238. </span>
  239. </li>
  240. )
  241. } else if (item.controlType == 6) {
  242. return (
  243. <li className={`${styles.itemPart} ${fillActive.details.length > 1 ? '' : styles.itemPartOne}`}>
  244. <span className={styles.itemPartL} title={item.name}>{item.name}</span>
  245. <span className={styles.itemPartT}>
  246. <input type="text"
  247. placeholder="(填写)"
  248. value={item.value}
  249. onKeyUp={(e) => { this.changeActivePart(idx, e.target.value.trim()) }}
  250. />
  251. <p className={styles.unit} title={item.labelSuffix}>{item.labelSuffix}</p>
  252. </span>
  253. </li>
  254. )
  255. }
  256. })
  257. }
  258. </ul>
  259. }
  260. handleSign(item,idx){
  261. const { handleSign,handlePush } = this.props;
  262. handleSign(item,idx)
  263. handlePush && handlePush({mode:8}); //右侧推送
  264. }
  265. getSearchList(list) {//搜索列表
  266. const { handleSign } = this.props;
  267. const contStyle={
  268. opacity:'0.4',
  269. right:'0',
  270. top:'1px',
  271. zIndex:'15',
  272. width:'14px',
  273. background:'#f1f1f1'};
  274. const barStyle={background:'#777',width:'100%'};
  275. return <ul className={`${styles.searchLiUl} ${styles.searchIsp}`} style={{height:'205px',width:'302px',overflow:'auto'}}>
  276. {
  277. list && list.map((item, idx) => {
  278. return <li key={idx}
  279. className={styles.searchLi}
  280. title={item.uniqueName}
  281. onClick={() => {
  282. this.props.setHighter(80)
  283. this.handleSign(item, idx, 'search');
  284. this.setState({ show: false })
  285. }}
  286. >
  287. {item.uniqueName}
  288. </li>
  289. })
  290. }
  291. </ul>;
  292. }
  293. getCommonList() {//常用列表
  294. const { handleSign, inspectList } = this.props;
  295. return <ul className={styles.searchLiUl}>
  296. {
  297. inspectList && inspectList.map((item, idx) => {
  298. return <li key={idx}
  299. className={styles.searchLi}
  300. title={item.name}
  301. onClick={() => {
  302. this.props.setHighter(80)
  303. handleSign(item.questionId, idx, 'common');
  304. this.setState({ show: false })
  305. }}
  306. >
  307. {item.name}
  308. </li>
  309. })
  310. }
  311. </ul>
  312. }
  313. showDetails(val) {
  314. let min = val.minValue, max = val.maxValue, value = val.value, dom = '';
  315. dom = getDomUpDown(min,max,value)
  316. if (val.questionDetailList.length > 0) {
  317. return val.questionDetailList.map((item) => {
  318. if (val.value == item.name) {
  319. return <td style={{ width: '20%' }} className={item.abnormal != '0' ? "red" : ''}>{val.value}</td>
  320. }
  321. })
  322. } else {
  323. // 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>
  324. return <td style={{ width: '20%' }}>{dom} {val.labelSuffix}</td>
  325. }
  326. }
  327. render() {
  328. 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;
  329. const { tmpId, tmpIdx, time, pageTop, impId } = this.state;
  330. const contStyle={
  331. opacity:'0.4',
  332. right:'0',
  333. top:'1px',
  334. zIndex:'15',
  335. width:'14px',
  336. background:'#f1f1f1'};
  337. const barStyle={background:'#777',width:'100%'};
  338. return (
  339. <div className={styles.wrapper}>
  340. <div className={styles.check}>
  341. <ul className={styles.labelWrap} >
  342. {
  343. labelListBig && labelListBig.map((item, idx) => {
  344. return <SlidePic
  345. item={item}
  346. checkOnOff={checkOnOff}
  347. time={time}
  348. handlePush={handlePush}
  349. handleDelClick={this.handleDelClick}
  350. setTipValue={setTipValue}
  351. handleDelConfirm={handleDelConfirm}
  352. ></SlidePic>
  353. })
  354. }
  355. {
  356. labelListSmall && labelListSmall.map((item, idx) => {
  357. return <SlidePic
  358. item={item}
  359. checkOnOff={checkOnOff}
  360. time={time}
  361. handlePush={handlePush}
  362. handleDelClick={this.handleDelClick}
  363. setTipValue={setTipValue}
  364. handleDelConfirm={handleDelConfirm}
  365. ></SlidePic>
  366. })
  367. }
  368. </ul>
  369. </div>
  370. <div style={{ position: "relative", clear: "both", top: "-2px" }}>
  371. <Add showText="添加医嘱" handleClick={(e) => this.handleSearchAdvice(e)} id="searchWrapAdvice" />
  372. {this.state.show ? <SearchOption searchType="2" detailClick={detailClick} windowHeight={windowHeight} height={280} refreshScroller={refreshScroller} pageTop={pageTop} handleChangeValue={handleChangeValue} visible={true}>
  373. {list && list.length > 0 ? this.getSearchList(list) : (inspectVal == '' ? '' : <p style={{ padding: '5px 136px', color: '#bfbfbf' }}>暂无筛选项</p>)}
  374. {/* {
  375. (list && list.length > 0) || (inspectVal != '') || (inspectList&&inspectList.length==0) ? '' : <div>
  376. <p style={{ padding: '5px 30px', color: '#bfbfbf' }}>常用检验项</p>
  377. <ScrollArea speed={0.8}
  378. horizontal={false}
  379. stopScrollPropagation={true}
  380. style={{height:'225px'}}
  381. className={styles["area"]}
  382. verticalContainerStyle={contStyle}
  383. verticalScrollbarStyle={barStyle}
  384. contentClassName="content">
  385. {
  386. this.getCommonList()
  387. }
  388. </ScrollArea>
  389. </div>
  390. } */}
  391. </SearchOption> : ''}
  392. </div>
  393. </div>
  394. )
  395. }
  396. }
  397. export default AddNewInspect;