index.jsx 16 KB

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