index.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import React, { Component } from "react";
  2. import style from "./index.less";
  3. import { normalVal } from '@utils/tools';
  4. import $ from "jquery";
  5. (function ($) {
  6. var opt;
  7. $.fn.jqprint = function (options) {
  8. opt = $.extend({}, $.fn.jqprint.defaults, options);
  9. var $element = (this instanceof $) ? this : $(this);
  10. if (opt.operaSupport && $.browser.opera) {
  11. var tab = window.open("", "jqPrint-preview");
  12. tab.document.open();
  13. var doc = tab.document;
  14. }
  15. else {
  16. var $iframe = $("<iframe />");
  17. if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-300px", top: "-300px" }); }
  18. $iframe.appendTo("body");
  19. var doc = $iframe[0].contentWindow.document;
  20. }
  21. if (opt.importCSS) {
  22. if ($("link[media=print]").length > 0) {
  23. $("link[media=print]").each(function () {
  24. doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' media='print' />");
  25. });
  26. }
  27. else {
  28. $("link").each(function () {
  29. doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' />");
  30. });
  31. }
  32. }
  33. if (opt.printContainer) { doc.write($element.outer()); }
  34. else { $element.each(function () { doc.write($(this).html()); }); }
  35. doc.close();
  36. (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus();
  37. setTimeout(function () { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 1000);
  38. }
  39. $.fn.jqprint.defaults = {
  40. debug: false,
  41. importCSS: true,
  42. printContainer: true,
  43. operaSupport: true
  44. };
  45. $.fn.outer = function () {
  46. return $($('<div></div>').html(this.clone())).html();
  47. }
  48. })($);
  49. import {filterDataArr} from '@utils/tools'
  50. class PreviewBody extends Component {
  51. constructor(props) {
  52. super(props)
  53. this.state={
  54. dateTime:"",
  55. }
  56. this.$content = React.createRef();
  57. this.getCurrentDate = this.getCurrentDate.bind(this);
  58. this.onPrint = this.onPrint.bind(this);
  59. }
  60. componentDidMount(){
  61. this.getCurrentDate();
  62. }
  63. componentWillReceiveProps(){
  64. $(this.$content.current)[0].scrollIntoView(true);
  65. }
  66. onPrint() {
  67. $("#content").jqprint({
  68. debug: false,
  69. importCSS: true,
  70. printContainer: true,
  71. operaSupport: false,
  72. });
  73. this.props.onClose()
  74. }
  75. getCurrentDate(){
  76. let myDate = new Date();
  77. let year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  78. let mon = myDate.getMonth()-0+1; //获取当前月份(0-11,0代表1月)
  79. let day = myDate.getDate(); //获取当前日(1-31)
  80. let date = year+'-'+(mon<10?'0'+mon:mon)+'-'+(day<10?'0'+day:day);
  81. this.setState({dateTime:date})
  82. }
  83. showDetails(val){
  84. if(val.questionDetailList.length > 0){
  85. return val.questionDetailList.map((item)=>{
  86. if(val.value == item.name){
  87. return <td style={{width:'23%'}}><span style={{color:item.abnormal != '0' ?"red":null}}>{val.value}</span> { val.labelSuffix}</td>
  88. }
  89. })
  90. }else{
  91. return <td style={{width:'23%'}}><span style={{color:(val.maxValue || val.minValue)?(val.value > val.maxValue || val.value < val.minValue?"red":null):null}}>{val.value}</span> { val.labelSuffix}</td>
  92. }
  93. }
  94. render() {
  95. const { show, preInfo, dataJson, dataStr,baseObj } = this.props;
  96. return <div className={style['content']}>
  97. <div className={style['contents']} id="content" style={{margin:"0 auto"}}>
  98. <div ref={this.$content} style={{ clear: 'both', fontSize: '24px', margin: '0px 0px 30px 0px',textAlign:'center' }}>{preInfo.hospitalName}</div>
  99. <table className={style['patInfo']} style={{ margin: '0px 0px 30px 0px', borderCollapse: 'collapse', width: "100%" }}>
  100. <tr>
  101. <td style={{ border: '1px solid #aaa', padding: '8px 10px', width: '25%' }}>卡号:{baseObj?baseObj.patientIdNo:JSON.stringify(preInfo) == '{}'?'':preInfo.patientIdNo}</td>
  102. <td style={{ border: '1px solid #aaa', padding: '8px 10px', width: '25%' }}>姓名:{baseObj?baseObj.patientName:JSON.stringify(preInfo) == '{}'?'':preInfo.patientName}</td>
  103. <td style={{ border: '1px solid #aaa', padding: '8px 10px', width: '25%' }}>年龄:{baseObj?baseObj.patientAge:JSON.stringify(preInfo) == '{}'?'':preInfo.patientAge}</td>
  104. <td style={{ border: '1px solid #aaa', padding: '8px 10px', width: '25%' }}>性别:{baseObj?baseObj.patientSex:JSON.stringify(preInfo) == '{}'?'':preInfo.patientSex}</td>
  105. </tr>
  106. <tr>
  107. <td style={{ border: '1px solid #aaa', padding: '8px 10px', width: '25%' }}>就诊时间:{baseObj?baseObj.inquiryDate:(JSON.stringify(preInfo) == '{}'?'':preInfo.systemTime.split(' ')[0])}</td>
  108. <td style={{ border: '1px solid #aaa', padding: '8px 10px', width: '25%' }}>科室:{baseObj?baseObj.hospitalDeptName:(JSON.stringify(preInfo) == '{}'?'':preInfo.hospitalDeptName)}</td>
  109. <td style={{ border: '1px solid #aaa', padding: '8px 10px', width: '25%' }}>医生:{baseObj?baseObj.doctorName:(JSON.stringify(preInfo) == '{}'?'':preInfo.doctorName)}</td>
  110. <td style={{ border: '1px solid #aaa', padding: '8px 10px', width: '25%' }}>门诊号:{baseObj?baseObj.inquiryCode:(JSON.stringify(preInfo) == '{}'?'':preInfo.recordId)}</td>
  111. </tr>
  112. </table>
  113. <table style={{width:"100%"}}>
  114. <tr style={{ verticalAlign: 'top' }}>
  115. <td style={{ width: 70, textAlign: 'right', padding: '0px 5px 16px 0px', fontSize: '14px' }}>主诉:</td>
  116. <td style={{ fontSize: '14px', padding: '0px 0px 16px 0px',lineHeight:'18px' }}>
  117. {
  118. filterDataArr(JSON.parse(dataStr.chief))
  119. }
  120. </td>
  121. </tr>
  122. <tr style={{ verticalAlign: 'top' }}>
  123. <td style={{ width: 70, textAlign: 'right', padding: '0px 5px 16px 0px', fontSize: '14px' }}>现病史:</td>
  124. <td style={{ fontSize: '14px', padding: '0px 0px 16px 0px',lineHeight:'18px' }}>
  125. {
  126. filterDataArr(JSON.parse(dataStr.present))
  127. }
  128. </td>
  129. </tr>
  130. <tr style={{ verticalAlign: 'top' }}>
  131. <td style={{ width: 70, textAlign: 'right', padding: '0px 5px 16px 0px', fontSize: '14px' }}>其他史:</td>
  132. <td style={{ fontSize: '14px', padding: '0px 0px 16px 0px',lineHeight:'18px' }}>
  133. {
  134. filterDataArr(JSON.parse(dataStr.other))
  135. }
  136. </td>
  137. </tr>
  138. <tr style={{ verticalAlign: 'top' }}>
  139. <td style={{ width: 70, textAlign: 'right', padding: '0px 5px 16px 0px', fontSize: '14px' }}>查体:</td>
  140. <td style={{ fontSize: '14px', padding: '0px 0px 16px 0px',lineHeight:'18px' }}>
  141. {
  142. filterDataArr(JSON.parse(dataStr.vital))
  143. }
  144. </td>
  145. </tr>
  146. <tr style={{ verticalAlign: 'top',width:'100%',overflow:"hidden" }}>
  147. <td style={{ width: 70, textAlign: 'right', padding: '0px 5px 16px 0px', fontSize: '14px' }}>化验:</td>
  148. <td style={{ fontSize: '14px', padding: '0px 0px 16px 0px',maxWidth:'650px'}}>
  149. {/* <table style={{ width: '100%' }}> */}
  150. {
  151. dataJson.lis.getExcelDataList && dataJson.lis.getExcelDataList.map((items)=>{
  152. return items.lisExcelRes && items.lisExcelRes.map((item)=>{
  153. return <table style={{margin:'8px 0',width:'100%',fontSize:'12px'}}>
  154. <tr style={{fontSize:'14px',lineHeight:'1.5'}}>{item.menus}</tr>
  155. {
  156. item.lisExcelItem && item.lisExcelItem.map((value)=>{
  157. return <tr style={{lineHeight:'1.5',maxWidth:'650px'}}>
  158. <td style={{width:'25%',fontSize:'12px'}}>{value.itemName}</td>
  159. <td style={{width:'23%',fontSize:'12px'}}><span style={{fontSize:'12px',color:value.type == 1?"red":null}}>{value.value}</span> {value.unit}</td>
  160. <td style={{width:'24%',fontSize:'12px'}}>
  161. {normalVal(value.min,value.max)}
  162. </td>
  163. <td style={{width:'28%',fontSize:'12px'}}>{value.time == ''?('导入时间: '+this.state.dateTime):'化验时间: '+value.time}</td>
  164. </tr>
  165. })
  166. }
  167. </table>
  168. })
  169. })
  170. }
  171. {
  172. dataJson.lis.labelList && dataJson.lis.labelList.map((item,idx) => {
  173. if(item.show){
  174. return <table style={{margin:'8px 0',width:'100%'}}>
  175. <tr style={{fontSize:'14px',lineHeight:'1.5'}}>{item.name}</tr>
  176. {
  177. item.details.map((val)=>{
  178. if(val.value && val.value != ''){
  179. return <tr style={{lineHeight:'1.5',width:'100%',fontSize:'12px'}}>
  180. <td style={{width:'25%'}}>{val.name}</td>
  181. {this.showDetails(val)}
  182. <td style={{width:'24%'}}>
  183. {normalVal(val.minValue,val.maxValue)}
  184. </td>
  185. <td style={{width:'28%'}}>{'化验时间:'+item.time}</td>
  186. </tr>
  187. }
  188. })
  189. }
  190. </table>
  191. }
  192. })
  193. }
  194. {/* </table> */}
  195. </td>
  196. </tr>
  197. <tr style={{ verticalAlign: 'top' }}>
  198. <td style={{ width: 70, textAlign: 'right', padding: '0px 5px 16px 0px', fontSize: '14px' }}>辅检:</td>
  199. <td style={{ fontSize: '14px', padding: '0px 0px 16px 0px',lineHeight:'18px' }}>
  200. {
  201. dataStr.pacs && dataStr.pacs != '' && dataStr.pacs.split(';').map((item)=>{
  202. return <div style={{ fontSize: '14px' }}>{item}</div>
  203. })
  204. }
  205. </td>
  206. </tr>
  207. <tr style={{ verticalAlign: 'top' }}>
  208. <td style={{ width: 70, textAlign: 'right', padding: '0px 5px 16px 0px', fontSize: '14px' }}>诊断:</td>
  209. <td style={{ fontSize: '14px', padding: '0px 0px 16px 0px',lineHeight:'18px' }}>
  210. {
  211. dataStr.diag && dataStr.diag != '' && dataStr.diag.split(';').map((item)=>{
  212. return <div style={{ fontSize: '14px'}}>{item}</div>
  213. })
  214. }
  215. </td>
  216. </tr>
  217. <tr style={{ verticalAlign: 'top' }}>
  218. <td style={{ width: 70, textAlign: 'right', padding: '0px 5px 16px 0px', fontSize: '14px' }}>医嘱:</td>
  219. <td style={{ fontSize: '14px', padding: '0px 0px 16px 0px' }}>
  220. {
  221. dataJson.advice.assay && dataJson.advice.assay.length > 0 || dataJson.advice.check && dataJson.advice.check.length > 0 ? <p style={{fontSize:'14px',marginBottom:"8px"}}>开单项目</p> : ''
  222. }
  223. {
  224. dataJson.advice.assay && <div style={{ fontSize: '12px', padding: '0px 0px 5px 0px' }}>{dataJson.advice.assay}</div>
  225. }
  226. {
  227. dataJson.advice.check && <div style={{ fontSize: '12px', padding: '0px 0px 5px 0px' }}>{dataJson.advice.check}</div>
  228. }
  229. {dataJson.advice.scheme && dataJson.advice.scheme.length > 0 && <p style={{fontSize:'14px', marginBottom: '8px',marginTop:'8px'}}>治疗方案</p>}
  230. {
  231. dataJson.advice.scheme && dataJson.advice.scheme.map((item, index) => {
  232. return <p>{item.treatment.map((it,ii) =>{
  233. return(it.treatmentStr && it.treatmentStr.length > 0 ?
  234. <div style={{ fontSize: '12px', padding: '0px 0px 5px 0px' }}>{ it.treatmentStr }</div>: '')
  235. })}</p>
  236. })
  237. }
  238. </td>
  239. </tr>
  240. </table>
  241. <table style={{ marginTop: '10px',marginBottom:'30px',display: show ? 'block' : 'none' }}>
  242. <tr style={{position:'absolute',right:'0px',verticalAlign: 'top'}}>
  243. <td>医生签名:</td>
  244. <td style={{
  245. minWidth:'50px',
  246. padding:'0 5px 2px 5px',
  247. borderBottom:'1px solid #333',
  248. }}>{baseObj?baseObj.doctorName:(JSON.stringify(preInfo) == '{}'?'':preInfo.doctorName)}</td>
  249. </tr>
  250. </table>
  251. </div>
  252. <div onClick={()=>{this.onPrint()}} style={{
  253. display: show ? 'inline-block' : 'none',
  254. padding: '10px 20px',
  255. float:'right',
  256. marginTop:'15px',
  257. background: '#3B9ED0',
  258. color: '#fff',
  259. borderRadius: '4px',
  260. cursor: 'pointer',
  261. position:'absolute',
  262. right:'40px'
  263. }}>打印</div>
  264. </div>
  265. }
  266. }
  267. export default PreviewBody;