index.jsx 16 KB

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