index.jsx 15 KB

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