index.jsx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import store from '@store';
  4. import styles from './index.less';
  5. import ReactDom from "react-dom";
  6. import sort from "./img/sort.png"
  7. import close from "./img/close.png";
  8. import PreviewBody from '@components/PreviewBody';
  9. import Empty from '@components/Empty'
  10. import { pushAllDataList,didPushParamChange } from '@utils/tools';
  11. // import { dragBox } from '@utils/drag';
  12. import { initItemList, setInitHistory } from '@store/async-actions/historyTemplates';
  13. import HistoryCases from '@containers/HistoryCases';
  14. import $ from 'jquery';
  15. import { ConfirmModal } from '@commonComp';
  16. import {showHistory} from "@store/actions/historyTemplates";
  17. import { SET_READ_MODE } from "@store/types/typeConfig";
  18. import {billing} from '@store/async-actions/pushMessage';
  19. import { getHistempDetail, asyncUpdateByIdUsNames, asyncCancelTemplateInfos} from '@store/async-actions/historyTemplates';
  20. import { embedPush } from '../../../store/async-actions/pushMessage'
  21. import edit from '../../../common/images/icon_edit_default@2x.png';
  22. import editHover from '../../../common/images/icon_edit_hover@2x.png';
  23. import del from '../../../common/images/icon_del_default@2x.png';
  24. import delHover from '../../../common/images/icon_del_hover@2x.png';
  25. import Notify from '@commonComp/Notify';
  26. import ScrollArea from 'react-scrollbar';
  27. class HistoryCaseContainer extends React.Component {
  28. constructor(props){
  29. super(props);
  30. this.state = {
  31. activeHis:{},//预览数据
  32. activeId:'0',
  33. dataStr:[],
  34. dataJson:{},
  35. visible:false,
  36. delVisible: false,
  37. editVisible: false,
  38. templateName: '', // 病历名称
  39. historyCase: [],
  40. currentIndex:-1, // 显示编辑/删除图标
  41. delId: '', //删除病历id
  42. editId: '', //编辑病历id
  43. activeIndex: -1, //字体显示蓝色高亮index
  44. showEditIcon: false,
  45. showDelIcon: false,
  46. desc: true, // 正序/逆序
  47. overHeight: 0
  48. }
  49. this.handleCaseClick=this.handleCaseClick.bind(this)
  50. this.handleQuoteClick=this.handleQuoteClick.bind(this)
  51. this.handleDelQuoteClick = this.handleDelQuoteClick.bind(this)
  52. this.handleEditQuoteClick = this.handleEditQuoteClick.bind(this)
  53. this.close = this.close.bind(this);
  54. this.closeDel = this.closeDel.bind(this);
  55. this.closeEdit = this.closeEdit.bind(this);
  56. this.makeSure = this.makeSure.bind(this);
  57. this.makeSureDel = this.makeSureDel.bind(this);
  58. this.makeSureEdit = this.makeSureEdit.bind(this);
  59. this.handleChange = this.handleChange.bind(this);
  60. this.handleSortClick = this.handleSortClick.bind(this);
  61. this.$scrollRef = React.createRef();
  62. }
  63. componentDidMount(){
  64. const {items} = this.props
  65. // dragBox('hisWrapMove','closeHis','add')
  66. setTimeout(() => {
  67. this.handleCaseClick(0, items[0])
  68. }, 50);
  69. this.setState({
  70. visible:false,
  71. })
  72. }
  73. // 操作后获取获取列表数据
  74. getTemplatePageAlls(val) {
  75. return new Promise((resolve,reject)=>{
  76. initItemList(val).then(res => {
  77. const result = res.data
  78. if (result.code == 0 && result.data) {
  79. store.dispatch(setInitHistory(result.data));
  80. resolve('ok')
  81. }
  82. })
  83. })
  84. }
  85. // 点击当前的历史病历
  86. handleCaseClick(idx,val) {
  87. const { items } = this.props;
  88. let tmpItems = []
  89. $("#hislistLeft li").eq(idx).css({
  90. background: '#fff'
  91. }).siblings().css({
  92. background: '#d2d1d1'
  93. })
  94. if (items.length == 0) {
  95. return
  96. } else {
  97. tmpItems = items[idx]
  98. }
  99. this.setState({
  100. activeId: idx,
  101. activeHis: tmpItems,
  102. dataStr: JSON.parse(tmpItems.preview)||[],
  103. activeIndex: idx,
  104. // overHeight: this.$scrollRef.current.scrollTop
  105. },
  106. // ()=> {
  107. // setTimeout(() => {
  108. // this.$scrollRef.current.scrollTop = this.state.overHeight
  109. // }, 0)}
  110. )
  111. }
  112. // 确认引用选中病历
  113. makeSure(){
  114. const {activeHis} = this.state;
  115. this.setState({visible:false});
  116. store.dispatch(showHistory(false));
  117. store.dispatch(getHistempDetail(activeHis)); // 获取引用数据
  118. const {handleQuoteClick} = this.props;
  119. handleQuoteClick && handleQuoteClick(activeHis);
  120. // 确定引用后,页面设置为可滚动
  121. document.body.style.overflow = 'auto';
  122. }
  123. //确认删除病历
  124. makeSureDel(){
  125. const { delId } = this.state
  126. store.dispatch(asyncCancelTemplateInfos(delId)).then(res => {
  127. if (res.data.code === '0') {
  128. Notify.success('病历删除成功');
  129. this.setState({
  130. delVisible: false
  131. })
  132. // 重新渲染列表
  133. this.getTemplatePageAlls().then(res=>{
  134. if(res === 'ok'){
  135. const { items } = this.props;
  136. if(items.length ===0) {
  137. this.setState({
  138. activeHis: {}
  139. })
  140. store.dispatch(showHistory(false));
  141. return
  142. }
  143. this.handleCaseClick(0, items[0])
  144. // this.$scrollRef.scrollArea.refresh();
  145. // this.context.scrollArea.scrollYTo(40);
  146. // console.log(this.$scrollRef,'this.$scrollRef');
  147. // console.log(this.context,'this.context');
  148. // this.forceUpdate()
  149. }
  150. })
  151. }
  152. }).catch(err => {
  153. Notify.info(err.msg);
  154. })
  155. }
  156. // 取消删除病历
  157. closeDel(){
  158. this.setState({
  159. delVisible: false
  160. })
  161. }
  162. // 显示删除确认框
  163. handleDelQuoteClick(e, val, idx) {
  164. e.stopPropagation()
  165. this.setState({
  166. delVisible: true,
  167. delId: val.id
  168. })
  169. }
  170. // 确认编辑病历
  171. makeSureEdit(){
  172. const { editId, templateName} = this.state
  173. if (templateName === '') {
  174. Notify.info('请输入病历名称')
  175. return
  176. }
  177. store.dispatch(asyncUpdateByIdUsNames(editId, templateName)).then(res=>{
  178. if (res.data.code === '0'){
  179. Notify.success('病历修改成功');
  180. this.setState({
  181. editVisible : false
  182. })
  183. // 重新渲染列表
  184. this.getTemplatePageAlls()
  185. }
  186. }).catch(err =>{
  187. Notify.info(err.msg);
  188. })
  189. }
  190. // 取消编辑病历
  191. closeEdit() {
  192. this.setState({
  193. editVisible: false,
  194. templateName: ''
  195. })
  196. }
  197. // 显示编辑确认框
  198. handleEditQuoteClick(e, val, idx) {
  199. // console.log(val,'显示编辑确认框');
  200. e.stopPropagation()
  201. this.setState({
  202. editVisible: true,
  203. editId: val.id,
  204. templateName: val.name
  205. })
  206. }
  207. close(){
  208. this.setState({
  209. visible:false
  210. })
  211. }
  212. // 引用,右侧文本数据同步渲染
  213. handleQuoteClick(e,val,idx){
  214. e.stopPropagation()
  215. this.setState({
  216. visible:true,
  217. activeId:idx,
  218. activeHis:val,
  219. // dataStr: JSON.parse(val.preview) || [],
  220. })
  221. document.body.scrollTop = document.documentElement.scrollTop = 0
  222. }
  223. // 修改模板名称 input的值
  224. handleChange(e){
  225. this.setState({
  226. templateName: e.target.value
  227. })
  228. }
  229. // 处理鼠标移入
  230. handleMouseEnterLi(idx){
  231. // console.log('处理鼠标移入li');
  232. this.setState({
  233. currentIndex: idx
  234. })
  235. }
  236. // 处理鼠标移除
  237. handleMouseLeaveLi(idx){
  238. // console.log('处理鼠标移除li');
  239. this.setState({
  240. currentIndex : -1
  241. })
  242. }
  243. // 处理鼠标移入编辑按钮
  244. handleMouseEnterEdit(idx) {
  245. this.setState({
  246. showEditIcon: true
  247. })
  248. }
  249. // 处理鼠标移出编辑按钮
  250. handleMouseLeaveEdit(idx) {
  251. this.setState({
  252. showEditIcon: false
  253. })
  254. }
  255. // 处理鼠标移入删除按钮
  256. handleMouseEnterDel(idx) {
  257. this.setState({
  258. showDelIcon: true
  259. })
  260. }
  261. // 处理鼠标移出删除按钮
  262. handleMouseLeaveDel(idx) {
  263. this.setState({
  264. showDelIcon: false
  265. })
  266. }
  267. // 排序
  268. handleSortClick(){
  269. this.setState({
  270. desc: !this.state.desc
  271. },()=>{
  272. let desc = this.state.desc ? 'up' : 'down'
  273. this.getTemplatePageAlls(desc).then(res => {
  274. if (res === 'ok') {
  275. const { items } = this.props;
  276. if (items.length === 0) {
  277. this.setState({
  278. activeHis: {}
  279. })
  280. store.dispatch(showHistory(false));
  281. return
  282. }
  283. this.handleCaseClick(0, items[0])
  284. }
  285. })
  286. })
  287. }
  288. render(){
  289. const { items,handleSortClick,showHistoryBox,preInfo } = this.props;
  290. const { activeHis, visible, dataJson, dataStr, delVisible, editVisible, historyCase, currentIndex, activeIndex } = this.state;
  291. const getAllDataStringList = (dataStr) =>{ //获取所有模块文本的数据
  292. let jsonDataString = {};
  293. jsonDataString.lis = {};
  294. jsonDataString.chief = dataStr[0] && dataStr[0].content || ''; //主诉
  295. jsonDataString.present = dataStr[1] &&dataStr[1].content || ''; //现病史
  296. jsonDataString.pastHistory = dataStr[2] &&dataStr[2].content || '';
  297. jsonDataString.personalHistory = dataStr[3] &&dataStr[3].content || '';
  298. jsonDataString.familyHistory = dataStr[4] &&dataStr[4].content || '';
  299. jsonDataString.marriageHistory = dataStr[5] &&dataStr[5].content || '';
  300. jsonDataString.menstruationHistory = dataStr[6] && dataStr[6].content || '';
  301. jsonDataString.vital = dataStr[7] && dataStr[7].content || ''; //查体
  302. jsonDataString.lis = dataStr[8] && dataStr[8].content || ''; //检验导入填写
  303. jsonDataString.pacs = dataStr[9] && dataStr[9].content || ''; //检查
  304. jsonDataString.diag = dataStr[10] &&dataStr[10].content || ''; //诊断
  305. jsonDataString.advice = dataStr[11] && dataStr[11].content || ''; //医嘱
  306. return jsonDataString;
  307. }
  308. const contStyle = {
  309. opacity: '0.4',
  310. right: '0',
  311. top: '1px',
  312. zIndex: '15',
  313. width: '14px',
  314. background: '#f1f1f1'
  315. };
  316. const barStyle = { background: '#777', width: '100%' };
  317. return (
  318. <div className={styles.mainHistory} id="hisWrapMove">
  319. <div className={styles.mainTop}>
  320. <div className={`${styles.closeHis} drag-title`} id="closeHis"></div>
  321. <img className={styles.close} src={close} alt="关闭历史病历" onClick={showHistoryBox} />
  322. </div>
  323. <div className={styles.mainHistoryLeft}>
  324. <div className={styles.title}>
  325. <span className={styles.his}>历史病历</span>
  326. <span className={styles.sort} onClick={this.handleSortClick}>排序 <img src={sort} alt="排序"/></span>
  327. </div>
  328. <div className={styles.lists}>
  329. {/* <List
  330. items = {items}
  331. handleCaseClick = {this.handleCaseClick}
  332. currentIndex ={ currentIndex}
  333. showEditIcon = {this.state.showEditIcon}
  334. activeIndex={activeIndex}
  335. showDelIcon={this.state.showDelIcon}
  336. ></List> */}
  337. <ScrollArea speed={0.8}
  338. key={items.length}
  339. // ref={this.$scrollRef}
  340. horizontal={false}
  341. // stopScrollPropagation={items.length > 6 ? true : false}
  342. style={{ height: '100%' }}
  343. onScroll={(value) => { }}
  344. className={styles["area"]}
  345. verticalContainerStyle={contStyle}
  346. verticalScrollbarStyle={barStyle}
  347. contentClassName="content">
  348. <ul id="hislistLeft" style={{ overflow:'auto' }} ref={this.$scrollRef}>
  349. {(items && items.length > 0) ? items.map((val,idx)=>{
  350. return <li key={val.id} onClick={() => { this.handleCaseClick(idx, val) }} onMouseEnter={() => this.handleMouseEnterLi(idx)} onMouseLeave={() => this.handleMouseLeaveLi(idx)}>
  351. <div className={styles.itemLeft}>
  352. <div className={styles.historyTop}>
  353. <span title={val.name} className={activeIndex === idx ? styles.itemNameActive :styles.itemName}>{val.name}</span>
  354. {currentIndex === idx && (
  355. <div className={styles.edit} onClick={(e) => { this.handleEditQuoteClick(e, val, idx) }} onMouseEnter={() => this.handleMouseEnterEdit(idx)} onMouseLeave={() => this.handleMouseLeaveEdit(idx)}>
  356. <img src={ this.state.showEditIcon ? editHover :edit} />
  357. </div>)}
  358. </div>
  359. <div className={activeIndex === idx ? styles.timeActive : styles.time}>{val.inquiryDate}</div>
  360. </div>
  361. <div className={styles.itemRight}>
  362. <button className={styles.quote} onClick={(e) => { this.handleQuoteClick(e, val, idx) }}>引 用</button>
  363. {currentIndex === idx && (
  364. <div className={styles.del} onClick={(e) => { this.handleDelQuoteClick(e, val, idx) }} onMouseEnter={() => this.handleMouseEnterDel(idx)} onMouseLeave={() => this.handleMouseLeaveDel(idx)}>
  365. <img src={this.state.showDelIcon?delHover :del} />
  366. </div>
  367. )}
  368. </div>
  369. </li>
  370. }):<Empty message={'无历史病历'}></Empty>
  371. }
  372. </ul>
  373. </ScrollArea>
  374. </div>
  375. </div>
  376. <div className={styles.mainHistoryRight}>
  377. {
  378. activeHis == undefined || JSON.stringify(activeHis) == "{}" ? null :
  379. <PreviewBody
  380. preInfo={preInfo}
  381. showHistoryCases={this.props.showHistoryCases}
  382. dataJson={dataJson}
  383. baseObj={activeHis}
  384. dataStr={dataStr.length > 0 ? getAllDataStringList(dataStr) : []}
  385. show={false}
  386. flg={true}
  387. showAssessBtn={true}
  388. ></PreviewBody>
  389. }
  390. </div>
  391. <ConfirmModal
  392. visible={visible}
  393. confirm={this.makeSure}
  394. close={this.close}
  395. cancel={this.close}
  396. okText={"引用"}
  397. okBorderColor={'#3B9ED0'}
  398. okColor={'#fff'}
  399. oKBg={'#3B9ED0'}
  400. >
  401. <p className={styles['center']}>确定引用该病历?</p>
  402. </ConfirmModal>
  403. <ConfirmModal
  404. visible={delVisible}
  405. confirm={this.makeSureDel}
  406. close={this.closeDel}
  407. cancel={this.closeDel}
  408. okText={"删除"}
  409. okBorderColor={'#3B9ED0'}
  410. okColor={'#fff'}
  411. oKBg={'#3B9ED0'}
  412. >
  413. <p className={styles['center']}>确定删除病历?</p>
  414. </ConfirmModal>
  415. <ConfirmModal
  416. visible={editVisible}
  417. confirm={this.makeSureEdit}
  418. close={this.closeEdit}
  419. cancel={this.closeEdit}
  420. okText={"保存"}
  421. okBorderColor={'#3B9ED0'}
  422. okColor={'#fff'}
  423. oKBg={'#3B9ED0'}
  424. title={'编辑病历名称'}
  425. height={200}
  426. >
  427. <div className={styles.outBox}>
  428. <span>病历名称:</span>
  429. <input type="text" className={styles.innerInput} placeholder="请输入病历名称" value={this.state.templateName} onChange={this.handleChange} autocomplete="off"/>
  430. </div>
  431. </ConfirmModal>
  432. </div>
  433. )
  434. }
  435. }
  436. export default HistoryCaseContainer;