index.jsx 16 KB

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