index.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. import React, { Component } from "react";
  2. import style from "./index.less";
  3. import printImg from '@common/images/icon_print_blue.png';
  4. import preview from '@common/images/preview.png';
  5. import saveHistory from '@common/images/saveHistory.png';
  6. import cancelTag from '@common/images/icon_back.png';
  7. import PrintPreviewContainer from '@containers/PrintPreviewContainer';
  8. import PreviewContainer from '@containers/PreviewContainer';
  9. import { ConfirmModal, Notify } from '@commonComp';
  10. import Search from './Search';
  11. import check_circle from './img/check-circle.png';
  12. import check_right from './img/check-right.png';
  13. import {getAllDataList,getAllDataStringList,isAllPartClear,isAllClear,filterDataArr,readyKeepHistory,checkDeptContent} from '@utils/tools';
  14. import {dragBox} from '@utils/drag';
  15. import store from '@store';
  16. import $ from 'jquery';
  17. class Operation extends Component {
  18. constructor(props) {
  19. super(props)
  20. this.state = {
  21. title: '',
  22. okText: '',
  23. borderColor: '',
  24. okColor: '',
  25. oKBg: '',
  26. msg: '',
  27. type: '',
  28. zIndex:40,
  29. sex:'3',
  30. le:'',
  31. deptId:'',//科室id
  32. value:''
  33. }
  34. this.showPrint = this.showPrint.bind(this);
  35. this.closePrint = this.closePrint.bind(this);
  36. this.showPreview = this.showPreview.bind(this);
  37. this.closePreview = this.closePreview.bind(this);
  38. this.saveAll = this.saveAll.bind(this);
  39. this.clearAll = this.clearAll.bind(this);
  40. this.saveHis = this.saveHis.bind(this);
  41. this.keypress = this.keypress.bind(this);
  42. this.setDeptId = this.setDeptId.bind(this);
  43. this.handleChangeIpt = this.handleChangeIpt.bind(this);
  44. }
  45. showPrint() {
  46. this.setState({
  47. zIndex:240
  48. })
  49. this.props.showPrintPreview()
  50. }
  51. closePrint() {
  52. this.setState({
  53. zIndex:40
  54. })
  55. this.props.closePrintPreview()
  56. dragBox('previewPrintWrapper','previewPrintStatic','del')
  57. }
  58. showPreview() {
  59. this.setState({
  60. zIndex:240
  61. })
  62. this.props.showPreview()
  63. }
  64. closePreview() {
  65. this.setState({
  66. zIndex:40
  67. })
  68. this.props.closePreview()
  69. dragBox('previewWrapper','previewStatic','del')
  70. }
  71. saveAll(type) {
  72. let keepState = readyKeepHistory();
  73. if(keepState == 1){
  74. Notify.info('主诉不能为空');
  75. return;
  76. }else if(keepState == 2){
  77. Notify.info('诊断不能为空');
  78. return;
  79. }else{
  80. this.setState({
  81. type: type,
  82. okText: '保存',
  83. borderColor: '#3B9ED0',
  84. okColor: '#fff',
  85. oKBg: '#3B9ED0',
  86. msg: <p className={style['msg']}>是否保存该病历?</p>
  87. })
  88. this.props.diagShowTmp(true)
  89. }
  90. }
  91. clearAll(type) {
  92. let baseList = store.getState();
  93. let jsonData = getAllDataList(baseList);
  94. let jsonStr = getAllDataStringList(baseList);
  95. let flg = isAllPartClear(jsonData,jsonStr,baseList);
  96. const tpVal = $("#templateSearch").val(); //模板是否有搜索条件未清空
  97. const mdVal = $("#medicalInfoSearch").val(); //知识是否有搜索条件未清空
  98. if(flg||tpVal||mdVal){
  99. this.setState({
  100. type: type,
  101. okText: '清除',
  102. borderColor: 'red',
  103. okColor: 'red',
  104. oKBg: '#fff',
  105. msg: <p className={style['msg']}>是否清空所有内容?</p>
  106. })
  107. this.props.diagShowTmp(true)
  108. }else{
  109. Notify.info('当前页面数据已清空');
  110. }
  111. }
  112. onchange(val) {
  113. this.setState({
  114. title: val
  115. })
  116. }
  117. handleInput(e){
  118. let val = (e.target.value).substring(0,30)
  119. this.onchange(val)
  120. }
  121. keypress(event) {
  122. let e = event?event:window.event;
  123. if (e.keyCode == 13) {
  124. this.makeSure()
  125. }
  126. }
  127. saveHis(type) {
  128. const { diagShowTmp } = this.props;
  129. let baseList = store.getState();
  130. let jsonStr = getAllDataStringList(baseList);
  131. let tmpLis = [];
  132. let flg = isAllClear(jsonStr);
  133. if(!flg){
  134. Notify.info('模板数据不能为空');
  135. return false;
  136. }
  137. if(!this.props.admin){
  138. tmpLis = baseList.tabTemplate.items;
  139. for(let i = 0;i <tmpLis.length;i++){
  140. let dataStr = tmpLis[i].preview;
  141. if(
  142. filterDataArr(JSON.parse(jsonStr.chief)) == filterDataArr(eval('('+JSON.parse(dataStr).chief+')')) &&
  143. filterDataArr(JSON.parse(jsonStr.present)) == filterDataArr(eval('('+JSON.parse(dataStr).present+')')) &&
  144. filterDataArr(JSON.parse(jsonStr.other)) == filterDataArr(eval('('+JSON.parse(dataStr).other+')')) &&
  145. filterDataArr(JSON.parse(jsonStr.vital)) == filterDataArr(eval('('+JSON.parse(dataStr).vital+')')) &&
  146. jsonStr.lis == JSON.parse(dataStr).lis &&
  147. jsonStr.pacs == JSON.parse(dataStr).pacs &&
  148. jsonStr.diag == JSON.parse(dataStr).diag &&
  149. jsonStr.advice == JSON.parse(dataStr).advice
  150. ){
  151. Notify.info('该模板已保存');
  152. return false;
  153. }
  154. }
  155. }
  156. this.setState({
  157. title: '',
  158. sex:'3',
  159. type: type,
  160. okText: '保存',
  161. borderColor: '#3B9ED0',
  162. okColor: '#fff',
  163. oKBg: '#3B9ED0',
  164. msg: this.changeTitle()
  165. })
  166. diagShowTmp(true)
  167. }
  168. changeTitle() {
  169. return <div className={style['box']}>
  170. {/* <div className={style.titleTip}></div> */}
  171. <div className={style['iptWrap']}>
  172. <div className={style.name}>
  173. <span>模板名称:</span>
  174. <input className={style['ipt']}
  175. placeholder="请输入模板名称"
  176. type="text"
  177. maxLength='30'
  178. onInput={(e) => {
  179. this.handleInput(e)
  180. }}
  181. onPropertyChange={(e) => { // 兼容ie
  182. this.handleInput(e)
  183. }}
  184. onKeyPress={e => this.keypress(e)}
  185. />
  186. </div>
  187. <div className={style.male}>
  188. <span>性别归属:</span>
  189. <span className={style['commonSex']} id="commonSex" onClick={this.changeRadio.bind(this,1)}><img src={check_right} alt=""/><i style={{color:'#000'}}>通用</i></span>
  190. <span id="maleSex" onClick={this.changeRadio.bind(this,2)}><img src={check_circle} alt=""/><i>男</i></span>
  191. <span id="femaleSex" onClick={this.changeRadio.bind(this,3)}><img src={check_circle} alt=""/><i>女</i></span>
  192. <span style={{paddingRight:0,color:'#777777'}}>(注:错误引用,显示可能有误)</span>
  193. </div>
  194. {/* <p>请选择模板性别归属(错误引用,显示可能有误)</p> */}
  195. </div>
  196. </div>
  197. }
  198. changeRadio(sex){
  199. if(sex == 1){
  200. $('#commonSex img').attr('src',check_right)
  201. $('#maleSex img').attr('src',check_circle)
  202. $('#femaleSex img').attr('src',check_circle)
  203. $('#commonSex i').css('color','#000')
  204. $('#maleSex i').css('color','#6b6969')
  205. $('#femaleSex i').css('color','#6b6969')
  206. this.setState({sex:'3'})
  207. }else if(sex == 2){
  208. $('#commonSex img').attr('src',check_circle)
  209. $('#maleSex img').attr('src',check_right)
  210. $('#femaleSex img').attr('src',check_circle)
  211. $('#commonSex i').css('color','#6b6969')
  212. $('#maleSex i').css('color','#000')
  213. $('#femaleSex i').css('color','#6b6969')
  214. this.setState({sex:'1'})
  215. }else if(sex == 3){
  216. $('#commonSex img').attr('src',check_circle)
  217. $('#maleSex img').attr('src',check_circle)
  218. $('#femaleSex img').attr('src',check_right)
  219. $('#commonSex i').css('color','#6b6969')
  220. $('#maleSex i').css('color','#6b6969')
  221. $('#femaleSex i').css('color','#000')
  222. this.setState({sex:'2'})
  223. }
  224. }
  225. makeSure() {
  226. const { save, clear, saveDataAll,saveDataAlls,diagShowTmp ,chronicMagItem,chronicDesease,admin} = this.props;
  227. const { type,deptId,sex,title } = this.state;
  228. if (type == 1) {
  229. diagShowTmp(false)
  230. this.setState({ title: '' })
  231. save();
  232. } else if (type == 2) {
  233. diagShowTmp(false);
  234. this.setState({ title: '' })
  235. // 慢病标识
  236. const chronicFlag = chronicMagItem || chronicDesease?true:false;
  237. clear(chronicFlag);
  238. //更新滚动条
  239. const that = this;
  240. setTimeout(function(){
  241. that.context.scrollArea&&that.context.scrollArea.refresh();
  242. });
  243. } else if (type == 3) {
  244. if (this.state.title.trim() == '') {
  245. Notify.error('请输入模板名称')
  246. return;
  247. }else if(admin&&deptId == ''){
  248. Notify.error('请选择科室')
  249. return;
  250. }
  251. if(admin){
  252. let baseList = store.getState();
  253. let tmpLis = baseList.tabTemplate.adminItems||[];
  254. let jsonStr = getAllDataStringList(baseList);
  255. for(let i = 0;i <tmpLis.length;i++){
  256. let dataStr = tmpLis[i].preview;
  257. if(
  258. filterDataArr(JSON.parse(jsonStr.chief)) == filterDataArr(eval('('+JSON.parse(dataStr).chief+')')) &&
  259. filterDataArr(JSON.parse(jsonStr.present)) == filterDataArr(eval('('+JSON.parse(dataStr).present+')')) &&
  260. filterDataArr(JSON.parse(jsonStr.other)) == filterDataArr(eval('('+JSON.parse(dataStr).other+')')) &&
  261. filterDataArr(JSON.parse(jsonStr.vital)) == filterDataArr(eval('('+JSON.parse(dataStr).vital+')')) &&
  262. jsonStr.lis == JSON.parse(dataStr).lis &&
  263. jsonStr.pacs == JSON.parse(dataStr).pacs &&
  264. jsonStr.diag == JSON.parse(dataStr).diag &&
  265. jsonStr.advice == JSON.parse(dataStr).advice&&
  266. deptId == tmpLis[i].hospitalDeptId
  267. ){
  268. Notify.info('该模板已保存');
  269. return false;
  270. }
  271. }
  272. saveDataAlls(title,sex,deptId);
  273. }else{
  274. saveDataAll(title,sex);
  275. }
  276. }
  277. }
  278. closeDiagBox(){
  279. const { diagShowTmp } = this.props;
  280. const { type } = this.state;
  281. if (type == 3){
  282. diagShowTmp(false)
  283. this.setState({ title: '' })
  284. }else{
  285. diagShowTmp(false)
  286. this.setState({ title: '' })
  287. }
  288. }
  289. setDeptId(id,name){
  290. this.props.handleClearValue()
  291. this.setState({
  292. deptId :id,
  293. value:name
  294. })
  295. }
  296. componentWillReceiveProps(next){//监听滚动事件
  297. const that = this;
  298. if(next.winWidth <= 1024){
  299. $(window).scroll(function(){
  300. let scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft;
  301. let left = -(scrollLeft - 10) +'px';
  302. that.setState({
  303. le:left
  304. })
  305. })
  306. }
  307. }
  308. handleChangeIpt(val){
  309. this.setState({
  310. value:val
  311. })
  312. }
  313. render() {
  314. const { showPrint, closePrint, showPreview, closePreview,handleChangeIpt } = this;
  315. const { visible, preVisible,diagShow } = this.props.print;
  316. const {winWidth,cancelDelTag,departLis,handleChangeValue,admin} = this.props;
  317. const {zIndex,type,le,value} = this.state;
  318. return <div className={style['container']} style={{left:le}}>
  319. <span className={style['button']} onClick={showPrint}><img src={printImg} /> 打印病历</span>
  320. <span className={style['preButton']} onClick={showPreview}><img src={preview} /> 预览</span>
  321. <span className={style['preButton']} onClick={() => { this.saveHis(3) }}><img src={saveHistory} /> 保存病历模板</span>
  322. <span className={style['preButton']} onClick={cancelDelTag}><img src={cancelTag} /> 还原标签</span>
  323. <span className={winWidth<=1082?`${style['saveButton']} ${style['minstyle']}`: style['saveButton']} onClick={() => { this.saveAll(1) }}>保存</span>
  324. <span className={winWidth<=1082?`${style['clearButton']} ${style['saveButton']} ${style['minstyle']}`:`${style['clearButton']} ${style['saveButton']}`} onClick={() => { this.clearAll(2) }}>清除</span>
  325. {visible?<PrintPreviewContainer visible={visible} onClose={closePrint} />:null}
  326. {preVisible?<PreviewContainer visible={preVisible} onClose={closePreview} />:null}
  327. <ConfirmModal
  328. visible={diagShow} //改为全局控制
  329. confirm={() => { this.makeSure() }}
  330. close={() => { this.closeDiagBox()}}
  331. cancel={() => {this.closeDiagBox()}}
  332. okText={this.state.okText}
  333. height={type==3?228:200}
  334. width={type==3?545:300}
  335. okBorderColor={this.state.borderColor}
  336. okColor={this.state.okColor}
  337. oKBg={this.state.oKBg}
  338. borderBtm={type==3?'1px solid #f5f5f5':null}
  339. title={type==3?'保存病历模板':null}
  340. >
  341. {this.state.msg}
  342. {
  343. admin&&type==3?<div className={style.department}>
  344. <span>科室归属:</span>
  345. <Search handleChangeValue={handleChangeValue} handleChangeIpt={handleChangeIpt} value={value} visible={true}>
  346. {
  347. departLis.length>0&&<ul className={style.departLis}>
  348. {
  349. departLis.map((item,idx)=>{
  350. return <li onClick={()=>this.setDeptId(item.id,item.conceptDeptName)}>
  351. {item.conceptDeptName}
  352. </li>
  353. })
  354. }
  355. </ul>
  356. }
  357. </Search>
  358. <span style={{paddingRight:0,color:'#777777'}}>(支持汉字关键字搜索)</span>
  359. </div>:null
  360. }
  361. </ConfirmModal>
  362. </div>;
  363. }
  364. }
  365. Operation.contextTypes = {
  366. scrollArea: React.PropTypes.object
  367. };
  368. export default Operation;