index.jsx 16 KB

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