import React, { Component } from "react";
import style from "./index.less";
import { normalVal, filterDataArr, filterOtherDataArr,timestampToTime } from '@utils/tools';
import Notify from '@commonComp/Notify';
import $ from "jquery";
import { relative } from "path";
(function ($) {
var opt;
$.fn.jqprint = function (options) {
opt = $.extend({}, $.fn.jqprint.defaults, options);
var $element = (this instanceof $) ? this : $(this);
if (opt.operaSupport && $.browser.opera) {
var tab = window.open("", "jqPrint-preview");
tab.document.open();
var doc = tab.document;
}
else {
var $iframe = $("");
if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-300px", top: "-300px" }); }
$iframe.appendTo("body");
var doc = $iframe[0].contentWindow.document;
}
if (opt.importCSS) {
if ($("link[media=print]").length > 0) {
$("link[media=print]").each(function () {
doc.write("");
});
}
else {
$("link").each(function () {
doc.write("");
});
}
}
if (opt.printContainer) { doc.write($element.outer()); }
else { $element.each(function () { doc.write($(this).html()); }); }
doc.close();
(opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus();
setTimeout(function () { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 1000);
}
$.fn.jqprint.defaults = {
debug: false,
importCSS: true,
printContainer: true,
operaSupport: true
};
$.fn.outer = function () {
return $($('
').html(this.clone())).html();
}
})($);
class PreviewBody extends Component {
constructor(props) {
super(props)
this.state = {
dateTime: "",
}
this.$content = React.createRef();
this.getCurrentDate = this.getCurrentDate.bind(this);
this.onPrint = this.onPrint.bind(this);
}
componentDidMount() {
this.getCurrentDate();
}
componentWillReceiveProps() {
$(this.$content.current)[0].scrollIntoView(true);
}
onPrint() {
$("#content").jqprint({
debug: false,
importCSS: true,
printContainer: true,
operaSupport: false,
});
this.props.onClose()
}
surePrint(jsonStr) {
if (filterDataArr(JSON.parse(jsonStr.chief)) == '') {
Notify.info('主诉不能为空');
return false;
} else if (!jsonStr.diag || jsonStr.diag.trim().length < 1) {
Notify.info('诊断不能为空');
return false;
} else {
this.onPrint();
this.props.save(true)
}
// if(filterDataArr(JSON.parse(jsonStr.chief)) == ''){
// Notify.info('主诉不能为空');
// return false;
// }else if(!jsonStr.diag || jsonStr.diag.trim().length < 1){
// Notify.info('诊断不能为空');
// return false;
// }else{
// this.onPrint();
// this.props.save(true)
// }
}
getCurrentDate() {
let myDate = new Date();
let year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
let mon = myDate.getMonth() - 0 + 1; //获取当前月份(0-11,0代表1月)
let day = myDate.getDate(); //获取当前日(1-31)
let date = year + '-' + (mon < 10 ? '0' + mon : mon) + '-' + (day < 10 ? '0' + day : day);
this.setState({ dateTime: date })
}
showDetails(val) {
if (val.questionDetailList.length > 0) {
return val.questionDetailList.map((item) => {
if (val.value == item.name) {
return {val.value} {val.labelSuffix} |
}
})
} else {
return val.maxValue || val.value < val.minValue ? "red" : null) : null }}>{val.value} {val.labelSuffix} |
}
}
toTime(time){
let tmpTim = time.split(',').join('')-0
if(time && tmpTim.toString() != 'NaN'){
let date = new Date('1900-01-01');
let dateTim = date.getTime();
let times = (tmpTim-2)*24*60*60*1000;
let result = timestampToTime(dateTim+times).split(' ')[0]
return result;
}else{
return time;
}
}
render() {
const { show, preInfo, dataJson, dataStr, baseObj, flg } = this.props;
const other_yjs = filterOtherDataArr(JSON.parse(dataStr.other),dataJson.other);
return
{preInfo.hospitalName}
卡号:{baseObj ? baseObj.patientIdNo : JSON.stringify(preInfo) == '{}' ? '' : preInfo.patientIdNo} |
姓名:{baseObj ? baseObj.patientName : JSON.stringify(preInfo) == '{}' ? '' : preInfo.patientName} |
年龄:{baseObj ? baseObj.patientAge : JSON.stringify(preInfo) == '{}' ? '' : preInfo.patientAge} |
性别:{baseObj ? baseObj.patientSex : JSON.stringify(preInfo) == '{}' ? '' : preInfo.patientSex} |
就诊时间:{baseObj ? baseObj.inquiryDate : (JSON.stringify(preInfo) == '{}' ? '' : preInfo.systemTime.split(' ')[0])} |
科室:{baseObj ? baseObj.hospitalDeptName : (JSON.stringify(preInfo) == '{}' ? '' : preInfo.hospitalDeptName)} |
医生:{baseObj ? baseObj.doctorName : (JSON.stringify(preInfo) == '{}' ? '' : preInfo.doctorName)} |
门诊号:{baseObj ? baseObj.inquiryCode : (JSON.stringify(preInfo) == '{}' ? '' : preInfo.recordId)} |
主诉: |
{
filterDataArr(JSON.parse(dataStr.chief))
}
|
现病史: |
{
filterDataArr(JSON.parse(dataStr.present))
}
|
其他史: |
{
other_yjs.str1
}
{dataJson['yjs_1']||dataJson['yjs_2']||dataJson['yjs_3']||dataJson['yjs_4']?
月经史:( |
{dataJson['yjs_1']||'初潮年龄'} |
{dataJson['yjs_2']||'行经天数'} |
{dataJson['yjs_4']||'停经时间'}) |
{dataJson['yjs_3']||'周期'} |
:''}
{
other_yjs.str2
}
|
查体: |
{
filterDataArr(JSON.parse(dataStr.vital))
}
|
化验: |
{
dataJson.lis.getExcelDataList && dataJson.lis.getExcelDataList.map((items) => {
return items.lisExcelRes && items.lisExcelRes.map((item) => {
return
{item.menus} |
{
item.lisExcelItem && item.lisExcelItem.map((value) => {
return
{value.itemName} |
{value.value} {value.unit} |
{normalVal(value.min, value.max)}
|
{value.time == '' ? ('导入时间: ' + this.state.dateTime) : '化验时间: ' + this.toTime(value.time)
} |
})
}
})
})
}
{
dataJson.lis.labelList && dataJson.lis.labelList.map((item, idx) => {
// if (item.show) {
return
{
item.show? {item.name} | :
「{item.name}」 |
}
{
item.details.map((val) => {
if (val.value && val.value != '') {
return
{val.name} |
{this.showDetails(val)}
{normalVal(val.minValue, val.maxValue)}
|
{'化验时间:' + item.time} |
}
})
}
// }
})
}
|
辅检: |
{
dataStr.pacs && dataStr.pacs != '' && dataStr.pacs.split(';').map((item) => {
return {item}
})
}
|
诊断: |
{
dataStr.diag && dataStr.diag != '' && dataStr.diag.split(';').map((item) => {
return {item}
})
}
|
医嘱: |
{dataJson.advice.commontreatment && dataJson.advice.commontreatment.length > 0 && 一般治疗 }
{
dataJson.advice.commontreatment && {dataJson.advice.commontreatment}
}
{dataJson.advice.scheme && dataJson.advice.scheme.length > 0 && 治疗方案 }
{
dataJson.advice.scheme && dataJson.advice.scheme.map((item, index) => {
return {item.treatment.map((it, ii) => {
return (it.treatmentStr && it.treatmentStr.length > 0 ?
{it.treatmentStr} : '')
})}
})
}
{
dataJson.advice.adviceInput && {dataJson.advice.adviceInput}
}
|
医生签名:{baseObj ? baseObj.doctorName : (JSON.stringify(preInfo) == '{}' ? '' : preInfo.doctorName)}
{ this.surePrint(dataStr) }} style={{
display: show ? 'inline-block' : 'none',
padding: '10px 20px',
float: 'right',
marginTop: '15px',
background: '#3B9ED0',
color: '#fff',
borderRadius: '4px',
cursor: 'pointer',
position: 'absolute',
right: '40px'
}}>打印
}
}
export default PreviewBody;